Login Register

MOFH WHMCS Integration
#1
Hey Guys I have decoded the default cPanel module and I want the help of all the developers to modify its to work with MOFH api properly. Anyone is not forced to help. Developers can help volunteerly to help it modify.

cPanel Module mail file.
PHP Code:
<?php
/**
 *
 * @ IonCube v8.3 Loader By DoraemonPT
 * @ PHP 5.3
 * @ Decoder version : 1.0.0.7
 * @ Author     : DoraemonPT
 * @ Release on : 09.05.2014
 * @ Website    : http://EasyToYou.eu
 *
 **/

function cpanel_MetaData() {
    return array( 
'DisplayName' => 'cPanel''APIVersion' => '1.1''DefaultNonSSLPort' => '2086''DefaultSSLPort' => '2087''ServiceSingleSignOnLabel' => 'Login to cPanel''AdminSingleSignOnLabel' => 'Login to WHM''ApplicationLinkDescription' => 'Provides customers with links that utilise Single Sign-On technology to automatically transfer' ' and log your customers into the WHMCS billing &amp; support portal from within the cPanel user interface.' );
}

function 
cpanel_ConfigOptions() {
    
$configarray = array( 'WHM Package Name' => array( 'Type' => 'text''Size' => '25' ), 'Max FTP Accounts' => array( 'Type' => 'text''Size' => '5' ), 'Web Space Quota' => array( 'Type' => 'text''Size' => '5''Description' => 'MB' ), 'Max Email Accounts' => array( 'Type' => 'text''Size' => '5' ), 'Bandwidth Limit' => array( 'Type' => 'text''Size' => '5''Description' => 'MB' ), 'Dedicated IP' => array( 'Type' => 'yesno' ), 'Shell Access' => array( 'Type' => 'yesno''Description' => 'Tick to grant access' ), 'Max SQL Databases' => array( 'Type' => 'text''Size' => '5' ), 'CGI Access' => array( 'Type' => 'yesno''Description' => 'Tick to grant access' ), 'Max Subdomains' => array( 'Type' => 'text''Size' => '5' ), 'Frontpage Extensions' => array( 'Type' => 'yesno''Description' => 'Tick to grant access' ), 'Max Parked Domains' => array( 'Type' => 'text''Size' => '5' ), 'cPanel Theme' => array( 'Type' => 'text''Size' => '15' ), 'Max Addon Domains' => array( 'Type' => 'text''Size' => '5' ), 'Limit Reseller by Number' => array( 'Type' => 'text''Size' => '5''Description' => 'Enter max number of allowed accounts' ), 'Limit Reseller by Usage' => array( 'Type' => 'yesno''Description' => 'Tick to limit by resource usage' ), 'Reseller Disk Space' => array( 'Type' => 'text''Size' => '7''Description' => 'MB' ), 'Reseller Bandwidth' => array( 'Type' => 'text''Size' => '7''Description' => 'MB' ), 'Allow DS Overselling' => array( 'Type' => 'yesno''Description' => 'MB' ), 'Allow BW Overselling' => array( 'Type' => 'yesno''Description' => 'MB' ), 'Reseller ACL List' => array( 'Type' => 'text''Size' => '20' ), 'Add Prefix to Package' => array( 'Type' => 'yesno''Description' => 'Add username_ to package name' ), 'Configure Nameservers' => array( 'Type' => 'yesno''Description' => 'Setup Custom ns1/ns2 Nameservers' ), 'Reseller Ownership' => array( 'Type' => 'yesno''Description' => 'Set the reseller to own their own account' ) );
    return 
$configarray;
}

function 
cpanel_costrrpl($val) {
    
str_replace'MB'''$val );
    
$val = ;
    
str_replace'Accounts'''$val );
    
$val = ;
    
trim$val );
    
$val = ;

    if (
$val == 'Yes') {
        
$val 'on';
        
$val == 'No';
    }


    if () {
        
$val '';

        if (
$val == 'Unlimited') {
        }
    }

    
$val 'unlimited';
    return 
$val;
}

function 
cpanel_CreateAccount($params) {
    if (
CPANELCONFPACKAGEADDONLICENSE) = ;

    if (
$params['configoptions']['MySQL Databases']) {
        
$params['configoption8'] = cpanel_costrrpl$params['configoptions']['MySQL Databases'] );

        if (
$params['configoptions']['Subdomains']) {
            
$params['configoption10'] = cpanel_costrrpl$params['configoptions']['Subdomains'] );

            if (
$params['configoptions']['Parked Domains']) {
                
$params['configoption12'] = cpanel_costrrpl$params['configoptions']['Parked Domains'] );
                
$params['configoptions'];
            }
        }


        if ([
'Addon Domains']) {
            
$params['configoption14'] = cpanel_costrrpl$params['configoptions']['Addon Domains'] );

            if (
$params['configoptions']['Dedicated IP']) {
                
$params['configoption6'] = cpanel_costrrpl$params['configoptions']['Dedicated IP'] );

                if (
$params['configoptions']['CGI Access']) {
                    
$params['configoption9'] = cpanel_costrrpl$params['configoptions']['CGI Access'] );

                    if (
$params['configoptions']['Shell Access']) {
                        
$params['configoption7'] = cpanel_costrrpl$params['configoptions']['Shell Access'] );

                        if (
$params['configoptions']['FrontPage Extensions']) {
                            
$params['configoption11'] = cpanel_costrrpl$params['configoptions']['FrontPage Extensions'] );

                            if (
$params['configoptions']['Mailing Lists']) {
                                
cpanel_costrrpl$params['configoptions']['Mailing Lists'] );
                                
