Automatic registration of users via a remoting framework

Discussion in 'Developers' Forum' started by dark_stealth, Apr 8, 2011.

  1. dark_stealth

    dark_stealth New Member

    I want to create a simple auto register users. Automatically when the registration should be created a web site and ftp user with the same name, for example "legendarno".
    Specially pay 5 euro ISPConfig 3 Manual (very little information about the possibilities of the remoting framework) , studied all the examples in remoting_client / examples.
    ISPConfig Version:
    In this forum, found the script and modified it a bit :

    // Configuration values
    $username 'remote_user';
    $password 'coolPassWORd';
    $soap_location 'https://isp.tld:8080/remote/index.php';
    $soap_uri 'https://isp.tld:8080/remote/';
    // GET ftp_user ID
    function get_ftp_user_id($db_host$db_user$db_password,$db_name,$db_table_ftp,$soap_user) {
    $conn mysql_connect($db_host$db_user$db_password) or die('Error connecting to mysql');
        if (
    $db_found) {
    $SQL "SELECT ftp_user_id FROM $db_table_ftp WHERE username='$soap_user'";
    $dbread mysql_fetch_row(mysql_query($SQL));
    $primary_id_ftp $dbread[0];
        } else {
    $soap_result .= 'Database Not Found ';
    // GET client ID
    function get_client_id($db_host$db_user$db_password,$db_name,$db_table_client,$soap_user) {
    $conn mysql_connect($db_host$db_user$db_password) or die('Error connecting to mysql');
        if (
    $db_found) {
    $SQL "SELECT client_id FROM $db_table_client WHERE username='$soap_user'";
    $dbread mysql_fetch_row(mysql_query($SQL));
    $primary_id_client $dbread[0];
        } else {
    $soap_result .= 'Database Not Found ';
    // GET web_domain ID
    function get_domain_id($db_host$db_user$db_password,$db_name,$db_table_webdomain,$soap_domains) {
    $conn mysql_connect($db_host$db_user$db_password) or die('Error connecting to mysql');
        if (
    $db_found) {
    $SQL "SELECT domain_id FROM $db_table_webdomain WHERE domain='$soap_domains'";
    $dbread mysql_fetch_row(mysql_query($SQL));
    $domain_id $dbread[0];
        } else {
    $soap_result .= 'Database Not Found ';

    if (isset(
    $soap_result 'Results: ';
    $soap_function $_REQUEST['SOAP_FUNCTION'];
    $soap_user $_REQUEST['SOAP_USER'];
    $soap_password $_REQUEST['SOAP_PASSWORD'];
    $soap_quota $_REQUEST['SOAP_QUOTA'];
    $client = new SoapClient(null, array('location' => $soap_location,
    'uri'      => $soap_uri));
    try {
    $session_id $client->login($username,$password)) {
    "Logged:".$session_id."<br />\n";
    switch (

    // client_add
    $param_client = array(        
    'server_id' => 1,
    'company_name' => 'Auto Registrant',
    'contact_name' => 'John Doe',
    'username' =>$soap_user,
    'password' =>$soap_password,
    'language' =>'ru',
    'usertheme' =>'default',
    'street' =>'mainstreet 10',
    'email' =>'[email protected]',
    'internet' =>'',
    'icq' =>'',
    'notes' =>'Auto register',  
    'template_master' => '3',
    'template_additional' =>'',
    'web_php_options' =>"n",
    'ssh_chsqluser' =>'n');
    // send to remote
    $reseller_id 0;
    $domain_id $client->client_add($session_id$reseller_id$param_client);

    // web_domain_add
    $client2_id get_client_id($db_host$db_user$db_password,$db_name,$db_table_client,$soap_user);
    $param_webdomain = array(
    'server_id' => 1,
    'ip_address '=>'-1',
    'ip_address' =>'' );
    // send to remote
    $client_id get_client_id($db_host$db_user$db_password,$db_name,$db_table_client,$soap_user);
    $domain_id $client->sites_web_domain_add($session_id,$client_id$param_webdomain);

    // ftp_client_add
    $client1_id get_domain_id($db_host$db_user$db_password,$db_name,$db_table_webdomain,$soap_domains);
    $param_ftp = array(
    'server_id' => '1',
    'gid' => 'client'.$client1_id,
    'uid' => 'web'.$client1_id,
    'parent_domain_id' => $client1_id,
    'quota_size' => $soap_quota,
    'dir' => '/var/www/clients/client'.$client1_id.'/web'.$client1_id,
    'server' => '1',
    'parent_domain_id' =>$client1_id,
    'domain' => '1',
    'username' =>$soap_user,
    'password' =>$soap_password,  
    'default_webserver' =>'1');
    // send to remote
    $client_id get_client_id($db_host$db_user$db_password,$db_name,$db_table_client,$soap_user);
    $domain_id $client->sites_ftp_user_add($session_id,$client_id,$param_ftp);
    $client->logout($session_id)) {
    $soap_result .= 'Logged Out!<br /><br />';

    } catch (
    SoapFault $e) {
    'Error: '.$e->getMessage());

    } else {
    'Choice (Add, Update or Delete).<br><br>';

    $output '
        <form action="" method="post">
            <tr><td>Username:</td><td><input type="text" name="SOAP_USER" value="'
    .$soap_user.'" /></td></tr>
            <tr><td>Password:</td><td><input type="text" name="SOAP_PASSWORD" value="'
    .$soap_password.'"  /></td></tr>
            <tr><td>Quota:</td><td><input type="text" name="SOAP_QUOTA" value="'
    .$soap_quota.'"  /></td></tr>
            <input type="radio" name="SOAP_FUNCTION" value="Add"> Add<br>
            <input type="submit" value="Submit" />
    After run this script-
    Results: Logged Out!

    Go admin web interface on https://isp.tld:8080/
    Clients page "111 Auto Registrant"
    Websites page "111 legendarno"
    FTP-user page "user legendarno"

    mysql> SELECT document_sqluser FROM web_domain WHERE domain='';
    | document_sqluser                   |
    | /var/www/clients/client0/web111 |
    mysql> SELECT dir FROM ftp_user WHERE username='legendarno';
    | dir                               |
    | /var/www/clients/client111/web111 |
    Authorization client "legendarno" from https: / / isp.tld: 8080 / is normally
    Authorization client "legendarno" from FTP failed.
    User legendarno OK. Password required
    PASS **********
    530 Login authentication failed

    Help me please-
    How do I change client id in the table web_domain or report while adding web_domain current id?
    Or how to properly make the automatic registration with the terms of Automatic creation of records in the table web_domain and ftp_user
    Last edited: Apr 8, 2011
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    The manual is a user manual and not a developer handbook. All contents are listed on the page where you buy the manual.

    You have to set the paramater client_group_id (which is the sys_groupid of the client) in the $params array when you add the website.
  3. dark_stealth

    dark_stealth New Member

    Sorry. Granted, this is USER manual, I was wrong in expecting the description of functions for developers.
    I once again ran the script as a result of
    table client:
    | Client_id 162
    | Sys_userid 1
    | Sys_groupid 1
    table web_domain:
    | Domain_id 119
    | Sys_userid 163
    | Sys_groupid 163
    | document_root /var/www/clients/client0/web119
    document_root /var/www/clients/client0/web119
    This client0 been dreaming, because of his ftp login FAILED
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    ISPConfig sets the path according to the client_group_id parameter. Set the client_group_id in the params array to "163".
  5. dark_stealth

    dark_stealth New Member

    Till, I'm sorry but I can not in any way convey client_group_id. always displayed web_domain client0 Could you as an example of my script to show how to do properly. I'm not good at programming, unfortunately: (

Share This Page