THT Community

Full Version: WHMPHP Plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Do you have a master reseller? But, THT only supports the root way of making resellers.
If you have WHMPHP, your in luck!!

First, open THTROOT/includes/servers/whm.php
After the comments, add
PHP Code:
require_once('THTPATHFULL/includes/whmphp.php'); 

We put it one directory below because it will be included twice when you make a server.

Find:
PHP Code:
private $server

Add After:
PHP Code:
private $pass "CPANEL PASS";
private 
$whmphp;
private 
$user "CPANEL USERNAME"// This may be refrenceable
function whm() {
        
$this->whmphp = new whmphp("YOURIP",$this->user,$this->pass); // Not localhost


Find:
PHP Code:
public function signup($server$reseller$user ''$email ''$pass '') { 

Replace Function With:
PHP Code:
public function signup($server$reseller$user ''$email ''$pass '') {
        global 
$main;
        global 
$db;
        if (
$user == '') { $user $main->getvar['username']; }
        if (
$email == '') { $email $main->getvar['email']; }
        if (
$pass == '') { $pass $main->getvar['password']; }
        
$this->server $server;
        if (
$reseller) {
            
$r $this->whmphp->createreseller($main->getvar['fplan'],$user,$pass,$main->getvar['fdom'],$email);
            echo 
$r[1];
            return 
$r[0];
        } else {
            
$action "/xml-api/createacct".
                        
"?username="$user "".
                        
"&password="$pass ."".
                        
"&domain="$main->getvar['fdom'] ."".
                        
"&plan="$main->getvar['fplan'] ."".
                        
"&contactemail="$email ."";
            
$command $this->remote($action);
            
            if(
$command->result->status == 1) {
                return 
true;    
            }
            else {
                echo 
"Error: "$command->result->statusmsg;    
            }
        }
    } 

Find:
PHP Code:
public function suspend($user$server$reason false) { 

Replace Function With:
PHP Code:
public function suspend($user$server$reason false) {
        
$this->server $server;
        if (
$server == 1) {
            return 
$this->whmphp->suspendreseller($user);
        } else {
            
$action "/xml-api/suspendacct?user=" strtolower($user);
            
$command $this->remote($action);
                    if(
$reason == false) {
                        
$command $this->remote($action);
                    }
                    else {
                        
$command $this->remote($action "&reason=" str_replace(" ""%20"$reason));
                    }
            if(
$command->result->status == 1) {
                return 
true;
            }
            else {
                return 
false;
            }
        }
    } 

Find:
PHP Code:
public function unsuspend($user$server) { 

Replace Function With:
PHP Code:
public function unsuspend($user$server) {
        
$this->server $server;
        if (
$server == 1) {
            return 
$this->whmphp->unsuspendreseller($user);
        } else {
            
$action "/xml-api/unsuspendacct?user=" strtolower($user);
            
$command $this->remote($action);
            if(
$command->result->status == 1) {
                return 
true;
            }
            else {
                return 
false;
            }
        }
    } 

Find:
PHP Code:
public function terminate($user$server) { 

Replace Function With:
PHP Code:
public function terminate($user$server) {
        
$this->server $server;
        if (
$server == 1) {
            return 
$this->whmphp->terminatereseller($user);
        } else {
            
$action "/xml-api/removeacct?user=" strtolower($user);
            
$command $this->remote($action0true);
            if(
$command == true) {
                return 
true;
            }
            else {
                return 
false;
            }
        }
    } 

Download Attachment
Place in: THTROOT/includes/

Your resellers must user the server ID 1. If you have to, switch the server id.
You will need 2 servers of the same details.
One with ID 1 for WHMPHP, one with another ID for whm.

Feel free to IM me for support:
[email protected]
[email protected]
jerryinchost (Yahoo)
ismywb (Skype)

edit: forgot to attach whmphp.php
what version is this for tryed on version 1.2.3 but it doesnt work and now it wont let me add,view,delete servers unless i restore the files Smile but i need it to work with WHMPHP could you please help
I get a blank page with this plugin when adding a server...
Sorry guys, I forgot to mention this:
PHP Code:
require_once('THTPATHFULL/includes/whmphp.php'); 
THTPATHFULL should be replaced with full path to THT. IE: /home/user/www/order
Interesting. I'll have to look into this. Maybe we can add this to TheHostingTool at some point? Smile
That would be nice. Big Grin If you do, would you mind adding credit to me in it? like, whmphp module created by Jerry Johnson?
Hi, I have found a bug in whmphp.php and I have a fix.

By the way, if I haven't said this, I am saying it now, this is not to be used by the root account to create master resellers, if it for masters resellers to create resellers.
Can anyone confirm that these updates work?