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.

[TOP SECRET]: Whm remote accounting!

Discussion in 'General Discussion' started by Samxm, Jun 12, 2006.

  1. Samxm

    Samxm Member

    Joined:
    May 29, 2006
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    I'm st-i-i-i-i-i-ll wondering of impossibility to find any info about whm remote accountung...
    In the Internet U can find ANYTHING but not a whm r/a info!

    So, maybe by asking some questions I'll reach some info...

    Well, the questions is:

    1. Can 'createacct' function use arguments received from out files(html form for example)? from db?
    2. May this block -
    [require '/usr/local/cpanel/Cpanel/Accounting.php.inc';
    $host = "localhost";
    .
    .
    createacct ($host, . . . ]
    be in the middle/end of script? Is there any restriction?
    3. And, certainly, any other helpful info is welcome!


    I'm sooo tired of trying make my skript work. It work only seporatly. as single block with predefinite args. And when I try to integrate it in big script it's not work...
     
  2. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    If you look around you should find some examples of how to use createacct(), although there aren't that many. I don't think there are any restrictions on where you use it, and since you don't post any real details (such as the actual error message you're getting) I can't help further.

    Createacct() could use variables from anywhere, just like any PHP script can. Not sure why you're asking, if you understand even the basics about PHP that should be obvious?
     
  3. Samxm

    Samxm Member

    Joined:
    May 29, 2006
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Yes, its obvious! But I already don't know what else could make trouble.

    Here is a working script:

    PHP:
    <?

    require 
    '/usr/local/cpanel/Cpanel/Accounting.php.inc';

    $host "localhost";
    $usessl 0;
    $whmuser "*****";
    $accesshash '74393fb80c6078c3c437a79f81c1bcef
    a029540ccc3c2a663e19d4f69e38986e
    990e1a259451ba9f311988673a6932e6
    9179767c17837b4ec1386974d31013bf
    e42d9dae80244196d47c0326269e1923
    63863eeb929b6700c8ccfa3ffb9c0b9b
    5580eb12fedaaf854daefa4e0f130e78
    ******************************
    acab13e94600a785f4476801736af0ff
    *******************************
    b0feddebdb916168ecaefe982e7b14bd
    9c6b83bb1b2dbd9b0a4c852470ebf685
    65d423f310e2cac39f687779f441c90a
    a4bdab89c6a13b20e47abedb0831a5f7
    033404110ed98521740ee5e8182c6544
    bfd5068f15cec2d8ef9ae0b68fc38db4
    4a43bf1a7e71da30da5124bcbefd9bc5
    4cdc3a8c8b116decfe11071d5503a37f
    911e5a5f00ce4f03e016b770b0122cd1
    aece7ba3e48c5d90884ce72351a8a577
    92fdf3c21601361d9c348ea79e343514
    4baa2ae2d128af0f5ae90cb8bc1777db
    2aaf9defb7b4374b219827bb7b214684
    715a3a0b56a215dd238cdcfd4c28149b
    69f9057d826f1d59339dcb2097643c49
    7789f7d3b70c2f55df8c26d986078ad7
    28a4fba963eabd0b9a799fc143df3729
    bea00f4fe7d39139b9e5c0bab09fbca3
    f4f98e3313123ca07e135e4ef10b8310
    '
    ;

    $domq="paganini.com";
    $loginq="paganini";
    $passq="genius";
    $planq="jolieh_hot";

    createacct ($host,$whmuser,$accesshash,$usessl,$domq,$loginq,$passq,$planq);

    ?>

    And this one is not work(arguments receives from an form):


    PHP:
    <?

    require 
    '/usr/local/cpanel/Cpanel/Accounting.php.inc';


    $host "localhost";
    $usessl 0;
    $whmuser "******";
    $accesshash '74393fb80c6078c3c437a79f81c1bcef
    a029540ccc3c2a663e19d4f69e38986e
    990e1a259451ba9f311988673a6932e6
    9179767c17837b4ec1386974d31013bf
    e42d9dae80244196d47c0326269e1923
    63863eeb929b6700c8ccfa3ffb9c0b9b
    5580eb12fedaaf854daefa4e0f130e78
    *******************************
    acab13e94600a785f4476801736af0ff
    ******************************
    b0feddebdb916168ecaefe982e7b14bd
    9c6b83bb1b2dbd9b0a4c852470ebf685
    65d423f310e2cac39f687779f441c90a
    a4bdab89c6a13b20e47abedb0831a5f7
    033404110ed98521740ee5e8182c6544
    bfd5068f15cec2d8ef9ae0b68fc38db4
    4a43bf1a7e71da30da5124bcbefd9bc5
    4cdc3a8c8b116decfe11071d5503a37f
    911e5a5f00ce4f03e016b770b0122cd1
    aece7ba3e48c5d90884ce72351a8a577
    92fdf3c21601361d9c348ea79e343514
    4baa2ae2d128af0f5ae90cb8bc1777db
    2aaf9defb7b4374b219827bb7b214684
    715a3a0b56a215dd238cdcfd4c28149b
    69f9057d826f1d59339dcb2097643c49
    7789f7d3b70c2f55df8c26d986078ad7
    28a4fba963eabd0b9a799fc143df3729
    bea00f4fe7d39139b9e5c0bab09fbca3
    f4f98e3313123ca07e135e4ef10b8310
    '
    ;



    createacct ($host,$whmuser,$accesshash,$usessl,$domq,$loginq,$passq,$planq);


    $dbname "******";
    $table "*******";
    $link mysql_connect ($host"*****""******");


       
    $acc="open";

       
    $query "UPDATE $table SET acc='$acc' where (login='$loginq')";
       
    $result mysql_db_query ($dbname$query$link);

       
    $fromfrom="Script ac.php";
       
    $textca "host - $host \n whmuser - $whmuser \n accesshash - $accesshash \n usessl - $usessl \n domain - $domq \n login - $loginq \n password - $passq \n plan - $planq";
        
    mail("admin@******.com""log from ac.php"$textca"From: $fromfrom");


    ?>
    And to admin@*******.com comes exactly what I insert in form, plan also coincide with whm plan.
    So I really can't understand whats wrong, plz, HELP!
     
    #3 Samxm, Jun 13, 2006
    Last edited: Jun 13, 2006
  4. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    You're relying on the variables to be set by the form in the second instance, and you don't check that they are. I'd put in some echo statements to see what $domq etc are set to.

    My bet is you don't have register_globals set to on, which would mean you'd need to refer to those form variables as $_POST['domq'] - although you could also use import_request_variables() to pull them in (or extract($_POST)) - see http://au.php.net/manual/en/function.import-request-variables.php for more info.

    To find out whether that's the case you'd need to use some debugging code on your page as I mentioned above (the echo "domq is $domq"; as above)
     
  5. Samxm

    Samxm Member

    Joined:
    May 29, 2006
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    register_globals is on as default, I check it now
    echo shows same good vars thats comes to email

    And its still dont work.
    I try to vary the code, try to split code to 2 files, - nothing help!

    This code work only seporatly as a single block with predefinite args.
     
  6. Samxm

    Samxm Member

    Joined:
    May 29, 2006
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Small revision:
    'createacct' dont work only when recieve arguments from form that in php, like this -
    <?php
    .
    .
    print(..FORM code here..)
    .
    .
    ?>
    and when args goes from normal html form everithing is ok :eek:
     
  7. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    Have you checked that the form variables are getting through? That seems to be the problem, pure and simple, and you can test it with an echo line above the createacct() call to see whether they're set. That's the first thing I'd test before going further.
     
  8. Samxm

    Samxm Member

    Joined:
    May 29, 2006
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    this script make me crazy :p

    here is the code that 100% must work, but it don't! -

    PHP:
    <?

    //import_request_variables("gP");

    require '/usr/local/cpanel/Cpanel/Accounting.php.inc';

    $host "localhost";
    $dbname "*****";
    $table "******";
    $link mysql_connect ($host"******""******");

    $queryext "SELECT * from $table where (login='$login')";
    $result mysql_db_query ($dbname$queryext$link);
    while (
    $row mysql_fetch_array ($result))  {  $login=$row[login]; $pass=$row[pass]; $dom=$row[domain]; $plan=$row[tarif]  }

    $usessl 0;
    $whmuser "*******";
    $accesshash '***********';

    print(
    "Vars line1: $dom$login$pass$plan");

    createacct ($host,$whmuser,$accesshash,$usessl,$dom,$login,$pass,$plan);

    print(
    "<br><br><center>Vars line2: $dom$login$pass$plan");


    ?>

    when I send from some form all 4 vars - $dom, $login, $pass, $plan, and disable dbquery - all work ok,
    but when I send only $login and extract other 3 vars from db whm account don't creates
    'print' show all varibales twice in both ways, but account don't creates, I CAN'T UNDERSTAND HOW IT CAN BE :eek: :eek: :eek:
     
    #8 Samxm, Jun 14, 2006
    Last edited: Jun 14, 2006
  9. Samxm

    Samxm Member

    Joined:
    May 29, 2006
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    It's seems to be a some kind of bermuda triangle :eek:
     
  10. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    probably it's to do with spacing or something similar in the extracted variables from the database, or maybe just that the plan/package doesn't exist. Put simply, it has to be something like that ...
     

Share This Page