Skip to content
Snippets Groups Projects
Commit 1a81546e authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Backported chx's XML-RPC library.

parent d2b7d7c5
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
<?php <?php
// by Edd Dumbill (C) 1999-2001
// <edd@usefulinc.com>
// $Id$
// Copyright (c) 1999,2000,2001 Edd Dumbill. function xmlrpc_server($callbacks) {
// All rights reserved. $xmlrpc_server = new stdClass();
// $defaults = array(
// Redistribution and use in source and binary forms, with or without 'system.multicall' => 'xmlrpc_server_multicall',
// modification, are permitted provided that the following conditions array(
// are met: 'system.methodSignature',
// 'xmlrpc_server_method_signature',
// * Redistributions of source code must retain the above copyright array('array', 'string'),
// notice, this list of conditions and the following disclaimer. 'Returns an array describing the return type and required parameters of a method'
// ),
// * Redistributions in binary form must reproduce the above array(
// copyright notice, this list of conditions and the following 'system.getCapabilities',
// disclaimer in the documentation and/or other materials provided 'xmlrpc_server_get_capabilities',
// with the distribution. array('struct'),
// 'Returns a struct describing the XML-RPC specifications supported by this server'
// * Neither the name of the "XML-RPC for PHP" nor the names of its ),
// contributors may be used to endorse or promote products derived array(
// from this software without specific prior written permission. 'system.listMethods',
// 'xmlrpc_server_list_methods',
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS array('array'),
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 'Returns an array of available methods on this server'),
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS array(
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 'system.methodHelp',
// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 'xmlrpc_server_method_help',
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES array('string', 'string'),
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 'Returns a documentation string for the specified method')
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) );
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // the order matters in the next line. which is the best?
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) foreach (array_merge($defaults, (array)$callbacks) as $key => $callback) {
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED // we could check for is_array($callback)
// OF THE POSSIBILITY OF SUCH DAMAGE. if (is_int($key)) {
$method = $callback[0];
// XML RPC Server class $xmlrpc_server->callbacks[$method] = $callback[1];
// requires: xmlrpc.inc $xmlrpc_server->signatures[$method] = $callback[2];
$xmlrpc_server->help[$method] = $callback[3];
}
else {
$xmlrpc_server->callbacks[$key] = $callback;
$xmlrpc_server->signatures[$key] = '';
$xmlrpc_server->help[$key] = '';
}
}
// listMethods: either a string, or nothing $data = file_get_contents('php://input');
$_xmlrpcs_listMethods_sig=array(array($xmlrpcArray, $xmlrpcString), if (!$data) {
array($xmlrpcArray)); die('XML-RPC server accepts POST requests only.');
$_xmlrpcs_listMethods_doc='This method lists all the methods that the XML-RPC server knows how to dispatch';
function _xmlrpcs_listMethods($server, $m) {
global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
$v=new xmlrpcval();
$dmap=$server->dmap;
$outAr=array();
for(reset($dmap); list($key, $val)=each($dmap); ) {
$outAr[]=new xmlrpcval($key, "string");
} }
$dmap=$_xmlrpcs_dmap; $xmlrpc_server->message = xmlrpc_message($data);
for(reset($dmap); list($key, $val)=each($dmap); ) { if (!xmlrpc_message_parse($xmlrpc_server->message)) {
$outAr[]=new xmlrpcval($key, "string"); xmlrpc_server_error(-32700, t('parse error. not well formed'));
} }
$v->addArray($outAr); if ($xmlrpc_server->message->messagetype != 'methodCall') {
return new xmlrpcresp($v); xmlrpc_server_error(-32600, t('server error. invalid xml-rpc. not conforming to spec. Request must be a method_call'));
}
$_xmlrpcs_methodSignature_sig=array(array($xmlrpcArray, $xmlrpcString));
$_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)';
function _xmlrpcs_methodSignature($server, $m) {
global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
$methName=$m->getParam(0);
$methName=$methName->scalarval();
if (ereg("^system\.", $methName)) {
$dmap=$_xmlrpcs_dmap; $sysCall=1;
} else {
$dmap=$server->dmap; $sysCall=0;
} }
// print "<!-- ${methName} -->\n"; xmlrpc_server_set($xmlrpc_server);
if (isset($dmap[$methName])) { $result = xmlrpc_server_call($xmlrpc_server, $xmlrpc_server->message->methodname, $xmlrpc_server->message->params);
if ($dmap[$methName]["signature"]) { // Is the result an error?
$sigs=array(); if ($result->is_error) {
$thesigs=$dmap[$methName]["signature"]; xmlrpc_server_error($result);
for($i=0; $i<sizeof($thesigs); $i++) {
$cursig=array();
$inSig=$thesigs[$i];
for($j=0; $j<sizeof($inSig); $j++) {
$cursig[]=new xmlrpcval($inSig[$j], "string");
}
$sigs[]=new xmlrpcval($cursig, "array");
}
$r=new xmlrpcresp(new xmlrpcval($sigs, "array"));
} else {
$r=new xmlrpcresp(new xmlrpcval("undef", "string"));
}
} else {
$r=new xmlrpcresp(0,
$xmlrpcerr["introspect_unknown"],
$xmlrpcstr["introspect_unknown"]);
} }
return $r; // Encode the result
} $r = xmlrpc_value($result);
// Create the XML
$xml = '
<methodResponse>
<params>
<param>
<value>'.
xmlrpc_value_get_xml($r)
.'</value>
</param>
</params>
</methodResponse>
$_xmlrpcs_methodHelp_sig=array(array($xmlrpcString, $xmlrpcString)); ';
$_xmlrpcs_methodHelp_doc='Returns help text if defined for the method passed, otherwise returns an empty string'; // Send it
function _xmlrpcs_methodHelp($server, $m) { xmlrpc_server_output($xml);
global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap; }
$methName=$m->getParam(0); function xmlrpc_server_error($error, $message = false) {
$methName=$methName->scalarval(); // Accepts either an error object or an error code and message
if (ereg("^system\.", $methName)) { if ($message && !is_object($error)) {
$dmap=$_xmlrpcs_dmap; $sysCall=1; $error = xmlrpc_error($error, $message);
} else {
$dmap=$server->dmap; $sysCall=0;
}
// print "<!-- ${methName} -->\n";
if (isset($dmap[$methName])) {
if ($dmap[$methName]["docstring"]) {
$r=new xmlrpcresp(new xmlrpcval($dmap[$methName]["docstring"]),
"string");
} else {
$r=new xmlrpcresp(new xmlrpcval("", "string"));
}
} else {
$r=new xmlrpcresp(0,
$xmlrpcerr["introspect_unknown"],
$xmlrpcstr["introspect_unknown"]);
} }
return $r; xmlrpc_server_output(xmlrpc_error_get_xml($error));
} }
$_xmlrpcs_dmap=array( function xmlrpc_server_output($xml) {
"system.listMethods" => $xml = '<?xml version="1.0"?>'."\n". $xml;
array("function" => "_xmlrpcs_listMethods", header('Connection: close');
"signature" => $_xmlrpcs_listMethods_sig, header('Content-Length: '. strlen($xml));
"docstring" => $_xmlrpcs_listMethods_doc), header('Content-Type: text/xml');
"system.methodHelp" => header('Date: '.date('r'));
array("function" => "_xmlrpcs_methodHelp", echo $xml;
"signature" => $_xmlrpcs_methodHelp_sig, exit;
"docstring" => $_xmlrpcs_methodHelp_doc),
"system.methodSignature" =>
array("function" => "_xmlrpcs_methodSignature",
"signature" => $_xmlrpcs_methodSignature_sig,
"docstring" => $_xmlrpcs_methodSignature_doc)
);
$_xmlrpc_debuginfo="";
function xmlrpc_debugmsg($m) {
global $_xmlrpc_debuginfo;
$_xmlrpc_debuginfo=$_xmlrpc_debuginfo . $m . "\n";
} }
class xmlrpc_server { function xmlrpc_server_list_methods() {
var $dmap=array(); $xmlrpc_server = xmlrpc_server_get();
return array_keys($xmlrpc_server->callbacks);
function xmlrpc_server($dispMap, $serviceNow=1) { }
// dispMap is a despatch array of methods
// mapped to function names and signatures
// if a method
// doesn't appear in the map then an unknown
// method error is generated
$this->dmap=$dispMap;
if ($serviceNow) {
$this->service();
}
}
function serializeDebug() { function xmlrpc_server_set($xmlrpc_server = NULL) {
global $_xmlrpc_debuginfo; static $server;
if ($_xmlrpc_debuginfo!="") if (!isset($server)) {
return "<!-- DEBUG INFO:\n\n" . $server = $xmlrpc_server;
$_xmlrpc_debuginfo . "\n-->\n";
else
return "";
} }
return $server;
}
function service() { function xmlrpc_server_get() {
$r=$this->parseRequest(); return xmlrpc_server_set();
$payload="<?xml version=\"1.0\"?>\n" . }
$this->serializeDebug() .
$r->serialize();
Header("Content-Type: text/xml\r\nContent-Length: " .
strlen($payload));
print $payload;
}
function verifySignature($in, $sig) { function xmlrpc_server_multicall($methodcalls) {
for($i=0; $i<sizeof($sig); $i++) { // See http://www.xmlrpc.com/discuss/msgReader$1208
// check each possible signature in turn $return = array();
$cursig=$sig[$i]; $xmlrpc_server = xmlrpc_server_get();
if (sizeof($cursig)==$in->getNumParams()+1) { foreach ($methodcalls as $call) {
$itsOK=1; $method = $call['methodName'];
for($n=0; $n<$in->getNumParams(); $n++) { $params = $call['params'];
$p=$in->getParam($n); if ($method == 'system.multicall') {
// print "<!-- $p -->\n"; $result = xmlrpc_error(-32600, t('Recursive calls to system.multicall are forbidden'));
if ($p->kindOf() == "scalar") { } else {
$pt=$p->scalartyp(); $result = xmlrpc_server_call($xmlrpc_server, $method, $params);
} else { }
$pt=$p->kindOf(); if ($result->is_error) {
} $return[] = array(
// $n+1 as first type of sig is return type 'faultCode' => $result->code,
if ($pt != $cursig[$n+1]) { 'faultString' => $result->message
$itsOK=0; );
$pno=$n+1; $wanted=$cursig[$n+1]; $got=$pt; } else {
break; $return[] = $result;
}
}
if ($itsOK)
return array(1);
}
} }
return array(0, "Wanted ${wanted}, got ${got} at param ${pno})");
} }
return $return;
}
function parseRequest($data="") {
global $_xh;
global $xmlrpcerr, $xmlrpcstr, $xmlrpcerrxml, $_xmlrpcs_dmap;
function xmlrpc_server_get_capabilities() {
return array(
'xmlrpc' => array(
'specUrl' => 'http://www.xmlrpc.com/spec',
'specVersion' => 1
),
'faults_interop' => array(
'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
'specVersion' => 20010516
),
'system.multicall' => array(
'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
'specVersion' => 1
),
'introspection' => array(
'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
'specVersion' => 1
)
);
}
if ($data=="") { function xmlrpc_server_call($xmlrpc_server, $methodname, $args) {
$data=$GLOBALS["HTTP_RAW_POST_DATA"]; // Make sure it's in an array
if ($args && !is_array($args)) {
$args = array($args);
} }
$parser = drupal_xml_parser_create($data); // Over-rides default call method, adds signature check
if (!isset($xmlrpc_server->callbacks[$methodname])) {
$_xh[$parser]=array(); return xmlrpc_error(-32601, t('server error. requested method %methodname not specified.',array("%methodname" => $xmlrpc_server->message->methodname)));
$_xh[$parser]['st']=""; }
$_xh[$parser]['cm']=0; $method = $xmlrpc_server->callbacks[$methodname];
$_xh[$parser]['isf']=0; $signature = $xmlrpc_server->signatures[$methodname];
$_xh[$parser]['params']=array();
$_xh[$parser]['method']="";
// decompose incoming XML into request structure
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); $ok = true;
xml_set_element_handler($parser, "xmlrpc_se", "xmlrpc_ee"); if (is_array($signature)) {
xml_set_character_data_handler($parser, "xmlrpc_cd"); $return_type = array_shift($signature);
xml_set_default_handler($parser, "xmlrpc_dh"); // Check the number of arguments
if (!xml_parse($parser, $data, 1)) { if (count($args) != count($signature)) {
// return XML error as a faultCode return xmlrpc_error(-32602, t('server error. wrong number of method parameters'));
$r=new xmlrpcresp(0,
$xmlrpcerrxml+xml_get_error_code($parser),
sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($parser)),
xml_get_current_line_number($parser)));
xml_parser_free($parser);
} else {
xml_parser_free($parser);
$m=new xmlrpcmsg($_xh[$parser]['method']);
// now add parameters in
$plist="";
for($i=0; $i<sizeof($_xh[$parser]['params']); $i++) {
//print "<!-- " . $_xh[$parser]['params'][$i]. "-->\n";
$plist.="$i - " . $_xh[$parser]['params'][$i]. " \n";
$m->addParam(eval('return '. $_xh[$parser]['params'][$i] .';'));
}
// uncomment this to really see what the server's getting!
// xmlrpc_debugmsg($plist);
// now to deal with the method
$methName=$_xh[$parser]['method'];
if (ereg("^system\.", $methName)) {
$dmap=$_xmlrpcs_dmap; $sysCall=1;
} else {
$dmap=$this->dmap; $sysCall=0;
} }
if (isset($dmap[$methName]['function'])) { // Check the argument types
// dispatch if exists foreach ($signature as $key => $type) {
if (isset($dmap[$methName]['signature'])) { $arg = $args[$key];
$sr=$this->verifySignature($m, switch ($type) {
$dmap[$methName]['signature'] ); case 'int':
case 'i4':
if (is_array($arg) || !is_int($arg)) {
$ok = false;
}
break;
case 'base64':
case 'string':
if (!is_string($arg)) {
$ok = false;
}
break;
case 'boolean':
if ($arg !== false && $arg !== true) {
$ok = false;
}
break;
case 'float':
case 'double':
if (!is_float($arg)) {
$ok = false;
}
break;
case 'date':
case 'dateTime.iso8601':
if (!$arg->is_date) {
$ok = false;
}
break;
} }
if ( (!isset($dmap[$methName]['signature'])) if (!$ok) {
|| $sr[0]) { return xmlrpc_error(-32602, t('server error. invalid method parameters'));
$f = $dmap[$methName]['function'];
// if no signature or correct signature
if ($sysCall) {
$r = $f($this, $m);
} else {
$r = $f($m);
}
} else {
$r=new xmlrpcresp(0,
$xmlrpcerr["incorrect_params"],
$xmlrpcstr["incorrect_params"].": ". $sr[1]);
} }
} else {
// else prepare error response
$r=new xmlrpcresp(0,
$xmlrpcerr["unknown_method"],
$xmlrpcstr["unknown_method"]);
} }
} }
return $r; // It passed the test - run the "real" method call
if (!isset($xmlrpc_server->callbacks[$methodname])) {
return xmlrpc_error(-32601, t('server error. requested method %methodname does not exist.',array("%methodname" => $methodname)));
} }
function echoInput() { $method = $xmlrpc_server->callbacks[$methodname];
// Perform the callback and send the response
// a debugging routine: just echos back the input /*
// packet as a string value if (count($args) == 1) {
// If only one paramater just send that instead of the whole array
$args = $args[0];
}
*/
if (!function_exists($method)) {
return xmlrpc_error(-32601, t('server error. requested function %method does not exist.', array("%method" => $method)));
}
// Call the function
return call_user_func_array($method, $args);
}
$r=new xmlrpcresp; function xmlrpc_server_method_signature($xmlrpc_server, $methodname) {
$r->xv=new xmlrpcval( "'Aha said I: '" . $GLOBALS["HTTP_RAW_POST_DATA"], "string"); if (!isset($xmlrpc_server->callbacks[$methodname])) {
print $r->serialize(); return xmlrpc_error(-32601, t('server error. requested method %methodname not specified.', array("%methodname" => $methodname)));
}
if (!is_array($xmlrpc_server->signature[$methodname])) {
return xmlrpc_error(-32601, t('server error. requested method %methodname signature not specified.', array("%methodname" => $methodname)));
}
// We should be returning an array of types
$return = array();
foreach ($xmlrpc_server->signatures[$methodname] as $type) {
switch ($type) {
case 'string':
$return[] = 'string';
break;
case 'int':
case 'i4':
$return[] = 42;
break;
case 'double':
$return[] = 3.1415;
break;
case 'dateTime.iso8601':
$return[] = xmlrpc_date(time());
break;
case 'boolean':
$return[] = true;
break;
case 'base64':
$return[] =xmlrpc_base64('base64');
break;
case 'array':
$return[] = array('array');
break;
case 'struct':
$return[] = array('struct' => 'struct');
break;
}
} }
return $return;
}
function xmlrpc_server_method_help($xmlrpc_server, $method) {
return $xmlrpc_server->help[$method];
} }
?> ?>
\ No newline at end of file
...@@ -259,8 +259,8 @@ function blog_menu($may_cache) { ...@@ -259,8 +259,8 @@ function blog_menu($may_cache) {
'callback' => 'blog_page', 'callback' => 'blog_page',
'access' => user_access('access content'), 'access' => user_access('access content'),
'type' => MENU_SUGGESTED_ITEM); 'type' => MENU_SUGGESTED_ITEM);
$items[] = array('path' => 'blog/'. $user->uid, 'title' => t('my blog'), $items[] = array('path' => 'blog/'. $user->uid, 'title' => t('my blog'),
'access' => user_access('edit own blog'), 'access' => user_access('edit own blog'),
'type' => MENU_DYNAMIC_ITEM); 'type' => MENU_DYNAMIC_ITEM);
} }
......
This diff is collapsed.
...@@ -70,22 +70,15 @@ function drupal_cron() { ...@@ -70,22 +70,15 @@ function drupal_cron() {
/** /**
* Callback function from drupal_xmlrpc() called when another site pings this one. * Callback function from drupal_xmlrpc() called when another site pings this one.
*/ */
function drupal_directory_ping($arguments) { function drupal_directory_ping($link, $name, $mail, $slogan, $mission) {
/* /*
** Parse our parameters: ** Parse our parameters:
*/ */
$argument = $arguments->getparam(0); foreach (array('link', 'name', 'mail', 'slogan', 'mission') as $key) {
$link = strip_tags($argument->scalarval()); $$key = strip_tags($$key);
$argument = $arguments->getparam(1); }
$name = trim(strip_tags($argument->scalarval()));
$argument = $arguments->getparam(2);
$mail = strip_tags($argument->scalarval());
$argument = $arguments->getparam(3);
$slogan = strip_tags($argument->scalarval());
$argument = $arguments->getparam(4);
$mission = strip_tags($argument->scalarval());
/* /*
** Update the data in our database and send back a reply: ** Update the data in our database and send back a reply:
...@@ -97,10 +90,10 @@ function drupal_directory_ping($arguments) { ...@@ -97,10 +90,10 @@ function drupal_directory_ping($arguments) {
watchdog('directory ping', t('Ping from %name (%link).', array('%name' => theme('placeholder', $name), '%link' => theme('placeholder', $link))), WATCHDOG_NOTICE, '<a href="'. check_url($link) .'">view</a>'); watchdog('directory ping', t('Ping from %name (%link).', array('%name' => theme('placeholder', $name), '%link' => theme('placeholder', $link))), WATCHDOG_NOTICE, '<a href="'. check_url($link) .'">view</a>');
return new xmlrpcresp(new xmlrpcval(1, 'int')); return 1;
} }
else { else {
return new xmlrpcresp(new xmlrpcval(0, 'int')); return 0;
} }
} }
...@@ -127,7 +120,17 @@ function drupal_directory_page($sort = 'name') { ...@@ -127,7 +120,17 @@ function drupal_directory_page($sort = 'name') {
* Implementation of hook_xmlrpc(). * Implementation of hook_xmlrpc().
*/ */
function drupal_xmlrpc() { function drupal_xmlrpc() {
return array('drupal.site.ping' => array('function' => 'drupal_directory_ping'), 'drupal.login' => array('function' => 'drupal_login')); return array(
array(
'drupal.site.ping',
'drupal_directory_ping',
array('boolean', 'string', 'string', 'string', 'string', 'string'),
t('Handling ping request')),
array(
'drupal.login',
'drupal_login',
array('int', 'string', 'string'),
t('Logging into a drupal site')));
} }
/** /**
...@@ -136,16 +139,10 @@ function drupal_xmlrpc() { ...@@ -136,16 +139,10 @@ function drupal_xmlrpc() {
function drupal_notify($server) { function drupal_notify($server) {
global $base_url; global $base_url;
$url = parse_url($server); $result = xmlrpc($server, 'drupal.site.ping', $base_url, variable_get('site_name', ''), variable_get('site_mail', ''), variable_get('site_slogan', ''), variable_get('site_mission', ''));
$client = new xmlrpc_client($url['path'], $url['host'], 80);
$message = new xmlrpcmsg('drupal.site.ping', array(new xmlrpcval($base_url, 'string'), new xmlrpcval(variable_get('site_name', ''), 'string'), new xmlrpcval(variable_get('site_mail', ''), 'string'), new xmlrpcval(variable_get('site_slogan', ''), 'string'), new xmlrpcval(variable_get('site_mission', ''), 'string')));
$result = $client->send($message, 5); if ($result === FALSE) {
watchdog('directory ping', t('Failed to notify %server, error code: %errno, error message: %error_msg.', array('%server' => theme('placeholder', $server), '%errno' => theme('placeholder', xmlrpc_errno()), '%error_msg' => theme('placeholder', xmlrpc_error_msg()))), WATCHDOG_WARNING);
if (!$result || $result->faultCode()) {
watchdog('directory ping', t('Failed to notify %url at %path: %error.', array('%url' => theme('placeholder', $url['host']), '%path' => theme('placeholder', $url['path']), '%error' => theme('placeholder', $result->faultString()))), WATCHDOG_WARNING);
} }
} }
...@@ -169,19 +166,13 @@ function drupal_info($field = 0) { ...@@ -169,19 +166,13 @@ function drupal_info($field = 0) {
* Implementation of hook_auth(). * Implementation of hook_auth().
*/ */
function drupal_auth($username, $password, $server) { function drupal_auth($username, $password, $server) {
$result = xmlrpc('http://'. $server .'/xmlrpc.php', 'drupal.login', $username, $password);
$message = new xmlrpcmsg('drupal.login', array(new xmlrpcval($username, 'string'), new xmlrpcval($password, 'string'))); if ($result === FALSE) {
drupal_set_message(t('Error %code : %message', array('%code' => theme('placeholder', xmlrpc_errno()), '%message' => theme('placeholder', xmlrpc_error_msg()))), 'error');
// TODO remove hard coded Port 80 }
// TODO manage server/path such that HTTP_HOST/xml.rpc.php is not assumed else {
$client = new xmlrpc_client('/xmlrpc.php', $server, 80); return $result;
$result = $client->send($message, 5);
if ($result && !$result->faultCode()) {
$value = $result->value();
$login = $value->scalarval();
} }
return $login;
} }
/** /**
...@@ -209,17 +200,12 @@ function drupal_page_help() { ...@@ -209,17 +200,12 @@ function drupal_page_help() {
* *
* Remote clients are usually other Drupal instances. * Remote clients are usually other Drupal instances.
*/ */
function drupal_login($arguments) { function drupal_login($username, $password) {
$argument = $arguments->getparam(0);
$username = $argument->scalarval();
$argument = $arguments->getparam(1);
$password = $argument->scalarval();
if ($user = user_load(array('name' => $username, 'pass' => $password, 'status' => 1))) { if ($user = user_load(array('name' => $username, 'pass' => $password, 'status' => 1))) {
return new xmlrpcresp(new xmlrpcval($user->uid, 'int')); return $user->uid;
} }
else { else {
return new xmlrpcresp(new xmlrpcval(0, 'int')); return 0;
} }
} }
......
...@@ -57,12 +57,9 @@ function _ping_notify($name, $url) { ...@@ -57,12 +57,9 @@ function _ping_notify($name, $url) {
*/ */
function ping_ping($name = '', $url = '') { function ping_ping($name = '', $url = '') {
$feed = url('node/feed', NULL, NULL, TRUE); $result = xmlrpc('http://rpc.pingomatic.com', 'weblogUpdates.ping', $name, $url);
$client = new xmlrpc_client('/', 'rpc.pingomatic.com', 80);
$message = new xmlrpcmsg('weblogUpdates.ping', array(new xmlrpcval($name), new xmlrpcval($url)));
$result = $client->send($message);
if (!$result || $result->faultCode()) { if ($result === FALSE) {
watchdog('directory ping', t('Failed to notify pingomatic.com (site).'), WATCHDOG_WARNING); watchdog('directory ping', t('Failed to notify pingomatic.com (site).'), WATCHDOG_WARNING);
} }
} }
......
...@@ -11,8 +11,5 @@ ...@@ -11,8 +11,5 @@
include_once 'includes/xmlrpc.inc'; include_once 'includes/xmlrpc.inc';
include_once 'includes/xmlrpcs.inc'; include_once 'includes/xmlrpcs.inc';
$functions = module_invoke_all('xmlrpc'); xmlrpc_server(module_invoke_all('xmlrpc'));
$server = new xmlrpc_server($functions);
?> ?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment