Ejemplo n.º 1
0
 /**
  * Конструктор
  * 
  * @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);
         }
     }
 }
Ejemplo n.º 2
0
require_once SOURCE_PATH . "engine/libs/time/UTCTime.php";
require_once SOURCE_PATH . "UserSignInOut.php";
require_once SOURCE_PATH . "UserRegister.php";
require_once SOURCE_PATH . "UserFull.php";
require_once SOURCE_PATH . "UserUTCChange.php";
require_once SOURCE_PATH . "UserStatus.php";
require_once "UserDataChange.php";
require_once "AdditionalInfo.php";
require_once SOURCE_PATH . "engine/modules/accessLevelRights/AccessLevelController.php";
require_once "engine/modules/finder/Finder.php";
$r = new UserRegister();
//var_dump($data["urlArray"]);
$smarty = new SmartyExst();
$links = array("enterForm" => "/" . $data["urlArray"][1] . "/", "signInPath" => "/" . $data["urlArray"][1] . "/view/", "signOutPath" => "/" . $data["urlArray"][1] . "/logout/", "enter" => "/" . $data["urlArray"][1] . "/enter/", "register" => "/" . $data["urlArray"][1] . "/register/", "create" => "/" . $data["urlArray"][1] . "/create/", "settings" => "/" . $data["urlArray"][1] . "/settings/");
$smarty->assign("links", $links);
$usersSignInOut = new UserSignInOut();
if (isset($_SESSION["error"])) {
    echo $_SESSION["error"];
    unset($_SESSION["error"]);
}
switch ($data["parameters"][0]) {
    case "activate":
        if (isset($data["parameters"][1])) {
            $smarty->assign("ID", $data["parameters"][1]);
            $output["text"] = $smarty->fetch("users.activate.tpl");
        }
        break;
    case "doactivate":
        $registerUser = new UserRegister();
        try {
            if (!$registerUser->activateByKey($_POST["id"], $_POST["key"])) {