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


PHP Strings::random方法代码示例

本文整理汇总了PHP中Nette\Utils\Strings::random方法的典型用法代码示例。如果您正苦于以下问题:PHP Strings::random方法的具体用法?PHP Strings::random怎么用?PHP Strings::random使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Utils\Strings的用法示例。


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

示例1: startup

 protected function startup()
 {
     parent::startup();
     $this->position = time();
     $this->route->setLocalUrl(Strings::webalize(Strings::random()));
     $this->getRoute()->setPublished(TRUE);
 }
开发者ID:svobodni,项目名称:web,代码行数:7,代码来源:AbstractItemEntity.php

示例2: startup

 public function startup()
 {
     parent::startup();
     $this->dir = new DirEntity();
     $this->dir->setInvisible(TRUE);
     $this->dir->setName(Strings::webalize(get_class($this)) . Strings::random());
 }
开发者ID:svobodni,项目名称:web,代码行数:7,代码来源:AbstractImageEntity.php

示例3: renderIn

 /**
  * @param string|NULL
  */
 public function renderIn($backlink)
 {
     $httpRequest = $this->getHttpRequest();
     $referer = NULL;
     if ($httpRequest instanceof \Nette\Http\Request) {
         $referer = $httpRequest->getReferer();
     }
     if (!$backlink && $referer && $referer->getHost() == $httpRequest->getUrl()->getHost()) {
         $url = new UrlScript($referer);
         $url->setScriptPath($httpRequest->getUrl()->getScriptPath());
         $tmp = new Request($url);
         $req = $this->router->match($tmp);
         if (!$req) {
             return;
         }
         if (isset($req->parameters[static::SIGNAL_KEY])) {
             $params = $req->parameters;
             unset($params[static::SIGNAL_KEY]);
             $req->setParameters($params);
         }
         if ($req->getPresenterName() != $this->getName()) {
             $session = $this->getSession('Nette.Application/requests');
             do {
                 $key = Strings::random(5);
             } while (isset($session[$key]));
             $session[$key] = array($this->getUser()->getId(), $req);
             $session->setExpiration('+ 10 minutes', $key);
             $this->params['backlink'] = $key;
         }
     }
 }
开发者ID:newPOPE,项目名称:web-addons.nette.org,代码行数:34,代码来源:SignPresenter.php

示例4: generateToken

 /**
  * @return string
  */
 private function generateToken($random = NULL)
 {
     if ($random === NULL) {
         $random = Nette\Utils\Strings::random(10);
     }
     return $random . base64_encode(sha1($this->getToken() . $random, TRUE));
 }
开发者ID:Johnik010,项目名称:rezervace,代码行数:10,代码来源:CsrfProtection.php

示例5: calculateHash

 /**
  * Computes salted password hash.
  * @param string $password
  * @param string $salt
  * @return string
  */
 public static function calculateHash($password, $salt = null)
 {
     if ($salt === null) {
         $salt = '$2a$07$' . Nette\Utils\Strings::random(32) . '$';
     }
     return crypt($password, $salt);
 }
开发者ID:redhead,项目名称:nette-quickstart,代码行数:13,代码来源:Authenticator.php

示例6: calculateAddonsPortalPasswordHash

 /**
  * @param string
  * @param string|NULL
  * @return string
  */
 private function calculateAddonsPortalPasswordHash($password, $salt = NULL)
 {
     if ($password === Strings::upper($password)) {
         // perhaps caps lock is on
         $password = Strings::lower($password);
     }
     return crypt($password, $salt ?: '$2a$07$' . Strings::random(22));
 }
开发者ID:newPOPE,项目名称:web-addons.nette.org,代码行数:13,代码来源:NetteOrgAuthenticator.php

示例7: generateHash

 /**
  * Generuje hash hesla i se solicim retezcem
  * @return string
  */
 public function generateHash($password, $salt = NULL)
 {
     if ($password === Strings::upper($password)) {
         // v pripade zapleho capslocku
         $password = Strings::lower($password);
     }
     return crypt($password, $salt ?: $this->user_salt . Strings::random(23));
 }
开发者ID:prcharom,项目名称:dp-auction-system,代码行数:12,代码来源:UserManager.php

示例8: generateHash

 /**
  * Generuje hash hesla i se solicim retezcem
  * @return string
  */
 public function generateHash($heslo, $salt = NULL)
 {
     if ($heslo === Strings::upper($heslo)) {
         // v pripade zapleho capslocku
         $heslo = Strings::lower($heslo);
     }
     return crypt($heslo, $salt ?: '$2a$07$' . Strings::random(23));
 }
开发者ID:prcharom,项目名称:w-pps-reality,代码行数:12,代码来源:Authenticator.php

示例9: __construct

 public function __construct(NewsletterEntity $newsletter)
 {
     $this->newsletter = $newsletter;
     $this->dir = new DirEntity();
     $this->dir->setParent($this->newsletter->route->getDir());
     $this->dir->setInvisible(TRUE);
     $this->dir->setName(Strings::webalize(get_class($this)) . Strings::random());
 }
开发者ID:venne,项目名称:newsletter-module,代码行数:8,代码来源:BoxEntity.php

