コード例 #1
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new SessionController();
     }
     return self::$instance;
 }
コード例 #2
0
 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
0
 /**
  * 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
0
ファイル: Users.php プロジェクト: herandil/discountnow
 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
0
 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
0
 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
0
 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
0
ファイル: Shop.php プロジェクト: ecuation/Control-de-stock
 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
0
ファイル: User.Controller.php プロジェクト: nathanfl/medtele
	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
0
 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
0
 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
0
ファイル: OmegaupTestCase.php プロジェクト: kukogit/omegaup
 /**
  * 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
0
ファイル: problem.php プロジェクト: kukogit/omegaup
<?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
0
 public function logout()
 {
     SessionController::delete("user_session");
 }
コード例 #15
0
<?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');
}
コード例 #16
0
<?php

//only visitors who are not logged in are allowed to continue
if (SessionController::userIsLoggedIn()) {
    gtRequire("scripts/redirect.php");
}
コード例 #17
0
<?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");
}
コード例 #18
0
ファイル: top.php プロジェクト: laiello/gtlolwebsite
<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>
コード例 #19
0
 /**
  * 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');
 }
コード例 #20
0
 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;
     }
 }
コード例 #21
0
 /**
  * Parses the URI from $_SERVER and determines which controller and
  * function to call.
  *
  * @return Request
  * @throws NotFoundException
  */
 private static function parseUrl()
 {
     $apiAsUrl = $_SERVER['REQUEST_URI'];
     // Spliting only by '/' results in URIs with parameters like this:
     //		/api/problem/list/?page=1
     //						 ^^
     // Adding '?' as a separator results in URIs like this:
     //		/api/problem/list?page=1
     //						 ^
     $args = preg_split('/[\\/?]/', $apiAsUrl);
     if ($args === false || count($args) < 2) {
         self::$log->error('Api called with URI with less args than expected: ' . count($args));
         throw new NotFoundException('apiNotFound');
     }
     $controllerName = ucfirst($args[2]);
     // Removing NULL bytes
     $controllerName = str_replace(chr(0), '', $controllerName);
     $methodName = str_replace(chr(0), '', $args[3]);
     $controllerName = $controllerName . 'Controller';
     if (!class_exists($controllerName)) {
         self::$log->error('Controller name was not found: ' . $controllerName);
         throw new NotFoundException('apiNotFound');
     }
     // Create request
     $request = new Request($_REQUEST);
     // Prepend api
     $methodName = 'api' . $methodName;
     // Check the method
     if (!method_exists($controllerName, $methodName)) {
         self::$log->error('Method name was not found: ' . $controllerName . '::' . $methodName);
         throw new NotFoundException('apiNotFound');
     }
     // Get the auth_token and user data from cookies
     $cs = SessionController::apiCurrentSession();
     // If we got an auth_token from cookies, replace it
     if (!is_null($cs['auth_token'])) {
         $request['auth_token'] = $cs['auth_token'];
     }
     for ($i = 4; $i + 1 < sizeof($args); $i += 2) {
         $request[$args[$i]] = urldecode($args[$i + 1]);
     }
     $request->method = $controllerName . '::' . $methodName;
     return $request;
 }
コード例 #22
0
<?php

