网址转换api源码

@Ta 2014-02-22 4797点击
<?php
/**
 * 好几个月之前写的,有些函数应该可以优化
 * 虎友们随便弄吧
 */
$url = $_GET["url"] == null ? $_POST["url"] == null ? "" : $_POST["url"] : $_GET["url"];
if($url === "") { echo '{"httpUrl":"null", "thunderUrl":"null", "qqdlUrl":"null", "flashgetUrl":"null"}'; exit; }

$url = ucfirst($url);

$xunleiBol	= strpos($url, "Thunder://");
$xuanfBol	= strpos($url, "Qqdl://");
$kuaicheBol	= strpos($url, "Flashget://");
$httpBol	= strpos($url, "Http://");

if($xunleiBol === false && $xuanfBol === false && $kuaicheBol === false && $httpBol === false) {
	$url = (strtolower(substr($url, 0,1)).substr($url, 1, strlen($url)-1));
	$url = "Http://".$url;
	$httpBol = strpos($url, "Http://");
}

$xunleiUrl = "";
$xuanfUrl = "";
$kuaicheUrl = "";
$httpUrl = "";

if($httpBol !== false) {
	$url = (strtolower(substr($url, 0,1)).substr($url, 1, strlen($url)-1));
	$httpUrl = $url;
	
	$xunleiUrl = "AA".$url."ZZ";
	$xunleiUrl = "thunder://".base64_encode($xunleiUrl);
	
	$xuanfUrl = "qqdl://".base64_encode($url);
	
	$kuaicheUrl = "[FLASHGET]".$url."[FLASHGET]";
	$kuaicheUrl = "flashget://".base64_encode($kuaicheUrl)."&mplogs";
}

if($xunleiBol !== false) {
	$httpUrl = preg_replace('/Thunder:\/\//','',$url);
	$httpUrl = base64_decode($httpUrl);
	$httpUrl = substr($httpUrl,2, strlen($httpUrl)-4);
	
	$xunleiUrl = "AA".$httpUrl."ZZ";
	$xunleiUrl = "thunder://".base64_encode($xunleiUrl);
	
	$xuanfUrl = "qqdl://".base64_encode($httpUrl);
	
	$kuaicheUrl = "[FLASHGET]".$httpUrl."[FLASHGET]";
	$kuaicheUrl = "flashget://".base64_encode($kuaicheUrl)."&mplogs";
}

if($xuanfBol !== false) {
	$httpUrl = preg_replace('/Qqdl:\/\//','',$url);
	$httpUrl = base64_decode($httpUrl);
	
	$xunleiUrl = "AA".$httpUrl."ZZ";
	$xunleiUrl = "thunder://".base64_encode($xunleiUrl);
	
	$xuanfUrl = "qqdl://".base64_encode($httpUrl);
	
	$kuaicheUrl = "[FLASHGET]".$httpUrl."[FLASHGET]";
	$kuaicheUrl = "flashget://".base64_encode($kuaicheUrl)."&mplogs";
}

if($kuaicheBol !== false) {
	$httpUrl = preg_replace('/Flashget:\/\//','',$url);
	//$httpUrl = substr($httpUrl, 0, strlen($httpUrl)-7);
	$httpUrl = base64_decode($httpUrl);
	$httpUrl = substr($httpUrl, 10, strlen($httpUrl)-20);
	
	$xunleiUrl = "AA".$httpUrl."ZZ";
	$xunleiUrl = "thunder://".base64_encode($xunleiUrl);
	
	$xuanfUrl = "qqdl://".base64_encode($httpUrl);
	
	$kuaicheUrl = "[FLASHGET]".$httpUrl."[FLASHGET]";
	$kuaicheUrl = "flashget://".base64_encode($kuaicheUrl)."&mplogs";
}

header("content-type: text/plain; charset=utf-8");
echo '{"httpUrl":"'.$httpUrl.'", "thunderUrl":"'.$xunleiUrl.'", "qqdlUrl":"'.$xuanfUrl.'", "flashgetUrl":"'.$kuaicheUrl.'"}';

?>
回复列表(14|隐藏机器人聊天)
添加新回复
回复需要登录