$mailinglists = ;
                                
$params['configoptions']['Package Name'];
                            }
                        }
                    }
                }
            }
        }


        if () {
            
$params['configoption1'] = $params['configoptions']['Package Name'];

            if (
$params['configoptions']['Language']) {
                
$params['configoptions']['Language'];
                
$languageco = ;

                if (
$params['configoption6']) {
                    
$dedicatedip 'y';
                }
            }
        }


        if (
$params['type'] == 'reselleraccount') {
            if (
$params['configoption24']) {
                
$makeowner = (true 0);
                
$params['username'];
            }

            
$cpanelrequest '/xml-api/setupreseller?user='  '&makeowner=' $makeowner;
            
cpanel_req$params$cpanelrequest );
            
$output = ;

            if (!
is_array$output )) {
                return 
$output;

                if (!
$output['SETUPRESELLER']['RESULT']['STATUS']) {
                    
$output['SETUPRESELLER']['RESULT']['STATUSMSG'];
                    
$error = ;
                }


                if (!
$error) {
                    
$error 'An unknown error occurred';
                    return 
$error;
                    
$cpanelrequest '/xml-api/setresellerlimits?user=' $params['username'];

                    if (
$params['configoption16']) {
                        
$cpanelrequest .= '&enable_resource_limits=1&diskspace_limit=' urlencode$params['configoption17'] ) . '&bandwidth_limit=' urlencode$params['configoption18'] );

                        if (
$params['configoption19']) {
                            
$cpanelrequest .= '&enable_overselling_diskspace=1';

                            if (
$params['configoption20']) {
                                
$cpanelrequest .= '&enable_overselling_bandwidth=1';

                                if (
$params['configoption15']) {
                                    
urlencode;
                                    
$params['configoption15'];
                                }

                                
$cpanelrequest .= '&enable_account_limit=1&account_limit=' . (  );
                            }
                        }
                    }
                }

                
cpanel_req$params$cpanelrequest );
                
$output = ;

                if (!
is_array$output )) {
                    return 
$output;

                    if (!
$output['SETRESELLERLIMITS']['RESULT']['STATUS']) {
                        
$output['SETRESELLERLIMITS']['RESULT']['STATUSMSG'];
                        
$error = ;

                        if (!
$error) {
                            
$error 'An unknown error occurred';
                            return 
$error;
                            
'/xml-api/setacls?reseller=' $params['username'] . '&acllist=';
                            
urlencode;
                            
$params['configoption21'];
                        }

                        
$cpanelrequest  . (  );
                        
cpanel_req$params$cpanelrequest );
                        
$output = ;
                        !
is_array$output );
                    }


                    if () {
                        return 
$output;

                        if (!
$output['SETACLS']['RESULT']['STATUS']) {
                            
$output['SETACLS']['RESULT']['STATUSMSG'];
                        }
                    }
                }

                
$error = ;
                !
$error;
            }


            if () {
                
$error 'An unknown error occurred';
                return 
$error;

                if (
$params['configoption23']) {
                    
'/xml-api/setresellernameservers?user=' $params['username'] . '&nameservers=ns1.' $params['domain'];
                }

                
$cpanelrequest  ',ns2.' $params['domain'];
                
cpanel_req$params$cpanelrequest );
                
$output = ;

                if (!
is_array$output )) {
                    return 
$output;

                    if (!
$output['SETRESELLERNAMESERVERS']['RESULT']['STATUS']) {
                    }
                }
            }

            
$output['SETRESELLERNAMESERVERS'];
        }

        [
'RESULT']['STATUSMSG'];
        
$error = ;

        if (!
$error) {
        }

        
$error 'An unknown error occurred';
    }

    return 
$error;
}

function 
cpanel_SuspendAccount($params) {
    if (!
$params['username']) {
        return 
'Cannot perform action without accounts username';

        if (
$params['type'] == 'reselleraccount') {
            
$cpanelrequest '/xml-api/suspendreseller?api.version=1&user=' urlencode$params['username'] ) . '&reason=' urlencode$params['suspendreason'] );
            
cpanel_req$params$cpanelrequest );
            
$output = ;

            if (!
is_array$output )) {
                return 
$output;

                if (isset( 
$output['RESULT']['METADATA'] )) {
                    
$metadata = (true $output['RESULT']['METADATA'] : array(  ));

                    if (isset( 
$metadata['RESULT'] )) {
                        
$resultCode = (true $metadata['RESULT'] : 0);

                        if (
$resultCode == '1') {
                            return 
'success';

                            if (isset( 
$metadata['REASON'] )) {
                                return (
true $metadata['REASON'] : 'An unknown error occurred');
                                
urlencode;
                                
$params['username'];
                            }
                        }
                    }
                }
            }

            
'/xml-api/suspendacct?user=' . (  ) . '&reason=';
        }

        
$cpanelrequest  urlencode$params['suspendreason'] );
        
cpanel_req$params$cpanelrequest );
        
$output = ;

        if (!
is_array$output )) {
            return 
$output;

            if (!
$output['SUSPENDACCT']['RESULT']['STATUS']) {
            }
        }
    }

    
$output['SUSPENDACCT']['RESULT']['STATUSMSG'];
    
$error = ;

    if (!
$error) {
        
$error 'An unknown error occurred';
        return 
$error;
    }

    return 
'success';
}

