<?
/*
  History
    v0.3 - initial release
    v0.30 - add configuable ping functions
    0.31 - fix ping on draft bug
    0.32 - fix fetal error when running with NP_Postman
 
 */
 
class NP_PingPong extends NucleusPlugin {
 
	function getName() { return 'PingPong'; }
 
	function getAuthor() { return 'Anand | admun (Edmond Hui) | and others'; }
	function getURL()    { return 'http://tamizhan.com/'; }
	function getVersion() { return '0.32'; }
 
	function getDescription() {
		return 'This plugin can be used to ping many blog tracking services';
	}
 
	function getEventList() {
		return array('PreAddItem','PostAddItem');
	}
 
	function event_PreAddItem($data) {
		$this->myBlogId    = $data['blog']->blogid;
		$this->myPostTitle = $data['title'];
		$this->draft       = $data['draft'];
	}
 
	function supportsFeature($what) {
		switch($what) {
			case 'SqlTablePrefix':
				return 1;
			default:
				return 0;
		}
	}
 
	function install() {
		$this->createOption('pingpong_pingomatic','Ping-o-matic','yesno','yes');  // Default, pinging Ping-o-Matic meta-ping service
 
		$this->createOption('pingpong_blogs','Blo.gs','yesno','no');
		$this->createOption('pingpong_euroweblog','EuroWeblog','yesno','no');
		$this->createOption('pingpong_weblogues','Weblogues','yesno','no'); 
		$this->createOption('pingpong_bloggde',"Blogg.de",'yesno','no');
		$this->createOption('pingpong_technorati',"Technorati",'yesno','no');
		$this->createOption('pingpong_blogrolling',"Blogrolling",'yesno','no');
	}
 
	function pingBloGs() {
		if ($this->draft == 1) return;
		$b = new BLOG($this->myBlogId);
 
		$message = new xmlrpcmsg(
				'weblogUpdates.extendedPing', array(
					new xmlrpcval($b->getName(),'string'),
					new xmlrpcval($b->getURL(),'string'),
					));
 
		$c = new xmlrpc_client('/', 'ping.blo.gs', 80);
 
		// $c->setDebug(1);
 
		$r = $c->send($message,15); // 15 seconds timeout...    
	} 
 
	function pingEuroWeblog() {
		if ($this->draft == 1) return;
		$b = new BLOG($this->myBlogId);
		$message = new xmlrpcmsg(
				'weblogUpdates.ping', array(
					new xmlrpcval($b->getName(),'string'),
					new xmlrpcval($b->getURL(),'string'),
					));
 
		$c = new xmlrpc_client('/RPC2', 'rcs.datashed.net', 80);
 
		// $c->setDebug(1);
 
		$r = $c->send($message,15); // 15 seconds timeout...    
	}
 
	function pingWebloguesDotCom() {
		if ($this->draft == 1) return;
		$b = new BLOG($this->myBlogId);
 
		$message = new xmlrpcmsg(
				'weblogUpdates.extendedPing',
				array(
					new xmlrpcval($b->getName(),'string'), // your blog title
					new xmlrpcval($b->getURL(),'string'),  // your blog url
					));
 
		$c = new xmlrpc_client('/RPC/', 'www.weblogues.com', 80);
 
		// $c->setDebug(1);
 
		$r = $c->send($message,15); // 15 seconds timeout...     
	}
 
	function pingPing() {
		if ($this->draft == 1) return;
		$b = new BLOG($this->myBlogId);
		if (!class_exists('xmlrpcmsg')) {
			global $DIR_LIBS;
			include($DIR_LIBS . 'xmlrpc.inc.php');
		}
		$message = new xmlrpcmsg(
				'weblogUpdates.ping', array(
					new xmlrpcval($b->getName(),'string'),
					new xmlrpcval($b->getURL(),'string'),
					));
 
		$c = new xmlrpc_client('/', 'rpc.pingomatic.com', 80);
 
		//$c->setDebug(1);
 
		$r = $c->send($message,15); // 15 seconds timeout...
	}
 
	function pingBloggDe() {
		if ($this->draft == 1) return;
		$b = new BLOG($this->myBlogId);
		$message = new xmlrpcmsg(
				'bloggUpdates.ping', array(
					new xmlrpcval($b->getName(),'string'),
					new xmlrpcval($b->getURL(),'string'),
					));
		$c = new xmlrpc_client('/', 'xmlrpc.blogg.de', 80);
		// $c->setDebug(1);
		$r = $c->send($message,15); // 15 seconds timeout...   
	} 
 
	function pingTechnorati() {
		if ($this->draft == 1) return;
		$b = new BLOG($this->myBlogId);
		$message = new xmlrpcmsg(
				'weblogUpdates.ping', array(
					new xmlrpcval($b->getName(),'string'),
					new xmlrpcval($b->getURL(),'string'),
					));
		$c = new xmlrpc_client('/rpc/ping', 'rpc.technorati.com', 80);
		// $c->setDebug(1);
		$r = $c->send($message,15); // 15 seconds timeout...
	}
 
	function pingBlogRollingDotCom() {
		if ($this->draft == 1) return;
		$b = new BLOG($this->myBlogId);         
		$message = new xmlrpcmsg(
				'weblogUpdates.ping',
				array(
					new xmlrpcval($b->getName(),'string'), // your blog title
					new xmlrpcval($b->getURL(),'string'),  // your blog url
					new xmlrpcval('changesurl='+$this->altUrl,'string'),  //  alternative url       
					new xmlrpcval('categoryname=\"'+$this->cat+'\"','string'))); // your category name       
		$c = new xmlrpc_client('/pinger/', 'rpc.blogrolling.com', 80);
		// $c->setDebug(1);
		$r = $c->send($message,15); // 15 seconds timeout...     
	} 
 
	function event_PostAddItem($data) {
		if ($this->getOption('pingpong_pingomatic')=='yes') $this->pingPing();
		if ($this->getOption('pingpong_blogs')=='yes') $this->pingBloGs();
		if ($this->getOption('pingpong_euroweblog')=='yes') $this->pingEuroWeblog();
		if ($this->getOption('pingpong_weblogues')=='yes') $this->pingWebloguesDotCom();
		if ($this->getOption('pingpong_bloggde')=='yes') $this->pingBloggDe();
		if ($this->getOption('pingpong_technorati')=='yes') $this->pingTechnorati();
		if ($this->getOption('pingpong_blogrolling')=='yes') $this->pingBlogRollingDotCom();
	}
 
}
?>
pingpongcode.txt · Last modified: 2006/07/05 13:03 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki