vipdownload.php
<?php // $str='d3d3LmpiNTEubmV0IOiEmuacrOS5i+Wutg=='; //定义字符串 // echo base64_decode($str); //输出解码后的内容 // $str='www.jb51.net 脚本之家'; //定义字符串 // echo base64_encode($str); // 输出编码后的内容为: d3d3LmpiNTEubmV0IOiEmuacrOS5i+Wutg== $pin = ""; if(!empty($_POST['pin'])){ $pin = $_POST['pin']; } if($pin = "" or $pin != "www.vpseo.com" ){?> <link rel="stylesheet" href="vipdownload.css" type="text/css" media="screen" /><form method="post" class="searchform cf" action="" style="text-align:center;"> <input type="text" name="pin" id="pin" placeholder="Please input your VIP code"> <button type="submit" style="">Download</button></form> <?php }?> <?php $pin = "";$file_address = "";$filecode = "";$file_name = "down.zip"; //下载文件名 $file_dir = "./down/"; //下载文件存放目录 $key = time(); if(!empty($_POST['pin'])){ $pin = $_POST['pin']; } if (!empty($_GET['filecode']) ) { $filecode = $_GET['filecode']; $file_address = base64_decode ($filecode); } if (!empty($_GET['file']) && empty($_GET['filecode'])) { $filecode = base64_encode($_GET['file']); header("location:vipdownload.php?filecode=".$filecode); } if ($pin == "www.vpseo.com") { $pieces = explode("/", $file_address); // end() 函数将数组内部指针指向最后一个元素,并返回该元素的值(如果成功); $file_name = end($pieces); //需要增加检查 文件类型 为 zip, pdf //检查文件是否存在 // if (! file_exists ( $file_dir . $file_name )) { if (! file_exists ( $file_address )) { header('HTTP/1.1 404 NOT FOUND'); } elseif ( substr($file_name,-3) == "zip" or substr($file_name,-3) == "pdf" ){ //以只读和二进制模式打开文件 $file = fopen ( $file_address, "rb" ); //告诉浏览器这是一个文件流格式的文件 Header ( "Content-type: application/octet-stream" ); //请求范围的度量单位 Header ( "Accept-Ranges: bytes" ); //Content-Length是指定包含于请求或响应中数据的字节长度 Header ( "Accept-Length: " . filesize ( $file_address ) ); //用来告诉浏览器,文件是可以当做附件被下载,下载后的文件名称为$file_name该变量的值。 Header ( "Content-Disposition: attachment; filename=" . $file_name ); //读取文件内容并直接输出到浏览器 // echo fread ( $file, filesize ( $file_dir . $file_name ) ); echo fread ( $file, filesize ( $file_address ) ); fclose ( $file ); exit (); } // endif fileexist } // endif $($_POST['pin'] == "www.vpseo.com") if(!empty($_POST['pin']) && $pin != "www.vpseo.com" ){echo "<p style='text-align:center;'><br>VIP code error ! <br>Please contact our sale rep or send email to cl@banqcn.com to get your VIP code.<br></p>"; // $filecode = authcode($file_address,'ENCODE',$key,0); //加密 调试 // echo $filecode; //调试 // echo $file_address;}?>