Created
December 27, 2015 15:24
-
-
Save keepanote/76367bdba553be1e07c2 to your computer and use it in GitHub Desktop.
虾米音乐 外部链接 - PHP 解析
This file contains 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 | |
// Save as: xiami.php | |
// Format: http://localhost/xiami.php?id=1769726699.mp3 | |
ERROR_REPORTING(0); | |
preg_match('/\d+/i', $_GET['id'], $id_matches); | |
$id = $id_matches[0]; | |
$content = file_get_contents('http://www.xiami.com/widget/xml-single/sid/'.$id); | |
preg_match("/<\!\[CDATA\[([^\]].*)\]\]><\/location>/i", $content, $location); | |
$xiami = ipcxiami($location[1]); | |
header('Content-Type:application/force-download'); | |
header("Location:".$xiami); | |
function ipcxiami($location) { | |
$count = (int)substr($location, 0, 1); | |
$url = substr($location, 1); | |
$line = floor(strlen($url) / $count); | |
$loc_5 = strlen($url) % $count; | |
$loc_6 = array(); | |
$loc_7 = 0; | |
$loc_8 = ''; | |
$loc_9 = ''; | |
$loc_10 = ''; | |
while ($loc_7 < $loc_5) { | |
$loc_6[$loc_7] = substr($url, ($line+1)*$loc_7, $line+1); | |
$loc_7++; | |
} | |
$loc_7 = $loc_5; | |
while($loc_7 < $count) { | |
$loc_6[$loc_7] = substr($url, $line * ($loc_7 - $loc_5) + ($line + 1) * $loc_5, $line); | |
$loc_7++; | |
} | |
$loc_7 = 0; | |
while ($loc_7 < strlen($loc_6[0])) { | |
$loc_10 = 0; | |
while ($loc_10 < count($loc_6)) { | |
$loc_8 .= @$loc_6[$loc_10][$loc_7]; | |
$loc_10++; | |
} | |
$loc_7++; | |
} | |
$loc_9 = str_replace('^', 0, urldecode($loc_8)); | |
return $loc_9; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment