Plugin Directory

Changeset 808562


Ignore:
Timestamp:
11/22/2013 01:53:45 AM (12 years ago)
Author:
pntrinh
Message:

add optimize

Location:
tr-cache-and-security/trunk
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • tr-cache-and-security/trunk/admin/css/admin.css

    r785643 r808562  
    356356    margin-top:2px;
    357357}
     358.tab_title{font-size:18px;font-weight:600}
  • tr-cache-and-security/trunk/admin/js/Admin_Page_Class.js

    r786017 r808562  
    522522    var group = jQuery("#option_group_name").val();
    523523    var seq_selector = "#apc_" + which + "_nonce";
    524     var action_selctor = "apc_" + which + "_" + group;
     524    var action_selctor = "apc_" + which+'_tr';
    525525    jQuery.ajaxSetup({ cache: false });
    526526    if (which == 'export')
     
    581581        action: action,
    582582        seq: jQuery(seq_selector).val(),
    583         imp: jQuery("#import_code").val(),
     583        imp: jQuery("#export_code").val(),
    584584      },
    585585      function(data) {
     
    605605   */
    606606  function before_ajax_import_export(which){
    607     jQuery(".import_status").hide("fast");
    608607    jQuery(".export_status").hide("fast");
    609608    jQuery(".export_results").html('').removeClass('alert-success').hide();
    610     jQuery(".import_results").html('').removeClass('alert-success').hide();
    611     if (which == 'import')
    612       jQuery(".import_status").show("fast");
    613     else
    614       jQuery(".export_status").show("fast");
     609    jQuery(".export_status").show("fast");     
    615610  }
    616611
     
    625620   */
    626621  function after_ajax_import_export(which){
    627     if (which == 'import')
    628       jQuery(".import_status").hide("fast");
    629     else
    630622      jQuery(".export_status").hide("fast");
    631623  }
     
    661653      jQuery("#apc_import_nonce").val(data.nonce);
    662654    if(data.err)
    663       jQuery(".import_results").html(data.err);
     655      jQuery(".export_results").html(data.err).show();
    664656    if (data.success)
    665       jQuery(".import_results").html(data.success).addClass('alert-success').show('slow');
     657      jQuery(".export_results").html(data.success).addClass('alert-success').show('slow');
    666658  }
    667659
     
    672664   */
    673665  jQuery("#apc_import_b").live("click",function(){
     666    if($('#export_code').val()=='')
     667    {
     668        jQuery(".export_results").html('Please Add Code below to Import').show();
     669        return false;
     670    }   
    674671    do_ajax_import_export('import');
    675672  });
     
    711708        success:function(rs){
    712709            $('.msg_alert_success',$this).html('The options are been restored!').css('display','block').removeClass('saving');
    713             location.reload();
     710            refresh_page();
    714711        }
    715712     })
     
    727724   */
    728725  function refresh_page(){
    729     location.reload();
     726    location = location.href;
    730727  }
    731728  $('input[type="checkbox"]').each(function(){
  • tr-cache-and-security/trunk/inc/actions.php

    r806087 r808562  
    338338   
    339339    //cache cache_media
    340     if($cache_options['on'] && $cache_options['cache_media'])
     340    if($cache_options['cache_media'])
    341341    {
    342342        $need.="# 1 WEEK\n<FilesMatch \"\.(jpg|jpeg|png|gif|swf|ico)$\">\n";
  • tr-cache-and-security/trunk/inc/admin.php

    r796375 r808562  
    1515    'slug' => 'trcs_settings',
    1616    'page_title' => 'Cache & Security',       //The name of this page
    17     'menu_title' => 'Cache & Security',
     17    //'menu_title' => 'Cache & Security',
    1818    'capability' => 'edit_themes',         // The capability needed to view the page
    1919    'option_group' => 'trcs_cache',       //the name of the option to create in the database
    20     'id' => 'trcs_settings',            // meta box id, unique per page
    21     'fields' => array(),            // list of fields (can be added by field arrays)
    2220    'local_images' => true,          // Use local or hosted images (meta box images for add/remove)
    2321   // 'icon_url' => TRJM_URL.'images/mobile.png',
    2422    'use_with_theme' => false ,         //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
    2523    'path' => dirname(dirname(__FILE__)),
     24    'usebackup'     => true,
    2625    'tabs' => array(
    2726        'this'  => 'Cache',
    28         'trcs_security' => array('option'=>'tr_security','label'=>'Security')
     27        'trcs_security' => array('option'=>'tr_security','label'=>'Security'),
    2928    )
    3029); 
     
    3332* Initiate your admin page
    3433*/
    35 new TR_Admin_Page_Class_V4($config);
     34new TR_Admin_Page_Class_V5($config);
    3635
    3736
  • tr-cache-and-security/trunk/inc/cache_security_clean.php

    r804796 r808562  
    22global $wpdb;
    33
    4 //clear cache
    5 $current_time   = time();
    6 $cache_options  = get_option('trcs_cache');
    7 $timeout = $cache_options['timeout']*60;
    8 if ($timeout >0 && $cache_options['on'])
     4function tr_cache_clear_dir($path,$timeout,$current_time)
    95{
    10     $path = TRSCSC_CACHE_PATH;
    11     $time = time();
    12 
    136    $handle = @opendir($path);
    147    if ($handle) {
     
    1710   
    1811            $t = @filemtime($path . '/' . $file);
    19             if ($time - $t > $timeout || ($invalidation_time && $t < $invalidation_time)) {
     12            if ($current_time - $t > $timeout ) {
    2013                @unlink($path . '/' . $file);
    2114            }
     
    2518}
    2619
     20//clear cache
     21$timeout30 = 86400 * 30;//30days
     22$current_time   = time();
     23$cache_options  = get_option('trcs_cache');
     24$timeout = $cache_options['timeout']*60;
     25if ($timeout >0 && $cache_options['on'])
     26{
     27    tr_cache_clear_dir(TRSCSC_CACHE_PATH,$timeout,$current_time);
     28}
     29
     30//clear cache js
     31$path = WP_CONTENT_DIR .'/'. TRSCSC_CACHE_JS;
     32$timeout   = ($timeout < $timeout30)? $timeout30 : $timeout;
     33tr_cache_clear_dir($path,$timeout,$current_time);
     34
     35//clear cache css
     36$path = WP_CONTENT_DIR .'/'. TRSCSC_CACHE_CSS;
     37$timeout   = ($timeout < $timeout30)? $timeout30 : $timeout;
     38tr_cache_clear_dir($path,$timeout,$current_time);
     39
     40//end clear cache
    2741
    2842
     43
     44//update security ban list
    2945$need_update_htacess = false;
    30 //update security ban list
    3146$secure_options = get_option('tr_security',array());
    3247if($secure_options['enable_auto_ban'])
  • tr-cache-and-security/trunk/inc/init.php

    r791202 r808562  
    77add_action('save_post', 'tr_wp_insert_comment', 10,1);
    88
     9
     10
    911function tr_cache_plugin_init()
    1012{   
     
    1315        include_once(TRSCSC_PATH.'inc/actions.php');
    1416    }
    15     if(!is_admin() && !is_user_logged_in())
     17    if(!is_admin())
    1618    {       
    17         add_filter( 'show_admin_bar', '__return_false' ,99);
     19        if(!is_user_logged_in())
     20            add_filter( 'show_admin_bar', '__return_false' ,99);
     21           
     22        global $tr_cache_options;
     23        if(!is_array($tr_cache_options))
     24            $tr_cache_options = get_option('trcs_cache',array());
     25           
     26        if($tr_cache_options['optimize_js'] || $tr_cache_options['optimaze_css'])
     27        {
     28            $cache_obj = Tr_Cache_Class::instance();
     29            if(!Tr_Cache_Class::$has_run)
     30                add_action('template_redirect',array(&$cache_obj,'template_redirect'),1);
     31        }
     32       
    1833    }
    1934}
  • tr-cache-and-security/trunk/inc/install.php

    r797937 r808562  
    77    $config = array(   
    88        'option_group' => 'tr_security',   
    9         'id' => 'trcs_settings',
    109        'path' => dirname(dirname(__FILE__)),
    1110    );
    12     $secu = new TR_Admin_Page_Class_V4($config);
     11    $secu = new TR_Admin_Page_Class_V5($config);
    1312    $secu->loadconfig('trcs_security');
    1413    $secu->restore();
     
    2120    $config = array(   
    2221        'option_group' => 'trcs_cache',   
    23         'id' => 'trcs_settings',
    2422        'path' => dirname(dirname(__FILE__)),
    2523    ); 
    26     $secu = new TR_Admin_Page_Class_V4($config);
    27     $secu->loadconfig('trcs_settings');
     24    $secu = new TR_Admin_Page_Class_V5($config);
     25    $secu->loadconfig('trcs_cache');
    2826    $secu->restore();
    2927}
  • tr-cache-and-security/trunk/inc/tr_security_class.php

    r806071 r808562  
    417417            $_SESSION['tr_sec_auto'] =$current_time;
    418418        }
    419         else if(!isset($_SESSION['tr_sec_auto']) || $_SESSION['tr_sec_auto'] < $current_time - 3600)
     419        else if(!isset($_SESSION['tr_sec_auto']) || $_SESSION['tr_sec_auto'] < $current_time - 86400)
    420420        {
    421421            $codecheck = wp_generate_password(12,false);
  • tr-cache-and-security/trunk/plug.php

    r806087 r808562  
    1414define('TRSCSC_PATH',plugin_dir_path(__FILE__).'/');
    1515define('TRSCSC_CACHE_PATH',WP_CONTENT_DIR . '/cache/tr-cache');
     16define('TRSCSC_CACHE_JS_PATH','/cache/js');
     17define('TRSCSC_CACHE_CSS_PATH','/cache/css');
    1618define('TRSCSC_SERVER','http://ngoctrinh.net/wp-load.php');
    1719
Note: See TracChangeset for help on using the changeset viewer.