本文整理匯總了PHP中Random::getString方法的典型用法代碼示例。如果您正苦於以下問題:PHP Random::getString方法的具體用法?PHP Random::getString怎麽用?PHP Random::getString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Random
的用法示例。
在下文中一共展示了Random::getString方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addSession
public function addSession($mysql, $uid) {
$time = Time::getTime();
$session= new Session;
$random = Random::getString(32);
$expiry = $time + 30*24*60*60;
$session->read($uid,$time,$expiry);
switch($session->insert($mysql, $random)) {
case Session::DATABASE_ERROR :
{
echo "<p>A Database error has occured.</p>";
return;
}
case Session::INVALID_DATA :
{
echo "<p>Invalid operation requested.</p>";
return;
}
case Session::INSERT_SUCCESS :
{
return $random;
}
default :
break;
}
}
示例2: getContext
public function getContext($model){
$conn = $model['conn'];
$username = $conn->escape($model['username']);
$email = $conn->escape($model['email']);
$subject = $model['subject'];
$message = $model['message'];
//$newusername = Random::getString(8);
$password = Random::getString(16);
$result = $conn->getResult("update users set password=MD5('$username$password') where username='$username' and email='$email';", true);
if($result === false || $result != 1){
$model['valid'] = false;
$model['msg'] = 'Error in Database';
return $model;
}
$message = str_replace('{username}', $username, $message);
$message = str_replace('{password}', $password, $message);
$sent = Mail::send($email, $subject, $message);
if($sent === false){
$model['valid'] = false;
$model['msg'] = 'Error in Sending Mail';
return $model;
}
$model['valid'] = true;
$model['sent'] = $sent;
return $model;
}
示例3: getContext
/**
* @interface ContextService
**/
public function getContext($model){
$conn = $model['conn'];
$uid = $model['uid'];
$interval = $model['interval'];
$sessionid = Random::getString(32);
$ts = Time::getTime();
$ts_exp = $ts + $interval;
$query = "delete from sessions where expiry < $ts;";
$conn->getResult($query, true);
$query = "insert into sessions values('$sessionid', $uid, $ts, $ts_exp);";
$result = $conn->getResult($query, true);
if($result === false){
$model['valid'] = false;
$model['msg'] = 'Error in Database @getContext/session.create';
return $model;
}
$model['valid'] = true;
$model['sessionid'] = $sessionid;
return $model;
}
示例4: getContext
/**
* @interface ContextService
**/
public function getContext($model){
$conn = $model['conn'];
$stgname = $conn->escape($model['stgname']);
$filename = $conn->escape($model['filename']);
$mime = $conn->escape($model['mime']);
$owner = $model['owner'];
$access = $model['access'];
$group = $model['group'];
$dirid = $conn->escape($model['dirid']);
$stgid = Random::getString(128);
$ts = Time::getTime();
$query = "insert into storages (stgid, stgname, filename, mime, owner, access, group, ctime, atime, mtime, dirid) values ('$stgid', '$stgname', '$filename', '$mime', $owner, $access, $group, $ts, $ts, $ts, '$dirid')";
$result = $conn->getResult($query);
if($result === false){
$model['valid'] = false;
$model['msg'] = 'Error in Database @getContext/storage.create';
return $model;
}
$model['valid'] = true;
$model['stgid'] = $stgid;
return $model;
}
示例5: getContext
/**
* @interface ContextService
**/
public function getContext($model){
$conn = $model['conn'];
$username = $conn->escape($model['username']);
$email = $conn->escape($model['email']);
$subject = $model['subject'];
$message = $model['message'];
$query = "select uid from users where (username='$username' or email='$email');";
$result = $conn->getResult($query);
if($result === false){
$model['valid'] = false;
$model['msg'] = 'Error in Database @getContext/user.register';
return $model;
}
if(count($result) != 0){
$model['valid'] = false;
$model['msg'] = 'Username / Email already registered';
return $model;
}
$password = Random::getString(16);
$result = $conn->getResult("insert into users (username, password, email) values ('$username', MD5('$username$password'), '$email');", true);
if($result === false){
$model['valid'] = false;
return $model;
}
$uid = $conn->getAutoId();
$message = str_replace('{username}', $username, $message);
$message = str_replace('{password}', $password, $message);
$sent = Mail::send($email, $subject, $message);
if($sent === false){
$model['valid'] = false;
$model['msg'] = 'Error in Sending Mail @getContext/user.register';
return $model;
}
$model['valid'] = true;
$model['uid'] = $uid;
$model['password'] = $password;
return $model;
}
示例6: generateId
function generateId()
{
return Random::getString(round($this->idLength));
}