应小伙伴的留言放出源码,并考虑多文件的情况。

这代码弄了好几天才搞出来的,100多行不容易。 🙄

本人菜鸟,代码上有问题的地方欢迎指正 互相学习!! 爱好php~

版本说明:

大于100MB,有提取密码的文件外链会失败。

,不过我在本地测试是成功的。其他未知
解决:

bae 403错误,正如Lostape所说,正则匹配的问题。

大部分的bae 503错误,应该是有太长的& or ?& 导致的。具体不详
更多BUG中~

使用说明:

微云:http://share.weiyun.com/eec279cd08578598b84e92403b3d5e99

普通下载:http://localHOST/weiyun.php/eec279cd08578598b84e92403b3d5e99.flv

BAE调用下载:http://ฏ๎๎๎๎๎๎๎๎๎ฏ ้้้ฏด้้้้้็็็็็้้้้้็็.duapp.com/t.php?/eec279cd08578598b84e92403b3d5e99.flv(尝试兼容bae)

http://ฏ๎๎๎๎๎๎๎๎๎ฏ ้้้ฏด้้้้้็็็็็้้้้้็็.duapp.com/t.php?u=eec279cd08578598b84e92403b3d5e99(再度尝试兼容bae)

技术问题,BAE上常出现503错误。不保证绝对可用,欢迎测试!!

再来mp3测试:

源码

<?php
/**
 * 微云解析 V200115
 * Author:不懂就乱来
 * Website:https://www.hhtjim.com
 * 13-12-27 15:46 主体编写完成
 * 2014/1/5 添加多文件的情况
 * 2014/1/15 解决BAE上的503错误
 **/
error_reporting(0);
$ttim = 600; //使用前需要配置缓存时间:600毫秒 = 10分钟
preg_match('|\.php\??\/(.*)\.\w+|', $_SERVER["REQUEST_URI"], $ur);
if (!isset($ur) || $ur == null)
{
    exit('Please Check <a href="https://www.hhtjim.com/message-wall#comment">here.');
}
$url = 'http://share.weiyun.com/' . $ur[1];
$class = new weiyun();
$conpage = $class->curl_get($url);
preg_match('|var shareInfo = ({.*?});|', $conpage, $con_json);
if (!$con_json)
{
    exit('Please Check <a href="https://www.hhtjim.com/message-wall#comment">here.');
}
$obj = json_decode($con_json[1], true);
preg_match('|url\.cn\/(\w+)|', $obj['short_url'], $surl);
$zn = $obj['file_list'][0]['file_name'];
preg_match('|([\s\S]+)\.([^\.]+)$|', $zn, $type);
$sename = "wy-$surl[1]";
$name = $type ? $type[1] : 'HHTJIM.com_file';
$houzui = $type ? $type[2] : 'TMD什么文件';
preg_match('|(http:\/\/[^"]+ftn_handler[^"]+)\?fname=|', $class->curl_get($url), $res);
if ($res)
{
    $dl[0] = $res[1] . '?&fname=' . $name . time() . '.' . $houzui;
}
else
{
    session_id($sename);
    session_start();
    parse_str($_SESSION[$sename], $info);
    if ($_SESSION[$sename] && $info['times'] + $ttim > time())
    {
        if (strpos($_SESSION[$sename], 'qq.com:443')) // 若匹配到多文件打包
        {
            $dl = explode('/?&', $_SESSION[$sename]);//解决BAE上的503错误
        }
        else
        {
            $dl = explode('&', $_SESSION[$sename] . '&fname=' . $name . time() . '.' . $houzui);
        }
    }elseif ($_SESSION[$sename] && $info['times'] + $ttim <= time())
    {
        if (strpos($class->get_wy_dl($url), 'qq.com:443'))
        {
            $dl = explode('/?&', $class->get_wy_dl($url));
        }
        else
        {
            $dl = explode('&', $class->get_wy_dl($url)) ;
        }
    }elseif (emptyempty($_SESSION[$sename]))
    {
        if (strpos($class->get_wy_dl($url), 'qq.com:443'))
        {
            $dl = explode('/?&', $class->get_wy_dl($url));
        }
        else
        {
            $dl = explode('&', $class->get_wy_dl($url)) ;
        }
    }
}
header("Location: " . $dl[0]);
class weiyun
{
    var $url;
    public function get_wy_dl($url)
    {
        $conpage = $this->curl_get($url);
        preg_match('|var shareInfo = ({.*?});|', $conpage, $con_json);
        $obj = json_decode($con_json[1], true);
        preg_match('|url\.cn\/(\w+)|', $obj['short_url'], $surl);
        $sename = "wy-$surl[1]";
        $conpage = $this->curl_get($url);
        preg_match('|var shareInfo = ({.*?});|', $conpage, $con_json);
        $this->url = $url;
        $zn = $obj['file_list'][0]['file_name'];
        preg_match('|([\s\S]+)\.([^\.]+)$|', $zn, $type);
        $name = $type ? $type[1] : 'HHTjim.Com_file';
        $houzui = $type ? $type[2] : 'TMD什么文件';
        $obj_fid = json_decode($con_json[1]); //多文件的情况
        $fidarry = $obj_fid->file_list;
        foreach ($fidarry as $fids)
        {
            $fid[] = $fids->file_id;
        }
        $fid = implode(',', $fid);
        $pdir = $obj['pdir_key'];
        $sharekey = $obj['share_key'];
        $dlskey = $obj['dlskey'];
        $uin = $obj['uin'];
        $lurl = "http://web.cgi.weiyun.com/share_dl.fcg?browser=mozilla&dir=&fid=$fid&os_info=windows&pdir=$pdir&sharekey=$sharekey&skey=&uin=$uin&ver=12&zn=" . time(); //修复BUG:CURL时&zn(文件名)参数后面出现阿拉伯文会400 bad错误
        $header[] = "Cookie: dlskey=$dlskey";
        $header[] = "Referer: " . $this->url;
        $header[] = "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:26.0) Gecko/20100101 Firefox/26.0";
        $rt = $this->curl_get($lurl, null, null, null, null, $header);
        preg_match('|Location: (.*)(\?fname=)?|', $rt, $do);
        if ($do)
        {
            if (strpos($do[1], 'qq.com:443')) // 若匹配到多文件打包,则输出,加缓存探针
            {
                $dl = $do[1] . '/?&times=' . time();
                $_SESSION[$sename] = $dl;
                return $dl;
            }
            else
            {
                $dl = $do[1] . '?&times=' . time();
                $_SESSION[$sename] = $dl;
                return $dl . '&fname=' . $name . time() . '.' . $houzui;
            }
        }
        else // 外链失败,跳转到微云文件URL
        {
            unset($_SESSION[$sename]);
            return $this->url;
        }
    }
    public function curl_get($url, $post = false, $carry_header = true, $REFERER_ = false, $useragent = false, $add_arry_header = null)
    {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_HEADER, 1);
        if ($carry_header)
        {
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent:Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16'));
        }
        if ($add_arry_header)
        {
            curl_setopt($ch, CURLOPT_HTTPHEADER, $add_arry_header);
        }
        if ($post)
        {
            curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
        }
        if ($REFERER_)
        {
            curl_setopt($ch, CURLOPT_REFERER, $REFERER_);
        }
        if ($useragent)
        {
            curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
        }
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $get_url = curl_exec($ch);
        curl_close($ch);
        return $get_url;
    }
}
?>
03-04 15:07