segue-1.x /sitelisting.php

Language PHP Lines 380
MD5 Hash 047ffa8a7d4e54c98b6a1652b056ab2c Estimated Cost $4,907 (why?)
Repository https://github.com/adamfranco/segue-1.x.git View Raw File View Project SPDX
  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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<? /* $Id$ */

// we need to include object files before session_start() or registered
// objects will be broken.
include("objects/objects.inc.php");

$content = '';
$numPerPage = 30;

ob_start();
session_start();


// include all necessary files
include("includes.inc.php");

db_connect($dbhost, $dbuser, $dbpass, $dbdb);


if ($_REQUEST[order]) 
	$order = $_REQUEST[order];
	
if ($_REQUEST[site]) 
	$site = $_REQUEST[site];
	
if ($_REQUEST[user]) 
	$user = $_REQUEST[user];

if ($_REQUEST[title]) {
	$title = $_REQUEST[title];
} else {
	$title = "";
}
	
if (!isset($order)
	|| !preg_match('/^[a-z0-9_.]+( (ASC|DESC))?$/i', $order))
	$order = "editedtimestamp DESC";

$orderby = " ORDER BY $order";

if ($_REQUEST[clear]=="clear") {
	$type = "";
	$user = "";
	$site = "";
	$title = "";
	//$type = "%";
	//$active = "%";
}


//printpre ($_REQUEST);

$w = array();$wExtra=array();
//if ($_REQUEST[type]) $w[]="slot_type like '%$type%'";
if ($cfg[allowpersonalsites] && $cfg[allowclasssites])
	$w[]="(slot_type='personal' OR slot_type='class' OR slot_type='other')";
else if ($cfg[allowpersonalsites]) $w[]="(slot_type='personal' OR slot_type='other')";
else if ($cfg[allowclasssites]) $w[]="slot_type='class'";
if ($user) $wExtra[]="user_uname like '%".addslashes($user)."%'";
if ($site) $wExtra[]="slot_name like '%".addslashes($site)."%'";
if ($title) $wExtra[]="site_title like '%".addslashes($title)."%'";
$w[] = "site_active='1'";
$w[] = "site_listed='1'";
//if ($_REQUEST[active]) $w[]="site_active like '%$active%'";
if (count($w)) {
	$where = " where ".implode(" and ",$w);
	$where2 = " where ".implode(" and ",array_merge($w,$wExtra));
}
$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);
$totalNumSites = $a[log_count];

$query = "
	SELECT 
		COUNT(*) AS log_count
	FROM 
		slot
			INNER JOIN
		site
			ON
		FK_site = site_id
			INNER JOIN
		user
			ON
		FK_owner = user_id	
	$where2";
$r=db_query($query); 
$a = db_fetch_assoc($r);
$numSites = $a[log_count];

//printpre ($query);

//if (!isset($lowerlimit)) $lowerlimit = 0;
//if ($lowerlimit < 0) $lowerlimit = 0;
//
//$lowerlimit = addslashes($lowerlimit);
//$limit = " limit $lowerlimit,$numPerPage";



if (isset($_REQUEST['lowerlimit']))
	$lowerlimit = intval($_REQUEST['lowerlimit']);
else
	$lowerlimit = 0;

if ($lowerlimit < 0) 
	$lowerlimit = 0;

$limit = " limit $lowerlimit,$numPerPage";


$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
	$where2$orderby$limit";

$r = db_query($query);

//print $query;

?>
<!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>Segue: Public Site Listing</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>

<table width='100%' class='bg'>
<tr><td class='bg'>
	<? print $content; ?>
	<div align='center' style='font-size: 14px;'><b><? echo $cfg[inst_name] ?> <? echo $site_name?> </b></div><br />
	<div align='left' style='font-size: 10px;'>
	Included here are all <b>class</b> sites and any other sites that requested to be included in this public listing of
	<? echo $cfg[inst_name] ?> sites. These are sorted by those that have been most recently updated.<br />
	<i>(Note: not all sites listed here are viewable to all users)</i>
	</div>
	<br />
	<? print "Total active listed Segue sites: ".$totalNumSites ?>


</td></tr>
</table>

