Plugin Directory

Changeset 1462053


Ignore:
Timestamp:
07/28/2016 08:56:53 AM (10 years ago)
Author:
baseapp
Message:

Cloudflare support and clean up

Location:
wpbase-cache/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wpbase-cache/trunk/wpbase-cache-admin.php

    r1372923 r1462053  
    5757
    5858    public function wpbase_cache_section_desc() {
    59         //echo 'These settings are part of wpoven manager plugin.';
    6059    }
    6160
  • wpbase-cache/trunk/wpbase-cache.php

    r1372923 r1462053  
    44  Plugin URI: https://github.com/baseapp/wpbase-cache
    55  Description: A wordpress plugin for using all caches on varnish, nginx, php-fpm stack with php-apc. This plugin includes db-cache-reloaded-fix for dbcache.
    6   Version: 5.0
     6  Version: 5.1
    77  Author: Vikrant Datta
    88  Author URI: http://blog.wpoven.com
     
    3232});
    3333
    34 //$path = dirname(dirname(dirname(__FILE__)));
    35 //if(is_file($path.'/db.php')){
    36 //   rename($path.'/db.php',$path.'/db_old.php');
    37 //}
    3834function upon_activation() {
    3935    $path = dirname(dirname(dirname(__FILE__)));
     
    4440
    4541function is_wpoven_site() {
    46    
     42
    4743    $file = ABSPATH . 'wp-config.php';
    4844    $content = file_get_contents($file);
     
    5147    $dbname = $match[1];
    5248    $sitename = substr($dbname, 2);
    53     $check_cache = get_option('wpbase_check_site',NULL);
    54    
     49    $check_cache = get_option('wpbase_check_site', NULL);
     50
    5551    if (!isset($check_cache)) {
    56         //echo "in";
    57         $ch = curl_init();
    58         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    59         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    60         curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    61         curl_setopt($ch, CURLOPT_URL, "https://wpoven.com/sites/check/wpbasecachecheck/" . $sitename);
    62         $content = curl_exec($ch);
    63         curl_close($ch);
    64        
    65         $content = (int)$content;
    66        
     52        $content = wp_remote_get("https://wpoven.com/sites/check/wpbasecachecheck/" . $sitename);
     53        $content = (int) $content;
    6754        update_option('wpbase_check_site', $content);
    6855    } else {
     
    7663    $check_site = is_wpoven_site();
    7764    if ($check_site == "1") {
     65
    7866        function custom_button_example($wp_admin_bar) {
    7967            $file = ABSPATH . 'wp-config.php';
     
    8674            $req_cache = json_decode($req_cache, true);
    8775            if (!get_option('wpbase_req_cache')) {
    88                 //echo "here";
    89                 $ch = curl_init();
    90                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    91                 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    92                 curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    93                 curl_setopt($ch, CURLOPT_URL, "https://wpoven.com/sites/checksiteinfo/" . $sitename);
    94                 $content = curl_exec($ch);
    95                 curl_close($ch);
    96                 //var_dump($content);
    97                 //$return_array = explode(",", $content);
     76                $content = wp_remote_get("https://wpoven.com/sites/checksiteinfo/" . $sitename);
    9877                $return_array = json_decode($content, true);
    9978                update_option('wpbase_req_cache', $content);
     
    10180                $return_array = $req_cache;
    10281            }
    103             //var_dump($return_array);
     82           
    10483            if ($return_array['status'] == "true") {
    10584                $args = array(
     
    124103            }
    125104        }
     105
    126106        add_action('admin_bar_menu', 'custom_button_example', 100);
    127107    }
     
    159139            'send_as' => 'noreply',
    160140            'admin_bar_button' => '1'
    161                 //'reject_url' => '',
    162                 //'reject_cookie' => '',
    163141        );
    164142
    165143        update_option('wpbase_cache_options', $options);
    166 
    167         // activate and enable db-cache-reloaded-fix
    168         // $this->activate_db_cache();
    169144    }
    170145
    171146    public function deactivate() {
    172         //$this->deactivate_db_cache();
     147
    173148        $options = array(
    174149            'db_cache' => '0',
     
    176151            'send_as' => '0',
    177152            'admin_bar_button' => ''
    178                 //'reject_url' => '',
    179                 //'reject_cookie' => '',
    180153        );
    181154
    182155        update_option('wpbase_cache_options', $options);
    183         //delete_option('wpbase_cache_options');
    184156    }
    185157
    186158    public function activate_db_cache() {
    187         /*    require_once(WPBASE_CACHE_INC_DIR.'/db-cache-reloaded-fix/db-cache-reloaded.php');
    188           $this->wp_db_cache_reloaded = new DBCacheReloaded();
    189           $options = array(
    190           'enabled' => true,
    191           'filter' => '_posts|_postmeta',
    192           'loadstat' => '',
    193           'wrapper' => false,
    194           'save' => 1
    195           );
    196           $this->wp_db_cache_reloaded->options_page($options); */
     159       
    197160    }
    198161
    199162    public function deactivate_db_cache() {
    200         /*  if($this->wp_db_cache_reloaded != null){
    201           $this->wp_db_cache_reloaded->dbcr_uninstall();
    202           } */
     163       
    203164    }
    204165
     
    208169        require_once(WPBASE_CACHE_INC_DIR . '/nginx-compatibility/nginx-compatibility.php');
    209170
    210         /*    if(isset($options['db_cache']) && $options['db_cache'] == '1'){
    211           require_once(WPBASE_CACHE_INC_DIR.'/db-cache-reloaded-fix/db-cache-reloaded.php');
    212           $this->wp_db_cache_reloaded = new DBCacheReloaded();
    213           } */
    214171
    215172        if (!isset($options['varnish_cache']) || $options['varnish_cache'] != '1') {
     
    245202    public function flush_all_cache() {
    246203        $url = get_site_url();
    247         $url = $url . '/';
     204        //  $url = $url . '/';
    248205        $this->flush_varnish_cache($url);
    249 
    250         /* if($this->wp_db_cache_reloaded != null){
    251           $this->wp_db_cache_reloaded->dbcr_clear();
    252           } */
    253     }
    254 
    255     public function flush_varnish_cache($url) {
     206    }
     207
     208        public function flush_varnish_cache($url) {
    256209        if (!(defined('WPBASE_CACHE_SANDBOX') && WPBASE_CACHE_SANDBOX)) {
    257             //echo $url;
    258             wp_remote_request($url, array('method' => 'PURGE'));
    259         }
     210            $urlParts = parse_url($url);
     211            $newURL = "http://127.0.0.1".$urlParts['path'];
     212            $response = wp_remote_request($newURL, array('method' => 'PURGE','headers'=>array('Host'=>$urlParts['host'])));
     213       }
    260214    }
    261215
     
    269223if (!isset($cache_options['varnish_cache']) || $cache_options['varnish_cache'] != '1') {
    270224    $site = site_url();
    271     //global $wpbase_cache;
     225
    272226    $wpbase_cache->flush_varnish_cache($site);
    273227}
     
    297251    $send_as = $options['send_as'];
    298252    if ($send_as != NULL) {
    299         // $sitename = strtolower($_SERVER['SERVER_NAME']);
    300         // $sitename = str_replace('www.','',$sitename);
    301253        global $wpdb;
    302254        $table_name = $wpdb->prefix . "options";
     
    311263            return $send_as . '@' . $domain;
    312264        }
    313 
    314         //$sitename = substr($sitename,0,4)=='www.' ? substr($sitename, 4) : $sitename;
    315265    }
    316266}
Note: See TracChangeset for help on using the changeset viewer.