summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorraylu <raylu@cmu.edu>2011-04-07 00:27:27 -0400
committerraylu <raylu@cmu.edu>2011-04-07 00:27:27 -0400
commitf8c9eb5220afaf2f9a62f9a176a45913240f4081 (patch)
tree99775178acfcef6e86e39184be0ac96083042f1b
downloadpathery-f8c9eb5220afaf2f9a62f9a176a45913240f4081.tar.xz
Initial import from Dropbox
-rw-r--r--changelog/changelog.txt202
-rw-r--r--changelog/datascheme.sql82
-rw-r--r--css/mapstyle.css384
-rw-r--r--css/pagestyle.css61
-rw-r--r--css/statsstyle.css25
-rw-r--r--do.php255
-rw-r--r--errors.php15
-rw-r--r--globe.php157
-rw-r--r--images/Old Images/GameIdea.bmpbin0 -> 967430 bytes
-rw-r--r--images/Old Images/GameIdea.jpgbin0 -> 53085 bytes
-rw-r--r--images/Old Images/mazetd graphics.jpgbin0 -> 109082 bytes
-rw-r--r--images/Old Tiles/OverlayA50.pngbin0 -> 3897 bytes
-rw-r--r--images/Old Tiles/OverlayB50.pngbin0 -> 3986 bytes
-rw-r--r--images/Old Tiles/OverlayC50.pngbin0 -> 3765 bytes
-rw-r--r--images/Old Tiles/OverlayD50.pngbin0 -> 3813 bytes
-rw-r--r--images/Old Tiles/OverlayE50.pngbin0 -> 3820 bytes
-rw-r--r--images/Old Tiles/TeleportInAni.gifbin0 -> 2140 bytes
-rw-r--r--images/Old Tiles/TeleportInAniOld.gifbin0 -> 711 bytes
-rw-r--r--images/Old Tiles/TeleportInAnib.gifbin0 -> 1208 bytes
-rw-r--r--images/Old Tiles/TeleportOutAni.gifbin0 -> 1713 bytes
-rw-r--r--images/Old Tiles/TeleportOutAniB.gifbin0 -> 863 bytes
-rw-r--r--images/Old Tiles/TeleportOutAniOld.gifbin0 -> 732 bytes
-rw-r--r--images/OverlayA50.pngbin0 -> 3553 bytes
-rw-r--r--images/OverlayA50ss.pngbin0 -> 3435 bytes
-rw-r--r--images/OverlayB50.pngbin0 -> 3523 bytes
-rw-r--r--images/OverlayB50ss.pngbin0 -> 3473 bytes
-rw-r--r--images/OverlayC50.pngbin0 -> 3592 bytes
-rw-r--r--images/OverlayC50ss.pngbin0 -> 3612 bytes
-rw-r--r--images/OverlayD50.pngbin0 -> 3522 bytes
-rw-r--r--images/OverlayD50ss.pngbin0 -> 3427 bytes
-rw-r--r--images/OverlayE50.pngbin0 -> 3486 bytes
-rw-r--r--images/OverlayE50ss.pngbin0 -> 3178 bytes
-rw-r--r--images/OverlayStart50.pngbin0 -> 1270 bytes
-rw-r--r--images/OverlayStart50i.pngbin0 -> 1424 bytes
-rw-r--r--images/OverlayTeleport.pngbin0 -> 3042 bytes
-rw-r--r--images/OverlayTeleport.xcfbin0 -> 2574 bytes
-rw-r--r--images/OverlayTile10.pngbin0 -> 2266 bytes
-rw-r--r--images/OverlayTile20.pngbin0 -> 2419 bytes
-rw-r--r--images/OverlayTile30.pngbin0 -> 2531 bytes
-rw-r--r--images/OverlayTile50.pngbin0 -> 2781 bytes
-rw-r--r--images/OverlayTileFaceted10.pngbin0 -> 2563 bytes
-rw-r--r--images/OverlayTileFaceted20.pngbin0 -> 2757 bytes
-rw-r--r--images/OverlayTileFaceted30.pngbin0 -> 2851 bytes
-rw-r--r--images/OverlayTileFaceted50.pngbin0 -> 3056 bytes
-rw-r--r--images/OverlayTiles.xcfbin0 -> 34075 bytes
-rw-r--r--images/Path1.pngbin0 -> 1577 bytes
-rw-r--r--images/Path2.pngbin0 -> 1424 bytes
-rw-r--r--images/Path3.pngbin0 -> 1459 bytes
-rw-r--r--images/Path4.pngbin0 -> 1812 bytes
-rw-r--r--images/Teleport1.pngbin0 -> 256 bytes
-rw-r--r--images/Teleport2.pngbin0 -> 262 bytes
-rw-r--r--images/Teleport3.pngbin0 -> 261 bytes
-rw-r--r--images/Teleport4.pngbin0 -> 261 bytes
-rw-r--r--images/TeleportIn.pngbin0 -> 3245 bytes
-rw-r--r--images/TeleportInW.pngbin0 -> 3428 bytes
-rw-r--r--images/TeleportOut.pngbin0 -> 3261 bytes
-rw-r--r--images/TeleportOutW.pngbin0 -> 3436 bytes
-rw-r--r--includes/datas.php1
-rw-r--r--includes/db.inc.php11
-rw-r--r--includes/header.php67
-rw-r--r--includes/mapoftheday.php1
-rw-r--r--includes/maps.php743
-rw-r--r--includes/openid.php740
-rw-r--r--includes/pathing.php108
-rw-r--r--index.php90
-rw-r--r--js/ajax.js195
-rw-r--r--js/mapspecs.js688
-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
-rw-r--r--sound-config.xml20
-rw-r--r--soundcontroller.swfbin0 -> 2015 bytes
-rw-r--r--sounds/beep.mp3bin0 -> 6312 bytes
-rw-r--r--sounds/bling.mp3bin0 -> 38528 bytes
-rw-r--r--sounds/blip.mp3bin0 -> 5686 bytes
-rw-r--r--sounds/cap.mp3bin0 -> 3200 bytes
-rw-r--r--sounds/charm.mp3bin0 -> 10368 bytes
-rw-r--r--sounds/click.mp3bin0 -> 4736 bytes
-rw-r--r--sounds/cosmic002.mp3bin0 -> 26752 bytes
-rw-r--r--sounds/cosmic003.mp3bin0 -> 193664 bytes
-rw-r--r--sounds/hologram.mp3bin0 -> 42112 bytes
-rw-r--r--sounds/page.mp3bin0 -> 11119 bytes
-rw-r--r--sounds/script/demo.js11
-rw-r--r--sounds/script/soundmanager.js182
-rw-r--r--sounds/select.mp3bin0 -> 7248 bytes
-rw-r--r--sounds/transmission.mp3bin0 -> 4224 bytes
-rw-r--r--sounds/ufoblip.mp3bin0 -> 11904 bytes
96 files changed, 5650 insertions, 0 deletions
diff --git a/changelog/changelog.txt b/changelog/changelog.txt
new file mode 100644
index 0000000..4489604
--- /dev/null
+++ b/changelog/changelog.txt
@@ -0,0 +1,202 @@
+=================
+== NamePending ==
+=================
+04-04-11
+ Setup the leaderboard to show every solution from yesterday. - Snap
+ Modified loadSol() JS function to support other calls. - Snap
+ Added col1 and col2 classes for the columns. They're now used on the homepage and leaderboard page. - raylu
+ The leaderboard specific CSS is in statsstyle.css. It's currently included on all pages, unfortunately. - raylu
+ Cleaned up the leaderboard.php code duplication. - raylu
+ Added some Javascript to only show one stats section at a time on the leaderboard page. - raylu
+
+04-03-11
+ Fixed a database related issue, solution size was insuffecient. - Snap
+ Preferences for mute/speed is now saved - Snap
+ Facebook page semi-started (awaiting name?) - Snap
+
+03-28-11 - 03-31-11
+ Added maps-per-day. - Snap
+ A few map-types designed and added. - Snap
+ Added deny all .htaccess to /pages. - Snap
+
+03-27-11
+ Added yesterdays best solution to leaderboard. - Snap
+
+03-26-11 (Back from vacation)
+ do.php now confirms that it is a current map. - Snap
+ isCurrentMap() function added to do.php
+ Moved $Links array to index.php. - Snap
+ Fixed an issue with generating links before cookielogin.
+ The logic of having them next to where it checks for those links is better too.
+
+03-16-11
+ Fixed an issue with the leaderboard. - Snap
+
+03-15-11
+ Some spelling/grammar fixes in how to play. -raylu
+ Redid the layout. -raylu
+ There is no navigation bar anymore; everything is in the top bar.
+ There are now two float:left divs with widths 25%, 50% on the homepage. This gives the
+ illusion that the second one is "centered."
+ Fixed a lot of issues with the animated path. - Snap
+
+03-14-11
+ Added cp.php, control-panel. - Snap
+ Allows users to change their displayname.
+ Link for now is located on their displayname, top right.
+ Fixed an issue where pathing didn't like to overlap. - Snap
+
+03-13-11
+ Turned the Speed into a dropdown. -Snap (Thanks Rory)
+ Login Logout top-bar added. - Snap
+ Your personal best solution is loaded for the map. - Snap
+ Leaderboard added. - Snap
+ Logout link removed from nav, but login link kept. (makes sense, right?) - Snap
+
+03-12-11
+ Tons if little changes to the UI. -Snap
+
+03-11-11
+ Cookie login method added; session data is rebuilt. - Snap
+ !~ Auth is not dependent on a time frame, this will need to be fixed.
+ Cookies are deleted on logout.
+ MapCode is now requested from the database, rather than using the exploitable JS code. - Snap
+ Implemented "formSolution" function into do.php; - Snap
+ Now identical solutions will appear identical.
+ This could be useful in the future, but only if this is implemented now.
+
+03-10-11
+ Updated our pipeline.txt - Snap
+ Added notification of when you beat or tie a record. - Snap
+ Fixed unusual bug where hitting a target could cause an issue with the counter-box. - Snap
+ Added datas.php for SQL statistical output. - Snap
+ Started topscores PHP function.
+
+
+03-09-11
+ Fixed a bug with reset button leaving shadows. - Snap (ty, everyone who mentioned that)
+ Added blink to teleport tiles when in use. - Snap
+ Test Path button is now disabled for the duration of the animation. - Snap
+ Started the 'How To Play' page: - Snap
+ Added optional arguement $example boolean = false to the PHP displayMap function.
+ When true, speed is set to slow, and the border-data is removed.
+ Fixed a height issue with smaller maps, which has been effecting other maps too. - Snap
+ Many improvements made to the "doAnimate" function. - Snap
+
+03-08-11
+ Fixed a bug when removing blocks could currupt the solution. - Snap
+ The animated path now goes 'over' special squares, instead of hoping over them. - Snap
+ New function mapOfTheDay(TYPE). - Snap
+ Returns the map created for that TYPE or generates one that day.
+ TYPES; 1 2 3 4, easy normal hard random. Default: random.
+ new types are created very easily, I.E. $motd = mapOfTheDay(5); will generate the map, unless existing that day.
+ To set custom definitions for that map, just add a case in mapOfTheDay's switch $type.
+
+03-07-11
+ Fixed a bug special where the path could be blocked by blocking a teleport OUT. - Snap (thanks Light)
+ (Special because other rare conditions had to be met too);
+ Tweaked game border-data. - Snap
+ Nice lookin IN and OUT tiles made. - Rex
+
+03-03-11 - 03-06-11
+ Tweaked colors. - Snap
+ Changed how javascript handled teleports. and gray-ed out teleports. - Snap
+ Pathing now goes INTO the teleport in - rather than teleporting before reaching TPin. - Snap
+ A required change for the animation to properly locate the teleport-in square.
+ Note; this change will add +1 moves per used-teleport in some solutions.
+ Added sounds. Snap
+ Added slow-med-fast animation. Snap
+ Added gray-out checkpoints. Snap
+ mapcode format changed - see documentation.txt. - Snap
+
+03-02-11
+ Started recording peoples best solution. - Snap
+ Login added. - Snap
+ Pages and links prepared. - Rex
+ Header navigation started. - Rex
+ mapoftheday.php and function mapOfTheDay() added; - Snap
+ Database tables added; maps, users, solutions - Snap
+
+03-01-11
+ Added 'Reset Walls' button. - Snap
+ Once again fixed a counting issue with PHP... - Snap
+ Contained mazes to allow for unlimited mazes to be displayed, animated and solved. - Snap
+
+
+02-28-11
+ Fixed an issue where pathing could run into mapMatrix[0] (headers) - Snap
+ DisplayMap now sneaks in a hidden div containing JSON data for wall count & etc. - Snap
+ $numBlocks arguement changed to optional, default -1 for random. - Snap
+ Random odds currently set to:
+ $numBlocks = Rand(7, (int)($rows * $cols) * .12);
+ Many, many bug fixes related to having 0 checkpoints & alike. - Snap
+ Fixed snake-color issue adjustable checkpoints. -Snap
+ Routepath correctly handles different amount of checkpoints. - Snap
+ GenerateMap now has 2 optional arguements for checkpoints and teleports.
+ -1 - 5, -1 - 2, default -1 - which is random. - Snap
+ Fixed an issue where php's movecount was off. - Snap
+ Added checkpoints "d" and "e" - Snap
+ Set the "snake"'s color the same as it's next target. - Snap
+
+02-27-11
+ Added 2nd teleport, and solved the many issues that arised with it. - Snap
+ Solved an issue where the javascript animation caused mapdistoration due to non-set width/height. - Snap
+ Fixed move-count when effected by teleports - Snap
+
+02-26-11
+ Discovered that if you block the teleport-out square, it jumps to the next target... - Snap
+ bewildered by the fact that my code didn't fail, perhaps we should leave it as is?
+ Semi-implemented arrow-snake. - Snap
+ More attractive images added. - Rex
+
+02-25-11 (Updates from previous days)
+ Added ValidateMap($mapMatrix) function. - Snap
+ Started a database, no tables. - Snap
+ <Link removed for security> contact Snap for DB access.
+ A sweet teleport 't' and 'u' added! w00 h00! - Snap (w/ help).
+ Updated Pathing to support multiple start locations. (['start'] = 'y,x' of start location) - Snap
+ Finished update on javascript to support multiple start locations. - Snap
+ Completed pathing. - Snap
+ Updated visuals.
+ Edited CSS for .grid_table. - Rex
+ Added Website Diagram to /Changelog. - Rex
+
+
+02-22-11
+ Modified MergeMapSolution function - Snap
+ Added optional $idprefix to DisplayMap, to allow for multiple maps on the same page. - Snap
+ Added required mapid to AnimatePath(path, mapid) - Snap
+ Added solution array, and blocks array, for multiple maps - Snap
+ Added alternate prefixes to CSS Transitions, sadly firefox doesn't support this property
+ but, it still looks good without it. (Opera & Netscape some others do).
+ Started work on gallery. - Snap
+
+02-21-11
+ Started work on AJAX (do.php & home.php). -Snap
+ Added function MergeMapSolution(Map, Solution) -Snap
+ Added JS function AnimatePath(PATHCODE) Fairly pretty :) -Snap
+ Had a lot of fun with css transitions.
+ Worked on FindPath function -Rex
+
+02/20/11
+ $mapMatrix[0] now holds header data
+ Edited GenerateMapCode - added more headers and adjusted loop
+ Created GenerateMapByCode function.
+ Created GetTile function. (Not working)
+ Fixed Checkpoint spawn
+ Fixed an issue regarding an extra column being generated in GenerateMap
+
+Snap 02/19/11
+
+ Added headers to GenerateMapCode
+ Temporarly moved Functions GenerateMapCode & GenerateMap to map.php
+ Created DisplayMap function
+ Lots of little things.
+
+
+02/18/11
+In Concept.
+
+
+
+
diff --git a/changelog/datascheme.sql b/changelog/datascheme.sql
new file mode 100644
index 0000000..bb00b23
--- /dev/null
+++ b/changelog/datascheme.sql
@@ -0,0 +1,82 @@
+-- phpMyAdmin SQL Dump
+-- version 3.3.8.1
+-- http://www.phpmyadmin.net
+--
+-- Host: db2838.perfora.net
+-- Generation Time: Mar 15, 2011 at 07:14 PM
+-- Server version: 5.0.91
+-- PHP Version: 5.2.17
+
+SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
+
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+
+--
+-- Database: `db358894438`
+--
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `mapOfTheDay`
+--
+
+CREATE TABLE `mapOfTheDay` (
+ `ID` int(11) NOT NULL auto_increment,
+ `mapID` int(11) NOT NULL,
+ `mapType` tinyint(4) NOT NULL,
+ `mapDate` date NOT NULL,
+ PRIMARY KEY (`ID`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `maps`
+--
+
+CREATE TABLE `maps` (
+ `ID` int(11) NOT NULL auto_increment,
+ `code` varchar(512) collate latin1_general_ci NOT NULL,
+ `dateCreated` timestamp NOT NULL default CURRENT_TIMESTAMP,
+ PRIMARY KEY (`ID`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `solutions`
+--
+
+CREATE TABLE `solutions` (
+ `ID` int(11) NOT NULL auto_increment,
+ `userID` int(11) NOT NULL,
+ `mapID` int(11) NOT NULL,
+ `solution` varchar(128) collate latin1_general_ci NOT NULL,
+ `moves` int(11) NOT NULL,
+ `dateModified` timestamp NOT NULL default CURRENT_TIMESTAMP,
+ PRIMARY KEY (`ID`),
+ KEY `userID` (`userID`,`mapID`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `users`
+--
+
+CREATE TABLE `users` (
+ `ID` int(11) NOT NULL auto_increment,
+ `openID` varchar(255) collate latin1_general_ci NOT NULL,
+ `email` varchar(128) collate latin1_general_ci NOT NULL,
+ `displayName` varchar(64) collate latin1_general_ci NOT NULL,
+ `dateLogin` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+ `dateJoined` timestamp NOT NULL default '0000-00-00 00:00:00',
+ `isAdmin` tinyint(1) NOT NULL default '0',
+ PRIMARY KEY (`ID`),
+ UNIQUE KEY `openID` (`openID`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
diff --git a/css/mapstyle.css b/css/mapstyle.css
new file mode 100644
index 0000000..77a8089
--- /dev/null
+++ b/css/mapstyle.css
@@ -0,0 +1,384 @@
+.grid_dsp_data {
+ padding:1px;
+ font-style:italic;
+ font-weight:bold;
+}
+
+.grid_outer
+{
+ position:relative;
+ padding: 0px;
+ margin-top: 10px;
+ margin-bottom: 60px;
+ padding-top:2px;
+ padding-bottom:10px;
+ margin-left:auto;
+ margin-right:auto;
+ border-top: 1px solid #000;
+ border-left: 1px solid #000;
+ border: 0px solid #000;
+ background-color: #333399;
+}
+.grid_outer a
+{
+ color: #FFFF33;
+}
+
+
+.dsp_33 {
+ width:32%;
+}
+.dsp_49 {
+ width:49%;
+}
+.dsp_24 {
+ width:23%;
+}
+.dsp_16 {
+ width:16%;
+}
+
+.grid_dsp_left,
+.grid_dsp_mid,
+.grid_dsp_right {
+ overflow: none;
+ position:relative;
+ float: left;
+ padding:2px;
+ color: #FFFFFF;
+}
+.grid_dsp_left {
+ text-align:left;
+ align:left;
+}
+.grid_dsp_mid {
+ text-align:center;
+}
+.grid_dsp_right {
+ text-align:right;
+}
+
+.grid_img {
+ padding: 0px;
+ margin: 0px;
+ border: 0px;
+ border-spacing: 0px;
+ width: 36px;
+ height: 35px;
+}
+
+
+.grid_table
+{
+ position:relative;
+ padding: 0px;
+ margin-top:1px;
+ margin-bottom:1px;
+ margin-left:auto;
+ margin-right:auto;
+ border-top: 0px solid #000;
+ border-left: 0px solid #000;
+ border: 1px solid #000;
+ border-spacing: 0px;
+}
+.grid_table td, .grid_table th {
+ padding: 0px;
+ margin: 0px;
+}
+.grid_td,
+.grid_td_rocks, .grid_td_walls,
+.grid_td_start, .grid_td_finish,
+.grid_td_cpa, .grid_td_cpb, .grid_td_cpc,
+.grid_td_cpd, .grid_td_cpe,
+.grid_td_animate, .grid_td_animate_pre,
+.grid_td_tp1_in, .grid_td_tp2_in, .grid_td_tp3_in, .grid_td_tp4_in, .grid_td_tp5_in,
+.grid_td_tp1_out, .grid_td_tp2_out, .grid_td_tp3_out, .grid_td_tp4_out,.grid_td_tp5_out,
+.grid_td_path1 , .grid_td_path2, .grid_td_path3, .grid_td_path4
+{
+ padding: 0px;
+ margin: 0px;
+ border: 0px;
+ border-right: 0px solid #000;
+ border-bottom: 0px solid #000;
+
+ overflow: hidden;
+ font-size: 4px;
+ line-height:9px;
+ width: 35px;
+ /* width: 22px; */
+ height: 35px;
+ min-height: 1px;
+ background: url(../images/OverlayTileFaceted50.png);
+ background-size: 100%;
+ transition:background-color 0s;
+ -webkit-transition:background-color 0s;
+ -o-transition:background-color 0s;
+ -moz-transition:background-color 0s;
+}
+.grid_td
+{
+ background: #F5FBFE url(../images/OverlayTile10.png);
+}
+.grid_td:hover
+{
+ background: #CCCCCC url(../images/OverlayTileFaceted10.png);
+}
+.grid_td_pressed {
+ background: #111122;
+}
+
+.grid_td_rocks {
+ background: #b85555 url(../images/OverlayTileFaceted50.png);
+}
+.grid_td_walls {
+ background-color: #777;
+ background: url(../images/OverlayTileFaceted50.png);
+ transition:background-color 1.6s ease-out;
+ -webkit-transition:background-color 1.6s ease-out;
+ -o-transition:background-color 1.6s ease-out;
+ -moz-transition:background-color 1.6s ease-out;
+}
+.grid_td_walls:hover {
+ background: #CCCCCC url(../images/OverlayTileFaceted30.png);
+ background-color: #999;
+}
+
+.grid_td_start {
+ background: url(../images/OverlayStart50i.png);
+ background-color: #F75555;
+}
+.grid_td_finish {
+ background: url(../images/OverlayStart50.png);
+ background-color: #6666FF;
+ color: #fff;
+}
+
+
+.grid_td_tp1_in, .grid_td_tp2_in, .grid_td_tp3_in, .grid_td_tp4_in, .grid_td_tp5_in,
+.grid_td_tp1_out, .grid_td_tp2_out,.grid_td_tp3_out, .grid_td_tp4_out,.grid_td_tp5_out,
+.grid_td_cpa, .grid_td_cpb, .grid_td_cpc, .grid_td_cpd, .grid_td_cpe
+{
+ transition:background-color 2s;
+ -webkit-transition:background-color2s;
+ -o-transition:background-color 2s;
+ -moz-transition:background-color 2s;
+}
+
+.no_transition {
+ transition:background-color 0s;
+ -webkit-transition:background-color 0s;
+ -o-transition:background-color 0s;
+ -moz-transition:background-color 0s;
+}
+
+
+
+.grid_td_tp1_in {
+ /* background: url(../images/OverlayTeleport.png),url(../images/TeleportInAni.gif); */
+ background: url(../images/TeleportInW.png);
+ background-color: #3377AA;
+}
+.grid_td_tp1_out {
+ /* background: url(../images/OverlayTeleport.png),url(../images/TeleportInAni.gif); */
+ background: url(../images/TeleportOutW.png);
+ background-color: #3377AA;
+}
+.grid_td_tp2_in {
+ /* background: url(../images/OverlayTeleport.png),url(../images/TeleportInAni.gif); */
+ background: url(../images/TeleportIn.png);
+ background-color: #44EE66;
+}
+.grid_td_tp2_out {
+ /* background: url(../images/OverlayTeleport.png),url(../images/TeleportOutAni.gif); */
+ background: url(../images/TeleportOut.png);
+ background-color: #44EE66;
+}
+.grid_td_tp3_in {
+ /* background: url(../images/OverlayTeleport.png),url(../images/TeleportInAni.gif); */
+ background: url(../images/TeleportInW.png);
+ background-color: #992200;
+}
+.grid_td_tp3_out {
+ /* background: url(../images/OverlayTeleport.png),url(../images/TeleportOutAni.gif); */
+ background: url(../images/TeleportOutW.png);
+ background-color: #992200;
+}
+.grid_td_tp4_in {
+ /* background: url(../images/OverlayTeleport.png),url(../images/TeleportInAni.gif); */
+ background: url(../images/TeleportIn.png);
+ background-color: #55CCFF;
+}
+.grid_td_tp4_out {
+ /* background: url(../images/OverlayTeleport.png),url(../images/TeleportOutAni.gif); */
+ background: url(../images/TeleportOut.png);
+ background-color: #55CCFF;
+}
+.grid_td_tp5_in {
+ /* background: url(../images/OverlayTeleport.png),url(../images/TeleportInAni.gif); */
+ background: url(../images/TeleportInW.png);
+ background-color: #005533;
+}
+.grid_td_tp5_out {
+ /* background: url(../images/OverlayTeleport.png),url(../images/TeleportOutAni.gif); */
+ background: url(../images/TeleportOutW.png);
+ background-color: #005533;
+}
+
+
+
+
+.grid_td_cpa {
+ background: url(../images/OverlayA50.png);
+ /* For non-fancy letters...*/
+ /* background: url(../images/OverlayA50ss.png); */
+ background-color: #F777FF;
+ color: #fff;
+}
+.grid_td_cpb {
+ background: url(../images/OverlayB50.png);
+ /* background: url(../images/OverlayB50ss.png); */
+ background-color: #FFFF11;
+ color: #000;
+}
+.grid_td_cpc {
+ background: url(../images/OverlayC50.png);
+ /* background: url(../images/OverlayC50ss.png); */
+ background-color: #FF4466;
+ color: #fff;
+}
+.grid_td_cpd{
+ background: url(../images/OverlayD50.png);
+ /* background: url(../images/OverlayC50ss.png); */
+ background-color: #ff9911;
+ color: #fff;
+}
+.grid_td_cpe {
+ background: url(../images/OverlayE50.png);
+ /* background: url(../images/OverlayC50ss.png); */
+ background-color: #00FFFF;
+ color: #fff;
+}
+.grid_td_animate {
+ /* background: url(../images/OverlayStart50i.png); */
+ background: url(../images/OverlayTile50.png);
+ background-color: #000055;
+ color: #0000ff;
+ transition:background-color 2s ease-out;
+ -webkit-transition:background-color 2s ease-out;
+ -o-transition:background-color 2s ease-out;
+ -moz-transition:background-color 2s ease-out;
+
+}
+.grid_td_animate_pre {
+ /* background: url(../images/OverlayTile50.png); */
+ background: url(../images/Path1.png);
+ background-color: #77ccff;
+ color: #00ccff;
+ transition:background-color 0s;
+ -webkit-transition:background-color 0s;
+ -o-transition:background-color 0s;
+ -moz-transition:background-color 0s;
+}
+.grid_td_path1 , .grid_td_path2, .grid_td_path3, .grid_td_path4 {
+ transition:background-color .5s ease-out;
+ -webkit-transition:background-color .5s ease-out;
+ -o-transition:background-color .5s ease-out;
+ -moz-transition:background-color .5s ease-out;
+}
+.grid_td_path1 {
+ background: url(../images/Path1.png);
+}
+.grid_td_path2 {
+ background: url(../images/Path2.png);
+}
+.grid_td_path3 {
+ background: url(../images/Path3.png);
+}
+.grid_td_path4 {
+ background: url(../images/Path4.png);
+}
+
+
+.mapdisplay, .mapdisplay_up
+{
+ position:absolute;
+ width:auto;
+ height:auto;
+ box-shadow: 10px 10px 5px #000055; /* Opera */
+ -webkit-box-shadow: 10px 10px 5px #000055; /* Safari and Chrome */
+
+ -webkit-transform:
+ skew(10deg,10deg)
+ scale(.3, .3)
+ translate(-390px, -230px)
+ rotate(1deg)
+ rotateX(0deg)
+ ;
+ -moz-transform:
+ skew(10deg,10deg)
+ scale(.3, .3)
+ translate(-390px, -230px)
+ rotate(1deg)
+ rotateX(0deg)
+ ;
+ /* Remember, we need to duplicate all of this with prefix -o- and w/o prefix for opera, ff, netscape. */
+ -webkit-transition:-webkit-transform 2s;
+ -webkit-transition-delay: 0s;
+ -moz-transition:-webkit-transform 2s;
+ -moz-transition-delay: 0s;
+ z-index:1;
+}
+.mapdisplay_up
+{
+
+ -webkit-transform:
+ skew(0deg,0deg)
+ scale(1, 1)
+ translate(0px, 0px)
+ rotate(0deg)
+ rotateX(0deg)
+ ;
+ -moz-transform:
+ skew(0deg,0deg)
+ scale(1, 1)
+ translate(0px, 0px)
+ rotate(0deg)
+ rotateX(0deg)
+ ;
+ -webkit-transition:-webkit-transform 1s;
+ -moz-transition:-webkit-transform 1s;
+ z-index:2;
+}
+.mapdisplay_up:hover {
+ background:#10e;
+}
+.mapdisplay:hover {
+ z-index:3;
+ background:#10e;
+}
+
+.mapgallery
+{
+ position:relative;
+ float: left;
+ width:auto;
+ height:700px;
+ background: #110088;
+ color: #FFF;
+}
+.mapgallery a
+{
+ color: #FFFF33;
+}
+
+
+.mapcontainer
+{
+ border:1px solid #000;
+ position:relative;
+ float: left;
+ width:300px;
+ height:200px;
+ background: #220099;
+}
+.clear { clear: both;}
diff --git a/css/pagestyle.css b/css/pagestyle.css
new file mode 100644
index 0000000..8a834bb
--- /dev/null
+++ b/css/pagestyle.css
@@ -0,0 +1,61 @@
+body {
+ font-size: 12pt;
+ font-family: helvetica, sans-serif;
+ background-color: #121212;
+ color: #ffffff;
+
+ min-width: 800px;
+ margin: 0;
+ padding: 6px;
+}
+
+form {
+ display: inline;
+}
+
+a:link, a:visited, a:active {
+ text-decoration: underline;
+ color: #FFFFCC;
+ transition:color .4s ease-out;
+ -webkit-transition:color .4s ease-out;
+ -o-transition:color .4s ease-out;
+ -moz-transition:color .4s ease-out;
+}
+a:hover {
+ color: #EEDDBB;
+ text-decoration: none;
+ transition:color 0s ease-out;
+ -webkit-transition:color 0s ease-out;
+ -o-transition:color 0s ease-out;
+ -moz-transition:color 0s ease-out;
+}
+
+.col1 {
+ float: left;
+ width: 25%;
+ min-width: 300px;
+ padding: 0 25px;
+}
+.col2 {
+ float: left;
+ width: 50%;
+ margin: 0 auto;
+}
+
+.float {
+ float:left;
+}
+.lfloat {
+ float:right;
+}
+
+.topbar {
+ background: #002266;
+ /*
+ background: #000044 url(../images/OverlayStart50i.png);
+ height:35px;
+ */
+ width: 95%;
+ padding: 5px 15px;
+ margin: 0 auto;
+}
diff --git a/css/statsstyle.css b/css/statsstyle.css
new file mode 100644
index 0000000..a15636f
--- /dev/null
+++ b/css/statsstyle.css
@@ -0,0 +1,25 @@
+table {
+ border-collapse: collapse;
+}
+td, th {
+ padding: 3px;
+}
+.lbrow {
+ background: #000000;
+ transition:background .5s;
+ -webkit-transition:background .5s;
+ -o-transition:color .5s;
+ -moz-transition:color .5s;
+ cursor: default;
+}
+.lbrow:hover {
+ background: #338899;
+ transition:background 0s;
+ -webkit-transition:background 0s;
+ -o-transition:color 0s;
+ -moz-transition:color 0s;
+}
+.hidden-stats {
+ display: none;
+}
+
diff --git a/do.php b/do.php
new file mode 100644
index 0000000..8ff2162
--- /dev/null
+++ b/do.php
@@ -0,0 +1,255 @@
+<?PHP
+session_start();
+
+include "includes/maps.php";
+include "includes/db.inc.php";
+
+include "includes/datas.php";
+
+// encode array $json to JSON string
+
+
+if ($_GET['act'] == "getmap") {
+ $map = GenerateMapByCode($_GET['mapcode']);
+
+ $solution = formSolution($_GET['solution']);
+
+ $solvedmap = MergeMapSolution($map, $solution);
+ if ($solvedmap == -1) {
+ $json['error'][] = "INVALID WALL POSITIONS";
+ }
+ if ($solvedmap == -2) {
+ $json['error'][] = "USED TOO MANY WALLS";
+ }
+}
+
+if ($_GET['r'] == 'getscores') {
+ $mapID = $_GET['mapid'] + 0;
+ if (!is_int($mapID))
+ return;
+ $topscores = topScores($mapID, 30);
+ $json['scores'] = $topscores;
+ $encoded = json_encode($json);
+ die($encoded);
+}
+
+
+if ($_GET['r'] == 'getsol') {
+ $solid = $_GET['solutionid'] + 0;
+ //echo "working...";
+ if (!is_int($solid)) return;
+
+ $sql = "SELECT `solution`, `mapID`
+ FROM `solutions`
+ WHERE
+ `ID` = '$solid'
+ LIMIT 1";
+
+ $result = mysql_query($sql);
+ if (mysql_num_rows($result) > 0) {
+ list($json['solution'], $json['mapid']) = mysql_fetch_row($result);
+ $encoded = json_encode($json);
+ die($encoded);
+ }
+}
+
+
+
+if ($_GET['r'] == 'getpath') {
+
+ $tmp = GenerateMapByCode($_GET['mapcode']);
+ $tmp = seperateMapSolution($tmp);
+
+ $mapID = $_GET[mapid] + 0;
+ $solution = formSolution($_GET['solution'].$tmp);
+
+ //By rule, i try to avoid $var = $_GET as you
+ // cannot trust $_GET to be non-maliciously inputed data
+ $mapcode = $_GET['mapcode'];
+ if ($mapID > 5) {
+ $mapcode = getMapCode($mapID);
+ }
+
+ $map = GenerateMapByCode($mapcode);
+
+ $mygrid = MergeMapSolution($map, $solution);
+
+ $json = routePath($mygrid, $start);
+
+ $moves = $json['moves'];
+
+ $topscores = topScores($mapID, 30);
+ $json['scores'] = $topscores;
+
+
+ if ($json['blocked']) {
+ //$json['error'][] = "blocked";
+ $encoded = json_encode($json);
+ die($encoded);
+ }
+ if ($mygrid == -1) {
+ $json['error'][] = "INVALID WALL POSITIONS";
+ $encoded = json_encode($json);
+ die($encoded);
+ }
+ if ($mygrid[0][4] < 0) {
+ $used = $mygrid[0][4] - $map[0][4];
+ $json['error'][] = "Too many walls used. ".$used." of ".$map[0][4]." walls used.";
+ $encoded = json_encode($json);
+ die($encoded);
+ }
+
+ for ($i = 1; $i <= $mygrid[0][1]; $i++) {
+ $start .= "0,$i.";
+ }
+ //$json['path'] = $pathmap1;
+
+ $json['mapid'] = $_GET[mapid];
+
+ if (!is_int($mapID)) return;
+ $sql = "SELECT `moves`, `displayName`
+ FROM `solutions`, `users`
+ WHERE
+ `mapID` = '$mapID' AND
+ `userID` = users.ID
+ ORDER BY `moves` DESC, `dateModified` ASC
+ LIMIT 1";
+
+ $result = mysql_query($sql);
+ if (mysql_num_rows($result) > 0) {
+ list($bestMoves, $byName) = mysql_fetch_row($result);
+ $json['best'] = $bestMoves;
+ //$json['best'] = 3;
+ $json['bestby'] = $byName;
+ } else {
+ $json['best'] = 0;
+ $json['bestby'] = 'no one';
+ }
+
+
+ //If there's a session, and this is a current map.
+ if ($_SESSION['accepted'] == 1 AND isCurrentMap($mapID)) {
+ $userID = $_SESSION['userID'];
+
+ $sql = "SELECT *
+ FROM `maps`
+ WHERE `ID` = '$mapID' AND `code` = '$mapcode'";
+
+ $result = mysql_query($sql);
+ if (mysql_num_rows($result) == 0) {
+ //$json['error'][] = "Error, mapID and code do not match.";
+ $encoded = json_encode($json);
+ die($encoded);
+ }
+
+ //Personal best
+ $sql = "SELECT `moves`
+ FROM `solutions`
+ WHERE `userID` = '$userID' AND
+ `mapID` = '$mapID'
+ ";
+ $result = mysql_query($sql);
+ if (mysql_num_rows($result) > 0) {
+ list($myMoves) = mysql_fetch_row($result);
+ $json['mybest'] = $myMoves;
+ }
+
+
+
+ //$result = mysql_query($sql);
+ //while (list($ListID, $modified) = mysql_fetch_row($result)) {
+ // $_SESSION['listsstate'][$ListID] = "$ListID$modified";
+ // }
+ $sql = "SELECT `moves`
+ FROM `solutions`
+ WHERE `userID` = '$userID'
+ AND `mapID` = $mapID;";
+
+ $result = mysql_query($sql);
+ if (mysql_num_rows($result) > 0) {
+ list($reqMoves) = mysql_fetch_row($result);
+ if ($reqMoves < $moves) {
+ $sql = "UPDATE `solutions`
+ SET `moves` = '$moves' ,
+ `dateModified` = NOW() ,
+ `solution` = '$solution'
+ WHERE `userID` = '$userID' AND
+ `mapID` = '$mapID'
+ ";
+ mysql_query($sql);
+ }
+ } else {
+ //Store solution.
+ $sql = "INSERT INTO `solutions` (`userID`, `mapID`, `solution`, `moves`)
+ VALUES ('$userID', '$mapID', '$solution', '$moves')
+ ";
+ mysql_query($sql);
+ }
+ //==This still leaves a lot of solutions...
+ $sql = "DELETE FROM `solutions` WHERE
+ `userID` = '$userID' AND
+ `mapID` = '$mapID' AND
+ `moves` < '$moves' ";
+ //mysql_query($sql);
+ }
+
+ $json['mapid'] = $_GET[mapid];
+
+ //$json[error][] = "Start value: $start";
+ //$json['start'] = "hello jack";
+ //$json['map'] = DisplayMap($mygrid);
+ $encoded = json_encode($json);
+ die($encoded);
+ //Die is the same as:
+ //echo + exit
+}
+
+
+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;
+}
+
+
+
+
+
+
+
+//Very simple, confirm that all targets are reachable.
+Function ValidateMap($mygrid) {
+ $start = "0,1.";
+ $target[] = 'a';
+ $target[] = 'b';
+ $target[] = 'c';
+ $target[] = 'f';
+ $blocked = false;
+ foreach($target as $t) {
+ $p = Findpath ($mygrid, $start, $t);
+ if ($p['blocked']) return false;
+ }
+ return true;
+}
+
+
+
+$json['error'][] = 'Division by 912 trillion!';
+$json['error'][] = 'Cant count that high.';
+
+$json['error'][] = "I forgot what I was doing!";
+$json['error'][] = "Lost track of time, and gaveup!";
+
+$encoded = json_encode($json);
+die($encoded);
+
+
+
+?> \ No newline at end of file
diff --git a/errors.php b/errors.php
new file mode 100644
index 0000000..05a717a
--- /dev/null
+++ b/errors.php
@@ -0,0 +1,15 @@
+<?PHP
+
+
+
+
+
+Echo "You're here because of error: $_GET[error] ";
+
+Echo "<br />$_SERVER[HTTP_REFERER]";
+
+Echo "<br /><a href='http://www.snapems.com'>Go back to Home</a>";
+
+
+
+?> \ No newline at end of file
diff --git a/globe.php b/globe.php
new file mode 100644
index 0000000..72795c8
--- /dev/null
+++ b/globe.php
@@ -0,0 +1,157 @@
+<?PHP
+session_start();
+//session_regenerate_id();
+
+//Database login:
+//include_once 'db.inc.php';
+
+
+
+
+$mydomain = "http://www.snapems.com/";
+
+//https://www.google.com/accounts/o8/id?id=AItOawl4GX29ka40T4ZeuXnR2FVsP4LZWaED_T8
+//https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawl
+
+
+
+include_once("./includes/header.php");
+
+
+
+function sql_clean($string) {
+ if (get_magic_quotes_gpc()) {
+ $string = stripslashes($string);
+ }
+ $string = mysql_real_escape_string($string);
+ return $string;
+}
+
+function CookieLogin() {
+ include_once "includes/db.inc.php";
+ $userID = $_COOKIE['userID'];
+ $auth = $_COOKIE['auth'];
+
+ $sql = "SELECT `openID`, `displayName`, `isAdmin`
+ FROM `users`
+ WHERE `ID` = '$userID'
+ ";
+
+ $result = mysql_query($sql);
+ if (mysql_num_rows($result) == 0)
+ return;
+
+ list($claimedid, $display, $isAdmin) = mysql_fetch_row($result);
+
+ $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);
+
+ if ($auth == $three) {
+ $_SESSION['accepted'] = 1;
+ $_SESSION['userID'] = $userID;
+ $_SESSION['displayName'] = $display;
+ if ($isAdmin == 1)
+ $_SESSION['isAdmin'] = true;
+
+ }
+ header("Location: $mydomain");
+}
+
+
+
+
+
+
+Function DoLogin($Username, $Password, $RememberMe = False, $EN = False) {
+
+ If ($EN == False) {
+ $MD5Salt = "LoveSnap";
+ $Password = MD5($Password.$MD5Salt);
+ //Echo " .Encrypted Entry. ";
+ }
+ If ($RememberMe = True) {
+ setcookie("RUsername", $Username, time()+(60*60*24*30));
+ setcookie("RPassword", $Password, time()+(60*60*24*30));
+ setcookie("DoLogin", "True", time()+(60*60*24*30));
+ }
+ //Echo "Logging in...";
+
+ $sql = "SELECT `ID`, `Username`, `Password`, `Status` FROM `USERS`
+ WHERE `Username` = '$Username' AND `Password` = '$Password'";
+ $result = mysql_query($sql);
+ If (mysql_num_rows($result) == 0) {
+ Return "Error username/password did not match";
+ } Else {
+ $theID = mysql_result($result, 0, 'ID');
+ $Username = mysql_result($result, 0, 'Username');
+ $Password = mysql_result($result, 0, 'Password');
+ $Status = mysql_result($result, 0, 'Status');
+
+ $Pepper = "MyPepperWuvsMe!@#$1234";
+
+ $_SESSION['accepted'] = 1;
+ //If 'remember me' use this for cookie password
+ $_SESSION['passcode'] = MD5($Password.$Pepper.$Username);
+ $_SESSION['userID'] = $theID;
+ $_SESSION['displayName'] = $Username;
+ $_SESSION['status'] = $Status;
+
+
+ $sql = "UPDATE `USERS` SET `Last_Logon` = ".Time()." WHERE `ID` = $theID LIMIT 1";
+ $result = mysql_query($sql);
+ return 1;
+ exit;
+ }
+}
+
+
+Function CheckAuth($page) {
+ //!!
+ if ($_SESSION['Accepted'] == 1) {
+ return true;
+ } else {
+ //DoRedirect("Logging you in...", "$mydomain?page=login&ref=$mydomain$page", 1);
+ header("Location: $mydomain?page=login&ref=$mydomain?page=$page");
+ return false;
+ }
+}
+
+//!! Contains domain !!
+Function DoRedirect($message = "Thanks", $to = "http://www.snapems.com/", $duration = "3") {
+ $to=(is_null($to)?'http://www.snapems.com/':$to);
+
+ if ($duration == 0) {
+ header("Location: $to");
+ }
+
+ //require "format/header.php";
+ echo "
+ <meta http-equiv='refresh' content='$duration; url=$to' />
+ <br />
+ <br />
+ <br />
+ <br />
+ <br />
+ <center>
+ <table>
+ <tr><td>
+ <center>$message
+ <br />You are now being redirected.
+ <br /><a href='$to'>Click here if not redirected in $duration seconds.</a>
+ </center>
+ </td></tr>
+ </table>
+ </center>
+ </body>
+ </html>
+";
+
+}
+
+
+?>
diff --git a/images/Old Images/GameIdea.bmp b/images/Old Images/GameIdea.bmp
new file mode 100644
index 0000000..18b7da1
--- /dev/null
+++ b/images/Old Images/GameIdea.bmp
Binary files differ
diff --git a/images/Old Images/GameIdea.jpg b/images/Old Images/GameIdea.jpg
new file mode 100644
index 0000000..940c68e
--- /dev/null
+++ b/images/Old Images/GameIdea.jpg
Binary files differ
diff --git a/images/Old Images/mazetd graphics.jpg b/images/Old Images/mazetd graphics.jpg
new file mode 100644
index 0000000..8f5ab2a
--- /dev/null
+++ b/images/Old Images/mazetd graphics.jpg
Binary files differ
diff --git a/images/Old Tiles/OverlayA50.png b/images/Old Tiles/OverlayA50.png
new file mode 100644
index 0000000..51bb005
--- /dev/null
+++ b/images/Old Tiles/OverlayA50.png
Binary files differ
diff --git a/images/Old Tiles/OverlayB50.png b/images/Old Tiles/OverlayB50.png
new file mode 100644
index 0000000..e382b7d
--- /dev/null
+++ b/images/Old Tiles/OverlayB50.png
Binary files differ
diff --git a/images/Old Tiles/OverlayC50.png b/images/Old Tiles/OverlayC50.png
new file mode 100644
index 0000000..fc5c02b
--- /dev/null
+++ b/images/Old Tiles/OverlayC50.png
Binary files differ
diff --git a/images/Old Tiles/OverlayD50.png b/images/Old Tiles/OverlayD50.png
new file mode 100644
index 0000000..f72f141
--- /dev/null
+++ b/images/Old Tiles/OverlayD50.png
Binary files differ
diff --git a/images/Old Tiles/OverlayE50.png b/images/Old Tiles/OverlayE50.png
new file mode 100644
index 0000000..5d55f5d
--- /dev/null
+++ b/images/Old Tiles/OverlayE50.png
Binary files differ
diff --git a/images/Old Tiles/TeleportInAni.gif b/images/Old Tiles/TeleportInAni.gif
new file mode 100644
index 0000000..c44444c
--- /dev/null
+++ b/images/Old Tiles/TeleportInAni.gif
Binary files differ
diff --git a/images/Old Tiles/TeleportInAniOld.gif b/images/Old Tiles/TeleportInAniOld.gif
new file mode 100644
index 0000000..007ea3b
--- /dev/null
+++ b/images/Old Tiles/TeleportInAniOld.gif
Binary files differ
diff --git a/images/Old Tiles/TeleportInAnib.gif b/images/Old Tiles/TeleportInAnib.gif
new file mode 100644
index 0000000..ec84975
--- /dev/null
+++ b/images/Old Tiles/TeleportInAnib.gif
Binary files differ
diff --git a/images/Old Tiles/TeleportOutAni.gif b/images/Old Tiles/TeleportOutAni.gif
new file mode 100644
index 0000000..95d3c19
--- /dev/null
+++ b/images/Old Tiles/TeleportOutAni.gif
Binary files differ
diff --git a/images/Old Tiles/TeleportOutAniB.gif b/images/Old Tiles/TeleportOutAniB.gif
new file mode 100644
index 0000000..481c24d
--- /dev/null
+++ b/images/Old Tiles/TeleportOutAniB.gif
Binary files differ
diff --git a/images/Old Tiles/TeleportOutAniOld.gif b/images/Old Tiles/TeleportOutAniOld.gif
new file mode 100644
index 0000000..816c925
--- /dev/null
+++ b/images/Old Tiles/TeleportOutAniOld.gif
Binary files differ
diff --git a/images/OverlayA50.png b/images/OverlayA50.png
new file mode 100644
index 0000000..90d4ea2
--- /dev/null
+++ b/images/OverlayA50.png
Binary files differ
diff --git a/images/OverlayA50ss.png b/images/OverlayA50ss.png
new file mode 100644
index 0000000..bd1015c
--- /dev/null
+++ b/images/OverlayA50ss.png
Binary files differ
diff --git a/images/OverlayB50.png b/images/OverlayB50.png
new file mode 100644
index 0000000..07b0aec
--- /dev/null
+++ b/images/OverlayB50.png
Binary files differ
diff --git a/images/OverlayB50ss.png b/images/OverlayB50ss.png
new file mode 100644
index 0000000..ea5eac5
--- /dev/null
+++ b/images/OverlayB50ss.png
Binary files differ
diff --git a/images/OverlayC50.png b/images/OverlayC50.png
new file mode 100644
index 0000000..778dcad
--- /dev/null
+++ b/images/OverlayC50.png
Binary files differ
diff --git a/images/OverlayC50ss.png b/images/OverlayC50ss.png
new file mode 100644
index 0000000..b0677ff
--- /dev/null
+++ b/images/OverlayC50ss.png
Binary files differ
diff --git a/images/OverlayD50.png b/images/OverlayD50.png
new file mode 100644
index 0000000..c416225
--- /dev/null
+++ b/images/OverlayD50.png
Binary files differ
diff --git a/images/OverlayD50ss.png b/images/OverlayD50ss.png
new file mode 100644
index 0000000..349be11
--- /dev/null
+++ b/images/OverlayD50ss.png
Binary files differ
diff --git a/images/OverlayE50.png b/images/OverlayE50.png
new file mode 100644
index 0000000..845d6b5
--- /dev/null
+++ b/images/OverlayE50.png
Binary files differ
diff --git a/images/OverlayE50ss.png b/images/OverlayE50ss.png
new file mode 100644
index 0000000..3a0e719
--- /dev/null
+++ b/images/OverlayE50ss.png
Binary files differ
diff --git a/images/OverlayStart50.png b/images/OverlayStart50.png
new file mode 100644
index 0000000..e6f6854
--- /dev/null
+++ b/images/OverlayStart50.png
Binary files differ
diff --git a/images/OverlayStart50i.png b/images/OverlayStart50i.png
new file mode 100644
index 0000000..42559e7
--- /dev/null
+++ b/images/OverlayStart50i.png
Binary files differ
diff --git a/images/OverlayTeleport.png b/images/OverlayTeleport.png
new file mode 100644
index 0000000..cc25107
--- /dev/null
+++ b/images/OverlayTeleport.png
Binary files differ
diff --git a/images/OverlayTeleport.xcf b/images/OverlayTeleport.xcf
new file mode 100644
index 0000000..0b5dcfb
--- /dev/null
+++ b/images/OverlayTeleport.xcf
Binary files differ
diff --git a/images/OverlayTile10.png b/images/OverlayTile10.png
new file mode 100644
index 0000000..66a750c
--- /dev/null
+++ b/images/OverlayTile10.png
Binary files differ
diff --git a/images/OverlayTile20.png b/images/OverlayTile20.png
new file mode 100644
index 0000000..8a559f8
--- /dev/null
+++ b/images/OverlayTile20.png
Binary files differ
diff --git a/images/OverlayTile30.png b/images/OverlayTile30.png
new file mode 100644
index 0000000..a7692e1
--- /dev/null
+++ b/images/OverlayTile30.png
Binary files differ
diff --git a/images/OverlayTile50.png b/images/OverlayTile50.png
new file mode 100644
index 0000000..20b6ed4
--- /dev/null
+++ b/images/OverlayTile50.png
Binary files differ
diff --git a/images/OverlayTileFaceted10.png b/images/OverlayTileFaceted10.png
new file mode 100644
index 0000000..affa9e0
--- /dev/null
+++ b/images/OverlayTileFaceted10.png
Binary files differ
diff --git a/images/OverlayTileFaceted20.png b/images/OverlayTileFaceted20.png
new file mode 100644
index 0000000..678db08
--- /dev/null
+++ b/images/OverlayTileFaceted20.png
Binary files differ
diff --git a/images/OverlayTileFaceted30.png b/images/OverlayTileFaceted30.png
new file mode 100644
index 0000000..e33c086
--- /dev/null
+++ b/images/OverlayTileFaceted30.png
Binary files differ
diff --git a/images/OverlayTileFaceted50.png b/images/OverlayTileFaceted50.png
new file mode 100644
index 0000000..362c5c5
--- /dev/null
+++ b/images/OverlayTileFaceted50.png
Binary files differ
diff --git a/images/OverlayTiles.xcf b/images/OverlayTiles.xcf
new file mode 100644
index 0000000..55e8aea
--- /dev/null
+++ b/images/OverlayTiles.xcf
Binary files differ
diff --git a/images/Path1.png b/images/Path1.png
new file mode 100644
index 0000000..65556a3
--- /dev/null
+++ b/images/Path1.png
Binary files differ
diff --git a/images/Path2.png b/images/Path2.png
new file mode 100644
index 0000000..42559e7
--- /dev/null
+++ b/images/Path2.png
Binary files differ
diff --git a/images/Path3.png b/images/Path3.png
new file mode 100644
index 0000000..736a123
--- /dev/null
+++ b/images/Path3.png
Binary files differ
diff --git a/images/Path4.png b/images/Path4.png
new file mode 100644
index 0000000..ef1f17d
--- /dev/null
+++ b/images/Path4.png
Binary files differ
diff --git a/images/Teleport1.png b/images/Teleport1.png
new file mode 100644
index 0000000..fad3912
--- /dev/null
+++ b/images/Teleport1.png
Binary files differ
diff --git a/images/Teleport2.png b/images/Teleport2.png
new file mode 100644
index 0000000..930efa7
--- /dev/null
+++ b/images/Teleport2.png
Binary files differ
diff --git a/images/Teleport3.png b/images/Teleport3.png
new file mode 100644
index 0000000..cb92ee6
--- /dev/null
+++ b/images/Teleport3.png
Binary files differ
diff --git a/images/Teleport4.png b/images/Teleport4.png
new file mode 100644
index 0000000..5165156
--- /dev/null
+++ b/images/Teleport4.png
Binary files differ
diff --git a/images/TeleportIn.png b/images/TeleportIn.png
new file mode 100644
index 0000000..b424072
--- /dev/null
+++ b/images/TeleportIn.png
Binary files differ
diff --git a/images/TeleportInW.png b/images/TeleportInW.png
new file mode 100644
index 0000000..ea8bf4f
--- /dev/null
+++ b/images/TeleportInW.png
Binary files differ
diff --git a/images/TeleportOut.png b/images/TeleportOut.png
new file mode 100644
index 0000000..d8c344e
--- /dev/null
+++ b/images/TeleportOut.png
Binary files differ
diff --git a/images/TeleportOutW.png b/images/TeleportOutW.png
new file mode 100644
index 0000000..737c4c4
--- /dev/null
+++ b/images/TeleportOutW.png
Binary files differ
diff --git a/includes/datas.php b/includes/datas.php
new file mode 100644
index 0000000..0d3d0c5
--- /dev/null
+++ b/includes/datas.php
@@ -0,0 +1 @@
+<?PHP // For interaction with the SQL database. // include_once('db.inc.php'); //Select Stats/Scores. function topScores($mapid, $top = 5) { $sql = " SELECT timediff(solutions.dateModified, TIMESTAMP(CURDATE())) as diff, users.displayName as display, solutions.moves as m, users.ID as ID FROM `users` JOIN `solutions` ON users.ID = solutions.userID WHERE solutions.mapID = '$mapid' ORDER BY solutions.moves DESC, solutions.dateModified ASC LIMIT $top "; $result = mysql_query($sql); if (mysql_num_rows($result) > 0) { $output .= "<table style='border:1px solid #FFF'>"; $output .= "<tr>"; $output .= "<th style='border:1px solid #ccc'>Rank</th>"; $output .= "<th style='border:1px solid #ccc'>Name</th>"; $output .= "<th style='border:1px solid #ccc'>Moves</th>"; $output .= "<th style='border:1px solid #ccc'>Time taken</th>"; $output .= "</tr>"; while (list($diff, $display, $moves, $userID) = mysql_fetch_row($result)) { $i++; if ($_SESSION['userID'] == $userID) $output .= "<tr style='background-color: #338899;'>"; else $output .= "<tr>"; $output .= "<td>$i</td>"; $output .= "<td><span title='UserID: $userID'>$display</span></td>"; $output .= "<td>$moves</td>"; $output .= "<td>$diff</td>"; //$output .= "<b>$i. <span title='UserID: $userID'>$display</span> with $moves moves. In $diff<br /></b>"; $output .= "</tr>"; } $output .= "</table>"; } return $output; } ?> \ No newline at end of file
diff --git a/includes/db.inc.php b/includes/db.inc.php
new file mode 100644
index 0000000..8e9bdfb
--- /dev/null
+++ b/includes/db.inc.php
@@ -0,0 +1,11 @@
+<?php
+
+global $mysqlid;
+$db_host = "db2838.perfora.net";
+$db_user = "dbo358894438";
+$db_name = "db358894438";
+$db_pass = "MAZE4US";
+$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.");
+
+?> \ No newline at end of file
diff --git a/includes/header.php b/includes/header.php
new file mode 100644
index 0000000..53c1a82
--- /dev/null
+++ b/includes/header.php
@@ -0,0 +1,67 @@
+<?PHP
+
+function htmlHeader() {
+?>
+<!DOCTYPE html>
+<html xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link href="css/mapstyle.css" rel="stylesheet" type="text/css" />
+ <link href="css/pagestyle.css" rel="stylesheet" type="text/css" />
+ <link href="css/statsstyle.css" rel="stylesheet" type="text/css" />
+ <title>Snapems.com Mazegame</title>
+
+ <script src="js/ajax.js" type="text/javascript"></script>
+ <script src="js/mapspecs.js" type="text/javascript"></script>
+
+<script type="text/javascript">
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-371072-3']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+</script>
+</head>
+<?
+}
+
+function htmlfooter() {
+
+}
+
+function topbar($links) {
+ echo '<div class="topbar">';
+
+ $page = $_GET[page];
+ if ($page == '')
+ $page = 'home';
+ $first = true;
+ foreach ($links as $key => $value) {
+ if ($first)
+ $first = false;
+ else
+ echo ' | ';
+ if ($page == $key)
+ echo "<b><a href='?page=$key'>$value</a></b>";
+ else
+ echo "<a href='?page=$key'>$value</a>";
+ }
+
+ echo "\t<div class='lfloat'>";
+ if ($_SESSION['accepted'] == 1) {
+ echo "Logged in as <a href='?page=cp' title='change name'>$_SESSION[displayName]</a>.\n";
+ echo "<a href='?page=logout'>Logout</a>";
+ if ($_SESSION['displayName'] == 'noname')
+ echo "<a href='?page=cp' title='change name'>Update your name</a>";
+ } else
+ echo "<a href='?page=login'>Sign in using Google</a>";
+
+ echo "\t</div>";
+ echo "</div>";
+}
+
+?>
diff --git a/includes/mapoftheday.php b/includes/mapoftheday.php
new file mode 100644
index 0000000..cd646cb
--- /dev/null
+++ b/includes/mapoftheday.php
@@ -0,0 +1 @@
+<?PHP include_once('maps.php'); include_once('db.inc.php'); //Select from current day. function getMapOfTheDay() { $sql = " select `ID`, `code` from `maps` WHERE ( DAY(dateCreated) = DAY(NOW()) AND MONTH(dateCreated) = MONTH(NOW()) AND YEAR(dateCreated) = YEAR(NOW()) ) "; $result = mysql_query($sql); //No map for today? if (mysql_num_rows($result) == 0) { // If you want to modify the maps created! This is the line $map = GenerateMap(rand(13, 18), rand(10, 14), rand(6, 9)); $code = GenerateMapCode($map); $sql = "INSERT INTO `maps` (`code`) VALUES ('$code')"; mysql_query($sql); $r['code'] = $code; $r['map'] = $map; $r['id'] = mysql_insert_id(); return $r; } $r['code'] = mysql_result($result, 0, 'code'); $r['map'] = GenerateMapByCode($r['code']); $r['id'] = mysql_result($result, 0, 'ID'); return $r; } function mapOfTheDay($type = 1) { $sql = " select maps.ID, maps.code FROM `mapOfTheDay`, `maps` WHERE `mapDate` = CURDATE() AND `mapType` = $type AND mapID = maps.ID "; $result = mysql_query($sql); //No map for today? if (mysql_num_rows($result) == 0) { // If you want to modify the maps created! This is the line //GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1) { switch ($type) { case 1: //Easy $map = GenerateMap(13, 7, 12, rand(7,10), rand(0, 2), 0); break; case 2: //Normal $map = GenerateMap(15, 9, 7, rand(11,13), rand(1,2) + rand(0,1), rand(0,1)); break; case 3: //Hard $map = GenerateMap(19, 9, rand(7, 9), rand(13,16), rand(2,5), rand(1,2)); break; case 4: //Full random map //Get the current day as int. $numday = date('w'); $numday = intval($numday); switch ($numday) { case 0: //Sunday //Thirty $map = GenerateMap( 18, 14, 20 , //width, height, rocks weight(30) , //Walls weight(1) , //Checkpoints weight(1) //Teleports ); break; case 1: //Monday //Simple $map = GenerateMap( 18, 9, 7 , //width, height, rocks weight(15,16,17) , //Walls weight(0) , //Checkpoints weight(0) //Teleports ); break; case 2: //Tuesday //ABC's $map = GenerateMap( 19, 11, 12 , //width, height, rocks weight(20,21,22,22,23) , //Walls weight(3) , //Checkpoints weight(0) //Teleports ); break; case 3: //Wednesday //Tele Madness $map = GenerateMap( 17, 12, 10 , //width, height, rocks weight(17,18) , //Walls weight(1) , //Checkpoints weight(5) //Teleports ); break; case 4: //Thursday //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 ); break; case 5: //Friday //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 ); break; case 6: //Saturday //ABC's $map = GenerateMap( 19, 11, 12 , //width, height, rocks weight(20,21,22,22,23) , //Walls weight(3) , //Checkpoints weight(0) //Teleports ); break; } break; default: $map = GenerateMap(rand(13, 18), rand(10, 14), rand(6, 9)); break; } $code = GenerateMapCode($map); $sql = "INSERT INTO `maps` (`code`) VALUES ('$code')"; mysql_query($sql); $mapID = mysql_insert_id(); $r['code'] = $code; $r['map'] = $map; $r['id'] = $mapID; $sql = "INSERT INTO `mapOfTheDay` (`mapID`, `mapType`, `mapDate`) VALUES ('$mapID', '$type', CURDATE()) "; mysql_query($sql); return $r; } $r['code'] = mysql_result($result, 0, 'code'); $r['map'] = GenerateMapByCode($r['code']); $r['id'] = mysql_result($result, 0, 'ID'); return $r; } // RMA # CT1160811 // 97686 //Select from yesterday function getYesterdaysMap() { $sql = " select `ID`, `code` from `maps` WHERE ( DAY(dateCreated) = DAY(NOW()) - 1 AND MONTH(dateCreated) = MONTH(NOW()) AND YEAR(dateCreated) = YEAR(NOW()) ) "; $result = mysql_query($sql); //No map for today? if (mysql_num_rows($result) == 0) { return -1; } $r['code'] = mysql_result($result, 0, 'code'); $r['id'] = mysql_result($result, 0, 'ID'); return $r; } ?> \ No newline at end of file
diff --git a/includes/maps.php b/includes/maps.php
new file mode 100644
index 0000000..acb4c6c
--- /dev/null
+++ b/includes/maps.php
@@ -0,0 +1,743 @@
+<?PHP
+function DisplayMap($mapMatrix, $idprefix = 1, $example = false, $speed = NULL) {
+ //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.
+
+
+ if ($speed == NULL) {
+ if ($example) {
+ $speed = 1;
+ } else {
+ $speed = 2;
+ }
+ }
+
+ 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;
+
+ //TP1
+ case 't': $maptable .= "<td title='Teleport 1 in' class='grid_td_tp1_in' id='$handle' ></td>"; break;
+ case 'u': $maptable .= "<td title='Teleport 1 out' class='grid_td_tp1_out' id='$handle' ></td>"; break;
+ //TP2
+ case 'm': $maptable .= "<td title='Teleport 2 in' class='grid_td_tp2_in' id='$handle' ></td>"; break;
+ case 'n': $maptable .= "<td title='Teleport 2 out'class='grid_td_tp2_out' id='$handle' ></td>"; break;
+ //TP3
+ case 'g': $maptable .= "<td title='Teleport 3 in' class='grid_td_tp3_in' id='$handle' ></td>"; break;
+ case 'h': $maptable .= "<td title='Teleport 3 out'class='grid_td_tp3_out' id='$handle' ></td>"; break;
+ //TP4
+ case 'i': $maptable .= "<td title='Teleport 4 in' class='grid_td_tp4_in' id='$handle' ></td>"; break;
+ case 'j': $maptable .= "<td title='Teleport 4 out'class='grid_td_tp4_out' id='$handle' ></td>"; break;
+ //TP5
+ case 'k': $maptable .= "<td title='Teleport 5 in' class='grid_td_tp5_in' id='$handle' ></td>"; break;
+ case 'l': $maptable .= "<td title='Teleport 5 out'class='grid_td_tp5_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' name='true' onClick='grid_click(this)' ></td>"; break; //wall
+ //default: $maptable .= "<td class='grid_td' id='$handle' onClick='grid_click(this)' >".$index."</td>";
+ default: $maptable .= "<td title='Position: $i,$j' 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>";
+
+
+ $prefSpeed = $_COOKIE['pref_speed'];
+ $speedOption['Slow'] = 1;
+ $speedOption['Med'] = 2;
+ $speedOption['Fast'] = 3;
+ $speedOption['Ultra'] = 4;
+ if (!in_array($prefSpeed, $speedOption))
+ $prefSpeed = '2';
+
+ foreach ($speedOption as $key => $value) {
+ $rOption .= "<option value='$value'";
+ if ($prefSpeed == $value)
+ $rOption .= " selected='selected'";
+ $rOption .= ">$key</option>\n";
+ }
+
+ if ($_COOKIE['pref_mute'] == "true") {
+ $mutebutton = "<label><input onclick='savePref(\"mute\", this.checked)' type='checkbox' id='$idprefix,mute' checked='checked' />Mute</label>";
+ } else {
+ $mutebutton = "<label><input onclick='savePref(\"mute\", this.checked)' type='checkbox' id='$idprefix,mute' />Mute</label>";
+ }
+
+
+ if ($example) {
+ $output = $maptable;
+ $output .= "<input id='$idprefix,btn' type='button' onclick='doSend($idprefix)' value='Test' />";
+ $output .= "
+ <div style='display:none;'>
+ <input type='checkbox' id='$idprefix,mute' checked=true />
+ <select id='$idprefix,speed'>
+ $rOption
+ </select>
+ </div>
+ ";
+ $output .= $mapdatadiv;
+ $output = "<div style='width:$width;height:$height;'>
+ $output
+ </div>";
+ return $output;
+ }
+ //$date = date("m-d-y");
+
+ $output = "
+ <div id='$idprefix,outer' class='grid_outer' style='width:".($width+2)."px;height:".($height+50)."px;'>
+
+ <div class='grid_dsp_left dsp_49'>
+ <div id='$idprefix,dspID' title='MapID: $idprefix'>
+ MapID: $idprefix
+ </div>
+ </div>
+
+
+ <div id='$idprefix,dsptr' class='grid_dsp_right dsp_33'>
+ <span id='$idprefix,dspWalls' class='grid_dsp_data'>
+ ".$mapdata['walls']." walls
+ </span>
+ <span>
+ ( <a href='javascript:resetwalls($idprefix)'>Reset</a> )
+ </span>
+ </div>
+
+
+ $maptable
+
+ <div id='$idprefix,dspbl' class='grid_dsp_left dsp_49'>
+ <input id='$idprefix,btn' type='button' onclick='doSend($idprefix)' value='Go!' />
+ Speed:
+ <select onChange='savePref(\"speed\", this.value)' id='$idprefix,speed'>
+ $rOption
+ </select>
+ </div>
+
+ <div class='grid_dsp_mid dsp_16'>
+ $mutebutton
+ </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;
+}
+//Generates map
+function GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1) {
+
+ //!! Possibility of inf loop here.
+ do {
+ $randvalue = rand(1, ($rows * $cols));
+ //As long as it isn't the first, or last column.
+ //if ((($randvalue +1) % ($rows)) > 1) {
+ //As long as it isn't in the first, 2nd, last and 2nd to last column.
+ if ((($randvalue +2) % ($rows)) > 3) {
+ $unique[] = $randvalue;
+ $unique = array_unique($unique);
+ $unique = array_values($unique);
+ }
+ } while (count($unique) < 15);
+
+ if ($numBlocks == -1)
+ $numBlocks = Rand(7, (int)($rows * $cols) * .12);
+
+ if ($cp == -1)
+ $cp = rand(0, 5);
+ if ($tp == -1)
+ $tp = rand(0, 2);
+ $tp = $tp * 2; //Requires an out-teleport.
+
+ $cpnames = Array("a", "b", "c", "d", "e");
+ $tpnames = Array("t", "u", "m", "n", 'g', 'h', 'i', 'j', 'k', 'l');
+
+ $teleport = Array();
+ $checkpoint = Array();
+
+ $i = 0;
+ for($p = 0; $p < $cp; $p++) {
+ $checkpoint[$cpnames[$p]] = $unique[$i];
+ $i++;
+ }
+ for($p = 0; $p < $tp; $p++) {
+ $teleport[$tpnames[$p]] = $unique[$i];
+ $i++;
+ }
+
+ $rocks = 0; //Number of rocks in the maze.
+
+ // We need to make sure the map we construct is valid.
+ // so we throw this in a do-while.
+ do {
+ $p = -1;
+ //Begin loop to populate grid.
+ for( $y = 1; $y <= $cols; $y++) { //Number of Columns
+ for( $x = 0; $x < $rows; $x++) { //Number of Rows
+ $p++;
+ //Start and Finish squares.
+ if ($x == 0) {
+ $grid[$y][$x] = "s";
+ } elseif ($x == $rows - 1) {
+ $grid[$y][$x] = "f";
+ //Randomly Placed Rocks
+ } elseif (rand(1, $rockchance) == 2) {
+ $grid[$y][$x] = "r";
+ $rocks++;
+ //!! rock count could be off if covered by checkpoint.
+ //Just a normal square.
+ } else {
+ $grid[$y][$x] = "o";
+ }
+ //Absolutely placed points; Checkpoints.
+ foreach ($checkpoint as $key => $v) {
+ if ($v == $p) {
+ $grid[$y][$x] = $key;
+ }
+ } //Teleports too
+ foreach ($teleport as $key => $v) {
+ if ($v == $p) {
+ $grid[$y][$x] = $key;
+ }
+ }
+
+ } //Rows
+ } //Cols
+ //Fill $grid[0] with header information
+ $grid[0][0] = $rows;
+ $grid[0][1] = $cols;
+ $grid[0][2] = count($checkpoint);
+ $grid[0][3] = $rocks;
+ $grid[0][4] = $numBlocks;
+ $grid[0][5] = count($teleport);
+
+ //Confirm the map isn't broken to start-out.
+ $path = routePath($grid);
+ //Only repeat if it's blocked.
+ } while ($path['blocked'] == true);
+
+ return $grid;
+}
+
+
+//Turns a mapMatrix into a code - see GenerateMapByCode
+function GenerateMapCode($mapMatrix) {
+ //Iterate through $mapMatrix and generate the code used to save and
+ // load the map through the database.
+
+ // 0.1 Snap. (added mapsize header data)
+ // 0.2 Rex - Added #checkpoints, #rocks, #walls to header data; adjusted loops.
+
+ $code = ""; //The string to return to the database.
+ $index = 0; //The current number of tiles from the last tile saved.
+
+ // $mapMatrix[0] stores header data--dimensions, #checkpoints, #rocks, #walls
+ // $mapMatrix[1] count will always be the width.
+ $mapsize = $mapMatrix[0][0].'x'.$mapMatrix[0][1]; //Width x Height
+
+ $code = $mapsize.
+ '.c'.$mapMatrix[0][2].
+ '.r'.$mapMatrix[0][3].
+ '.w'.$mapMatrix[0][4].
+ '.t'.$mapMatrix[0][5];
+ // dimensions + # checkpoints + # rocks + # placeable walls
+
+ //echo $code."<br />";
+
+ $code .= ".:";
+
+ for( $i = 1; $i < count($mapMatrix); $i++)
+ {
+ for( $j = 0; $j < count($mapMatrix[$i]); $j++)
+ {
+ if($mapMatrix[$i][$j] != 'o')
+ {
+ //As long as the tile is NOT open, embed it in the code.
+ $code .= $index.$mapMatrix[$i][$j].'.';
+ $index = -1;
+ //==echo "<br /><b>".$index.$mapMatrix[$i][$j]."</b><br />";
+ }
+ $index += 1;
+ }
+ }
+
+ return $code;
+}
+
+//Turns a mapcode into a mapMatrix, - see GenerateMapCode
+function GenerateMapByCode($code) {
+ //Create $mapMatrix by iterating through $code (a string value).
+ //==$mapMatrix = array();
+
+
+ $tmp = explode( ":", $code);
+
+ $headers = explode( '.', $tmp[0]);
+ $splitCode = explode( '.', $tmp[1]);
+
+ //Extract header information.
+ //==$mapMatrix[0] = array();
+ $dimensions = explode( 'x', $headers[0]);
+ $mapMatrix[0][0] = $dimensions[0]; //Width
+ $mapMatrix[0][1] = $dimensions[1]; //Height
+
+ //Select the next parameters by ignoring the character label.
+ $mapMatrix[0][2] = (int)substr($headers[1], 1); //Number of Checkpoints
+ $mapMatrix[0][3] = (int)substr($headers[2], 1); //Number of Rocks
+ $mapMatrix[0][4] = (int)substr($headers[3], 1); //Number of Wall Blocks
+ $mapMatrix[0][5] = (int)substr($headers[4], 1); //Number of Teleports
+
+ //Printing out parameters for debug purposes...
+ /*
+ echo "<br />Map Parameters:<br />";
+ echo "mapMatrix[0][0]: ".$mapMatrix[0][0]."<br />";
+ echo "mapMatrix[0][1]: ".$mapMatrix[0][1]."<br />";
+ echo "mapMatrix[0][2]: ".$mapMatrix[0][2]."<br />";
+ echo "mapMatrix[0][3]: ".$mapMatrix[0][3]."<br />";
+ echo "mapMatrix[0][4]: ".$mapMatrix[0][4]."<br />";
+ echo "mapMatrix[0][5]: ".$mapMatrix[0][5]."<br />";
+ */
+ //Begin creating our mapMatrix
+ $t = -1;
+ $index = 0;
+ for( $i = 1; $i <= $mapMatrix[0][1]; $i++) { //Number of Rows
+ for( $j = 0; $j < $mapMatrix[0][0]; $j++) { //Number of Columns
+ $t++;
+ $next = substr($splitCode[$index], 0, strlen($splitCode[$index]) - 1);
+
+ if ($next == $t) {
+ $type = substr($splitCode[$index], -1, 1);
+ $mapMatrix[$i][$j] = $type;
+ $index++;
+ $t = -1;
+
+ //echo "type:".$type."<br />";
+ //echo "number:".$next."<br />";
+ //echo "original:".$splitCode[$index]."<br />";
+ } else {
+ $mapMatrix[$i][$j] = 'o'; //Empty Tile
+ }
+ //echo "Value:".$mapMatrix[$i][$j]."<br />";
+ }
+ }
+
+ //echo "mapMatrix[1][0]: ".$mapMatrix[1][0]."<br />";
+ //echo "mapMatrix[1][1]: ".$mapMatrix[1][1]."<br />";
+
+ return $mapMatrix;
+ //Snap Stops
+
+ //Iterate through the code and adjust spaces as directed.
+ /* UNREACHABLE CODE
+ $index = 0;
+ for ( $i = 4; $i < count($splitCode); $i++)
+ {
+ echo "<br />";
+
+ $index += (int)$splitCode[$i];
+ $type = $splitCode[$i][strlen($splitCode[$i])-1];
+
+ //$tile = GetTile($mapMatrix, $index);
+ echo "$x = (int)($index / ".$mapMatrix[0][0].");<br />";
+ $x = (int)($index / $mapMatrix[0][0]);
+ $y = $id % $mapMatrix[0][0];
+
+
+ echo "splitCode: ".$splitCode[$i]."<br />";
+ echo "Index: ".$index." -- ".$x.",".$y." to ".$type;
+ echo "<br />";
+
+ $mapMatrix[$x][$y] = $type;
+ }
+
+ return $mapMatrix; */
+}
+
+//Returns a mapMatrix merged with a solution/maze.
+function MergeMapSolution($mapMatrix, $solution) {
+ //echo $solution;
+ $sa = explode( '.', $solution);
+ foreach($sa as $v) {
+ if ($v == '') continue;
+ $v= explode(",", $v);
+ $i = $v[0];
+ $j = $v[1];
+
+ //Trying to place a wall - where?
+ if ($mapMatrix[$i][$j] <> 'o') return -1;
+ $mapMatrix[$i][$j] = 'w';
+
+ //Are we out of blocks?
+ //if ($mapMatrix[0][2] < 1) return -2;
+ $mapMatrix[0][4]--;
+ }
+ return $mapMatrix;
+}
+
+function seperateMapSolution($mapMatrix) {
+ for( $i = 1; $i <= $mapMatrix[0][1]; $i++) //Number of Rows
+ for( $j = 0; $j < $mapMatrix[0][0]; $j++) //Number of Columns
+ if ($mapMatrix[$i][$j] == 'w')
+ $solution .= "$i,$j.";
+ $solution = ".".$solution;
+ return $solution;
+}
+
+//This is required to identify identical solutions, or even 'close' ones.
+function formSolution($solution) {
+ $tmp = explode(".", $solution);
+ $tmp = array_filter($tmp);
+ sort($tmp);
+ $tmp = '.'.implode(".", $tmp).'.';
+ return $tmp;
+}
+
+//Returns the best solution.
+function getSolution($userID, $mapID) {
+ include_once('db.inc.php');
+ $sql = "SELECT `solution`
+ FROM `solutions`
+ WHERE `userID` = '$userID' AND
+ `mapID` = '$mapID'
+ ";
+ $result = mysql_query($sql);
+ if (mysql_num_rows($result) > 0) {
+ list($solution) = mysql_fetch_row($result);
+ return $solution;
+ }
+}
+
+function getMapCode($mapID) {
+ include_once('db.inc.php');
+ $sql = "SELECT `code`
+ FROM `maps`
+ WHERE `ID` = '$mapID'
+ ";
+ $result = mysql_query($sql);
+ if (mysql_num_rows($result) > 0) {
+ list($map) = mysql_fetch_row($result);
+ return $map;
+ }
+}
+
+function pastMap($maptype, $daysago) {
+ $sql = "
+ SELECT `mapID`
+ FROM `mapOfTheDay`
+ WHERE DATE_ADD(CURDATE(), INTERVAL -$daysago DAY) =
+ DATE_FORMAT(mapDate,'%Y-%m-%d') AND
+ `mapType` = '$maptype'
+ ";
+ //echo "<br />$sql<br />";
+ $result = mysql_query($sql) or die(mysql_error());
+ //No map for today?
+ if (mysql_num_rows($result) == 0)
+ return -1;
+
+ $r = mysql_result($result, 0, 'mapID');
+ //echo "result: $r";
+ return $r;
+}
+
+
+
+
+
+// Returns: ARRAY( blocked, path, start, end )
+function findPath($mapMatrix, $start = '0,1.', $target = 'f') {
+ $seed = explode(".", $start);
+ foreach ($seed as &$v) {
+ $v = explode(",", $v);
+ $v[2] = $v[0].','.$v[1];
+ }
+ //print_r ($seed);
+
+ $index = count($seed);
+
+ do {
+ foreach ($seed as $key => $v) {
+ //Search the squares around, to spread the seeds
+ for($i = 1; $i <= 4; $i++) {
+ $x = $v[0];
+ $y = $v[1];
+ //Create a handle on the squares around it.
+ switch($i){
+ case 1: $y--; break; //up
+ case 2: $x++; break; //right
+ case 3: $y++; break; //down
+ case 4: $x--; break; //left
+ }
+ if ($y < 1 OR $x < 0) continue 1;
+ //What's there?
+ switch($mapMatrix[$y][$x]) {
+ case $target: //Finishline!
+ //Our search is over.
+ $r['blocked'] = false;
+ $r['path'] = $seed[$key][3].$i;
+ $r['start'] = $v[2];
+ $r['end'] = "$x,$y";
+ return $r;
+ break;
+ // Teleports m t g i k
+ case "m": case "t": case "g": case "i": case "k":
+ $path = $mapMatrix[$y][$x];
+
+ case "o": //Available squares
+ //!!
+ case "s": case "f": //Start and end tiles
+
+ case "a": case "b": case "c": case "d": case "e": //Checkpoints too
+ case "u": case "n": case "h": case "j": case "l": //Teleport-out towers included!
+ //Plant Seed here
+ $seed[$index][0] = $x;
+ $seed[$index][1] = $y;
+ //Save our starting position.
+ $seed[$index][2] = $v[2];
+ //Save 'PATH'
+ $path = $i.$path;
+ $seed[$index][3] = $v[3].$path;
+ $path = '';
+ //Been there, done that.
+ $mapMatrix[$y][$x] = null;
+ //Move index
+ $index++;
+
+ break;
+ }
+ }
+ //Running out of seeds?
+ if (count($seed) < 2) {
+ $r['blocked'] = true;
+ $r['path'] = $seed[$key][3].$i;
+ $r['end'] = "$x,$y";
+ return $r;
+ }
+ //Lets not try this again.
+ unset($seed[$key]);
+ }
+ } while ( 1);
+ echo "Ran outa seeds.<br />";
+ print_r($seed);
+ return $mapMatrix;
+}
+
+
+/* UNUSED FUNCTION
+function GetTile($mapMatrix, $id)
+{
+ //Returns the location in $mapMatrix indicated by $id
+ $toReturn = &$mapMatrix [ (int)($id / $mapMatrix[0][0]) ]
+ [ $id % $mapMatrix[0][0] ];
+
+ return $toReturn;
+}
+ */
+
+//Routes a path through all checkpoints and teleports, returning an array.
+// [path] path-string. [blocked] boolean, [moves] int.
+function routePath($mygrid, $start = '') {
+
+ //== This should grab the start positions by scaning the map.
+ if ($start == '') {
+ for ($i = 1; $i <= $mygrid[0][1]; $i++) {
+ $start .= "0,$i.";
+ }
+ }
+
+ //Checkpoint names
+ $cpnames = Array("a", "b", "c", "d", "e");
+ //Get the amount of checkpoints on this map.
+ $cpcount = $mygrid[0][2];
+
+ //Add the existing checkpoints to targets.
+ for($p = 0; $p < $cpcount; $p++) {
+ $target[] = $cpnames[$p];
+ }
+ //Always need the finish line.
+ $target[] = 'f';
+
+ //Assume that we're not blocked, and raise a red flag later.
+ $blocked = false;
+
+
+ //All possible teleports in play.
+ $tpnames = Array('t', 'm', 'g', 'i', 'k');
+
+ $tpcount = intval($mygrid[0][5] * .5);
+ //Add the existing checkpoints to targets.
+ for($p = 0; $p < $tpcount; $p++) {
+ $teleport[] = $tpnames[$p];
+ }
+
+ $teleout['t'] = 'u';
+ $teleout['m'] = 'n';
+ $teleout['g'] = 'h';
+ $teleout['i'] = 'j';
+ $teleout['k'] = 'l';
+
+ //$r['tparray'] = $teleport;
+ //$r['cparray'] = $target;
+
+ //Loop through all the targets.
+ foreach($target as $t) {
+ //Path from where we are, to the target.
+ $p = Findpath ($mygrid, $start, $t);
+ //It's possible to start from multiple places;
+ //so mark where we ended up starting from.
+ if ($r['start'] == '')
+ $r['start'] = $p['start'];
+
+ //$f = 0;
+ //1449
+ //2263
+ do {
+ //Make sure there is a teleport to search.
+ if (! is_array($teleport))
+ break 1;
+ //Search through the path to find first teleport hit, if any.
+
+ $pathary = str_split($p['path']);
+
+ //As per usual, it's best to assume that you've failed.
+ $foundtele = false;
+ //Search through pathary and compare all existing teleports.
+ foreach ($pathary as $position => $char) {
+ foreach ($teleport as $ktel => $port) {
+ //$r['z'] .= ';'.$f++;
+ if ($port == $char) {
+ //Disable teleport
+ //$teleport[$ktel] = '';
+ unset($teleport[$ktel]);
+ //$teleport = array_values($teleport);
+ //We found it
+ $foundtele = true;
+ break 2;
+ }
+ }
+ }
+ if ($foundtele == false) {
+ break 1;
+ }
+
+
+ $outchar = $teleout[$port];
+ if ($position === false) continue;
+ //if ($teleactive[$port] === false) continue;
+ //Where is the tele $out location.
+ $x = Findpath($mygrid, $start, $outchar);
+ $out = $x['end'];
+ if ($x['blocked']) $blocked = true; //Optional?
+
+ //New path starting from our out-location.
+ $z = Findpath($mygrid, $out, $t);
+ if ($z['blocked']) $blocked = true; //Optional?
+
+ //Deactivate teleport
+ $teleactive[$port] = false;
+ //$r['debug'] = "TPD: $port";
+
+ //Apply modified path, and warp-cordinates.
+ //123 _Tele_ 222
+ //123
+ $p['path'] = substr($p['path'], 0, $position + 1);
+ //123
+ //123 U CORDS U
+ $p['path'] .= $outchar.$out.$outchar;
+ //123 U CORDS U
+ //123 U CORDS U 2322
+ $p['path'] .= $z['path'];
+
+ $movesoffset -= countmoves($out);
+ //}
+ } while ($foundtele);
+
+ //$start = explode(",", $p['end']);
+ $start = $p['end'];
+ if ($p['blocked']) $blocked = true;
+ $tpath .= $t.$p['path'].'r';
+ }
+ $r['blocked'] = $blocked;
+ $r['path'] = $tpath;
+ //$moves = count_chars($tpath, 0);
+ $moves = countmoves($tpath);
+ $moves += $movesoffset;
+ $r['moves'] = $moves;
+ //$r['moves'] = print_r($moves);
+ return $r;
+}
+//For use with routepath;
+function cmp($a, $b) {
+ if ($a === false) $a = 10000;
+ if ($b === false) $b = 10000;
+ if ($a == $b) {
+ return 0;
+ }
+ return ($a < $b) ? -1 : 1;
+}
+//For use with routepath;
+function countmoves($path) {
+ $moves = substr_count($path, '1');
+ $moves += substr_count($path, '2');
+ $moves += substr_count($path, '3');
+ $moves += substr_count($path, '4');
+ return $moves;
+}
+
+//Returns a random selection of one of the arguements.
+function weight() {
+ $weights = func_get_args();
+ return $weights[rand(0, (count($weights) -1))];
+}
+
+
+?>
diff --git a/includes/openid.php b/includes/openid.php
new file mode 100644
index 0000000..85af9a8
--- /dev/null
+++ b/includes/openid.php
@@ -0,0 +1,740 @@
+<?php
+/**
+ * This class provides a simple interface for OpenID (1.1 and 2.0) authentication.
+ * Supports Yadis discovery.
+ * The authentication process is stateless/dumb.
+ *
+ * Usage:
+ * Sign-on with OpenID is a two step process:
+ * Step one is authentication with the provider:
+ * <code>
+ * $openid = new LightOpenID;
+ * $openid->identity = 'ID supplied by user';
+ * header('Location: ' . $openid->authUrl());
+ * </code>
+ * The provider then sends various parameters via GET, one of them is openid_mode.
+ * Step two is verification:
+ * <code>
+ * if ($this->data['openid_mode']) {
+ * $openid = new LightOpenID;
+ * echo $openid->validate() ? 'Logged in.' : 'Failed';
+ * }
+ * </code>
+ *
+ * Optionally, you can set $returnUrl and $realm (or $trustRoot, which is an alias).
+ * The default values for those are:
+ * $openid->realm = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];
+ * $openid->returnUrl = $openid->realm . $_SERVER['REQUEST_URI'];
+ * If you don't know their meaning, refer to any openid tutorial, or specification. Or just guess.
+ *
+ * AX and SREG extensions are supported.
+ * To use them, specify $openid->required and/or $openid->optional before calling $openid->authUrl().
+ * These are arrays, with values being AX schema paths (the 'path' part of the URL).
+ * For example:
+ * $openid->required = array('namePerson/friendly', 'contact/email');
+ * $openid->optional = array('namePerson/first');
+ * If the server supports only SREG or OpenID 1.1, these are automaticaly
+ * mapped to SREG names, so that user doesn't have to know anything about the server.
+ *
+ * To get the values, use $openid->getAttributes().
+ *
+ *
+ * The library requires PHP >= 5.1.2 with curl or http/https stream wrappers enabled.
+ * @author Mewp
+ * @copyright Copyright (c) 2010, Mewp
+ * @license http://www.opensource.org/licenses/mit-license.php MIT
+ */
+class LightOpenID
+{
+ public $returnUrl
+ , $required = array()
+ , $optional = array()
+ , $verify_peer = null
+ , $capath = null
+ , $cainfo = null;
+ private $identity, $claimed_id;
+ protected $server, $version, $trustRoot, $aliases, $identifier_select = false
+ , $ax = false, $sreg = false, $data;
+ static protected $ax_to_sreg = array(
+ 'namePerson/friendly' => 'nickname',
+ 'contact/email' => 'email',
+ 'namePerson' => 'fullname',
+ 'birthDate' => 'dob',
+ 'person/gender' => 'gender',
+ 'contact/postalCode/home' => 'postcode',
+ 'contact/country/home' => 'country',
+ 'pref/language' => 'language',
+ 'pref/timezone' => 'timezone',
+ );
+
+ function __construct()
+ {
+ $this->trustRoot = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];
+ $uri = rtrim(preg_replace('#((?<=\?)|&)openid\.[^&]+#', '', $_SERVER['REQUEST_URI']), '?');
+ $this->returnUrl = $this->trustRoot . $uri;
+
+ $this->data = $_POST + $_GET; # OPs may send data as POST or GET.
+ }
+
+ function __set($name, $value)
+ {
+ switch ($name) {
+ case 'identity':
+ if (strlen($value = trim((String) $value))) {
+ if (preg_match('#^xri:/*#i', $value, $m)) {
+ $value = substr($value, strlen($m[0]));
+ } elseif (!preg_match('/^(?:[=@+\$!\(]|https?:)/i', $value)) {
+ $value = "http://$value";
+ }
+ if (preg_match('#^https?://[^/]+$#i', $value, $m)) {
+ $value .= '/';
+ }
+ }
+ $this->$name = $this->claimed_id = $value;
+ break;
+ case 'trustRoot':
+ case 'realm':
+ $this->trustRoot = trim($value);
+ }
+ }
+
+ function __get($name)
+ {
+ switch ($name) {
+ case 'identity':
+ # We return claimed_id instead of identity,
+ # because the developer should see the claimed identifier,
+ # i.e. what he set as identity, not the op-local identifier (which is what we verify)
+ return $this->claimed_id;
+ case 'trustRoot':
+ case 'realm':
+ return $this->trustRoot;
+ case 'mode':
+ return empty($this->data['openid_mode']) ? null : $this->data['openid_mode'];
+ }
+ }
+
+ /**
+ * Checks if the server specified in the url exists.
+ *
+ * @param $url url to check
+ * @return true, if the server exists; false otherwise
+ */
+ function hostExists($url)
+ {
+ if (strpos($url, '/') === false) {
+ $server = $url;
+ } else {
+ $server = @parse_url($url, PHP_URL_HOST);
+ }
+
+ if (!$server) {
+ return false;
+ }
+
+ return !!gethostbynamel($server);
+ }
+
+ protected function request_curl($url, $method='GET', $params=array())
+ {
+ $params = http_build_query($params, '', '&');
+ $curl = curl_init($url . ($method == 'GET' && $params ? '?' . $params : ''));
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
+ curl_setopt($curl, CURLOPT_HEADER, false);
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/xrds+xml, */*'));
+
+ if($this->verify_peer !== null) {
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verify_peer);
+ if($this->capath) {
+ curl_setopt($curl, CURLOPT_CAPATH, $this->capath);
+ }
+
+ if($this->cainfo) {
+ curl_setopt($curl, CURLOPT_CAINFO, $this->cainfo);
+ }
+ }
+
+ if ($method == 'POST') {
+ curl_setopt($curl, CURLOPT_POST, true);
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
+ } elseif ($method == 'HEAD') {
+ curl_setopt($curl, CURLOPT_HEADER, true);
+ curl_setopt($curl, CURLOPT_NOBODY, true);
+ } else {
+ curl_setopt($curl, CURLOPT_HTTPGET, true);
+ }
+ $response = curl_exec($curl);
+
+ if($method == 'HEAD') {
+ $headers = array();
+ foreach(explode("\n", $response) as $header) {
+ $pos = strpos($header,':');
+ $name = strtolower(trim(substr($header, 0, $pos)));
+ $headers[$name] = trim(substr($header, $pos+1));
+ }
+
+ # Updating claimed_id in case of redirections.
+ $effective_url = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
+ if($effective_url != $url) {
+ $this->identity = $this->claimed_id = $effective_url;
+ }
+
+ return $headers;
+ }
+
+ if (curl_errno($curl)) {
+ throw new ErrorException(curl_error($curl), curl_errno($curl));
+ }
+
+ return $response;
+ }
+
+ protected function request_streams($url, $method='GET', $params=array())
+ {
+ if(!$this->hostExists($url)) {
+ throw new ErrorException('Invalid request.');
+ }
+
+ $params = http_build_query($params, '', '&');
+ switch($method) {
+ case 'GET':
+ $opts = array(
+ 'http' => array(
+ 'method' => 'GET',
+ 'header' => 'Accept: application/xrds+xml, */*',
+ 'ignore_errors' => true,
+ )
+ );
+ $url = $url . ($params ? '?' . $params : '');
+ break;
+ case 'POST':
+ $opts = array(
+ 'http' => array(
+ 'method' => 'POST',
+ 'header' => 'Content-type: application/x-www-form-urlencoded',
+ 'content' => $params,
+ 'ignore_errors' => true,
+ )
+ );
+ break;
+ case 'HEAD':
+ # We want to send a HEAD request,
+ # but since get_headers doesn't accept $context parameter,
+ # we have to change the defaults.
+ $default = stream_context_get_options(stream_context_get_default());
+ stream_context_get_default(
+ array('http' => array(
+ 'method' => 'HEAD',
+ 'header' => 'Accept: application/xrds+xml, */*',
+ 'ignore_errors' => true,
+ ))
+ );
+
+ $url = $url . ($params ? '?' . $params : '');
+ $headers_tmp = get_headers ($url);
+ if(!$headers_tmp) {
+ return array();
+ }
+
+ # Parsing headers.
+ $headers = array();
+ foreach($headers_tmp as $header) {
+ $pos = strpos($header,':');
+ $name = strtolower(trim(substr($header, 0, $pos)));
+ $headers[$name] = trim(substr($header, $pos+1));
+
+ # Following possible redirections. The point is just to have
+ # claimed_id change with them, because get_headers() will
+ # follow redirections automatically.
+ # We ignore redirections with relative paths.
+ # If any known provider uses them, file a bug report.
+ if($name == 'location') {
+ if(strpos($headers[$name], 'http') === 0) {
+ $this->identity = $this->claimed_id = $headers[$name];
+ } elseif($headers[$name][0] == '/') {
+ $parsed_url = parse_url($this->claimed_id);
+ $this->identity =
+ $this->claimed_id = $parsed_url['scheme'] . '://'
+ . $parsed_url['host']
+ . $headers[$name];
+ }
+ }
+ }
+
+ # And restore them.
+ stream_context_get_default($default);
+ return $headers;
+ }
+
+ if($this->verify_peer) {
+ $opts += array('ssl' => array(
+ 'verify_peer' => true,
+ 'capath' => $this->capath,
+ 'cafile' => $this->cainfo,
+ ));
+ }
+
+ $context = stream_context_create ($opts);
+
+ return file_get_contents($url, false, $context);
+ }
+
+ protected function request($url, $method='GET', $params=array())
+ {
+ if(function_exists('curl_init') && !ini_get('safe_mode')) {
+ return $this->request_curl($url, $method, $params);
+ }
+ return $this->request_streams($url, $method, $params);
+ }
+
+ protected function build_url($url, $parts)
+ {
+ if (isset($url['query'], $parts['query'])) {
+ $parts['query'] = $url['query'] . '&' . $parts['query'];
+ }
+
+ $url = $parts + $url;
+ $url = $url['scheme'] . '://'
+ . (empty($url['username'])?''
+ :(empty($url['password'])? "{$url['username']}@"
+ :"{$url['username']}:{$url['password']}@"))
+ . $url['host']
+ . (empty($url['port'])?'':":{$url['port']}")
+ . (empty($url['path'])?'':$url['path'])
+ . (empty($url['query'])?'':"?{$url['query']}")
+ . (empty($url['fragment'])?'':"#{$url['fragment']}");
+ return $url;
+ }
+
+ /**
+ * Helper function used to scan for <meta>/<link> tags and extract information
+ * from them
+ */
+ protected function htmlTag($content, $tag, $attrName, $attrValue, $valueName)
+ {
+ preg_match_all("#<{$tag}[^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*$valueName=['\"](.+?)['\"][^>]*/?>#i", $content, $matches1);
+ preg_match_all("#<{$tag}[^>]*$valueName=['\"](.+?)['\"][^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*/?>#i", $content, $matches2);
+
+ $result = array_merge($matches1[1], $matches2[1]);
+ return empty($result)?false:$result[0];
+ }
+
+ /**
+ * Performs Yadis and HTML discovery. Normally not used.
+ * @param $url Identity URL.
+ * @return String OP Endpoint (i.e. OpenID provider address).
+ * @throws ErrorException
+ */
+ function discover($url)
+ {
+ if (!$url) throw new ErrorException('No identity supplied.');
+ # Use xri.net proxy to resolve i-name identities
+ if (!preg_match('#^https?:#', $url)) {
+ $url = "https://xri.net/$url";
+ }
+
+ # We save the original url in case of Yadis discovery failure.
+ # It can happen when we'll be lead to an XRDS document
+ # which does not have any OpenID2 services.
+ $originalUrl = $url;
+
+ # A flag to disable yadis discovery in case of failure in headers.
+ $yadis = true;
+
+ # We'll jump a maximum of 5 times, to avoid endless redirections.
+ for ($i = 0; $i < 5; $i ++) {
+ if ($yadis) {
+ $headers = $this->request($url, 'HEAD');
+
+ $next = false;
+ if (isset($headers['x-xrds-location'])) {
+ $url = $this->build_url(parse_url($url), parse_url(trim($headers['x-xrds-location'])));
+ $next = true;
+ }
+
+ if (isset($headers['content-type'])
+ && (strpos($headers['content-type'], 'application/xrds+xml') !== false
+ || strpos($headers['content-type'], 'text/xml') !== false)
+ ) {
+ # Apparently, some providers return XRDS documents as text/html.
+ # While it is against the spec, allowing this here shouldn't break
+ # compatibility with anything.
+ # ---
+ # Found an XRDS document, now let's find the server, and optionally delegate.
+ $content = $this->request($url, 'GET');
+
+ preg_match_all('#<Service.*?>(.*?)</Service>#s', $content, $m);
+ foreach($m[1] as $content) {
+ $content = ' ' . $content; # The space is added, so that strpos doesn't return 0.
+
+ # OpenID 2
+ $ns = preg_quote('http://specs.openid.net/auth/2.0/');
+ if(preg_match('#<Type>\s*'.$ns.'(server|signon)\s*</Type>#s', $content, $type)) {
+ if ($type[1] == 'server') $this->identifier_select = true;
+
+ preg_match('#<URI.*?>(.*)</URI>#', $content, $server);
+ preg_match('#<(Local|Canonical)ID>(.*)</\1ID>#', $content, $delegate);
+ if (empty($server)) {
+ return false;
+ }
+ # Does the server advertise support for either AX or SREG?
+ $this->ax = (bool) strpos($content, '<Type>http://openid.net/srv/ax/1.0</Type>');
+ $this->sreg = strpos($content, '<Type>http://openid.net/sreg/1.0</Type>')
+ || strpos($content, '<Type>http://openid.net/extensions/sreg/1.1</Type>');
+
+ $server = $server[1];
+ if (isset($delegate[2])) $this->identity = trim($delegate[2]);
+ $this->version = 2;
+
+ $this->server = $server;
+ return $server;
+ }
+
+ # OpenID 1.1
+ $ns = preg_quote('http://openid.net/signon/1.1');
+ if (preg_match('#<Type>\s*'.$ns.'\s*</Type>#s', $content)) {
+
+ preg_match('#<URI.*?>(.*)</URI>#', $content, $server);
+ preg_match('#<.*?Delegate>(.*)</.*?Delegate>#', $content, $delegate);
+ if (empty($server)) {
+ return false;
+ }
+ # AX can be used only with OpenID 2.0, so checking only SREG
+ $this->sreg = strpos($content, '<Type>http://openid.net/sreg/1.0</Type>')
+ || strpos($content, '<Type>http://openid.net/extensions/sreg/1.1</Type>');
+
+ $server = $server[1];
+ if (isset($delegate[1])) $this->identity = $delegate[1];
+ $this->version = 1;
+
+ $this->server = $server;
+ return $server;
+ }
+ }
+
+ $next = true;
+ $yadis = false;
+ $url = $originalUrl;
+ $content = null;
+ break;
+ }
+ if ($next) continue;
+
+ # There are no relevant information in headers, so we search the body.
+ $content = $this->request($url, 'GET');
+ $location = $this->htmlTag($content, 'meta', 'http-equiv', 'X-XRDS-Location', 'content');
+ if ($location) {
+ $url = $this->build_url(parse_url($url), parse_url($location));
+ continue;
+ }
+ }
+
+ if (!$content) $content = $this->request($url, 'GET');
+
+ # At this point, the YADIS Discovery has failed, so we'll switch
+ # to openid2 HTML discovery, then fallback to openid 1.1 discovery.
+ $server = $this->htmlTag($content, 'link', 'rel', 'openid2.provider', 'href');
+ $delegate = $this->htmlTag($content, 'link', 'rel', 'openid2.local_id', 'href');
+ $this->version = 2;
+
+ if (!$server) {
+ # The same with openid 1.1
+ $server = $this->htmlTag($content, 'link', 'rel', 'openid.server', 'href');
+ $delegate = $this->htmlTag($content, 'link', 'rel', 'openid.delegate', 'href');
+ $this->version = 1;
+ }
+
+ if ($server) {
+ # We found an OpenID2 OP Endpoint
+ if ($delegate) {
+ # We have also found an OP-Local ID.
+ $this->identity = $delegate;
+ }
+ $this->server = $server;
+ return $server;
+ }
+
+ throw new ErrorException('No servers found!');
+ }
+ throw new ErrorException('Endless redirection!');
+ }
+
+ protected function sregParams()
+ {
+ $params = array();
+ # We always use SREG 1.1, even if the server is advertising only support for 1.0.
+ # That's because it's fully backwards compatibile with 1.0, and some providers
+ # advertise 1.0 even if they accept only 1.1. One such provider is myopenid.com
+ $params['openid.ns.sreg'] = 'http://openid.net/extensions/sreg/1.1';
+ if ($this->required) {
+ $params['openid.sreg.required'] = array();
+ foreach ($this->required as $required) {
+ if (!isset(self::$ax_to_sreg[$required])) continue;
+ $params['openid.sreg.required'][] = self::$ax_to_sreg[$required];
+ }
+ $params['openid.sreg.required'] = implode(',', $params['openid.sreg.required']);
+ }
+
+ if ($this->optional) {
+ $params['openid.sreg.optional'] = array();
+ foreach ($this->optional as $optional) {
+ if (!isset(self::$ax_to_sreg[$optional])) continue;
+ $params['openid.sreg.optional'][] = self::$ax_to_sreg[$optional];
+ }
+ $params['openid.sreg.optional'] = implode(',', $params['openid.sreg.optional']);
+ }
+ return $params;
+ }
+
+ protected function axParams()
+ {
+ $params = array();
+ if ($this->required || $this->optional) {
+ $params['openid.ns.ax'] = 'http://openid.net/srv/ax/1.0';
+ $params['openid.ax.mode'] = 'fetch_request';
+ $this->aliases = array();
+ $counts = array();
+ $required = array();
+ $optional = array();
+ foreach (array('required','optional') as $type) {
+ foreach ($this->$type as $alias => $field) {
+ if (is_int($alias)) $alias = strtr($field, '/', '_');
+ $this->aliases[$alias] = 'http://axschema.org/' . $field;
+ if (empty($counts[$alias])) $counts[$alias] = 0;
+ $counts[$alias] += 1;
+ ${$type}[] = $alias;
+ }
+ }
+ foreach ($this->aliases as $alias => $ns) {
+ $params['openid.ax.type.' . $alias] = $ns;
+ }
+ foreach ($counts as $alias => $count) {
+ if ($count == 1) continue;
+ $params['openid.ax.count.' . $alias] = $count;
+ }
+
+ # Don't send empty ax.requied and ax.if_available.
+ # Google and possibly other providers refuse to support ax when one of these is empty.
+ if($required) {
+ $params['openid.ax.required'] = implode(',', $required);
+ }
+ if($optional) {
+ $params['openid.ax.if_available'] = implode(',', $optional);
+ }
+ }
+ return $params;
+ }
+
+ protected function authUrl_v1()
+ {
+ $returnUrl = $this->returnUrl;
+ # If we have an openid.delegate that is different from our claimed id,
+ # we need to somehow preserve the claimed id between requests.
+ # The simplest way is to just send it along with the return_to url.
+ if($this->identity != $this->claimed_id) {
+ $returnUrl .= (strpos($returnUrl, '?') ? '&' : '?') . 'openid.claimed_id=' . $this->claimed_id;
+ }
+
+ $params = array(
+ 'openid.return_to' => $returnUrl,
+ 'openid.mode' => 'checkid_setup',
+ 'openid.identity' => $this->identity,
+ 'openid.trust_root' => $this->trustRoot,
+ ) + $this->sregParams();
+
+ return $this->build_url(parse_url($this->server)
+ , array('query' => http_build_query($params, '', '&')));
+ }
+
+ protected function authUrl_v2($identifier_select)
+ {
+ $params = array(
+ 'openid.ns' => 'http://specs.openid.net/auth/2.0',
+ 'openid.mode' => 'checkid_setup',
+ 'openid.return_to' => $this->returnUrl,
+ 'openid.realm' => $this->trustRoot,
+ );
+ if ($this->ax) {
+ $params += $this->axParams();
+ }
+ if ($this->sreg) {
+ $params += $this->sregParams();
+ }
+ if (!$this->ax && !$this->sreg) {
+ # If OP doesn't advertise either SREG, nor AX, let's send them both
+ # in worst case we don't get anything in return.
+ $params += $this->axParams() + $this->sregParams();
+ }
+
+ if ($identifier_select) {
+ $params['openid.identity'] = $params['openid.claimed_id']
+ = 'http://specs.openid.net/auth/2.0/identifier_select';
+ } else {
+ $params['openid.identity'] = $this->identity;
+ $params['openid.claimed_id'] = $this->claimed_id;
+ }
+
+ return $this->build_url(parse_url($this->server)
+ , array('query' => http_build_query($params, '', '&')));
+ }
+
+ /**
+ * Returns authentication url. Usually, you want to redirect your user to it.
+ * @return String The authentication url.
+ * @param String $select_identifier Whether to request OP to select identity for an user in OpenID 2. Does not affect OpenID 1.
+ * @throws ErrorException
+ */
+ function authUrl($identifier_select = null)
+ {
+ if (!$this->server) $this->discover($this->identity);
+
+ if ($this->version == 2) {
+ if ($identifier_select === null) {
+ return $this->authUrl_v2($this->identifier_select);
+ }
+ return $this->authUrl_v2($identifier_select);
+ }
+ return $this->authUrl_v1();
+ }
+
+ /**
+ * Performs OpenID verification with the OP.
+ * @return Bool Whether the verification was successful.
+ * @throws ErrorException
+ */
+ function validate()
+ {
+ $this->claimed_id = isset($this->data['openid_claimed_id'])?$this->data['openid_claimed_id']:$this->data['openid_identity'];
+ $params = array(
+ 'openid.assoc_handle' => $this->data['openid_assoc_handle'],
+ 'openid.signed' => $this->data['openid_signed'],
+ 'openid.sig' => $this->data['openid_sig'],
+ );
+
+ if (isset($this->data['openid_ns'])) {
+ # We're dealing with an OpenID 2.0 server, so let's set an ns
+ # Even though we should know location of the endpoint,
+ # we still need to verify it by discovery, so $server is not set here
+ $params['openid.ns'] = 'http://specs.openid.net/auth/2.0';
+ } elseif (isset($this->data['openid_claimed_id'])
+ && $this->data['openid_claimed_id'] != $this->data['openid_identity']
+ ) {
+ # If it's an OpenID 1 provider, and we've got claimed_id,
+ # we have to append it to the returnUrl, like authUrl_v1 does.
+ $this->returnUrl .= (strpos($this->returnUrl, '?') ? '&' : '?')
+ . 'openid.claimed_id=' . $this->claimed_id;
+ }
+
+ if ($this->data['openid_return_to'] != $this->returnUrl) {
+ # The return_to url must match the url of current request.
+ # I'm assuing that noone will set the returnUrl to something that doesn't make sense.
+ return false;
+ }
+
+ $server = $this->discover($this->claimed_id);
+
+ foreach (explode(',', $this->data['openid_signed']) as $item) {
+ # Checking whether magic_quotes_gpc is turned on, because
+ # the function may fail if it is. For example, when fetching
+ # AX namePerson, it might containg an apostrophe, which will be escaped.
+ # In such case, validation would fail, since we'd send different data than OP
+ # wants to verify. stripslashes() should solve that problem, but we can't
+ # use it when magic_quotes is off.
+ $value = $this->data['openid_' . str_replace('.','_',$item)];
+ $params['openid.' . $item] = get_magic_quotes_gpc() ? stripslashes($value) : $value;
+
+ }
+
+ $params['openid.mode'] = 'check_authentication';
+
+ $response = $this->request($server, 'POST', $params);
+
+ return preg_match('/is_valid\s*:\s*true/i', $response);
+ }
+
+ protected function getAxAttributes()
+ {
+ $alias = null;
+ if (isset($this->data['openid_ns_ax'])
+ && $this->data['openid_ns_ax'] != 'http://openid.net/srv/ax/1.0'
+ ) { # It's the most likely case, so we'll check it before
+ $alias = 'ax';
+ } else {
+ # 'ax' prefix is either undefined, or points to another extension,
+ # so we search for another prefix
+ foreach ($this->data as $key => $val) {
+ if (substr($key, 0, strlen('openid_ns_')) == 'openid_ns_'
+ && $val == 'http://openid.net/srv/ax/1.0'
+ ) {
+ $alias = substr($key, strlen('openid_ns_'));
+ break;
+ }
+ }
+ }
+ if (!$alias) {
+ # An alias for AX schema has not been found,
+ # so there is no AX data in the OP's response
+ return array();
+ }
+
+ $attributes = array();
+ foreach ($this->data as $key => $value) {
+ $keyMatch = 'openid_' . $alias . '_value_';
+ if (substr($key, 0, strlen($keyMatch)) != $keyMatch) {
+ continue;
+ }
+ $key = substr($key, strlen($keyMatch));
+ if (!isset($this->data['openid_' . $alias . '_type_' . $key])) {
+ # OP is breaking the spec by returning a field without
+ # associated ns. This shouldn't happen, but it's better
+ # to check, than cause an E_NOTICE.
+ continue;
+ }
+ $key = substr($this->data['openid_' . $alias . '_type_' . $key],
+ strlen('http://axschema.org/'));
+ $attributes[$key] = $value;
+ }
+ return $attributes;
+ }
+
+ protected function getSregAttributes()
+ {
+ $attributes = array();
+ $sreg_to_ax = array_flip(self::$ax_to_sreg);
+ foreach ($this->data as $key => $value) {
+ $keyMatch = 'openid_sreg_';
+ if (substr($key, 0, strlen($keyMatch)) != $keyMatch) {
+ continue;
+ }
+ $key = substr($key, strlen($keyMatch));
+ if (!isset($sreg_to_ax[$key])) {
+ # The field name isn't part of the SREG spec, so we ignore it.
+ continue;
+ }
+ $attributes[$sreg_to_ax[$key]] = $value;
+ }
+ return $attributes;
+ }
+
+ /**
+ * Gets AX/SREG attributes provided by OP. should be used only after successful validaton.
+ * Note that it does not guarantee that any of the required/optional parameters will be present,
+ * or that there will be no other attributes besides those specified.
+ * In other words. OP may provide whatever information it wants to.
+ * * SREG names will be mapped to AX names.
+ * * @return Array Array of attributes with keys being the AX schema names, e.g. 'contact/email'
+ * @see http://www.axschema.org/types/
+ */
+ function getAttributes()
+ {
+ if (isset($this->data['openid_ns'])
+ && $this->data['openid_ns'] == 'http://specs.openid.net/auth/2.0'
+ ) { # OpenID 2.0
+ # We search for both AX and SREG attributes, with AX taking precedence.
+ return $this->getAxAttributes() + $this->getSregAttributes();
+ }
+ return $this->getSregAttributes();
+ }
+}
diff --git a/includes/pathing.php b/includes/pathing.php
new file mode 100644
index 0000000..fc07f0b
--- /dev/null
+++ b/includes/pathing.php
@@ -0,0 +1,108 @@
+<?PHP
+//
+function FindPath($mapMatrix)
+{
+ //FindPath will generate a string consisting of the moves made by the
+ // puppy to reach each checkpoint and then the finish.
+
+ $status = array(); //This stores the search status of each tile
+ // in the grid.
+ //-2 - Unprocessed; -1 - Queued; [x] - Processed/Previous tile
+
+ $queue = array(); //This is the order to check tiles in, to
+ // prevent overcommitting. Stores TileID.
+
+ $targets = array(); //This is the queue of targets the path must connect. Flags.
+
+ $finish = array(); //This is the set of finish tiles. Stores TileID.
+
+ $path = ""; //This is a string of the moves taken by the
+ // puppy!
+ //1 - Up; 2 - Right; 3 - Down; 4 - Left
+
+ //Initialize $status
+ for( $i = 0; $i < count($mapMatrix); $i++)
+ {
+ $status[i] = array();
+ for( $j = 0; $j < count($mapMatrix[$i]); $j++)
+ {
+ $status[i][j] = -1;
+ }
+ }
+
+ //Initialize $queue with tiles adjacent to Starts
+ //Assuming the LEFT column is entirely composed of Start tiles...
+ // NOTE: This is what we would change should the Start tiles become different.
+ for( $i = 1; $i <= $mapMatrix[0][1]; $i++)
+ {
+ $status[1][$i] = 0;
+ $nextTile = GetTileID($mapMatrix, 2, $i);
+ $queue[($i-1)] = $nextTile;
+ }
+
+ //Initialize $finish queue with Finish tiles.
+ //Assuming the RIGHT column is entirely composed of Finish tiles...
+ // NOTE: This is what we would change should the Finish tiles become different.
+ for( $i = 1; $i <= $mapMatrix[0][1]; $i++)
+ {
+ echo "Tile #".GetTileID($mapMatrix, $mapMatrix[0][0] - 1, $i)." has been marked as a Finish tile.<br />";
+ $nextTile = GetTileID($mapMatrix, $mapMatrix[0][0] - 1, $i);
+ $finish[($i-1)] = $nextTile;
+ }
+
+ //Initialize $targets with Checkpoints and Finish.
+ switch($mapMatrix[0][2])
+ {
+ case 3: array_push($targets, 'C');
+ case 2: array_push($targets, 'B');
+ case 1: array_push($targets, 'A');
+ }
+ array_reverse($targets);
+ array_push($targets, 'Finish');
+
+ print_r($queue);
+ echo "<br />";
+
+ while(count($queue) > 0)
+ {
+ $nextSearch = array_shift($queue);
+ $idFinish = array_shift($targets);
+ }
+
+ /*
+ echo "Pre-PrintArray. <br />";
+ print_r($queue);
+ echo "Post-PrintArray. <br />";
+ */
+
+ //Search($mapMatrix, $loc, $path);
+
+ return $path;
+}
+
+function Search($mapMatrix, $idStart, $idFinish, $path)
+{
+
+}
+
+function GetTileID($mapMatrix, $x, $y)
+{
+ //echo "Request for TileID of (".$x.",".$y."): ";
+ if($mapMatrix[0][0] >= $x && $mapMatrix[0][1] >= $y)
+ return $mapMatrix[0][0] * ($y-1) + $x;
+ else return -1;
+}
+
+//WOULD be a function if not for overhead of calling a function and
+// inconvenience of returning an array. Here to display formula.
+
+function GetTileCoordinates($mapMatrix, $tileID)
+{
+ $x = $tileID % $mapMatrix[0][0];
+ $y = (int)($tileID / $mapMatrix[0][0]) + 1;
+
+ echo "(".$x.",".$y.")";
+ echo "<br />";
+}
+
+?> \ No newline at end of file
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..0c87fa7
--- /dev/null
+++ b/index.php
@@ -0,0 +1,90 @@
+<?PHP
+include_once("globe.php");
+
+//Load our page
+if ($_SESSION['accepted'] <> 1)
+ if ($_COOKIE['doLogin'] == 'yes')
+ CookieLogin();
+
+
+//Links appear in order.
+$Links['home'] = "Home";
+$Links['leaderboard'] = "Scoreboard";
+$Links['howtoplay'] = "How to Play";
+//$Links['gallery'] = "Gallery";
+if ($_SESSION['accepted'] <> 1) {
+ $Links['login'] = "Log In";
+} else {
+ //$Links['logout'] = "Logout";
+}
+if ($_SESSION['isAdmin'] == true) {
+ $Links['admin'] = 'Admin';
+}
+$Links['faq'] = "FAQ";
+$Links['about'] = "About us";
+
+switch (strtolower($_GET[page])) {
+
+ case "test":
+ require("pages/test.php");
+ break;
+
+ case "about":
+ require("pages/about.php");
+ break;
+
+ case "gallery":
+ require("pages/gallery.php");
+ break;
+
+ case "faq":
+ require("pages/faq.php");
+ break;
+
+ case "howtoplay":
+ require("pages/howtoplay.php");
+ break;
+
+ case "leaderboard":
+ require("pages/leaderboard.php");
+ break;
+
+ case "cp":
+ require("pages/cp.php");
+ break;
+
+ case "login":
+ require 'pages/login.php';
+ break;
+
+ case "admin":
+ if ($_SESSION['isAdmin'] == true)
+ require 'pages/admin.php';
+ else
+ require 'pages/about.php';
+ break;
+
+ case "members":
+ if ($_SESSION['isAdmin'] == true)
+ require 'pages/memberlist.php';
+ else
+ require 'pages/memberlist.php';
+ break;
+
+ case "logout":
+ //If this needs to be any larger we can move it to a function.
+ setcookie("doLogin", "");
+ setcookie("userID", "");
+ setcookie("auth", "");
+ session_start();
+ session_destroy();
+ header("Location: $mydomain");
+ break;
+
+ case "home":
+ //No break here
+ Default:
+ require("pages/home.php");
+}
+
+?> \ No newline at end of file
diff --git a/js/ajax.js b/js/ajax.js
new file mode 100644
index 0000000..4b1dd50
--- /dev/null
+++ b/js/ajax.js
@@ -0,0 +1,195 @@
+/* Simple AJAX Code-Kit (SACK) v1.6.1 */
+/* ©2005 Gregory Wild-Smith */
+/* www.twilightuniverse.com */
+/* Software licenced under a modified X11 licence,
+ see documentation or authors website for more details */
+
+function sack(file) {
+ this.xmlhttp = null;
+
+ this.resetData = function() {
+ this.method = "POST";
+ this.queryStringSeparator = "?";
+ this.argumentSeparator = "&";
+ this.URLString = "";
+ this.encodeURIString = true;
+ this.execute = false;
+ this.element = null;
+ this.elementObj = null;
+ this.requestFile = file;
+ this.vars = new Object();
+ this.responseStatus = new Array(2);
+ };
+
+ this.resetFunctions = function() {
+ this.onLoading = function() { };
+ this.onLoaded = function() { };
+ this.onInteractive = function() { };
+ this.onCompletion = function() { };
+ this.onError = function() { };
+ this.onFail = function() { };
+ };
+
+ this.reset = function() {
+ this.resetFunctions();
+ this.resetData();
+ };
+
+ this.createAJAX = function() {
+ try {
+ this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
+ } catch (e1) {
+ try {
+ this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
+ } catch (e2) {
+ this.xmlhttp = null;
+ }
+ }
+
+ if (! this.xmlhttp) {
+ if (typeof XMLHttpRequest != "undefined") {
+ this.xmlhttp = new XMLHttpRequest();
+ } else {
+ this.failed = true;
+ }
+ }
+ };
+
+ this.setVar = function(name, value){
+ this.vars[name] = Array(value, false);
+ };
+
+ this.encVar = function(name, value, returnvars) {
+ if (true == returnvars) {
+ return Array(encodeURIComponent(name), encodeURIComponent(value));
+ } else {
+ this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
+ }
+ }
+
+ this.processURLString = function(string, encode) {
+ encoded = encodeURIComponent(this.argumentSeparator);
+ regexp = new RegExp(this.argumentSeparator + "|" + encoded);
+ varArray = string.split(regexp);
+ for (i = 0; i < varArray.length; i++){
+ urlVars = varArray[i].split("=");
+ if (true == encode){
+ this.encVar(urlVars[0], urlVars[1]);
+ } else {
+ this.setVar(urlVars[0], urlVars[1]);
+ }
+ }
+ }
+
+ this.createURLString = function(urlstring) {
+ if (this.encodeURIString && this.URLString.length) {
+ this.processURLString(this.URLString, true);
+ }
+
+ if (urlstring) {
+ if (this.URLString.length) {
+ this.URLString += this.argumentSeparator + urlstring;
+ } else {
+ this.URLString = urlstring;
+ }
+ }
+
+ // prevents caching of URLString
+ this.setVar("rndval", new Date().getTime());
+
+ urlstringtemp = new Array();
+ for (key in this.vars) {
+ if (false == this.vars[key][1] && true == this.encodeURIString) {
+ encoded = this.encVar(key, this.vars[key][0], true);
+ delete this.vars[key];
+ this.vars[encoded[0]] = Array(encoded[1], true);
+ key = encoded[0];
+ }
+
+ urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
+ }
+ if (urlstring){
+ this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
+ } else {
+ this.URLString += urlstringtemp.join(this.argumentSeparator);
+ }
+ }
+
+ this.runResponse = function() {
+ eval(this.response);
+ }
+
+ this.runAJAX = function(urlstring) {
+ if (this.failed) {
+ this.onFail();
+ } else {
+ this.createURLString(urlstring);
+ if (this.element) {
+ this.elementObj = document.getElementById(this.element);
+ }
+ if (this.xmlhttp) {
+ var self = this;
+ if (this.method == "GET") {
+ totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
+ this.xmlhttp.open(this.method, totalurlstring, true);
+ } else {
+ this.xmlhttp.open(this.method, this.requestFile, true);
+ try {
+ this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
+ } catch (e) { }
+ }
+
+ this.xmlhttp.onreadystatechange = function() {
+ switch (self.xmlhttp.readyState) {
+ case 1:
+ self.onLoading();
+ break;
+ case 2:
+ self.onLoaded();
+ break;
+ case 3:
+ self.onInteractive();
+ break;
+ case 4:
+ self.response = self.xmlhttp.responseText;
+ self.responseXML = self.xmlhttp.responseXML;
+ self.responseStatus[0] = self.xmlhttp.status;
+ self.responseStatus[1] = self.xmlhttp.statusText;
+
+ if (self.execute) {
+ self.runResponse();
+ }
+
+ if (self.elementObj) {
+ elemNodeName = self.elementObj.nodeName;
+ elemNodeName.toLowerCase();
+ if (elemNodeName == "input"
+ || elemNodeName == "select"
+ || elemNodeName == "option"
+ || elemNodeName == "textarea") {
+ self.elementObj.value = self.response;
+ } else {
+ self.elementObj.innerHTML = self.response;
+ }
+ }
+ if (self.responseStatus[0] == "200") {
+ self.onCompletion();
+ } else {
+ self.onError();
+ }
+
+ self.URLString = "";
+ break;
+ }
+ };
+
+ this.xmlhttp.send(this.URLString);
+ }
+ }
+ };
+
+ this.reset();
+ this.createAJAX();
+}
+
+var ajax = new sack(); //VGR26042006 ADDed declaration here \ No newline at end of file
diff --git a/js/mapspecs.js b/js/mapspecs.js
new file mode 100644
index 0000000..fe58658
--- /dev/null
+++ b/js/mapspecs.js
@@ -0,0 +1,688 @@
+//
+// 1.0
+//
+//
+//
+
+window.onload = function(){
+ //document.getElementById('blocksdisplay').innerHTML = "<b>"+blocks+"</b>";
+ //doSend();
+ loadSol();
+}
+
+var solution = new Array();
+var blocks = new Array();
+var count = new Array();
+var mapdata = new Array();
+var mapjson = new Array();
+var htmlscores = '';
+
+function loadSol(sol) {
+ //alert("Temporary debug");
+ //document.getElementById('debug').innerHTML = "<br />Exe1...";
+ if (sol == null)
+ if (document.getElementById('mapsol') != undefined)
+ sol = document.getElementById('mapsol').innerHTML;
+
+ if (sol) {
+
+ tmp = sol.split(':');
+ position = tmp[1].split('.');
+ mapid = tmp[0];
+
+ clearwalls(mapid);
+
+ //document.getElementById('debug').innerHTML += "<br />"+mapid+','+position[1];
+ for(var i in position) {
+ //document.getElementById('debug').innerHTML += "<br />"+mapid+','+position[i];
+ if (document.getElementById(mapid+','+position[i]) != undefined) {
+ object = document.getElementById(mapid+','+position[i]);
+ grid_click(object);
+
+ }
+ //alert(soldata[i]);
+ }
+ }
+}
+
+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);
+ }
+ //alert(obj.cv);
+
+ if (obj.cv) {
+ obj.cv = false;
+
+ //obj.style.backgroundColor = '#ffffff';
+ obj.setAttribute("class", "grid_td");
+ //IE 7
+ obj.style.backgroundColor = '';
+ blocks[mapid]++;
+ //alert(obj.id);
+ //Remove wall
+ solution[mapid] = solution[mapid].replace('.'+y+','+x+'.', '.');
+ //alert(y+','+x+'.');
+ } else {
+ if (blocks[mapid] < 1) {
+ //alert("Outa blocks!");
+ updateDsp(mapid, 'dspWalls', "OUT!");
+ //document.getElementById(mapid+',dspWalls').innerHTML = "OUT!";
+ return;
+ }
+ obj.cv = true;
+ //obj.style.backgroundColor = '#ff0000';
+ obj.setAttribute("class", "grid_td_walls");
+ //IE 7:
+ obj.style.backgroundColor = '#666666';
+ //Add Wall
+ solution[mapid] += y+','+x+'.';
+ blocks[mapid]--;
+ }
+ //document.getElementById('blocksdisplay').innerHTML = "<b>"+blocks[mapid]+"</b>";
+
+ updateDsp(mapid, 'dspWalls', blocks[mapid]+" walls");
+ //document.getElementById(mapid+',dspWalls').innerHTML = " "+blocks[mapid]+" walls";
+
+}
+
+function updateDsp(mapid, element, data) {
+ if (mapdata[mapid] == undefined)
+ return;
+ if (mapdata[mapid].example != true) {
+ if (document.getElementById(mapid+','+element) != undefined) {
+ handle = document.getElementById(mapid+','+element);
+ handle.innerHTML = data;
+ }
+ }
+}
+
+function getmapdata(mapid) {
+ //alert(typeof(JSON));
+ if (typeof(JSON) == 'undefined') {
+ //alert("We're using EVAL instead");
+ text = document.getElementById(mapid+',mapdata').innerHTML;
+ mapdata[mapid] = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g, ''))) && eval('(' + text + ')');
+ //mapdata[mapid] = eval(document.getElementById(mapid+',mapdata').innerHTML);
+ } else {
+ //alert("We're using JSON");
+ mapdata[mapid] = JSON.parse(document.getElementById(mapid+',mapdata').innerHTML);
+ }
+
+ blocks[mapid] = mapdata[mapid].walls;
+ solution[mapid] = '.';
+
+ updateDsp(mapid, 'dspWalls', blocks[mapid]+" walls");
+
+ //document.getElementById(mapid+',dspWalls').innerHTML = " "+blocks[mapid]+" walls";
+ //document.getElementById(mapid+',dspWalls').innerHTML = blocks[mapid];
+}
+
+function doSend(mapid) {
+ if (solution[mapid] == undefined) {
+ getmapdata(mapid);
+ }
+
+ 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 requestSol(solid) {
+ //alert("requesting solution id:" + solid);
+ ajax.requestFile = "do.php?r=getsol&solutionid="+solid; //prepare strdata
+ ajax.onCompletion = requestSolDone; // Specify function to be executed on response.
+ ajax.runAJAX();// Do it!
+}
+
+function requestSolDone() {
+ //alert("request complete");
+
+ if (typeof(JSON) == 'undefined') {
+ //alert("We're using EVAL instead AGAIN.");
+ text = ajax.response;
+ var JO = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g, ''))) && eval('(' + text + ')');
+ //mapdata[mapid] = eval(document.getElementById(mapid+',mapdata').innerHTML);
+ } else {
+ //alert("We're using JSON again");
+ var JO = JSON.parse(ajax.response);
+ }
+
+ clearwalls(JO.mapid);
+ loadSol(JO.mapid + ":" + JO.solution);
+}
+
+function clearwalls(mapid) {
+ 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.style.backgroundColor = '';
+ obj.cv = false;
+ //alert("exe");
+ }
+ }
+ solution[mapid] = undefined;
+ getmapdata(mapid);
+}
+
+function resetwalls(mapid) {
+ answer = confirm("Remove walls and start fresh?");
+ if (answer) {
+ clearwalls(mapid);
+ }
+}
+
+function request_path_done() {
+ //document.getElementById('mapdisplay').innerHTML = ajax.response;
+ //alert ("resp: "+ajax.response);
+ //if (ajax.response == undefined) return;
+
+ if (typeof(JSON) == 'undefined') {
+ //alert("We're using EVAL instead AGAIN.");
+ text = ajax.response;
+ var JO = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g, ''))) && eval('(' + text + ')');
+ //mapdata[mapid] = eval(document.getElementById(mapid+',mapdata').innerHTML);
+ } else {
+ //alert("We're using JSON again");
+ var JO = JSON.parse(ajax.response);
+ }
+
+ mapjson[JO.mapid] = JO;
+
+ //alert ("resp: "+ajax.response);
+ // if (typeof(JSON) == undefined) {
+ // var JO = eval(ajax.response);
+ // } else {
+ // var JO = JSON.parse(ajax.response);
+ // }
+ if (JO.scores) {
+ updateDsp(JO.mapid, 'dspScore', JO.scores);
+ }
+
+ 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;
+ var disptext = "Record: "+JO.best+" by "+JO.bestby;
+
+ updateDsp(JO.mapid, 'dspID', disptext);
+ //document.getElementById(JO.mapid+',dspID').innerHTML = JO.best;
+
+ animatePath(JO.path, JO.mapid, JO.start);
+
+ //Get score update.
+ ajax.requestFile = "do.php?r=getscores&mapid="+JO.mapid; //prepare strdata
+ ajax.onCompletion = request_scores_done; // Specify function to be executed on response.
+ ajax.runAJAX();// Do it!
+}
+
+function animatePath(path, mapid, start) {
+ tmp = start.split(',');
+ y = tmp[0];
+ x = tmp[1];
+
+ p = path;
+ //alert("Begin");
+ //t = p.length;
+ t = '';
+ //count[mapid] = 0;
+ document.getElementById(mapid+',btn').disabled = true;
+ doanimate(x, y, p, t, mapid);
+ //setTimeout("doanimate("+x+","+y+",'"+p+"',"+t+")",500);
+}
+
+function animatePathDone(mapid) {
+ document.getElementById(mapid+',btn').disabled = false;
+ //alert("animate done..." + htmlscores);
+ if (htmlscores) {
+ //alert("showing scores...");
+ updateDsp(mapid, 'dspScore', htmlscores);
+ htmlscores = '';
+ }
+}
+
+function request_scores_done() {
+
+ //alert("score request complete");
+ //Get scores.
+ if (typeof(JSON) == 'undefined') {
+ //alert("We're using EVAL instead AGAIN.");
+ text = ajax.response;
+ var JO = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g, ''))) && eval('(' + text + ')');
+ //mapdata[mapid] = eval(document.getElementById(mapid+',mapdata').innerHTML);
+ } else {
+ //alert("We're using JSON again");
+ var JO = JSON.parse(ajax.response);
+ }
+ //alert("scores saveing " + JO.scores);
+ htmlscores = JO.scores;
+}
+
+
+function checkSound(mapid) {
+ if (document.getElementById(mapid+',mute').checked) {
+ return false;
+ }
+ if (typeof(soundManager) != 'object') {
+ return false;
+ }
+ return true;
+}
+
+var snake = new Array();
+var snakeeffected = new Array();
+function doanimate(x, y, p, c, mapid) {
+
+ //x, y position
+ //p path string being trunicated.
+ //c current target code.
+ //t next target code.
+ t = p.substring(0, 1);
+
+ //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';
+ }
+
+ //Display movecount
+ updateDsp(mapid, 'dspCount', count[mapid]+ " moves");
+ //document.getElementById(mapid+',dspCount').innerHTML = count[mapid]+ " moves";
+
+ //Get a handle on the element.
+ eid = mapid+','+x+','+y;
+ //Verify.
+ if (document.getElementById(eid) == undefined) {
+ alert("Path exited field..?");
+ animatePathDone(mapid);
+ 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' ) {
+ // 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;
+
+
+ //Animate.
+ switch(c) {
+ case '1': //1 - Up
+ case '2': //2 - Right
+ case '3': //3 - Down
+ case '4': //4 - Left
+ count[mapid]++;
+
+ switch(count[mapid]) {
+ case mapjson[mapid].best:
+ flashelement(mapid+',dspCount', 4, "#FF0000");
+ break;
+ case 500:
+ case 400:
+ case 350:
+ case 300:
+ case 250:
+ case 200:
+ case 150:
+ case 100:
+ case 50:
+ if (checkSound(mapid)) {
+ soundManager.play('charm');
+ }
+ //alert("count-hit: "+count[mapid]);
+ //Flash
+ flashelement(mapid+',dspCount', 4);
+ break;
+ }
+ //if (checkSound(mapid)) {
+ //soundManager.play('bling');
+ //soundManager.play('sc');
+ //soundManager.setVolume('click', 50);
+ //soundManager.play('click');
+ //soundManager.play('charm');
+ //soundManager.play('ufoblip');
+ //}
+ handle.setAttribute('class', 'grid_td_path'+c);
+ handle.className = 'grid_td_path'+c;
+ handle.style.backgroundColor = snake[mapid]['color'];
+
+ string = "if (document.getElementById('"+eid+"').className == 'grid_td_path"+c+"') ";
+ string += "document.getElementById('"+eid+"').className = '"+origclass+"';";
+ //alert (string);
+ setTimeout(string, 855);
+ //And incase that didn't work...
+ //setTimeout("document.getElementById('"+eid+"').className = '"+origclass+"'", 7500);
+ //setTimeout("document.getElementById('"+eid+"').setAttribute('class', '"+origclass+"')", 855);
+
+ if (handle.pressed == true) {
+ setTimeout("document.getElementById('"+eid+"').style.backgroundColor = '#dddddd';", 865);
+ } else {
+ //alert(eid);
+ setTimeout("document.getElementById('"+eid+"').style.backgroundColor = '';", 865);
+ }
+
+ break;
+ //Teleports
+ case 't':
+ //case 'u':
+ case 'm':
+ case 'g':
+ case 'i':
+ case 'k':
+ //case 'n':
+ // if (t == "u" || t == "n") {
+ //alert("teleport");
+ //if (checkSound(mapid)) {
+ //soundManager.play('bling');
+ //soundManager.play('sc');
+ //soundManager.play('ufoblip');
+ //soundManager.play('002');
+ //soundManager.play('003');
+ //soundManager.setVolume('click', 50);
+ //soundManager.play('click');
+ //soundManager.play('charm');
+ //}
+ //flashelement(eid, 4);
+
+ // } else {
+ // break;
+ // }
+ //Targets
+ case 'q': //Teleport out;
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+
+ //break
+ case 'r':
+ //handle.setAttribute('class', 'grid_td_pressed');
+ //handle.classOrigName = 'grid_td_pressed';
+ snakeeffected.push("document.getElementById('"+eid+"').style.backgroundColor = '';");
+ snakeeffected.push("document.getElementById('"+eid+"').pressed = false;");
+ handle.style.backgroundColor = '#dddddd';
+ setTimeout("document.getElementById('"+eid+"').style.backgroundColor = '#dddddd';", 865);
+ handle.pressed = true;
+
+ break;
+ }
+
+ //Sound effects
+ if (c == 'r') {
+ if (checkSound(mapid)) {
+ soundManager.play('bling');
+ //soundManager.play('blip');
+ //soundManager.play('charm');
+ }
+ }
+
+ //Done messing with current target
+ //Now take pre-action regarding the next tile.
+
+ //Speaking of the next tile - does it exist?
+ //End of the line?
+ if (t == '') {
+
+ //Did we beat or tie any records?
+ //Saw someone do this, thought it was clever.
+ //Switch for range result.
+ var disptext = ""
+ switch (true) {
+ case (count[mapid] > mapjson[mapid].best):
+ disptext = "Beat "+mapjson[mapid].bestby+"'s record of "+mapjson[mapid].best+" with "+count[mapid]+"!";
+ break;
+
+ case (count[mapid] == mapjson[mapid].best):
+ disptext = "Tied "+mapjson[mapid].bestby+"'s record of "+mapjson[mapid].best;
+ break;
+
+ case (count[mapid] > mapjson[mapid].mybest):
+ disptext = "Improved score "+mapjson[mapid].mybest+ " to "+count[mapid];
+ break;
+
+ case (count[mapid] == mapjson[mapid].mybest):
+ disptext = "Tied personal best of "+count[mapid];
+ break;
+
+ }
+ //if anything worth mentioning happend let them know.
+ if (disptext != "") {
+ if (checkSound(mapid)) {
+ soundManager.play('charm');
+ soundManager.play('bling');
+ soundManager.play('sc');
+ }
+ updateDsp(mapid, 'dspID', disptext);
+ flashelement(mapid+',dspID', 8, "#FF3377");
+ }
+
+ //This is the end, lets reset stuff to defaults.
+ count[mapid] = 0;
+ snake[mapid]['color'] = '#4444bb';
+ //Bring the color back to our checkpoints/teleports.
+ for(var i in snakeeffected) {
+ //eval(snakeeffected[i]);
+ setTimeout((snakeeffected[i]), 2000);
+ }
+ //Clear
+ snakeeffected = new Array();
+ //We're done,
+ animatePathDone(mapid);
+ return;
+ }
+
+
+ //The next tile exists, how fast should we get there?
+ rs = 85;
+ //How fast should we be going?
+ selectbox = document.getElementById(mapid+',speed');
+ selected = selectbox.options[selectbox.selectedIndex].value;
+ switch (selected) {
+ case '1':
+ rs =310;
+ break;
+
+ case '2':
+ rs =85;
+ break;
+
+ case '3':
+ rs =45;
+ break;
+
+ case '4':
+ rs =23;
+ break;
+
+ }
+
+
+ //The next path code.
+ switch(t) {
+ //Are we just moving someplace?
+ 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 within the path.
+ //Did we aquire a target?
+ //Checkpoint targets:
+ case 'a':
+ // rs = rs * 9;
+ snake[mapid]['color'] = '#F777FF';
+ break;
+ case 'b':
+ rs = rs + 500;
+ snake[mapid]['color'] = '#FFFF11';
+ //handle.style.backgroundColor = "#000000";
+ break;
+ case 'c':
+ rs = rs + 500;
+ snake[mapid]['color'] = '#FF4466';
+ break;
+ case 'd':
+ rs = rs + 500;
+ snake[mapid]['color'] = '#ff9911';
+ break;
+ case 'e':
+ rs = rs + 500;
+ snake[mapid]['color'] = '#00FFFF';
+ break;
+ //Finish target
+ case 'f':
+ rs = rs + 500;
+ snake[mapid]['color'] = '#4444bb';
+ break;
+
+ //Hey, we've ran into a teleport.
+ case 'u': //tp1
+ case 'n': //tp2
+ case 'h': //tp3
+ case 'j': //tp4
+ case 'l': //tp5
+ //Get teleport coords
+ tmp = p.split(t);
+ loc = tmp[1].split(',');
+ y = loc[0];
+ x = loc[1];
+
+ //Flash teleport-out
+ //Teleport Element ID
+ tpEid = mapid+','+x+','+y;
+ if (checkSound(mapid)) {
+ soundManager.play('ufoblip');
+ //soundManager.play('002');
+ //soundManager.play('003');
+ }
+ //alert(tpEid);
+ document.getElementById(eid).style.backgroundColor='#CCCCCC';
+ document.getElementById(tpEid).style.backgroundColor='#CCCCCC';
+ //flashelement(eid, 7);
+ flashelement(tpEid, 8, snake[mapid]['color']);
+
+
+ //The path once teleported - and an r to indicate to gray the teleport-out too.
+ p = 'q'+tmp[2];
+ //Slow down
+ rs = rs + 1500;
+ setTimeout("doanimate("+x+","+y+",'"+p+"','"+t+"',"+mapid+")",rs);
+ return;
+ break;
+ }
+ //Remove move from p
+ p = p.substring(1);
+ //rs = (10 * p.length) + 40;
+
+ setTimeout("doanimate("+x+","+y+",'"+p+"','"+t+"','"+mapid+"')",rs);
+}
+
+function flashelement(eid, times, color) {
+ //alert("exe"+eid);
+ if (document.getElementById(eid) == undefined) return;
+ if (!color) {
+ color = "#FFFF44";
+ }
+ //document.getElementById(eid).setAttribute('class', 'no_transition');
+ var currentclass = document.getElementById(eid).className;
+ if (document.getElementById(eid).classOrigName != undefined)
+ currentclass = document.getElementById(eid).classOrigName;
+ var currentColor = document.getElementById(eid).style.backgroundColor;
+ document.getElementById(eid).className='no_transition '+currentclass;
+ document.getElementById(eid).style.backgroundColor = '#000000';
+ for (var i=0; i<times; i++) {
+ //Flash bright
+ setTimeout("document.getElementById('"+eid+"').style.color = '#000000'", i*220);
+ setTimeout("document.getElementById('"+eid+"').style.backgroundColor = '"+color+"'", i*220);
+ // setTimeout("document.getElementById('"+mapid+",dspCount').style.fontWeight = 'bold'", i*200);
+ //Flash out
+ setTimeout("document.getElementById('"+eid+"').style.color = ''", (i*220) + 100);
+ setTimeout("document.getElementById('"+eid+"').style.backgroundColor = ''", (i*220) + 100);
+ // setTimeout("document.getElementById('"+mapid+",dspCount').style.fontWeight = ''", i*200);
+ }
+
+ //setTimeout("document.getElementById('"+eid+"').className = '"+currentclass+"'", (i*220) + 200);
+ setTimeout("document.getElementById('"+eid+"').style.backgroundColor = '"+currentColor+"'", (i*220) + 200);
+ //document.getElementById(eid).className=currentclass;
+ //document.getElementById(eid).style.backgroundColor=currentColor;
+}
+
+
+
+function savePref(pref, value) {
+ setCookie('pref_'+pref, value,31);
+}
+
+//Cookie function from w3schools.com
+function setCookie(c_name,value,exdays)
+{
+ var exdate=new Date();
+ exdate.setDate(exdate.getDate() + exdays);
+ var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
+ document.cookie=c_name + "=" + c_value;
+}
+
+
+
+
+//== Outdated functions
+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);
+}
+//== End
+
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
diff --git a/sound-config.xml b/sound-config.xml
new file mode 100644
index 0000000..9549d9a
--- /dev/null
+++ b/sound-config.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- SoundManager Flash configuration -->
+<!-- Sound IDs are referenced from JS -->
+
+<items baseHref="sounds/" defaultVol="100">
+
+ <sound id="ufoblip" href="ufoblip.mp3" />
+ <sound id="003" href="cosmic003.mp3" />
+ <sound id="002" href="cosmic002.mp3" />
+ <sound id="bling" href="bling.mp3" />
+ <sound id="charm" href="charm.mp3" />
+ <sound id="blip" href="blip.mp3" />
+ <sound id="cap" href="cap.mp3" />
+ <sound id="click" href="click.mp3" />
+ <sound id="sc" href="transmission.mp3" />
+ <sound id="hologram" href="hologram.mp3" />
+
+
+</items> \ No newline at end of file
diff --git a/soundcontroller.swf b/soundcontroller.swf
new file mode 100644
index 0000000..4af6a54
--- /dev/null
+++ b/soundcontroller.swf
Binary files differ
diff --git a/sounds/beep.mp3 b/sounds/beep.mp3
new file mode 100644
index 0000000..54b8fba
--- /dev/null
+++ b/sounds/beep.mp3
Binary files differ
diff --git a/sounds/bling.mp3 b/sounds/bling.mp3
new file mode 100644
index 0000000..1aec9d2
--- /dev/null
+++ b/sounds/bling.mp3
Binary files differ
diff --git a/sounds/blip.mp3 b/sounds/blip.mp3
new file mode 100644
index 0000000..20355bc
--- /dev/null
+++ b/sounds/blip.mp3
Binary files differ
diff --git a/sounds/cap.mp3 b/sounds/cap.mp3
new file mode 100644
index 0000000..10c6590
--- /dev/null
+++ b/sounds/cap.mp3
Binary files differ
diff --git a/sounds/charm.mp3 b/sounds/charm.mp3
new file mode 100644
index 0000000..951c8d1
--- /dev/null
+++ b/sounds/charm.mp3
Binary files differ
diff --git a/sounds/click.mp3 b/sounds/click.mp3
new file mode 100644
index 0000000..01f73b9
--- /dev/null
+++ b/sounds/click.mp3
Binary files differ
diff --git a/sounds/cosmic002.mp3 b/sounds/cosmic002.mp3
new file mode 100644
index 0000000..9233dae
--- /dev/null
+++ b/sounds/cosmic002.mp3
Binary files differ
diff --git a/sounds/cosmic003.mp3 b/sounds/cosmic003.mp3
new file mode 100644
index 0000000..83d9774
--- /dev/null
+++ b/sounds/cosmic003.mp3
Binary files differ
diff --git a/sounds/hologram.mp3 b/sounds/hologram.mp3
new file mode 100644
index 0000000..0f265ee
--- /dev/null
+++ b/sounds/hologram.mp3
Binary files differ
diff --git a/sounds/page.mp3 b/sounds/page.mp3
new file mode 100644
index 0000000..e25c51d
--- /dev/null
+++ b/sounds/page.mp3
Binary files differ
diff --git a/sounds/script/demo.js b/sounds/script/demo.js
new file mode 100644
index 0000000..40153e4
--- /dev/null
+++ b/sounds/script/demo.js
@@ -0,0 +1,11 @@
+// Page-specific demo stuff - not needed for library
+
+function stressTest(sound,count) {
+ for (var i=0; i<count; i++) {
+ setTimeout("soundManager.play('"+sound+"',1,true)",(i+1)*50);
+ }
+}
+
+function ihatespam(s) {
+ return s.replace('improbablyaspammer','scott');
+} \ No newline at end of file
diff --git a/sounds/script/soundmanager.js b/sounds/script/soundmanager.js
new file mode 100644
index 0000000..f886c45
--- /dev/null
+++ b/sounds/script/soundmanager.js
@@ -0,0 +1,182 @@
+
+var isIE = navigator.appName.toLowerCase().indexOf('internet explorer')+1;
+var isMac = navigator.appVersion.toLowerCase().indexOf('mac')+1;
+
+function SoundManager(container) {
+ // DHTML-controlled sound via Flash
+ var self = this;
+ this.movies = []; // movie references
+ this.container = container;
+ this.unsupported = 0; // assumed to be supported
+ this.defaultName = 'default'; // default movie
+
+ this.FlashObject = function(url) {
+ var me = this;
+ this.o = null;
+ this.loaded = false;
+ this.isLoaded = function() {
+ if (me.loaded) return true;
+ if (!me.o) return false;
+ me.loaded = ((typeof(me.o.readyState)!='undefined' && me.o.readyState == 4) || (typeof(me.o.PercentLoaded)!='undefined' && me.o.PercentLoaded() == 100));
+ return me.loaded;
+ }
+ this.mC = document.createElement('div');
+ this.mC.className = 'movieContainer';
+ with (this.mC.style) {
+ // "hide" flash movie
+ position = 'absolute';
+ left = '-256px';
+ width = '64px';
+ height = '64px';
+ }
+ var html = ['<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"><param name="movie" value="'+url+'"><param name="quality" value="high"></object>','<embed src="'+url+'" width="1" height="1" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>'];
+ if (navigator.appName.toLowerCase().indexOf('microsoft')+1) {
+ this.mC.innerHTML = html[0];
+ this.o = this.mC.getElementsByTagName('object')[0];
+ } else {
+ this.mC.innerHTML = html[1];
+ this.o = this.mC.getElementsByTagName('embed')[0];
+ }
+ document.getElementsByTagName('div')[0].appendChild(this.mC);
+ }
+
+ this.addMovie = function(movieName,url) {
+ self.movies[movieName] = new self.FlashObject(url);
+ }
+
+ this.checkMovie = function(movieName) {
+ movieName = movieName||self.defaultName;
+ if (!self.movies[movieName]) {
+ self.errorHandler('checkMovie','Exception: Could not find movie',arguments);
+ return false;
+ } else {
+ return (self.movies[movieName].isLoaded())?self.movies[movieName]:false;
+ }
+ }
+
+ this.errorHandler = function(methodName,message,oArguments,e) {
+ writeDebug('<div class="error">soundManager.'+methodName+'('+self.getArgs(oArguments)+'): '+message+(e?' ('+e.name+' - '+(e.message||e.description||'no description'):'')+'.'+(e?')':'')+'</div>');
+ }
+
+ this.play = function(soundID,loopCount,noDebug,movieName) {
+ if (self.unsupported) return false;
+ movie = self.checkMovie(movieName);
+ if (!movie) return false;
+ if (typeof(movie.o.TCallLabel)!='undefined') {
+ try {
+ self.setVariable(soundID,'loopCount',loopCount||1,movie);
+ movie.o.TCallLabel('/'+soundID,'start');
+ if (!noDebug) writeDebug('soundManager.play('+self.getArgs(arguments)+')');
+ } catch(e) {
+ self.errorHandler('play','Failed: Flash unsupported / undefined sound ID (check XML)',arguments,e);
+ }
+ }
+ }
+
+ this.stop = function(soundID,movieName) {
+ if (self.unsupported) return false;
+ movie = self.checkMovie(movieName);
+ if (!movie) return false;
+ try {
+ movie.o.TCallLabel('/'+soundID,'stop');
+ writeDebug('soundManager.stop('+self.getArgs(arguments)+')');
+ } catch(e) {
+ // Something blew up. Not supported?
+ self.errorHandler('stop','Failed: Flash unsupported / undefined sound ID (check XML)',arguments,e);
+ }
+ }
+
+ this.getArgs = function(params) {
+ var x = params?params.length:0;
+ if (!x) return '';
+ var result = '';
+ for (var i=0; i<x; i++) {
+ result += (i&&i<x?', ':'')+(params[i].toString().toLowerCase().indexOf('object')+1?typeof(params[i]):params[i]);
+ }
+ return result
+ }
+
+ this.setVariable = function(soundID,property,value,oMovie) {
+ // set Flash variables within a specific movie clip
+ if (!oMovie) return false;
+ try {
+ oMovie.o.SetVariable('/'+soundID+':'+property,value);
+ // writeDebug('soundManager.setVariable('+self.getArgs(arguments)+')');
+ } catch(e) {
+ // d'oh
+ self.errorHandler('setVariable','Failed',arguments,e);
+ }
+ }
+
+ this.setVariableExec = function(soundID,fromMethodName,oMovie) {
+ try {
+ oMovie.o.TCallLabel('/'+soundID,'setVariable');
+ } catch(e) {
+ self.errorHandler(fromMethodName||'undefined','Failed',arguments,e);
+ }
+ }
+
+ this.callMethodExec = function(soundID,fromMethodName,oMovie) {
+ try {
+ oMovie.o.TCallLabel('/'+soundID,'callMethod');
+ } catch(e) {
+ // Something blew up. Not supported?
+ self.errorHandler(fromMethodName||'undefined','Failed',arguments,e);
+ }
+ }
+
+ this.callMethod = function(soundID,methodName,methodParam,movieName) {
+ movie = self.checkMovie(movieName||self.defaultName);
+ if (!movie) return false;
+ self.setVariable(soundID,'jsProperty',methodName,movie);
+ self.setVariable(soundID,'jsPropertyValue',methodParam,movie);
+ self.callMethodExec(soundID,methodName,movie);
+ }
+
+ this.setPan = function(soundID,pan,movieName) {
+ self.callMethod(soundID,'setPan',pan,movieName);
+ }
+
+ this.setVolume = function(soundID,volume,movieName) {
+ self.callMethod(soundID,'setVolume',volume,movieName);
+ }
+
+ // constructor - create flash objects
+
+ if (isIE && isMac) {
+ this.unsupported = 1;
+ }
+
+ if (!this.unsupported) {
+ this.addMovie(this.defaultName,'soundcontroller.swf');
+ // this.addMovie('rc','rubber-chicken-audio.swf');
+ }
+
+}
+
+function SoundManagerNull() {
+ // Null object for unsupported case
+ this.movies = []; // movie references
+ this.container = null;
+ this.unsupported = 1;
+ this.FlashObject = function(url) {}
+ this.addMovie = function(name,url) {}
+ this.play = function(movieName,soundID) {
+ return false;
+ }
+ this.defaultName = 'default';
+}
+
+function writeDebug(msg) {
+ var o = document.getElementById('debugContainer');
+ if (!o) return false;
+ var d = document.createElement('div');
+ d.innerHTML = msg;
+ o.appendChild(d);
+}
+
+var soundManager = null;
+
+function soundManagerInit() {
+ soundManager = new SoundManager();
+} \ No newline at end of file
diff --git a/sounds/select.mp3 b/sounds/select.mp3
new file mode 100644
index 0000000..ed10543
--- /dev/null
+++ b/sounds/select.mp3
Binary files differ
diff --git a/sounds/transmission.mp3 b/sounds/transmission.mp3
new file mode 100644
index 0000000..56800a0
--- /dev/null
+++ b/sounds/transmission.mp3
Binary files differ
diff --git a/sounds/ufoblip.mp3 b/sounds/ufoblip.mp3
new file mode 100644
index 0000000..ef9b820
--- /dev/null
+++ b/sounds/ufoblip.mp3
Binary files differ