} if (!is_numeric($iduser) || $iduser <= 0) { $errored = 1; $txterror .= 'Error... '; } if ($errored == 1) { echo '0: ' . $txterror; } else { $totalitems = $this->db2->fetch_field('SELECT COUNT(DISTINCT id_from) FROM chat WHERE id_to=' . $this->user->id); $r = $this->db2->query('SELECT * FROM (SELECT * FROM chat, users WHERE id_to=' . $this->user->id . ' AND id_from = iduser ORDER BY thedate DESC) as itemchat GROUP BY id_from ORDER BY thedate DESC LIMIT ' . $numitems . ',' . $C->NUM_USERCHAT_PAGE); $numitemsnow = $this->db2->num_rows(); $htmlResults = ''; while ($obj = $this->db2->fetch_object($r)) { $D->isThisUserVerified = $obj->validated == 1 ? TRUE : FALSE; $D->f_name = empty($obj->firstname) || empty($obj->lastname) ? stripslashes($obj->username) : stripslashes($obj->firstname) . ' ' . stripslashes($obj->lastname); $D->f_codeuser = $obj->code; $D->f_avatar = $obj->avatar; $D->f_lastmessage = analyzeMessageChat($obj->message); $D->f_date = $obj->thedate; $D->f_username = $obj->username; $htmlResults .= $this->load_template('__dashboard-one-userchat.php', FALSE); } unset($r, $obj); if ($totalitems <= $numitemsnow + $numitems) { echo "2: " . $htmlResults; return; } else { echo "1: " . $htmlResults; return; } }
<?php // We check in which language we will work if (isset($_SESSION["DATAGLOBAL"][0]) && !empty($_SESSION["DATAGLOBAL"][0])) { $C->LANGUAGE = $_SESSION["DATAGLOBAL"][0]; } $this->load_langfile('global/global.php'); $this->load_langfile('inside/dashboard.php'); $r = $this->db2->query('SELECT * FROM (SELECT * FROM chat, users WHERE id_to=' . $this->user->id . ' AND id_from = iduser ORDER BY id DESC) as itemchat GROUP BY id_from ORDER BY id DESC LIMIT ' . $C->NUM_NOTIFICATIONSMSG_ALERT); $this->db2->query('UPDATE chat SET isread=1 WHERE id_to=' . $this->user->id . ' AND isread=0'); $txtResult = ''; ob_start(); while ($obj = $this->db2->fetch_object($r)) { $D->username = $obj->username; $D->uname = empty($obj->firstname) || empty($obj->lastname) ? stripslashes($obj->username) : stripslashes($obj->firstname) . ' ' . stripslashes($obj->lastname); $D->avatar = $obj->avatar; $D->dateago = $obj->thedate; $D->message = analyzeMessageChat(str_cut($obj->message, 50)); $this->load_template('__dashboard-one-alert-messages.php'); } $txtResult = ob_get_contents(); ob_end_clean(); unset($r, $obj); if (!empty($txtResult)) { echo '1: ' . $txtResult; return; } else { echo '1: <div style="text-align:center; padding:10px 5px 10px">' . $this->lang('dashboard_mynotifications_nonotifications') . '</div>'; return; }
$D->totalmsgchat = $this->db2->fetch_field('SELECT count(chat.id) FROM users, chat WHERE (id_from=' . $this->user->id . ' AND id_to=' . $D->u->iduser . ' AND id_from=iduser) OR (id_from=' . $D->u->iduser . ' AND id_to=' . $this->user->id . ' AND id_from=iduser)'); $r = $this->db2->query('SELECT * FROM users, chat WHERE (id_from=' . $this->user->id . ' AND id_to=' . $D->u->iduser . ' AND id_from=iduser) OR (id_from=' . $D->u->iduser . ' AND id_to=' . $this->user->id . ' AND id_from=iduser) ORDER BY chat.id DESC LIMIT 0,' . $C->CHAT_NUM_MSG_START); $D->nummsgchat = $this->db2->num_rows(); $D->htmlChat = ''; if ($r) { $this->db2->query('UPDATE chat SET isread=1 WHERE id_from=' . $D->u->iduser . ' AND id_to=' . $this->user->id . ' AND isread=0'); $rowmsgs = array(); while ($obj = $this->db2->fetch_object($r)) { $rowmsgs[] = $obj; } $rowmsgs = array_reverse($rowmsgs); ob_start(); foreach ($rowmsgs as $onemsg) { $D->idmsg = $onemsg->id; $D->iduser = $onemsg->iduser; $D->username = $onemsg->username; $D->uname = empty($onemsg->firstname) || empty($onemsg->lastname) ? stripslashes($onemsg->username) : stripslashes($onemsg->firstname) . ' ' . stripslashes($onemsg->lastname); $D->avatar = $onemsg->avatar; $D->dateago = $onemsg->thedate; $D->message = analyzeMessageChat($onemsg->message); $this->load_template('__profile-one-msgchat.php'); } $D->htmlChat = ob_get_contents(); ob_end_clean(); unset($r, $obj); } } /*************************************************************************/ $D->page_title = $D->nameUser . ' - ' . $this->lang('profile_messages_title') . ' - ' . $C->SITE_TITLE; $D->optionactive = 5; $this->load_template('messages.php');