-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathadmin.php
170 lines (130 loc) · 3.95 KB
/
admin.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
/*
* @copyright (c) 2008 Nicolo John Davis
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
session_start();
if(!isset($_SESSION['isloggedin']))
{
echo "<meta http-equiv='Refresh' content='0; URL=login.php' />";
exit(0);
}
else
{
$username = $_SESSION['username'];
$userid = $_SESSION['userid'];
if($_SESSION['admin'] != true)
{
print "You need to be the administrator to access this file";
exit(0);
}
}
include('settings.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="Keywords" content="programming, contest, coding, judge" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Distribution" content="Global" />
<meta name="Robots" content="index,follow" />
<link rel="stylesheet" href="images/Envision.css" type="text/css" />
<title>Programming Contest</title>
<script type="text/javascript" src="jquery-1.3.1.js"></script>
<script type="text/javascript" src="jquery.timers-1.1.2.js"></script>
<?php include('timer.php'); ?>
<script type="text/javascript">
<!--
$(document).ready(
function()
{
dispTime();
getLeaders();
getDetails();
setInterval("dispTime()", 1000);
setInterval("getLeaders()", getLeaderInterval);
setInterval("getDetails()", getLeaderInterval);
$(".announcementform").focus();
$(".announcementform").keypress( function(e) {
if(e.which == 13)
{
var msg = this.value;
this.value = "";
if(msg != "") //To prevent empty line announcements
$.post("admin/submitannouncement.php", { message: msg }, function(){
messagebox('Announcement posted');
});
}
});
$("#uname,#problemid").change( function() {
var uname = $("#uname").val();
var id = $("#problemid").val();
$.get("admin/getcode.php", {username: uname, problemid: id, mode: 'getdir'}, function(data) { $("#filename").html(data); });
});
//Initially populate the filename box with problem 1 of admin
$.get("admin/getcode.php", {username: 'admin', problemid: '1', mode: 'getdir'}, function(data) { $("#filename").html(data); });
$("#viewcodebutton").click( function() {
var uname = $("#uname").val();
var id = $("#problemid").val();
var file = $("#filename").val();
$.get("admin/getcode.php", {username: uname, problemid: id, filename: file}, function(data) { $("#codeplaceholder").html(data).fadeIn("fast"); });
});
}
);
-->
</script>
</head>
<body class="menu7">
<!-- wrap starts here -->
<div id="wrap">
<!--header -->
<?php include('header.php'); ?>
<!-- menu -->
<?php include('menu.php'); ?>
<!-- content-wrap starts here -->
<div id="content-wrap">
<div id="main">
<div class="messagebox" style="display: none"> </div>
<h2>Post Announcement</h2>
<input maxlength="400" class="announcementform" type="text" />
<h2>View Code</h2>
<p>
Username
<select id="uname">
<?php
$cn = mysql_connect('localhost', $DBUSER , $DBPASS);
mysql_select_db($DBNAME, $cn);
$result = mysql_query("select username from users");
while($row = mysql_fetch_array($result))
print "<option value='$row[0]'> $row[0] </option>";
mysql_close($cn);
?>
</select>
Problem
<select id="problemid">
<?php
for($i=1 ; $i <= count($points) ; $i++)
print "<option value='$i'> $i </option>";
?>
</select>
Filename
<select id="filename">
</select>
<button id="viewcodebutton">View</button>
</p>
<pre id="codeplaceholder" style="display: none">
</pre>
</div>
<div id="sidebar">
<?php include('sidebar.php'); ?>
</div>
<!-- content-wrap ends here -->
</div>
<!--footer starts here-->
<div id="footer">
<?php include('footer.php'); ?>
</div>
<!-- wrap ends here -->
</div>
</body>
</html>