PHP Cross Reference of WordPress Subversion HEAD |
| [ Index ] [ Classes ] [ Functions ] [ Variables ] [ Constants ] |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * A simple set of functions to check our version 1.0 update service 4 * 5 * @package WordPress 6 * @since 2.3 7 */ 8 9 /** 10 * wp_version_check() - Check WordPress version against the newest version. 11 * 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. 14 * 15 * @package WordPress 16 * @since 2.3 17 * @uses $wp_version Used to check against the newest WordPress version. 18 * 19 * @return mixed Returns null if update is unsupported. Returns false if check is too soon. 20 */ 21 function wp_version_check() { 22 if ( !function_exists('fsockopen') || strpos($_SERVER['PHP_SELF'], 'install.php') !== false || defined('WP_INSTALLING') ) 23 return; 24 25 global $wp_version; 26 $php_version = phpversion(); 27 28 $current = get_option( 'update_core' ); 29 $locale = get_locale(); 30 31 if ( 32 isset( $current->last_checked ) && 33 43200 > ( time() - $current->last_checked ) && 34 $current->version_checked == $wp_version 35 ) 36 return false; 37 38 $new_option = ''; 39 $new_option->last_checked = time(); // this gets set whether we get a response or not, so if something is down or misconfigured it won't delay the page load for more than 3 seconds, twice a day 40 $new_option->version_checked = $wp_version; 41 42 $http_request = "GET /core/version-check/1.0/?version=$wp_version&php=$php_version&locale=$locale HTTP/1.0\r\n"; 43 $http_request .= "Host: api.wordpress.org\r\n"; 44 $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n"; 45 $http_request .= 'User-Agent: WordPress/' . $wp_version . '; ' . get_bloginfo('url') . "\r\n"; 46 $http_request .= "\r\n"; 47 48 $response = ''; 49 if ( false !== ( $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3 ) ) && is_resource($fs) ) { 50 fwrite( $fs, $http_request ); 51 while ( !feof( $fs ) ) 52 $response .= fgets( $fs, 1160 ); // One TCP-IP packet 53 fclose( $fs ); 54 55 $response = explode("\r\n\r\n", $response, 2); 56 $body = trim( $response[1] ); 57 $body = str_replace(array("\r\n", "\r"), "\n", $body); 58 59 $returns = explode("\n", $body); 60 61 $new_option->response = $returns[0]; 62 if ( isset( $returns[1] ) ) 63 $new_option->url = $returns[1]; 64 } 65 update_option( 'update_core', $new_option ); 66 } 67 68 add_action( 'init', 'wp_version_check' ); 69 70 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated Thu Dec 6 06:47:08 2007 for RedAlt XRefs | Cross-referenced by PHPXref 0.6 and RedAlt |