protected function clearPersistentData($key)
 {
     if (!in_array($key, self::$kSupportedKeys)) {
         self::errorLog('Unsupported key passed to clearPersistentData.');
         return;
     }
     $session_var_name = $this->constructSessionVariableName($key);
     Session::forget($session_var_name);
 }
 /**
  * Flash a general message to the session data.
  *
  * This method allows you to conveniently pass messages to views.
  *
  * <code>
  *		// Redirect and flash messages to the session
  *		return Redirect::to('item_list')->with_message('Your item was added.');
  *
  *    // Flash a message with a type
  *		return Redirect::to('item_list')->with_message('Your item was added.', 'success');
  * </code>
  * 
  * @param  string $text
  * @param  string $type
  * @return Redirect
  */
 public function with_message($text, $type = '')
 {
     $messages = Session::get('messages', new TypedMessages());
     $messages->add_typed($text, $type);
     Session::flash('messages', $messages);
     return $this;
 }
 /**
  * Define the "namespace" from session
  * */
 public function setSessionNamespace($namespace)
 {
     // Clear data for old session namespace
     Session::forget($this->namespace);
     $this->namespace = $namespace;
     return $this;
 }
Example #4
0
 /**
  * Sweep the expired sessions from storage.
  *
  * @param  array  $arguments
  * @return void
  */
 public function sweep($arguments = array())
 {
     $driver = Session::factory(Config::get('session.driver'));
     // If the driver implements the "Sweeper" interface, we know that it
     // can sweep expired sessions from storage. Not all drivers need be
     // sweepers since they do their own.
     if ($driver instanceof Sweeper) {
         $lifetime = Config::get('session.lifetime');
         $driver->sweep(time() - $lifetime * 60);
     }
     echo "The session table has been swept!";
 }
Example #5
0
 public function __construct()
 {
     // If a session driver has been specified, we will bind an instance of the
     // module error message container. If an error instance
     // exists in the session, we will use that instance.
     if (!isset(static::$errors)) {
         if (Session::started() and Session::has('errors')) {
             static::$errors = Session::get('errors');
         } else {
             static::$errors = new Messages();
         }
     }
 }
 public function __construct($view, $data = array())
 {
     parent::__construct($view, $data);
     // If a session driver has been specified, we will bind an instance of the
     // message container to every view. If a container instance
     // exists in the session, we will use that instance.
     $key = 'messages';
     if (!isset($this->data[$key])) {
         if (Session::started() and Session::has($key)) {
             $this->data[$key] = Session::get($key);
         } else {
             $this->data[$key] = new TypedMessages();
         }
     }
 }
