From: garvinhicking Date: Wed, 11 Oct 2006 18:59:31 +0000 (+0000) Subject: Add google ping X-Git-Tag: 1.1~76 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=e3938ba3040da01b9c587e24ddd71d65c1189371;p=s9y.git Add google ping safer check for "filter" extension --- diff --git a/include/compat.inc.php b/include/compat.inc.php index 4e0ec77..ad5f90b 100644 --- a/include/compat.inc.php +++ b/include/compat.inc.php @@ -2,6 +2,11 @@ # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team) # All rights reserved. See LICENSE file for licensing details +if (defined('S9Y_FRAMEWORK_COMPAT')) { + return; +} +@define('S9Y_FRAMEWORK_COMPAT', true); + $serendipity = array(); @ini_set('magic_quotes_runtime', 'off'); @@ -96,7 +101,7 @@ if (!isset($_SERVER)) { $_SERVER = &$HTTP_SERVER_VARS; } -if (extension_loaded('filter') && input_name_to_filter(ini_get('filter.default')) !== FILTER_UNSAFE_RAW) { +if (extension_loaded('filter') && function_exists('input_name_to_filter') && input_name_to_filter(ini_get('filter.default')) !== FILTER_UNSAFE_RAW) { foreach ($_POST as $key => $value) { $_POST[$key] = input_get(INPUT_POST, $key, FILTER_UNSAFE_RAW); } @@ -186,6 +191,33 @@ function serendipity_get_bool($item) { } } +/** + * Get the current charset + * + * @return string Empty string or "UTF-8/". + */ +function serendipity_getCharset() { + global $serendipity; + + $charset = $serendipity['charset']; + if (!empty($_POST['charset'])) { + if ($_POST['charset'] == 'UTF-8/') { + $charset = 'UTF-8/'; + } else { + $charset = ''; + } + } + + if (!empty($serendipity['POST']['charset'])) { + if ($serendipity['POST']['charset'] == 'UTF-8/') { + $charset = 'UTF-8/'; + } else { + $charset = ''; + } + } + return $charset; +} + /** * Detect the language of the User Agent/Visitor * @@ -202,11 +234,13 @@ function serendipity_detectLang($use_include = false) { $supported_languages = array_keys($serendipity['languages']); $possible_languages = explode(',', (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '')); if (is_array($possible_languages)) { + $charset = serendipity_getCharset(); + foreach($possible_languages as $index => $lang) { $preferred_language = strtolower(preg_replace('@^([^\-_;]*)_?.*$@', '\1', $lang)); if (in_array($preferred_language, $supported_languages)) { if ($use_include) { - @include_once(S9Y_INCLUDE_PATH . 'lang/serendipity_lang_' . $preferred_language . '.inc.php'); + @include(S9Y_INCLUDE_PATH . 'lang/' . $charset . 'serendipity_lang_' . $preferred_language . '.inc.php'); $serendipity['autolang'] = $preferred_language; } return $preferred_language; diff --git a/plugins/serendipity_event_weblogping/serendipity_event_weblogping.php b/plugins/serendipity_event_weblogping/serendipity_event_weblogping.php index e1bc3c4..3abb92d 100644 --- a/plugins/serendipity_event_weblogping/serendipity_event_weblogping.php +++ b/plugins/serendipity_event_weblogping/serendipity_event_weblogping.php @@ -22,7 +22,7 @@ class serendipity_event_weblogping extends serendipity_event $propbag->add('description', PLUGIN_EVENT_WEBLOGPING_DESC); $propbag->add('stackable', false); $propbag->add('author', 'Serendipity Team'); - $propbag->add('version', '1.02'); + $propbag->add('version', '1.07'); $propbag->add('requirements', array( 'serendipity' => '0.8', 'smarty' => '2.6.7', @@ -34,7 +34,8 @@ class serendipity_event_weblogping extends serendipity_event 'backend_insert' => true, 'backend_update' => true, 'backend_publish' => true, - 'backend_draft' => true + 'backend_draft' => true, + 'external_plugin' => true )); $propbag->add('groups', array('BACKEND_EDITOR')); @@ -112,12 +113,14 @@ class serendipity_event_weblogping extends serendipity_event
services AS $index => $service) { // Detect if the current checkbox needs to be saved. We use the field chk_timestamp to see, // if the form has already been submitted and individual changes shall be preserved $selected = (($serendipity['POST']['chk_timestamp'] && $serendipity['POST']['announce_entries_' . $service['name']]) || (!isset($serendipity['POST']['chk_timestamp']) && $this->get_config($service['name']) == 'true') ? 'checked="checked"' : ''); - $onclick = ''; + $noneclick .= 'document.getElementById(\'serendipity[announce_entries_' . $service['name'] . ']\').checked = false; '; + $onclick = ''; if (!empty($service['supersedes'])) { $onclick = 'onclick="'; $supersedes = explode(', ', $service['supersedes']); @@ -135,6 +138,8 @@ class serendipity_event_weblogping extends serendipity_event + +
services as $index => $service) { if (!empty($service['supersedes']) && isset($serendipity['POST']['announce_entries_' . $service['name']])) { @@ -156,8 +161,10 @@ class serendipity_event_weblogping extends serendipity_event } } foreach ($this->services as $index => $service) { - if (isset($serendipity['POST']['announce_entries_' . $service['name']])) { - printf(PLUGIN_EVENT_WEBLOGPING_SENDINGPING . '...', $service['host']); + 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? @@ -200,6 +207,8 @@ class serendipity_event_weblogping extends serendipity_event $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"); @@ -213,9 +222,14 @@ class serendipity_event_weblogping extends serendipity_event $http_response = $req->getResponseBody(); $xmlrpc_result = $message->parseResponse($http_response); if ($xmlrpc_result->faultCode()) { - echo sprintf(PLUGIN_EVENT_WEBLOGPING_SEND_FAILURE . "
", htmlspecialchars($xmlrpc_result->faultString())); + $out = sprintf(PLUGIN_EVENT_WEBLOGPING_SEND_FAILURE . "
", htmlspecialchars($xmlrpc_result->faultString())); } else { - echo PLUGIN_EVENT_WEBLOGPING_SEND_SUCCESS . "
"; + $out = PLUGIN_EVENT_WEBLOGPING_SEND_SUCCESS . "
"; + } + serendipity_request_end(); + + if (!defined('SERENDIPITY_IS_XMLRPC') || defined('SERENDIPITY_XMLRPC_VERBOSE')) { + echo $out; } } } @@ -223,6 +237,16 @@ class serendipity_event_weblogping extends serendipity_event return true; break; + case 'external_plugin': + if ($eventData == 'xmlrpc_ping') { + echo "XMLRPC START\n"; + @define('SERENDIPITY_IS_XMLRPC', true); + @define('SERENDIPITY_XMLRPC_VERBOSE', true); + $this->event_hook('backend_publish', $bag, $eventData); + echo "XMLRPC DONE\n"; + } + return true; + case 'frontend_display': case 'backend_insert': case 'backend_update': diff --git a/plugins/serendipity_event_weblogping/servicesdb_de.inc.php b/plugins/serendipity_event_weblogping/servicesdb_de.inc.php new file mode 100644 index 0000000..17ec3c8 --- /dev/null +++ b/plugins/serendipity_event_weblogping/servicesdb_de.inc.php @@ -0,0 +1,64 @@ + # +# http://www.jannis.to/programming/serendipity.html # +# # +########################################################################## + + $servicesdb = array( + array( + 'name' => 'Ping-o-Matic', + 'host' => 'rpc.pingomatic.com', + 'path' => '/', + 'extended' => true, + 'supersedes' => array('blo.gs', 'blogrolling.com', 'technorati.com', 'weblogs.com', 'Yahoo!') + ), + + array( + 'name' => 'blo.gs', + 'host' => 'ping.blo.gs', + 'path' => '/', + 'extended' => true + ), + + array( + 'name' => 'blogrolling.com', + 'host' => 'rpc.blogrolling.com', + 'path' => '/pinger/' + ), + + array( + 'name' => 'technorati.com', + 'host' => 'rpc.technorati.com', + 'path' => '/rpc/ping' + ), + + array( + 'name' => 'weblogs.com', + 'host' => 'rpc.weblogs.com', + 'path' => '/RPC2' + ), + + array( + 'name' => 'ge.bloggt.org', + 'host' => 'ping.ge.bloggt.org', + 'path' => '/' + ), + + array( + 'name' => 'Yahoo!', + 'host' => 'api.my.yahoo.com', + 'path' => '/RPC2' + ), + + array( + 'name' => 'Google', + 'host' => 'blogsearch.google.com', + 'path' => '/ping/RPC2' + ), + ); +?> diff --git a/plugins/serendipity_event_weblogping/servicesdb_en.inc.php b/plugins/serendipity_event_weblogping/servicesdb_en.inc.php index bb14187..4781ce9 100644 --- a/plugins/serendipity_event_weblogping/servicesdb_en.inc.php +++ b/plugins/serendipity_event_weblogping/servicesdb_en.inc.php @@ -43,12 +43,13 @@ 'path' => '/RPC2' ), +/* array( 'name' => 'blogg.de', 'host' => 'xmlrpc.blogg.de', 'path' => '/' ), - +*/ array( 'name' => 'Yahoo!', 'host' => 'api.my.yahoo.com', @@ -57,6 +58,12 @@ array( 'name' => 'Blogbot.dk', 'host' => 'blogbot.dk', - 'path' => '/io/xml-rpc.php') + 'path' => '/io/xml-rpc.php'), + array( + 'name' => 'Google', + 'host' => 'blogsearch.google.com', + 'path' => '/ping/RPC2' + ), + ); ?> diff --git a/plugins/serendipity_event_weblogping/servicesdb_tn.inc.php b/plugins/serendipity_event_weblogping/servicesdb_tn.inc.php index 880230e..dda025b 100644 --- a/plugins/serendipity_event_weblogping/servicesdb_tn.inc.php +++ b/plugins/serendipity_event_weblogping/servicesdb_tn.inc.php @@ -47,12 +47,6 @@ 'path' => '/RPC2' ), - array( - 'name' => 'blogg.de', - 'host' => 'xmlrpc.blogg.de', - 'path' => '/' - ), - array( 'name' => 'Yahoo!', 'host' => 'api.my.yahoo.com',