Наследование: extends Eloquent
 public function registerAction(Request $request)
 {
     $registerForm = new RegisterModel($request);
     if ($request->isPost()) {
         if ($registerForm->isValid()) {
             if ($registerForm->usernameValid()) {
                 if ($registerForm->passwordStrong()) {
                     if ($registerForm->isUserExist()) {
                         $registerForm->insertIntoDB();
                         Session::setFlash(__t('successfully_logged'));
                         $this->redirect("/");
                     } else {
                         Session::setFlash(__t('user_already_exists'));
                     }
                 } else {
                     Session::setFlash(__t('password_not_strong'));
                 }
             } else {
                 Session::setFlash(__t('invalid_login'));
             }
         } else {
             Session::setFlash($registerForm->passwordMath() ? __t('fill_fields') : __t('passwords_dont_match'));
         }
     }
     $args = array('registerForm' => $registerForm);
     return $this->render($args);
 }
Пример #2
0
 public function load()
 {
     parent::load();
     $this->SNdata = 0;
     $this->success = FALSE;
     $ip = $_SERVER['REMOTE_ADDR'];
     if ($this->isPost()) {
         if ($this->globalModel->isGameOver()) {
             $this->redirect("over.php");
         } else {
             $name = trim($_POST['name']);
             $email = trim($_POST['email']);
             $pwd = trim($_POST['pwd']);
             $this->err[0] = strlen($name) < 3 ? register_player_txt_notless3 : "";
             if ($this->err[0] == "") {
                 $this->err[0] = preg_match("/[:,\\. \\n\\r\\t\\s]+/", $name) ? register_player_txt_invalidchar : "";
             }
             if ($name == "[ally]" || $name == "admin" || $name == "administrator" || $name == "مدير" || $name == "تتار" || $name == "التتار" || $name == "دعم" || $name == "الدعم" || $name == $this->appConfig['system']['adminName'] || $name == tatar_tribe_player) {
                 $this->err[0] = register_player_txt_reserved;
             }
             $this->err[1] = !preg_match("/^[^@]+@[a-zA-Z0-9._-]+\\.[a-zA-Z]+\$/", $email) ? register_player_txt_invalidemail : "";
             $this->err[2] = strlen($pwd) < 4 ? register_player_txt_notless4 : "";
             $this->err[3] = !isset($_POST['tid']) || $_POST['tid'] != 1 && $_POST['tid'] != 2 && $_POST['tid'] != 3 && $_POST['tid'] != 6 && $_POST['tid'] != 7 ? "<li>" . register_player_txt_choosetribe . "</li>" : "";
             $this->err[3] .= !isset($_POST['kid']) || !is_numeric($_POST['kid']) || $_POST['kid'] < 0 || 4 < $_POST['kid'] ? "<li>" . register_player_txt_choosestart . "</li>" : "";
             if (0 < strlen($this->err[0]) || 0 < strlen($this->err[1]) || 0 < strlen($this->err[2]) || 0 < strlen($this->err[3])) {
                 return;
             }
             $m = new RegisterModel();
             $this->err[0] = $m->isPlayerNameExists($name) ? register_player_txt_usedname : "";
             $this->err[1] = $m->isPlayerEmailExists($email) ? register_player_txt_usedemail : "";
             $this->err[1] = $m->isPlayerIpExists($ip) ? "Canot Register IP address already in use" : "";
             if (0 < strlen($this->err[0]) || 0 < strlen($this->err[1])) {
                 $m->dispose();
             } else {
                 $ip = $_SERVER['REMOTE_ADDR'];
                 $villageName = new_village_name_prefix . " " . $name;
                 #removed 'PLAYERTYPE_NORMAL' right after map_size thing. Dunno why it doesnt make him player_type = 1 but owke.
                 $result = $m->createNewPlayer($name, $email, $pwd, $_POST['tid'], $_POST['kid'], $villageName, $this->setupMetadata['map_size'], 1, 1, $this->SNdata, $ip);
                 if ($result['hasErrors']) {
                     $this->err[3] = register_player_txt_fullserver;
                     $m->dispose();
                 } else {
                     $m->dispose();
                     $link = WebHelper::getbaseurl() . "activate.php?id=" . $result['activationCode'];
                     $to = $email;
                     $from = $this->appConfig['system']['email'];
                     $subject = register_player_txt_regmail_sub;
                     $message = sprintf(register_player_txt_regmail_body, $name, $name, $pwd, $link, $link);
                     WebHelper::sendmail($to, $from, $subject, $message);
                     $this->success = TRUE;
                 }
             }
         }
     }
 }
 public function registerAction(Request $request)
 {
     $registerForm = new RegisterModel($request);
     $msg = $request->get('msg');
     if ($request->isPost()) {
         if ($registerForm->isValid()) {
             if ($registerForm->isUserExist()) {
                 $registerForm->insertIntoDB();
                 $this->redirect("index.php?rout=index/page&id=1&msg=Вы успешно зарегистрировались");
             } else {
                 $msg = 'Such user already exists!';
             }
         } else {
             $msg = $registerForm->passwordMath() ? 'Please fill in fields' : 'Passwords don\'t match';
         }
     }
     $args = array('registerForm' => $registerForm, 'msg' => $msg);
     return $this->render('register', $args);
 }
