當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Token::check方法代碼示例

本文整理匯總了PHP中Token::check方法的典型用法代碼示例。如果您正苦於以下問題:PHP Token::check方法的具體用法?PHP Token::check怎麽用?PHP Token::check使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Token的用法示例。


在下文中一共展示了Token::check方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _index

 public function _index($url)
 {
     $id = $url[0];
     if (!empty($url[0])) {
         $data = DB::fetch('post', array('unique_id' => $id));
         if (empty($data)) {
             echo 'Not Found';
             die;
         } else {
             if (!empty($url[1])) {
                 switch ($url[1]) {
                     case 'comment':
                         $post = Input::post();
                         if (!empty($post)) {
                             if (Token::check($post['token'])) {
                                 User::comment($url[0], $post['comment']);
                                 echo 'Commented';
                             } else {
                                 echo 'Security token missing';
                             }
                         } else {
                             Redirect::to('/post/' . $url[0]);
                         }
                         break;
                     default:
                         break;
                 }
             } else {
                 self::init('PostModel', 'post', $url);
             }
         }
     } else {
         Redirect::to('/');
     }
 }
開發者ID:ncube,項目名稱:edu,代碼行數:35,代碼來源:post.php

示例2: RequesracallAction

    public function RequesracallAction()
    {
        if (Input::exists() && Token::check(Input::get('token'))) {
            $this->_DB->insert('phones', array('id' => 0, 'name' => Input::get('name'), 'number' => Input::get('number')));
            $this->registerAction();
        }
        ?>
<form action="" method="post">
    <div class="field">
        <LABEL for="name">Name: </LABEL>
        <input
            type="text"
            name="name"
            id="name" />
    </div>
    <div class="field">
        <label for="number">Number: </label>
        <input
            type="tel"
            name="number"
            id="number" />
    </div>
    <input type="hidden" name="token" value="<?php 
        echo Token::generate();
        ?>
" />
    <input type="submit" value="Save"/>
</form>
        <?php 
    }
開發者ID:ITESolutions,項目名稱:desktop,代碼行數:30,代碼來源:index.php

示例3: login

 public function login($id = null)
 {
     $user = $this->user;
     $this->data['user']['name'] = $user->data()->user;
     Config::set('html.title', 'Авторизация');
     Config::set('html.description.val', 'На этой странице можно залогиниться');
     //$user = new User();
     $salt = uniqid();
     if (!Session::exists(Config::get('session.token_name'))) {
         Token::generate();
     }
     if (Input::exists()) {
         if (Token::check(Input::get('token'))) {
             $validate = new VALIDATE();
             $validation = $validate->check($_POST, array('user' => array('required' => true), 'password' => array('required' => true)));
             if ($validate->passed()) {
                 $remember = Input::get('remember') === 'on' ? true : false;
                 $login = $user->login(Input::get('user'), Input::get('password'), null);
                 if ($login) {
                     Redirect::to('/');
                 } else {
                     echo '<p>Sorry, logging in failed</p>';
                 }
             } else {
                 foreach ($validation->errors() as $error) {
                     //echo $error, '<br/>';
                     $this->data['validate_errors'][] = $error;
                 }
             }
         }
     }
     //$this->data['id']=$id;
     //$this->data['name']=Input::get('name');
     $this->view('user/login');
 }
開發者ID:nanofelix,項目名稱:sample-app,代碼行數:35,代碼來源:user.php

示例4: _index

 public function _index()
 {
     // Deny access if not logged in
     new Protect('ajax');
     $post = Input::post();
     $token = Token::check($post['token']);
     if (!empty($post['username']) && !empty($post['type']) && $token === TRUE) {
         $request = User::request($post);
         if ($request === TRUE) {
             $data['success'][] = TRUE;
         } else {
             $data['errors'][] = $request;
         }
     } else {
         if (!$token) {
             $data['errors'][] = 'Security Token Missing';
         } else {
             $data['errors'][] = 'Username & Type Required';
         }
     }
     if (!empty($data)) {
         return $data;
     } else {
         return FALSE;
     }
 }
開發者ID:ncube,項目名稱:edu,代碼行數:26,代碼來源:request.php

示例5: _index

 public function _index()
 {
     $post = Input::post();
     if (!empty($post)) {
         $validate = Validate::register($post);
         $token = Token::check($post['token']);
         if ($validate === TRUE && $token === TRUE) {
             User::addUser($post);
             echo 'Registered';
         } else {
             if (!$token) {
                 echo 'Security Token is missing';
             }
             echo '<pre>';
             print_r($validate);
             echo '</pre>';
         }
     } else {
         if (Session::exists('user_id')) {
             header('Location: /');
             exit;
         }
         self::init('RegisterModel', 'register', $arg);
     }
 }
