假如a.com/a.rar在天朝無法訪問,如果寫一個a.php指令碼,放在海外伺服器上,訪問指令碼路徑b.com/a.php?url=http://a.com/a.rar
就可以實現檔案下載了,請問這個a.php檔案怎麼寫
回複討論(解決方案)
你確定 繞著彎就可以翻牆了?
http://www.cnblogs.com/sum41van/articles/1422450.html
b.com/a.php?url=http://a.com/a.rar
如果檔案不大可以這樣寫
$url = isset($_GET['url'])? $_GET['url'] : '';if($url){ $content = file_get_contents($url); if($content){ header('cache-control:public'); header('content-type:application/octet-stream'); header('content-disposition:attachment; filename='.basename($url)); echo $content; }}
要保證
1.天朝可以訪問b.com
2.b.com可以訪問a.com
可以使用 curl
$url = '傳入的目標url';$ch = curl_init(); //初始化curl_setopt($ch, CURLOPT_URL, $url);//curl_setopt($ch, CURLOPT_REFERER, '某個來路url'); //偽造來路頁面curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'func');curl_exec($ch); //執行function func($ch, $str) { static $s = '@'; if($s) { $s = trim($str); if($s) header($s); }else echo $str; return strlen($str);}
b.com/a.php?url=http://a.com/a.rar
如果檔案不大可以這樣寫
$url = isset($_GET['url'])? $_GET['url'] : '';if($url){ $content = file_get_contents($url); if($content){ header('cache-control:public'); header('content-type:application/octet-stream'); header('content-disposition:attachment; filename='.basename($url)); echo $content; }}
謝謝親,如果能加入下載流量統計就好了
下載次數統計?
下載次數統計?
不是的。就是記錄通過這個檔案下載過的檔案大小加起來數值
把下載的功能,整合到方法裡面,執行一次就往資料表加1
下載次數統計?
不是的。就是記錄通過這個檔案下載過的檔案大小加起來數值
下??的檔案大小加起??
echo strlen($content);
可以?取大小後??在???。
下載次數統計?
不是的。就是記錄通過這個檔案下載過的檔案大小加起來數值
下??的檔案大小加起??
echo strlen($content);
可以?取大小後??在???。
謝謝啦,今天學了一天的html把代碼整合進去的作品
下載次數統計?
不是的。就是記錄通過這個檔案下載過的檔案大小加起來數值
下??的檔案大小加起??
echo strlen($content);
可以?取大小後??在???。
謝謝啦,今天學了一天的html把代碼整合進去的作品
http://qqgae.byethost16.com/1/
如問題解決了請結貼。