/
viewsites.php
executable file
·337 lines (282 loc) · 9.37 KB
/
viewsites.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
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<? /* $Id$ */
// we need to include object files before session_start() or registered
// objects will be broken.
include("objects/objects.inc.php");
$content = '';
ob_start();
session_start();
// include all necessary files
include("includes.inc.php");
//if ($_SESSION['ltype'] != 'admin') exit;
db_connect($dbhost, $dbuser, $dbpass, $dbdb);
if ($_REQUEST[order])
$order = $_REQUEST[order];
if (!isset($order)
|| !preg_match('/^[a-z0-9_.]+( (ASC|DESC))?$/i', $order))
$order = "editedtimestamp DESC";
$orderby = " ORDER BY $order";
$w = array();
if ($_REQUEST[user]) {
$user = $_REQUEST[user];
} else {
$user = "";
}
$w[]="user_uname like '%".addslashes($user)."%'";
if ($_REQUEST[site]) {
$site = $_REQUEST[site];
} else {
$site ="";
}
$w[]="slot_name like '%".addslashes($site)."%'";
if ($_REQUEST[title]) {
$title = $_REQUEST[title];
} else {
$title = "";
}
$w[]="site_title like '%".addslashes($title)."%'";
if (count($w)) $where = " where ".implode(" and ",$w);
if ($_REQUEST[clear]) {
$type = "";
$user = "";
$site = "";
$title = "";
//$type = "%";
//$active = "%";
}
$query = "
SELECT
COUNT(*) AS log_count
FROM
slot
INNER JOIN
site
ON
FK_site = site_id
INNER JOIN
user
ON
FK_owner = user_id
$where
";
$r=db_query($query);
$a = db_fetch_assoc($r);
$numlogs = $a[log_count];
if (isset($_REQUEST['lowerlimit']))
$lowerlimit = intval($_REQUEST['lowerlimit']);
else
$lowerlimit = 0;
if ($lowerlimit < 0)
$lowerlimit = 0;
$limit = " limit $lowerlimit,30";
$query = "
SELECT
slot_type AS type,
slot_name AS name,
site_title AS title,
site_theme AS theme,
site_updated_tstamp AS editedtimestamp,
site_active AS active,
user_uname AS addedby,
user_fname AS addedbyfull
FROM
slot
INNER JOIN
site
ON
FK_site = site_id
INNER JOIN
user
ON
FK_owner = user_id
$where $orderby $limit";
//printpre($query);
$r = db_query($query);
/******************************************************************************
* Get site id for links to participation section
******************************************************************************/
$siteObj =&new site($name);
$siteid = $siteObj->id;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>View Logs</title>
<? include("themes/common/logs_css.inc.php"); ?>
<script type="text/JavaScript">
// <![CDATA[
function changeOrder(order) {
f = document.searchform;
f.order.value=order;
f.submit();
}
// ]]>
</script>
</head>
<body>
<div align='right' class='bg'>
<?
/******************************************************************************
* Get site id for links to participation section
******************************************************************************/
$siteObj =&new site($site);
$siteid = $siteObj->id;
if ($_SESSION['ltype']=='admin') {
print "<table width='100%' class='bg'><tr><td class='bg'>
Logs: sites
| <a href='viewlogs.php?$sid&site=$site'>users</a>
</td><td align='right' class='bg'>
<a href='users.php?$sid&site=$site'>add/edit users</a> |
<a href='classes.php?$sid&site=$site'>add/edit classes</a> |
<a href='add_slot.php?$sid&site=$site'>add/edit slots</a> |
<a href='update.php?$sid&site=$site'>segue updates</a>
</td></tr></table>";
}
if ($site) {
if (isclass($site)) print "<a href='add_students.php?$sid&name=$site'>Roster</a> |";
print " <a href='email.php?$sid&siteid=$siteid&site=$site&action=list&scope=site'>Participation</a>";
print " | <a href='viewlogs.php?$sid&site=$site'>Logs</a>";
}
?>
</div>
<div class='bg'>
<? print $content; ?>
</div>
<table cellspacing='1' width='100%' id='maintable' style='margin-top: 5px;'>
<tr>
<td colspan='8'>
<table width='100%'>
<tr>
<td>
<form action='<?echo "$PHP_SELF?$sid"?>' method='post' name='searchform'>
<?
if ($_SESSION['ltype'] != 'admin') {
print "Activity on $site";
} else {
?>
site: <input type='text' name='site' size='10' value='<?echo $site?>' />
title: <input type='text' name='title' size='10' value='<?echo $title?>' />
user: <input type='text' name='user' size='10' value='<?echo $user?>' />
<input type='submit' value='go' />
<input type='submit' name='clear' value='clear' />
<input type='hidden' name='order' value='<? echo $order ?>'/>
<? }
print "\n\t\t\t\t\t\t\t\t\t<br />Total sites found:".$numlogs;
?>
</form>
</td>
<td align='right'>
<?
$tpages = ceil($numlogs/30);
$curr = ceil(($lowerlimit+30)/30);
$prev = $lowerlimit-30;
if ($prev < 0) $prev = 0;
$next = $lowerlimit+30;
if ($next >= $numlogs) $next = $numlogs-30;
if ($next < 0) $next = 0;
print "$curr of $tpages ";
// print "$prev $lowerlimit $next ";
if ($prev != $lowerlimit)
print "\n\t\t\t\t\t\t\t\t\t<input type='button' value='<<' onclick='window.location=\"$PHP_SELF?$sid&lowerlimit=$prev&type=$type&user=$user&title=$title&site=$site&order=$order\"' />";
if ($next != $lowerlimit && $next > $lowerlimit)
print "\n\t\t\t\t\t\t\t\t\t<input type='button' value='>>' onclick='window.location=\"$PHP_SELF?$sid&lowerlimit=$next&type=$type&user=$user&title=$title&site=$site&order=$order\"' />";
?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<?
print "\n\t\t\t<th><a href='#' onclick=\"changeOrder('";
if ($order =='editedtimestamp desc') print "editedtimestamp asc";
else print "editedtimestamp desc";
print "')\" style='color: #000'>Time";
if ($order =='editedtimestamp asc') print " ∨";
if ($order =='editedtimestamp desc') print " ∧";
print "</a></th>";
print "\n\t\t\t<th><a href='#' onclick=\"changeOrder('";
if ($order =='name asc') print "name desc";
else print "name asc";
print "')\" style='color: #000'>Site";
if ($order =='name asc') print " ∨";
if ($order =='name desc') print " ∧";
print "</a></th>";
print "\n\t\t\t<th><a href='#' onclick=\"changeOrder('";
if ($order =='active asc') print "active desc";
else print "active asc";
print "')\" style='color: #000'>Active";
if ($order =='active asc') print " ∨";
if ($order =='active desc') print " ∧";
print "</a></th>";
print "\n\t\t\t<th><a href='#' onclick=\"changeOrder('";
if ($order =='type asc') print "type desc";
else print "type asc";
print "')\" style='color: #000'>Type";
if ($order =='type asc') print " ∨";
if ($order =='type desc') print " ∧";
print "</a></th>";
print "\n\t\t\t<th><a href='#' onclick=\"changeOrder('";
if ($order =='theme asc') print "theme desc";
else print "theme asc";
print "')\" style='color: #000'>Theme";
if ($order =='theme asc') print " ∨";
if ($order =='theme desc') print " ∧";
print "</a></th>";
print "\n\t\t\t<th><a href='#' onclick=\"changeOrder('";
if ($order =='title asc') print "title desc";
else print "title asc";
print "')\" style='color: #000'>Title";
if ($order =='title asc') print " ∨";
if ($order =='title desc') print " ∧";
print "</a></th>";
print "\n\t\t\t<th><a href='#' onclick=\"changeOrder('";
if ($order =='addedby asc') print "addedby desc";
else print "addedby asc";
print "')\" style='color: #000'>Owner";
if ($order =='addedby asc') print " ∨";
if ($order =='addedby desc') print " ∧";
print "</a></th>";
?>
</tr>
<?
$color = 0;
$today = date(Ymd);
$yesterday = date(Ymd)-1;
if (db_num_rows($r)) {
while ($a=db_fetch_assoc($r)) {
print "\n\t\t<tr>";
print "\n\t\t\t<td class='td$color' style='white-space: nowrap;'>";
print "\n\t\t\t\t<a href='viewlogs.php?$sid&site=$a[name]' style='color: #000;'>";
//print "$yesterday";
if (strncmp($today, $a[editedtimestamp], 8) == 0 || strncmp($yesterday, $a[editedtimestamp], 8) == 0) print "<b>";
print timestamp2usdate($a[editedtimestamp],1);
if (strncmp($today, $a[editedtimestamp], 8) == 0 || strncmp($yesterday, $a[editedtimestamp], 8) == 0) print "</b>";
print "</a>";
print "\n\t\t\t</td>";
print "\n\t\t\t<td class='td$color'>$a[name]</td>";
print "\n\t\t\t<td class='td$color' style='color: #".(($a[active])?"090'>active":"900'>inactive")."</td>";
print "\n\t\t\t<td class='td$color'>".((group::getClassesFromName($a[name]))?"group - ":"")."$a[type]</td>";
print "\n\t\t\t<td class='td$color'>$a[theme]</td>";
print "\n\t\t\t<td class='td$color'>";
print "\n\t\t\t\t<a href='#' onclick='opener.window.location=\"index.php?$sid&action=site&site=$a[name]\"'>";
print stripslashes($a[title]);
print "</a>";
print "\n\t\t\t</td>";
print "\n\t\t\t<td class='td$color'>";
print "$a[addedbyfull] ($a[addedby])";
print "</td>";
print "\n\t\t</tr>";
$color = 1-$color;
}
} else {
print "\n\t\t<tr>\n\t\t\t<td colspan='7'>No sites found based on above criteria.</td>\n\t\t</tr>";
}
?>
</table>
<br />
<div align='right'>
<input type='button' value='Close Window' onclick='window.close()' />
</div>
</body>
</html>