read() public static méthode

Reads a value from a persistent session store.
public static read ( string $key = null, array $options = [] ) : mixed
$key string Key to be read.
$options array Optional parameters that this method accepts: - `'name'` _string_: To force the read from a specific adapter, specify the name of the configuration (i.e. `'default'`) here. - `'strategies'` _boolean_: Indicates whether or not a configuration's applied strategy classes should be enabled for this operation. Defaults to `true`.
Résultat mixed Read result on successful session read, `null` otherwise.
 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 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 #3
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)));
 }
 public function _init()
 {
     parent::_init();
     if (!Session::read('user')) {
         $this->redirect('Sessions::add');
     }
 }
Exemple #5
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));
 }
 public function login()
 {
     $token = Session::read('oauth.request');
     if (empty($token)) {
         $this->redirect('Client::authorize');
     }
     $this->redirect(Consumer::authenticate($token));
 }
 public function _init()
 {
     $this->_render['negotiate'] = true;
     parent::_init();
     if (!Session::read('user')) {
         $this->redirect('Sessions::add');
     }
 }
 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 #12
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 #13
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 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 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 #17
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 _init()
 {
     parent::_init();
     if (!Session::read('user')) {
         $this->redirect('Sessions::add');
     }
     Projectos::applyFilter('save', function ($self, $params, $chain) {
         //Temporarily store our entity object so that we can manipulate it
         $record = $params['entity'];
         //If an id doesn't exist yet, then we know we're saving for the first time. If a
         //password is provided, we need to hash it
         var_dump($record->foto);
         //Write the modified object back to $params
         $params['entity'] = $record;
         //Allow the next filter to be run
         return $chain->next($self, $params, $chain);
     });
 }
Exemple #19
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 #20
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 #21
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 #22
0
 public function trychar($char)
 {
     // do we have an active game session?
     if (!Session::check("game_id", array('name' => 'default'))) {
         return $this->redirect('games::index');
     }
     // state: 0 = in-game, 1 = won, 2 = lost, 3 = already won, 4 = already lost
     $game = Games::find('first', array('conditions' => array('id' => Session::read('game_id'))));
     $word = Words::find('first', array('conditions' => array('id' => $game->word_id)));
     $resp = array("success" => 0, "wrong_tries_left" => $game->max_wrong_tries - $game->wrong_tries, "placeholders" => Games::getPlaceholders(), "image" => Games::getImage(), "message" => "", "state" => 0, "word" => "");
     // game already won
     if ($game->state == 1) {
         $resp['message'] = "You already won!";
         $resp['state'] = 3;
         return $this->render(array('type' => 'json', 'data' => $resp, 'layout' => false));
         // game already lost
     } elseif ($game->state == 2) {
         $resp['message'] = "You already lost!";
         $resp['state'] = 4;
         return $this->render(array('type' => 'json', 'data' => $resp, 'layout' => false));
     }
     // ist der gesendete buchstabe erlaubt?
     if (!Games::isValidChar($char)) {
         $resp['success'] = 0;
         $resp['message'] = "Non-valid char used.";
         return $this->render(array('type' => 'json', 'data' => $resp, 'layout' => false));
         // falls der gesendete buchstabe schonmal gesendet wurde
     } elseif (stripos($game->input_text, $char) !== false) {
         $resp['success'] = 0;
         $resp['message'] = "Char was already used.";
         return $this->render(array('type' => 'json', 'data' => $resp, 'layout' => false));
         // buchstabe ist valid und wurde nicht schon gesendet
     } else {
         $game->input_text .= $char;
         $game->save();
         $resp['success'] = 1;
         $resp['placeholders'] = Games::getPlaceholders();
         // buchstabe kommt in gesuchtem wort vor
         if (!(stripos($word->value, $char) === false) && stripos($word->value, $char) >= 0) {
             $resp['image'] = Games::getImage();
             // alle zeichen erraten, gewonnen
             // WIN!
             if (stripos(Games::getPlaceholders(), self::PLACEHOLDER) === false) {
                 $game->state = 1;
                 // won
                 $game->save();
                 $resp['state'] = 1;
                 // won
                 $resp['message'] = "You won! Play a new game?";
                 $resp['wrong_tries_left'] = $game->max_wrong_tries - $game->wrong_tries;
                 return $this->render(array('type' => 'json', 'data' => $resp, 'layout' => false));
                 // buchstabe stimmt, aber noch nicht alles erraten
             } else {
                 $resp['wrong_tries_left'] = $game->max_wrong_tries - $game->wrong_tries;
                 $resp['message'] = "Nice! Guess the next char!";
                 return $this->render(array('type' => 'json', 'data' => $resp, 'layout' => false));
             }
             // buchstabe kommt NICHT vor
         } else {
             $game->wrong_tries++;
             $game->save();
             $resp['image'] = Games::getImage();
             // hat der benutzer die maximale anzahl versuche überschritten?
             // LOOSE!
             if ($game->wrong_tries >= $game->max_wrong_tries) {
                 $resp['wrong_tries_left'] = 0;
                 $resp['message'] = "Out of tries. New Game?";
                 $resp['state'] = 2;
                 // lost
                 $game->state = 2;
                 // lost
                 $resp['word'] = $word->value;
                 $game->save();
                 return $this->render(array('type' => 'json', 'data' => $resp, 'layout' => false));
                 // falscher buchstaben eingegeben, benutzer hat weiteren versuch
             } else {
                 $resp['wrong_tries_left'] = $game->max_wrong_tries - $game->wrong_tries;
                 $resp['message'] = "Nope. Try again!";
                 return $this->render(array('type' => 'json', 'data' => $resp, 'layout' => false));
             }
         }
     }
     return $this->render(array('type' => 'json', 'data' => $resp, 'layout' => false));
 }
