本文整理汇总了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);
}
示例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());
}
示例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;
}
}
}
示例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));
}
示例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);
}
示例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));
}
示例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));
}
示例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));
}
示例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());
}
示例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));
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}