wantyou5354 2016-10-19 15:14 采纳率: 60%
浏览 1082

php文件管理在iis环境下不正常

<?php
require "../include/conn.php";
require "../include/function.php";
require "checkloginstate.php";
?>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>后台管理-<?php echo $config['sitename']?></title>
    <link rel="stylesheet" type="text/css" href="css/common.css"/>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <script type="text/javascript" src="js/libs/modernizr.min.js"></script>
    <script type="text/javascript" src="../include/jquery.min.js"></script>
    <script type="text/javascript" src="../include/laydate/laydate.js"></script>
    <script type="text/javascript" src="../include/layer/layer.js"></script>
</head>
<body>
<?php require "top.php"; ?>
<div class="container clearfix">
    <?php require "left.php"; ?>
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="index.php">首页</a><span class="crumb-step">&gt;</span><a class="crumb-name" href="tool.php">常用工具</a><span class="crumb-step">&gt;</span><span>文件管理</span></div>
        </div>
        <div class="result-wrap">
            <div class="result-content">
<?php 
/* 
遍历文件夹; 功能:(a)可删除文件 (b)可编辑文本,网页文件 (c)可删除文件夹,前提是该文件夹为空 (d)可建立文件,文件夹,修改文件夹名称; 
lost63.com原创, 转载请注明出处. 交流QQ:35501547 
*/ 
$path="../"; 
$path=str_replace("/","\\",$path); 
//指定文件夹 
$path=$path."\\"; 
if($_GET['folder']) 
{ 
$path.=$_GET['folder']."\\";
$path=iconv("utf-8","gb2312//IGNORE",$path);
} 
//本页面路径,下面传回时将用到; 
$url=$_SERVER['PHP_SELF']; 
//如果是文件夹,将加上链接; 
function folder($path,$str) 
{ 
if(filetype($path.$str)=="dir") 
{ 
return "<a href=\"?folder=".$_GET['folder']."\\".iconv("GBK","utf-8",$str)."\"><i class='icon-font'>&#xe009;</i> ".iconv("GBK","utf-8",$str)."</a>"; 
}else{ 
return "<i class='icon-font'>&#xe005;</i> ".iconv("GBK","utf-8",$str); 
} 
} 
switch($_GET['action']) 
{ 
case "del"; 
if($_GET['type']=="file") 
{ 
unlink(iconv("utf-8","gb2312//IGNORE",$_GET['path'])); 
}else{ 
deldir(iconv("utf-8","gb2312//IGNORE",$_GET['path'])); 
} 
echo "<script type=\"text/javascript\">alert('恭喜,删除成功!');location.href=\"".$url."\";</script>"; 
break; 
case "edit"; 
if($_GET['type']=="file") 
{
$file=iconv("utf-8","gb2312//IGNORE",$_GET['path']);
$file=fopen($file,"r"); 
while(!feof($file)) 
{ 
$result.=fgets($file,9999); 
} 
fclose($file); 
echo '<form name="form1" method="post" action="?action=editsave&path='.$_GET['path'].'&type='.$_GET['type'].'"> 
<table width="100%" class="result-tab"> 
<tr> 
<th><strong> 编辑文件</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$url.'">返回</a></th> 
</tr> 
<tr> 
<td>文件:'.$_GET['path'].'</td> 
</tr> 
<tr> 
<td><textarea name="textarea" style="width:98%;height:450px;">'.$result.'</textarea></td> 
</tr> 
<tr> 
<td><input class="botton-common" type="submit" name="Submit" value="提交"> 
<input class="botton-common" type="reset" name="Submit2" value="重置"></td> 
</tr> 
</table> 
</form>'; 
}else{ 
echo '<form name="form1" method="post" action="?action=dir_rename&path='.$_GET['path'].'&type='.$_GET['type'].'"> 
<table width="100%" class="result-tab"> 
<tr> 
<th><strong>文件夹更名</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$url.'">返回</a></th> 
</tr> 
<tr> 
<td>文件夹更名:
<input name="filename" type="text" value="'.$_GET['path'].'" size="50"></td> 
</tr> 
<tr> 
<td><input class="botton-common" type="submit" name="Submit" value="提交"> 
<input class="botton-common" type="reset" name="Submit2" value="重置"></td> 
</tr> 
</table> 
</form>'; 
} 
break; 
case "editsave";
$file=iconv("utf-8","gb2312//IGNORE",$_GET['path']);
$file=fopen($file,"w"); 
fwrite($file,$_POST['textarea']); 
fclose($file); 
echo "<script type=\"text/javascript\">alert('恭喜,编辑成功!');location.href=\"".$url."\";</script>"; 
break; 
case "addfile"; 
echo '<form name="form1" method="post" action="?action=filesave&path='.$_GET['path'].'"> 
<table width="100%" class="result-tab"> 
<tr> 
<th><strong>新建文件</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$url.'">返回</a></th> 
</tr> 
<tr> 
<td>文件名: 
<input name="filename" type="text" value="'.$_GET['path'].'" size="50"></td> 
</tr> 
<tr> 
<td><textarea name="textarea" style="width:98%;height:450px;">输入内容 
</textarea></td> 
</tr> 
<tr> 
<td><input class="botton-common" type="submit" name="Submit" value="提交"> 
<input class="botton-common" type="reset" name="Submit2" value="重置"></td> 
</tr> 
</table> 
</form>'; 
break; 
case "filesave"; 
//包含点则建立文件,否则建立文件夹 
if(strpos($_POST['filename'],".",2)){
$file=fopen(iconv("utf-8","gb2312//IGNORE",$_POST['filename']),"w"); 
fwrite($file,$_POST['textarea']); 
fclose($file); 
}else{
//文件夹若存在则退出,不存在则建立! 
if(file_exists($_POST['filename'])){
exit; 
}else{
mkdir(iconv("utf-8","gb2312//IGNORE",$_POST['filename'])); 
} 
} 
echo "<script type=\"text/javascript\">alert('恭喜,".$_POST['filename']."建立成功!');location.href=\"".$url."\";</script>"; 
break; 
case "dir_rename"; 
rename(iconv("utf-8","gb2312//IGNORE",$_GET['path']),iconv("utf-8","gb2312//IGNORE",$_POST['filename'])); 
echo "<script type=\"text/javascript\">alert('恭喜,".$_POST['filename']."更名成功!');location.href=\"".$url."\";</script>"; 
break; 
default: 
$s=explode("\n",trim(`dir/b $path`)); 
echo '<table width="100%" class="result-tab"> 
<tr> 
<td colspan="4"><a class="link-common" href="?action=addfile&path='.iconv("GBK","utf-8",$path).'"><i class="icon-font">&#xe026;</i> 建立文件</a><a class="link-common" href="'.$url.'"><i class="icon-font">&#xe010;</i> 返回上一级</a></td>
</tr> 
<tr> 
<th>文件/文件夹</td> 
<th class="tc">文件属性</td> 
<th class="tc">文件大小</td> 
<th>操作</td> 
</tr>'; 
foreach($s as $value) 
{ 
echo ' 
<tr> 
<td>'.folder($path,$value).'</td> 
<td class="tc">'.filetype($path.$value).'</td> 
<td class="tc">'.round(filesize($path.$value)/1024).'kb</td> 
<td class="tc"><a class="link-common" href="?action=edit&path='.iconv("GBK","utf-8",$path.'\\'.$value).'&type='.filetype($path.$value).'">编辑</a><a class="link-common" href="?action=del&path='.iconv("GBK","utf-8",$path.'\\'.$value).'&type='.filetype($path.$value).'" onClick="return confirm(\'确定删除:'.iconv("GBK","utf-8",$value).'\');">删除</a></td> 
</tr>'; 
} 
echo "</table>"; 
break; 
} 
?>
            </div>
        </div>

    </div>
    <!--/main-->
</div>
</body>
</html>

这是我用的一个php文件管理代码,在apache环境下运行没有问题,但在iis环境下路径就出现问题,没有列出根目录下相应的文件,下面附上截图:

apache环境下:
图片说明

iis环境下:
图片说明

大家帮看一下是什么问题

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥20 蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