The Session layer of Lithium inherits from the common Adaptable class, which provides the generic configuration setting & retrieval logic, as well as the logic required to locate & instantiate the proper adapter class. In most cases, you will configure various named session configurations in your bootstrap process, which will then be available to you in all other parts of your application. Each adapter provides a consistent interface for the basic cache operations of write, read and delete, which can be used interchangably between all adapters. For more information on Session methods and specific adapters, please see their relevant documentation.
See also: lithium\core\Adaptable
See also: lithium\storage\session\adapter
Inheritance: extends lithium\core\Adaptable
 public function post()
 {
     $token = Session::read('oauth.access');
     $result = Consumer::post('/1/statuses/update.json', array('status' => 'Testing my status'), compact('token'));
     echo $result;
     exit;
 }
Exemple #2
0
 public function check($credentials, array $options = array())
 {
     // This enables PHPBB login:
     global $phpbb_root_path, $phpEx, $user, $auth, $template, $cache, $db, $config;
     define('IN_PHPBB', true);
     $phpbb_root_path = \app\util\Config::get('forum_path');
     $phpEx = substr(strrchr(__FILE__, '.'), 1);
     include $phpbb_root_path . 'common.' . $phpEx;
     // creates $user and $auth objects here.
     $user->session_begin();
     $logged_in = $user->data['is_registered'];
     $username = strtolower($user->data['username_clean']);
     if ($logged_in === false) {
         // Not Logged In
         return false;
     }
     $model = $this->_model;
     $query = $this->_query;
     $conditions = $this->_scope + array('prv_uid' => $username);
     $id = $model::$query(compact('conditions'));
     if (!$id) {
         \lithium\storage\Session::write('non_linked_phpbb_login', true);
     }
     return $id;
 }
 public function _init()
 {
     parent::_init();
     if (!Session::read('user')) {
         $this->redirect('Sessions::add');
     }
 }
Exemple #4
0
 public function index()
 {
     Header('Cache-Control: no-cache');
     Header('Pragma: no-cache');
     $this->_render['layout'] = 'dialog';
     $apontador['token'] = Session::read('apontadorToken');
     $apontador['name'] = Session::read('apontadorName');
     $apontador['email'] = Session::read('apontadorEmail');
     $apontador['logged'] = !empty($apontador['token']);
     $foursquare['token'] = Session::read('foursquareToken');
     $foursquare['name'] = Session::read('foursquareName');
     $foursquare['email'] = Session::read('foursquareEmail');
     $foursquare['logged'] = !empty($foursquare['token']);
     $twitter['token'] = Session::read('twitterToken');
     $twitter['name'] = Session::read('twitterName');
     $twitter['logged'] = !empty($twitter['token']);
     $facebook['token'] = Session::read('facebookToken');
     $facebook['name'] = Session::read('facebookName');
     $facebook['email'] = Session::read('facebookEmail');
     $facebook['logged'] = !empty($facebook['token']);
     $orkut['token'] = Session::read('orkutToken');
     $orkut['name'] = Session::read('orkutName');
     $orkut['email'] = Session::read('orkutEmail');
     $orkut['logged'] = !empty($orkut['token']);
     $title = "Configurações de conta";
     return \array_merge(compact('title', 'apontador', 'foursquare', 'twitter', 'facebook', 'orkut'));
 }
