Serendipity PHP Cross Reference Blogging Systems

Source: /exit.php - 35 lines - 1520 bytes - Summary - Text - Print

   1  <?php # $Id$
   2  # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
   3  # All rights reserved.  See LICENSE file for licensing details
   4  
   5  include  'serendipity_config.inc.php';
   6  
   7  $url      = $serendipity['baseURL'];
   8  
   9  if (isset($_GET['url_id']) && !empty($_GET['url_id']) && isset($_GET['entry_id']) && !empty($_GET['entry_id'])) {
  10  
  11      // See if the submitted link is in our database and should be tracked
  12      $links = serendipity_db_query("SELECT link FROM {$serendipity['dbPrefix']}references WHERE id = " . (int)$_GET['url_id'] . " AND entry_id = " . (int)$_GET['entry_id'], true);
  13  
  14      if (is_array($links) && isset($links['link'])) {
  15          // URL is valid. Track it.
  16          $url = str_replace('&amp;', '&', $links['link']);
  17          serendipity_track_url('exits', $url, $_GET['entry_id']);
  18      } elseif (isset($_GET['url']) && !empty($_GET['url'])) {
  19          // URL is invalid. But a URL-location was sent, so we want to redirect the user kindly.
  20          $url = str_replace('&amp;', '&', base64_decode($_GET['url']));
  21      }
  22  
  23  } elseif (isset($_GET['url']) && !empty($_GET['url'])) {
  24      // No entry-link ID was submitted. Possibly a spammer tried to mis-use the script to get into the top-list.
  25      $url = strip_tags(str_replace('&amp;', '&', base64_decode($_GET['url'])));
  26  }
  27  
  28  if (serendipity_isResponseClean($url)) {
  29      header('HTTP/1.0 301 Moved Permanently');
  30      header('Status: 301 Moved Permanently');
  31      header('Location: ' . $url);
  32  }
  33  exit;
  34  /* vim: set sts=4 ts=4 expandtab : */
  35  ?>

title

Description

title

Description

title

Description

title

title

Body