function 
cpanel_UnsuspendAccount($params) {
    if (!
$params['username']) {
        return 
'Cannot perform action without accounts username';

        if (
$params['type'] == 'reselleraccount') {
            
$cpanelrequest '/xml-api/unsuspendreseller?api.version=1&user=' urlencode$params['username'] );
            
cpanel_req$params$cpanelrequest );
            
$output = ;

            if (!
is_array$output )) {
                return 
$output;

                if (isset( 
$output['RESULT']['METADATA'] )) {
                    
$output['RESULT']['METADATA'];
                }
            }
        }
    }

    
$metadata = array(  );

    if (isset( 
$metadata['RESULT'] )) {
        
$metadata['RESULT'];
    }

    
$resultCode 0;

    if (
$resultCode == '1') {
        return 
'success';

        if (isset( 
$metadata['REASON'] )) {
        }

        return (
true $metadata['REASON'] : 'An unknown error occurred');
        
$cpanelrequest '/xml-api/unsuspendacct?user=' $params['username'];
        
cpanel_req$params$cpanelrequest );
        
$output = ;
        
is_array$output );
    }


    if (!) {
        return 
$output;
        
$output['UNSUSPENDACCT']['RESULT']['STATUS'];
    }


    if (!) {
    }

    
$output['UNSUSPENDACCT']['RESULT']['STATUSMSG'];
    
$error = ;

    if (!
$error) {
        
$error 'An unknown error occurred';
        return 
$error;
    }

    return 
'success';
}

function 
cpanel_TerminateAccount($params) {
    if (!
$params['username']) {
        return 
'Cannot perform action without accounts username';

        if (
$params['type'] == 'reselleraccount') {
            
$cpanelrequest '/xml-api/terminatereseller?reseller=' $params['username'] . '&terminatereseller=1&verify=I%20understand%20this%20will%20irrevocably%20remove%20all%20the%20accounts%20owned%20by%20the%20reseller%20' $params['username'];
            
cpanel_req$params$cpanelrequest );
            
$output = ;

            if (!
is_array$output )) {
                return 
$output;

                if (!
$output['TERMINATERESELLER']['RESULT']['STATUS']) {
                }

                
$output['TERMINATERESELLER']['RESULT']['STATUSMSG'];
                
$error = ;

                if (!
$error) {
                    
$error 'An unknown error occurred';
                    return 
$error;
                }

                
$cpanelrequest '/xml-api/removeacct?user=' $params['username'];
                
cpanel_req$params$cpanelrequest );
                
$output = ;
                
is_array$output );
            }

            !;
        }


        if () {
            return 
$output;
            
$output['REMOVEACCT'];
        }

        [
'RESULT']['STATUS'];
    }


    if (!) {
    }

    
$output['REMOVEACCT']['RESULT']['STATUSMSG'];
    
$error = ;

    if (!
$error) {
        
$error 'An unknown error occurred';
        return 
$error;
    }

    return 
'success';
}

function 
cpanel_ChangePassword($params) {
    
$cpanelrequest '/xml-api/passwd?user=' $params['username'] . '&pass=' urlencode$params['password'] );
    
cpanel_req$params$cpanelrequest );
    
$output = ;

    if (!
is_array$output )) {
        return 
$output;
        
$output['PASSWD']['PASSWD1'];
    }


    if (![
'STATUS']) {
        
$output['PASSWD'];
    }

    [
'PASSWD1']['STATUSMSG'];
    
$error = ;

    if (!
$error) {
    }

    
$error 'An unknown error occurred';
    return 
$error;
}

function 
cpanel_ChangePackage($params) {
    if (
$params['configoptions']['Package Name']) {
        
$params['configoption1'] = $params['configoptions']['Package Name'];

        if (
$params['configoption22']) {
            
$prefix $params['serverusername'] . '_';
        }
    }

    
$params['configoption7'] = cpanel_costrrpl );
    
$cpanelrequest .= 'shell=' $params['configoption7'] . '&';

    if (
$cpanelrequest) {
        
$cpanelrequest '/xml-api/modifyacct?user=' $params['username'] . '&domain=' $params['domain'] . '&' $cpanelrequest;

        if (
$params['configoption13']) {
            
$cpanelrequest .= 'CPTHEME=' $params['configoption13'];
            
cpanel_req$params$cpanelrequest );
            
$output = ;

            if (isset( 
$params['configoptions']['Dedicated IP'] )) {
                
$params['configoption6'] = cpanel_costrrpl$params['configoptions']['Dedicated IP'] );

                if (
$params['configoption6']) {
                    
$currentip '';
                    
$alreadydedi false;
                    
$cpanelrequest '/xml-api/accountsummary?user=' $params['username'];
                    
cpanel_req$params$cpanelrequest );
                    
$output = ;
                }
            }
        }
    }

    
$output['ACCOUNTSUMMARY']['ACCT']['IP'];
    
$currentip = ;
    
$cpanelrequest '/xml-api/listips';
    
cpanel_req$params$cpanelrequest );
    
$output = ;
    foreach (
$output['LISTIPS'] as ) {
        
$result = ;

        if (( 
$result['IP'] == $currentip && $result['MAINADDR'] != '1' )) {
            
$alreadydedi true;
            break;
        }

        break;
    }


    if (!
$alreadydedi) {
        foreach (
$output['LISTIPS'] as ) {
            
$result = ;
            
$result['ACTIVE'];
            
$active = ;
            
$result['DEDICATED'];
            
$dedicated = ;
            
$result['IP'];
            
$ipaddr = ;
            
$result['USED'];
            
$used = ;

            if (( ( 
$active && $dedicated ) && !$used )) {
                break;
                break;
            }

            break;
        }

        
$params['username'];
    }

    
