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.

PHP accounting

Discussion in 'General Discussion' started by dhrx, Feb 20, 2004.

  1. dhrx

    dhrx Member

    Joined:
    Jan 22, 2003
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    Hi

    I have been searchin the forums for ages now but I have not found an easy way of doing this in the php accounting module.

    I want to setup accounts automatically or when a button is clicked without a plan already set up on the server so I obvisly need to send the variables with it.

    I tried editing it but I just got errors and confused myself so if possible can somebody post an example of what to be put in the accounting file and what php code should be used so I can setup accounts which quotas and specs are set from variables not from a plan pre made on the server.

    Thanks I really need this help :)

    Dan
     
  2. nybble

    nybble Well-Known Member

    Joined:
    Jan 26, 2004
    Messages:
    223
    Likes Received:
    0
    Trophy Points:
    16
    Look at how accounting.php.inc works - it calls on the server scripts :P

    So? Do the same to add a plan.
     
  3. dhrx

    dhrx Member

    Joined:
    Jan 22, 2003
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    I can't get the url it posts to well I can but not the variables it posts so I don't know how.

    Why can't Nick just make the php accounting more functional like the perl version is?

    I sure hope he will

    Thanks

    Dan
     
  4. nybble

    nybble Well-Known Member

    Joined:
    Jan 26, 2004
    Messages:
    223
    Likes Received:
    0
    Trophy Points:
    16
    How isnt it functional?

    It calls remote stuff on the other server, for example as you would in WHM yourself, like adduser.cgi?user=what ever
     
  5. dhrx

    dhrx Member

    Joined:
    Jan 22, 2003
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    Sorry need to be more clear.

    It is functional, but the perl version has already programmed in add packages add custom plans the works. But the php version hasn't had this kind of treatment I mean.

    If anybody can give me the link to the add package thing it would be a great help just the /scripts/ and what ever goes after it with the variables in tact.

    Thanks!

     
  6. nybble

    nybble Well-Known Member

    Joined:
    Jan 26, 2004
    Messages:
    223
    Likes Received:
    0
    Trophy Points:
    16
    For example:

    PHP:
    function killacct (
    $host,$user,$accesshash,$usessl,$killuser) {
    $result whmreq("/scripts/killacct?user=${killuser}&nohtml=1",$host,$user,$accesshash,$usessl);
          if (
    $cpanelaccterr != "") { return; }      return $result;  }
    Now, see how that works?
    It calls on /scripts/killacct?user=${killuser}&nohtml=1

    Now with this in mind, You can make your own function, accept tell it to addpackage? (Or what ever it is)

    I thank Nick for his very neat code, A+ man :)

    I am guessing the add package plan is going to be a little more advanced, but if you know php you wont have any problems :)
     
  7. dhrx

    dhrx Member

    Joined:
    Jan 22, 2003
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    Sorry to post again, but I know how to do that, thats a simple one, the problem is that I don't know the url for the add package whrn i right click props in whm it onlu gives me the start.

    /scripts/killacct?user=${killuser}&nohtml=1

    I dont know the bit after the killacct I can't get what to post across so all I am going to get is errors, so thats why I would like somebody who knows how that bit works to post the full url with everything intact.

    Thanks

    Dan
     
  8. h2oski

    h2oski Well-Known Member

    Joined:
    Dec 12, 2001
    Messages:
    68
    Likes Received:
    0
    Trophy Points:
    6
    ok, let's look at the html for createing a new package in WHM

    *note - I cut out all the extra html other than just the basic form for ease of reading.
    PHP:
    <form method=POST action="/scripts2/addpkg" name="mainform">
    <
    input type="text" name="name">
    <
    input type="text" name="quota">Mega Bytes</td>
    <
    input value="1" type="checkbox" checked name="hasshell"></td>
    <
    input  value="unlimited" type="text" name="maxftp"></td>
    <
    input type="text"  value="unlimited" name="maxpop"></td>
    <
    input  value="unlimited"  type="text" name="maxlst"></td>
    <
    input type="text"   value="unlimited" name="maxsql"></td>
    <
    input type="text" name="maxsub"  value="unlimited" ></td>
    <
    input type="text" name="maxpark"  value="0" >
    <
    input type="text" name="maxaddon"  value="0" ></td>
    <
    input value="1" type="checkbox" name="ip">
    <
    input value="1" type="checkbox" checked name="cgi">
    <
    input value="1" type="checkbox" checked name="frontpage"></td>
    <
    input type="text" name="bwlimit" value="unlimited"MegaBytes</td>

    <
    select name="cpmod">
    <
    option value=NO>NO</option>
    <
    option value=YES>YES</option>
    <
    option value=advanced>advanced</option>
    <
    option value=tree>tree</option>
    <
    option value=y>y</option>
    <
    option value=monsoon>monsoon</option>
    <
    option value=default selected>default</option>
    <
    option value=iconic>iconic</option>
    <
    option value=mailonly>mailonly</option>
    <
    option value=x>x</option>
    <
    option value=x2>x2</option>
    <
    option value=xmail>xmail</option>
    <
    option value=cclpanel>cclpanel</option>
    <
    option value=bluetrix>bluetrix</option>
    <
    option value=bluelagoon>bluelagoon</option>
    <
    option value=vertex>vertex</option>   </select>

    <
    select name="featurelist">
    <
    option value="testlist">testlist</option>
    <
    option value="default" selected>default</option>
    </
    select>
      
    </
    form>
    now, we know we are going to call the whmreq function
    PHP:
    function whmreq ($request,$host,$user,$accesshash,$usessl) {
    so we need to format everything from the form above into the $request string and then call the function

    you will have a script that ends up looking like this:

    PHP:
    $request "/scripts2/addpkg?name".$_POST['name']."&quota=".$_POST['quota']...........conintue for each parm
    you get the idea. for each form field append the name and value to the request string. As you can see from the $_POST I am assuming you have a php page where you are getting all the post values from a html form

    once you have the request string formated you can call whmreq function

    does that help?
     
  9. dhrx

    dhrx Member

    Joined:
    Jan 22, 2003
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    Thats really great thanks now I see how everybody makes these url's never occured to me.

    Thanks again :)

    Dan
     
  10. nybble

    nybble Well-Known Member

    Joined:
    Jan 26, 2004
    Messages:
    223
    Likes Received:
    0
    Trophy Points:
    16
    Well :) Thats one big post :) nice way of saying it
     
  11. dhrx

    dhrx Member

    Joined:
    Jan 22, 2003
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    Ive just done what you said it comes up with no error message or anything just no plan gets added which is strange

    Thanks

    Dan
     
    #11 dhrx, Feb 23, 2004
    Last edited: Feb 24, 2004
  12. dhrx

    dhrx Member

    Joined:
    Jan 22, 2003
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    Hi

    Can anybody spot the error in this I am getting no error message well nothing at all actually.

    Really greatful for all your help

    Dan
     

    Attached Files:

  13. h2oski

    h2oski Well-Known Member

    Joined:
    Dec 12, 2001
    Messages:
    68
    Likes Received:
    0
    Trophy Points:
    6
    no need to create your own fuction in Accounting.php.inc

    just call whmreq

    also, I am pretty sure you can not see the $_POST variables inside your fuction. If you want your own fuction you will need to pass them all in. No fun.

    give this version a try:
     
  14. h2oski

    h2oski Well-Known Member

    Joined:
    Dec 12, 2001
    Messages:
    68
    Likes Received:
    0
    Trophy Points:
    6
  15. dhrx

    dhrx Member

    Joined:
    Jan 22, 2003
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    Sorry to say that didnt work which is a tad annoying as it looked promising.

    Any other ideas?

    Dan
     
  16. h2oski

    h2oski Well-Known Member

    Joined:
    Dec 12, 2001
    Messages:
    68
    Likes Received:
    0
    Trophy Points:
    6
    make sure you have your access key correct.

    If accounting.php.inc can not communicate with whm it will just return nothing, for you resulting in a blank page

    your access key should not contain the -----begin key--- and -----end key-----
     
  17. dhrx

    dhrx Member

    Joined:
    Jan 22, 2003
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    Nope theres no change the key is exactly the same it doesn't have to be all on one line does it?

    It has worked before when reading accounts etc... just obvisly not now when I'm trying something different.

    Dan
     
  18. h2oski

    h2oski Well-Known Member

    Joined:
    Dec 12, 2001
    Messages:
    68
    Likes Received:
    0
    Trophy Points:
    6
    jump on AIM I will see if I can help you there.

    AIM: cclHstng
     
  19. h2oski

    h2oski Well-Known Member

    Joined:
    Dec 12, 2001
    Messages:
    68
    Likes Received:
    0
    Trophy Points:
    6
  20. dhrx

    dhrx Member

    Joined:
    Jan 22, 2003
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    You are one amazing guy thanks so so much.

    This guy needs a aword for helping me ;)

    Thanks again

    Dan
     
Loading...

Share This Page