View Single Post
  #1  
Old 8th April 2011, 09:27
dark_stealth dark_stealth is offline
Junior Member
 
Join Date: Mar 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Automatic registration of users via a remoting framework

Hi.
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: 3.0.3.2
In this forum, found the script and modified it a bit :
PHP Code:
<?php

// Configuration values
$username 'remote_user';
$password 'coolPassWORd';
$def_domain'hosting.tld';
$db_user='sqluser';
$db_password='coolPassWORd';
$db_host='localhost';
$db_name='dbispconfig';
$soap_location 'https://isp.tld:8080/remote/index.php';
$soap_uri 'https://isp.tld:8080/remote/';
$db_table_ftp='ftp_user';
$db_table_client='client';
$db_table_webdomain='web_domain';
$soap_domains'legendarno.hosting.tld';
// 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');
    
$db_found=mysql_select_db($db_name);
    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 ';
    }
    
mysql_close($conn);
    return 
$primary_id_ftp;
}
// 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');
    
$db_found=mysql_select_db($db_name);
    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 ';
    }
    
mysql_close($conn);
    return 
$primary_id_client;
}
// 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');
    
$db_found=mysql_select_db($db_name);
    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 ';
    }
    
mysql_close($conn);
    return 
$domain_id;
}

if (isset(
$_REQUEST['SOAP_FUNCTION'])) {
    
$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 {
    if(
$session_id $client->login($username,$password)) {
                    echo 
"Logged:".$session_id."<br />\n";
}
switch (
$soap_function){
    case 
'Add':

// 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' =>'mail@domain.com',
'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,
'domain_id'=>'1',
'system_user'=>'-1',
'system_group'=>'client'.$client2_id,
'domain'=>$soap_user.'.'.$def_domain,
'type'=>'vhost',
'domain_id'=>'',
'document_sqluser'=>'-1',
'vhost_type'=>'name',
'hd_quota'=>'1234',
'active'=>'y',
'traffic_quota'=>'100',
'allow_override'=>'All',
'php_open_basedir'=>'-1',
'errordocs'=>'0',
'parent_domain_id'=>'0',
'ip_address '=>'-1',
'cgi'=>'NONE',
'ssi'=>'NONE',
'suexec'=>'NONE',
'php'=>'NONE',
'ruby'=>'NONE',
'is_subdomainwww'=>'NONE',
'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,  
'active'=>'y',
'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);
break;
}
    if(
$client->logout($session_id)) {
        
$soap_result .= 'Logged Out!<br /><br />';
        }

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

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

$output '
    <form action="http://reg.hosting.tld/reg/index-ftp9.php" method="post">
        <table><tr><td>
        <table>
        <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>
        </table>
        </td><td>
        <input type="radio" name="SOAP_FUNCTION" value="Add"> Add<br>
        <input type="submit" value="Submit" />
        </td></tr></table>
    </form>'
;
print 
$output;
?>
After run this script-
Logged:7feda79f9ee5e739f9662a84ca80d1e1
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"

HTML Code:
mysql> SELECT document_sqluser FROM web_domain WHERE domain='legendarno.hosting.tld';
+---------------------------------+
| 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 by dark_stealth; 8th April 2011 at 10:13.
Reply With Quote
Sponsored Links