Changeset 12797 for trunk/admin


Ignore:
Timestamp:
Dec 27, 2011, 9:26:49 PM (12 years ago)
Author:
rvelices
Message:

feature 2541 multisize

  • nicer presentation on picture.php
  • added a maintenance purge derivatives action
Location:
trunk/admin
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions.php

    r12763 r12797  
    22472247  return array_from_query($query, 'user_id');
    22482248}
     2249
     2250function 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
     2283function 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}
    22492328?>
  • trunk/admin/maintenance.php

    r11827 r12797  
    122122    break;
    123123  }
    124   case 'compiled-templates' :
     124  case 'compiled-templates':
    125125  {
    126126    $template->delete_compiled_templates();
    127127    FileCombiner::clear_combined_files();
     128    break;
     129  }
     130  case 'derivatives':
     131  {
     132    clear_derivative_cache();
    128133    break;
    129134  }
     
    155160    'U_MAINT_SEARCH' => sprintf($url_format, 'search'),
    156161    'U_MAINT_COMPILED_TEMPLATES' => sprintf($url_format, 'compiled-templates'),
     162    'U_MAINT_DERIVATIVES' => sprintf($url_format, 'derivatives'),
    157163    'U_HELP' => get_root_url().'admin/popuphelp.php?page=maintenance',
    158164    )
  • trunk/admin/rating.php

    r12796 r12797  
    173173    i.path,
    174174    i.file,
    175     i.tn_ext,
     175    i.representative_ext,
    176176    i.rating_score       AS score,
    177177    MAX(r.date)          AS recently_rated,
  • trunk/admin/themes/default/template/maintenance.tpl

    r10133 r12797  
    3030        <li><a href="{$U_MAINT_SEARCH}"onclick="return confirm('{'Purge search history'|@translate|@escape:'javascript'}');">{'Purge search history'|@translate}</a></li>
    3131        <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>
    3233</ul>
Note: See TracChangeset for help on using the changeset viewer.