-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
75 lines (63 loc) · 1.81 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
//http://www.sharejs.com/codes/php/
//http://www.php-open.com/
//www.ocshine.net
/**
* 列出目录
*/
define('STUDYPATH', dirname(__FILE__));
//列出父目录下的所有子目录
function listDir($fDir){
if( $handle = opendir($fDir) ){
$output = array();
while(false !== ( $item = readdir( $handle ) ) ){
if(is_dir($fDir.'/'.$item) and $item != '.' and $item != '..' ){
$output[] = $item;
}
}
closedir($handle);
return $output;
}else{
return false;
}
}
//读取单个目录下的index.php信息
function readFileInfo($dir, $fileName){
if( $handle = opendir( $dir ) ){
$output = array();
//echo $dir."/".$fileName;
$str = "";
while ( false !== ( $index = readdir( $handle ) ) ){
if( is_file( $dir."/".$fileName ) && ( $index == $fileName ) ){
$str = file_get_contents($dir."/".$fileName);
echo $str;
}
}
}
}
readFileInfo('./ajax', 'index.php');
$dirs = listDir(STUDYPATH);
//var_dump($dirs);
?>
<html>
<head>
<title>目录列表</title>
</head>
<body>
<style>
.top{border-bottom: 1px solid blue;height:50px;line-height: 50px;text-align: center;font-weight:bold;font-size: 30px;}
ul li{float:left;width:140px;height:30px;line-height: 30px;}
ul li a{font-size: 20px;}
</style>
<div class="top">目录列表</div>
<ul>
<?php
foreach ($dirs as $dir){
?>
<li><a href="./<?=$dir ?>"><?=$dir ?></a></li>
<?php
}
?>
</ul>
</body>
</html>