This repository has been archived by the owner on Oct 29, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
browse_by_tag.php
executable file
·435 lines (349 loc) · 11.7 KB
/
browse_by_tag.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
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
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
<?php
session_start();
require("include/functions.php");
$config_file = 'config.php';
if (file_exists($config_file)) {
require("config.php");
} else {
header("Location: error.php?e=config");
die();
}
require("include/apply_config.php");
require("include/check_login.php");
#Sanitize inputs
$Tagq=filter_var($_GET["Tag"], FILTER_SANITIZE_STRING);
if (isset($_GET["SiteID"])){
$SiteID=filter_var($_GET["SiteID"], FILTER_SANITIZE_NUMBER_INT);
}
if (isset($_GET["startid"])){
$startid=filter_var($_GET["startid"], FILTER_SANITIZE_NUMBER_INT);
}
else{
$startid=1;
}
if (isset($_GET["order_by"])){
$order_by=filter_var($_GET["order_by"], FILTER_SANITIZE_STRING);
}
else{
$order_by = "Date";
}
if (isset($_GET["order_dir"])){
$order_dir=filter_var($_GET["order_dir"], FILTER_SANITIZE_STRING);
}
else{
$order_dir = "ASC";
}
#Display type saved as a cookie
if (isset($_GET["display_type"])){
$display_type = filter_var($_GET["display_type"], FILTER_SANITIZE_STRING);
setcookie("display_type", $display_type, time()+(3600*24*30), $app_dir);
}
else{
if(isset($_COOKIE["display_type"])) {
$display_type = $_COOKIE["display_type"];
}
else {
$display_type = "summary";
setcookie("display_type", $display_type, time()+(3600*24*30), $app_dir);
}
}
if ($order_by=="Date")
$order_byq = "Date $order_dir, Time";
else
$order_byq = $order_by;
#If user is not logged in, add check for QF
if ($pumilio_loggedin==FALSE) {
$qf_check = "AND Sounds.QualityFlagID>='$default_qf'";
}
else {
$qf_check = "";
}
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html>
<head>
<title>$app_custom_name - Browse Sounds by Tag</title>";
require("include/get_css.php");
require("include/get_jqueryui.php");
require("include/nocache.php");
#Multiple delete script to select all
echo "
<SCRIPT language=\"javascript\">
$(function(){
// add multiple select / deselect functionality
$(\"#selectall\").click(function () {
$('.case').attr('checked', this.checked);
});
// if all checkbox are selected, check the selectall checkbox
// and viceversa
$(\".case\").click(function(){
if($(\".case\").length == $(\".case:checked\").length) {
$(\"#selectall\").attr(\"checked\", \"checked\");
} else {
$(\"#selectall\").removeAttr(\"checked\");
}
});
});
</SCRIPT>";
?>
<?php
$query_all_tags = "SELECT DISTINCT Tag FROM Tags";
$result_all_tags=query_several($query_all_tags, $connection);
$nrows_all_tags = mysqli_num_rows($result_all_tags);
if ($nrows_all_tags>0) {
/*
#Deprecated
echo "
<!-- JQuery Autocomplete http://docs.jquery.com/Plugins/Autocomplete -->
<script type=\"text/javascript\" src=\"$app_url/js/jquery/jquery.autocomplete.pack.js\"></script>";
*/
echo "<script type=\"text/javascript\">
$(function() {
var mytags = [ ";
for ($a=0; $a<($nrows_all_tags - 1); $a++) {
$row_all_tags = mysqli_fetch_array($result_all_tags);
extract($row_all_tags);
echo "\"$Tag\", ";
}
for ($a=$nrows_all_tags - 1; $a<$nrows_all_tags; $a++) {
$row_all_tags = mysqli_fetch_array($result_all_tags);
extract($row_all_tags);
echo "\"$Tag\"";
}
echo "];
$( \"#newtag\" ).autocomplete({
source: mytags
});
});
</script>
";
}
?>
<!--jquery form-->
<!-- http://jquery.malsup.com/form/ -->
<script type="text/javascript" src="js/jquery.form.js"></script>
<?php
for ($ajax = 0; $ajax < 10; $ajax++) {
echo "
<script type=\"text/javascript\">
$(document).ready(function() {
var options = {
target: '#tagspace$ajax', // target element(s) to be updated with server response
// beforeSubmit: showRequest, // pre-submit callback
// success: showResponse, // post-submit callback
clearForm: true,
resetForm: true
};
// bind form using 'ajaxForm'
$('#addtags$ajax').ajaxForm(options);
});
</script>
";
}
if ($use_googleanalytics) {
echo $googleanalytics_code;
}
?>
<!-- Hide success messages -->
<script type="text/javascript">
$(function() {
// setTimeout() function will be fired after page is loaded
// it will wait for 5 sec. and then will fire
// $("#successMessage").hide() function
setTimeout(function() {
$("#md").hide('blind', {}, 500)
}, 5000);
});
</script>
<?php
#Execute custom code for head, if set
if (is_file("$absolute_dir/customhead.php")) {
include("customhead.php");
}
?>
</head>
<body>
<!--Blueprint container-->
<div class="container">
<?php
require("include/topbar.php");
?>
<div class="span-24 last">
<hr noshade>
</div>
<div class="span-11">
<?php
//How many sounds associated with that tag
$no_sounds=query_one("SELECT COUNT(*) as no_sounds_tag FROM Tags WHERE Tag='$Tagq'", $connection);
if ($startid<1)
$startid=1;
$startid_q=$startid-1;
if ($display_type=="summary")
$how_many_to_show=10;
elseif ($display_type=="gallery")
$how_many_to_show=18;
$endid = $how_many_to_show;
$endid_show=$startid_q+$endid;
if ($startid_q+$how_many_to_show >= $no_sounds){
$endid_show = $no_sounds;
}
$sql_limit = "$startid_q, $endid";
#Check if user can edit files (i.e. has admin privileges)
$username = $_COOKIE["username"];
echo "<p class=\"highlight3 ui-corner-all\" style=\"text-align: left;\"><strong>Tag: $Tagq</strong><br>$no_sounds sounds</p>";
?>
</div>
<div class="span-4">
<?php
echo "<div class=\"center\">";
if ($special_wrapper==TRUE){
$browse_site_link = "$wrapper?page=browse_by_tag";
$db_filedetails_link = "$wrapper?page=db_filedetails";
}
else {
$browse_site_link = "browse_by_tag.php?";
$db_filedetails_link = "db_filedetails.php?";
}
#count and next
echo "Results<br>";
if ($startid>1) {
$go_to=$startid-$how_many_to_show;
echo "<a href=\"$browse_site_link&Tag=$Tagq&startid=$go_to&order_by=$order_by&order_dir=$order_dir\"><img src=\"$app_url/images/arrowleft.png\"></a>";
}
echo " $startid to $endid_show ";
if ($endid_show<$no_sounds) {
$go_to=$startid+$how_many_to_show;
echo "<a href=\"$browse_site_link&Tag=$Tagq&startid=$go_to&order_by=$order_by&order_dir=$order_dir\"><img src=\"$app_url/images/arrowright.png\"></a>";
}
echo "<br>of $no_sounds</div>";
?>
</div>
<div class="span-3">
<?php
#Order by sound name
echo "<p>Name <a href=\"browse_by_tag.php?Tag=$Tagq&order_by=SoundName&order_dir=ASC\"><img src=\"images/arrowdown.png\"></a> <a href=\"browse_by_tag.php?Tag=$Tagq&order_by=SoundName&order_dir=DESC\"><img src=\"images/arrowup.png\"></a>";
?>
</div>
<div class="span-3">
<?php
#Order by sound date
echo "<p>Date <a href=\"browse_by_tag.php?Tag=$Tagq&order_by=Date&order_dir=ASC\"><img src=\"images/arrowdown.png\"></a> <a href=\"browse_by_tag.php?Tag=$Tagq&order_by=Date&order_dir=DESC\"><img src=\"images/arrowup.png\"></a>";
?>
</div>
<div class="span-3 last">
<?php
#Order by sound duration
echo "<p>Display: <a href=\"browse_by_tag.php?Tag=$Tagq&order_by=$order_by&order_dir=$order_dir&display_type=summary&startid=$startid\" title=\"Display as summary\"><img src=\"images/application_view_columns.png\" alt=\"Display as summary\"></a> <a href=\"browse_by_tag.php?Tag=$Tagq&order_by=$order_by&order_dir=$order_dir&display_type=gallery&startid=$startid\" title=\"Display as gallery\"><img src=\"images/application_view_tile.png\" alt=\"Display as gallery\"></a>";
?>
</div>
<?php
echo "<div class=\"span-24 last\">
<hr noshade style=\"margin-top: 10px;\">";
#Confirm delete
if (isset($_GET["md"])){
$md=filter_var($_GET["md"], FILTER_SANITIZE_NUMBER_INT);
if ($md == 1){
echo "<div <div class=\"success\" id=\"md\">One file was deleted.</div>";
}
else{
echo "<div <div class=\"success\" id=\"md\">$md files were deleted.</div>";
}
}
echo "</div>";
$query = "SELECT *, DATE_FORMAT(Sounds.Date, '%d-%b-%Y') AS Date_h FROM Sounds,Tags WHERE Tags.Tag='$Tagq' AND Tags.SoundID=Sounds.SoundID AND Sounds.SoundStatus!='9' $qf_check ORDER BY $order_byq $order_dir LIMIT $sql_limit";
$result=query_several($query, $connection);
$nrows = mysqli_num_rows($result);
$check_result=query_several($query, $connection);
#echo "<div class=\"span-24 last\">";
if ($nrows>0) {
if ($display_type=="summary") {
require("include/view_summary.php");
}
elseif ($display_type=="gallery") {
require("include/view_gallery.php");
}
}
else {
echo "<div class=\"span-24 last\"><p>There are no more files with that tag.
</div>";
}
echo "<div class=\"span-24 last\">
<br><hr noshade>
</div>
<div class=\"span-10\">";
#Quick form to select a file based on its name
echo "<form action=\"db_filedetails.php\" method=\"GET\">Select a file from this tag:<br>";
$query_q = "SELECT * FROM Sounds,Tags WHERE Tags.Tag='$Tagq' AND Tags.SoundID=Sounds.SoundID
AND Sounds.SoundStatus!='9' $qf_check ORDER BY SoundName";
$result_q = mysqli_query($connection, $query_q)
or die (mysqli_error($connection));
$nrows_q = mysqli_num_rows($result_q);
echo "<select name=\"SoundID\" class=\"ui-state-default ui-corner-all\">";
for ($q=0;$q<$nrows_q;$q++) {
$row_q = mysqli_fetch_array($result_q);
extract($row_q);
echo "<option value=\"$SoundID\">$SoundName</option>\n";
}
echo "</select>
<input type=submit value=\" Select \" class=\"fg-button ui-state-default ui-corner-all\"></form>
</div>";
?>
<div class="span-8">
<?php
echo "<div class=\"center\">";
if ($special_wrapper==TRUE){
$browse_site_link = "$wrapper?page=browse_by_tag";
$db_filedetails_link = "$wrapper?page=db_filedetails";
}
else {
$browse_site_link = "browse_by_tag.php?";
$db_filedetails_link = "db_filedetails.php?";
}
#count and next
echo "Results<br>";
if ($startid>1) {
$go_to=$startid-$how_many_to_show;
echo "<a href=\"$browse_site_link&Tag=$Tagq&startid=$go_to&order_by=$order_by&order_dir=$order_dir\"><img src=\"$app_url/images/arrowleft.png\"></a>";
}
echo " $startid to $endid_show ";
if ($endid_show<$no_sounds) {
$go_to=$startid+$how_many_to_show;
echo "<a href=\"$browse_site_link&Tag=$Tagq&startid=$go_to&order_by=$order_by&order_dir=$order_dir\"><img src=\"$app_url/images/arrowright.png\"></a>";
}
echo "<br>of $no_sounds</div>";
echo "</div>
<div class=\"span-6 last\">";
if (($no_sounds%$how_many_to_show)==0)
$no_pages=floor($no_sounds/$how_many_to_show)-1;
else
$no_pages=floor($no_sounds/$how_many_to_show);
echo "<form action=\"browse_by_tag.php\" method=\"GET\">Jump to page:<br>
<input type=\"hidden\" name=\"Tag\" value=\"$Tagq\">
<input type=\"hidden\" name=\"order_by\" value=\"$order_by\">
<input type=\"hidden\" name=\"order_dir\" value=\"$order_dir\">";
echo "<select name=\"startid\" class=\"ui-state-default ui-corner-all\">";
for ($p=0;$p<($no_pages+1);$p++) {
$this_p=$p+1;
$s_id=($p*$how_many_to_show)+1;
if ($s_id==$startid) {
echo "<option value=\"$s_id\" SELECTED>$this_p</option>\n";
}
else {
echo "<option value=\"$s_id\">$this_p</option>\n";
}
}
echo "</select>
<input type=submit value=\" Select \" class=\"fg-button ui-state-default ui-corner-all\">
</form>
</div>";
?>
<div class="span-24 last">
</div>
<div class="span-24 last">
<?php
require("include/bottom.php");
?>
</div>
</div>
</body>
</html>