本文整理汇总了PHP中SessionController类的典型用法代码示例。如果您正苦于以下问题:PHP SessionController类的具体用法?PHP SessionController怎么用?PHP SessionController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SessionController类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getInstance
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new SessionController();
}
return self::$instance;
}
开发者ID:ecuation,项目名称:Control-de-stock,代码行数:7,代码来源:SessionController.php
示例2: testUserNameCollision
public function testUserNameCollision()
{
$salt = time();
// Test users should not exist
$this->assertNull(UsersDAO::FindByUsername('A' . $salt));
$this->assertNull(UsersDAO::FindByUsername('A' . $salt . '1'));
$this->assertNull(UsersDAO::FindByUsername('A' . $salt . '2'));
// Create collision
$c = new SessionController();
$c->LoginViaGoogle('A' . $salt . '@isp1.com');
$c->LoginViaGoogle('A' . $salt . '@isp2.com');
$c->LoginViaGoogle('A' . $salt . '@isp3.com');
$this->assertNotNull(UsersDAO::FindByUsername('A' . $salt));
$this->assertNotNull(UsersDAO::FindByUsername('A' . $salt . '1'));
$this->assertNotNull(UsersDAO::FindByUsername('A' . $salt . '2'));
}
开发者ID:andreasantillana,项目名称:omegaup,代码行数:16,代码来源:UserRegistrationTest.php
示例3: authenticateRequest
/**
* Given the request, returns what user is performing the request by
* looking at the auth_token
*
* @param Request $r
* @throws InvalidDatabaseOperationException
* @throws UnauthorizedException
*/
protected static function authenticateRequest(Request $r)
{
$session = SessionController::apiCurrentSession($r);
if (!$session['valid'] || $session['user'] == null) {
throw new UnauthorizedException();
}
$r['current_user'] = $session['user'];
$r['current_user_id'] = $session['user']->user_id;
}
开发者ID:andreasantillana,项目名称:omegaup,代码行数:17,代码来源:Controller.php
示例4: login
public function login($email = null, $user_password = null)
{
//check if email exists in data base
//check if password is set
if ($this->find_by_email($email) && $user_password) {
$this->_email = $email;
$this->_password = $user_password;
$this->_hash = $this->_data['password'];
if (Encryption::checkPassword($this->_password, $this->_hash)) {
//set the data in a session.
$session = new SessionController();
$session->set('user_session', array("user_id" => $this->_data['id'], "name" => $this->_data['name'] . " " . $this->_data['lastname']));
return true;
// RedirectController::to("/kortingennu/");
}
}
return false;
}
开发者ID:herandil,项目名称:discountnow,代码行数:18,代码来源:Users.php
示例5: getAndClauses
public function getAndClauses(array $definitions, $db_field)
{
if ($definitions['operator'] == "LIKE" && strlen($this->_post[$definitions['alias']]) > 0) {
$this->queryString .= ' ' . $definitions['clause'] . ' ' . $definitions['table'] . '.' . $db_field . ' ' . $definitions['operator'] . ' "%' . $this->_post[$definitions['alias']] . '%" ';
} elseif ($definitions['operator'] != "LIKE" && strlen($this->_post[$definitions['alias']]) > 0) {
$this->queryString .= ' ' . $definitions['clause'] . ' ' . $definitions['table'] . '.' . $db_field . ' ' . $definitions['operator'] . ' "' . trim($this->_post[$definitions['alias']]) . '" ';
}
$querySession = SessionController::getInstance();
$querySession->setSessionVar('adminQuery', $this->queryString);
$querySession->setSessionVar('tagQuery', $this->_post['name']);
}
开发者ID:ecuation,项目名称:Control-de-stock,代码行数:11,代码来源:Searcher.php
示例6: setWebmasterAutentication
public function setWebmasterAutentication()
{
if (isset($_POST['submit'])) {
if ($_POST['password'] == "esbien") {
$webmasterSession = SessionController::getInstance();
$webmasterSession->setSessionVar('webmaster', 1);
}
if (isset($_SESSION['webmaster'])) {
header('Location: index.php');
}
}
}
开发者ID:ecuation,项目名称:Control-de-stock,代码行数:12,代码来源:Webmaster_accessController.php
示例7: auth
public function auth()
{
if (isset($_COOKIE["masterpw"]) && $_COOKIE["masterpw"] == Config::MASTERPWD) {
SessionController::setAuth();
}
if (isset($_POST["password"]) && $_POST["password"] == Config::MASTERPWD) {
SessionController::setAuth();
setcookie("masterpw", $_POST["password"], time() + 86400 * 30);
} else {
SessionController::addMsg("access denied");
}
}
开发者ID:tseifert3Go,项目名称:AnimeVenus,代码行数:12,代码来源:AuthController.php
示例8: openShopSession
public function openShopSession()
{
if (isset($_POST['shop_action'])) {
$db = PDOQuery::getInstance();
$db->connect();
$sql = "INSERT INTO shop_session\n\t\t\t\t\t\t(id_user, id_shop, date, is_active)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t(?, ?, ?, 1)";
$res = $db->prepareQuery($sql);
$res->execute(array($_SESSION['id_employee'], $_SESSION['id_shop'], time()));
SessionController::getInstance()->setSessionVar('shop_session_id', $db->insert_id());
$db->close();
}
}
开发者ID:ecuation,项目名称:Control-de-stock,代码行数:12,代码来源:Shop.php
示例9: login
public function login( DatabaseConnection $connection ) {
if( null == $connection || null == $this->user ) {
echo "something null";
return;
}
if ( $this->user->login( $connection ) ) {
$this->session = SessionController::getInstance();
$this->session->setMessage( "Welcome back {$this->user->username}");
$this->session->setupAuthorizedSession( $this->user );
} else {
echo "not logged in";
print_r( $this->user);
}
}
开发者ID:nathanfl,项目名称:medtele,代码行数:14,代码来源:User.Controller.php
示例10: renderView
public function renderView($data = array())
{
$ds = DIRECTORY_SEPARATOR;
if (SessionController::getAuth() == NULL) {
self::partial("auth.php");
} elseif (isset($_GET["anime"]) && isset($_GET["episode"])) {
self::partial("video.php", $data["video"]);
} elseif (isset($_GET["download"])) {
self::partial("navbar.php", $data["navbar"]);
self::partial("download.php");
} else {
self::partial("navbar.php", $data["navbar"]);
self::partial("list.php", $data["list"]);
}
include_once '..' . $ds . 'protected' . $ds . 'view' . $ds . 'layout.php';
}
开发者ID:tseifert3Go,项目名称:AnimeVenus,代码行数:16,代码来源:IndexController.php
示例11: parseLogin
public static function parseLogin()
{
$email = $_POST['email'];
$senha = $_POST['senha'];
$temp = DBController::init();
$usuarios = $temp->db_user;
$all = iterator_to_array($usuarios->find(["email" => $email, "senha" => $senha]));
if ($all != array()) {
foreach ($all as $key => $value) {
$obj = array('token' => $key, 'nome' => $value['nome'], 'email' => $value['email'], 'senha' => $value['senha'], 'status' => true, 'message' => "Login feito com sucesso");
}
SessionController::set("user", $obj);
} else {
$obj = array('email' => $email, 'senha' => $senha, 'status' => false, 'message' => "Email ou senha incorretos", 'status' => false);
}
RotaController::res($obj);
}
开发者ID:adrielcardoso,项目名称:mongodb_teste,代码行数:17,代码来源:UserController.php
示例12: login
/**
* Logs in a user an returns the auth_token
*
* @param Users $user
* @return string auth_token
*/
public static function login(Users $user)
{
UserController::$sendEmailOnVerify = false;
// Deactivate cookie setting
$oldCookieSetting = SessionController::$setCookieOnRegisterSession;
SessionController::$setCookieOnRegisterSession = false;
// Inflate request with user data
$r = new Request(array("usernameOrEmail" => $user->getUsername(), "password" => $user->getPassword()));
// Call the API
$response = UserController::apiLogin($r);
// Sanity check
self::assertEquals("ok", $response["status"]);
// Clean up leftovers of Login API
unset($_REQUEST);
// Set cookie setting as it was before the login
SessionController::$setCookieOnRegisterSession = $oldCookieSetting;
return $response["auth_token"];
}
开发者ID:kukogit,项目名称:omegaup,代码行数:24,代码来源:OmegaupTestCase.php
示例13: Request
<?php
require_once '../../server/bootstrap.php';
$r = new Request($_REQUEST);
$session = SessionController::apiCurrentSession($r);
$r['statement_type'] = 'html';
$r['show_solvers'] = true;
try {
$result = ProblemController::apiDetails($r);
$problem = ProblemsDAO::GetByAlias($result['alias']);
} catch (ApiException $e) {
header('HTTP/1.1 404 Not Found');
die(file_get_contents('../404.html'));
}
$smarty->assign('problem_statement', $result['problem_statement']);
$smarty->assign('problem_statement_language', $result['problem_statement_language']);
$smarty->assign('problem_alias', $result['alias']);
$smarty->assign('public', $result['public']);
$smarty->assign('source', $result['source']);
$smarty->assign('title', $result['title']);
$smarty->assign('points', $result['points']);
$smarty->assign('validator', $result['validator']);
$smarty->assign('time_limit', $result['time_limit'] / 1000 . 's');
$smarty->assign('validator_time_limit', $result['validator_time_limit'] / 1000 . 's');
$smarty->assign('overall_wall_time_limit', $result['overall_wall_time_limit'] / 1000 . 's');
$smarty->assign('memory_limit', $result['memory_limit'] / 1024 . 'MB');
$smarty->assign('solvers', $result['solvers']);
$smarty->assign('karel_problem', count(array_intersect(explode(',', $result['languages']), array('kp', 'kj'))) == 2);
if (isset($result['sample_input'])) {
$smarty->assign('sample_input', $result['sample_input']);
}
开发者ID:kukogit,项目名称:omegaup,代码行数:31,代码来源:problem.php
示例14: logout
public function logout()
{
SessionController::delete("user_session");
}
开发者ID:herandil,项目名称:discountnow,代码行数:4,代码来源:UsersController.php
示例15:
<?php
require_once '../server/bootstrap.php';
UITools::redirectToLoginIfNotLoggedIn();
UITools::setProfile($smarty);
$ses = SessionController::apiCurrentSession();
if (isset($ses['needs_basic_info']) && $ses['needs_basic_info']) {
$smarty->display('../templates/user.basicedit.tpl');
} else {
$smarty->display('../templates/user.edit.tpl');
}
开发者ID:andreasantillana,项目名称:omegaup,代码行数:11,代码来源:profileedit.php
示例16: gtRequire
<?php
//only visitors who are not logged in are allowed to continue
if (SessionController::userIsLoggedIn()) {
gtRequire("scripts/redirect.php");
}
开发者ID:laiello,项目名称:gtlolwebsite,代码行数:6,代码来源:requireNoLogin.php
示例17: SessionController
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/casarover/application/common/common_tools.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/casarover/application/controllers/SessionController.php';
$location = $_GET['location'];
$sessionController = new SessionController();
$sessionController->destroyUser();
if ($location == 'backstage') {
header("Location:../../website/backstage/admin_login.php");
} else {
header("Location:../../website");
}
开发者ID:dreamingodd,项目名称:casarover,代码行数:12,代码来源:logout_action.php
示例18:
<div id="accountInfo">
<?php
if (SessionController::userIsLoggedIn()) {
$username = SessionController::getCurrentUsersUsername();
?>
<a href="/users/">
<?php
print $username;
?>
</a>|
<a href="/users/logout.php?returnURL=<?php
print $_SERVER['PHP_SELF'];
?>
">logout</a>
<?php
} else {
?>
<form id="login" name="login" action="/users/login.php?returnURL=<?php
print $_SERVER['PHP_SELF'];
?>
" method="post">
<a id="adminlink" href="#">Admin</a>
<input id="username" name="username" type="text" size="22" placeholder="Username" />
<input id="password" name="password" type="password" size="22" placeholder="Password" />
<input type="submit" id="btnLogin" name="btnLogin" value="Login" />
<input type="submit" formaction="/users/register.php" id="btnRegisterLink" name="btnRegisterLink" value="Register" />
</form>
<?php
}
?>
</div>
开发者ID:laiello,项目名称:gtlolwebsite,代码行数:31,代码来源:top.php
示例19: apiUpdate
/**
* Update user profile
*
* @param Request $r
* @return array
* @throws InvalidDatabaseOperationException
* @throws InvalidParameterException
*/
public static function apiUpdate(Request $r)
{
self::authenticateRequest($r);
Validators::isStringNonEmpty($r['name'], 'name', false);
Validators::isStringNonEmpty($r['country_id'], 'country_id', false);
if (!is_null($r['country_id'])) {
try {
$r['country'] = CountriesDAO::getByPK($r['country_id']);
} catch (Exception $e) {
throw new InvalidDatabaseOperationException($e);
}
}
if ($r['state_id'] === 'null') {
$r['state_id'] = null;
}
Validators::isNumber($r['state_id'], 'state_id', false);
if (!is_null($r['state_id'])) {
try {
$r['state'] = StatesDAO::getByPK($r['state_id']);
} catch (Exception $e) {
throw new InvalidDatabaseOperationException($e);
}
}
if (!is_null($r['school_id'])) {
if (is_numeric($r['school_id'])) {
try {
$r['school'] = SchoolsDAO::getByPK($r['school_id']);
} catch (Exception $e) {
throw new InvalidDatabaseOperationException($e);
}
if (is_null($r['school'])) {
throw new InvalidParameterException('parameterInvalid', 'school');
}
} elseif (empty($r['school_name'])) {
$r['school_id'] = null;
} else {
try {
$schoolR = new Request(array('name' => $r['school_name'], 'state_id' => $r['state_id'], 'auth_token' => $r['auth_token']));
$response = SchoolController::apiCreate($schoolR);
$r['school_id'] = $response['school_id'];
} catch (Exception $e) {
throw new InvalidDatabaseOperationException($e);
}
}
}
Validators::isStringNonEmpty($r['scholar_degree'], 'scholar_degree', false);
if (!is_null($r['graduation_date'])) {
if (is_numeric($r['graduation_date'])) {
$r['graduation_date'] = (int) $r['graduation_date'];
} else {
Validators::isDate($r['graduation_date'], 'graduation_date', false);
$r['graduation_date'] = strtotime($r['graduation_date']);
}
}
if (!is_null($r['birth_date'])) {
if (is_numeric($r['birth_date'])) {
$r['birth_date'] = (int) $r['birth_date'];
} else {
Validators::isDate($r['birth_date'], 'birth_date', false);
$r['birth_date'] = strtotime($r['birth_date']);
}
}
if (!is_null($r['locale'])) {
// find language in Language
$query = LanguagesDAO::search(new Languages(array('name' => $r['locale'])));
if (sizeof($query) == 1) {
$r['current_user']->setLanguageId($query[0]->getLanguageId());
}
}
$valueProperties = array('name', 'country_id', 'state_id', 'scholar_degree', 'school_id', 'graduation_date' => array('transform' => function ($value) {
return gmdate('Y-m-d', $value);
}), 'birth_date' => array('transform' => function ($value) {
return gmdate('Y-m-d', $value);
}));
self::updateValueProperties($r, $r['current_user'], $valueProperties);
try {
UsersDAO::save($r['current_user']);
} catch (Exception $e) {
throw new InvalidDatabaseOperationException($e);
}
// Expire profile cache
Cache::deleteFromCache(Cache::USER_PROFILE, $r['current_user']->getUsername());
$sessionController = new SessionController();
$sessionController->InvalidateCache();
return array('status' => 'ok');
}
开发者ID:RicardoMelgoza,项目名称:omegaup,代码行数:94,代码来源:UserController.php
示例20: RegisterSession
private function RegisterSession(Users $vo_User, $b_ReturnAuthTokenAsString = false)
{
// Log the login.
UserLoginLogDAO::save(new UserLoginLog(array('user_id' => $vo_User->user_id, 'ip' => ip2long($_SERVER['REMOTE_ADDR']))));
// Expire the local session cache.
self::$current_session = null;
//find if this user has older sessions
$vo_AuthT = new AuthTokens();
$vo_AuthT->setUserId($vo_User->getUserId());
//erase expired tokens
try {
$tokens_erased = AuthTokensDAO::expireAuthTokens($vo_User->getUserId());
} catch (Exception $e) {
// Best effort
self::$log->error("Failed to delete expired tokens: {$e->getMessage}()");
}
// Create the new token
$entropy = bin2hex(mcrypt_create_iv(SessionController::AUTH_TOKEN_ENTROPY_SIZE, MCRYPT_DEV_URANDOM));
$s_AuthT = $entropy . '-' . $vo_User->getUserId() . '-' . hash('sha256', OMEGAUP_MD5_SALT . $vo_User->getUserId() . $entropy);
$vo_AuthT = new AuthTokens();
$vo_AuthT->setUserId($vo_User->getUserId());
$vo_AuthT->setToken($s_AuthT);
try {
AuthTokensDAO::save($vo_AuthT);
} catch (Exception $e) {
throw new InvalidDatabaseOperationException($e);
}
if (self::$setCookieOnRegisterSession) {
$sm = $this->getSessionManagerInstance();
$sm->setCookie(OMEGAUP_AUTH_TOKEN_COOKIE_NAME, $s_AuthT, 0, '/');
}
Cache::deleteFromCache(Cache::SESSION_PREFIX, $s_AuthT);
if ($b_ReturnAuthTokenAsString) {
return $s_AuthT;
}
}
开发者ID:andreasantillana,项目名称:omegaup,代码行数:36,代码来源:SessionController.php
注:本文中的SessionController类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论