Mercurial > defr > drupal > core
comparison modules/ping/ping.module @ 1:c1f4ac30525a 6.0
Drupal 6.0
| author | Franck Deroche <webmaster@defr.org> |
|---|---|
| date | Tue, 23 Dec 2008 14:28:28 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:5a113a1c4740 | 1:c1f4ac30525a |
|---|---|
| 1 <?php | |
| 2 // $Id: ping.module,v 1.52 2007/12/19 17:45:42 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 if (db_result(db_query("SELECT COUNT(*) 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); | |
| 33 } | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 /** | |
| 38 * Call hook_ping() in all modules to notify remote sites that there is | |
| 39 * new content at this one. | |
| 40 */ | |
| 41 function _ping_notify($name, $url) { | |
| 42 module_invoke_all('ping', $name, $url); | |
| 43 } | |
| 44 | |
| 45 /** | |
| 46 * Implementation of hook_ping(). | |
| 47 * | |
| 48 * Notifies pingomatic.com, blo.gs, and technorati.com of changes at this site. | |
| 49 */ | |
| 50 function ping_ping($name = '', $url = '') { | |
| 51 | |
| 52 $result = xmlrpc('http://rpc.pingomatic.com', 'weblogUpdates.ping', $name, $url); | |
| 53 | |
| 54 if ($result === FALSE) { | |
| 55 watchdog('directory ping', 'Failed to notify pingomatic.com (site).', array(), WATCHDOG_WARNING); | |
| 56 } | |
| 57 } | |
| 58 | |
| 59 |
