当前位置: 首页>>代码示例>>PHP>>正文


PHP Token类代码示例

本文整理汇总了PHP中Token的典型用法代码示例。如果您正苦于以下问题:PHP Token类的具体用法?PHP Token怎么用?PHP Token使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Token类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test__construct

 /**
  * @covers Xoops\Form\Token::__construct
  * @covers Xoops\Form\Token::render
  */
 public function test__construct()
 {
     // '<input hidden type="hidden" name="XOOPS_TOKEN_REQUEST" value="'
     $oldWay = new Token();
     $newWay = new Token([]);
     $this->assertEquals(substr($oldWay->render(), 0, 62), substr($newWay->render(), 0, 62));
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:11,代码来源:TokenTest.php

示例2: precedence

 /**
  * Verificação da Precedência
  * @param Token $tokenA Token para Verificação
  * @param Token $tokenB Token para Verificação
  * @throws Exception Token de Tipo Não Operador
  * @return int Comparação de Precedências dos Tokens
  */
 public function precedence($tokenA, $tokenB)
 {
     /* @todo Checar Precedência */
     $precedenceA = $this->_mapper[$tokenA->getContent()];
     $precedenceB = $this->_mapper[$tokenB->getContent()];
     return $precedenceA - $precedenceB;
 }
开发者ID:laiello,项目名称:wanderson,代码行数:14,代码来源:Parser.php

示例3: createToken

 /**
  * @param int $userId
  * @param string $token
  * @return Token
  */
 public static function createToken($userId, $token)
 {
     $newToken = new Token();
     $newToken->setUserId($userId);
     $newToken->setToken($token);
     return $newToken;
 }
开发者ID:euBatham,项目名称:javacature,代码行数:12,代码来源:TokenFactory.class.php

示例4: postRegistro

 public function postRegistro()
 {
     $input = Input::all();
     $reglas = array('nombre' => 'required', 'apellido' => 'required', 'celular' => 'required|numeric|unique:users', 'cedula' => 'required|numeric|unique:users', 'email' => 'required|email|unique:users', 'pin' => 'required|numeric|digits_between:0,4', 'password' => 'required|numbers|case_diff|letters|min:6|confirmed', 'password_confirmation' => 'required|min:6');
     $validation = Validator::make($input, $reglas);
     if ($validation->fails()) {
         return Response::json(['success' => false, 'errors' => $validation->errors()->toArray()]);
     }
     try {
         // se guarda los datos del usuario
         $user = Sentry::register(array('first_name' => Input::get('nombre'), 'last_name' => Input::get('apellido'), 'email' => Input::get('email'), 'habilitar_pin' => 1, 'celular' => Input::get('celular'), 'cedula' => Input::get('cedula'), 'password' => Input::get('password'), 'pin' => Input::get('pin'), 'porcentaje' => 0.05, 'activated' => true));
         $userId = $user->getId();
         $token = new Token();
         $token->user_id = $userId;
         $token->api_token = hash('sha256', Str::random(10), false);
         $token->client = BrowserDetect::toString();
         $token->expires_on = Carbon::now()->addMonth()->toDateTimeString();
         $token->save();
         // Se autentica de una
         $user_login = Sentry::findUserById($userId);
         Sentry::login($user_login, false);
         return Response::json(['success' => true, 'user' => $user_login, 'token' => $token->api_token]);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         $error = array('usuario' => 'Email es requerido');
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         $error = array('usuario' => 'Password es requerido');
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         $error = array('usuario' => 'El Email ya está registrado');
     }
     return Response::json(['success' => false, 'errors' => $error]);
 }
开发者ID:riverajefer,项目名称:bcserver,代码行数:31,代码来源:AuthController.php

示例5: conjure

 public static function conjure($token, TokenSet $tokenSet, TokenOutput $tokenOutput = null)
 {
     if (is_array($token)) {
         switch ($token[0]) {
             case T_INTERFACE:
                 $t = new InterfaceToken($token, $tokenSet);
                 break;
             case T_CLASS:
                 $t = new ClassToken($token, $tokenSet);
                 break;
             case T_FUNCTION:
                 $t = new FunctionToken($token, $tokenSet);
                 break;
             default:
                 // fall through to regular Token
                 $t = new Token($token, $tokenSet);
         }
     } else {
         // fall through to regular Token
         $t = new Token($token, $tokenSet);
     }
     if ($tokenOutput == null) {
         $tokenOutput = new TextTokenOutput();
     }
     $t->setOutput($tokenOutput);
     return $t;
 }
开发者ID:scoates,项目名称:tokalizer,代码行数:27,代码来源:Token.class.php

示例6: test1

 public function test1()
 {
     // TODO make proper test
     $tok = new Token();
     $val = $tok->generate(1000, 'bajs');
     echo $val . "\n";
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:7,代码来源:TokenTest.php

示例7: occupy

 /**
  * @param integer $steps
  * @param Token $token
  *
  * @return $this
  */
 protected function occupy($steps, Token $token)
 {
     if ($token->owner()->equals($this->homeSquares->owner())) {
         return $this->homeSquares->occupy(--$steps, $token);
     }
     return parent::occupy($steps, $token);
 }
开发者ID:JBuijgers,项目名称:jb-ludo-game,代码行数:13,代码来源:EndingSquare.php

示例8: testIsExpired

 public function testIsExpired()
 {
     $token = new Token(array('access_token' => '', 'refresh_token' => '', 'expires_in' => 5));
     $this->assertFalse($token->isExpired());
     $token = new Token(array('access_token' => '', 'refresh_token' => '', 'expires_in' => -5));
     $this->assertTrue($token->isExpired());
 }
开发者ID:mattmerrill,项目名称:infusionsoft-php,代码行数:7,代码来源:TokenTest.php

示例9: extract_potential_named_entities

 /**
  * Simply attempts to attract place names or names.
  */
 private function extract_potential_named_entities()
 {
     for ($i = 0, $n = count($this->tokens); $i < $n; $i++) {
         $entity = NULL;
         $token = new Token($this->tokens[$i]);
         // If the token is uppercase, maybe it is a name or a place.
         if ($token->isUpperCase() && !$token->isStopWord() && !$token->isInitWord()) {
             $entity = array($token->getText());
             // Look two words ahead.
             if (isset($this->tokens[$i + 2])) {
                 $next = new Token($this->tokens[$i + 2]);
                 while ($next->isUpperCase() || $next->isPrefixOrInfix()) {
                     // Jump two words.
                     $i += 2;
                     $entity[] = $next->getText();
                     if (isset($this->tokens[$i + 2])) {
                         $next = new Token($this->tokens[$i + 2]);
                     } else {
                         break;
                     }
                 }
             }
             $this->named_entities[] = $entity;
         }
     }
 }
开发者ID:NLPcse4027,项目名称:tagger,代码行数:29,代码来源:EntityPreprocessor.class.php

示例10: readToken

 /**
  * Reads the next token from the INI file
  *
  * @throws  IOException     On error
  * @return Token
  */
 function readToken()
 {
     if ($this->file === null) {
         throw new BuildException("No File set for IniFileTokenReader");
     }
     static $tokens = null;
     if ($tokens === null) {
         $tokens = array();
         $arr = parse_ini_file($this->file->getAbsolutePath(), true);
         if ($this->section === null) {
             foreach ($arr as $sec_name => $values) {
                 foreach ($arr[$sec_name] as $key => $value) {
                     $tok = new Token();
                     $tok->setKey($key);
                     $tok->setValue($value);
                     $tokens[] = $tok;
                 }
             }
         } else {
             if (isset($arr[$this->section])) {
                 foreach ($arr[$this->section] as $key => $value) {
                     $tok = new Token();
                     $tok->setKey($key);
                     $tok->setValue($value);
                     $tokens[] = $tok;
                 }
             }
         }
     }
     if (count($tokens) > 0) {
         return array_pop($tokens);
     } else {
         return null;
     }
 }
开发者ID:sensorsix,项目名称:app,代码行数:41,代码来源:IniFileTokenReader.php

示例11: createAutologinToken

 /**
  * @param integer $user_id
  * @return Token
  */
 public function createAutologinToken($user_id)
 {
     $token = new Token();
     $token->setUserId($user_id);
     $token->setAction(Token::$ACTION_AUTOLOGIN);
     return $token;
 }
开发者ID:newZinc,项目名称:timehive,代码行数:11,代码来源:TokenTable.class.php

示例12: testRender

 /**
  * @covers Xoops\Form\Token::render
  */
 public function testRender()
 {
     $value = $this->object->render();
     $this->assertTrue(is_string($value));
     $this->assertTrue(false !== strpos($value, '<input'));
     $this->assertTrue(false !== strpos($value, 'type="hidden"'));
     $this->assertTrue(false !== strpos($value, 'name="XOOPS_TOKEN_REQUEST"'));
 }
开发者ID:redmexico,项目名称:XoopsCore,代码行数:11,代码来源:TokenTest.php

示例13: sign

 /**
  * Sign the Request with a Token
  *
  * @param Token  $token
  * @param string $prefix
  * @return array
  */
 public function sign(Token $token, $prefix = self::PREFIX)
 {
     $auth = [$prefix . 'version' => self::VERSION, $prefix . 'key' => $token->key(), $prefix . 'timestamp' => $this->timestamp];
     $payload = $this->payload($auth, $this->params);
     $signature = $this->signature($payload, $this->method, $this->uri, $token->secret());
     $auth[$prefix . 'signature'] = $signature;
     return $auth;
 }
开发者ID:philipbrown,项目名称:signplz,代码行数:15,代码来源:Request.php

示例14: _getParseTokenFromToken

 protected function _getParseTokenFromToken(Token $token)
 {
     $code = $token->getCode();
     if ($code === "WHILE_START") {
         $code = "WHILE";
     }
     return new ParseToken($code, $token->getContent(), $token->getChar(), $token->getLine());
 }
开发者ID:relaxnow,项目名称:php-brain-fuck,代码行数:8,代码来源:Parser.php

示例15: create

 /**
  * @param array $params Parameters for creating an account
  *                      username, password, email are required
  *                      language, first_name, last_name are optional
  * @return array
  */
 public function create($params)
 {
     $params = $this->filter_parameters($params, array('username', 'password', 'first_name', 'last_name', 'email', 'language'));
     $v = new \Valitron\Validator($params);
     $v->rules(['required' => [['username'], ['password'], ['email'], ['language']]]);
     $used_values = null;
     $return_errors = null;
     if ($v->validate()) {
         if ($this->get_user_id($params['username']) !== false) {
             $used_values[] = 'username';
         }
         if ($this->email_used($params['email'])) {
             $used_values[] = 'email';
         }
         if ($used_values === null) {
             $v->rule('email', 'email');
             if ($v->validate()) {
                 $v->rules(['lengthMax' => [['username', 20]]]);
                 if ($v->validate()) {
                     $params['password'] = create_hash($params['password']);
                     $sql = "INSERT INTO user (";
                     foreach ($params as $key => $value) {
                         $sql .= $key . ",";
                     }
                     $sql = substr($sql, 0, -1);
                     $sql .= ") VALUES (";
                     foreach ($params as $key => $value) {
                         $sql .= " :" . $key . ",";
                         $params[':' . $key] = $value;
                     }
                     $sql = substr($sql, 0, -1);
                     $sql .= ")";
                     $query = $this->db->prepare($sql);
                     $query->execute($params);
                     $user_id = $this->get_user_id($params['username']);
                     $auth = new Token($this->db);
                     require_once 'core/Mail.php';
                     $mail = new Mail();
                     $mail->addAddress($params['email'], $params['username']);
                     $mail->isHTML(true);
                     $mail->Subject = "Welcome to buckbrowser";
                     $mail->Body = str_replace(['%username%', '%bb-link%'], [$params['username'], 'http://buckbrowser.langstra.nl'], file_get_contents(TEMPLATE_PATH . 'mail/signup.html'));
                     $mail->send();
                     return array('token' => $auth->create_token($user_id));
                 } else {
                     $return_errors['incorrect_fields'] = 'username';
                 }
             } else {
                 $return_errors['incorrect_fields'] = 'email';
             }
         } else {
             $return_errors['already_exists'] = $used_values;
         }
     } else {
         $return_errors['empty_fields'] = array_keys($v->errors());
     }
     return $this->create_error($return_errors);
 }
开发者ID:Buckbrowser,项目名称:buck-server,代码行数:64,代码来源:user_model.php


注:本文中的Token类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。