Changeset 1462053
- Timestamp:
- 07/28/2016 08:56:53 AM (10 years ago)
- Location:
- wpbase-cache/trunk
- Files:
-
- 2 edited
-
wpbase-cache-admin.php (modified) (1 diff)
-
wpbase-cache.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wpbase-cache/trunk/wpbase-cache-admin.php
r1372923 r1462053 57 57 58 58 public function wpbase_cache_section_desc() { 59 //echo 'These settings are part of wpoven manager plugin.';60 59 } 61 60 -
wpbase-cache/trunk/wpbase-cache.php
r1372923 r1462053 4 4 Plugin URI: https://github.com/baseapp/wpbase-cache 5 5 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. 06 Version: 5.1 7 7 Author: Vikrant Datta 8 8 Author URI: http://blog.wpoven.com … … 32 32 }); 33 33 34 //$path = dirname(dirname(dirname(__FILE__)));35 //if(is_file($path.'/db.php')){36 // rename($path.'/db.php',$path.'/db_old.php');37 //}38 34 function upon_activation() { 39 35 $path = dirname(dirname(dirname(__FILE__))); … … 44 40 45 41 function is_wpoven_site() { 46 42 47 43 $file = ABSPATH . 'wp-config.php'; 48 44 $content = file_get_contents($file); … … 51 47 $dbname = $match[1]; 52 48 $sitename = substr($dbname, 2); 53 $check_cache = get_option('wpbase_check_site', NULL);54 49 $check_cache = get_option('wpbase_check_site', NULL); 50 55 51 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; 67 54 update_option('wpbase_check_site', $content); 68 55 } else { … … 76 63 $check_site = is_wpoven_site(); 77 64 if ($check_site == "1") { 65 78 66 function custom_button_example($wp_admin_bar) { 79 67 $file = ABSPATH . 'wp-config.php'; … … 86 74 $req_cache = json_decode($req_cache, true); 87 75 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); 98 77 $return_array = json_decode($content, true); 99 78 update_option('wpbase_req_cache', $content); … … 101 80 $return_array = $req_cache; 102 81 } 103 //var_dump($return_array);82 104 83 if ($return_array['status'] == "true") { 105 84 $args = array( … … 124 103 } 125 104 } 105 126 106 add_action('admin_bar_menu', 'custom_button_example', 100); 127 107 } … … 159 139 'send_as' => 'noreply', 160 140 'admin_bar_button' => '1' 161 //'reject_url' => '',162 //'reject_cookie' => '',163 141 ); 164 142 165 143 update_option('wpbase_cache_options', $options); 166 167 // activate and enable db-cache-reloaded-fix168 // $this->activate_db_cache();169 144 } 170 145 171 146 public function deactivate() { 172 //$this->deactivate_db_cache(); 147 173 148 $options = array( 174 149 'db_cache' => '0', … … 176 151 'send_as' => '0', 177 152 'admin_bar_button' => '' 178 //'reject_url' => '',179 //'reject_cookie' => '',180 153 ); 181 154 182 155 update_option('wpbase_cache_options', $options); 183 //delete_option('wpbase_cache_options');184 156 } 185 157 186 158 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 197 160 } 198 161 199 162 public function deactivate_db_cache() { 200 /* if($this->wp_db_cache_reloaded != null){ 201 $this->wp_db_cache_reloaded->dbcr_uninstall(); 202 } */ 163 203 164 } 204 165 … … 208 169 require_once(WPBASE_CACHE_INC_DIR . '/nginx-compatibility/nginx-compatibility.php'); 209 170 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 } */214 171 215 172 if (!isset($options['varnish_cache']) || $options['varnish_cache'] != '1') { … … 245 202 public function flush_all_cache() { 246 203 $url = get_site_url(); 247 $url = $url . '/';204 // $url = $url . '/'; 248 205 $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) { 256 209 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 } 260 214 } 261 215 … … 269 223 if (!isset($cache_options['varnish_cache']) || $cache_options['varnish_cache'] != '1') { 270 224 $site = site_url(); 271 //global $wpbase_cache; 225 272 226 $wpbase_cache->flush_varnish_cache($site); 273 227 } … … 297 251 $send_as = $options['send_as']; 298 252 if ($send_as != NULL) { 299 // $sitename = strtolower($_SERVER['SERVER_NAME']);300 // $sitename = str_replace('www.','',$sitename);301 253 global $wpdb; 302 254 $table_name = $wpdb->prefix . "options"; … … 311 263 return $send_as . '@' . $domain; 312 264 } 313 314 //$sitename = substr($sitename,0,4)=='www.' ? substr($sitename, 4) : $sitename;315 265 } 316 266 }
Note: See TracChangeset
for help on using the changeset viewer.