Security::token PHP Méthode

token() public static méthode

public static token ( )
    public static function token()
    {
        return $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT'] . Session::id();
    }

Usage Example

Exemple #1
0
 public function action_index()
 {
     $view = View::factory('forgot_password');
     $this->template->content = $view->render();
     if ($this->request->method() === Request::POST) {
         $email = $this->request->post('email');
         $user = new Model_User();
         $password_recovery = new Model_Password_Recovery();
         $unique_email = $user->unique_email($email);
         if ($unique_email === true) {
             throw new Exception("Email is not correct!");
         }
         $view_for_message = View::factory('forgot_password/send_email');
         $user_id = $user->get_id($email);
         $hash = sha1(Security::token());
         $view_for_message->user_id = $user_id;
         $view_for_message->hash = $hash;
         $create_attemp = $password_recovery->create_attemp($email, $user_id, $hash);
         if (!$create_attemp) {
             throw new Exception("Cannot create attemp!");
         }
         Email::connect();
         $to = array($email);
         $from = array('user@localhost', 'admin');
         $subject = 'Password recovery';
         $message = $view_for_message->render();
         $send_email = Email::send($to, $from, $subject, $message, true);
         if (!$send_email) {
             throw new Exception("Cannot send email! \n {$send_email}");
         }
         $this->redirect('/');
     }
 }
All Usage Examples Of Security::token