• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Token类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getRandomToken

 private function getRandomToken($studentId)
 {
     $t = new Token($this->tokenAlphabet, $this->tokenLength);
     // check for existing tokens
     while ($this->checkToken($studentId, $t->getString())) {
         $t = Token($this->tokenAlphabet, $this->tokenLength);
     }
     return $t->getString();
 }
开发者ID:RadoRado,项目名称:Fmi-Feedback,代码行数:9,代码来源:authentication.php


示例17: getSalt

 public function getSalt()
 {
     $password = $this->password;
     $token = new Token();
     $hash = $token->generatePassword(15);
     $this->hash = $hash;
     $salt = md5($password . $hash);
     return $salt;
 }
开发者ID:toppestkek,项目名称:TwigBlog,代码行数:9,代码来源:Salt.php


示例18: apply

 function apply(TokenStream $ts, Token $t, BlueContext $blueContext)
 {
     if (isset($this->raytraceLiteral[(string) $t]) || isset($this->raytraceNonliteral[$t->type()])) {
         foreach ($this->directives as $directives) {
             foreach ($directives as $directive) {
                 $directive->apply($ts, $this, $blueContext);
             }
         }
     }
 }
开发者ID:lastguest,项目名称:yay,代码行数:10,代码来源:Directives.php


示例19: isOperator

 /**
  * Check if the token is operator
  *
  * @param Token $token
  * @return boolean
  */
 public function isOperator(Token $token)
 {
     if (T_STRING == $token->getType()) {
         if (isset($this->byPass[$token->getValue()])) {
             return false;
         }
         return isset($this->operatorsStrings[$token->getValue()]);
     }
     return isset($this->operators[$token->getType()]);
 }
开发者ID:truffo,项目名称:PhpMetrics,代码行数:16,代码来源:TokenType.php


示例20: addToken

 /**
  * Adds a new token to the admin, and returns with the id of the newly created Doctrine model.
  *
  * @param object $admin an Admin model object
  * @param string $tokenType
  * @param string $token default null if null then one will be generated
  * @param string $rid default null if null then one will be generated
  * @return object the new Token model object
  */
 public static function addToken($admin, $tokenType, $token = null, $rid = null)
 {
     $model = new Token();
     $model->username = $admin['username'];
     $model->type = $tokenType;
     $model->token = $token === null ? self::createRandomString() : $token;
     $model->rid = $rid === null ? self::createRandomString(32) : $rid;
     $model->save();
     return $model;
 }
开发者ID:nereliz,项目名称:ViMbAdmin,代码行数:19,代码来源:TokenTable.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Tool类代码示例发布时间:2022-05-23
下一篇:
PHP TitleArray类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap