[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/modules/ping/ -> ping.module (source)

   1  <?php
   2  // $Id: ping.module,v 1.52.2.1 2009/11/06 07:46:22 goba Exp $
   3  
   4  /**
   5   * @file
   6   * Alerts other sites that your site has been updated.
   7   */
   8  
   9  /**
  10   * Implementation of hook_help().
  11   */
  12  function ping_help($path, $arg) {
  13    switch ($path) {
  14      case 'admin/help#ping':
  15        $output = '<p>'. t('The ping module is useful for notifying interested sites that your site has changed. It automatically sends notifications, or "pings", to the <a href="@external-http-pingomatic-com">pingomatic</a> service about new or updated content. In turn, <a href="@external-http-pingomatic-com">pingomatic</a> notifies other popular services, including weblogs.com, Technorati, blo.gs, BlogRolling, Feedster.com, and Moreover.', array('@external-http-pingomatic-com' => 'http://pingomatic.com/')) .'</p>';
  16        $output .= '<p>'. t('The ping module requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))) .'</p>';
  17        $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@ping">Ping module</a>.', array('@ping' => 'http://drupal.org/handbook/modules/ping/')) .'</p>';
  18        return $output;
  19    }
  20  }
  21  
  22  /**
  23   * Implementation of hook_cron().
  24   *
  25   * Fire off notifications of updates to remote sites.
  26   */
  27  function ping_cron() {
  28    global $base_url;
  29  
  30    if (variable_get('site_name', 0)) {
  31      $cron_last = variable_get('cron_last', time());
  32      // Query changed first since usually changed >= created.
  33      if (db_result(db_query('SELECT COUNT(*) FROM {node} WHERE status = 1 AND changed > %d', $cron_last)) || db_result(db_query('SELECT COUNT(*) FROM {node} WHERE status = 1 AND created > %d', $cron_last))) {
  34        _ping_notify(variable_get('site_name', ''), $base_url);
  35      }
  36    }
  37  }
  38  
  39  /**
  40   * Call hook_ping() in all modules to notify remote sites that there is
  41   * new content at this one.
  42   */
  43  function _ping_notify($name, $url) {
  44    module_invoke_all('ping', $name, $url);
  45  }
  46  
  47  /**
  48   * Implementation of hook_ping().
  49   *
  50   * Notifies pingomatic.com, blo.gs, and technorati.com of changes at this site.
  51   */
  52  function ping_ping($name = '', $url = '') {
  53  
  54    $result = xmlrpc('http://rpc.pingomatic.com', 'weblogUpdates.ping', $name, $url);
  55  
  56    if ($result === FALSE) {
  57      watchdog('directory ping', 'Failed to notify pingomatic.com (site).', array(), WATCHDOG_WARNING);
  58    }
  59  }
  60  
  61  


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7