summaryrefslogtreecommitdiffstats
path: root/pages/home.php
blob: cc4aca930623febb435d891a1817e69c18349c98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<?php
htmlHeader(array('stats'), 'Pathery');

include_once ('./includes/maps.php');
include_once ('./includes/mapoftheday.php');
include_once ('./includes/db.inc.php');
include_once ('./includes/datas.php');

//Get custom wall colors;
$wallColor = '';
$wallEmblem = '';
if ($_SESSION[accepted] == 1) {
	$userID = $_SESSION['userID'];

	$sql = "
	SELECT 
		userData.wallColor,
		userData.wallEmblem
	FROM `userData` 
	WHERE userID = '$userID' ";
	$result = mysql_query($sql);
	if ($result)
		list($wallColor, $wallEmblem) = mysql_fetch_row($result);
		
	$note = getNotified($userID);
	if ($note !== false) {
		//$note = str_replace("'", "\'", $note);
		//Double your slashes double your fun (Required)
		$note = addslashes($note);
		$note = addslashes($note);
		$noteScript = "
<script type='text/javascript'>
setTimeout(\"showNotification('".$note."');\", 1000);
if (getCookie('pref_mute') != 'true') {
	setTimeout(\"soundManager.setVolume('achieve', 40);\", 1340);
	setTimeout(\"soundManager.play('achieve');\", 1350);
}
</script>
		";
	}
}


function tutorialComplete($userID) {
	$sql = "SELECT * FROM `achievements` 
	WHERE `type` = 32 AND `userID` = '$userID'";
	$result = mysql_query($sql);
	if (mysql_num_rows($result) >= 1)
		return true;
	else
		return false;
}


?>

<body>
<script type="text/javascript">
playerWallColor = '<?PHP echo $wallColor; ?>';
playerWallEmblem = '<?PHP echo $wallEmblem; ?>';
</script>

<?php
topbar($Links);


?>

<div class="wrapper">
<strong>Update in progress</strong>
<p><strong>M</strong>any improvements including Achievements are being added!
<br />During this testing phase, some achievements and unlocks may be removed or re-added for you.
<br />Thank your for your patience! - Also please <a href='about'>email me or contact me</a> if you have suggestions or feedback.
</p>

	<?
	if ($_SESSION['accepted'] == 1) {
		if (tutorialComplete($userID) == false) {
			echo "<center><a href='tutorial'>Complete the tutorial</a> to unlock a blue wall color:";
			echo "<table><tr><td style='background-color:#4444ff;' class='grid_td_rocks'></td></tr></table></center><br />";
		}
	}
	?>

	<div id="difficulties">
		<a href="javascript:showStats(1)" id="dl-1">Simple</a>
		<a href="javascript:showStats(2)" id="dl-2">Normal</a>
		<a href="javascript:showStats(3)" id="dl-3">Complex</a>
		<a href="javascript:showStats(4)" id="dl-4">Special</a>
	</div>
	<div style="clear: both"></div>

	<noscript>Sorry, this game requires scripts to run. Please enable javascript and <a href='home'>Reload this site</a>
	<br />This game is best viewed in <a href='http://www.google.com/chrome'>Google Chrome</a>
	</noscript>


<?
function displayMaze($mapType, $name) {
	
	//Gather data for map;
	$motd = MapOfTheDay($mapType);
	$mapID = $motd['id'];
	$map = $motd['map'];
	$width = $map[0][0];
	//data for the topscores
	$topscores = topScores($motd['id'], 30);
	$topscorediv = "<div id='$mapID,dspScore'>\n$topscores\n</div>";

	$userID = $_SESSION['userID'];
	if ($_SESSION['accepted'] == 1) {
		$sol = getSolution($userID, $mapID);
		$mysolution = $sol['solution'];
		//!! implement mymoves
		$mymoves = $sol['moves'];
	}
	if (isset($_SESSION[$mapID.'sol']) AND $mysolution == '') {
		$mysolution = $_SESSION[$mapID.'sol'];
		$mymoves = $_SESSION[$mapID.'moves'];
	}
	
		
	echo "<div id=\"yms-$mapType\" class='hidden-maps'>";
	echo "	<div class='wrapper'>";
	
	//	if ($width <= 16) {
		// echo '		<div class="col1">';
		// echo $topscorediv;
		// echo '		</div>';
		
		// echo '		<div class="col2">';
		// echo "<a href='javascript:requestSol(\"$mapID\");'>Load your best solution</a><br />";
		// echo DisplayMap($map, $mapID); 
		// echo '		</div>';
	echo "		<div style='text-align: center;'>";
	echo "			<div style='display:inline-block;margin: 0 auto;text-align: left;'>";
	echo "			<a href='javascript:requestSol(\"$mapID\");'>Load your best solution</a><br />";
	echo DisplayMap($map, $mapID); 
	echo "		</div></div>";

	echo "		<div style='padding-top: 20px;'>";
	echo $topscorediv;
	echo '		</div>';

	echo '	</div>';
	echo '</div>';

	$mapSolDiv = "<script>
	loadSol(\"$mapID:$mysolution\", \"$mymoves\");
	</script>";
	echo $mapSolDiv;
	
	//Clear our floatingness
	echo '<div style="clear: both"></div>';
	
}
displayMaze(1, 'Simple');
displayMaze(2, 'Normal');
displayMaze(3, 'Complex');
displayMaze(4, 'Special');

$timerem = strtotime("tomorrow") - strtotime("now");
?>
	<div style='text-align: center; margin-top: 5px;'>
		New maps in: <span id="countdown">00:00:00</span>
	</div>
	<script type="text/javascript">
	var countdownInt = self.setInterval(countdown, 1000);
	var tomorrow = new Date().getTime() + <? echo $timerem; ?> * 1000;

	function countdown() {
		var now = new Date();
		var timerem = new Date(tomorrow - now + now.getTimezoneOffset() * 60 * 1000);
		if (timerem < 1000)
			window.clearInterval(countdownInt);
		var hours = addZero(timerem.getHours());
		var minutes = addZero(timerem.getMinutes());
		var seconds = addZero(timerem.getSeconds());
		var stamp = hours + ":" + minutes + ":" + seconds;
		document.getElementById("countdown").innerHTML = stamp;
	}

	function addZero(num) {
		var numStr = num + '';
		if (numStr.length < 2)
			numStr = "0" + numStr;
		return numStr;
	}
	</script>
</div>



<div id="copy" style='width:100%;clear: both'>
	Copyright &copy; 2011 pathery.com
</div>



<script>
function showStats(type) {
	for (var i = 1; i <= 4; i++) {
		var elem = document.getElementById("yms-" + i);
		elem.className = elem.className.replace('shown-maps', 'hidden-maps');
		// var elem = document.getElementById("yms-" + i);
		// if (elem.className.indexOf('hidden-maps') < 0)
			// elem.className += 'hidden-maps';
		elem = document.getElementById("dl-" + i);
		elem.className = elem.className.replace('selected', '');
	}
	var elem = document.getElementById("yms-" + type);
	elem.className = elem.className.replace('hidden-maps', 'shown-maps');
	elem = document.getElementById("dl-" + type);
	if (elem.className.indexOf('selected') < 0)
		elem.className += 'selected';
}
showStats(1);
</script>
<script src="sounds/script/soundmanager.js"></script>
<script type="text/javascript">soundManagerInit();</script>

<?PHP echo $noteScript; ?>

<?php
htmlFooter();
?>