home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / unitednuke / unitednuke.exe / html / includes / sessions.php < prev    next >
PHP Script  |  2004-01-10  |  26KB  |  818 lines

  1. <?php
  2. /***************************************************************************
  3.  *                                sessions.php
  4.  *                            -------------------
  5.  *   begin                : Saturday, Feb 13, 2001
  6.  *   copyright            : (C) 2001 The phpBB Group
  7.  *   email                : support@phpbb.com
  8.  *
  9.  *   $Id: sessions.php,v 1.58.2.10 2003/04/05 12:04:33 acydburn Exp $
  10.  *
  11.  *
  12.  ***************************************************************************/
  13.  
  14. /***************************************************************************
  15. * phpbb2 forums port version 2.0.5 (c) 2003 - Nuke Cops (http://nukecops.com)
  16. *
  17. * Ported by Nuke Cops to phpbb2 standalone 2.0.5 Test
  18. * and debugging completed by the Elite Nukers and site members.
  19. *
  20. * You run this package at your sole risk. Nuke Cops and affiliates cannot
  21. * be held liable if anything goes wrong. You are advised to test this
  22. * package on a development system. Backup everything before implementing
  23. * in a production environment. If something goes wrong, you can always
  24. * backout and restore your backups.
  25. *
  26. * Installing and running this also means you agree to the terms of the AUP
  27. * found at Nuke Cops.
  28. *
  29. * This is version 2.0.5 of the phpbb2 forum port for PHP-Nuke. Work is based
  30. * on Tom Nitzschner's forum port version 2.0.6. Tom's 2.0.6 port was based
  31. * on the phpbb2 standalone version 2.0.3. Our version 2.0.5 from Nuke Cops is
  32. * now reflecting phpbb2 standalone 2.0.5 that fixes some bugs and the
  33. * invalid_session error message.
  34. ***************************************************************************/
  35. /***************************************************************************
  36.  *   This file is part of the phpBB2 port to Nuke 6.0 (c) copyright 2002
  37.  *   by Tom Nitzschner (tom@toms-home.com)
  38.  *   http://bbtonuke.sourceforge.net (or http://www.toms-home.com)
  39.  *
  40.  *   As always, make a backup before messing with anything. All code
  41.  *   release by me is considered sample code only. It may be fully
  42.  *   functual, but you use it at your own risk, if you break it,
  43.  *   you get to fix it too. No waranty is given or implied.
  44.  *
  45.  *   Please post all questions/request about this port on http://bbtonuke.sourceforge.net first,
  46.  *   then on my site. All original header code and copyright messages will be maintained
  47.  *   to give credit where credit is due. If you modify this, the only requirement is
  48.  *   that you also maintain all original copyright messages. All my work is released
  49.  *   under the GNU GENERAL PUBLIC LICENSE. Please see the README for more information.
  50.  *
  51.  ***************************************************************************/
  52. /***************************************************************************
  53.  *
  54.  *   This program is free software; you can redistribute it and/or modify
  55.  *   it under the terms of the GNU General Public License as published by
  56.  *   the Free Software Foundation; either version 2 of the License, or
  57.  *   (at your option) any later version.
  58.  *
  59.  ***************************************************************************/
  60.  
  61. //
  62. // Adds/updates a new session to the database for the given userid.
  63. // Returns the new session ID on success.
  64. //
  65. function session_begin($user_id, $user_ip, $page_id, $auto_create = 0, $enable_autologin = 0)
  66. {
  67.     global $db, $board_config;
  68.     global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;
  69.  
  70.     $cookiename = $board_config['cookie_name'];
  71.     $cookiepath = $board_config['cookie_path'];
  72.     $cookiedomain = $board_config['cookie_domain'];
  73.     $cookiesecure = $board_config['cookie_secure'];
  74.  
  75.     if ( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) || isset($HTTP_COOKIE_VARS[$cookiename . '_data']) )
  76.     {
  77.         $session_id = isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) ? $HTTP_COOKIE_VARS[$cookiename . '_sid'] : '';
  78.         $sessiondata = isset($HTTP_COOKIE_VARS[$cookiename . '_data']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookiename . '_data'])) : array();
  79.         $sessionmethod = SESSION_METHOD_COOKIE;
  80.     }
  81.     else
  82.     {
  83.         $sessiondata = array();
  84.         $session_id = ( isset($HTTP_GET_VARS['sid']) ) ? $HTTP_GET_VARS['sid'] : '';
  85.         $sessionmethod = SESSION_METHOD_GET;
  86.     }
  87.  
  88.     $last_visit = 0;
  89.     $current_time = time();
  90.     $expiry_time = $current_time - $board_config['session_length'];
  91.  
  92.     //
  93.     // Try and pull the last time stored in a cookie, if it exists
  94.     //
  95.     $sql = "SELECT *
  96.         FROM " . USERS_TABLE . "
  97.         WHERE user_id = $user_id";
  98.     if ( !($result = $db->sql_query($sql)) )
  99.     {
  100.         message_die(CRITICAL_ERROR, 'Could not obtain lastvisit data from user table', '', __LINE__, __FILE__, $sql);
  101.     }
  102.  
  103.     $userdata = $db->sql_fetchrow($result);
  104.  
  105.     if ( $user_id != ANONYMOUS )
  106.     {
  107.         $auto_login_key = $userdata['user_password'];
  108.  
  109.         if ( $auto_create )
  110.         {
  111.             if ( isset($sessiondata['autologinid']) && $userdata['user_active'] )
  112.             {
  113.                 // We have to login automagically
  114.                 if( $sessiondata['autologinid'] == $auto_login_key )
  115.                 {
  116.                     // autologinid matches password
  117.                     $login = 1;
  118.                     $enable_autologin = 1;
  119.                 }
  120.                 else
  121.                 {
  122.                     // No match; don't login, set as anonymous user
  123.                     $login = 0;
  124.                     $enable_autologin = 0;
  125.                                         $user_id = $userdata['user_id'] = ANONYMOUS;
  126.                 }
  127.             }
  128.             else
  129.             {
  130.                 // Autologin is not set. Don't login, set as anonymous user
  131.                 $login = 0;
  132.                 $enable_autologin = 0;
  133.                                 $user_id = $userdata['user_id'] = ANONYMOUS;
  134.             }
  135.         }
  136.         else
  137.         {
  138.             $login = 1;
  139.         }
  140.     }
  141.     else
  142.     {
  143.         $login = 0;
  144.         $enable_autologin = 0;
  145.     }
  146.  
  147.     //
  148.     // Initial ban check against user id, IP and email address
  149.     //
  150.     preg_match('/(..)(..)(..)(..)/', $user_ip, $user_ip_parts);
  151.  
  152.     $sql = "SELECT ban_ip, ban_userid, ban_email
  153.         FROM " . BANLIST_TABLE . "
  154.         WHERE ban_ip IN ('" . $user_ip_parts[1] . $user_ip_parts[2] . $user_ip_parts[3] . $user_ip_parts[4] . "', '" . $user_ip_parts[1] . $user_ip_parts[2] . $user_ip_parts[3] . "ff', '" . $user_ip_parts[1] . $user_ip_parts[2] . "ffff', '" . $user_ip_parts[1] . "ffffff')
  155.             OR ban_userid = $user_id";
  156.     if ( $user_id != ANONYMOUS )
  157.     {
  158.         $sql .= " OR ban_email LIKE '" . str_replace("\'", "''", $userdata['user_email']) . "'
  159.             OR ban_email LIKE '" . substr(str_replace("\'", "''", $userdata['user_email']), strpos(str_replace("\'", "''", $userdata['user_email']), "@")) . "'";
  160.     }
  161.     if ( !($result = $db->sql_query($sql)) )
  162.     {
  163.         message_die(CRITICAL_ERROR, 'Could not obtain ban information', '', __LINE__, __FILE__, $sql);
  164.     }
  165.  
  166.     if ( $ban_info = $db->sql_fetchrow($result) )
  167.     {
  168.         if ( $ban_info['ban_ip'] || $ban_info['ban_userid'] || $ban_info['ban_email'] )
  169.         {
  170.             message_die(CRITICAL_MESSAGE, 'You_been_banned');
  171.         }
  172.     }
  173.  
  174.     //
  175.     // Create or update the session
  176.     //
  177.     $sql = "UPDATE " . SESSIONS_TABLE . "
  178.         SET session_user_id = $user_id, session_start = $current_time, session_time = $current_time, session_page = $page_id, session_logged_in = $login
  179.         WHERE session_id = '" . $session_id . "'
  180.             AND session_ip = '$user_ip'";
  181.     if ( !$db->sql_query($sql) || !$db->sql_affectedrows() )
  182.     {
  183.         $session_id = md5(uniqid($user_ip));
  184.  
  185.         $sql = "INSERT INTO " . SESSIONS_TABLE . "
  186.             (session_id, session_user_id, session_start, session_time, session_ip, session_page, session_logged_in)
  187.             VALUES ('$session_id', $user_id, $current_time, $current_time, '$user_ip', $page_id, $login)";
  188.         if ( !$db->sql_query($sql) )
  189.         {
  190.                 $error = TRUE;
  191.                 if (SQL_LAYER == "mysql" || SQL_LAYER == "mysql4")
  192.                 {
  193.                     $sql_error = $db->sql_error($result);
  194.                     if ($sql_error["code"] == 1114)
  195.                     {
  196.                         $result = $db->sql_query('SHOW TABLE STATUS LIKE "'.SESSIONS_TABLE.'"');
  197.                         $row = $db->sql_fetchrow($result);
  198.                         if ($row["Type"] == "HEAP")
  199.                         {
  200.                             if ($row["Rows"] > 2500)
  201.                             {
  202.                                 $delete_order = (SQL_LAYER=="mysql4") ? " ORDER BY session_time ASC" : "";
  203.                                 $db->sql_query("DELETE QUICK FROM ".SESSIONS_TABLE."$delete_order LIMIT 50");
  204.                             }
  205.                             else
  206.                             {
  207.                                 $db->sql_query("ALTER TABLE ".SESSIONS_TABLE." MAX_ROWS=".($row["Rows"]+50));
  208.                             }
  209.                             if ($db->sql_query($sql))
  210.                             {
  211.                                 $error = FALSE;
  212.                             }
  213.                         }
  214.                     }
  215.                 }
  216.                 if ($error)
  217.                 {
  218.                     message_die(CRITICAL_ERROR, "Error creating new session", "", __LINE__, __FILE__, $sql);
  219.                 }
  220.                 }
  221.     }
  222.  
  223.     if ( $user_id != ANONYMOUS )
  224.     {// ( $userdata['user_session_time'] > $expiry_time && $auto_create ) ? $userdata['user_lastvisit'] : (
  225.         $last_visit = ( $userdata['user_session_time'] > 0 ) ? $userdata['user_session_time'] : $current_time;
  226.  
  227.         $sql = "UPDATE " . USERS_TABLE . "
  228.             SET user_session_time = $current_time, user_session_page = $page_id, user_lastvisit = $last_visit
  229.             WHERE user_id = $user_id";
  230.         if ( !$db->sql_query($sql) )
  231.         {
  232.             message_die(CRITICAL_ERROR, 'Error updating last visit time', '', __LINE__, __FILE__, $sql);
  233.         }
  234.  
  235.         $userdata['user_lastvisit'] = $last_visit;
  236.  
  237.         $sessiondata['autologinid'] = ( $enable_autologin && $sessionmethod == SESSION_METHOD_COOKIE ) ? $auto_login_key : '';
  238.         $sessiondata['userid'] = $user_id;
  239.     }
  240.  
  241.     $userdata['session_id'] = $session_id;
  242.     $userdata['session_ip'] = $user_ip;
  243.     $userdata['session_user_id'] = $user_id;
  244.     $userdata['session_logged_in'] = $login;
  245.     $userdata['session_page'] = $page_id;
  246.     $userdata['session_start'] = $current_time;
  247.     $userdata['session_time'] = $current_time;
  248.  
  249.     setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);
  250.     setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure);
  251.     $SID = ( $sessionmethod == SESSION_METHOD_GET ) ? 'sid=' . $session_id : '';
  252.  
  253.     return $userdata;
  254. }
  255.  
  256. //
  257. // Checks for a given user session, tidies session table and updates user
  258. // sessions at each page refresh
  259. //
  260. function session_pagestart($user_ip, $thispage_id, $nukeuser)
  261. {
  262.     global $db, $lang, $board_config, $session_id;
  263.     global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;
  264.  
  265.     $cookiename = $board_config['cookie_name'];
  266.     $cookiepath = $board_config['cookie_path'];
  267.     $cookiedomain = $board_config['cookie_domain'];
  268.     $cookiesecure = $board_config['cookie_secure'];
  269.  
  270.     $current_time = time();
  271.     unset($userdata);
  272.  
  273.     if ( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) || isset($HTTP_COOKIE_VARS[$cookiename . '_data']) )
  274.     {
  275.         $sessiondata = isset( $HTTP_COOKIE_VARS[$cookiename . '_data'] ) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookiename . '_data'])) : array();
  276.         $session_id = isset( $HTTP_COOKIE_VARS[$cookiename . '_sid'] ) ? $HTTP_COOKIE_VARS[$cookiename . '_sid'] : '';
  277.         $sessionmethod = SESSION_METHOD_COOKIE;
  278.     }
  279.     else
  280.     {
  281.         $sessiondata = array();
  282.         $session_id = ( isset($HTTP_GET_VARS['sid']) ) ? $HTTP_GET_VARS['sid'] : '';
  283.         $sessionmethod = SESSION_METHOD_GET;
  284.     }
  285.         if ( ($nukeuser != "") && ($userdata['session_logged_in'] == "" )) {
  286.                 bblogin($nukeuser, $session_id);
  287.         } else {
  288.                 $sessiondata = array();
  289.         }
  290.  
  291.     //
  292.     // Does a session exist?
  293.     //
  294.     if ( !empty($session_id) )
  295.     {
  296.         //
  297.         // session_id exists so go ahead and attempt to grab all
  298.         // data in preparation
  299.         //
  300.         $sql = "SELECT u.*, s.*
  301.             FROM " . SESSIONS_TABLE . " s, " . USERS_TABLE . " u
  302.             WHERE s.session_id = '$session_id'
  303.                 AND u.user_id = s.session_user_id";
  304.         if ( !($result = $db->sql_query($sql)) )
  305.         {
  306.             message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch', '', __LINE__, __FILE__, $sql);
  307.         }
  308.  
  309.         $userdata = $db->sql_fetchrow($result);
  310.  
  311.         //
  312.         // Did the session exist in the DB?
  313.         //
  314.         if ( isset($userdata['user_id']) )
  315.         {
  316.             //
  317.             // Do not check IP assuming equivalence, if IPv4 we'll check only first 24
  318.             // bits ... I've been told (by vHiker) this should alleviate problems with
  319.             // load balanced et al proxies while retaining some reliance on IP security.
  320.             //
  321.             $ip_check_s = substr($userdata['session_ip'], 0, 6);
  322.             $ip_check_u = substr($user_ip, 0, 6);
  323.  
  324.             if ($ip_check_s == $ip_check_u)
  325.             {
  326.                 $SID = ($sessionmethod == SESSION_METHOD_GET || defined('IN_ADMIN')) ? 'sid=' . $session_id : '';
  327.  
  328.                 //
  329.                 // Only update session DB a minute or so after last update
  330.                 //
  331.                 if ( $current_time - $userdata['session_time'] > 60 )
  332.                 {
  333.                     $sql = "UPDATE " . SESSIONS_TABLE . "
  334.                         SET session_time = $current_time, session_page = $thispage_id
  335.                         WHERE session_id = '" . $userdata['session_id'] . "'";
  336.                     if ( !$db->sql_query($sql) )
  337.                     {
  338.                         message_die(CRITICAL_ERROR, 'Error updating sessions table', '', __LINE__, __FILE__, $sql);
  339.                     }
  340.  
  341.                     if ( $userdata['user_id'] != ANONYMOUS )
  342.                     {
  343.                         $sql = "UPDATE " . USERS_TABLE . "
  344.                             SET user_session_time = $current_time, user_session_page = $thispage_id
  345.                             WHERE user_id = " . $userdata['user_id'];
  346.                         if ( !$db->sql_query($sql) )
  347.                         {
  348.                             message_die(CRITICAL_ERROR, 'Error updating sessions table', '', __LINE__, __FILE__, $sql);
  349.                         }
  350.                     }
  351.  
  352.                     //
  353.                     // Delete expired sessions
  354.                     //
  355.                     $expiry_time = $current_time - $board_config['session_length'];
  356.                     $sql = "DELETE FROM " . SESSIONS_TABLE . "
  357.                         WHERE session_time < $expiry_time
  358.                             AND session_id <> '$session_id'";
  359.                     if ( !$db->sql_query($sql) )
  360.                     {
  361.                         message_die(CRITICAL_ERROR, 'Error clearing sessions table', '', __LINE__, __FILE__, $sql);
  362.                     }
  363.  
  364.                     setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);
  365.                     setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure);
  366.                 }
  367.  
  368.                 return $userdata;
  369.             }
  370.         }
  371.     }
  372.  
  373.     //
  374.     // If we reach here then no (valid) session exists. So we'll create a new one,
  375.     // using the cookie user_id if available to pull basic user prefs.
  376.     //
  377.     $user_id = ( isset($sessiondata['userid']) ) ? intval($sessiondata['userid']) : ANONYMOUS;
  378.  
  379.     if ( !($userdata = session_begin($user_id, $user_ip, $thispage_id, TRUE)) )
  380.     {
  381.         message_die(CRITICAL_ERROR, 'Error creating user session', '', __LINE__, __FILE__, $sql);
  382.     }
  383.  
  384.     return $userdata;
  385.  
  386. }
  387.  
  388. //
  389. // session_end closes out a session
  390. // deleting the corresponding entry
  391. // in the sessions table
  392. //
  393. function session_end($session_id, $user_id)
  394. {
  395.     global $db, $lang, $board_config;
  396.     global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;
  397.  
  398.     $cookiename = $board_config['cookie_name'];
  399.     $cookiepath = $board_config['cookie_path'];
  400.     $cookiedomain = $board_config['cookie_domain'];
  401.     $cookiesecure = $board_config['cookie_secure'];
  402.  
  403.     $current_time = time();
  404.  
  405.     //
  406.     // Pull cookiedata or grab the URI propagated sid
  407.     //
  408.     if ( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) )
  409.     {
  410.         $session_id = isset( $HTTP_COOKIE_VARS[$cookiename . '_sid'] ) ? $HTTP_COOKIE_VARS[$cookiename . '_sid'] : '';
  411.         $sessionmethod = SESSION_METHOD_COOKIE;
  412.     }
  413.     else
  414.     {
  415.         $session_id = ( isset($HTTP_GET_VARS['sid']) ) ? $HTTP_GET_VARS['sid'] : '';
  416.         $sessionmethod = SESSION_METHOD_GET;
  417.     }
  418.  
  419.     //
  420.     // Delete existing session
  421.     //
  422.     $sql = "DELETE FROM " . SESSIONS_TABLE . "
  423.         WHERE session_id = '$session_id'
  424.             AND session_user_id = $user_id";
  425.     if ( !$db->sql_query($sql) )
  426.     {
  427.         message_die(CRITICAL_ERROR, 'Error removing user session', '', __LINE__, __FILE__, $sql);
  428.     }
  429.  
  430.     setcookie($cookiename . '_data', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);
  431.     setcookie($cookiename . '_sid', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);
  432.  
  433.     return true;
  434. }
  435.  
  436. //
  437. // Append $SID to a url. Borrowed from phplib and modified. This is an
  438. // extra routine utilised by the session code above and acts as a wrapper
  439. // around every single URL and form action. If you replace the session
  440. // code you must include this routine, even if it's empty.
  441. //
  442. function append_sid($url, $non_html_amp = false)
  443. {
  444.     global $SID, $admin;
  445.     if (ereg("admin=1", $url) || ereg("admin_", $url) || ereg("pane=", $url)){
  446.                                 //  The format is fine, don't change a thing.
  447.     } else if (ereg("Your_Account", $url)){
  448.             $url = str_replace(".php", "", $url);         //  Strip the .php from all the files,
  449.             $url = str_replace("modules", "modules.php", $url); //  and put it back for the modules.php
  450.     }
  451.     else if (ereg("redirect", $url))
  452.     {
  453.             $url = str_replace("login.php", "modules.php?name=Your_Account", $url);         //  Strip the .php from all the files,
  454.             $url = str_replace(".php", "", $url);         //  Strip the .php from all the files,
  455.             $url = str_replace("?redirect", "&redirect", $url);         //  Strip the .php from all the files,
  456.             $url = str_replace("modules", "modules.php", $url); //  and put it back for the modules.php
  457.     }
  458.     else if (ereg("menu=1", $url))
  459.     {
  460.             $url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
  461.             $url = str_replace(".php", "", $url);         //  Strip the .php from all the files,
  462.         $url = "../../../modules.php?name=Forums&file=$url";
  463.     }
  464.     else if ((ereg("privmsg", $url)) && (!ereg("highlight=privmsg", $url)))
  465.     {
  466.             $url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
  467.             $url = str_replace("privmsg.php", "modules.php?name=Private_Messages&file=index", $url); //  and put it back for the modules.php
  468.     }
  469.     else if ((ereg("profile", $url)) && (!ereg("highlight=profile", $url)))
  470.     {
  471.             $url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
  472.             $url = str_replace("profile.php", "modules.php?name=Forums&file=profile", $url); //  and put it back for the modules.php
  473.         $dummy = 1;
  474.     }
  475.     else if ((ereg("memberlist", $url)) && (!ereg("highlight=memberlist", $url)))
  476.     {
  477.             $url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
  478.             $url = str_replace("memberlist.php", "modules.php?name=Members_List&file=index", $url); //  and put it back for the modules.php
  479.     } else {
  480.             $url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
  481.             $url = str_replace(".php", "", $url);
  482.             $url = "modules.php?name=Forums&file=".$url; //Change to Nuke format
  483.     }
  484.  
  485.     if ( !empty($SID) && !eregi('sid=', $url) && !areyouabot()  )
  486.     {
  487.         if ( !empty($SID) && !eregi('sid=', $url) )    {
  488.         $url .= ( ( strpos($url, '?') != false ) ?  ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
  489.         }
  490.     }
  491.     return($url);
  492. }
  493. function areyouabot()
  494. {
  495. global $HTTP_SERVER_VARS;
  496.         $RobotsList = array (
  497.         "antibot",
  498.         "appie",
  499.         "architext",
  500.         "bjaaland",
  501.         "digout4u",
  502.         "echo",
  503.         "fast-webcrawler",
  504.         "ferret",
  505.         "googlebot",
  506.         "gulliver",
  507.         "harvest",
  508.         "htdig",
  509.         "ia_archiver",
  510.         "jeeves",
  511.         "jennybot",
  512.         "linkwalker",
  513.         "lycos",
  514.         "mercator",
  515.         "moget",
  516.         "muscatferret",
  517.         "myweb",
  518.         "netcraft",
  519.         "nomad",
  520.         "petersnews",
  521.         "scooter",
  522.         "slurp",
  523.         "unlost_web_crawler",
  524.         "voila",
  525.         "voyager",
  526.         "webbase",
  527.         "weblayers",
  528.         "wget",
  529.         "wisenutbot",
  530.         "acme.spider",
  531.         "ahoythehomepagefinder",
  532.         "alkaline",
  533.         "arachnophilia",
  534.         "aretha",
  535.         "ariadne",
  536.         "arks",
  537.         "aspider",
  538.         "atn.txt",
  539.         "atomz",
  540.         "auresys",
  541.         "backrub",
  542.         "bigbrother",
  543.         "blackwidow",
  544.         "blindekuh",
  545.         "bloodhound",
  546.         "brightnet",
  547.         "bspider",
  548.         "cactvschemistryspider",
  549.         "cassandra",
  550.         "cgireader",
  551.         "checkbot",
  552.         "churl",
  553.         "cmc",
  554.         "collective",
  555.         "combine",
  556.         "conceptbot",
  557.         "coolbot",
  558.         "core",
  559.         "cosmos",
  560.         "cruiser",
  561.         "cusco",
  562.         "cyberspyder",
  563.         "deweb",
  564.         "dienstspider",
  565.         "digger",
  566.         "diibot",
  567.         "directhit",
  568.         "dnabot",
  569.         "download_express",
  570.         "dragonbot",
  571.         "dwcp",
  572.         "e-collector",
  573.         "ebiness",
  574.         "eit",
  575.         "elfinbot",
  576.         "emacs",
  577.         "emcspider",
  578.         "esther",
  579.         "evliyacelebi",
  580.         "nzexplorer",
  581.         "fdse",
  582.         "felix",
  583.         "fetchrover",
  584.         "fido",
  585.         "finnish",
  586.         "fireball",
  587.         "fouineur",
  588.         "francoroute",
  589.         "freecrawl",
  590.         "funnelweb",
  591.         "gama",
  592.         "gazz",
  593.         "gcreep",
  594.         "getbot",
  595.         "geturl",
  596.         "golem",
  597.         "grapnel",
  598.         "griffon",
  599.         "gromit",
  600.         "hambot",
  601.         "havindex",
  602.         "hometown",
  603.         "htmlgobble",
  604.         "hyperdecontextualizer",
  605.         "iajabot",
  606.         "ibm",
  607.         "iconoclast",
  608.         "ilse",
  609.         "imagelock",
  610.         "incywincy",
  611.         "informant",
  612.         "infoseek",
  613.         "infoseeksidewinder",
  614.         "infospider",
  615.         "inspectorwww",
  616.         "intelliagent",
  617.         "irobot",
  618.         "iron33",
  619.         "israelisearch",
  620.         "javabee",
  621.         "jbot",
  622.         "jcrawler",
  623.         "jobo",
  624.         "jobot",
  625.         "joebot",
  626.         "jubii",
  627.         "jumpstation",
  628.         "katipo",
  629.         "kdd",
  630.         "kilroy",
  631.         "ko_yappo_robot",
  632.         "labelgrabber.txt",
  633.         "larbin",
  634.         "legs",
  635.         "linkidator",
  636.         "linkscan",
  637.         "lockon",
  638.         "logo_gif",
  639.         "macworm",
  640.         "magpie",
  641.         "marvin",
  642.         "mattie",
  643.         "mediafox",
  644.         "merzscope",
  645.         "meshexplorer",
  646.         "mindcrawler",
  647.         "momspider",
  648.         "monster",
  649.         "motor",
  650.         "mwdsearch",
  651.         "netcarta",
  652.         "netmechanic",
  653.         "netscoop",
  654.         "newscan-online",
  655.         "nhse",
  656.         "northstar",
  657.         "occam",
  658.         "octopus",
  659.         "openfind",
  660.         "orb_search",
  661.         "packrat",
  662.         "pageboy",
  663.         "parasite",
  664.         "patric",
  665.         "pegasus",
  666.         "perignator",
  667.         "perlcrawler",
  668.         "phantom",
  669.         "piltdownman",
  670.         "pimptrain",
  671.         "pioneer",
  672.         "pitkow",
  673.         "pjspider",
  674.         "pka",
  675.         "plumtreewebaccessor",
  676.         "poppi",
  677.         "portalb",
  678.         "puu",
  679.         "python",
  680.         "raven",
  681.         "rbse",
  682.         "resumerobot",
  683.         "rhcs",
  684.         "roadrunner",
  685.         "robbie",
  686.         "robi",
  687.         "robofox",
  688.         "robozilla",
  689.         "roverbot",
  690.         "rules",
  691.         "safetynetrobot",
  692.         "search_au",
  693.         "searchprocess",
  694.         "senrigan",
  695.         "sgscout",
  696.         "shaggy",
  697.         "shaihulud",
  698.         "sift",
  699.         "simbot",
  700.         "site-valet",
  701.         "sitegrabber",
  702.         "sitetech",
  703.         "slcrawler",
  704.         "smartspider",
  705.         "snooper",
  706.         "solbot",
  707.         "spanner",
  708.         "speedy",
  709.         "spider_monkey",
  710.         "spiderbot",
  711.         "spiderline",
  712.         "spiderman",
  713.         "spiderview",
  714.         "spry",
  715.         "ssearcher",
  716.         "suke",
  717.         "suntek",
  718.         "sven",
  719.         "tach_bw",
  720.         "tarantula",
  721.         "tarspider",
  722.         "techbot",
  723.         "templeton",
  724.         "teoma_agent1",
  725.         "titin",
  726.         "titan",
  727.         "tkwww",
  728.         "tlspider",
  729.         "ucsd",
  730.         "udmsearch",
  731.         "urlck",
  732.         "valkyrie",
  733.         "victoria",
  734.         "visionsearch",
  735.         "vwbot",
  736.         "w3index",
  737.         "w3m2",
  738.         "wallpaper",
  739.         "wanderer",
  740.         "wapspider",
  741.         "webbandit",
  742.         "webcatcher",
  743.         "webcopy",
  744.         "webfetcher",
  745.         "webfoot",
  746.         "weblinker",
  747.         "webmirror",
  748.         "webmoose",
  749.         "webquest",
  750.         "webreader",
  751.         "webreaper",
  752.         "websnarf",
  753.         "webspider",
  754.         "webvac",
  755.         "webwalk",
  756.         "webwalker",
  757.         "webwatch",
  758.         "whatuseek",
  759.         "whowhere",
  760.         "wired-digital",
  761.         "wmir",
  762.         "wolp",
  763.         "wombat",
  764.         "worm",
  765.         "wwwc",
  766.         "wz101",
  767.         "xget",
  768.         "awbot",
  769.         "bobby",
  770.         "boris",
  771.         "bumblebee",
  772.         "cscrawler",
  773.         "daviesbot",
  774.         "ezresult",
  775.         "gigabot",
  776.         "gnodspider",
  777.         "internetseer",
  778.         "justview",
  779.         "linkbot",
  780.         "linkchecker",
  781.         "nederland.zoek",
  782.         "perman",
  783.         "pompos",
  784.         "psbot",
  785.         "redalert",
  786.         "shoutcast",
  787.         "slysearch",
  788.         "ultraseek",
  789.         "webcompass",
  790.         "yandex",
  791.         "robot",
  792.         "crawl"
  793.         );
  794.         $botID = strtolower($HTTP_SERVER_VARS['HTTP_USER_AGENT']);
  795.         for ($i = 0; $i < count($RobotsList); $i++)
  796.         {
  797.                 if ( strstr($botID, $RobotsList[$i]) )
  798.                 {
  799.                         return TRUE;
  800.                 }
  801.         }
  802.         return FALSE;
  803.  
  804. }
  805. function admin_sid($url, $non_html_amp = false)
  806. {
  807.     global $SID;
  808.         $url = "../../../modules.php?name=Forums&file=$url";
  809.  
  810.     if ( !empty($SID) && !preg_match('#sid=#', $url) )
  811.     {
  812.         $url .= ( ( strpos($url, '?') != false ) ?  ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
  813.     }
  814.  
  815.     return $url;
  816. }
  817.  
  818. ?>