function drupal_client_ping in Drupal 5
Same name and namespace in other branches
- 4 modules/drupal.module \drupal_client_ping()
Callback function from drupal_xmlrpc() called when another site pings this one.
1 string reference to 'drupal_client_ping'
- drupal_xmlrpc in modules/
drupal/ drupal.module - Implementation of hook_xmlrpc().
File
- modules/
drupal/ drupal.module, line 165 - Lets users log in using a Drupal ID and can notify a central server about your site.
Code
function drupal_client_ping($client, $system) {
/*
** Parse our parameters:
*/
foreach (array(
'link',
'name',
'mail',
'slogan',
'mission',
) as $key) {
$client[$key] = strip_tags($client[$key]);
}
/*
** Update the data in our database and send back a reply:
*/
if ($client['link'] && $client['name'] && $client['mail'] && $client['slogan'] && $client['mission']) {
$result = db_query("SELECT cid FROM {client} WHERE link = '%s'", $client['link']);
if (db_num_rows($result)) {
$record = db_fetch_object($result);
$client['cid'] = $record->cid;
// We have an existing record.
db_query("UPDATE {client} SET link = '%s', name = '%s', mail = '%s', slogan = '%s', mission = '%s', users = %d, nodes = %d, version = '%s', changed = '%s' WHERE cid = %d", $client['uid'], $client['link'], $client['name'], $client['mail'], $client['slogan'], $client['mission'], $client['users'], $client['nodes'], $client['version'], time(), $client['cid']);
}
else {
$client['cid'] = db_next_id('{client}_cid');
db_query("INSERT INTO {client} (cid, link, name, mail, slogan, mission, users, nodes, version, created, changed) VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $client['cid'], $client['link'], $client['name'], $client['mail'], $client['slogan'], $client['mission'], $client['users'], $client['nodes'], $client['version'], time(), time());
}
if (is_array($system)) {
db_query("DELETE FROM {client_system} WHERE cid = %d", $client['cid']);
foreach ($system as $item) {
db_query("INSERT INTO {client_system} (cid, name, type) VALUES (%d, '%s', '%s')", $client['cid'], $item['name'], $item['type']);
}
}
watchdog('client ping', t('Ping from %name (%link).', array(
'%name' => $client['name'],
'%link' => $client['link'],
)), WATCHDOG_NOTICE, '<a href="' . check_url($client['link']) . '">view</a>');
return TRUE;
}
else {
return 0;
}
}