湖南站长站 发表于 2013-9-21 22:35:53

百度网盘外链转换直链工具 PHP源码

国内网盘竞相扩容,不断满足网友文件存储需求,下面代码可以转换百度网盘分享文件直接外链下载,更方便在论坛或个人博客中分享你的下载文件.
使用:复制下面2段代码,第一段保存为html文件,第二段保存为baidupan.php文件,上传自己的空间个人php网站上.
分享文件后缀可自定义。
演示:http://www.zairun.com/wangpan/

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>百度网盘文件永久外链</title>
<linkhref="http://libs.baidu.com/bootstrap/2.0.4/css/bootstrap.min.css" type="text/css" rel="stylesheet" media="screen" />
<style type="text/css">
            body {
                padding-top: 40px;
                padding-bottom: 40px;
                background-color: #f5f5f5;
            }
            .form_pan {
                max-width: 650px;
                padding: 19px 29px 29px;
                margin: 0 auto 20px;
                background-color: #fff;
                border: 1px solid #e5e5e5;
                -webkit-border-radius: 5px;
                -moz-border-radius: 5px;
                border-radius: 5px;
                -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
                -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
                box-shadow: 0 1px 2px rgba(0,0,0,.05);
            }
            .form_pan .form_pan-heading {
                margin-bottom: 10px;
            }
</style>
</head>

<script type="text/javascript">
      function Change()
      {   
                  var host = window.location.host;   
                  var url = document.getElementById("text1").value;
                  var arr = url.split("&");
                  var shareid = arr.split("=");
                  var uk = arr.split("=");
                var file_value = "";
                  var file_type = document.getElementsByName("file_type");
                  for (var i = 0; i < file_type.length; i++) {
                  if (file_type.checked) {
                        file_value = file_type.value;
                        break;
                  }
                };
      var file_other = document.getElementById("file_other");
            file_other_text = document.getElementById("file_other_text");
      if (file_value == 'other') {
                  if (file_other_text.value.length == 0) {
                        alert("扩展名不能为空!");
                        inputUrl.focus();
                        return false;
                         }
                        //outputUrl.value = hostname + abc + "." + file_other_text.value;
                        var songurl = "http://"+host+"/baidupan.php/"+shareid+"/"+uk + "."+file_other_text.value;
                        document.getElementById("text2").value = songurl;
                            } else {
                                    //outputUrl.value = hostname + abc + "." + file_value;
                              var songurl = "http://"+host+"/baidupan.php/"+shareid+"/"+uk+"." + file_value;
                              document.getElementById("text2").value = songurl;
                     }

            //var songurl = "http://linuxlib.org/baidupan.php/"+shareid+"/"+uk+".mp3";
            //document.getElementById("text2").value = songurl;
      }
      function fileOtherTextChange() {
                if (file_other.checked == true) {
                  file_other_text.disabled = false;
                  file_other_text.focus();
                } else {
                  file_other_text.disabled = true;
                }
            }
</script>

<body>
   <div class='container'>
            <form class="form_pan" id="pan_form">
                <h2 class="form_pan-heading">百度网盘文件永久外链</h2><p>

                  分享地址:<input id="text1" type="TEXT" value="" style="width:550px;" size=""/><br />
                  外链地址:<input id="text2" type="TEXT" value="" style="width:550px;" size=""/><br />
      <p>
                  文件的扩展名:
                  <input type="radio" class="radio" name="file_type" id="file_mp3" value="mp3" checked />
                  mp3
                  <input type="radio" class="radio" name="file_type" id="file_png" value="png" />
                  png
                  <input type="radio" class="radio" name="file_type" id="file_exe" value="exe" />
                  exe
                  <input type="radio" class="radio" name="file_type" id="file_zip" value="zip" />
                  zip
                  <input type="radio" class="radio" name="file_type" id="file_mp4" value="mp4" />
                  mp4
                  <input type="radio" class="radio" name="file_type" id="file_other" value="other" />
                  其他格式
                  <input type="text" class="input-medium search-query" style="width:80px;" id="file_other_text" disabled />
                </p>
            <input type="BUTTON" value="转换"/>
      </div>
</body>
</html>

首先复制下面的php代码,另存为文件baidupan.php,然后将php文件放到网站根目录。
**** Hidden Message *****
本文转载自 载润的博客


http://bbs.hnzzz.net/xwb/images/bgimg/icon_logo.png 该贴已经同步到 湖南站长站的微博
页: [1]
查看完整版本: 百度网盘外链转换直链工具 PHP源码