From 86aac4847705f0a4559400da6c0e9f1aeba5cdf8 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Fri, 10 May 2013 02:17:14 -0700 Subject: Many bugs and PHP notices & warning fixes. --- ajax/chat.ajax.php | 4 ++-- ajax/maps.ajax.php | 2 +- ajax/scores.ajax.php | 7 +++++-- do.php | 2 +- includes/datas.php | 10 +++++----- includes/header.php | 16 +++++++++++++--- js/mapspecs.js | 18 +++++++++++------- pages/chat.php | 2 ++ pages/home.php | 2 +- pages/memberlist.php | 5 ----- 10 files changed, 41 insertions(+), 27 deletions(-) diff --git a/ajax/chat.ajax.php b/ajax/chat.ajax.php index 97db510..59f7ae3 100644 --- a/ajax/chat.ajax.php +++ b/ajax/chat.ajax.php @@ -9,7 +9,7 @@ if (strtotime('now') - $_SESSION['chatLastReset'] > 6) { $_SESSION['chatSendCount'] = 0; $_SESSION['chatLastReset'] = strtotime('now'); } -if ($_REQUEST['messages']) { +if (isset($_REQUEST['messages'])) { $_SESSION['chatSendCount']++; if ($_SESSION['chatSendCount'] > 4) { $r[0]['error'] = 'Spam'; @@ -40,7 +40,7 @@ require('../includes/chats.php'); $sent = false; -if ($_REQUEST['messages']) { +if (isset($_REQUEST['messages'])) { $date = isMuted($userID); if ($date !== false) { $r[0]['error'] = 'Muted'; diff --git a/ajax/maps.ajax.php b/ajax/maps.ajax.php index 4919fb9..210fd1b 100644 --- a/ajax/maps.ajax.php +++ b/ajax/maps.ajax.php @@ -31,7 +31,7 @@ if (isset($_GET['mapid'])) { function sendCacheHeaders() { $expires = 365*24*60*60; //TODO: Remove this line once we're confident in data in the mapObject. - $expires = 120; + $expires = 31*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"); diff --git a/ajax/scores.ajax.php b/ajax/scores.ajax.php index 897da3b..70d78ff 100644 --- a/ajax/scores.ajax.php +++ b/ajax/scores.ajax.php @@ -22,11 +22,14 @@ $json['page'] = $page; //TODO: Show notifications someplace else! $note = false; -if ($_SESSION['accepted'] == 1) { +if (isset($_SESSION['accepted']) AND $_SESSION['accepted'] == 1) { $userID = $_SESSION['userID']; $note = getNotified($userID); } else { - if ($_SESSION['preCompletedTutorial'] == true && $_SESSION['preCompletedTutorialNotified'] == false) { + if ( + isset($_SESSION['preCompletedTutorial']) && + $_SESSION['preCompletedTutorial'] == true && + $_SESSION['preCompletedTutorialNotified'] == false) { $_SESSION['preCompletedTutorialNotified'] = true; $note = "Tutorial Completed!"; $note .= "
You've unlocked: Blue Wall Color!"; diff --git a/do.php b/do.php index 43da407..ad48408 100644 --- a/do.php +++ b/do.php @@ -126,7 +126,7 @@ if ($_GET['r'] == 'getpath') { $userID = $_SESSION['userID'] + 0; //valid mapID? - $mapID = $_GET[mapid] + 0; + $mapID = $_GET['mapid'] + 0; if (!is_int($mapID)) return; //$firephp->log($mapID, "mapID"); diff --git a/includes/datas.php b/includes/datas.php index 2e48b14..b8ffef7 100644 --- a/includes/datas.php +++ b/includes/datas.php @@ -512,8 +512,7 @@ function applyAchievements($userID, $aType) { if (!isset($aArray[$aNextLevel])) return false; list($required, $unlockType, $unlockValue, $unlockName, $unlockSubtype) = $aArray[$aNextLevel]; - if ($amount < $required) - return false; + if ($amount < $required) return false; $sql = "INSERT INTO `achievements` (`userID`, `type`, `level`) @@ -788,12 +787,13 @@ function getMembers($pageNumber = 1, $pageDivide = 50, $order = 'DESC', $orderBy $output['updateTime'] = date("g:i A (T)"); $i = $limitTop; + $userPosition = -1; $foundUser = false; while ($row = mysql_fetch_assoc($result)) { $i++; $userID = $row['ID']; - if ($_SESSION['userID'] == $userID) { + if (isset($_SESSION['userID']) AND $_SESSION['userID'] == $userID) { $userPosition = $i; } @@ -889,6 +889,7 @@ function getScores($mapID, $pageNumber = 1, $pageDivide = 10) { $output['updateTime'] = time(); $i = 0; + $userPosition = -1; $foundUser = false; while ($row = mysql_fetch_assoc($result)) { @@ -1056,9 +1057,8 @@ function loadChallengeMapCode($mapIdUnsanitized) return NULL; } - function isCurrentMap($mapID) { - include_once('./includes/sqlEmbedded.php'); + include_once('sqlEmbedded.php'); $sql = "SELECT mapID FROM `mapOfTheDay` WHERE `mapID` = '$mapID' diff --git a/includes/header.php b/includes/header.php index da5e11d..35fd323 100644 --- a/includes/header.php +++ b/includes/header.php @@ -1,6 +1,7 @@ @@ -9,7 +10,14 @@ function htmlHeader($css = array(), $title = 'Pathery', $desc = '', $scripts = a <? echo $title; ?> - +'; + } else { + echo ""; + } + // +?> "; - foreach ($scripts as $s) echo ""; + foreach ($scripts as $s) echo ""; ?> @@ -136,12 +144,14 @@ function htmlFooter() { s.parentNode.appendChild(ga, s); })(); @@ -215,7 +225,7 @@ function userDataToJS() { $userID = $_SESSION['userID']; include_once('includes/datas.php'); $hasInsaneSpeed = hasExtrasUnlock($userID, UNLOCK_EXTRAS, MISC_UNLOCK_INSANE_SPEED); - $r .= 'hasInsaneSpeed":'.$hasInsaneSpeed.'};'."\n"; + $r = 'hasInsaneSpeed":'.$hasInsaneSpeed.'};'."\n"; $json = array('ID' => 'fat'); $json['ID'] = $userID; $json['wallColor'] = $wallColor; diff --git a/js/mapspecs.js b/js/mapspecs.js index f55eb14..1a0693f 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -876,15 +876,19 @@ function mapAsHTML(map, targetWidth, mapEditor) { var scale = map.width / targetWidth; //alert(scale); - var width = parseInt(map.width / scale); - var height = parseInt(map.height / scale); - var tileWidth = parseInt(width / map.width); + //var width = parseInt(map.width / scale); + //var height = parseInt(map.height / scale); - width = tileWidth * map.width; + var tileWidth = parseInt((map.width / scale) / map.width); + var tileHeight = tileWidth; + + var width = tileWidth * map.width; + var height = tileHeight * map.height; var mapgrid = ''; mapgrid += '
'; + for (var y in map.tiles) { for (var x in map.tiles[y]) { var type = map.tiles[y][x][0]; @@ -901,13 +905,13 @@ function mapAsHTML(map, targetWidth, mapEditor) { //oldy is used for Position too... for now if (mapEditor == true) { - mapgrid += "
"; + mapgrid += "
"; mapgrid += "
"; } else if (type == 'o') { - mapgrid += "
"; + mapgrid += "
"; mapgrid += "
"; } else { - mapgrid += "
"; + mapgrid += "
"; mapgrid += "
"; } } diff --git a/pages/chat.php b/pages/chat.php index d479f7b..8b8217d 100644 --- a/pages/chat.php +++ b/pages/chat.php @@ -70,6 +70,8 @@ function getChatDone(data) { var timestamp = postDate.format("hh:MM:ss"); var timestampDetails = postDate.format("ddd h:MM TT"); + if (!chat.message) return; + var strClass = ''; if (chat.userID == userObj.ID) { strClass += ' self'; diff --git a/pages/home.php b/pages/home.php index 696c0cc..9c4cf3d 100644 --- a/pages/home.php +++ b/pages/home.php @@ -90,7 +90,7 @@ function adToggle() { -

Members