PHP脚本实现Magento权限设置与缓存清理
发布:smiling 来源: PHP粉丝网 添加日期:2014-07-30 11:25:32 浏览: 评论:0
PHP脚本实现Magento权限设置与缓存清理的实例代码有需要的朋友可参考一下.PHP实例代码如下:
- <?php
- ## 设置文件644,目录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 );
- }
- }
- ## 清除指定目录
- 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);
- }
- }
- ## 判断目录是否为空
- 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 the app/code/local folder<br/>";
- }
- If (!isDirEmpty("app/code/community/")) {
- echo "-= WARNING =- Overrides or extensions exist in the app/code/community folder<br/>";
- }
- $end = (float) array_sum(explode(' ',microtime()));
- echo "<br/>------------------- CLEANUP COMPLETED in:". sprintf("%.4f", ($end-$start))." seconds ------------------<br/>";
- ?>
Tags: PHP缓存 Magento 权限设置
- 上一篇:PHP中常用的缓存技术介绍
- 下一篇:phpExcel数据内存溢出解决办法
相关文章
- ·php 全面禁止浏览器缓存页面内容详解(2014-07-23)
- ·PHP中常用的缓存技术介绍(2014-07-29)
- ·php中用缓存与不用缓存性能测试(2014-08-27)
- ·php实现memcache缓存实例详解(2014-08-27)
- ·php文件缓存类实例整理(2014-08-27)
- ·PHP利用memcache缓存技术简单介绍(2014-08-28)
- ·php中文件缓存实现程序代码(2014-08-28)
- ·php与浏览器缓存机制介绍(2014-08-28)
- ·php页面缓存实现方法总结(2014-08-28)
- ·php缓存技术详细介绍及php缓存实现代码(2014-08-28)
- ·php配置memcache缓存方法 (2014-09-05)
- ·php文件缓存实例代码(2014-09-08)
- ·php实现文件数据缓存实现代码(2014-09-09)
- ·PHP MemCached 缓存应用(2014-09-09)
- ·PHP中使用memcache缓存技术提高响应速度详解(2014-09-10)
- ·PHP缓存集成库phpFastCache学习教程(2015-04-15)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)