3 Note: based on NP_PingPong, adapt for the new ping mechanism
7 v1.1 - Add JustPosted event support
8 v1.2 - JustPosted event handling in background
9 v1.3 - pinged variable support
10 v1.4 - language file support
11 v1.5 - remove arg1 in exec() call
14 class NP_Ping extends NucleusPlugin {
16 function getName() { return 'Ping'; }
18 function getAuthor() { return 'admun (Edmond Hui)'; }
19 function getURL() { return 'http://edmondhui.homeip.net/nudn'; }
20 function getVersion() { return '1.5'; }
22 function getMinNucleusVersion() { return '330'; }
24 function getDescription() {
28 function supportsFeature($what) {
30 case 'SqlTablePrefix':
39 $language = ereg_replace( '[\\|/]', '', getLanguageName());
40 if (file_exists($this->getDirectory() . $language . '.php')) {
41 include_once($this->getDirectory() . $language . '.php');
43 include_once($this->getDirectory() . 'english.php');
48 $this->createOption('pingpong_pingomatic',_PING_PINGOM,'yesno','yes'); // Default, http://pingomatic.com
49 $this->createOption('pingpong_weblogs',_PING_WEBLOGS,'yesno','no'); // http://weblogs.com
50 $this->createOption('pingpong_technorati',_PING_TECHNOR,'yesno','no'); // http://www.technorati.com
51 $this->createOption('pingpong_blogrolling',_PING_BLOGR,'yesno','no'); // http://www.blogrolling.com
52 $this->createOption('pingpong_blogs',_PING_BLOGS,'yesno','no'); // http://blo.gs
53 $this->createOption('pingpong_weblogues',_PING_WEBLOGUES,'yesno','no'); // http://weblogues.com/
54 $this->createOption('pingpong_bloggde',_PING_BLOGGDE,'yesno','no'); // http://blogg.de
55 $this->createOption('ping_background',_PING_BG,'yesno','yes');
58 function getEventList() {
59 return array('SendPing', 'JustPosted');
62 function event_JustPosted($data) {
63 global $DIR_PLUGINS, $DIR_NUCLEUS;
65 // exit is another plugin already send ping
66 if ($data['pinged'] == true) {
70 if ($this->getOption('ping_background') == "yes") {
71 exec("php $DIR_PLUGINS/ping/ping.php " . $data['blogid'] . " &");
73 $this->sendPings($data['blogid']);
75 ACTIONLOG::add(INFO, 'NP_Ping: Sending ping (from foreground)');
78 // mark the ping has been sent
79 $data['pinged'] = true;
82 function event_SendPing($data) {
83 $this->sendPings($data);
86 function sendPings($data) {
87 if (!class_exists('xmlrpcmsg')) {
89 include($DIR_LIBS . 'xmlrpc.inc.php');
92 $this->myBlogId = $data['blogid'];
94 if ($this->getOption('pingpong_pingomatic')=='yes') {
95 echo _PINGING . "Ping-o-matic:<br/>";
96 echo $this->pingPingomatic();
100 if ($this->getOption('pingpong_weblogs')=='yes') {
101 echo _PINGING . "Weblogs.com:<br/>";
102 echo $this->pingWeblogs();
106 if ($this->getOption('pingpong_technorati')=='yes') {
107 echo _PINGING . "Technorati:<br/>";
108 echo $this->pingTechnorati();
112 if ($this->getOption('pingpong_blogrolling')=='yes') {
113 echo _PINGING . "Blogrolling.com:<br/>";
114 echo $this->pingBlogRollingDotCom();
118 if ($this->getOption('pingpong_blogs')=='yes') {
119 echo _PINGING . "Blog.gs:<br/>";
120 echo $this->pingBloGs();
124 if ($this->getOption('pingpong_weblogues')=='yes') {
125 echo _PINGING . "Weblogues.com:<br/>";
126 echo $this->pingWebloguesDotCom();
130 if ($this->getOption('pingpong_bloggde')=='yes') {
131 echo _PINGING . "Blog.de:<br/>";
132 echo $this->pingBloggDe();
137 function pingPingomatic() {
138 $b = new BLOG($this->myBlogId);
139 $message = new xmlrpcmsg(
140 'weblogUpdates.ping', array(
141 new xmlrpcval($b->getName(),'string'),
142 new xmlrpcval($b->getURL(),'string')
145 $c = new xmlrpc_client('/', 'rpc.pingomatic.com', 80);
148 $r = $c->send($message,30); // 30 seconds timeout...
149 return $this->processPingResult($r);
152 function pingWeblogs() {
153 $b = new BLOG($this->myBlogId);
154 $message = new xmlrpcmsg(
155 'weblogupdates.ping',array(
156 new xmlrpcval($b->getName(),'string'),
157 new xmlrpcval($b->getUrl(),'string')
160 $c = new xmlrpc_client('/rpc2', 'rpc.weblogs.com', 80);
163 $r = $c->send($message,30); // 30 seconds timeout...
164 return $this->processPingResult($r);
167 function pingTechnorati() {
168 $b = new BLOG($this->myBlogId);
169 $message = new xmlrpcmsg(
170 'weblogUpdates.ping', array(
171 new xmlrpcval($b->getName(),'string'),
172 new xmlrpcval($b->getURL(),'string')
175 $c = new xmlrpc_client('/rpc/ping/', 'rpc.technorati.com', 80);
178 $r = $c->send($message,30); // 30 seconds timeout...
179 return $this->processPingResult($r);
182 function pingBlogRollingDotCom() {
183 $b = new BLOG($this->myBlogId);
184 $message = new xmlrpcmsg(
185 'weblogUpdates.ping',
187 new xmlrpcval($b->getName(),'string'), // your blog title
188 new xmlrpcval($b->getURL(),'string') // your blog url
191 $c = new xmlrpc_client('/pinger/', 'rpc.blogrolling.com', 80);
194 $r = $c->send($message,30); // 30 seconds timeout...
195 return $this->processPingResult($r);
198 function pingBloGs() {
199 $b = new BLOG($this->myBlogId);
200 $message = new xmlrpcmsg(
201 'weblogUpdates.extendedPing', array(
202 new xmlrpcval($b->getName(),'string'),
203 new xmlrpcval($b->getURL(),'string')
206 $c = new xmlrpc_client('/', 'ping.blo.gs', 80);
209 $r = $c->send($message,30); // 30 seconds timeout...
210 return $this->processPingResult($r);
213 function pingWebloguesDotCom() {
214 $b = new BLOG($this->myBlogId);
215 $message = new xmlrpcmsg(
216 'weblogUpdates.extendedPing',
218 new xmlrpcval($b->getName(),'string'), // your blog title
219 new xmlrpcval($b->getURL(),'string') // your blog url
222 $c = new xmlrpc_client('/RPC/', 'www.weblogues.com', 80);
225 $r = $c->send($message,30); // 30 seconds timeout...
226 return $this->processPingResult($r);
229 function pingBloggDe() {
230 $b = new BLOG($this->myBlogId);
231 $message = new xmlrpcmsg(
232 'bloggUpdates.ping', array(
233 new xmlrpcval($b->getName(),'string'),
234 new xmlrpcval($b->getURL(),'string')
237 $c = new xmlrpc_client('/', 'xmlrpc.blogg.de', 80);
240 $r = $c->send($message,30); // 30 seconds timeout...
241 return $this->processPingResult($r);
244 function processPingResult($r) {
245 global $php_errormsg;
247 if (($r == 0) && ($r->errno || $r->errstring)) {
248 return _PING_ERROR . " " . $r->errno . ' : ' . $r->errstring;
249 } elseif (($r == 0) && ($php_errormsg)) {
250 return _PING_PHP_ERROR . $php_errormsg;
252 return _PING_PHP_PING_ERROR;
253 } elseif ($r->faultCode() != 0) {
254 return _PING_ERROR . ': ' . $r->faultString();
256 $r = $r->value(); // get response struct
259 $flerror = $r->structmem('flerror');
260 $flerror = $flerror->scalarval();
262 $message = $r->structmem('message');
263 $message = $message->scalarval();
266 return _PING_ERROR . ' (flerror=1): ' . $message;
269 return _PING_SUCCESS . ': ' . $message;