summaryrefslogtreecommitdiffstats
path: root/includes
diff options
context:
space:
mode:
authorraylu <raylu@mixpanel.com>2011-11-05 03:04:49 -0700
committerraylu <raylu@mixpanel.com>2011-11-05 03:04:49 -0700
commitcf4af138b16da878404cf3319d5d988dacee198a (patch)
tree41187e9c8206657f9f5138de70c5e5a6f447a251 /includes
parent264ed976da6b3012209386a76520327faeddf82e (diff)
downloadpathery-cf4af138b16da878404cf3319d5d988dacee198a.tar.xz
new layout
Diffstat (limited to 'includes')
-rw-r--r--includes/datas.php53
-rw-r--r--includes/db.inc.php11
-rw-r--r--includes/header.php62
-rw-r--r--includes/maps.php2
4 files changed, 91 insertions, 37 deletions
diff --git a/includes/datas.php b/includes/datas.php
index 0d3d0c5..912eea8 100644
--- a/includes/datas.php
+++ b/includes/datas.php
@@ -1 +1,52 @@
-<?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
+<?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 class='score'>";
+ $output .= "<tr>";
+ $output .= "<th>Rank</th>";
+ $output .= "<th>Name</th>";
+ $output .= "<th>Moves</th>";
+ $output .= "<th>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: #356;'>";
+ 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;
+}
+
+?>
diff --git a/includes/db.inc.php b/includes/db.inc.php
index 9287ed2..198cf40 100644
--- a/includes/db.inc.php
+++ b/includes/db.inc.php
@@ -1,12 +1,11 @@
<?php
-
global $mysqlid;
-$db_host = "db2894.perfora.net";
-$db_user = "dbo362854667";
-$db_name = "db362854667";
-$db_pass = "mazes4me";
+$db_host = 'localhost';
+$db_user = 'pathery';
+$db_name = 'pathery';
+$db_pass = 'pathery';
$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
index b402025..1e24e8c 100644
--- a/includes/header.php
+++ b/includes/header.php
@@ -1,6 +1,6 @@
<?PHP
-function htmlHeader() {
+function htmlHeader($css) {
?>
<!DOCTYPE html>
<html xml:lang="en" lang="en">
@@ -8,13 +8,22 @@ function htmlHeader() {
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>pathery.com</title>
- <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" />
- <script src="js/ajax.js" type="text/javascript"></script>
- <script src="js/mapspecs.js" type="text/javascript"></script>
+ <link href="css/page.css" rel="stylesheet" type="text/css" />
+ <link href="css/maps.css" rel="stylesheet" type="text/css" />
+ <?php
+ foreach ($css as $c) {
+ echo "<link href=\"css/$c.css\" rel=\"stylesheet\" type=\"text/css\" />";
+ }
+ ?>
+ <script src="js/ajax.js" async="async"></script>
+ <script src="js/mapspecs.js" async="async"></script>
+</head>
+<?
+}
- <script type="text/javascript">
+function htmlFooter() {
+?>
+ <script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-371072-3']);
_gaq.push(['_trackPageview']);
@@ -28,45 +37,40 @@ function htmlHeader() {
fo.rel = 'stylesheet';
fo.type = 'text/css';
fo.href = "http://fonts.googleapis.com/css?family=Cantarell:400,700";
- var l = document.getElementsByTagName('link')[0]; l.parentNode.insertBefore(fo, l);
+ var l = document.getElementsByTagName('link')[0]; l.parentNode.appendChild(fo);
+ document.getElementsByTagName('body')[0].style.fontFamily = 'cantarell, helvetica, sans-serif';
})();
- </script>
-</head>
-<?
-}
-
-function htmlfooter() {
+ </script>
+</body>
+</html>
+<?
}
function topbar($links) {
- echo '<div class="topbar">';
+ echo '<div id="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>";
+ $selected = " selected";
+ else
+ $selected = "";
+ echo "<a href='?page=$key' class='nav$selected'>$value</a>";
}
- echo "\t<div class='lfloat'>";
+ echo "<div id='user'>";
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>";
+ echo "Logged in as <a href='?page=cp' title='change name'>$_SESSION[displayName]</a><br>";
if ($_SESSION['displayName'] == 'noname')
- echo "<a href='?page=cp' title='change name'>Update your name</a>";
+ echo "<a href='?page=cp' title='change name'>Update your name</a> | ";
+ echo "<a href='?page=logout'>Logout</a>";
} else
- echo "<a href='?page=login'>Sign in using Google</a>";
+ echo "<a href='?page=login'>Sign in with Google</a>";
+ echo "</div>";
- echo "\t</div>";
echo "</div>";
}
diff --git a/includes/maps.php b/includes/maps.php
index a1bbc95..901a946 100644
--- a/includes/maps.php
+++ b/includes/maps.php
@@ -146,7 +146,7 @@ function DisplayMap($mapMatrix, $idprefix = 1, $style = 'normal', $speed = NULL)
$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 />
+ <input type='checkbox' id='$idprefix,mute' checked='checked' />
<select id='$idprefix,speed'>
$rOption
</select>