-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat.php
More file actions
33 lines (30 loc) · 991 Bytes
/
Copy pathchat.php
File metadata and controls
33 lines (30 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
require_once("chat.class.php"); //Include chat class
$chat = new Chat();//Create object of class chat
$id = 0;//Default value of id
//If request is to send message
if(isset($_POST['json_sendMessage']))
{
$json_decode = json_decode($_POST['json_sendMessage']);
$name = $json_decode->name;
$message = $json_decode->message;
$id = $json_decode->id;
if ($name != '' && $message != '')
{
$chat->postMessage($name, $message); //Call post message function
}
}
//If request is to retrive message
else if(isset($_POST['json_requestNewMessages']))
{
$chat->CreateTable(); //Create table if not exist
$json_decode = json_decode($_POST['json_requestNewMessages']);
$id = $json_decode->id;
}
if(ob_get_length())
ob_clean();//Clear buffer for previous content
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header('Content-Type: text/xml');
echo $chat->retrieveNewMessages($id); //Call retrive message function which prints output
?>