Example #7
0
 /**
  * Create a new view instance.
  *
  * <code>
  *		// Create a new view instance
  *		$view = new View('home.index');
  *
  *		// Create a new view instance of a bundle's view
  *		$view = new View('admin::home.index');
  *
  *		// Create a new view instance with bound data
  *		$view = new View('home.index', array('name' => 'Taylor'));
  * </code>
  *
  * @param  string  $view
  * @param  array   $data
  * @return void
  */
 public function __construct($view, $data = array())
 {
     $this->view = $view;
     $this->data = $data;
     $this->path = $this->path($view);
     // If a session driver has been specified, we will bind an instance of the
     // validation error message container to every view. If an errors instance
     // exists in the session, we will use that instance.
     //
     // This makes error display in the view extremely convenient, since the
     // developer can always assume they have a message container instance
     // available to them in the view's variables.
     if (!isset($this->data['errors'])) {
         if (Session::started() and Session::has('errors')) {
             $this->data['errors'] = Session::get('errors');
         } else {
             $this->data['errors'] = new Messages();
         }
     }
 }
 /**
  * Create a new view instance.
  *
  * <code>
  *		// Create a new view instance
  *		$view = new View('home.index');
  *
  *		// Create a new view instance of a bundle's view
  *		$view = new View('admin::home.index');
  *
  *		// Create a new view instance with bound data
  *		$view = new View('home.index', array('name' => 'Taylor'));
  * </code>
  *
  * @param  string  $view
  * @param  array   $data
  * @return void
  */
 public function __construct($view, $data = array())
 {
     $this->view = $view;
     $this->data = $data;
     // In order to allow developers to load views outside of the normal loading
     // conventions, we'll allow for a raw path to be given in place of the
     // typical view name, giving total freedom on view loading.
     if (starts_with($view, 'path: ')) {
         $this->path = substr($view, 6);
     } else {
         $this->path = $this->path($view);
     }
     // If a session driver has been specified, we will bind an instance of the
     // validation error message container to every view. If an error instance
     // exists in the session, we will use that instance.
     if (!isset($this->data['errors'])) {
         if (Session::started() and Session::has('errors')) {
             $this->data['errors'] = Session::get('errors');
         } else {
             $this->data['errors'] = new Messages();
         }
     }
 }
 public static function calcSessionQuotationCurrentValue($upTo)
 {
     $price = 0;
     // Init stage
     $layout = \Laravel\Session::get('quote_layout');
     $price = $layout->cost;
     $deliveryData = self::calcDeliver();
     $price = $price + $deliveryData['price'];
     if ($upTo == "init") {
         return (double) $price;
     }
     // Customise stage - Stage 1
     $price = $price + \Laravel\Session::get('quote_customise_swap_window', 0) * QuotationPriceAdjustments::getPrice('swap_window_wall');
     $price = $price + \Laravel\Session::get('quote_customise_swap_wall', 0) * QuotationPriceAdjustments::getPrice('swap_wall_window');
     $price = $price + \Laravel\Session::get('quote_customise_extra_door', 0) * QuotationPriceAdjustments::getPrice('add_extra_door');
     $price = $price + \Laravel\Session::get('quote_customise_fanlight', 0) * QuotationPriceAdjustments::getPrice('add_fanlight_window');
     $price = $price + \Laravel\Session::get('quote_customise_half_window', 0) * QuotationPriceAdjustments::getPrice('add_half_window');
     $price = $price + \Laravel\Session::get('quote_customise_picture_window', 0) * QuotationPriceAdjustments::getPrice('add_1820_window');
     if ($upTo == "customise") {
         return (double) $price;
     }
     // Decking / Flyover stage - Stage 2
     $price = $price + \Laravel\Session::get('quote_decking_composite_deck_910_910', 0) * QuotationPriceAdjustments::getPrice('composite_deck_910_910');
     $price = $price + \Laravel\Session::get('quote_decking_composite_deck_910_1820', 0) * QuotationPriceAdjustments::getPrice('composite_deck_910_1820');
     $price = $price + \Laravel\Session::get('quote_decking_composite_deck_910_2730', 0) * QuotationPriceAdjustments::getPrice('composite_deck_910_2730');
     $price = $price + \Laravel\Session::get('quote_decking_flyover_roof_910_910', 0) * QuotationPriceAdjustments::getPrice('flyover_roof_910_910');
     $price = $price + \Laravel\Session::get('quote_decking_flyover_roof_910_1820', 0) * QuotationPriceAdjustments::getPrice('flyover_roof_910_1820');
     $price = $price + \Laravel\Session::get('quote_decking_flyover_roof_910_2730', 0) * QuotationPriceAdjustments::getPrice('flyover_roof_910_2730');
     if ($upTo == "deckingflyover") {
         return (double) $price;
     }
     // Electrics stage - Stage 3
     $price = $price + \Laravel\Session::get('quote_electrics_double_sockets_450', 0) * QuotationPriceAdjustments::getPrice('electrics_double_sockets_450');
     $price = $price + \Laravel\Session::get('quote_electrics_double_sockets_1150', 0) * QuotationPriceAdjustments::getPrice('electrics_double_sockets_1150');
     $price = $price + \Laravel\Session::get('quote_electrics_light_switch', 0) * QuotationPriceAdjustments::getPrice('electrics_light_switch');
     $price = $price + \Laravel\Session::get('quote_electrics_panel_heater', 0) * QuotationPriceAdjustments::getPrice('electrics_panel_heater');
     $price = $price + \Laravel\Session::get('quote_electrics_double_floor_socket', 0) * QuotationPriceAdjustments::getPrice('electrics_double_floor_socket');
     $price = $price + \Laravel\Session::get('quote_electrics_fused_spur_socket', 0) * QuotationPriceAdjustments::getPrice('electrics_fused_spur_socket');
     if ($upTo == "electrics") {
         return (double) $price;
     }
     // Electrics stage - Stage 4
     $price = $price + \Laravel\Session::get('quote_internals_silver_aluminium_venitian_blind_no_screws', 0) * QuotationPriceAdjustments::getPrice('silver_aluminium_venitian_blind_no_screws');
     $price = $price + \Laravel\Session::get('quote_internals_recessed_blinds', 0) * QuotationPriceAdjustments::getPrice('recessed_blinds');
     $price = $price + \Laravel\Session::get('quote_internals_internal_910_partition_wall', 0) * QuotationPriceAdjustments::getPrice('internal_910_partition_wall');
     $price = $price + \Laravel\Session::get('quote_internals_internal_door_dividing_studio', 0) * QuotationPriceAdjustments::getPrice('internal_door_dividing_studio');
     $price = $price + \Laravel\Session::get('quote_internals_internal_wall_corner_post', 0) * QuotationPriceAdjustments::getPrice('internal_wall_corner_post');
     if ($upTo == "interior") {
         return (double) $price;
     }
     // Other stage - Stage 5
     $price = $price + \Laravel\Session::get('quote_other_decoupled_floor', 0) * QuotationPriceAdjustments::getPrice('other_decoupled_floor');
     $price = $price + \Laravel\Session::get('quote_other_aquastep_oak_floor', 0) * QuotationPriceAdjustments::getPrice('other_aquastep_oak_floor');
     $price = $price + \Laravel\Session::get('quote_other_walls_to_timber', 0) * QuotationPriceAdjustments::getPrice('other_walls_to_timber');
     $price = $price + \Laravel\Session::get('quote_other_taller_walls', 0) * QuotationPriceAdjustments::getPrice('other_taller_walls');
     $price = $price + \Laravel\Session::get('quote_other_entry_steps', 0) * QuotationPriceAdjustments::getPrice('other_entry_steps');
     $price = $price + \Laravel\Session::get('quote_other_entry_handrail', 0) * QuotationPriceAdjustments::getPrice('other_entry_handrail');
     $price = $price + \Laravel\Session::get('quote_other_skirt', 0) * QuotationPriceAdjustments::getPrice('other_skirt');
     if ($upTo == "other") {
         return (double) $price;
     }
     return $price;
 }
 /**
  * Test the Auth::logout method.
  *
  * @group laravel
  */
 public function testLogoutMethodLogsOutUser()
 {
     Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
     $data = Session::$instance->session['data']['laravel_auth_drivers_fluent_login'] = 1;
     Auth::logout();
     $this->assertNull(Auth::user());
     $this->assertFalse(isset(Session::$instance->session['data']['laravel_auth_drivers_fluent_login']));
     $this->assertTrue(Cookie::$jar['laravel_auth_drivers_fluent_remember']['expiration'] < time());
 }
