当前位置: 首页>>代码示例>>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;未经允许,请勿转载。