国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

PHP腳本實現Magento權限設置與緩存清理

2024-05-04 21:48:08
字體:
來源:轉載
供稿:網友

PHP腳本實現Magento權限設置與緩存清理的實例代碼有需要的朋友可參考一下.PHP實例代碼如下:

  1. <?php
  2. ## 設置文件644,目錄755 
  3. function AllDirChmod( $dir = "./"$dirModes = 0755, $fileModes = 0644 ){ 
  4.    $d = new RecursiveDirectoryIterator( $dir ); 
  5.    foreachnew RecursiveIteratorIterator( $d, 1 ) as $path ){ 
  6.       if$path->isDir() ) chmod$path$dirModes ); 
  7.       else ifis_file$path ) ) chmod$path$fileModes ); 
  8.   } 
  9.  
  10. ## 清除指定目錄 
  11. function cleandir($dir) { 
  12.     if ($handle = opendir($dir)) { 
  13.         while (false !== ($file = readdir($handle))) { 
  14.             if ($file != '.' && $file != '..' && is_file($dir.'/'.$file)) { 
  15.                 if (unlink($dir.'/'.$file)) { } 
  16.                 else { echo $dir . '/' . $file . ' (file) NOT deleted!<br />'; } 
  17.             } 
  18.             else if ($file != '.' && $file != '..' && is_dir($dir.'/'.$file)) { 
  19.                 cleandir($dir.'/'.$file); 
  20.                 if (rmdir($dir.'/'.$file)) { } 
  21.                 else { echo $dir . '/' . $file . ' (directory) NOT deleted!<br />'; } 
  22.             } 
  23.         } 
  24.         closedir($handle); 
  25.     } 
  26.  
  27. ## 判斷目錄是否為空 
  28. function isDirEmpty($dir){ 
  29.      return (($files = @scandir($dir)) && count($files) <= 2); 
  30.  
  31. echo "----------------------- CLEANUP START -------------------------<br/>"
  32. $start = (float) array_sum(explode(' ',microtime())); 
  33. echo "<br/>*************** SETTING PERMISSIONS ***************<br/>"
  34. echo "Setting all folder permissions to 755<br/>"
  35. echo "Setting all file permissions to 644<br/>"
  36. AllDirChmod( "." ); 
  37. echo "Setting pear permissions to 550<br/>"
  38. chmod("pear", 550); 
  39.  
  40. echo "<br/>****************** CLEARING CACHE ******************<br/>"
  41.  
  42. if (file_exists("var/cache")) { 
  43.     echo "Clearing var/cache<br/>"
  44.     cleandir("var/cache"); 
  45.  
  46. if (file_exists("var/session")) { 
  47.     echo "Clearing var/session<br/>"
  48.     cleandir("var/session"); 
  49.  
  50. if (file_exists("var/minifycache")) { 
  51.     echo "Clearing var/minifycache<br/>"
  52.     cleandir("var/minifycache"); 
  53.  
  54. if (file_exists("downloader/pearlib/cache")) { 
  55.     echo "Clearing downloader/pearlib/cache<br/>"
  56.     cleandir("downloader/pearlib/cache"); 
  57.  
  58. if (file_exists("downloader/pearlib/download")) { 
  59.     echo "Clearing downloader/pearlib/download<br/>"
  60.     cleandir("downloader/pearlib/download"); 
  61.  
  62. if (file_exists("downloader/pearlib/pear.ini")) { 
  63.     echo "Removing downloader/pearlib/pear.ini<br/>"
  64.     unlink ("downloader/pearlib/pear.ini"); 
  65.  
  66. echo "<br/>************** CHECKING FOR EXTENSIONS ***********<br/>"
  67. If (!isDirEmpty("app/code/local/")) {  
  68.     echo "-= WARNING =- Overrides or extensions exist in the app/code/local folder<br/>"
  69. If (!isDirEmpty("app/code/community/")) {  
  70.     echo "-= WARNING =- Overrides or extensions exist in the app/code/community folder<br/>"
  71. $end = (float) array_sum(explode(' ',microtime())); 
  72. echo "<br/>------------------- CLEANUP COMPLETED in:". sprintf("%.4f", ($end-$start))." seconds ------------------<br/>"
  73. ?> 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 射洪县| 惠来县| 区。| 益阳市| 晋中市| 新巴尔虎右旗| 上思县| 舒城县| 荥阳市| 石家庄市| 色达县| 乐业县| 通山县| 客服| 三河市| 城固县| 张家界市| 临清市| 云阳县| 左权县| 双牌县| 西盟| 平顶山市| 宣化县| 上犹县| 睢宁县| 福安市| 祁东县| 巨鹿县| 秦皇岛市| 南靖县| 遂昌县| 东港市| 安溪县| 凉城县| 廉江市| 廉江市| 兴义市| 阜南县| 金堂县| 宁阳县|