2 // $Id: ping.module,v 1.45 2006/11/21 20:14:18 dries Exp $
6 * Alerts other sites that your site has been updated.
10 * Implementation of hook_help().
12 function ping_help($section) {
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 (called "pings") to the <a href="@external-http-pingomatic-com">pingomatic</a> service to tell it that your site has changed. In turn pingomatic will ping other services such as weblogs.com, Technorati, blo.gs, BlogRolling, Feedster.com, Moreover, etc.', array('@external-http-pingomatic-com' => 'http://pingomatic.com/')) .'</p>';
16 $output .= '<p>'. t('The ping module requires <code>cron</code> or a similar periodic job scheduler to be enabled.') .'</p>';
17 $output .= '<p>'. t('For more information please read the configuration and customization handbook <a href="@ping">Ping page</a>.', array('@ping' => 'http://drupal.org/handbook/modules/ping/')) .'</p>';
23 * Implementation of hook_cron().
25 * Fire off notifications of updates to remote sites.
27 function ping_cron() {
30 if (variable_get('site_name', 0)) {
31 if (db_num_rows(db_query("SELECT nid FROM {node} WHERE status = 1 AND (created > '". variable_get('cron_last', time()) ."' OR changed > '". variable_get('cron_last', time()) ."')"))) {
32 _ping_notify(variable_get('site_name', ''), $base_url);
38 * Call hook_ping() in all modules to notify remote sites that there is
39 * new content at this one.
41 function _ping_notify($name, $url) {
42 module_invoke_all('ping', $name, $url);
46 * Implementation of hook_ping().
48 * Notifies pingomatic.com, blo.gs, and technorati.com of changes at this site.
50 function ping_ping($name = '', $url = '') {
52 $result = xmlrpc('http://rpc.pingomatic.com', 'weblogUpdates.ping', $name, $url);
54 if ($result === FALSE) {
55 watchdog('directory ping', t('Failed to notify pingomatic.com (site).'), WATCHDOG_WARNING);