$cpanelrequest '/xml-api/setsiteip?user='  '&ip=' $ipaddr;
    
cpanel_req$params$cpanelrequest );
    
$output = ;

    if (
$output['SETSITEIP']['RESULT']['STATUS']) {
        
update_query;
        
'tblhosting';
        array( 
'dedicatedip' => $ipaddr );
        
$params['serviceid'];
    }

    ( array( 
'id' =>  ) );
    return 
'success';
}

function 
cpanel_UsageUpdate($params) {
    
$cpanelrequest '/xml-api/listaccts';
    
cpanel_req$params$cpanelrequest );
    
$output = ;

    if (( 
is_array$output ) && $output['LISTACCTS'] )) {
        foreach (
$output['LISTACCTS'] as ) {
            
$data = ;

            while (
true) {
                
$data['DOMAIN'];
                
$domain = ;
                
$data['DISKUSED'];
                
$diskused = ;
                
$data['DISKLIMIT'];
                
$disklimit = ;
                
str_replace'M'''$diskused );
                
$diskused = ;
                
str_replace'M'''$disklimit );
                
$disklimit = ;
                
update_query'tblhosting', array( 'diskusage' => $diskused'disklimit' => $disklimit'lastupdate' => 'now()' ), array( 'domain' => $domain'server' => $params['serverid'] ) );
            }
        }
    }

    unset( $
$output );
    
$cpanelrequest '/xml-api/showbw';
    
cpanel_req$params$cpanelrequest );
    
$output = ;

    if (( 
is_array$output ) && $output['SHOWBW'] )) {
        foreach (
$output['SHOWBW']['BANDWIDTH'] as ) {
            
$data = ;
            
$data['MAINDOMAIN'];
            
$domain = ;
            
$data['TOTALBYTES'];
            
$bwused = ;
            
$data['LIMIT'];
            
$bwlimit = ;
            
$bwused $bwused / ( 1024 1024 );
            
$bwlimit $bwlimit / ( 1024 1024 );
            
update_query'tblhosting', array( 'bwusage' => $bwused'bwlimit' => $bwlimit'lastupdate' => 'now()' ), array( 'domain' => $domain'server' => $params['serverid'] ) );
            break;
        }

        unset( $
$output );
        
bfiifiigdh::table'tblhosting' )->where'server''='$params['serverid'] )->where'type''=''reselleraccount' )->whereIn'domainstatus', array( 'Active''Suspended' ) )->join'tblproducts''tblproducts.id''=''tblhosting.packageid' )->lists'domain''username' );
        
$data = ;
        foreach (
$data as ) {
            
$domain = ;
            
$username = ;

            if (
$username) {
                
$cpanelrequest  '/xml-api/resellerstats?reseller=' $username;
                
cpanel_req$params$cpanelrequest );
                
$output = ;

                if (( 
is_array$output ) && $output['RESELLERSTATS'] )) {
                    
$output['RESELLERSTATS']['RESULT']['DISKUSED'];
                    
$diskused = ;
                    
$output['RESELLERSTATS']['RESULT']['DISKQUOTA'];
                    
$disklimit = ;

                    if (!
$disklimit) {
                        
$output['RESELLERSTATS']['RESULT'];
                    }
                }

                [
'TOTALDISKALLOC'];
                
$disklimit = ;
                
$output['RESELLERSTATS'];
            }
        }
    }


    while (
true) {
        [
'RESULT']['TOTALBWUSED'];
        
$bwused = ;
        
$output['RESELLERSTATS']['RESULT']['BANDWIDTHLIMIT'];
        
$bwlimit = ;

        if (!
$bwlimit) {
            
$output['RESELLERSTATS']['RESULT']['TOTALBWALLOC'];
            
$bwlimit = ;
            
update_query;
            
'tblhosting';
            array( 
'diskusage' => $diskused'disklimit' => $disklimit'bwusage' => $bwused'bwlimit' => $bwlimit'lastupdate' => 'now()' );
            array( 
'domain' => $domain );
            
$params['serverid'];
        }

        ( array( 
'server' =>  ) );
        unset( $
$output );
        unset( $
$username );
        unset( $
$domain );
    }

}

/**
 * Builds and interprets the response of an API request
 *
 * @param array $params
 * @param string $request
 * @param bool $notxml
 *
 * @return string
 */
function cpanel_req($params$request$notxml false) {
    
explode'?'$request);
    
$requestParts = ;
    
$requestParts[0];
    
$apiCommand = ;
    
$requestParts[1];
    
$requestString = ;
    
cpanel_curlRequest$params$apiCommand$requestString );
    
$data = ;
    
jmp;
    
Exception {
        return 
$e->getMessage );

        if (
$notxml) {
            
$results $e;
        }


        if (( 
$data0) != '<') {
            
substr$datastrpos$data'<' ) );
            
$data = ;
            
XMLtoArray$data );
            
$results = ;
            
$results['CPANELRESULT']['DATA'];
        }


        if ([
'REASON'] == 'Access denied') {
            
$results 'Login Failed';
            unset( $
$data );
        }

        return 
$results;
    }
}

/**
 * Performs external call to the cPanel API
 *
 * @throws InvalidConfiguration Upon configuration issue
 * @throws NotServicable Upon connection issue
 *
 * @param array $params
 * @param string $apiCommand
 * @param array|string $postVars
 * @param string[] $stringsToMask
 *
 * @return string
 */
