Changeset 1908589
- Timestamp:
- 07/13/2018 07:27:17 AM (8 years ago)
- Location:
- perfectdashboard/trunk
- Files:
-
- 12 edited
-
Cms/Wordpress/Api.php (modified) (1 diff)
-
Cms/Wordpress/Task/GetExtensions.php (modified) (3 diffs)
-
Cms/Wordpress/Task/PostExtensionUpdate.php (modified) (11 diffs)
-
Cms/Wordpress/Upgrader/Skin/Core.php (modified) (1 diff)
-
Cms/Wordpress/Upgrader/Skin/Languagepack.php (modified) (1 diff)
-
Cms/Wordpress/Upgrader/Skin/Plugin.php (modified) (1 diff)
-
Cms/Wordpress/Upgrader/Skin/Theme.php (modified) (1 diff)
-
app/Admin.php (modified) (2 diffs)
-
lib/src/Config.php (modified) (2 diffs)
-
perfectdashboard.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
-
tmpl/configuration_form_autoupdater_fields.tmpl.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
perfectdashboard/trunk/Cms/Wordpress/Api.php
r1883279 r1908589 29 29 } 30 30 31 // set the en_US as a default 32 load_default_textdomain('en_US'); 33 31 34 if (!AutoUpdater_Config::get('ssl_verify', 0)) 32 35 { -
perfectdashboard/trunk/Cms/Wordpress/Task/GetExtensions.php
r1883279 r1908589 7 7 class AutoUpdater_Cms_Wordpress_Task_GetExtensions extends AutoUpdater_Task_GetExtensions 8 8 { 9 protected $servers = array(); 10 protected $request_defaults = array(); 11 protected $current_theme = ''; 9 protected $current_theme = ''; 12 10 13 11 /** … … 183 181 $pagenow = 'update-core.php'; 184 182 185 $this->request_defaults = array( 186 'method' => 'GET', 187 'timeout' => apply_filters('http_request_timeout', 5), 188 'redirection' => apply_filters('http_request_redirection_count', 5), 189 '_redirection' => apply_filters('http_request_redirection_count', 5), 190 'httpversion' => apply_filters('http_request_version', '1.0'), 191 'user-agent' => apply_filters('http_headers_useragent', 192 'WordPress/' . AUTOUPDATER_WP_VERSION . '; ' . get_bloginfo('url')), 193 'reject_unsafe_urls' => apply_filters('http_request_reject_unsafe_urls', false), 194 'blocking' => true, 195 'compress' => false, 196 'decompress' => true, 197 'sslverify' => true, 198 'sslcertificates' => ABSPATH . WPINC . '/certificates/ca-bundle.crt', 199 'stream' => false, 200 'filename' => null, 201 'limit_response_size' => null, 202 ); 183 require_once AUTOUPDATER_WP_PLUGIN_PATH . 'Cms/Wordpress/Helper/Tracker.php'; 184 AutoUpdater_Cms_Wordpress_Helper_Tracker::initDefaults(); 203 185 204 186 // catch updateservers 205 add_filter('pre_http_request', array($this, 'catchRequest'), 11, 3);187 add_filter('pre_http_request', 'AutoUpdater_Cms_Wordpress_Helper_Tracker::trackRequest', 11, 3); 206 188 207 189 // delete cached data with updates … … 359 341 'success' => true, 360 342 'updates' => $updates, 361 'update_servers' => $this->servers, 362 ); 363 } 364 365 /** 366 * @param bool $preempt 367 * @param array $request 368 * @param string $url 369 * 370 * @return bool 371 */ 372 public function catchRequest($preempt = false, $request = array(), $url = '') 373 { 374 // Cactch only commercial update servers for plugins and themes not present at the official WordPress repository 375 if (!empty($url) && strpos($url, '://api.wordpress.org/') === false) 376 { 377 $data = array_merge(array('url' => $url), $request); 378 $cache_key = md5(serialize($data)); 379 if (!isset($this->servers[$cache_key])) 380 { 381 // Remove defaults 382 foreach ($data as $key => $item) 383 { 384 if (isset($this->request_defaults[$key])) 385 { 386 if ($this->request_defaults[$key] === $item) 387 { 388 unset($data[$key]); 389 } 390 } 391 elseif (empty($item)) 392 { 393 unset($data[$key]); 394 } 395 } 396 397 // Change the certificates path to relative 398 if (!empty($data['sslcertificates'])) 399 { 400 $data['sslcertificates'] = str_replace(ABSPATH, '', $data['sslcertificates']); 401 } 402 403 $this->servers[$cache_key] = $data; 404 } 405 } 406 407 return $preempt; 343 'update_servers' => AutoUpdater_Cms_Wordpress_Helper_Tracker::getCachedRequests(), 344 ); 408 345 } 409 346 -
perfectdashboard/trunk/Cms/Wordpress/Task/PostExtensionUpdate.php
r1883279 r1908589 35 35 } 36 36 37 $upgrader_path = dirname(dirname(__FILE__)) . '/Upgrader/';37 $upgrader_path = AUTOUPDATER_WP_PLUGIN_PATH . 'Cms/Wordpress/Upgrader/'; 38 38 require_once $upgrader_path . 'Dependencies.php'; 39 require_once AUTOUPDATER_WP_PLUGIN_PATH . 'Cms/Wordpress/Helper/Tracker.php'; 39 40 40 41 switch ($type) … … 85 86 new AutoUpdater_Cms_Wordpress_Upgrader_Skin_Core()); 86 87 $result = $upgrader->upgrade($update, array('pre_check_md5' => false)); 87 ob_end_clean();88 $output = ob_get_clean(); 88 89 89 90 // returns string with a new version or null on success … … 106 107 require_once $upgrader_path . 'Skin/Plugin.php'; 107 108 109 $data = get_file_data(WP_PLUGIN_DIR . '/' . $slug, array('Version' => 'Version')); 110 $old_version = $data['Version']; 111 $expected_version = $this->input('version'); 112 108 113 if ($path) 109 114 { … … 117 122 $nonce = 'upgrade-plugin_' . $plugin; 118 123 $url = 'update.php?action=upgrade-plugin&plugin=' . urlencode($plugin); 124 125 $this->logInAdmin(); 126 AutoUpdater_Cms_Wordpress_Helper_Tracker::initDefaults(); 127 add_filter('pre_http_request', 'AutoUpdater_Cms_Wordpress_Helper_Tracker::trackRequest', 11, 3); 119 128 } 120 129 … … 125 134 )); 126 135 $result = $path ? $upgrader->install($path) : $upgrader->upgrade($slug); 127 ob_end_clean(); 136 $output = ob_get_clean(); 137 138 $data = get_file_data(WP_PLUGIN_DIR . '/' . $slug, array('Version' => 'Version')); 139 $new_version = $data['Version']; 128 140 break; 129 141 … … 133 145 require_once $upgrader_path . 'Theme.php'; 134 146 require_once $upgrader_path . 'Skin/Theme.php'; 147 148 $data = get_file_data(WP_CONTENT_DIR . '/themes/' . $slug, array('Version' => 'Version')); 149 $old_version = $data['Version']; 150 $expected_version = $this->input('version'); 135 151 136 152 if ($path) … … 145 161 $nonce = 'upgrade-theme_' . $theme; 146 162 $url = 'update.php?action=upgrade-theme&theme=' . urlencode($theme);; 163 164 $this->logInAdmin(); 165 AutoUpdater_Cms_Wordpress_Helper_Tracker::initDefaults(); 166 add_filter('pre_http_request', 'AutoUpdater_Cms_Wordpress_Helper_Tracker::trackRequest', 11, 3); 147 167 } 148 168 … … 153 173 )); 154 174 $result = $path ? $upgrader->install($path) : $upgrader->upgrade($slug); 155 ob_end_clean(); 175 $output = ob_get_clean(); 176 177 $data = get_file_data(WP_CONTENT_DIR . '/themes/' . $slug, array('Version' => 'Version')); 178 $new_version = $data['Version']; 156 179 break; 157 180 … … 174 197 )); 175 198 $result = $upgrader->bulk_upgrade(); 176 ob_end_clean();199 $output = ob_get_clean(); 177 200 178 201 // returns an array of results on success, or true if there are no updates … … 181 204 $result = true; 182 205 } 206 elseif ($result === true) 207 { 208 $result = new WP_Error('up_to_date', 'There are no translations updates'); 209 } 183 210 } 184 211 else … … 190 217 $filemanager->clearPhpCache(); 191 218 192 if ($result === true || is_null($result)) 219 $errors = isset($upgrader) ? $upgrader->skin->get_errors() : array(); 220 if (is_wp_error($result)) 221 { 222 /** @var WP_Error $result */ 223 $errors[$result->get_error_code()] = $result->get_error_message(); 224 $result = false; 225 } 226 227 if (array_key_exists('up_to_date', $errors) && 228 (!isset($expected_version, $new_version) || $expected_version && version_compare($expected_version, $new_version, '<='))) 193 229 { 194 230 return array( 195 231 'success' => true, 196 ); 197 } 198 elseif (is_wp_error($result)) 199 { 200 /** @var WP_Error $result */ 232 'message' => $errors['up_to_date'] != 'up_to_date' ? $errors['up_to_date'] : 'Up-to-date' 233 ); 234 } 235 elseif (array_key_exists('no_package', $errors)) 236 { 237 $result = false; 201 238 $response['error'] = array( 202 'code' => $result->get_error_code(), 203 'message' => $result->get_error_message(), 204 ); 205 206 if ($response['error']['code'] == 'up_to_date') 207 { 208 return array( 209 'success' => true, 210 'message' => 'Up to date', 211 ); 212 } 213 } 214 elseif ($result === false) 215 { 216 $errors = $upgrader->skin->get_errors(); 217 if (array_search('up_to_date', $errors)) 218 { 219 return array( 220 'success' => true, 221 'message' => 'Up to date', 222 ); 223 } 224 239 'code' => 'no_package_warning', 240 'message' => $errors['no_package'] 241 ); 242 unset($errors['no_package']); 243 } 244 elseif (isset($old_version, $new_version) && version_compare($old_version, $new_version, '=')) 245 { 246 $result = false; 225 247 $response['error'] = array( 226 'code' => 'update_failed', 227 'message' => array_shift($errors), 228 ); 229 230 if (count($errors) > 0) 231 { 232 $response['error']['messages'] = $errors; 233 } 248 'code' => 'no_update_warning', 249 'message' => 'No update was performed, current version ' . $new_version . ' remains' 250 ); 251 } 252 253 if ($result === true || is_null($result)) 254 { 255 return array( 256 'success' => true, 257 ); 234 258 } 235 259 elseif (!is_null($result) && !is_bool($result)) 236 260 { 237 261 $response['error'] = array( 238 'code' => 'unknown', 239 'message' => var_export($result, true), 240 ); 262 'code' => 'unknown_error', 263 'message' => 'Dump: ' . var_export($result, true) 264 ); 265 } 266 267 if (count($errors)) 268 { 269 $response['errors'] = $errors; 270 } 271 272 if (!empty($output)) 273 { 274 AutoUpdater_Log::debug('Updater output: ' . $output); 275 } 276 277 if ($requests = AutoUpdater_Cms_Wordpress_Helper_Tracker::getCachedRequests()) 278 { 279 AutoUpdater_Log::debug('Updater requests: ' . print_r($requests, true)); 241 280 } 242 281 243 282 return $response; 244 283 } 284 285 /** 286 * @return bool 287 */ 288 protected function logInAdmin() 289 { 290 $users = get_users(array('role' => 'administrator', 'number' => 1)); 291 if (!empty($users[0]->ID)) 292 { 293 require_once ABSPATH . 'wp-includes/pluggable.php'; 294 wp_set_current_user($users[0]->ID); 295 } 296 297 return is_user_logged_in(); 298 } 245 299 } -
perfectdashboard/trunk/Cms/Wordpress/Upgrader/Skin/Core.php
r1883279 r1908589 39 39 if (is_string($errors)) 40 40 { 41 $this->errors[ ]= $errors;41 $this->errors[$errors] = $message = $errors; 42 42 } 43 43 elseif (is_wp_error($errors)) 44 44 { 45 45 /** @var WP_Error $errors */ 46 $this->errors[] = 'Code: ' . $errors->get_error_code() . ' Message: ' . $errors->get_error_message(); 46 $message = 'Error code: ' . $errors->get_error_code() . ', message: ' . $errors->get_error_message(); 47 48 $this->errors[$errors->get_error_code()] = $errors->get_error_message(); 47 49 } 48 50 else 49 51 { 50 $this->errors[] = var_export($errors, true); 52 $error = var_export($errors, true); 53 $message = 'Unknown error, dump: ' . $error; 54 55 $this->errors['unknown_error'] = $error; 51 56 } 57 58 AutoUpdater_Log::debug($message); 52 59 } 53 60 -
perfectdashboard/trunk/Cms/Wordpress/Upgrader/Skin/Languagepack.php
r1883279 r1908589 39 39 if (is_string($errors)) 40 40 { 41 $this->errors[ ]= $errors;41 $this->errors[$errors] = $message = $errors; 42 42 } 43 43 elseif (is_wp_error($errors)) 44 44 { 45 45 /** @var WP_Error $errors */ 46 $this->errors[] = 'Code: ' . $errors->get_error_code() . ' Message: ' . $errors->get_error_message(); 46 $message = 'Error code: ' . $errors->get_error_code() . ', message: ' . $errors->get_error_message(); 47 48 $this->errors[$errors->get_error_code()] = $errors->get_error_message(); 47 49 } 48 50 else 49 51 { 50 $this->errors[] = var_export($errors, true); 52 $error = var_export($errors, true); 53 $message = 'Unknown error, dump: ' . $error; 54 55 $this->errors['unknown_error'] = $error; 51 56 } 57 58 AutoUpdater_Log::debug($message); 52 59 } 53 60 -
perfectdashboard/trunk/Cms/Wordpress/Upgrader/Skin/Plugin.php
r1883279 r1908589 39 39 if (is_string($errors)) 40 40 { 41 $this->errors[ ]= $errors;41 $this->errors[$errors] = $message = $errors; 42 42 } 43 43 elseif (is_wp_error($errors)) 44 44 { 45 45 /** @var WP_Error $errors */ 46 $this->errors[] = 'Code: ' . $errors->get_error_code() . ' Message: ' . $errors->get_error_message(); 46 $message = 'Error code: ' . $errors->get_error_code() . ', message: ' . $errors->get_error_message(); 47 48 $this->errors[$errors->get_error_code()] = $errors->get_error_message(); 47 49 } 48 50 else 49 51 { 50 $this->errors[] = var_export($errors, true); 52 $error = var_export($errors, true); 53 $message = 'Unknown error, dump: ' . $error; 54 55 $this->errors['unknown_error'] = $error; 51 56 } 57 58 AutoUpdater_Log::debug($message); 52 59 } 53 60 -
perfectdashboard/trunk/Cms/Wordpress/Upgrader/Skin/Theme.php
r1883279 r1908589 39 39 if (is_string($errors)) 40 40 { 41 $this->errors[ ]= $errors;41 $this->errors[$errors] = $message = $errors; 42 42 } 43 43 elseif (is_wp_error($errors)) 44 44 { 45 45 /** @var WP_Error $errors */ 46 $this->errors[] = 'Code: ' . $errors->get_error_code() . ' Message: ' . $errors->get_error_message(); 46 $message = 'Error code: ' . $errors->get_error_code() . ', message: ' . $errors->get_error_message(); 47 48 $this->errors[$errors->get_error_code()] = $errors->get_error_message(); 47 49 } 48 50 else 49 51 { 50 $this->errors[] = var_export($errors, true); 52 $error = var_export($errors, true); 53 $message = 'Unknown error, dump: ' . $error; 54 55 $this->errors['unknown_error'] = $error; 51 56 } 57 58 AutoUpdater_Log::debug($message); 52 59 } 53 60 -
perfectdashboard/trunk/app/Admin.php
r1883279 r1908589 115 115 $update_themes = AutoUpdater_Config::get('update_themes', 0); 116 116 $excluded_themes_unprepared = AutoUpdater_Config::get('excluded_themes'); 117 $time_of_day = AutoUpdater_Config::get('time_of_day', 1);117 $time_of_day = AutoUpdater_Config::get('time_of_day', 'night'); 118 118 $notification_end_user_email = AutoUpdater_Config::get('notification_end_user_email'); 119 $notification_on_success = AutoUpdater_Config::get('notification_on_success', 1); 120 $notification_on_failure = AutoUpdater_Config::get('notification_on_failure', 1); 119 121 120 122 $excluded_extensions = array(); … … 318 320 'time_of_day' => isset($_POST['time_of_day']) ? $_POST['time_of_day'] : 'night', 319 321 'notification_end_user_email' => isset($_POST['notification_end_user_email']) ? $_POST['notification_end_user_email'] : '', 322 'notification_on_success' => isset($_POST['notification_on_success']) ? $_POST['notification_on_success'] : 1, 323 'notification_on_failure' => isset($_POST['notification_on_failure']) ? $_POST['notification_on_failure'] : 1, 320 324 ); 321 325 } -
perfectdashboard/trunk/lib/src/Config.php
r1883279 r1908589 284 284 } 285 285 286 if (isset($settings->notification_on_success)) 287 { 288 $this->setOption('notification_on_success', (int) $settings->notification_on_success); 289 } 290 if (isset($settings-> notification_on_failure)) 291 { 292 $this->setOption('notification_on_failure', (int) $settings->notification_on_failure); 293 } 286 294 287 295 // Notifications in CMS dashboard … … 406 414 $settings['notification_end_user_email'] = (string) $data['notification_end_user_email']; 407 415 if ((string) $this->getOption('notification_end_user_email') !== $settings['notification_end_user_email']) 416 { 417 $changed = true; 418 } 419 } 420 if (array_key_exists('notification_on_success', $data)) 421 { 422 $settings['notification_on_success'] = (int) $data['notification_on_success']; 423 if ((int) $this->getOption('notification_on_success') !== $settings['notification_on_success']) 424 { 425 $changed = true; 426 } 427 } 428 if (array_key_exists('notification_on_failure', $data)) 429 { 430 $settings['notification_on_failure'] = (int) $data['notification_on_failure']; 431 if ((int) $this->getOption('notification_on_failure') !== $settings['notification_on_failure']) 408 432 { 409 433 $changed = true; -
perfectdashboard/trunk/perfectdashboard.php
r1883279 r1908589 4 4 * Plugin URI: https://perfectdashboard.com/?utm_source=backend&utm_medium=installer&utm_campaign=in&utm_term=WP 5 5 * Description: 6 * Version: 1.1 7.06 * Version: 1.18.0 7 7 * Text Domain: autoupdater 8 8 * Author: Perfect Dashboard … … 32 32 version_compare(PHP_VERSION, '5.3', '>=')) 33 33 { 34 $data = get_ plugin_data(__FILE__, false, false);34 $data = get_file_data(__FILE__, array('Version' => 'Version')); 35 35 36 36 define('AUTOUPDATER_WP_PLUGIN_NAME', 'Perfect Dashboard'); -
perfectdashboard/trunk/readme.txt
r1883279 r1908589 5 5 Requires at least: 3.0 6 6 Tested up to: 4.9.6 7 Stable tag: 1.1 7.07 Stable tag: 1.18.0 8 8 License: GNU/GPL 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html -
perfectdashboard/trunk/tmpl/configuration_form_autoupdater_fields.tmpl.php
r1883281 r1908589 180 180 </td> 181 181 </tr> 182 <tr> 183 <th scope="row"> 184 <label><?php _e('Notification on successful update', 'autoupdater') ?></label> 185 </th> 186 <td> 187 <label> 188 <input type="radio" name="notification_on_success" value="0" <?php if (!$notification_on_success) echo 'checked="checked"'; ?>> 189 <?php _e('No') ?> 190 </label> 191 <label> 192 <input type="radio" name="notification_on_success" value="1" <?php if ($notification_on_success) echo 'checked="checked"'; ?>> 193 <?php _e('Yes') ?> 194 </label> 195 <p class="description"> 196 <?php _e('Receive a notification after a successful update', 'autoupdater') ?> 197 </p> 198 </td> 199 </tr> 200 <tr> 201 <th scope="row"> 202 <label><?php _e('Notification on failed update', 'autoupdater') ?></label> 203 </th> 204 <td> 205 <label> 206 <input type="radio" name="notification_on_failure" value="0" <?php if (!$notification_on_failure) echo 'checked="checked"'; ?>> 207 <?php _e('No') ?> 208 </label> 209 <label> 210 <input type="radio" name="notification_on_failure" value="1" <?php if ($notification_on_failure) echo 'checked="checked"'; ?>> 211 <?php _e('Yes') ?> 212 </label> 213 <p class="description"> 214 <?php _e('Receive a notification after a failed update', 'autoupdater') ?> 215 </p> 216 </td> 217 </tr> 182 218 </tbody> 183 219 </table>
Note: See TracChangeset
for help on using the changeset viewer.