summaryrefslogtreecommitdiffstats
path: root/pages/admin.php
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 /pages/admin.php
downloadpathery-f8c9eb5220afaf2f9a62f9a176a45913240f4081.tar.xz
Initial import from Dropbox
Diffstat (limited to 'pages/admin.php')
-rw-r--r--pages/admin.php233
1 files changed, 233 insertions, 0 deletions
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>