Plugin Directory

Changeset 2308925


Ignore:
Timestamp:
05/20/2020 03:54:06 PM (6 years ago)
Author:
sdffamt
Message:

tagging version 1.3.8

Location:
wp-proxy
Files:
3 edited
6 copied

Legend:

Unmodified
Added
Removed
  • wp-proxy/tags/1.3.8/class-wp-proxy.php

    r2236894 r2308925  
    3737            $this->options = $options;
    3838            if ( $options['enable'] ) {
    39                 add_filter( 'pre_http_request', array( $this, 'pre_http_request' ), 100, 2 );
     39                add_filter( 'http_request_args', array( $this, 'http_request_args' ), 100, 2 );
    4040                add_filter( 'pre_http_send_through_proxy', array( $this, 'send_through_proxy' ), 10, 4 );
    4141                defined( 'WP_PROXY_HOST' ) ? '' : define( 'WP_PROXY_HOST', $options['proxy_host'] );
     
    4747                    defined( 'WP_PROXY_PASSWORD' ) ? '' : define( 'WP_PROXY_PASSWORD', $options['password'] );
    4848                }
     49                add_action( 'http_api_curl', array( $this, 'curl_before_send' ), 100, 3 );
    4950            }
    5051        } else {
     
    9798        $options['username']   = '';
    9899        $options['password']   = '';
     100        $options['type']       = '';
    99101        $options['enable']     = false;
    100102        return $options;
     
    129131                    $wp_proxy_options['password'] = sanitize_text_field( wp_unslash( $_POST['password'] ) );
    130132                }
     133                if ( isset( $_POST['type'] ) ) {
     134                    $wp_proxy_options['type'] = sanitize_text_field( wp_unslash( $_POST['type'] ) );
     135                }
    131136                if ( isset( $_POST['domains'] ) ) {
    132137                    $wp_proxy_options['domains'] = str_replace( ' ', "\n", sanitize_text_field( wp_unslash( $_POST['domains'] ) ) );
     
    166171     * In plugins page show some links
    167172     *
    168      * @param   array  $links links.
    169      * @param   string $file file.
     173     * @param array  $links
     174     * @param string $file
    170175     * @since 1.3.2
    171176     */
     
    180185     * In plugins page show some links
    181186     *
    182      * @param   array  $links links.
    183      * @param   string $file file.
     187     * @param array  $links
     188     * @param string $file
    184189     * @since 1.3.2
    185190     */
     
    198203     * Admin bar menu
    199204     *
    200      * @param   mixed $wp_admin_bar admin_bar.
     205     * @param mixed $wp_admin_bar
    201206     * @since 1.3.4
    202207     */
     
    237242     * Set request arg
    238243     *
    239      * @param   array  $parsed_args args.
    240      * @param   string $url url.
    241      */
    242     public function pre_http_request( $parsed_args, $url ) {
     244     * @param array  $parsed_args
     245     * @param string $url
     246     */
     247    public function http_request_args( $parsed_args, $url ) {
    243248        if ( $this->send_through_proxy( null, $url, $url, '' ) ) {
    244249            $parsed_args['timeout'] = $parsed_args['timeout'] + 1200;
     
    249254
    250255    /**
     256     * Set proxy type
     257     *
     258     * @param resource $handle
     259     * @param array    $request
     260     * @param string   $url
     261     * @since 1.3.8
     262     */
     263    public function curl_before_send( $handle, $request, $url ) {
     264        if ( $this->send_through_proxy( null, $url, $url, '' ) ) {
     265            if ( 'SOCKS5' === $this->options['type'] ) {
     266                curl_setopt( $handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5 );
     267            } elseif ( 'SOCKS4' === $this->options['type'] ) {
     268                curl_setopt( $handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4 );
     269            } elseif ( 'SOCKS4A' === $this->options['type'] ) {
     270                curl_setopt( $handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A );
     271            }
     272        }
     273    }
     274
     275    /**
    251276     * Check URL
    252277     *
    253      * @param   string $null null.
    254      * @param   string $url url.
    255      * @param   bool   $check check result.
    256      * @param   string $home site home.
     278     * @param string $null
     279     * @param string $url
     280     * @param bool   $check
     281     * @param string $home
    257282     * @since 1.0
    258283     */
     
    319344            __( 'Password' ),
    320345            array( $this, 'proxy_password_callback' ),
     346            'wp_proxy',
     347            'wp_proxy_config'
     348        );
     349        add_settings_field(
     350            'type',
     351            __( 'Type' ),
     352            array( $this, 'proxy_type_callback' ),
    321353            'wp_proxy',
    322354            'wp_proxy_config'
     
    407439
    408440    /**
     441     * Show proxy type field
     442     *
     443     * @since 1.3.8
     444     */
     445    public function proxy_type_callback() {
     446        ?>
     447            <select name="type" id="type" autocomplete="off">
     448                <option value="" <?php selected( $this->options['type'], '', true ); ?>>http</option>
     449                <option value="SOCKS5" <?php selected( $this->options['type'], 'SOCKS5', true ); ?>>socks5</option>
     450                <option value="SOCKS4" <?php selected( $this->options['type'], 'SOCKS4', true ); ?>>socks4</option>
     451                <option value="SOCKS4A" <?php selected( $this->options['type'], 'SOCKS4A', true ); ?>>socks4a</option>
     452            </select>
     453        <?php
     454    }
     455
     456    /**
    409457     * Show domains field
    410458     *
  • wp-proxy/tags/1.3.8/readme.txt

    r2236894 r2308925  
    33Donate link: https://xn--vkuk.org/blog/wp-proxy
    44Tags: proxy
    5 Requires at least: 3.0.1
    6 Tested up to: 5.3.2
    7 Stable tag: 1.3.6
    8 Requires PHP: 5.2.4
     5Requires at least: 5.0.0
     6Tested up to: 5.4.1
     7Stable tag: 1.3.8
     8Requires PHP: 5.0.0
    99License: GPLv2 or later
    1010
     
    3232== Changelog ==
    3333
     34= 1.3.8 =
     35support proxy type: http(default), socks5, socks4, socks4a. ps: if use curl as request transport.
     36
     37= 1.3.7 =
     38fix http_request_args. (我傻了)
     39
    3440= 1.3.6 =
    3541fix pre_http_request filter. thanks lcufrankw
  • wp-proxy/tags/1.3.8/wp-proxy.php

    r2236894 r2308925  
    44 * Plugin URI: https://xn--vkuk.org/blog/wp-proxy
    55 * Description: manage proxy for WordPress
    6  * Version: 1.3.6
     6 * Version: 1.3.8
    77 * Author: sleepm
    88 * Author URI: https://xn--vkuk.org/blog/
  • wp-proxy/trunk/class-wp-proxy.php

    r2236894 r2308925  
    3737            $this->options = $options;
    3838            if ( $options['enable'] ) {
    39                 add_filter( 'pre_http_request', array( $this, 'pre_http_request' ), 100, 2 );
     39                add_filter( 'http_request_args', array( $this, 'http_request_args' ), 100, 2 );
    4040                add_filter( 'pre_http_send_through_proxy', array( $this, 'send_through_proxy' ), 10, 4 );
    4141                defined( 'WP_PROXY_HOST' ) ? '' : define( 'WP_PROXY_HOST', $options['proxy_host'] );
     
    4747                    defined( 'WP_PROXY_PASSWORD' ) ? '' : define( 'WP_PROXY_PASSWORD', $options['password'] );
    4848                }
     49                add_action( 'http_api_curl', array( $this, 'curl_before_send' ), 100, 3 );
    4950            }
    5051        } else {
     
    9798        $options['username']   = '';
    9899        $options['password']   = '';
     100        $options['type']       = '';
    99101        $options['enable']     = false;
    100102        return $options;
     
    129131                    $wp_proxy_options['password'] = sanitize_text_field( wp_unslash( $_POST['password'] ) );
    130132                }
     133                if ( isset( $_POST['type'] ) ) {
     134                    $wp_proxy_options['type'] = sanitize_text_field( wp_unslash( $_POST['type'] ) );
     135                }
    131136                if ( isset( $_POST['domains'] ) ) {
    132137                    $wp_proxy_options['domains'] = str_replace( ' ', "\n", sanitize_text_field( wp_unslash( $_POST['domains'] ) ) );
     
    166171     * In plugins page show some links
    167172     *
    168      * @param   array  $links links.
    169      * @param   string $file file.
     173     * @param array  $links
     174     * @param string $file
    170175     * @since 1.3.2
    171176     */
     
    180185     * In plugins page show some links
    181186     *
    182      * @param   array  $links links.
    183      * @param   string $file file.
     187     * @param array  $links
     188     * @param string $file
    184189     * @since 1.3.2
    185190     */
     
    198203     * Admin bar menu
    199204     *
    200      * @param   mixed $wp_admin_bar admin_bar.
     205     * @param mixed $wp_admin_bar
    201206     * @since 1.3.4
    202207     */
     
    237242     * Set request arg
    238243     *
    239      * @param   array  $parsed_args args.
    240      * @param   string $url url.
    241      */
    242     public function pre_http_request( $parsed_args, $url ) {
     244     * @param array  $parsed_args
     245     * @param string $url
     246     */
     247    public function http_request_args( $parsed_args, $url ) {
    243248        if ( $this->send_through_proxy( null, $url, $url, '' ) ) {
    244249            $parsed_args['timeout'] = $parsed_args['timeout'] + 1200;
     
    249254
    250255    /**
     256     * Set proxy type
     257     *
     258     * @param resource $handle
     259     * @param array    $request
     260     * @param string   $url
     261     * @since 1.3.8
     262     */
     263    public function curl_before_send( $handle, $request, $url ) {
     264        if ( $this->send_through_proxy( null, $url, $url, '' ) ) {
     265            if ( 'SOCKS5' === $this->options['type'] ) {
     266                curl_setopt( $handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5 );
     267            } elseif ( 'SOCKS4' === $this->options['type'] ) {
     268                curl_setopt( $handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4 );
     269            } elseif ( 'SOCKS4A' === $this->options['type'] ) {
     270                curl_setopt( $handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A );
     271            }
     272        }
     273    }
     274
     275    /**
    251276     * Check URL
    252277     *
    253      * @param   string $null null.
    254      * @param   string $url url.
    255      * @param   bool   $check check result.
    256      * @param   string $home site home.
     278     * @param string $null
     279     * @param string $url
     280     * @param bool   $check
     281     * @param string $home
    257282     * @since 1.0
    258283     */
     
    319344            __( 'Password' ),
    320345            array( $this, 'proxy_password_callback' ),
     346            'wp_proxy',
     347            'wp_proxy_config'
     348        );
     349        add_settings_field(
     350            'type',
     351            __( 'Type' ),
     352            array( $this, 'proxy_type_callback' ),
    321353            'wp_proxy',
    322354            'wp_proxy_config'
     
    407439
    408440    /**
     441     * Show proxy type field
     442     *
     443     * @since 1.3.8
     444     */
     445    public function proxy_type_callback() {
     446        ?>
     447            <select name="type" id="type" autocomplete="off">
     448                <option value="" <?php selected( $this->options['type'], '', true ); ?>>http</option>
     449                <option value="SOCKS5" <?php selected( $this->options['type'], 'SOCKS5', true ); ?>>socks5</option>
     450                <option value="SOCKS4" <?php selected( $this->options['type'], 'SOCKS4', true ); ?>>socks4</option>
     451                <option value="SOCKS4A" <?php selected( $this->options['type'], 'SOCKS4A', true ); ?>>socks4a</option>
     452            </select>
     453        <?php
     454    }
     455
     456    /**
    409457     * Show domains field
    410458     *
  • wp-proxy/trunk/readme.txt

    r2236894 r2308925  
    33Donate link: https://xn--vkuk.org/blog/wp-proxy
    44Tags: proxy
    5 Requires at least: 3.0.1
    6 Tested up to: 5.3.2
    7 Stable tag: 1.3.6
    8 Requires PHP: 5.2.4
     5Requires at least: 5.0.0
     6Tested up to: 5.4.1
     7Stable tag: 1.3.8
     8Requires PHP: 5.0.0
    99License: GPLv2 or later
    1010
     
    3232== Changelog ==
    3333
     34= 1.3.8 =
     35support proxy type: http(default), socks5, socks4, socks4a. ps: if use curl as request transport.
     36
     37= 1.3.7 =
     38fix http_request_args. (我傻了)
     39
    3440= 1.3.6 =
    3541fix pre_http_request filter. thanks lcufrankw
  • wp-proxy/trunk/wp-proxy.php

    r2236894 r2308925  
    44 * Plugin URI: https://xn--vkuk.org/blog/wp-proxy
    55 * Description: manage proxy for WordPress
    6  * Version: 1.3.6
     6 * Version: 1.3.8
    77 * Author: sleepm
    88 * Author URI: https://xn--vkuk.org/blog/
Note: See TracChangeset for help on using the changeset viewer.