oSystem=&$oSystem; $this->msUserPKField=$sPKField; $this->msUserTable=$sTable; } function getClientPK() { return $this->oUserData->ClientPK; } function getClientKey() { return $this->oClientData->ClientKey; } function getUserPK() { $sU=$this->msUserPKField; return $this->oUserData->$sU; } function getRemoteUserPK() { } function gbSetTable($sTable) { $this->msUserTable=$sTable; } function gbUpdatePassword($newPass,$lUserPK=false) { if($lUserPK===false) $lUserPK=$this->getUserPK(); return $this->oSystem->oDB->goUpdate($this->msUserTable,"UserPass='".$newPass."'",$this->msUserPKField."=".$lUserPK); } function gsGetUserPass($lUserPK=false) { if($lUserPK===false) $lUserPK=$this->getUserPK(); return $this->oSystem->oDB->gsGetFieldValue($this->msUserTable,"UserPass",$this->msUserPKField."=".$lUserPK); } function gsGetUserName($lUserPK) { return $this->oSystem->oDB->gsGetFieldValue($this->msUserTable,"UserName",$this->msUserPKField."=".$lUserPK); } function gbLoginUser($sMD5UserName,$sMD5Password,$bUseMD5=true) { $oTableInfo=$this->oSystem->oDB->goGetTableInfo($this->msUserTable); if($oTableInfo->gbFieldExists("CanLogin")) $sAdd=" AND CanLogin=-1"; if($bUseMD5===true) $sQuery="SELECT * FROM ".$this->msUserTable." WHERE UserName='".$sMD5UserName."' AND UserPass=MD5('".$sMD5Password."')".$sAdd; else $sQuery="SELECT * FROM ".$this->msUserTable." WHERE (UserName)=('".$sMD5UserName."') AND (UserPass)=('".$sMD5Password."')".$sAdd; if($mlRequestID=$this->oSystem->oDB->mlQuery($sQuery)) { $oResult=$this->oSystem->oDB->goGetResult($mlRequestID); if($oResult->glGetNumberOfRecords()==1) { if($this->oUserData=$oResult->goGetRecord()) { $this->oSystem->oLog->gLog("Login",$this->oUserData); if($this->oSystem->oDB->gsGetFieldValue("tdClients","AccessAllowed","ClientPK=".$this->oUserData->ClientPK,"IF(AccessAllowed=-1,'true','false') as AccessAllowed")=="true") { $sSessionID=$this->oSystem->oSession->mvntStartSession(); $this->gbSetSessionID($sSessionID); $sSessionID; return $sSessionID; } else { $this->mlError=1; $this->oSystem->oLog->gLog("Access Denied",$oUserData); return false; } } } } else { $oError=$this->oSystem->oDB->goGetError(); } return false; } function gbSetSessionID($sSessionID) { $oTableInfo=$this->oSystem->oDB->goGetTableInfo($this->msUserTable); $sPrimaryKey=$oTableInfo->PrimaryKey; $asUpdate["CurrentSessionID"]="'".$sSessionID."'"; if($oResult=$this->oSystem->oDB->goUpdateArray($this->msUserTable,$asUpdate,$oTableInfo->PrimaryKey."=".$this->oUserData->$sPrimaryKey)) { if($oResult->glGetAffectedRows()==1) { return true; } } return false; } function goGetUserLocation() { $sQuery="SELECT *,IFNULL(Latitude,'__false__') as Latitude FROM tdClientLocations WHERE LocationPK=".$this->oUserData->LocationPK; if($oRes=$this->oSystem->oDB->goQuery($sQuery)) { return $oRes->goGetRecord(); } return false; } function gsGetCurrentSessionID() { return $this->oSystem->oSession->gsGetCurrentSessionID(); } function gasGetAccessData() { $asData["ClientPK"]=$this->oUserData->ClientPK; $asData["UserPK"]=$this->oUserData->UserPK; return $asData; } function gsGetUserValue($sValue) { } function gLoadUserData() { $sSessionID=$this->oSystem->oSession->gsGetCurrentSessionID(); if($oResult=$this->oSystem->oDB->goQuery("SELECT * FROM ".$this->msUserTable." WHERE CurrentSessionID='".$sSessionID."'")) { if($this->oUserData=$oResult->goGetRecord()) { if(!isset($this->oUserData->UserPK)) { $this->oUserData->UserPK=$this->getUserPK(); } $oTableInfo=$this->oSystem->oDB->goGetTableInfo($this->msUserTable); if($oTableInfo->gbFieldExists("LastAction")) { $this->oSystem->oDB->goUpdate("tdUser","LastAction=now()","UserPK=".$this->oUserData->UserPK); } if($oResult=$this->oSystem->oDB->goQuery("SELECT *,IFNULL(MaxUser,'__false__') as MaxUser FROM tdClients WHERE ClientPK=".$this->oUserData->ClientPK)) { $this->oClientData=new CUserClientData($this->oSystem,$oResult->goGetRecord()); return true; } else { mail("thorsten.k@kk-gbr.de","NIX",mysql_error()); } } else { echo mysql_error(); // benutzerdaten nicht ladbar return false; } } else { return false; } } } class CUserClientData { var $oSystem; var $oClientData; var $mlMaxUser; function CUserClientData(&$oSystem,$oClientData) { $this->mlMaxUser=false; $this->oSystem=&$oSystem; $this->oClientData=$oClientData; } function glGetNumberOfClientUser() { if($this->mlMaxUser===false) $this->mlMaxUser=$this->oSystem->oDB->glGetNumberOfRecords($this->msUserTable,"ClientPK=".$this->oClientData->ClientPK); return $this->mlMaxUser; } function glGetMaxUser() { return $this->oClientData->MaxUser; } function gasGetData() { $asReturn["UserCount"]=$this->mlMaxUser; $asReturn["MaxUser"]=$this->oClientData->MaxUser; $asReturn["NextUser"]=$this->mlMaxUser+1;; return $asReturn; } function gbUseAsRemoteFE() { return $this->oClientData->UseAsRemoteFE==-1; } function gbCanAddUser() { if($this->oClientData->MaxUser=="__false__") return true; if($this->glGetNumberOfClientUser()<=$this->oClientData->MaxUser) return true; return false; } }