function startSession() { session_start(); $time = time(); $logged_in = checkLogin(); if (!$logged_in) { $username = $_SESSION['username'] = GUEST_NAME; $userlevel = GUEST_LEVEL; addActiveGuest($_SERVER['REMOTE_ADDR'], $time); } else { addActiveUser($username, $time); } // remove inactive users removeInactiveUsers(); removeInactiveGuests(); // set referrer page if (isset($_SESSION['url'])) { $referrer = $_SESSION['url']; } else { $referrer = "/"; } //set current url $url = $_SESSION['url'] = $_SERVER['PHP_SELF']; }
} else { if (empty($_POST['email1']) || empty($_POST['password1'])) { if (!$redirect) { $redirect = "/"; } header("Location: " . $redirect . "?loginfail=1"); } else { $user = strtolower(addslashes($_POST['email1'])); $pass = $_POST['password1']; if (confirmUserPass($user, $pass) == 0) { /* Username and password correct, register session variables */ $userinfo = getUserInfo($user); $username = $_SESSION['username'] = $userinfo['user_email']; $userlevel = $_SESSION['userlevel'] = $userinfo['user_type']; /* Update active users table */ addActiveUser($username, $time); removeActiveGuest($_SERVER['REMOTE_ADDR']); if (!$redirect) { $redirect = "/"; } header("Location: " . $redirect); } else { if (!$redirect) { $redirect = "/"; } header("Location: " . $redirect . "?loginfail=1"); } } } } }