當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Random::getString方法代碼示例

本文整理匯總了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;
			}
	}
開發者ID:nimitz92,項目名稱:lcm,代碼行數:27,代碼來源:SessionManager.class.php

示例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;
	}
開發者ID:nimitz92,項目名稱:enhanCSE-core,代碼行數:32,代碼來源:UserResetContext.class.php

示例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;
	}
開發者ID:nimitz92,項目名稱:enhanCSE-core,代碼行數:29,代碼來源:SessionCreateContext.class.php

示例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;
	}
開發者ID:nimitz92,項目名稱:enhanCSE-core,代碼行數:29,代碼來源:StorageCreateContext.class.php

示例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;
	}
開發者ID:nimitz92,項目名稱:enhanCSE-core,代碼行數:51,代碼來源:UserRegisterContext.class.php

示例6: generateId

 function generateId()
 {
     return Random::getString(round($this->idLength));
 }
開發者ID:redcatphp,項目名稱:identify,代碼行數:4,代碼來源:Session.php


注:本文中的Random::getString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。