SessionDuration=SESSIONTIMEOUT; $this->oSystem=&$oSystem; if($this->oSessionDatabase=$this->oSystem->goGetDB("session")) { $this->msSessionStore="td".APPKEY."Sessions"; $sQuery="CREATE TABLE IF NOT EXISTS ".$this->msSessionStore." ( `SessionID` MEDIUMINT UNSIGNED NOT NULL , `SessionData` MEDIUMTEXT NOT NULL , `SessionDies` BIGINT NOT NULL , PRIMARY KEY ( `SessionID` ) )"; $this->oSessionDatabase->mlQuery($sQuery); } else $oSystem->oError->gsGenerateFinalError("db"); } function gbSessionKiller() { } function msGenerateSessionID() { $sSessionID=md5(mt_rand()); while($this->oSessionDatabase->glGetNumberOfRecords($this->msSessionStore,"SessionID='".$sSessionID."'")==1) $sSessionID=md5(mt_rand()); $this->msSessionID=$sSessionID; return $this->msSessionID ; } function gsGetCurrentSessionID() { return $this->msSessionID; } function gbSaveSessionData() { $asData["SerializedSessionData"]="'".serialize($this->masSessionData)."'"; $asData["SessionDies"]=time()+SESSIONTIMEOUT; if ($this->oDB->gbUpdateArray($this->msSessionStore,$asData,"SessionID='".$this->msSessionID."'")) { return true; } return false; } function gvntSaveVar($sName,$vntValue) { $this->masSessionData[$sName]=$vntValue; } function gvntGetVar($sName,$x=false) { if (isset($this->masSessionData[$sName])) { return $this->masSessionData[$sName]; } return $x; } function mbUnregisterSession() { session_destroy(); return $this->oDB->gbDelete($this->msSessionStore,"SessionID='".$this->msSessionID."'"); } function gbSaveVar($sVarName,$sValue) { $_SESSION[$sVarName]=$sValue; } function gvGetVar($sVarName) { if(isset($_SESSION[$sVarName])) return $_SESSION[$sVarName]; return false; } function gDeleteVar($sVarName) { unset($_SESSION[$sVarName]); } function mbSessionExists($sSessionID=false) { if($oResult=$this->oSessionDatabase->goQuery("SELECT * FROM ".$this->msSessionStore." WHERE UNIX_TIMESTAMP(NOW())>SessionDies")) { $aoSessions=$oResult->gaoGetAllRecords(); $asS=array(); foreach($aoSessions as $oSess) { array_push($asS,$oSess->SessionID); if(sizeof($asS)>30) { $sS="'".join("','",$asS)."'"; $this->oSystem->oDB->goUpdate($this->oSystem->oUser->msUserTable,"CurrentSessionID='__abgemeldet__'","CurrentSessionID IN (".$sS.")"); unset($asS); $asS=array(); } } if(sizeof($asS)>0) { $sS="'".join("','",$asS)."'"; $this->oSystem->oDB->goUpdate($this->oSystem->oUser->msUserTable,"CurrentSessionID='__abgemeldet__'","CurrentSessionID IN (".$sS.")"); } } $this->oSessionDatabase->goDelete($this->msSessionStore,"UNIX_TIMESTAMP(NOW())>SessionDies"); if ($sSessionID=="") return false; if ($this->oSessionDatabase->glGetNumberOfRecords($this->msSessionStore,"SessionID='".$sSessionID."'")==0) return false; $asUpdateData["SessionDies"]=time()+$this->SessionDuration; $this->oSessionDatabase->goUpdateArray($this->msSessionStore,$asUpdateData,"SessionID='".$sSessionID."'"); $this->msSessionID=$sSessionID; ini_set("session.use_cookies","0"); ini_set("session.cache_limiter","nocache"); setcookie("__MY__",$this->msSessionID,time()+7200,"/".CLIENTNAME."/"); session_id("qs".$sSessionID); //session_save_path("c:/phpsessions/"); session_start(); return true; } function mvntStartSession() { // returns the sessionid in case of success // saves the sessionid in $oExternalData! $asData["SessionID"]="'".$this->msGenerateSessionID()."'"; $asData["SessionDies"]=time()+$this->SessionDuration; if ($this->oSessionDatabase->goInsertArray($this->msSessionStore,$asData)) { return $this->msSessionID; } else { return false; } return true; } }