From: garvinhicking <garvinhicking>
Date: Tue, 4 Oct 2005 13:05:08 +0000 (+0000)
Subject: Fix exit tracking, when no URL id is found.
X-Git-Tag: 0.9~92
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=8529d272b1a002c2d42336007b4c301d8ae7e5cd;p=s9y.git

Fix exit tracking, when no URL id is found.
---

diff --git a/docs/NEWS b/docs/NEWS
index 3f3cdcb..be4a6a0 100644
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,9 @@
 Version 0.9-beta2 ()
 ------------------------------------------------------------------------
 
+    * Fix track exits plugin to redirect to the right URL when no URL-ID
+      was found. (garvinhicking)
+
     * "Recent comments" plugin can be configured whether to show
        trackbacks, comments or both. (garvinhicking)
 
diff --git a/exit.php b/exit.php
index e6e7f3d..b3554fc 100644
--- a/exit.php
+++ b/exit.php
@@ -22,7 +22,7 @@ if (isset($_GET['url_id']) && !empty($_GET['url_id']) && isset($_GET['entry_id']
 
 } elseif (isset($_GET['url']) && !empty($_GET['url'])) {
     // No entry-link ID was submitted. Possibly a spammer tried to mis-use the script to get into the top-list.
-    $url = str_replace('&amp;', '&', base64_decode($_GET['url']));
+    $url = strip_tags(str_replace('&amp;', '&', base64_decode($_GET['url'])));
 }
 
 if (serendipity_isResponseClean($url)) {
diff --git a/plugins/serendipity_event_trackexits/serendipity_event_trackexits.php b/plugins/serendipity_event_trackexits/serendipity_event_trackexits.php
index 1e55a28..4c4d4aa 100644
--- a/plugins/serendipity_event_trackexits/serendipity_event_trackexits.php
+++ b/plugins/serendipity_event_trackexits/serendipity_event_trackexits.php
@@ -27,7 +27,7 @@ class serendipity_event_trackexits extends serendipity_event
         $propbag->add('description',   PLUGIN_EVENT_TRACKBACK_DESC);
         $propbag->add('stackable',     false);
         $propbag->add('author',        'Serendipity Team');
-        $propbag->add('version',       '1.2');
+        $propbag->add('version',       '1.3');
         $propbag->add('requirements',  array(
             'serendipity' => '0.8',
             'smarty'      => '2.6.7',
@@ -193,13 +193,14 @@ class serendipity_event_trackexits extends serendipity_event
         $is_over  = (stristr($buffer[0], 'onmouseover=') !== false ? true : false);
         $is_out   = (stristr($buffer[0], 'onmouseout=')  !== false ? true : false);
 
-        $link     = '<a%shref="%sexit.php?url_id=%s%s" ' . (!$is_title ? 'title="%s" ' : '%s') . (!$is_over ? ' onmouseover="window.status=\'%s\';return true;" ' : '%s') . (!$is_out ? 'onmouseout="window.status=\'\';return true;"' : '') . '%s>';
+        $link     = '<a%shref="%sexit.php?url%s=%s%s" ' . (!$is_title ? 'title="%s" ' : '%s') . (!$is_over ? ' onmouseover="window.status=\'%s\';return true;" ' : '%s') . (!$is_out ? 'onmouseout="window.status=\'\';return true;"' : '') . '%s>';
         
         if (is_array($this->links) && isset($this->links[$url])) {
             return sprintf(
                 $link,
                 $buffer[1],
                 $serendipity['baseURL'],
+                '_id',
                 $this->links[$url],
                 ($entry_id != 0) ? '&amp;entry_id=' . $entry_id : '',
                 (!$is_title ? $url : ''),
@@ -211,6 +212,7 @@ class serendipity_event_trackexits extends serendipity_event
                 $link,
                 $buffer[1],
                 $serendipity['baseURL'],
+                '',
                 base64_encode($url),
                 ($entry_id != 0) ? '&amp;entry_id=' . $entry_id : '',
                 (!$is_title ? $url : ''),
diff --git a/plugins/serendipity_plugin_remoterss/serendipity_plugin_remoterss.php b/plugins/serendipity_plugin_remoterss/serendipity_plugin_remoterss.php
index dc7b03e..d264a0e 100644
--- a/plugins/serendipity_plugin_remoterss/serendipity_plugin_remoterss.php
+++ b/plugins/serendipity_plugin_remoterss/serendipity_plugin_remoterss.php
@@ -273,7 +273,7 @@ class serendipity_plugin_remoterss extends serendipity_plugin {
         $propbag->add('description',   PLUGIN_REMOTERSS_BLAHBLAH);
         $propbag->add('stackable',     true);
         $propbag->add('author',        'Udo Gerhards, Richard Thomas Harrison');
-        $propbag->add('version',       '1.3');
+        $propbag->add('version',       '1.4');
         $propbag->add('requirements',  array(
             'serendipity' => '0.8',
             'smarty'      => '2.6.7',
@@ -383,6 +383,19 @@ class serendipity_plugin_remoterss extends serendipity_plugin {
         return true;
     }
 
+    // Check if a given URI is readable.
+    function urlcheck($uri) {
+        return true;
+        require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
+        $req = &new HTTP_Request($uri);
+        
+        if (PEAR::isError($req->sendRequest()) || !preg_match('@^[23]..@', $req->getResponseCode())) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
     function generate_content(&$title) {
         global $serendipity;
 
@@ -415,8 +428,9 @@ class serendipity_plugin_remoterss extends serendipity_plugin {
         if (trim($rssuri)) {
             $feedcache = $serendipity['serendipityPath'] . 'templates_c/remoterss_cache_' . preg_replace('@[^a-z0-9]*@i', '', $rssuri) . '.dat';
             if (!file_exists($feedcache) || filesize($feedcache) == 0 || filemtime($feedcache) < (time() - $cachetime)) {
-
-                if ($feedtype == 'rss') {
+                if (!$this->urlcheck($rssuri)) {
+                    echo '<!-- No valid URL! -->';
+                } elseif ($feedtype == 'rss') {
                     require_once S9Y_PEAR_PATH . 'Onyx/RSS.php';
                     $c = &new Onyx_RSS($charset);
                     $c->parse($rssuri);