/** * Конструктор * * @param integer $id Необязательный параметр. Если NULL, то берутся данные * пользователя который вошёл в систему (сессии), иначе по ID другого пользователя * @return User */ public final function __construct($id = NULL) { if (self::$instance != true) { throw new UserException(UserException::CREATION, 0); } MySQLConnector::__construct(); secureStartSession(); if ($id == NULL || $id == $_SESSION["user"]["id"]) { if (!isset($_SESSION["user"])) { $userSignOut = new UserSignInOut(); if ($userSignOut->checkIfSave()) { $uId = (int) $_COOKIE["id"]; $this->_sql->query("SELECT `mail`,`password` FROM `SITE_USERS` WHERE `id`={$uId}"); $secArr = $this->_sql->GetRows(); $mailSec = $secArr[0]["mail"]; $pass = $secArr[0]["password"]; if (md5($uId) . md5($mailSec) != $_COOKIE["sec"]) { throw new UserException("", UserException::USR_NOT_AUTENT); } else { $userSignOut->authentication($mailSec, $pass, false, true); $this->setData($_SESSION["user"]); $this->isOnline = true; } } else { throw new UserException("", UserException::USR_NOT_AUTENT); } } else { $this->setData($_SESSION["user"]); $this->isOnline = true; $this->checkLastTime(parent::$updateInterval); } } else { try { $this->other = true; $this->setData($this->getDataFromDb($id)); } catch (Exception $ex) { throw new UserException($id, UserException::USR_NOT_EXSIST); } } }
case "doactivate": $registerUser = new UserRegister(); try { if (!$registerUser->activateByKey($_POST["id"], $_POST["key"])) { $_SESSION["error"] = "WRONG KEY"; header("Location: /user/activate/{$_POST['id']}/"); } } catch (UserException $usEx) { $_SESSION["error"] = $usEx->getMessage(); header("Location: /user/activate/{$_POST['id']}/"); } break; case "enter": try { if (!$usersSignInOut->isEntered()) { $sigin = $usersSignInOut->authentication($_POST["mail"], $_POST["password"], $_POST["save"]); } } catch (UserException $ex) { $_SESSION["error"] = $ex->getMessage(); header("Location: /user/"); } if ($sigin) { header("Location: {$links['signInPath']}"); } break; case "view": try { if ($usersSignInOut->isEntered()) { if ($data["parameters"][1] != NULL) { $currentUser = UserFull::create($data["parameters"][1]); } else {