drupal_client_ping

Versions
4.7 – 5
drupal_client_ping($client, $system)

Callback function from drupal_xmlrpc() called when another site pings this one.

Code

modules/drupal.module, line 164

<?php
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(db_rewrite_sql("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' => theme('placeholder', $client['name']), '%link' => theme('placeholder', $client['link']))), WATCHDOG_NOTICE, '<a href="'. check_url($client['link']) .'">view</a>');

    return TRUE;
  }
  else {
    return 0;
  }

}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.