示例10: calculateHash

 /**
  * Computes password hash.
  *
  * @param string
  * @param string|NULL
  * @return string
  */
 public static function calculateHash($password, $salt = NULL)
 {
     if ($password === Strings::upper($password)) {
         // perhaps caps lock is on
         $password = Strings::lower($password);
     }
     return crypt($password, $salt ?: '$2a$07$' . Strings::random(22));
 }
开发者ID:newPOPE,项目名称:web-addons.nette.org,代码行数:15,代码来源:Authenticator.php

示例11: getToken

 /**
  * @return string
  */
 public function getToken()
 {
     $session = $this->getSession()->getSection(__CLASS__);
     if (!isset($session->token)) {
         $session->token = Nette\Utils\Strings::random();
     }
     return $session->token;
 }
开发者ID:jurasm2,项目名称:nette,代码行数:11,代码来源:CsrfProtection.php

示例12: setUp

 public function setUp()
 {
     $array = array(array('guid' => 0, 'name' => 'test', 'account' => 1, 'type' => 1), array('guid' => 0, 'name' => 'test', 'account' => 1, 'type' => 1));
     for ($i = 2; $i < 500; $i++) {
         $array[] = array('guid' => $i, 'name' => \Nette\Utils\Strings::random(10), 'account' => rand(1, 1000), 'type' => rand(0, 1));
     }
     $this->dataSource = new ArrayDataSource($array);
 }
开发者ID:drahak,项目名称:tables,代码行数:8,代码来源:ArrayDataSourceTest.php

示例13:

 /**
  * @param ServerToken $serverToken
  * @param $expiration
  * @param null $randomSalt
  */
 function __construct(ServerToken $serverToken, $expiration, $randomSalt = null)
 {
     $this->serverToken = $serverToken;
     $this->expiration = (string) $expiration;
     if ($randomSalt === null) {
         $randomSalt = Strings::random(5);
     }
     $this->randomSalt = $randomSalt;
 }
开发者ID:Budry,项目名称:TinyREST,代码行数:14,代码来源:ClientToken.php

示例14: __construct

 /**
  * @param Uploader $uploader
  * @param IUploadQueueFactory $uploadQueueFactory
  * @param IStorage $cacheStorage
  */
 public function __construct(Uploader $uploader, IUploadQueueFactory $uploadQueueFactory, IStorage $cacheStorage)
 {
     parent::__construct();
     $this->uploader = $uploader;
     $this->uploadQueueFactory = $uploadQueueFactory;
     $this->cacheStorage = $cacheStorage;
     $this->templateFile = __DIR__ . '/../templates/control/plupload.latte';
     $this->id = Strings::random();
 }
开发者ID:echo511,项目名称:plupload,代码行数:14,代码来源:PluploadControl.php

示例15: parse

 /**
  * Process all {macros} and <tags/>.
  * @param  string
  * @return string
  */
 public function parse($s)
 {
     if (!Strings::checkEncoding($s)) {
         throw new ParseException('Template is not valid UTF-8 stream.');
     }
     $s = str_replace("\r\n", "\n", $s);
     $this->templateId = Strings::random();
     $this->input =& $s;
     $this->offset = 0;
     $this->output = '';
     $this->htmlNodes = $this->macroNodes = array();
     foreach ($this->macroHandlers as $handler) {
         $handler->initialize($this);
     }
     $len = strlen($s);
     try {
         while ($this->offset < $len) {
             $matches = $this->{"context" . $this->context[0]}();
             if (!$matches) {
                 // EOF
                 break;
             } elseif (!empty($matches['comment'])) {
                 // {* *}
             } elseif (!empty($matches['macro'])) {
                 // {macro}
                 list($macroName, $macroArgs, $macroModifiers) = $this->parseMacro($matches['macro']);
                 $isRightmost = $this->offset >= $len || $this->input[$this->offset] === "\n";
                 $this->writeMacro($macroName, $macroArgs, $macroModifiers, $isRightmost);
             } else {
                 // common behaviour
                 $this->output .= $matches[0];
             }
         }
     } catch (ParseException $e) {
         if (!$e->sourceLine) {
             $e->sourceLine = $this->getLine();
         }
         throw $e;
     }
     $this->output .= substr($this->input, $this->offset);
     foreach ($this->htmlNodes as $node) {
         if (!empty($node->attrs)) {
             throw new ParseException("Missing end tag </{$node->name}> for macro-attribute " . self::N_PREFIX . implode(' and ' . self::N_PREFIX, array_keys($node->attrs)) . ".", 0, $this->getLine());
         }
     }
     $prologs = $epilogs = '';
     foreach ($this->macroHandlers as $handler) {
         $res = $handler->finalize();
         $prologs .= isset($res[0]) ? "<?php {$res['0']}\n?>" : '';
         $epilogs .= isset($res[1]) ? "<?php {$res['1']}\n?>" : '';
     }
     $this->output = ($prologs ? $prologs . "<?php\n//\n// main template\n//\n?>\n" : '') . $this->output . $epilogs;
     if ($this->macroNodes) {
         throw new ParseException("There are unclosed macros.", 0, $this->getLine());
     }
     return $this->output;
 }
开发者ID:kovkus,项目名称:r-cms,代码行数:62,代码来源:Parser.php


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