Пример #4
0
 function load()
 {
     parent::load();
     $this->SNdata = 0;
     $this->success = FALSE;
     if ($this->isPost()) {
         if ($this->globalModel->isGameOver()) {
             $this->redirect('over.php');
             return null;
         }
         $name = trim($_POST['name']);
         $email = trim($_POST['email']);
         $pwd = trim($_POST['pwd']);
         $this->err[0] = strlen($name) < 3 ? register_player_txt_notless3 : '';
         if ($this->err[0] == '') {
             $this->err[0] = preg_match('/[:,\\. \\n\\r\\t\\s]+/', $name) ? register_player_txt_invalidchar : '';
         }
         if ($name == '[ally]' || $name == 'admin' || $name == 'administrator' || $name == 'مدير' || $name == 'تتار' || $name == 'التتار' || $name == 'دعم' || $name == 'الدعم' || $name == $this->appConfig['system']['adminName'] || $name == tatar_tribe_player) {
             $this->err[0] = register_player_txt_reserved;
         }
         $this->err[1] = !preg_match("/^[^@]+@[a-zA-Z0-9._-]+\\.[a-zA-Z]+\$/", $email) ? register_player_txt_invalidemail : "";
         $this->err[2] = strlen($pwd) < 4 ? register_player_txt_notless4 : "";
         $this->err[3] = !isset($_POST['tid']) || $_POST['tid'] != 1 && $_POST['tid'] != 2 && $_POST['tid'] != 3 && $_POST['tid'] != 6 && $_POST['tid'] != 8 && $_POST['tid'] != 7 && $_POST['tid'] != 8 && $_POST['tid'] != 9 ? "<li>" . register_player_txt_choosetribe . "</li>" : "";
         $this->err[3] .= !isset($_POST['kid']) || !is_numeric($_POST['kid']) || $_POST['kid'] < 0 || 4 < $_POST['kid'] ? "<li>" . register_player_txt_choosestart . "</li>" : "";
         if (0 < strlen($this->err[0]) || 0 < strlen($this->err[1]) || 0 < strlen($this->err[2]) || 0 < strlen($this->err[3])) {
             return null;
         }
         $m = new RegisterModel();
         $this->err[0] = $m->isPlayerNameExists($name) ? register_player_txt_usedname : '';
         $this->err[1] = $m->isPlayerEmailExists($email) ? register_player_txt_usedemail : '';
         if (0 < strlen($this->err[0]) || 0 < strlen($this->err[1])) {
             $m->dispose();
             return null;
         }
         $villageName = new_village_name_prefix . ' ' . $name;
         $result = $m->createNewPlayer($name, $email, $pwd, $_POST['tid'], $_POST['kid'], $villageName, $this->setupMetadata['map_size'], PLAYERTYPE_NORMAL, 1, $this->SNdata);
         if ($result['hasErrors']) {
             $this->err[3] = register_player_txt_fullserver;
             $m->dispose();
             return null;
         }
         $m->dispose();
         $link = WebHelper::getbaseurl() . 'activate.php?id=' . $result['activationCode'];
         $to = $email;
         $from = $this->appConfig['system']['email'];
         $subject = register_player_txt_regmail_sub;
         $message = sprintf(register_player_txt_regmail_body, $name, $name, $pwd, $link, $link);
         WebHelper::sendmail($to, $from, $subject, $message);
         $this->success = TRUE;
     }
 }
Пример #5
0
 /**
  * Post the register form
  *
  *@return redirect
  */
 function postRegister()
 {
     $rules = array('email' => 'required|email|unique:vendors', 'password' => 'required|min:2');
     $email = Input::get('email');
     $password = Input::get('password');
     $validator = Validator::make(['email' => $email, 'password' => $password], $rules);
     $vendorType = Input::get('type');
     $vendorData = array('email' => $email, 'password' => sha1($password), 'manufacturer' => $vendorType);
     if ($validator->passes()) {
         $id = RegisterModel::addVendor($vendorData);
         $profileData = array('id' => $id, 'email' => $email, 'password' => sha1($password), 'vendor_type' => $vendorType, 'verified' => 0);
         RegisterModel::addProfile($profileData);
         Session::put('vendor_id', $id);
         mkdir(base_path() . '/uploads/vendors/' . $id, 0700);
         mkdir(base_path() . '/uploads/products/' . $id, 0700);
         mkdir(base_path() . '/uploads/csvs/' . $id, 0700);
         return Redirect::to('/profile/');
     }
     return Redirect::to('/')->with('e_msg', 'Something went wrong with the registration!')->withErrors($validator)->withInput();
 }
