예제 #1
0
파일: LPC_Page.php 프로젝트: Gutza/LPC
	protected function renderFooter()
	{
		$result=array();

		if ($this->noFooter)
			return $result;

		$copy=new LPC_HTML_node("DIV");
		$copy->setAttr('class','copyright');
		$copy->content="Powered by <b>LPC</b> v".LPC_version." by <a href='http://www.moongate.eu/'>Moongate</a>";
		$result[]=$copy;

		if (!strlen(LPC_user_class) || !LPC_User::getCurrent(true))
			return $result; // no info in footer if you're not logged in

		$loadInfo="";
		if ($this->loadAvgFile && is_readable($this->loadAvgFile)) {
			$coreCount=`cat {$this->cpuinfoFile} | grep processor | wc -l`;
			list($loadInfo)=explode(" ",file_get_contents($this->loadAvgFile));
			$loadInfo="; load 5s: ".($loadInfo*100/$coreCount)."% (avg on ".$coreCount.($coreCount>1?' cores':' core').")";
		}

		$result[]=$this->renderMessageTranslations();

		$runtime=new LPC_HTML_node("DIV");
		$runtime->setAttr('style',"color:#c0c0c0; text-align:center; font-size:80%; margin-top:10px");
		$runTime=number_format(microtime(true)-LPC_start_time,3);
		$runtime->content="Page rendered in ".$runTime." seconds".$loadInfo;
		$result[]=$runtime;

		return $result;
	}
예제 #2
0
파일: LPC_Logger.php 프로젝트: Gutza/LPC
	static function getUserID()
	{
		$userID=0;
		if (LPC_User::configuredForUsers()) {
			$u=LPC_User::getCurrent(true);
			if ($u)
				$userID=$u->id;
		}

		return $userID;
	}
예제 #3
0
	private function nameUP($name,$userID,$projectID)
	{
		if (!$userID) {
			$u=LPC_User::getCurrent();
			$userID=$u->id;
		}
		if (!$projectID) {
			$p=LPC_Project::getCurrent();
			$projectID=$p->id;
		}
		return $name.'.u'.$userID.'.p'.$projectID;
	}
예제 #4
0
	function addForcedVisi($obj, $attr, $mode)
	{
		$this->query("
			INSERT INTO ".$this->getTableName()."
			(user, class_name, field_name, action)
			VALUES (?, ?, ?, ?)
		", array(
			LPC_User::getCurrent()->id,
			get_class($obj),
			$attr,
			$mode,
		));
	}
예제 #5
0
파일: LPC_User.php 프로젝트: Gutza/LPC
	public static function setCurrent($object=NULL)
	{
		if (empty($object) || !$object->id) {
			self::$currentInstance=NULL;
			$_SESSION['LPC']['current_user_id']=0;
			return true;
		}

		if (!is_a($object, "LPC_User"))
			throw new RuntimeException(
				"You can only assign LPC_User objects or descendants as the current user [".
				gettype($object)."]"
			);

		self::$currentInstance = $object;
		$_SESSION['LPC']['current_user_id'] = $object->id;
		$_SESSION['LPC']['current_user_last_seen'] = time();
		return true;
	}
예제 #6
0
	private function uid($userID)
	{
		if ($userID)
			return $userID;
		return LPC_User::getCurrent()->id;
	}
예제 #7
0
파일: LPC_Object.php 프로젝트: Gutza/LPC
	/**
	* Checks whether the current user has a specific CRUD scaffolding right.
	*
	* Superusers (and hyperusers) always have all rights by default.
	* Other users (including anonymous users) never have any right by default.
	* Override this method in descendants if you want to customize it.
	*
	* Typically you'll want to start with the following code:
	* if (parent::hasScaffoldingRight($right)) return true;
	*
	* @param char $right the right to check for; one of "C", "R", "U", "D"
	* @return boolean true if the current user does have the specified right, false otherwise.
	*/
	public function hasScaffoldingRight($right)
	{
		if (!defined('LPC_user_class'))
			// This project doesn't have registered users
			return false;

		$u=LPC_User::getCurrent();
		return $u->isSuperuser();
	}
