Rev 30 | Rev 35 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php// Get current page file name$pageFile = basename($_SERVER['PHP_SELF']);// Include config file && User classrequire_once 'config.php';require_once 'User.class.php';// Check whether user ID is available in cookieif(isset($_COOKIE['rememberUserId']) && !empty($rememberUserId)){$_SESSION['sessData']['userLoggedIn'] = TRUE;$_SESSION['sessData']['userID'] = $rememberUserId;}// Get session data$sessData = !empty($_SESSION['sessData'])?$_SESSION['sessData']:array();// Redirect to homepage if user not logged in$userLoggedIn = (!empty($sessData['userLoggedIn']) && !empty($sessData['userID']))?true:false;switch($pageFile){case 'account.php':case 'editAccount.php':case 'changePassword.php':if($userLoggedIn){$user = new User();$conditions['where'] = array('id' => $sessData['userID'],);$conditions['return_type'] = 'single';$userData = $user->getRows($conditions);$httpPos = strpos($userData['picture'], 'http');if($httpPos === false){$userPicture = !empty($userData['picture'])?UPLOAD_URL.'profile_picture/'.$userData['picture']:PUBLIC_URL.'images/default.png';}else{$userPicture = $userData['picture'];}$userName = $userData['first_name'].' '.$userData['last_name'];}else{MySessionHandler::commit(session_id());header("Location: index.php");exit();}break;case 'forgotPassword.php':case 'registration.php':case 'resetPassword.php':if($userLoggedIn){MySessionHandler::commit(session_id());header("Location: account.php");exit();}break;case 'index.php':case 'index.php':if($userLoggedIn){MySessionHandler::commit(session_id());header("Location: account.php");exit();}else{// Include social login handlerrequire_once 'socialLogin.php';}// fall throughdefault:$userData = array();}// Get status message from sessionif(!empty($sessData['status']['msg'])){$statusMsg = $sessData['status']['msg'];$statusMsgType = $sessData['status']['type'];unset($_SESSION['sessData']['status']);}MySessionHandler::commit(session_id());