開發者ID:ncube,項目名稱:edu,代碼行數:25,代碼來源:register.php

示例6: create

 public function create()
 {
     new Protect();
     $post = Input::post();
     echo '<pre>';
     if (!empty($post)) {
         if (Token::check($post['token'])) {
             Question::postQuestion($post);
             echo 'Posted';
         } else {
             echo 'Security token missing.';
         }
     } else {
         echo '
         <form method="post" action="">
             <input type="text" name="title" placeholder="Title">
             <input type="hidden" name="token" value="' . Token::generate() . '">
             <br>
             <textarea placeholder="Description" type="text" name="content"></textarea>
             <br>
             <input type="submit">
         </form>
     ';
     }
 }
開發者ID:ncube,項目名稱:edu,代碼行數:25,代碼來源:questions.php

示例7: _index

 public function _index()
 {
     $token = $token = Token::check(Input::post('token'));
     if ($token) {
         // Destroy Session
         session_destroy();
         // Redirect to index
         Redirect::to('/');
     } else {
         echo 'Security Token Missing';
     }
 }
開發者ID:ncube,項目名稱:edu,代碼行數:12,代碼來源:logout.php

示例8: run

 public function run()
 {
     if (Input::exists('post')) {
         //check if form loaded propely
         if (Token::check(Input::get('token'))) {
             echo $this->model->process();
         } else {
             return miscellaneous::Error();
         }
     } else {
         return miscellaneous::Error();
     }
 }
開發者ID:WWAHIDAADNAN,項目名稱:JUSTAS,代碼行數:13,代碼來源:admissionform_controller.php

示例9: accept

 public function accept()
 {
     $post = Input::post();
     if (!empty($post['username'])) {
         if (Token::check($post['token']) === TRUE) {
             User::accept(Input::post());
         } else {
             echo 'Security Token Missing';
         }
     } else {
         echo 'username required';
     }
 }
開發者ID:ncube,項目名稱:edu,代碼行數:13,代碼來源:requests.php

示例10: salvarUsuario

 /**
  * Registra um usuário com dados recebidos do formulário
  *
  */
 public function salvarUsuario($id = null)
 {
     if (Input::exists()) {
         if (Token::check(Input::get('token'))) {
             $usuario = $this->setDados();
             if ($this->getModel()->findByLogin($usuario)) {
                 $this->atualizar = true;
             }
             $msg = $this->getModel()->gravar($usuario, $this->atualizar);
             Session::flash('msg', $msg['fc_criar_usuario'], 'success');
         }
     }
 }
開發者ID:dnaCRM,項目名稱:dnaCRM,代碼行數:17,代碼來源:Usuario.php

示例11: validateInput

 public function validateInput($Input = array())
 {
     $validater = new \Validation();
     if (\Token::check($Input["token"])) {
         $valid = $validater->Validate($Input, array('Username' => array('required' => true, 'min' => 3, 'max' => 35, 'exists' => array("Value" => 'Users', 'CustomError' => "{Value} is not a registered User")), 'Password' => array('required' => true, 'min' => 5, 'differs' => 'Username')));
         if ($valid === true) {
             //Attempt to Authenticate
             $this->User = new \User();
             try {
                 $this->Authenticated = $this->User->Authenticate(escape($Input["Username"]), escape($Input["Password"]), $Input["remember"]);
             } catch (\Exception $e) {
                 $this->Errors = array($e->getMessage());
             }
         } else {
             $this->Errors = $valid;
         }
     }
 }
開發者ID:25564,項目名稱:Resume,代碼行數:18,代碼來源:login.php

示例12: authAPICall

 static function authAPICall($dbh, $output_on_error = true, $output_type = "json")
 {
     require_once "Token.php";
     $token_data = Token::check($dbh, Token::getToken());
     if (isset($token_data["organization_user_id"])) {
         $user = $dbh->query("SELECT * FROM organization_user WHERE id = ?", array($token_data["organization_user_id"]));
         if (count($user)) {
             $user = $user[0];
             $user["token_data"] = $token_data;
             return $user;
         }
     }
     if ($output_on_error) {
         $status = "401 Unauthorized";
         output($output_type, array("status" => $status, "success" => false, "error" => array("Invalid token")), $status);
         exit;
     }
 }
開發者ID:4534-WiredWizards,項目名稱:ScoutingApp,代碼行數:18,代碼來源:Auth.php

