if (count($ausgabeJSON_Inhalt)>0) echo $ausgabeJSON_Anfang.implode(",", $ausgabeJSON_Inhalt).$ausgabeJSON_Ende;
}
/**
* Every pull refreshes the user data in the session table, etchat_useronline
*
* @param Array $user_array requested data from user table
* @param Array $raum_array requested data from room table
* @param String $user_param_all User IP data for Blacklist
* @uses ConnectDB::sqlGet()
* @uses ConnectDB::sqlSet()
* @return void
*/
private function refreshUserSession($user_array,$raum_array,$user_param_all){
$user_onlineid = $this->dbObj->sqlGet("SELECT etchat_onlineid FROM {$this->_prefix}etchat_useronline where etchat_onlineuser_fid = ".$_SESSION['etchat_'.$this->_prefix.'user_id']);
// if the usersession was created and is now existing
if(is_array($user_onlineid))
$this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_useronline SET
* @uses RoomAllowed::$room_status if the room is open/closed/pw-protected
* @return Array
*/
private function getRoomArray(){
// Get room Array
$raum_array=$this->dbObj->sqlGet("SELECT etchat_id_room, etchat_roomname, etchat_room_goup, etchat_room_message FROM {$this->_prefix}etchat_rooms where etchat_id_room =".(int)$_POST['room']);
// Checks if the posted roomID exists now, it could be just deleted by admin
if (!is_array($raum_array)){
$_POST['room'] = 1;
$raum_array=$this->dbObj->sqlGet("SELECT etchat_id_room, etchat_roomname, etchat_room_goup, etchat_room_message FROM {$this->_prefix}etchat_rooms where etchat_id_room = 1");
$raum_array=$this->dbObj->sqlGet("SELECT etchat_id_room, etchat_roomname, etchat_room_goup FROM {$this->_prefix}etchat_rooms where etchat_id_room = 1");
}
}
return $raum_array;
}
/**
* Checks if the user is in the kicklist now
*
* @uses ConnectDB::sqlGet()
* @uses ConnectDB::sqlSet()
* @return bool
*/
private function checkKicklist(){
// Get all data from the kick tab
$kicklist=$this->dbObj->sqlGet("SELECT id from {$this->_prefix}etchat_kick_user where etchat_kicked_user_id = ".$_SESSION['etchat_'.$this->_prefix.'user_id']);
if (is_array($kicklist)){
// delete the user from kicklist
$this->dbObj->sqlSet("delete from {$this->_prefix}etchat_kick_user where etchat_kicked_user_id = ".$_SESSION['etchat_'.$this->_prefix.'user_id']);
$rechte_zum_kicken=$this->dbObj->sqlGet("select etchat_userprivilegien FROM {$this->_prefix}etchat_user where etchat_user_id = ".$_SESSION['etchat_'.$this->_prefix.'user_id']);
if ($rechte_zum_kicken[0][0]!="admin" && $rechte_zum_kicken[0][0]!="mod") return true;
else return false;
}
else return false;
}
/**
* Print a error message, and close db connect
*
* @param string $message Outputmessage, usualy "0" (if any error)
* Creates a dataset with all needed messages for the user
*
* @uses ConnectDB::sqlGet()
* @uses ConnectDB::sqlSet()
* @return Array
*/
private function selectMessagesForTheUser(){
// on first message / on entrance
if (empty($_SESSION['etchat_'.$this->_prefix.'last_id'])) {
// checks if the own last_id is realy the last one
$counted_ids=$this->dbObj->sqlGet("SELECT count(etchat_id) FROM {$this->_prefix}etchat_messages WHERE etchat_id > ".$_SESSION['etchat_'.$this->_prefix.'my_first_mess_id']);
FROM {$this->_prefix}etchat_messages, {$this->_prefix}etchat_user where (etchat_fid_room = ".(int)$_POST['room']." or etchat_fid_room = 0 or etchat_privat=".$_SESSION['etchat_'.$this->_prefix.'user_id'].") and
(etchat_privat=0 or etchat_privat=".$_SESSION['etchat_'.$this->_prefix.'user_id']." or etchat_user_fid=".$_SESSION['etchat_'.$this->_prefix.'user_id'].") and etchat_user_id=etchat_user_fid ORDER BY etchat_id DESC LIMIT ".$this->_messages_shown_on_entrance);
FROM {$this->_prefix}etchat_messages, {$this->_prefix}etchat_user WHERE (etchat_fid_room = ".(int)$_POST['room']." or etchat_fid_room = 0 or etchat_privat=".$_SESSION['etchat_'.$this->_prefix.'user_id'].")
and etchat_id > ".$_SESSION['etchat_'.$this->_prefix.'last_id']." and
(etchat_privat=0 or etchat_privat=".$_SESSION['etchat_'.$this->_prefix.'user_id']." or etchat_user_fid=".$_SESSION['etchat_'.$this->_prefix.'user_id'].")
and etchat_user_id=etchat_user_fid ORDER BY etchat_id ");
if (is_array($feld)) $_SESSION['etchat_'.$this->_prefix.'last_id']= $feld[(count($feld)-1)][0];
else
// DE
// Das ist wichtig hier die last_id aus der DB auszulesen sogar wenn für das Raum in bem sich der User befindet keine
// neuen Messages gab. Sonst bleibt das last_id das alte und beim Raumwechsel kanns passieren, dass alle sonstigen Messages
// aus dem Raum in den gewächselt wurde, ausgegeben werden.
// EN
// It is importent to get the last_id from the DB, even there is no messges for the user. Othewise it kan happen that
// when the user is going to the other chat room hi's got all messges from this room
{
$id=$this->dbObj->sqlGet("SELECT etchat_id FROM {$this->_prefix}etchat_messages ORDER BY etchat_id DESC LIMIT 1");