<table cellspacing='1' width='100%' id='maintable'>
<tr>
	<td colspan='8'>
		<table width='100%'>
		<tr><td>
		<form action='<?echo "$PHP_SELF?$sid"?>' method='post' name='searchform'>
		<?
		// $r1 = db_query("select distinct type from sites order by type asc");
		?>
		<!-- type: <select name='type'>
		<option value=''>all -->
		<?
		//while ($a=db_fetch_assoc($r1))
		//	print "<option".(($type==$a[type])?" selected":"").">$a[type]\n";
		
		if (true) {
		?>
			<!-- </select> -->
			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 ?>' />
			<!--
			type: <select name='type'>
				<option<?=($type=='%')?" selected":""?>>all
				<option<?=($type=='class')?" selected":""?>>class
				<option<?=($type=='other')?" selected":""?>>other
				<option<?=($type=='personal')?" selected":""?>>personal
				<option<?=($type=='system')?" selected":""?>>system
				</select>
			-->
			<input type='submit' value='go' />
			<input type='submit' name='clear' value='clear' />
			<input type='hidden' name='order' value='<? echo $order ?>' />
		<? } ?>
		</form>
		</td>
		<td align='right'>
		<?
		$tpages = ceil($numSites/$numPerPage);
		$curr = ceil(($lowerlimit+$numPerPage)/$numPerPage);
		$prev = $lowerlimit-$numPerPage;
		if ($prev < 0) $prev = 0;
		$next = $lowerlimit+$numPerPage;
		if ($next >= $numSites) $next = $numSites-$numPerPage;
		if ($next < 0) $next = 0;
		print "$curr of $tpages ";
// 		print "(Prev: $prev LL: $lowerlimit Next: $next )";
		if ($prev != $lowerlimit)
			print "<input type='button' value='&lt;&lt;' onclick='window.location=\"$PHP_SELF?$sid&lowerlimit=$prev&type=$type&user=$user&title=$title&site=$site&order=$order\"' />\n";
		if ($next != $lowerlimit && $next > $lowerlimit)
			print "<input type='button' value='&gt;&gt;' onclick='window.location=\"$PHP_SELF?$sid&lowerlimit=$next&type=$type&user=$user&title=$title&site=$site&order=$order\"' />\n";
		?>
		</td>
		</tr>
		</table>
	</td>
</tr>
<tr>
<?
	print "<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 " &or;";
	if ($order =='editedtimestamp desc') print " &and;";	
	print "</a></th>";
	
	print "<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 " &or;";
	if ($order =='name desc') print " &and;";	
	print "</a></th>";
	
//	print "<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 " &or;";
//	if ($order =='active desc') print " &and;";	
//	print "</a></th>";
	
	print "<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 " &or;";
	if ($order =='type desc') print " &and;";	
	print "</a></th>";
	
/* 	print "<th><a href=# onclick=\"changeOrder('"; */
/* 	if ($order =='viewpermissions asc') print "viewpermissions desc"; */
/* 	else print "viewpermissions asc"; */
/* 	print "')\" style='color: #000'>View"; */
/* 	if ($order =='viewpermissions asc') print " &or;"; */
/* 	if ($order =='viewpermissions desc') print " &and;";	 */
/* 	print "</a></th>"; */

//	print "<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 " &or;";
//	if ($order =='theme desc') print " &and;";	
//	print "</a></th>";
	
	print "<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 " &or;";
	if ($order =='title desc') print " &and;";	
	print "</a></th>";
	
	print "<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 " &or;";
	if ($order =='addedby desc') print " &and;";	
	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 "<tr>";
		print "<td class='td$color'><span style='white-space: nowrap;'>";
			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 "</span>";
		print "</td>";
		print "<td class='td$color'>$a[name]</td>";
//		print "<td class='td$color'><span style='color: #".(($a[active])?"090'>active":"900'>inactive")."</span></td>";
		print "<td class='td$color'>".((group::getClassesFromName($a[name]))?"group - ":"")."$a[type]</td>";
/* 		print "<td class='td$color'><span style='color: #"; */
/* 			if ($a[viewpermissions] == 'anyone') print "000"; */
/* 			if ($a[viewpermissions] == 'midd') print "00c"; */
/* 			if ($a[viewpermissions] == 'class') print "900"; */
/* 		print "'>$a[viewpermissions]</span></td>"; */
//		print "<td class='td$color'>$a[theme]</td>";
		print "<td class='td$color'>";
		print "<a href='#' onclick='opener.window.location=\"index.php?$sid&action=site&site=$a[name]\"'>";
		print stripslashes($a[title]);
		print "</a>";
		print "</td>";
		print "<td class='td$color'>";
		print "$a[addedbyfull] ($a[addedby])";
		print "</td>";
		print "</tr>";
		$color = 1-$color;
	}
} else {
	print "<tr><td colspan='5'>No sites found based on above criteria.</td></tr>";
}
?>
</table><br />
<div align='right'><input type='button' value='Close Window' onclick='window.close()' /></div>

<?
// debug output -- handy :)
/* print "<pre>"; */
/* print "request:\n"; */
/* print_r($_REQUEST); */
/* print "\n\n"; */
/* print "session:\n"; */
/* print_r($_SESSION); */
/* print "\n\n"; */

/*
 if (is_object($thisPage)) { 
 	print "\n\n"; 
 	print "thisPage:\n"; 
 	print_r($thisPage); 
 } /*else if (is_object($thisSection)) { 
	print "\n\n"; 
 	print "thisSection:\n"; 
 	print_r($thisSection); 
 } else if (is_object($thisSite)) { 
 	print "\n\n"; 
 	print "thisSite:\n"; 
 	print_r($thisSite); 
 } */
 
/* print "</pre>"; */
Back to Top