- Timestamp:
- Apr 20, 2011, 1:21:20 PM (14 years ago)
- Location:
- trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/xpress_upgrade.php
r499 r698 1 1 <?php 2 function upgrade_page() 3 { 2 function find_xpress_update( $version, $locale ){ 3 $latest_version = get_option('xpressme_latest_version'); 4 return (object)$latest_version; 5 } 6 7 8 function list_xpress_update( $update=null ) { 4 9 global $xoops_config,$xpress_config; 5 10 6 11 $xpress_version = $xoops_config->module_version . $xoops_config->module_codename; 12 $xpress_version = '2.38'; 7 13 $lang = WPLANG; 8 14 … … 12 18 echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n"; 13 19 echo '<h2>' . __('XPressME Upgrade', 'xpressme') . "</h2><br>\n"; 14 15 if(get_xpress_latest_version()){ 20 if( get_xpress_latest_version($check_url)){ 16 21 $latest = get_option('xpressme_latest_version'); 17 22 if ($latest) { … … 23 28 24 29 25 if (version_compare($xpress_version, $latest_version, '>')){ 30 if (version_compare($xpress_version, $latest_version, '>')){ 26 31 echo '<h3 class="response">'; 27 32 printf(__('You are using a XPressME Integration Kit development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.', 'xpressme') , $xpress_version , $latest['develop_url']); … … 29 34 30 35 } else if (version_compare($xpress_version, $latest_version, '<')) { 31 echo '<h3 class="response">'. __('There is a new version of XPressME Integration Kit available for upgrade', 'xpressme') . '</h3>'; 32 echo '<p>'; 33 printf(__('You can upgrade to version %s download the package and install it manually:', 'xpressme'),$latest_version); 34 echo '</p>'; 35 echo '<a class="button" href="' . $package . '">'; 36 printf(__('Download %s', 'xpressme') , $latest_version); 37 echo '</a>'; 38 36 echo '<h3 class="response">'; 37 _e( 'An updated version of XPressME Integration Kit is available.' ); 38 echo '</h3>'; 39 39 40 if ($latest['diff_response'] == 'diff_exists'){ 40 echo '<p>'; 41 printf(__('You can download the differential file from version %s to %s and upgrade it manually:', 'xpressme'),$xpress_version,$latest['diff_latest_version']); 42 echo '</p>'; 43 echo '<a class="button" href="' . $latest['diff_package'] . '">'; 44 printf(__('Download differential file for %s', 'xpressme') , $latest['diff_latest_version']); 45 echo '</a>'; 41 // echo '<p>'; 42 // printf(__('You can download the differential file from version %s to %s and upgrade it manually:', 'xpressme'),$xpress_version,$latest['diff_latest_version']); 43 // echo '</p>'; 44 $download_diff ='<a class="button" href="' . $latest['diff_package'] . '">'; 45 // $download_diff .= sprintf(__('Download differential file for %s', 'xpressme') , $latest['diff_latest_version']); 46 $download_diff .= sprintf(__('Download differential file for %s', 'xpressme') , $xpress_version); 47 $download_diff .='</a>'; 46 48 } 49 $message = sprintf(__('You can update to <a href="http://codex.wordpress.org/Version_%1$s">XPressME Integration Kit Ver %2$s</a> automatically or download the package and install it manually:'), $update->current, $latest_version); 50 $submit = __('Update Automatically'); 51 $form_action = 'admin.php?page=upgrade_page&action=do-xpress-upgrade'; 52 $download = sprintf(__('Download %s', 'xpressme') , $latest_version); 53 $show_buttons = true; 54 47 55 } else { 48 echo '<h3 class="response">'. __('You have the latest version of XPressME Integration Kit. You do not need to upgrade', 'xpressme') . '</h3>'; 56 echo '<h3>'; 57 printf(__('You have the latest version of XPressME Integration Kit Ver.%s.'),$xpress_version); 58 echo '</h3>'; 59 60 $message = __('You have the latest version of XPressME Integration Kit. You do not need to upgrade', 'xpressme'); 61 $submit = __('Re-install Automatically'); 62 $form_action = 'update-core.php?action=do-core-reinstall'; 63 49 64 } 50 65 … … 74 89 } 75 90 91 echo '<p>'; 92 echo $message; 93 echo '</p>'; 94 echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">'; 95 // wp_nonce_field('upgrade-core'); 96 echo '<p>'; 97 echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>'; 98 echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>'; 99 if ( $show_buttons ) { 100 echo '<input id="upgrade" class="button" type="submit" value="' . esc_attr($submit) . '" name="upgrade" /> '; 101 echo '<a href="' . esc_url($package) . '" class="button">' . $download . '</a> '; 102 echo $download_diff; 103 } 104 echo '</form>'; 76 105 } else { 77 106 echo '<h3 class="response">'; 78 107 printf(__('There is no response from <a href="%s">version check API</a> now. sorry, please confirm it after.', 'xpressme'),$check_url); 79 108 echo "</div>\n"; 109 } 110 } 111 112 113 function xpress_update_core($current) { 114 include_once ABSPATH . 'wp-content/plugins/xpressme/include/class-xpress-upgrader.php'; 115 $upgrader = new Xpress_Upgrader(); 116 return $upgrader->upgrade($current); 117 } 118 119 function do_xpress_upgrade( $reinstall = false ) { 120 global $wp_filesystem; 121 122 if ( $reinstall ) 123 $url = 'update-xpress.php?action=do-xpress-reinstall'; 124 else 125 $url = 'update-xpress.php?action=do-xpress-upgrade'; 126 $url = wp_nonce_url($url, 'upgrade-xpress'); 127 if ( false === ($credentials = request_filesystem_credentials($url, '', false, ABSPATH)) ) 128 return; 129 130 $version = isset( $_POST['version'] )? $_POST['version'] : false; 131 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US'; 132 $update = find_xpress_update( $version, $locale ); 133 // $update = true; 134 if ( !$update ) 135 return; 136 137 138 if ( ! WP_Filesystem($credentials, ABSPATH) ) { 139 request_filesystem_credentials($url, '', true, ABSPATH); //Failed to connect, Error and request again 140 return; 141 } 142 ?> 143 <div class="wrap"> 144 <?php screen_icon(); ?> 145 <h2><?php _e('Update XPressME Integration Kit'); ?></h2> 146 <?php 147 if ( $wp_filesystem->errors->get_error_code() ) { 148 foreach ( $wp_filesystem->errors->get_error_messages() as $message ) 149 show_message($message); 150 echo '</div>'; 151 return; 152 } 153 154 if ( $reinstall ) 155 $update->response = 'reinstall'; 156 157 $result = xpress_update_core($update, 'show_message'); 158 159 if ( is_wp_error($result) ) { 160 show_message($result); 161 if ('up_to_date' != $result->get_error_code() ) 162 show_message( __('Installation Failed') ); 163 } else { 164 show_message( __('XPressME Integration Kit updated successfully') ); 165 $update_url = 'http://localhost/cube/modules/xp_test/admin/update.php'; 166 show_message( '<strong>' . __('Actions:') . '</strong> <a href="' . esc_url( $update_url ) . '">' . __('Go to Module Update') . '</a>' ); 167 } 168 echo '</div>'; 169 } 170 171 172 173 174 function upgrade_page() 175 { 176 if ( ! current_user_can('update_plugins') ) 177 wp_die(__('You do not have sufficient permissions to update XPressME Integration Kit for this site.')); 178 $action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-xpress'; 179 $upgrade_error = false; 180 if ( 'upgrade-xpress' == $action ) { 181 list_xpress_update(); 182 } elseif ( 'do-xpress-upgrade' == $action) { 183 do_xpress_upgrade(); 80 184 } 81 185 } … … 103 207 } 104 208 105 function get_xpress_latest_version( ){209 function get_xpress_latest_version($check_url){ 106 210 global $wp_version, $wpdb, $wp_local_package; 107 211 global $xoops_config; … … 110 214 $lang = WPLANG; 111 215 112 $check_url = "http://ja.xpressme.info/version_check/index.php?version=$xpress_version&lang=$lang";216 // $check_url = "http://ja.xpressme.info/version_check/index.php?version=$xpress_version&lang=$lang"; 113 217 $request_options = array( 114 218 'timeout' => 3,
Note: See TracChangeset
for help on using the changeset viewer.