<?php

use app\models\Trades;
use lithium\storage\Session;
use app\extensions\action\Functions;
$user = Session::read('member');
?>
<div class="navbar-header">
	<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
		<span class="sr-only">Toggle navigation</span>
		<span class="icon-bar"></span>
		<span class="icon-bar"></span>
		<span class="icon-bar"></span>
	</button>
	<a class="navbar-brand" href="/"><img src="/img/logo.png" alt="<?php 
echo COMPANY_URL;
?>
" title="<?php 
echo COMPANY_SHORT;
?>
"></a>
</div> <!-- navbar-header-->
<div class="navbar-collapse collapse">
	<?php 
if (strtolower($this->_request->controller) == 'ex') {
    ?>
	
	<?php 
} else {
    ?>
	
 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));
 }
Exemple #25
0
 public function getReadMails()
 {
     $user = Session::read('member');
     $id = $user['_id'];
     $getReadMails = Messages::find('all', array('conditions' => array('refer_id' => $id, 'read' => 1)));
     return $getReadMails;
 }
<?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>
Exemple #27
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;
 }
Exemple #28
0
 public function add()
 {
     //assume there's no problem with authentication
     $noauth = false;
     //perform the authentication check and redirect on success
     Session::delete('default');
     $response = file_get_contents("http://ipinfo.io/{$_SERVER['REMOTE_ADDR']}");
     $IPResponse = json_decode($response);
     if ($IPResponse->tor) {
         // Display error message or something
         $user = "";
         Session::delete('default');
         return false;
     }
     $user = Users::find("first", array("conditions" => array("username" => $this->request->data['username'])));
     $default = array('username' => $user['username'], '_id' => $user['_id'], 'firstname' => $user['firstname'], 'lastname' => $user['lastname'], 'email' => $user['email'], 'walletid' => $user['walletid']);
     if (password_verify($this->request->data['password'], $user['password'])) {
         //Redirect on successful login
         $loginpassword = $this->request->data['loginpassword'];
         Session::write('default', $default);
         $details = Details::find('first', array('conditions' => array('username' => $default['username'], 'user_id' => (string) $default['_id'])));
         if ($details['active'] == "No") {
             Session::delete('default');
             return $this->redirect('/');
             exit;
         }
         if ($details["EmailPasswordSecurity"] === "true" || $details["EmailPasswordSecurity"] === null) {
             if ($details['oneCode'] === $this->request->data['loginpassword']) {
                 $data = array('oneCodeused' => 'Yes', 'lastconnected' => array('IP' => $IPResponse->ip, 'ISO' => $IPResponse->country, 'hostname' => $IPResponse->hostname, 'city' => $IPResponse->city, 'region' => $IPResponse->region, 'loc' => $IPResponse->loc, 'org' => $IPResponse->org, 'postal' => $IPResponse->postal, 'DateTime' => new \MongoDate()));
                 $details = Details::find('first', array('conditions' => array('username' => $default['username'], 'user_id' => (string) $default['_id'])))->save($data);
                 $details = Details::find('first', array('conditions' => array('username' => $default['username'], 'user_id' => (string) $default['_id'])));
                 if ($details["TOTP.Validate"] == 1 && $details["TOTP.Login"] == true) {
                     $totp = $this->request->data['totp'];
                     $ga = new GoogleAuthenticator();
                     if ($totp == "") {
                         Session::delete('default');
                     } else {
                         $checkResult = $ga->verifyCode($details['secret'], $totp, 2);
                         if ($checkResult == 1) {
                             Session::write('default', $default);
                             $user = Session::read('default');
                             /////////////////////////////////////////////////////////////////////////////////
                             $function = new Functions();
                             $IP = $function->get_ip_address();
                             $data = array('username' => $user['username'], 'IP' => $IPResponse->ip, 'ISO' => $IPResponse->country, 'hostname' => $IPResponse->hostname, 'city' => $IPResponse->city, 'region' => $IPResponse->region, 'loc' => $IPResponse->loc, 'org' => $IPResponse->org, 'postal' => $IPResponse->postal, 'DateTime' => new \MongoDate());
                             Logins::create()->save($data);
                             /////////////////////////////////////////////////////////////////////////////////
                             $user = Session::read('default');
                             return $this->redirect('ex::dashboard');
                             exit;
                         } else {
                             Session::delete('default');
                         }
                     }
                 } else {
                     Session::write('default', $default);
                     $user = Session::read('default');
                     /////////////////////////////////////////////////////////////////////////////////
                     $function = new Functions();
                     $IP = $function->get_ip_address();
                     $data = array('username' => $user['username'], 'IP' => $IPResponse->ip, 'ISO' => $IPResponse->country, 'hostname' => $IPResponse->hostname, 'city' => $IPResponse->city, 'region' => $IPResponse->region, 'loc' => $IPResponse->loc, 'org' => $IPResponse->org, 'postal' => $IPResponse->postal, 'DateTime' => new \MongoDate());
                     Logins::create()->save($data);
                     /////////////////////////////////////////////////////////////////////////////////
                     $user = Session::read('default');
                     return $this->redirect('ex::dashboard');
                     exit;
                 }
             } else {
                 Session::delete('default');
             }
         } else {
             $data = array('oneCodeused' => 'Yes', 'lastconnected' => array('IP' => $IPResponse->ip, 'ISO' => $IPResponse->country, 'hostname' => $IPResponse->hostname, 'city' => $IPResponse->city, 'region' => $IPResponse->region, 'loc' => $IPResponse->loc, 'org' => $IPResponse->org, 'postal' => $IPResponse->postal, 'DateTime' => new \MongoDate()));
             $details = Details::find('first', array('conditions' => array('username' => $default['username'], 'user_id' => (string) $default['_id'])))->save($data);
             $details = Details::find('first', array('conditions' => array('username' => $default['username'], 'user_id' => (string) $default['_id'])));
             Session::write('default', $default);
             $user = Session::read('default');
             /////////////////////////////////////////////////////////////////////////////////
             $function = new Functions();
             $IP = $function->get_ip_address();
             $data = array('username' => $user['username'], 'IP' => $IPResponse->ip, 'ISO' => $IPResponse->country, 'hostname' => $IPResponse->hostname, 'city' => $IPResponse->city, 'region' => $IPResponse->region, 'loc' => $IPResponse->loc, 'org' => $IPResponse->org, 'postal' => $IPResponse->postal, 'DateTime' => new \MongoDate());
             Logins::create()->save($data);
             /////////////////////////////////////////////////////////////////////////////////
             $user = Session::read('default');
             return $this->redirect('ex::dashboard');
         }
     }
     //if theres still post data, and we weren't redirected above, then login failed
     if ($this->request->data) {
         //Login failed, trigger the error message
         if (isset($this->request->query['check']) && $this->request->query['check'] == SECURITY_CHECK) {
             $check = $this->request->query['check'];
         }
         $noauth = true;
     }
     //Return noauth status
     $page = Pages::find('first', array('conditions' => array('pagename' => 'login')));
     $title = $page['title'];
     $keywords = $page['keywords'];
     $description = $page['description'];
     return compact('noauth', 'title', 'keywords', 'description');
     return $this->redirect('/');
     exit;
     // Handle failed authentication attempts
 }
 public function testEncryptedStrategy()
 {
     $this->skipIf(!MockEncrypt::enabled(), 'The Mcrypt extension is not installed or enabled.');
     $key = 'foobar';
     $adapter = new Memory();
     Session::config(array('primary' => array('adapter' => $adapter, 'filters' => array(), 'strategies' => array('lithium\\tests\\mocks\\storage\\session\\strategy\\MockEncrypt' => array('secret' => $key)))));
     $value = array('foo' => 'bar');
     Session::write('test', $value);
     $this->assertEqual(array('foo' => 'bar'), Session::read('test'));
     $this->assertTrue(Session::check('test'));
     $this->assertTrue(Session::check('test', array('strategies' => false)));
     $encrypted = Session::read('test', array('strategies' => false));
     $this->assertNotEqual($value, $encrypted);
     $this->assertTrue(is_string($encrypted));
     $result = Session::read('test');
     $this->assertEqual($value, $result);
     $result = Session::clear(array('strategies' => false));
     $this->assertNull(Session::read('test'));
     $this->assertFalse(Session::check('test'));
     $this->assertFalse(Session::check('test', array('strategies' => false)));
     $savedData = array('test' => $value);
     $encrypt = new MockEncrypt(array('secret' => $key));
     $result = $encrypt->encrypt($savedData);
     $this->assertEqual($encrypted, $result);
     $result = $encrypt->decrypt($encrypted);
     $this->assertEqual($savedData, $result);
 }
Exemple #30
0
 public function testStrategiesPhpAdapter()
 {
     Session::config(array('strategy' => array('adapter' => 'Php', 'strategies' => array('Hmac' => array('secret' => 'somesecretkey')))));
     $key = 'test';
     $value = 'value';
     Session::write($key, $value, array('name' => 'strategy'));
     $result = Session::read($key, array('name' => 'strategy'));
     $this->assertEqual($value, $result);
     $this->assertTrue(Session::delete($key, array('name' => 'strategy')));
     $result = Session::read($key, array('name' => 'strategy'));
     $this->assertNull($result);
     Session::write($key, $value, array('name' => 'strategy'));
     $result = Session::read($key, array('name' => 'strategy'));
     $this->assertEqual($value, $result);
     $cache = $_SESSION;
     $_SESSION['injectedkey'] = 'hax0r';
     $this->expectException('/Possible data tampering - HMAC signature does not match data./');
     $result = Session::read($key, array('name' => 'strategy'));
     $_SESSION = $cache;
 }