-
+ 203C4BA760E8B8010E6C64B1851744F5ACC768A1673D4CFB0584ACA332F2D0E9054004EB69A9253EB49241F8669570FBDF7706BE630C2E6FA3BF7FF0268DCDC4
mp-wp/wp-includes/update.php
(0 . 0)(1 . 308)
155052 <?php
155053 /**
155054 * A simple set of functions to check our version 1.0 update service.
155055 *
155056 * @package WordPress
155057 * @since 2.3.0
155058 */
155059
155060 /**
155061 * Check WordPress version against the newest version.
155062 *
155063 * The WordPress version, PHP version, and Locale is sent. Checks against the
155064 * WordPress server at polimedia.us/muiewp server. Will only check if WordPress
155065 * isn't installing.
155066 *
155067 * @package WordPress
155068 * @since 2.3.0
155069 * @uses $wp_version Used to check against the newest WordPress version.
155070 *
155071 * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
155072 */
155073 function wp_version_check() {
155074 if ( defined('WP_INSTALLING') )
155075 return;
155076
155077 global $wp_version, $wpdb, $wp_local_package;
155078 $php_version = phpversion();
155079
155080 $current = get_option( 'update_core' );
155081 if ( ! is_object($current) )
155082 $current = new stdClass;
155083
155084 $locale = get_locale();
155085 if (
155086 isset( $current->last_checked ) &&
155087 43200 > ( time() - $current->last_checked ) &&
155088 $current->version_checked == $wp_version
155089 )
155090 return false;
155091
155092 // Update last_checked for current to prevent multiple blocking requests if request hangs
155093 $current->last_checked = time();
155094 update_option( 'update_core', $current );
155095
155096 if ( method_exists( $wpdb, 'db_version' ) )
155097 $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version($wpdb->users));
155098 else
155099 $mysql_version = 'N/A';
155100 $local_package = isset( $wp_local_package )? $wp_local_package : '';
155101 $url = "http://polimedia.us/muiewp/core/version-check/1.3/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package";
155102
155103 $options = array('timeout' => 3);
155104 $options['headers'] = array(
155105 'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'),
155106 'User-Agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url')
155107 );
155108
155109 $response = wp_remote_request($url, $options);
155110
155111 if ( is_wp_error( $response ) )
155112 return false;
155113
155114 if ( 200 != $response['response']['code'] )
155115 return false;
155116
155117 $body = trim( $response['body'] );
155118 $body = str_replace(array("\r\n", "\r"), "\n", $body);
155119 $new_options = array();
155120 foreach( explode( "\n\n", $body ) as $entry) {
155121 $returns = explode("\n", $entry);
155122 $new_option = new stdClass();
155123 $new_option->response = attribute_escape( $returns[0] );
155124 if ( isset( $returns[1] ) )
155125 $new_option->url = clean_url( $returns[1] );
155126 if ( isset( $returns[2] ) )
155127 $new_option->package = clean_url( $returns[2] );
155128 if ( isset( $returns[3] ) )
155129 $new_option->current = attribute_escape( $returns[3] );
155130 if ( isset( $returns[4] ) )
155131 $new_option->locale = attribute_escape( $returns[4] );
155132 $new_options[] = $new_option;
155133 }
155134
155135 $updates = new stdClass();
155136 $updates->updates = $new_options;
155137 $updates->last_checked = time();
155138 $updates->version_checked = $wp_version;
155139 update_option( 'update_core', $updates);
155140 }
155141 add_action( 'init', 'wp_version_check' );
155142
155143 /**
155144 * Check plugin versions against the latest versions hosted on WordPress.org.
155145 *
155146 * The WordPress version, PHP version, and Locale is sent along with a list of
155147 * all plugins installed. Checks against the WordPress server at
155148 * polimedia.us/muiewp. Will only check if WordPress isn't installing.
155149 *
155150 * @package WordPress
155151 * @since 2.3.0
155152 * @uses $wp_version Used to notidy the WordPress version.
155153 *
155154 * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
155155 */
155156 function wp_update_plugins() {
155157 global $wp_version;
155158
155159 if ( defined('WP_INSTALLING') )
155160 return false;
155161
155162 // If running blog-side, bail unless we've not checked in the last 12 hours
155163 if ( !function_exists( 'get_plugins' ) )
155164 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
155165
155166 $plugins = get_plugins();
155167 $active = get_option( 'active_plugins' );
155168 $current = get_option( 'update_plugins' );
155169 if ( ! is_object($current) )
155170 $current = new stdClass;
155171
155172 $new_option = '';
155173 $new_option->last_checked = time();
155174 $time_not_changed = isset( $current->last_checked ) && 43200 > ( time() - $current->last_checked );
155175
155176 $plugin_changed = false;
155177 foreach ( $plugins as $file => $p ) {
155178 $new_option->checked[ $file ] = $p['Version'];
155179
155180 if ( !isset( $current->checked[ $file ] ) ) {
155181 $plugin_changed = true;
155182 continue;
155183 }
155184
155185 if ( strval($current->checked[ $file ]) !== strval($p['Version']) )
155186 $plugin_changed = true;
155187 }
155188
155189 if ( isset ( $current->response ) && is_array( $current->response ) ) {
155190 foreach ( $current->response as $plugin_file => $update_details ) {
155191 if ( ! isset($plugins[ $plugin_file ]) ) {
155192 $plugin_changed = true;
155193 }
155194 }
155195 }
155196
155197 // Bail if we've checked in the last 12 hours and if nothing has changed
155198 if ( $time_not_changed && !$plugin_changed )
155199 return false;
155200
155201 // Update last_checked for current to prevent multiple blocking requests if request hangs
155202 $current->last_checked = time();
155203 update_option( 'update_plugins', $current );
155204
155205 $to_send->plugins = $plugins;
155206 $to_send->active = $active;
155207 $send = serialize( $to_send );
155208 $body = 'plugins=' . urlencode( $send );
155209
155210 $options = array('method' => 'POST', 'timeout' => 3, 'body' => $body);
155211 $options['headers'] = array(
155212 'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'),
155213 'Content-Length' => strlen($body),
155214 'User-Agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url')
155215 );
155216
155217 $raw_response = wp_remote_request('http://polimedia.us/muiewp/plugins/update-check/1.0/', $options);
155218
155219 if ( is_wp_error( $raw_response ) )
155220 return false;
155221
155222 if( 200 != $raw_response['response']['code'] ) {
155223 return false;
155224 }
155225
155226 $response = unserialize( $raw_response['body'] );
155227
155228 if ( false !== $response )
155229 $new_option->response = $response;
155230 else
155231 $new_option->response = array();
155232
155233 update_option( 'update_plugins', $new_option );
155234 }
155235
155236 /**
155237 * Check theme versions against the latest versions hosted on WordPress.org.
155238 *
155239 * A list of all themes installed in sent to WP. Checks against the
155240 * WordPress server at polimedia.us/muiewp. Will only check if WordPress isn't
155241 * installing.
155242 *
155243 * @package WordPress
155244 * @since 2.7.0
155245 * @uses $wp_version Used to notidy the WordPress version.
155246 *
155247 * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
155248 */
155249 function wp_update_themes( ) {
155250 global $wp_version;
155251
155252 if( defined( 'WP_INSTALLING' ) )
155253 return false;
155254
155255 if( !function_exists( 'get_themes' ) )
155256 require_once( ABSPATH . 'wp-includes/theme.php' );
155257
155258 $installed_themes = get_themes( );
155259 $current_theme = get_option( 'update_themes' );
155260 if ( ! is_object($current_theme) )
155261 $current_theme = new stdClass;
155262
155263 $new_option = '';
155264 $new_option->last_checked = time( );
155265 $time_not_changed = isset( $current_theme->last_checked ) && 43200 > ( time( ) - $current_theme->last_checked );
155266
155267 if( $time_not_changed )
155268 return false;
155269
155270 // Update last_checked for current to prevent multiple blocking requests if request hangs
155271 $current_theme->last_checked = time();
155272 update_option( 'update_themes', $current_theme );
155273
155274 $themes = array( );
155275 $themes['current_theme'] = $current_theme;
155276 foreach( (array) $installed_themes as $theme_title => $theme ) {
155277 $themes[$theme['Template']] = array( );
155278
155279 foreach( (array) $theme as $key => $value ) {
155280 $themes[$theme['Template']][$key] = $value;
155281 }
155282 }
155283
155284 $options = array(
155285 'method' => 'POST',
155286 'timeout' => 3,
155287 'body' => 'themes=' . urlencode( serialize( $themes ) )
155288 );
155289 $options['headers'] = array(
155290 'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' ),
155291 'Content-Length' => strlen( $options['body'] ),
155292 'User-Agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
155293 );
155294
155295 $raw_response = wp_remote_request( 'http://polimedia.us/muiewp/themes/update-check/1.0/', $options );
155296
155297 if( is_wp_error( $raw_response ) )
155298 return false;
155299
155300 if( 200 != $raw_response['response']['code'] )
155301 return false;
155302
155303 $response = unserialize( $raw_response['body'] );
155304 if( $response )
155305 $new_option->response = $response;
155306
155307 update_option( 'update_themes', $new_option );
155308 }
155309
155310 /**
155311 * Check the last time plugins were run before checking plugin versions.
155312 *
155313 * This might have been backported to WordPress 2.6.1 for performance reasons.
155314 * This is used for the wp-admin to check only so often instead of every page
155315 * load.
155316 *
155317 * @since 2.7.0
155318 * @access private
155319 */
155320 function _maybe_update_plugins() {
155321 $current = get_option( 'update_plugins' );
155322 if ( isset( $current->last_checked ) && 43200 > ( time() - $current->last_checked ) )
155323 return;
155324 wp_update_plugins();
155325 }
155326
155327 /**
155328 * Check themes versions only after a duration of time.
155329 *
155330 * This is for performance reasons to make sure that on the theme version
155331 * checker is not run on every page load.
155332 *
155333 * @since 2.7.0
155334 * @access private
155335 */
155336 function _maybe_update_themes( ) {
155337 $current = get_option( 'update_themes' );
155338 if( isset( $current->last_checked ) && 43200 > ( time( ) - $current->last_checked ) )
155339 return;
155340
155341 wp_update_themes( );
155342 }
155343
155344 add_action( 'load-plugins.php', 'wp_update_plugins' );
155345 add_action( 'load-update.php', 'wp_update_plugins' );
155346 add_action( 'admin_init', '_maybe_update_plugins' );
155347 add_action( 'wp_update_plugins', 'wp_update_plugins' );
155348
155349 add_action( 'admin_init', '_maybe_update_themes' );
155350 add_action( 'wp_update_themes', 'wp_update_themes' );
155351
155352 if ( !wp_next_scheduled('wp_update_plugins') && !defined('WP_INSTALLING') )
155353 wp_schedule_event(time(), 'twicedaily', 'wp_update_plugins');
155354
155355
155356 if ( !wp_next_scheduled('wp_update_themes') && !defined('WP_INSTALLING') )
155357 wp_schedule_event(time(), 'twicedaily', 'wp_update_themes');
155358
155359 ?>