-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
executable file
·183 lines (180 loc) · 6.1 KB
/
admin.php
File metadata and controls
executable file
·183 lines (180 loc) · 6.1 KB
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
<?php
/***************************************************************************
* Middlebury Music United
* This code is proprietary and property of William S. Potter.
* It has been licensed for use to Middlebury College in this installation.
* Use of this code requires consent from William S. Potter
* wp@punkypond.com
***************************************************************************/
include_once("LocalSettings.php");
if(isset($_COOKIE['mu_admin']))
{
?>
<!DOCTYPE html>
<html>
<head>
<title>Middlebury Music United | Home</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="wrapper">
<?php
include_once("LoginBar.php");
$con = mysql_connect($dbHost,$dbUser,$dbPass);
if (!$con)
{die('Could not connect: ' . mysql_error());}
mysql_select_db($dbSchema, $con);
?>
<div id="content">
<div id="header"><a href="index.php"><img src="mmuweb.jpg" alt=""></a></div>
<div id="maincontent">
<div id="outerbox">
<div id="tabrow">
<a href="admin.php"><div class="<?php if(!isset($_REQUEST['events'])) echo 'selected '; ?>tab">Users</div></a>
<a href="?events"><div class="<?php if(isset($_REQUEST['events'])) echo 'selected '; ?>tab">Events</div></a>
</div>
<div id="innerbox">
<?php
if(isset($_REQUEST['events']))
{
}
else
{
if(isset($_POST['SUBMITUSERS']))
{
$result = mysql_query("SELECT * FROM user");
while($row = mysql_fetch_array($result))
{
$ids[]=$row['id'];
}
foreach($ids as $i)
{
$valid=0;
$admin=0;
if(!empty($_POST[$i]))
{
foreach($_POST[$i] as $j)
{
if($j=="valid") $valid=1;
if($j=="admin") $admin=1;
}
}
else
{
$valid=0;
$admin=0;
}
mysql_query("UPDATE user SET valid='$valid', admin='$admin' WHERE id='$i'");
}
$result = mysql_query("SELECT * FROM user");
$users = array();
while($row=mysql_fetch_array($result))
{
$username = $row['username'];
$users[$username]['username']=$username;
$users[$username]['firstname'] = $row['firstname'];
$users[$username]['lastname'] = $row['lastname'];
$users[$username]['id'] = $row['id'];
$users[$username]['valid'] = $row['valid'];
$users[$username]['admin'] = $row['admin'];
}
asort($users);
$bgcolor = "#eeeeee";
echo '<p>Changes saved successfully!</p>';
echo '<form method="post" action="admin.php">';
echo '<table id="userlisttable" cellspacing="0" width="100%">';
echo '<tr><td style="text-align:center;" colspan="4"><input type="submit" name="SUBMITUSERS" value="Update Users"></td></tr>';
echo '<tr><th>Name</th><th>Username</th><th>Active?</th><th>Admin</th></tr>';
foreach($users as $user)
{
echo '<tr style="background-color:'.$bgcolor.';">';
echo '<td>'.$user['firstname'].' '.$user['lastname'].'</td>';
echo '<td class="userlistun"><a href="mailto:'.$user['username'].'@middlebury.edu">'.$user['username'].'</a></td>';
if($user['valid']==1) echo '<td><input type="checkbox" checked="checked" name="'.$user['id'].'[]" value="valid"></td>';
else echo '<td><input type="checkbox" name="'.$user['id'].'[]" value="valid"></td>';
if($user['admin']==1) echo '<td><input type="checkbox" checked="checked" name="'.$user['id'].'[]" value="admin"></td>';
else echo '<td><input type="checkbox" name="'.$user['id'].'[]" value="admin"></td>';
echo '</tr>';
$bgcolor=$bgcolor=="#dddddd"?"#eeeeee":"#dddddd";
}
echo '</table>';
echo '</form>';
}
else
{
$result = mysql_query("SELECT * FROM user");
$users = array();
while($row=mysql_fetch_array($result))
{
$username = $row['username'];
$users[$username]['username']=$username;
$users[$username]['firstname'] = $row['firstname'];
$users[$username]['lastname'] = $row['lastname'];
$users[$username]['id'] = $row['id'];
$users[$username]['valid'] = $row['valid'];
$users[$username]['admin'] = $row['admin'];
}
asort($users);
$bgcolor = "#eeeeee";
echo '<form method="post" action="admin.php">';
echo '<table id="userlisttable" cellspacing="0" width="100%">';
echo '<tr><td style="text-align:center;" colspan="4"><input type="submit" name="SUBMITUSERS" value="Update Users"></td></tr>';
echo '<tr><th>Name</th><th>Username</th><th>Active?</th><th>Admin</th></tr>';
foreach($users as $user)
{
echo '<tr style="background-color:'.$bgcolor.';">';
echo '<td>'.$user['firstname'].' '.$user['lastname'].'</td>';
echo '<td class="userlistun"><a href="mailto:'.$user['username'].'@middlebury.edu">'.$user['username'].'</a></td>';
if($user['valid']==1) echo '<td><input type="checkbox" checked="checked" name="'.$user['id'].'[]" value="valid"></td>';
else echo '<td><input type="checkbox" name="'.$user['id'].'[]" value="valid"></td>';
if($user['admin']==1) echo '<td><input type="checkbox" checked="checked" name="'.$user['id'].'[]" value="admin"></td>';
else echo '<td><input type="checkbox" name="'.$user['id'].'[]" value="admin"></td>';
echo '</tr>';
$bgcolor=$bgcolor=="#dddddd"?"#eeeeee":"#dddddd";
}
echo '</table>';
echo '</form>';
}
}
?>
</div>
</div>
</div>
</div>
</div>
<?php
include_once("Footer.php");
?>
</body>
</html>
<?php
}
else
{
?>
<!DOCTYPE html>
<html>
<head>
<title>Middlebury Music United | Home</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="wrapper">
<?php
include_once("LoginBar.php");
?>
<div id="content">
<div id="header"><a href="index.php"><img src="mmuweb.jpg" alt=""></a></div>
<div id="maincontent">
<p>You must be an admin to view this page!</p>
</div>
</div>
</div>
<?php
include_once("Footer.php");
?>
</body>
</html>
<?php
}
?>