ping.module in Drupal 5
Same filename and directory in other branches
Alerts other sites that your site has been updated.
File
modules/ping/ping.moduleView source
<?php
/**
* @file
* Alerts other sites that your site has been updated.
*/
/**
* Implementation of hook_help().
*/
function ping_help($section) {
switch ($section) {
case 'admin/help#ping':
$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>';
$output .= '<p>' . t('The ping module requires <code>cron</code> or a similar periodic job scheduler to be enabled.') . '</p>';
$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>';
return $output;
}
}
/**
* Implementation of hook_cron().
*
* Fire off notifications of updates to remote sites.
*/
function ping_cron() {
global $base_url;
if (variable_get('site_name', 0)) {
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()) . "')"))) {
_ping_notify(variable_get('site_name', ''), $base_url);
}
}
}
/**
* Call hook_ping() in all modules to notify remote sites that there is
* new content at this one.
*/
function _ping_notify($name, $url) {
module_invoke_all('ping', $name, $url);
}
/**
* Implementation of hook_ping().
*
* Notifies pingomatic.com, blo.gs, and technorati.com of changes at this site.
*/
function ping_ping($name = '', $url = '') {
$result = xmlrpc('http://rpc.pingomatic.com', 'weblogUpdates.ping', $name, $url);
if ($result === FALSE) {
watchdog('directory ping', t('Failed to notify pingomatic.com (site).'), WATCHDOG_WARNING);
}
}
Functions
Name | Description |
---|---|
ping_cron | Implementation of hook_cron(). |
ping_help | Implementation of hook_help(). |
ping_ping | Implementation of hook_ping(). |
_ping_notify | Call hook_ping() in all modules to notify remote sites that there is new content at this one. |