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.

Problems creating account remotely

Discussion in 'General Discussion' started by oszone, Nov 27, 2006.

  1. oszone

    oszone Registered

    Joined:
    Sep 18, 2005
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    I have some problems.
    I have files: config.php with all variables needed ($host, $user, acesshash...)
    Nad also file with functions create, kill, suspend, unsuspend and whmreq.
    Bus something is not working. Now I`m trying to make account in the simpliest way.
    In nes file I included files listed below nad i wrote function create. when i open file. O get nothing. So is there way to get an error message?
    My functions:

    PHP:
    <?
    function 
    whmreq ($request,$host,$user,$remote_key,$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;
    ?>
    also
    PHP:
    <?
    function 
    create ($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
      };
    ?>

     
  2. oszone

    oszone Registered

    Joined:
    Sep 18, 2005
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
Loading...

Share This Page