157 lines
4.0 KiB
PHP
157 lines
4.0 KiB
PHP
<?php
|
|
|
|
namespace BRSystems\Core\Library\cSession;
|
|
|
|
/**
|
|
* Session module
|
|
*
|
|
* @category LIB numbers
|
|
* @author Mareks Keišs <mareks.keiss@brsystems.lv>
|
|
* @since Version 1.0
|
|
*
|
|
*
|
|
* -------------------------------------------------
|
|
* USER OBJECT DATA PROPERTIES
|
|
* -------------------------------------------------
|
|
* @property int|bool id
|
|
* @property int|bool selCp
|
|
* @property int|bool cpCount
|
|
*
|
|
* @property int selCpData
|
|
* @property int selCpStartingDate
|
|
* @property int activity_time
|
|
*
|
|
* @property bool bPWD
|
|
* @property bool bSuUser
|
|
* @property bool bTrial
|
|
* @property bool bTrialExpired
|
|
* @property bool b2FAEnabled
|
|
*
|
|
* @property string|bool selCpYear
|
|
* @property string|bool selCpYearLock
|
|
* @property string|bool selCpTitle
|
|
* @property string|bool selCpDbName
|
|
* @property string|bool selCpImg
|
|
* @property string|bool selCpTitleInitials
|
|
*
|
|
* @property array permissions
|
|
* @property array companyPermissions
|
|
* @property array selCpYearCfg
|
|
*
|
|
* @property mixed TPASSWD
|
|
*
|
|
* @property mixed post
|
|
* @property mixed data
|
|
* @property mixed vUserData
|
|
* @property mixed suser
|
|
* @property mixed SUBSCRIPTION_DATA
|
|
* @property mixed FILTER
|
|
* @property bool REQUEST_FROM_LURSOFT
|
|
* @property int REQUEST_FROM_LURSOFT_LINK_ID
|
|
* @property array REQUESTS
|
|
*
|
|
* @property mixed scrollTo
|
|
* @property mixed APARTMENTS
|
|
* @property mixed URLS2COMPANY
|
|
*
|
|
*
|
|
*
|
|
* -------------------------------------------------
|
|
* URL PROPERTIES
|
|
* -------------------------------------------------
|
|
* @property string|bool forceRedirect
|
|
* @property string|bool pubafterlogin
|
|
*
|
|
*/
|
|
class cSession
|
|
{
|
|
private $_index;
|
|
|
|
public function __construct($index) {
|
|
|
|
$this->_index = $index;
|
|
if(!isset($_SESSION[$index])){
|
|
$_SESSION[$index] = array();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Function to get variable like call from object
|
|
*
|
|
* @author Mareks Keišs <mareks.keiss@brsystems.lv>
|
|
* @category Module
|
|
* @returns mixed true or found value
|
|
*/
|
|
public function __call($name, $args){
|
|
if(isset($_SESSION[$this->_index][$name]))
|
|
return $_SESSION[$this->_index][$name];
|
|
else
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Function to get variable from array
|
|
*
|
|
* @author Mareks Keišs <mareks.keiss@brsystems.lv>
|
|
* @category Module
|
|
* @returns mixed true or found value
|
|
*/
|
|
public function &__get($name){
|
|
if(isset($_SESSION[$this->_index][$name]))
|
|
return $_SESSION[$this->_index][$name];
|
|
else{
|
|
$_SESSION[$this->_index][$name] = false;
|
|
return $_SESSION[$this->_index][$name];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Function to set variable like call from object
|
|
*
|
|
* @author Mareks Keišs <mareks.keiss@brsystems.lv>
|
|
* @category Module
|
|
* @returns void
|
|
*/
|
|
public function __set($name, $args){
|
|
if($args === false)
|
|
unset($_SESSION[$this->_index][$name]);
|
|
else
|
|
$_SESSION[$this->_index][$name] = $args;
|
|
}
|
|
|
|
/**
|
|
* Function to get all array info
|
|
*
|
|
* @author Mareks Keišs <mareks.keiss@brsystems.lv>
|
|
* @category Module
|
|
* @returns mixed true or found value
|
|
*/
|
|
public function getArray(){
|
|
if(isset($_SESSION[$this->_index]))
|
|
return $_SESSION[$this->_index];
|
|
else
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Function to destroy array
|
|
*
|
|
* @author Mareks Keišs <mareks.keiss@brsystems.lv>
|
|
* @category Module
|
|
* @param array $preserveIndexes - indexes to preserve
|
|
* @return bool true or found value
|
|
*/
|
|
public function destroy($preserveIndexes = array()){
|
|
if(isset($_SESSION[$this->_index])){
|
|
if(!!$preserveIndexes){
|
|
foreach($_SESSION[$this->_index] as $k=>$v)
|
|
if(!in_array($k, $preserveIndexes))
|
|
unset($_SESSION[$this->_index][$k]);
|
|
}else
|
|
unset($_SESSION[$this->_index]);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|