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}"); } }
public static function hasEmailVerified($username = NULL) { if ($username === NULL) { $username = fAuthorization::getUserToken(); } $email = UserEmail::fetch($username); if ($email === NULL) { return FALSE; } return strlen($email) > 0; }
public function allowQuestion() { return $this->isRunning() and (User::isSuper() or $this->checkRegistered(fAuthorization::getUserToken())); }
<?php include_once __DIR__ . '/inc/init.php'; fAuthorization::requireLoggedIn(); $errmsg = ''; if (fRequest::isPost()) { $old_password = fRequest::get('old-password'); $new_password = fRequest::get('new-password'); $confirm_password = fRequest::get('confirm-password'); $token = fAuthorization::getUserToken(); $username = $token['name']; $user_id = $token['id']; if (empty($old_password) or empty($new_password) or empty($confirm_password)) { $errmsg = '密码不能为空'; } else { if ($new_password != $confirm_password) { $errmsg = '两次输入的新密码不一致'; } else { if (login_check_credential($db, $username, $old_password) == false) { $errmsg = '旧密码错误'; } else { if (login_change_password($db, $user_id, $new_password)) { fURL::redirect(fSession::delete('change-password-referer', SITE_BASE)); } else { $errmsg = '修改密码失败'; } } } } } else { if (fSession::get('change-password-referer') == null) {
<th>Item Code</th><th width="300px">Description</th><th>Quantity</th><th>UOM</th><th>Unit Price</th><th>Extended Price</th></tr> </thead> <tbody> </tbody> <tfoot> <tr><td colspan="5"></td><td>Discount</td><td><input type="text" id="discountRate" value="0.00"></input></td></tr> <tr><td colspan="5" id="addRowBTN"><div class="ui-icon ui-icon-circle-plus span-1 last"></div>Add Row</td><td class="tfootCaption">Total</td><td id="purchaseTotal"></td></tr> </tfoot> </table> <div class="pdbox span-11"><label>Payment Terms</label><br /><textarea id="payment" rows="4" cols="10" style="height: 30px; margin-bottom: 20px;"></textarea></div> <div class="pdbox span-11"><label>Delivery Terms</label><br /><textarea id="delivery" rows="4" cols="10" style="height: 30px; margin-bottom: 20px;"></textarea></div> <div class="pdbox span-11"><label>Special Instructions</label><br /><textarea id="special" rows="4" cols="10" style="height: 30px; margin-bottom: 20px;"></textarea></div> <table id="approveContent"> <tbody> <tr> <td><label>Requester </label></td><td id="requester"><?php echo fAuthorization::getUserToken(); ?> </td><td><label>Date </label><input type="text" id="reqDate" class="datepicker"></input></td> </tr> <tr style="display: none;"> <td><label>Approver 1 </label></td><td></td><td><label>Date </label><input type="text" id="app1Date" class="datepicker"></input></td> </tr> </tbody> </table> <input type="button" id="submitPOBTN" value="Submit to PO" style="float: left;"> <input type="button" id="submitBTN" value="Submit" style="float: right;"/> </div> </div> <?php $tmpl->place('footer');
echo Profile::fetchGrade(fAuthorization::getUserToken()); ?> "> </div> </div> <div class="control-group"> <label class="control-label" for="phone">手机 (必填)</label> <div class="controls"> <input type="text" class="input-medium" id="phone" name="phone" placeholder="手机" value="<?php echo Profile::fetchPhoneNumber(fAuthorization::getUserToken()); ?> "> </div> </div> <div class="control-group"> <label class="control-label" for="qq">QQ</label> <div class="controls"> <input type="text" class="input-medium" id="qq" name="qq" placeholder="QQ" value="<?php echo Profile::fetchQQ(fAuthorization::getUserToken()); ?> "> </div> </div> <div class="form-actions"> <button type="submit" class="btn btn-success">修改我的个人信息</button> <a class="btn" href="javascript:history.go(-1);void(0);">取消</a> </div> </fieldset> </form> <?php include __DIR__ . '/../layout/footer.php';
<?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 }
public function testUserToken() { $this->assertEquals(NULL, fAuthorization::getUserToken()); fAuthorization::setUserToken('*****@*****.**'); $this->assertEquals('*****@*****.**', fAuthorization::getUserToken()); }
</head> <body> <div class="container"> <div id="header" class="span-24 ui-corner-top last"> <div id="tab1" class="span-3 tab ui-corner-top"> <a href="admin-user.php">Admin</a> </div> <div id="tab2" class="span-3 tab ui-corner-top"> <a href="list-pr.php">Document</a> </div> <div id="tab3" class="span-3 tab ui-corner-top"> <a href="inventory.php">Inventory</a> </div> <div id="tab4" class="span-3 tab ui-corner-top"> <a href="report.php">Report</a> </div> <div id="logintab" class="span-7"> <?php //echo "<p style=\"float: right;\">"; if (fAuthorization::checkLoggedIn()) { echo "Welcome " . fAuthorization::getUserToken(); //echo "<a>Change Password </a>"; echo " <a href=\"authentication.php?type=logout\">Logout </a>"; //echo "</p>"; } ?> </div> <div id="logo" class="go-right span-3 last"></div> </div>
public function checkVericode($id, $vericode) { try { $v = new Vericode($id); if ($v->getUsername() != fAuthorization::getUserToken() or $v->getVericode() != $vericode) { throw new fValidationException('Invalid verification code.'); } $ue = new UserEmail(); $ue->setUsername($v->getUsername()); $ue->setEmail($v->getEmail()); $ue->store(); fMessaging::create('success', 'Your email address is verified successfully.'); $referer = fMessaging::retrieve('referer', SITE_BASE . '/email/verify'); if ($referer == NULL) { $referer = SITE_BASE; } fURL::redirect($referer); } catch (fException $e) { fMessaging::create('error', 'Email verification failed: ' . $e->getMessage()); Util::redirect('/email/verify'); } }
echo "<tr class=\"linkable\"><td class=\"docNumber\">" . $mattran->prepareDocNumber() . "</td>"; echo "<td>" . $mattran->prepareDocDate("j F Y") . "</td>"; echo "<td>" . $mattran->prepareRequester() . "</td>"; echo "<td>" . $fromBranch->prepareName() . "</td>"; echo "<td>" . $toBranch->prepareName() . "</td>"; echo "<td>" . $mattran->prepareStatus() . "</td></tr>"; } } catch (fExpectedException $e) { echo $e->printMessage(); } ?> </tbody> </table> <?php } else { $user = new User(fAuthorization::getUserToken()); ?> <h3>List - Attention</h3> <table> <thead> <tr> <th>Document Number</th><th>Document Date</th><th>Requester</th> <th>from Department</th><th>to Department</th><th>Status</th> </tr> </thead> <tbody> <?php try { //$mattrans = Material_transfer::findByBranchFrom(10,$user->getBranchId()); $mattrans = Material_transfer::findByBranchToFro($user->getBranchId(), 20); foreach ($mattrans as $mattran) {
/** * Master function to evaluate current user's login-ish-ness. */ public static function evaluateSession() { if (!static::isLoggedIn()) { return; } static::$logged_in = true; static::$current_user = fAuthorization::getUserToken(); }
public function newQuestion($id) { try { $report = new Report($id); if (!$report->allowQuestion()) { throw new fValidationException('Not allowed to ask question.'); } $category = fRequest::get('category', 'integer'); if ($category == 0) { throw new fValidationException('Please choose a category.'); } $question = new Question(); $question->setUsername(fAuthorization::getUserToken()); $question->setReportId($report->getId()); if ($category < 0) { $question->setCategory($category); } else { $question->setCategory(Question::ABOUT_PROBLEM_HIDDEN); $problem = new Problem($category); $question->setProblemId($problem->getId()); } $question->setAskTime(new fTimestamp()); $question->setQuestion(trim(fRequest::get('question'))); if (strlen($question->getQuestion()) < 10) { throw new fValidationException('Question too short (minimum 10 bytes).'); } if (strlen($question->getQuestion()) > 500) { throw new fValidationException('Question too long (maximum 500 bytes).'); } $question->store(); fMessaging::create('success', 'Question saved.'); } catch (fExpectedException $e) { fMessaging::create('warning', $e->getMessage()); } catch (fUnexpectedException $e) { fMessaging::create('error', $e->getMessage()); } Util::redirect("/contest/{$id}"); }
public static function getDisplayName() { $token = fAuthorization::getUserToken(); return $token['display_name']; }
public function isReadable() { return fAuthorization::getUserToken() == $this->getOwner() or User::can('view-any-record'); }