View Full Version : Remoting Framework
dayjahone
25th October 2008, 06:12
I am trying to set up Remoting Framework so I can add users to a website remotely.
Do we still need to change the ISPConfig install script so it doesn't disable xml? If so, is there a way to do it retroactively as I've already installed ISPConfig 2.2.27.
I also installed remoting framework, added a user, checked all the little boxes under the user, and uncommented the function to add a reseller in the test.php file, and I when I browse to mydomain.com/test.php, I get Script end ... but it doesn't actually create a reseller.
Also, can you still use Remoting Framework to add users? I had this working a long time ago and used the following:
// Add User
$params = array ( 'sid' => $session_id,
'module' => 'web',
'function' => 'user_add',
'params' => array ( web_title => 'mydomain.com', // web_title or web_id
user_username => $new_username_field,
user_name => $first_name,
user_email => $new_username_field,
user_passwort => $new_password_field,
user_speicher => 0,
user_mailquota => 1000,
user_admin => 0
));
$user_id = $soap_client->call('service',$params);
if($err = $soap_client->getError()) die("Error: ".$err);
I tried it and again got "script end..." without it adding a user.
till
25th October 2008, 13:28
Do we still need to change the ISPConfig install script so it doesn't disable xml?
No.
Also, can you still use Remoting Framework to add users?
Yes.
Which version of the remoting framework did you install?
dayjahone
25th October 2008, 16:58
The latest and greatest: Remoting extension 4.2 Beta.
I seem to remember in an older version, "add users" was an option you can give your remoting access user. I don't see that anymore.
Any idea why I'm not getting an error, but it's not doing anything?
Thanks.
dayjahone
26th October 2008, 22:14
I just barely setup the system...installed hardy heron, ISPConfig 2.2.27, and remoting extension 4.2...
till
27th October 2008, 09:16
Which message do you get if you call the remoting URL, the one that you specified in the remoting client script, directly in a browser?
dayjahone
27th October 2008, 14:51
I didn't specify it, but, in the test.php file there is /remote/index.php. So, if I go to https://server1.mydomain.com:81/remote/index.php, I get the following:
Servermethod '' not defined in service ''
till
27th October 2008, 15:07
Ok, thats fine. But you must specify the complete URL in the test file.
dayjahone
27th October 2008, 15:24
So, in the test.php file, it should say:
$soap_client = new soap_client($server_url.'https://server1.mydomain.com:81/remote/index.php');
?
dayjahone
27th October 2008, 15:29
It gives me an error and says it cannot resolve the host. I looked back in the old file that worked on the old machine and it and it had the following, which is the same in the test.php file:
// Insert here your 42go Server
$server_url = "https://server1.mydomain.com:81";
// creating object for SoapClient
$soap_client = new soap_client($server_url.'/remote/index.php');
Any ideas where I'm going wrong?
till
27th October 2008, 15:33
This is fine. Just make sure that https://server1.mydomain.com:81 is correct. Also you need to install the openssl extension for php on the server that runs the client as you connect with https and not http.
dayjahone
27th October 2008, 15:39
I'm assuming it's correct. When I go to https://server1.mydomain.com:81, I can login.
What is the package name for openssh extension? Is this not part of the perfect setup? (I'm running Hardy Heron).
till
27th October 2008, 15:45
I'm assuming it's correct. When I go to https://server1.mydomain.com:81, I can login.
This does only mean that you installed ISPCOnfig correctly and not the the php which runs the client script has openssl compiled in. Where did you run the client script?
dayjahone
27th October 2008, 15:59
I'm sorry, but I don't know what you mean. This is the extent of what I have done:
1) Setup ISPConfig according to the perfect setup.
2) Created the website www.newdomain.com
2) Installed remoting plugin using the update manager.
3) added a user and a password and gave him all of the rights.
4) Edited the test.php file by adding
$server_url = "https://server1.mydomain.com:81";
and
$parameters = array('user' => 'user',
'pass' => 'password');
and uncommenting the function to create a reseller.
5) I then uploaded test.php, soap.lib.php, and auto.php to ftp.newdomain.com.
jnsc
27th October 2008, 16:13
I you are courageous and if this is not a production server, you may try to replace /home/admispconfig/ispconfig/lib/classes/ispconfig_soap.obj.php and soap.lib.php by the one I posted here http://bugtracker.ispconfig.org/index.php?do=details&task_id=270
dayjahone
27th October 2008, 17:24
It's not a production server, so I will try that...thanks...I'm a little surprised to run into problems when I'm not doing anything out of the ordinary.
dayjahone
28th October 2008, 06:08
Now, I get the following error:
Fatal error: Class 'soap_client' not found in /var/www/web1/web/test.php on line 18
So I did a search and replace for all every instance of soapclient and changed it to soap_client based on the first times I tried this and still no luck: http://howtoforge.com/forums/showthread.php?t=13855&highlight=uncaught+SoapFault+exception
I have no idea where it is at now. How can I uninstall the plug-in and start over...and is this advisable? Did I do anything wrong in my initial setup?
jnsc
28th October 2008, 10:00
Sorry, this was not explained very well in the bug report, you will have to replace soapclient, or now soap_client with nusoap_client.
dayjahone
28th October 2008, 14:50
Now I get the following error:
Error: Response not of type text/xml: text/html
jnsc
28th October 2008, 17:17
Ok, try to past this echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($soapclient->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($soapclient->response, ENT_QUOTES) . '</pre>';
in your test.php file
dayjahone
29th October 2008, 06:59
I wasn't sure where to put it, but here is what I have now in my test file:
<?php
/**
* ISPConfig Soap Connector
* Version 1.3
* (c) Projektfarm GmbH 2005
*
* This script requires PHP with CURL extension
*
*/
include("soap.lib.php");
// Insert here your 42go Server
$server_url = "https://server1.mydomain.com:81";
// creating object for nusoap_client
$nusoap_client = new nusoap_client($server_url.'/remote/index.php');
// Username and Password of the remoting user (not identical
// with the user to log into the web interface!)
$parameters = array('user' => 'roach',
'pass' => 'two');
// Login into 42go Server
$session_id = $nusoap_client->call('login',$parameters);
// Error Check
if($err = $nusoap_client->getError()) die("Error: ".$err);
/*
// Get Reseller List
$params = array ( 'sid' => $session_id,
'module' => 'reseller',
'function' => 'reseller_list',
'params' => '');
$reseller_list = $nusoap_client->call('service',$params);
// Error Check
if($err = $nusoap_client->getError()) die("Error: ".$err);
print_r($reseller_list);
*/
/*
// Get Reseller
$params = array ( 'sid' => $session_id,
'module' => 'reseller',
'function' => 'reseller_get',
'params' => array ( reseller_title => "Reseller1"));
$reseller = $nusoap_client->call('service',$params);
// Error Check
if($err = $nusoap_client->getError()) die("Error: ".$err);
print_r($reseller);
*/
// Adding a reseller
$params = array ( 'sid' => $session_id,
'module' => 'reseller',
'function' => 'reseller_add',
'params' => array ( reseller_title => 'Reseller1',
firma => 'Reseller4',
vorname => 'Jens',
limit_user => '50',
limit_disk => '1000',
limit_web => '10',
limit_domain => '10',
name => 'Jensen',
strasse => 'Hauptstr. 1',
plz => '12345',
ort => 'Hauptstadt',
telefon => '0511 5469766',
fax => '0511 9799655',
email => 'test@hostobserver.com',
internet => 'http://www.reseller4.tld',
reseller_user => 'reseller4',
reseller_passwort => 'huhu',
anrede => 'Herr', // Herr, Frau, Firma
land => 'Deutschland',
limit_httpd_include => '1',
limit_dns_manager => '1',
limit_domain_dns => '50',
province => 'Niedersachsen',
limit_shell_access => '0',
limit_cgi => '1',
limit_php => '1',
limit_ssi => '1',
limit_ftp => '1',
limit_mysql => '1',
limit_ssl => '1',
limit_anonftp => '1',
limit_standard_cgis => '1',
limit_wap => '1',
limit_error_pages => '1',
limit_frontpage => '0',
limit_mysql_anzahl_dbs => '100',
limit_slave_dns => '50',
client_salutatory_email_sender_email => '',
client_salutatory_email_sender_name => '',
client_salutatory_email_bcc => '',
client_salutatory_email_subject => '',
client_salutatory_email_message => '',
standard_index => '',
user_standard_index => ''
));
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
$reseller_id = $nusoap_client->call('service',$params);
if($err = $nusoap_client->getError()) die("Error: ".$err);
print_r($reseller_id);
...and...
I now get the same error:
Error: Response not of type text/xml: text/html
I put it at the very end...same error.
dayjahone
29th October 2008, 07:12
Which brand of Linux was remoting access written for? I don't mind re-installing everything...I just want it to work.
till
29th October 2008, 10:20
Which brand of Linux was remoting access written for?
For all linux distributions supported by ISPCOnfig.
jnsc
29th October 2008, 10:31
You shouhld set this debuging variables just after
$reseller_id = $nusoap_client->call('service',$params);
and if you still does not seen the debuging info, you should place it just after
// Login into 42go Server
$session_id = $nusoap_client->call('login',$parameters);
I just saw that you also renamed the $soapclient variable to $nusoap_client so the text sould also be
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($nusoap_client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($nusoap_client->response, ENT_QUOTES) . '</pre>';
I'm using the remoting framework with debian, and everything is working fine.
dayjahone
29th October 2008, 14:52
When I placed it under
// Login into 42go Server
$session_id = $nusoap_client->call('login',$parameters);
I got the following:
Request
POST /remote/index.php HTTP/1.0
Host: server1.mydomain.com:81
User-Agent: NuSOAP/0.7.3 (1.51)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: ""
Content-Length: 538
<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns3263:login xmlns:ns3263="http://tempuri.org"><user xsi:type="xsd:string">roach</user><pass xsi:type="xsd:string">two</pass></ns3263:login></SOAP-ENV:Body></SOAP-ENV:Envelope>
Response
HTTP/1.1 200 OK
Date: Wed, 29 Oct 2008 12:48:41 GMT
Server: Apache
X-Powered-By: PHP/5.2.6
Set-Cookie: PHPSESSID=607fd47af0588e1e48411ca5fd901b00; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: text/html
<br />
<b>Fatal error</b>: Class 'soap_server' not found in <b>/home/admispconfig/ispconfig/web/remote/index.php</b> on line <b>10</b><br />
Error: Response not of type text/xml: text/html
I was asking about which brand of Linux because I've done this twice, neither time doing anything custom and neither time deviating from the perfect setup for ubuntu, and both times, it hasn't worked too well. The first time took a lot of posts and tinkering to get it to work. I was wondering if it was smoother with other brands. I picked ubuntu because I thought it was most common.
jnsc
29th October 2008, 15:24
In /home/admispconfig/ispconfig/web/remote/index.php replace soap_server with nusoap_server
dayjahone
29th October 2008, 15:45
Here is that index.php file:
<?php
include("../../lib/config.inc.php");
include("../../lib/app.inc.php");
// Lade Soap Klasse
$go_api->uses_obj("soap");
$s = new nusoap_server;
$s->register('service');
$s->register('login');
$s->register('logout');
function login($user, $pass) {
global $go_api, $go_info;
// alte Sessions löschen
$go_api->db->query("DELETE FROM remote_session WHERE tstamp < '".(time() - 1800)."'");
if(empty($user) or empty($pass)) {
return new soap_fault('Client','','username or password empty.');
} else {
$user = addslashes($user);
$pass = addslashes($pass);
$user = $go_api->db->queryOneRecord("SELECT * FROM remote_user WHERE username = '$user' and passwort = md5('$pass')");
// Checke IP
if($user["ip"] != '') {
if($_SERVER['REMOTE_ADDR'] != $user["ip"]) return new soap_fault('Client','','IP-Address not allowed.');
}
if($user["ruserid"] > 0) {
$session["user"] = $user;
$session_data = addslashes(serialize($session));
$session_id = md5 (uniqid (rand()));
$go_api->db->query("INSERT INTO remote_session (sid,ruserid,data,tstamp) VALUES ('$session_id','".$user["ruserid"]."','$session_data','".time()."')");
return $session_id;
} else {
return new soap_fault('Client','','username or password incorrect.');
}
}
}
function logout($sid) {
global $go_api, $go_info;
if(empty($sid)) {
return new soap_fault('Client','','sid empty.');
} else {
$sid = addslashes($sid);
$sql = "DELETE FROM remote_session WHERE sid = '$sid'";
$go_api->db->query($sql);
return true;
}
}
function service($sid, $module, $function, $params) {
global $go_api, $go_info;
// prüfe ob session aktiv
$session = addslashes($session);
// lösche abgelaufene session records ( älter als 30 minuten)
$go_api->db->query("DELETE FROM remote_session WHERE tstamp < ".time() + 1800);
// hole Session
$session_record = $go_api->db->queryOneRecord("SELECT * FROM remote_session WHERE sid = '$sid'");
if(empty($session_record["data"])) {
return new soap_fault('Server','','session not available.');
} else {
$session = unserialize(stripslashes($session_record["data"]));
$ruserid = $session_record["ruserid"];
unset($session_record);
}
// allowed Modules
$allowed_modules[] = 'dns';
$allowed_modules[] = 'slave';
$allowed_modules[] = 'reseller';
$allowed_modules[] = 'kunde';
$allowed_modules[] = 'web';
// überprüfen ob modul und funktion übergeben wurden
// Checke IP
if($session["ip"] != '') {
if($_SERVER['REMOTE_ADDR'] != $session["ip"]) return new soap_fault('Client','','IP-Address not allowed.');
}
if(in_array($module,$allowed_modules)) {
$go_api->uses($module);
if(class_exists($module)) {
if(method_exists($go_api->$module,$function)) {
$retval = $go_api->$module->$function($session,$params);
if($go_api->$module->errorMessage == '') {
return $retval;
} else {
return new soap_fault('Client','',$go_api->$module->errorMessage);
}
} else {
return new soap_fault('Client','','function does not exist.');
}
} else {
return new soap_fault('Client','','moduleclass not available.');
}
} else {
return new soap_fault('Client','','module not allowed.');
}
}
$s->service($HTTP_RAW_POST_DATA);
?>
and here is the error I'm still getting:
Request
POST /remote/index.php HTTP/1.0
Host: server1.mydomain.com:81
User-Agent: NuSOAP/0.7.3 (1.51)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: ""
Content-Length: 538
<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns2885:login xmlns:ns2885="http://tempuri.org"><user xsi:type="xsd:string">roach</user><pass xsi:type="xsd:string">two</pass></ns2885:login></SOAP-ENV:Body></SOAP-ENV:Envelope>
Response
HTTP/1.1 200 OK
Date: Wed, 29 Oct 2008 13:44:42 GMT
Server: Apache
X-Powered-By: PHP/5.2.6
Set-Cookie: PHPSESSID=08d4043c1357535830f5f22b779bc9c6; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: text/html
<br />
<b>Fatal error</b>: Call to undefined function xml_parser_create() in <b>/home/admispconfig/ispconfig/lib/classes/ispconfig_soap.obj.php</b> on line <b>6409</b><br />
Error: Response not of type text/xml: text/html
jnsc
30th October 2008, 00:02
This looks like you didn't had libxml2-dev installed when you installed ISPConfig.
what is the output of sudo dpkg-query -W -f='${Status} ${Version}\n' libxml2-dev
If it's not installed you will need to install it
sudo apt-get install libxml2-dev and then either recompile ISPConfigs PHP with XML support, or, the simply method, reinstall ISPConfig. Since 2.2.24 ISPConfig detects if libxml2-dev is installed and if yes it enables XML in the bundled PHP.
dayjahone
30th October 2008, 06:24
Wow! So, it worked. The problem must have been that I installed the package after installing ISPConfig. So, I am still having problems with the form that I used on my old system. I am trying to check for a user and if the username doesn't exist, create it. If I just have the add user script, it works, but if it's already there, it doesn't give me an error, but echos the following:
Error: Response not of type text/xml: text/html
When I have both scripts, I get that error regardless and it doesn't create a user. Here are the functions I am using:
// Get a User
$params = array ( 'sid' => $session_id,
'module' => 'web',
'function' => 'user_get',
'params' => array ( user_username => $new_username_field // user_username or user_id
));
$user = $nusoap_client->call('service',$params);
if($err = $nusoap_client->getError()) die("Error: ".$err);
// Add User
$params = array ( 'sid' => $session_id,
'module' => 'web',
'function' => 'user_add',
'params' => array ( web_title => 'mydomain.com', // web_title or web_id
user_username => $new_username_field,
user_name => $first_name,
user_email => $new_username_field,
user_passwort => $new_password_field,
user_speicher => 0,
user_mailquota => 1000,
user_admin => 0
));
$user_id = $nusoap_client->call('service',$params);
if($err = $nusoap_client->getError()) die("Error: ".$err);
// 42go Server logout
$nusoap_client->call('logout',array('sid' => $session_id));
// Error Check
if($err = $nusoap_client->getError()) die("Error: ".$err);
This same code worked fine on the old system. I'm not sure what's wrong.
dayjahone
31st October 2008, 04:48
Jnsc,
C'mon, it's soooo close....Please help with this last little piece.
jnsc
31st October 2008, 10:30
Try also to use the debugging function in the case you get "Error: Response not of type text/xml: text/html"
dayjahone
4th December 2008, 06:55
I don't understand this, but I did a fresh install (for multiple reasons), uploaded the test file and it didn't work. I changed the remoting access user's password to something without numbers or any fancy stuff and it worked fine.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.