diff options
Diffstat (limited to 'ajax_chat.php')
-rw-r--r-- | ajax_chat.php | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ajax_chat.php b/ajax_chat.php index 37521de..04a6fd4 100644 --- a/ajax_chat.php +++ b/ajax_chat.php @@ -20,13 +20,14 @@ if ($_REQUEST['messages']) { if ($_REQUEST['getChatFromID']) {
+ $getChatID = $_REQUEST['getChatFromID'];
if ($sent) {
//Wait .2 seconds
usleep(200000);
//echo "yesSent";
for( $i = 1; $i < 3; $i++) {
//echo "loop";
- $data = getChat($_REQUEST['getChatFromID']);
+ $data = getChat($getChatID);
if ($data !== false) {
//$data['debug'][] = "Count times: $i";
//$data['debug'][] = "Count value:".count($data);
@@ -38,17 +39,20 @@ if ($_REQUEST['getChatFromID']) { }
}
//echo "reachedEnd";
- $json = prepareChatData(getChat($_REQUEST['getChatFromID']));
+ $json = prepareChatData(getChat($getChatID));
echo $json;
exit;
}
function prepareChatData($data) {
- foreach($data as &$user) {
- //$user['message'] = $user['message'].'write-append';
- $user['secondsSince'] = strtotime($user['dateSent']) - strtotime("now");
+ if ($data) {
+ foreach($data as &$user) {
+ //$user['message'] = $user['message'].'write-append';
+ $user['secondsSince'] = strtotime($user['dateSent']) - strtotime("now");
+ }
+ return json_encode($data);
}
- return json_encode($data);
+ return $data;
}
|