diff options
author | Patrick Davison <snapwilliam@gmail.com> | 2013-01-15 01:40:54 -0800 |
---|---|---|
committer | Patrick Davison <snapwilliam@gmail.com> | 2013-01-15 01:40:54 -0800 |
commit | c7d671712a9d5f90752475960c3a602aeb0da8d0 (patch) | |
tree | f912484612e8811b5e7fd52533770942647a769e /ajax_chat.php | |
parent | cc579e91af8adbef5ddda979dbbe5db93a8c32ef (diff) | |
download | pathery-c7d671712a9d5f90752475960c3a602aeb0da8d0.tar.xz |
Chat cleanup
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;
}
|