Page 1 of 2 12 LastLast
Results 1 to 15 of 20

Thread: PHP accounting

  1. #1
    Member
    Join Date
    Jan 2003
    Posts
    23

    Default PHP accounting

    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. #2
    Member
    Join Date
    Jan 2004
    Posts
    227

    Default

    Look at how accounting.php.inc works - it calls on the server scripts :P

    So? Do the same to add a plan.

  3. #3
    Member
    Join Date
    Jan 2003
    Posts
    23

    Default

    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. #4
    Member
    Join Date
    Jan 2004
    Posts
    227

    Default

    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. #5
    Member
    Join Date
    Jan 2003
    Posts
    23

    Default

    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!

    Originally posted by nybble
    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

  6. #6
    Member
    Join Date
    Jan 2004
    Posts
    227

    Default

    For example:

    PHP Code:
    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. #7
    Member
    Join Date
    Jan 2003
    Posts
    23

    Default

    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. #8
    Member h2oski's Avatar
    Join Date
    Dec 2001
    Posts
    71

    Default

    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 Code:
    <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 Code:
    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 Code:
    $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. #9
    Member
    Join Date
    Jan 2003
    Posts
    23

    Default

    Originally posted by h2oski
    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 Code:
    <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 Code:
    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 Code:
    $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?
    Thats really great thanks now I see how everybody makes these url's never occured to me.

    Thanks again

    Dan

  10. #10
    Member
    Join Date
    Jan 2004
    Posts
    227

    Default

    Well Thats one big post nice way of saying it

  11. #11
    Member
    Join Date
    Jan 2003
    Posts
    23

    Default

    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
    Last edited by dhrx; 02-24-2004 at 11:42 AM.

  12. #12
    Member
    Join Date
    Jan 2003
    Posts
    23

    Default

    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 Attached Files

  13. #13
    Member h2oski's Avatar
    Join Date
    Dec 2001
    Posts
    71

    Default

    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. #14
    Member h2oski's Avatar
    Join Date
    Dec 2001
    Posts
    71

    Default

    hey, where is the attachment?

    oh well here is a link: http://ccldevelopment.com/cpanel2.zip

  15. #15
    Member
    Join Date
    Jan 2003
    Posts
    23

    Default

    Sorry to say that didnt work which is a tad annoying as it looked promising.

    Any other ideas?

    Dan

Page 1 of 2 12 LastLast

Similar Threads

  1. accounting.php.inc
    By Claus in forum cPanel & WHM Discussions
    Replies: 3
    Last Post: 05-16-2008, 01:33 PM
  2. Accounting.php.inc where to get?
    By oszone in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 11-08-2006, 05:17 AM
  3. Accounting.inc.php
    By nvez in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 07-17-2006, 05:00 PM
  4. Accounting.php.inc
    By nybble in forum cPanel & WHM Discussions
    Replies: 11
    Last Post: 02-13-2004, 09:51 AM
  5. Accounting.php
    By gic in forum cPanel & WHM Discussions
    Replies: 5
    Last Post: 08-05-2003, 08:55 AM