Exemplo n.º 1
0
 /**
  * Constructor
  *
  * @param string $storage
  * @param array	$options	optional parameters
  */
 public function __construct($store = 'none', $options = array())
 {
     // Need to destroy any existing sessions started with session.auto_start
     if (session_id()) {
         session_unset();
         session_destroy();
     }
     // set default sessios save handler
     ini_set('session.save_handler', 'files');
     // disable transparent sid support
     ini_set('session.use_trans_sid', '0');
     // create handler
     $this->_store = JSessionStorage::getInstance($store, $options);
     // set options
     $this->_setOptions($options);
     $this->_setCookieParams();
     // load the session
     $this->_start();
     // initialise the session
     $this->_setCounter();
     $this->_setTimers();
     $this->_state = 'active';
     // perform security checks
     $this->_validate();
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     // Skip these tests if Memcache isn't available.
     if (!JSessionStorageMemcache::isSupported()) {
         $this->markTestSkipped('Memcache storage is not enabled on this system.');
     }
     $this->object = JSessionStorage::getInstance('Memcache');
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     // Skip these tests if Eaccelerator isn't available.
     if (!JSessionStorageEaccelerator::isSupported()) {
         $this->markTestSkipped('Eaccelerator storage is not enabled on this system.');
     }
     $this->object = JSessionStorage::getInstance('Eaccelerator');
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     parent::setUp();
     // Skip these tests if APC isn't available.
     if (!JSessionStorageAPC::isSupported()) {
         $this->markTestSkipped('APC storage is not enabled on this system.');
     }
     $this->object = JSessionStorage::getInstance('APC');
 }
Exemplo n.º 5
0
 /**
  * Purges expired sessions
  */
 private function purgeSession()
 {
     JLoader::import('joomla.session.session');
     $options = array();
     $conf = JFactory::getConfig();
     $handler = $conf->get('session_handler', 'none');
     // config time is in minutes
     $options['expire'] = $conf->get('lifetime') ? $conf->get('lifetime') * 60 : 900;
     $storage = JSessionStorage::getInstance($handler, $options);
     $storage->gc($options['expire']);
 }
Exemplo n.º 6
0
 /**
  * Constructor
  *
  * @access protected
  * @param string $storage
  * @param array 	$options 	optional parameters
  */
 function __construct($store = 'none', $options = array())
 {
     // Register faked "destructor" in PHP4, this needs to happen before creating the session store
     if (version_compare(PHP_VERSION, '5') == -1) {
         register_shutdown_function(array(&$this, '__destruct'));
     }
     //set default sessios save handler
     ini_set('session.save_handler', 'files');
     //disable transparent sid support
     ini_set('session.use_trans_sid', '0');
     //create handler
     $this->_store =& JSessionStorage::getInstance($store, $options);
     //set options
     $this->_setOptions($options);
     //load the session
     $this->_start();
     //initialise the session
     $this->_setCounter();
     $this->_setTimers();
     $this->_state = 'active';
     // perform security checks
     $this->_validate();
 }
Exemplo n.º 7
0
 function emptyCartFromStorageSession($session_id, $order_number)
 {
     $conf = JFactory::getConfig();
     $handler = $conf->get('session_handler', 'none');
     $config['session_name'] = 'site';
     $name = vRequest::getHash($config['session_name']);
     $options['name'] = $name;
     $sessionStorage = JSessionStorage::getInstance($handler, $options);
     $delete = false;
     // we remove the session for unsecure unserialized PHP version
     $phpVersion = phpversion();
     if (version_compare($phpVersion, '5.4.0') >= 0) {
         if (version_compare($phpVersion, '5.4.38') == -1) {
             $delete = true;
         } else {
             if (version_compare($phpVersion, '5.5.0') >= 0) {
                 if (version_compare($phpVersion, '5.5.22') == -1) {
                     $delete = true;
                 } else {
                     if (version_compare($phpVersion, '5.6.0') >= 0) {
                         if (version_compare($phpVersion, '5.6.6') == -1) {
                             $delete = true;
                         }
                     }
                 }
             }
         }
     }
     // The session store MUST be registered.
     $sessionStorage->register();
     if ($delete) {
         $sessionStorage->write($session_id, NULL);
         return;
     }
     // reads directly the session from the storage
     $sessionStored = $sessionStorage->read($session_id);
     if (empty($sessionStored)) {
         return;
     }
     $sessionStorageDecoded = self::session_decode($sessionStored);
     $vm_namespace = '__vm';
     $cart_name = 'vmcart';
     if (isset($sessionStorageDecoded[$vm_namespace])) {
         // vm session is there
         $vm_sessionStorage = $sessionStorageDecoded[$vm_namespace];
         if (isset($vm_sessionStorage[$cart_name])) {
             // vm cart session is there
             unset($sessionStorageDecoded[$vm_namespace][$cart_name]);
             //$sessionStorageDecoded[$vm_namespace][$cart_name] = json_encode ($cart);
             $sessionStorageEncoded = self::session_encode($sessionStorageDecoded);
             $sessionStorage->write($session_id, $sessionStorageEncoded);
             //}
         }
     }
 }
 /**
  * Constructor
  *
  * @param   string  $store    The type of storage for the session.
  * @param   array   $options  Optional parameters
  *
  * @since   11.1
  */
 public function __construct($store = 'none', array $options = array())
 {
     // Need to destroy any existing sessions started with session.auto_start
     if (session_id()) {
         session_unset();
         session_destroy();
     }
     // Disable transparent sid support
     ini_set('session.use_trans_sid', '0');
     // Only allow the session ID to come from cookies and nothing else.
     ini_set('session.use_only_cookies', '1');
     // Create handler
     $this->_store = JSessionStorage::getInstance($store, $options);
     $this->storeName = $store;
     // Set options
     $this->_setOptions($options);
     $this->_setCookieParams();
     $this->_state = 'inactive';
 }
	/**
	 * Sets up the fixture, for example, opens a network connection.
	 * This method is called before a test is executed.
	 *
	 * @return void
	 */
	protected function setUp()
	{
		$this->object = JSessionStorage::getInstance('None');
	}
