Changeset 2222202
- Timestamp:
- 01/05/2020 04:42:14 AM (6 years ago)
- Location:
- wp-proxy/trunk
- Files:
-
- 3 edited
-
class-wp-proxy.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
-
wp-proxy.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-proxy/trunk/class-wp-proxy.php
r2219135 r2222202 37 37 $this->options = $options; 38 38 if ( $options['enable'] ) { 39 add_filter( 'pre_http_request', array( $this, 'pre_http_request' ), 10, 3 ); 39 40 add_filter( 'pre_http_send_through_proxy', array( $this, 'send_through_proxy' ), 10, 4 ); 40 41 defined( 'WP_PROXY_HOST' ) ? '' : define( 'WP_PROXY_HOST', $options['proxy_host'] ); … … 50 51 add_option( 'wp_proxy_options', $this->defualt_options() ); 51 52 } 52 add_action( 'admin_menu', array( $this, 'options_page' ) ); 53 add_action( 'admin_init', array( $this, 'register_settings' ) ); 54 add_action( 'admin_init', array( $this, 'wp_proxy_enable_or_disable' ) ); 55 add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 1000 ); 56 add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 ); 53 if ( is_admin() ) { 54 add_action( 'admin_menu', array( $this, 'options_page' ) ); 55 add_action( 'admin_init', array( $this, 'register_settings' ) ); 56 add_action( 'admin_init', array( $this, 'wp_proxy_enable_or_disable' ) ); 57 add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 1000 ); 58 add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 ); 59 } 57 60 add_filter( 'plugin_row_meta', array( $this, 'plugin_details_links' ), 10, 2 ); 58 61 } … … 232 235 233 236 /** 237 * Set request arg 238 * 239 * @param bool $false is pre. 240 * @param array $parsed_args args. 241 * @param string $url url. 242 */ 243 public function pre_http_request( $false, $parsed_args, $url ) { 244 if ( $this->send_through_proxy( null, $url, $url, '' ) ) { 245 $parsed_args['timeout'] = $parsed_args['timeout'] + 1200; 246 @set_time_limit( $parsed_args['timeout'] + 60 ); 247 } 248 return $parsed_args; 249 } 250 251 /** 234 252 * Check URL 235 253 * … … 241 259 */ 242 260 public function send_through_proxy( $null, $url, $check, $home ) { 243 $rules = explode( '\n', $this->options['domains'] );261 $rules = explode( "\n", $this->options['domains'] ); 244 262 $host = false; 245 263 if ( ! is_array( $check ) ) { … … 249 267 $host = $check['host']; 250 268 } 269 $regex = array(); 251 270 foreach ( $rules as $rule ) { 252 $rule = str_replace( '*.', '(.*)\.', $rule );253 271 if ( $rule === $host ) { 254 272 return true; 255 } elseif ( preg_match( '#' . $rule . '#i', $host ) ) { 256 return true; 257 } 273 } else { 274 $regex[] = str_replace( '\*', '.+', preg_quote( $rule, '/' ) ); 275 } 276 } 277 if ( ! empty( $regex ) ) { 278 $regex = '^(' . implode( '|', $regex ) . ')$'; 279 return preg_match( '#' . $regex . '#i', $host ); 258 280 } 259 281 return false; -
wp-proxy/trunk/readme.txt
r2219135 r2222202 1 # W ordPress 代理访问1 # WP Proxy 2 2 Contributors: sdffamt 3 3 Donate link: https://xn--vkuk.org/blog/wp-proxy … … 5 5 Requires at least: 3.0.1 6 6 Tested up to: 5.3.2 7 Stable tag: 1.3. 47 Stable tag: 1.3.5 8 8 Requires PHP: 5.2.4 9 9 License: GPLv2 or later -
wp-proxy/trunk/wp-proxy.php
r2219135 r2222202 4 4 * Plugin URI: https://xn--vkuk.org/blog/wp-proxy 5 5 * Description: manage proxy for WordPress 6 * Version: 1.3. 46 * Version: 1.3.5 7 7 * Author: sleepm 8 * Author URI: https://xn--vkuk.org/blog/ 8 9 * Text Domain: wp-proxy 9 10 * Domain Path: /languages
Note: See TracChangeset
for help on using the changeset viewer.