diff options
Diffstat (limited to 'plugins/jetpack/modules/protect.php')
-rw-r--r-- | plugins/jetpack/modules/protect.php | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/plugins/jetpack/modules/protect.php b/plugins/jetpack/modules/protect.php index 09b0c81c..bcbaf94c 100644 --- a/plugins/jetpack/modules/protect.php +++ b/plugins/jetpack/modules/protect.php @@ -6,6 +6,7 @@ * Recommendation Order: 4 * First Introduced: 3.4 * Requires Connection: Yes + * Requires User Connection: Yes * Auto Activate: Yes * Module Tags: Recommended * Feature: Security @@ -13,7 +14,6 @@ */ use Automattic\Jetpack\Constants; -use Automattic\Jetpack\Connection\Utils as Connection_Utils; include_once JETPACK__PLUGIN_DIR . 'modules/protect/shared-functions.php'; @@ -25,9 +25,7 @@ class Jetpack_Protect_Module { public $whitelist; public $whitelist_error; public $whitelist_saved; - private $user_ip; private $local_host; - private $api_endpoint; public $last_request; public $last_response_raw; public $last_response; @@ -249,9 +247,7 @@ class Jetpack_Protect_Module { } // Request the key - $xml = new Jetpack_IXR_Client( array ( - 'user_id' => get_current_user_id() - ) ); + $xml = new Jetpack_IXR_Client(); $xml->query( 'jetpack.protect.requestKey', $request ); // Hmm, can't talk to wordpress.com @@ -383,9 +379,10 @@ class Jetpack_Protect_Module { /** * Get all IP headers so that we can process on our server... * - * @return string + * @return array */ function get_headers() { + $output = array(); $ip_related_headers = array ( 'GD_PHP_HANDLER', 'HTTP_AKAMAI_ORIGIN_HOP', @@ -407,7 +404,7 @@ class Jetpack_Protect_Module { ); foreach ( $ip_related_headers as $header ) { - if ( isset( $_SERVER[ $header ] ) ) { + if ( ! empty( $_SERVER[ $header ] ) ) { $output[ $header ] = $_SERVER[ $header ]; } } @@ -725,7 +722,7 @@ class Jetpack_Protect_Module { $request['host'] = $this->get_local_host(); $request['headers'] = json_encode( $this->get_headers() ); $request['jetpack_version'] = constant( 'JETPACK__VERSION' ); - $request['wordpress_version'] = strval( $wp_version ); + $request['wordpress_version'] = (string) $wp_version ; $request['api_key'] = $api_key; $request['multisite'] = "0"; @@ -752,7 +749,7 @@ class Jetpack_Protect_Module { 'timeout' => absint( $timeout ) ); - $response_json = wp_remote_post( $this->get_api_host(), $args ); + $response_json = wp_remote_post( JETPACK_PROTECT__API_HOST, $args ); $this->last_response_raw = $response_json; $transient_name = $this->get_transient_name(); @@ -860,17 +857,6 @@ class Jetpack_Protect_Module { return get_transient( $transient ); } - function get_api_host() { - if ( isset( $this->api_endpoint ) ) { - return $this->api_endpoint; - } - - //Check to see if we can use SSL - $this->api_endpoint = Connection_Utils::fix_url_for_bad_hosts( JETPACK_PROTECT__API_HOST ); - - return $this->api_endpoint; - } - function get_local_host() { if ( isset( $this->local_host ) ) { return $this->local_host; @@ -903,6 +889,6 @@ class Jetpack_Protect_Module { $jetpack_protect = Jetpack_Protect_Module::instance(); global $pagenow; -if ( isset( $pagenow ) && 'wp-login.php' == $pagenow ) { +if ( isset( $pagenow ) && 'wp-login.php' === $pagenow ) { $jetpack_protect->check_login_ability(); } |