// something like cron-job to delete wasteful/old data from db
$this->dbObj->sqlSet("delete FROM {$this->_prefix}etchat_messages where etchat_timestamp < ".(date('U')-($_SESSION['etchat_'.$this->_prefix.'loeschen_nach']*3600*24)));
$this->dbObj->sqlSet("delete FROM {$this->_prefix}etchat_blacklist where etchat_blacklist_time < ".date('U'));
$this->dbObj->sqlSet("delete FROM {$this->_prefix}etchat_kick_user where etchat_kicked_user_time < ".date('U'));
if ($this->user_application) header('Location: ./?AfterBlacklistInsertion');
return false;
}
// delete all old datasets from the etchat_useronline table (session table)
$this->dbObj->sqlSet("DELETE FROM {$this->_prefix}etchat_useronline WHERE etchat_onlinetimestamp < ".(date('U')-(($_SESSION['etchat_'.$this->_prefix.'config_reloadsequenz']/1000)*4)));
// abort, if $username empty or to long
if (empty($username) || strlen($username)>100) {$this->errorMessage(""); return false; }
// Dataset with Userparameter from etchat_user tab. The dataset is empty if there no such user with this name
$user_exists = $this->dbObj->sqlGet("SELECT etchat_user_id, etchat_username, etchat_userpw, etchat_userprivilegien FROM {$this->_prefix}etchat_user WHERE etchat_username = '".$username."' order by etchat_userpw DESC");
// create new CheckerAndInserterObj Object
$userCheckerAndInserterObj = new UserCheckerAndInserter($this->dbObj, $user_exists, $username, $_POST['pw'], $gender, $this->lang);
// Status 1 means that the loggining was sucessfull
if ($userCheckerAndInserterObj->status==1) $this->messageOnEnter();
// if a returned dataset is an array, then the Username is now in etchat_useronline tab, so in the chat session
if(is_array($this->dbObj->sqlGet("SELECT etchat_username FROM {$this->_prefix}etchat_useronline, {$this->_prefix}etchat_user WHERE etchat_username = '".$user."' AND etchat_user_id = etchat_onlineuser_fid LIMIT 1"))){
setcookie("cookie_anzahl_logins_in_XX_sek",1);
return true;
}
else return false;
}
/**
* Print a error message, and close db connect
*
* @param string $message Outputmessage is status != 1, so the user cant be loggin to chat