Пример #1
0
 public function Register()
 {
     $login = $_POST['login'];
     $password = $_POST['password'];
     Session::start();
     //$captcha = $_SESSION['rand_code'];
     $captcha = $_POST['captcha'];
     unset($_SESSION['rand_code']);
     $err = User::Validate($login, $password, $_POST['password_to'], $captcha);
     if (empty($err)) {
         $user = new User($login, $password);
         $user->login = $login;
         $user->password = sha1($password);
         $user->save();
         $stats = new Stats();
         $stats->login = $user->login;
         $stats->Save();
         $state = new State();
         $state->login = $user->login;
         $state->save();
         $forest = new Forest();
         $forest->login = $user->login;
         $forest->save();
         $stock = new Stock();
         $stock->login = $user->login;
         $stock->save();
         Notification::Set($login . ', Вы зарегистрировались, можете войти на сайт', 'Accept');
         header('location: /visitor/login');
         die;
     } else {
         Notification::Set($err, 'Error');
         header('location: /visitor/register');
         die;
     }
 }
Пример #2
0
 public function init()
 {
     //если не авторизован перенаврабляем на страницу авторизации
     if (!Auth::IsAuth()) {
         header('location: /visitor/login');
         die;
     }
     $this->view = new View();
     $this->view->notification = Notification::Get();
     $stats = Stats::FindByColumn('login', Auth::GetLogin());
     if ($stats === false) {
         Auth::Logout();
         header('location: /visitor/login');
         die;
     }
     $this->view->stats = $stats;
     $state = State::FindByColumn('login', Auth::GetLogin());
     if ($state->state == 'gamer') {
         header('location: /game');
         die;
     }
 }