add support for cucked urls
This commit is contained in:
1 parent
e03c582f74
commit
ffb1fc00f3
8 files changed
+223
-318
No files matched your search
+18
-5
@@ -5,8 +5,8 @@ $resolver = new resolver();
|
||||
class resolver{
|
||||
|
||||
public const resolvers = [
|
||||
"sc",
|
||||
"google"
|
||||
"google",
|
||||
"brave"
|
||||
];
|
||||
|
||||
public function __construct(){
|
||||
@@ -20,7 +20,6 @@ class resolver{
|
||||
){
|
||||
|
||||
$this->do400("Missing or invalid scraper");
|
||||
return;
|
||||
}
|
||||
|
||||
if(
|
||||
@@ -29,25 +28,37 @@ class resolver{
|
||||
){
|
||||
|
||||
$this->do400("Missing or invalid target");
|
||||
return;
|
||||
}
|
||||
|
||||
if(
|
||||
!isset($_GET["sig"]) ||
|
||||
!is_string($_GET["sig"])
|
||||
){
|
||||
|
||||
$this->do400("Missing or malformed signature");
|
||||
}
|
||||
|
||||
$scraper = $_GET["scraper"];
|
||||
$target = $_GET["target"];
|
||||
$signature = $_GET["sig"];
|
||||
|
||||
try{
|
||||
|
||||
include "resolve/{$scraper}.php";
|
||||
$resolver = new $scraper();
|
||||
$link = $resolver->resolve($target);
|
||||
$link = $resolver->resolve($target, $signature);
|
||||
|
||||
if(
|
||||
is_string($link) &&
|
||||
!empty($link)
|
||||
){
|
||||
|
||||
http_response_code(302);
|
||||
header("Location: {$link}");
|
||||
echo 'If your ass is not getting redirected, <a href="' . htmlspecialchars($link) . '">click here</a>.';
|
||||
}else{
|
||||
|
||||
$this->do404("Fuck! Failed to resolve URL: Scraper returned no URL");
|
||||
}
|
||||
}catch(Exception $error){
|
||||
|
||||
@@ -60,6 +71,7 @@ class resolver{
|
||||
header("Content-Type: text/plain");
|
||||
http_response_code(400);
|
||||
echo htmlspecialchars($message);
|
||||
die();
|
||||
}
|
||||
|
||||
public function do404($message){
|
||||
@@ -67,5 +79,6 @@ class resolver{
|
||||
header("Content-Type: text/plain");
|
||||
http_response_code(404);
|
||||
echo htmlspecialchars($message);
|
||||
die();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user