set_include_path($_SERVER["DOCUMENT_ROOT"] . "/shalomshanti/");
if (!isset($session)) {
    require_once "Controller/SessionController.php";
    $session = SessionController::getSession();
}
class RSVPArticle
{
    public static function createRSVPArticle($event_name)
    {
        global $session;
        $dom = new DOMDocument('1.0', 'utf-8');
        $dom->appendChild(self::createTitle($dom, $event_name));
        $dom->appendChild(self::createNumbers($dom, $event_name));
        $dom->appendChild(self::createAttendantInputs($dom, $event_name));
        if ($session->user->rsvp->numberInvitedTo($event_name) > $session->user->rsvp->numberOfAttendantsAt($event_name)) {
            $dom->appendChild(self::createAddButton($dom));
        }
        return $dom->saveHTML();
    }
    private static function createTitle($dom, $event_name)
    {
        $title = $dom->createElement('h2');
        $title->setAttribute('class', 'typ-title');
        // TODO: Automate this
        if ($event_name === "havdalah") {
            $mehendi = $dom->createElement("span");
            $mehendi->appendChild($dom->createTextNode("Mehendi"));
            $ampersand = $dom->createElement("span");
            $ampersand->appendChild($dom->createTextNode("&"));
コード例 #23
0
ファイル: login.php プロジェクト: kukogit/omegaup
<?php

require_once "../server/bootstrap.php";
require_once "api/ApiCaller.php";
$triedToLogin = false;
$emailVerified = true;
$c_Session = new SessionController();
if (isset($_POST["request"]) && $_POST["request"] == "login") {
    // user wants to login natively
    $r = new Request();
    $r["usernameOrEmail"] = $_POST["user"];
    $r["password"] = $_POST["pass"];
    $r->method = "UserController::apiLogin";
    $response = ApiCaller::call($r);
    if ($response["status"] === "error") {
        if ($response["errorcode"] === 600 || $response["errorcode"] === 601) {
            $emailVerified = false;
        }
    }
    $triedToLogin = true;
}
if (isset($_GET["state"])) {
    $c_Session->LoginViaFacebook();
    $triedToLogin = true;
}
if (isset($_GET["shva"])) {
    $triedToLogin = true;
}
if ($c_Session->CurrentSessionAvailable()) {
    if (isset($_GET['redirect'])) {
        die(header('Location: ' . $_GET['redirect']));
コード例 #24
0
include_once 'SessionController.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/casarover/application/common/common_tools.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/casarover/application/services/ThemeService.php';
/**
 * 
 * @author Ye_WD
 * @2016-1-27
 */
$action = $_GET['action'];
$service = new ThemeService();
$id = $_GET['id'];
if (!$id) {
    $id = $_POST['id'];
}
if ($action == 'edit') {
    $sc = new SessionController();
    $theme_items = array();
    $area_ids = array();
    $service->addOrUpdate($_POST['name'], $_POST['description'], $_POST['filepath'], $sc->getUsername(), $theme_items, $area_ids, $id);
    header("Location:../../website/backstage/success.php?info=添加或更新主题成功!&type=theme");
} else {
    if ($action == 'recycle') {
        $service->recycleTheme($id);
        header("Location:../../website/backstage/theme_list.php");
    } else {
        if ($action == 'recover') {
            $service->recoverTheme($id);
            header("Location:../../website/backstage/theme_list.php?deleted=1");
        }
    }
}
コード例 #25
0
ファイル: bootstrap.php プロジェクト: heduenas/omegaup
 $smarty->assign("CURRENT_USER_IS_ADMIN", 0);
 if (defined("SMARTY_CACHE_DIR")) {
     $smarty->setCacheDir(SMARTY_CACHE_DIR)->setCompileDir(SMARTY_CACHE_DIR);
 }
 $smarty->assign("GOOGLECLIENTID", OMEGAUP_GOOGLE_CLIENTID);
 $smarty->assign("LOGGED_IN", "0");
 UITools::$IsLoggedIn = false;
 $smarty->assign("FB_URL", SessionController::getFacebookLoginUrl());
 if (defined("OMEGAUP_GA_TRACK") && OMEGAUP_GA_TRACK) {
     $smarty->assign("OMEGAUP_GA_TRACK", 1);
     $smarty->assign("OMEGAUP_GA_ID", OMEGAUP_GA_ID);
 } else {
     $smarty->assign("OMEGAUP_GA_TRACK", 0);
 }
 $userRequest = new Request($_REQUEST);
 $session = SessionController::apiCurrentSession($userRequest);
 if ($session['valid']) {
     $smarty->assign("LOGGED_IN", "1");
     UITools::$IsLoggedIn = true;
     $smarty->assign("CURRENT_USER_USERNAME", $session["username"]);
     $smarty->assign("CURRENT_USER_EMAIL", $session["email"]);
     $smarty->assign("CURRENT_USER_IS_EMAIL_VERIFIED", $session["is_email_verified"]);
     $smarty->assign("CURRENT_USER_IS_ADMIN", $session["is_admin"]);
     $smarty->assign("CURRENT_USER_PRIVATE_CONTESTS_COUNT", $session["private_contests_count"]);
     $smarty->assign("CURRENT_USER_PRIVATE_PROBLEMS_COUNT", $session["private_problems_count"]);
     $smarty->assign("CURRENT_USER_AUTH_TOKEN", $session["auth_token"]);
     $smarty->assign("CURRENT_USER_GRAVATAR_URL_128", '<img src="https://secure.gravatar.com/avatar/' . md5($session["email"]) . '?s=92">');
     $smarty->assign("CURRENT_USER_GRAVATAR_URL_16", '<img src="https://secure.gravatar.com/avatar/' . md5($session["email"]) . '?s=16">');
     $smarty->assign("CURRENT_USER_GRAVATAR_URL_32", '<img src="https://secure.gravatar.com/avatar/' . md5($session["email"]) . '?s=32">');
     UITools::$isAdmin = $session["is_admin"];
     $userRequest["username"] = $session["username"];
コード例 #26
0
 public static function apiArbitrateRequest(Request $r)
 {
     $result = array("status" => "ok");
     if (is_null($r["resolution"])) {
         throw new InvalidParameterException("invalidParameters");
     }
     // user must be admin of contest to arbitrate security
     $current_ses = SessionController::getCurrentSession($r);
     try {
         $r["contest"] = ContestsDAO::getByAlias($r["contest_alias"]);
     } catch (Exception $e) {
         throw new NotFoundException($e);
     }
     if (is_null($r["contest"])) {
         throw new NotFoundException("contestNotFound");
     }
     $r["target_user"] = UsersDAO::FindByUsername($r["username"]);
     $request = ContestUserRequestDAO::getByPK($r["target_user"]->user_id, $r["contest"]->contest_id);
     if (is_null($request)) {
         throw new InvalidParameterException("userNotInListOfRequests");
     }
     if ($r["resolution"] === "false") {
         // "false" casts to true.
         $resolution = false;
     } else {
         $resolution = (bool) $r["resolution"];
     }
     $request->setAccepted($resolution);
     $request->setExtraNote($r["note"]);
     $request->setLastUpdate(gmdate('Y-m-d H:i:s'));
     ContestUserRequestDAO::save($request);
     // Save this action in the history
     $history = new ContestUserRequestHistory();
     $history->user_id = $request->user_id;
     $history->contest_id = $request->user_id;
     $history->time = $request->last_update;
     $history->admin_id = $current_ses["id"];
     $history->accepted = $request->accepted;
     ContestUserRequestHistoryDAO::save($history);
     self::$log->info("Arbitrated contest for user, new accepted user_id=" . $r["target_user"]->user_id . ", state=" . $resolution);
     return $result;
 }
コード例 #27
0
<?php

include_once 'SessionController.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/casarover/application/common/common_tools.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/casarover/application/models/UserDao.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/casarover/application/vo/UserInSession.php';
$phone = $_POST['cellphone_number'];
$pwd = $_POST['password'];
$base_url = getBaseUrl();
$userDao = new UserDao();
$sessionController = new SessionController();
$user_row = $userDao->getByPhone($phone);
if (empty($user_row)) {
    // phone number doesn't exist.
    error('此手机号没有注册过!');
} else {
    if ($user_row['pwd'] != md5($pwd)) {
        // incorrect password
        error('用户名或密码错误!');
    } else {
        // login successfully
        // tip: "double quetos" is a necessity for json format, json数据必须使用双引号
        $userInSession = new UserInSession($user_row['id'], $user_row['name'], UserDao::TYPE_PHONE, null, null);
        $sessionController->addUserJson(json_encode($userInSession));
        echo "{\"msg\":\"success\"}";
    }
}
function error($info)
{
    echo $info;
}
コード例 #28
0
 public static function resetSession()
 {
     self::startSessionIfNecessary();
     self::$singleton = new SessionController();
     return self::$singleton;
 }
コード例 #29
0
ファイル: routes.php プロジェクト: tuureilmarinen/tsoha
    TaskController::edit($id);
});
$routes->get('/task/:id/markasdone', function ($id) {
    TaskController::markasdone($id);
});
$routes->get('/task/:id/markasundone', function ($id) {
    TaskController::markasundone($id);
});
$routes->post('/login', function () {
    SessionController::store();
});
$routes->get('/login', function () {
    SessionController::create();
});
$routes->get('/logout', function () {
    SessionController::destroy();
});
$routes->get('/signup', function () {
    UserController::create();
});
$routes->post('/signup', function () {
    UserController::store();
});
$routes->get('/user', function () {
    UserController::index();
});
$routes->get('/user/:id', function ($id) {
    UserController::show($id);
});
$routes->post('/user/:id', function ($id) {
    UserController::update($id);
コード例 #30
0
<?php

session_start();
require_once dirname(__FILE__) . '/settings.inc.php';
require_once dirname(__FILE__) . '/functions.php';
require_once dirname(__FILE__) . '/defines.inc.php';
require_once dirname(__FILE__) . '/defines.uri.inc.php';
require_once dirname(__FILE__) . '/smarty.config.inc.php';
require_once _CONFIG_DIR_ . 'autoload.php';
/* Get Context */
$context = Context::getContext();
/* instantiate language class */
$context->languageList = array(1 => 'en', 2 => 'es', 3 => 'de', 4 => 'nl');
$context->language = new MultiLanguageClass($context->languageList);
define(_ID_LANG_, $context->language->getLanguageId());
//contains session object
$context->session = SessionController::getInstance();
/* Get Smarty */
$context->smarty = $smarty;