2002-11-01 09:31:59 +00:00
<?php
// $Id$
2004-08-21 06:42:38 +00:00
/**
* @file
* Alerts other sites that your site has been updated.
*/
2004-05-18 19:15:14 +00:00
/**
* Implementation of hook_help().
*/
function ping_help($section) {
2003-12-28 10:47:33 +00:00
switch ($section) {
2003-10-09 18:53:22 +00:00
case 'admin/help#ping':
2006-05-07 00:08:36 +00:00
$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>';
2005-11-01 10:17:34 +00:00
$output .= '<p>'. t('The ping module requires <code>cron</code> or a similar periodic job scheduler to be enabled.') .'</p>';
$output .= t('<p>You can:</p>
<ul>
<li> enable or disable the ping module at <a href="%admin-modules">administer >> modules</a>.</li>
<li>run your cron job at your sites <a href="%file-cron">cron page</a>.</li>
<li>read about <a href="%external-http-drupal-org-node-23714">configuring cron jobs</a>.</li>
</ul></p>
', array('%admin-modules' => url('admin/modules'), '%file-cron' => 'cron.php', '%external-http-drupal-org-node-23714' => 'http://drupal.org/node/23714'));
2006-02-21 18:46:54 +00:00
$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>';
2005-11-01 10:17:34 +00:00
return $output;
2004-06-18 15:04:37 +00:00
case 'admin/modules#description':
2006-04-11 11:19:59 +00:00
return t('Alerts other sites when your site has been updated.');
2003-08-21 20:50:03 +00:00
}
2002-11-01 09:31:59 +00:00
}
2004-05-18 19:15:14 +00:00
/**
* Implementation of hook_cron().
*
* Fire off notifications of updates to remote sites.
*/
2002-11-01 09:31:59 +00:00
function ping_cron() {
2003-03-07 06:37:30 +00:00
global $base_url;
2004-05-18 19:15:14 +00:00
if (variable_get('site_name', 0) && variable_get('site_slogan', 0)) {
2005-12-31 14:18:22 +00:00
if (db_num_rows(db_query("SELECT nid FROM {node} WHERE status = 1 AND moderate = 0 AND (created > '". variable_get('cron_last', time()) ."' OR changed > '". variable_get('cron_last', time()) ."')"), 1)) {
2004-05-18 19:15:14 +00:00
_ping_notify(variable_get('site_name', '') .' - '. variable_get('site_slogan', ''), $base_url);
2002-11-01 09:31:59 +00:00
}
}
}
2004-05-18 19:15:14 +00:00
/**
* Call hook_ping() in all modules to notify remote sites that there is
* new content at this one.
*/
2002-11-01 09:31:59 +00:00
function _ping_notify($name, $url) {
2004-05-18 19:15:14 +00:00
module_invoke_all('ping', $name, $url);
2002-11-01 09:31:59 +00:00
}
2004-05-18 19:15:14 +00:00
/**
* Implementation of hook_ping().
*
2004-12-27 12:27:02 +00:00
* Notifies pingomatic.com, blo.gs, and technorati.com of changes at this site.
2004-05-18 19:15:14 +00:00
*/
function ping_ping($name = '', $url = '') {
2004-08-04 20:36:24 +00:00
2005-07-13 18:46:15 +00:00
$result = xmlrpc('http://rpc.pingomatic.com', 'weblogUpdates.ping', $name, $url);
2004-11-06 12:56:05 +00:00
2005-07-13 18:46:15 +00:00
if ($result === FALSE) {
2005-01-09 09:22:40 +00:00
watchdog('directory ping', t('Failed to notify pingomatic.com (site).'), WATCHDOG_WARNING);
2004-11-06 12:56:05 +00:00
}
2002-11-01 09:31:59 +00:00
}
2004-11-06 12:56:05 +00:00
2005-08-25 21:14:17 +00:00