?
/************************************
Name:listdir
Author:riyao Chen
version:0.0.1
Date:2006-05-16
License:gpl
This class are to list all file & directory follow a directory
Parameter: $strdir, which directory you want list; $del _url,the Manage URL,
*********************************/
Class listdir{
var $dir;
var $edit _url= "";
var $del _url= "";
var $num = 0;
function Listdir ($strdir, $del _url= "", $edit _url= "")
{
$this->dir = $strdir;
$this->del_url = $del _url;
$this->edit_url = $edit _url;
}
function MakeDir ($StrDir)
{
Global $num;
if (Is_dir ($StrDir)) {
if ($dh = @opendir ($StrDir)) {
while (($file = Readdir ($DH))!== false) {
$newdir = $StrDir. $file;
if ($file = = "." | | $file = = "...")
{
Continue
}
$this->num = $this->num + 1;
Print Str_repeat ("", $this->num);
if (filetype ($newdir) = = "Dir")
{
print "<br>";
print "$file [directory]<br>\n];
}
Else
{
Print "<a href= '". $this->del_url. "? File= ". $newdir." ' >EDIT</a> <a href= ' ". $newdir." ' > $file </a> <br>\n ";
}
if (Is_dir ($newdir))
{
$this->makedir ($newdir.) /");
}
$this->num = $this->num-1;
}
print "<br>";
Closedir ($DH);
}
}
}
function Showdir ()
{
$this->makedir ($this->dir);
}
}
/*
Exemple
Include_once ("./class.dir.php");
$dir = new Listdir ("c:/", "http://127.0.0.1/index.php");
$dir->showdir ();
*/