Exemple #5
0
 public function Rates($FirstCurrency = "BTC", $SecondCurrency = "USD")
 {
     $title = $FirstCurrency . "/" . $SecondCurrency;
     $back = strtolower($FirstCurrency . "_" . $SecondCurrency);
     $Refresh = "No";
     $user = Session::read('member');
     $id = $user['_id'];
     $details = Details::find('first', array('conditions' => array('user_id' => $id)));
     if ($details['page.refresh'] == true || $details['page.refresh'] == 1) {
         $data = array('page.refresh' => false);
         Details::find('all', array('conditions' => array('user_id' => $id)))->save($data);
         $Refresh = "Yes";
     }
     $URL = "/" . $locale . 'ex/x/' . $back;
     $trades = Trades::find('first', array('conditions' => array('trade' => $title)));
     if ($trades['refresh'] == true || $trades['refresh'] == 1) {
         $data = array('refresh' => false);
         Trades::find('all', array('conditions' => array('trade' => $title)))->save($data);
         $Refresh = "Yes";
     }
     $mongodb = Connections::get('default')->connection;
     $Rates = Orders::connection()->connection->command(array('aggregate' => 'orders', 'pipeline' => array(array('$project' => array('_id' => 0, 'Action' => '$Action', 'PerPrice' => '$PerPrice', 'Completed' => '$Completed', 'FirstCurrency' => '$FirstCurrency', 'SecondCurrency' => '$SecondCurrency', 'TransactDateTime' => '$Transact.DateTime')), array('$match' => array('Completed' => 'Y', 'FirstCurrency' => $FirstCurrency, 'SecondCurrency' => $SecondCurrency)), array('$group' => array('_id' => array('year' => array('$year' => '$TransactDateTime'), 'month' => array('$month' => '$TransactDateTime'), 'day' => array('$dayOfMonth' => '$TransactDateTime')), 'min' => array('$min' => '$PerPrice'), 'max' => array('$max' => '$PerPrice'))), array('$sort' => array('_id.year' => -1, '_id.month' => -1, '_id.day' => -1)), array('$limit' => 1))));
     //		print_r($Rates['result']);
     foreach ($Rates['result'] as $r) {
         $Low = $r['min'];
         $High = $r['max'];
     }
     $Last = Orders::find('all', array('conditions' => array('Completed' => 'Y', 'FirstCurrency' => $FirstCurrency, 'SecondCurrency' => $SecondCurrency), 'limit' => 1, 'order' => array('Transact.DateTime' => 'DESC')));
     foreach ($Last as $l) {
         $LastPrice = $l['PerPrice'];
     }
     $TotalOrders = Orders::connection()->connection->command(array('aggregate' => 'orders', 'pipeline' => array(array('$project' => array('_id' => 0, 'Action' => '$Action', 'Amount' => '$Amount', 'Completed' => '$Completed', 'FirstCurrency' => '$FirstCurrency', 'SecondCurrency' => '$SecondCurrency', 'TransactDateTime' => '$Transact.DateTime', 'TotalAmount' => array('$multiply' => array('$Amount', '$PerPrice')))), array('$match' => array('Completed' => 'Y', 'Action' => 'Buy', 'FirstCurrency' => $FirstCurrency, 'SecondCurrency' => $SecondCurrency)), array('$group' => array('_id' => array('year' => array('$year' => '$TransactDateTime'), 'month' => array('$month' => '$TransactDateTime')), 'Amount' => array('$sum' => '$Amount'), 'TotalAmount' => array('$sum' => '$TotalAmount'))), array('$sort' => array('_id.year' => -1, '_id.month' => -1)), array('$limit' => 1))));
     //		print_r($SecondCurrency);
     return $this->render(array('json' => array('Refresh' => $Refresh, 'URL' => $URL, 'Low' => number_format($Low, 5), 'High' => number_format($High, 5), 'Last' => number_format($LastPrice, 5), 'VolumeFirst' => number_format($TotalOrders['result'][0]['Amount'], 5), 'VolumeSecond' => number_format($TotalOrders['result'][0]['TotalAmount'], 3), 'VolumeFirstUnit' => $FirstCurrency, 'VolumeSecondUnit' => $SecondCurrency)));
 }
