diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/.gitignore | 1 | ||||
-rw-r--r-- | includes/chats.php | 2 | ||||
-rw-r--r-- | includes/datas.php | 26 | ||||
-rw-r--r-- | includes/db.inc.php | 11 | ||||
-rw-r--r-- | includes/emails.php | 2 | ||||
-rw-r--r-- | includes/header.php | 17 | ||||
-rw-r--r-- | includes/mapclass.php | 82 | ||||
-rw-r--r-- | includes/sqlEmbedded.php | 3 | ||||
-rw-r--r-- | includes/sqli.php | 4 |
9 files changed, 113 insertions, 35 deletions
diff --git a/includes/.gitignore b/includes/.gitignore new file mode 100644 index 0000000..4f36fe0 --- /dev/null +++ b/includes/.gitignore @@ -0,0 +1 @@ +/db.inc.php diff --git a/includes/chats.php b/includes/chats.php index dcd46c9..18d0810 100644 --- a/includes/chats.php +++ b/includes/chats.php @@ -2,7 +2,7 @@ /*
* addChat, getChat functions
*/
-include_once('sqli.php');
+include_once('sqlEmbedded.php');
define('CHAT_ROWS_TO_KEEP', 75);
diff --git a/includes/datas.php b/includes/datas.php index c341ddf..1db0060 100644 --- a/includes/datas.php +++ b/includes/datas.php @@ -646,7 +646,9 @@ function getMazeMasteryArray() { //TYPE 4 function getChampionPointsArray() { //$cp[0] = array(requiredpoints, type, 'value', 'name'); - $r[1] = array(100, 2, 'DiagonalCover_B.png', 'Light Diagnol Cover', 0); + //TODO: Crap.... typo... Need to fix this in SQL too. + //$r[1] = array(100, 2, 'DiagonalCover_B.png', 'Light Diagnol Cover', 0); + $r[1] = array(100, 2, 'DiagonalCover_B.png', 'Light Diagonal Cover', 0); $r[2] = array(250, 1, '#22aaaa', 'Teal'); $r[3] = array(500, 2, 'OffsetStripesDiagonal_B.png', 'Dark Diagonal Stripes', 0); $r[4] = array(1000, 2, 'DiamondLargeDonut_W_I.png', 'Inverted Light Annulated Diamond', 0); @@ -807,7 +809,7 @@ function getScores($mapID, $pageNumber = 1, $pageDivide = 10) { timediff(solutions.dateModified, TIMESTAMP(CURDATE())) as diff, users.displayName as display, solutions.moves as moves, - solutions.challengePointsWorth as points, + solutions.championPointsWorth as points, users.ID as ID, users.displayColor, users.wallColor, @@ -825,7 +827,7 @@ function getScores($mapID, $pageNumber = 1, $pageDivide = 10) { $result = mysql_query($sql); //$utime = date("g:i A (T)"); - $output['updateTime'] = date("g:i A (T)"); + $output['updateTime'] = time(); $i = 0; $foundUser = false; @@ -853,7 +855,7 @@ function getScores($mapID, $pageNumber = 1, $pageDivide = 10) { } $scoredDate = strtotime($row['cdate']); - $secondsSinceScored = strtotime("now") - $scoredDate ; + $secondsSinceScored = strtotime("now") - $scoredDate; //Alternate background colors $background = '#262631'; @@ -980,4 +982,20 @@ function loadChallengeMapCode($mapIdUnsanitized) } return NULL; } + + +function isCurrentMap($mapID) { + include_once('./includes/sqlEmbedded.php'); + $sql = "SELECT mapID + FROM `mapOfTheDay` + WHERE `mapID` = '$mapID' + AND mapExpireTime > NOW() + LIMIT 1 + "; + + $result = mysql_query($sql) or die(mysql_error()); + return (mysql_num_rows($result) != 0); +} + + ?> diff --git a/includes/db.inc.php b/includes/db.inc.php deleted file mode 100644 index 6cd3f01..0000000 --- a/includes/db.inc.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php
-
-global $mysqlid;
-$db_host = "db2894.perfora.net";
-$db_user = "dbo362854667";
-$db_name = "db362854667";
-$db_pass = "mazes4me";
-$mysqlid = @mysql_connect($db_host,$db_user, $db_pass) or die("Cannot connect to database.");
-@mysql_select_db($db_name, $mysqlid) or die("Invalid database.");
-
-?>
diff --git a/includes/emails.php b/includes/emails.php index 182749c..74658ad 100644 --- a/includes/emails.php +++ b/includes/emails.php @@ -2,7 +2,7 @@ /*
* Email methods; QueueEmail and SendQueuedEmail
*/
-include_once('sqli.php');
+include_once('sqlEmbedded.php');
//Email sending lock
define('FILE_EMAIL_LOCK', './emailLockFile');
diff --git a/includes/header.php b/includes/header.php index c18ae2e..cf427e4 100644 --- a/includes/header.php +++ b/includes/header.php @@ -10,6 +10,7 @@ function htmlHeader($css = array(), $title = 'Pathery', $desc = '', $scripts = a <link href="css/page.css?v=011013" rel="stylesheet" type="text/css" />
<link href="css/maps.css?v=122612" rel="stylesheet" type="text/css" />
+ <link rel="image_src" type="image/png" href="/images/linkdsp.png" />
<?php
foreach ($css as $c) {
echo " <link href=\"css/$c.css\" rel=\"stylesheet\" type=\"text/css\" />\n";
@@ -19,11 +20,10 @@ function htmlHeader($css = array(), $title = 'Pathery', $desc = '', $scripts = a foreach ($scripts as $s) echo "<script src='js/$s.js?v=122612'></script>";
?>
<script src="js/ajax.js" async="async"></script>
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="js/mapspecs.js?v=122612"></script>
<script src="js/globe.js?v=122612"></script>
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
-
<script>
(function(c,a){window.mixpanel=a;var b,d,h,e;b=c.createElement("script");b.type="text/javascript";b.async=!0;b.src=("https:"===c.location.protocol?"https:":"http:")+'//cdn.mxpnl.com/libs/mixpanel-2.1.min.js';d=c.getElementsByTagName("script")[0];d.parentNode.insertBefore(b,d);a._i=[];a.init=function(b,c,f){function d(a,b){var c=b.split(".");2==c.length&&(a=a[c[0]],b=c[1]);a[b]=function(){a.push([b].concat(Array.prototype.slice.call(arguments,0)))}}var g=a;"undefined"!==typeof f?
g=a[f]=[]:f="mixpanel";g.people=g.people||[];h="disable track track_pageview track_links track_forms register register_once unregister identify name_tag set_config people.identify people.set people.increment".split(" ");for(e=0;e<h.length;e++)d(g,h[e]);a._i.push([b,c,f])};a.__SV=1.1})(document,window.mixpanel||[]);
@@ -155,7 +155,7 @@ function htmlFooter() { function topbar($links) {
global $accepted, $wallColor, $wallEmblem, $request;
- echo '<div id="topbar">';
+ echo '<div id="topbar"><div id="topbarContent">';
foreach ($links as $key => $value) {
if ($request == $key) {
@@ -174,13 +174,10 @@ function topbar($links) { echo " <a href='cp' title='change name'>Update your name</a> | ";
echo " <a href='logout'>Logout</a>";
echo " </div>";
- echo "
- <div class='grid_td' style='float:left; margin:5px 1px 1px 9px; width:35px; height:35px; background:$wallColor url(images/marks/$wallEmblem);'>
- <a href='achievements'>
- <div style='background-color:transparent;' class='grid_td_inner grid_td_rocks'>
- </div>
- </a>
+ echo "<div id='topbarBadge' style='background-color: $wallColor; background-image: url(images/marks/$wallEmblem);'>
+ <a href='achievements'><div></div></a>
</div>";
+
} else {
@@ -199,7 +196,7 @@ function topbar($links) { <?
}
echo " </div>";
- echo "</div><div class='topbarSpacer'></div>"; //div id='user'
+ echo "</div></div><div class='topbarSpacer'></div>"; //div id='user'
}
function userDataToJS() {
diff --git a/includes/mapclass.php b/includes/mapclass.php index 9e91d3f..24b9108 100644 --- a/includes/mapclass.php +++ b/includes/mapclass.php @@ -43,8 +43,15 @@ class map { public function __construct($code = NULL, $mapID = NULL) { //TODO: Use new code by default. if ($mapID !== NULL) $this->ID = $mapID; - if ($code !== NULL) $this->applyMapFromOldCode($code); - //$this->applyMapFromCode($code); + if ($code !== NULL) { + $dimensions = explode('.', explode(':', $code)[0])[0]; + if (strpos($dimensions, 'x') == true) { + $this->applyMapFromOldCode($code); + } else { + $this->applyMapFromCode($code); + } + } + } public function applyMapFromOldCode($code) { @@ -218,8 +225,7 @@ class map { //Outputs the new code. public function getCode() { //If we already have the code on hand... - if ($this->code) - return $this->code; + //if ($this->code) return $this->code; //Otherwise we need to build the code: $headers[0] = $this->width; $headers[1] = $this->height; @@ -247,6 +253,74 @@ class map { return $code; } + function getOldCode() { + + $code = ""; //The string to return to the database. + $index = 0; //The current number of tiles from the last tile saved. + + $code = $this->width.'x'.$this->height; + $code .= '.c'.$this->checkpoints; + $code .= '.r0'; //rocks... yeah. + $code .= '.w'.$this->walls; + $code .= '.t'.$this->teleports; + $code .= '.'.$this->name; + $code .= ".:"; + + $oldNames['o'] = 'o'; + + $oldNames['s'] = 's'; + $oldNames['s2'] = 'S'; + $oldNames['f'] = 'f'; + + $oldNames['c'] = 'a'; + $oldNames['c2'] = 'b'; + $oldNames['c3'] = 'c'; + $oldNames['c4'] = 'd'; + $oldNames['c5'] = 'e'; + + $oldNames['t'] = 't'; + $oldNames['t2'] = 'm'; + $oldNames['t3'] = 'g'; + $oldNames['t4'] = 'i'; + $oldNames['t5'] = 'k'; + + $oldNames['u'] = 'u'; + $oldNames['u2'] = 'n'; + $oldNames['u3'] = 'h'; + $oldNames['u4'] = 'j'; + $oldNames['u5'] = 'l'; + + $oldNames['x'] = 'x'; + $oldNames['x2'] = 'X'; + + $oldNames['r'] = 'r'; + $oldNames['r2'] = 'R'; + + for( $i = 0; $i < $this->height; $i++) { + for( $j = 0; $j < $this->width; $j++) { + if($this->tiles[$i][$j][0] != 'o') { + //As long as the tile is NOT open, embed it in the code. + + + $type = $this->tiles[$i][$j][0]; + $value = $this->tiles[$i][$j][1]; + if ($value <= 1) $value = ''; + + $code .= $index.$oldNames[$type.$value].'.'; + + + //$code .= $index.$mapMatrix[$i][$j].'.'; + //Start from 0 again. + $index = -1; + } + $index += 1; + } + } + + return $code; + + } + //Other "Magical" functions. public function __toString() { return $this->name; diff --git a/includes/sqlEmbedded.php b/includes/sqlEmbedded.php index b7a32b5..64fa5c5 100644 --- a/includes/sqlEmbedded.php +++ b/includes/sqlEmbedded.php @@ -1,6 +1,9 @@ <?php include_once('db.inc.php'); +global $mysqli; +$mysqli = @mysqli_connect($db_host, $db_user, $db_pass, $db_name) or die("SQLI Failed to connect to database"); + global $mysqlid; $mysqlid = @mysql_connect($db_host,$db_user, $db_pass) or die("Cannot connect to database."); @mysql_select_db($db_name, $mysqlid) or die("Invalid database."); diff --git a/includes/sqli.php b/includes/sqli.php deleted file mode 100644 index d19069b..0000000 --- a/includes/sqli.php +++ /dev/null @@ -1,4 +0,0 @@ -<?php
-include_once('db.inc.php');
-$mysqli = mysqli_connect($db_host, $db_user, $db_pass, $db_name) or die("Failed to connect to database");
-?>
\ No newline at end of file |