Хорошо, тогда с вашего разрешения выкладываю ваш код встроенный в то, что работает у меня
<?php
ini_set("log_errors", 1); ini_set("error_log", $_SERVER['SCRIPT_FILENAME'].".log"); ini_set('error_reporting', E_ALL); ini_set("display_errors", 1);
$urlBase = "http://moonwalk.cc";$url = isset($_REQUEST['url' ]) ? $_REQUEST['url' ] : "" ;$type = isset($_REQUEST['type' ]) ? $_REQUEST['type'] : "m3u8";$urlonly = isset($_REQUEST['urlonly']);$attacha = isset($_REQUEST['at' ]);if (!$url) die("No moonwalk iframe url in the parameters.");
$cookies = array();
$userAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36";$headers = "Accept-Encoding: gzip, deflate, br\r\n" .
"Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n" .
"Referer: " . $url . "\r\n" .
"User-Agent: $userAgent\r\n";$page = LoadPage($url, "GET", $headers);$headers .= ":authority: moonwalk.cc\r\n";$data = GetRegexValue($page, "#VideoBalancer\((.*?)\);#is");
if (!$data) die("No VideoBalancer info in the loaded iframe.");
$options = JSDecode($data);$jsUrl = GetRegexValue($page, '#src="(.*?)"#');
if (!$jsUrl) die("Not found js url in the loaded iframe.");
$jsData = LoadPage($urlBase . $jsUrl, "GET", $headers);$postData = array();
$postData["a"] = (int)$options["partner_id"];
$postData["b"] = (int)$options["domain_id"];
$postData["c"] = false;
$postData["e"] = $options["video_token"];
$postData["f"] = $userAgent;
$data4Encrypt = json_encode($postData, JSON_UNESCAPED_SLASHES);
preg_match_all('#r=\[(.*?)\];#',$jsData,$keys);
preg_match('#e\[o\("0xb"\)\]="([^"]+)$k = explode(',',$keys[1][8]);
preg_match_all('#,e[\[\]"a-z0-9\(\)]+=([\[\]"a-z0-9\(\)\+.\.]
$iv = GetRegexValue($jsData, '#,\b[ira]="([^"]+)if (!$iv)
$iv = str_replace('"','',array_reduce($k, function ($a, $b) { return (string)strlen($a) > (string)strlen($b) ? $a : $b; }));
$tmpKey = array_reduce($e[1], function ($a, $b) { return (string)strlen($a) > (string)strlen($b) ? $a : $b; });
$sums = explode('+', $tmpKey);
$t = (int)GetRegexValue($jsData, '#}\(r,(\d{1,})
for (;--$t;)
{
array_push($k, array_shift($k));
}
$offset = GetRegexValue($jsData, '#r\[e\]};(.+),e[\[\]"a-z0-9\(\)]+=[\[\]"a-z0-9\(\)\+.\.]+;v
$k[array_search('"90fc8f081c"', $k)] = $k[0x0];
$key = '';
foreach($sums as $value){
$find = substr($value,2);
$find = trim($find, ']');
$find = str_replace('(','\(', $find);
$find = str_replace(')','\)', $find);
if(substr($find, 0,2) == 'o\\')
{
$of = GetRegexValue($jsData,'#e[\[\.]'.$find.'[\]]*=[o\("]+([0-9a-fx]+)["\)]+[,\W]#');
if (!$of )
{
$tmp = str_replace('"','',$k[intval(substr($find,4), 16)]);
$of = GetRegexValue($jsData,'#e[\[\.]'.$tmp.'[\]]*=[o\("]+([0-9a-fx]+)["\)]+[,\W]#');
if (!$of)
{
$tmp = $k[intval(substr($find,4), 16)];
$tmp = GetRegexValue($jsData,'#e[\[\.]'.$tmp.'[\]]*=[o\("]+([0-9a-fx]+)["\)]+[,\W]#');
$of = str_replace('"','',$k[intval(substr($tmp,2), 16)]);
}
$key .= str_replace('"','',$of);
continue;
}
if (substr($of,0,2) !== '0x')
$key .= $of;
else
$key .= str_replace('"','',$k[intval(substr($of,2), 16)]);
}
else if (substr($value, 0,2) == 'e[')
{
$tmp = 'o\("0x'.dechex(array_search($find, $k)).'"\)';
$of = GetRegexValue($jsData,'#e[\[\.]'.$tmp.'[\]]*=[o\("]+([0-9a-fx]+)["\)]+[,\W]#');
if(!$of)
$key .= str_replace('"','',$k[array_search($find, $k)]);
else
$key .= str_replace('"','',$k[intval(substr($of,2), 16)]);
}
else if (substr($value, 0,2) == 'e.')
{
$tmp = 'o\("0x'.dechex(array_search('"'.$find.'"', $k)).'"\)';
$of = GetRegexValue($jsData,'#e[\[\.]'.$tmp.'[\]]*=[o\("]+([0-9a-fx]+)["\)]+[,\W]#');
if(!$of)
$key .= str_replace('"','',$k[array_search($find, $k)]);
else
$key .= str_replace('"','',$k[intval(substr($of,2), 16)]);
}
}
$crypted = openssl_encrypt($data4Encrypt, 'aes-256-cbc', hex2bin($key), 0, hex2bin($iv));$data = LoadPage($urlBase . "/vs", "POST", $headers, "q=".urlencode($crypted));
if ($type=="json") die($data);$answerObject = json_decode($data, TRUE);$link = "";
if (isset($answerObject["mp4" ]) && $type=="mp4") $link = $answerObject["mp4" ];
if (isset($answerObject["m3u8"]) && $link=="" ) $link = $answerObject["m3u8"];if ($link) {
if ($urlonly)
$data = $link;
else { $data = LoadPage($link, "GET", $headers);
if ($attacha) {
header("Content-Length: ".strlen($data));
header("Content-Disposition: attachment; filename=play.$type");
}
}
} echo $data;function LoadPage($url, $method, $headers, $data='') {
global $cookies;
$coo = "";
foreach($cookies as $key => $val) $coo .= $key."=".urlencode($val)."; ";
if ($coo) $headers .= "Cookie: $coo\r\n";
$options = array();
$options['http'] = array('method' => $method ,
'header' => $headers,
'content'=> $data );
$context = stream_context_create($options);
$page = file_get_contents($url, false, $context);
foreach($http_response_header as $c => $h) {
if (stristr($h, 'content-encoding') and stristr($h, 'gzip')) {
$page = gzdecode($page);
} else if (preg_match('#^Set-Cookie:\s*([^;] parse_str($matches[1], $tmp);
$cookies += $tmp;
}
}
return $page;
}function GetRegexValue($text, $pattern, $group=1) {
if (preg_match($pattern, $text, $matches))
return $matches[$group];
return "";
}function JSDecode($data) {
$data = str_replace("encodeURIComponent(", "", $data); $data = str_replace("'),", "',", $data);
$data = str_replace("'", "\"" , $data); $data = str_replace(["\n","\r"], "", $data); $data = preg_replace('/([^\w"\.])(\w+)\s*:/','$1"$2":', $data); $data = preg_replace('/("\w+")\s*:\s*([\w\.]+)/' ,'$1:"$2"', $data); $data = preg_replace('/(,\s*)(})/','$2', $data); $json = json_decode($data, true);
return $json;
}
?>
Сегодня, после смены ключей, ваш код прекрасно продолжил работать. Браво!