2023-07-22 13:41:14 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2024-06-07 19:47:08 -05:00
|
|
|
Initialize random stuff
|
2023-07-22 13:41:14 -05:00
|
|
|
*/
|
2023-11-07 08:04:56 -05:00
|
|
|
include "data/config.php";
|
|
|
|
|
2023-07-22 13:41:14 -05:00
|
|
|
include "lib/frontend.php";
|
|
|
|
$frontend = new frontend();
|
|
|
|
|
|
|
|
[$scraper, $filters] = $frontend->getscraperfilters("news");
|
|
|
|
|
|
|
|
$get = $frontend->parsegetfilters($_GET, $filters);
|
|
|
|
|
2023-10-16 01:30:43 -05:00
|
|
|
/*
|
|
|
|
Captcha
|
|
|
|
*/
|
2024-02-17 23:22:19 -05:00
|
|
|
include "lib/bot_protection.php";
|
|
|
|
new bot_protection($frontend, $get, $filters, "news", true);
|
2023-07-22 13:41:14 -05:00
|
|
|
|
|
|
|
$payload = [
|
2024-02-17 23:22:19 -05:00
|
|
|
"timetaken" => microtime(true),
|
2023-07-22 13:41:14 -05:00
|
|
|
"class" => "",
|
|
|
|
"right-left" => "",
|
|
|
|
"right-right" => "",
|
|
|
|
"left" => ""
|
|
|
|
];
|
|
|
|
|
|
|
|
try{
|
|
|
|
$results = $scraper->news($get);
|
|
|
|
|
|
|
|
}catch(Exception $error){
|
|
|
|
|
2024-03-24 21:31:19 -05:00
|
|
|
$frontend->drawscrapererror($error->getMessage(), $get, "news", $payload["timetaken"]);
|
2023-07-22 13:41:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
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);
|