-
Notifications
You must be signed in to change notification settings - Fork 10
/
ajax.suggest.php
63 lines (58 loc) · 2.23 KB
/
ajax.suggest.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
<?php
/**
* ------- U-232 Codename Trinity ----------*
* ---------------------------------------------*
* -------- @authors U-232 Team --------------*
* ---------------------------------------------*
* ----- @site https://u-232.duckdns.org/ ----*
* ---------------------------------------------*
* ----- @copyright 2020 U-232 Team ----------*
* ---------------------------------------------*
* ------------ @version V6 ------------------*
*/
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'bittorrent.php');
require_once INCL_DIR.'user_functions.php';
dbconn(true);
loggedinorreturn();
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
$orderby = 'ORDER BY ';
$order = [
0 => 'seeders',
1 => 'leechers',
2 => 'id',
3 => 'size',
4 => 'hits',
5 => 'vip',
];
$outhtml = "<style>.hover:hover{color:".($_POST["color"] ?? 'green')."}</style><table border='0' style='width:100%;border:0px;' ><tr><td>";
if (empty($_POST['search'])) {
die(false);
}
$wh = isset($_POST["order"]) ? (int)$_POST["order"] : 2;
$orderby .= isset($wh) && array_key_exists($wh, $order) ? sqlesc($order[$wh]) : 'id';
$limit = isset($_POST["limit"]) ? (int)$_POST["limit"] : 10;
$where = isset($_POST["search"]) ? sprintf('WHERE name LIKE \'%s\'', '%'.$_POST["search"].'%') : die(false);
$query = "SELECT id, name FROM torrents $where $orderby LIMIT $limit";
($res = sql_query("SELECT COUNT(id) FROM torrents $where")) || sqlerr(__FILE__, __LINE__);
$row = $res->fetch_row();
$count = $row[0];
if ($count > 0) {
($res = sql_query($query)) || sqlerr(__FILE__, __LINE__);
$ye = '';
$i = 1;
while ($row = $res->fetch_assoc()) {
if (empty($row['name'])) {
die(false);
}
$outhtml .= "$i : <a href='details.php?id=".(int)$row['id']."' class='hover'>".htmlsafechars($row['name'])."</a><br/>";
$i++;
}
echo $outhtml .= "</td></tr></table>";
} else {
die(false);
}
} else {
header("Location: {$TRINITY20['baseurl']}/index.php");
}
die(false);
?>