I want to put this script into a folder and use it to to read all the folders and files wich are in the same folder as the script (included subfolders!)...
The first time the readDirectory-Function is called everything works fine, afterwards when the function is called it doesn\'t detect directory\'s anymore, means that it\'s not continuing reading the directorys...
Can someone help me ???
Here\'s the script:
<?php class mapper {
var $name;
var $dirToread;
var $dirArr;
var $handle;
var $file;
var $path;
function mapper($name, $dir_zus) {
$this->dirArr = array();
$this->name = $name;
$this->dirToread=$dir_zus;
}
function readDirectory() {
$this->handle=opendir($this->dirToread);
while ($this->file = readdir($this->handle)) {
if ($this->file == \".\" || $this->file == \"..\") { }
elseif (is_dir($this->file)) {
echo($this->file.\"is a Directory<br>\");
$this->path =\"\";
$this->path .=$this->dirToread.\"/\".$this->file;
$this->file = new mapper($this->file, $this->path);
$this->dirArr[count($this->dirArr)]=$this->file;
} else {
echo($this->file.\"is not a directory<br>\");
}
}
closedir($this->handle);
if (count($this->dirArr)!=0) {
foreach($this->dirArr as $key=>$val){
$val->readDirectory();
}
}
}
}
?>
<?php
$d = new mapper(\"root\", getcwd());
$d->readDirectory();
echo(\"DIRECTORY:\");
echo(getcwd());
?>