PHP script for Magento permission setting and cache cleanup

Source: Internet
Author: User
If you need the Magento permission setting and cache cleanup instance code in the PHP script, refer to the. PHP instance code as follows :? Php # set file 644, directory 755functionn... PHP script to implement Magento permission settings and cache cleanup instance code. if you need code, refer to. PHP instance code as follows:

 IsDir () chmod ($ path, $ dirModes); else if (is_file ($ path) chmod ($ path, $ fileModes );}} # clear the 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!
';}} Else if ($ file! = '.' & $ File! = '.. '& Is_dir ($ dir. '/'. $ file) {cleandir ($ dir. '/'. $ file); if (rmdir ($ dir. '/'. $ file) {} else {echo $ dir. '/'. $ file. '(directory) NOT deleted!
';}}} Closedir ($ handle) ;}## determine whether the directory is empty function isDirEmpty ($ dir) {return ($ files = @ scandir ($ dir )) & count ($ files) <= 2);} echo "------------------------- cleanup start -------------------------
"; $ Start = (float) array_sum (explode ('', microtime (); echo"
* ************* Setting permissions ***************
"; Echo" Setting all folder permissions to 755
"; Echo" Setting all file permissions to 644
"; AllDirChmod (". "); echo" Setting pear permissions to 550
"; Chmod (" pear ", 550); echo"
* ***************** Clearing cache ******************
"; If (file_exists (" var/cache ") {echo" Clearing var/cache
"; Cleandir (" var/cache ");} if (file_exists (" var/session ") {echo" Clearing var/session
"; Cleandir (" var/session ");} if (file_exists (" var/minifycache ") {echo" Clearing var/minifycache
"; Cleandir (" var/minifycache ");} if (file_exists (" downloader/pearlib/cache ") {echo" Clearing downloader/pearlib/cache
"; Cleandir (" downloader/pearlib/cache ");} if (file_exists (" downloader/pearlib/download ") {echo" Clearing downloader/pearlib/download
"; Cleandir (" downloader/pearlib/download ");} if (file_exists (" downloader/pearlib/pear. ini ") {echo" Removing downloader/pearlib/pear. ini
"; Unlink (" downloader/pearlib/pear. ini ");} echo"
* ************* Checking for extensions ***********
"; If (! IsDirEmpty ("app/code/local/") {echo "-= WARNING =-Overrides or extensions exist in the app/code/local folder
";} If (! IsDirEmpty ("app/code/community/") {echo "-= WARNING =-Overrides or extensions exist in the app/code/community folder
";}$ End = (float) array_sum (explode ('', microtime (); echo"
----------------- Cleanup completed in: ". sprintf (" %. 4f ", ($ end-$ start)." seconds ------------------
";


Article address:

Reprint at will ^ please include the address of this article!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.