Changeset 3400
- Timestamp:
- 01/05/2006 02:56:42 AM (19 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/cache.php
r3388 r3400 92 92 return; 93 93 94 $this->rm ($this->cache_dir.'*');94 $this->rm_cache_dir(); 95 95 $this->cache = array (); 96 96 $this->dirty_objects = array (); … … 215 215 } 216 216 217 function rm($fileglob) { 218 if (is_file($fileglob)) { 219 return @ unlink($fileglob); 220 } else 221 if (is_dir($fileglob)) { 222 $ok = WP_Object_Cache::rm("$fileglob/*"); 223 if (!$ok) 224 return false; 225 return @ rmdir($fileglob); 226 } else { 227 $matching = glob($fileglob); 228 if ($matching === false) 229 return true; 230 $rcs = array_map(array ('WP_Object_Cache', 'rm'), $matching); 231 if (in_array(false, $rcs)) { 232 return false; 233 } 234 } 235 return true; 217 function rm_cache_dir() { 218 $dir = $this->cache_dir; 219 $dir = rtrim($dir, DIRECTORY_SEPARATOR); 220 $stack = array($dir); 221 222 while (count($stack)) { 223 # Get last directory on stack 224 $dir = end($stack); 225 226 $dh = @ opendir($dir); 227 if (!$dh) 228 return false; 229 230 while (($file = @ readdir($dh)) !== false) { 231 if ($file == '.' or $file == '..') 232 continue; 233 234 if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file)) 235 $stack[] = $dir . DIRECTORY_SEPARATOR . $file; 236 else if (@ is_file($dir . DIRECTORY_SEPARATOR . $file)) 237 @ unlink($dir . DIRECTORY_SEPARATOR . $file); 238 } 239 240 if (end($stack) == $dir) { 241 @ rmdir($dir); 242 array_pop($stack); 243 } 244 } 236 245 } 237 246 -
trunk/wp-includes/functions-compat.php
r3280 r3400 90 90 } 91 91 92 /* Added in PHP 4.3.0 */93 94 if( !function_exists('glob') ):95 function glob($pattern) {96 // get pathname (everything up until the last / or \)97 $path=$output=null;98 // if(PHP_OS=='WIN32')99 // $slash='\\';100 // else101 // $slash='/';102 $slash = '/';103 $lastpos=strrpos($pattern,$slash);104 if(!($lastpos===false)) {105 $path=substr($pattern,0,$lastpos); #negative length means take from the right106 $pattern=substr($pattern,$lastpos+1);107 } else {108 //no dir info, use current dir109 $path=getcwd();110 }111 $handle=@ opendir($path);112 if($handle===false)113 return false;114 while($dir=readdir($handle)) {115 if ( '.' == $dir || '..' == $dir )116 continue;117 if (pattern_match($pattern,$dir))118 $output[]=$path . '/' . $dir;119 }120 closedir($handle);121 if(is_array($output))122 return $output;123 124 return false;125 }126 127 function pattern_match($pattern,$string) {128 // basically prepare a regular expression129 $out=null;130 $chunks=explode(';',$pattern);131 foreach($chunks as $pattern) {132 $escape=array('$','^','.','{','}','(',')','[',']','|');133 while(strpos($pattern,'**')!==false)134 $pattern=str_replace('**','*',$pattern);135 foreach($escape as $probe)136 $pattern=str_replace($probe,"\\$probe",$pattern);137 138 $pattern=str_replace('?*','*',139 str_replace('*?','*',140 str_replace('*',".*",141 str_replace('?','.{1,1}',$pattern))));142 $out[]=$pattern;143 }144 145 if(count($out)==1)146 return(eregi("^$out[0]$",$string));147 else148 foreach($out as $tester)149 if(eregi("^$tester$",$string))150 return true;151 return false;152 }153 endif;154 155 92 ?>
Note: See TracChangeset
for help on using the changeset viewer.