API Creator User Automatic di Direct Admin

Discussion in 'Desain Web dan Programming' started by UNMETERED, 21 Jun 2016.

Thread Status:
Not open for further replies.
  1. UNMETERED

    UNMETERED Apprentice 2.0

    Messages:
    535
    Likes Received:
    85
    Trophy Points:
    28
    Yth Kepada : Para Web Master / Web Hoster DWH
    Kami ada beberapa permasalahan sehingga terjadi kesalahan dalam membuat Kode tentang "Account Creator Automatic untuk Panel Direct Admin". Saya sudah googling dan menemukan beberapa script kode dari forum diskusi http://forum.directadmin.com/ tentang cara create akun secara otomatis di panel direct admin, namun tidak berjalan ( no working ). Mungkin ada beberapa master yang ingin meluruskan kodenya dan dari sudut mana kesalahan yang terjadi. Berikut ini API Account Creator Direct Admin

    PHP:
    <?php
    if($_GET['create'] == 1)
    {
    if(
    $_POST['pass'] != "pass"){echo "ERROR PASSWORD INCORRECT";exit;}
    include 
    'httpsocket.php';
    $create = new HTTPSocket;
    $create->connect('ssl://202.181.1XX.182',2222);
    $create->set_login("""");
    $create->set_method('POST');
    $create->query('/CMD_API_ACCOUNT_USER',
    array(
    'username' => $_POST['username'], // The User's username. 4-8 characters, alphanumeric
    'email' => $_POST['email'], // A valid email address
    'passwd' => $_POST['pwd'], // The User's password. 5+ characters, ascii
    'passwd2' => $_POST['pwd2'], // Password double check. 5+ characters, ascii
    'domain' => $_POST['domain'], // A valid domain name in the form: domain.com
    'package' => $_POST['package'], // One of the User packages created by the Reseller
    'ip' => '202.XXX.178.182'// One of the ips which is available for user creation. Only free or shared ips are allowed.
    'notify' => 'yes'// yes or no. If yes, an email will be sent to email
    'action' => 'create',
    'add' => 'Submit'
    ));
    $result $create->fetch_parsed_body();
    if(
    $result['error'] == 1)
    {
    ?>
    <center>Error Creating account<br>The Error Is : <? echo "$result[details]"?> </center>
    <?php
    }
    else
    {
    ?>
    <center>Account Successfuly Created. An Email has been sent with more information.<br></center>
    <?php
    }
    exit;
    }
    ?>
    <html>
    <form action='<?=$PHP_SELF;?>?create=1' method='post' name='form'>
    <div align="center">  <table width="600" border="0" cellpadding="0" cellspacing="0" bordercolor="#333333">
    <tr>  <td width="300"><div align="center">Username*:</div></td>
    <td width="300">
    <div align="justify">
    <input name='username' type='text' style="WIDTH: 300px" />
    </div></td>  </tr>
    <tr>  <td><div align="center">Email:</div></td>  <td>
    <div align="justify">
    <input name='email' type='text' style="WIDTH: 300px" />
    </div></td>  </tr>
    <tr>  <td><div align="center">Password**:</div></td>
    <td>  <div align="justify">
    <input name='pwd' type='password' style="WIDTH: 300px" />
    </div></td>  </tr>
    <tr>  <td><div align="center">Password Validate**:</div></td>
    <td>  <div align="justify">  <input name='pwd2' type='password' style="WIDTH: 300px" />
    </div></td>  </tr>  <tr>
    <td><div align="center">Domain:</div></td>
    <td>  <div align="justify">  <input type="text" name='domain' style="WIDTH: 300px" />  </div></td>
    </tr>
    <tr>  <td><div align="center">Bandwidth:</div></td>  <td> <div align="center">10 GB + </div></td>
    </tr>
    <tr>  <td bordercolor="#666666"><div align="center">U - Bandwidth:</div></td>
    <td bordercolor="#666666"><div align="center">
    <input type="radio" value='on' name='package' checked="checked" />
    PL1000
    <input type="radio" value='off' name='package' />
    PL500 </div></td>  </tr>
    <tr>
    <td colspan="2" bordercolor="#666666"><div align="center">
    <input name="submit" type="submit" value='Submit' />
    <br />
    * 4-8 Characters, alphanumeric<br />
    ** 5+ Characters, alphanumeric<br />
    Cheaked means yes</div></td>
    </tr>
    </table>
    </div>
    <div align="center"></div>
    </form>
    </html>
    Kode yang kedua :

    PHP:
    <?

    include 
    'httpsocket.php';

    $server_ip="11.22.33.44"//IP that User is assigned to
    $server_login="admin";
    $server_pass="yourpass";
    $server_host="127.0.0.1"//where the API connects to
    $server_ssl="N";
    $server_port=2222;

    if (isset(
    $_POST['action']) && $_POST['action'] == "add")
    {

        
    $username=$_POST['username'];
        
    $domain=$_POST['domain'];
        
    $email=$_POST['email'];
        
    $pass=$_POST['pass'];
        
    $package=$_POST['package'];


        echo 
    "Creating user $username on $server_ip.... <br>\n";
        
    $sock = new HTTPSocket;
        if (
    $server_ssl == 'Y')
        {
            
    $sock->connect("ssl://".$server_host$server_port);
        }
        else
        {
            
    $sock->connect($server_host$server_port);
        }
        
    $sock->set_login($server_login,$server_pass);
        
    $sock->query('/CMD_API_ACCOUNT_USER',
            array(
                
    'action' => 'create',
                
    'add' => 'Submit',
                
    'username' => $username,
                
    'email' => $email,
                
    'passwd' => $pass,
                
    'passwd2' => $pass,
                
    'domain' => $domain,
                
    'package' => $package,
                
    'ip' => $server_ip,
                
    'notify' => 'yes'
            
    ));
        
    $result $sock->fetch_parsed_body();
        if (
    $result['error'] != "0")
        {
            echo 
    "<b>Error Creating user $username on server $server_ip:<br>\n";
            echo 
    $result['text']."<br>\n";
            echo 
    $result['details']."<br></b>\n";
        }
        else
        {
            echo 
    "User $username created on server $server_ip<br>\n";
        }

        exit(
    0);
    }

    echo 
    "Will connect to: ".($server_ssl == "Y" "https" "http")."://".$server_host.":".$server_port."<br>\n";

    ?>


    <form action='?' method="POST">
    <input type=hidden name=action value="add">
    Username: <input type=text name=username><br>
    Domain:<input type=text name=domain><br>
    Email: <input type=text name=email><br>
    Pass: <input type=password name=pass><br>
    Packge: <input type=text name=package><br>
    </form>
    Kedua-duanya tidak work, mungkin ada petunjuk dari para hoster dan ijin colek @PusatHosting
     
  2. PusatHosting

    PusatHosting Hosting Guru Web Hosting

    Messages:
    3,340
    Likes Received:
    326
    Trophy Points:
    83
    Script saya ini, sama seperti yang ke-2 dan bisa jalan
    Code:
    <?php
    error_reporting(E_ERROR | E_WARNING | E_PARSE);
    include 'httpsocket.php';
    
    // akun yang mau diciptakan
    $username    = "username";
    $domain        = "domain";
    $email        = "email";
    $pass         = "passwd";
    $package    = "package";
    
    // akun reseller yang menciptakan
    $server_ip    = "xxxx.xxx.xxx.xxx"; //server remote
    $server_login    = "username";
    $server_pass    = "password";
    $server_host    = "hostname-server"; //where the API connects to
    $server_ssl    = "N";
    $server_port    = "2222";
    
    if ($domain!="" && $server_login !="")
    {
    
        $sock = new HTTPSocket;
         $sock->set_method('POST');
        if ($server_ssl == 'Y')
        {
            $sock->connect("ssl://".$server_host, $server_port);
        }
        else
        {
            $sock->connect($server_host, $server_port);
        }
    
        $rs = $sock->set_login($server_login,$server_pass);
    
        $sock->query('/CMD_API_ACCOUNT_USER',
            array(
                'action' => 'create',
                'add' => 'Submit',
                'username' => $username,
                'email' => $email,
                'passwd' => $pass,
                'passwd2' => $pass,
                'domain' => $domain,
                'package' => $package,
                'notify' => 'no',
                'ip' => $server_ip
            ));
    
        $result = $sock->fetch_parsed_body();
    
        if(isset($result))
        {
            if ($result['error'] != "0")
            {
                echo "<b>Error Creating user $username on server $server_ip:<br>\n";
                echo $result['text']."<br>\n";
                echo $result['details']."<br></b>\n";
            }
            else
            {
                echo "User $username created on server $server_ip<br>\n";
            }
        }
    }
    ?>
    
     
Loading...
Thread Status:
Not open for further replies.

Share This Page

Loading...