本文將介紹如何通過 PHP 函數處理,輕鬆產生製作各種第三方下載工具(比如迅雷,快車,QQ旋風)的下載連結資料,並直接輸出到前台上,同時也可以將轉換過的連結還原為原始的下載地址。
該功能所用到的 PHP 函數主要是下面兩個:
1. base64_encode: 用於以 base64 方式加密字串;
2. base64_decode: 用於解密以 base64 方式加密的字串。
下面直接通過樣本說明,基本都能理解,就不做詳細解釋了。
<html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>PHP產生迅雷、快車、QQ旋風下載連結的方法</title></head><body><?phpfunction zhuanhuan($url){if(empty($url)) return $result;$urlodd=explode("//",$url,2);$head=strtolower($urlodd[0]);$behind=$urlodd[1];if($head=="thunder:"){$url=substr(base64_decode($behind),2,-2);}else if($head=="flashget:"){$url1=explode("&",$behind,2);$url=substr(base64_decode($url1[0]),10,-10);}else if($head=="qqdl:"){$url=base64_decode($behind);}else if($head=="http:"$head=="ftp:"$head=="mms:"$head=="rtsp:"$head=="https:"){$url=array("thunder"=>"thunder://".base64_encode("AA".$url."ZZ"),"flashget"=>"Flashget://".base64_encode("[FLASHGET]".$url."[FLASHGET]")."&aiyh","qqdl"=>"qqdl://".base64_encode($url));}else{return "";}return $url;}$url=isset($_GET["url"])?$_GET["url"]:"";$result=zhuanhuan($url);?> <form action="" method=GET>請輸入普通連結或者迅雷,快車,旋風鏈地址:<br /> <input type=text name="url" size="80"> <input type=submit value="轉換"> </form><?phpif(is_array($result)){//www.Alixixi.com?><p>地址:<a href="<?php echo $url;?>" target="_blank"><?php echo $url;?></a> <p>迅雷鏈:<a href="<?php echo $result["thunder"];?>" target="_blank"><?php echo $result["thunder"];?></a> <p>快車鏈:<a href="<?php echo $result["flashget"];?>" target="_blank"><?php echo $result["flashget"];?></a> <p>旋風鏈:<a href="<?php echo $result["qqdl"];?>" target="_blank"><?php echo $result["qqdl"];?></a><?php}else{?><p>實際地址:<a href="<?php echo $result;?>" target="_blank"><?php echo $result;?></a> <?php}?></body></html>
頁面的效果如下圖:
您可能感興趣的文章
- php擷取遠程圖片並下載儲存到本地
- PHP 產生連續的數字(字母)數組函數range()分析,PHP抽獎程式函數
- php大量刪除超連結
- php常用函數收集並附解釋說明
- php用header()實現檔案下載,下載的檔案提示被破壞不能開啟的解決辦法
- php產生動態驗證碼圖片(gif)
- PHP 利用 Curl Functions 實現多線程抓取網頁和下載檔案
- php利用curl實現多線程的類,php curl多線程下載圖片