Plugin Directory

Changeset 2154797


Ignore:
Timestamp:
09/11/2019 01:15:47 PM (6 years ago)
Author:
runcloud
Message:

updated random key prefix

Location:
runcache-purger/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • runcache-purger/trunk/assets/runcache_purger.css

    r2154691 r2154797  
    548548
    549549@media (max-width: 783px) {
     550
     551    #runcachepurger-wrap .cache-redis {
     552        padding-left: 0px;
     553    }
     554
    550555    #runcachepurger-wrap .cache-redis > label {
    551556        display: block;
  • runcache-purger/trunk/languages/runcachepurger.pot

    r2154691 r2154797  
    55msgstr  "Project-Id-Version: RunCache Purger 1.0.0\n"
    66        "Report-Msgid-Bugs-To: https://runcloud.io\n"
    7         "POT-Creation-Date: 2019-09-11 17:47+0800\n"
     7        "POT-Creation-Date: 2019-09-11 21:09+0800\n"
    88        "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    99        "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    3838msgstr  ""
    3939
    40 #: runcache-purger.php:506 runcache-purger.php:625
     40#: runcache-purger.php:516 runcache-purger.php:635
    4141msgid   "Settings"
    4242msgstr  ""
    4343
    44 #: runcache-purger.php:640
     44#: runcache-purger.php:650
    4545msgid   "Clear Cache this Post"
    4646msgstr  ""
    4747
    48 #: runcache-purger.php:651
     48#: runcache-purger.php:661
    4949msgid   "Clear Cache this URL"
    5050msgstr  ""
    5151
    52 #: runcache-purger.php:661 views/settings.php:191
     52#: runcache-purger.php:671 views/settings.php:191
    5353msgid   "Clear All Cache"
    5454msgstr  ""
    5555
    56 #: runcache-purger.php:1086
     56#: runcache-purger.php:1096
    5757msgid   "Failed to purge cache."
    5858msgstr  ""
    5959
    60 #: runcache-purger.php:1093
     60#: runcache-purger.php:1103
    6161msgid   "Purging cache was successful."
    6262msgstr  ""
    6363
    64 #: runcache-purger.php:1095
     64#: runcache-purger.php:1105
    6565msgid   "Purging redis object cache was successful."
    6666msgstr  ""
    6767
    68 #: runcache-purger.php:1100
     68#: runcache-purger.php:1110
    6969#, php-format
    7070msgid   "Purging method not implement. Status Code %s"
    7171msgstr  ""
    7272
    73 #: runcache-purger.php:1104
     73#: runcache-purger.php:1114
    7474msgid   "Failed to purge redis object cache."
    7575msgstr  ""
    7676
    77 #: runcache-purger.php:1106
     77#: runcache-purger.php:1116
    7878msgid   "Purging method not implement."
    7979msgstr  ""
    8080
    81 #: runcache-purger.php:1111
     81#: runcache-purger.php:1121
    8282#, php-format
    8383msgid   "Failed to purge cache. Status Code %s"
  • runcache-purger/trunk/runcache-purger-cli.php

    r2154386 r2154797  
    4848        WP_CLI::halt($ret);
    4949    }
     50
     51    public function reinstall($args, $assoc_args)
     52    {
     53        $ok = false;
     54        if ( !empty($args) && is_array($args) ) {
     55            $arg = $args[0];
     56            if ( 'options' === $arg ) {
     57                RunCache_Purger::reinstall_options();
     58                WP_CLI::success('Reinstall options success', false);
     59                $ok = true;
     60            } elseif ( 'dropin' === $arg ) {
     61                if ( RunCache_Purger::reinstall_dropin() ) {
     62                    WP_CLI::success('Reinstall dropin success', false);
     63                    $ok = true;
     64                } else {
     65                    WP_CLI::error('Failed to reinstall dropin', false);
     66                    WP_CLI::halt(1);
     67                }
     68            }
     69        }
     70
     71        if ( $ok ) {
     72            WP_CLI::halt(0);
     73        }
     74
     75        WP_CLI::error('Invalid parameter. Usage: reinstall [options, dropin]', false);
     76        WP_CLI::halt(1);
     77    }
    5078}
    5179
  • runcache-purger/trunk/runcache-purger.php

    r2154691 r2154797  
    55 * Plugin URI:      https://runcloud.io
    66 * Description:     This plugin will purge RunCloud.io NGINX fastcgi, Proxy Cache and Redis Object Cache.
    7  * Version:         1.0.6
     7 * Version:         1.0.7
    88 * Author:          RunCloud
    99 * Author URI:      https://profiles.wordpress.org/runcloud/
     
    6363
    6464    // version
    65     private static $version      = '1.0.6';
    66     private static $version_prev = '1.0.5';
     65    private static $version      = '1.0.7';
     66    private static $version_prev = '1.0.6';
    6767
    6868    // later
     
    326326            'redis_purge_onn'              => 1,
    327327            'redis_cache_onn'              => 1,
    328             'redis_prefix'                 => 'runcache-purger',
     328            'redis_prefix'                 => ( defined('WP_CACHE_KEY_SALT') ? md5(WP_CACHE_KEY_SALT) : md5('runcache-purger'.time()) ),
    329329            'redis_host'                   => '127.0.0.1',
    330330            'redis_port'                   => 6379,
     
    355355
    356356        $__varfunc_install = function () {
     357            $options = self::default_settings();
     358            $options['redis_prefix'] = wp_hash($options['redis_prefix'], 'secure_auth');
    357359            add_option(self::$dslug, self::default_settings());
    358360        };
     
    400402            $__varfunc_uninstall();
    401403        }
     404    }
     405
     406    /**
     407     * get_dropin_file.
     408     */
     409    private static function get_dropin_file() {
     410        return WP_CONTENT_DIR.'/object-cache.php';
    402411    }
    403412
     
    429438            $code .= "!defined('RUNCACHE_PURGER_DROPIN_PREFIX') && define('RUNCACHE_PURGER_DROPIN_PREFIX', '".addslashes($redis_prefix)."');".PHP_EOL;
    430439
    431             $buff = str_replace('/*@CONFIG-MARKER*/', $code, $buff);
    432 
    433             $filesave = WP_CONTENT_DIR.'/object-cache.php';
     440            $buff = str_replace('/*@CONFIG-MARKER@*/', trim($code), $buff);
     441            $buff .= '//@'.date( 'YmdHis' ).PHP_EOL;
     442
     443            $file_dropin = self::get_dropin_file();
    434444
    435445            $perm = self::get_fileperms('file');
    436             if (file_put_contents($filesave, $buff)) {
     446            if (file_put_contents($file_dropin, $buff)) {
    437447                @chmod($filesave, $perm);
    438448                return true;
     
    448458    private static function uninstall_dropin()
    449459    {
    450         $filesave = WP_CONTENT_DIR.'/object-cache.php';
    451         return unlink($filesave);
     460        $file_dropin = self::get_dropin_file();
     461        return unlink($file_dropin);
    452462    }
    453463
     
    457467    private static function try_install_dropin()
    458468    {
    459         if ( !defined('RUNCACHE_PURGER_DROPIN') ) {
     469        if ( !defined('RUNCACHE_PURGER_DROPIN') || !file_exists(self::get_dropin_file()) ) {
    460470            self::install_dropin();
    461471        }
     
    11931203            'is_avail' => ( $is_avail ? 1 : 0 )
    11941204        ];
    1195  
     1205
    11961206        if ( !$purge ) {
    11971207            self::$req_status = $return;
     
    16451655
    16461656    /**
     1657     * reinstall_options.
     1658     */
     1659    public static function reinstall_options() {
     1660        self::uninstall_options();
     1661        self::install_options();
     1662    }
     1663
     1664    /**
     1665     * reinstall_dropin.
     1666     */
     1667    public static function reinstall_dropin() {
     1668        self::uninstall_dropin();
     1669        return self::install_dropin();
     1670    }
     1671
     1672    /**
    16471673     * register_wpcli_hooks.
    16481674     */
Note: See TracChangeset for help on using the changeset viewer.