diff options
-rw-r--r-- | do.php | 83 | ||||
-rw-r--r-- | globe.php | 10 | ||||
-rw-r--r-- | includes/datas.php | 4 | ||||
-rw-r--r-- | includes/header.php | 12 | ||||
-rw-r--r-- | includes/maps.php | 34 | ||||
-rw-r--r-- | index.php | 80 | ||||
-rw-r--r-- | pages/cp.php | 4 | ||||
-rw-r--r-- | pages/home.php | 22 | ||||
-rw-r--r-- | pages/leaderboard.php | 85 | ||||
-rw-r--r-- | pages/login.php | 6 | ||||
-rw-r--r-- | pages/tutorial.php | 7 |
11 files changed, 176 insertions, 171 deletions
@@ -7,19 +7,19 @@ include "includes/datas.php"; //Auto login;
include_once("globe.php");
-if ($_SESSION['accepted'] <> 1)
- if ($_COOKIE['doLogin'] == 'yes')
+if (!isset($_SESSION['accepted']) || $_SESSION['accepted'] <> 1)
+ if (isset($_COOKIE['doLogin']) && $_COOKIE['doLogin'] == 'yes')
CookieLogin();
// encode array $json to JSON string
-
-if ($_GET['act'] == "getmap") {
+
+if (isset($_GET['act']) && $_GET['act'] == "getmap") {
$map = GenerateMapByCode($_GET['mapcode']);
-
+
$solution = formSolution($_GET['solution']);
-
+
$solvedmap = MergeMapSolution($map, $solution);
if ($solvedmap == -1) {
$json['error'][] = "INVALID WALL POSITIONS";
@@ -29,21 +29,21 @@ if ($_GET['act'] == "getmap") { }
}
-if ($_GET['checkachieve'] == 'true' AND $_SESSION['accepted'] == 1) {
+if (isset($_GET['checkachieve']) && $_GET['checkachieve'] == 'true' && $_SESSION['accepted'] == 1) {
$json['notification'] = true;
-
+
$userID = $_SESSION['userID'];
-
+
//Located in includes/datas.php
$note = getNotified($userID);
-
+
if ($note !== false)
$json['notificationtext'] = $note;
}
if ($_GET['r'] == 'getscores') {
$mapID = $_GET['mapid'] + 0;
- if (!is_int($mapID))
+ if (!is_int($mapID))
return;
$topscores = topScores($mapID, 30);
$json['scores'] = $topscores;
@@ -58,7 +58,7 @@ if ($_GET['r'] == 'getsol') { if (!is_int($mapID)) return;
$userID = $_SESSION['userID'];
-
+
if ($_SESSION['accepted'] == 1)
$json = getSolution($userID, $mapID);
if (isset($_SESSION[$mapID.'sol']) AND $mysolution == '') {
@@ -66,7 +66,7 @@ if ($_GET['r'] == 'getsol') { $json['moves'] = $_SESSION[$mapID.'moves'];
}
$json['mapid'] = $mapID;
-
+
$encoded = json_encode($json);
die($encoded);
}
@@ -76,36 +76,36 @@ if ($_GET['r'] == 'getsol') { if ($_GET['r'] == 'getpath') {
//Join the partial-solution from the map, and the solution sent.
- //Could be used to validate maps in for challenges where
+ //Could be used to validate maps in for challenges where
// getting the map code from the database is not an option
//$tmp = GenerateMapByCode($_GET['mapcode']);
//$tmp = seperateMapSolution($tmp);
//$solution = formSolution($_GET['solution'].$tmp);
-
+
// Enables the ability to discover an exact duplicate solution.
$solution = formSolution($_GET['solution']);
- //valid mapID?
+ //valid mapID?
$mapID = $_GET[mapid] + 0;
if (!is_int($mapID)) return;
-
+
//the first 10 ID's reserved for challenges & tutorial.
if ($mapID > 10)
$mapcode = getMapCode($mapID);
- else
+ else
$mapcode = $_GET['mapcode'];
-
+
//mygrid will be the map, with the solution applied.
$map = GenerateMapByCode($mapcode);
$mygrid = MergeMapSolution($map, $solution);
-
+
//Route the path
$json = routePath($mygrid, $start);
-
+
$moves = $json['moves'];
$json['mapid'] = $mapID;
-
+
//What could go wrong?
if ($json['blocked']) {
//$json['error'][] = "blocked";
@@ -133,10 +133,10 @@ if ($_GET['r'] == 'getpath') { FROM `solutions`
WHERE `userID` = '$userID' AND
`mapID` = '$mapID'
- ) as q1
+ ) as q1
ON 1
WHERE
- `mapID` = '$mapID' AND
+ `mapID` = '$mapID' AND
`userID` = users.ID
ORDER BY `moves` DESC, `dateModified` ASC
LIMIT 1";
@@ -150,18 +150,18 @@ if ($_GET['r'] == 'getpath') { $json['best'] = 0;
$json['bestby'] = 'no one';
}
-
+
// --------- RUSH THE PATH BACK TO THE USER
ignore_user_abort(true);
$encoded = json_encode($json);
header("Connection: close");
- header("Content-Length: " . mb_strlen($encoded));
+ header("Content-Length: " . mb_strlen($encoded));
echo $encoded;
flush();
-
+
// --------- CONTINUE EXECUTION
-
-
+
+
// --------- USER NOT LOGGED IN?
if ($_SESSION['accepted'] !== 1) {
if ($moves >= ($_SESSION[$mapID.'moves'] + 0)) {
@@ -171,27 +171,27 @@ if ($_GET['r'] == 'getpath') { return;
}
// --------- USER LOGGED IN
-
+
//Challenge/Tutorial?
if ($mapID <= 10 AND $_GET['isChallenge'] = 'true') {
//echo "running function".$_GET['challengeID'];
applyChallengeAchievements($userID, $_GET['challengeID'], $mapID, $solution, $moves);
return;
}
-
+
//Is the map still valid to score on?
if (!isCurrentMap($mapID))
return;
// --------- UPDATE SCORES
-
+
$checkcp = false;
$checkcm = false;
-
+
//Is there an existing record?
if ($myMoves > 0) {
if ($myMoves < $moves) {
- $sql = "UPDATE `solutions`
+ $sql = "UPDATE `solutions`
SET `moves` = '$moves' ,
`dateModified` = NOW() ,
`solution` = '$solution'
@@ -201,13 +201,12 @@ if ($_GET['r'] == 'getpath') { $checkcp = true;
//Update the solution only, if it's the same score.
} elseif ($myMoves == $moves) {
- $sql = "UPDATE `solutions`
+ $sql = "UPDATE `solutions`
SET `moves` = '$moves' ,
`solution` = '$solution'
WHERE `userID` = '$userID' AND
`mapID` = '$mapID'";
mysql_query($sql);
-
}
//Create a new record.
} else {
@@ -217,7 +216,7 @@ if ($_GET['r'] == 'getpath') { $checkcm = true;
$checkcp = true;
}
-
+
// --------- APPLY ACHIEVEMENTS
if ($checkcp)
@@ -231,7 +230,7 @@ if ($_GET['r'] == 'getpath') { // no need w/ rush-sending.
//$encoded = json_encode($json);
//echo $encoded;
-
+
// --------- END
}
@@ -243,9 +242,9 @@ function isCurrentMap($mapID) { `mapID` = '$mapID'
";
$result = mysql_query($sql) or die(mysql_error());
- if (mysql_num_rows($result) == 0)
+ if (mysql_num_rows($result) == 0)
return false;
- else
+ else
return true;
}
@@ -271,7 +270,7 @@ function ValidateMap($mygrid) { $json['error'][] = 'Division by 912 trillion!';
$json['error'][] = 'Cant count that high.';
-
+
$json['error'][] = "I forgot what I was doing!";
$json['error'][] = "Lost track of time, and gaveup!";
@@ -280,4 +279,4 @@ die($encoded); -?>
\ No newline at end of file +?>
@@ -1,5 +1,7 @@ <?PHP
-session_start();
+date_default_timezone_set('America/Los_Angeles'); +if (!session_id())
+ session_start();
//session_regenerate_id();
//Database login:
@@ -45,8 +47,8 @@ function CookieLogin() { if ($auth == $three) {
$_SESSION['accepted'] = 1;
- $_SESSION['userID'] = $userID;
- $_SESSION['displayName'] = $display;
+ $_SESSION['userID'] = $userID;
+ $_SESSION['displayName'] = $display;
if ($isAdmin == 1)
$_SESSION['isAdmin'] = true;
@@ -181,4 +183,4 @@ function EmailError($data) { Return $mail_sent;
}
-?>
\ No newline at end of file +?> diff --git a/includes/datas.php b/includes/datas.php index 5d901ee..c445ca1 100644 --- a/includes/datas.php +++ b/includes/datas.php @@ -26,9 +26,9 @@ function topScores($mapid, $top = 5, $bottom = 0) { ORDER BY solutions.moves DESC, solutions.dateModified ASC LIMIT $bottom, $top "; - $result = mysql_query($sql); + $result = mysql_query($sql) or die(mysql_error()); $utime = date("g:i A (T)"); - $output .= "<table class='score'>"; + $output = "<table class='score'>"; $output .= "<tr title='Updated $utime'>"; $output .= "<th>Rank</th>"; $output .= "<th>Badge</th>"; diff --git a/includes/header.php b/includes/header.php index d718588..887aa41 100644 --- a/includes/header.php +++ b/includes/header.php @@ -1,6 +1,7 @@ <?php
-
+$accepted = isset($_SESSION['accepted']) && $_SESSION['accepted'] == 1;
function htmlHeader($css = array(), $title = 'Pathery', $desc = '') {
+ global $accepted;
?>
<!DOCTYPE html>
<html xml:lang="en" lang="en">
@@ -25,7 +26,7 @@ function htmlHeader($css = array(), $title = 'Pathery', $desc = '') { for(e=0;e<g.length;e++)(function(a){b[a]=function(){b.push([a].concat(Array.prototype.slice.call(arguments,0)))}})(g[e]);c._i.push([a,d,f])};window.mixpanel=c})(document,[]);
mixpanel.init("24743c6567f831ddfcbbbd3f397e11e4");
<?php
- if ($_SESSION['accepted'] == 1) {
+ if ($accepted) {
if ($_SESSION['displayName'] != 'noname')
echo 'mixpanel.name_tag(' . json_encode($_SESSION['displayName']) . ');';
if ($_SERVER['HTTP_HOST'] == 'www.pathery.com')
@@ -89,11 +90,10 @@ function htmlFooter() { }
function topbar($links) {
+ global $accepted;
echo '<div id="topbar">';
- $page = $_GET['page'];
- if ($page == '')
- $page = 'home';
+ $page = isset($_GET['page']) ? $_GET['page'] : 'home';
foreach ($links as $key => $value) {
if ($page == $key)
$selected = " selected";
@@ -103,7 +103,7 @@ function topbar($links) { }
echo "<div id='user'>";
- if ($_SESSION['accepted'] == 1) {
+ if ($accepted) {
echo "Logged in as <a href='cp' title='change name'>$_SESSION[displayName]</a><br>";
if ($_SESSION['displayName'] == 'noname')
echo "<a href='cp' title='change name'>Update your name</a> | ";
diff --git a/includes/maps.php b/includes/maps.php index 4618ff8..16aa35c 100644 --- a/includes/maps.php +++ b/includes/maps.php @@ -109,7 +109,7 @@ function DisplayMap($mapMatrix, $idprefix = 1, $style = 'normal', $speed = NULL) $jsonmap = str_replace("'", "\'", json_encode($mapdata));
//This works in chrome, not sure about others.
- $preloaddiv .= "
+ $preloaddiv = "
<div style='visibility:hidden;display:none'>
<img src='images/Path1.png' alt=''>
<img src='images/Path2.png' alt=''>
@@ -134,16 +134,20 @@ function DisplayMap($mapMatrix, $idprefix = 1, $style = 'normal', $speed = NULL) <table style='width:$width;height:$height;' class='grid_table'>
$maptable
</table>";
-
-
- $prefSpeed = $_COOKIE['pref_speed'];
- $speedOption['Slow'] = 1;
- $speedOption['Med'] = 2;
- $speedOption['Fast'] = 3;
- $speedOption['Ultra'] = 4;
- if (!in_array($prefSpeed, $speedOption))
+
+
+ if (isset($_COOKIE['pref_speed'])) {
+ $prefSpeed = $_COOKIE['pref_speed'];
+ $speedOption['Slow'] = 1;
+ $speedOption['Med'] = 2;
+ $speedOption['Fast'] = 3;
+ $speedOption['Ultra'] = 4;
+ if (!in_array($prefSpeed, $speedOption))
+ $prefSpeed = '2';
+ } else
$prefSpeed = '2';
+ $rOption = '';
foreach ($speedOption as $key => $value) {
$rOption .= "<option value='$value'";
if ($prefSpeed == $value)
@@ -151,7 +155,7 @@ function DisplayMap($mapMatrix, $idprefix = 1, $style = 'normal', $speed = NULL) $rOption .= ">$key</option>\n";
}
- if ($_COOKIE['pref_mute'] == "true") {
+ if (isset($_COOKIE['pref_mute']) && $_COOKIE['pref_mute'] == "true") {
$mutebutton = "<label><input onclick='savePref(\"mute\", this.checked)' type='checkbox' id='$idprefix,mute' checked='checked' />Mute</label>";
} else {
$mutebutton = "<label><input onclick='savePref(\"mute\", this.checked)' type='checkbox' id='$idprefix,mute' />Mute</label>";
@@ -400,27 +404,27 @@ function GenerateShapedMap($shape, $params) { // $checkpoints++;
//Confirm params.
- if ($params['rockchance'])
+ if (isset($params['rockchance']))
$rockchance = $params['rockchance'];
else
$rockchance = 10;
- if ($params['checkpoints'])
+ if (isset($params['checkpoints']))
$checkpoints = $params['checkpoints'];
else
$checkpoints = 0;
- if ($params['teleports'])
+ if (isset($params['teleports']))
$teleports = $params['teleports'];
else
$teleports = 0;
- if ($params['name'])
+ if (isset($params['name']))
$mapName = $params['name'];
else
$mapName = '';
- if (is_int($params['walls']))
+ if (isset($params['walls']) && is_int($params['walls']))
$walls = $params['walls'];
else
$walls = 13;
@@ -2,31 +2,29 @@ include_once("globe.php");
include_once("./includes/header.php");
-//Load our page
-if ($_SESSION['accepted'] <> 1)
- if ($_COOKIE['doLogin'] == 'yes')
+if (!$accepted)
+ if (isset($_COOKIE['doLogin']) && $_COOKIE['doLogin'] == 'yes')
CookieLogin();
-
//Links appear in order.
$Links['home'] = "Home";
$Links['leaderboard'] = "Scoreboard";
-//$Links['howtoplay'] = "How to Play";
-$Links['tutorial'] = "Tutorial";
+//$Links['howtoplay'] = "How to Play";
+$Links['tutorial'] = "Tutorial";
-if ($_SESSION['accepted'] == 1) {
+if ($accepted) {
$linkname = 'achievements?id='.$_SESSION['userID'];
$Links[$linkname] = "Achievements";
}
$Links['members'] = "<i title='New!'>Member List</i>";
-if ($_SESSION['isAdmin'] == true) {
+if (isset($_SESSION['isAdmin']) && $_SESSION['isAdmin'] == true) {
$Links['admin'] = 'Admin';
}
$Links['faq'] = "FAQ";
$Links['about'] = "About Us";
-$request = strtolower($_GET[page]);
-if ($request == '' AND $_SESSION['accepted'] <> 1)
+$request = isset($_GET['page']) ? strtolower($_GET['page']) : '';
+if ($request == '' && !$accepted)
$request = 'hometutorial';
switch ($request) {
@@ -35,77 +33,77 @@ switch ($request) { require("pages/tutorial.php");
break;
- case "test":
+ case "test":
require("pages/test.php");
break;
-
- case "m":
+
+ case "m":
require("pages/mobile.php");
break;
-
- case "h":
+
+ case "h":
require("pages/newhome.php");
break;
-
- case "achievements":
+
+ case "achievements":
require("pages/achievements.php");
break;
-
- case "share":
+
+ case "share":
require("pages/share.php");
break;
-
- case "embed":
+
+ case "embed":
require("pages/embed.php");
break;
-
+
case "about":
require("pages/about.php");
break;
-
+
case "gallery":
require("pages/gallery.php");
break;
-
+
case "faq":
require("pages/faq.php");
- break;
-
+ break;
+
case "laws":
require("pages/laws.php");
break;
-
+
case "howtoplay":
require("pages/howtoplay.php");
break;
-
+
case "leaderboard":
require("pages/leaderboard.php");
- break;
-
+ break;
+
case "cp":
require("pages/cp.php");
break;
-
+
case "login":
require 'pages/login.php';
- break;
-
+ break;
+
case "chooselogin":
require 'pages/chooselogin.php';
- break;
-
+ break;
+
case "admin":
if ($_SESSION['isAdmin'] == true)
require 'pages/admin.php';
- else
+ else
require 'pages/about.php';
break;
-
+
case "members":
require 'pages/memberlist.php';
break;
-
+
case "logout":
//If this needs to be any larger we can move it to a function.
setcookie("doLogin", "");
@@ -115,7 +113,7 @@ switch ($request) { session_destroy();
header("Location: $mydomain");
break;
-
+
case "users":
require 'pages/users.php';
break;
@@ -123,8 +121,8 @@ switch ($request) { case "challenge":
require 'pages/challenge.php';
break;
-
- case "home":
+
+ case "home":
//No break here
Default:
require("pages/home.php");
diff --git a/pages/cp.php b/pages/cp.php index 2abc6b4..c6bcf93 100644 --- a/pages/cp.php +++ b/pages/cp.php @@ -26,7 +26,7 @@ if (isset($_POST['displayName'])) { $inputname = chatFilter($inputname);
$userID = $_SESSION['userID'];
- if ($_SESSION['accepted'] == 1) {
+ if ($accepted) {
if (validatename($inputname)) {
$sql = "UPDATE `users`
SET `displayName` = '$inputname'
@@ -79,4 +79,4 @@ function chatFilter($chat) { htmlFooter();
-?>
\ No newline at end of file +?>
diff --git a/pages/home.php b/pages/home.php index e9b65be..b1335a4 100644 --- a/pages/home.php +++ b/pages/home.php @@ -9,7 +9,8 @@ include_once ('./includes/datas.php'); //Get custom wall colors;
$wallColor = '';
$wallEmblem = '';
-if ($_SESSION[accepted] == 1) {
+$noteScript = '';
+if ($accepted) {
$userID = $_SESSION['userID'];
$sql = "
@@ -87,8 +88,8 @@ switch ($numday) { <body>
<script type="text/javascript">
-playerWallColor = '<?PHP echo $wallColor; ?>';
-playerWallEmblem = '<?PHP echo $wallEmblem; ?>';
+playerWallColor = '<?PHP echo isset($wallColor) ? $wallColor : ''; ?>';
+playerWallEmblem = '<?PHP echo isset($wallEmblem) ? $wallEmblem : ''; ?>';
</script>
<?php
@@ -101,7 +102,7 @@ topbar($Links); <?
-if ($_SESSION['accepted'] == 1) {
+if ($accepted) {
if (tutorialComplete($userID) == false) {
echo "<center><a href='tutorial'>Complete the tutorial</a> to unlock a blue wall color:";
echo "<table><tr><td style='background-color:#4444ff;' class='grid_td_rocks'></td></tr></table></center><br />";
@@ -110,7 +111,7 @@ if ($_SESSION['accepted'] == 1) { $motd = MapOfTheDay(1);
$jmid[1] = $motd['id'];
-$mapContent .= displayMaze($motd, 1);
+$mapContent = displayMaze($motd, 1);
$motd = MapOfTheDay(2);
$jmid[2] = $motd['id'];
@@ -148,7 +149,7 @@ if ($special == '') { <?
function displayMaze($motd, $mapType) {
-
+ global $accepted, $userID;
//Gather data for map;
$mapID = $motd['id'];
$map = $motd['map'];
@@ -158,19 +159,20 @@ function displayMaze($motd, $mapType) { $topscores = topScores($motd['id'], 30);
$topscorediv = "<div id='$mapID,dspScore'>\n$topscores\n</div>";
- $userID = $_SESSION['userID'];
- if ($_SESSION['accepted'] == 1) {
+ $mysolution = '';
+ $mymoves = '';
+ if ($accepted) {
$sol = getSolution($userID, $mapID);
$mysolution = $sol['solution'];
//!! implement mymoves
$mymoves = $sol['moves'];
}
- if (isset($_SESSION[$mapID.'sol']) AND $mysolution == '') {
+ if (isset($_SESSION[$mapID.'sol']) && $mysolution == '') {
$mysolution = $_SESSION[$mapID.'sol'];
$mymoves = $_SESSION[$mapID.'moves'];
}
- $r .= "<div id=\"yms-$mapType\" class='hidden-maps'>";
+ $r = "<div id=\"yms-$mapType\" class='hidden-maps'>";
$r .= " <div class='wrapper'>";
// if ($width <= 16) {
diff --git a/pages/leaderboard.php b/pages/leaderboard.php index 8f4dcc6..440f1e5 100644 --- a/pages/leaderboard.php +++ b/pages/leaderboard.php @@ -13,28 +13,29 @@ include('./includes/datas.php'); include_once ('./includes/db.inc.php');
-
-//Holy non-PHP included function batman.
-function date_diff($date1, $date2) {
- $current = $date1;
- $datetime2 = date_create($date2);
- $count = 0;
- while(date_create($current) < $datetime2){
- $current = gmdate("Y-m-d", strtotime("+1 day", strtotime($current)));
- $count++;
- }
- return $count;
-}
+function day_diff($date1, $date2) {
+ $current = $date1;
+ $datetime2 = date_create($date2);
+ $count = 0;
+ while(date_create($current) < $datetime2){
+ $current = gmdate("Y-m-d", strtotime("+1 day", strtotime($current)));
+ $count++;
+ }
+ return $count;
+}
//The date to display
$dateDisplay = date('Y-m-d', strtotime("-1 days"));
//This is only used in a strtotime function, so this should be safe.
-$dateLookup = $_GET['date'];
-if (!strtotime($dateLookup))
+if (isset($_GET['date'])) {
+ $dateLookup = $_GET['date'];
+ if (!strtotime($dateLookup))
+ $dateLookup = $dateDisplay;
+} else
$dateLookup = $dateDisplay;
-$daysAgo = date_diff($dateLookup, date('Y-m-d'));
+$daysAgo = day_diff($dateLookup, date('Y-m-d'));
$dateAgo = strtotime("-$daysAgo days");
$dateAsStr = date('l F jS Y', $dateAgo);
@@ -55,13 +56,13 @@ $mStats = getStat(4, $daysAgo); function getStat ($type, $daysAgo = 1) {
switch ($type) {
-
+
//Todays
case 1:
$where = "
- DATE_ADD(CURDATE(), INTERVAL -0 DAY) =
+ DATE_ADD(CURDATE(), INTERVAL -0 DAY) =
DATE_FORMAT(solutions.dateModified,'%Y-%m-%d')
- AND DATE_ADD(CURDATE(), INTERVAL -0 DAY) =
+ AND DATE_ADD(CURDATE(), INTERVAL -0 DAY) =
DATE_FORMAT(maps.dateCreated,'%Y-%m-%d')
";
$statname = "Today's Best Overall:";
@@ -69,9 +70,9 @@ function getStat ($type, $daysAgo = 1) { //Yesterdays
case 2:
$where = "
- DATE_ADD(CURDATE(), INTERVAL -$daysAgo DAY) =
+ DATE_ADD(CURDATE(), INTERVAL -$daysAgo DAY) =
DATE_FORMAT(solutions.dateModified,'%Y-%m-%d')
- AND DATE_ADD(CURDATE(), INTERVAL -$daysAgo DAY) =
+ AND DATE_ADD(CURDATE(), INTERVAL -$daysAgo DAY) =
DATE_FORMAT(maps.dateCreated,'%Y-%m-%d')
";
$statname = "Yesterday's Best Overall:";
@@ -81,7 +82,7 @@ function getStat ($type, $daysAgo = 1) { break;
case 3:
$where = "
- YEARweek(solutions.dateModified) = YEARweek(CURRENT_DATE)
+ YEARweek(solutions.dateModified) = YEARweek(CURRENT_DATE)
";
$statname = "This week, starting Sunday";
break;
@@ -93,15 +94,15 @@ function getStat ($type, $daysAgo = 1) { break;
}
- $sql = "SELECT
- users.displayName as Name,
+ $sql = "SELECT
+ users.displayName as Name,
SUM(solutions.moves) as Moves,
timediff(MAX(dateModified), maps.dateCreated) as Timetaken,
userData.wallColor,
userData.wallEmblem,
userData.displayColor,
users.ID as userID
- FROM `maps`
+ FROM `maps`
JOIN `solutions`
ON maps.ID = solutions.mapID
JOIN `users`
@@ -131,7 +132,7 @@ if ($daysAgo > 1) { echo "<a href='leaderboard?date=$dateNextDay' title='Newer'>Next Day</a>";
}
echo "<a href='leaderboard?date=$datePrevDay' title='Older'>Previous Day</a>";
-
+
$statContent .= displayPastMaze(1, 'Simple', $daysAgo);
$statContent .= displayPastMaze(2, 'Normal', $daysAgo);
$statContent .= displayPastMaze(3, 'Complex', $daysAgo);
@@ -143,7 +144,7 @@ if ($specialMapName != '') ?>
</div>
-
+
<div id="difficulties">
<a href="javascript:showStats(1)" id="dl-1">Simple</a>
<a href="javascript:showStats(2)" id="dl-2">Normal</a>
@@ -161,18 +162,18 @@ function displayPastMaze($mapType, $name, $daysAgo = 1) { //Ensure no cheating
if ($daysAgo < 1)
return;
-
- $sql = "SELECT
+
+ $sql = "SELECT
maps.ID as mapID,
solution,
- users.displayName as Name,
+ users.displayName as Name,
SUM(solutions.moves) as Moves,
timediff(solutions.dateModified, maps.dateCreated) as Timetaken,
userData.wallColor,
userData.wallEmblem,
userData.displayColor,
users.ID as userID
- FROM `maps`
+ FROM `maps`
JOIN `solutions`
ON maps.ID = solutions.mapID
JOIN `users`
@@ -181,16 +182,16 @@ function displayPastMaze($mapType, $name, $daysAgo = 1) { ON maps.ID = mapOfTheDay.mapID
LEFT JOIN `userData`
ON users.ID = userData.userID
- WHERE DATE_ADD(CURDATE(), INTERVAL -$daysAgo DAY) =
+ WHERE DATE_ADD(CURDATE(), INTERVAL -$daysAgo DAY) =
DATE_FORMAT(solutions.dateModified,'%Y-%m-%d')
- AND DATE_ADD(CURDATE(), INTERVAL -$daysAgo DAY) =
+ AND DATE_ADD(CURDATE(), INTERVAL -$daysAgo DAY) =
DATE_FORMAT(maps.dateCreated,'%Y-%m-%d')
AND `mapType` = '$mapType'
GROUP BY solutions.userID
ORDER BY Moves DESC, `dateModified` ASC
";
$result = mysql_query($sql);
-
+
$statname = "Yesterday's Best $name:";
if ($daysAgo > 1) {
$statname = "$daysAgo days ago's Best $name:";
@@ -201,13 +202,13 @@ function displayPastMaze($mapType, $name, $daysAgo = 1) { $mapID = $pastMap;
$mapcode = getMapCode($mapID);
$map = GenerateMapByCode($mapcode);
-
+
//Sucky temporary solution:
$GLOBALS['specialMapName'] = $map[0][6];
-
+
$sql = "SELECT `moves`, `displayName`, `solution`
FROM `solutions`, `users`
- WHERE `mapID` = '$mapID' AND
+ WHERE `mapID` = '$mapID' AND
`userID` = users.ID
ORDER BY `moves` DESC, `dateModified` ASC
LIMIT 1";
@@ -219,7 +220,7 @@ function displayPastMaze($mapType, $name, $daysAgo = 1) { //echo DisplayMap($map, $mapID);
}
$r = '';
-
+
$r .= '<div style="clear: both"></div>';
$r .= "<div id=\"yms-$mapType\">";
$r .= '<div class="col1">';
@@ -228,7 +229,7 @@ function displayPastMaze($mapType, $name, $daysAgo = 1) { $r .= '<div class="col2">';
$r .= "Best solution for this map: <b>$bestMoves by $byName </b>";
- $r .= DisplayMap($map, $mapID, 'example', 2);
+ $r .= DisplayMap($map, $mapID, 'example', 2);
$r .= '</div>';
$r .= '</div>';
return $r;
@@ -246,8 +247,8 @@ function displaystats($result, $caption = NULL) { //Headers on the top. including Rank.
$r .= "<tr>";
$r .= $headers;
- $r .= "</tr>";
-
+ $r .= "</tr>";
+
$i = 1;
while ($row = mysql_fetch_assoc($result)) {
$rowcontent = '';
@@ -258,11 +259,11 @@ function displaystats($result, $caption = NULL) { $displayColor = $row['displayColor'];
$displayName = $row['Name'];
$userID = $row['userID'];
-
+
//Default
if ($wallColor == '')
$wallColor = '#666666';
-
+
$r .= "<tr class='lbrow' onmouseover='changeWallEmblem(\"$wallEmblem\"); changeWallColor(\"$wallColor\"); loadSol(\"$mapid:$solution\");'>\n";
$r .= "<td>$i</td>";
$r .= "<td><span title='UserID: $userID'><a href='achievements?id=$userID' style='color:$displayColor'>$displayName</a></span></td>";
diff --git a/pages/login.php b/pages/login.php index 49847c4..5042cd8 100644 --- a/pages/login.php +++ b/pages/login.php @@ -1,5 +1,5 @@ <?php
-if ($_SESSION['accepted'] == 1) {
+if ($accepted) {
header("Location: $mydomain");
exit;
}
@@ -110,10 +110,10 @@ try { '".sql_clean($display)."',
'".sql_clean($email)."',
NOW(), NOW())";
- $result = mysql_query($sql);
+ $result = mysql_query($sql) or die(mysql_error());
//Allright, all set.
//echo "$sql <br /> <br />";
- If ($result) {
+ if ($result) {
$userID = mysql_insert_id();
} //Oh crap?
else {
diff --git a/pages/tutorial.php b/pages/tutorial.php index 8e3b583..1965f51 100644 --- a/pages/tutorial.php +++ b/pages/tutorial.php @@ -12,7 +12,7 @@ topbar($Links); //!! Turn this into a function?
-if ($_SESSION[accepted] == 1) {
+if ($accepted) {
include_once ('./includes/db.inc.php');
$userID = $_SESSION['userID'];
@@ -28,9 +28,8 @@ if ($_SESSION[accepted] == 1) { }
?>
<script type="text/javascript">
-playerWallColor = '<?PHP echo $wallColor; ?>';
-playerWallEmblem = '<?PHP echo $wallEmblem; ?>';
-<?PHP echo $noteScript; ?>
+playerWallColor = '<?PHP echo isset($wallColor) ? $wallColor : ''; ?>';
+playerWallEmblem = '<?PHP echo isset($wallEmblem) ? $wallEmblem : ''; ?>';
</script>
<script src="sounds/script/soundmanager.js"></script>
|