Exemple #6
0
 /**
  * 初始化CSRF并检查token是否存在, 不存在则生成token 
  */
 public static function init()
 {
     $value = \lithium\storage\Session::read(self::$_session_key);
     if (empty($value)) {
         RequestToken::get();
     }
 }
 public function login()
 {
     $token = Session::read("{$this->_config['namespace']}.request");
     if (empty($token)) {
         return $this->redirect('Client::authorize', array('exit' => true));
     }
     return $this->redirect(Consumer::authenticate($token), array('exit' => true));
 }
 function test_getFromSession()
 {
     Session::write(Trackers::$name, array(array('_trackPageview'), array('_setDomainName', 'example.org')), array('name' => 'default'));
     Trackers::add('test', array('account' => 'test', 'adapter' => 'GoogleAnalytics', 'commands' => array(array('_setDomainName', 'example.org'))));
     $expected = array(array('_setAccount', 'test'), array('_trackPageview'), array('_setDomainName', 'example.org'));
     $tracking = Trackers::get('test');
     $this->assertEqual($expected, $tracking->commands());
 }
 public function login()
 {
     $token = Session::read('oauth.request');
     if (empty($token)) {
         $this->redirect('Client::authorize');
     }
     $this->redirect(Consumer::authenticate($token));
 }
 public function login()
 {
     Session::delete('oauth.request');
     Session::delete('oauth.access');
     $token = Consumer::token('request', array('params' => array('oauth_callback' => 'http://local.moodpik.com/tweet/success')));
     Session::write('oauth.request', $token);
     if (empty($token)) {
         $this->redirect('Tweet::authorize');
     }
     $this->redirect(Consumer::authenticate($token));
 }
 public function testWriteReadDelete()
 {
     $key = 'test';
     $value = 'value';
     Session::write($key, $value, array('name' => 'test'));
     $result = Session::read($key, array('name' => 'test'));
     $this->assertEqual($value, $result);
     $this->assertTrue(Session::delete($key, array('name' => 'test')));
     $result = Session::read($key, array('name' => 'test'));
     $this->assertNull($result);
 }
 public function testBasicAuthCheck()
 {
     $this->assertFalse(Auth::check('test'));
     $user = array('user' => 'bob');
     $result = Auth::check('test', $user, array('success' => true));
     $this->assertEqual($user, $result);
     $result = Session::read('test');
     $this->assertEqual($user, $result);
     $result = Auth::check('test');
     $this->assertEqual($user, $result);
 }
 public function index()
 {
     $user = Session::read('default');
     $id = $user['_id'];
     $details = Details::find('first', array('conditions' => array('user_id' => (string) $id)));
     $userInfo = Users::find('first', array('conditions' => array('_id' => (string) $id)));
     $order = Orders::find('first', array('conditions' => array('user_id' => (string) $id, 'Completed' => 'N')));
     $title = "API";
     $keywords = "API, documentation, ibwt";
     $description = "API documentation for ibwt.co.uk";
     return compact('title', 'keywords', 'description', 'details', 'userInfo', 'order');
 }
Exemple #14
0
 public function document()
 {
     $user = Session::read('member');
     $id = md5($user['email']);
     $document = Details::find('first', array('conditions' => array('user_id' => (string) $user['_id'])));
     //		if(count($document)==0){return $this->redirect('/');}
     $uploadOk = 1;
     if ($this->request->data) {
         $extension = pathinfo($this->request->data['file']['name'], PATHINFO_EXTENSION);
         $allowed = array('pdf');
         if (!in_array(strtolower($extension), $allowed)) {
             $msg = "Sorry, only PDF files are allowed.";
             $uploadOk = 0;
         }
         if ($uploadOk = 1) {
             $option = 'doc';
             $data = array('details_' . $option . '_id' => (string) $document['_id'], 'docname' => $this->request->data['docname'], 'date' => $this->request->data['date'], 'DateTime' => new \MongoDate(), 'keywords' => $this->request->data['keywords'], 'description' => $this->request->data['description'], $option => $this->request->data['file'], $option . '.verified' => 'No', $option . '.IP' => $_SERVER['REMOTE_ADDR']);
             $field = 'details_' . $option . '_id';
             $Documents = Documents::create($data);
             $saved = $Documents->save();
             $fileData = array('file' => $this->request->data['file'], 'documents_' . $option . '_id' => (string) $Documents->_id);
             $file = File::create();
             if ($file->save($fileData)) {
                 $msg = "Upload OK";
             }
             $image_address = File::find('first', array('conditions' => array('documents_doc_id' => (string) $Documents->_id)));
             if ($image_address['filename'] != "") {
                 $imagename_address = $image_address['_id'] . '_' . $image_address['filename'];
                 $path = LITHIUM_APP_PATH . '/webroot/download/' . $imagename_address;
                 file_put_contents($path, $image_address->file->getBytes());
             }
             //		print_r($path);
             $pages = $this->getPDFPages($path);
             // Output: 13
             //				print_r($pages);exit;
             unlink($path);
             $docdata = array();
             foreach ($pages as $page) {
                 $params = explode(":", $page);
                 $left = $params[0];
                 $right = $params[1];
                 $docdata = array_merge($docdata, array($left => trim($right)));
             }
             $data = array("document" => $docdata);
             $conditions = array("_id" => (string) $Documents->_id);
             Documents::update($data, $conditions);
             // Use the function
         }
     }
     return $this->redirect('ex::save');
 }
