예제 #1
0
파일: LPC_Cache.php 프로젝트: Gutza/LPC
	private static function build_cache_apc()
	{
		self::$type=self::GENERIC_TYPE_GLOBAL;
		self::$speed=self::SPEED_FAST;
		return new LPC_Cache_apc();
	}
예제 #2
0
	static function clearTranslationCache($messageKey,$langID)
	{
		if (!self::checkCache())
			return;

		$cache=LPC_Cache::getCurrent();
		return $cache->deleteG(self::getCacheKey($messageKey,$langID));
	}
예제 #3
0
파일: LPC_User.php 프로젝트: Gutza/LPC
	function isHyperuser($id=0)
	{
		static $local_cache=array(); // A local cache, used just for runtime
		$userID=$this->defaultID($id);
		if (isset($local_cache[$userID]))
			return $local_cache[$userID];

		$cache=LPC_Cache::getCurrent();

		$hyper=$cache->getU(self::HU_KEY,$userID);
		if ($hyper!==false && $this->validatePermissionsCache(0,$userID)) {
			$local_cache[$userID]=(bool) $hyper;
			return $local_cache[$userID];
		}

		self::ensureCacheExpiration($userID,0);

		$rs=$this->query("
			SELECT member_to
			FROM LPC_user_membership
			WHERE
				project=0 AND
				user_member=".$userID." AND
				member_to=1
		");
		$isHyperuser=!$rs->EOF;
		if ($isHyperuser)
			// We just setU() because isHyperuser() is always the first one to run globally.
			// We only set it when we FIND a hyperuser; if we did write it otherwise
			// then all subsequent permissions tests would've used the old cache.
			$cache->setU(self::PD_KEY, self::getNow(), $userID);

		$local_cache[$userID]=$isHyperuser;
		$cache->setU(self::HU_KEY, (int) $isHyperuser, $userID);

		return $isHyperuser;
	}
예제 #4
0
파일: debug.php 프로젝트: Gutza/LPC
	return;
}

$u=LPC_User::newUser();
$u->idFromArrayKey($_REQUEST, 'user_id');

$f=new LPC_HTML_form();
$p->a($f);
$f->a(htmlspecialchars(_LS('rightsTestUserID')).": <input type='text' name='user_id' value='".$u->id."'> ");
$f->a("<input type='submit' name='submit' value='"._LS('rightsTestSubmit')."'>");

if (!$u->id)
	return;

if (defined('LPC_project_class') && LPC_project_class)
	$prj=LPC_Project::getCurrent();
else
	$prj=NULL;

$cache=LPC_Cache::getCurrent();
$t=new LPC_HTML_table();
$p->a($t);
$t->a("<tr><th>"._LS('rightTestUserDate')."</td><td>".date('r', $cache->getUPf(LPC_User::PD_KEY, $u->id))." (".($u->validatePermissionsCache()?"VALID":"INVALID").")</td></tr>");
$t->a("<tr><th>"._LS('rightTestGlobalExpDate')."</th><td>".date('r', $cache->getG(LPC_User::PE_KEY))."</td></tr>");
$t->a("<tr><th>"._LS('rightTestUserExpDate')."</th><td>".date('r', $cache->getU(LPC_User::PE_KEY, $u->id))."</td></tr>");
if ($prj) {
	$t->a("<tr><th>"._LS('rightTestProjectExpDate')."</th><td>".date('r', $cache->getP(LPC_User::PE_KEY, $prj->id))."</td></tr>");
	$t->a("<tr><th>"._LS('rightTestUserProjectExpDate')."</th><td>".date('r', $cache->getUP(LPC_User::PE_KEY, $u->id, $prj->id))."</td></tr>");
}
$t->a("<tr><th>"._LS('rightTestUserPermissions')."</th><td><pre>".print_r($cache->getUPf(LPC_User::P_KEY, $u->id),1));