From 79d928cd42c32122edd47d1a450fb0c4ced3de2f Mon Sep 17 00:00:00 2001 From: raylu Date: Wed, 18 Jul 2012 01:45:55 -0700 Subject: fix lots of warnings, whitespace --- pages/cp.php | 4 +-- pages/home.php | 22 +++++++------ pages/leaderboard.php | 85 ++++++++++++++++++++++++++------------------------- pages/login.php | 6 ++-- pages/tutorial.php | 7 ++--- 5 files changed, 63 insertions(+), 61 deletions(-) (limited to 'pages') 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) { Complete the tutorial to unlock a blue wall color:"; echo "

"; @@ -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 == '') { \n$topscores\n"; - $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 .= "
"; + $r = "
"; $r .= "
"; // 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 "Next Day"; } echo "Previous Day"; - + $statContent .= displayPastMaze(1, 'Simple', $daysAgo); $statContent .= displayPastMaze(2, 'Normal', $daysAgo); $statContent .= displayPastMaze(3, 'Complex', $daysAgo); @@ -143,7 +144,7 @@ if ($specialMapName != '') ?>
- +
Simple Normal @@ -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 .= '
'; $r .= "
"; $r .= '
'; @@ -228,7 +229,7 @@ function displayPastMaze($mapType, $name, $daysAgo = 1) { $r .= '
'; $r .= "Best solution for this map: $bestMoves by $byName "; - $r .= DisplayMap($map, $mapID, 'example', 2); + $r .= DisplayMap($map, $mapID, 'example', 2); $r .= '
'; $r .= '
'; return $r; @@ -246,8 +247,8 @@ function displaystats($result, $caption = NULL) { //Headers on the top. including Rank. $r .= ""; $r .= $headers; - $r .= ""; - + $r .= ""; + $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 .= "\n"; $r .= "$i"; $r .= "$displayName"; 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 @@
"; - 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) { } ?> -- cgit v1.2.3