Ejemplo n.º 1
0
 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');
 }
Ejemplo n.º 2
0
 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';
 }
Ejemplo n.º 3
0
 public function homework()
 {
     if (fAuthorization::checkLoggedIn()) {
         $this->cache_control('private', 5);
     } else {
         $this->cache_control('private', 10);
     }
     $conditions = array('title~' => array('homework', '作业'));
     if (!User::can('view-any-report')) {
         $conditions['visible='] = TRUE;
     }
     $this->reports = fRecordSet::build('Report', $conditions, array('id' => 'desc'));
     $this->nav_class = 'homework';
     $this->render('report/homework');
 }
Ejemplo n.º 4
0
 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');
 }
Ejemplo n.º 5
0
 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());
     }
 }
Ejemplo n.º 6
0
<?php

$title = '微博';
$no_sidebar = true;
$stylesheets = array('bootstrap.min', 'tweets');
include __DIR__ . '/../layout/header.php';
?>
<div class="timeline feed-list">
  <h1>最新微博</h1>
  <?php 
if (fAuthorization::checkLoggedIn()) {
    ?>
  <center>
    <form class="well form-search w500" action="<?php 
    echo SITE_BASE;
    ?>
/tweets" method="post" onsubmit="$.blockUI();">
      <input type="hidden" name="quick" value="true"/>
      <?php 
    if ($tweet_success = fMessaging::retrieve('success', 'create tweet')) {
        ?>
        <div class="alert alert-success fade in">
          <a class="close" data-dismiss="alert">&times;</a>
          <?php 
        echo $tweet_success;
        ?>
        </div>
      <?php 
    }
    ?>
      <?php 
Ejemplo n.º 7
0
 /**
  * Force disable all cache functions if the session is logged in as per
  * fAuthorization::checkLoggedIn();
  */
 public static function disableForAuthorized()
 {
     if (fAuthorization::checkLoggedIn()) {
         static::$authorized_override = true;
     }
 }
Ejemplo n.º 8
0
<?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 testCheckLoggedIn2()
 {
     $this->assertEquals(FALSE, fAuthorization::checkLoggedIn());
     fAuthorization::setAuthLevels(array('user' => 20, 'admin' => 50));
     fAuthorization::setUserAuthLevel('admin');
     $this->assertEquals(TRUE, fAuthorization::checkLoggedIn());
 }
Ejemplo n.º 10
0
      <th>作者</th>
      <th>通过率 (通过/提交)</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <?php 
foreach ($this->problems as $p) {
    ?>
      <tr>
        <td>
          <?php 
    echo $p->getId();
    ?>
          <?php 
    if (fAuthorization::checkLoggedIn() and User::hasAccepted($p)) {
        ?>
            <i class="icon-ok"></i>
          <?php 
    }
    ?>
        </td>
        <td><a href="<?php 
    echo SITE_BASE;
    ?>
/problem/<?php 
    echo $p->getId();
    ?>
"><?php 
    echo fHTML::encode($p->getTitle());
    ?>
Ejemplo n.º 11
0
 /**
  * Check if user is logged in. Uses own static variable, not fAuthorization.
  * 
  * @return boolean		True when the user is logged in
  */
 public static function isLoggedIn()
 {
     return fAuthorization::checkLoggedIn();
 }
Ejemplo n.º 12
0
 public static function requireProfile()
 {
     if (fRequest::isGet() && fAuthorization::checkLoggedIn() && !self::hasProfile()) {
         fURL::redirect(SITE_BASE . '/profiles/new');
     }
 }
Ejemplo n.º 13
0
    <tr>
      <?php 
    foreach ($this->board->getFooters() as $footer) {
        ?>
        <th><?php 
        echo $footer;
        ?>
</th>
      <?php 
    }
    ?>
    </tr>
  </tfoot>
</table>
<div class="alert alert-info">
  Sort multiple columns simultaneously by 
  holding down the <strong>shift</strong> key and 
  clicking a second, third or even fourth column header!
</div>
<?php 
}
$contest_id = $this->report->getId();
if ($this->report->getElapsedRatio() < 100) {
    $meta_refresh = Variable::getInteger('status-refresh', 30);
}
if (fAuthorization::checkLoggedIn() and $this->report->isRunning()) {
    $javascripts = array('jquery.tablesorter.min', 'board', 'ts-alert');
} else {
    $javascripts = array('jquery.tablesorter.min', 'board');
}
include __DIR__ . '/../layout/footer.php';