西部数码主机 | 阿里云主机| 虚拟主机 | 西部数码云服务器 | 返回乐道官网
当前位置: 主页 > php教程 > ecshop教程 >

ecshop校验文件生成MD5文件代码

时间:2011-10-14 09:25来源:未知 作者:好模板 点击:次
ecshop校验文件生成MD5文件的代码 define( 'ROOT_PATH' , str_replace ( basename ( __FILE__ ), '' , str_replace ( '\\',' /', __FILE__ ))); ini_set ( 'max_execution_time' , '300' ); checkfiles( './' , '\.php' ,0); checkfiles( 'admin/'

 ecshop校验文件生成MD5文件的代码

  1. define('ROOT_PATH', str_replace(basename( __FILE__), '', str_replace('\\', '/', __FILE__))); 
  2.  
  3. ini_set('max_execution_time', '300'); 
  4.  
  5. checkfiles('./', '\.php', 0); 
  6. checkfiles('admin/', '\.php|\.htm|\.js|\.css|\xml'); 
  7. checkfiles('api/', '\.php'); 
  8. checkfiles('includes/', '\.php|\.html|\.js',1,'fckeditor');    //fck不检查 
  9. checkfiles('js/', '\.js|\.css'); 
  10. checkfiles('languages/', '\.php'); 
  11. checkfiles('plugins/', '\.php'); 
  12. checkfiles('wap/', '\.php|\.wml'); 
  13. /* 
  14. checkfiles('themes/default/', '\.dwt|\.lbi|\.css');   //模板 
  15. checkfiles('uc_client/', '\.php', 0); 
  16. checkfiles('uc_client/control/', '\.php'); 
  17. checkfiles('uc_client/model/', '\.php'); 
  18. checkfiles('uc_client/lib/', '\.php'); 
  19. */ 
  20.  
  21. file_put_contents('./admin/ecshopfiles.md5',$md5str);   //保存文件校验信息 
  22.  
  23. echo "MD5文件生成完成"; 
  24.  
  25.  
  26.  
  27.  
  28. /**检查文件 
  29. * @param  string $currentdir    //待检查目录 
  30. * @param  string $ext           //待检查的文件类型 
  31. * @param  int    $sub           //是否检查子目录 
  32. * @param  string $skip          //不检查的目录或文件 
  33. */ 
  34. function checkfiles($currentdir, $ext = '', $sub = 1, $skip = '') 
  35. { 
  36.     global $md5data, $md5str; 
  37.     $dir = @opendir(ROOT_PATH.$currentdir); 
  38.     $exts = '/('.$ext.')$/i'; 
  39.     $skips = explode(',', $skip); 
  40.  
  41.     while($entry = @readdir($dir)) 
  42.     { 
  43.         $file = $currentdir.$entry; 
  44.         if($entry != '.' && $entry != '..' && $entry != '.svn' && (preg_match($exts, $entry) || $sub && is_dir($file)) && !in_array($entry, $skips)) 
  45.         { 
  46.             if($sub && is_dir($file)) 
  47.             { 
  48.                 checkfiles($file.'/', $ext, $sub, $skip); 
  49.             } 
  50.             else 
  51.             { 
  52.                 if($file != './md5.php') 
  53.                 { 
  54.                     $md5data[$file] = md5_file($file); 
  55.                     $md5str .= md5_file($file).' *'.$file."\r\n"; 
  56.                 } 
  57.             } 
  58.  
  59.         } 
  60.  
  61.     } 
  62. } 

好模板搜集该ecshop教程,转载请注明网址!

(责任编辑:好模板)
顶一下
(0)
0%
踩一下
(2)
100%
------分隔线----------------------------
栏目列表
热点内容