Example #11
0
 /**
  * Store a user's token in the session.
  *
  * @param  string  $token
  * @return void
  */
 protected function store($token)
 {
     Session::put($this->token(), $token);
 }
Example #12
0
 /**
  * __construct
  *
  * @return void
  */
 public function __construct()
 {
     $this->errors = Session::has('errors') ? Session::get('errors') : new Messages();
 }
Example #13
0
 public static function required_database_version($type = 'mysql', $version = '5.0')
 {
     // Server version
     if ($type == 'mysql') {
         // Retrieve the database settings from the session
         $server = Session::get('mysql_hostname') . ':' . Session::get('mysql_port');
         $username = Session::get('mysql_username');
         $password = Session::get('mysql_password');
         if (empty($port) or !is_integer($port)) {
             $port = 3306;
         }
         if (!empty($server) and !empty($username) and !empty($password)) {
             // Connect to MySQL
             if ($db = @mysql_connect($server, $username, $password)) {
                 //self::$mysql_server_version = @mysql_get_server_info($db);
                 $mysql_server_version = preg_replace('/[^0-9\\.]/', '', @mysql_get_server_info($db));
                 // Close the connection
                 @mysql_close($db);
                 // If the MySQL server version is at least version 5 return TRUE, else FALSE
                 return $mysql_server_version >= $version ? TRUE : FALSE;
             } else {
                 @mysql_close($db);
                 return false;
             }
         }
         return false;
     }
     if ($type == 'posertgere') {
         return false;
     }
 }
Example #14
0
 private static function _do_user($user)
 {
     // Set the user.
     unset($user['UsersPassword']);
     Me::set($user);
     // Set the account.
     $account_id = Session::get('AccountId');
     Me::set_account(\Accounts::get_by_id($account_id));
 }
Example #15
0
| content and sets the raw string result as the new response.
|
*/
$response->render();
/*
|--------------------------------------------------------------------------
| Persist The Session To Storage
|--------------------------------------------------------------------------
|
| If a session driver has been configured, we will save the session to
| storage so it is available for the next request. This will also set
| the session cookie in the cookie jar to be sent to the user.
|
*/
if (Config::get('session.driver') !== '') {
    Session::save();
}
/*
|--------------------------------------------------------------------------
| Send The Response To The Browser
|--------------------------------------------------------------------------
|
| We'll send the response back to the browser here. This method will also
| send all of the response headers to the browser as well as the string
| content of the Response. This should make the view available to the
| browser and show something pretty to the user.
|
*/
$response->send();
/*
|--------------------------------------------------------------------------
 private function loadQuote(Quotation $quote)
 {
     // Find layout
     $layout = Layout::find($quote->quotation_layouts_id);
     $customer = Customer::find($quote->customer_id);
     // Init
     \Laravel\Session::put('quote_id', $quote->id);
     \Laravel\Session::put('quote_email', $customer->email);
     \Laravel\Session::put('quote_layout', $layout);
     \Laravel\Session::put('quote_layout_id', $layout->id);
     \Laravel\Session::put('quote_size', $layout->size_x . 'x' . $layout->size_y);
     \Laravel\Session::put('quote_postcode', $quote->postcode);
     //Customise
     \Laravel\Session::put('quote_customise_swap_window', $quote->quote_customise_swap_window);
     \Laravel\Session::put('quote_customise_swap_wall', $quote->quote_customise_swap_wall);
     \Laravel\Session::put('quote_customise_extra_door', $quote->quote_customise_extra_door);
     \Laravel\Session::put('quote_customise_fanlight', $quote->quote_customise_fanlight);
     \Laravel\Session::put('quote_customise_half_window', $quote->quote_customise_half_window);
     \Laravel\Session::put('quote_customise_picture_window', $quote->quote_customise_picture_window);
     //Decking & floyover
     \Laravel\Session::put('quote_decking_composite_deck_910_910', $quote->quote_decking_composite_deck_910_910);
     \Laravel\Session::put('quote_decking_composite_deck_910_1820', $quote->quote_decking_composite_deck_910_1820);
     \Laravel\Session::put('quote_decking_composite_deck_910_2730', $quote->quote_decking_composite_deck_910_2730);
     \Laravel\Session::put('quote_decking_flyover_roof_910_910', $quote->quote_decking_flyover_roof_910_910);
     \Laravel\Session::put('quote_decking_flyover_roof_910_1820', $quote->quote_decking_flyover_roof_910_1820);
     \Laravel\Session::put('quote_decking_flyover_roof_910_2730', $quote->quote_decking_flyover_roof_910_2730);
     // Electrics
     \Laravel\Session::put('quote_electrics_double_sockets_450', $quote->quote_electrics_double_sockets_450);
     \Laravel\Session::put('quote_electrics_double_sockets_1150', $quote->quote_electrics_double_sockets_1150);
     \Laravel\Session::put('quote_electrics_light_switch', $quote->quote_electrics_light_switch);
     \Laravel\Session::put('quote_electrics_panel_heater', $quote->quote_electrics_panel_heater);
     \Laravel\Session::put('quote_electrics_double_floor_socket', $quote->quote_electrics_double_floor_socket);
     \Laravel\Session::put('quote_electrics_fused_spur_socket', $quote->quote_electrics_fused_spur_socket);
     // Internals
     \Laravel\Session::put('quote_internals_silver_aluminium_venitian_blind_no_screws', $quote->quote_internals_silver_aluminium_venitian_blind_no_screws);
     \Laravel\Session::put('quote_internals_recessed_blinds', $quote->quote_internals_recessed_blinds);
     \Laravel\Session::put('quote_internals_internal_910_partition_wall', $quote->quote_internals_internal_910_partition_wall);
     \Laravel\Session::put('quote_internals_internal_door_dividing_studio', $quote->quote_internals_internal_door_dividing_studio);
     \Laravel\Session::put('quote_internals_internal_wall_corner_post', $quote->quote_internals_internal_wall_corner_post);
     // Other
     \Laravel\Session::put('quote_other_decoupled_floor', $quote->quote_other_decoupled_floor);
     \Laravel\Session::put('quote_other_aquastep_oak_floor', $quote->quote_other_aquastep_oak_floor);
     \Laravel\Session::put('quote_other_walls_to_timber', $quote->quote_other_walls_to_timber);
     \Laravel\Session::put('quote_other_taller_walls', $quote->quote_other_taller_walls);
     \Laravel\Session::put('quote_other_entry_steps', $quote->quote_other_entry_steps);
     \Laravel\Session::put('quote_other_entry_handrail', $quote->quote_other_entry_handrail);
     \Laravel\Session::put('quote_other_skirt', $quote->quote_other_skirt);
 }
Example #17
0
 public function validate_test_db_connection()
 {
     $this->adm_lang = Session::get('adm_lang');
     $this->messages['test_db_connection'] = __('install::lang.Unable to connect to database')->get($this->adm_lang);
     return Installer::test_db_connection(Input::all());
 }
Example #18
0
 /**
  * Test the Session::started method.
  *
  * @group laravel
  */
 public function testStartedMethodIndicatesIfSessionIsStarted()
 {
     $this->assertFalse(Session::started());
     Session::$instance = 'foo';
     $this->assertTrue(Session::started());
 }
