From a0ddc1af74d04b7c95968fcab43d4de727bae5ad Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 16 Dec 2001 11:44:41 +0000 Subject: - Added new feature. Explanation will follow on the mailing list. --- modules/drupal/drupal.module | 92 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) (limited to 'modules/drupal') diff --git a/modules/drupal/drupal.module b/modules/drupal/drupal.module index d69351083..8867e81b3 100644 --- a/modules/drupal/drupal.module +++ b/modules/drupal/drupal.module @@ -1,5 +1,97 @@ getparam(0); + $link = strip_tags($argument->scalarval()); + $argument = $arguments->getparam(1); + $name = 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: + */ + + if ($link && $name && $mail && $slogan && $mission) { + db_query("DELETE FROM directory WHERE link = '". check_query($link) ."'"); + db_query("INSERT INTO directory (link, name, mail, slogan, mission, timestamp) VALUES ('". check_query($link) ."', '". check_query($name) ."', '". check_query($mail) ."', '". check_query($slogan) ."', '". check_query($mission) ."', '". time() ."')"); + + watchdog("message", "directory: ping from '$name' ($link)"); + + return new xmlrpcresp(new xmlrpcval(1, "int")); + } + else { + return new xmlrpcresp(new xmlrpcval(0, "int")); + } + +} + +function drupal_directory_page() { + $result = db_query("SELECT * FROM directory ORDER BY name"); + + while ($site = db_fetch_object($result)) { + $output .= "link\">$site->name - $site->slogan
$site->mission

"; + } + + return $output; +} + +function drupal_xmlrpc() { + return array("drupal.site.ping" => array("function" => "drupal_directory_ping")); +} + +function drupal_notify($server) { + + $url = parse_url($server); + + $client = new xmlrpc_client($url["path"], $url["host"], 80); + + $message = new xmlrpcmsg("drupal.site.ping", array(new xmlrpcval(path_uri(), "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 || $result->faultCode()) { + watchdog("error", "failed to notify '". $url["host"] ."' at '". $url["path"] ."': ". $result->faultString()); + } + +} + function drupal_info($field = 0) { $info["name"] = "Drupal"; $info["protocol"] = "XML-RPC"; -- cgit v1.2.3