I have extended, reorganised and partly recoded the optional core-module "ping.module". Since I am not a Drupal-master, could someone please tell me, if I should make this an ISSUE (feature-proposal) ? I Or can/should I append this new "ping.module" somewhere? AND Would anyone with good backend-development-skills extend this module to make it more dynamical in the backend/admin-interface of Drupal?


//  ======================================================================
//  PING.module   from / by   PS (PHILIPP-SCHAFFNER.CH)   |   v1.0
//  ======================================================================
# 1.)   function "ping_cron()"  is activated by CRON-functionality (CRON = time-based automatism) due to the function-suffix "_cron"
# 2.)   function "ping_cron()" now initializes function "ping_ping()" via  command "module_invoke('ping','ping')"
# 3.)   function "ping_ping()" goes through a user-generated list of XML-RPC-Service-Providers / directories. 
#           For every new URL to such a service this function calls the function "_PS__pingit()", which does the REAL job 
#           (including a detailed watchdog-information). 
# 4.)    The order of the code / functions below is based on a functional logic, NOT on a chronological one !

##  QUESTION (ps) >  WHY module_invoke "ping" at all (old system/method) from within the HOOK_cron() ? ?    
##  WHY not just call ping_ping()-function directly ? 
//  ======================================================================


function ping_help($section) {
  switch ($section) {
    case 'admin/help#ping':
      $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>';
      $output .= '<p>'. t('The ping module requires cron or a similar periodic job scheduler to be enabled.') .'</p>';
      $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>';
      return $output;
  }
}

//  PS__function  -->  excluded/outsourced from function "ping_ping()" due to redundancy !
function _PS__pingit($rpc_service) {
 global $base_url;
 $name = variable_get('site_name', ''); 
 
 //  xmlrpc ( string url, string method-name [, mixedArguments] )    -->  api.drupal.org/api/function/xmlrpc/5
 $result = xmlrpc($rpc_service, 'weblogUpdates.ping', $name, $base_url);
    if ($result === FALSE) {
     watchdog('directory ping', t('XML-RPC negativ: '.$rpc_service), WATCHDOG_WARNING);
    } else {
     watchdog("directory ping",t('XML-RPC positiv: '.$rpc_service), WATCHDOG_NOTICE);
    }
 unset($result);
}

//  HOOK _ping()
//  PS_modified, PS_simplified  ||  This part should finally go into the MySQL-database & the Drupal-Backend-Admin ! (Dynamical List of RPC-Services)
function ping_ping() {  
  $rpc_service = "http://rpc.pingomatic.com"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://ping.blo.gs/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://blogsearch.google.com/ping/RPC2"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://api.my.yahoo.com/RPC2"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://api.my.yahoo.com/rss/ping"; 
   _PS__pingit($rpc_service);
  $rpc_service = "https://phobos.apple.com/WebObjects/MZFinance.woa/wa/pingPodcast"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://signup.alerts.msn.com/alerts-PREP/submitPingExtended.doz"; 
   _PS__pingit($rpc_service);

  $rpc_service = "http://xmlrpc.blogg.de"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://ping.blogg.de/"; 
   _PS__pingit($rpc_service);

  $rpc_service = "http://services.newsgator.com/ngws/xmlrpcping.aspx"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://rpc.technorati.com/rpc/ping"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://rpc.icerocket.com:10080/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://rpc.newsgator.com/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://rpc.pingomatic.com/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://api.feedster.com/ping"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://api.feedster.com/ping.php"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://1470.net/api/ping"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://api.moreover.com/ping"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://api.moreover.com/RPC2"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://ping.syndic8.com/xmlrpc.php"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://bblog.com/ping.php"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://bitacoras.net/ping"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://blogdb.jp/xmlrpc"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://blog.goo.ne.jp/XMLRPC"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://blogmatcher.com/u.php"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://bulkfeeds.net/rpc"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://coreblog.org/ping/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://mod-pubsub.org/kn_apps/blogchatt"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://ping.amagle.com/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://ping.bitacoras.com"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://ping.bloggers.jp/rpc/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://ping.blogmura.jp/rpc/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://ping.blo.gs/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://ping.cocolog-nifty.com/xmlrpc"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://pinger.blogflux.com/rpc/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://ping.exblog.jp/xmlrpc"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://ping.feedburner.com"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://ping.myblog.jp"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://pingqueue.com/rpc/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://ping.rootblog.com/rpc.php"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://ping.weblogalot.com/rpc.php"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://ping.weblogs.se/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://rcs.datashed.net/RPC2/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://rpc.blogbuzzmachine.com/RPC2"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://rpc.blogrolling.com/pinger/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://rpc.britblog.com/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://rpc.tailrank.com/feedburner/RPC2"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://rpc.weblogs.com/RPC2"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://rpc.wpkeys.com/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://topicexchange.com/RPC2"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://trackback.bakeinu.jp/bakeping.php"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.a2b.cc/setloc/bp.a2b"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.bitacoles.net/ping.php"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.blogdigger.com/RPC2"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.blogoole.com/ping/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.blogoon.net/ping/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.blogpeople.net/servlet/weblogUpdates"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.blogroots.com/tb_populi.blog?id=1"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.blogshares.com/rpc.php"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.blogsnow.com/ping"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.blogstreet.com/xrbin/xmlrpc.cgi"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.holycowdude.com/rpc/ping/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.lasermemory.com/lsrpc/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.imblogs.net/ping/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.mod-pubsub.org/kn_apps/blogchatter/ping.php"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.newsisfree.com/RPCCloud"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.newsisfree.com/xmlrpctest.php"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.popdex.com/addsite.php"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.snipsnap.org/RPC2"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.weblogues.com/RPC/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://xping.pubsub.com/ping/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.zhuaxia.com/rpc/server.php"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.blogsdominicanos.com/ping/"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.xianguo.com/xmlrpc/ping.php"; 
   _PS__pingit($rpc_service);
  $rpc_service = "http://www.feedsky.com/api/RPC2"; 
   _PS__pingit($rpc_service);

}
/*  LIST from 'http://codex.wordpress.org/Update_Services'
    Extension recommended (depending on interest, branche, region etc.)
*/


//  HOOK _cron()
function ping_cron() {
    if (db_num_rows(db_query("SELECT nid FROM {node} WHERE status = 1 AND (created > '". variable_get('cron_last', time()) ."' OR changed > '". variable_get('cron_last', time()) ."')"))) {

        //  Invoke a hook in a particular module.
        //  module_invoke ( string module, string hook [, mixedArguments] )    -->  api.drupal.org/api/function/module_invoke/5
        module_invoke('ping','ping');

        //  watchdog ( string type, string message, WATCHDOG_NOTICE || _WARNING || _ERROR [, string link-url] )    -->  api.drupal.org/api/function/watchdog/5
        watchdog("directory ping",t('CRON PING.module (XML-RPC-Services) positiv!'), WATCHDOG_NOTICE);
    }
}

// Omit PHP-end-tag ?> in real version! This is only for Drupal-forum-purposes.

Comments

vm’s picture

My suggestion is to create an issue and file a proper patch so that the patch can be reviewed and added to the module by maintainers.
_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )

Blooniverse’s picture

... I have understood ;-)

By the way: Imagine the new "ping.module". If this works out, from now on Drupal is able to ping just as many xml-rpc-service-sites as wordpress and/or even more -- as desired !!

I have tested it on http://mpub.mobi and it works there !!!

zoo33’s picture

There is already a patch which makes Ping configurable: 11148. It's been around for ages.