webmaster@1
|
1 <?php |
webmaster@1
|
2 // $Id: ping.module,v 1.52 2007/12/19 17:45:42 goba Exp $ |
webmaster@1
|
3 |
webmaster@1
|
4 /** |
webmaster@1
|
5 * @file |
webmaster@1
|
6 * Alerts other sites that your site has been updated. |
webmaster@1
|
7 */ |
webmaster@1
|
8 |
webmaster@1
|
9 /** |
webmaster@1
|
10 * Implementation of hook_help(). |
webmaster@1
|
11 */ |
webmaster@1
|
12 function ping_help($path, $arg) { |
webmaster@1
|
13 switch ($path) { |
webmaster@1
|
14 case 'admin/help#ping': |
webmaster@1
|
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>'; |
webmaster@1
|
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>'; |
webmaster@1
|
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>'; |
webmaster@1
|
18 return $output; |
webmaster@1
|
19 } |
webmaster@1
|
20 } |
webmaster@1
|
21 |
webmaster@1
|
22 /** |
webmaster@1
|
23 * Implementation of hook_cron(). |
webmaster@1
|
24 * |
webmaster@1
|
25 * Fire off notifications of updates to remote sites. |
webmaster@1
|
26 */ |
webmaster@1
|
27 function ping_cron() { |
webmaster@1
|
28 global $base_url; |
webmaster@1
|
29 |
webmaster@1
|
30 if (variable_get('site_name', 0)) { |
webmaster@1
|
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()) ."')"))) { |
webmaster@1
|
32 _ping_notify(variable_get('site_name', ''), $base_url); |
webmaster@1
|
33 } |
webmaster@1
|
34 } |
webmaster@1
|
35 } |
webmaster@1
|
36 |
webmaster@1
|
37 /** |
webmaster@1
|
38 * Call hook_ping() in all modules to notify remote sites that there is |
webmaster@1
|
39 * new content at this one. |
webmaster@1
|
40 */ |
webmaster@1
|
41 function _ping_notify($name, $url) { |
webmaster@1
|
42 module_invoke_all('ping', $name, $url); |
webmaster@1
|
43 } |
webmaster@1
|
44 |
webmaster@1
|
45 /** |
webmaster@1
|
46 * Implementation of hook_ping(). |
webmaster@1
|
47 * |
webmaster@1
|
48 * Notifies pingomatic.com, blo.gs, and technorati.com of changes at this site. |
webmaster@1
|
49 */ |
webmaster@1
|
50 function ping_ping($name = '', $url = '') { |
webmaster@1
|
51 |
webmaster@1
|
52 $result = xmlrpc('http://rpc.pingomatic.com', 'weblogUpdates.ping', $name, $url); |
webmaster@1
|
53 |
webmaster@1
|
54 if ($result === FALSE) { |
webmaster@1
|
55 watchdog('directory ping', 'Failed to notify pingomatic.com (site).', array(), WATCHDOG_WARNING); |
webmaster@1
|
56 } |
webmaster@1
|
57 } |
webmaster@1
|
58 |
webmaster@1
|
59 |