summaryrefslogtreecommitdiffstats
path: root/pages
diff options
context:
space:
mode:
Diffstat (limited to 'pages')
-rw-r--r--pages/.htaccess1
-rw-r--r--pages/about.php32
-rw-r--r--pages/admin.php233
-rw-r--r--pages/cp.php69
-rw-r--r--pages/faq.php43
-rw-r--r--pages/gallery.php113
-rw-r--r--pages/home.php167
-rw-r--r--pages/howtoplay.php102
-rw-r--r--pages/leaderboard.php236
-rw-r--r--pages/login.php117
-rw-r--r--pages/memberlist.php91
-rw-r--r--pages/test.php408
12 files changed, 1612 insertions, 0 deletions
diff --git a/pages/.htaccess b/pages/.htaccess
new file mode 100644
index 0000000..3418e55
--- /dev/null
+++ b/pages/.htaccess
@@ -0,0 +1 @@
+deny from all \ No newline at end of file
diff --git a/pages/about.php b/pages/about.php
new file mode 100644
index 0000000..f5ddb8e
--- /dev/null
+++ b/pages/about.php
@@ -0,0 +1,32 @@
+<?PHP
+htmlHeader();
+?>
+
+<body>
+<?php
+topbar($Links);
+
+echo "<br />";
+echo "<br />";
+
+?>
+
+<center>
+<br />Email us: <a href='mailto:snapems@gmail.com'>snapems@gmail.com</a>
+<br />
+<h3>Created by:</h3> <span title='AKA Snap'>Patrick Davison</span> and <span title='Goes by "Rex"'>Rex Ounekeo</span>.
+<br />
+<h3>Special thanks:</h3>
+<h4>Programmers:</h4>
+<br />raylu
+<h4>Testers:</h4>
+Steven Gosling
+<br />Patrick's Family
+<br />Josh
+<br />Rory Matthias Quentin Maison
+<br />Matt
+<br />
+</center>
+
+</body>
+</html>
diff --git a/pages/admin.php b/pages/admin.php
new file mode 100644
index 0000000..f06e1b4
--- /dev/null
+++ b/pages/admin.php
@@ -0,0 +1,233 @@
+<?PHP
+htmlHeader();
+?>
+
+<body>
+<?php
+topbar($Links);
+
+include('./includes/maps.php');
+include('./includes/mapoftheday.php');
+include('./includes/db.inc.php');
+
+//$motd = MapOfTheDay(3);
+//$mapID = $motd['id'];
+
+$pastMap = pastMap(3, 1);
+$mapID = $pastMap;
+
+echo $mapID;
+
+//$mapID = '38';
+$mapcode = getMapCode($mapID);
+$map = GenerateMapByCode($mapcode);
+
+$sql = "SELECT `moves`, `displayName`, `solution`
+ FROM `solutions`, `users`
+ WHERE `mapID` = '$mapID' AND
+ `userID` = users.ID
+ ORDER BY `moves` DESC, `dateModified` ASC
+ LIMIT 1";
+
+$result = mysql_query($sql) or die(mysql_error());
+if (mysql_num_rows($result) > 0) {
+ list($bestMoves, $byName, $solution) = mysql_fetch_row($result);
+ echo "<br />Best solution for this map: $bestMoves by $byName";
+
+ //$map = MergeMapSolution($motd['map'], $solution);
+ $map = MergeMapSolution($map, $solution);
+ echo DisplayMap($map, $mapID);
+
+ echo "<br />";
+ echo "<br />Is Current:";
+ $is = isCurrentMap(77);
+ echo "<br />$is";
+ $is = isCurrentMap(20);
+ echo "<br />$is";
+ $is = isCurrentMap(76);
+ echo "<br />$is";
+ $is = isCurrentMap(75);
+ echo "<br />$is";
+ $is = isCurrentMap(74);
+ echo "<br />$is";
+ echo "<br />";
+
+}
+
+function isCurrentMap($mapID) {
+ include_once('./includes/db.inc.php');
+ $sql = "SELECT `ID` FROM `mapOfTheDay`
+ WHERE `mapDate` = CURDATE() AND
+ `mapID` = '$mapID'
+ ";
+ $result = mysql_query($sql) or die(mysql_error());
+ if (mysql_num_rows($result) == 0)
+ return false;
+ else
+ return true;
+}
+
+
+
+echo "<br />";
+echo "<br />";
+echo "<br />Solution before";
+echo "<br />";
+echo $solution;
+echo "<br />";
+echo "<br />Solution after";
+echo "<br />";
+$solution = formSolution($solution);
+echo $solution;
+echo "<br />";
+echo "<br />";
+echo "<br />";
+// echo "<center><b> The map for today:
+// <br />Once logged in your best solutions for the map(s) are saved.
+// <br />- Soon i'll fix it so you can see those solutions, and compare them with others.
+// <br />- New maps are generated daily, at 9:00 PM Pacific Standard. (for now...)
+// </b></center>";
+// echo DisplayMap($motd['map'], $motd['id']);
+
+
+
+
+function createThumbnail($mapMatrix, $idprefix, $width, $height) {
+ //Iterate through $mapMatrix and generate the html
+
+ $maptable = ""; //The string to return to the database.
+ $index = 0; //The current number of tiles from the last tile saved.
+
+ for( $i = 1; $i < count($mapMatrix); $i++)
+ {
+ $maptable .= "<tr>";
+ for( $j = 0; $j < count($mapMatrix[$i]); $j++)
+ {
+ //==
+ $index++;
+
+ $handle = "$idprefix,$i,$j";
+ switch($mapMatrix[$i][$j])
+ {
+ case 's': $maptable .= "<td class='grid_td_start' id='$handle' ></td>"; break;
+ case 'f': $maptable .= "<td class='grid_td_finish' id='$handle' ></td>"; break;
+ case 't': $maptable .= "<td class='grid_td_tp1_in' id='$handle' ></td>"; break;
+ //case 't': $maptable .= "<td class='grid_td_tp1_in' id='$handle' ><img class='grid_img' src='images/OverlayTeleport.png' /></td>"; break;
+ case 'u': $maptable .= "<td class='grid_td_tp1_out' id='$handle' ></td>"; break;
+ case 'm': $maptable .= "<td class='grid_td_tp2_in' id='$handle' ></td>"; break;
+ case 'n': $maptable .= "<td class='grid_td_tp2_out' id='$handle' ></td>"; break;
+
+ case 'a': $maptable .= "<td class='grid_td_cpa' id='$handle' ></td>"; break;
+ case 'b': $maptable .= "<td class='grid_td_cpb' id='$handle' ></td>"; break;
+ case 'c': $maptable .= "<td class='grid_td_cpc' id='$handle' ></td>"; break;
+ case 'd': $maptable .= "<td class='grid_td_cpd' id='$handle' ></td>"; break;
+ case 'e': $maptable .= "<td class='grid_td_cpe' id='$handle' ></td>"; break;
+
+ case 'r': $maptable .= "<td class='grid_td_rocks' id='$handle' ></td>"; break; //rock
+ case 'w': $maptable .= "<td class='grid_td_walls' id='$handle' onClick='grid_click(this)' ></td>"; break; //wall
+ //default: $maptable .= "<td class='grid_td' id='$handle' onClick='grid_click(this)' >".$index."</td>";
+ default: $maptable .= "<td class='grid_td' id='$handle' onClick='grid_click(this)' ></td>";
+ //default: $maptable .= "<td class='grid_td' id='$handle' onClick='grid_click(this)' >".$mapMatrix[$i][$j]."</td>";
+ }
+ }
+ $maptable .= "</tr>";
+ }
+ //Prepare mapdata.
+ $mapdata['height'] = $mapMatrix[0][0];
+ $mapdata['width'] = $mapMatrix[0][1];
+ $mapdata['points'] = $mapMatrix[0][2];
+ $mapdata['rocks'] = $mapMatrix[0][3];
+ $mapdata['walls'] = $mapMatrix[0][4];
+ $mapdata['teleports'] = $mapMatrix[0][5];
+ $mapdata['example'] = $example;
+ $mapdata['mapid'] = $idprefix;
+
+ $path = routePath($mapMatrix, '');
+ $mapdata['code'] = GenerateMapCode($mapMatrix);
+
+ $width = (($j * 35) + 2).'px';
+ //$width = (($j * 23) + 2).'px';
+ $i -= 1;
+ $height = (($i * 35)).'px';
+ //$height = (($i * 22) + 2).'px';
+
+ $jsonmap = json_encode($mapdata);
+ $mapdatadiv .= "<div id='$idprefix,mapdata' style='visibility:hidden;display:none'>";
+ $mapdatadiv .= $jsonmap;
+ $mapdatadiv .= '</div>';
+
+ $maptable = "<table style='width:$width;height:$height;' class='grid_table'>
+ $maptable
+ </table>";
+
+ if ($example) {
+ $output = $maptable;
+ $output .= "<input id='$idprefix,btn' type='button' onclick='doSend($idprefix)' value='Test path' />";
+ $output .= "
+ <div style='display:none;'>
+ <input type='radio' name='$idprefix,speed' id='$idprefix,spdslow' checked=true />
+ <input type='radio' name='$idprefix,speed' id='$idprefix,spdmed' />
+ <input type='radio' name='$idprefix,speed' id='$idprefix,spdfast' />
+ <input type='checkbox' id='$idprefix,mute' checked=true />
+ </div>
+ ";
+ $output .= $mapdatadiv;
+ $output = "<div style='width:$width;height:$height;'>
+ $output
+ </div>";
+ return $output;
+ }
+
+ $output = "
+<div id='$idprefix,outer' class='grid_outer' style='width:".($width+30)."px;height:".($height+50)."px;'>
+
+ <div class='grid_dsp_left dsp_49'>
+ <div id='$idprefix,dspID' class='grid_dsp_data' title='MapID: $idprefix'>
+ MapID: $idprefix
+ </div>
+ </div>
+
+ <div id='$idprefix,dsptl' class='grid_dsp_mid dsp_24'>
+ <a href='javascript:resetwalls($idprefix)'>Reset</a>
+ </div>
+
+
+ <div id='$idprefix,dsptr' class='grid_dsp_right dsp_24'>
+ <div id='$idprefix,dspWalls' class='grid_dsp_data'>
+ ".$mapdata['walls']." walls
+ </div>
+ </div>
+
+ $maptable
+
+ <div id='$idprefix,dspbl' class='grid_dsp_left dsp_49'>
+ <input id='$idprefix,btn' type='button' onclick='doSend($idprefix)' value='Test path' />
+
+ <label><input type='radio' name='$idprefix,speed' id='$idprefix,spdslow' />slow</label>
+ <label><input type='radio' name='$idprefix,speed' id='$idprefix,spdmed' checked=true />med</label>
+ <label><input type='radio' name='$idprefix,speed' id='$idprefix,spdfast' />fast</label>
+ </div>
+
+ <div class='grid_dsp_mid dsp_16'>
+ <label><input type='checkbox' id='$idprefix,mute' />Mute</label>
+ </div>
+
+ <div id='$idprefix,dspbr' class='grid_dsp_right dsp_33'>
+ <div id='$idprefix,dspCount' class='grid_dsp_data'>
+ ".$path['moves']." moves
+ </div>
+ </div>
+
+ $mapdatadiv
+</div>
+ ";
+
+ return $output;
+}
+
+
+
+
+?>
+</body>
+</html>
diff --git a/pages/cp.php b/pages/cp.php
new file mode 100644
index 0000000..44e1c2e
--- /dev/null
+++ b/pages/cp.php
@@ -0,0 +1,69 @@
+<?PHP
+htmlHeader();
+?>
+
+<body>
+
+<?php
+
+topbar($Links);
+
+include('./includes/maps.php');
+
+include_once ('./includes/db.inc.php');
+
+
+function validatename($name) {
+ if (strlen($name) < 1)
+ return false;
+ if ($name != htmlentities($name))
+ return false;
+ if (strlen($name) > 16)
+ return false;
+ return true;
+}
+
+echo "<br />";
+echo "<br />";
+$inputname = sql_clean($_POST['displayName']);
+
+if ($inputname) {
+ $inputname = sql_clean($_POST['displayName']);
+ $userID = $_SESSION['userID'];
+
+ if ($_SESSION['accepted'] == 1) {
+ if (validatename($inputname)) {
+ $sql = "UPDATE `users`
+ SET `displayName` = '$inputname'
+ WHERE `ID` = '$userID'
+ ";
+ mysql_query($sql);
+ $_SESSION['displayName'] = $inputname;
+ echo "<br /><b>Name change success (Your name may take a moment to be updated)</b> <br />";
+ } else {
+ echo "<br />Invalid name";
+ }
+ }
+}
+
+$displayName = $_SESSION['displayName'];
+
+?>
+<br />
+<br />
+<br /><h2>Change your display name</h2>
+<br />
+
+<form action="?page=cp" method="post" name='changename'>
+<? echo "<input type='text' size='20' maxlength='16' value='$displayName' name='displayName' class='forminput' />";
+?>
+<input type="submit" value="Change name" style='font-weight:bold;font-size:14px' class='forminput' />
+
+</form>
+
+
+
+
+
+</body>
+</html>
diff --git a/pages/faq.php b/pages/faq.php
new file mode 100644
index 0000000..9bac845
--- /dev/null
+++ b/pages/faq.php
@@ -0,0 +1,43 @@
+<?PHP
+htmlHeader();
+?>
+
+<body>
+<?php
+topbar($Links);
+
+?>
+
+
+<h2>Questions and Answers</h2>
+
+</br >
+<h3>Can you explain how the pathing works?</h3>
+The pathing trys to find the best route possible.
+In open areas there's lots of identical paths for it to take;
+To choose which path it will go it follows these priorities:
+<b> UP, RIGHT, DOWN, LEFT.</b>
+This means that the path will go UP as far as it can first- then, right, down, left.
+<br />If the path is going to the TOP RIGHT from the BOTTOM LEFT, the path will go UP all the way to the top, then RIGHT.
+<br />If the path is going to the BOTTOM LEFT, from the TOP RIGHT, the path will go all the way DOWN and then LEFT.
+<br />TOP LEFT, from BOTTOM RIGHT, UP, then LEFT.
+<br />So, BOTTOM LEFT, from TOP RIGHT? If you answer "DOWN then LEFT" you are correct!
+<br />If you answered "uhhmm.. What's up with the directions in caps." then you get a bonus point!
+<br />Remember, teleports are Traps, and does not effect the path choice.
+<br />
+<br />
+<h3>Why use Google to sign in?</h3>
+'OpenID' allows websites to use 3rd party servers to identify you.
+<br />We ask Google for your E-mail address, which you have to approve.
+<br />Basically, we send you to Google, and ask who you are, (You're not a robot, right?)
+<br />Google responds saying they know you, and gives me a code to identify you with, if you login again.
+<br />Many sites have started adopting this method of registration/login due to the safety it provides,
+not just for me, but for YOU.
+<br />There's no chance I can leak a password, because I never recieve one. - Plus you don't have to make up/remember another password.
+
+
+
+
+
+</body>
+</html> \ No newline at end of file
diff --git a/pages/gallery.php b/pages/gallery.php
new file mode 100644
index 0000000..68c17ae
--- /dev/null
+++ b/pages/gallery.php
@@ -0,0 +1,113 @@
+<?PHP
+htmlHeader();
+?>
+
+<body>
+<?php
+topbar($Links);
+
+
+include('../mazetd/includes/maps.php');
+include('../mazetd/includes/mapoftheday.php');
+
+
+echo "<br />";
+echo "<br />";
+echo "";
+
+echo rand(0,1);
+echo rand(0,1);
+echo rand(0,1);
+echo rand(0,1);
+echo rand(0,1);
+
+//15x9.c3.r28.w12.t2.:0s.8r.4f.0s.9r.3f.0s.12r.0f.0s.8r.0r.3f.0s.5r.5r.1f.0s.1r.11f.0s.0r.8r.1r.1f.0s.8r.4f.0s.4r.3r.4f.
+
+$map = GenerateMap(
+ 15, 9, 7 , //width, height, rocks
+ rand(11,13) , //Walls
+ weight(0,1,2,2,3,3) , //Checkpoints
+ rand(0,1) //Teleports
+ );
+
+
+$map = GenerateMap(
+ 14, 15, 50 , //width, height, rocks
+ weight(17,18,19,20) , //Walls
+ weight(1,2,2,3,3) , //Checkpoints
+ weight(0,0,0,1) //Teleports
+);
+
+//Weekend Map
+$map = GenerateMap(
+ 25, 15, 9 , //width, height, rocks
+ weight(20) , //Walls
+ weight(5) , //Checkpoints
+ weight(5) //Teleports
+);
+
+
+//Rocky Maze
+$map = GenerateMap(
+ 19, 15, 5 , //width, height, rocks
+ weight(16,17,18) , //Walls
+ weight(1,2,2,2,3,3) , //Checkpoints
+ weight(0) //Teleports
+);
+
+
+//Tele Madness
+$map = GenerateMap(
+ 17, 12, 10 , //width, height, rocks
+ weight(17,18) , //Walls
+ weight(1) , //Checkpoints
+ weight(5) //Teleports
+);
+
+//Tall tall
+$map = GenerateMap(
+ 6, 17, 10 , //width, height, rocks
+ weight(17,18,19,20) , //Walls
+ weight(1,2,2,2,3,3) , //Checkpoints
+ weight(0,0,0,1) //Teleports
+);
+//Side to Side
+$map = GenerateMap(
+ 26, 6, 12 , //width, height, rocks
+ weight(17,18,19) , //Walls
+ weight(2,2,2,3,3) , //Checkpoints
+ weight(3,3,3,4) //Teleports
+);
+
+
+
+$mapdisplay = DisplayMap($map);
+$code = GenerateMapCode($map);
+
+
+echo "<br />$mapdisplay";
+echo "<br />$code";
+print_r ($map);
+
+echo "<br />";
+echo "<br />";
+echo "<br />";
+echo weight(1,2,3,4,5,6);
+echo "<br />";
+echo weight(1,2,3,4,5,6);
+echo "<br />";
+echo weight(1,2,3,4,5,6);
+echo "<br />";
+echo weight(1,2,3,4,5,6);
+echo "<br />";
+echo weight(1,2,3,4,5,6);
+echo "<br />";
+echo weight(1,2,3,4,5,6);
+
+
+
+
+
+?>
+</body>
+</html>
diff --git a/pages/home.php b/pages/home.php
new file mode 100644
index 0000000..4a034c3
--- /dev/null
+++ b/pages/home.php
@@ -0,0 +1,167 @@
+<?PHP
+htmlHeader();
+?>
+
+<body>
+<script type="text/javascript" src="sounds/script/soundmanager.js"></script>
+
+<?php
+include('./includes/maps.php');
+include('./includes/mapoftheday.php');
+
+include('./includes/datas.php');
+
+switch ($_GET['maptype']) {
+ case "normal":
+ case "2":
+ $maptype = 2;
+ break;
+
+ case "hard":
+ case "3":
+ $maptype = 3;
+ break;
+
+ case "day":
+ case "4":
+ $maptype = 4;
+ break;
+
+ case "easy":
+ case "1":
+ default:
+ $maptype = 1;
+}
+
+//$motd = getMapOfTheDay();
+$motd = MapOfTheDay($maptype);
+
+topbar($Links);
+
+
+$mapID = $motd['id'];
+$map = $motd['map'];
+$userID = $_SESSION['userID'];
+$date = date("m-d-y");
+//$mergesolution = mergeMapSolution($map, $mysolution);
+$topscores = topScores($motd['id'], 30);
+$topscorediv = "<div id='$mapID,dspScore'>\n$topscores\n</div>";
+$mergesolution = $map;
+
+//Like button
+ //<br /><b>I made a like button!</b> I'm not sure what happens if you press it.
+ //<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.snapems.com&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;action=like&amp;font&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe>
+ //<br />Let me know if it makes your computer explode or something.
+
+
+?>
+<br />
+
+<div class="col1">
+ <b>I'm testing letting the path go over the START and FINISH tiles.</b>
+ <br /> Have an opinion about this? Let me know!
+ <p>
+ New maps are generated daily at 9:00 PM Pacific Time.
+ <br />Maps for <?php echo "$date" ?>:
+ <br /><a href='?page=home&amp;maptype=easy'>Simple</a>
+ <br /><a href='?page=home&amp;maptype=normal'>Normal</a>
+ <br /><a href='?page=home&amp;maptype=hard'>Complex</a>
+ <br /><a href='?page=home&amp;maptype=day'>Today's Special</a>
+ </p>
+
+ <? echo $topscorediv; ?>
+</div>
+
+<div class="col2" style="text-align: center">
+<?
+if ($_SESSION['accepted'] != 1) {
+ ?>
+ New? Check out <a href='?page=howtoplay'>How to Play</a>
+ <br /><span style="background-color: #444; font-weight: bold">
+ The object of the game is to make the longest maze.</span>
+ <br /><a href='?page=login'>Sign in using Google</a> to have your best solution saved.
+ <?
+} else
+ echo "<br />";
+
+
+//Get the current day as int.
+$numday = date('w');
+$numday = intval($numday);
+switch ($numday) {
+ case 0:
+ $mapstyle = 'Thirty';
+ break;
+ case 1:
+ $mapstyle = 'Simple';
+ break;
+ case 2:
+ $mapstyle = "ABC's";
+ break;
+ case 3:
+ $mapstyle = 'Teleport Madness';
+ break;
+ case 4:
+ $mapstyle = 'Rocky Maze';
+ break;
+ case 5: //Friday
+ $mapstyle = 'Side to Side';
+ break;
+ case 6: //Saturday
+ $mapstyle = "ABC's";
+ break;
+}
+
+echo "<br />$date<br /><a href='?page=home&amp;maptype=easy'>Simple</a> | ";
+echo "<a href='?page=home&amp;maptype=normal'>Normal</a> | ";
+echo "<a href='?page=home&amp;maptype=hard'>Complex</a> | ";
+$today = date('l');
+//if ($today == 'Sunday' OR $today == 'Saturday')
+ //$today = 'Weekend Map';
+//else
+ $today .= "'s";
+echo "<i><b> NEW: </b></i> <a href='?page=home&amp;maptype=day'>$today $mapstyle</a>";
+
+
+echo DisplayMap($mergesolution, $mapID);
+
+$mysolution = getSolution($userID, $mapID);
+$solutiondiv .= "<div id='mapsol' style='visibility:hidden;display:none'>";
+//$solutiondiv .= "<div id='mapsol'>";
+$solutiondiv .= $mapID.":".$mysolution;
+$solutiondiv .= '</div>';
+
+echo $solutiondiv;
+
+//Start tests
+
+// echo "<br /><br />map $map mapid $mapID userID $userID";
+// $mysolution = getSolution($userID, $mapID);
+// $mysolution = formSolution($mysolution);
+// echo " last-best solution $mysolution";
+// $mergesolution = mergeMapSolution($map, $mysolution);
+// echo " merge sol1: $mergesolution <br />";
+// $mergesolution = seperateMapSolution($mergesolution);
+// $mergesolution = formSolution($mergesolution);
+// echo " merge sol2: $mergesolution <br />";
+
+//echo "<br /><div id='debug'>tmp debug data</div><br />";
+
+//End tests
+//
+
+?>
+
+ <br />Please spread the word about this game.
+ <br />Send feedback to <a href='mailto:snapems@gmail.com'>snapems@gmail.com</a> (or IM me if you know me).
+ <br />We've been aptly implementing changes from feedback.
+ <br />This game is being adjusted, some 'rules' may change.
+ <br />Copyright &copy; 2011 Snapems.com
+
+</div>
+
+<script type="text/javascript">soundManagerInit();</script>
+
+
+</body>
+</html>
diff --git a/pages/howtoplay.php b/pages/howtoplay.php
new file mode 100644
index 0000000..11dc429
--- /dev/null
+++ b/pages/howtoplay.php
@@ -0,0 +1,102 @@
+<?PHP
+htmlHeader();
+?>
+
+<body>
+<?php
+topbar($Links);
+
+include('./includes/maps.php');
+
+// function GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1) {
+//$map = GenerateMap(6, 3, 1000, 3, 5, 0);
+//$mapcode = GenerateMapCode($map);
+
+//echo "$mapcode <br />";
+//echo displaymap($map, 0, true);
+
+//Demo nothing.
+$basicmapcode = '6x3.c0.r0.w9.t0.:0s.4f.0s.4f.0s.4f.';
+$basicmap = displaymap(GenerateMapByCode($basicmapcode), 1, true);
+
+//Map Demoing the checkpoints
+$cpcode = "6x3.c5.r0.w9.t0.:0s.0a.2b.0f.0s.1e.2f.0s.0d.2c.0f.";
+$cpmap = displaymap(GenerateMapByCode($cpcode), 2, true);
+
+//Map Demoing the teleports
+$tpcode = "6x3.c0.r0.w5.t4.:0s.0n.2t.0f.0s.4f.0s.0u.2m.0f.";
+$tpmap = displaymap(GenerateMapByCode($tpcode), 3, true);
+
+?>
+
+<h1>Tutorial</h2>
+<p>
+<br />The object of the game is to make the longest maze.
+<br />The "Snake" (name pending) must go to all the checkpoints.
+<br />It starts from the red arrows:
+<table><tr><td class='grid_td_start'></td></tr></table>
+and goes to the blue arrows:
+<table><tr><td class='grid_td_finish'></td></tr></table>
+<br />Build a maze by clicking to place blocks. You can remove a block by clicking it again.
+<br />It must be able to make it through your maze, so no walling completely!
+<br />Try it:
+<div style='width:200px;'>
+<? echo $basicmap; ?>
+</div>
+</p>
+<br /><h2>Checkpoints:</h2>
+<table>
+ <tr>
+ <td class='grid_td_cpa'></td>
+ <td class='grid_td_cpb'></td>
+ <td class='grid_td_cpc'></td>
+ <td class='grid_td_cpd'></td>
+ <td class='grid_td_cpe'></td>
+ </tr>
+</table>
+<p>
+The path must reach all these (if they exist) before going to finish. Try it:
+
+<div style='width:200px;'>
+<? echo $cpmap; ?>
+</div>
+<br />
+<br />
+<br />Tip: - Try to combine odd-letters with each other;
+<br />I.E. If A, B, C exist, try to make a box around A and C, then maze the entrance to the box.
+<br />This way, the path enters the box for A, leaves for B, returns for C, and leaves for the exit.
+This would make the path go through your maze 4 times!
+</p>
+<h2>Teleports:</h2>
+<table>
+ <tr>
+ <td><b>Teleport 1:</b></td>
+ <td class='grid_td_tp1_in' ></td>
+ <td class='grid_td_tp1_out' ></td>
+ </tr>
+ <tr>
+ <td><b>Teleport 2:</b></td>
+ <td class='grid_td_tp2_in' ></td>
+ <td class='grid_td_tp2_out' ></td>
+ </tr>
+</table>
+<p>
+<br />Teleport tiles are traps. When the path goes across the "IN" tile, it gets thrown to the "OUT" tile.
+<br />The path will not avoid teleports. Check this example out:
+<div style='width:200px;'>
+<? echo $tpmap; ?>
+</div>
+<br />
+<br />
+Implementing a teleport into your maze can have a big impact.
+</p>
+
+<br /><p>That should be enough information to get you started.
+<br />Now <a href='?page=home'>go try it out!</a>
+<br /></p>
+<br />
+<br />
+<br />
+
+</body>
+</html>
diff --git a/pages/leaderboard.php b/pages/leaderboard.php
new file mode 100644
index 0000000..c8f03b8
--- /dev/null
+++ b/pages/leaderboard.php
@@ -0,0 +1,236 @@
+<?PHP
+htmlHeader();
+?>
+
+<body>
+
+<?php
+
+topbar($Links);
+
+include('./includes/maps.php');
+//include('./includes/mapoftheday.php');
+include('./includes/datas.php');
+
+include_once ('./includes/db.inc.php');
+
+echo '<br /><br />';
+
+
+$tStats = getStat(1);
+$yStats = getStat(2);
+
+$wStats = getStat(3);
+$mStats = getStat(4);
+
+
+function getStat ($type) {
+ switch ($type) {
+
+ //Todays
+ case 1:
+ $where = "
+ DATE_ADD(CURDATE(), INTERVAL -0 DAY) =
+ DATE_FORMAT(solutions.dateModified,'%Y-%m-%d')
+ AND DATE_ADD(CURDATE(), INTERVAL -0 DAY) =
+ DATE_FORMAT(maps.dateCreated,'%Y-%m-%d')
+ ";
+ $statname = "Today's Best Overall:";
+ break;
+ //Yesterdays
+ case 2:
+ $where = "
+ DATE_ADD(CURDATE(), INTERVAL -1 DAY) =
+ DATE_FORMAT(solutions.dateModified,'%Y-%m-%d')
+ AND DATE_ADD(CURDATE(), INTERVAL -1 DAY) =
+ DATE_FORMAT(maps.dateCreated,'%Y-%m-%d')
+ ";
+ $statname = "Yesterday's Best Overall:";
+ break;
+ case 3:
+ $where = "
+ YEARweek(solutions.dateModified) = YEARweek(CURRENT_DATE)
+ ";
+ $statname = "This week, starting Sunday";
+ break;
+ case 4:
+ $where = "
+ month(solutions.dateModified) = month(CURRENT_DATE)
+ ";
+ $statname = "This month's Best";
+ break;
+ }
+
+ $sql = "SELECT
+ users.displayName as Name,
+ SUM(solutions.moves) as Moves,
+ timediff(MAX(dateModified), maps.dateCreated) as Timetaken
+ FROM `maps`
+ JOIN `solutions`
+ ON maps.ID = solutions.mapID
+ JOIN `users`
+ ON solutions.userID = users.ID
+ WHERE $where
+ GROUP BY solutions.userID
+ ORDER BY Moves DESC, MAX(dateModified) ASC
+ ";
+ $result = mysql_query($sql);
+ return displayStats($result, $statname);
+}
+
+
+
+?>
+<div style="padding-left: 400px">
+<a href="javascript:showStats(0)">Overall</a> |
+<a href="javascript:showStats(1)">Simple</a> |
+<a href="javascript:showStats(2)">Normal</a> |
+<a href="javascript:showStats(3)">Complex</a> |
+<a href="javascript:showStats(4)">Special</a> |
+<a href="javascript:showStats(5)">Week/Month</a>
+</div>
+<br />
+
+<div id="yms-0">
+ <div class="col1">
+ <? echo $tStats;?>
+ </div>
+ <div class="col2">
+ <? echo $yStats;?>
+ </div>
+</div>
+
+
+<?
+function yesterdayMaze($mapType, $name) {
+ $sql = "SELECT
+ maps.ID as mapID,
+ solution,
+ users.displayName as Name,
+ SUM(solutions.moves) as Moves,
+ timediff(solutions.dateModified, maps.dateCreated) as Timetaken
+ FROM `maps`
+ JOIN `solutions`
+ ON maps.ID = solutions.mapID
+ JOIN `users`
+ ON solutions.userID = users.ID
+ JOIN `mapOfTheDay`
+ ON maps.ID = mapOfTheDay.mapID
+ WHERE DATE_ADD(CURDATE(), INTERVAL -1 DAY) =
+ DATE_FORMAT(solutions.dateModified,'%Y-%m-%d')
+ AND DATE_ADD(CURDATE(), INTERVAL -1 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);
+ $stats = displayStats($result, "Yesterday's Best $name:");
+
+
+ $pastMap = pastMap($mapType, 1);
+ $mapID = $pastMap;
+ $mapcode = getMapCode($mapID);
+ $map = GenerateMapByCode($mapcode);
+ $sql = "SELECT `moves`, `displayName`, `solution`
+ FROM `solutions`, `users`
+ WHERE `mapID` = '$mapID' AND
+ `userID` = users.ID
+ ORDER BY `moves` DESC, `dateModified` ASC
+ LIMIT 1";
+ $result = mysql_query($sql) or die(mysql_error());
+ if (mysql_num_rows($result) > 0) {
+ list($bestMoves, $byName, $solution) = mysql_fetch_row($result);
+ //echo "Best solution for this map: $bestMoves by $byName";
+ //$map = MergeMapSolution($map, $solution);
+ //echo DisplayMap($map, $mapID);
+ }
+ echo '<div style="clear: both"></div>';
+ echo "<div id=\"yms-$mapType\">";
+ echo '<div class="col1">';
+ echo $stats;
+ echo '</div>';
+
+ echo '<div class="col2">';
+ echo "Best solution for this map: <b>$bestMoves by $byName </b>";
+ echo DisplayMap($map, $mapID, true, 2);
+ echo '</div>';
+ echo '</div>';
+}
+
+function displaystats($result, $caption = NULL) {
+ //Get names.
+ $headers .= "<th style='border:1px solid #ccc'>Rank</th>";
+ $headers .= "<th style='border:1px solid #ccc'>Name</th>";
+ $headers .= "<th style='border:1px solid #ccc'>Moves</th>";
+ $headers .= "<th style='border:1px solid #ccc'>Time taken</th>";
+ //Start table
+ $r .= "<table style='border:1px solid #FFF'>";
+ $r .= "<caption>$caption</caption>";
+ //Headers on the top. including Rank.
+ $r .= "<tr>";
+ $r .= $headers;
+ $r .= "</tr>";
+
+ $i = 1;
+ while ($row = mysql_fetch_assoc($result)) {
+ $rowcontent = '';
+ $mapid = $row['mapID'];
+ $solution = $row['solution'];
+
+ $r .= "<tr class='lbrow' onmouseover='javascript:loadSol(\"$mapid:$solution\")'>";
+ $r .= "<td>$i</td>";
+ $r .= '<td>' . $row['Name'] . '</td>';
+ $r .= '<td><a href="javascript:void(0)">' . $row['Moves'] . '</a></td>';
+ $r .= '<td>' . $row['Timetaken'] . '</td>';
+ $r .= "</tr>";
+ $i++;
+ }
+ $r .= "</table>";
+ return $r;
+}
+
+function mysql_field_array( $query ) {
+ $field = mysql_num_fields( $query );
+ for ( $i = 0; $i < $field; $i++ ) {
+ $names[] = mysql_field_name( $query, $i );
+ }
+ return $names;
+}
+
+// $sql = 'select columnname etc'
+// $result = mysql_query($sql);
+// while ($data[] = mysql_fetch_row($result));
+
+// $data[1]['columnname'] == 'my data';
+
+yesterdayMaze(1, 'Easy');
+yesterdayMaze(2, 'Normal');
+yesterdayMaze(3, 'Complex');
+yesterdayMaze(4, 'Special');
+
+?>
+
+<div style="clear: both"></div>
+<div id="yms-5">
+ <div class="col1">
+ <? echo $wStats;?>
+ </div>
+ <div class="col2">
+ <? echo $mStats;?>
+ </div>
+</div>
+
+
+<script>
+function showStats(type) {
+ for (var i = 0; i < 6; i++) {
+ var elem = document.getElementById("yms-" + i);
+ if (elem.className.indexOf('hidden-stats') < 0)
+ elem.className += 'hidden-stats';
+ }
+ var elem = document.getElementById("yms-" + type);
+ elem.className = elem.className.replace('hidden-stats', '');
+}
+showStats(0);
+</script>
diff --git a/pages/login.php b/pages/login.php
new file mode 100644
index 0000000..c730846
--- /dev/null
+++ b/pages/login.php
@@ -0,0 +1,117 @@
+<?php
+if ($_SESSION['accepted'] == 1) {
+ header("Location: $mydomain");
+ exit;
+}
+
+require 'includes/openid.php';
+try {
+ $openid = new LightOpenID;
+
+ //Require Email, and first name.
+ $openid->required = array('namePerson/first', 'contact/email');
+ //$openid->optional = array('namePerson/friendly', 'pref/timezone');
+
+ //Are we not logged in?
+ if(!$openid->mode) {
+ $openid->identity = 'https://www.google.com/accounts/o8/id';
+ header('Location: ' . $openid->authUrl());
+ } //Did we try to log in, but then the user canceled it?
+ elseif($openid->mode == 'cancel') {
+ // header('Location: ' . $mydomain);
+ //echo 'User has canceled authentication!';
+ } //We logged in and it worked!
+ elseif ($openid->validate()) {
+ //echo 'User has logged in.';
+
+ //What's in the goodie bag labeled "personal information"... hmmm
+ $tmp = $openid->getAttributes();
+ $display = $tmp['namePerson/first'];
+ //You don't have a name entered? whyfore!?
+ if (strlen($display) == 0) {
+ $display = 'noname';
+ }
+ $email = $tmp['contact/email'];
+ //print_r ($tmp);
+ //exit;
+ $claimedid = $openid->__get('identity');
+
+ //I know just where to put this stuff!
+ require './includes/db.inc.php';
+ //Unless I already have this information...
+ $sql = "SELECT `ID`, `isAdmin` FROM `users` WHERE `openID` = '$claimedid'";
+ $result = mysql_query($sql);
+
+ $_SESSION['isAdmin'] = false;
+ //echo "\n$sql\n";
+ //What a loser, he's already registered.
+ if (mysql_num_rows($result) > 0) {
+ $userID = mysql_result($result, 0, 'ID');
+ //Is he a cool admin person?
+ if (mysql_result($result, 0, 'isAdmin') == 1)
+ $_SESSION['isAdmin'] = true;
+
+ //I last-see you now!
+ $sql = "UPDATE `users`
+ SET `dateLogin` = NOW()
+ WHERE `ID` = '$userID'";
+ mysql_query($sql);
+ } //Well hello there new dude!
+ else {
+
+ //About that personal information - give me a second while save it.
+ // sql_clean is an addslashes equivilent
+ $sql = "INSERT INTO `users` (`openID`, `displayName`, `email`, `dateJoined`, `dateLogin`)
+ VALUES (
+ '$claimedid',
+ '".sql_clean($display)."',
+ '".sql_clean($email)."',
+ NOW(), NOW())";
+ $result = mysql_query($sql);
+ //Allright, all set.
+ //echo "$sql <br /> <br />";
+ If ($result) {
+ $userID = mysql_insert_id();
+ } //Oh crap?
+ else {
+ //echo "monkeys and etc";
+ DoRedirect("<br />new-user db register failure of unknown cause.\n
+ <br />Also, there were no monkeys trained or otherwise sent to resolve this problem.\n
+ <br />Sorry. youtube offered them more.\n", NULL, 10);
+ exit;
+ }
+ }
+ //If 'remember me' use this for cookie password
+ //$_SESSION['Passcode'] = MD5($Password.$Pepper.$Username);
+ $_SESSION['accepted'] = 1;
+ $_SESSION['userID'] = $userID;
+ $_SESSION['displayName'] = $display;
+
+ //The below is me hashing the claimedID.
+ $salt = "33qs5d4j6z98gt1a7n6b5d4x1c66f5nuh8a6d8g9j09aphgf56z5745";
+ $pepper = "Dear sir, have you ever heard of a wild goose chase?
+ If you've gotten this far, please email me: snapwilliam@gmail.com with this message.
+ I'll give you some sort of prize.";
+ $one = MD5($claimedid);
+ $two = MD5($one.$salt);
+ $three = MD5($pepper.$two);
+
+ $expire = time() + (7 * 24 * 60 * 60);
+ setcookie("userID", $userID, $expire);
+ setcookie("doLogin", "yes", $expire);
+ setcookie("auth", $three, $expire);
+
+
+ //DoRedirect("Thank you $display.", $_GET['ref']);
+ DoRedirect("", $_GET['ref'], 0);
+ exit;
+ } //Okay well, we considered logging in at least, right?
+ else {
+ DoRedirect("Login failed. Back to the home page with you!");
+ }
+ //The defaults will do fine here.
+ DoRedirect();
+} catch(ErrorException $e) {
+ echo $e->getMessage();
+}
+?>
diff --git a/pages/memberlist.php b/pages/memberlist.php
new file mode 100644
index 0000000..e9f2059
--- /dev/null
+++ b/pages/memberlist.php
@@ -0,0 +1,91 @@
+<?PHP
+htmlHeader();
+?>
+
+<body>
+
+<?php
+
+topbar($Links);
+
+include_once ('./includes/db.inc.php');
+
+
+
+//$sql = "SELECT `ID`, `Display`, `Date_Joined`, `Date_Login` FROM `USERS`";
+$sql = "SELECT `ID`, `displayName`, `dateJoined`, `dateLogin` FROM `users`";
+$result = mysql_query($sql);
+
+echo "
+<br />
+<table>
+<tr>
+<td>ID</td><td>Display name:</td><td>Joined On:</td><td>Last Logon</td>
+</tr>
+";
+
+while (list($CUID, $CUsername, $Joined, $LastLogon) = mysql_fetch_row($result)) {
+
+ //$Joined = Date("d/m/y - g:ia", $Joined);
+ //$Joined = relative_date($Joined);
+
+ if ($LastLogon == 0) {
+ $LastLogon = "Never";
+ } else {
+ //$LastLogon = Date("d/m/y - g:ia", $LastLogon);
+ //$LastLogon = date('M j, Y', $LastLogon);
+ //$LastLogon = relative_date($LastLogon);
+ }
+ //$LastLogon = Date("l, M jS. g:iA", $LastLogon);
+
+ Echo "<tr>
+<td>$CUID</td>
+<td><a href='javascript:;'>$CUsername</a></td>
+<td>$Joined</td>
+<td>$LastLogon</td>
+</tr>";
+
+}
+
+Echo "
+ </table>
+ <br />
+ <br />
+ </td>
+ </tr>
+</table>
+";
+
+
+//Thank you:
+//http://snippets.dzone.com/posts/show/196
+function relative_date($time) {
+ $today = strtotime(date('M j, Y'));
+ $reldays = ($time - $today)/86400;
+ if ($reldays >= 0 && $reldays < 1) {
+ return 'Today';
+ } else if ($reldays >= 1 && $reldays < 2) {
+ return 'Tomorrow';
+ } else if ($reldays >= -1 && $reldays < 0) {
+ return 'Yesterday';
+ }
+ if (abs($reldays) < 7) {
+ if ($reldays > 0) {
+ $reldays = floor($reldays);
+ return 'in ' . $reldays . ' day' . ($reldays != 1 ? 's' : '');
+ } else {
+ $reldays = abs(floor($reldays));
+ return $reldays . ' day' . ($reldays != 1 ? 's' : '') . ' ago';
+ }
+ }
+ if (abs($reldays) < 182) {
+ return date('l, F j',$time ? $time : time());
+ } else {
+ return date('l, F j, Y',$time ? $time : time());
+ }
+}
+
+
+
+
+?> \ No newline at end of file
diff --git a/pages/test.php b/pages/test.php
new file mode 100644
index 0000000..a5fe882
--- /dev/null
+++ b/pages/test.php
@@ -0,0 +1,408 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!-- iso-8859-1 -->
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link href="css/mapstyles.css" rel="stylesheet" type="text/css" />
+ <title>Maze TowerD</title>
+
+<?PHP
+// <script src="js/mapspecs.js" type="text/javascript"></script>
+
+include('../mazetd/includes/maps.php');
+
+//$mygrid = GenerateMap(20, 8, 4, 3);
+if (isset($_GET[mapcode])) {
+ $mygrid = GenerateMapByCode($_GET[mapcode]);
+} else {
+ $mygrid = GenerateMap(12, 12, 8);
+ $mygrid2 = GenerateMap(rand(12, 18), rand(10, 14), 8);
+ //$mygrid = GenerateMap(23, 13, 7, 3);
+}
+$code = GenerateMapCode($mygrid);
+
+
+?>
+
+ <script src="js/ajax.js" type="text/javascript"></script>
+
+<script type="text/javascript">
+window.onload = function(){
+ document.getElementById('blocksdisplay').innerHTML = "<b>"+blocks+"</b>";
+ //doSend();
+}
+
+
+var solution = new Array();
+var blocks = new Array();
+var count = new Array();
+var mapdata = new Array();
+
+function grid_click(obj) {
+
+ //Prepare data
+ tmp = obj.id.split(',');
+ mapid = tmp[0] - 0;
+ y = tmp[1];
+ x = tmp[2];
+
+ if (solution[mapid] == undefined) {
+ getmapdata(mapid);
+ }
+
+ if (obj.cv) {
+ obj.cv = false;
+
+ //obj.style.backgroundColor = '#ffffff';
+ obj.setAttribute("class", "grid_td");
+ blocks[mapid]++;
+ //alert(obj.id);
+ //Remove wall
+ solution[mapid] = solution[mapid].replace(y+','+x+'.', '');
+ } else {
+ if (blocks[mapid] < 1) {
+ alert("Outa blocks!");
+ return;
+ }
+ obj.cv = true;
+ //obj.style.backgroundColor = '#ff0000';
+ obj.setAttribute("class", "grid_td_walls");
+ //Add Wall
+ solution[mapid] += y+','+x+'.';
+ blocks[mapid]--;
+ }
+ document.getElementById('blocksdisplay').innerHTML = "<b>"+blocks[mapid]+"</b>";
+
+ document.getElementById(mapid+',dsptr').innerHTML = " "+blocks[mapid]+" walls remain.";
+
+}
+
+function getmapdata(mapid) {
+ mapdata[mapid] = JSON.parse(document.getElementById(mapid+',mapdata').innerHTML);
+ blocks[mapid] = mapdata[mapid].walls;
+ solution[mapid] = '.';
+ document.getElementById(mapid+',dsptr').innerHTML = " "+blocks[mapid]+" walls remain.";
+ //document.getElementById(mapid+',dsptr').innerHTML = blocks[mapid];
+}
+
+//==needs mapid
+function doSend(mapid) {
+ //mapcode = document.getElementById('mapcode').innerHTML;
+ //alert("dosend..");
+ //mapid = 1;
+ if (solution[mapid] == undefined) {
+ getmapdata(mapid);
+ }
+
+ mapcode = '<? echo $code; ?>';
+ reqstr = "";
+ reqstr += "&mapcode="+mapdata[mapid].code;
+ reqstr += "&mapid="+mapid;
+ //alert (mapdata[mapid].code);
+ reqstr += "&solution="+solution[mapid];
+
+ //alert(reqstr);
+ document.getElementById('dispdo').innerHTML = "http://mazetd.4xg.net/do.php?r=getpath"+reqstr
+
+ //alert("request string:"+reqstr);
+ ajax.requestFile = "do.php?r=getpath"+reqstr; //prepare strdata
+ ajax.onCompletion = request_path_done; // Specify function to be executed on response.
+ ajax.runAJAX();// Do it!
+}
+function resetwalls(mapid) {
+ answer = confirm("Remove walls and start fresh?");
+ if (answer) {
+ if (solution[mapid] == undefined) return;
+ walls = solution[mapid].split('.');
+ for(var i in walls) {
+ //alert(walls[i]);
+ tmp = walls[i].split(',');
+ eid = mapid+','+tmp[0]+','+tmp[1];
+ //alert('eid:'+eid);
+ if (document.getElementById(eid) != undefined) {
+ obj = document.getElementById(eid);
+ obj.setAttribute("class", "grid_td");
+ obj.cv = false;
+ //alert("exe");
+ }
+ }
+ solution[mapid] = undefined;
+ getmapdata(mapid);
+ }
+}
+
+function request_path_done() {
+ //document.getElementById('mapdisplay').innerHTML = ajax.response;
+ //alert ("resp: "+ajax.response);
+ //if (ajax.response == undefined) return;
+
+ //alert ("resp: "+ajax.response);
+ var JO = JSON.parse(ajax.response);
+
+ for(var i in JO.error) {
+ alert('\n JO error ' + JO.error[i]);
+ }
+
+ //document.getElementById('disp').innerHTML = JO.map;
+
+ if (JO.blocked) {
+ alert("Path is blocked make sure there is a way for it to go!");
+ return;
+ }
+ //document.write(JO.map);
+ //alert ("moves: "+JO.moves);
+ //alert ("path: "+JO.start);
+ document.getElementById('disppath').innerHTML = JO.path;
+ document.getElementById('disptotalmoves').innerHTML = JO.moves;
+
+ AnimatePath(JO.path, JO.mapid, JO.start);
+
+ //document.getElementById('mapdisplay').innerHTML = JO.map;
+
+}
+
+
+//This needs a start location.
+function AnimatePath(path, mapid, start) {
+ tmp = start.split(',');
+ y = tmp[0];
+ x = tmp[1];
+
+ p = path;
+ //alert("Begin");
+ t = p.length;
+ //count[mapid] = 0;
+ doanimate(x, y, p, t, mapid);
+ //setTimeout("doanimate("+x+","+y+",'"+p+"',"+t+")",500);
+}
+
+var snake = new Array();
+
+function doanimate(x, y, p, t, mapid) {
+ //Animate current square, and move to next one.
+ if (count[mapid] == undefined) {
+ count[mapid] = 0;
+ }
+ //alert("test");
+ if (snake[mapid] == undefined) {
+ snake[mapid] = new Array();
+ snake[mapid]['color'] = '#4444bb';
+ }
+
+ //==
+ // document.getElementById('1count').innerHTML = count[mapid];
+ document.getElementById(mapid+',dspbr').innerHTML = count[mapid]+ " moves";
+
+ eid = mapid+','+x+','+y;
+
+ //Verify.
+ if (document.getElementById(eid) == undefined) {
+ alert("Path exited field..?");
+ return;
+ }
+ handle = document.getElementById(eid);
+
+ //Maintain our original classname, no matter the cost!
+ origclass = handle.className;
+ if ( origclass == 'grid_td_path1' ||
+ origclass == 'grid_td_path2' ||
+ origclass == 'grid_td_path3' ||
+ origclass == 'grid_td_path4' ||
+ origclass == 'grid_td_animate_pre' ) {
+ // if (origclass == 'grid_td_animate' || origclass == 'grid_td_animate_pre' ) {
+ origclass = handle.classOrigName;
+ //setTimeout(handle.setAttribute('class', origclass), 850);
+ //alert('ex ' + origclass);
+ }
+ //handle.style.backgroundColor = snake[mapid]['color'];
+ handle.classOrigName = origclass;
+
+
+ //Just moves
+ switch(t) {
+ case '1': //1 - Up
+ case '2': //2 - Right
+ case '3': //3 - Down
+ case '4': //4 - Left
+ count[mapid]++;
+ handle.setAttribute('class', 'grid_td_path'+t);
+ break;
+ }
+ handle.style.backgroundColor = snake[mapid]['color'];
+
+ //setTimeout(handle.setAttribute('class', origclass), 850);
+ setTimeout("document.getElementById('"+eid+"').setAttribute('class', '"+origclass+"')", 855);
+ setTimeout("document.getElementById('"+eid+"').style.backgroundColor = '';", 855);
+
+ //Okay lets make it look cool now.
+ //document.getElementById(handle).setAttribute('class', 'grid_td_animate_pre');
+ //Needs a delay, or simply wont work.
+ //setTimeout("document.getElementById('"+handle+"').setAttribute('class', 'grid_td_animate')", 55);
+
+ //document.getElementById('blocksdisplay').innerHTML = "<b>"+origclass+"</b>";
+
+ //if (origclass != 'grid_td_animate' && origclass != 'grid_td_animate_pre' ) {
+ //document.getElementById('blocksdisplay').innerHTML = "<b>"+origclass+"</b>";
+ // setTimeout("document.getElementById('"+handle+"').setAttribute('class', '"+origclass+"')", 850);
+ //} else {
+ //document.getElementById('blocksdisplay').innerHTML = "<b>HELLO WORLD!?</b>";
+ //}
+
+ //Moving on:
+ speed = 85;
+ t = p.substring(0, 1);
+ if (t == '') {
+ count[mapid] = 0;
+ snake[mapid]['color'] = '#4444bb';
+ return;
+ }
+ switch(t) {
+ case '1': x--; break; //1 - Up
+ case '2': y++; break; //2 - Right
+ case '3': x++; break; //3 - Down
+ case '4': y--; break; //4 - Left
+ //Special codes.
+ //Reached Target
+ case 'a':
+ speed = 800;
+ snake[mapid]['color'] = '#F777FF';
+ break;
+ case 'b':
+ speed = 800;
+ snake[mapid]['color'] = '#FFFFAA';
+ break;
+ case 'c':
+ speed = 800;
+ snake[mapid]['color'] = '#44EE66';
+ break;
+ case 'd':
+ speed = 800;
+ snake[mapid]['color'] = '#ff9911';
+ break;
+ case 'e':
+ speed = 800;
+ snake[mapid]['color'] = '#44ddee';
+ break;
+ case 'f':
+ speed = 800;
+ snake[mapid]['color'] = '#4444bb';
+ break;
+ //The mighty teleport.
+ case 'u':
+ //alert(p);
+ tmp = p.split('u');
+ //alert(tmp[1]);
+ //alert(tmp[2]);
+ AnimatePath(tmp[2], mapid, tmp[1]);
+ //setTimeout("doanimate("+x+","+y+",'"+p+"','"+t+"','"+mapid+"')",speed);
+ return;
+ speed = 800;
+ break;
+ case 'n':
+ //alert(p);
+ tmp = p.split('n');
+ //alert(tmp[1]);
+ //alert(tmp[2]);
+ AnimatePath(tmp[2], mapid, tmp[1]);
+ //setTimeout("doanimate("+x+","+y+",'"+p+"','"+t+"','"+mapid+"')",speed);
+ return;
+ speed = 800;
+ break;
+ }
+ //Remove move from p
+ p = p.substring(1);
+ //speed = (10 * p.length) + 40;
+
+ setTimeout("doanimate("+x+","+y+",'"+p+"','"+t+"','"+mapid+"')",speed);
+}
+var de = false;
+function displaymap(obj) {
+ if (de == false) {
+ obj.setAttribute('class', 'mapdisplay_up');
+ }
+}
+function minmap(obj) {
+ de = true;
+ obj.setAttribute('class', 'mapdisplay');
+ setTimeout("de = false;", 1000);
+}
+
+</script>
+</head>
+
+<body>
+<?php
+
+
+echo DisplayMap($mygrid, 1);
+echo DisplayMap($mygrid2, 2);
+
+//Echo Findpath ($mygrid);
+$start[0] = 0;
+$start[1] = 1;
+
+//$p = Findpath ($mygrid, $start, 'a');
+//$pathmap1 = $p['path'];
+
+//echo "<br />BP1:".$p['path']."<br />";
+//echo "<br />yx2:".$p['end']."<br />";
+
+//$p = Findpath ($mygrid, explode(",", $p['end']), 'b');
+//echo "<br />BP:".$p['path']."<br />";
+//echo "<br />yx:".$p['end']."<br />";
+// $pathmap1 .= $p['path'];
+
+// $p = Findpath ($mygrid, explode(",", $p['end']), 'c');
+// $pathmap1 .= $p['path'];
+
+$p = Findpath ($mygrid, "2,4.3,4", 'f');
+$pathmap1 .= $p['path'];
+
+//echo DisplayMap($pathmap);
+
+//==Needs to contain mapid.
+//echo "<br /> <b><a href='javascript:doSend()'>Attempt Solution laaaaaaaaaaaaa laaaaaaaaaaaa CLick on this..</a></b>";
+echo "<br /><div style='font-size:32pt;' id='1count'><b>b</b></div> ";
+echo "<br />";
+var_dump ($p);
+
+
+echo "<br />";
+
+ // $time = microtime();
+ // $time = explode(' ', $time);
+ // $time = $time[1] + $time[0];
+ // $begintime = $time;
+
+ //for($i = 1; $i <= 500; $i++) {
+ //$mygrid = generateMap(13, 8, 4, 3);
+ //echo "$i <br />";
+ // $pathmap = Findpath ($mygrid, $start, 'a');
+ // $pathmap = Findpath ($mygrid, $start, 'b');
+ // $pathmap = Findpath ($mygrid, $start, 'c');
+ // $pathmap = Findpath ($mygrid, $start, 'f');
+ //}
+ // $time = microtime();
+ // $time = explode(" ", $time);
+ // $time = $time[1] + $time[0];
+ // $endtime = $time;
+ // $totaltime = round($endtime - $begintime, 5);
+ // echo "<br /><b>500 paths executed in: $totaltime s</b>";
+
+ //Starting result:
+ //500 paths executed in: 5.24884 s
+ //On a $mygrid = GenerateMap(13, 8, 4, 3); board.
+ //Now 1.
+echo "Mapcode: $code";
+?>
+<div id="blocksdisplay"><b>b</b></div>
+
+<div id="disp"><b></b></div>
+<div id="disppath"><b></b></div>
+<br />
+<div id="dispdo"><b></b></div>
+<br />
+<div id="disptotalmoves"><b></b></div>
+</body>
+</html> \ No newline at end of file