PHP迅雷/快车/QQ旋风下载地址与普通URL链接互转
PHP使用下面自定义函数,可以将迅雷/快车/QQ旋风下载地址、转换成普通URL地址,或者将普通URL地址、转换为迅雷/快车/QQ旋风等下载地址。
自定义函数代码:
用法举例:
自定义函数代码:
<?php /* * 将普通URL链接转换为迅雷、快车(FlashGet)、QQ旋风下载地址函数 * 爱E族:aiezu.com */ function download_url_encode( $url, $type = 'thunder' ) { switch( strtolower($type) ) { case "thunder": $url = sprintf("thunder://%s", base64_encode(sprintf("AA%sZZ", $url))); break; case "flashget": $url = sprintf("Flashget://%s", base64_encode(sprintf("[FLASHGET]%s[FLASHGET]", $url))); break; case "qqdl": $url = sprintf("qqdl://%s", base64_encode($url)); break; } echo $url . "\n"; return $url; } /* * 将迅雷、快车(FlashGet)、QQ旋风下载地址,转换为普通URL链接函数 * 爱E族:aiezu.com */ function download_url_decode( $url ) { $match = parse_url( $url ); switch( strtolower($match['scheme']) ) { case "thunder": $url = substr(base64_decode($match['host']), 2, -2); break; case "flashget": $url = substr(base64_decode($match['host']), 10, -10); break; case "qqdl": $url = base64_decode($match['host']); break; } return $url; }
用法举例:
//普通链接转迅雷、快车、旋风下载链接(爱E族:aiezu.com) $url = 'http://aiezu.com/download.zip'; //虚构的链接 echo sprintf("普通链接: %s\n", $url); echo sprintf("迅雷链接: %s\n", download_url_encode($url, 'thunder')); echo sprintf("快车链接: %s\n", download_url_encode($url, 'flashget')); echo sprintf("旋风链接: %s\n", download_url_encode($url, 'qqdl')); //迅雷、快车、旋风下载链接,转回普通链接(爱E族:aiezu.com) echo sprintf("迅雷:%s\n", download_url_decode('thunder://QUFodHRwOi8vYWllenUuY29tL2Rvd25sb2FkLnppcFpa')); echo sprintf("快车:%s\n", download_url_decode('Flashget://W0ZMQVNIR0VUXWh0dHA6Ly9haWV6dS5jb20vZG93bmxvYWQuemlwW0ZMQVNIR0VUXQ==')); echo sprintf("旋风:%s\n", download_url_decode('qqdl://aHR0cDovL2FpZXp1LmNvbS9kb3dubG9hZC56aXA='));输出:
普通链接: http://aiezu.com/download.zip 迅雷链接: thunder://QUFodHRwOi8vYWllenUuY29tL2Rvd25sb2FkLnppcFpa 快车链接: Flashget://W0ZMQVNIR0VUXWh0dHA6Ly9haWV6dS5jb20vZG93bmxvYWQuemlwW0ZMQVNIR0VUXQ== 旋风链接: qqdl://aHR0cDovL2FpZXp1LmNvbS9kb3dubG9hZC56aXA= 迅雷:http://aiezu.com/download.zip 快车:http://aiezu.com/download.zip 旋风:http://aiezu.com/download.zip