Ticket #7265: 7265.3.diff
File 7265.3.diff, 5.9 KB (added by , 16 years ago) |
---|
-
wp-admin/includes/update.php
53 53 echo "<span id='wp-version-message'>$msg</span>"; 54 54 } 55 55 56 function wp_update_plugins() {57 global $wp_version;58 59 if ( !function_exists('fsockopen') )60 return false;61 62 $plugins = get_plugins();63 $active = get_option( 'active_plugins' );64 $current = get_option( 'update_plugins' );65 66 $new_option = '';67 $new_option->last_checked = time();68 69 $plugin_changed = false;70 foreach ( $plugins as $file => $p ) {71 $new_option->checked[ $file ] = $p['Version'];72 73 if ( !isset( $current->checked[ $file ] ) ) {74 $plugin_changed = true;75 continue;76 }77 78 if ( strval($current->checked[ $file ]) !== strval($p['Version']) )79 $plugin_changed = true;80 }81 82 if (83 isset( $current->last_checked ) &&84 43200 > ( time() - $current->last_checked ) &&85 !$plugin_changed86 )87 return false;88 89 $to_send->plugins = $plugins;90 $to_send->active = $active;91 $send = serialize( $to_send );92 93 $request = 'plugins=' . urlencode( $send );94 $http_request = "POST /plugins/update-check/1.0/ HTTP/1.0\r\n";95 $http_request .= "Host: api.wordpress.org\r\n";96 $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option('blog_charset') . "\r\n";97 $http_request .= "Content-Length: " . strlen($request) . "\r\n";98 $http_request .= 'User-Agent: WordPress/' . $wp_version . '; ' . get_bloginfo('url') . "\r\n";99 $http_request .= "\r\n";100 $http_request .= $request;101 102 $response = '';103 if( false != ( $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3) ) && is_resource($fs) ) {104 fwrite($fs, $http_request);105 106 while ( !feof($fs) )107 $response .= fgets($fs, 1160); // One TCP-IP packet108 fclose($fs);109 $response = explode("\r\n\r\n", $response, 2);110 }111 112 $response = unserialize( $response[1] );113 114 if ( $response )115 $new_option->response = $response;116 117 update_option( 'update_plugins', $new_option );118 }119 add_action( 'init', 'wp_update_plugins' );120 121 56 function wp_plugin_update_row( $file, $plugin_data ) { 122 57 $current = get_option( 'update_plugins' ); 123 58 if ( !isset( $current->response[ $file ] ) ) -
wp-includes/update.php
10 10 * wp_version_check() - Check WordPress version against the newest version. 11 11 * 12 12 * The WordPress version, PHP version, and Locale is sent. Checks against the WordPress server at 13 * api.wordpress.org server. Will only check if PHP has fsockopen enabled and WordPress isn't installing.13 * api.wordpress.org. Will only check if PHP has fsockopen enabled and WordPress isn't installing. 14 14 * 15 15 * @package WordPress 16 16 * @since 2.3 … … 19 19 * @return mixed Returns null if update is unsupported. Returns false if check is too soon. 20 20 */ 21 21 function wp_version_check() { 22 if ( !function_exists('fsockopen') || strpos($_SERVER['PHP_SELF'], 'install.php') !== false ||defined('WP_INSTALLING') )22 if ( !function_exists('fsockopen') || defined('WP_INSTALLING') ) 23 23 return; 24 24 25 25 global $wp_version; … … 69 69 } 70 70 update_option( 'update_core', $new_option ); 71 71 } 72 73 72 add_action( 'init', 'wp_version_check' ); 74 73 74 /** 75 * wp_update_plugins() - Check plugin versions against the latest versions hosted on WordPress.org. 76 * 77 * The WordPress version, PHP version, and Locale is sent along with a list of all plugins installed. 78 * Checks against the WordPress server at api.wordpress.org. 79 * Will only check if PHP has fsockopen enabled and WordPress isn't installing. 80 * 81 * @package WordPress 82 * @since 2.3 83 * @uses $wp_version Used to notidy the WordPress version. 84 * 85 * @return mixed Returns null if update is unsupported. Returns false if check is too soon. 86 */ 87 function wp_update_plugins() { 88 global $wp_version; 89 90 if ( !function_exists('fsockopen') || defined('WP_INSTALLING') ) 91 return false; 92 93 $plugins = get_plugins(); 94 $active = get_option( 'active_plugins' ); 95 $current = get_option( 'update_plugins' ); 96 97 $new_option = ''; 98 $new_option->last_checked = time(); 99 100 $plugin_changed = false; 101 foreach ( $plugins as $file => $p ) { 102 $new_option->checked[ $file ] = $p['Version']; 103 104 if ( !isset( $current->checked[ $file ] ) ) { 105 $plugin_changed = true; 106 continue; 107 } 108 109 if ( strval($current->checked[ $file ]) !== strval($p['Version']) ) 110 $plugin_changed = true; 111 } 112 113 if ( 114 isset( $current->last_checked ) && 115 43200 > ( time() - $current->last_checked ) && 116 !$plugin_changed 117 ) 118 return false; 119 120 $to_send->plugins = $plugins; 121 $to_send->active = $active; 122 $send = serialize( $to_send ); 123 124 $request = 'plugins=' . urlencode( $send ); 125 $http_request = "POST /plugins/update-check/1.0/ HTTP/1.0\r\n"; 126 $http_request .= "Host: api.wordpress.org\r\n"; 127 $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option('blog_charset') . "\r\n"; 128 $http_request .= "Content-Length: " . strlen($request) . "\r\n"; 129 $http_request .= 'User-Agent: WordPress/' . $wp_version . '; ' . get_bloginfo('url') . "\r\n"; 130 $http_request .= "\r\n"; 131 $http_request .= $request; 132 133 $response = ''; 134 if( false != ( $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3) ) && is_resource($fs) ) { 135 fwrite($fs, $http_request); 136 137 while ( !feof($fs) ) 138 $response .= fgets($fs, 1160); // One TCP-IP packet 139 fclose($fs); 140 $response = explode("\r\n\r\n", $response, 2); 141 } 142 143 $response = unserialize( $response[1] ); 144 145 if ( $response ) 146 $new_option->response = $response; 147 148 update_option( 'update_plugins', $new_option ); 149 } 150 add_action( 'init', 'wp_update_plugins' ); 151 75 152 ?> 153 No newline at end of file