大家还记得这样的一个PHP代码么
就是一个简单的php文件,把它放在一个目录下,目录下的所有文件就会显示出来,谁有,发下 php目录文件直读看看jgftp有木 ftp进不去了阿
<?php
error_reporting(0);
function upfile($file_var,$tofile,$filepath){
if(!is_writable($filepath)){
echo"$filepath 目录不存在或不可写";
return false;
exit;
}
//echo $_FILES["$file_var"]['name'];
$Filetype=substr(strrchr($_FILES["$file_var"]['name'],"."),1);
($tofile==='')?($uploadfile = $_FILES["$file_var"]['name']):($uploadfile = $tofile.".".$Filetype);//文件名
$Array = $tofile.'.'.$Filetype;
$Array= $_FILES["$file_var"]['name'];
if(!($uploadfile==='')){
if (!is_uploaded_file($_FILES["$file_var"]['tmp_name'])){
echo $_FILES["$file_var"]['tmp_name']." 上传失败.";
return false;
exit;
}
if (!move_uploaded_file($_FILES["$file_var"]['tmp_name'],$filepath.'/'.$uploadfile)){
echo "上传失败。错误信息:\n";
print_r($_FILES);
exit;
}else{
return $Array;
}
}else{
return false;
echo"无法上传";
}
}
function getSize(&$fs)
{
if($fs<1024)
return $fs."Byte";
elseif($fs>=1024&&$fs<1024*1024)
return @number_format($fs/1024, 3)." KB";
elseif($fs>=1024*1024 && $fs<1024*1024*1024)
return @number_format($fs/1024*1024, 3)." M";
elseif($fs>=1024*1024*1024)
return @number_format($fs/1024*1024*1024, 3)." G";
}
if ($_GET['downfile']) {
$downfile=$_GET['downfile'];
if (!@is_file($downfile)) {
echo "<script>alert(\"你要下载的文件不存在\")</script>";
}
$filename = basename($downfile);
$filename_info = explode('.', $filename);
$fileext = $filename_info;
header('Content-type: application/x-'.$fileext);
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Description: PHP3 Generated Data');
readfile($downfile);
exit;
}
if(@$_GET['delfile']!="") {
$delfile=$_GET['delfile'];
if(file_exists($delfile)) {
@unlink($delfile);
} else {
$exists="1";
echo "<script>alert(\"文件已不存在\")</script>";
}
if(!file_exists($delfile)&&$exists!="1") {
echo"<script>alert(\"删除成功\")</script>";
} else {
echo"<script>alert(\"删除失败\")</script>";
}
}
$CurrentPath = $_POST['path']?$_POST['path']:($_GET['path']?$_GET['path']:false);
if($CurrentPath===false)
{
$CurrentPath = dirname(__FILE__);
}
$CurrentPath = realpath(str_replace('\\','/',$CurrentPath));
if($_POST['dirname'])
{
$newdir = $CurrentPath."/".$_POST['dirname'];
if(is_dir($newdir))
{
echo"<script>alert(\"此目录名已经存在!\")</script>";
exit;
}else {
if(mkdir($newdir,0700))
{
echo"<script>alert(\"创建成功!\")</script>";
}else {
echo "<script>alert(\"创建失败!\")</script>";
}
}
}
if($_POST['upload'])
{
if(!(upfile("upfiles",$_POST['fname'],$CurrentPath)))
{
echo"<script>alert(\"上传失败!\")</script>";
}else {
echo "<script>alert(\"上传成功!\")</script>";
}
}
?>
<!--nobanner--><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>file</title>
<style type="text/css">
<!--
body{margin-left: 0px}
td {font-family: "宋体"; font-size: 9pt; color: #666666; text-decoration: none}
input {border-width: 1pix; border-style: solid; border-color: #cccccc}
.title { border: 1px solid #000000; background-color: #6699cc; height: 25px; font-weight: bold; line-height: 150%; color: #ffffff}
.content { border: 1px solid #000000; background-color: #f5f9fd}
-->
</style>
</head>
<body>
<table width="760" border="0" align="center" cellpadding="3" cellspacing="3">
<tr>
<td class="title">PHP版本: <?php echo PHP_VERSION;?></td>
</tr>
<tr>
<td class="content">
<table width="100%" height="100%" border="0" cellpadding="5" cellspacing="0">
<tr>
<form name="form2" method="post" action="">
<td><strong>新建目录: </strong><input name="dirname" type="text" id="dirname"> <input type="submit" name="submit" value="创 建"></td>
</form>
</tr>
<form name="form3" method="post" action="" enctype="multipart/form-data">
<tr>
<td><strong>上传文件: </strong><input name="upfiles" type="file" id="upfiles"></td>
</tr>
<tr>
<td><strong>新文件名: </strong><input name="fname" type="test" id="fname"> <input type="submit" name="upload" value="上 传"></td>
</tr>
</form>
<tr>
<td><strong>当前路径: </strong><?php echo $CurrentPath;?></td>
</tr>
</table>
</td>
</tr>
</table>
<table width="760" border="0" align="center" cellpadding="3" cellspacing="3">
<tr>
<td class="title">目录</td>
</tr>
<tr>
<td class="content">
<table width="100%" height="100%" border="0" cellpadding="3" cellspacing="0">
<?php
$fso=@opendir($CurrentPath);
while ($file=@readdir($fso)) {
$fullpath = "$CurrentPath/$file";
$is_dir = @is_dir($fullpath);
if($is_dir=="1"){
if($file!=".."&&$file!=".") {
echo "<tr>\n";
echo "<td>【目录】 <a href=\"?path=".urlencode($CurrentPath)."/".urlencode($file)."\">$file</a></td>\n";
echo "</tr>\n";
} else {
if($file=="..")
{
echo "<tr>\n";
echo "<td>【上级】 <a href=\"?path=".urlencode($CurrentPath)."/".urlencode($file)."\">上级目录</a></td>";
echo "</tr>\n";
}
}
}
}
@closedir($fso);
?>
</table>
</td>
</tr>
<tr>
<td class="title">文件列表</td>
</tr>
<tr>
<td class="content">
<table width="100%" height="100%" border="0" cellpadding="3" cellspacing="0">
<tr bgcolor="#eef2f7">
<td><b>文件名</b></td>
<td><b>修改日期</b></td>
<td><b>文件大小</b></td>
<td><b>操作</b></td>
</tr>
<?php
$fso=@opendir($CurrentPath);
while ($file=@readdir($fso)) {
$fullpath = "$CurrentPath/$file";
$is_dir = @is_dir($fullpath);
if($is_dir=="0"){
$size=@filesize("$CurrentPath/$file");
$size=@getSize($size);
$lastsave=@date("Y-n-d H:i:s",filemtime("$CurrentPath/$file"));
echo "<tr>\n";
echo "<td>● $file</td>\n";
echo "<td>$lastsave</td>\n";
echo "<td>$size</td>\n";
echo "<td><a href=\"?downfile=".urlencode($CurrentPath)."/".urlencode($file)."\">下载</a> | <a href=\"?path=".urlencode($CurrentPath)."&delfile=".urlencode($CurrentPath)."/".urlencode($file)."\">删除</a></td>\n";
echo "</tr>\n";
}
}
@closedir($fso);
?>
</table>
</td>
</tr>
</table>
<table width="760" border="0" align="center" cellpadding="3" cellspacing="3">
<tr>
<td class="content"><strong>服务器操作系统: <?php echo php_uname();?></strong></td>
</tr>
</table>
<style>
</body>
</html>
原帖由 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 原帖由 幽鬼狼魂 于 2006-12-13 23:16 发表
现写的就是牛B
牛B大了 BB很大:Q :Q
页:
[1]