ping.module

You are here

  1. 4.6 modules/ping.module
  2. 4.7 modules/ping.module
  3. 5 modules/ping/ping.module
  4. 6 modules/ping/ping.module

Alerts other sites that your site has been updated.

Functions

Namesort descending 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.

File

modules/ping/ping.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * Alerts other sites that your site has been updated.
  5. */
  6. /**
  7. * Implementation of hook_help().
  8. */
  9. function ping_help($path, $arg) {
  10. switch ($path) {
  11. case 'admin/help#ping':
  12. $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>';
  13. $output .= '<p>'. t('The ping module requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))) .'</p>';
  14. $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>';
  15. return $output;
  16. }
  17. }
  18. /**
  19. * Implementation of hook_cron().
  20. *
  21. * Fire off notifications of updates to remote sites.
  22. */
  23. function ping_cron() {
  24. global $base_url;
  25. if (variable_get('site_name', 0)) {
  26. $cron_last = variable_get('cron_last', time());
  27. // Query changed first since usually changed >= created.
  28. if (db_result(db_query('SELECT COUNT(*) FROM {node} WHERE status = 1 AND changed > %d', $cron_last)) || db_result(db_query('SELECT COUNT(*) FROM {node} WHERE status = 1 AND created > %d', $cron_last))) {
  29. _ping_notify(variable_get('site_name', ''), $base_url);
  30. }
  31. }
  32. }
  33. /**
  34. * Call hook_ping() in all modules to notify remote sites that there is
  35. * new content at this one.
  36. */
  37. function _ping_notify($name, $url) {
  38. module_invoke_all('ping', $name, $url);
  39. }
  40. /**
  41. * Implementation of hook_ping().
  42. *
  43. * Notifies pingomatic.com, blo.gs, and technorati.com of changes at this site.
  44. */
  45. function ping_ping($name = '', $url = '') {
  46. $result = xmlrpc('http://rpc.pingomatic.com', 'weblogUpdates.ping', $name, $url);
  47. if ($result === FALSE) {
  48. watchdog('directory ping', 'Failed to notify pingomatic.com (site).', array(), WATCHDOG_WARNING);
  49. }
  50. }