예제 #8
0
파일: LPC_Group.php 프로젝트: Gutza/LPC
	function removeFromGroup($group)
	{
		if (is_integer($group)) {
			$groupID=$group;
			$group=new LPC_Group($groupID);
		} elseif ($group instanceof LPC_Group)
			$groupID=$group->id;
		else
			throw new RuntimeException("Unknown parameter type! Expecting an integer or a LPC_Group instance.");

		LPC_User::expireCache($this->getAttr('project'),0);

		$rs=$this->query("
			DELETE
			FROM LPC_group_membership
			WHERE
				group_member=".$this->id." AND
				member_to=".$groupID
		);
		return $rs->Affected_Rows;
	}
예제 #9
0
파일: welcome.php 프로젝트: Gutza/LPC
function validation_conditions()
{
	$u=LPC_User::newUser();
	$conds=array();
	$conds[]=_LH('lpcAuthValidCondMinLength',$u->password_conditions['min_length']);
	if ($u->password_conditions['need_alpha'])
		$conds[]=_LH('lpcAuthValidCondAlpha');
	if ($u->password_conditions['need_numeric'])
		$conds[]=_LH('lpcAuthValidCondNumeric');
	return "<ul><li>".implode($conds,"</li><li>")."</li></ul>";
}
예제 #10
0
파일: LPC_lib.php 프로젝트: Gutza/LPC
require LPC_include."/LPC_intl.php";
require LPC_include."/LPC_config.php";

if (LPC_GUI)
	require LPC_include."/LPC_icons.php";

if (LPC_GUI_OB)
	ob_start();

if (
	getenv("LPC_auth") &&
	isset($_SERVER['REMOTE_ADDR']) && // not for CLI
	!LPC_User::getCurrent(true) &&
	($usr=LPC_User::newUser()) && // lazy instantiation
	LPC_URI::getCurrent()->getPath() != $usr->recoverPasswordURL() &&
	LPC_URI::getCurrent()->getFullPath() != $usr->processTokenBaseURL()
)
	LPC_User::getCurrent();

function LPC_prefill(&$array, $values)
{
	$count=0;
	foreach($values as $key=>$value) {
		if (array_key_exists($key, $array))
			continue;
		$array[$key]=$value;
		$count++;
	}
	return $count;
}
예제 #11
0
파일: logout.php 프로젝트: Gutza/LPC
<?php

$p = LPC_Page::getCurrent();
$u = LPC_User::getCurrent(true);
if (!$u)
	$p->a(new LPC_HTML_error(__L("lpcLogoutAlready")));
else {
	$u->logout();
	$p->a(new LPC_HTML_confirm(__L("lpcLogoutConfirm")));
}
$p->show();
예제 #12
0
<?php

$p=LPC_Page::getCurrent();
$p->title=_LS('lpcAuthRecoverTitle');
$p->st();

if (LPC_User::getCurrent(true)) {
	$p->a(new LPC_HTML_error(_LH('lpcAuthErrAlreadyLoggedOn')));
	return;
}

if (!empty($_POST['email'])) {
	// Requesting e-mail
	$us=LPC_User::newUser();
	$us=$us->search($us->user_fields["email"],$_POST['email']);
	if ($us && !$us[0]->sendRecover())
		$p->a(new LPC_HTML_error(_LH('lpcAuthErrFailEmail',$_POST['email'])));
	else
		$p->a(new LPC_HTML_confirm(_LH('lpcAuthConfirmRecoverEmail',$_POST['email'])));
	return;
}

$form=new LPC_HTML_form();
$p->a($form);
$div=new LPC_HTML_node('div');
$form->a($div);
$div->a("
<table>
<tr>
	<td>"._LS('lpcAuthRecoverEmailField')."</td>
	<td><input type='text' name='email' id='email'></td>
예제 #13
0
파일: debug.php 프로젝트: Gutza/LPC
<?php

$p=LPC_Page::getCurrent();
$p->st(_LS('rightsTestCache'));

if (!LPC_User::getCurrent()->isSuperuser()) {
	$p->a(new LPC_HTML_error(_LS('genericErrorRights')));
	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>");
예제 #14
0
파일: LPC_Project.php 프로젝트: Gutza/LPC
	public function canUse($projectID=0)
	{
		$projectID=$this->defaultID($projectID);
		if ($u=LPC_User::getCurrent(true))
			return (bool) $u->getAllPermissions($projectID);
		return true;
	}
예제 #15
0
파일: LPC_Menu.php 프로젝트: Gutza/LPC
	function noPermission($atom)
	{
		$u=LPC_User::getCurrent(); // Let's make sure you're logged in
		header('HTTP/1.1 403 Forbidden');
		echo $this->noPermMessage;
		trigger_error("LPC: Access denied",E_USER_WARNING);
		exit;
	}