From 43067b7e18c0bd44f703a8bee8770bcdab674f20 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Tue, 15 Jan 2013 01:22:15 -0800 Subject: This is the chat app* whoops. --- ajax_chat.php | 78 +++++++++++++++++++ includes/chats.php | 74 ++++++++++++++++++ pages/chat.php | 220 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 372 insertions(+) create mode 100644 ajax_chat.php create mode 100644 includes/chats.php create mode 100644 pages/chat.php diff --git a/ajax_chat.php b/ajax_chat.php new file mode 100644 index 0000000..37521de --- /dev/null +++ b/ajax_chat.php @@ -0,0 +1,78 @@ + \ No newline at end of file diff --git a/includes/chats.php b/includes/chats.php new file mode 100644 index 0000000..56c88d1 --- /dev/null +++ b/includes/chats.php @@ -0,0 +1,74 @@ +prepare("INSERT INTO `chat` + (`userID`, `message`) + VALUES (?, ?)"); + $stmt->bind_param('is', $userID, $message); + $stmt->execute(); + + $ID = $stmt->insert_id; + $stmt->close(); + // $mysqli->close; + return $ID; +} + +function getChat($startID = 0) { + global $mysqli; + $array = array(); + + if (!is_numeric($startID)) + return false; + + //Not sure why this happens; but just return nothing.. + if (!is_object($mysqli)) + die("Error creating object"); + + $res = $mysqli->query(" + SELECT + chat.ID, chat.userID, chat.message, chat.dateSent, + users.displayName, + userData.displayColor, + userData.wallColor, + userData.wallEmblem + FROM `chat` + LEFT JOIN `userData` + ON chat.userID = userData.userID + LEFT JOIN `users` + ON chat.userID = users.ID + WHERE chat.ID > '$startID' + ORDER BY chat.ID ASC + "); + $array = array(); + if ($res->num_rows == 0) { + $res->close(); + return false; + } + while ($response = $res->fetch_assoc()) { + $array[] = $response; + $lastID = $response['ID']; + } + $res->close(); + + if (count($array) < 1) + return false; + + //Turnicate messages. + $deleteFromID = $lastID - CHAT_ROWS_TO_KEEP; + $mysqli->query("DELETE FROM `chat` WHERE `ID` < $deleteFromID"); + $mysqli->close(); + + return $array; +} + + +?> \ No newline at end of file diff --git a/pages/chat.php b/pages/chat.php new file mode 100644 index 0000000..11bb935 --- /dev/null +++ b/pages/chat.php @@ -0,0 +1,220 @@ + + + + + + + + + + +

this page will overflow...

+ +
+
+ + + +
+
+ +
+ +
+ + + \ No newline at end of file -- cgit v1.2.3