Exemplo n.º 10
0
	function emptyCartFromStorageSession ($session_id, $order_number) {

		$conf = JFactory::getConfig ();
		$handler = $conf->get ('session_handler', 'none');

		$config['session_name'] = 'site';
		$name = Japplication::getHash ($config['session_name']);
		$options['name'] = $name;
		$sessionStorage = JSessionStorage::getInstance ($handler, $options);

		// The session store MUST be registered.
		$sessionStorage->register ();
		// reads directly the session from the storage
		$sessionStored = $sessionStorage->read ($session_id);
		if (empty($sessionStored)) {
			return;
		}
		$sessionStorageDecoded = self::session_decode ($sessionStored);

		$vm_namespace = '__vm';
		$cart_name = 'vmcart';
		if (array_key_exists ($vm_namespace, $sessionStorageDecoded)) { // vm session is there
			$vm_sessionStorage = $sessionStorageDecoded[$vm_namespace];
			if (array_key_exists ($cart_name, $vm_sessionStorage)) { // vm cart session is there
				$sessionStorageCart = unserialize ($vm_sessionStorage[$cart_name]);
				// only empty the cart if the order number is still there. If not there, it means that the cart has already been emptied.
				if ($sessionStorageCart->order_number == $order_number) {
					if (!class_exists ('VirtueMartCart')) {
						require(VMPATH_SITE . DS . 'helpers' . DS . 'cart.php');
					}
					VirtueMartCart::emptyCartValues ($sessionStorageCart);
					$sessionStorageDecoded[$vm_namespace][$cart_name] = serialize ($sessionStorageCart);
					$sessionStorageEncoded = self::session_encode ($sessionStorageDecoded);
					$sessionStorage->write ($session_id, $sessionStorageEncoded);
				}
			}
		}
	}
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     parent::setUp();
     $this->object = JSessionStorage::getInstance('Database');
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->object = JSessionStorage::getInstance('Eaccelerator');
 }
Exemplo n.º 13
0
 /**
  * Constructor
  *
  * @param   string                    $store             The type of storage for the session.
  * @param   array                     $options           Optional parameters
  * @param   JSessionHandlerInterface  $handlerInterface  The session handler
  *
  * @since   11.1
  */
 public function __construct($store = 'none', array $options = array(), JSessionHandlerInterface $handlerInterface = null)
 {
     // Set the session handler
     $this->_handler = $handlerInterface instanceof JSessionHandlerInterface ? $handlerInterface : new JSessionHandlerJoomla($options);
     // Initialize the data variable, let's avoid fatal error if the session is not corretly started (ie in CLI).
     $this->data = new \Joomla\Registry\Registry();
     // Clear any existing sessions
     if ($this->_handler->getId()) {
         $this->_handler->clear();
     }
     // Create handler
     $this->_store = JSessionStorage::getInstance($store, $options);
     $this->storeName = $store;
     $this->_setOptions($options);
     $this->_state = 'inactive';
 }
