Guest User

ERROR

a guest
Nov 6th, 2012
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.25 KB | None | 0 0
  1. //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
  2.  
  3. {class e_online {
  4.     function online($online_tracking = false, $flood_control = false) {
  5.         if($online_tracking == true || $flood_control == true)
  6.         {
  7.             global $online_timeout, $online_warncount, $online_bancount;
  8.             if(!isset($online_timeout)) {
  9.                 $online_timeout = 300;
  10.             }
  11.             if(!isset($online_warncount)) {
  12.                 $online_warncount = 90;
  13.             }
  14.             if(!isset($online_bancount)) {
  15.                 $online_bancount = 100;
  16.             }
  17.             global $sql, $pref, $e107, $listuserson, $e_event, $tp;
  18.             $page = (strpos(e_SELF, "forum_") !== FALSE) ? e_SELF.".".e_QUERY : e_SELF;
  19.             $page = (strpos(e_SELF, "comment") !== FALSE) ? e_SELF.".".e_QUERY : $page;
  20.             $page = (strpos(e_SELF, "content") !== FALSE) ? e_SELF.".".e_QUERY : $page;
  21.             $page = $tp -> toDB($page, true);
  22.  
  23.             $ip = $e107->getip();
  24.             $udata = (USER === true ? USERID.".".USERNAME : "0");
  25.  
  26.             if (USER)
  27.             {
  28.                 // Find record that matches IP or visitor, or matches user info
  29.                 if ($sql->db_Select("online", "*", "(`online_ip` = '{$ip}' AND `online_user_id` = '0') OR `online_user_id` = '{$udata}'")) {
  30.                     $row = $sql->db_Fetch();
  31.  
  32.                     if ($row['online_user_id'] == $udata) {
  33.                         //Matching user record
  34.                         if ($row['online_timestamp'] < (time() - $online_timeout)) {
  35.                             //It has been at least 'timeout' seconds since this user has connected
  36.                             //Update user record with timestamp, current IP, current page and set pagecount to 1
  37.                             $query = "online_timestamp='".time()."', online_ip='{$ip}', online_location='{$page}', online_pagecount=1 WHERE online_user_id='{$row['online_user_id']}' LIMIT 1";
  38.                         } else {
  39.                             if (!ADMIN) {
  40.                                 $row['online_pagecount'] ++;
  41.                             }
  42.                             // Update user record with current IP, current page and increment pagecount
  43.                             $query = "online_ip='{$ip}', `online_location` = '{$page}', `online_pagecount` = '".intval($row['online_pagecount'])."' WHERE `online_user_id` = '{$row['online_user_id']}' LIMIT 1";
  44.                         }
  45.                     } else {
  46.                         //Found matching visitor record (ip only) for this user
  47.                         if ($row['online_timestamp'] < (time() - $online_timeout)) {
  48.                             // It has been at least 'timeout' seconds since this user has connected
  49.                             // Update record with timestamp, current IP, current page and set pagecount to 1
  50.                             $query = "`online_timestamp` = '".time()."', `online_user_id` = '{$udata}', `online_location` = '{$page}', `online_pagecount` = 1 WHERE `online_ip` = '{$ip}' AND `online_user_id` = '0' LIMIT 1";
  51.                         } else {
  52.                             if (!ADMIN) {
  53.                                 $row['online_pagecount'] ++;
  54.                             }
  55.                             //Update record with current IP, current page and increment pagecount
  56.                             $query = "`online_user_id` = '{$udata}', `online_location` = '{$page}', `online_pagecount` = ".intval($row['online_pagecount'])." WHERE `online_ip` = '{$ip}' AND `online_user_id` = '0' LIMIT 1";
  57.                         }
  58.                     }
  59.                     $sql->db_Update("online", $query);
  60.                 } else {
  61.                     $sql->db_Insert("online", " '".time()."', '0', '{$udata}', '{$ip}', '{$page}', 1, 0");
  62.                 }
  63.             }
  64.             else
  65.             {
  66.                 //Current page request is from a visitor
  67.                 if ($sql->db_Select("online", "*", "`online_ip` = '{$ip}' AND `online_user_id` = '0'")) {
  68.                     $row = $sql->db_Fetch();
  69.  
  70.                     if ($row['online_timestamp'] < (time() - $online_timeout)) //It has been at least 'timeout' seconds since this ip has connected
  71.                     {
  72.                         //Update record with timestamp, current page, and set pagecount to 1
  73.                         $query = "`online_timestamp` = '".time()."', `online_location` = '{$page}', `online_pagecount` = 1 WHERE `online_ip` = '{$ip}' AND `online_user_id` = '0' LIMIT 1";
  74.                     } else {
  75.                         //Update record with current page and increment pagecount
  76.                         $row['online_pagecount'] ++;
  77.                         //   echo "here {$online_pagecount}";
  78.                         $query="`online_location` = '{$page}', `online_pagecount` = {$row['online_pagecount']} WHERE `online_ip` = '{$ip}' AND `online_user_id` = '0' LIMIT 1";
  79.                     }
  80.                     $sql->db_Update("online", $query);
  81.                 } else {
  82.                     $sql->db_Insert("online", " '".time()."', '0', '0', '{$ip}', '{$page}', 1, 0");
  83.                 }
  84.             }
  85.  
  86.         if (ADMIN || ($pref['autoban'] != 1 && $pref['autoban'] != 2) || (!isset($row['online_pagecount']))) // Auto-Ban is switched off. (0 or 3)
  87.             {
  88.                 $row['online_pagecount'] = 1;
  89.             }
  90.  
  91.             if ($row['online_pagecount'] > $online_bancount && ($row['online_ip'] != "127.0.0.1"))
  92.             {
  93.                 include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_banlist.php');
  94.                 $sql->db_Insert('banlist', "'{$ip}', '0', '".str_replace('--HITS--',$row['online_pagecount'],BANLAN_78)."' ");
  95.                 $e_event->trigger("flood", $ip);
  96.                 exit();
  97.             }
  98.             if ($row['online_pagecount'] >= $online_warncount && $row['online_ip'] != "127.0.0.1") {
  99.                 echo "<div style='text-align:center; font: 11px verdana, tahoma, arial, helvetica, sans-serif;'><b>".LAN_WARNING."</b><br /><br />".CORE_LAN6."<br /></div>";
  100.                 exit();
  101.             }
  102.  
  103.             $sql->db_Delete("online", "`online_timestamp` < ".(time() - $online_timeout));
  104.  
  105.             global $members_online, $total_online, $member_list, $listuserson;
  106.             $total_online = $sql->db_Count("online");
  107.             if ($members_online = $sql->db_Select("online", "*", "online_user_id != '0' ")) {
  108.                 $member_list = '';
  109.                 $listuserson = array();
  110.                 while ($row = $sql->db_Fetch()) {
  111.                     $vals = explode(".", $row['online_user_id'], 2);
  112.                     $member_list .= "<a href='".e_BASE."user.php?id.{$vals[0]}'>{$vals[1]}</a> ";
  113.                     $listuserson[$row['online_user_id']] = $row['online_location'];
  114.                 }
  115.             }
  116.             define("TOTAL_ONLINE", $total_online);
  117.             define("MEMBERS_ONLINE", $members_online);
  118.             define("GUESTS_ONLINE", $total_online - $members_online);
  119.             define("ON_PAGE", $sql->db_Count("online", "(*)", "WHERE `online_location` = '{$page}' "));
  120.             define("MEMBER_LIST", $member_list);
  121.         }
  122.         else
  123.         {
  124.             define("e_TRACKING_DISABLED", true);
  125.             define("TOTAL_ONLINE", "");
  126.             define("MEMBERS_ONLINE", "");
  127.             define("GUESTS_ONLINE", "");
  128.             define("ON_PAGE", "");
  129.             define("MEMBER_LIST", ""); //
  130.         }
  131.     }
  132. }
  133. }
  134. //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
Advertisement
Add Comment
Please, Sign In to add comment