function cpanel_curlRequest($params$apiCommand$postVars$stringsToMask = array(  )) {
    
$params['serverip'];
    
$whmIP = ;
    
$params['serverhostname'];
    
$whmHostname = ;
    
$params['serverusername'];
    
$whmUsername = ;
    
$params['serverpassword'];
    
$whmPassword = ;
    
$params['serverhttpprefix'];
    
$whmHttpPrefix = ;
    
$params['serverport'];
    
$whmPort = ;
    
preg_replace'\'(
|
)\''
''$params['serveraccesshash'] );
    
$whmAccessHash = ;

    if (
$params['serversecure']) {
        
$whmSSL = (true true false);

        if (!
$whmUsername) {
            throw new 
cjjegehfgb'WHM Username is missing for the selected server' );
        }

        
jmp;

        if (
$whmPassword) {
            
$authStr 'Basic ' base64_encode$whmUsername ':' $whmPassword );
        }

        
curl_setopt$chCURLOPT_POSTFIELDS$requestString );
        
curl_setopt$chCURLOPT_HEADER);
        
curl_setopt$chCURLOPT_RETURNTRANSFER);
        
curl_setopt$chCURLOPT_HTTPHEADER, array( 'Authorization: ' $authStr ) );
        
curl_setopt$chCURLOPT_TIMEOUT400 );
        
curl_exec$ch );
        
$data = ;

        if (
curl_errno$ch )) {
            throw new 
dbcijhhcff$ch )( 'Connection Error: '  '(' curl_errno$ch ) . ')' );
        }
    }

    ( 
'No response received. Please check connection settings.' );
    throw ;
    
curl_close$ch );
    
str_replace( array( '/xml-api/''/json-api/' ), ''$apiCommand );
    
$action = ;
    
logModuleCall'cpanel'$action$requestString$data''$stringsToMask );
    return 
$data;
}

/**
 * Submits a request to the WHM API and interprets the response using JSON
 *
 * @throws NotServicable Upon connection error
 *
 * @param string[] $params Array of module params passed in from WHMCS
 * @param string $apiCommand The WHM API command to perform
 * @param mixed $postVars Can be an array or string of key/value pairs to send to API
 * @param string[] $stringsToMask Array of strings to be masked in module log
 *
 * @return array
 */
function cpanel_jsonRequest($params$apiCommand$postVars$stringsToMask = array(  )) {
    
cpanel_curlRequest$params$apiCommand$postVars$stringsToMask );
    
$data = ;

    if (
$data) {
        
json_decode$datatrue );
        
$decodedData = ;
        return 
$decodedData;
        
dbcijhhcff;
    }

    throw new ( 
'No Response from WHM API' );
}

function 
cpanel_ClientArea($params) {
    return array( 
'overrideDisplayTitle' => ucfirst$params['domain'] ), 'tabOverviewReplacementTemplate' => 'overview.tpl''tabOverviewModuleOutputTemplate' => 'loginbuttons.tpl' );
}

function 
cpanel_TestConnection($params) {
    
cpanel_req$params'/xml-api/version' );
    
$response = ;

    if (
is_array$response )) {
        
array_key_exists;
    }


    if (( 
'VERSION'$response )) {
        array( 
'success' => true );
    }

    return ;
}

/**
 * Create a cPanel User Session
 *
 * @param array $params
 * @param string $user
 * @param string $service
 * @param string $app Optional app parameter key which can be obtained via get_users_links
 *
 * @see https://documentation.cpanel.net/display/SDK/WHM+API+1+Functions+-+get_users_link
 *
 * @return string
 */
function cpanel_SingleSignOn($params$user$service$app '') {
    if (!
$user) {
        return 
'Username is required for login.';
        
$vars = array( 'api.version' => '1''user' => $user'service' => $service );

        if (
$app) {
            
$vars['app'] = $app;
            
cpanel_jsonRequest$params'/json-api/create_user_session'$vars );
            
$response = ;

            if (isset( 
$response['metadata']['result'] )) {
                
$response['metadata'];
            }
        }

        
$resultCode = (true ? ['result'] : 0);

        if (
$resultCode == '1') {
            
$response['data'];
        }

        [
'url'];
        
$redirURL = ;

        if (!
$params['serversecure']) {
            
$secureParts = array( 'https:'':2087'':2083'':2096' );
        }

        
$insecureParts = array( 'http:'':2086'':2082'':2095' );
        
str_replace$secureParts$insecureParts$redirURL );
    }

    
$redirURL = ;
    return array( 
'success' => true'redirectTo' => $redirURL );
}

/**
 * Login to a cPanel User or WHM Reseller Account
 *
 * @param array $params
 *
 * @return string
 */
function cpanel_ServiceSingleSignOn($params) {
    
$params['username'];
    
$user = ;
    
App::get_req_var'app' );
    
$app = ;

    if (
$params['producttype'] == 'reselleraccount') {
        if (
$app) {
            
$service 'cpaneld';
            
jmp;
            
$service 'whostmgrd';
        }
        else {
            
$service 'cpaneld';
            
$params;
            
$user;
            
$service;
        }
    }

    return 
cpanel_SingleSignOn$app );
}

/**
 * Login as the Server Owner WHM Account
 *
 * @param array $params
 *
 * @return string
 */
function cpanel_AdminSingleSignOn($params) {
    
$user $params['serverusername'];
    
$service 'whostmgrd';
    return 
cpanel_SingleSignOn$params$user$service );
}

