本文整理汇总了PHP中SessionManager类的典型用法代码示例。如果您正苦于以下问题:PHP SessionManager类的具体用法?PHP SessionManager怎么用?PHP SessionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SessionManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: startApp
public function startApp()
{
$rootLocation = "Location:http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$lv = new LayoutView();
$ud = new userDAL();
$sm = new SessionManager();
$lm = new LoginModel($ud, $sm);
if (!$lm->isUserLoggedIn()) {
if ($lv->userWantsToRegister()) {
$validate = new ValidateCredentials();
$v = new RegisterView($validate, $sm);
$c = new RegisterController($v, $ud, $sm);
$c->userPost();
if ($sm->SessionGetSuccessfulRegistration()) {
header($rootLocation);
}
} else {
$v = new LoginView($lm, $sm);
$c = new LoginController($v, $lm);
$c->userPost();
}
}
if ($lm->isUserLoggedIn()) {
$c = new GameController($lm, $ud, $sm, $lv);
$v = $c->startApp();
if ($c->userWantsToLogout()) {
header($rootLocation);
}
}
$lv->render($v, $lm->isUserLoggedIn());
}
示例2: __construct
/**
* Identical to the parent constructor, except that
* we start a PHP session to store the user ID and
* access token if during the course of execution
* we discover them.
*
* @param Array $config the application configuration.
* @see BaseMeli::__construct in Meli.php
*/
public function __construct($config, $sm = NULL)
{
if (is_null($sm)) {
$sm = new SessionManager();
}
$sm->start();
parent::__construct($config);
}
示例3: login
function login()
{
if (session_id() == '') {
session_start();
}
if (isset($_POST["mail"]) & isset($_POST["password"]) & isset($_POST["cre"])) {
if ($_POST["mail"] != "" and $_POST["password"] != "" and $_POST["cre"] != "") {
$mail = $_POST["mail"];
$password = $_POST["password"];
$role = $_POST["cre"];
require_once 'SessionManager.php';
$session_manager = new SessionManager();
require_once 'medoo.min.php';
$database = new medoo();
$count = $database->count("triotrack_users", ["email" => "{$mail}"]);
if ($count > 0) {
$profile = $database->get("triotrack_users", ["username", "password", "salt", "client"], ["email" => "{$mail}"]);
if ($role === "admin") {
if ($profile["password"] === sha1($password . $profile["salt"])) {
$username = $profile["username"];
$client = $profile["client"];
$cookie = array("email" => "{$mail}", "username" => "{$username}", "password" => "{$password}", "client" => "{$client}", "role" => "{$role}");
$encoded_cookie = $session_manager->encode_session(json_encode($cookie));
$_SESSION["user_id"] = $encoded_cookie;
setcookie("user_id", $encoded_cookie, time() + 86400 * 1, "/");
// 86400 = 1 day
echo "admin";
exit;
} else {
echo "failed";
exit;
}
} else {
if ($profile["client"] === $password) {
$username = $profile["username"];
$client = $profile["client"];
$cookie = array("email" => "{$mail}", "username" => "{$username}", "password" => "{$password}", "client" => "{$client}", "role" => "{$role}");
$encoded_cookie = $session_manager->encode_session(json_encode($cookie));
$_SESSION["user_id"] = $encoded_cookie;
setcookie("user_id", $encoded_cookie, time() + 86400 * 1, "/");
// 86400 = 1 day
echo "client";
exit;
} else {
echo "failed";
exit;
}
}
}
} else {
echo "failed";
}
exit;
}
}
示例4: vtws_logout
function vtws_logout($sessionId, $user)
{
$sessionManager = new SessionManager();
$sid = $sessionManager->startSession($sessionId);
if (!isset($sessionId) || !$sessionManager->isValid()) {
return $sessionManager->getError();
}
$sessionManager->destroy();
// $sessionManager->setExpire(1);
return array("message" => "successfull");
}
示例5: showConnectedProfiles
private function showConnectedProfiles()
{
$output = '<div class="clearfix networks">';
$facebookLoginUrl = SessionManager::getInstance()->getFacebook()->getLoginUrl(array('redirect_uri' => APP_URL . '/' . Content::l() . '/login/facebookcallback/' . Content::l() . '/settings/', 'scope' => 'publish_stream'));
$linkedInLoginUrl = APP_URL . '/' . Content::l() . '/login/linkedin/' . Content::l() . '/settings/';
$twitterLoginUrl = APP_URL . '/' . Content::l() . '/login/twitter/' . Content::l() . '/settings/';
// Facebook
$output .= '<div class="clearfix">';
if ($this->userDetails['facebook_access_token']) {
$output .= '<a href="' . $facebookLoginUrl . '" id="loginFacebook" class="ir loggedIn">Facebook</a>' . '<a href="/' . Content::l() . '/ajax/disconnect/?network=Facebook" class="disconnect">' . str_replace('SOCIAL_NETWORK_NAME', 'Facebook', Content::c()->settings->disconnect) . '</a>';
} else {
$output .= '<a href="' . $facebookLoginUrl . '" id="loginFacebook" class="ir">Facebook</a>' . '<a href="' . $facebookLoginUrl . '" class="connect">' . str_replace('SOCIAL_NETWORK_NAME', 'Facebook', Content::c()->settings->connect) . '</a>';
}
// LinkedIn
$output .= '</div><div class="clearfix">';
if ($this->userDetails['linkedin_access_token']) {
$output .= '<a href="' . $linkedInLoginUrl . '" id="loginLinkedIn" class="ir loggedIn">LinkedIn</a>' . '<a href="/' . Content::l() . '/ajax/disconnect/?network=LinkedIn" class="disconnect">' . str_replace('SOCIAL_NETWORK_NAME', 'LinkedIn', Content::c()->settings->disconnect) . '</a>';
} else {
$output .= '<a href="' . $linkedInLoginUrl . '" id="loginLinkedIn" class="ir">LinkedIn</a>' . '<a href="' . $linkedInLoginUrl . '" class="connect">' . str_replace('SOCIAL_NETWORK_NAME', 'LinkedIn', Content::c()->settings->connect) . '</a>';
}
// Twitter
$output .= '</div><div class="clearfix">';
if ($this->userDetails['twitter_access_token']) {
$output .= '<a href="' . $twitterLoginUrl . '" id="loginTwitter" class="ir loggedIn">Twitter</a>' . '<a href="/' . Content::l() . '/ajax/disconnect/?network=Twitter" class="disconnect">' . str_replace('SOCIAL_NETWORK_NAME', 'Twitter', Content::c()->settings->disconnect) . '</a>';
} else {
$output .= '<a href="' . $twitterLoginUrl . '" id="loginTwitter" class="ir">Twitter</a>' . '<a href="' . $twitterLoginUrl . '" class="connect">' . str_replace('SOCIAL_NETWORK_NAME', 'Twitter', Content::c()->settings->connect) . '</a>';
}
$output .= '</div></div>';
return $output;
}
示例6: __construct
public function __construct()
{
if (SessionManager::getInstance()->isAdmin()) {
$aid = SessionManager::getInstance()->getAdminID();
$admin = DBManager::getInstance()->getAdmin($aid);
$this->isGlobalAdmin = $admin['isGlobalAdmin'];
$this->adminGroups = DBManager::getInstance()->getAdminGroupsByAdminID($aid);
$this->servers = DBManager::getInstance()->getAdminGroupServersByAdminId($aid);
$this->perms = array();
foreach ($this->adminGroups as $group) {
foreach ($group['adminOnServers'] as $serverId) {
foreach ($group['perms'] as $perm => $value) {
if ($perm != 'serverID' && $perm != 'groupID') {
if (!isset($this->perms[$serverId])) {
$this->perms[$serverId] = array();
}
$this->perms[$serverId][$perm] = $value;
}
}
}
}
} else {
$this->isGlobalAdmin = false;
$this->perms = DBManager::$defaultAdminGroupPerms;
$this->servers = array();
}
}
示例7: getInstance
public static function getInstance()
{
if (is_null(self::$_sessionManager)) {
self::$_sessionManager = new SessionManager();
}
return self::$_sessionManager;
}
示例8: __construct
public function __construct()
{
session_start();
header('Content-type: text/json');
// Get the website user
$userId = SessionManager::getInstance()->getUserId();
// Make sure a user is logged in
if (empty($userId)) {
Debug::l('No user logged in');
$json['result'] = 'false';
echo json_encode($json);
exit;
}
// Validate input
if (empty($_POST['email']) || !filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL)) {
Debug::l('Invalid email');
$json['result'] = 'false';
echo json_encode($json);
exit;
}
// Update email address
$db = Database::getInstance();
$sth = $db->prepare('UPDATE person SET email = :email WHERE id = :id');
$sth->execute(array(':email' => $_POST['email'], ':id' => $userId));
$json['result'] = 'true';
echo json_encode($json);
}
示例9: __construct
/**
* Constructor of the Class
*
* @author Jonathan Sandoval <jonathan_s_pisis@yahoo.com.mx>
* @param integer $idUser idUser
* @param integer $idChurch idChurch
* @param boolean $full full document
*/
function __construct($idUser = 0, $idChurch = 0)
{
//Define the constructor
parent::FPDF('L', 'mm', 'Letter');
$this->church = ChurchManager::getSingleChurch('id', $idChurch);
$this->user = SessionManager::getSingleUser('id', $idUser);
}
示例10: handleRequest
/**
* Handle a new request.
*/
function handleRequest()
{
if (!Config::getVar('general', 'installed') && pageRequiresInstall()) {
// Redirect to installer if application has not been installed
Request::redirect(null, 'install');
}
// Determine the handler for this request
$page = Request::getRequestedPage();
$op = Request::getRequestedOp();
$sourceFile = sprintf('pages/%s/index.php', $page);
// If a hook has been registered to handle this page, give it the
// opportunity to load required resources and set HANDLER_CLASS.
if (!HookRegistry::call('LoadHandler', array(&$page, &$op, &$sourceFile))) {
if (file_exists($sourceFile)) {
require $sourceFile;
} else {
require 'pages/index/index.php';
}
}
if (!defined('SESSION_DISABLE_INIT')) {
// Initialize session
$sessionManager =& SessionManager::getManager();
$session =& $sessionManager->getUserSession();
}
$methods = array_map('strtolower', get_class_methods(HANDLER_CLASS));
if (in_array(strtolower($op), $methods)) {
// Call a specific operation
call_user_func(array(HANDLER_CLASS, $op), Request::getRequestedArgs());
} else {
// Call the selected handler's index operation
call_user_func(array(HANDLER_CLASS, 'index'), Request::getRequestedArgs());
}
}
示例11: Init
public static function Init($params)
{
DebugManager::Log("Got a logout request!", '@');
$account = AccountController::Create($params);
SessionManager::Create($account);
return new ResponseObject();
}
示例12: Init
/**
* Initialize Page Manager
*
* ## Overview
*
* @uses SatanBarbaraApp
* @uses SessionManager
* @uses ViewManager
* @uses DebugManager
* @uses RouteManager
* @uses PageView
*
* @see RouteManager
*
* @param array An array of creds for SendGrid API.
* @return true Always unless fatal error or exception is thrown.
*
* @version 2015-07-05.1
* @since 0.5.1b
* @author TronNet DevOps [Sean Murray] <smurray@tronnet.me>
*/
public static function Init($params)
{
DebugManager::Log("Initializing Page Manager", '@');
DebugManager::Log($params);
$appConfig = SatanBarbaraApp::GetConfig();
/**
* @todo have config in it's own 'config' position instead of array_merge
*/
$data = array('app' => array_merge($appConfig[SATANBARBARA_CURRENT_ENVIRONMENT], array()), 'page' => $params);
DebugManager::Log("checking if logged in...", null, 3);
if (SessionManager::IsLoggedIn()) {
$data['session'] = array('is_auth' => true, 'account' => SessionManager::GetAccount());
DebugManager::Log("Got an account, checking for a saved program...", null, 3);
}
$Page = ucfirst($params['page']) . 'View';
DebugManager::Log("Searching for view with class name: " . $Page);
if ($Page::HasAccess(SessionManager::GetAccessLevel())) {
$Page::Init($data);
ViewManager::Render($Page);
} else {
DebugManager::Log("looks like this page requires auth but user isn't authenticated!");
RouteManager::GoToPageURI('login');
}
return true;
}
示例13: elseif
/**
* Loads the current locale. It works so that it tries to fetch the parameter "lang" from the
* request. If it's not available, then it will try to look for it in the session. If it is not
* there either, it will try to guess the most prefered language according to what the User Agent
* included in the HTTP_ACCEPT_LANGUAGE string sent with the request. If none matches available
* languages we have to use the value of "default_locale" and display the default language.
*
* @private
* @return Returns a reference to a Locale object
*/
function &_loadLocale()
{
$requestLocale =& $this->_request->getValue("lang");
$localeCode = "";
$serverVars =& HttpVars::getServer();
// check if there's something in the request...
// if not, check the session or at least try to
// guess the apropriate languege from the http_accept_lnaguage string
if ($requestLocale) {
// check if it's a valid one
if (Locales::isValidLocale($requestLocale)) {
$localeCode = $requestLocale;
}
} else {
$sessionLocale =& SessionManager::getSessionValue("summaryLang");
if ($sessionLocale) {
$localeCode = $sessionLocale;
} elseif ($this->_config->getValue("use_http_accept_language_detection", HTTP_ACCEPT_LANGUAGE_DETECTION) == 1) {
$localeCode =& $this->_matchHttpAcceptLanguages($serverVars['HTTP_ACCEPT_LANGUAGE']);
}
}
// check if the locale code is correct
// and as a valid resort, use the default one if the locale ist not valid or 'false'
if ($localeCode === false || !Locales::isValidLocale($localeCode)) {
$localeCode = $this->_config->getValue("default_locale");
}
// now put whatever locale value back to the session
SessionManager::setSessionValue("summaryLang", $localeCode);
// load the correct locale
$locale =& Locales::getLocale($localeCode);
return $locale;
}
示例14: singleton
/**
* singleton function to return
* the instance of the class
*
* @return SessionManager
*/
public static function singleton($args = NULL)
{
if (!self::$instance) {
self::$instance = new SessionManager($args);
}
return self::$instance;
}
示例15: __construct
function __construct()
{
if (SessionManager::isAuthorized()) {
header('Location:/main');
die;
}
}