Changeset 8630 for trunk/wp-includes/update.php
- Timestamp:
- 08/12/2008 09:21:11 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/update.php
r8595 r8630 1 1 <?php 2 2 /** 3 * A simple set of functions to check our version 1.0 update service 3 * A simple set of functions to check our version 1.0 update service. 4 4 * 5 5 * @package WordPress … … 8 8 9 9 /** 10 * Check WordPress version against the newest version. * 10 * Check WordPress version against the newest version. 11 * 11 12 * The WordPress version, PHP version, and Locale is sent. Checks against the 12 13 * WordPress server at api.wordpress.org server. Will only check if WordPress 13 14 * isn't installing. 14 15 15 * 16 16 * @package WordPress … … 42 42 43 43 $url = "http://api.wordpress.org/core/version-check/1.2/?version=$wp_version&php=$php_version&locale=$locale"; 44 44 45 $options = array('timeout' => 3); 45 46 $headers = array( 46 $options['headers'] = array( 47 47 'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'), 48 48 'User-Agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url') 49 49 ); 50 50 51 $response = wp_remote_request($url, $options, $headers); 51 $response = wp_remote_request($url, $options); 52 53 if ( is_wp_error( $response ) ) 54 return false; 52 55 53 56 if ( 200 != $response['response']['code'] ) 54 57 return false; 55 58 56 $body = $response['body']; 57 $body = trim( $body ); 59 $body = trim( $response['body'] ); 58 60 $body = str_replace(array("\r\n", "\r"), "\n", $body); 59 61 $returns = explode("\n", $body); … … 74 76 75 77 /** 76 * wp_update_plugins() -Check plugin versions against the latest versions hosted on WordPress.org.78 * Check plugin versions against the latest versions hosted on WordPress.org. 77 79 * 78 * The WordPress version, PHP version, and Locale is sent along with a list of all plugins installed. 79 * Checks against the WordPress server at api.wordpress.org. 80 * Will only check if PHP has fsockopen enabled and WordPress isn't installing. 80 * The WordPress version, PHP version, and Locale is sent along with a list of 81 * all plugins installed. Checks against the WordPress server at 82 * api.wordpress.org. Will only check if PHP has fsockopen enabled and WordPress 83 * isn't installing. 81 84 * 82 85 * @package WordPress … … 89 92 global $wp_version; 90 93 91 if ( !function_exists('fsockopen') ||defined('WP_INSTALLING') )94 if ( defined('WP_INSTALLING') ) 92 95 return false; 93 96 … … 117 120 } 118 121 119 foreach ( (array) $current->response as $plugin_file => $update_details ) { 120 if ( ! isset($plugins[ $plugin_file ]) ) { 121 $plugin_changed = true; 122 if ( isset ( $current->response ) && is_array( $current->response ) ) { 123 foreach ( $current->response as $plugin_file => $update_details ) { 124 if ( ! isset($plugins[ $plugin_file ]) ) { 125 $plugin_changed = true; 126 } 122 127 } 123 128 } … … 130 135 $to_send->active = $active; 131 136 $send = serialize( $to_send ); 137 $body = 'plugins=' . urlencode( $send ); 132 138 133 $request = 'plugins=' . urlencode( $send ); 134 $http_request = "POST /plugins/update-check/1.0/ HTTP/1.0\r\n"; 135 $http_request .= "Host: api.wordpress.org\r\n"; 136 $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option('blog_charset') . "\r\n"; 137 $http_request .= "Content-Length: " . strlen($request) . "\r\n"; 138 $http_request .= 'User-Agent: WordPress/' . $wp_version . '; ' . get_bloginfo('url') . "\r\n"; 139 $http_request .= "\r\n"; 140 $http_request .= $request; 139 $options = array('method' => 'POST', 'timeout' => 3, 'body' => $body); 140 $options['headers'] = array( 141 'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'), 142 'Content-Length' => strlen($body), 143 'User-Agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url') 144 ); 141 145 142 $response = ''; 143 if( false != ( $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3) ) && is_resource($fs) ) { 144 fwrite($fs, $http_request); 146 $raw_response = wp_remote_request('http://api.wordpress.org/plugins/update-check/1.0/', $options); 145 147 146 while ( !feof($fs) ) 147 $response .= fgets($fs, 1160); // One TCP-IP packet 148 fclose($fs); 149 $response = explode("\r\n\r\n", $response, 2); 148 if( 200 != $raw_response['response']['code'] ) { 149 return false; 150 150 } 151 151 152 $response = unserialize( $r esponse[1] );152 $response = unserialize( $raw_response['body'] ); 153 153 154 154 if ( $response )
Note: See TracChangeset
for help on using the changeset viewer.