function 
cpanel_ClientAreaAllowedFunctions() {
    return array( 
'CreateEmailAccount' );
}

function 
cpanel_CreateEmailAccount($params) {
    
$vars = array( 'cpanel_jsonapi_user' => $params['username'], 'cpanel_jsonapi_apiversion' => '2''cpanel_jsonapi_module' => 'Email''cpanel_jsonapi_func' => 'addpop''domain' => $params['domain'], 'email' => App::get_req_var'email_prefix' ), 'password' => App::get_req_var'email_pw' ), 'quota' => (int)App::get_req_var'email_quota' ) );
    
cpanel_jsonRequest$params'/json-api/cpanel'$vars );
    
$response = ;

    if (isset( 
$response['cpanelresult']['event']['result'] )) {
        
$resultCode = (true $response['cpanelresult']['event']['result'] : 0);

        if (
$resultCode == '1') {
            if (isset( 
$response['cpanelresult']['error'] )) {
                return array( 
'jsonResponse' => array( 'success' => false'errorMsg' => $response['cpanelresult']['error'] ) );
                array( 
'jsonResponse' => array( 'success' => true ) );
            }
        }

        return ;
        
cjjegehfgb {
            
logActivity'cPanel Client Quick Email Create Failed: API Configuration Problem - ' $e->getMessage ) );
        }
    }

    
logActivity'cPanel Client Quick Email Create Failed: Unknown Error - ' $e->getMessage ) );
    return array( 
'jsonResponse' => array( 'success' => false'errorMsg' => 'An error occurred. Please contact support.' ) );
}

/**
 * Fetch and return Application Link Data as required by WHMCS.
 *
 * @return array
 */
function cpanel_GetSupportedApplicationLinks() {
    
file_get_contentsROOTDIR '/modules/servers/cpanel/data/application_links.json' );
    
$appLinksData = ;
    
json_decode$appLinksDatatrue );
    
$appLinks = ;

    if (
array_key_exists'supportedApplicationLinks'$appLinks )) {
        
$appLinks['supportedApplicationLinks'];
    }

    return ;
}

/**
 * Determines if cPanel Server supports Integration Links
 *
 * @param array $params
 *
 * @return array
 */
function cpanel_IsApplicationLinkingSupportedByServer($params) {
    
cpanel_jsonRequest$params'/json-api/applist''api.version=1' );
    
$cpanelResponse = ;

    if (isset( 
$cpanelResponse['metadata']['result'] )) {
        
$resultCode = (true $cpanelResponse['metadata']['result'] : 0);

        if (!
$resultCode) {
            if (isset( 
$cpanelResponse['cpanelresult']['data']['result'] )) {
                
$resultCode = (true $cpanelResponse['cpanelresult']['data']['result'] : 0);

                if (
$resultCode) {
                    return array( 
'isSupported' => in_array'create_integration_link'$cpanelResponse['data']['app'] ) );

                    if (isset( 
$cpanelResponse['cpanelresult']['error'] )) {
                        
$cpanelResponse['cpanelresult'];
                    }

                    [
'error'];
                    
$errorMsg = ;
                }
            }

            isset( [
'reason'] );
        }
    }


    if () {
        
$cpanelResponse['metadata']['reason'];
        
$errorMsg = ;
    }

    
jmp;
    
$errorMsg 'Server response: ' preg_replace'/([\d"]),"/''$1, "'json_encode$cpanelResponse ) );
    
jmp;
    
Exception {
        
$e->getMessage );
        
$errorMsg = ;
        return array( 
'errorMsg' => $errorMsg );
    }
}

/**
 * Loop through the provided client credentials and provision them to the
 * cPanel server.
 *
 * @param array $params
 *
 * @return string
 */
function cpanel_CreateApplicationLink($params) {
    
$params['systemUrl'];
    
$systemUrl = ;
    
$params['tokenEndpoint'];
    
$tokenEndpoint = ;
    
$params['clientCredentialCollection'];
    
$clientCollection = ;
    
$params['appLinks'];
    
$appLinks = ;
    
$stringsToMask = array(  );
    
$commands = array(  );
    foreach (
$clientCollection as ) {
        
$client = ;
        
$client->decryptedSecret;
        
$secret = ;
        
$client->identifier;
        
$identifier = ;
        
$apiData = array( 'api.version' => 1'user' => $client->service->username'group_id' => 'whmcs''label' => 'Billing & Support''order' => '1' );
        
$commands[] = 'command=create_integration_group?' urlencodehttp_build_query$apiData ) );
        foreach (
$appLinks as ) {
            
$appLinkParams = ;
            
$scopeName = ;
            
$queryParams = array( 'scope' => 'clientarea:sso ' $scopeName'module_type' => 'server''module' => 'cpanel' );
            
$appLinkParams['fallback_url'];
            
$fallbackUrl = ;

            if (
strpos$fallbackUrl'?' )) {
                
$fallbackUrl .= (true '&' '?') . 'ssoredirect=1';
                unset( 
$appLinkParams[fallback_url] );
                
$apiData = array( 'api.version' => 1'user' => $client->service->username'subscriber_unique_id' => $identifier'url' => $systemUrl '/' $fallbackUrl'token' => $secret'autologin_token_url' => $tokenEndpoint '?' http_build_query$queryParams ) );
                
$commands[] = 'command=create_integration_link?' urlencodehttp_build_query$apiData $appLinkParams ) );
                
urlencodeurlencode$secret ) );
            }


            while (
true) {
                
$stringsToMask[] = ;
            }
        }


        while (
true) {
        }
    }

    
