-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader.php
150 lines (140 loc) · 4.76 KB
/
header.php
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
<?
/*
scavhunt - An online scavenger hunt
Copyright 2010, Andy Schmitz
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License (in the
LICENSE file) for more details.
*/
// Set up the timezone - pick your own from the standard tzdata list.
// For the US, http://www.statoids.com/tus.html looks like a decent list.
date_default_timezone_set('America/Los_Angeles');
// This shows a countdown before the scavenger hunt actually launched.
if (time() < strtotime("May 3, 2010 06:00:00")) {
include 'count/index.php';
die();
}
// Make sure this isn't cached
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
require_once(dirname(__FILE__).'/lib/login.php');
userLogin();
if (($user != false) && isset($_SESSION['redir_to'])) {
header('Location: '.$_SESSION['redir_to']);
unset($_SESSION['redir_to']);
die();
} elseif ($require_login && ($user == false)) {
$_SESSION['redir_to'] = $_SERVER['REQUEST_URI'];
header('Location: /login.php');
die();
} elseif ($require_nouser && ($user != false)) {
header('Location: /');
die();
}
// Look through the list of challenges, find the current challenge.
$challenges = preg_split('/[\r\n]+/mis', file_get_contents(dirname(__FILE__).'/data/challenges.txt'), 0, PREG_SPLIT_NO_EMPTY);
$challengeTotal = count($challenges);
$challengeId = false;
for($challengeNumber = 1; $challengeNumber <= $challengeTotal; $challengeNumber++) {
$challengeBits = explode('-', $challenges[$challengeNumber-1]);
if (time() < strtotime(trim($challengeBits[1]))) {
// If this challenge hasn't passed, it must be the current challenge.
$challengeId = trim($challengeBits[0]);
$challengeEnd = trim($challengeBits[1]);
break;
} else {
$lastChallengeEnd = trim($challengeBits[1]);
}
}
if ($noHeader) {
$noHeader = false;
return;
}
?>
<html>
<head>
<title><?=htmlentities($title)?> - Scavenger Hunt</title>
<link rel="stylesheet" href="/css/reset.css" />
<link rel="stylesheet" href="/css/960.css" />
<link rel="stylesheet" href="/css/style.css?v=6" />
<script language="JavaScript">
var refTime = new Date("<?=date('F j, Y H:i:s');?>");
var nowTime = new Date();
var timeOffset = refTime.valueOf() - nowTime.valueOf();
</script>
<script language="JavaScript" src="/script/scav.js?v=4"></script>
</head>
<body>
<div class="container_12 header">
<div class="grid_8">
<a href="/"><img src="/images/scavhunt_logo.jpg" /></a><br />
<div class="tagline">a scavenger hunt at your high school *</div>
</div>
<div class="grid_4 countdown_container">
<div id="countdown"><?=$challengeEnd?></div>
</div>
<div class="clear"></div>
</div>
<div class="menu">
<div class="container_12">
<? if ($challengeId) { ?>
<a class="grid_2 item<?=($tab == 'current') ? ' selected' : '' ?>" href="/">
current
</a>
<a class="grid_2 item<?=($tab == 'previously') ? ' selected' : '' ?>" href="/previously.php">
previously
</a>
<a class="grid_2 item<?=($tab == 'scoreboard') ? ' selected' : '' ?>" href="/scoreboard.php">
scoreboard
</a>
<a class="grid_2 item<?=($tab == 'contact') ? ' selected' : '' ?>" href="/contact.php">
contact
</a>
<div class="grid_4 name">
<? if ($user) { ?>
<?=htmlentities(strtolower($user['first'].' '.$user['last'])) ?>
<a href="/logout.php" class="smallText">[logout]</a>
<? } ?>
</div>
<? } else { ?>
<a class="grid_2 item<?=($tab == 'previously') ? ' selected' : '' ?>" href="/previously.php">
previously
</a>
<a class="grid_2 item<?=($tab == 'scoreboard') ? ' selected' : '' ?>" href="/scoreboard.php">
scoreboard
</a>
<a class="grid_2 item<?=($tab == 'contact') ? ' selected' : '' ?>" href="/contact.php">
contact
</a>
<div class="grid_2">
</div>
<div class="grid_4 name">
<? if ($user) { ?>
<?=htmlentities(strtolower($user['first'].' '.$user['last'])) ?>
<a href="/logout.php" class="smallText">[logout]</a>
<? } ?>
</div>
<? } ?>
</div>
<div class="clear"></div>
</div> <!-- menu -->
<div class="body">
<div class="container_12 body">
<div style="height: 30px;"></div>
<div class="clear"></div>
<? if (isset($_SESSION['error'])) { ?>
<div class="errorText"><?= $_SESSION['error'] ?></div>
<div style="height: 30px;"></div>
<? unset($_SESSION['error']);
} ?>
<? if (isset($_SESSION['flash'])) { ?>
<div class="flashText"><?= $_SESSION['flash'] ?></div>
<div style="height: 30px;"></div>
<? unset($_SESSION['flash']);
} ?>