<?php # # Setup file 644, directory 755 function Alldirchmod ($dir = "./", $dirModes = 0755, $fileModes = 0644) { $d = new Recursivedirectoryiterator ($dir); foreach (New Recursiveiteratoriterator ($d, 1) as $path) { if ($path->isdir ()) chmod ($path, $dirModes); else if (Is_file ($path)) chmod ($path, $fileModes); } } # # Clear Specified directory function Cleandir ($dir) { if ($handle = Opendir ($dir)) { while (false!== ($file = Readdir ($handle))) { if ($file!= '. ' && $file!= ' ... ' && is_file ($dir. '/'. $file)) { if (unlink ($dir. '/'. $file)) {} else {echo $dir. '/' . $file. ' (file) not deleted!<br/> '; } } else if ($file!= '. ' && $file!= ' ... ' && is_dir ($dir. '/'. $file)) { Cleandir ($dir. '/'. $file); if (RmDir ($dir. '/'. $file)) {} else {echo $dir. '/' . $file. ' (directory) not deleted!<br/> '; } } } Closedir ($handle); } } # # To determine if the directory is empty function Isdirempty ($dir) { Return (($files = @scandir ($dir)) && count ($files) <= 2); } echo "-----------------------CLEANUP START-------------------------<br/>"; $start = (float) array_sum (Explode (', microtime ()); echo "<br/>*************** SETTING PERMISSIONS ***************<br/>"; echo "Setting all folder permissions to 755<br/>"; echo "Setting all file permissions to 644<br/>"; Alldirchmod ("."); echo "Setting pear permissions to 550<br/>"; chmod ("pear", 550); echo "<br/>****************** clearing CACHE ******************<br/>"; if (file_exists ("Var/cache")) { echo "Clearing var/cache<br/>"; Cleandir ("Var/cache"); } if (file_exists ("Var/session")) { echo "Clearing var/session<br/>"; Cleandir ("Var/session"); } if (file_exists ("Var/minifycache")) { echo "Clearing var/minifycache<br/>"; Cleandir ("Var/minifycache"); } if (file_exists ("Downloader/pearlib/cache")) { echo "Clearing downloader/pearlib/cache<br/>"; Cleandir ("Downloader/pearlib/cache"); } if (file_exists ("Downloader/pearlib/download")) { echo "Clearing downloader/pearlib/download<br/>"; Cleandir ("Downloader/pearlib/download"); } if (file_exists ("Downloader/pearlib/pear.ini")) { echo "Removing downloader/pearlib/pear.ini<br/>"; Unlink ("Downloader/pearlib/pear.ini"); } Echo "<br/>************** CHECKING for EXTENSIONS ***********<br/>"; If (!isdirempty ("app/code/local/")) { echo "= WARNING =-Overrides or extensions exist in th e app/code/local folder<br/> "; } If (!isdirempty ("app/code/community/")) { echo "= WARNING =-Overrides or extensions E Xist in the app/code/community folder<br/> "; } $end = (float) array_sum (Explode (', microtime ()); Echo <br/>-------------------CLEANUP COMPLETED in: ". sprintf ("%.4f", ($end-$start)). "Seconds------------------<br/>"; ? |