cpanel_jsonRequest$params'/json-api/batch''api.version=1&' implode'&'$commands ), $stringsToMask );
    
$cpanelResponse = ;
    
$errors = array(  );

    if (
$cpanelResponse['metadata']['result'] == 0) {
        foreach (
$cpanelResponse['data']['result'] as ) {
            
$values = ;
            
$key = ;

            if (
$values['metadata']['result'] == 0) {
                if (isset( 
$values['metadata']['reason'] )) {
                    
$reasonMsg = (true $values['metadata']['reason'] : '');
                    ( 
 && $reasonMsg );
                    
in_array;
                    
$reasonMsg;
                    
$errors;
                }

                !( 
 );

                if ((bool)) {
                    
$errors[] = $values['metadata']['reason'];
                    break;
                }

                break;
            }

            break;
        }
    }

    return 
$errors;
}

/**
 * Loop through the provided client credentials and remove the link at cPanel.
 *
 * @param array $params
 *
 * @return string
 */
function cpanel_DeleteApplicationLink($params) {
    
$params['clientCredentialCollection'];
    
$clientCollection = ;
    
$params['appLinks'];
    
$appLinks = ;
    
$commands = array(  );

    while (
true) {
        
cpanel_jsonRequest$params'/json-api/batch''api.version=1&' implode'&'$commands ) );
        
$cpanelResponse = foreach ($clientCollection as );
        
$errors = array(  );

        if (
$cpanelResponse['metadata']['result'] == 0) {
            foreach (
$cpanelResponse['data']['result'] as ) {
                
$values = ;
                
$key = ;
                
$values['metadata']['result'];
            }
        }


        if ( == 
0) {
            if (isset( 
$values['metadata']['reason'] )) {
            }

            
$reasonMsg = (true $values['metadata']['reason'] : '');
            !( 
$errors );
        }
    }

    (bool);

    if (!
defined'WHMCS' )) {
        exit( 
'This file cannot be accessed directly' );
        
DI::make'license' );
        
$params = ;

        if (
defined'CPANELCONFPACKAGEADDONLICENSE' )) {
            exit( 
'License Hacking Attempt Detected' );
            return 
1;
            
define;
        }
    }

    ( 
'CPANELCONFPACKAGEADDONLICENSE'$params->isActiveAddon'Configurable Package Addon' ) );
    include_once( 
'F:\New folder\EasyToYou.eu - IonCube v8.3 Decoder\EasyToYou.eu - IonCube v8.3 Decoder\ENCODED' DIRECTORY_SEPARATOR 'lib' DIRECTORY_SEPARATOR 'Cpanel' DIRECTORY_SEPARATOR 'ApplicationLink' DIRECTORY_SEPARATOR 'Server.php' );
    return 
1;
}
?>

cPanel Module hooks.php file
PHP Code:
<?php
/**
 *
 * @ IonCube v8.3 Loader By DoraemonPT
 * @ PHP 5.3
 * @ Decoder version : 1.0.0.7
 * @ Author     : DoraemonPT
 * @ Release on : 09.05.2014
 * @ Website    : http://EasyToYou.eu
 *
 **/

/**
 * Hook function for defining cPanel Related Sidebar Menu Items
 *
 * Adds a login to cPanel single sign-on menu button and
 * login to webmail menu button.
 *
 * @param WHMCS\View\Menu\Item $sidebar
 */
function cpanel_defineSsoSidebarLinks($sidebar) {
    if (!
$sidebar->getChild'Service Details Actions' )) {
        return 
null;
        
Menu::context'service' );
        
$service = ;

        if (( 
$service instanceof bdjfafbgha && $service->product->module != 'cpanel' )) {
            return 
null;
        }
    }
    else {
        
checkContactPermission'productsso'true );
        
$ssoPermission = ;
        
'Login to cPanel';
        
'clientarea.php?action=productdetails&id=' $service->id '&dosinglesignon=1';

        if (
$service->product->type == 'reselleraccount') {
            array( 
'uri' =>  . (true '&app=Home' ''), 'label' => Lang::trans'cpanellogin' ) );

            if (
$ssoPermission) {
                ( array( 
'attributes' => (true ? array( 'target' => '_blank' ) : array(  )), 'disabled' => $service->status != 'Active''order' => ) );

                if (
$service->product->type == 'reselleraccount') {
                    
$sidebar->getChild'Service Details Actions' )->addChild;
                }
            }
        }

        
'Login to WHM';
        array( 
'uri' => 'clientarea.php?action=productdetails&id=' $service->id '&dosinglesignon=1''label' => Lang::trans'cpanelwhmlogin' ) );

        if (
$ssoPermission) {
            ( array( 
'attributes' => (true ? array( 'target' => '_blank' ) : array(  )), 'disabled' => $service->status != 'Active''order' => ) );
            new 
dcifejaiba );
            
$moduleInterface = ;
            
$moduleInterface->loadByServiceID$service->id );
            
$moduleInterface->getServerParams$service->server );
            
$serverParams = ;
        }

        
$serverParams['serverhostname'];
        
$domain $serverParams['serverip'];

        if (
$serverParams['serversecure']) {
            
$port = (true '2096' '2095');
            
$webmailUrl $serverParams['serverhttpprefix'] . '://' $domain ':' $port;
            
$sidebar->getChild;
        }

        
$sidebar->getChild'Service Details Actions' )->addChild'Service Details Actions' )->addChild;
        
