The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Accounting.php.inc Issue

Discussion in 'General Discussion' started by lancelumpy, Apr 11, 2006.

  1. lancelumpy

    lancelumpy Registered

    Joined:
    Jul 2, 2005
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    I am pretty new to coding with Accounting.php.inc, but I managed to get it working, and I created an account. There is one problem though. It seems there is no way to attach an email to an account while using remote access. I looked at the function in Accounting.php.inc and there was certainly no $email variable in there. Is there a way I can get it to attach an email or am I going to have to get my members to manually do it / keep creating accounts through the WHM?

    Cheers,

    Joe
     
  2. MFhosting

    MFhosting Member

    Joined:
    Apr 9, 2005
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    it would be really nice if someone could help with this as i have been looking for how to do this aswell...

    i thought accounting.php.inc is a great way to get accounts set up... but once i got the email problem too well... that pretty much did it for me...

    is there a way to edit accounting.php.inc and somehow define the variable for the email? or like lance said is it not possible and just get members to manually do it.

    looking forwards for an answer on this one...

    (sorry for hi-jacking lance ;) )
     
  3. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    You can just feed the email in there by adding another argument. Here's mine:

    PHP:
    function createacct ($whm_host,$whm_user,$accesshash,$usessl,$acctdomain,$acctuser,$acctpass,$acctplan,$acctcontact) {
        
    $result whmreq("/scripts/wwwacct?remote=1&nohtml=1&username=${acctuser}&password=${acctpass}&domain=${acctdomain}&plan=${acctplan}&contactemail=${acctcontact}",$whm_host,$whm_user,$accesshash,$usessl);
        if (
    $cpanelaccterr != "") { return; }
        return 
    $result;
    }
    I think some of the argument names are slightly different than the original, but the principle is fine.

    In this instance, you can take a look at /scripts/wwwacct (the bit that actually does all the hard work) and check what arguments it can accept.
     
  4. MFhosting

    MFhosting Member

    Joined:
    Apr 9, 2005
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    this is good... although we are on a shared server... so if we change that, it could make the other users scripts (like ihost) mess up.
     
  5. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    Not at all.

    If other scripts are expecting to supply createacct() with 8 arguments, it might be a problem if createacct() required 9 arguments . . . so set a default for the 9th argument so that it doesn't need to be supplied.

    PHP:
    function createacct ($whm_host,$whm_user,$accesshash,$usessl,$acctdomain,$acctuser,$acctpass,$acctplan,$acctcontact="") {
        if (
    $acctcontact == "") {
          
    $result whmreq("/scripts/wwwacct?remote=1&nohtml=1&username=${acctuser}&password=${acctpass}&domain=${acctdomain}&plan=${acctplan}",$whm_host,$whm_user,$accesshash,$usessl);
        } else {
          
    $result whmreq("/scripts/wwwacct?remote=1&nohtml=1&username=${acctuser}&password=${acctpass}&domain=${acctdomain}&plan=${acctplan}&contactemail=${acctcontact}",$whm_host,$whm_user,$accesshash,$usessl);
        }

        if (
    $cpanelaccterr != "") { return; }
        return 
    $result;
     
    #5 webignition, Apr 12, 2006
    Last edited: Apr 12, 2006
  6. MFhosting

    MFhosting Member

    Joined:
    Apr 9, 2005
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1

    ooooohhh great i'm sure this will help lancelumpy too it sure helped me!
     
  7. lancelumpy

    lancelumpy Registered

    Joined:
    Jul 2, 2005
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    That's great mate :D. Thanks for the help. Never thought of doing that!

    Cheers,

    Joe
     
  8. esouza

    esouza Registered

    Joined:
    Jun 16, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    No access to Accounting.php.inc

    What to do?

    Im using this script, but no efect.

    <?php

    // PARA USAR, DÁ UMA PESQUISADA NA NET SOBRE FUNÇÕES DE ACESSO REMOTO AO WHM
    // no site ( phpbrasil.com ) tem uns scripts que fazem a conexão ...

    global $cpanelaccterr;

    // SUSPENDE CONTAS WHM
    function suspend ($host,$user,$accesshash,$usessl,$suspenduser) {
    $result = whmreq("/scripts/remote_suspend?user=${suspenduser}",$host,$user,$accesshash,$usessl);
    if ($cpanelaccterr != "") { return; }
    return $result;
    }

    // ATIVA CONTAS WHM
    function unsuspend ($host,$user,$accesshash,$usessl,$suspenduser) {
    $result = whmreq("/scripts/remote_unsuspend?user=${suspenduser}",$host,$user,$accesshash,$usessl);
    if ($cpanelaccterr != "") { return; }
    return $result;
    }

    // TERMINA UMA CONTA NO WHM
    function killacct ($host,$user,$accesshash,$usessl,$killuser) {
    $result = whmreq("/scripts/killacct?user=${killuser}&nohtml=1",$host,$user,$accesshash,$usessl);
    if ($cpanelaccterr != "") { return; }
    return $result;
    }

    // MOSTRA INFORMAÇÕES DE CONTAS
    function showversion ($host,$user,$accesshash,$usessl) {
    $result = whmreq("/scripts2/showversion",$host,$user,$accesshash,$usessl);
    if ($cpanelaccterr != "") { return; }
    return $result;
    }


    // CRIA UMA CONTA NO WHM
    function createacct ($host,$user,$accesshash,$usessl,$acctdomain,$acctuser,$acctpass,$acctplan) {
    $result = whmreq("/scripts/wwwacct?remote=1&nohtml=1&username=${acctuser}&password=${acctpass}&domain=${acctdomain}&plan=${acctplan}",$host,$user,$accesshash,$usessl);
    if ($cpanelaccterr != "") { return; }
    return $result;
    }



    // LISTA AS CONTAS
    function listaccts ($host,$user,$accesshash,$usessl) {
    $result = whmreq("/scripts2/listaccts?nohtml=1&viewall=1",$host,$user,$accesshash,$usessl);
    if ($cpanelaccterr != "") { return; }

    $page = split("\n",$result);
    foreach ($page as $line) {
    list($acct,$contents) = split("=", $line);
    if ($acct != "") {
    $allc = split(",", $contents);
    $accts[$acct] = $allc;
    }
    }
    return($accts);
    }


    // MOSTRA PACOTES
    function listpkgs ($host,$user,$accesshash,$usessl) {
    $result = whmreq("/scripts/remote_listpkg",$host,$user,$accesshash,$usessl);
    if ($cpanelaccterr != "") { return; }


    $page = split("\n",$result);
    foreach ($page as $line) {
    list($pkg,$contents) = split("=", $line);
    if ($pkg != "") {
    $allc = split(",", $contents);
    $pkgs[$pkg] = $allc;
    }
    }
    return($pkgs);
    }
    function whmreq ($request,$host,$user,$accesshash,$usessl) {


    $cleanaccesshash = preg_replace("'(\r|\n)'","",$accesshash);
    $authstr = $user . ":" . $cleanaccesshash;
    $cpanelaccterr = "";


    if (function_exists("curl_init")) {
    $ch = curl_init();
    if ($usessl) {
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
    curl_setopt($ch, CURLOPT_URL, "https://${host}:2087" . $request);
    } else {
    curl_setopt($ch, CURLOPT_URL, "http://${host}:2086" . $request);
    }
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    $curlheaders[0] = "Authorization: WHM $authstr";
    curl_setopt($ch,CURLOPT_HTTPHEADER,$curlheaders);
    $data=curl_exec ($ch);
    curl_close ($ch);
    } elseif (function_exists("socket_create")) {
    if ($usessl) {
    $cpanelaccterr = "SSL Support requires curl";
    return;
    }
    $service_port = 2086;
    $address = gethostbyname($host);
    $socket = socket_create (AF_INET, SOCK_STREAM, 0);
    if ($socket < 0) {
    $cpanelaccterr = "socket_create() failed";
    return;
    }
    $result = socket_connect ($socket, $address, $service_port);
    if ($result < 0) {
    $cpanelaccterr = "socket_connect() failed";
    return;
    }
    $in = "GET $request HTTP/1.0\n";
    socket_write($socket,$in,strlen($in));
    $in = "Connection: close\n";
    socket_write($socket,$in,strlen($in));
    $in = "Authorization: WHM $authstr\n\n\n";
    socket_write($socket,$in,strlen($in));

    $inheader = 1;
    while(($buf = socket_read($socket, 512)) != false) {
    if (!$inheader) {
    $data .= $buf;
    }
    if(preg_match("'\r\n\r\n$'s", $buf)) {
    $inheader = 0;
    }
    if(preg_match("'\n\n$'s", $buf)) {
    $inheader = 0;
    }
    if(preg_match("'\r\n$'s", $buf)) {
    $inheader = 0;
    }
    }

    } else {
    $cpanelaccterr = "php not compiled with --enable-sockets OR curl";
    return;
    }

    return $data;
    }

    // Passando os parâmetros para teste

    $accesshash='--> KEY <<--';
    $host='webprocess.com.br';
    $user='MY ACCOUNT USER';
    $usessl='0';
    $acctdomain='teste1234.webprocess.com.br';
    $acctuser='webproce_teste1234';
    $acctpass='teste';
    $acctplan='webproce_WP-01';

    // Caling the function

    createacct ($host,$user,$accesshash,$usessl,$acctdomain,$acctuser,$acctpass,$acctplan);
    ?>
     
  9. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    The accounting functions supplied with cPanel work.

    You'd have to opt for the traditional method of troubleshooting your script to find out where the problem is!
     
Loading...

Share This Page