本文整理汇总了PHP中SessionController类的典型用法代码示例。如果您正苦于以下问题:PHP SessionController类的具体用法?PHP SessionController怎么用?PHP SessionController使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SessionController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new SessionController();
}
return self::$instance;
}
示例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'));
}
示例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;
}
示例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;
}
示例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']);
}
示例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');
}
}
}
示例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");
}
}
示例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();
}
}
示例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);
}
}
示例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';
}
示例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);
}
示例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"];
}
示例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']);
}
示例14: logout
public function logout()
{
SessionController::delete("user_session");
}
示例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');
}