-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsearch.php
More file actions
82 lines (61 loc) · 1.89 KB
/
search.php
File metadata and controls
82 lines (61 loc) · 1.89 KB
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
<?php
include_once('global.php');
$token = regenToken($pseudo, $password, $w);
if (trim($token) == "") {
handleError('token', $w);
}
$res = null;
if(strpos(formatQuery($query), "@today") === 0) {
$torrents = searchT411Top($token, "today");
} elseif(strpos(formatQuery($query), "@week") === 0) {
$torrents = searchT411Top($token, "week");
} elseif(strpos(formatQuery($query), "@month") === 0) {
$torrents = searchT411Top($token, "month");
} elseif(strpos(formatQuery($query), "@100") === 0) {
$torrents = searchT411Top($token, "100");
} elseif(strpos(formatQuery($query), "#") === 0) {
$idCat = extractIdCategory($query, $w);
$query = explode(" ", trim($query));
array_shift($query);
$query = implode(" ", $query);
$res = searchT411Cat($query, $idCat, $token);
if(isset($res->code)) {
handleError($res->code, $w);
}
if(!isset($res->torrents) || count($res->torrents) == 0) {
handleError("empty", $w);
}
$torrents = $res->torrents;
} else {
$res = searchT411($query, $token);
if(isset($res->code)) {
handleError($res->code, $w);
}
if(!isset($res->torrents) || count($res->torrents) == 0) {
handleError("empty", $w);
}
$torrents = $res->torrents;
}
$tab_all = array();
foreach ($torrents as $item) {
$tab_all[] = array(
'id' => $item->id,
'name' => $item->name,
'size' => $item->size,
'seeders' => $item->seeders,
'leechers' => $item->leechers,
'category' => $item->category
);
}
foreach ($tab_all as $key => $row) {
$seeders[$key] = $row['seeders'];
}
array_multisort($seeders, SORT_DESC, $tab_all);
foreach ($tab_all as $index => $item) {
if($index > 100) {
break;
}
$catName = getCategoryName($item["category"]);
$w->result($item["id"], $item["id"], $item["name"], size_formatted($item["size"]) . ', ' . $item["seeders"] . ' seeders, ' . $item["leechers"] . ' leechers, in ' . $catName, 'icon.png');
}
echo $w->toxml();