Index: ping.module =================================================================== RCS file: /cvs/drupal/drupal/modules/ping.module,v retrieving revision 1.16 diff -u -r1.16 ping.module --- ping.module 18 May 2004 19:15:14 -0000 1.16 +++ ping.module 20 May 2004 03:10:00 -0000 @@ -6,7 +6,7 @@ */ function ping_help($section) { switch ($section) { - case 'admin/help#ping': + case 'admin/help#ping': $output .= t("
Drupal can pings sites automatically to notify them that your site has changed. It can ping the following sites:
%weblogs, a web site that tracks and displays links to changed weblogs and news-oriented web sites. To get your Drupal site listed, weblogs.com must be informed about your site's updates. This is the job of the ping module and when installed, the administrator doesn't have to do anything to participate in the %weblogs system. The ping module automatically notifies weblogs.com when your site is updated. To do so, Drupal implements the %weblogs-XML.
@@ -35,15 +35,33 @@ if (db_num_rows(db_query("SELECT nid FROM {node} WHERE status = 1 AND moderate = 0 AND (created > '". variable_get('ping_cron_last', time()) ."' OR changed > '". variable_get('ping_cron_last', time()) ."')"), 1)) { _ping_notify(variable_get('site_name', '') .' - '. variable_get('site_slogan', ''), $base_url); } - variable_set('ping_cron_last', time()); } } +function ping_settings() { + $output = ''; + + $group .= form_checkbox(t('Ping blo.gs'), 'ping_blogs', 1, variable_get('ping_blogs', 1)); + $group .= form_checkbox(t('Ping weblogs.com'), 'ping_weblogs', 1, variable_get('ping_blogs', 1)); + $group .= form_checkbox(t('Ping technorati.com'), 'ping_technorati', 1, variable_get('ping_technorati', 1)); + $group .= form_checkbox(t('Ping rootblog'), 'ping_rootblog', 1, variable_get('ping_rootblog', 1)); + $group .= form_checkbox(t('Ping Yahoo!'), 'ping_yahoo', 1, variable_get('ping_yahoo', 1)); + + $output = form_group(t('Ping Sites'), $group); + + $group = form_textarea(t('Send an additonal ping to those sites'), 'ping_normping', variable_get('ping_normping', ''), 70, 4, t('These sites will receive a standard weblogUpdates.ping - if unsure try this. Add one ping URL (the URL to ping) per line.')); + $group .= form_textarea(t('Send an additonal extended ping to those sites'), 'ping_xping', variable_get('ping_xping', ''), 70, 4, t('These sites will receive an extended weblogUpdates.extendedPing - Technorati is such a page, for example (enable technorati above). Add one URL per line.')); + $group .= form_textarea(t('Send a "rssUpdate" ping to'), 'ping_rss', variable_get('ping_rss', ''), 70, 4, t('Send an additonal rssUpdate to these sites. Add one URL per line.')); + $output .= form_group(t('Enter Freeform Ping URLs'), $group); + return $output; +} + /** * 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); } @@ -56,50 +74,157 @@ function ping_ping($name = '', $url = '') { $feed = url('node/feed'); - $client = new xmlrpc_client('/RPC2', 'rpc.weblogs.com', 80); - - $message = new xmlrpcmsg('weblogUpdates.ping', array(new xmlrpcval($name), new xmlrpcval($url))); - - $result = $client->send($message); - - if (!$result || $result->faultCode()) { - watchdog('error', 'failed to notify "weblogs.com" (site)'); - } - - unset($client); - - $client = new xmlrpc_client('/RPC2', 'rssrpc.weblogs.com', 80); - - $message = new xmlrpcmsg('rssUpdate', array(new xmlrpcval($name), new xmlrpcval($feed))); - - $result = $client->send($message); - - if (!$result || $result->faultCode()) { - watchdog('error', 'failed to notify "weblogs.com" (RSS)'); + if (variable_get('ping_weblogs', 1)) { + + unset ($client); + + $client = new xmlrpc_client('/RPC2', 'rpc.weblogs.com', 80); + $message = new xmlrpcmsg('weblogUpdates.ping', array(new xmlrpcval($name), new xmlrpcval($url))); + + $result = $client->send($message); + + if (!$result || $result->faultCode()) { + watchdog('error', 'failed to notify "weblogs.com" (site)'); + } + + + unset($client); + + $client = new xmlrpc_client('/RPC2', 'rssrpc.weblogs.com', 80); + $message = new xmlrpcmsg('rssUpdate', array(new xmlrpcval($name), new xmlrpcval($feed))); + + $result = $client->send($message); + + if (!$result || $result->faultCode()) { + watchdog('error', 'failed to notify "weblogs.com" (RSS)'); + } + } + + if (variable_get('ping_blogs', 1)) { + unset($client); + + $client = new xmlrpc_client('/', 'ping.blo.gs', 80); + $message = new xmlrpcmsg('weblogUpdates.extendedPing', array(new xmlrpcval($name), new xmlrpcval($url), new xmlrpcval($url), new xmlrpcval($feed))); + $result = $client->send($message); + + if (!$result || $result->faultCode()) { + watchdog('error', 'failed to notify "blo.gs" '); + } + } + + if (variable_get('ping_technorati', 1)) { + unset ($client); + + $client = new xmlrpc_client('/rpc/ping', 'rpc.technorati.com', 80); + $message = new xmlrpcmsg('weblogUpdates.ping', array(new xmlrpcval($name), new xmlrpcval($url))); + $result = $client->send($message); + + if (!$result || $result->faultCode()) { + watchdog('error', 'failed to notify "technorati.com"'); + } + } + + if (variable_get('ping_rootblog', 1)) { + + unset ($client); + $client = new xmlrpc_client('/rpc.php', 'ping.rootblog.com', 80); + $message = new xmlrpcmsg('weblogUpdates.ping', array(new xmlrpcval($name), new xmlrpcval($url))); + $result = $client->send($message); + + if (!$result || $result->faultCode()) { + watchdog('error', 'failed to notify "rootblog.com"'); + } + } + + if (variable_get('ping_yahoo', 1)) { + unset($client); + + $client = new xmlrpc_client('/RPC2', 'api.my.yahoo.com', 80); + $message = new xmlrpcmsg('weblogUpdates.ping', array(new xmlrpcval($name), new xmlrpcval($url))); + $result = $client->send($message); + + if (!$result || $result->faultCode()) { + watchdog('error', 'failed to notify "api.my.yahoo.com"'); + } + } + + if (variable_get("ping_normping", NULL)) { + unset($client); + $urls = preg_split("/\s+/", variable_get("ping_normping", NULL)); + + foreach ($urls as $pingurl) { + $purl = parse_url($pingurl); + $path = $purl['path']; + + if (strlen($purl['query']) >0) { + $path .= "?".$purl['query']; + } + + if (strlen($purl['fragment']) >0) { + $path .= "#".$purl['fragment']; + } + + $client = new xmlrpc_client($path,$purl['host'],$purl['port']); + $message = new xmlrpcmsg("weblogUpdates.ping", array(new xmlrpcval($name), new xmlrpcval($url))); + $result = $client->send($message,0,$purl['scheme']); + + if (!$result || $result->faultCode()) { + watchdog("error", "weblogUpdates.extendedPing: failed to notify ". $pingurl); + } + } } - unset($client); - - $client = new xmlrpc_client('/', 'ping.blo.gs', 80); - - $message = new xmlrpcmsg('weblogUpdates.extendedPing', array(new xmlrpcval($name), new xmlrpcval($url), new xmlrpcval($url), new xmlrpcval($feed))); - - $result = $client->send($message); - - if (!$result || $result->faultCode()) { - watchdog('error', 'failed to notify "blo.gs" '); + if (variable_get("ping_xping", NULL)) { + unset($client); + $urls = preg_split("/\s+/", variable_get("ping_xping", NULL)); + + foreach ($urls as $pingurl) { + $purl = parse_url($pingurl); + $path = $purl['path']; + + if (strlen($purl['query']) >0) { + $path .= "?".$purl['query']; + } + + if (strlen($purl['fragment']) >0) { + $path .= "#".$purl['fragment']; + } + + $client = new xmlrpc_client($path,$purl['host'],$purl['port']); + $message = new xmlrpcmsg("weblogUpdates.extendedPing", array(new xmlrpcval($name), new xmlrpcval($url), new xmlrpcval($url), new xmlrpcval($feed))); + $result = $client->send($message,0,$purl['scheme']); + + if (!$result || $result->faultCode()) { + watchdog("error", "weblogUpdates.extendedPing: failed to notify ". $pingurl); + } + } } - unset($client); - - $client = new xmlrpc_client('/rpc/ping', 'rpc.technorati.com', 80); - - $message = new xmlrpcmsg('weblogUpdates.ping', array(new xmlrpcval($name), new xmlrpcval($url))); - - $result = $client->send($message); - - if (!$result || $result->faultCode()) { - watchdog('error', 'failed to notify "technorati.com"'); + if (variable_get("ping_rss", NULL)) { + unset($client); + $urls = preg_split("/\s+/", variable_get("ping_rss", NULL)); + + foreach ($urls as $pingurl) { + $purl = parse_url($pingurl); + $path = $purl['path']; + + if (strlen($purl['query']) >0) { + $path .= "?".$purl['query']; + } + + if (strlen($purl['fragment']) >0) { + $path .= "#".$purl['fragment']; + } + + $client = new xmlrpc_client($path,$purl['host'],$purl['port']); + $message = new xmlrpcmsg("rssUpdate", array(new xmlrpcval($name), new xmlrpcval($feed))); + $result = $client->send($message,0,$purl['scheme']); + + if (!$result || $result->faultCode()) { + watchdog("error", "rssUpdate: failed to notify ". $pingurl); + } + } } + } ?>