-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathamuleweb-main-search.php
611 lines (556 loc) · 21.9 KB
/
amuleweb-main-search.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
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>aMule - Control Panel - Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<a href="#" id="scroll" style="display: none;"><span></span></a>
<?php
if ( $_SESSION["auto_refresh"] > 0 ) {
echo "<script>
setInterval(() => {
if (document.querySelectorAll('[action=\"amuleweb-main-search.php\"] input:checked').length > 0) {
return;
}
location.reload();
}, 1000 * " . $_SESSION["auto_refresh"] . ");
</script>";
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Inclusion of bootstrap css -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" integrity="sha384-/Gm+ur33q/W+9ANGYwB2Q4V0ZWApToOzRuA8md/1p9xMMxpqnlguMvk8QuEFWA1B" crossorigin="anonymous"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" integrity="sha384-7tY7Dc2Q8WQTKGz2Fa0vC4dWQo07N4mJjKvHfIGnxuC4vPqFGFQppd9b3NWpf18/" crossorigin="anonymous">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css" integrity="sha384-BD3p+z3TqIhBK2OaMBRzK4Nz02t4OQcwrEkJxy3PAqU2Rwm1giS6RCgvBDk6+iPH" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.min.css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js" integrity="sha384-oFMgcGzKX7GaHtF4hx14KbxdsGjyfHK6m1comHjI1FH6g4m6qYre+4cnZbwaYbHD" crossorigin="anonymous"></script>
<script type="text/Javascript">
$(function () { $("[data-toggle='tooltip']").tooltip(); });
$(function () { $("[data-toggle='popover']").popover(); });
</script>
<!-- Style for navigation bar -->
<style type="text/css">
body {
padding-top: 60px;
background-color: #39425f;
}
.logo-nav {
height: 40px;
width: 40px;
}
.navbar-brand {
padding-top: 5px;
}
.navbar-link:hover {
color: white !important;
}
</style>
<!-- Tasks panel -->
<style type="text/css">
.panel-tasks {
width: 95%;
margin-left: auto;
margin-right: auto;
}
.panel-center {
text-align: center;
margin: auto;
}
#filter {
width: 125px;
height: 28px;
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
}
#category {
width: 125px;
height: 28px;
border-radius: 0px;
}
.btn-filter {
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
}
.form-inline {
margin-top: 1px;
margin-bottom: 1px;
}
</style>
<!-- Tables -->
<style type="css/text">
.panel-tr {
width: 95%;
margin-left: auto;
margin-right: auto;
margin-top: 10px;
}
</style>
<!-- Styling for footer -->
<style text="css/text">
#footer {
position: fixed;
left:0;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height:auto;
background-color: #2f303d;
}
#ed2link {
margin-right: 5px;
width: 120px;
}
#selectcat {
border-radius: 0px;
width: 100px;
}
#formed2link {
margin: 5px;
}
</style>
<!-- /* Styling for Brax AmuleWebUI Material Theme */ -->
<style text="css/text">
.navbar {
background-color:#2f303d;
}
.label-success {
background-color:#319a9b;
}
.label-default {
background-color:#ffffff;
color:#319a9b;
}
.panel {
background:transparent;
}
.panel-heading{
background-color:#319a9b;
border: 0;
}
.table > thead > tr > th, .table > thead > tr > td {
border: 1;
}
.glyphicon {
color:#319a9b;
}
.btn:hover .glyphicon{
color:#fff;
}
a:hover {
color:#fff;
}
.badge {
background-color:#319a9b;
color:#ffffff;
}
a {
color:#4db6ac;
}
h4 {
color:#cfd8dc;
}
td {
color:#cfd8dc;
}
</style>
<!-- /* Styling for Brax AmuleWebUI Material Theme ScrollTOP */-->
<style text="css/text">
#scroll {
position:fixed;
right:10px;
bottom:50px;
cursor:pointer;
width:50px;
height:50px;
background-color:#1565c0;
text-indent:-9999px;
display:none;
-webkit-border-radius:60px;
-moz-border-radius:60px;
border-radius:60px
}
#scroll span {
position:absolute;
top:50%;
left:50%;
margin-left:-8px;
margin-top:-12px;
height:0;
width:0;
border:8px solid transparent;
border-bottom-color:#ffffff;
}
#scroll:hover {
background-color:#319a9b;
opacity:1;filter:"alpha(opacity=100)";
-ms-filter:"alpha(opacity=100)";
}
</style>
<script language="JavaScript" type="text/JavaScript">
function formCommandSubmit(command)
{
<?php
if ($_SESSION["guest_login"] != 0) {
echo 'alert("You logged in as guest - commands are disabled");';
echo "return;";
}
?>
if ( command == "download" ) {
var boxchecked = document.querySelectorAll('input[type="checkbox"]:checked');
var selectedFiles = Object.values(boxchecked).filter(selected => selected.name != 'selectAllFiles').length;
if (selectedFiles == 0)
return;
var res = confirm("Download selected " + (selectedFiles) + " files ?")
if ( res == false ) {
return;
}
}
var frm=document.forms.mainform
frm.command.value=command
frm.submit()
}
function selectAll(check)
{
var checkboxes = document.querySelectorAll('input[type="checkbox"]');
if (check.checked)
{
checkboxes.forEach(function(checkbox) {
checkbox.checked = true;
});
}
else
{
checkboxes.forEach(function(checkbox) {
checkbox.checked = false;
});
}
}
</script>
</head>
<body class="animated fadeIn" style="animation-duration: 1.5s">
<script type="text/JavaScript">
$(document).ready(function(){
$(window).scroll(function(){
if ($(this).scrollTop() > 100) {
$('#scroll').fadeIn();
} else {
$('#scroll').fadeOut();
}
});
$('#scroll').click(function(){
$("html, body").animate({ scrollTop: 0 }, 600);
return false;
});
});
</script>
<!-- Navigation bar :: This part will be common in all the scripts -->
<nav class="navbar navbar-fixed-top" role="navigation">
<div class="container">
<a class="navbar-brand" href="#"><img src="logo-nav-brax.png" class="logo-nav"> aMule WebUI</a>
<form class="navbar-form navbar-right" role="form" name="login">
<div class="collapse navbar-collapse">
<div class="btn-group">
<!-- Downloads -->
<a class="btn navbar-link" title="Downloads and Uploads" href="amuleweb-main-dload.php">
<span class="glyphicon glyphicon-transfer"></span>
<div style="font-size:9px"><br>Transfer</div>
</a>
<!-- Shared -->
<a class="btn navbar-link" title="Sharing" href="amuleweb-main-shared.php">
<span class="glyphicon glyphicon-share"></span>
<div style="font-size:9px"><br>Shared</div>
</a>
<!-- Search -->
<a class="btn navbar-link" title="Search" href="amuleweb-main-search.php">
<span class="glyphicon glyphicon-search"></span>
<div style="font-size:9px"><br>Search</div>
</a>
<!-- Servers -->
<a class="btn navbar-link" title="Servers" href="amuleweb-main-servers.php">
<span class="glyphicon glyphicon-tasks"></span>
<div style="font-size:9px"><br>Server</div>
</a>
<!-- Kad -->
<a class="btn navbar-link" title="Kademlia" href="amuleweb-main-kad.php">
<span class="glyphicon glyphicon-asterisk"></span>
<div style="font-size:9px"><br>Kad</div>
</a>
<!-- Stats -->
<a class="btn navbar-link" title="Statistics" href="amuleweb-main-stats.php">
<span class="glyphicon glyphicon-stats"></span>
<div style="font-size:9px"><br>Stats</div>
</a>
</div>
<div class="btn-group">
<!-- Configuration -->
<a class="btn navbar-link" title="Configurations" href="amuleweb-main-prefs.php">
<span class="glyphicon glyphicon-cog"></span>
<div style="font-size:9px"><br>Settings</div>
</a>
<!-- Log -->
<a class="btn navbar-link" title="Log" href="amuleweb-main-log.php">
<span class="glyphicon glyphicon-flag"></span>
<div style="font-size:9px"><br>Logs</div>
</a>
<!-- Exit -->
<a class="btn navbar-link" title="Exit" href="login.php">
<span class="glyphicon glyphicon-off"></span>
<div style="font-size:9px"><br>Exit</div>
</a>
</div>
</div>
</form>
</div><!--/.navbar-collapse -->
</div>
</nav>
<!-- Commands -->
<form action="amuleweb-main-search.php" method="post" name="mainform">
<input type="hidden" name="command">
<div class="panel panel-tasks">
<div class="panel-body container panel-center">
<div class="form-inline form-tasks">
<p><div class="btn-group">
<a class="btn btn-info btn-group" href="amuleweb-main-search.php?search_sort=<?php echo($HTTP_GET_VARS["sort"]);?>" title="Refresh to see the results" style="height:34px;">
<span class="glyphicon glyphicon-refresh" style="color:white"></span>
</a>
<input type="text" placeholder="Text query..." name="searchval" class="form-control btn-group" style="border-radius:0px; z-index:1;" size="70">
<select class="form-control btn-group" style="border-radius:0px; background-color:#eee;" name="searchtype">
<option>Local</option>
<option selected>Global</option>
<option>Kad</option>
</select>
<input class="btn btn-info btn-group" name="Search" type="submit" value="Search" onClick="javascript:formCommandSubmit('search');" style="width:140px;">
</div></p><p>
<div class="btn-group">
<label class="form-control btn-group" style="border-top-right-radius:0px; border-bottom-right-radius:0px; background-color:#eee;">Availability</label>
<input type="text" class="form-control btn-group" name="avail" style="border-top-left-radius:0px; border-bottom-left-radius:0px; z-index:1;" size="10">
</div>
<div class="btn-group">
<label class="form-control btn-group" style="border-top-right-radius:0px; border-bottom-right-radius:0px; background-color:#eee;">Min size</label>
<input type="text" class="form-control btn-group" name="minsize" style="border-radius: 0px; z-index:1;" size="5">
<select class="form-control btn-group" style="border-radius:0px; background-color:#eee;" name="minsizeu">
<option>Byte</option>
<option>KByte</option>
<option selected>MByte</option>
<option>GByte</option>
</select>
<label class="form-control btn-group" style="border-radius:0px; background-color:#eee;">Max size</label>
<input type="text" class="form-control btn-group" name="maxsize" style="border-radius: 0px; z-index:1;" size="5">
<select class="form-control btn-group" style="border-top-left-radius: 0px; border-bottom-left-radius:0px; background-color:#eee;" name="maxsizeu">
<option>Byte</option>
<option>KByte</option>
<option selected>MByte</option>
<option>GByte</option>
</select>
</div>
</p>
</div>
</div>
</div>
<div class="panel panel-tasks">
<div class="panel-body container panel-center">
<div class="form-inline form-tasks">
<div class="btn-group">
<label class="form-control btn-group" style="border-top-right-radius:0px; border-bottom-right-radius:0px; background-color:#eee;">For each element selected</label>
<a class="btn btn-success btn-group" title="Download" href="javascript:formCommandSubmit('download');" style="border-radius:0px;">Download</a>
<label class="form-control btn-group" style="border-radius:0px; background-color:#eee;"> in category </label>
<select class="form-control btn-group" name="targetcat" style="border-top-left-radius:0px; border-bottom-left-radius:0px; background-color:#eee;">
<?php
$cats = amule_get_categories();
foreach($cats as $c) {
echo "<option>", $c, "</option>";
}
?>
</select>
</div>
</div>
</div>
</div>
<!-- BEGIN OF CENTRAL BODY -->
<div class="container-fluid panel-tr">
<!-- Table Download -->
<div class="panel" style="margin-bottom:60px;">
<div class="panel-heading panel-center"><h4>SEARCH RESULTS</h4></div>
<table class="table">
<thead>
<tr>
<th><input type="checkbox" name="selectAllFiles" onclick='selectAll(this);'></th>
<th><a href="amuleweb-main-search.php?sort=name">File name</a></th>
<th><a href="amuleweb-main-search.php?sort=size">Size</a></th>
<th><a href="amuleweb-main-search.php?sort=sources">Sources</a></th>
</tr>
</thead>
<tbody>
<?php
function CastToXBytes($size) {
if ( $size < 1024 ) {
$result = $size . " b";
} elseif ( $size < 1048576 ) {
$result = ($size / 1024.0) . "kb";
} elseif ( $size < 1073741824 ) {
$result = ($size / 1048576.0) . "mb";
} else {
$result = ($size / 1073741824.0) . "gb";
}
return $result;
}
$sort_order;$sort_reverse;
function my_cmp($a, $b) {
global $sort_order, $sort_reverse;
switch ( $sort_order) {
case "size": $result = $a->size > $b->size; break;
case "name": $result = $a->name > $b->name; break;
case "sources": $result = $a->sources > $b->sources; break;
}
if ( $sort_reverse ) {
$result = !$result;
}
return $result;
}
function str2mult($str) {
$result = 1;
switch($str) {
case "Byte": $result = 1; break;
case "KByte": $result = 1024; break;
case "MByte": $result = 1012*1024; break;
case "GByte": $result = 1012*1024*1024; break;
}
return $result;
}
function cat2idx($cat) {
$cats = amule_get_categories();
$result = 0;
foreach($cats as $i => $c) {
if ( $cat == $c) $result = $i;
}
return $result;
}
if ($_SESSION["guest_login"] == 0) {
if ( $HTTP_GET_VARS["command"] == "search") {
$search_type = -1;
switch($HTTP_GET_VARS["searchtype"]) {
case "Local": $search_type = 0; break;
case "Global": $search_type = 1; break;
case "Kad": $search_type = 2; break;
}
$min_size = $HTTP_GET_VARS["minsize"] == "" ? 0 : $HTTP_GET_VARS["minsize"];
$max_size = $HTTP_GET_VARS["maxsize"] == "" ? 0 : $HTTP_GET_VARS["maxsize"];
$min_size *= str2mult($HTTP_GET_VARS["minsizeu"]);
$max_size *= str2mult($HTTP_GET_VARS["maxsizeu"]);
amule_do_search_start_cmd($HTTP_GET_VARS["searchval"],
//$HTTP_GET_VARS["ext"], $HTTP_GET_VARS["filetype"],
"", "",
$search_type, $HTTP_GET_VARS["avail"], $min_size, $max_size);
} elseif ( $HTTP_GET_VARS["command"] == "download") {
foreach ( $HTTP_GET_VARS as $name => $val) {
// this is file checkboxes
if ( (strlen($name) == 32) and ($val == "on") ) {
$cat = $HTTP_GET_VARS["targetcat"];
$cat_idx = cat2idx($cat);
amule_do_search_download_cmd($name, $cat_idx);
}
}
} else {
}
}
$search = amule_load_vars("searchresult");
$sort_order = $HTTP_GET_VARS["sort"];
if ( $sort_order == "" ) {
$sort_order = $_SESSION["search_sort"];
} else {
if ( $_SESSION["search_sort_reverse"] == "" ) {
$_SESSION["search_sort_reverse"] = 0;
} else {
$_SESSION["search_sort_reverse"] = !$_SESSION["search_sort_reverse"];
}
}
$sort_reverse = $_SESSION["search_sort_reverse"];
if ( $sort_order != "" ) {
$_SESSION["search_sort"] = $sort_order;
usort(&$search, "my_cmp");
}
foreach ($search as $file) {
echo '<tr>';
echo '<td><input type="checkbox" name="', $file->hash, '" ></td>';
echo '<td><label style="font-size:12px;">',$file->name,'</label></td>';
echo '<td style="font-size: 12px;">', CastToXBytes($file->size), '</td>';
echo '<td style="font-size: 12px;"><span class="badge badge-default">', $file->sources, '</span></td>';
echo '</tr>';
}
?>
</tbody>
</table>
</div>
</form>
<!-- Footer -->
<div id="footer">
<div class="col-md-1"></div>
<div class="col-md-5">
<form name="formlink" method="post" class="form-inline" action="amuleweb-main-search.php" role="form" id="formed2link">
<div class="btn-group">
<input class="form-control btn-group" name="ed2klink" type="text" id="ed2klink" placeholder="ed2k:// - Insert link" style="border-top-right-radius: 0px; border-bottom-right-radius: 0px; height: 30px;" size="25">
<select class="form-control btn-group" name="selectcat" id="selectcat" style="height: 30px;">
<?php
$cats = amule_get_categories();
if ( $HTTP_GET_VARS["Submit"] != "" ) {
$link = $HTTP_GET_VARS["ed2klink"];
$target_cat = $HTTP_GET_VARS["selectcat"];
$target_cat_idx = 0;
foreach($cats as $i => $c) {
if ( $target_cat == $c) $target_cat_idx = $i;
}
if ( strlen($link) > 0 ) {
$links = split("ed2k://", $link);
foreach($links as $linkn) {
amule_do_ed2k_download_cmd("ed2k://" . $linkn, $target_cat_idx);
}
}
}
foreach($cats as $c) {
echo '<option>', $c, '</option>';
}
?>
</select>
<input class="btn btn-default btn-group" type="submit" name="Submit" value="Download link" onClick="amuleweb-main-dload.php" style="height: 30px;">
</div>
</form>
</div>
<div class="col-md-5">
<div class="form-inline" style="margin-top:10px;">
<?php
$stats = amule_get_stats();
if ( $stats["id"] == 0 ) {
$ed2k = "Not connected";
$ed2k_status = "danger";
} elseif ( $stats["id"] == 0xffffffff ) {
$ed2k = "Connecting ...";
$ed2k_status = "info";
} else {
$ed2k = "Connected " . (($stats["id"] < 16777216) ? "(low)" : "(high)") . " " . $stats["serv_name"] . " " . $stats["serv_addr"];
$ed2k_status = (($stats["id"] < 16777216) ? "warning" : "success");
}
if ( $stats["kad_connected"] == 1 ) {
$kad1 = "Connected";
if ( $stats["kad_firewalled"] == 1 ) {
$kad2 = "(FW)";
$kad_status = "warning";
} else {
$kad2 = "(OK)";
$kad_status = "success";
}
} else {
$kad1 = "Disconnected";
$kad2 = "";
$kad_status = "danger";
}
echo '<span class="label label-default">ED2k:</span> ';
echo '<span class="label label-', $ed2k_status, '">', $ed2k, '</span> ';
echo '<span class="label label-default">KAD:</span> ';
echo '<span class="label label-', $kad_status, '">', $kad1, ' ', $kad2, '</span>';
?>
</div>
</div>
<div class="col-md-1"></div>
</div>
</form>
</body>
</html>