示例13: create

 public function create()
 {
     if (isset($_POST['token'])) {
         if (Token::check($_POST['token'])) {
             $title = $_POST['title'];
             //dodawanie pauzy w mijsce spacji i astapywanie pauz tyldami
             $title = Shift::add($title);
             $article = $_POST['article'];
             $DB = new DB();
             $DB->insert("INSERT INTO article VALUES(NULL,'{$title}','{$article}',NOW(),0)");
             $this->index(null);
         } else {
             $this->view('pages/Portfolio/create');
         }
     } else {
         $this->view('pages/Portfolio/create');
     }
 }
開發者ID:browar777,項目名稱:MVC,代碼行數:18,代碼來源:Portfolio.php

示例14: register

 public function register()
 {
     $Token = new Token();
     if (!$Token->check($_POST['token'])) {
         $_SESSION['alert'] = 'Error, please try again.';
     } else {
         $Verify = new Verify();
         $username = trim(strip_tags($_POST['username']));
         $password = trim(strip_tags($_POST['password']));
         $repassword = trim(strip_tags($_POST['repassword']));
         $email = trim(strip_tags($_POST['email']));
         $email = explode('@', $email);
         if (!isset($username) && !isset($password) && !isset($repassword) && !isset($email)) {
             $_SESSION['alert'] = 'Not all fields have been completed.';
         } elseif (!$Verify->length($username, 255)) {
             $_SESSION['alert'] = 'The username is too long.';
         } elseif (!$Verify->same($password, $repassword)) {
             $_SESSION['alert'] = 'The passwords entered are not the same.';
         } elseif (!$Verify->length($email[0], 255)) {
             $_SESSION['alert'] = 'The email entered is too long.';
         } elseif (!$Verify->length($email[1], 255)) {
             $_SESSION['alert'] = 'The email entered is too long.';
         } else {
             $Db = new Db();
             $query = $Db->query('user', array(array('username', '=', $username, '')));
             $numrows = mysqli_num_rows($query);
             if ($numrows > 0) {
                 $_SESSION['alert'] = 'Error, please try again.';
             } else {
                 $salt = base64_encode(mcrypt_create_iv(128, MCRYPT_DEV_URANDOM));
                 $crypt = hash('sha512', $username . $salt . $password);
                 $datetime = date('Y-m-d H:i:s');
                 $rank = 0;
                 $insert = $Db->insert('user', array('', $username, $crypt, $email[0], $email[1], $salt, $datetime, $rank));
                 if (!$insert) {
                     $_SESSION['alert'] = 'User could not be registered.';
                 } else {
                     $_SESSION['alert'] = 'Successfully registered, you can now login with your credentials.';
                     header('Location: login.php');
                 }
             }
         }
     }
 }
開發者ID:jryantz,項目名稱:awc-framework,代碼行數:44,代碼來源:User.php

示例15: index

 public function index()
 {
     //add params
     $user = new User();
     if ($user->isLoggedIn()) {
         Redirect::to('account');
         //$this->view('user/index', ['flash' => '', 'name' => $user->data()->name]);
     } else {
         if (Input::exists()) {
             if (Token::check(Input::get('token'))) {
                 $validate = new Validation();
                 $validation = $validate->check($_POST, array('username' => array('required' => true), 'password' => array('required' => true)));
                 if ($validation->passed()) {
                     $user = new User();
                     $remember = Input::get('remember') === 'on' ? true : false;
                     $login = $user->login(Input::get('username'), Input::get('password'), $remember);
                     if ($login) {
                         //login success
                         Session::flash('account', 'You are now logged in');
                         Redirect::to('account');
                     } else {
                         //login failed
                         $error_string = 'Username or passowrd incorrect<br>';
                         $this->view('login/failed', ['loggedIn' => 2, 'page_heading' => 'Login', 'errors' => $error_string]);
                     }
                 } else {
                     $error_string = '';
                     //there were errors
                     //Create a file that prints errors
                     foreach ($validation->errors() as $error) {
                         $error_string .= $error . '<br>';
                     }
                     $this->view('login/failed', ['loggedIn' => 0, 'page_name' => 'Login', 'errors' => $error_string]);
                 }
             } else {
                 //token did not match so go back to login page
                 $this->view('login/index', ['loggedIn' => 2, 'page_name' => 'Login']);
             }
         } else {
             $this->view('login/index', ['loggedIn' => 2, 'page_name' => 'Login']);
         }
     }
 }
開發者ID:armourjami,項目名稱:armourtake,代碼行數:43,代碼來源:login.php


注:本文中的Token::check方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。