From f8c9eb5220afaf2f9a62f9a176a45913240f4081 Mon Sep 17 00:00:00 2001 From: raylu Date: Thu, 7 Apr 2011 00:27:27 -0400 Subject: Initial import from Dropbox --- pages/.htaccess | 1 + pages/about.php | 32 ++++ pages/admin.php | 233 ++++++++++++++++++++++++++++ pages/cp.php | 69 +++++++++ pages/faq.php | 43 ++++++ pages/gallery.php | 113 ++++++++++++++ pages/home.php | 167 +++++++++++++++++++++ pages/howtoplay.php | 102 +++++++++++++ pages/leaderboard.php | 236 +++++++++++++++++++++++++++++ pages/login.php | 117 +++++++++++++++ pages/memberlist.php | 91 +++++++++++ pages/test.php | 408 ++++++++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 1612 insertions(+) create mode 100644 pages/.htaccess create mode 100644 pages/about.php create mode 100644 pages/admin.php create mode 100644 pages/cp.php create mode 100644 pages/faq.php create mode 100644 pages/gallery.php create mode 100644 pages/home.php create mode 100644 pages/howtoplay.php create mode 100644 pages/leaderboard.php create mode 100644 pages/login.php create mode 100644 pages/memberlist.php create mode 100644 pages/test.php (limited to 'pages') 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 @@ + + + +"; +echo "
"; + +?> + +
+
Email us: snapems@gmail.com +
+

Created by:

Patrick Davison and Rex Ounekeo. +
+

Special thanks:

+

Programmers:

+
raylu +

Testers:

