100分求php读取目录文件

来源:百度知道 编辑:UC知道 时间:2024/06/30 10:05:48
<?php
include( "inc/header.php" );
login_check( );
echo "\r\n<body>\r\n<table width=\"98%\" border=\"1\" align=\"center\" cellpadding=\"5\" cellspacing=\"0\" class=\"table\">\r\n <tr>\r\n <td><a href=\"Admin_Sql.php\">返回数据库操作首页</a> | <a href=\"Admin_Sql.php?Action=back\">立即备份新的数据库</a></td>\r\n </tr>\r\n</table><br>\r\n";
if ( $_GET['Action'] == "backin" )
{
$file_name = "back/".$_GET['file'];
set_time_limit( 0 );
if ( !( $fp = @fopen( $file_name, "r" ) ) )
{
exit( "不能打开SQL文件 ".$file_name );
}
if ( !mysql_connect( $DB_Host, $DB_User, $DB_Password ) )
{
exit(

if ( $handle = opendir( "back" ) )
{
$i = 0;
while ( false !== ( $file = readdir( $handle ) ) )
{
if ( !( $file != "." ) && !( $file != ".." ) )
{
$i += 1;
echo "\t\r\n\t<tr>\r\n\t\t<td>";
echo $i;
echo "</td>\r\n \t<td>";
echo $file;
echo "</td>\r\n \t <td align=\"center\">\r\n\t\t<a href=\"Admin_Sql.php?Action=backin&file=";
echo $file;
echo "\">导入</a>\r\n\t\t<a href=\"Admin_Sql.php?Action=delback&file=";
echo $file;
echo "\">删除</a>\r\n\t </td>\r\n\t</tr>\r\n";
}
}
closedir( $handle );
}

这一段修改为下面的三行:

echo '<pre>