/
admin.php
executable file
·159 lines (126 loc) · 5.02 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
<?php
include('functions.php');
sqlconnect();
include('auth.php');
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0">
<script src="js/stay_standalone.js" type="text/javascript"></script>
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="apple-touch-icon" href="autoxicon.png" />
<link href="css/bootstrap.css" rel="stylesheet" media="screen">
<link href="css/bootstrap-responsive.css" rel="stylesheet" media="screen">
<link href="css/colorbox.css" rel="stylesheet" media="screen">
<style>
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
}
</style>
<title>GGC BMW CCA Autocross page</title>
<link href="css/bootstrap-responsive.css" rel="stylesheet" media="screen">
<style>
body {
background-image: url('img/satinweave.png') /*thanks SubtlePatterns.com */
}
</style>
</head>
<body>
<?php include('navbar.html'); ?>
<div class="container">
<?php
if ($usergroup == "admin"){
echo"<a href='showcars.php?export=Y' class='btn btn-primary'>Download autocross export</a> <a href='showcars.php?export=Y&tds=Y' class='btn btn-primary'>Download autocross export for TDS</a><br>";
echo"<h3>Autocross dates</h3>
<Table class='table table-condensed table-striped'>
<thead><th>Date</th><th>Location</th><th>Action</th></thead>
<tbody>";
$result = mysql_query("SELECT * FROM `autox_dates` ORDER BY `autoxdate` ASC") or die("Error: " . mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo"<tr id='$row[0]'><Td>$row[1]</td><Td>$row[2]</td><td><a href='#' class='btn btn-error deldate'>Delete</a></td></tr>";
}
echo"<tr><td><input class='input-small'id='datetoadd' placeholder='YYYY-MM-DD'></td><td><input class='input-medium' id='localetoadd'></td><td><a href='#' class='btn adddate'>Add</a></td></tr>";
echo"</table>";
echo"<h3>When to close the classification system</h3>
<h6>Relative to an autocross date - this uses php's strtotime function</h6>
<Table class='table table-condensed'>
<thead><th>Close date/time</th><th>Open date/time</th><th>Message</th><th>Actions</th></thead>
<tbody>";
$result = mysql_query("SELECT * FROM `autox_close`") or die("Error: " . mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo"<tr id='$row[0]'><Td><input id='closedate' class='input-large' value='$row[1]'></td><Td><input id='opendate' class='input-large' value='$row[2]'></td><Td><textarea id='msg' rows='3'>$row[3]</textarea></td><td><a href='#' class='btn updatetimes'>Update</a></td></tr>";
}
echo"</table>";
if ($username){
echo"<a href='#' class='btn btn-danger closesystem'>Manually Close System</a> <textarea id='closemessage' placeholder='closed message' rows='3'></textarea>";
} else {
echo"<a href='#' class='btn btn-success opensystem'>Manually Open System</a>";
}
echo"
<Br><Br>
Go to main page as someone else: <select id='alternateuser'>";
$result = mysql_query("SELECT * FROM `wp_users` ORDER BY `display_name` ASC") or die("Error: " . mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
$escaped = str_replace("'", "", $row[9]);
echo"<option value='$row[1]'>$escaped ($row[1])</option>";
}
echo"</select><br><Br><br>
<script src='http://code.jquery.com/jquery-latest.js'></script>
<script src='js/bootstrap.min.js'></script>
<script src='js/bootstrap-typeahead.js'></script>
<script src='js/jquery.colorbox.js'></script>";
?>
<script>
var username = "<?php echo $creds[0];?>";
$('.deldate').click(function(event){
var trid = $(this).closest('tr').attr('id');
//alert ("del car where id = " + trid);
$.get('updatecars.php?action=deldate&id='+trid+'&username='+username, function(data) {
location.reload();
});
});
$('.adddate').click(function(event){
value = $("#datetoadd").val();
locale = $("#localetoadd").val();
$.get('updatecars.php?action=adddate&id='+value+'&locale='+locale+'&username='+username, function(data) {
location.reload();
});
});
$('.updatetimes').click(function(event){
var trid = $(this).closest('tr').attr('id');
closedate = $("#closedate").val();
opendate = $("#opendate").val();
msg = $("#msg").val();
$.get('updatecars.php?action=updatetimes&id='+trid+'&closedate='+closedate+'&opendate='+opendate+'&msg='+msg, function(data) {
location.reload();
});
});
$('.closesystem').click(function(event){
closemsg = $("#closemessage").val();
$.get('updatecars.php?action=closesystem&id='+closemsg+'&username='+username, function(data) {
location.reload();
});
});
$('.opensystem').click(function(event){
closemsg = $("#closemessage").val();
$.get('updatecars.php?action=opensystem&username='+username, function(data) {
location.reload();
});
});
$('#alternateuser').change(function(event){
var theuser = $(this).val();
//alert(theuser);
window.location = "index.php?user=" + theuser;
});
</script>
<?php
} else {
echo"You're not an admin!";
}
?>
<Br><Br>
</div> <!--container-->
<Br><Br><br>
</body>
</html>