summaryrefslogtreecommitdiffstats
path: root/ajax
diff options
context:
space:
mode:
Diffstat (limited to 'ajax')
-rw-r--r--ajax/chat.ajax.php71
-rw-r--r--ajax/maps.ajax.php62
-rw-r--r--ajax/scores.ajax.php174
-rw-r--r--ajax/users.ajax.php2
4 files changed, 134 insertions, 175 deletions
diff --git a/ajax/chat.ajax.php b/ajax/chat.ajax.php
index ae00b6f..7f5684c 100644
--- a/ajax/chat.ajax.php
+++ b/ajax/chat.ajax.php
@@ -1,13 +1,36 @@
<?
session_start();
+if (strtotime('now') - $_SESSION['chatLastReset'] > 6) {
+ $_SESSION['chatSendCount'] = 0;
+ $_SESSION['chatLastReset'] = strtotime('now');
+}
+if ($_REQUEST['messages']) {
+ $_SESSION['chatSendCount']++;
+ if ($_SESSION['chatSendCount'] > 4) {
+ $r[0]['error'] = 'Spam';
+ $r[0]['serverMessage'] = 'true';
+ $r[0]['message'] = "You're talking too fast - or your internet is being too slow. *OR ARE YOU SPAMMING ON PURPOSE?! JERK!*";
+ $r[0]['secondsSince'] = 0;
+ $r[0]['displayName'] = 'SERVER';
+ $r[0]['userID'] = -1;
+ echo json_encode($r);
+ exit;
+ }
+}
+//Don't lockout requests by holding the session file open!
session_write_close();
-//Just doing this as evidence that $_SESSION as read-only is still available.
$userID = $_SESSION['userID'];
$chatLockDown = false;
// STOP CHAT?
//$chatLockDown = true;
+if (true) {
+ if ($_SESSION['accepted'] !== 1) {
+ exit;
+ }
+}
+
require('../includes/chats.php');
$sent = false;
@@ -49,10 +72,13 @@ if ($_REQUEST['messages']) {
$insertID = addchat(-1, substr($message, 5));
}
}
- //Anyone commands:
+ //javascript based commands:
+ if ($command == 'spoiler' OR $command == 'me') {
+ $insertID = addchat($userID, $message);
+ }
if ($command == 'help') {
$r[0]['serverMessage'] = 'true';
- $r[0]['message'] = "Commands: /help /time . - Chat by Pathery.com";
+ $r[0]['message'] = "Commands: /help /time /spoiler /me. Surround text with ** for bold * for italics and ~~ for strikethrough. Chat by Pathery.com";
$r[0]['secondsSince'] = 0;
$r[0]['userID'] = -1;
echo json_encode($r);
@@ -66,7 +92,7 @@ if ($_REQUEST['messages']) {
echo json_encode($r);
exit;
}
- } else {
+ } else {
$insertID = addchat($userID, $message);
}
}
@@ -97,7 +123,6 @@ if ($_REQUEST['getChatFromID']) {
}
exit;
-
function prepareChatData($data) {
if ($data) {
foreach($data as &$user) {
@@ -109,26 +134,40 @@ function prepareChatData($data) {
return $data;
}
-
function chatFilter($chat) {
//cuss words
$chat = str_ireplace("fuck you", "i am moron", $chat);
- $chat = preg_replace("[fF]+\s*[uUvV]+\s*[hH]*\s*[cC\(kK]+\s*[iI]*\s*[nN]*\s*[gG]*", "dumb", $chat);
- $chat = str_ireplace("asshole", "dumb", $chat);
- $chat = str_ireplace("damnit", "do'h", $chat);
+ $chat = preg_replace("/[f]+\s*[uv]+\s*[h]*\s*[c\(k]+\s*(([i]*\s*[n]*\s*[g])|([e]*\s*[r]*))*/i", "dumb ", $chat); //fucker / fucking
+ $chat = preg_replace("/[^a-z]fag(g?[oi]t)?/i", " prince", $chat); //faggot
+ $chat = preg_replace("/^fag(g?[oi]t)?/i", "prince", $chat); //faggot (beginning of line)
+ $chat = preg_replace("/^suck\s*my.*(cock|dick|penis)/i", "join me in a riveting game of checkers", $chat); //suck my dick
+
$chat = str_ireplace("damn", "dumb", $chat);
- $chat = str_ireplace("cunt", "dumb", $chat);
$chat = str_ireplace("shit", "dumb", $chat);
- $chat = str_ireplace("bitch", "dumb", $chat);
- $chat = str_ireplace("cock", "elbow", $chat);
$chat = str_ireplace("sucks ass", "is dumb", $chat);
$chat = str_ireplace("suck ass", "are dumb", $chat);
+ $chat = str_ireplace("damnit", "do'h", $chat);
+
+ $chat = str_ireplace("a bitch", "an engaging conversationalist", $chat);
+ $chat = str_ireplace("bitch", "engaging conversationalist", $chat);
+ $chat = str_ireplace("an asshole", "a pleasant person to be around", $chat);
+ $chat = str_ireplace("asshole", "pleasant person to be around", $chat);
+
+ $chat = str_ireplace("cock", "elbow", $chat);
+ $chat = str_ireplace("dick", "elbow", $chat);
+ $chat = str_ireplace("penis", "elbow", $chat);
+ $chat = str_ireplace("vagina", "femur bone", $chat);
+ $chat = str_ireplace("cunt", "femur bone", $chat);
+
+ $chat = str_ireplace("hell", "the supermarket", $chat);
+ $chat = str_ireplace("whore", "entrepreneur", $chat);
$chat = str_ireplace("stfu", "be still my beating heart", $chat);
$chat = str_ireplace("omfg", "omg", $chat);
+ $chat = str_ireplace("4chan", "NEWT GINGRICH", $chat);
+ $chat = str_ireplace("nigger", "classy gentleman", $chat);
+ $chat = str_ireplace("pedophile", "Optimus Prime", $chat);
+ $chat = str_ireplace("pedo", "Optimus Prime", $chat);
+ $chat = str_ireplace("rape", "shake hands with", $chat);
return $chat;
}
-
-
-
-
?> \ No newline at end of file
diff --git a/ajax/maps.ajax.php b/ajax/maps.ajax.php
index 611080d..8ceade5 100644
--- a/ajax/maps.ajax.php
+++ b/ajax/maps.ajax.php
@@ -3,21 +3,35 @@ ob_start("ob_gzhandler");
include('../includes/mapclass.php');
include('../includes/maps.php');
+include('../includes/sqlEmbedded.php');
-//Remove the ending .js
-$tmp = explode(".", $_GET['mapid']);
-$mapID = $tmp[0] * 1;
-if (!is_int($mapID)) exit;
-
-$map = getMapObjectByID($mapID);
+if (isset($_GET['getmapidsbydate'])) {
+ //Remove the ending .js
+ $tmp = explode(".", $_GET['getmapidsbydate']);
+ $requestDate = $tmp[0];
+ sendCacheHeaders();
+ echo json_encode(getMapIDsByDate($requestDate));
+ exit;
+}
+if (isset($_GET['mapid'])) {
+ //Remove the ending .js
+ $tmp = explode(".", $_GET['mapid']);
+ $mapID = $tmp[0] * 1;
+ if (!is_int($mapID)) exit;
+ $map = getMapObjectByID($mapID);
+ sendCacheHeaders();
+ echo json_encode($map);
+ exit;
+}
-$expires = 365*24*60*60;
-//TODO: Remove this line once we're confident in data in the mapObject.
-$expires = 1*24*60*60;
-header("Cache-Control: public, maxage=".$expires);
-header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
-header("Content-type: text/javascript");
-echo json_encode($map);
+function sendCacheHeaders() {
+ $expires = 365*24*60*60;
+ //TODO: Remove this line once we're confident in data in the mapObject.
+ $expires = 120;
+ header("Cache-Control: public, maxage=".$expires);
+ header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
+ header("Content-type: text/javascript");
+}
function getMapObjectByID($mapID) {
include_once('../includes/sqlEmbedded.php');
@@ -37,5 +51,27 @@ function getMapObjectByID($mapID) {
}
}
+function getMapIDsByDate($date) {
+ global $mysqli;
+ $sql = "SELECT MIN(mapOfTheDay.mapId) AS mapId
+ FROM `mapOfTheDay`
+ INNER JOIN
+ (
+ SELECT mapType, MIN(mapExpireTime) AS mapExpireTime
+ FROM mapOfTheDay
+ WHERE mapExpireTime > ?
+ GROUP BY mapType
+ ) AS expireTimes ON mapOfTheDay.mapType = expireTimes.mapType
+ AND mapOfTheDay.mapExpireTime = expireTimes.mapExpireTime
+ GROUP BY mapOfTheDay.mapType";
+ $stmt = $mysqli->prepare($sql);
+ $stmt->bind_param("s", $date);
+ $stmt->execute();
+ $stmt->bind_result($mapID);
+ while ($stmt->fetch()) {
+ $ids[] = $mapID;
+ }
+ return $ids;
+}
?> \ No newline at end of file
diff --git a/ajax/scores.ajax.php b/ajax/scores.ajax.php
index 7ba25d0..f2d38fc 100644
--- a/ajax/scores.ajax.php
+++ b/ajax/scores.ajax.php
@@ -8,153 +8,37 @@ $userID = $_SESSION['userID'];
require('../includes/maps.php');
require('../includes/mapclass.php');
require('../includes/datas.php');
-include_once('../includes/sqli.php');
-
-if ($_GET['getmap'] == 'true') {
- $mapID = $_GET['mapID'];
- $code = getMapCode($mapID);
- $map = GenerateMapByCode($code);
- echo displaymap($map, $mapID);
-}
-
-
-if ($_GET['getscores'] == 'true') {
-
-}
-
-if ($_GET['getmaplist'] == 'true') {
- $daysAgo = $_GET['daysago'];
- //echo "$daysAgo";
- $todaysScoreMaps = getMapsPlayed($daysAgo);
- echo getMapNavigation($todaysScoreMaps);
-}
-
-if (isset($_GET['getmapidsbydate'])) {
- //TODO: SANATIZE
- $requestDate = $_GET['getmapidsbydate'];
- echo json_encode(getMapIDsByDate($requestDate));
-}
-
-// Here is that SQL for you
-// SELECT correctMapIds.mapType, maps.ID, maps.code
-// FROM maps
-// INNER JOIN
-// (
- // SELECT MIN(mapOfTheDay.mapId) AS mapId, mapOfTheDay.mapType
- // FROM `mapOfTheDay`
- // INNER JOIN
- // (
- // SELECT mapType, MIN(mapExpireTime) AS mapExpireTime
- // FROM mapOfTheDay
- // WHERE mapExpireTime > DATE_ADD(CURDATE(), INTERVAL -1 DAY)
- // GROUP BY mapType
- // ) AS expireTimes ON mapOfTheDay.mapType = expireTimes.mapType
- // AND mapOfTheDay.mapExpireTime = expireTimes.mapExpireTime
- // GROUP BY mapOfTheDay.mapType
-// ) AS correctMapIds ON maps.ID = correctMapIds.mapId
-
-//TODO: SANITIZE.
-function getMapIDsByDate($date) {
- global $mysqli;
-$sql = "SELECT MIN(mapOfTheDay.mapId) AS mapId
-FROM `mapOfTheDay`
-INNER JOIN
-(
- SELECT mapType, MIN(mapExpireTime) AS mapExpireTime
- FROM mapOfTheDay
- WHERE mapExpireTime > ?
- GROUP BY mapType
-) AS expireTimes ON mapOfTheDay.mapType = expireTimes.mapType
- AND mapOfTheDay.mapExpireTime = expireTimes.mapExpireTime
-GROUP BY mapOfTheDay.mapType";
-
-$stmt = $mysqli->prepare($sql);
-$stmt->bind_param("s", $date);
-$stmt->execute();
-
- $stmt->bind_result($mapID);
- /* fetch values */
- while ($stmt->fetch()) {
- $ids[] = $mapID;
- }
-
- return $ids;
-
-var_dump($ids);
-
-
-while ($myrow[] = $result->fetch_assoc()) {}
-
- $result = mysql_query($sql) or die(mysql_error());
- if (mysql_num_rows($result) == 0) return -1;
- global $mapNamesByType;
- $r = array();
- while($data[] = mysql_fetch_array($result)) {
- $mapID = $data['mapID'];
- $mapType = $data['mapType'];
- $map = new map($code);
- if ($map->name == '')
- $map->name = $mapNamesByType[$mapType];
- $r[$mapID] = $map;
+include_once('../includes/sqlEmbedded.php');
+
+$tmp = explode('.', $_GET['r']);
+$args = explode('_', $tmp[0]);
+$mapID = $args[0] * 1;
+$page = $args[1] * 1;
+
+if (!is_int($mapID) OR !is_int($page)) return;
+
+//Include the notification text
+$json = getScores($mapID, $page, 10);
+$json['mapid'] = $mapID;
+$json['page'] = $page;
+
+//TODO: Show notifications someplace else!
+$note = false;
+if ($_SESSION['accepted'] == 1) {
+ $userID = $_SESSION['userID'];
+ $note = getNotified($userID);
+} else {
+ if ($_SESSION['preCompletedTutorial'] == true && $_SESSION['preCompletedTutorialNotified'] == false) {
+ $_SESSION['preCompletedTutorialNotified'] = true;
+ $note = "<strong>Tutorial Completed!</strong>";
+ $note .= "<center>You've unlocked: Blue Wall Color!";
+ $note .= "<table><tr><td onclick='changeWallColor(\"#4444ff\")' style='background-color:#4444ff;' class='grid_td_rocks'></td></tr></table>";
+ $note .= '<br /><a href="javascript:showSignin();"><strong>Sign in</strong></a> to save your progress!<br />';
+ $note .= "</center>";
}
- return $myrow;
}
+if ($note !== false) $json['notificationtext'] = $note;
-
-function getMapsPlayed($daysAgo) {
- // $sql = "
- // SELECT `mapID`, `code`, `mapType`
- // FROM `mapOfTheDay`
- // INNER JOIN `maps` ON `mapID` = maps.ID
- // WHERE DATE_ADD(CURDATE(), INTERVAL -$daysAgo DAY) =
- // mapDate AND
- // `mapType` IN (1, 2, 3, 4, 5)
- // ";
-
- $sql = "SELECT correctMapIds.mapType, maps.ID as mapID, maps.code
-FROM maps
-INNER JOIN
-(
- SELECT MIN(mapOfTheDay.mapId) AS mapId, mapOfTheDay.mapType
- FROM `mapOfTheDay`
- INNER JOIN
- (
- SELECT mapType, MIN(mapExpireTime) AS mapExpireTime
- FROM mapOfTheDay
- WHERE mapExpireTime > DATE_ADD(CURDATE(), INTERVAL -$daysAgo DAY)
- GROUP BY mapType
- ) AS expireTimes ON mapOfTheDay.mapType = expireTimes.mapType
- AND mapOfTheDay.mapExpireTime = expireTimes.mapExpireTime
- GROUP BY mapOfTheDay.mapType
-) AS correctMapIds ON maps.ID = correctMapIds.mapId";
-
- $result = mysql_query($sql) or die(mysql_error());
- if (mysql_num_rows($result) == 0)
- return -1;
- global $mapNamesByType;
- $r = array();
- while($data = mysql_fetch_array($result)) {
- $code = $data['code'];
- $mapID = $data['mapID'];
- $mapType = $data['mapType'];
- $map = new map($code);
- if ($map->name == '') $map->name = $mapNamesByType[$mapType];
- $r[$mapID] = $map;
-
- }
- return $r;
-}
-
-function getMapNavigation(&$maps) {
- foreach ($maps as $mapID => &$map) {
- $r .= "<div class='mapThumbnail' onclick='displayMap($mapID)'>";
- $r .= $map->name;
- $r .= DisplayMapThumbnail($map);
- $r .= "</div>";;
- }
- return $r;
-}
-
-
+echo json_encode($json);
?> \ No newline at end of file
diff --git a/ajax/users.ajax.php b/ajax/users.ajax.php
index 7ee9cc2..9ac3754 100644
--- a/ajax/users.ajax.php
+++ b/ajax/users.ajax.php
@@ -3,7 +3,7 @@ ob_start("ob_gzhandler");
//include('../includes/mapclass.php');
//include('../includes/maps.php');
-include_once('../includes/sqli.php');
+include_once('../includes/sqlEmbedded.php');
//Remove the ending .js
$tmp = explode(".", $_GET['userid']);