找回密码
 注册
广告投放 虚位以待【阿里云】2核2G云新老同享 99元/年,续费同价做网站就用糖果主机-sugarhosts.comJtti.com-新加坡服务器,美国服务器,香港服务器
查看: 767|回复: 6

大家还记得这样的一个PHP代码么

[复制链接]
发表于 2006 年 12 月 13 日 22:51:34 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
就是一个简单的php文件,把它放在一个目录下,目录下的所有文件就会显示出来,谁有,发下
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
发表于 2006 年 12 月 13 日 22:53:33 | 显示全部楼层
【腾讯云】2核2G云服务器新老同享 99元/年,续费同价
php目录文件直读
看看jgftp有木
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

 楼主| 发表于 2006 年 12 月 13 日 22:56:56 | 显示全部楼层
ftp进不去了  阿
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2006 年 12 月 13 日 23:14:55 | 显示全部楼层

  1. <?php
  2. error_reporting(0);
  3. function upfile($file_var,$tofile,$filepath){
  4.         if(!is_writable($filepath)){
  5.                 echo"$filepath 目录不存在或不可写";
  6.                 return false;
  7.                 exit;
  8.         }
  9.         //echo $_FILES["$file_var"]['name'];
  10.         $Filetype=substr(strrchr($_FILES["$file_var"]['name'],"."),1);
  11.         ($tofile==='')?($uploadfile = $_FILES["$file_var"]['name']):($uploadfile = $tofile.".".$Filetype);//文件名
  12.      $Array[tofile] = $tofile.'.'.$Filetype;
  13.          $Array[oldfile]= $_FILES["$file_var"]['name'];
  14.         if(!($uploadfile==='')){
  15.                 if (!is_uploaded_file($_FILES["$file_var"]['tmp_name'])){
  16.              echo $_FILES["$file_var"]['tmp_name']." 上传失败.";
  17.                          return false;
  18.              exit;
  19.                 }

  20.             if (!move_uploaded_file($_FILES["$file_var"]['tmp_name'],$filepath.'/'.$uploadfile)){
  21.              echo "上传失败。错误信息:\n";
  22.              print_r($_FILES);
  23.              exit;
  24.                          }else{
  25.                          return $Array;
  26.                          }
  27.         }else{
  28.                 return false;
  29.         echo"无法上传";
  30.         }
  31. }
  32. function getSize(&$fs)
  33. {
  34.         if($fs<1024)
  35.                 return $fs."Byte";
  36.         elseif($fs>=1024&&$fs<1024*1024)
  37.                 return @number_format($fs/1024, 3)." KB";
  38.         elseif($fs>=1024*1024 && $fs<1024*1024*1024)
  39.                 return @number_format($fs/1024*1024, 3)." M";
  40.         elseif($fs>=1024*1024*1024)
  41.                 return @number_format($fs/1024*1024*1024, 3)." G";
  42. }
  43. if ($_GET['downfile']) {
  44.         $downfile=$_GET['downfile'];
  45.         if (!@is_file($downfile)) {
  46.                 echo "<script>alert("你要下载的文件不存在")</script>";
  47.         }
  48.         $filename = basename($downfile);
  49.         $filename_info = explode('.', $filename);
  50.         $fileext = $filename_info[count($filename_info)-1];
  51.         header('Content-type: application/x-'.$fileext);
  52.         header('Content-Disposition: attachment; filename='.$filename);
  53.         header('Content-Description: PHP3 Generated Data');
  54.         readfile($downfile);
  55.         exit;
  56. }
  57. if(@$_GET['delfile']!="") {
  58.         $delfile=$_GET['delfile'];
  59.         if(file_exists($delfile)) {
  60.                 @unlink($delfile);
  61.         } else {
  62.                 $exists="1";
  63.                 echo "<script>alert("文件已不存在")</script>";
  64.         }
  65.         if(!file_exists($delfile)&&$exists!="1") {
  66.                 echo"<script>alert("删除成功")</script>";
  67.         } else {
  68.                 echo"<script>alert("删除失败")</script>";
  69.         }
  70. }
  71. $CurrentPath        = $_POST['path']?$_POST['path']:($_GET['path']?$_GET['path']:false);
  72. if($CurrentPath===false)
  73. {
  74.         $CurrentPath        = dirname(__FILE__);
  75. }
  76. $CurrentPath        = realpath(str_replace('\\','/',$CurrentPath));
  77. if($_POST['dirname'])
  78. {
  79.         $newdir        = $CurrentPath."/".$_POST['dirname'];
  80.         if(is_dir($newdir))
  81.         {
  82.                 echo"<script>alert("此目录名已经存在!")</script>";
  83.                 exit;
  84.         }else {
  85.                 if(mkdir($newdir,0700))
  86.                 {
  87.                         echo"<script>alert("创建成功!")</script>";
  88.                 }else {
  89.                         echo "<script>alert("创建失败!")</script>";
  90.                 }
  91.         }
  92. }
  93. if($_POST['upload'])
  94. {
  95.         if(!(upfile("upfiles",$_POST['fname'],$CurrentPath)))
  96.         {
  97.                 echo"<script>alert("上传失败!")</script>";
  98.         }else {
  99.                 echo "<script>alert("上传成功!")</script>";
  100.         }
  101. }
  102. ?>
  103. <!--nobanner--><html>
  104. <head>
  105. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  106. <title>file</title>
  107. <style type="text/css">
  108. <!--
  109. body{margin-left: 0px}
  110. td {font-family: "宋体"; font-size: 9pt; color: #666666; text-decoration: none}
  111. input {border-width: 1pix; border-style: solid; border-color: #cccccc}
  112. .title { border: 1px solid #000000; background-color: #6699cc; height: 25px; font-weight: bold; line-height: 150%; color: #ffffff}
  113. .content { border: 1px solid #000000; background-color: #f5f9fd}
  114. -->
  115. </style>
  116. </head>

  117. <body>
  118. <table width="760" border="0" align="center" cellpadding="3" cellspacing="3">
  119.   <tr>
  120.     <td class="title">PHP版本: <?php echo PHP_VERSION;?></td>
  121.   </tr>
  122.   <tr>
  123.     <td class="content">
  124.       <table width="100%" height="100%" border="0" cellpadding="5" cellspacing="0">
  125.         <tr>
  126.           <form name="form2" method="post" action="">
  127.             <td><strong>新建目录: </strong><input name="dirname" type="text" id="dirname"> <input type="submit" name="submit" value="创 建"></td>
  128.           </form>
  129.         </tr>
  130.       <form name="form3" method="post" action="" enctype="multipart/form-data">
  131.         <tr>
  132.           <td><strong>上传文件: </strong><input name="upfiles" type="file" id="upfiles"></td>
  133.         </tr>
  134.         <tr>
  135.           <td><strong>新文件名: </strong><input name="fname" type="test" id="fname"> <input type="submit" name="upload" value="上 传"></td>
  136.         </tr>
  137.       </form>
  138.         <tr>
  139.           <td><strong>当前路径: </strong><?php echo $CurrentPath;?></td>
  140.         </tr>
  141.       </table>
  142.     </td>
  143.   </tr>
  144. </table>

  145. <table width="760" border="0" align="center" cellpadding="3" cellspacing="3">
  146.   <tr>
  147.     <td class="title">目录</td>
  148.   </tr>
  149.   <tr>
  150.     <td class="content">
  151.       <table width="100%" height="100%" border="0" cellpadding="3" cellspacing="0">
  152. <?php
  153. $fso=@opendir($CurrentPath);
  154. while ($file=@readdir($fso)) {
  155.         $fullpath        = "$CurrentPath/$file";
  156.         $is_dir                = @is_dir($fullpath);
  157.         if($is_dir=="1"){
  158.         if($file!=".."&&$file!=".")        {
  159.                 echo "<tr>\n";
  160.                 echo "  <td>【目录】 <a href="?path=".urlencode($CurrentPath)."/".urlencode($file)."">$file</a></td>\n";
  161.                 echo "</tr>\n";
  162.         } else {
  163.                 if($file=="..")
  164.                 {
  165.                         echo "<tr>\n";
  166.                         echo "<td>【上级】 <a href="?path=".urlencode($CurrentPath)."/".urlencode($file)."">上级目录</a></td>";
  167.                         echo "</tr>\n";
  168.                 }
  169.         }
  170.         }
  171. }
  172. @closedir($fso);
  173. ?>
  174.       </table>
  175.     </td>
  176.   </tr>
  177.   <tr>
  178.     <td class="title">文件列表</td>
  179.   </tr>
  180.   <tr>
  181.     <td class="content">
  182.       <table width="100%" height="100%" border="0" cellpadding="3" cellspacing="0">
  183.         <tr bgcolor="#eef2f7">
  184.           <td><b>文件名</b></td>
  185.           <td><b>修改日期</b></td>
  186.           <td><b>文件大小</b></td>
  187.           <td><b>操作</b></td>
  188.         </tr>
  189. <?php
  190. $fso=@opendir($CurrentPath);
  191. while ($file=@readdir($fso)) {
  192.         $fullpath        = "$CurrentPath/$file";
  193.         $is_dir                = @is_dir($fullpath);
  194.         if($is_dir=="0"){
  195.         $size=@filesize("$CurrentPath/$file");
  196.         $size=@getSize($size);
  197.         $lastsave=@date("Y-n-d H:i:s",filemtime("$CurrentPath/$file"));
  198.     echo "<tr>\n";
  199.     echo "<td>● $file</td>\n";
  200.         echo "  <td>$lastsave</td>\n";
  201.     echo "  <td>$size</td>\n";
  202.         echo "  <td><a href="?downfile=".urlencode($CurrentPath)."/".urlencode($file)."">下载</a> | <a href="?path=".urlencode($CurrentPath)."&delfile=".urlencode($CurrentPath)."/".urlencode($file)."">删除</a></td>\n";
  203.         echo "</tr>\n";
  204.         }
  205. }
  206. @closedir($fso);
  207. ?>
  208.       </table>
  209.     </td>
  210.   </tr>
  211. </table>

  212. <table width="760" border="0" align="center" cellpadding="3" cellspacing="3">
  213.   <tr>
  214.     <td class="content"><strong>服务器操作系统: <?php echo php_uname();?></strong></td>
  215.   </tr>
  216. </table>
  217. <style>
  218. </body>
  219. </html>
复制代码
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2006 年 12 月 13 日 23:16:39 | 显示全部楼层
原帖由 esnak 于 2006-12-13 23:14 发表

<?php
error_reporting(0);
function upfile($file_var,$tofile,$filepath){
        if(!is_writable($filepath)){
                echo"$filepath 目录不存在或不可写";
                return false;
                exit;
        }
        //ec ...

现写的就是牛B
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2006 年 12 月 14 日 12:15:56 | 显示全部楼层
原帖由 幽鬼狼魂 于 2006-12-13 23:16 发表

现写的就是牛B

牛B大了
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2006 年 12 月 14 日 12:23:56 | 显示全部楼层
【腾讯云】2核2G云服务器新老同享 99元/年,续费同价
BB很大
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|金光论坛

GMT+8, 2025 年 2 月 4 日 21:59 , Processed in 0.041689 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表