-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.php
74 lines (71 loc) · 1.9 KB
/
index.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
<?php
if ($_GET['qnet'] != "") {
$add = fopen("downloads/add/" . uniqid(), "w");
fwrite($add, $_GET['qnet'] . "\t" . $_GET['qnick'] . "\t" . $_GET['qnum'] . "\t" . $_GET['qname'] . "\n");
fclose($add);
header('Location: '.$_SERVER['PHP_SELF'].'?s='.$_GET['s']);
die();
}
?>
<h3>QUEUE</h3>
<pre>
<?php
echo file_get_contents('downloads/queue.txt');
?>
</pre>
<h3>DONE</h3>
<pre>
<?php
echo file_get_contents('downloads/done.txt');
?>
</pre>
<h3>FAILED</h3>
<pre>
<?php
echo file_get_contents('downloads/failed.txt');
?>
</pre>
<h3>Search</h3>
<form>
<input name="s" value="<?php echo $_GET["s"] ?>">
</form>
<?php if ($_GET["s"] != ""): ?>
<table>
<tr>
<th>Network</th>
<th>Channel</th>
<th>Nick</th>
<th>Number</th>
<th>Filename</th>
<th>Size</th>
<th>Gets</th>
<th>Date</th>
</tr>
<?php
$db = new SQLite3('downloads/xdcc.db');
$parts = explode(" ", $_GET["s"]);
function name_like($s) { return "name like '%$s%'"; }
$where = join(" and ", array_map("name_like", $parts));
$results = $db->query("SELECT * FROM offers where $where");
while ($row = $results->fetchArray()):
$query_params = array(
's' => $_GET["s"],
'qnet' => $row["network"],
'qnick' => $row["nick"],
'qnum' => $row["number"],
'qname' => $row["name"]
);
?>
<tr>
<td><?php echo $row["network"] ?></td>
<td><?php echo $row["channel"] ?></td>
<td><?php echo $row["nick"] ?></td>
<td><?php echo $row["number"] ?></td>
<td><a href="?<?php echo http_build_query($query_params) ?>"><?php echo $row["name"] ?></a></td>
<td><?php echo $row["size"] ?></td>
<td><?php echo $row["gets"] ?></td>
<td><?php echo $row["date"] ?></td>
</tr>
<?php endwhile; ?>
</table>
<?php endif ?>