Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Developers' Forum

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #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
  #2  
Old 8th April 2011, 13:04
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 37,015
Thanks: 840
Thanked 5,652 Times in 4,461 Posts
Default

Quote:
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.
The manual is a user manual and not a developer handbook. All contents are listed on the page where you buy the manual.

Quote:
Help me please-
How do I change client id in the table web_domain or report while adding web_domain current id?
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.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #3  
Old 8th April 2011, 14:53
dark_stealth dark_stealth is offline
Junior Member
 
Join Date: Mar 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by till View Post
The manual is a user manual and not a developer handbook. All contents are listed on the page where you buy the manual.
Sorry. Granted, this is USER manual, I was wrong in expecting the description of functions for developers.
Quote:
Originally Posted by till View Post
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.
I once again ran the script as a result of
HTML Code:
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
Reply With Quote
  #4  
Old 8th April 2011, 15:01
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 37,015
Thanks: 840
Thanked 5,652 Times in 4,461 Posts
Default

Quote:
document_root /var/www/clients/client0/web119
This client0 been dreaming, because of his ftp login FAILED
ISPConfig sets the path according to the client_group_id parameter. Set the client_group_id in the params array to "163".
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #5  
Old 8th April 2011, 16:30
dark_stealth dark_stealth is offline
Junior Member
 
Join Date: Mar 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

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: (
Reply With Quote
Reply

Bookmarks

Tags
remoting framework

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Freebsd 6.1 support misterm Installation/Configuration 10 9th April 2009 10:29
Problem with Clamav + samba configuration wammy28 HOWTO-Related Questions 8 31st January 2009 20:12
Cacti and ISPConfig: Monitoring Tool VMartins Tips/Tricks/Mods 11 9th August 2008 19:37
Add Users with Remoting Framework dayjahone General 4 6th July 2007 12:21
Junk mail and spamassassin... sthompson Installation/Configuration 4 27th December 2006 17:11


All times are GMT +2. The time now is 23:09.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.