Пример #6
0
 function actionIndex()
 {
     $name = '';
     $lastname = '';
     $bithday = '';
     $email = '';
     $password = '';
     $result = '';
     $errors = array();
     if (isset($_POST['submit'])) {
         $name = $_POST['name'];
         $lastname = $_POST['lastname'];
         $bithday = $_POST['bithday'];
         $email = $_POST['email'];
         $password = $_POST['password'];
         if (!RegisterModel::checkName($name)) {
             $errors[] = 'Имя не должно быть короче 2-ух символов';
         }
         if (!RegisterModel::checkDate($bithday)) {
             $errors[] = 'Дата рождения не валидна - ' . $bithday;
         }
         if (!RegisterModel::checkEmail($email)) {
             $errors[] = 'Некорректный Email';
         }
         if ($this->model->checkEmailExists($email)) {
             $errors[] = 'Такой Email уже используется';
         }
         if (!RegisterModel::checkPassword($password)) {
             $errors[] = 'Пароль не должен быть короче 6-и символов';
         }
         $password = UserModel::encrypt_pass($password);
         if ($errors == false) {
             // SAVE USER
             $result = $this->model->signUp($name, $lastname, $bithday, $email, $password);
         }
     }
     $data = array('title' => 'Регистрация', 'result' => $result, 'errors' => $errors);
     $this->view->render('register.twig', $data);
 }
Пример #7
0
 /**
  * Follows a route and produces a web page from it.
  */
 public function route()
 {
     $view = null;
     $exception = null;
     /* construct template engine */
     $smarty = new Smarty();
     $smarty->caching = true;
     $smarty->cache_lifetime = 120;
     $smarty->setTemplateDir(__DIR__ . '/layouts');
     $smarty->setCompileDir(__DIR__ . '/../../smarty/compiled_templates');
     $smarty->setCacheDir(__DIR__ . '/../../smarty/cache');
     switch ($this->path) {
         case 'index':
             $view = new IndexView($smarty);
             break;
         case 'statuses':
             if (!$this->isLoggedIn()) {
                 $exception = new Exception('You must be <a href="?action=login">logged in<a> to view the circuit board status list.');
                 break;
             }
             $view = new StatusesView($smarty);
             $model = new StatusesModel($view);
             $controller = new StatusesController($model);
             try {
                 $controller->fetchStatuses();
             } catch (Exception $e) {
                 $exception = $e;
             }
             break;
         case 'updates':
             if (!$this->isLoggedIn() || $_SESSION['rank'] != 'ADMIN') {
                 $exception = new Exception('You must be <a href="?action=login">logged in<a> to an administrator\'s account to poll the service for updates.');
                 break;
             }
             $view = new UpdatesView($smarty);
             $model = new UpdatesModel($view);
             $controller = new UpdatesController($model);
             try {
                 $controller->fetchUpdates();
             } catch (Exception $e) {
                 $exception = $e;
             }
             break;
         case 'register':
             $view = new RegisterView($smarty);
             $model = new RegisterModel($view);
             $controller = new RegisterController($model);
             try {
                 $controller->checkValidRegistration();
                 $username = $model->getUsername();
                 if ($model->isRegistered()) {
                     $view = new RegisteredView($smarty);
                     $model = new RegisteredModel($view);
                     $model->setUsername($username);
                 }
             } catch (Exception $e) {
                 $exception = $e;
             }
             break;
         case 'login':
             $view = new LoginView($smarty);
             $model = new LoginModel($view);
             $controller = new LoginController($model);
             try {
                 $controller->checkValidLogin();
                 if ($model->isLoggedIn()) {
                     // successful login
                     $view = new LoggedInView($smarty);
                     $model = new LoggedInModel($view);
                     $model->setUsername($_SESSION['username']);
                 }
             } catch (Exception $e) {
                 $exception = $e;
             }
             break;
         case 'logout':
             $view = new LogoutView($smarty);
             $model = new LogoutModel($view, $this->isLoggedIn());
             $controller = new LogoutController($model);
             try {
                 $controller->logout();
             } catch (Exception $e) {
                 $exception = $e;
             }
             break;
         case 'debug':
             if (!$this->isLoggedIn() || $_SESSION['rank'] != 'ADMIN') {
                 $exception = new Exception('You must be <a href="?action=login">logged in<a> to an administrator\'s account view the debug page.');
                 break;
             }
             $view = new DebugView($smarty);
             break;
             /* any unhandled action return them to the welcome screen */
         /* any unhandled action return them to the welcome screen */
         default:
             $this->path = 'index';
             $view = new IndexView($smarty);
             break;
     }
     if ($exception !== null) {
         $view = new ErrorView($smarty);
         $model = new ErrorModel($view);
         $model->setMessage($exception->getMessage());
     }
     if (!DEBUG_MODE) {
         /* optimize the output by removing whitespace */
         $smarty->loadFilter("output", "trimwhitespace");
     }
     /* apply view specific information to the template engine */
     $view->applyTemplate($this->isLoggedIn());
     /* display generated template */
     $smarty->display($view->getId() . '.tpl');
 }