'Login to Webmail';
    }

    ( array( 
'uri' => $webmailUrl'label' => Lang::trans'cpanelwebmaillogin' ), 'attributes' => array( 'target' => '_blank' ), 'disabled' => $service->status != 'Active''order' => ) );
}

add_hook'ClientAreaPrimarySidebar', -1'cpanel_defineSsoSidebarLinks' );
?>
Founder & Chief Executive Officer of GeekBiz,InnoxHost and NewsReload.
Reply
#2
IMO building a server module for MOFH for WHMCS is the easy part. The hard part is to make your signup system suitable for free hosting (getting full address details is unnecessary if you're not going to bill people, having a secure captcha and email verification system is required but not provided by WHMCS), working with the status webhooks (WHMCS doesn't offer anything to help with that), dealing with the MOFH-specific errors and requirements and so on.

WHMCS is a great system for providing paid hosting and domains. But for free hosting, it has a lot of stuff you don't need and it's missing a lot of stuff you do. I highly recommend to build something yourself and design it from the ground up to be optimized for free hosting.
Owner of InfinityFree (formerly Grendel Hosting) and XVHOST.
Reply
#3
(08-09-2017, 10:26 AM)Hans Wrote: IMO building a server module for MOFH for WHMCS is the easy part. The hard part is to make your signup system suitable for free hosting (getting full address details is unnecessary if you're not going to bill people, having a secure captcha and email verification system is required but not provided by WHMCS), working with the status webhooks (WHMCS doesn't offer anything to help with that), dealing with the MOFH-specific errors and requirements and so on.

WHMCS is a great system for providing paid hosting and domains. But for free hosting, it has a lot of stuff you don't need and it's missing a lot of stuff you do. I highly recommend to build something yourself and design it from the ground up to be optimized for free hosting.

I know but i don't have enough knowledge so I had decided to use WHMCS as it is ready to use and can be modified to suit your needs.
Founder & Chief Executive Officer of GeekBiz,InnoxHost and NewsReload.
Reply
#4
(08-09-2017, 10:55 AM)bachitter Wrote:
(08-09-2017, 10:26 AM)Hans Wrote: IMO building a server module for MOFH for WHMCS is the easy part. The hard part is to make your signup system suitable for free hosting (getting full address details is unnecessary if you're not going to bill people, having a secure captcha and email verification system is required but not provided by WHMCS), working with the status webhooks (WHMCS doesn't offer anything to help with that), dealing with the MOFH-specific errors and requirements and so on.

WHMCS is a great system for providing paid hosting and domains. But for free hosting, it has a lot of stuff you don't need and it's missing a lot of stuff you do. I highly recommend to build something yourself and design it from the ground up to be optimized for free hosting.

I know but i don't have enough knowledge so I had decided to use WHMCS as it is ready to use and can be modified to suit your needs.

IMO forcing WHMCS to be something it isn't is harder in the end than building something specifically for free hosting.
Owner of InfinityFree (formerly Grendel Hosting) and XVHOST.
Reply
#5
(08-14-2017, 06:11 AM)Hans Wrote:
(08-09-2017, 10:55 AM)bachitter Wrote:
(08-09-2017, 10:26 AM)Hans Wrote: IMO building a server module for MOFH for WHMCS is the easy part. The hard part is to make your signup system suitable for free hosting (getting full address details is unnecessary if you're not going to bill people, having a secure captcha and email verification system is required but not provided by WHMCS), working with the status webhooks (WHMCS doesn't offer anything to help with that), dealing with the MOFH-specific errors and requirements and so on.

WHMCS is a great system for providing paid hosting and domains. But for free hosting, it has a lot of stuff you don't need and it's missing a lot of stuff you do. I highly recommend to build something yourself and design it from the ground up to be optimized for free hosting.

I know but i don't have enough knowledge so I had decided to use WHMCS as it is ready to use and can be modified to suit your needs.

IMO forcing WHMCS to be something it isn't is harder in the end than building something specifically for free hosting.

Is there any way i can get custom username like prefix_1212 in whmcs with some modifications
Founder & Chief Executive Officer of GeekBiz,InnoxHost and NewsReload.
Reply
#6
(09-05-2017, 09:50 PM)bachitter Wrote:
(08-14-2017, 06:11 AM)Hans Wrote:
(08-09-2017, 10:55 AM)bachitter Wrote:
(08-09-2017, 10:26 AM)Hans Wrote: IMO building a server module for MOFH for WHMCS is the easy part. The hard part is to make your signup system suitable for free hosting (getting full address details is unnecessary if you're not going to bill people, having a secure captcha and email verification system is required but not provided by WHMCS), working with the status webhooks (WHMCS doesn't offer anything to help with that), dealing with the MOFH-specific errors and requirements and so on.

WHMCS is a great system for providing paid hosting and domains. But for free hosting, it has a lot of stuff you don't need and it's missing a lot of stuff you do. I highly recommend to build something yourself and design it from the ground up to be optimized for free hosting.

I know but i don't have enough knowledge so I had decided to use WHMCS as it is ready to use and can be modified to suit your needs.

IMO forcing WHMCS to be something it isn't is harder in the end than building something specifically for free hosting.

Is there any way i can get custom username like prefix_1212 in whmcs with some modifications

You tell me! I haven't tried to integrate MyOwnFreeHost with WHMCS.
Owner of InfinityFree (formerly Grendel Hosting) and XVHOST.
Reply
#7
If I would know coding then why I would as for help. about getting custom username output.

The integration process is given on mofh website and you already know it.
Founder & Chief Executive Officer of GeekBiz,InnoxHost and NewsReload.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)