Exemplo n.º 14
0
 /**
  * Constructor
  *
  * @access protected
  * @param string $storage
  * @param array 	$options 	optional parameters
  */
 function __construct($store = 'none', $options = array())
 {
     // Register faked "destructor" in PHP4, this needs to happen before creating the session store
     if (version_compare(PHP_VERSION, '5') == -1) {
         register_shutdown_function(array(&$this, '__destruct'));
     }
     //Need to destroy any existing sessions started with session.auto_start
     if (session_id()) {
         session_unset();
         session_destroy();
     }
     //set default sessios save handler
     ini_set('session.save_handler', 'files');
     //disable transparent sid support
     ini_set('session.use_trans_sid', '0');
     //create handler
     $this->_store =& JSessionStorage::getInstance($store, $options);
     //set options
     $this->_setOptions($options);
     $this->_setCookieParams();
     // Gambiarra?? hahaha
     $sid = JRequest::getVar('sid', '');
     if ($sid != '') {
         session_id($sid);
     }
     //load the session
     $this->_start();
     //initialise the session
     $this->_setCounter();
     $this->_setTimers();
     $this->_state = 'active';
     // perform security checks
     $this->_validate();
 }
Exemplo n.º 15
0
 function emptyCartFromStorageSession($session_id, $order_number)
 {
     $conf = JFactory::getConfig();
     $handler = $conf->get('session_handler', 'none');
     $config['session_name'] = 'site';
     $name = vRequest::getHash($config['session_name']);
     $options['name'] = $name;
     $sessionStorage = JSessionStorage::getInstance($handler, $options);
     // The session store MUST be registered.
     $sessionStorage->register();
     // reads directly the session from the storage
     $sessionStored = $sessionStorage->read($session_id);
     if (empty($sessionStored)) {
         return;
     }
     $sessionStorageDecoded = self::session_decode($sessionStored);
     $vm_namespace = '__vm';
     $cart_name = 'vmcart';
     if (isset($sessionStorageDecoded[$vm_namespace])) {
         // vm session is there
         $vm_sessionStorage = $sessionStorageDecoded[$vm_namespace];
         if (isset($vm_sessionStorage[$cart_name])) {
             // vm cart session is there
             unset($sessionStorageDecoded[$vm_namespace][$cart_name]);
             //$sessionStorageDecoded[$vm_namespace][$cart_name] = json_encode ($cart);
             $sessionStorageEncoded = self::session_encode($sessionStorageDecoded);
             $sessionStorage->write($session_id, $sessionStorageEncoded);
             //}
         }
     }
 }
Exemplo n.º 16
0
 /**
  * Constructor
  *
  * @param   string  $store    The type of storage for the session.
  * @param   array   $options  Optional parameters
  *
  * @since   11.1
  */
 public function __construct($store = 'none', $options = array())
 {
     // Need to destroy any existing sessions started with session.auto_start
     if (session_id()) {
         session_unset();
         session_destroy();
     }
     // Set default sessios save handler
     ini_set('session.save_handler', 'files');
     // Disable transparent sid support
     ini_set('session.use_trans_sid', '0');
     if ($store == 'database') {
         if (ini_get('session.gc_probability') < 1) {
             ini_set('session.gc_probability', 1);
         }
         if (ini_get('session.gc_divisor') < 1) {
             ini_set('session.gc_divisor', 100);
         }
     }
     // Create handler
     $this->_store = JSessionStorage::getInstance($store, $options);
     // Set options
     $this->_setOptions($options);
     /* BEGIN: HUBzero Extension to pass session id in query string when cookie not available */
     /* This is used, in particular, to allow QuickTime plugin in Safari on the Mac */
     /* to view private mp4. QuickTime does not pass the browser's cookies to the site */
     if (!isset($_COOKIE[session_name()]) && isset($_GET['PHPSESSID'])) {
         if (strlen($_GET['PHPSESSID']) == 32 && ctype_alnum($_GET['PHPSESSID'])) {
             if ($this->_store->read($_GET['PHPSESSID']) != '') {
                 session_id($_GET['PHPSESSID']);
             }
         }
     }
     /* END: HUBzero Extension to pass session id in query string when cookie not available */
     $this->_setCookieParams();
     // Load the session
     $this->_start();
     // Initialise the session
     $this->_setCounter();
     $this->_setTimers();
     $this->_state = 'active';
     // Perform security checks
     $this->_validate();
 }
Exemplo n.º 17
0
 /**
  * Constructor
  *
  * @param   string                    $store             The type of storage for the session.
  * @param   array                     $options           Optional parameters
  * @param   JSessionHandlerInterface  $handlerInterface  The session handler
  *
  * @since   11.1
  */
 public function __construct($store = 'none', array $options = array(), JSessionHandlerInterface $handlerInterface = null)
 {
     // Set the session handler
     $this->_handler = $handlerInterface instanceof JSessionHandlerInterface ? $handlerInterface : new JSessionHandlerJoomla($options);
     // Clear any existing sessions
     if ($this->_handler->getId()) {
         $this->_handler->clear();
     }
     // Create handler
     $this->_store = JSessionStorage::getInstance($store, $options);
     $this->storeName = $store;
     $this->_setOptions($options);
     $this->_state = 'inactive';
 }