Exemple #15
0
 public function load()
 {
     $this->populate(unserialize(Session::read('location')));
     $lat = $this->point->getLat();
     $lng = $this->point->getLng();
     if (empty($lat) || empty($lng)) {
         $city = new City();
         $city->setName("São Paulo");
         $city->setState("SP");
         $this->point->setLat(-23.48033);
         $this->point->setLng(-46.63459);
         $this->address->setCity($city);
     }
 }
 public function delete()
 {
     // Check Author authentication Session
     if (!Auth::check('default')) {
         return $this->redirect('Authors::login');
     }
     $book = Books::find($this->request->id);
     if ($book && $book->delete()) {
         Session::write('message', 'Book deleted');
         $this->redirect(array('Authors::dashboard'));
     } else {
         Session::write('message', 'Book can not be deleted');
     }
 }
 public function testClear()
 {
     FlashMessage::write('Foo');
     FlashMessage::clear();
     $result = Session::read('message.default', array('name' => 'default'));
     $this->assertNull($result);
     FlashMessage::write('Foo 2', 'test1');
     FlashMessage::clear('test1');
     $result = Session::read('message.test1', array('name' => 'default'));
     $this->assertNull($result);
     FlashMessage::write('Foo 3', 'test2');
     FlashMessage::write('Foo 4', 'test3');
     FlashMessage::clear(null);
     $result = Session::read('message', array('name' => 'default'));
     $this->assertNull($result);
 }
 public function editar($id)
 {
     $alliances = alliances::find('first', array('conditions' => array('_id' => $id)));
     if ($this->request->data) {
         $alliances->name = $this->request->data['name'];
         $alliances->power = $this->request->data['power'];
         $alliances->overlord = $this->request->data['overlord'];
         if ($alliances->save()) {
             Session::write('message', array('status' => 'green', 'msg' => 'projecto ' . $alliances->titulo . ' editado com sucesso'));
         } else {
             Session::write('message', array('status' => 'red', 'msg' => 'Falha ao editar ' . $alliances->titulo));
         }
         $this->redirect('alliances::index');
     }
     $alliancestrue = TRUE;
     return compact('alliances', 'alliancestrue');
 }
