Changeset 1932005
- Timestamp:
- 08/28/2018 08:01:26 PM (8 years ago)
- Location:
- perfectdashboard/trunk
- Files:
-
- 11 edited
-
Cms/Wordpress/Task/GetExtensions.php (modified) (9 diffs)
-
Cms/Wordpress/Task/PostChildUpdate.php (modified) (1 diff)
-
Cms/Wordpress/Task/PostExtensionUpdate.php (modified) (1 diff)
-
Cms/Wordpress/Upgrader/Plugin.php (modified) (1 diff)
-
Cms/Wordpress/Upgrader/Theme.php (modified) (1 diff)
-
lib/src/Config.php (modified) (1 diff)
-
lib/src/Loader.php (modified) (2 diffs)
-
lib/src/Task/GetEnvironment.php (modified) (2 diffs)
-
lib/src/Task/GetExtensions.php (modified) (1 diff)
-
perfectdashboard.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
perfectdashboard/trunk/Cms/Wordpress/Task/GetExtensions.php
r1908589 r1932005 8 8 { 9 9 protected $current_theme = ''; 10 protected $updates = array(); 10 11 11 12 /** 12 13 * @return array 13 14 */ 14 public function doTask()15 {16 if (($site_id = (int) $this->input('pd_site_id')))17 {18 AutoUpdater_Config::set('site_id', $site_id);19 }20 21 if (defined('DOING_AJAX'))22 {23 return $this->getUpdatesFromCustomServers();24 }25 else26 {27 return $this->getExtensions();28 }29 }30 31 /**32 * @return array33 */34 15 protected function getExtensions() 35 16 { 36 $extensions = array( 37 array( 38 'name' => 'WordPress', 39 'type' => 'cms', 40 'slug' => 'wordpress', 41 'version' => get_bloginfo('version'), 42 'enabled' => 1, 43 'author' => 'WordPress Team', 44 'author_url' => 'https://wordpress.org', 45 ), 46 $extensions[] = array( 47 'name' => 'Translations', 48 'slug' => 'core', 49 'type' => 'language', 50 'cms' => 'wordpress', 51 'version' => AUTOUPDATER_WP_VERSION, 52 'enabled' => 1, 53 'author' => 'WordPress Team', 54 'author_url' => 'https://wordpress.org', 55 ) 56 ); 17 $extensions = array(); 18 $this->updates = $this->getUpdatesFromCustomServers(); 19 20 $cms = new stdClass(); 21 $cms->name = 'WordPress'; 22 $cms->type = 'cms'; 23 $cms->slug = 'wordpress'; 24 $cms->version = get_bloginfo('version'); 25 $cms->enabled = 1; 26 $cms->update_servers = array(); 27 $cms->update = null; 28 29 $translations = new stdClass(); 30 $translations->name = 'Translations'; 31 $translations->type = 'language'; 32 $translations->slug = 'core'; 33 $translations->version = AUTOUPDATER_WP_VERSION; 34 $translations->enabled = 1; 35 $translations->update_servers = array(); 36 $translations->update = $this->checkForUpdates($translations->slug, $translations->type); 37 38 $extensions[] = $cms; 39 $extensions[] = $translations; 57 40 58 41 $list = get_plugins(); … … 86 69 } 87 70 88 return array( 89 'success' => true, 90 'extensions' => $extensions, 91 ); 71 return $extensions; 92 72 } 93 73 … … 100 80 protected function getPluginInfo($slug, $plugin) 101 81 { 102 $item = array( 103 'name' => $this->filterHTML($plugin['Name']), 104 'type' => 'plugin', 105 'slug' => $slug, 106 'version' => strtolower($this->filterHTML($plugin['Version'])), 107 'enabled' => (int) is_plugin_active($slug), 108 'update_servers' => '', 109 ); 110 111 // Get author name 112 if (isset($plugin['Author'])) 113 { 114 $item['author'] = $this->filterHTML($plugin['Author']); 115 } 116 elseif (isset($plugin['AuthorName'])) 117 { 118 $item['author'] = $this->filterHTML($plugin['AuthorName']); 119 } 120 else 121 { 122 $item['author'] = null; 123 } 124 125 // Get author url 126 if (isset($plugin['AuthorURI'])) 127 { 128 $item['author_url'] = $this->filterHTML($plugin['AuthorURI']); 129 } 130 else 131 { 132 $item['author_url'] = null; 133 } 82 $item = new stdClass(); 83 $item->name = $this->filterHTML($plugin['Name']); 84 $item->type = 'plugin'; 85 $item->slug = $slug; 86 $item->version = strtolower($this->filterHTML($plugin['Version'])); 87 $item->enabled = (int) is_plugin_active($slug); 88 $item->update_servers = array(); 89 $item->update = $this->checkForUpdates($item->slug, $item->type); 134 90 135 91 return $item; … … 151 107 152 108 // build array with themes data to Dashboard 153 $item = array( 154 'name' => $this->filterHTML( 155 $legacy ? $theme['Name'] : $theme->get('Name')), 156 'type' => 'theme', 157 'slug' => $legacy ? $theme['Template'] : pathinfo($slug, PATHINFO_FILENAME), 158 'version' => strtolower($this->filterHTML( 159 $legacy ? $theme['Version'] : $theme->get('Version'))), 160 'update_servers' => '', 161 ); 162 163 // Get author name 164 $item['author'] = $this->filterHTML( 165 $legacy ? $theme['Author'] : $theme->get('Author')); 166 $item['author_url'] = $this->filterHTML( 167 $legacy ? $theme['Author URI'] : $theme->get('AuthorURI')); 168 169 // Check if theme is activated 170 $item['enabled'] = (int) ($this->current_theme == $item['name']); 109 $item = new stdClass(); 110 $item->name = $this->filterHTML($legacy ? $theme['Name'] : $theme->get('Name')); 111 $item->type = 'theme'; 112 $item->slug = $legacy ? $theme['Template'] : pathinfo($slug, PATHINFO_FILENAME); 113 $item->version = strtolower($this->filterHTML($legacy ? $theme['Version'] : $theme->get('Version'))); 114 $item->enabled = (int) ($this->current_theme == $item->name); 115 $item->update_servers = array(); 116 $item->update = $this->checkForUpdates($item->slug, $item->type); 171 117 172 118 return $item; … … 181 127 $pagenow = 'update-core.php'; 182 128 183 require_once AUTOUPDATER_WP_PLUGIN_PATH . 'Cms/Wordpress/Helper/Tracker.php'; 129 if (!class_exists(AutoUpdater_Loader::getClassPrefix() . 'Cms_Wordpress_Helper_Tracker')) 130 { 131 require_once AUTOUPDATER_WP_PLUGIN_PATH . 'Cms/Wordpress/Helper/Tracker.php'; 132 } 184 133 AutoUpdater_Cms_Wordpress_Helper_Tracker::initDefaults(); 185 134 … … 248 197 } 249 198 250 $updates[] = array( 251 'slug' => $slug, 252 'type' => 'plugin', 253 'cms' => 'wordpress', 199 $updates[$slug . '_plugin'] = array( 254 200 'version' => $plugin->new_version, 255 201 'download_url' => $plugin->package, 256 'cms_version_max' => !empty($plugin->tested) ? $plugin->tested : null ,202 'cms_version_max' => !empty($plugin->tested) ? $plugin->tested : null 257 203 ); 258 204 } … … 300 246 } 301 247 302 $updates[] = array( 303 'slug' => $slug, 304 'type' => 'theme', 305 'cms' => 'wordpress', 248 $updates[$slug . '_theme'] = array( 306 249 'version' => $theme->new_version, 307 250 'download_url' => $theme->package, 308 'cms_version_max' => !empty($theme->tested) ? $theme->tested : null ,251 'cms_version_max' => !empty($theme->tested) ? $theme->tested : null 309 252 ); 310 253 } … … 328 271 if ($translations) 329 272 { 330 $updates[] = array( 331 'slug' => 'core', 332 'type' => 'language', 333 'cms' => 'wordpress', 273 $updates['core_language'] = array( 334 274 'version' => AUTOUPDATER_WP_VERSION . (substr_count(AUTOUPDATER_WP_VERSION, '.') === 1 ? '.0.1' : '.1'), 335 275 'download_url' => null, 336 'cms_version_max' => AUTOUPDATER_WP_VERSION ,276 'cms_version_max' => AUTOUPDATER_WP_VERSION 337 277 ); 338 278 } 339 279 340 return array( 341 'success' => true, 342 'updates' => $updates, 343 'update_servers' => AutoUpdater_Cms_Wordpress_Helper_Tracker::getCachedRequests(), 344 ); 280 return $updates; 345 281 } 346 282 … … 354 290 if (!empty($settings['dlid'])) 355 291 { 356 $plugin['update_servers'] = array( 357 array( 358 'url' => 'https://www.perfect-web.co/index.php?option=com_ars&view=update&task=stream&format=json&id=8', 359 'dl_query' => 'dlid=' . trim($settings['dlid']), 360 ), 361 ); 292 $plugin->update_servers = array('https://www.perfect-web.co/index.php?option=com_ars&view=update&task=stream&format=json&id=8&dlid=' . trim($settings['dlid'])); 362 293 } 363 294 364 295 // Fix name 365 if (version_compare($plugin ['version'], '2.1.5', '<') &&366 strripos($plugin ['name'], ' PRO') === false &&296 if (version_compare($plugin->version, '2.1.5', '<') && 297 strripos($plugin->name, ' PRO') === false && 367 298 file_exists(WP_PLUGIN_DIR . '/pwebcontact/uploader.php')) 368 299 { 369 $plugin['name'] = $plugin['name'] . ' PRO'; 370 } 300 $plugin->name = $plugin->name . ' PRO'; 301 } 302 } 303 304 /** 305 * @param string $slug 306 * @param string $type 307 * 308 * @return object|null 309 */ 310 protected function checkForUpdates($slug, $type) 311 { 312 return isset($this->updates[$slug . '_' . $type]) ? $this->updates[$slug . '_' . $type] : null; 371 313 } 372 314 } -
perfectdashboard/trunk/Cms/Wordpress/Task/PostChildUpdate.php
r1883279 r1932005 11 11 $this->setInput('type', 'plugin'); 12 12 $this->setInput('slug', AUTOUPDATER_WP_PLUGIN_SLUG); 13 14 if (substr(AUTOUPDATER_WP_PLUGIN_BASENAME, 0, 1) === 'a' || AUTOUPDATER_STAGE != 'app') 15 { 16 $this->setInput('path', AutoUpdater_Config::getAutoUpdaterUrl() 13 $this->setInput('path', AutoUpdater_Config::getAutoUpdaterUrl() 17 14 . 'download/child/' . AUTOUPDATER_CMS . '/' . AUTOUPDATER_WP_PLUGIN_BASENAME . '.zip'); 18 }19 else20 {21 $this->setInput('path', 'https://downloads.wordpress.org/plugin/' . AUTOUPDATER_WP_PLUGIN_BASENAME . '.zip');22 }23 15 24 16 return AutoUpdater_Task::getInstance('PostExtensionUpdate', $this->payload) -
perfectdashboard/trunk/Cms/Wordpress/Task/PostExtensionUpdate.php
r1916974 r1932005 269 269 elseif (!is_null($result) && !is_bool($result)) 270 270 { 271 $response['error'] = array( 272 'code' => 'unknown_error', 273 'message' => 'Dump: ' . var_export($result, true) 274 ); 271 $errors['unknown_error'] = 'Result dump: ' . var_export($result, true); 275 272 } 276 273 277 274 if (count($errors)) 278 275 { 279 $response['errors'] = $errors; 276 if (!isset($response['error'])) 277 { 278 end($errors); 279 $response['error'] = array( 280 'code' => key($errors), 281 'message' => current($errors) 282 ); 283 unset($errors[$response['error']['code']]); 284 } 285 if (count($errors)) 286 { 287 $response['errors'] = $errors; 288 } 280 289 } 281 290 -
perfectdashboard/trunk/Cms/Wordpress/Upgrader/Plugin.php
r1883279 r1932005 67 67 /** @since 3.6.0 */ 68 68 $options['abort_if_destination_exists'] = false; 69 70 if (version_compare(AUTOUPDATER_WP_VERSION, '3.6.0', '<')) 71 { 72 $options['clear_destination'] = true; 73 } 69 $options['clear_destination'] = true; 74 70 75 71 return parent::run($options); -
perfectdashboard/trunk/Cms/Wordpress/Upgrader/Theme.php
r1883279 r1932005 67 67 /** @since 3.6.0 */ 68 68 $options['abort_if_destination_exists'] = false; 69 70 if (version_compare(AUTOUPDATER_WP_VERSION, '3.6.0', '<')) 71 { 72 $options['clear_destination'] = true; 73 } 69 $options['clear_destination'] = true; 74 70 75 71 return parent::run($options); -
perfectdashboard/trunk/lib/src/Config.php
r1908589 r1932005 197 197 } 198 198 199 if (!$force && ! AUTOUPDATER_DEBUG&& $this->getOption('config_cached', 0) > strtotime('-1 hour'))199 if (!$force && !defined('AUTOUPDATER_DEBUG') && $this->getOption('config_cached', 0) > strtotime('-1 hour')) 200 200 { 201 201 return true; -
perfectdashboard/trunk/lib/src/Loader.php
r1883279 r1932005 29 29 $path = str_replace('_', '/', $name) . '.php'; 30 30 31 if (!file_exists(AUTOUPDATER_LIB_PATH . $path))32 {33 return false;34 }35 36 include_once AUTOUPDATER_LIB_PATH . $path;37 38 31 if (!class_exists(static::getClassPrefix() . $name)) 39 32 { 40 return false; 33 if (!file_exists(AUTOUPDATER_LIB_PATH . $path)) 34 { 35 return false; 36 } 37 38 include_once AUTOUPDATER_LIB_PATH . $path; 39 40 if (!class_exists(static::getClassPrefix() . $name)) 41 { 42 return false; 43 } 41 44 } 42 45 … … 45 48 if (AUTOUPDATER_CMS) 46 49 { 47 $path = dirname(dirname(AUTOUPDATER_LIB_PATH)) . '/Cms/' . ucfirst(strtolower(AUTOUPDATER_CMS)) . '/' . $path; 48 if (file_exists($path)) 50 $prefix = 'Cms_' . ucfirst(strtolower(AUTOUPDATER_CMS)) . '_'; 51 52 if (!class_exists(static::getClassPrefix() . $prefix . $name)) 49 53 { 50 include_once$path;51 $prefix = 'Cms_' . ucfirst(strtolower(AUTOUPDATER_CMS)) . '_'; 52 if ( class_exists(static::getClassPrefix() . $prefix . $name))54 $path = dirname(dirname(AUTOUPDATER_LIB_PATH)) . '/Cms/' . ucfirst(strtolower(AUTOUPDATER_CMS)) . '/' . $path; 55 56 if (file_exists($path)) 53 57 { 54 static::$loaded[$name] = static::$loaded[$prefix . $name] = static::getClassPrefix() . $prefix . $name;58 include_once $path; 55 59 } 60 } 61 62 if (class_exists(static::getClassPrefix() . $prefix . $name)) 63 { 64 static::$loaded[$name] = static::$loaded[$prefix . $name] = static::getClassPrefix() . $prefix . $name; 56 65 } 57 66 } -
perfectdashboard/trunk/lib/src/Task/GetEnvironment.php
r1883279 r1932005 14 14 'cms_version' => null, 15 15 'cms_language' => AutoUpdater_Config::getSiteLanguage(), 16 'php_version' => PHP_VERSION,16 'php_version' => php_sapi_name() !== 'cli' ? PHP_VERSION : '', 17 17 'os' => php_uname('s'), 18 18 'server' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '', … … 21 21 ); 22 22 23 if (!$this->input('refresh')) 24 { 25 $data['success'] = true; 26 } 27 23 28 return $data; 24 29 } -
perfectdashboard/trunk/lib/src/Task/GetExtensions.php
r1883279 r1932005 9 9 public function doTask() 10 10 { 11 if (($site_id = (int) $this->input('pd_site_id'))) 12 { 13 AutoUpdater_Config::set('site_id', $site_id); 14 } 15 16 $extensions = $this->getExtensions(); 17 18 $environment = AutoUpdater_Task::getInstance('GetEnvironment', array( 19 'refresh' => 1 20 ))->doTask(); 21 22 $all_extensions = filter_var($this->input('pd_all'), FILTER_VALIDATE_BOOLEAN); 23 24 // set defaults 25 $checksum = sha1(json_encode($extensions)); 26 $checksum_cached = null; 27 $diff = array( 28 'changed' => $extensions, 29 'deleted' => array() 30 ); 31 32 // get the cache to compare with the current state 33 $cache = $all_extensions ? json_encode($extensions) : AutoUpdater_Config::get('extensions_cache', null); 34 35 if ($cache !== null && !$all_extensions) 36 { 37 // make checksum 38 $checksum_cached = sha1($cache); 39 40 $cache = json_decode($cache); 41 42 // compare the extension array with the cache to get changed and removed extensions 43 if (is_array($cache)) 44 { 45 $diff = $this->diff($extensions, $cache); 46 } 47 } 48 49 // save cache & checksum 50 AutoUpdater_Config::set('extensions_cache', json_encode($extensions)); 51 11 52 return array( 12 'success' => true, 13 'extensions' => array(), 53 'success' => true, 54 'extensions' => array_merge( 55 $diff, array( 56 'checksum' => $checksum, 57 'checksum_cached' => $checksum_cached 58 ) 59 ), 60 'environment' => $environment 14 61 ); 62 } 63 64 /** 65 * @param array $extensions 66 * @param array $cache 67 * 68 * @return array 69 */ 70 protected function diff($extensions, $cache) 71 { 72 $changed = array(); 73 74 foreach ($extensions as $extension) 75 { 76 // look for this extension in the cache 77 $cache_key = $this->findExtensionInCache($extension->type, $extension->slug, $cache); 78 79 // this is a newly installed extension 80 if ($cache_key === false) 81 { 82 $changed[] = $extension; 83 continue; 84 } 85 else 86 { 87 $cache_extension = $cache[$cache_key]; 88 unset($cache[$cache_key]); 89 90 // the status of the extension has changed 91 if (sha1(json_encode($extension)) != sha1(json_encode($cache_extension))) 92 { 93 $changed[] = $extension; 94 continue; 95 } 96 } 97 } 98 99 return array( 100 'changed' => $changed, 101 'deleted' => array_values($cache) 102 ); 103 } 104 105 /** 106 * @param string $type 107 * @param string $slug 108 * @param array $cache 109 * 110 * @return int|bool 111 */ 112 protected function findExtensionInCache($type, $slug, $cache) 113 { 114 foreach ($cache as $i => $extension) 115 { 116 if ($extension->type == $type && $extension->slug == $slug) 117 { 118 return $i; 119 } 120 } 121 122 return false; 15 123 } 16 124 -
perfectdashboard/trunk/perfectdashboard.php
r1915233 r1932005 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 8.16 * Version: 1.19.0 7 7 * Text Domain: autoupdater 8 8 * Author: Perfect Dashboard -
perfectdashboard/trunk/readme.txt
r1922057 r1932005 5 5 Requires at least: 3.0 6 6 Tested up to: 4.9.8 7 Stable tag: 1.1 8.17 Stable tag: 1.19.0 8 8 License: GNU/GPL 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html
Note: See TracChangeset
for help on using the changeset viewer.