当前位置: 首页>>代码示例>>PHP>>正文


PHP fSession类代码示例

本文整理汇总了PHP中fSession的典型用法代码示例。如果您正苦于以下问题:PHP fSession类的具体用法?PHP fSession怎么用?PHP fSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了fSession类的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}");
     }
 }
开发者ID:daerduoCarey,项目名称:oj,代码行数:35,代码来源:SubmitController.php

示例2: findAll

	/**
	 * Returns all checks on the system
	 * 
	 * @param  string  $sort_column  The column to sort by
	 * @param  string  $sort_dir     The direction to sort the column
	 * @return fRecordSet  An object containing all meetups
	 */
	static function findAll($sort_column = 'name', $sort_dir = 'desc')
	{
       return fRecordSet::build(
          __CLASS__,
          array('enabled=' => true,'user_id=|visibility=' => array(fSession::get('user_id'),0)),
          array($sort_column => $sort_dir)
          );
	}    
开发者ID:rberger,项目名称:Graphite-Tattle,代码行数:15,代码来源:Check.php

示例3: findActive

 static function findActive($check_id = NULL)
 {
     if (!is_null($check_id) && is_numeric($check_id)) {
         $filter = ' AND check_id=' . $check_id;
     } else {
         $filter = '';
     }
     return fRecordSet::buildFromSQL(__CLASS__, array('SELECT subscriptions.* FROM subscriptions WHERE user_id = ' . fSession::get('user_id') . $filter));
 }
开发者ID:nagyist,项目名称:Tattle,代码行数:9,代码来源:Subscription.php

示例4: setPreviousSortDirection

 /**
  * Set the sort direction to be used on returning pages
  *
  * @param  string $sort_direction  The sort direction to save
  * @return void
  */
 private static function setPreviousSortDirection($sort_direction)
 {
     fSession::set(__CLASS__ . '::' . fURL::get() . '::previous_sort_direction', $sort_direction);
 }
开发者ID:gopalgrover23,项目名称:flourish-classes,代码行数:10,代码来源:fCRUD.php

