sql_query($sql); $ip = $_SERVER["REMOTE_ADDR"]; $ctime = time(); if ($_SESSION['logged'] == true) { $cookietime= time()+3600*24*14; setcookie ("crfauth[logged]", "true", $cookietime); setcookie ("crfauth[uid]", $_SESSION['uid'] , $cookietime); setcookie ("crfauth[username]", $_SESSION['username'], $cookietime); setcookie ("crfauth[auth]", $_SESSION['auth'], $cookietime); setcookie ("crfauth[access]", $_SESSION['access'], $cookietime); $uname = $_SESSION['username']; if (isset($_SERVER['HTTP_USER_AGENT'])) { $agent = $_SERVER['HTTP_USER_AGENT']; } else { $agent = ''; } $sql = "SELECT time FROM sessions WHERE `host_addr` = '$ip'";// $result = $db->sql_query($sql); if ($db->sql_numrows($result) > 0) { $sql = "UPDATE `sessions` SET `uname`='$uname', `time`='$ctime', `host_addr`='$ip', `guest`='1', `agent` = '$agent' WHERE `host_addr` = '$ip';"; } else { $sql = "INSERT INTO `sessions` (`uname`, `time`, `host_addr`, `guest`, `agent`) VALUES ('$uname', '$ctime', '$ip', '1', '$agent');"; } $db->sql_query($sql); } else { session_defaults(); $uname = "Anonymous"; $agent = $_SERVER['HTTP_USER_AGENT']; if (preg_match("/Yahoo/i", $agent)){ $uname = "Slurp (Yahoo Bot)"; } elseif (preg_match("/googlebot/i", $agent)){ $uname = "Googlebot"; } elseif (preg_match("/Feedburner/i", $agent)){ $uname = "Feedburner"; } elseif (preg_match("/Feedfetcher/i", $agent)){ $uname = "Feedfetcher (Google)"; } elseif (preg_match("/msnbot/i", $agent)){ $uname = "MSNBot"; } elseif (preg_match("/Baiduspider/i", $agent)){ $uname = "Baiduspider"; } elseif (preg_match("/Freecrawl/i", $agent)){ $uname = "Freecrawl"; } elseif (preg_match("/ia_archiver/i", $agent)){ $uname = "AlexaBot"; } elseif (preg_match("/Mediapartners/i", $agent)){ $uname = "Mediapartners (Adsense)"; } elseif (preg_match("/SnapPreviewBot/i", $agent)){ $uname = "Snap Preview Bot"; } elseif (preg_match("/Speedy Spider/i", $agent)){ $uname = "Speedy Spider"; } elseif (preg_match("/pramnos/i", $agent)){ $uname = "Pramnos.net Toolbar"; } elseif (preg_match("/IRLbot/i", $agent)){ $uname = "IRLbot"; } elseif (preg_match("/Gigabot/i", $agent)){ $uname = "Gigabot"; } elseif (preg_match("/J12bot/i", $agent)){ $uname = "MJ12bot"; } elseif (preg_match("/InternetSeer/i", $agent)){ $uname = "InternetSeer"; } elseif ($ip == "62.1.217.20" and $agent == "") { $uname = "Pramnos.gr Server"; $agent = "Pramnos.gr"; } $sql = "SELECT time FROM sessions WHERE `host_addr` = '$ip'";// $result = $db->sql_query($sql); if ($db->sql_numrows($result) > 0) { $sql = "UPDATE `sessions` SET `uname`='$uname', `time`='$ctime', `host_addr`='$ip', `guest`='1', `agent` = '$agent' WHERE `host_addr` = '$ip';"; } else { $sql = "INSERT INTO `sessions` (`uname`, `time`, `host_addr`, `guest`, `agent`) VALUES ('$uname', '$ctime', '$ip', '1', '$agent');"; } $db->sql_query($sql); } } function session_defaults() { global $config, $_GET, $_COOKIE, $db; $_SESSION['logged'] = false; $_SESSION['uid'] = 1; $_SESSION['username'] = ''; $_SESSION['cookie'] = 0; $_SESSION['remember'] = false; $_SESSION['access'] = 0; $_SESSION['auth'] = ""; if (isset($_COOKIE['crfauth'])) { $sql = "SELECT userid, username, password FROM users WHERE `username` = '".$_COOKIE['crfauth']['username']."' and `active` = '1'"; $result = $db->sql_query($sql); $setinfo = $db->sql_fetchrow($result); if ($_COOKIE['crfauth']['auth'] == $setinfo['password'] and $_COOKIE['crfauth']['uid'] == $setinfo['userid']) { $_SESSION['logged'] = true; $_SESSION['uid'] = $_COOKIE['crfauth']['uid']; $_SESSION['username'] = $_COOKIE['crfauth']['username']; $_SESSION['cookie'] = 1; $_SESSION['remember'] = true; $_SESSION['auth'] = $_COOKIE['crfauth']['auth']; $_SESSION['access'] = $_COOKIE['crfauth']['access']; } } } //End of session management ?> CRF Zygomycosis Application