Exemple #19
0
 /**
  * Displays a basic Facebook Connect login button.
  * Works with the PHP SDK to get the login URL.
  * This does not use the JavaScript SDK for xfbml.
  *
  * @param $options Array
  * @return String
  */
 public function facebook_login(array $options = array())
 {
     $defaults = array('div' => 'fb_login', 'button_image' => '/li3_facebook/img/fb-login-button.png', 'button_alt' => 'Login with Facebook', 'additional_copy' => null, 'fb_login_url_session_key' => 'fb_login_url');
     $options += $defaults;
     $output = '';
     $fb_login_url = Session::read($options['fb_login_url_session_key']);
     if (!empty($fb_login_url)) {
         if ($options['div'] !== false) {
             $output .= '<div id="' . $options['div'] . '">' . $options['additional_copy'];
         }
         $output .= '<a href="' . $fb_login_url . '"><img src="' . $options['button_image'] . '" alt="' . $options['button_alt'] . '" /></a>';
         if ($options['div'] !== false) {
             $output .= '</div>';
         }
     }
     return $output;
 }
 public function getKYCWallet()
 {
     $kyc = $this->request->query['kyc'];
     $opts = array('http' => array('method' => "GET", 'user_agent' => "MozillaXYZ/1.0"));
     $context = stream_context_create($opts);
     $json = file_get_contents('https://kycglobal.net/kyc/info/' . $kyc, false, $context);
     $details = json_decode($json);
     if ($details->percent > 60) {
         $user = Session::read('default');
         $data = array('kyc_id' => $kyc);
         $conditions = array("walletid" => $user['walletid']);
         Details::update($data, $conditions);
         return $this->render(array('json' => array('success' => 1, 'email' => $details->email, 'name' => $details->details->Name->first . " " . $details->details->Name->last, 'phone' => $details->details->Mobile, 'score' => $details->score, 'percent' => $details->percent)));
     } else {
         return $this->render(array('json' => array('success' => 0)));
     }
 }
	public function testClear() {
		FlashMessage::set('Foo');
		FlashMessage::clear();
		$result = Session::read('FlashMessage.default', array('name' => 'flash_message'));
		$this->assertNull($result);
		
		FlashMessage::set('Foo 2', array(), 'TestKey');
		FlashMessage::clear('TestKey');
		$result = Session::read('FlashMessage.TestKey', array('name' => 'flash_message'));
		$this->assertNull($result);
		
		FlashMessage::set('Foo 3', array(), 'TestKey2');
		FlashMessage::set('Foo 4', array(), 'TestKey3');
		FlashMessage::clear(null);
		$result = Session::read('FlashMessage', array('name' => 'flash_message'));
		$this->assertNull($result);
	}
Exemple #22
0
 public function login()
 {
     $result = Auth::check($this->request->adapter, $this->request);
     $redirectUrl = $this->request->env('HTTP_REFERER') ?: '/';
     if ($result) {
         # Convert array to identity object
         if ($this->request->adapter === 'password') {
             $result = Identities::find($result['_id']);
         }
         $session_data = array();
         $new_session = uniqid();
         if (isset($result['session']['id'])) {
             $session_data['id'] = (array) $result['session']['id']->data();
         } else {
             $session_data['id'] = array();
         }
         // Remember users for two weeks
         $session_data['expires'] = time() + \app\util\Config::get('session_length', 7) * 24 * 60 * 60;
         array_push($session_data['id'], $new_session);
         setcookie('session.id', $new_session, $session_data['expires'], '/', $_SERVER['HTTP_HOST']);
         $result->save(array('session' => $session_data));
         Auth::set('any', $result);
     } else {
         $addendum = '';
         // Adapter-specific error messages
         if ($this->request->adapter == 'phpbb') {
             if (Session::read('non_linked_phpbb_login')) {
                 Session::delete('non_linked_phpbb_login');
                 $addendum = 'You are logged into the forums, but there is no leagues account associated with with your forum account.';
             } else {
                 $addendum = 'Please ensure that you are logged into the <a href="http://www.afdc.com/forum/">forums</a>.';
             }
         } else {
             Logger::debug("Failed login for " . $this->request->data['email'] . " with password " . $this->request->data["password"]);
         }
         $error_message = 'Your login was unsuccessful. ';
         if (isset($addendum) and !empty($addendum)) {
             $error_message .= "<br />{$addendum}`<br />";
         }
         $error_message .= 'If you\'re having trouble, checkout the <a href="/help/login">login instructions</a>.';
         $this->flashMessage($error_message, array('alertType' => 'error'));
     }
     return $this->redirect($redirectUrl);
 }
