Source for file _generic_ping.plugin.php
Documentation is available at _generic_ping.plugin.php
* This file implements the generic_ping_plugin.
* This file is part of the evoCore framework - {@link http://evocore.net/}
* See also {@link http://sourceforge.net/projects/evocms/}.
* @copyright (c)2003-2008 by Francois PLANQUE - {@link http://fplanque.net/}
* Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
* {@internal License choice
* - If you have received this file as part of a package, please find the license.txt file in
* the same folder or the closest folder above for complete license terms.
* - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
* then you must choose one of the following licenses before using the file:
* - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
* - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
* {@internal Open Source relicensing agreement:
* Daniel HAHLER grants Francois PLANQUE the right to license
* Daniel HAHLER's contributions to this file and the b2evolution project
* under any OSI approved OSS license (http://www.opensource.org/licenses/).
* @author blueyed: Daniel HAHLER
* @version $Id: _generic_ping.plugin.php,v 1.8 2008/01/21 09:35:41 fplanque Exp $
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
* Variables below MUST be overriden by plugin implementations,
* either in the subclass declaration or in the subclass constructor.
var $help_url =
''; // empty URL defaults to manual wiki
* These variables MAY be overriden.
* This gets called after a plugin has been registered/instantiated.
$this->name =
T_('Generic Ping plugin');
$this->short_desc =
T_('Use this plugin to add a generic ping service to your installation.');
if( $params['is_installed'] )
{ // is not set for not-installed Plugins
* Get the settings that the plugin can use.
* Those settings are transfered into a Settings member object of the plugin
* and can be edited in the backoffice (Settings / Plugins).
* @see Plugin::GetDefaultSettings()
* @see Plugin::PluginSettingsValidateSet()
'ping_service_url' =>
array(
'label' =>
T_('Ping service URL'),
'note' =>
T_('The URL of the ping service.').
' '.
sprintf('E.g. «%s»', 'rpc.weblogs.com/RPC2 or rpc.foobar.com:8080'),
'ping_service_extended' =>
array(
'label' =>
T_('Extended ping?'),
'note' =>
T_('Use weblogUpdates.extendedPing method instead of weblogUpdates.ping?'),
'ping_service_name' =>
array(
'label' =>
T_('Ping service name'),
'note' =>
T_('The name of the ping service, used for displaying only.'),
'ping_service_note' =>
array(
'label' =>
T_('Ping service note'),
'note' =>
T_('Notes about the ping service, used for displaying only.'),
* Check ping service URL and plugin code.
$ping_service_url =
$this->Settings->get('ping_service_url');
if( empty($ping_service_url) )
return T_('You must configure a ping service URL before the plugin can be enabled.');
return T_('The ping plugin needs a non-empty code.');
* Check ping service URL.
if( $params['name'] ==
'ping_service_url' )
return T_('The ping service URL is invalid.');
* Parse a given ping service URL
* @return false|arrayFalse in case of error, array with keys 'host', 'port', 'path' otherwise
if( ! preg_match( '~^([^/:]+)(:\d+)?(/.*)?$~', $url, $match ) )
'port' =>
empty($match[2]) ?
80 :
$match[2],
'path' =>
empty($match[3]) ?
'/' :
$match[3],
* Send a ping to the configured service.
$item_Blog =
$Item->get_Blog();
$client =
new xmlrpc_client( $url['path'], $url['host'], $url['port'] );
$client->debug =
($debug &&
$params['display']);
if( $this->Settings->get('ping_service_extended') )
$message =
new xmlrpcmsg("weblogUpdates.extendedPing", array(
new xmlrpcval( $item_Blog->get('atom_url') ),
$message =
new xmlrpcmsg("weblogUpdates.ping", array(
$result =
$client->send($message);
$params['xmlrpcresp'] =
$result;
* $Log: _generic_ping.plugin.php,v $
* Revision 1.8 2008/01/21 09:35:41 fplanque
* Revision 1.7 2007/06/16 20:23:21 blueyed
* Added "ping_service_extended" setting to use weblogUpdates.extendedPing
* Revision 1.6 2007/04/26 00:11:04 fplanque
* Revision 1.5 2007/01/20 23:48:10 blueyed
* Changed plugin default URL to manual.b2evolution.net/classname_plugin
* Revision 1.4 2006/11/24 18:27:27 blueyed
* Fixed link to b2evo CVS browsing interface in file docblocks
* Revision 1.3 2006/10/30 19:00:37 blueyed
* Lazy-loading of Plugin (User)Settings for PHP5 through overloading
* Revision 1.2 2006/10/11 17:21:09 blueyed
* Revision 1.1 2006/10/05 01:19:11 blueyed
* Initial import of generic ping plugin.