do400("Missing or invalid scraper"); } if( !isset($_GET["target"]) || !is_string($_GET["target"]) ){ $this->do400("Missing or invalid target"); } 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, $signature); if( is_string($link) && !empty($link) ){ http_response_code(302); header("Location: {$link}"); echo 'If your ass is not getting redirected, click here.'; }else{ $this->do404("Fuck! Failed to resolve URL: Scraper returned no URL"); } }catch(Exception $error){ $this->do404("Fuck! Failed to resolve URL: " . $error->getMessage()); } } public function do400($message){ header("Content-Type: text/plain"); http_response_code(400); echo htmlspecialchars($message); die(); } public function do404($message){ header("Content-Type: text/plain"); http_response_code(404); echo htmlspecialchars($message); die(); } }