Example #19
0
 /**
  * Create a new module instance.
  *
  * <code>
  *      // Create a new module instance
  *      $module = new Modules\Module('registration');
  *
  *      // Create a new module instance with a path
  *      $module = new Modules\Module('registration', 'registration/extended');
  *
  *      // Create a new module instance with a full path
  *      $module = new Modules\Module('registration', 'path: /var/www/project/registration');
  * </code>
  *
  * @param  string  $module
  * @param  string  $path
  * @return void
  */
 public function __construct($module_slug, $path = null)
 {
     $this->slug = $module_slug;
     $ins = \Laravel\Config::get('installed_modules.' . $module_slug);
     $this->installed = isset($ins) and !empty($ins) ? true : false;
     $this->enabled = \Laravel\Bundle::exists($this->slug);
     $this->installer = Installer::make($module_slug);
     // if path starts with "path: "
     // its a custom path
     if (!isset($path)) {
         $this->path = path('bundle') . $this->slug . DS;
     } else {
         if (starts_with($path, 'path: ')) {
             $this->path = substr($path, 6);
         } else {
             // sets the path to modules
             // folder + path
             // module with different folder name?
             $this->path = path('bundle') . $path;
         }
     }
     // If a session driver has been specified, we will bind an instance of the
     // module error message container. If an error instance
     // exists in the session, we will use that instance.
     if (!isset($this->errors)) {
         if (Session::started() and Session::has('errors')) {
             $this->errors = Session::get('errors');
         } else {
             $this->errors = new Messages();
         }
     }
 }
