public static function update_visitor_log($uid, $force_update = false) { $http_referer = session::$db->escape(session::get_http_referer()); $user_agent = session::$db->escape(session::get_user_agent()); $ip_address = session::$db->escape(get_ip_address()); if (!($forum_fid = get_forum_fid())) { $forum_fid = 0; } $current_datetime = date(MYSQL_DATETIME, time()); $uid = is_numeric($uid) && $uid > 0 ? session::$db->escape($uid) : 'NULL'; if (!($search_id = session::is_search_engine())) { $search_id = 'NULL'; } if (!$force_update) { $sql = "SELECT UNIX_TIMESTAMP(MAX(LAST_LOGON)) FROM VISITOR_LOG WHERE FORUM = {$forum_fid} "; $sql .= "AND ((UID = {$uid} AND {$uid} IS NOT NULL) OR (SID = {$search_id} AND {$search_id} IS NOT NULL) "; $sql .= "OR (IPADDRESS = '{$ip_address}' AND {$uid} IS NULL AND {$search_id} IS NULL))"; if (!($result = session::$db->query($sql))) { return false; } list($last_logon) = $result->fetch_row(); } if (!isset($last_logon) || $last_logon < time() - HOUR_IN_SECONDS) { $sql = "REPLACE INTO VISITOR_LOG (FORUM, UID, LAST_LOGON, IPADDRESS, REFERER, USER_AGENT, SID) "; $sql .= "VALUES ('{$forum_fid}', {$uid}, CAST('{$current_datetime}' AS DATETIME), '{$ip_address}', "; $sql .= "'{$http_referer}', '{$user_agent}', {$search_id})"; if (!session::$db->query($sql)) { return false; } } return true; }
function light_html_draw_bottom() { static $called = false; if ($called) { return; } $called = true; $webtag = get_webtag(); forum_check_webtag_available($webtag); echo "</div>\n"; echo "<div id=\"footer\">\n"; if (!session::is_search_engine()) { echo " <div id=\"footer_links\">\n"; echo " <a href=\"#top\">", gettext("Top"), "</a> · <a href=\"index.php?webtag={$webtag}&view=full\">", gettext("Desktop Version"), "</a>\n"; echo " </div>\n"; } echo " <h6><a href=\"http://www.beehiveforum.co.uk/\" target=\"_blank\">Beehive Forum ", BEEHIVE_VERSION, "<br />© ", strftime('%Y'), " Project Beehive Forum</a></h6>\n"; echo "</div>\n"; echo "</body>\n"; echo "</html>\n"; }
$mode = ALL_DISCUSSIONS; } } } if (browser_mobile()) { light_html_draw_top(array('js' => array('js/thread_list.js'))); } if (forums_get_available_count() > 1 || !forum_get_default()) { light_navigation_bar(array('back' => "lforums.php?webtag={$webtag}")); } else { light_navigation_bar(); } light_draw_thread_list($mode, $folder, $start_from); } } } else { if (browser_mobile()) { light_html_draw_top(); } light_navigation_bar(); light_draw_my_forums(); } if (!browser_mobile() && !session::is_search_engine()) { echo "</div>\n"; echo "</body>\n"; echo "</noframes>\n"; echo "</frameset>\n"; html_draw_bottom(true); } else { light_html_draw_bottom(); }
function browser_mobile() { $mobile_browser = 0; if (isset($_SERVER['HTTP_ACCEPT']) && strpos(strtolower($_SERVER['HTTP_ACCEPT']), 'application/vnd.wap.xhtml+xml') !== false) { $mobile_browser++; } if (isset($_SERVER['HTTP_X_WAP_PROFILE'])) { $mobile_browser++; } if (isset($_SERVER['HTTP_PROFILE'])) { $mobile_browser++; } // User Agent from https://code.google.com/p/the-devices-detection/source/list $mobile_agents = array('iPhone', 'iPad', 'iPod', 'incognito', 'webmate', 'dream', 'CUPCAKE', 'webOS', 's8000', 'Googlebot-Mobile', 'Palm', 'EudoraWeb', 'Blazer', 'AvantGo', 'Android', 'Windows CE', 'Cellphone', 'Small', 'MMEF20', 'Danger', 'hiptop', 'Proxinet', 'ProxiNet', 'Newt', 'PalmOS', 'NetFront', 'SHARP-TQ-GX10', 'SonyEricsson', 'SymbianOS', 'UP.Browser', 'UP.Link', 'TS21i-10', 'MOT-V', 'portalmmm', 'DoCoMo', 'Opera Mini', 'Palm', 'Handspring', 'Nokia', 'Kyocera', 'Samsung', 'Motorola', 'Mot', 'Smartphone', 'Blackberry', 'WAP', 'SonyEricsson', 'PlayStation Portable', 'LG', 'MMP', 'OPWV', 'Symbian', 'EPOC'); $mobile_agents_preg = implode('|', array_map('preg_quote_callback', $mobile_agents)); if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/({$mobile_agents_preg})/u", $_SERVER['HTTP_USER_AGENT'])) { $mobile_browser++; } if (isset($_SERVER['ALL_HTTP']) && strpos(strtolower($_SERVER['ALL_HTTP']), 'operamini') !== false) { $mobile_browser++; } // Exclude Windows desktop browsers if (isset($_SERVER['ALL_HTTP']) && strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'windows') !== false) { $mobile_browser = 0; } // Windows Phone 7 if (isset($_SERVER['ALL_HTTP']) && strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'windows phone') !== false) { $mobile_browser++; } if (html_get_cookie('view', 'full')) { $mobile_browser = 0; } if (session::is_search_engine() || html_get_cookie('view', 'mobile')) { $mobile_browser++; } return $mobile_browser > 0; }
public static function update_visitor_log($uid, $forum_fid) { $ip_address = get_ip_address(); $http_referer = session::$db->escape(session::get_http_referer()); $user_agent = session::$db->escape(session::get_user_agent()); $ip_address = session::$db->escape($ip_address); $current_datetime = date(MYSQL_DATETIME, time()); $uid = is_numeric($uid) && $uid > 0 ? $uid : 'NULL'; if (!($search_id = session::is_search_engine())) { $search_id = 'NULL'; } $sql = "REPLACE INTO VISITOR_LOG (FORUM, UID, LAST_LOGON, IPADDRESS, REFERER, USER_AGENT, SID) "; $sql .= "VALUES ('{$forum_fid}', {$uid}, CAST('{$current_datetime}' AS DATETIME), '{$ip_address}', "; $sql .= "'{$http_referer}', '{$user_agent}', {$search_id})"; if (!session::$db->query($sql)) { return false; } return true; }