Пример #8
0
 function _createAdminPlayer($map_size, $adminEmail)
 {
     $m = new RegisterModel();
     $adminName = $GLOBALS['AppConfig']['system']['adminName'];
     $result = $m->createNewPlayer($adminName, $adminEmail, $GLOBALS['AppConfig']['system']['adminPassword'], 6, 0, $adminName, $map_size, PLAYERTYPE_ADMIN);
     if ($result['hasErrors']) {
         return FALSE;
     }
     $m->dispose();
     return TRUE;
 }
Пример #9
0
 public function createTatarVillages()
 {
     require_once MODEL_PATH . "register.php";
     $map_size = $GLOBALS['SetupMetadata']['map_size'];
     $m = new RegisterModel();
     $result = $m->createNewPlayer(tatar_tribe_player, "", "", 5, 0, tatar_tribe_villages, $map_size, PLAYERTYPE_TATAR, 13);
     if ($result['hasErrors']) {
         return;
     }
     $this->provider->executeQuery("UPDATE p_players p SET p.total_people_count=15045, p.description1='%s', p.guide_quiz='-1' WHERE id=%s", array(tatar_tribe_desc, intval($result['playerId'])));
     $troop_ids = array();
     foreach ($GLOBALS['GameMetadata']['troops'] as $k => $v) {
         if ($v['for_tribe_id'] == 5) {
             $troop_ids[] = $k;
         }
     }
     $firstFlag = TRUE;
     foreach ($result['villages'] as $createdVillage => $v) {
         $troops_num = "";
         foreach ($troop_ids as $tid) {
             if ($troops_num != "") {
                 $troops_num .= ",";
             }
             $num = $tid == 49 || $tid == 50 ? 0 : mt_rand(42300, 117600);
             $troops_num .= sprintf("%s %s", $tid, $num);
         }
         $troops_num = "-1:" . $troops_num;
         $this->provider->executeQuery("UPDATE p_villages v SET v.troops_num='%s', v.is_capital=%s, v.people_count=%s WHERE v.id=%s", array($troops_num, $firstFlag ? "1" : "0", $firstFlag ? "864" : "163", intval($createdVillage)));
         $firstFlag = FALSE;
     }
     $m->dispose();
 }
Пример #10
0
 function createTatarVillages()
 {
     require_once MODEL_PATH . 'register.php';
     $map_size = $GLOBALS['SetupMetadata']['map_size'];
     $m = new RegisterModel();
     $result = $m->createNewPlayer(tatar_tribe_player, '', '', 5, 0, tatar_tribe_villages, $map_size, PLAYERTYPE_TATAR, 13);
     if ($result['hasErrors']) {
         return null;
     }
     $this->provider->executeQuery('UPDATE p_players p SET p.total_people_count=15045, p.description1=\'%s\', p.guide_quiz=\'-1\' WHERE id=%s', array(tatar_tribe_desc, intval($result['playerId'])));
     $troop_ids = array();
     foreach ($GLOBALS['GameMetadata']['troops'] as $k => $v) {
         if ($v['for_tribe_id'] == 5) {
             $troop_ids[] = $k;
             continue;
         }
     }
     $firstFlag = TRUE;
     foreach ($result['villages'] as $createdVillage => $v) {
         $troops_num = '';
         foreach ($troop_ids as $tid) {
             if ($troops_num != '') {
                 $troops_num .= ',';
             }
             $num = $tid == 49 || $tid == 50 ? 0 : mt_rand(42300, 117600);
             $troops_num .= sprintf('%s %s', $tid, $num);
         }
         $troops_num = '-1:' . $troops_num;
         $this->provider->executeQuery('UPDATE p_villages v SET v.troops_num=\'%s\', v.is_capital=%s, v.people_count=%s WHERE v.id=%s', array($troops_num, $firstFlag ? '1' : '0', $firstFlag ? '864' : '163', intval($createdVillage)));
         $firstFlag = FALSE;
     }
     $m->dispose();
 }
Пример #11
0
 public function __construct($DAL)
 {
     self::$userDAL = $DAL;
 }