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; }
static function getUserID() { $userID=0; if (LPC_User::configuredForUsers()) { $u=LPC_User::getCurrent(true); if ($u) $userID=$u->id; } return $userID; }
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; }
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, )); }
private function uid($userID) { if ($userID) return $userID; return LPC_User::getCurrent()->id; }
/** * 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(); }
<?php $p=LPC_Page::getCurrent(); $p->title=_LS('lpcAuthRecoverTitle'); if (LPC_User::getCurrent(true)) { $p->st(); $p->a(new LPC_HTML_error(_LH('lpcAuthErrAlreadyLoggedOn'))); return; } $u=LPC_User::newUser(); $us=$u->search(array($u->user_fields['email'],$u->user_fields['token']),array($_REQUEST['e'],$_REQUEST['t'])); if (!$us || $us[0]->getAttr($u->user_fields['token_date'])<time()) { $p->a(new LPC_HTML_error(_LH('lpcAuthInvalidToken'))); return; } $u=$us[0]; if ($u->getAttr($u->user_fields['password'])) $p->title=_LS('lpcAuthResetPasswordTitle'); else $p->title=_LS('lpcAuthCreatePasswordTitle'); $p->st(); if (isset($_POST['reset_password']) && $_POST['reset_password']) { $u->resetToken(); if ($u->save()) { $p->a(new LPC_HTML_confirm(_LH('lpcAuthDoneCancel'))); return; }
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; }
<?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();
<?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>");
public function canUse($projectID=0) { $projectID=$this->defaultID($projectID); if ($u=LPC_User::getCurrent(true)) return (bool) $u->getAllPermissions($projectID); return true; }
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; }