Exemple #23
0
 public function testAuthPersist()
 {
     Auth::reset();
     Auth::config(array('test' => array('adapter' => $this->_classes['mockAuthAdapter'])));
     $config = Auth::config();
     $this->assertTrue(isset($config['test']['session']['persist']));
     $this->assertTrue(empty($config['test']['session']['persist']));
     $user = array('username' => 'foo', 'password' => 'bar');
     $result = Auth::check('test', $user, array('success' => true));
     $this->assertTrue(isset($result['username']));
     $this->assertFalse(isset($result['password']));
     Auth::reset();
     Auth::config(array('test' => array('adapter' => $this->_classes['mockAuthAdapter'], 'session' => array('persist' => array('username', 'email')))));
     $user = array('username' => 'foobar', 'password' => 'not!important', 'email' => '*****@*****.**', 'insuranceNumer' => 1234567);
     $expected = array('username' => 'foobar', 'email' => '*****@*****.**');
     $result = Auth::check('test', $user, array('success' => true, 'checkSession' => false));
     $this->assertEqual($expected, $result);
     $this->assertEqual($expected, Session::read('test'));
 }
Exemple #24
0
 public function save($id = null)
 {
     $user = Session::read('member');
     if ($user == "") {
         return $this->redirect('/');
     }
     //			$id = 		md5($user['email']);
     if ($id != "") {
         $data = array("Saved" => "Yes");
         $conditions = array('_id' => $id);
         Documents::update($data, $conditions);
         $this->redirect("ex::dashboard");
     }
     $detail = Details::find('first', array('conditions' => array('user_id' => (string) $user['_id'])));
     $option = 'fileType';
     $document = Documents::find('first', array('conditions' => array('details_doc_id' => (string) $detail['_id'], 'Saved' => null)));
     $rates = Rates::find('first', array('conditions' => array('Min' => array('$lte' => intval($document['document']['Pages'])), 'Max' => array('$gte' => intval($document['document']['Pages'])))));
     return compact('document', 'rates');
 }
Exemple #25
0
<?php

/**
 * Lithium: the most rad php framework
 *
 * @copyright     Copyright 2010, Union of RAD (http://union-of-rad.org)
 * @license       http://opensource.org/licenses/bsd-license.php The BSD License
 */
/**
 * This configures your session storage. The Cookie storage adapter must be connected first, since
 * it intercepts any writes where the `'expires'` key is set in the options array.
 */
use lithium\storage\Session;
Session::config(array('cookie' => array('adapter' => 'Cookie'), 'default' => array('adapter' => 'Php')));
/**
 * Uncomment this to enable forms-based authentication. The configuration below will attempt to
 * authenticate users against a `User` model. In a controller, run
 * `Auth::check('default', $this->request)` to authenticate a user. This will check the POST data of
 * the request (`lithium\action\Request::$data`) to see if the fields match the `'fields'` key of
 * the configuration below. If successful, it will write the data returned from `User::first()` to
 * the session using the default session configuration. Once the session data is written, you can
 * call `Auth::check('default')` to check authentication status or retrieve the user's data from the
 * session. Call `Auth::clear('default')` to remove the user's authentication details from the
 * session. This effectively logs a user out of the system. To modify the form input that the
 * adapter accepts, or how the configured model is queried, or how the data is stored in the
 * session, see the `Form` adapter API or the `Auth` API, respectively.
 *
 * @see lithium\security\auth\adapter\Form
 * @see lithium\action\Request::$data
 * @see lithium\security\Auth
 */
<?php
/**
 * Lithium: the most rad php framework
 *
 * @copyright     Copyright 2010, Union of RAD (http://union-of-rad.org)
 * @license       http://opensource.org/licenses/bsd-license.php The BSD License
 */

/**
 * This configures your session storage. The Cookie storage adapter must be connected first, since
 * it intercepts any writes where the `'expires'` key is set in the options array.
 */
use lithium\storage\Session;

Session::config(array(
	'default' => array('adapter' => 'Php')
));

