PHP Read Directory Delete (can delete directory files) This article provides a PHP directory management program, he can be in the directory of files, folders, and other files for the management of delete operations, can support the management of an unlimited level of directory OH.
PHP Tutorial Read Directory Delete (can delete files under directory)
This article provides a PHP directory management program, he can be in the directory of files, folders, and other files for the management of delete operations, can support the management of an unlimited level of directory OH.
*/
Include ("class.php");
$path = $_get[' path '];
if ($path = = "") {
$path = "dir";
}else{
if (!strstr ($path, "dir")) {
$path = "dir/". $path;
}else{
$path = $path;
}
}
$newdir = new Dirver ();
$newdir-SetPath ($path);
$newdir-Dirdata ();
$files = $newdir-GetFiles ();
$dirs = $newdir-Getdirs ();
Print_r ($files);
Print_r ($dirs);
Echo (' );
$max = 3;
$j = 0;
if (count ($dirs) = = 2) {
Echo
'; Print ("
"); Print ("); Print ($dirs [0]); Print ("); Print (" | "); Print ("
"); Print ("); Print ($dirs [1]); Print ("); Print (" | "); Print ("
"); Print (""); Print (" | "); Echo '
';
}else{
Echo
'; while ($j <= (COUNT ($dirs)-1) {print ("
"); Print ("); Print ($dirs [$j]); Print ("); Print (" | "); if (($j + 1)% $max = = 0) {echo '
'; if ($j + 1)! = Count ($dirs)) {echo '
'; }} $j + +; } Echo '
';
}
$i = 0;
if (count ($files) = = 2) {
Echo
'; Print ("
Getfiletype ($files [0]). ". PNG '/> '); Print ($newdir-change2line ($files [0]); Print (" | "); Print ("
Getfiletype ($files [1]). ". PNG '/> '); Print ($newdir-Change2line ($files [1]); Print (" | "); Print ("
"); Print (""); Print (" | "); Echo '
';
}else{
Echo
'; while ($i <= (COUNT ($files)-1) {print ("
Getfiletype ($files [$i]). ". PNG '/> '); Print ($newdir-Change2line ($files [$i]); Print (" | "); if (($i + 1)% 3 = = 0) {echo '
'; if ($i + 1)! = Count ($files)) {echo '
'; }} $i + +;} Echo '
';
}
?>
class.php
Class for php4.x
Class dirver{
/class var/
var $path;
var $flies;
var $dirs;
/
function Dirver () {
$this, Path = "";
$this, files = Array ();
$this-dirs = Array ();
}
function Dirdata () {
if (isset ($this, path)) {
$handle = Dir ($this, path);
while (false!== ($data = $handle, read ())) {
if (Is_dir ($this, $this, $data)) && $data! = "." && $data! = "...") {
$this-dirs[] = $data;
Continue
}
if ($data! = "." && $data! = ":" && is_file ($this, Connectname ($this, Path, $data)) {
$this-files[] = $data;
Continue
}
}
$handle-Close ();
}else{
return false;
}
}
function SetPath ($SRC) {
if ($src! = "") {
$this, path = $SRC;
}else{
return false;
}
}
/
function Connectname ($path, $name) {
return $path. " /". $name;
}
/
function Change2line ($name) {
$basename = Explode (".", $name);
$basename = $basename [0];
$tmp = Path $this. " /". $name;
$tmp = ". $basename.";
return $tmp;
}
function Getfiletype ($file) {
if ($file! = "") {
$tmp = Explode (".", $file);
$type = $tmp [Count ($tmp)-1];
return $type;
}
}
function GetFiles () {
return $this files;
}
function Getdirs () {
return $this, dirs;
}
//
}
?>
http://www.bkjia.com/PHPjc/444856.html www.bkjia.com true http://www.bkjia.com/PHPjc/444856.html techarticle php Read Directory Delete (can delete directory files) This article provides a PHP directory management program, he can be in the directory of files, folders, and other files to manage delete operations, ...