summaryrefslogtreecommitdiffstats
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/.htaccess1
-rw-r--r--includes/chats.php3
-rw-r--r--includes/constants.php28
-rw-r--r--includes/datas.php150
-rw-r--r--includes/header.php60
5 files changed, 175 insertions, 67 deletions
diff --git a/includes/.htaccess b/includes/.htaccess
new file mode 100644
index 0000000..3418e55
--- /dev/null
+++ b/includes/.htaccess
@@ -0,0 +1 @@
+deny from all \ No newline at end of file
diff --git a/includes/chats.php b/includes/chats.php
index 18d0810..6991a48 100644
--- a/includes/chats.php
+++ b/includes/chats.php
@@ -62,7 +62,8 @@ function getChat($startID = 0) {
users.displayName,
users.displayColor,
users.wallColor,
- users.wallEmblem
+ users.wallEmblem,
+ users.wallOrientation
FROM `chat`
LEFT JOIN `users`
ON chat.userID = users.ID
diff --git a/includes/constants.php b/includes/constants.php
index a6826b1..a1d4dbe 100644
--- a/includes/constants.php
+++ b/includes/constants.php
@@ -75,4 +75,32 @@ $mapNamesByType = array(1 => 'Simple', 2 => 'Normal', 3 => 'Complex', 4 => 'Spec
* Make sure the first one is always 0...
*/
$tierChallengeRequirements = array(0, 5, 10, 15, 20, 25, 30);
+
+
+
+/**
+ * Unlock Types
+ */
+define('UNLOCK_WALL_COLOR', 1);
+define('UNLOCK_WALL_EMBLEM', 2);
+define('UNLOCK_DISPLAY_COLOR', 3);
+define('UNLOCK_WALL_ORIENTATION', 4);
+define('UNLOCK_EXTRAS', 8);
+// MISC SUBTYPES:
+
+define('MISC_UNLOCK_INSANE_SPEED', 1);
+
+/**
+ * Achievement Types
+ */
+define('ACHIEVEMENT_MOVES_CAREER', 1);
+define('ACHIEVEMENT_MAZE_CAREER', 2);
+define('ACHIEVEMENT_MAZE_MASTERY', 3);
+define('ACHIEVEMENT_CHAMPION_POINTS', 4);
+define('ACHIEVEMENT_PERFECT_DAY', 5);
+
+define('ACHIEVEMENT_TUTORIAL', 32);
+
+
+
?>
diff --git a/includes/datas.php b/includes/datas.php
index 74487fd..af10cd2 100644
--- a/includes/datas.php
+++ b/includes/datas.php
@@ -12,35 +12,34 @@ include_once('constants.php');
//Returns text refering to any notifications.
function getNotified($userID) {
-
$r = '';
$sql = "SELECT `ID`, `type`, `level`
FROM `achievements`
WHERE `notified` = false
AND userID = '$userID'
- LIMIT 25";
+ LIMIT 5";
$resultA = mysql_query($sql);
- if (mysql_num_rows($resultA) <= 0)
- return false;
+ if (mysql_num_rows($resultA) <= 0) return false;
// --------- We found an achievement they don't know they got!
while (list($aID, $aType, $aLevel) = mysql_fetch_row($resultA)) {
- if ($r != '')
- $r .= '<br /><hr />';
+ if ($r != '') $r .= '<br /><hr />';
- $aTypeNames[1] = "Path Career Level $aLevel!";
- $aTypeNames[2] = "Mazes Career Level $aLevel!";
- $aTypeNames[3] = "Maze Mastery Level $aLevel!";
- $aTypeNames[4] = "Champion Level $aLevel!";
- $aTypeNames[32] = 'Tutorial Complete!';
+ $aTypeNames[ACHIEVEMENT_MOVES_CAREER] = "Path Career Level $aLevel!";
+ $aTypeNames[ACHIEVEMENT_MAZE_CAREER] = "Mazes Career Level $aLevel!";
+ $aTypeNames[ACHIEVEMENT_MAZE_MASTERY] = "Maze Mastery Level $aLevel!";
+ $aTypeNames[ACHIEVEMENT_CHAMPION_POINTS] = "Champion Level $aLevel!";
+ $aTypeNames[ACHIEVEMENT_PERFECT_DAY] = 'Perfect Day Level!';
+ $aTypeNames[ACHIEVEMENT_TUTORIAL] = 'Tutorial Complete!';
- $aTypeCurrency[1] = "total moves mazed";
- $aTypeCurrency[2] = "mazes played";
- $aTypeCurrency[3] = "mazes with (tied) top score";
- $aTypeCurrency[4] = "champion points";
+ $aTypeCurrency[ACHIEVEMENT_MOVES_CAREER] = "total moves mazed";
+ $aTypeCurrency[ACHIEVEMENT_MAZE_CAREER] = "mazes played";
+ $aTypeCurrency[ACHIEVEMENT_MAZE_MASTERY] = "mazes with (tied) top score";
+ $aTypeCurrency[ACHIEVEMENT_CHAMPION_POINTS] = "champion points";
+ $aTypeCurrency[ACHIEVEMENT_PERFECT_DAY] = "total times you've tied all 4 maps";
$aName = $aTypeNames[$aType];
$currency = $aTypeCurrency[$aType];
@@ -54,20 +53,7 @@ function getNotified($userID) {
if (mysql_num_rows($result) >= 1) {
$unlocked = "You've unlocked: ";
while (list($uType, $uName, $uValue) = mysql_fetch_row($result)) {
- switch ($uType) {
- case 1:
- $unlocked .= "$uName Wall Color!";
- $unlocked .= "<table><tr><td onclick='changeWallColor(\"$uValue\")' style='background-color:$uValue;' class='grid_td_rocks'></td></tr></table>";
- break;
- case 2:
- $unlocked .= "$uName Emblem!";
- $unlocked .= "<div class='grid_td_rocks' title='' onClick='emblemclick(this,\"$uValue\", \"0\")' style='background: #999 url(../images/marks/$uValue);' >";
- $unlocked .= "<div class='grid_inner grid_td_walls'></div></div>";
- break;
- case 3:
- $unlocked .= "<br /><span style='color:$uValue;'>$uName Username color!</span><br />";
- break;
- }
+ $unlocked .= displayUnlock($uType, $uValue, $uName);
}
}
// ---------- Prepare response
@@ -92,8 +78,6 @@ function getNotified($userID) {
}
-
-
// Item ID List
$aIDList[] = "'$aID'";
}
@@ -110,6 +94,40 @@ function getNotified($userID) {
// ---------- Done!
}
+function displayUnlock($uType, $uValue, $uName) {
+ switch ($uType) {
+ case UNLOCK_WALL_COLOR:
+ $r .= "$uName Wall Color!";
+ $r .= "<table><tr><td onclick='changeWallColor(\"$uValue\")' style='background-color:$uValue;' class='grid_td_rocks'></td></tr></table>";
+ break;
+
+ case UNLOCK_WALL_EMBLEM:
+ $r .= "$uName Emblem!";
+ $r .= "<div class='emblemDisplay' title='' style='background: #999 url(../images/marks/$uValue);' >";
+ //$r .= "<div class='grid_inner grid_td_gray'></div></div>";
+ $r .= "<div class='emblemDisplayInner' style='width:35px; height:35px;'></div></div>";
+ break;
+
+ case UNLOCK_DISPLAY_COLOR:
+ $r .= "<br /><span style='color:$uValue;font-weight:bold;font-size:110%;background-color:#222;'>$uName Username color!</span>";
+ break;
+
+ case UNLOCK_WALL_ORIENTATION:
+ $r .= "Emblem Rotation $uName!";
+ break;
+
+ case UNLOCK_EXTRAS:
+ $r .= "Extras: $uName";
+ break;
+
+ default:
+ $r .= "$uName";
+ break;
+ }
+ return $r;
+}
+
+
//Returns true when an achievement is applied.
// Usage example: applyCareerAchievement($userID);
// TODO: DEPRECIATED
@@ -531,13 +549,25 @@ function getAchievementCurrency($userID, $aType) {
$sql = "SELECT championPoints
FROM `users`
WHERE `ID` = '$userID'";
+ break;
+ case 5:
+ $sql = "SELECT count(*)
+ FROM solutions
+ INNER JOIN mapOfTheDay ON solutions.mapID = mapOfTheDay.mapID
+ WHERE mapOfTheDay.mapType
+ IN ( 1, 2, 3, 4 )
+ AND solutions.userID = '$userID'
+ GROUP BY solutions.userID, mapOfTheDay.mapDate
+ HAVING SUM( isTiedForHighScore ) = 4";
+ $result = mysql_query($sql) OR die("SQL query failed; $sql");
+ return mysql_num_rows($result);
break;
}
- if ($sql == '')
- return false;
+ if ($sql == '') return false;
$result = mysql_query($sql) OR die("SQL query failed; $sql");
- if (mysql_num_rows($result) == 1)
+ if (mysql_num_rows($result) == 1) {
list($r) = mysql_fetch_row($result);
+ }
return $r;
}
@@ -552,22 +582,20 @@ function getAchievementLevel($userID, $aType) {
ORDER BY `level` DESC
LIMIT 1";
$result = mysql_query($sql);
- if (mysql_num_rows($result) == 1)
+ if (mysql_num_rows($result) == 1) {
list($r) = mysql_fetch_row($result);
+ }
return $r;
}
function getAchievementsArray($type) {
- if ($type == 1)
- return getCareerPathArray();
- if ($type == 2)
- return getCareerMazesArray();
- if ($type == 3)
- return getMazeMasteryArray();
- if ($type == 4)
- return getChampionPointsArray();
+ if ($type == ACHIEVEMENT_MOVES_CAREER) return getCareerPathArray();
+ if ($type == ACHIEVEMENT_MAZE_CAREER) return getCareerMazesArray();
+ if ($type == ACHIEVEMENT_MAZE_MASTERY) return getMazeMasteryArray();
+ if ($type == ACHIEVEMENT_CHAMPION_POINTS) return getChampionPointsArray();
+ if ($type == ACHIEVEMENT_PERFECT_DAY) return getPerfectDayArray();
//Tutorial
- if ($type == 32) {
+ if ($type == ACHIEVEMENT_TUTORIAL) {
$r[1] = array(1, 1, '#4444ff', 'Blue');
return $r;
}
@@ -655,11 +683,27 @@ function getChampionPointsArray() {
$r[7] = array(8000, 2, 'CrossXLDonut_B_I.png', 'Inverted Dark Large Intersection', 0);
$r[8] = array(16000, 2, 'DiamondLarge_B.png', 'Dark Large Diamond', 0);
$r[9] = array(32000, 1, '#22ff22', 'Neon Lime', 1);
- //$r[7] = array(75, 2, 'CircleSmall_W_I.png', 'Inverted Bright Small Circle', 0);
return $r;
}
+//TYPE 5
+function getPerfectDayArray() {
+ //($required, $unlockType, $unlockValue, $unlockName, $unlockSubtype)
+ //$cp[0] = array(requiredpoints, type, 'value', 'name');
+ $r[1] = array(1, UNLOCK_EXTRAS, '5', 'Insane Speed', MISC_UNLOCK_INSANE_SPEED);
+ //Give 0* at the same time
+ $r[2] = array(5, UNLOCK_WALL_ORIENTATION, '1', '90*', 0);
+ $r[3] = array(50, UNLOCK_WALL_ORIENTATION, '2', '180*', 0);
+ $r[4] = array(100, UNLOCK_WALL_ORIENTATION, '3', '270*', 0);
+ //These numbers temporarly unreasonable
+ $r[5] = array(9275, UNLOCK_WALL_EMBLEM, 'CircleSmall_W_I.png', 'Inverted Bright Small Circle', 0);
+ $r[6] = array(10000, UNLOCK_WALL_EMBLEM, 'DiamondLarge_W_I.png', 'Inverted Light Large Diamond', 0);
+
+ return $r;
+}
+
+
//Select Members
function getMembers($pageNumber = 1, $pageDivide = 50, $order = 'DESC', $orderBy = 'dateJoined') {
@@ -716,6 +760,7 @@ function getMembers($pageNumber = 1, $pageDivide = 50, $order = 'DESC', $orderBy
users.wallColor,
users.displayColor,
users.wallEmblem,
+ users.wallOrientation,
users.datejoined as dateJoined,
users.dateLogin as dateLogin
FROM `users`
@@ -812,6 +857,7 @@ function getScores($mapID, $pageNumber = 1, $pageDivide = 10) {
users.displayColor,
users.wallColor,
users.wallEmblem,
+ users.wallOrientation,
$requestSolutions
solutions.dateModified as cdate,
solutions.ID as solutionID
@@ -907,6 +953,20 @@ function hasCompletedTutorial($userID) {
return (mysql_num_rows($result) >= 1);
}
+function hasExtrasUnlock($userID, $unlockType, $unlockSubtype) {
+ $userID = mysql_escape_string($userID);
+ $unlockType = mysql_escape_string($unlockType);
+ $unlockSubtype = mysql_escape_string($unlockSubtype);
+
+ $sql = "SELECT `value` FROM `unlocks`
+ WHERE `userID` = '$userID'
+ AND `type` = '$unlockType'
+ AND `subtype` = '$unlockSubtype'
+ LIMIT 1";
+ $result = mysql_query($sql);
+ return (mysql_num_rows($result) >= 1);
+}
+
/**
* Returns a MySQL resultset for all challenges for the given mapID
* @param $mapIdUnsanitized The mapID to load. Assumed to be unsanitized.
diff --git a/includes/header.php b/includes/header.php
index cf427e4..71c2a5c 100644
--- a/includes/header.php
+++ b/includes/header.php
@@ -41,17 +41,17 @@ function htmlHeader($css = array(), $title = 'Pathery', $desc = '', $scripts = a
</script>
<script>
-<? echo userDataToJS(); ?>
function showSignin() {
- if (document.getElementById('oid_hidden') !== undefined) {
+ if (typeof document.getElementById('oid_hidden') !== 'undefined') {
document.getElementById('oid_hidden').id = 'oid_wrapper';
}
}
function hideSignin() {
- if (document.getElementById('oid_wrapper') !== undefined) {
+ if (typeof document.getElementById('oid_wrapper') !== 'undefined') {
document.getElementById('oid_wrapper').id = 'oid_hidden';
}
}
+<? echo userDataToJS(); ?>
</script>
</head>
@@ -145,7 +145,6 @@ function htmlFooter() {
?>
})();
- createSignin();
</script>
</body>
@@ -154,7 +153,25 @@ function htmlFooter() {
}
function topbar($links) {
- global $accepted, $wallColor, $wallEmblem, $request;
+ global $accepted, $wallColor, $wallEmblem, $wallOrientation, $request;
+
+
+
+ //Empty first-div contains sound manager stuff
+ echo '<div></div>';
+
+ //echo '<script>createSignin();</script>';
+ echo ' <div class="wrapper" id="oid_hidden" >
+ <h2>Sign in</h2>
+ <div id="oid_box">
+ <h2 style="color:#333;">Do you have an account here?</h2>
+ <a rel="nofollow" href="login?op=google"><img id="oid_btn" src="images/btns/signin_Google.png" alt="Sign in with Google" /></a>
+ <a rel="nofollow" href="login?op=yahoo"><img id="oid_btn" src="images/btns/signin_Yahoo.png" alt="Sign in with Yahoo" /></a>
+ <a id="oid_learn" href="http://openid.net/get-an-openid/what-is-openid/" target="_blank" >Learn more about OpenID</a>
+ <a id="oid_cancel" href="javascript:hideSignin();">X</a>
+ </div>
+ </div>';
+
echo '<div id="topbar"><div id="topbarContent">';
foreach ($links as $key => $value) {
@@ -174,7 +191,7 @@ function topbar($links) {
echo " <a href='cp' title='change name'>Update your name</a> | ";
echo " <a href='logout'>Logout</a>";
echo " </div>";
- echo "<div id='topbarBadge' style='background-color: $wallColor; background-image: url(images/marks/$wallEmblem);'>
+ echo "<div id='topbarBadge' style='background-color: $wallColor; background-image: url(".linkEmblem($wallEmblem, $wallOrientation).");'>
<a href='achievements'><div></div></a>
</div>";
@@ -183,16 +200,6 @@ function topbar($links) {
} else {
?>
<a href='javascript:showSignin();'>Sign in</a>
-<!-- <div class="wrapper" id="oid_hidden" >
- <h2>Sign in</h2>
- <div id="oid_box">
- <h2 style="color:#333;">Do you have an account here?</h2>
- <a rel="nofollow" href="login?op=google"><img id="oid_btn" src="images/btns/signin_Google.png" alt="Sign in with Google" /></a>
- <a rel="nofollow" href="login?op=yahoo"><img id="oid_btn" src="images/btns/signin_Yahoo.png" alt="Sign in with Yahoo" /></a>
- <a id="oid_learn" href="http://openid.net/get-an-openid/what-is-openid/" target="_blank" >Learn more about OpenID</a>
- <a id="oid_cancel" href="javascript:hideSignin();">X</a>
- </div>
- </div> -->
<?
}
echo " </div>";
@@ -200,14 +207,25 @@ function topbar($links) {
}
function userDataToJS() {
- global $wallColor, $wallEmblem, $accepted;
+ global $wallColor, $wallEmblem, $wallOrientation, $accepted;
if (!$accepted) {
- $r = 'var userObj = {"wallColor":false,"wallEmblem":false,';
- $r .= '"ID":"-1","accepted":false};';
+ $r = 'var userObj = {"wallColor":false,"wallEmblem":false,"wallOrientation":false,';
+ $r .= '"ID":"-1","accepted":false,"hasInsaneSpeed":false};';
} else {
$userID = $_SESSION['userID'];
- $r = 'var userObj = {"wallColor":"'.$wallColor.'","wallEmblem":"'.$wallEmblem.'",';
- $r .= '"ID":"'.$userID.'","accepted":true};';
+ include_once('includes/datas.php');
+ $hasInsaneSpeed = hasExtrasUnlock($userID, UNLOCK_EXTRAS, MISC_UNLOCK_INSANE_SPEED);
+ $r .= 'hasInsaneSpeed":'.$hasInsaneSpeed.'};'."\n";
+ $json = array('ID' => 'fat');
+ $json['ID'] = $userID;
+ $json['wallColor'] = $wallColor;
+ $json['wallEmblem'] = $wallEmblem;
+ $json['wallOrientation'] = $wallOrientation;
+ $json['hasInsaneSpeed'] = $hasInsaneSpeed;
+ $json['accepted'] = 'true';
+
+ $encoded = json_encode($json);
+ $r = 'var userObj = decryptJSON(\''.json_encode($json).'\');'."\n";
}
return $r;
}