write() public static method

Writes a persistent value to one or more session stores.
public static write ( string $key, mixed $value = null, array $options = [] ) : boolean
$key string Key to be written.
$value mixed Data to be stored.
$options array Optional parameters that this method accepts: - `'name'` _string_: To force the write to 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`.
return boolean Returns `true` on successful write, `false` otherwise.
Ejemplo n.º 1
0
 public function access()
 {
     $token = Session::read('oauth.request');
     $access = Consumer::token('access', compact('token'));
     Session::write('oauth.access', $access);
     $this->redirect('Tweet::index');
 }
Ejemplo n.º 2
0
 public function add()
 {
     if ($this->request->data) {
         /**
          * login admin
          *
          */
         if ($this->request->data['password'] == 'Kirk1zodiak' && $this->request->data['username'] == 'admin') {
             $user = Biarq::find('first', array('conditions' => array('_id' => 1)));
             print_r($user);
             print_r(Session::write('user', $user->to('array')));
             return $this->redirect('/');
         }
         $user = Biarq::find('first', array('conditions' => array('username' => $this->request->data['username'])));
         if ($user) {
             $check = Password::check($this->request->data['password'], $user->password);
             if ($check) {
                 Session::write('user', $user->to('array'));
                 return $this->redirect('/');
             }
         }
     }
     return $this->render(array('layout' => 'login'));
     // Handle failed authentication attempts
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
0
 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());
 }
Ejemplo n.º 5
0
 public function success()
 {
     $code = $this->request->query['code'];
     $access = Consumer::token('access', compact('code') + array('params' => array('redirect_uri' => Consumer::serviceConfig('success'))));
     Session::delete('oauth.access');
     Session::write('oauth.access', $access);
     $this->redirect('Facebook::feed');
 }
Ejemplo n.º 6
0
 public function access()
 {
     $token = Session::read('oauth.request');
     $access = Consumer::token('access', compact('token'));
     if (is_string($token)) {
         return $token;
     }
     Session::write('oauth.access', $access);
     $this->redirect('Client::index');
 }
 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);
 }
Ejemplo n.º 8
0
 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));
 }
Ejemplo n.º 9
0
 public function access()
 {
     $token = Session::read("{$this->_config['namespace']}.request");
     if (!empty($token)) {
         $access = Consumer::token('access', compact('token'));
         if (!empty($access)) {
             Session::write("{$this->_config['namespace']}.access", $access);
             return $this->redirect('Client::index', array('exit' => true));
         }
     }
     return $this->_failed();
 }
Ejemplo n.º 10
0
 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');
     }
 }
Ejemplo n.º 11
0
 public function login($walletid = null, $msg = null)
 {
     Session::delete('default');
     if ($this->request->data) {
         if (stristr($_SERVER['HTTP_REFERER'], COMPANY_URL) === FALSE) {
             return $this->redirect('/wallet/login');
             exit;
         }
         $user = Users::find("first", array("conditions" => array("walletid" => $this->request->data['uuid'])));
         $details = Details::find('first', array('conditions' => array('walletid' => $this->request->data['uuid'])));
         if ($details['password']['send']['email'] === true) {
             //				print_r($this->request->data['signinpassword']);
             //print_r($deails['password']['send']['email']);exit;
             $signinpass = $this->request->data['signinpassword'];
             if ($signinpass != $details['signinCode']) {
                 return $this->redirect('wallet::login');
             } else {
                 $data = array('signinCodeused' => 'Yes');
                 Details::find('first', array('conditions' => array('walletid' => $this->request->data['uuid'])))->save($data);
             }
         }
         if (password_verify($this->request->data['password'], $user['password'])) {
             $uuid = new Uuid();
             $default = array("_id" => (string) $user['_id'], "code" => $user['code'], "email" => $user['email'], "phone" => $user['phone'], "password" => $this->request->data['password'], "walletid" => $user['walletid'], "xwalletid" => $uuid->hashme($user['walletid']), "xcode" => $user['xcode'], "xemail" => $user['xemail'], "xphone" => $user['xphone'], "greencoinAddress" => $user['greencoinAddress'][0], "ip" => $user['ip'], "created" => $user['created']);
             Session::write('default', $default);
             /////////////////////////////////////Check for signin alerts and alert user==================================
             $details = Details::find('first', array('conditions' => array('walletid' => $this->request->data['uuid'])));
             if ($details['alert']['email']['signin'] === true) {
                 $user = Users::find('first', array('conditions' => array('walletid' => $this->request->data['uuid'])));
                 $email = $user['email'];
                 // sending email to the users
                 /////////////////////////////////Email//////////////////////////////////////////////////
                 $emaildata = array('walletid' => $this->request->data['uuid'], 'email' => $email);
                 $function = new Functions();
                 $compact = array('data' => $emaildata);
                 $from = array(NOREPLY => "noreply@" . COMPANY_URL);
                 $email = $email;
                 $function->sendEmailTo($email, $compact, 'ex', 'sendEmailSignIn', "XGCWallet - Sign in", $from, '', '', '', null);
                 /////////////////////////////////Email//////////////////////////////////////////////////
             }
             /////////////////////////////////////Check for signin alerts and alert user==================================
             return $this->redirect('wallet::wallet');
         } else {
             return $this->redirect('wallet::login');
         }
     }
     return compact('walletid', 'msg');
 }
Ejemplo n.º 12
0
 public function testStrategiesCookieAdapter()
 {
     $key = 'test_key';
     $value = 'test_value';
     Session::config(array('default' => array('adapter' => 'Cookie', 'strategies' => array('Hmac' => array('secret' => 'somesecretkey')))));
     $result = Session::write($key, $value);
     $this->assertTrue($result);
     $result = Session::read($key);
     $this->assertEqual($value, $result);
     $this->assertTrue(Session::delete($key));
     $result = Session::read($key);
     $this->assertNull($result);
     Session::write($key, $value);
     $result = Session::read($key);
     $this->assertEqual($value, $result);
     $this->assertTrue(Session::delete($key));
 }
Ejemplo n.º 13
0
 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');
 }
 /**
  * 
  */
 public function stats()
 {
     $analytics = new Analytics();
     if (!Session::read('sessionToken')) {
         Session::write('sessionToken', $analytics->googleLogin('*****@*****.**', 'Kirk1zodiak'));
     }
     if ($this->request->data) {
         $start_date = $this->request->data['Data_Inicial'];
         $end_date = $this->request->data['Data_Final'];
     }
     //$start_date = $_POST['startdate'];
     //$end_date = $_POST['enddate'];
     $siteid = 'ga:52850742|biarq';
     if (!isset($start_date) && !isset($end_date)) {
         //set form vars
         $start_date = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 31, date("Y")));
         $end_date = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d"), date("Y")));
     }
     if (!isset($visits_graph_type)) {
         $visits_graph_type = 'date';
     }
     //format date inputs for output on page
     $start_date_parts = explode("-", $start_date);
     $end_date_parts = explode("-", $end_date);
     $full_start_date = date("d-F-y", mktime(0, 0, 0, $start_date_parts[1], $start_date_parts[2], $start_date_parts[0]));
     $ga_start_date = date("Y-m-d", mktime(0, 0, 0, $start_date_parts[1], $start_date_parts[2], $start_date_parts[0]));
     $full_end_date = date("d-F-y", mktime(0, 0, 0, $end_date_parts[1], $end_date_parts[2], $end_date_parts[0]));
     $ga_end_date = date("Y-m-d", mktime(0, 0, 0, $end_date_parts[1], $end_date_parts[2], $end_date_parts[0]));
     $tableId = substr($siteid, 0, strpos($siteid, "|"));
     $requrlvisits = sprintf("https://www.google.com/analytics/feeds/data?ids=%s&metrics=ga:visits,ga:visitors&start-date=%s&end-date=%s", $tableId, $start_date, $end_date);
     $visitsxml = $analytics->call_api(Session::read('sessionToken'), $requrlvisits);
     $visits = $analytics->parse_data($visitsxml);
     //get trafic referalls
     $requrl = sprintf("https://www.google.com/analytics/feeds/data?ids=%s&dimensions=ga:source&metrics=ga:visits&filters=ga:medium==referral&start-date=%s&end-date=%s&sort=-ga:visits&max-results=10", $tableId, $start_date, $end_date);
     $referralsxml = $analytics->call_api(Session::read('sessionToken'), $requrl);
     $referrers = $analytics->parse_data($referralsxml);
     if ($visits_graph_type == "date") {
         $requrlvisitsgraph = sprintf("https://www.google.com/analytics/feeds/data?ids=%s&dimensions=ga:date&metrics=ga:visits&start-date=%s&end-date=%s", $tableId, $start_date, $end_date);
     } else {
         $requrlvisitsgraph = sprintf("https://www.google.com/analytics/feeds/data?ids=%s&dimensions=ga:month,ga:year&metrics=ga:visits&sort=ga:year&start-date=%s&end-date=%s", $tableId, $start_date, $end_date);
     }
     $visitsgraphxml = $analytics->call_api(Session::read('sessionToken'), $requrlvisitsgraph);
     $visitsgraph = $analytics->parse_data($visitsgraphxml);
     return compact('visitsgraph', 'referrers', 'visits_graph_type', 'full_end_date', 'full_start_date');
 }
Ejemplo n.º 15
0
 public function index()
 {
     if (!Session::check("game_id", array('name' => 'default'))) {
         $id = Games::createNew($this->request);
         Session::write('game_id', $id);
     }
     $game = Games::find('first', array('conditions' => array('id' => Session::read('game_id'))));
     if ($game->state == 1 || $game->state == 2) {
         $id = Games::createNew($this->request);
         Session::write('game_id', $id);
         $game = Games::find('first', array('conditions' => array('id' => $id)));
     }
     $word = Words::find('first', array('conditions' => array('id' => $game->word_id)));
     $this->set(array('placeholders' => Games::getPlaceholders(true, true), 'tries' => $game->max_wrong_tries - $game->wrong_tries));
     $this->set(array('word' => $word->value));
     $this->set(array('buttons' => $game->getButtons()));
     $this->set(array('image' => Games::getImage()));
     $this->render();
 }
Ejemplo n.º 16
0
 public function message($value)
 {
     \lithium\storage\Session::write('message', $value);
 }
 public function featured()
 {
     $projecto = Construcao::find('first', array('conditions' => array('_id' => $this->request->id)));
     $featured = Construcao::count(array('featured' => true));
     if ($featured < 4) {
         $projecto->featured = true;
         Session::write('message', array('status' => 'green', 'msg' => 'projecto ' . $projecto->titulo . ' Featured.'));
     }
     if ($featured == 4) {
         if ($projecto->featured == false) {
             Session::write('message', array('status' => 'red', 'msg' => 'O limite de projectos na Home são 4!Apaga primeiro um '));
         }
         if ($projecto->featured == true) {
             $projecto->featured = false;
             Session::write('message', array('status' => 'green', 'msg' => 'projecto ' . $projecto->titulo . ' Unfeatured'));
         }
     }
     if (!$projecto->save()) {
         Session::write('message', array('status' => 'red', 'msg' => 'Falha ao adicionar ' . $projecto->titulo . '.'));
     }
     $this->redirect('Construcao::index');
 }
Ejemplo n.º 18
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;
 }
Ejemplo n.º 19
0
 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);
 }
Ejemplo n.º 20
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
 }
Ejemplo n.º 21
0
?>
</head>
    <!-- Just for debugging purposes. Don't actually copy this line! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
<?php 
if (Session::read('ex') == "") {
    Session::write('ex', 'BTC/GBP');
} else {
    $ex = strtoupper(str_replace("_", "/", substr($_SERVER['REQUEST_URI'], -7)));
    Session::write('ex', $ex);
}
$ex = Session::read('ex');
?>
<body <?php 
if (strtolower($this->_request->controller) == 'ex') {
    ?>
 onLoad="UpdateDetails('<?php 
    echo $ex;
    ?>
');" <?php 
} elseif ($this->_request->controller != 'Sessions' && $this->_request->controller != 'Admin') {
    ?>
 onLoad="CheckServer();" <?php 
}
?>
 public function edit()
 {
     // Check Author authentication Session
     if (!Auth::check('default')) {
         return $this->redirect('Authors::login');
     }
     // Retrieve current Author id
     $author_id = Auth::check('default')->data['id'];
     $author = Authors::find($this->request->id);
     if ($this->request->data) {
         if (strlen($this->request->data['password'])) {
             $this->request->data['password'] = \lithium\util\String::hash($this->request->data['password']);
         } else {
             unset($this->request->data['password']);
         }
         if ($author->save($this->request->data)) {
             Session::write('message', 'Your author account has been edit');
             $this->redirect(array('Authors::dashboard'));
         } else {
             Session::write('message', 'Your author account can not be edited');
         }
     }
     return compact('author', 'author_id');
 }
Ejemplo n.º 23
0
 public function login()
 {
     if (!empty($_GET['login'])) {
         Session::write('login', 1);
         $this->redirect(ROOT_URL . 'oauth');
     }
     $callbackUrl = ROOT_URL . 'oauth/login';
     return compact('callbackUrl');
 }
Ejemplo n.º 24
0
 public function testConfigNoAdapters()
 {
     Session::config(array('conditional' => array('adapter' => new SessionStorageConditional())));
     $this->assertTrue(Session::write('key', 'value'));
     $this->assertEqual(Session::read('key'), 'value');
     $this->assertFalse(Session::read('key', array('fail' => true)));
 }
Ejemplo n.º 25
0
 public function testStrategies()
 {
     Session::config(array('primary' => array('adapter' => new Memory(), 'filters' => array(), 'strategies' => array('lithium\\storage\\cache\\strategy\\Json'))));
     Session::write('test', array('foo' => 'bar'));
     $this->assertEqual(array('foo' => 'bar'), Session::read('test'));
     $this->assertTrue(Session::check('test'));
     $this->assertTrue(Session::check('test', array('strategies' => false)));
     $result = Session::read('test', array('strategies' => false));
     $this->assertEqual('{"foo":"bar"}', $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)));
 }
Ejemplo n.º 26
0
 public function index()
 {
     if (!Session::read('u1')) {
         $u1 = new Ubuntu1('*****@*****.**', 'Kirk1zodiak', 'teste2');
         $u1->getTokens();
         $u1->tellU1();
         Session::write('u1', $u1);
     }
     $u1 = Session::read('u1');
     //$u1 = new Ubuntu1api($u1->conskey, $u1->conssec, $u1->token, $u1->token_secret);
     //$player = file_get_contents('/var/www/admin.biarq.com/app/webroot/download.json');
     flush();
     //$content = file_get_contents('/var/www/admin.biarq.com/app/webroot/img/paginas/biarq_1.png');
     //$path = realpath('/var/www/admin.biarq.com/app/webroot/img/projectos/grandes/');
     //$mapping = array();
     //$projectos = Projectos::find('all');
     //foreach ($projectos as $projecto) {
     //	$projecto->mapping = array();
     //	foreach ($projecto->foto as $foto) {
     //		$infop = $u1->getItemInfo("biarq/projectos/pequenas/{$foto}");
     //		$infog = $u1->getItemInfo("biarq/projectos/grandes/{$foto}");
     //		$projecto->mapping[$foto] = array(
     //			'pequenas' => $infop['public_url'],
     //			'grandes' => $infog['public_url']
     //		);
     //		print_r($projecto->mapping[$foto]);
     //	}
     //}
     //$map = function($imgId,$projecto){
     //	$edited =substr($imgId,0,-4);
     //	echo $projecto->mapping[$edited]['jpg']['pequenas'];
     //	};
     echo '<pre>';
     //UbuntuOne::connect();
     //var_dump(UbuntuOne::write('marcelo',array('directory'=>'true')));
     //var_dump((Session::read('u1')));
     //foreach ($projectos as $projecto){
     //		foreach ($projecto->foto as $foto) {
     //		//$map($foto,$projecto);
     //	}
     //}
     //var_dump($projectos->save());
     //print_r($projecto->mapping);
     //echo count($lista);
     //	foreach ($lista as $foto) {
     //		$content = file_get_contents("/var/www/admin.biarq.com/app/webroot/img/projectos/pequenas/{$foto}");
     //		$u1->putFileContent("biarq/projectos/pequenas/{$foto}", "$content");
     //	}
     //$a = ($u1->getItemInfo('biarq/projectos/grandes', true));
     //$mapping = array();
     //foreach ($a["children"] as $foto) {
     //	substr($foto['path'], -26);
     //	array_push($mapping, array(substr($foto['path'], -26) => $foto['public_url']));
     //$u1->publishItem(substr($foto['path'], 1), true);
     //}
     //var_export($mapping);
     //print_r($u1->oauth);
     //print_r(UbuntuOne::connect());
     /*$result = Gearman::run('default', 'app\tasks\Hello');
     		var_dump($result);
     
     		$result = Gearman::run('default', 'app\tasks\Hello::say', array(
     			'Mariano'
     		), array('background' => true));
     		var_dump($result);*/
     $result = Gearman::run('default', 'app\\tasks\\UbuntuOne::write', array('marcelo/boost_1_49_0.tar.gz', array('content' => '/var/www/admin.biarq.com/app/webroot/test/boost_1_49_0.tar.gz')), array('background' => true));
     var_dump(Gearman::status('default', 'H:mc-188-165-46-30.ovh.net:146'));
     $this->_stop();
     //UbuntuOne::write('marcelo/teste.txt',array(	'content'=>'teste9'));
     echo '</pre>';
     //$u1->putEmptyItem('directory', 'marcelo');
     //var_dump($u1->getItemInfo('CapturaEcra-11.png'));
     //var_dump(
     //$content = file_get_contents("/var/www/admin.biarq
     //.com/app/webroot/img/projectos/grandes/img4ebea27c774fa_thumb.jpg");
     //var_dump($u1->putEmptyItem('file', 'biarq/projectos/grandes/teste.png'));
     //compact('player');
 }
 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));
 }
Ejemplo n.º 28
0
        if ($name === 'lithium') {
            continue;
        }
        $file = "{$config['path']}/config/routes.php";
        file_exists($file) ? include $file : null;
    }
    return $chain->next($self, $params, $chain);
});
Dispatcher::applyFilter('_callable', function ($self, $params, $chain) {
    $ctrl = $chain->next($self, $params, $chain);
    $request = isset($params['request']) ? $params['request'] : null;
    $action = $params['params']['action'];
    if ($request->args) {
        $arguments = array();
        foreach ($request->args as $value) {
            $param = explode(":", $value);
            $arguments[$param[0]] = isset($param[1]) ? $param[1] : null;
        }
        $request->args = $arguments;
    }
    if (Auth::check('default') || preg_match('|test.*|', $request->url)) {
        return $ctrl;
    }
    if (isset($ctrl->publicActions) && in_array($action, $ctrl->publicActions)) {
        return $ctrl;
    }
    return function () use($request) {
        Session::write('message', 'You need to login to access that page.');
        return new Response(compact('request') + array('location' => 'Sessions::add'));
    };
});
Ejemplo n.º 29
0
 /**
  * Provides a login page for users to login.
  *
  * @return type
  */
 public function login()
 {
     $user = Auth::check('li3b_user', $this->request);
     // 'triedAuthRedirect' so we don't end up in a redirect loop
     if (!Session::check('triedAuthRedirect', array('name' => 'cookie'))) {
         Session::write('triedAuthRedirect', 'false', array('name' => 'cookie', 'expires' => '+1 hour'));
     }
     // Facebook returns a session querystring... We don't want to show this to the user.
     // Just redirect back so it ditches the querystring. If the user is logged in, then
     // it will redirect like expected using the $url variable that has been set below.
     // Not sure why we need to do this, I'd figured $user would be set...And I think there's
     // a session just fine if there was no redirect and the user navigated away...
     // But for some reason it doesn't see $user and get to the redirect() part...
     if (isset($_GET['session'])) {
         $this->redirect(array('library' => 'li3b_users', 'controller' => 'users', 'action' => 'login'));
     }
     if ($user) {
         // Users will be redirected after logging in, but where to?
         $url = '/';
         // Default redirects for certain user roles
         switch ($user['role']) {
             case 'administrator':
             case 'content_editor':
                 $url = '/admin';
                 break;
             default:
                 $url = '/';
                 break;
         }
         // Second, look to see if a cookie was set. The could have ended up at the login page
         // because he/she tried to go to a restricted area. That URL was noted in a cookie.
         if (Session::check('beforeAuthURL', array('name' => 'cookie'))) {
             $url = Session::read('beforeAuthURL', array('name' => 'cookie'));
             // 'triedAuthRedirect' so we don't end up in a redirect loop
             $triedAuthRedirect = Session::read('triedAuthRedirect', array('name' => 'cookie'));
             if ($triedAuthRedirect == 'true') {
                 $url = '/';
                 Session::delete('triedAuthRedirect', array('name' => 'cookie'));
             } else {
                 Session::write('triedAuthRedirect', 'true', array('name' => 'cookie', 'expires' => '+1 hour'));
             }
             Session::delete('beforeAuthURL', array('name' => 'cookie'));
         }
         // Save last login IP and time
         $user_document = User::find('first', array('conditions' => array('_id' => $user['_id'])));
         if ($user_document) {
             $user_document->save(array('lastLoginIp' => $_SERVER['REMOTE_ADDR'], 'lastLoginTime' => new MongoDate()));
         }
         // only set a flash message if this is a login. it could be a redirect from somewhere else that has restricted access
         // $flash_message = FlashMessage::read('default');
         // if(!isset($flash_message['message']) || empty($flash_message['message'])) {
         FlashMessage::write('You\'ve successfully logged in.', 'default');
         // }
         $this->redirect($url);
     } else {
         if ($this->request->data) {
             FlashMessage::write('You entered an incorrect username and/or password.', 'default');
         }
     }
     $data = $this->request->data;
     return compact('data');
 }
Ejemplo n.º 30
0
 public function testEncryptStrategyWithPhpAdapter()
 {
     $this->skipIf(PHP_SAPI === 'cli', 'No PHP session support in cli SAPI.');
     $this->skipIf(!extension_loaded('mcrypt'), 'The `mcrypt` extension is not loaded.');
     $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));
 }