Beispiel #1
0
 public static function generate()
 {
     //����������� PHP ���������� captchastring ������ ��������
     $captchastring = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz';
     //�������� ������ 6 �������� ����� �� ������������� � ������� ������� str_shuffle
     $captchastring = substr(str_shuffle($captchastring), 0, 6);
     //������������� ���������� ������ � ������� ��������������� ��������� captchastring,
     //���������� 6 ��������
     ErSession::saveToSession("code", $captchastring);
     //���������� CAPTCHA
     //������� ����� ����������� �� ����� background.png
     $image = imagecreatefrompng('application/data/images/background.png');
     //������������� ���� (R-200, G-240, B-240) �����������, ����������� � $image
     $colour = imagecolorallocate($image, 200, 240, 240);
     //����������� ���������� font �������� ������
     $font = 'application/data/fonts/oswald.ttf';
     //������������� ��������� ����� ����� -10 � 10 �������� ��� �������� ������
     $rotate = rand(-10, 10);
     //������ ����� �� ����������� ������� TrueType (1 �������� - ����������� ($image),
     //2 - ������ ������ (18), 3 - ���� �������� ������ ($rotate),
     //4, 5 - ��������� ���������� x � y ��� ������ (18,30), 6 - ������ ����� ($colour),
     //7 - ���� � ����� ������ ($font), 8 - ����� ($captchastring)
     imagettftext($image, 18, $rotate, 28, 32, $colour, $font, $captchastring);
     //����� ���������� ����������� � ������� png
     header('Content-type: image/png');
     //������� �����������
     return imagepng($image);
 }
 public function routeAction()
 {
     $request = new Request();
     $request->initRequest();
     $post = $request->getPost();
     ErSession::saveToSession('start', $post['start']);
     ErSession::saveToSession('finish', $post['finish']);
     if ($post['findaction']) {
         ErApplication::redirect(ErApplication::getBaseUrl() . 'road/index');
     } else {
         ErApplication::redirect(ErApplication::getBaseUrl() . 'road/addroute');
     }
 }
 public function registerAction()
 {
     Request::ajax();
     $message = ErMessenger::getInstance();
     $request = new Request();
     $request->initRequest();
     $post = $request->getPost();
     if (isset($post)) {
         if (!empty($post['email']) && !empty($post['password']) && !empty($post['pass_confirm']) && !empty($post['captcha'])) {
             $userMapper = new UserMapper();
             $user = $userMapper->getUserByEmail($post["email"]);
             if (!$user) {
                 if (Captcha::verify()) {
                     $givenEmail = $this->clearStr($post['email']);
                     $givenPassword = $this->clearStr($post["password"]);
                     if (filter_var($givenEmail, FILTER_VALIDATE_EMAIL)) {
                         $user = new User();
                         $userMapper = new UserMapper();
                         $user->email = $givenEmail;
                         $user->crdate = date("Y-m-d");
                         $user->access = 'ps';
                         $user->userstatus = 1;
                         $user->userpassword = hash("md5", $givenPassword);
                         if ($userMapper->insertNewUser($user)) {
                             $message->setSucceedMessage('201', 'index/index');
                             ErSession::saveToSession('user', $user->email);
                             if ($user->username != null) {
                                 ErSession::saveToSession('username', $user->username);
                             }
                         } else {
                             $message->setErrMessage('101', 'user/signup');
                         }
                     } else {
                         $message->setErrMessage('103', 'user/signup');
                     }
                 } else {
                     $message->setErrMessage('104', 'user/signup');
                 }
             } else {
                 $message->setErrMessage('102', 'user/signup');
             }
         }
     }
 }