示例5: Check

        fMessaging::create('error', fURL::get(), $e->getMessage());
    }
    include VIEW_PATH . '/ackAll_results.php';
} else {
    if ($action == 'notifyAll') {
        try {
            $check = new Check($check_id);
            $subject_mail = fRequest::get('subject_mail');
            $content_mail = fRequest::get('content_mail');
            if (fRequest::isPost()) {
                if (empty($subject_mail) || empty($content_mail)) {
                    fMessaging::create('error', fURL::get(), "You have to fill the subject and the content to send this mail");
                } else {
                    fRequest::validateCSRFToken(fRequest::get('token'));
                    $recipients = array();
                    $id_user_session = fSession::get('user_id');
                    $user_session = new User($id_user_session);
                    $recipients[] = array("mail" => $user_session->getEmail(), "name" => $user_session->getUsername());
                    $alt_ids = array();
                    $subscription_alt = Subscription::findAll($check_id, NULL, NULL, NULL, TRUE);
                    foreach ($subscription_alt as $alt) {
                        $user = new User($alt->getUserId());
                        $recipients[] = array("mail" => usr_var('alt_email', $user->getUserId()), "name" => $user->getUsername());
                        $alt_ids[] = $alt->getUserId();
                    }
                    $subscriptions = $db->query("SELECT DISTINCT user_id,check_id FROM subscriptions WHERE check_id=" . $check_id . ";");
                    foreach ($subscriptions as $sub) {
                        $user_id = $sub['user_id'];
                        if (!in_array($user_id, $alt_ids) && $user_id != $id_user_session) {
                            $user = new User($sub['user_id']);
                            $recipients[] = array("mail" => $user->getEmail(), "name" => $user->getUsername());
开发者ID:nagyist,项目名称:Tattle,代码行数:31,代码来源:result.php

示例6: validateCSRFToken

 /**
  * Validates a request token generated by ::generateCSRFToken()
  * 
  * This method takes a request token and ensures it is valid, otherwise
  * it will throw an fValidationException.
  * 
  * @throws fValidationException  When the CSRF token specified is invalid
  * 
  * @param  string $token  The request token to validate
  * @param  string $url    The URL to validate the token for, default to the current page
  * @return void
  */
 public static function validateCSRFToken($token, $url = NULL)
 {
     if ($url === NULL) {
         $url = fURL::get();
     }
     $key = __CLASS__ . '::' . $url . '::csrf_tokens';
     $tokens = fSession::get($key, array());
     if (!in_array($token, $tokens)) {
         throw new fValidationException('The form submitted could not be validated as authentic, please try submitting it again');
     }
     $tokens = array_diff($tokens, array($token));
     fSession::set($key, $tokens);
 }
开发者ID:hibble,项目名称:printmaster,代码行数:25,代码来源:fRequest.php

示例7: fValidation

        $validator = new fValidation();
        $validator->addRequiredFields('password', 'email');
        $validator->addEmailFields('email');
        $validator->validate();
        $users = fRecordSet::build('User', array('email=' => strtolower($_POST['email'])));
        if ($users->count() == 0) {
            throw new fValidationException('Invalid username or password.');
        }
        $rec = $users->getRecords();
        $user = $rec[0];
        if (!fCryptography::checkPasswordHash($_POST['password'], $user->getPassword())) {
            throw new fValidationException('Invalid username or password.');
        }
        fSession::set('user', $user->getId());
        if (fRequest::get('persistent_login', 'boolean')) {
            fSession::enablePersistence();
        }
        if (isset($_POST['forward'])) {
            fURL::redirect('http://' . $_SERVER['SERVER_NAME'] . $_POST['forward']);
        } else {
            fURL::redirect('/members');
        }
        exit;
    } catch (fValidationException $e) {
        echo "<p>" . $e->printMessage() . "</p>";
    } catch (fSQLException $e) {
        echo "<p>An unexpected error occurred, please try again later</p>";
        trigger_error($e);
    }
}
?>
开发者ID:russss,项目名称:hackspace-foundation-sites,代码行数:31,代码来源:login.php

示例8: setUserToken

 /**
  * Sets some piece of information to use to identify the current user
  *
  * @param  mixed $token  The user's token. This could be a user id, an email address, a user object, etc.
  * @return void
  */
 public static function setUserToken($token)
 {
     fSession::set(__CLASS__ . '::user_token', $token);
     fSession::regenerateID();
 }
开发者ID:gopalgrover23,项目名称:flourish-classes,代码行数:11,代码来源:fAuthorization.php

示例9:

    echo Subscription::makeURL('add', $check);
    ?>
" class="btn btn-default">Subscribe</a>
             <?php 
}
?>
             <div class="required"><em>*</em> Required field</div>
             <input type="hidden" name="token" value="<?php 
echo fRequest::generateCSRFToken();
?>
" />
<?php 
if ($action == 'add') {
    ?>
             <input type="hidden" name="user_id" value="<?php 
    echo fSession::get('user_id');
    ?>
" />
             <input type="hidden" name="type" value="<?php 
    echo $check_type;
    ?>
" />
<?php 
}
?>
           </div>
           </div>
         </fieldset>
     </form>
    </div>
    <div id="check_graph" class="col-md-9">
开发者ID:nagyist,项目名称:Tattle,代码行数:31,代码来源:add_edit_predictive_check.php

示例10: findAllByGroupId

 /**
  * Returns all checks on the system that matches the group id
  *
  * @param  string  $type         The type of check to return 'threshold', 'predictive'
  * @param  string  $sort_column  The column to sort by
  * @param  string  $sort_dir     The direction to sort the column
  * @param  int     $limit        The max number of records to show
  * @param  int     $page         The offset
  * @return fRecordSet  An object containing all meetups
  */
 static function findAllByGroupId($type, $group_id, $sort_column = 'name', $sort_dir = 'desc', $limit = NULL, $page = NULL)
 {
     return fRecordSet::build(__CLASS__, array('type=' => $type, 'group_id=' => $group_id, 'enabled=' => true, 'user_id=|visibility=' => array(fSession::get('user_id'), 0)), array($sort_column => $sort_dir), $limit, $page);
 }
开发者ID:nagyist,项目名称:Tattle,代码行数:14,代码来源:Check.php

示例11: exit

<?php

fSession::open();
$idUser = fSession::get(SESSION_ID_USER);
if (empty($idUser) || !fAuthorization::checkACL('geolocation', 'edit')) {
    exit("No se ha podido acceder a esta secci&oacite;n");
}
$id = fRequest::encode('id', 'integer');
if (empty($id)) {
    exit("Ha ocurrido un error");
}
if (!fAuthorization::checkAuthLevel('super')) {
    $isOwner = fRecordSet::build('EconomicUnit', array('economic_unit_id =' => $id, 'economic_unit_region=' => fSession::get('regs')));
    $count = $isxOwner->count() > 0;
    if (!$count) {
        header('Location: ' . SITE);
    }
}
try {
    $av = new EconomicUnit($id);
} catch (Exception $e) {
    header("Location: " . SITE);
}
$av->setEconomicUnitName(fRequest::encode('title', 'string'));
//$av->setCreatedAt(date('Y-m-d H:m:s'));
$av->setEconomicUnitStreetType(fRequest::encode('type', 'string'));
$av->setEconomicUnitLatitude(fRequest::encode('latitude', 'string'));
$av->setEconomicUnitLongitude(fRequest::encode('longitude', 'string'));
$av->setEconomicUnitDescription(fRequest::encode('description', 'string'));
$av->setEconomicUnitStreetName(fRequest::encode('street', 'string'));
$av->setEconomicUnitLocationNumber(fRequest::encode('number', 'string'));
开发者ID:nevermind89x,项目名称:Mi-morelia,代码行数:31,代码来源:geolocation_edit.php

示例12: fValidationException

        $validator->addRequiredFields('fullname', 'password', 'email', 'address');
        $validator->addEmailFields('email');
        $validator->validate();
        if ($_POST['password'] != $_POST['passwordconfirm']) {
            throw new fValidationException('Passwords do not match');
        }
        $user = new User();
        $user->setEmail(strtolower($_POST['email']));
        $user->setFullName($_POST['fullname']);
        $user->setAddress($_POST['address']);
        $user->setPassword(fCryptography::hashPassword($_POST['password']));
        if (isset($_POST['hackney'])) {
            $user->setHackney(true);
        }
        $user->store();
        fSession::set('user', $user->getId());
        fURL::redirect('/members');
        exit;
    } catch (fValidationException $e) {
        echo "<p>" . $e->printMessage() . "</p>";
    } catch (fSQLException $e) {
        echo "<p>An unexpected error occurred, please try again later</p>";
        trigger_error($e);
    }
}
?>
<h2>Membership</h2>
<p>The London Hackspace is a members-owned non-profit association. Members have a hand in the running of the
organisation as well as 24/7 access to the space.</p>

<p>Membership is paid monthly by standing order. We ask that you pay what you think the space is worth to you. Running an
开发者ID:russss,项目名称:hackspace-foundation-sites,代码行数:31,代码来源:signup.php

示例13: tearDown

 public function tearDown()
 {
     if (defined('SKIPPING')) {
         return;
     }
     fSession::reset();
 }
开发者ID:nurulimamnotes,项目名称:flourish-old,代码行数:7,代码来源:fSessionTest.php

示例14: catch

        try {
            $user->populate();
        } catch (fExpectedException $e) {
            fMessaging::create('error', fURL::get(), $e - getMessage());
        }
    }
    include VIEW_PATH . '/add_edit_user_settings.php';
} elseif ('delete' == $action) {
    try {
        $user = new User($user_id);
        if (fRequest::isPost()) {
            fRequest::validateCSRFToken(fRequest::get('token'));
            $user->delete();
            fMessaging::create('success', User::makeUrl('edit', $user), 'The user ' . $user->getName() . ' was successfully deleted');
            fURL::redirect(User::makeUrl('edit', $user));
        }
    } catch (fNotFoundException $e) {
        fMessaging::create('error', User::makeUrl('edit', $user), 'The line requested could not be found');
        fURL::redirect(User::makeUrl('edit', $user));
    } catch (fExpectedException $e) {
        fMessaging::create('error', fURL::get(), $e->getMessage());
    }
    include VIEW_PATH . '/delete.php';
} else {
    if (!fAuthorization::checkAuthLevel('admin')) {
        fURL::redirect(User::makeURL('edit', fSession::get('user_id')));
    } else {
        $users = User::findAll();
        include VIEW_PATH . '/list_users.php';
    }
}
开发者ID:nleskiw,项目名称:Graphite-Tattle,代码行数:31,代码来源:user.php

示例15: dirname

<?
include dirname(__FILE__) . '/inc/init.php';

fAuthorization::requireLoggedIn();
$breadcrumbs[] = array('name' => 'Alerts', 'url' => '#','active' => false);

$latest_alerts = 'SELECT c.check_id,name,r.status,count(c.check_id) as count, r.timestamp '.
                 'FROM subscriptions s '. 
                 'JOIN checks c ON s.check_id = c.check_id '.
                 'JOIN check_results r ON s.check_id = r.check_id '.
                 'WHERE r.timestamp >= DATE_SUB(CURDATE(),INTERVAL 1 DAY) '.
                 'AND r.status IS NOT NULL '.
                 'AND acknowledged = 0 '.
                 'AND s.user_id = ' . fSession::get('user_id') . ' ' .
                 'Group by c.check_id;';
$results = $mysql_db->query($latest_alerts);

include dirname(__FILE__) . '/inc/views/index.php';
开发者ID:rberger,项目名称:Graphite-Tattle,代码行数:18,代码来源:index.php


注:本文中的fSession类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。