| Server IP : 172.64.80.1 / Your IP : 172.69.17.157 Web Server : Apache System : Linux mail.federalpolyede.edu.ng 5.10.0-32-amd64 #1 SMP Debian 5.10.223-1 (2024-08-10) x86_64 User : federalpolyede.edu.ng_idh35skikv ( 10000) PHP Version : 7.4.33 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/federalpolyede.edu.ng/httpdocs_backup/chat/scripts/ |
Upload File : |
<?php
require_once('../../connect.php');
class chatClass
{
public static function getRestChatLines($id,$username,$chatwith)
{
$arr = array();
$jsonData = '{"results":[';
// echo $id;
if ($id=="1")
$sql="select * from tblchat where ((Msg_From='$username' and Msg_To ='$chatwith') or (Msg_From='$chatwith' and Msg_To ='$username')) and (Chat_Id > $id) order by Chat_Id ";
else
$sql="select * from tblchat where (Msg_From='$chatwith' and Msg_To ='$username') and (Chat_Id > $id) order by Chat_Id ";
// echo $sql;
$result=mysql_query($sql);
$num=mysql_num_rows($result);
$count=0;
$line = new stdClass;
while ($count<$num) {
$line->Chatid = mysql_result($result,$count,'Chat_Id');
$line->MsgFrom = mysql_result($result,$count,'Msg_From');
$line->MsgTo = mysql_result($result,$count,'Msg_To');
$line->Msg = mysql_result($result,$count,'Message');
if (mysql_result($result,$count,'Msg_From')== $username )
$line->IsUser = "Yes";
else
$line->IsUser = "No";
$uImg = "../passport/Reg" . mysql_result($result,$count,'Msg_From') . ".jpg";
if (file_exists("../" . $uImg))
$line->UserImg=$uImg;
else
$line->UserImg="img/user-2.png";
$line->Date_Sent = date('d-m-y H:i:s', strtotime( mysql_result($result,$count,'Date_Sent')));
$arr[] = json_encode($line);
++$count;
}
$jsonData .= implode(",", $arr);
$jsonData .= ']}';
// alert($jsonData);
return $jsonData;
}
public static function setChatLines( $chattext, $username,$chatwith) {
$sql="insert into tblchat(Msg_From,Msg_To,Message) values('". $username."','".$chatwith."','". $chattext."')";
$result=mysql_query($sql);
$line = new stdClass;
$jsonData = '{"results":[';
$line->Chatid ="-1";
$line->MsgFrom = $username;
$line->MsgTo =$chatwith;
$line->Msg = $chattext;
$line->IsUser = "Yes";
$uImg = "../passport/Reg" . $username . ".jpg";
if (file_exists("../" . $uImg))
$line->UserImg=$uImg;
else
$line->UserImg="img/user-2.png";
$line->Date_Sent = date('d-m-y H:i:s');
$jsonData .= json_encode($line) . ']}';
echo $jsonData;
}
}
?>