Example #20
0
 /**
  * Create a fresh session array with a unique ID.
  *
  * @return array
  */
 public function fresh()
 {
     // Fetch a guest session with the same IP address
     $old_guest_session = $this->table()->where_user_id(1)->where_last_ip(Request::ip())->first();
     // We will simply generate an empty session payload array, using an ID
     // that is either not currently assigned to any existing session or
     // that belongs to a guest with the same IP address.
     if (is_null($old_guest_session)) {
         $id = $this->id();
     } else {
         $id = $old_guest_session->id;
         Session::instance()->exists = true;
     }
     return array('id' => $id, 'data' => array(':new:' => array(), ':old:' => array()));
 }
Example #21
0
 /**
  * Empty persistent form field_data.
  */
 public static function forget_input()
 {
     // remove the persistent form data FOR-EV-ER, FOR-EV-ER, FOR..
     Session::forget('serialized_field_data[' . get_called_class() . ']');
 }
Example #22
0
 /**
  * Empties the cart, and removes the session.
  *
  * @access   public
  * @return   void
  */
 public function destroy()
 {
     // Remove all the data from the cart and set some base values
     //
     array_set($this->cart_contents, $this->cart_name, array('cart_total' => 0, 'total_items' => 0));
     // Remove the session.
     //
     Session::forget($this->cart_name);
 }
Example #23
0
 /**
  * Add an item to the session flash data.
  *
  * This is useful for "passing" status messages or other data to the next request.
  *
  * <code>
  *		// Create a redirect response and flash to the session
  *		return Redirect::to('profile')->with('message', 'Welcome Back!');
  * </code>
  *
  * @param  string          $key
  * @param  mixed           $value
  * @return Redirect
  */
 public function with($key, $value)
 {
     if (Config::get('session.driver') == '') {
         throw new \Exception('A session driver must be set before setting flash data.');
     }
     Session::flash($key, $value);
     return $this;
 }
Example #24
0
 public function getOpenChats()
 {
     // TODO: Remove hack
     $chats = Session::get('chats', array(2));
     // Testing hack
     $chats_content = array();
     foreach ($chats as $chat) {
         $chats_content[$chat] = $this->messages($chat)->get();
     }
     return $chats_content;
 }
Example #25
0
 /**
  * Determine if the request has been forged.
  *
  * The session CSRF token will be compared to the CSRF token in the request input.
  *
  * @return bool
  */
 public static function forged()
 {
     return Input::get(Session::csrf_token) !== Session::token();
 }
Example #26
0
 /**
  * Add a notification of any sort
  *
  * @param  string  	$type
  * @param  string  	$message
  * @param  int  	$time
  * @param  boolean  $close
  * @return void
  */
 protected static function add($type, $message, $time, $close)
 {
     static::$notifications[] = array('type' => $type, 'message' => $message, 'time' => $time, 'close' => $close);
     Session::flash('notifications', static::$notifications);
 }
Example #27
0
 /**
  * Test the Auth::logout method.
  *
  * @group laravel
  */
 public function testLogoutMethodLogsOutUser()
 {
     Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
     $data = Session::$instance->session['data']['laravel_auth_drivers_fluent_login'] = 1;
     Auth::logout();
     // A workaround since Cookie will is only stored in memory, until Response class is called.
     Auth::driver()->token = null;
     $this->assertNull(Auth::user());
     $this->assertFalse(isset(Session::$instance->session['data']['laravel_auth_drivers_fluent_login']));
     $this->assertTrue(Cookie::$jar['laravel_auth_drivers_fluent_remember']['expiration'] < time());
 }
Example #28
0
 /**
  * Test `laravel.auth: login` and `laravel.auth: logout` is called properly
  *
  * @group laravel
  */
 public function testAuthEventIsCalledProperly()
 {
     Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
     Event::listen('laravel.auth: login', function () {
         $_SERVER['test.user.login'] = '******';
     });
     Event::listen('laravel.auth: logout', function () {
         $_SERVER['test.user.logout'] = 'foo';
     });
     $this->assertNull($_SERVER['test.user.login']);
     $this->assertNull($_SERVER['test.user.logout']);
     Auth::login(1, true);
     $this->assertEquals('foo', $_SERVER['test.user.login']);
     Auth::logout();
     $this->assertEquals('foo', $_SERVER['test.user.logout']);
 }