+Steven Gosling +
Patrick's Family +
Josh +
Rory Matthias Quentin Maison +
Matt +
+
+ + + 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 @@ + + + + 0) { + list($bestMoves, $byName, $solution) = mysql_fetch_row($result); + echo "
Best solution for this map: $bestMoves by $byName"; + + //$map = MergeMapSolution($motd['map'], $solution); + $map = MergeMapSolution($map, $solution); + echo DisplayMap($map, $mapID); + + echo "
"; + echo "
Is Current:"; + $is = isCurrentMap(77); + echo "
$is"; + $is = isCurrentMap(20); + echo "
$is"; + $is = isCurrentMap(76); + echo "
$is"; + $is = isCurrentMap(75); + echo "
$is"; + $is = isCurrentMap(74); + echo "
$is"; + echo "
"; + +} + +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 "
"; +echo "
"; +echo "
Solution before"; +echo "
"; +echo $solution; +echo "
"; +echo "
Solution after"; +echo "
"; +$solution = formSolution($solution); +echo $solution; +echo "
"; +echo "
"; +echo "
"; +// echo "
The map for today: +//
Once logged in your best solutions for the map(s) are saved. +//
- Soon i'll fix it so you can see those solutions, and compare them with others. +//
- New maps are generated daily, at 9:00 PM Pacific Standard. (for now...) +//
"; +// 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 .= ""; + for( $j = 0; $j < count($mapMatrix[$i]); $j++) + { + //== + $index++; + + $handle = "$idprefix,$i,$j"; + switch($mapMatrix[$i][$j]) + { + case 's': $maptable .= ""; break; + case 'f': $maptable .= ""; break; + case 't': $maptable .= ""; break; + //case 't': $maptable .= ""; break; + case 'u': $maptable .= ""; break; + case 'm': $maptable .= ""; break; + case 'n': $maptable .= ""; break; + + case 'a': $maptable .= ""; break; + case 'b': $maptable .= ""; break; + case 'c': $maptable .= ""; break; + case 'd': $maptable .= ""; break; + case 'e': $maptable .= ""; break; + + case 'r': $maptable .= ""; break; //rock + case 'w': $maptable .= ""; break; //wall + //default: $maptable .= "".$index.""; + default: $maptable .= ""; + //default: $maptable .= "".$mapMatrix[$i][$j].""; + } + } + $maptable .= ""; + } + //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 .= "'; + + $maptable = " + $maptable +
"; + + if ($example) { + $output = $maptable; + $output .= ""; + $output .= " +
+ + + + +
+ "; + $output .= $mapdatadiv; + $output = "
+ $output +
"; + return $output; + } + + $output = " +
+ +
+
+ MapID: $idprefix +
+
+ +
+ Reset +
+ + +
+
+ ".$mapdata['walls']." walls +
+
+ + $maptable + +
+ + + + + +
+ +
+ +
+ +
+
+ ".$path['moves']." moves +
+
+ + $mapdatadiv +
+ "; + + return $output; +} + + + + +?> + + 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 @@ + + + + + 16) + return false; + return true; +} + +echo "
"; +echo "
"; +$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 "
Name change success (Your name may take a moment to be updated)
"; + } else { + echo "
Invalid name"; + } + } +} + +$displayName = $_SESSION['displayName']; + +?> +
+
+

Change your display name

+
+ +
+"; +?> + + +
+ + + + + + + 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 @@ + + + + + + +

Questions and Answers

+ +
+

Can you explain how the pathing works?

+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: + UP, RIGHT, DOWN, LEFT. +This means that the path will go UP as far as it can first- then, right, down, left. +
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. +
If the path is going to the BOTTOM LEFT, from the TOP RIGHT, the path will go all the way DOWN and then LEFT. +
TOP LEFT, from BOTTOM RIGHT, UP, then LEFT. +
So, BOTTOM LEFT, from TOP RIGHT? If you answer "DOWN then LEFT" you are correct! +
If you answered "uhhmm.. What's up with the directions in caps." then you get a bonus point! +
Remember, teleports are Traps, and does not effect the path choice. +
+
+

Why use Google to sign in?

+'OpenID' allows websites to use 3rd party servers to identify you. +
We ask Google for your E-mail address, which you have to approve. +
Basically, we send you to Google, and ask who you are, (You're not a robot, right?) +
Google responds saying they know you, and gives me a code to identify you with, if you login again. +
Many sites have started adopting this method of registration/login due to the safety it provides, +not just for me, but for YOU. +
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. + + + + + + + \ 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 @@ + + + +"; +echo "
"; +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 "
$mapdisplay"; +echo "
$code"; +print_r ($map); + +echo "
"; +echo "
"; +echo "
"; +echo weight(1,2,3,4,5,6); +echo "
"; +echo weight(1,2,3,4,5,6); +echo "
"; +echo weight(1,2,3,4,5,6); +echo "
"; +echo weight(1,2,3,4,5,6); +echo "
"; +echo weight(1,2,3,4,5,6); +echo "
"; +echo weight(1,2,3,4,5,6); + + + + + +?> + + 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 @@ + + + + + +\n$topscores\n"; +$mergesolution = $map; + +//Like button + //
I made a like button! I'm not sure what happens if you press it. + // + //
Let me know if it makes your computer explode or something. + + +?> +
+ +
+ I'm testing letting the path go over the START and FINISH tiles. +
Have an opinion about this? Let me know! +

+ New maps are generated daily at 9:00 PM Pacific Time. +
Maps for : +
Simple +
Normal +
Complex +
Today's Special +

+ + +
+ +
+ + New? Check out How to Play +
+ The object of the game is to make the longest maze. +
Sign in using Google to have your best solution saved. + "; + + +//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 "
$date
Simple | "; +echo "Normal | "; +echo "Complex | "; +$today = date('l'); +//if ($today == 'Sunday' OR $today == 'Saturday') + //$today = 'Weekend Map'; +//else + $today .= "'s"; +echo " NEW: $today $mapstyle"; + + +echo DisplayMap($mergesolution, $mapID); + +$mysolution = getSolution($userID, $mapID); +$solutiondiv .= " + + + + + + 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 @@ + + + +"; +//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); + +?> + +

Tutorial

+

+
The object of the game is to make the longest maze. +
The "Snake" (name pending) must go to all the checkpoints. +
It starts from the red arrows: +
+and goes to the blue arrows: +
+
Build a maze by clicking to place blocks. You can remove a block by clicking it again. +
It must be able to make it through your maze, so no walling completely! +
Try it: +

+ +
+

+

Checkpoints:

+ + + + + + + + +
+

+The path must reach all these (if they exist) before going to finish. Try it: + +

+ +
+
+
+
Tip: - Try to combine odd-letters with each other; +
I.E. If A, B, C exist, try to make a box around A and C, then maze the entrance to the box. +
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! +

+

Teleports:

+ + + + + + + + + + + +
Teleport 1:
Teleport 2:
+

+
Teleport tiles are traps. When the path goes across the "IN" tile, it gets thrown to the "OUT" tile. +
The path will not avoid teleports. Check this example out: +

+ +
+
+
+Implementing a teleport into your maze can have a big impact. +

+ +

That should be enough information to get you started. +
Now go try it out! +

+
+
+
+ + + 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 @@ + + + + +
'; + + +$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); +} + + + +?> +
+Overall | +Simple | +Normal | +Complex | +Special | +Week/Month +
+
+ +
+
+ +
+
+ +
+
+ + + 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 '
'; + echo "
"; + echo '
'; + echo $stats; + echo '
'; + + echo '
'; + echo "Best solution for this map: $bestMoves by $byName "; + echo DisplayMap($map, $mapID, true, 2); + echo '
'; + echo '
'; +} + +function displaystats($result, $caption = NULL) { + //Get names. + $headers .= "Rank"; + $headers .= "Name"; + $headers .= "Moves"; + $headers .= "Time taken"; + //Start table + $r .= ""; + $r .= ""; + //Headers on the top. including Rank. + $r .= ""; + $r .= $headers; + $r .= ""; + + $i = 1; + while ($row = mysql_fetch_assoc($result)) { + $rowcontent = ''; + $mapid = $row['mapID']; + $solution = $row['solution']; + + $r .= ""; + $r .= ""; + $r .= ''; + $r .= ''; + $r .= ''; + $r .= ""; + $i++; + } + $r .= "
$caption
$i' . $row['Name'] . '' . $row['Moves'] . '' . $row['Timetaken'] . '
"; + 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'); + +?> + +
+
+
+ +
+
+ +
+
+ + + 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 @@ +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

"; + If ($result) { + $userID = mysql_insert_id(); + } //Oh crap? + else { + //echo "monkeys and etc"; + DoRedirect("
new-user db register failure of unknown cause.\n +
Also, there were no monkeys trained or otherwise sent to resolve this problem.\n +
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 @@ + + + + + + + + + +"; + +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 " + + + + +"; + +} + +Echo " +
IDDisplay name:Joined On:Last Logon
$CUID$CUsername$Joined$LastLogon
+
+
+ + + +"; + + +//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 @@ + + + + + + + Maze TowerD + + + +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); + + +?> + + + + + + + +BP1:".$p['path']."
"; +//echo "
yx2:".$p['end']."
"; + +//$p = Findpath ($mygrid, explode(",", $p['end']), 'b'); +//echo "
BP:".$p['path']."
"; +//echo "
yx:".$p['end']."
"; +// $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 "
Attempt Solution laaaaaaaaaaaaa laaaaaaaaaaaa CLick on this.."; +echo "
b
"; +echo "
"; +var_dump ($p); + + +echo "
"; + + // $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
"; + // $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 "
500 paths executed in: $totaltime s"; + + //Starting result: + //500 paths executed in: 5.24884 s + //On a $mygrid = GenerateMap(13, 8, 4, 3); board. + //Now 1. +echo "Mapcode: $code"; +?> +
b
+ +
+
+
+
+
+
+ + \ No newline at end of file -- cgit v1.2.3