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 Account Creation

Discussion in 'General Discussion' started by jlimited, Apr 29, 2005.

  1. jlimited

    jlimited Well-Known Member

    Joined:
    Jun 4, 2004
    Messages:
    69
    Likes Received:
    0
    Trophy Points:
    6
    Hello,

    I have a working PHP account creation script. But, I would like the end user to see the information for their account on the web as it being created.

    Does cPanel have output strings that show account creation messages? Is there a documents that explains how to do this?

    Also, I cannot seem to set the contact email in cPanel at the time of account creation. Is there a way to make this a PHP option?

    Thanks
    Jlimited
     
  2. cyphergr

    cyphergr Registered

    Joined:
    Apr 30, 2005
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    Your script is probably making use of the Accounting.php class am I right?

    If that's the case then you must be using the createacct function, the role of this function is to submit the query

    $result = whmreq("/scripts/wwwacct?remote=1&nohtml=1&username=${acctuser}&password=${acctpass}&domain=${acctdomain}&plan=${acctplan}",$host,$user,$accesshash,$usessl);

    and then it returns the result string.

    Unfortunatelly as you can see above the query includes nohtml=1 and as a result
    it does not return the messages you want to display. It's also missing the field contactemail which is the contact's e-mail.

    If you use whmreq instead of the function createacct then you should be able to do what you wish.

    Take care,
    G.
     
  3. dkz

    dkz Well-Known Member

    Joined:
    Sep 10, 2004
    Messages:
    100
    Likes Received:
    0
    Trophy Points:
    16
    I'm currently working on a custom script for WHM. It includes the contactmail option as well. I assume you know PHP so you should be able to figure out the next step using php's mail option. Just make sure all the variables get submitted from an external page...

    Here's my script...
    PHP:
    #!/usr/local/cpanel/3rdparty/bin/php

    <?php

    $host 
    "localhost";
    $user "root";
    $accesshash 
    'HASH GOES HERE';

    $response whmreq("/scripts/wwwacct?remote=0&nohtml=1&domain=$domain&username=$username&password=$password&quota=$quota&cpmod=$cpmod&contactemail=$contactemail&msel=$msel&plan=$plan&ip=$ip&cgi=$cgi&frontpage=$frontpage&maxftp=$maxftp&maxsql=$maxsql&maxpop=$maxpop&maxlst=$maxlst&maxsub=$maxsub&bwlimit=$bwlimit&hasshell=$hasshell&maxpark=$maxpark&maxaddon=$maxaddon&sign=$sign&customip=$customip&reseller=$reseller&ownerself=$ownerself",$host,$user,$accesshash,$usessl); 

    global 
    $cpanelaccterr;
    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($chCURLOPT_SSL_VERIFYPEER,0);                
                
    curl_setopt($chCURLOPT_SSL_VERIFYHOST,0);
                
    curl_setopt($chCURLOPT_URL"https://${host}:2087" $request);
            } else {
                
    curl_setopt($chCURLOPT_URL"http://${host}:2086" $request);
                    }
            
    curl_setopt($chCURLOPT_HEADER0);
            
    curl_setopt($chCURLOPT_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_INETSOCK_STREAM0);
            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($socket512)) != 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;    
    }

    print_r($response);
    ?>
     
  4. Tapan

    Tapan Well-Known Member

    Joined:
    Dec 4, 2004
    Messages:
    109
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Chandigarh
    Hi,

    So by using your thread can i use it to create account you mean ? I mean what happens if the username which i enter already exists or something ?

    Thanks
     
  5. yanayun

    yanayun Member

    Joined:
    May 14, 2005
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    Reseller

    hi,

    this script can't use for reseller user, it's display cpanel login.

    :(

    do you have Idea?
     
  6. jlimited

    jlimited Well-Known Member

    Joined:
    Jun 4, 2004
    Messages:
    69
    Likes Received:
    0
    Trophy Points:
    6
    email information

    When I used this script, minus a few variables. It works fine.

    When I ran the script, it placed all the information in to 1 row of text. So, I played around with the nohtml variable and was able to get the look on the web site right.

    But when I added the email contactemail feature, I get a email will all the HTML code.

    mail($contactemail, "New Account Information", $response,
    "From: sales@limitedwebgroup.com");

    When I turn nohtml to 1 and the email looks great, but the web site does not. So I tried adding the following lines.

    $message = whmreq("/scripts/wwwacct?remote=0&nohtml=1&domain=$acctdomain&username=$acctuser&password=$acctpass&contactemail=$contactemail&plan=$acctplan",$host,$user,$accesshash,$usessl);

    mail($contactemail, "New Account Information", $message,
    "From: sales@limitedwebgroup.com");

    But, I do not get an email at all.

    How can I get the website to give me a html view of the information and the email to give me a nohtml view of the information? Do I need to print_r($message);?

    Thanks
    Jlimited
     
Loading...

Share This Page