All pastes #521723 Raw Edit

Something

public text v1 · immutable
#521723 ·published 2007-05-30 08:05 UTC
rendered paste body
<?php
/*
@ Author 'Alex'
@ File : file_tree.php created 30/05/2007
*/

class file_tree {
	
	# Configuration of system
	var $buffer;
	var $not_countable = array(".","..");
	
	function file_tree() {
		$this->buffer = "Starting file dumper of ".$path;
		$this->path = "./";
		$this->construct_tree($this->path);
	}
	
	function construct_tree($path) {
		$this->handle = opendir($path) or die("error #1");
		echo "<br> Directory: ".$path. "<br>";
		
		while(false !== ($this->file = readdir($this->handle))) {
			if(!in_array($this->file,$this->not_countable)) {
				if(is_file($this->file)) {
					echo($this->file."<br>");
				} elseif(is_dir($this->file)) {
					$this->construct_tree($this->file."/");
				}
			}     	
		}
		closedir($this->handle);
	}
	
}

$ins = new file_tree();

?>



// 0utput

Directory: ./
asd.php

Directory: new_cms/
asd.php

Warning: readdir(): 3 is not a valid Directory resource in /www/05/nero.pri.ee/erti/file_tree.php on line 23

Warning: closedir(): 3 is not a valid Directory resource in /www/05/nero.pri.ee/erti/file_tree.php on line 32