Changeset 12797 for trunk/admin
- Timestamp:
- Dec 27, 2011, 9:26:49 PM (12 years ago)
- Location:
- trunk/admin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions.php
r12763 r12797 2247 2247 return array_from_query($query, 'user_id'); 2248 2248 } 2249 2250 function clear_derivative_cache($type='all') 2251 { 2252 $pattern='#.*-'; 2253 if ($type == 'all') 2254 { 2255 $type_urls = array(); 2256 foreach(ImageStdParams::get_all_types() as $dtype) 2257 { 2258 $type_urls[] = derivative_to_url($dtype); 2259 } 2260 $type_urls[] = derivative_to_url(IMG_CUSTOM); 2261 $pattern .= '(' . implode('|',$type_urls) . ')'; 2262 } 2263 else 2264 { 2265 $pattern .= derivative_to_url($type); 2266 } 2267 $pattern.='(_[a-zA-Z0-9]+)*\.[a-zA-Z0-9]{3,4}$#'; 2268 if ($contents = opendir(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR)) 2269 { 2270 while (($node = readdir($contents)) !== false) 2271 { 2272 if ($node != '.' 2273 and $node != '..' 2274 and is_dir(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR.$node)) 2275 { 2276 clear_derivative_cache_rec(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR.$node, $pattern); 2277 } 2278 } 2279 closedir($contents); 2280 } 2281 } 2282 2283 function clear_derivative_cache_rec($path, $pattern) 2284 { 2285 $rmdir = true; 2286 $rm_index = false; 2287 2288 if ($contents = opendir($path)) 2289 { 2290 while (($node = readdir($contents)) !== false) 2291 { 2292 if ($node == '.' or $node == '..') 2293 continue; 2294 if (is_dir($path.'/'.$node)) 2295 { 2296 $rmdir &= clear_derivative_cache_rec($path.'/'.$node, $pattern); 2297 } 2298 else 2299 { 2300 if (preg_match($pattern, $node)) 2301 { 2302 unlink($path.'/'.$node); 2303 } 2304 elseif ($node=='index.htm') 2305 { 2306 $rm_index = true; 2307 } 2308 else 2309 { 2310 $rmdir = false; 2311 } 2312 } 2313 } 2314 closedir($contents); 2315 2316 if ($rmdir) 2317 { 2318 if ($rm_index) 2319 { 2320 unlink($path.'/index.htm'); 2321 } 2322 clearstatcache(); 2323 rmdir($path); 2324 } 2325 return $rmdir; 2326 } 2327 } 2249 2328 ?> -
trunk/admin/maintenance.php
r11827 r12797 122 122 break; 123 123 } 124 case 'compiled-templates' 124 case 'compiled-templates': 125 125 { 126 126 $template->delete_compiled_templates(); 127 127 FileCombiner::clear_combined_files(); 128 break; 129 } 130 case 'derivatives': 131 { 132 clear_derivative_cache(); 128 133 break; 129 134 } … … 155 160 'U_MAINT_SEARCH' => sprintf($url_format, 'search'), 156 161 'U_MAINT_COMPILED_TEMPLATES' => sprintf($url_format, 'compiled-templates'), 162 'U_MAINT_DERIVATIVES' => sprintf($url_format, 'derivatives'), 157 163 'U_HELP' => get_root_url().'admin/popuphelp.php?page=maintenance', 158 164 ) -
trunk/admin/rating.php
r12796 r12797 173 173 i.path, 174 174 i.file, 175 i. tn_ext,175 i.representative_ext, 176 176 i.rating_score AS score, 177 177 MAX(r.date) AS recently_rated, -
trunk/admin/themes/default/template/maintenance.tpl
r10133 r12797 30 30 <li><a href="{$U_MAINT_SEARCH}"onclick="return confirm('{'Purge search history'|@translate|@escape:'javascript'}');">{'Purge search history'|@translate}</a></li> 31 31 <li><a href="{$U_MAINT_COMPILED_TEMPLATES}">{'Purge compiled templates'|@translate}</a></li> 32 <li><a href="{$U_MAINT_DERIVATIVES}">{'Purge derivative image cache'|@translate}</a></li> 32 33 </ul>
Note: See TracChangeset
for help on using the changeset viewer.