Пример #1
0
        $array = (array) $array;
    }
    if (is_array($array)) {
        foreach ($array as $key => $value) {
            $array[$key] = object_array($value);
        }
    }
    return $array;
}
if (!empty($_GET['url'])) {
    $url = trim($_GET['url']);
    $arr = explode('_', $url);
    $surl = $arr[0];
    $url = str_replace('_', '%20', $url);
    //默认分隔符为空格,所以需将_替换成%20才能正常解析
    $domain = 'http://so.ygyhg.com/';
    $geturl = $domain . '360jiexi.php?url=' . urlencode('http://yunpan.cn/' . $url);
    $res = object_array(file_get_contents($geturl));
    if (strstr($res, 'errno')) {
        $errno = Search_String($res, 'errno":', ',');
        if ($errno == 0) {
            $downurl = Search_String($res, '"downloadurl":"', '"');
            $downurl = str_replace('\\', '', $downurl);
            header("Location:" . $downurl);
            return;
        }
    }
    //解析失败则跳到360分享页面
    $downurl = 'http://yunpan.cn/' . $surl;
    header("Location:" . $downurl);
}
Пример #2
0
        $ch = curl_init($downurl);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_COOKIE, $cookie);
        //Header无法改变和$cookie取值有关,晕死了。。。
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
        $response = curl_exec($ch);
        $errmsg = curl_error($ch);
        curl_close($ch);
        if (strstr($response, "errno")) {
            //终于成功了
            //echo '终于成功了<br>';
            $size = Search_String($response, '&fsize=', '&');
            $res = array();
            $add = array('filename' => $name, 'email' => $email, 'size' => (int) $size);
            //补充信息
            $res = object_array(json_decode($response));
            $res = array_merge($res, $add);
            echo json_encode($res);
        } else {
            $res = array('errno' => $errno, 'errmsg' => $errmsg);
            echo json_encode($res);
        }
    } else {
        $res = array('errno' => $errno, 'errmsg' => $errmsg);
        echo json_encode($res);
    }
}