Created
July 26, 2024 11:42
-
-
Save dvygolov/0bb60265072362fb0d49d873c0e93aea to your computer and use it in GitHub Desktop.
Place this file somewhere in your Keitaro and use it like https://youtracker.com/path/shakes.php?q={STREAMCODE}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ShakesRedirectCorrector | |
{ | |
private function get_headers($url): array | |
{ | |
$ch = curl_init(); | |
$headers = []; | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); | |
curl_setopt($ch, CURLOPT_HEADERFUNCTION, | |
function ($curl, $header) use (&$headers) { | |
$len = strlen($header); | |
$header = explode(':', $header, 2); | |
if (count($header) < 2) // ignore invalid headers | |
return $len; | |
$headers[strtolower(trim($header[0]))][] = trim($header[1]); | |
return $len; | |
} | |
); | |
$data = curl_exec($ch); | |
return $headers; | |
} | |
public function get_https_redirect(): string | |
{ | |
$queries = array(); | |
parse_str($_SERVER['QUERY_STRING'], $queries); | |
$url = "http://streamshakes.com/".$queries['q']; | |
$prefix= "http://"; | |
$headers = $this->get_headers($url); | |
$location = $headers['location'][0]; | |
if (strpos($location, $prefix) === 0) | |
$location = "https://" . str_replace($prefix, "", $location); | |
return $location; | |
} | |
} | |
$r = new ShakesRedirectCorrector(); | |
$location = $r->get_https_redirect(); | |
header("Location: {$location}"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment