thinkphp Clear all directories (including subdirectories)
common.php file in the common directory of the admin project:/*** Delete all XML files under XML directory * string $fp file path (not including file name) * String $FN file name (including extension) * Boolean $ Whether the type is associated to all subdirectories */function delxml ($type =true, $fn = ', $fp = './xml ') {if (!is_dir ($fp)) {return ' Nodir '; The deleted directory does not exist}else{if (!is_empty_dir ($fp)) {//If it is not empty $H = @ opendir ($FP); while (False!== ($_file=readdir ($H))) {//retrieves the directory if (Is_dir ($fp. " /". $_file) && $_file! =". "&& $_file!=": "&& $_file!==" Thumbs.db ") {if ($type) {if"!is_e Mpty_dir ($fp. '/'. $_file)} {//If not, call itself, but the original path + his subordinate directory name Delxml ($type, $FN, $fp. " /". $_file); } if (Is_empty_dir ($fp. '/'. $_file)) {//If it is empty, delete the rmdir ($fp. '/'. $_file); }}//Retrieve file}else if (Is_file ($fp. " /". $_file) && $_file!=". "&& $_file!=": "&& $_file!==" Thumbs.db ") {if (eregi ('/') $file, '/'. $_ File) {if (!unlink ($fp. '/'. $_file)) {return false;//delete Failed}}}} Closedir ($H); } return true; Delete Failed}} Determines whether the directory is empty, true is null, false is not empty function Is_empty_dir ($fp) {$H = @ opendir ($fp); $i = 0; while ($_file=readdir ($H)) {$i + +; } closedir ($H); if ($i >2) {return false;} else{return true; }} Call method: SiteMapAction.class.php file under the action directory of the Admin project: Class Sitemapaction extends Action {//delete all XML directory map file function Delxml () {$flag = Delxml (); Exit ($flag); }} Static page Ajax method:
<title>Delete a catalog file</title>
?