-
Notifications
You must be signed in to change notification settings - Fork 0
/
news.php
86 lines (62 loc) · 1.62 KB
/
news.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
<?php
/*
Initialize random shit
*/
include "data/config.php";
include "lib/frontend.php";
$frontend = new frontend();
[$scraper, $filters] = $frontend->getscraperfilters("news");
$get = $frontend->parsegetfilters($_GET, $filters);
/*
Captcha
*/
include "lib/bot_protection.php";
new bot_protection($frontend, $get, $filters, "news", true);
$payload = [
"timetaken" => microtime(true),
"class" => "",
"right-left" => "",
"right-right" => "",
"left" => ""
];
try{
$results = $scraper->news($get);
}catch(Exception $error){
$frontend->drawscrapererror($error->getMessage(), $get, "news", $payload["timetaken"]);
}
/*
Populate links
*/
if(count($results["news"]) === 0){
$payload["left"] =
'<div class="infobox">' .
"<h1>Nobody here but us chickens!</h1>" .
'Have you tried:' .
'<ul>' .
'<li>Using a different scraper</li>' .
'<li>Using fewer keywords</li>' .
'<li>Defining broader filters (Is NSFW turned off?)</li>' .
'</ul>' .
'</div>';
}
foreach($results["news"] as $news){
$greentext = [];
if($news["date"] !== null){
$greentext[] = date("jS M y @ g:ia", $news["date"]);
}
if($news["author"] !== null){
$greentext[] = htmlspecialchars($news["author"]);
}
if(count($greentext) !== 0){
$greentext = implode(" • ", $greentext);
}else{
$greentext = null;
}
$n = null;
$payload["left"] .= $frontend->drawtextresult($news, $greentext, $n, $get["s"]);
}
if($results["npt"] !== null){
$payload["left"] .=
'<a href="' . $frontend->htmlnextpage($get, $results["npt"], "news") . '" class="nextpage">Next page ></a>';
}
echo $frontend->load("search.html", $payload);