| [ Index ] |
PHP Cross Reference of Nucleus CMS 3.32 |
[Summary view] [Print] [Text view]
1 <? 2 /* 3 Note: based on NP_PingPong, adapt for the new ping mechanism 4 5 History 6 v1.0 - Initial version 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 */ 13 14 class NP_Ping extends NucleusPlugin { 15 16 function getName() { return 'Ping'; } 17 18 function getAuthor() { return 'admun (Edmond Hui)'; } 19 function getURL() { return 'http://edmondhui.homeip.net/nudn'; } 20 function getVersion() { return '1.5'; } 21 22 function getMinNucleusVersion() { return '330'; } 23 24 function getDescription() { 25 return _PING_DESC; 26 } 27 28 function supportsFeature($what) { 29 switch($what) { 30 case 'SqlTablePrefix': 31 return 1; 32 default: 33 return 0; 34 } 35 } 36 37 function init() 38 { 39 $language = ereg_replace( '[\\|/]', '', getLanguageName()); 40 if (file_exists($this->getDirectory() . $language . '.php')) { 41 include_once($this->getDirectory() . $language . '.php'); 42 }else { 43 include_once($this->getDirectory() . 'english.php'); 44 } 45 } 46 47 function install() { 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'); 56 } 57 58 function getEventList() { 59 return array('SendPing', 'JustPosted'); 60 } 61 62 function event_JustPosted($data) { 63 global $DIR_PLUGINS, $DIR_NUCLEUS; 64 65 // exit is another plugin already send ping 66 if ($data['pinged'] == true) { 67 return; 68 } 69 70 if ($this->getOption('ping_background') == "yes") { 71 exec("php $DIR_PLUGINS/ping/ping.php " . $data['blogid'] . " &"); 72 } else { 73 $this->sendPings($data['blogid']); 74 75 ACTIONLOG::add(INFO, 'NP_Ping: Sending ping (from foreground)'); 76 } 77 78 // mark the ping has been sent 79 $data['pinged'] = true; 80 } 81 82 function event_SendPing($data) { 83 $this->sendPings($data); 84 } 85 86 function sendPings($data) { 87 if (!class_exists('xmlrpcmsg')) { 88 global $DIR_LIBS; 89 include ($DIR_LIBS . 'xmlrpc.inc.php'); 90 } 91 92 $this->myBlogId = $data['blogid']; 93 94 if ($this->getOption('pingpong_pingomatic')=='yes') { 95 echo _PINGING . "Ping-o-matic:<br/>"; 96 echo $this->pingPingomatic(); 97 echo "<br/>"; 98 } 99 100 if ($this->getOption('pingpong_weblogs')=='yes') { 101 echo _PINGING . "Weblogs.com:<br/>"; 102 echo $this->pingWeblogs(); 103 echo "<br/>"; 104 } 105 106 if ($this->getOption('pingpong_technorati')=='yes') { 107 echo _PINGING . "Technorati:<br/>"; 108 echo $this->pingTechnorati(); 109 echo "<br/>"; 110 } 111 112 if ($this->getOption('pingpong_blogrolling')=='yes') { 113 echo _PINGING . "Blogrolling.com:<br/>"; 114 echo $this->pingBlogRollingDotCom(); 115 echo "<br/>"; 116 } 117 118 if ($this->getOption('pingpong_blogs')=='yes') { 119 echo _PINGING . "Blog.gs:<br/>"; 120 echo $this->pingBloGs(); 121 echo "<br/>"; 122 } 123 124 if ($this->getOption('pingpong_weblogues')=='yes') { 125 echo _PINGING . "Weblogues.com:<br/>"; 126 echo $this->pingWebloguesDotCom(); 127 echo "<br/>"; 128 } 129 130 if ($this->getOption('pingpong_bloggde')=='yes') { 131 echo _PINGING . "Blog.de:<br/>"; 132 echo $this->pingBloggDe(); 133 echo "<br/>"; 134 } 135 } 136 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') 143 )); 144 145 $c = new xmlrpc_client('/', 'rpc.pingomatic.com', 80); 146 //$c->setDebug(1); 147 148 $r = $c->send($message,30); // 30 seconds timeout... 149 return $this->processPingResult($r); 150 } 151 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') 158 )); 159 160 $c = new xmlrpc_client('/rpc2', 'rpc.weblogs.com', 80); 161 //$c->setdebug(1); 162 163 $r = $c->send($message,30); // 30 seconds timeout... 164 return $this->processPingResult($r); 165 } 166 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') 173 )); 174 175 $c = new xmlrpc_client('/rpc/ping/', 'rpc.technorati.com', 80); 176 //$c->setDebug(1); 177 178 $r = $c->send($message,30); // 30 seconds timeout... 179 return $this->processPingResult($r); 180 } 181 182 function pingBlogRollingDotCom() { 183 $b = new BLOG($this->myBlogId); 184 $message = new xmlrpcmsg( 185 'weblogUpdates.ping', 186 array( 187 new xmlrpcval($b->getName(),'string'), // your blog title 188 new xmlrpcval($b->getURL(),'string') // your blog url 189 )); 190 191 $c = new xmlrpc_client('/pinger/', 'rpc.blogrolling.com', 80); 192 //$c->setDebug(1); 193 194 $r = $c->send($message,30); // 30 seconds timeout... 195 return $this->processPingResult($r); 196 } 197 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') 204 )); 205 206 $c = new xmlrpc_client('/', 'ping.blo.gs', 80); 207 //$c->setDebug(1); 208 209 $r = $c->send($message,30); // 30 seconds timeout... 210 return $this->processPingResult($r); 211 } 212 213 function pingWebloguesDotCom() { 214 $b = new BLOG($this->myBlogId); 215 $message = new xmlrpcmsg( 216 'weblogUpdates.extendedPing', 217 array( 218 new xmlrpcval($b->getName(),'string'), // your blog title 219 new xmlrpcval($b->getURL(),'string') // your blog url 220 )); 221 222 $c = new xmlrpc_client('/RPC/', 'www.weblogues.com', 80); 223 //$c->setDebug(1); 224 225 $r = $c->send($message,30); // 30 seconds timeout... 226 return $this->processPingResult($r); 227 } 228 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') 235 )); 236 237 $c = new xmlrpc_client('/', 'xmlrpc.blogg.de', 80); 238 //$c->setDebug(1); 239 240 $r = $c->send($message,30); // 30 seconds timeout... 241 return $this->processPingResult($r); 242 } 243 244 function processPingResult($r) { 245 global $php_errormsg; 246 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; 251 } elseif ($r == 0) { 252 return _PING_PHP_PING_ERROR; 253 } elseif ($r->faultCode() != 0) { 254 return _PING_ERROR . ': ' . $r->faultString(); 255 } else { 256 $r = $r->value(); // get response struct 257 258 // get values 259 $flerror = $r->structmem('flerror'); 260 $flerror = $flerror->scalarval(); 261 262 $message = $r->structmem('message'); 263 $message = $message->scalarval(); 264 265 if ($flerror != 0) { 266 return _PING_ERROR . ' (flerror=1): ' . $message; 267 } 268 else { 269 return _PING_SUCCESS . ': ' . $message; 270 } 271 } 272 } 273 } 274 275 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Feb 12 15:34:36 2008 | Cross-referenced by PHPXref 0.7 |