php读取根目录下的内容生成地图

今天分享关于php读取根目录下的内容生成地图html目录索引

<?php
require '../../common.inc.php';
require '../config.inc.php';
$mid=$moduleid;
$module = $MODULE[$mid]['module'];
$modurl = $MODULE[$mid]['linkurl'];
$modulename=$MODULE[$mid]['name'];
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $modulename;?>模块地图</title>

<style type="text/css">
	body {font-family: Verdana;FONT-SIZE: 12px;MARGIN: 0;color: #000000;background: #ffffff;}
	img {border:0;}
	li {margin-top: 8px;}
	.page {padding: 4px; border-top: 1px #EEEEEE solid}
	.author {background-color:#EEEEFF; padding: 6px; border-top: 1px #ddddee solid}
	#nav, #content, #footer {padding: 8px; border: 1px solid #EEEEEE; clear: both; width: 95%; margin: auto; margin-top: 10px;}
</style>
</head>
<body>

<h2 style="text-align: center; margin-top: 20px"><?php echo $modulename;?>站点地图 </h2>
<div id="content">
<h3><?php echo $modulename;?>最新文章</h3>
<ul>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<?php
$new_array = array();
function loopDir($dir,&$new_array,$modurl)
{
  $handle = opendir($dir);
  while(($file = readdir($handle))!== false ){
    if ($file != '.' && $file != '..'){
      if (filetype($dir.'/'.$file) != 'dir'){
		  $fileurl=$modurl."html/".$file;
		  echo "<li><a href='".$fileurl."'>".$file."</a></li>";
      }
      if (filetype($dir.'/'.$file) == 'dir'){
        loopDir($file,$new_array);
      }
    }
  }
}

$dir = './';
loopDir($dir,$new_array,$modurl);
?>
</tr>

</body>
</html>

  这样去执行访问:http://www.04411.net/fangfa/html/

posted @ 2023-05-15 10:39  圆柱模板  阅读(33)  评论(0编辑  收藏  举报