本文整理汇总了PHP中Time::getTime方法的典型用法代码示例。如果您正苦于以下问题:PHP Time::getTime方法的具体用法?PHP Time::getTime怎么用?PHP Time::getTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Time
的用法示例。
在下文中一共展示了Time::getTime方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContext
/**
* @interface ContextService
**/
public function getContext($model){
$conn = $model['conn'];
$stgid = $conn->escape($model['stgid']);
$uid = $model['uid'];
$access = $model['access'];
$ts = Time::getTime();
$query = "update storages set access=$access, mtime=$ts where stgid='$stgid' and owner=$uid))";
$result = $conn->getResult($query);
if($result === false){
$model['valid'] = false;
$model['msg'] = 'Error in Database @getContext/storage.chmod';
return $model;
}
if($result != 1){
$model['valid'] = false;
$model['msg'] = 'Invalid Storage ID / Not Permitted';
return $model;
}
$model['valid'] = true;
return $model;
}
示例2: 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;
}
}
示例3: getContext
public function getContext($model){
$conn = $model['conn'];
$sessionid = $conn->escape($model['sessionid']);
$ts = Time::getTime();
$query = "delete from sessions where expiry < $ts;";
$conn->getResult($query, true);
$query = "select uid from sessions where sessionid='$sessionid';";
$result = $conn->getResult($query);
if($result === false){
$model['valid'] = false;
$model['uid'] = null;
return $model;
}
if(count($result) != 1){
$model['valid'] = false;
$model['uid'] = null;
return $model;
}
$model['valid'] = true;
$model['uid'] = $result[0][0];
return $model;
}
示例4: 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;
}
示例5: 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;
}
示例6: getDaysFromTime
/**
* Возвращает кол-во полных дней от переданного времени
* @param int $fromTime
* @param int|null $toTime
* @return int
*/
public static function getDaysFromTime($fromTime, $toTime = null)
{
if (is_null($toTime)) {
$toTime = Time::getTime();
}
$fromTime = strtotime(date("Y-m-d", $fromTime));
$toTime = strtotime(date("Y-m-d", $toTime));
$diff = abs($toTime - $fromTime);
return (int) floor($diff / self::TIME_DAY);
}
示例7: getContext
public function getContext($model){
$conn = $model['conn'];
$address = $conn->escape($model['address']);
$message = $conn->escape($model['message']);
$ts = Time::getTime();
$result = $conn->getResult("insert into logs (message, address, time) values ('$message', '$address', $ts);", true);
if($result === false){
$model['valid'] = false;
$model['msg'] = 'Error in Database';
return $model;
}
$model['valid'] = true;
return $model;
}
示例8: setContext
/**
* @interface ContextService
**/
public function setContext($model){
$conn = $model['conn'];
$stgid = $conn->escape($model['stgid']);
$ts = Time::getTime();
$query = "update storages set atime=$ts where stgid='$stgid';";
$result = $conn->getResult($query);
if($result === false){
$model['valid'] = false;
$model['msg'] = 'Error in Database @setContext/storage.list';
return $model;
}
$model['valid'] = true;
return $model;
}
示例9: getContext
/**
* @interface ContextService
**/
public function getContext($model){
$conn = $model['conn'];
$stgid = $conn->escape($model['stgid']);
$dirid = $conn->escape($model['dirid']);
$uid = $model['uid'];
$query = "select stgid from storages where stgid='$dirid';";
$result = $conn->getResult($query);
if($result === false){
$model['valid'] = false;
$model['msg'] = 'Error in Database @getContext/storage.move';
return $model;
}
if(count($result) != 1){
$model['valid'] = false;
$model['msg'] = 'Invalid Storage ID Directory / Not Permitted';
return $model;
}
$ts = Time::getTime();
$query = "update storages set dirid='$dirid', mtime=$ts where stgid='$stgid' and owner=$uid))";
$result = $conn->getResult($query);
if($result === false){
$model['valid'] = false;
$model['msg'] = 'Error in Database @getContext/storage.move';
return $model;
}
if($result != 1){
$model['valid'] = false;
$model['msg'] = 'Invalid Storage ID / Not Permitted';
return $model;
}
$model['valid'] = true;
return $model;
}
示例10: require_once
require_once('init.php');
require_once(ROOT . 'lib/database/MySQL.class.php');
require_once(ROOT . 'lib/session/SessionManager.class.php');
require_once(ROOT . 'lib/user/UserManager.class.php');
require_once(ROOT . 'lib/util/Time.class.php');
if(isset($_POST["action"])){
$um=new UserManager();
$mysql= new MySQL();
$sm=new SessionManager();
$username=$_POST["username"];
$password=$_POST["password"];
$res=$um->authenticate($mysql,$username,$password);
if($res>0){
$random=$sm->addSession($mysql,$res);
setcookie("lcmsession",$random,Time::getTime()+30*24*60*60);
header("Location:index.php");
}
else
{
echo "Username/Password Incorrect.";
}
}
echo <<<HEADER
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>LOGIN</title>