Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php error_reporting(0); header('Content-type: application/json; charset=utf8'); $ur..

Decoded Output download

<?php 
error_reporting(0); 
header('Content-type: application/json; charset=utf8'); 
 
$url = $_GET['url'] ?? ''; 
if (empty($url)) { 
    die(json_encode(['code' => 400, 'msg' => 'URL!'], JSON_UNESCAPED_UNICODE)); 
} 
 
$id = str_replace('/', '', parse_url($url, PHP_URL_PATH)); 
$roomurl = "https://mp.huya.com/cache.php?m=Live&do=profileRoom&roomid=$id"; 
$json = json_decode(file_get_contents($roomurl), true); 
$data = $json['data']; 
$uid = $data['profileInfo']['uid']; 
$streamname = $data['stream']['baseSteamInfoList'][0]['sStreamName']; 
$dataurl = $data['stream']['flv']['multiLine'][array_rand($data['stream']['flv']['multiLine'])]['url']; 
$burl = explode('?', $dataurl)[0]; 
 
$seqid = strval(intval($uid) + intval(microtime(true) * 1000)); 
$ss = md5("{$seqid}|tars_wap|102"); 
$wsTime = dechex(time() + 21600); 
$fm = str_replace(["$0", "$1", "$2", "$3"], [$uid, $streamname, $ss, $wsTime], "DWq8BcJ3h6DJt6TY_$0_$1_$2_$3"); 
$wsSecret = md5($fm); 
 
$p = http_build_query([ 
    "wsSecret" => $wsSecret, 
    "wsTime" => $wsTime, 
    "ctype" => 'tars_wap', 
    "seqid" => $seqid, 
    "uid" => $uid, 
    "fs" => "bgct", 
    "ver" => "1", 
    "t" => '102' 
]); 
 
$vurl = $burl . '?' . $p; 
if (empty($vurl) || $vurl === $url) { 
    $obj->code = 404; 
    $obj->msg = ''; 
    $obj->link = $url; 
} else { 
    $obj->code = 200; 
    $obj->msg = ''; 
    $obj->url = $vurl; 
    $obj->link = $url; 
} 
echo json_encode($obj, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); ?>

Did this file decode correctly?

Original Code

<?php
error_reporting(0);
header('Content-type: application/json; charset=utf8');

$url = $_GET['url'] ?? '';
if (empty($url)) {
    die(json_encode(['code' => 400, 'msg' => 'URL!'], JSON_UNESCAPED_UNICODE));
}

$id = str_replace('/', '', parse_url($url, PHP_URL_PATH));
$roomurl = "https://mp.huya.com/cache.php?m=Live&do=profileRoom&roomid=$id";
$json = json_decode(file_get_contents($roomurl), true);
$data = $json['data'];
$uid = $data['profileInfo']['uid'];
$streamname = $data['stream']['baseSteamInfoList'][0]['sStreamName'];
$dataurl = $data['stream']['flv']['multiLine'][array_rand($data['stream']['flv']['multiLine'])]['url'];
$burl = explode('?', $dataurl)[0];

$seqid = strval(intval($uid) + intval(microtime(true) * 1000));
$ss = md5("{$seqid}|tars_wap|102");
$wsTime = dechex(time() + 21600);
$fm = str_replace(["$0", "$1", "$2", "$3"], [$uid, $streamname, $ss, $wsTime], "DWq8BcJ3h6DJt6TY_$0_$1_$2_$3");
$wsSecret = md5($fm);

$p = http_build_query([
    "wsSecret" => $wsSecret,
    "wsTime" => $wsTime,
    "ctype" => 'tars_wap',
    "seqid" => $seqid,
    "uid" => $uid,
    "fs" => "bgct",
    "ver" => "1",
    "t" => '102'
]);

$vurl = $burl . '?' . $p;
if (empty($vurl) || $vurl === $url) {
    $obj->code = 404;
    $obj->msg = '';
    $obj->link = $url;
} else {
    $obj->code = 200;
    $obj->msg = '';
    $obj->url = $vurl;
    $obj->link = $url;
}
echo json_encode($obj, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);

Function Calls

None

Variables

None

Stats

MD5 65f0668696cc80c1293dba94d33c91f5
Eval Count 0
Decode Time 70 ms