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
12 v1.6 - move send update ping override option to plugin
15 class NP_Ping extends NucleusPlugin {
17 function getName() { return 'Ping'; }
19 function getAuthor() { return 'admun (Edmond Hui)'; }
20 function getURL() { return 'http://edmondhui.homeip.net/nudn'; }
21 function getVersion() { return '1.6'; }
23 function getMinNucleusVersion() { return '330'; }
25 function getDescription() {
29 function supportsFeature($what) {
31 case 'SqlTablePrefix':
40 $language = ereg_replace( '[\\|/]', '', getLanguageName());
41 if (file_exists($this->getDirectory() . $language . '.php')) {
42 include_once($this->getDirectory() . $language . '.php');
44 include_once($this->getDirectory() . 'english.php');
49 $this->createOption('pingpong_pingomatic',_PING_PINGOM,'yesno','yes'); // Default, http://pingomatic.com
50 $this->createOption('pingpong_weblogs',_PING_WEBLOGS,'yesno','no'); // http://weblogs.com
51 $this->createOption('pingpong_technorati',_PING_TECHNOR,'yesno','no'); // http://www.technorati.com
52 $this->createOption('pingpong_blogrolling',_PING_BLOGR,'yesno','no'); // http://www.blogrolling.com
53 $this->createOption('pingpong_blogs',_PING_BLOGS,'yesno','no'); // http://blo.gs
54 $this->createOption('pingpong_weblogues',_PING_WEBLOGUES,'yesno','no'); // http://weblogues.com/
55 $this->createOption('pingpong_bloggde',_PING_BLOGGDE,'yesno','no'); // http://blogg.de
56 $this->createOption('ping_background',_PING_BG,'yesno','yes');
59 function getEventList() {
64 'EditItemFormExtras');
67 function event_JustPosted($data) {
68 global $DIR_PLUGINS, $DIR_NUCLEUS;
70 // exit is another plugin already send ping
71 if ($data['pinged'] == true) {
75 if ($this->getOption('ping_background') == "yes") {
76 exec("php $DIR_PLUGINS/ping/ping.php " . $data['blogid'] . " &");
78 $this->sendPings($data['blogid']);
80 ACTIONLOG::add(INFO, 'NP_Ping: Sending ping (from foreground)');
83 // mark the ping has been sent
84 $data['pinged'] = true;
87 function event_SendPing($data) {
88 $this->sendPings($data);
91 function DisplayFormOptions($sendping) {
93 $check = 'checked="checked"';
97 $output = '<h3>' . _PING_EXTRA_PLUGIN_OPTION . '</h3>
98 <p><input id="dosendping" name="dosendping" value="1" type="checkbox" ' . $check . '><label for="dosendping">' . _UPDATEDPING_GOSENDPING . '</label> </p>';
102 function event_AddItemFormExtras($data){
103 $this->DisplayFormOptions($data['blog']->sendPing());
106 function event_EditItemFormExtras($data){
107 // we are not sending ping by default after edit an item
108 $this->DisplayFormOptions(0);
111 function sendPings($data) {
112 if (!class_exists('xmlrpcmsg')) {
114 include($DIR_LIBS . 'xmlrpc.inc.php');
117 $this->myBlogId = $data['blogid'];
119 if ($this->getOption('pingpong_pingomatic')=='yes') {
120 echo _PINGING . "Ping-o-matic:<br/>";
121 echo $this->pingPingomatic();
125 if ($this->getOption('pingpong_weblogs')=='yes') {
126 echo _PINGING . "Weblogs.com:<br/>";
127 echo $this->pingWeblogs();
131 if ($this->getOption('pingpong_technorati')=='yes') {
132 echo _PINGING . "Technorati:<br/>";
133 echo $this->pingTechnorati();
137 if ($this->getOption('pingpong_blogrolling')=='yes') {
138 echo _PINGING . "Blogrolling.com:<br/>";
139 echo $this->pingBlogRollingDotCom();
143 if ($this->getOption('pingpong_blogs')=='yes') {
144 echo _PINGING . "Blog.gs:<br/>";
145 echo $this->pingBloGs();
149 if ($this->getOption('pingpong_weblogues')=='yes') {
150 echo _PINGING . "Weblogues.com:<br/>";
151 echo $this->pingWebloguesDotCom();
155 if ($this->getOption('pingpong_bloggde')=='yes') {
156 echo _PINGING . "Blog.de:<br/>";
157 echo $this->pingBloggDe();
162 function pingPingomatic() {
163 $b = new BLOG($this->myBlogId);
164 $message = new xmlrpcmsg(
165 'weblogUpdates.ping', array(
166 new xmlrpcval($b->getName(),'string'),
167 new xmlrpcval($b->getURL(),'string')
170 $c = new xmlrpc_client('/', 'rpc.pingomatic.com', 80);
173 $r = $c->send($message,30); // 30 seconds timeout...
174 return $this->processPingResult($r);
177 function pingWeblogs() {
178 $b = new BLOG($this->myBlogId);
179 $message = new xmlrpcmsg(
180 'weblogupdates.ping',array(
181 new xmlrpcval($b->getName(),'string'),
182 new xmlrpcval($b->getUrl(),'string')
185 $c = new xmlrpc_client('/rpc2', 'rpc.weblogs.com', 80);
188 $r = $c->send($message,30); // 30 seconds timeout...
189 return $this->processPingResult($r);
192 function pingTechnorati() {
193 $b = new BLOG($this->myBlogId);
194 $message = new xmlrpcmsg(
195 'weblogUpdates.ping', array(
196 new xmlrpcval($b->getName(),'string'),
197 new xmlrpcval($b->getURL(),'string')
200 $c = new xmlrpc_client('/rpc/ping/', 'rpc.technorati.com', 80);
203 $r = $c->send($message,30); // 30 seconds timeout...
204 return $this->processPingResult($r);
207 function pingBlogRollingDotCom() {
208 $b = new BLOG($this->myBlogId);
209 $message = new xmlrpcmsg(
210 'weblogUpdates.ping',
212 new xmlrpcval($b->getName(),'string'), // your blog title
213 new xmlrpcval($b->getURL(),'string') // your blog url
216 $c = new xmlrpc_client('/pinger/', 'rpc.blogrolling.com', 80);
219 $r = $c->send($message,30); // 30 seconds timeout...
220 return $this->processPingResult($r);
223 function pingBloGs() {
224 $b = new BLOG($this->myBlogId);
225 $message = new xmlrpcmsg(
226 'weblogUpdates.extendedPing', array(
227 new xmlrpcval($b->getName(),'string'),
228 new xmlrpcval($b->getURL(),'string')
231 $c = new xmlrpc_client('/', 'ping.blo.gs', 80);
234 $r = $c->send($message,30); // 30 seconds timeout...
235 return $this->processPingResult($r);
238 function pingWebloguesDotCom() {
239 $b = new BLOG($this->myBlogId);
240 $message = new xmlrpcmsg(
241 'weblogUpdates.extendedPing',
243 new xmlrpcval($b->getName(),'string'), // your blog title
244 new xmlrpcval($b->getURL(),'string') // your blog url
247 $c = new xmlrpc_client('/RPC/', 'www.weblogues.com', 80);
250 $r = $c->send($message,30); // 30 seconds timeout...
251 return $this->processPingResult($r);
254 function pingBloggDe() {
255 $b = new BLOG($this->myBlogId);
256 $message = new xmlrpcmsg(
257 'bloggUpdates.ping', array(
258 new xmlrpcval($b->getName(),'string'),
259 new xmlrpcval($b->getURL(),'string')
262 $c = new xmlrpc_client('/', 'xmlrpc.blogg.de', 80);
265 $r = $c->send($message,30); // 30 seconds timeout...
266 return $this->processPingResult($r);
269 function processPingResult($r) {
270 global $php_errormsg;
272 if (($r == 0) && ($r->errno || $r->errstring)) {
273 return _PING_ERROR . " " . $r->errno . ' : ' . $r->errstring;
274 } elseif (($r == 0) && ($php_errormsg)) {
275 return _PING_PHP_ERROR . $php_errormsg;
277 return _PING_PHP_PING_ERROR;
278 } elseif ($r->faultCode() != 0) {
279 return _PING_ERROR . ': ' . $r->faultString();
281 $r = $r->value(); // get response struct
284 $flerror = $r->structmem('flerror');
285 $flerror = $flerror->scalarval();
287 $message = $r->structmem('message');
288 $message = $message->scalarval();
291 return _PING_ERROR . ' (flerror=1): ' . $message;
294 return _PING_SUCCESS . ': ' . $message;