/**
 * Uncomment the lines below to enable forms-based authentication. This configuration will attempt
 * to authenticate users against a `Users` model. In a controller, run
 * `Auth::check('default', $this->request)` to authenticate a user. This will check the POST data of
 * the request (`lithium\action\Request::$data`) to see if the fields match the `'fields'` key of
 * the configuration below. If successful, it will write the data returned from `Users::first()` to
 * the session using the default session configuration.
 *
 * Once the session data is written, you can call `Auth::check('default')` to check authentication
 * status or retrieve the user's data from the session. Call `Auth::clear('default')` to remove the
 * user's authentication details from the session. This effectively logs a user out of the system.
 * To modify the form input that the adapter accepts, or how the configured model is queried, or how
 * the data is stored in the session, see the `Form` adapter API or the `Auth` API, respectively.
 public function testEncryptStrategyWithPhpAdapter()
 {
     $config = array('name' => 'encryptInt');
     Session::config(array($config['name'] => array('adapter' => 'Php', 'strategies' => array('Encrypt' => array('secret' => 's3cr3t')))));
     Session::clear($config);
     $key = 'test';
     $value = 'value';
     $this->assertTrue(Session::write($key, $value, $config));
     $this->assertEqual($value, Session::read($key, $config));
     $this->assertTrue(Session::delete($key, $config));
     $this->assertNull(Session::read($key, $config));
     Session::clear($config);
     $this->assertTrue(Session::write('foo', 'bar', $config));
     $this->assertEqual('bar', Session::read('foo', $config));
     $this->assertTrue(Session::write('foo', 'bar1', $config));
     $this->assertEqual('bar1', Session::read('foo', $config));
     Session::clear($config);
     $this->assertTrue(Session::write($key, $value, $config));
     $this->assertEqual($value, Session::read($key, $config));
 }
<?php

use lithium\storage\Session;
$user = Session::read('default');
$session = false;
if ($user != "") {
    $session = true;
}
use lithium\core\Environment;
if (substr(Environment::get('locale'), 0, 2) == "en") {
    $locale = "en";
} else {
    $locale = Environment::get('locale');
}
//if(strlen($locale>2)){$locale='en';}
// print_r(Environment::get('locale'));
// print_r($locale);
?>
<nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">...</span>
            <span class="icon-bar"></span>
            <span clas8="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="/<?php 
echo $locale;
?>
/"><img src="/img/logo-GreenCoinX.png" height="30px" title="XGC Wallet"> </a>
 * This file contains configurations for connecting to external caching resources, as well as
 * default caching rules for various systems within your application
 */
require __DIR__ . '/bootstrap/cache.php';
/**
 * This file contains your application's globalization rules, including inflections,
 * transliterations, localized validation, and how localized text should be loaded. Uncomment this
 * line if you plan to globalize your site.
 */
// require __DIR__ . '/bootstrap/g11n.php';
/**
 * This file contains configurations for handling different content types within the framework,
 * including converting data to and from different formats, and handling static media assets.
 */
// require __DIR__ . '/bootstrap/media.php';
/**
 * This file configures console filters and settings, specifically output behavior and coloring.
 */
// require __DIR__ . '/bootstrap/console.php';
/**
 * This file contains filters for the test suite to bypass having a controller and render test
 * templates directly through the test dispatcher.
 */
require __DIR__ . '/bootstrap/test.php';
/**
 * This configures your session storage. The Cookie storage adapter must be connected first, since
 * it intercepts any writes where the `'expires'` key is set in the options array.
 */
use lithium\storage\Session;
Session::config(array('cookie' => array('adapter' => 'Cookie', 'expire' => '+2 days'), 'default' => array('adapter' => 'Php')));
Exemple #30
0
 public static function getImage()
 {
     $game = Games::find('first', array('conditions' => array('id' => Session::read('game_id'))));
     $word = Words::find('first', array('conditions' => array('id' => $game->word_id)));
     $img_number = self::MAX_IMAGE_COUNT - $game->max_wrong_tries + $game->wrong_tries;
     if ($game->max_wrong_tries == 5) {
         switch ($game->wrong_tries) {
             case 1:
                 $img_number = 3;
                 break;
             case 2:
                 $img_number = 5;
                 break;
             case 3:
                 $img_number = 7;
                 break;
             case 4:
                 $img_number = 9;
                 break;
             case 5:
                 $img_number = 11;
                 break;
             case 0:
             default:
                 $img_number = 0;
                 break;
         }
     }
     return self::HANG_IMAGE_PRE . $img_number . self::HANG_IMAGE_POST;
 }