Note: Pls remove the prefix space on all the HTML tags, before compile this program.
/*
Author : evergreenphp
Website : http://evergreenphp.blogspot.com
Website Info : Lots of source code
FREEly available, in PHP, javascript, AJAX,
MySQL etc.,
Note : 1. Before using this program, pls take a backup of your file and folders
2. Give folder and file permission then only this code will work nice..
Description : This program is used to remove all the file and folder in a specified folder
*/
/* Configuration settings start */
$path_file = '/www/htdocs/evergreenphp';
/* 0 - files not deleted, 1 - files will be deleted */
$display_with_destroy_files = 1;
/* 0 - files not deleted, 1 - files will be deleted */
$display_with_destroy_folders = 1;
/* Configuration settings ends */
$file_folder_list = scan_Dir($path_file);
$Files_list_array = Organize_file_list($file_folder_list, $display_with_destroy_files);
$Folders_list_array = Organize_folder_list($file_folder_list, $display_with_destroy_folders);
echo "Current Folder : " . $path_file . "< br>" ;
echo "< br>Files Found : ".count($Files_list_array);
echo "< pre>";
print_r($Files_list_array);
echo "< /pre>";
echo "< br>Folders Found : ".count($Folders_list_array);;
echo "< pre>";
print_r($Folders_list_array);
echo "< /pre>";
/* ---------------------------------------------------------------------------- */
/* List out all files and folders in the Current Directory (Specific Directory) */
function scan_Dir($dir=".") {
$arrfiles = array();
if (is_dir($dir)) {
if ($handle = opendir($dir)) {
chdir($dir);
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (is_dir($file)) {
//$arrfiles[] = $dir."/".$file;
$arr = scan_Dir($file);
$arrfiles[] = $dir."/".$file;
foreach ($arr as $value) {
$arrfiles[] = $dir."/".$value;
}
} else {
$arrfiles[] = $dir."/".$file;
}
}
}
chdir("../");
}
closedir($handle);
}
return $arrfiles;
}
/* Organize the files list */
function Organize_file_list($files_folders, $delete_status=0)
{
$Files_array = array();
for ($i=0; $i< count($files_folders); $i++)
{
$check = explode(".", $files_folders[$i]);
if (count($check) > 1) {
if($delete_status == 1)
@unlink($files_folders[$i]); /* Removing the files */
else
$Files_array[] = $files_folders[$i];
}
}
return $Files_array;
}
/* Organize the folders list */
function Organize_folder_list($files_folders, $delete_status=0)
{
$Files_array = array();
for ($i=0; $i< count($files_folders); $i++)
{
$check = explode(".", $files_folders[$i]);
if (count($check) == 1){
if($delete_status == 1)
@rmdir($files_folders[$i]); /* Removing the Folder */
else
$Files_array[] = $files_folders[$i];
}
}
return $Files_array;
}
?>
Subscribe to:
Post Comments (Atom)
Popular Posts
-
1. How old PHP language is? - PHP began in 1994, so 14 years old. 2. What are different names of PHP? - PHP originally stood for Persona...
-
HTML: a. HTML is a markup language that is used to build static (non interactive and nonanimated) webpages. b. HTML is Case-Insensitive. So...
-
A payment gateway is an e-commerce application service provider service that authorizes payments for e-businesses, online retailers, bricks...
-
Note : This is not a perfect sort order, we have just displaying the list of PHP companies. 1. Photon Infotech No. 2/102, Arvind IT Park (N...
-
- count() -- Count elements in a variable - syntax for count() [int count ( mixed var [, int mode])] - If the optional mode parameter is set...
-
Hai all, Simple show hide sample using Show/Hide? Simple Show/Hide code
-
Sharing PHP, MySQL, Javascript, CSS Knowledge, We can share our PHP knowledge on the basis of PHP versioning, Javascript, AJAX, Stylesheet, ...
-
Use the below code and you can get the exact value in php as us saw in browser. Code: $encode_data = iconv('UTF-8', 'windows-125...
-
Download and Enjoy!
-
A hyperlink is a text or a image that you can click on, and move from one page to another web page. Syntax: < a href= "web pag...
No comments:
Post a Comment