diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/chats.php | 74 | ||||
-rw-r--r-- | includes/emails.php | 4 | ||||
-rw-r--r-- | includes/mapclass.php | 50 |
3 files changed, 102 insertions, 26 deletions
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 @@ +<?
+/*
+ * addChat, getChat functions
+*/
+include_once('sqli.php');
+
+define('CHAT_ROWS_TO_KEEP', 30);
+
+
+function addChat($userID, $message) {
+ global $mysqli;
+
+ $stmt = $mysqli->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/includes/emails.php b/includes/emails.php index 84f657c..c971f25 100644 --- a/includes/emails.php +++ b/includes/emails.php @@ -3,6 +3,10 @@ * Email methods; QueueEmail and SendQueuedEmail
*/
+//Email sending lock
+define('FILE_EMAIL_LOCK', './emailLockFile');
+
+
//Returns false if nothing is sent.
function SendQueuedEmail() {
//Delay by x seconds per email:
diff --git a/includes/mapclass.php b/includes/mapclass.php index ddf08cd..03bbedd 100644 --- a/includes/mapclass.php +++ b/includes/mapclass.php @@ -8,6 +8,7 @@ define("TileType", 0); define("TileValue", 1); +define("TileWall", 'w'); //User-placed-wall. define("TileEmpty", 'o'); define("TileStart", 's'); define("TileFinish", 'f'); @@ -74,35 +75,32 @@ class map { switch ($type) { case 'S': $this->isMultiPath = true; - $value = 1; - $type = 's'; - break; - case 'R': - $value = 1; - $type = 'r'; - break; - case 'q': $value = 2; - $type = 'r'; + $type = TileStart; break; + case 'w': $value = ''; $type = Tilewall; break; + + case 'r': $value = ''; $type = TileRock; break; + case 'R': $value = 2; $type = TileRock; break; + case 'q': $value = 3; $type = TileRock; break; //Probably a more intelligent way to do this; but it works: - case 'a': $value = ''; $type = 'c'; break; - case 'b': $value = 2; $type = 'c'; break; - case 'c': $value = 3; $type = 'c'; break; - case 'd': $value = 4; $type = 'c'; break; - case 'e': $value = 5; $type = 'c'; break; - - case 't': $value = ''; $type = 't'; break; - case 'm': $value = 2; $type = 't'; break; - case 'g': $value = 3; $type = 't'; break; - case 'i': $value = 4; $type = 't'; break; - case 'k': $value = 5; $type = 't'; break; + case 'a': $value = ''; $type = TileCheckpoint; break; + case 'b': $value = 2; $type = TileCheckpoint; break; + case 'c': $value = 3; $type = TileCheckpoint; break; + case 'd': $value = 4; $type = TileCheckpoint; break; + case 'e': $value = 5; $type = TileCheckpoint; break; + + case 't': $value = ''; $type = TileTeleportIn; break; + case 'm': $value = 2; $type = TileTeleportIn; break; + case 'g': $value = 3; $type = TileTeleportIn; break; + case 'i': $value = 4; $type = TileTeleportIn; break; + case 'k': $value = 5; $type = TileTeleportIn; break; - case 'u': $value = ''; $type = 'u'; break; - case 'n': $value = 2; $type = 'u'; break; - case 'h': $value = 3; $type = 'u'; break; - case 'j': $value = 4; $type = 'u'; break; - case 'l': $value = 5; $type = 'u'; break; + case 'u': $value = ''; $type = TileTeleportOut; break; + case 'n': $value = 2; $type = TileTeleportOut; break; + case 'h': $value = 3; $type = TileTeleportOut; break; + case 'j': $value = 4; $type = TileTeleportOut; break; + case 'l': $value = 5; $type = TileTeleportOut; break; } $this->tiles[$y][$x][TileType] = $type; @@ -112,7 +110,7 @@ class map { $t = -1; } else { - $this->tiles[$y][$x][TileType] = 'o'; //Empty Tile + $this->tiles[$y][$x][TileType] = TileEmpty; } } } |