add('name', PLUGIN_EVENT_WEBLOGPING_TITLE); $propbag->add('description', PLUGIN_EVENT_WEBLOGPING_DESC); $propbag->add('stackable', false); $propbag->add('author', 'Serendipity Team'); $propbag->add('version', '1.07'); $propbag->add('requirements', array( 'serendipity' => '0.8', 'smarty' => '2.6.7', 'php' => '4.1.0' )); $propbag->add('event_hooks', array( 'backend_display' => true, 'frontend_display' => true, 'backend_insert' => true, 'backend_update' => true, 'backend_publish' => true, 'backend_draft' => true, 'external_plugin' => true )); $propbag->add('groups', array('BACKEND_EDITOR')); $servicesdb = array(); $servicesdb_file = dirname(__FILE__) . '/servicesdb_' . $serendipity['lang'] . '.inc.php'; if (!file_exists($servicesdb_file)) { $servicesdb_file = dirname(__FILE__) . '/servicesdb_en.inc.php'; } include $servicesdb_file; $this->services =& $servicesdb; $manual_services = explode(',', $this->get_config('manual_services')); if (is_array($manual_services)) { foreach($manual_services as $ms_index => $ms_name) { if (!empty($ms_name)) { $is_extended = ($ms_name{0} == '*' ? true : false); $ms_name = trim($ms_name, '*'); $ms_parts = explode('/', $ms_name); $ms_host = $ms_parts[0]; unset($ms_party[0]); array_shift( $ms_parts); // remove hostname. $this->services[] = array( 'name' => $ms_name, 'host' => $ms_host, 'path' => '/'.implode('/', $ms_parts), 'extended' => $is_extended ); } } } $conf_array = array(); foreach($this->services AS $key => $service) { $conf_array[] = $service['name']; } $conf_array[] = 'manual_services'; $propbag->add('configuration', $conf_array); } function introspect_config_item($name, &$propbag) { switch($name) { case 'manual_services': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_EVENT_WEBLOGPING_CUSTOM); $propbag->add('description', PLUGIN_EVENT_WEBLOGPING_CUSTOM_BLAHBLA); $propbag->add('default', ''); break; default: $propbag->add('type', 'boolean'); $propbag->add('name', $name); $propbag->add('description', sprintf(PLUGIN_EVENT_WEBLOGPING_PING, $name)); $propbag->add('default', 'false'); } return true; } function generate_content(&$title) { $title = PLUGIN_EVENT_WEBLOGPING_TITLE; } function event_hook($event, &$bag, &$eventData) { global $serendipity; $hooks = &$bag->get('event_hooks'); if (isset($hooks[$event])) { switch($event) { case 'backend_display': ?>
services as $index => $service) { if (!empty($service['supersedes']) && isset($serendipity['POST']['announce_entries_' . $service['name']])) { $supersedes = explode(', ', $service['supersedes']); foreach($supersedes AS $sid => $servicename) { // A service has been checked that is superseded by another checked meta-service. Remove that service from the list of services to be ping'd unset($serendipity['POST']['announce_entries_' . $servicename]); } } } foreach ($this->services as $index => $service) { if (isset($serendipity['POST']['announce_entries_' . $service['name']]) || (defined('SERENDIPITY_IS_XMLRPC') && serendipity_db_bool($this->get_config($service['name'])))) { if (!defined('SERENDIPITY_IS_XMLRPC') || defined('SERENDIPITY_XMLRPC_VERBOSE')) { printf(PLUGIN_EVENT_WEBLOGPING_SENDINGPING . '...', $service['host']); } flush(); # XXX append $serendipity['indexFile'] to baseURL? $args = array( new XML_RPC_Value( $serendipity['blogTitle'], 'string' ), new XML_RPC_Value( $serendipity['baseURL'], 'string' ) ); if ($service['extended']) { # the checkUrl: for when the main page is not really the main page $args[] = new XML_RPC_Value( '', 'string' ); # the rssUrl $args[] = new XML_RPC_Value( $serendipity['baseURL'] . 'rss.php?version=2.0', 'string' ); } $message = new XML_RPC_Message( $service['extended'] ? 'weblogUpdates.extendedPing' : 'weblogUpdates.ping', $args ); $client = new XML_RPC_Client( trim($service['path']), trim($service['host']) ); # 15 second timeout may not be long enough for weblogs.com $message->createPayload(); $options = array(); serendipity_plugin_api::hook_event('backend_http_request', $options, 'weblogping'); serendipity_request_start(); $req = new HTTP_Request("http://".$service['host'].$service['path'], $options); $req->setMethod(HTTP_REQUEST_METHOD_POST); $req->addHeader("Content-Type", "text/xml"); if (strtoupper(LANG_CHARSET) != 'UTF-8') { $payload = utf8_encode($message->payload); } else { $payload = $message->payload; } $req->addRawPostData($payload); $http_result = $req->sendRequest(); $http_response = $req->getResponseBody(); $xmlrpc_result = $message->parseResponse($http_response); if ($xmlrpc_result->faultCode()) { $out = sprintf(PLUGIN_EVENT_WEBLOGPING_SEND_FAILURE . "