本文整理汇总了PHP中opToolkit::getRandom方法的典型用法代码示例。如果您正苦于以下问题:PHP opToolkit::getRandom方法的具体用法?PHP opToolkit::getRandom怎么用?PHP opToolkit::getRandom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opToolkit
的用法示例。
在下文中一共展示了opToolkit::getRandom方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRandom
protected function getRandom($length)
{
if (is_callable(array('opToolkit', 'getRandom'))) {
// for OpenPNE3.6 <=
return opToolkit::getRandom($length);
}
mt_srand();
return substr(md5(mt_rand()), 0, $length);
}
示例2: generateMobileUidCookie
public function generateMobileUidCookie()
{
$request = sfContext::getInstance()->getRequest();
if (!$request->isMobile() || !$request->isCookie()) {
return false;
}
$value = opToolkit::getRandom();
$this->setCookie(opWebRequest::MOBILE_UID_COOKIE_NAME, $value, strtotime('+20years'));
return $value;
}
示例3: generateApiKey
public function generateApiKey()
{
$apiKey = opToolkit::getRandom();
$this->setConfig('api_key', $apiKey);
return $apiKey;
}
示例4: setRememberLoginCookie
/**
* set remember login cookie
*/
protected function setRememberLoginCookie($isDeleteCookie = false)
{
$key = md5(sfContext::getInstance()->getRequest()->getHost());
$path = sfContext::getInstance()->getRequest()->getRelativeUrlRoot();
if (!$path)
{
$path = '/';
}
if ($isDeleteCookie)
{
if (!sfContext::getInstance()->getRequest()->getCookie($key))
{
return;
}
if ($this->getMemberId())
{
$this->getMember()->setConfig('remember_key', '');
}
$value = null;
$expire = time() - 3600;
}
else
{
$rememberKey = opToolkit::getRandom();
if (!$this->getMemberId())
{
throw new LogicException('No login');
}
$this->getMember()->setConfig('remember_key', $rememberKey);
$value = base64_encode(serialize(array($this->getMemberId(), $rememberKey)));
$expire = time() + sfConfig::get('op_remember_login_limit', 60*60*24*30);
}
sfContext::getInstance()->getResponse()->setCookie($key, $value, $expire, $path, '', false, true);
}
示例5: executeLocation
/**
* Executes location action
*
* @param sfWebRequest $request
*/
public function executeLocation(sfWebRequest $request)
{
try {
$this->processLocation($request);
} catch (LogicException $e) {
return sfView::ERROR;
}
$this->forward404Unless(in_array($request->getParameter('type'), array('cell', 'gps')));
$params = array();
if ($request->hasParameter('callback')) {
$params['callback'] = $request->getParameter('callback');
}
$params['method'] = $request->isMethod(sfWebRequest::GET) ? 'GET' : 'POST';
$this->tk = opToolkit::getRandom('12');
$t = opToolkit::getRandom();
$this->getUser()->setFlash('op_opensocial_location_t_' . $this->tk, $t);
$params['t'] = $t;
$this->location->setParameters($params);
}