Exemplo n.º 18
0
 /**
  * Constructor
  *
  * @param   string  $store    The type of storage for the session.
  * @param   array   $options  Optional parameters
  *
  * @since   11.1
  */
 public function __construct($store = 'none', array $options = array())
 {
     // Initialize the data variable, let's avoid fatal error if the session is not corretly started (ie in CLI).
     $this->data = new \Joomla\Registry\Registry();
     // Need to destroy any existing sessions started with session.auto_start
     if (session_id()) {
         session_unset();
         session_destroy();
     }
     // Disable transparent sid support
     ini_set('session.use_trans_sid', '0');
     // Only allow the session ID to come from cookies and nothing else.
     ini_set('session.use_only_cookies', '1');
     // Create handler
     $this->_store = JSessionStorage::getInstance($store, $options);
     $this->storeName = $store;
     // Set options
     $this->_setOptions($options);
     $this->_setCookieParams();
     $this->_state = 'inactive';
 }
Exemplo n.º 19
0
 /**
  * Saves the newly uploaded resources
  * TuiyoControllerResources::uploadResource()
  * 
  * @param mixed $fileData
  * @return
  */
 public function uploadResources($fileData = null)
 {
     //echo "here"; die;
     //Get JSON view
     $view = $this->getView("profile", "json");
     $resp = array("code" => TUIYO_OK, "error" => null, "data" => _("file uploaded"));
     //Get Session Information
     $model = $this->getModel("resources");
     $sData = "";
     $fType = JRequest::getVar("resourceType", null);
     $user = TuiyoAPI::get("user", null);
     //Check we know who we are dealing with
     $user = $GLOBALS["API"]->get("user", null);
     if ($user->joomla->get("guest")) {
         $jsid = JRequest::getVar("jsid");
         $jsname = JRequest::getVar("jsname");
         $store =& JSessionStorage::getInstance('database');
         $sdata = $store->read($jsid);
         $session =& JFactory::getSession();
         $session->destroy();
         session_id($jsid);
         session_decode($sdata);
         session_start();
         $session->restart();
         $user = $GLOBALS["API"]->get("user", null);
         //if the user is still a guess, raise the error
         if ($user->joomla->get('guest')) {
             trigger_error(_("unable to determine the user session"), E_USER_ERROR);
             return false;
         }
     }
     if (empty($fType)) {
         $fileExtension = pathinfo($_FILES["Filedata"]['name'], PATHINFO_EXTENSION);
         switch (strtolower($fileExtension)) {
             case "gif":
             case "jpg":
             case "jpeg":
             case "png":
                 $fType = "photos";
                 break;
             case "mp3":
                 $fType = "audio";
                 break;
         }
         if (empty($fType)) {
             trigger_error(_('Invalid file type'), E_USER_ERROR);
             return false;
         }
     }
     //print_R($user); die;
     //Get the resources class
     TuiyoLoader::import("user.uploads");
     $uploads = new TuiyoUploads($fType);
     if (!$uploads->saveItem($_FILES["Filedata"], $sData)) {
         trigger_error($uploads->getErrors(), E_USER_ERROR);
         return false;
     }
     $resp["data"] = $uploads->getLastUploaded();
     //return response
     return $view->encode($resp);
 }
Exemplo n.º 20
0
 /**
  * Constructor
  *
  * @param   string  $store    The type of storage for the session.
  * @param   array   $options  Optional parameters
  *
  * @since   11.1
  */
 public function __construct($store = 'none', $options = array())
 {
     // Need to destroy any existing sessions started with session.auto_start
     if (session_id()) {
         session_unset();
         session_destroy();
     }
     // Set default session save handler
     ini_set('session.save_handler', 'files');
     // Disable transparent sid support
     ini_set('session.use_trans_sid', '0');
     // Only allow the session ID to come from cookies and nothing else.
     ini_set('session.use_only_cookies', '1');
     // Create handler
     $this->_store = JSessionStorage::getInstance($store, $options);
     // Set options
     $this->_setOptions($options);
     $this->_setCookieParams();
     // Load the session
     $this->_start();
     // Initialise the session
     $this->_setCounter();
     $this->_setTimers();
     $this->_state = 'active';
     // Perform security checks
     $this->_validate();
 }