本文整理汇总了PHP中Session::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::instance方法的具体用法?PHP Session::instance怎么用?PHP Session::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade
public function upgrade()
{
if (php_sapi_name() == "cli") {
// @todo this may screw up some module installers, but we don't have a better answer at
// this time.
$_SERVER["HTTP_HOST"] = "example.com";
} else {
if (!user::active()->admin && !Session::instance()->get("can_upgrade", false)) {
access::forbidden();
}
}
// Upgrade gallery and user first
module::install("gallery");
module::install("user");
// Then upgrade the rest
foreach (module::available() as $id => $module) {
if ($id == "gallery") {
continue;
}
if ($module->active && $module->code_version != $module->version) {
module::install($id);
}
}
if (php_sapi_name() == "cli") {
print "Upgrade complete\n";
} else {
url::redirect("upgrader?done=1");
}
}
示例2: __construct
public function __construct()
{
parent::__construct('taxon_group');
$this->columns = array('title' => '');
$this->pagetitle = "Taxon Groups";
$this->session = Session::instance();
}
示例3: load
public static function load()
{
if (empty(self::$instance)) {
self::$instance = new Session();
}
return self::$instance;
}
示例4: __construct
/**
* Loads Session and configuration options.
*
* @return void
*/
public function __construct($config = array())
{
// Load Session
$this->session = Session::instance();
// Append default auth configuration
$config += Eight::config('auth');
// Save the config in the object
$this->config = $config;
// Init Bcrypt if we're using it
if ($this->config['hash_method'] == 'bcrypt') {
$this->bcrypt = new Bcrypt(12);
}
// Set the driver class name
$driver = 'Auth_Driver_' . $config['driver'];
if (!Eight::auto_load($driver)) {
throw new Eight_Exception('core.driver_not_found', $config['driver'], get_class($this));
}
// Load the driver
$driver = new $driver($config);
if (!$driver instanceof Auth_Driver) {
throw new Eight_Exception('core.driver_implements', $config['driver'], get_class($this), 'Auth_Driver');
}
// Load the driver for access
$this->driver = $driver;
Eight::log('debug', 'Auth Library loaded');
}
示例5: test_csrf_token
/**
* Tests Security::token()
*
* @test
* @dataProvider provider_csrf_token
* @covers Security::token
*/
public function test_csrf_token($expected, $input, $iteration)
{
Security::$token_name = 'token_' . $iteration;
$this->assertSame(TRUE, $input);
$this->assertSame($expected, Security::token(FALSE));
Session::instance()->delete(Security::$token_name);
}
示例6: tearDown
public function tearDown()
{
$this->clear_tables();
Session::instance()->destroy();
Session::instance()->create();
parent::tearDown();
}
示例7: getInstance
/**
* Returns an instance of Session object
* @return Session
*/
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = new self();
}
return self::$instance;
}
示例8: verify
/**
* Verify the login result and do whatever is needed to access the user data from this provider.
* @return bool
*/
public function verify()
{
// create token
$request_token = OAuth_Token::factory('request', array('token' => Session::instance()->get('oauth_token'), 'secret' => Session::instance()->get('oauth_token_secret')));
// Store the verifier in the token
$verifier = Arr::get($_REQUEST, 'oauth_verifier');
if (empty($verifier)) {
return false;
}
$request_token->verifier($verifier);
// Exchange the request token for an access token
$access_token = $this->provider->access_token($this->consumer, $request_token);
if ($access_token and $access_token->name === 'access') {
$request = OAuth_Request::factory('resource', 'GET', 'https://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline,email-address)?format=json', array('oauth_consumer_key' => $this->consumer->key, 'oauth_signature_method' => "HMAC-SHA1", 'oauth_token' => $access_token->token));
// Sign the request using only the consumer, no token is available yet
$request->sign(new OAuth_Signature_HMAC_SHA1(), $this->consumer, $access_token);
// decode and store data
$data = json_decode($request->execute(), true);
$this->uid = $data['id'];
$this->data = $data;
return true;
} else {
return false;
}
}
示例9: action_index
/**
* @return void
*/
public function action_index()
{
$this->template->content->active = "options";
$session = Session::instance();
// Check for post
if ($this->request->method() === "POST") {
$bucket_name = trim($this->request->post('bucket_name'));
// Check for updates to the bucket name
if (Valid::not_empty($bucket_name) and strcmp($bucket_name, $this->bucket['name']) !== 0) {
$bucket_id = $this->bucket['id'];
$parameters = array('name' => $bucket_name, 'public' => (bool) $this->request->post('bucket_publish'));
//
if (($bucket = $this->bucket_service->modify_bucket($bucket_id, $parameters, $this->user)) != FALSE) {
$session->set('message', __("Bucket settings successfully saved"));
// Reload the settings page using the updated bucket name
$this->redirect($bucket['url'] . '/settings', 302);
} else {
$session->set('error', __("The bucket settings could not be updated"));
}
}
}
// Set the messages and/or error messages
$this->template->content->set('message', $session->get('message'))->set('error', $session->get('error'));
$this->settings_content = View::factory('pages/bucket/settings/display')->bind('bucket', $this->bucket)->bind('collaborators_view', $collaborators_view);
// Collaboraotors view
$collaborators_view = View::factory('/template/collaborators')->bind('fetch_url', $fetch_url)->bind('collaborator_list', $collaborators);
$fetch_url = $this->bucket_base_url . '/collaborators';
$collaborators = json_encode($this->bucket_service->get_collaborators($this->bucket['id']));
$session->delete('message');
$session->delete('error');
}
示例10: action_index
public function action_index()
{
$auth = Auth::instance();
//si el usuario esta logeado entocnes mostramos el menu
if ($auth->logged_in()) {
//View::set_global('pass', $auth->hash_password('admin'));
$user = ORM::factory('users')->where('id', '=', $auth->get_user())->find();
$session = Session::instance();
$session->set('nombreUsuario', $user->nombre);
} else {
$this->request->redirect(URL::base() . 'login');
if (isset($_POST['submit'])) {
$validate = Validation::factory($this->request->post());
$validate->rule('usuario', 'not_empty')->rule('password', 'not_empty');
if ($validate->check()) {
$user = $auth->login(Arr::get($_POST, 'usuario'), Arr::get($_POST, 'password'));
if ($user) {
$this->request->redirect('index');
} else {
Request::current()->redirect('login');
}
}
}
$this->template->title = 'Login';
//$this->template->header = View::factory ('templates/menu');
$this->template->content = View::factory('admin/login');
}
}
示例11: instance
/**
* Возвращает объект для взаимодействия с сессией.
*/
public static function instance()
{
if (null === self::$instance) {
self::$instance = new Session();
}
return self::$instance;
}
示例12: before
/**
* The before() method is called before your controller action.
* In our template controller we override this method so that we can
* set up default values. These variables are then available to our
* controllers if they need to be modified.
*/
public function before()
{
//Run any before if needed
parent::before();
//Open session
$this->session = Session::instance();
//Check user auth and role
$action_name = Request::instance()->action;
if (is_array($this->secure_actions) && array_key_exists($action_name, $this->secure_actions) && Auth::instance()->logged_in($this->secure_actions[$action_name]) === FALSE) {
if (Auth::instance()->logged_in()) {
Request::instance()->redirect('admin/site/noaccess');
} else {
Request::instance()->redirect('admin/site/signin');
}
}
if ($this->auto_render) {
// Initialize empty values
$this->template->title = '';
$this->template->meta_keywords = '';
$this->template->meta_description = '';
$this->template->meta_copywrite = '';
$this->template->header = '';
$this->template->content = '';
$this->template->footer = '';
$this->template->styles = array();
$this->template->scripts = array();
$this->template->section_title = ' ';
}
}
示例13: action_index
public function action_index()
{
$message = false;
$user = false;
if (Arr::get($_POST, 'hidden') == 'form_sent') {
if (Auth::instance()->login(Arr::get($_POST, 'username'), Arr::get($_POST, 'password'), Arr::get($_POST, 'remember'))) {
$user = Auth::instance()->get_user();
Session::instance()->set('username', $user->name . ' ' . $user->surname)->set('language', $user->language)->set('listsize', $user->listsize);
}
}
if (Auth::instance()->logged_in()) {
$user = Auth::instance()->get_user();
Session::instance()->set('username', $user->name . ' ' . $user->surname)->set('language', $user->language)->set('listsize', $user->listsize);
try {
$server_config = $user->object->as_array();
$fb_config = array('type' => 'pdo', 'connection' => array('dsn' => 'firebird:dbname=' . $server_config['config_server'] . ':' . $server_config['config_bdfile'], 'username' => $server_config['config_bduser'], 'password' => $server_config['config_bdpass']));
Session::instance()->set('fb_config', $fb_config);
$fb = Database::instance('fb', $fb_config);
//$fb->connect();
$this->request->redirect('/admin/');
} catch (Database_Exception $e) {
$message = __('error.connection_db');
Auth::instance()->logout();
}
}
$this->request->response = View::factory('login', array('message' => $message));
}
示例14: __construct
/**
* Template loading and setup routine.
*/
public function __construct()
{
parent::__construct();
// checke request is ajax
$this->ajax_request = request::is_ajax();
// Load the template
$this->template = new View($this->template);
if ($this->auto_render == TRUE) {
Event::add('system.post_controller', array($this, '_render'));
}
/**
* 判断用户登录情况
*/
if (isset($_REQUEST['session_id'])) {
$session = Session::instance($_REQUEST['session_id']);
$manager = role::get_manager($_REQUEST['session_id']);
} else {
$session = Session::instance();
$manager = role::get_manager();
}
/* 当前请求的URL */
$current_url = urlencode(url::current(TRUE));
//当前用户管理的站点的ID
$this->site_id = site::id();
}
示例15: instance
public function instance()
{
if (!isset(self::$instance)) {
self::$instance = new Session();
}
return self::$instance;
}