]> git.mjollnir.org Git - s9y.git/commitdiff
Add google ping
authorgarvinhicking <garvinhicking>
Wed, 11 Oct 2006 18:59:31 +0000 (18:59 +0000)
committergarvinhicking <garvinhicking>
Wed, 11 Oct 2006 18:59:31 +0000 (18:59 +0000)
safer check for "filter" extension

include/compat.inc.php
plugins/serendipity_event_weblogping/serendipity_event_weblogping.php
plugins/serendipity_event_weblogping/servicesdb_de.inc.php [new file with mode: 0644]
plugins/serendipity_event_weblogping/servicesdb_en.inc.php
plugins/serendipity_event_weblogping/servicesdb_tn.inc.php

index 4e0ec77113fc765617918b9c80718aa41a94112d..ad5f90b445a09d01f5c45b750855ea7af0b2f2fb 100644 (file)
@@ -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;
index e1bc3c41a8c3067c3b264f9fd418c7e49853256c..3abb92d23cba4cdbd3a01925f6b8284c2d0420e7 100644 (file)
@@ -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
                     <fieldset style="margin: 5px">
                         <legend><?php echo PLUGIN_EVENT_WEBLOGPING_PING; ?></legend>
 <?php
+                    $noneclick = '';
                     foreach($this->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
 <?php
     }
 ?>
+                            <input onclick="<?php echo $noneclick; ?>" style="margin: 0px; padding: 0px; vertical-align: bottom;" type="checkbox" value="none" id="serendipity[announce_entries_none]" />
+                                <label title="<?php echo NONE; ?>" style="vertical-align: bottom; margin: 0px; padding: 0px;" for="serendipity[announce_entries_none]">&nbsp;<?php echo NONE; ?>&nbsp;&nbsp;</label><br />
                     </fieldset>
 <?php
                     return true;
@@ -144,7 +149,7 @@ class serendipity_event_weblogping extends serendipity_event
                     if (!class_exists('XML_RPC_Base')) {
                         include_once(S9Y_PEAR_PATH . "XML/RPC.php");
                     }
-                                                                
+
                     // First cycle through list of services to remove superseding services which may have been checked
                     foreach ($this->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 . "<br />", htmlspecialchars($xmlrpc_result->faultString()));
+                                $out = sprintf(PLUGIN_EVENT_WEBLOGPING_SEND_FAILURE . "<br />", htmlspecialchars($xmlrpc_result->faultString()));
                             } else {
-                                echo PLUGIN_EVENT_WEBLOGPING_SEND_SUCCESS . "<br />";
+                                $out = PLUGIN_EVENT_WEBLOGPING_SEND_SUCCESS . "<br />";
+                            }
+                            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 (file)
index 0000000..17ec3c8
--- /dev/null
@@ -0,0 +1,64 @@
+<?php # $Id: servicesdb_en.inc.php 7 2005-04-16 06:39:31Z s_bergmann $
+
+##########################################################################
+# serendipity - another blogger...                                       #
+##########################################################################
+#                                                                        #
+# (c) 2003 Jannis Hermanns <J@hacked.it>                                 #
+# 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'
+            ),
+        );
+?>
index bb14187c1a7617cff96d900f7c649785afae1043..4781ce926f697e7c5524a58583f30400e4878685 100644 (file)
               'path' => '/RPC2'
             ),
 
+/*
             array(
               'name' => 'blogg.de',
               'host' => 'xmlrpc.blogg.de',
               'path' => '/'
             ),
-
+*/
             array(
               'name' => 'Yahoo!',
               'host' => 'api.my.yahoo.com',
             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'
+            ),
+                                                                  
         );
 ?>
index 880230e8e96825e58240083375493bed9c121cde..dda025bcfc4e7be0fd28325299a4b59b88c09f75 100644 (file)
               'path' => '/RPC2'\r
             ),\r
 \r
-            array(\r
-              'name' => 'blogg.de',\r
-              'host' => 'xmlrpc.blogg.de',\r
-              'path' => '/'\r
-            ),\r
-\r
             array(\r
               'name' => 'Yahoo!',\r
               'host' => 'api.my.yahoo.com',\r