summaryrefslogtreecommitdiffstats
path: root/do.php
diff options
context:
space:
mode:
Diffstat (limited to 'do.php')
-rw-r--r--do.php85
1 files changed, 60 insertions, 25 deletions
diff --git a/do.php b/do.php
index c82de22..bbaa665 100644
--- a/do.php
+++ b/do.php
@@ -56,6 +56,18 @@ if (isset($_GET['checkachieve']) && $_GET['checkachieve'] == 'true' && $_SESSION
$json['notificationtext'] = $note;
}
+if ($_GET['r'] == 'reqMemberPage') {
+
+ $order = 'ORDER BY dateJoined DESC';
+ $page = $_GET['reqPage'] + 0;
+ if (!is_int($page))
+ return;
+ $json = getMembers($order, $page, 4);
+ $json['page'] = $page;
+ $encoded = json_encode($json);
+ die($encoded);
+}
+
if ($_GET['r'] == 'reqScorePage') {
$mapID = $_GET['mapid'] + 0;
$page = $_GET['reqPage'] + 0;
@@ -107,14 +119,14 @@ if ($_GET['r'] == 'getsol') {
$userID = $_SESSION['userID'];
-///// TODO: FIX FIX FIX FIX FIX FIX //////
- if ($_SESSION['accepted'] == 1) {
- $json = getSolution($userID, $mapID);
- if ($tmp['moves'] > $_SESSION[$mapID.'sol']) {
- $json = $tmp;
- }
+ $json['solution'] = '';
+ $json['moves'] = 0;
+ if ($accepted) {
+ $sol = getSolution($userID, $mapID);
+ $json['solution'] = $sol['solution'];
+ $json['moves'] = $sol['moves'];
}
- if (isset($_SESSION[$mapID.'sol'])) {
+ if (isset($_SESSION[$mapID.'sol']) && $_SESSION[$mapID.'moves'] > $json['moves']) {
$json['solution'] = $_SESSION[$mapID.'sol'];
$json['moves'] = $_SESSION[$mapID.'moves'];
}
@@ -125,6 +137,22 @@ if ($_GET['r'] == 'getsol') {
die($encoded);
}
+if ($_GET['r'] == 'getChallengeSolution') {
+ $mapID = $_GET['mapID'] + 0;
+ $challengeID = $_GET['challengeID'] + 0;
+ //echo "working...";
+ if (!is_int($mapID) OR !is_int($challengeID)) return;
+ if (!$accepted) return;
+
+ $userID = $_SESSION['userID'];
+
+ $json = getChallengeSolution($userID, $challengeID);
+
+ $json['mapid'] = $mapID;
+ $encoded = json_encode($json);
+ die($encoded);
+}
+
// ------------ MAIN; getpath.
if ($_GET['r'] == 'getpath') {
@@ -137,7 +165,8 @@ if ($_GET['r'] == 'getpath') {
// Enables the ability to discover an exact duplicate solution.
$solution = formSolution($_GET['solution']);
-
+ $userID = $_SESSION['userID'];
+
//valid mapID?
$mapID = $_GET[mapid] + 0;
if (!is_int($mapID)) return;
@@ -176,9 +205,15 @@ if ($_GET['r'] == 'getpath') {
$encoded = json_encode($json);
die($encoded);
}
+
+ if ($_GET['isChallenge'] == 'true' AND isChallengeMap($mapID)) {
+ // $firephp->log('Calling challenges');
+ $json['completedChallenges'] = getCompletedChallenges($userID, $mapID, $solution, $moves, $json['path']);
+ // $firephp->log('Challenges called!');
+ die(json_encode($json));
+ }
//Get current score data. - to see if a pertinent score was beat.
- $userID = $_SESSION['userID'];
$sql = "SELECT `moves` as bestmoves, `displayName`, IFNULL(q1.mymoves, 0)
FROM `solutions`, `users`
LEFT JOIN (
@@ -203,8 +238,10 @@ if ($_GET['r'] == 'getpath') {
$json['best'] = 0;
$json['bestby'] = 'no one';
}
-
- // --------- RUSH THE PATH BACK TO THE USER
+
+ // --------- ------------------------------ ---------
+ // --------- RUSH THE PATH BACK TO THE USER ---------
+ // --------- ------------------------------ ---------
if (!$debug) {
ignore_user_abort(true);
$encoded = json_encode($json);
@@ -212,22 +249,21 @@ if ($_GET['r'] == 'getpath') {
header("Content-Length: " . mb_strlen($encoded));
echo $encoded;
flush();
+ //The connection is now closed, no further communication to the client can be done!
}
+ // --------- CONTINUE EXECUTION ---------
- $json['error'][] = "bestMoves, byName, myMoves: $bestMoves, $byName, $myMoves;";
-
- // --------- CONTINUE EXECUTION
+ // Now we don't have to worry about how long we're taking.
+ // All of this code will execute without the user waiting on the server.
+
+ //$json['error'][] = "bestMoves, byName, myMoves: $bestMoves, $byName, $myMoves;";
//TODO: Commented this out - temporarly.
// $firephp->log('Got this far');
// $firephp->log($_SESSION['accepted'], '$_SESSION["accepted"]');
////Challenge/Tutorial?
- // if ($_GET['isChallenge'] == 'true') {
- // $firephp->log('Calling challenges');
- // $json['completedChallenges'] = getCompletedChallenges($userID, $mapID, $solution, $moves, $json['path']);
- // $firephp->log('Challenges called!');
- // }
+
////--------- RUSH THE PATH BACK TO THE USER
// ignore_user_abort(true);
@@ -255,10 +291,9 @@ if ($_GET['r'] == 'getpath') {
$_SESSION['preCompletedTutorialNotified'] = false;
}
if ($accepted == false)
- return;
-
+ die(json_encode($json));
getCompletedChallenges($userID, $mapID, $solution, $moves, $paths);
- return;
+ die(json_encode($json));
}
@@ -332,12 +367,12 @@ if ($_GET['r'] == 'getpath') {
$json['error'][] = 'Rush-send failed';
-$encoded = json_encode($json);
-die($encoded);
+//$encoded = json_encode($json);
+die(json_encode($json));
function isCurrentMap($mapID) {
- // TODO: Broke
+ // TODO: change methodology
include_once('./includes/db.inc.php');
$sql = "SELECT maps.ID
FROM `mapOfTheDay`