Plugin Directory

Changeset 808578


Ignore:
Timestamp:
11/22/2013 02:40:43 AM (12 years ago)
Author:
pntrinh
Message:

add optimize

Location:
tr-cache-and-security/trunk/inc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tr-cache-and-security/trunk/inc/actions.php

    r808562 r808578  
    6262        $path = TRSCSC_CACHE_PATH;
    6363    }
    64     $handle = @opendir($path);
    65     if ($handle)
    66     {
    67         while ($file = readdir($handle))
    68         {
    69             if ($file != '.' && $file != '..')
    70             {
    71                 @unlink($path . '/' . $file);
    72             }
    73         }
    74         closedir($handle);
    75     }
     64    tr_cache_clear_by_dir($path,0,time() + 999999);
     65   
     66    //clear cache js
     67    $path = WP_CONTENT_DIR .'/'. TRSCSC_CACHE_JS;
     68    tr_cache_clear_by_dir($path,0,time() + 999999);
     69   
     70    $path = WP_CONTENT_DIR .'/'. TRSCSC_CACHE_CSS;
     71    tr_cache_clear_by_dir($path,0,time() + 999999);
     72   
     73   
    7674    echo 'ok';
    7775    exit();
     76}
     77
     78function tr_cache_clear_by_dir($path,$timeout,$current_time)
     79{
     80    $handle = @opendir($path);
     81    if ($handle) {
     82        while ($file = readdir($handle)) {
     83            if ($file == '.' || $file == '..' || $file[0] == '_') continue;
     84   
     85            $t = @filemtime($path . '/' . $file);
     86            if ($current_time - $t > $timeout ) {
     87                @unlink($path . '/' . $file);
     88            }
     89        }
     90    }
     91    @closedir($handle);
    7892}
    7993
  • tr-cache-and-security/trunk/inc/cache_security_clean.php

    r808562 r808578  
    11<?php
    22global $wpdb;
     3include_once (TRSCSC_PATH . 'inc/actions.php');
    34
    4 function tr_cache_clear_dir($path,$timeout,$current_time)
    5 {
    6     $handle = @opendir($path);
    7     if ($handle) {
    8         while ($file = readdir($handle)) {
    9             if ($file == '.' || $file == '..' || $file[0] == '_') continue;
    10    
    11             $t = @filemtime($path . '/' . $file);
    12             if ($current_time - $t > $timeout ) {
    13                 @unlink($path . '/' . $file);
    14             }
    15         }
    16     }
    17     @closedir($handle);
    18 }
    195
    206//clear cache
     
    2511if ($timeout >0 && $cache_options['on'])
    2612{
    27     tr_cache_clear_dir(TRSCSC_CACHE_PATH,$timeout,$current_time);
     13    tr_cache_clear_by_dir(TRSCSC_CACHE_PATH,$timeout,$current_time);
    2814}
    2915
     
    3117$path = WP_CONTENT_DIR .'/'. TRSCSC_CACHE_JS;
    3218$timeout   = ($timeout < $timeout30)? $timeout30 : $timeout;
    33 tr_cache_clear_dir($path,$timeout,$current_time);
     19tr_cache_clear_by_dir($path,$timeout,$current_time);
    3420
    3521//clear cache css
    3622$path = WP_CONTENT_DIR .'/'. TRSCSC_CACHE_CSS;
    3723$timeout   = ($timeout < $timeout30)? $timeout30 : $timeout;
    38 tr_cache_clear_dir($path,$timeout,$current_time);
     24tr_cache_clear_by_dir($path,$timeout,$current_time);
    3925
    4026//end clear cache
     
    10086
    10187if($need_update_htacess)
    102 {
    103     include_once (TRSCSC_PATH . 'inc/actions.php');
     88{   
    10489    trwr_action_change_htaccess();
    10590}
Note: See TracChangeset for help on using the changeset viewer.