本文整理汇总了PHP中fAuthorization类的典型用法代码示例。如果您正苦于以下问题:PHP fAuthorization类的具体用法?PHP fAuthorization怎么用?PHP fAuthorization使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了fAuthorization类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submit
public function submit($problem_id)
{
try {
$problem = new Problem($problem_id);
$language = fRequest::get('language', 'integer');
if (!array_key_exists($language, static::$languages)) {
throw new fValidationException('Invalid language.');
}
fSession::set('last_language', $language);
$code = trim(fRequest::get('code', 'string'));
if (strlen($code) == 0) {
throw new fValidationException('Code cannot be empty.');
}
if ($problem->isSecretNow()) {
if (!User::can('view-any-problem')) {
throw new fAuthorizationException('Problem is secret now. You are not allowed to submit this problem.');
}
}
$record = new Record();
$record->setOwner(fAuthorization::getUserToken());
$record->setProblemId($problem->getId());
$record->setSubmitCode($code);
$record->setCodeLanguage($language);
$record->setSubmitDatetime(Util::currentTime());
$record->setJudgeStatus(JudgeStatus::PENDING);
$record->setJudgeMessage('Judging... PROB=' . $problem->getId() . ' LANG=' . static::$languages[$language]);
$record->setVerdict(Verdict::UNKNOWN);
$record->store();
Util::redirect('/status');
} catch (fException $e) {
fMessaging::create('error', $e->getMessage());
fMessaging::create('code', '/submit', fRequest::get('code', 'string'));
Util::redirect("/submit?problem={$problem_id}");
}
}
示例2: login_authenticate
function login_authenticate($db, $username, $password)
{
if ($row = login_check_credential($db, $username, $password)) {
fAuthorization::setUserToken(array('id' => $row['id'], 'name' => $username, 'email' => $row['email'], 'display_name' => $row['display_name']));
return true;
}
return false;
}
示例3: requireEmailVerified
public static function requireEmailVerified()
{
if (!fAuthorization::checkLoggedIn()) {
return;
}
if (User::hasEmailVerified()) {
return;
}
fMessaging::create('warning', 'You are required to verify your email address before doing this action.');
Util::redirect('/email/verify');
}
示例4: render
protected function render($name)
{
// before output page
// if the visitor is anonymous
// do NOT send Set-Cookie to enable caching of Varnish
if (!fAuthorization::checkLoggedIn()) {
header_remove('Set-Cookie');
}
// then output page
profiler_render_begin();
include __DIR__ . '/../views/' . $name . '.php';
}
示例5: index
public function index()
{
if (fAuthorization::checkLoggedIn()) {
$this->cache_control('private', 2);
} else {
$this->cache_control('private', 5);
}
$top = fRequest::get('top', 'integer');
$this->owner = trim(fRequest::get('owner'));
$this->problem_id = trim(fRequest::get('problem'));
$this->language = trim(fRequest::get('language'));
$this->verdict = trim(fRequest::get('verdict'));
$this->page = fRequest::get('page', 'integer', 1);
$this->records = Record::find($top, $this->owner, $this->problem_id, $this->language, $this->verdict, $this->page);
$this->page_records = $this->records;
$common_url = SITE_BASE . "/status?owner={$this->owner}&problem={$this->problem_id}&language={$this->language}&verdict={$this->verdict}";
$this->top_url = "{$common_url}&top=";
$this->page_url = "{$common_url}&page=";
$this->nav_class = 'status';
$this->render('record/index');
}
示例6: show
public function show($id)
{
if (fAuthorization::checkLoggedIn()) {
$this->cache_control('private', 30);
} else {
$this->cache_control('private', 60);
}
try {
$this->problem = new Problem($id);
if ($this->problem->isSecretNow()) {
if (!User::can('view-any-problem')) {
throw new fAuthorizationException('Problem is secret now.');
}
}
$this->nav_class = 'problems';
$this->render('problem/show');
} catch (fExpectedException $e) {
fMessaging::create('warning', $e->getMessage());
fURL::redirect(Util::getReferer());
} catch (fUnexpectedException $e) {
fMessaging::create('error', $e->getMessage());
fURL::redirect(Util::getReferer());
}
}
示例7: dirname
<?php
include dirname(__FILE__) . '/../inc/init.php';
fAuthorization::requireLoggedIn();
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
$debug = fRequest::get('debug', 'boolean');
if (!$debug) {
header('Content-type: application/json');
}
$check_id = fRequest::get('check_id', 'integer');
$check = new Check($check_id);
$url = GRAPHITE_URL . '/graphlot/rawdata?&from=-24hour&until=-0hour' . '&target=' . $check->prepareTarget() . '&target=keepLastValue(threshold(' . $check->prepareWarn() . '))';
// '&target=threshold(' . $check->prepareError() . ')';
$contents = file_get_contents($url);
//$contents = file_get_contents(GRAPHITE_URL . '/graphlot/rawdata?&from=-24hour&until=-0hour&target=' . $check->prepareTarget() . '&target=' . $check->prepareWarn() . '&target=' . $check->prepareError());
print $contents;
示例8: allowQuestion
public function allowQuestion()
{
return $this->isRunning() and (User::isSuper() or $this->checkRegistered(fAuthorization::getUserToken()));
}
示例9: count
<?php
$section = 'categories';
$section_id = 25;
$sub = 'listGcategory';
$typeOfUser = fAuthorization::checkAuthLevel('super');
$where = "";
if (!$typeOfUser) {
$where = " WHERE " . fSession::get('where_at');
}
?>
<?php
$limit = fRequest::encode('limit', 'integer');
$page = fRequest::encode('p', 'integer');
if ($page < 1) {
exit;
}
$start = ($page - 1) * $limit;
$categories = fRecordSet::buildFromSQL('EconomicUnitCategory', "SELECT * FROM economic_unit_categories {$where} LIMIT {$start},{$limit}", "SELECT count(*) FROM economic_unit_categories {$where}", $limit, $page);
if ($categories->count() == 0) {
echo '<div class="notification information" >
Por el momento no hay registros en <b> Categorías de Geolocalización</b>.
</div>';
} else {
$p = new Pagination($categories->getPages(), $categories->getPage(), 3);
$pagination = $p->getPaginationLinks();
?>
<center>
<table class="contenttoc" style="width:auto; float:left">
<tr>
示例10: Supplier
<?php
include './resources/init.php';
fAuthorization::requireAuthLevel('admin');
$tmpl->place('header');
?>
<script type="text/javascript" src="./js/admin-supplier-view.js"></script>
</head>
<body>
<div class = "container">
<div id="View" class = "view-frame span-23 last">
<?php
if (!isset($_GET['id'])) {
echo "<div class=\"ui-state-error ui-corner-all\">\n\t\t\t\t\t\t<span class=\"ui-icon ui-icon-alert\" style=\"float: left; margin-right: 30px;\"></span>\n\t\t\t\t\t\tYou arrived to this page in error</div>";
} else {
try {
$supplier = new Supplier($_GET['id']);
?>
<h2><span id="titleName"><?php
echo $supplier->prepareName();
?>
</span></h2>
<input id="key" type="hidden" value="<?php
echo $supplier->prepareId();
?>
" />
<table>
<tr>
<td width="100"><b>Name</b></td>
<td><span id="supName" class="varInput"><?php
echo $supplier->prepareName();
示例11:
<?php
include './resources/init.php';
fAuthorization::requireAuthLevel('super');
$tmpl->place('header');
?>
<script type="text/javascript" src="./resources/library/jquery.autocomplete/jquery.autocomplete.min.js"></script>
<script type="text/javascript" src="./resources/library/jquery.autocomplete/lib/jquery.bgiframe.min.js"></script>
<script type="text/javascript" src="./resources/library/jquery.blockUI.js"></script>
<link media="screen, projection" href="./resources/library/jquery.autocomplete/jquery.autocomplete.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript" src="./js/admin-stock.js"></script>
<?php
$tmpl->place('menu');
?>
<div id="content" class="span-24 last">
<?php
$tmpl->place('menuAdmin');
?>
<div id="main" class="span-24 last">
<h2>Administration</h2><h3>Stock</h3>
<br />
<form action = "admin-stock.php" method = "get">
<label for="inv_item">Choose Inventory Item: </label>
<span id="inv_item">
<input id="autocompleteItem" name="item"></input>
</span>
<input id="submitBTN" type="submit" value="Submit" />
</form>
<?php
if (isset($_GET['item'])) {
try {
示例12: define
fORM::mapClassToTable('Role', TBL_ROLE);
fORM::mapClassToTable('Permission', TBL_PERMISSION);
fORM::mapClassToTable('Category', TBL_CATEGORY);
fORM::mapClassToTable('UserPermission', TBL_USER_PERMISSION);
fORM::mapClassToTable('Log', 'log');
/* Public Directories & Files */
define('SITE', 'http:' . DS . DS . $_SERVER['HTTP_HOST'] . DS . 'adminv3' . DS);
define('CSS', SITE . 'css' . DS);
define('JS', SITE . 'js' . DS);
define('SCRIPT', JS . 'script' . DS);
define('HOME', SITE . 'home' . DS);
define('BANNER', SITE . 'banner' . DS);
define('GEOLOCATION', SITE . 'geolocation' . DS);
define('USER', SITE . 'user' . DS);
define('CATEGORIES', SITE . 'categories' . DS);
define('LOGOUT', SITE . 'logout' . DS);
define('LOGIN', SITE . 'login' . DS);
define('IMAGES', SITE . 'images' . DS);
define('ICON', IMAGES . 'icon' . DS);
/* Private Directories & Files */
define('INCLUDES', ROOT . 'includes' . DS);
define('LOAD', ROOT . 'load' . DS);
/* Session */
define('SESSION_ID_USER', 'idUser');
define('SESSION_REGIONS', 'regions');
define('SALT', '#^&(!)()');
$db = new fDatabase('mysql', 'adminv2n', 'root', 'tortoise');
fORMDatabase::attach($db);
fAuthorization::setLoginPage(SITE . 'login.php');
fAuthorization::setAuthLevels(array('super' => 100, 'admin' => 80, 'cliente' => 20, 'adminUsers' => 80, 'employee' => 50, 'guest' => 25));
$acceptedFiles = array('image/gif', 'image/bmp', 'image/jpeg', 'image/pjpeg', 'image/png', 'application/msword', 'application/pdf', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'text/plain', 'text/richtext', 'text/html', 'video/mpeg', 'video/x-mpeg2', 'video/msvideo', 'video/quicktime', 'video/vivo', 'video/wavelet', 'video/x-sgi-movie', 'video/x-flv', 'video/mp4', 'audio/x-wav', 'audio/x-mp3', 'audio/midi');
示例13: elseif
<?php
if (fAuthorization::checkLoggedIn() and Registration::has(fAuthorization::getUserToken(), $this->report->getId())) {
?>
<button class="btn btn-mini btn-success disabled">已确认参赛</button>
<?php
} elseif ($this->report->isRegistrable()) {
?>
<form style="display:inline;margin:0" action="<?php
echo SITE_BASE;
?>
/contest/<?php
echo $this->report->getId();
?>
/register" method="POST">
<button type="submit" class="btn btn-mini btn-success">确认参赛</button>
</form>
<?php
}
示例14: testGetLoginPage
public function testGetLoginPage()
{
fAuthorization::setLoginPage('/login/');
$this->assertEquals('/login/', fAuthorization::getLoginPage());
}
示例15: if
<table class="zebra-striped">
<thead>
<tr>
<th>Username</th>
<th>Email</th>
<th>Action</th>
</tr></thead><tbody>
<?php
$first = TRUE;
foreach ($users as $user) {
?>
<tr>
<td><?php echo $user->prepareUsername() ?></td>
<td><?php echo $user->prepareEmail() ?></td>
<td><?php if (fSession::get('user_id') == $user->getUserId() || fAuthorization::checkAuthLevel('admin')) { echo '<a href="' . User::makeUrl('edit',$user) . '">Edit</a>'; } ?>
<?php if (fAuthorization::checkAuthLevel('admin') || $user->getUserId() != 1) {
?> <a href="<?php echo User::makeUrl('delete',$user); ?>">Delete</a></td>
<?php } ?>
</tr>
<?php } ?>
</tbody></table>
<?
} catch (fEmptySetException $e) {
?>
<p class="info">There are currently no Tattle users? <a href="<?php echo '<a href="'. User::makeUrl('add'); ?>">Add one now</a></p>
<?php
}
?>
</div>
<?php $tmpl->place('footer') ?>