Changeset 2678176
- Timestamp:
- 02/14/2022 05:42:31 AM (3 years ago)
- Location:
- iwp-client/trunk
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
iwp-client/trunk/addons/post_links/post.class.php
r2548691 r2678176 63 63 // create dynamic url RegExp 64 64 $dot_match_count = 0; 65 $iwp_regexp_url = ""; 66 67 if(!empty($post_upload_dir)){ 65 66 if(empty($post_upload_dir)){ 67 $iwp_regexp_url = ""; 68 $iwp_base_url = array(); 69 $iwp_base_url['host'] = ''; 70 $iwp_base_url['path'] = ''; 71 }else{ 68 72 $iwp_base_url = parse_url($post_upload_dir['url']); 69 73 $iwp_regexp_url = $iwp_base_url['host'] . $iwp_base_url['path']; 74 } 70 75 $rep = array( 71 76 '/', … … 89 94 $iwp_mmb_dot_url = str_replace($rep, $with, $iwp_mmb_dot_url); 90 95 $dot_match_count = preg_match_all('/(<a[^>]+href=\"([^"]+)\"[^>]*>)?(<\s*img.[^\/>]*src="([^"]*' . $iwp_mmb_dot_url . '[^\s]+\.(jpg|jpeg|png|gif|bmp))"[^>]*>)/ixu', $post_data['post_content'], $dot_get_urls, PREG_SET_ORDER); 91 }92 96 93 97 -
iwp-client/trunk/addons/wp_optimize/purge-plugins-cache-class.php
r2128300 r2678176 80 80 } 81 81 82 if (empty($params) || isset($params['litespeed-cache'])) { 83 $response = $this->deleteAllLiteSpeedCache(); 84 if (!empty($response['success'])) { 85 $text .= "<span class='wpm_results_db'> Litespeed Cache"." : " . $response['success'] . "</span><br>"; 86 $cleanup_values['value_array']['litespeed-cache'] = $values['value']; 87 }elseif(!empty($response['error'])){ 88 $text .= "<span class='wpm_results_db'> Litespeed Cache"." : " . $response['error'] . "</span><br>"; 89 $cleanup_values['value_array']['auto_optimize'] = 'Litespeed Cache'; 90 } 91 } 92 82 93 if ($text !==''){ 83 94 $cleanup_values['message'] = $text; … … 126 137 return true; 127 138 } 139 } 140 return false; 141 } 142 143 public function checkLiteSpeedCachePlugin() { 144 include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 145 if ( is_plugin_active( 'litespeed-cache/litespeed-cache.php' ) ) { 146 @include_once(WP_PLUGIN_DIR . '/litespeed-cache/litespeed-cache.php'); 147 return true; 128 148 } 129 149 return false; … … 280 300 } 281 301 302 public function deleteAllLiteSpeedCache(){ 303 if ($this->checkLiteSpeedCachePlugin()) { 304 do_action('litespeed_purge_all'); 305 return array('success' => 'Purged all caches successfully'); 306 }else { 307 return array('error'=>"Litespeed cache not activated", 'error_code' => 'litespeed_cache_plugin_is_not_activated'); 308 } 309 } 310 282 311 } 283 312 -
iwp-client/trunk/backup.class.multicall.php
r2548691 r2678176 284 284 } 285 285 upgradeOldDropBoxBackupList($params['account_info']['iwp_dropbox']); 286 } 287 288 if (!empty($params['account_info']['iwp_dropbox'])) { 289 set_iwp_dropbox_auth_setting($params['account_info']['iwp_dropbox']); 286 290 } 287 291 … … 4524 4528 function remove_ftp_backup($args) 4525 4529 { 4530 global $iwp_backup_core; 4526 4531 extract($args); 4527 4532 //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder … … 4545 4550 ); 4546 4551 } 4552 $iwp_backup_core->ensure_phpseclib('Crypt_Blowfish', 'Crypt/Blowfish'); 4547 4553 if (!$sftp->login($ftp_username, $ftp_password)) { 4548 4554 return array( … … 4599 4605 function get_ftp_backup($args, $current_file_num = 0) 4600 4606 { 4607 global $iwp_backup_core; 4601 4608 extract($args); 4602 4609 if(isset($use_sftp) && $use_sftp==1) { … … 4618 4625 ); 4619 4626 } 4627 $iwp_backup_core->ensure_phpseclib('Crypt_Blowfish', 'Crypt/Blowfish'); 4620 4628 if (!$sftp->login($ftp_username, $ftp_password)) { 4621 4629 return array( … … 4774 4782 $dropbox_destination .= '/' . basename($backup_file); 4775 4783 }else{ 4776 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/API.php'; 4777 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/Exception.php'; 4778 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/ConsumerAbstract.php'; 4779 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/Curl.php'; 4780 4781 $oauth = new IWP_Dropbox_OAuth_Consumer_Curl($dropbox_app_key, $dropbox_app_secure_key); 4782 $oauth->setToken($dropbox_access_token); 4783 $dropbox = new IWP_Dropbox_API($oauth); 4784 4785 if(!isset($dropbox_email) && empty($dropbox_email)){ 4786 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/API.php'; 4787 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/Exception.php'; 4788 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/ConsumerAbstract.php'; 4789 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/Curl.php'; 4790 4791 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/backup/dropbox.php'; 4792 4793 $oauth = new IWP_Dropbox_OAuth_Consumer_Curl($dropbox_app_key, $dropbox_app_secure_key); 4794 $oauth->setToken($dropbox_access_token); 4795 $dropbox = new IWP_Dropbox_API($oauth); 4796 4797 }else{ 4798 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/backup/dropbox.php'; 4799 4800 try{ 4801 $helper = new IWP_MMB_UploadModule_dropbox(); 4802 $dropbox = $helper->bootstrap(); 4803 } 4804 catch(Exception $e){ 4805 return $this->statusLog($historyID, array('stage' => 'uploadDropBox', 'status' => 'error', 'statusMsg' => $e->getMessage(), 'statusCode' => 'dropbox_verification_failed_file_may_be_corrupted')); 4806 } 4807 } 4808 4784 4809 $oldRoot = 'Apps/InfiniteWP/'; 4785 4810 $dropbox_destination = $oldRoot.ltrim(trim($dropbox_destination), '/'); … … 4981 5006 $dropbox_destination .= '/' . $this->site_name; 4982 5007 }else{ 4983 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/API.php'; 4984 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/Exception.php'; 4985 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/ConsumerAbstract.php'; 4986 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/Curl.php'; 5008 if(!isset($dropbox_email) && empty($dropbox_email)){ 5009 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/API.php'; 5010 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/Exception.php'; 5011 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/ConsumerAbstract.php'; 5012 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/Curl.php'; 4987 5013 4988 $oauth = new IWP_Dropbox_OAuth_Consumer_Curl($dropbox_app_key, $dropbox_app_secure_key); 4989 $oauth->setToken($dropbox_access_token); 4990 $dropbox = new IWP_Dropbox_API($oauth); 5014 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/backup/dropbox.php'; 5015 5016 $oauth = new IWP_Dropbox_OAuth_Consumer_Curl($dropbox_app_key, $dropbox_app_secure_key); 5017 $oauth->setToken($dropbox_access_token); 5018 $dropbox = new IWP_Dropbox_API($oauth); 5019 5020 }else{ 5021 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/backup/dropbox.php'; 5022 5023 try{ 5024 set_iwp_dropbox_auth_setting($args); 5025 $helper = new IWP_MMB_UploadModule_dropbox(); 5026 $dropbox = $helper->bootstrap(); 5027 } 5028 catch(Exception $e){ 5029 5030 } 5031 } 4991 5032 $oldRoot = 'Apps/InfiniteWP/'; 4992 5033 $dropbox_destination = $oldRoot.ltrim(trim($dropbox_destination), '/'); -
iwp-client/trunk/backup.class.singlecall.php
r2548691 r2678176 2028 2028 function ftp_backup($args) 2029 2029 { 2030 global $iwp_backup_core; 2030 2031 extract($args); 2031 2032 //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder, $ftp_site_folder … … 2048 2049 ); 2049 2050 } 2051 $iwp_backup_core->ensure_phpseclib('Crypt_Blowfish', 'Crypt/Blowfish'); 2050 2052 if (!$sftp->login($ftp_username, $ftp_password)) { 2051 2053 return array( … … 2149 2151 function remove_ftp_backup($args) 2150 2152 { 2153 global $iwp_backup_core; 2151 2154 extract($args); 2152 2155 //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder … … 2169 2172 ); 2170 2173 } 2174 $iwp_backup_core->ensure_phpseclib('Crypt_Blowfish', 'Crypt/Blowfish'); 2171 2175 if (!$sftp->login($ftp_username, $ftp_password)) { 2172 2176 return array( … … 2240 2244 $dropbox_destination .= '/' . basename($backup_file); 2241 2245 }else{ 2242 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/API.php'; 2243 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/Exception.php'; 2244 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/ConsumerAbstract.php'; 2245 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/Curl.php'; 2246 if(!isset($dropbox_email) && empty($dropbox_email)){ 2247 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/API.php'; 2248 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/Exception.php'; 2249 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/ConsumerAbstract.php'; 2250 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/Curl.php'; 2246 2251 2247 $oauth = new IWP_Dropbox_OAuth_Consumer_Curl($dropbox_app_key, $dropbox_app_secure_key); 2248 $oauth->setToken($dropbox_access_token); 2249 $dropbox = new IWP_Dropbox_API($oauth); 2252 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/backup/dropbox.php'; 2253 2254 $oauth = new IWP_Dropbox_OAuth_Consumer_Curl($dropbox_app_key, $dropbox_app_secure_key); 2255 $oauth->setToken($dropbox_access_token); 2256 $dropbox = new IWP_Dropbox_API($oauth); 2257 2258 }else{ 2259 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/backup/dropbox.php'; 2260 2261 try{ 2262 set_iwp_dropbox_auth_setting($args); 2263 $helper = new IWP_MMB_UploadModule_dropbox(); 2264 $dropbox = $helper->bootstrap(); 2265 } 2266 catch(Exception $e){ 2267 2268 } 2269 } 2250 2270 $oldRoot = 'Apps/InfiniteWP/'; 2251 2271 $oldVersion = false; … … 2308 2328 $oldVersion = true; 2309 2329 }else{ 2310 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/API.php'; 2311 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/Exception.php'; 2312 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/ConsumerAbstract.php'; 2313 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/Curl.php'; 2330 if(!isset($dropbox_email) && empty($dropbox_email)){ 2331 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/API.php'; 2332 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/Exception.php'; 2333 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/ConsumerAbstract.php'; 2334 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/Curl.php'; 2314 2335 2315 $oauth = new IWP_Dropbox_OAuth_Consumer_Curl($dropbox_app_key, $dropbox_app_secure_key); 2316 $oauth->setToken($dropbox_access_token); 2317 $dropbox = new IWP_Dropbox_API($oauth); 2336 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/backup/dropbox.php'; 2337 2338 $oauth = new IWP_Dropbox_OAuth_Consumer_Curl($dropbox_app_key, $dropbox_app_secure_key); 2339 $oauth->setToken($dropbox_access_token); 2340 $dropbox = new IWP_Dropbox_API($oauth); 2341 2342 }else{ 2343 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/backup/dropbox.php'; 2344 2345 try{ 2346 set_iwp_dropbox_auth_setting($args); 2347 $helper = new IWP_MMB_UploadModule_dropbox(); 2348 $dropbox = $helper->bootstrap(); 2349 } 2350 catch(Exception $e){ 2351 2352 } 2353 } 2318 2354 $oldRoot = 'Apps/InfiniteWP/'; 2319 2355 $dropbox_destination = $oldRoot.ltrim(trim($dropbox_destination), '/'); -
iwp-client/trunk/backup/backup-repo-test.php
r2548691 r2678176 144 144 145 145 public function SFTPTestConnection($args){ 146 global $iwp_backup_core; 146 147 extract($args); 147 148 … … 161 162 ); 162 163 } 164 // Ensure phpseclib Crypt_Blowfish is loaded, over PEAR's 165 $iwp_backup_core->ensure_phpseclib('Crypt_Blowfish', 'Crypt/Blowfish'); 163 166 if (!$sftp->login($ftp_username, $ftp_password)) { 164 167 return array('status' => 'error', … … 189 192 $uploadFilePath = IWP_BACKUP_DIR; 190 193 $uploadTestFile = $sftp->put(basename($backup_file),$backup_file,NET_SFTP_LOCAL_FILE); 194 $remote_test_file = rtrim($ftp_remote_folder, '/') . '/' . basename($backup_file); 195 $sftp->delete($remote_test_file); 191 196 @unlink($backup_file); 192 197 if ($uploadTestFile === false) { … … 202 207 public function backupRepositoryDropbox($args){ 203 208 extract($args); 204 if(isset($dropbox_access_token) && !empty($dropbox_access_token)){ 205 require_once $GLOBALS['iwp_mmb_plugin_dir'].'/lib/Dropbox/API.php'; 206 require_once $GLOBALS['iwp_mmb_plugin_dir'].'/lib/Dropbox/Exception.php'; 207 require_once $GLOBALS['iwp_mmb_plugin_dir'].'/lib/Dropbox/OAuth/Consumer/ConsumerAbstract.php'; 208 require_once $GLOBALS['iwp_mmb_plugin_dir'].'/lib/Dropbox/OAuth/Consumer/Curl.php'; 209 209 $dropbox = null; 210 if(!isset($dropbox_email) && empty($dropbox_email) && isset($dropbox_access_token) && !empty($dropbox_access_token)){ 211 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/API.php'; 212 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/Exception.php'; 213 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/ConsumerAbstract.php'; 214 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/Curl.php'; 215 216 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/backup/dropbox.php'; 210 217 try{ 211 218 $oauth = new IWP_Dropbox_OAuth_Consumer_Curl($dropbox_app_key, $dropbox_app_secure_key); 212 219 $oauth->setToken($dropbox_access_token); 213 $dropbox = new IWP_Dropbox_API($oauth); 220 $dropbox = new IWP_Dropbox_API($oauth); 221 } 222 catch(Exception $e){ 223 return array('error' => $e->getMessage(), 'error_code' => 'dropbox_test_failed'); 224 } 225 226 }elseif( isset($dropbox_email) && !empty($dropbox_email) ){ 227 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/backup/dropbox.php'; 228 229 try{ 230 set_iwp_dropbox_auth_setting($args); 231 $helper = new IWP_MMB_UploadModule_dropbox(); 232 $dropbox = $helper->bootstrap(); 233 } 234 catch(Exception $e){ 235 return array('error' => $e->getMessage(), 'error_code' => 'dropbox_test_failed'); 236 } 237 } 238 239 if (!is_null($dropbox)) { 240 try{ 214 241 $oldRoot = 'Apps/InfiniteWP'; 215 242 $dropbox_destination = $oldRoot.$dropbox_destination; 216 243 $response = $dropbox->accountInfo(); 217 return array('status' => 'success'); 244 return array('status' => 'success'); 218 245 } 219 246 catch(Exception $e){ … … 221 248 } 222 249 } 250 223 251 return array('error' => 'Consumer Secret not available', 'error_code' => 'consumer_secret_not_available'); 224 252 } -
iwp-client/trunk/backup/backup.core.class.php
r2548691 r2678176 3739 3739 } 3740 3740 3741 public function ensure_phpseclib ($classes = false, $class_paths = false) {3741 public function ensure_phpseclib_old($classes = false, $class_paths = false) { 3742 3742 3743 3743 $this->no_deprecation_warnings_on_php7(); … … 3760 3760 } 3761 3761 } 3762 } 3763 3764 public function ensure_phpseclib($classes = array()) { 3765 3766 $classes = (array) $classes; 3767 3768 $this->no_deprecation_warnings_on_php7(); 3769 3770 $any_missing = false; 3771 3772 foreach ($classes as $cl) { 3773 if (!class_exists($cl)) $any_missing = true; 3774 } 3775 3776 if (!$any_missing) return true; 3777 3778 $ret = true; 3779 3780 // From phpseclib/phpseclib/phpseclib/bootstrap.php - we nullify it there, but log here instead 3781 if (extension_loaded('mbstring')) { 3782 // 2 - MB_OVERLOAD_STRING 3783 // @codingStandardsIgnoreLine 3784 if (ini_get('mbstring.func_overload') & 2) { 3785 // We go on to try anyway, in case the caller wasn't using an affected part of phpseclib 3786 // @codingStandardsIgnoreLine 3787 $ret = new WP_Error('mbstring_func_overload', 'Overloading of string functions using mbstring.func_overload is not supported by phpseclib.'); 3788 } 3789 } 3790 3791 $phpseclib_dir = $GLOBALS['iwp_mmb_plugin_dir'].'/lib/phpseclib/phpseclib/phpseclib'; 3792 if (false === strpos(get_include_path(), $phpseclib_dir)) set_include_path(get_include_path().PATH_SEPARATOR.$phpseclib_dir); 3793 foreach ($classes as $cl) { 3794 $path = str_replace('_', '/', $cl); 3795 if (!class_exists($cl)) include_once($phpseclib_dir.'/'.$path.'.php'); 3796 } 3797 3798 return $ret; 3762 3799 } 3763 3800 … … 3997 4034 'dropbox_site_folder' => $dropbox_details['dropbox_site_folder'] 3998 4035 ); 4036 if ( !empty($dropbox_details['dropbox_email']) ) { 4037 $opts['email'] = $dropbox_details['dropbox_email']; 4038 } 3999 4039 IWP_MMB_Backup_Options::update_iwp_backup_option('IWP_dropbox', $opts); 4000 4040 }elseif (!empty($params['account_info']['iwp_gdrive'])) { … … 4425 4465 4426 4466 public function createCloudInstance($type, $args){ 4467 global $iwp_backup_core; 4427 4468 if ($type == 'dropbox') { 4428 4469 extract($args['iwp_dropbox']); 4429 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/API.php'; 4430 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/Exception.php'; 4431 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/ConsumerAbstract.php'; 4432 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/Curl.php'; 4470 if(!isset($dropbox_email) && empty($dropbox_email)){ 4471 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/API.php'; 4472 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/Exception.php'; 4473 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/ConsumerAbstract.php'; 4474 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/Dropbox/OAuth/Consumer/Curl.php'; 4433 4475 4434 $oauth = new IWP_Dropbox_OAuth_Consumer_Curl($dropbox_app_key, $dropbox_app_secure_key); 4435 $oauth->setToken($dropbox_access_token); 4436 $dropbox = new IWP_Dropbox_API($oauth); 4476 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/backup/dropbox.php'; 4477 4478 $oauth = new IWP_Dropbox_OAuth_Consumer_Curl($dropbox_app_key, $dropbox_app_secure_key); 4479 $oauth->setToken($dropbox_access_token); 4480 $dropbox = new IWP_Dropbox_API($oauth); 4481 4482 }else{ 4483 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/backup/dropbox.php'; 4484 4485 try{ 4486 set_iwp_dropbox_auth_setting($args['iwp_dropbox']); 4487 $helper = new IWP_MMB_UploadModule_dropbox(); 4488 $dropbox = $helper->bootstrap(); 4489 } 4490 catch(Exception $e){ 4491 return false; 4492 } 4493 } 4437 4494 return $dropbox; 4438 4495 }elseif ($type == 'ftp') { … … 4452 4509 return false; 4453 4510 } 4511 $iwp_backup_core->ensure_phpseclib('Crypt_Blowfish', 'Crypt/Blowfish'); 4454 4512 if (!$sftp->login($ftp_username, $ftp_password)) { 4455 4513 return false; … … 4697 4755 } 4698 4756 } 4757 4758 if (isset($backups[$timestamp]['service_setting'])) { 4759 $service_setting = $backups[$timestamp]['service_setting']; 4760 if (isset($service_setting['dropbox_site_folder'])) { 4761 set_iwp_dropbox_auth_setting($service_setting); 4762 } 4763 } 4699 4764 } 4700 4765 … … 4753 4818 foreach ($instance_settings as $instance_id => $options) { 4754 4819 4755 $remote_obj->set_options($ options, false, $instance_id);4820 $remote_obj->set_options($service_setting, false, $instance_id); 4756 4821 4757 4822 foreach ($files as $index => $file) { … … 4988 5053 'dropbox_site_folder' => $dropbox_details['dropbox_site_folder'] 4989 5054 ); 5055 if ( !empty($dropbox_details['dropbox_email']) ) { 5056 $opts['email'] = $dropbox_details['dropbox_email']; 5057 } 4990 5058 IWP_MMB_Backup_Options::update_iwp_backup_option('IWP_dropbox', $opts); 4991 5059 }elseif (!empty($params['account_info']['iwp_gdrive'])) { -
iwp-client/trunk/backup/backup.upload.php
r1851728 r2678176 9 9 10 10 private $_instance_id; 11 12 private $_storage; 11 13 12 14 /** … … 23 25 24 26 if (null !== $instance_id) $this->set_instance_id($instance_id); 27 28 if (!empty($this->_storage)) unset($this->_storage); 25 29 26 30 if ($save) return $this->save_options(); … … 39 43 } 40 44 41 if (!$this->_instance_id) {42 throw new Exception('set_options() requires an instance ID, but was called without setting one (either directly or via set_instance_id())');43 }45 // if (!$this->_instance_id) { 46 // throw new Exception('set_options() requires an instance ID, but was called without setting one (either directly or via set_instance_id())'); 47 // } 44 48 45 49 global $iwp_backup_core; … … 292 296 293 297 } 298 299 300 /** 301 * This method will set the stored storage object to that indicated 302 * 303 * @param Object $storage - the storage client 304 */ 305 public function set_storage($storage) { 306 $this->_storage = $storage; 307 } 308 309 /** 310 * This method will return the stored storage client 311 * 312 * @return Object - the stored remote storage client 313 */ 314 public function get_storage() { 315 if (!empty($this->_storage)) return $this->_storage; 316 } 294 317 } -
iwp-client/trunk/backup/dropbox.php
r1851728 r2678176 32 32 33 33 $time_now = microtime(true); 34 $storage = $this->get_storage(); 34 35 35 36 $time_since_last_tick = $time_now - $this->upload_tick; … … 50 51 $new_chunk = $new_chunk - ($new_chunk % 524288); 51 52 $chunk_size = (int)$new_chunk; 52 $ this->dropbox_object->setChunkSize($chunk_size);53 $storage->setChunkSize($chunk_size); 53 54 $iwp_backup_core->jobdata_set('dropbox_chunk_size', $chunk_size); 54 55 } … … 441 442 } 442 443 443 public function config_print() {444 public function config_print() { 444 445 445 446 $opts = $this->get_options(); … … 486 487 $sec = empty($opts['appkey']) ? '' : $opts['appkey']; 487 488 488 $oauth2_id = base64_decode('aXA3NGR2Zm1sOHFteTA5'); 489 $oauth2_id = $key; 490 $old_auth = false; 491 if ( empty($opts['email']) ) { 492 $old_auth = true; 493 } 489 494 490 495 … … 493 498 494 499 // Instantiate the storage 495 $ storage = new Dropbox_WordPress($encrypter, "tk_", 'IWP_dropbox', $this);500 $dropbox_storage = new Dropbox_WordPress($encrypter, "tk_", 'IWP_dropbox', $this); 496 501 497 502 // WordPress consumer does not yet work … … 508 513 509 514 try { 510 $OAuth = new Dropbox_Curl($sec, $oauth2_id, $key, $ storage, null, null, $deauthenticate);515 $OAuth = new Dropbox_Curl($sec, $oauth2_id, $key, $dropbox_storage, null, null, $deauthenticate, null,$old_auth); 511 516 } catch (Exception $e) { 512 517 global $iwp_backup_core; … … 517 522 518 523 if ($deauthenticate) return true; 519 520 $OAuth->setToken($opts['tk_access_token']); 521 $this->dropbox_object = new IWP_MMB_Dropbox_API($OAuth, $root); 522 return $this->dropbox_object; 524 525 if ( empty($opts['email']) ) { 526 $dropbox_storage->set($opts['tk_access_token'], 'access_token'); 527 } 528 529 $storage = new IWP_MMB_Dropbox_API($OAuth, $root); 530 531 $this->set_storage($storage); 532 533 return $storage; 523 534 } 524 535 -
iwp-client/trunk/core.class.php
r2548691 r2678176 794 794 Description: This plugin will be created automatically when you activate your InfiniteWP Client plugin to improve the performance. And it will be deleted when you deactivate the client plugin. 795 795 Author: Revmakx 796 Version: 1.0.0 796 797 Author URI: https://infinitewp.com/ 797 798 */ … … 844 845 throw new Exception(sprintf('Unable to write loader: %s', $error['message'])); 845 846 } 847 update_option('iwp_mu_plugin_version','1.0.0'); 846 848 } 847 849 -
iwp-client/trunk/init.php
r2548691 r2678176 5 5 Description: This is the client plugin of InfiniteWP that communicates with the InfiniteWP Admin panel. 6 6 Author: Revmakx 7 Version: 1.9. 4.117 Version: 1.9.6 8 8 Author URI: http://www.revmakx.com 9 9 Network: true … … 30 30 endif; 31 31 if(!defined('IWP_MMB_CLIENT_VERSION')) 32 define('IWP_MMB_CLIENT_VERSION', '1.9. 4.11');32 define('IWP_MMB_CLIENT_VERSION', '1.9.6'); 33 33 34 34 … … 3281 3281 $iwp_plugin_fix->fixSpamShield(); 3282 3282 $iwp_plugin_fix->fixWpSpamShieldBan(); 3283 $iwp_plugin_fix->fix PantheonGlobals();3283 $iwp_plugin_fix->fixGlobals(); 3284 3284 3285 3285 } … … 3292 3292 3293 3293 if (file_exists($loaderPath)) { 3294 return; 3294 $iwp_mu_plugin_version = get_option('iwp_mu_plugin_version'); 3295 if(empty($iwp_mu_plugin_version)){ 3296 $iwp_mu_plugin_version = '1.0.0'; 3297 $data = build_mu_plugin_version($loaderPath,$iwp_mu_plugin_version); 3298 if(!$data){ 3299 iwp_mmb_response(array('error' => 'Unable to read InfiniteWP must use plugin', 'error_code' => 'iwp_mu_plugin_read_failed'), false); 3300 return; 3301 } 3302 }else{ 3303 return; //Both file and version number exisit 3304 } 3305 }else{ 3306 $data = $iwp_mmb_core->buildLoaderContent('iwp-client/init.php'); 3295 3307 } 3296 3308 try { 3297 $iwp_mmb_core->registerMustUse($loaderName, $iwp_mmb_core->buildLoaderContent('iwp-client/init.php'));3309 $iwp_mmb_core->registerMustUse($loaderName,$data); 3298 3310 } catch (Exception $e) { 3299 3311 iwp_mmb_response(array('error' => 'Unable to write InfiniteWP Client loader:'.$e->getMessage(), 'error_code' => 'iwp_mu_plugin_loader_failed'), false); 3300 3312 } 3301 3313 } 3314 3315 function build_mu_plugin_version($loaderPath,$iwp_mu_plugin_version){ 3316 $res = false; 3317 $loaderWritten = @file_get_contents($loaderPath); 3318 if($loaderWritten){ 3319 $res = preg_replace('/Author: Revmakx/', "Author: Revmakx ".PHP_EOL."Version :".$iwp_mu_plugin_version." ", $loaderWritten); 3320 } 3321 return $res; 3322 } 3323 3324 function set_iwp_dropbox_auth_setting($dropbox_details){ 3325 if ( !empty($dropbox_details['dropbox_email']) ) { 3326 $opts = array( 3327 'appkey' => $dropbox_details['dropbox_app_key'], 3328 'secret' => $dropbox_details['dropbox_app_secure_key'], 3329 'tk_access_token' => $dropbox_details['dropbox_access_token'], 3330 'folder' => $dropbox_details['dropbox_destination'], 3331 'ownername' => '', 3332 'email' => $dropbox_details['dropbox_email'], 3333 'CSRF' => '', 3334 'dropbox_site_folder' => $dropbox_details['dropbox_site_folder'] 3335 ); 3336 IWP_MMB_Backup_Options::update_iwp_backup_option('IWP_dropbox', $opts); 3337 } 3338 } 3339 3302 3340 if(!function_exists('iwp_mmb_is_WPTC')) { 3303 3341 function iwp_mmb_is_WPTC() { -
iwp-client/trunk/lib/Dropbox2/API.php
r1851728 r2678176 11 11 class IWP_MMB_Dropbox_API { 12 12 // API Endpoints 13 const API_URL = 'https://api.dropbox.com/1/';14 13 const API_URL_V2 = 'https://api.dropboxapi.com/'; 15 const CONTENT_URL = 'https://api-content.dropbox.com/1/';16 14 const CONTENT_URL_V2 = 'https://content.dropboxapi.com/2/'; 17 15 … … 72 70 } 73 71 } 72 73 /** 74 * This function will make a request to refresh the access token 75 * 76 * @return void 77 */ 78 public function refreshAccessToken() { 79 $this->OAuth->refreshAccessToken(); 80 } 74 81 75 82 /** … … 86 93 /** 87 94 * Retrieves information about the user's quota 95 * @param array $options - valid keys are 'timeout' 88 96 * @return object stdClass 89 97 */ 90 public function quotaInfo( ) {98 public function quotaInfo($options = array()) { 91 99 $call = '2/users/get_space_usage'; 92 $params = array('api_v2' => true); 100 // Cases have been seen (Apr 2019) where a response came back (HTTP/2.0 response header - suspected outgoing web hosting proxy, as everyone else seems to get HTTP/1.0 and I'm not aware that current Curl versions would do HTTP/2.0 without specifically being told to) after 180 seconds; a valid response, but took a long time. 101 $params = array( 102 'api_v2' => true, 103 'timeout' => isset($options['timeout']) ? $options['timeout'] : 20 104 ); 93 105 $response = $this->fetch('POST', self::API_URL_V2, $call, $params); 94 106 return $response; 95 107 } 96 97 /**98 * Not used99 * Uploads a physical file from disk100 * Dropbox impose a 150MB limit to files uploaded via the API. If the file101 * exceeds this limit or does not exist, an Exception will be thrown102 * @param string $file Absolute path to the file to be uploaded103 * @param string|bool $filename The destination filename of the uploaded file104 * @param string $path Path to upload the file to, relative to root105 * @param boolean $overwrite Should the file be overwritten? (Default: true)106 * @return object stdClass107 */108 // public function putFile($file, $filename = false, $path = '', $overwrite = true)109 // {110 // if (file_exists($file)) {111 // if (filesize($file) <= 157286400) {112 // $call = 'files/' . $this->root . '/' . $this->encodePath($path);113 // // If no filename is provided we'll use the original filename114 // $filename = (is_string($filename)) ? $filename : basename($file);115 // $params = array(116 // 'filename' => $filename,117 // 'file' => '@' . str_replace('\\', '/', $file) . ';filename=' . $filename,118 // 'overwrite' => (int) $overwrite,119 // );120 // $response = $this->fetch('POST', self::CONTENT_URL, $call, $params);121 // return $response;122 // }123 // throw new Exception('File exceeds 150MB upload limit');124 // }125 126 // // Throw an Exception if the file does not exist127 // throw new Exception('Local file ' . $file . ' does not exist');128 // }129 130 /**131 * Not used132 * Uploads file data from a stream133 * Note: This function is experimental and requires further testing134 * @todo Add filesize check135 * @param resource $stream A readable stream created using fopen()136 * @param string $filename The destination filename, including path137 * @param boolean $overwrite Should the file be overwritten? (Default: true)138 * @return array139 */140 // public function putStream($stream, $filename, $overwrite = true)141 // {142 // $this->OAuth->setInFile($stream);143 // $path = $this->encodePath($filename);144 // $call = 'files_put/' . $this->root . '/' . $path;145 // $params = array('overwrite' => (int) $overwrite);146 // $response = $this->fetch('PUT', self::CONTENT_URL, $call, $params);147 // return $response;148 // }149 108 150 109 /** … … 159 118 * @return stdClass 160 119 */ 120 121 public function chunked_upload($file, $path = '', $overwrite = true, $uploadID = null, $offset = 0, $isCommit = false) { 122 $starting_backup_path_time = time(); 123 124 $file = str_replace("\\", "/",$file); 125 if (!file_exists($file)) throw new Exception('Local file ' . $file . ' does not exist'); 126 127 if (!($handle = @fopen($file, 'r'))) throw new Exception('Could not open ' . $file . ' for reading'); 128 129 // Seek to the correct position on the file pointer 130 fseek($handle, $offset); 131 $to_exit = false; 132 133 //Set firstCommit to true so that the upload session start endpoint is called. 134 $firstCommit = (0 == $offset); 135 136 // Read from the file handle until EOF, uploading each chunk 137 if ($data = fread($handle, $this->chunkSize)) { 138 139 // Set the file, request parameters and send the request 140 $this->OAuth->setInFile($data); 141 142 if ($firstCommit) { 143 $params = array( 144 'close' => false, 145 'api_v2' => true, 146 'content_upload' => true 147 ); 148 $response = $this->fetch('POST', self::CONTENT_URL_V2, 'files/upload_session/start', $params); 149 $firstCommit = false; 150 151 } else { 152 $params = array( 153 'cursor' => array( 154 'session_id' => $uploadID, 155 // If you send it as a string, Dropbox will be unhappy 156 'offset' => (int)$offset 157 ), 158 'api_v2' => true, 159 'content_upload' => true 160 ); 161 $response = $this->append_upload($params, false); 162 } 163 164 // On subsequent chunks, use the upload ID returned by the previous request 165 if (isset($response['body']->session_id)) { 166 $uploadID = $response['body']->session_id; 167 } 168 169 /* 170 API v2 no longer returns the offset, we need to manually work this out. So check that there are no errors and update the offset as well as calling the callback method. 171 */ 172 if (!isset($response['body']->error)) { 173 $offset = ftell($handle); 174 $output['response']= $response; 175 if($isCommit ==false){ 176 177 $output['offset']= $offset; 178 $output['upload_id']= $uploadID; 179 } 180 $this->OAuth->setInFile(null); 181 } 182 183 } 184 // Complete the chunked upload 185 if ($isCommit) { 186 $filename = (is_string($filename)) ? $filename : basename($file); 187 $params = array( 188 'cursor' => array( 189 'session_id' => $uploadID, 190 'offset' => (int)$offset 191 ), 192 'commit' => array( 193 'path' => '/' . $this->encodePath($path .'/'. $filename), 194 'mode' => 'overwrite' 195 ), 196 'api_v2' => true, 197 'content_upload' => true 198 ); 199 $response = $this->append_upload($params, true); 200 $offset = ftell($handle); 201 $output['response']= $response; 202 } 203 204 fclose($handle); 205 return $output; 206 } 207 161 208 public function chunkedUpload($file, $filename = false, $path = '', $overwrite = true, $offset = 0, $uploadID = null, $callback = null) { 162 209 … … 175 222 // Read from the file handle until EOF, uploading each chunk 176 223 while ($data = fread($handle, $this->chunkSize)) { 177 178 224 225 // Set the file, request parameters and send the request 179 226 $this->OAuth->setInFile($data); 180 227 … … 257 304 // $params['cursor']['offset'] = $responseCheck[1]; 258 305 // $response = $this->append_upload($params, $last_call); 306 } elseif (isset($responseCheck) && strpos($responseCheck[0], 'closed') !== false) { 307 throw new Exception("Upload with upload_id {$params['cursor']['session_id']} already completed"); 259 308 } else { 260 309 throw $e; … … 265 314 266 315 /** 267 * Downloads a file 268 * Returns the base filename, raw file data and mime type returned by Fileinfo 269 * @param string $file Path to file, relative to root, including path 270 * @param string $outFile Filename to write the downloaded file to 271 * @param string $revision The revision of the file to retrieve 272 * @param boolean $allow_resume - append to the file if it already exists 273 * @return array 274 */ 275 public function getFile($file, $outFile = false, $revision = null, $allow_resume = false) { 316 * Chunked downloads a file from Dropbox, it will return false if a file handle is not passed and will return true if the call was successful. 317 * 318 * @param string $file Path - to file, relative to root, including path 319 * @param resource $outFile - the local file handle 320 * @param array $options - any extra options to be passed e.g headers 321 * @return boolean - a boolean to indicate success or failure 322 */ 323 public function download($file, $outFile = null, $options = array()) { 276 324 // Only allow php response format for this call 277 325 if ($this->responseFormat !== 'php') { 278 326 throw new Exception('This method only supports the `php` response format'); 279 327 } 280 281 $handle = null; 282 if ($outFile !== false) { 283 // Create a file handle if $outFile is specified 284 if ($allow_resume && file_exists($outFile)) { 285 if (!$handle = fopen($outFile, 'a')) { 286 throw new Exception("Unable to open file handle for $outFile"); 287 } else { 288 $this->OAuth->setOutFile($handle); 289 $params['headers'] = array('Range: bytes='.filesize($outFile).'-'); 290 } 291 } 292 elseif (!$handle = fopen($outFile, 'w')) { 293 throw new Exception("Unable to open file handle for $outFile"); 294 } else { 295 $this->OAuth->setOutFile($handle); 296 } 297 } 298 299 $file = $this->encodePath($file); 300 $call = 'files/download'; 301 $params = array('path' => '/' . $file, 'api_v2' => true, 'content_download' => true); 302 $response = $this->fetch('GET', self::CONTENT_URL_V2, $call, $params); 303 304 // Close the file handle if one was opened 305 if ($handle) fclose($handle); 306 307 return array( 308 'name' => ($outFile) ? $outFile : basename($file), 309 'mime' => $this->getMimeType(($outFile) ? $outFile : $response['body'], $outFile), 310 'meta' => json_decode($response['headers']['dropbox-api-result']), 311 'data' => $response['body'], 312 ); 313 } 314 315 /** 316 * Not used 317 * Retrieves file and folder metadata 318 * @param string $path The path to the file/folder, relative to root 319 * @param string $rev Return metadata for a specific revision (Default: latest rev) 320 * @param int $limit Maximum number of listings to return 321 * @param string $hash Metadata hash to compare against 322 * @param bool $list Return contents field with response 323 * @param bool $deleted Include files/folders that have been deleted 324 * @return object stdClass 325 */ 326 public function metaData($path = null, $rev = null, $limit = 10000, $hash = false, $list = true, $deleted = false) { 327 $call = '2/files/get_metadata' ; 328 $params = array( 329 'path' => '/' . $this->normalisePath($path), 330 'api_v2' => true 331 ); 332 333 return $this->fetch('POST', self::API_URL_V2, $call, $params); 334 } 335 336 /** 337 * Not used 338 * Return "delta entries", intructing you how to update 339 * your application state to match the server's state 340 * Important: This method does not make changes to the application state 341 * @param null|string $cursor Used to keep track of your current state 342 * @return array Array of delta entries 343 */ 344 // public function delta($cursor = null) 345 // { 346 // $call = 'delta'; 347 // $params = array('cursor' => $cursor); 348 // $response = $this->fetch('POST', self::API_URL, $call, $params); 349 // return $response; 350 // } 351 352 /** 353 * Not used 354 * Obtains metadata for the previous revisions of a file 355 * @param string Path to the file, relative to root 356 * @param integer Number of revisions to return (1-1000) 357 * @return array 358 */ 359 // public function revisions($file, $limit = 10) 360 // { 361 // $call = 'revisions/' . $this->root . '/' . $this->encodePath($file); 362 // $params = array( 363 // 'rev_limit' => ($limit < 1) ? 1 : (($limit > 1000) ? 1000 : (int) $limit), 364 // ); 365 // $response = $this->fetch('GET', self::API_URL, $call, $params); 366 // return $response; 367 // } 368 369 /** 370 * Not used 371 * Restores a file path to a previous revision 372 * @param string $file Path to the file, relative to root 373 * @param string $revision The revision of the file to restore 374 * @return object stdClass 375 */ 376 // public function restore($file, $revision) 377 // { 378 // $call = 'restore/' . $this->root . '/' . $this->encodePath($file); 379 // $params = array('rev' => $revision); 380 // $response = $this->fetch('POST', self::API_URL, $call, $params); 381 // return $response; 382 // } 383 384 /** 385 * Returns metadata for all files and folders that match the search query 328 329 if ($outFile) { 330 $this->OAuth->setOutFile($outFile); 331 332 $params = array('path' => '/' . $file, 'api_v2' => true, 'content_download' => true); 333 334 if (isset($options['headers'])) { 335 foreach ($options['headers'] as $key => $header) { 336 $headers[] = $key . ': ' . $header; 337 } 338 $params['headers'] = $headers; 339 } 340 341 $file = $this->encodePath($file); 342 $call = 'files/download'; 343 344 $response = $this->fetch('GET', self::CONTENT_URL_V2, $call, $params); 345 346 fclose($outFile); 347 348 return true; 349 } else { 350 return false; 351 } 352 } 353 354 /** 355 * Calls the relevant method to return metadata for all files and folders that match the search query 386 356 * @param mixed $query The search string. Must be at least 3 characters long 387 357 * @param string [$path=''] The path to the folder you want to search in 388 358 * @param integer [$limit=1000] Maximum number of results to return (1-1000) 389 * @param integer [$ start=0] Result number to startfrom359 * @param integer [$cursor=''] A Dropbox ID to start the search from 390 360 * @return array 391 361 */ 392 public function search($query, $path = '', $limit = 1000, $start = 0) { 393 $call = '2/files/search'; 362 public function search($query, $path = '', $limit = 1000, $cursor = '') { 363 if (empty($cursor)) { 364 return $this->start_search($query, $path, $limit); 365 } else { 366 return $this->continue_search($cursor); 367 } 368 } 369 370 /** 371 * This method will start a search for all files and folders that match the search query 372 * 373 * @param mixed $query - the search string, must be at least 3 characters long 374 * @param string $path - the path to the folder you want to search in 375 * @param integer $limit - maximum number of results to return (1-1000) 376 * 377 * @return array - an array of search results 378 */ 379 private function start_search($query, $path, $limit) { 380 $call = '2/files/search_v2'; 394 381 $path = $this->encodePath($path); 395 382 // APIv2 requires that the path match this regex: String(pattern="(/(.|[\r\n])*)?|(ns:[0-9]+(/.*)?)") 396 383 if ($path && '/' != substr($path, 0, 1)) $path = "/$path"; 397 384 $params = array( 398 'path' => $path,399 385 'query' => $query, 400 'start' => $start, 401 'max_results' => ($limit < 1) ? 1 : (($limit > 1000) ? 1000 : (int) $limit), 386 'options' => array( 387 'path' => $path, 388 'max_results' => ($limit < 1) ? 1 : (($limit > 1000) ? 1000 : (int) $limit), 389 ), 402 390 'api_v2' => true, 403 391 ); … … 405 393 return $response; 406 394 } 407 408 /** 409 * Not used 410 * Creates and returns a shareable link to files or folders 411 * The link returned is for a preview page from which the user an choose to 412 * download the file if they wish. For direct download links, see media(). 413 * @param string $path The path to the file/folder you want a sharable link to 414 * @return object stdClass 415 */ 416 // public function shares($path, $shortUrl = true) 417 // { 418 // $call = 'shares/' . $this->root . '/' .$this->encodePath($path); 419 // $params = array('short_url' => ($shortUrl) ? 1 : 0); 420 // $response = $this->fetch('POST', self::API_URL, $call, $params); 421 // return $response; 422 // } 423 424 /** 425 * Not used 426 * Returns a link directly to a file 427 * @param string $path The path to the media file you want a direct link to 428 * @return object stdClass 429 */ 430 // public function media($path) 431 // { 432 // $call = 'media/' . $this->root . '/' . $this->encodePath($path); 433 // $response = $this->fetch('POST', self::API_URL, $call); 434 // return $response; 435 // } 436 437 /** 438 * Not used 439 * Gets a thumbnail for an image 440 * @param string $file The path to the image you wish to thumbnail 441 * @param string $format The thumbnail format, either JPEG or PNG 442 * @param string $size The size of the thumbnail 443 * @return array 444 */ 445 // public function thumbnails($file, $format = 'JPEG', $size = 'small') 446 // { 447 // // Only allow php response format for this call 448 // if ($this->responseFormat !== 'php') { 449 // throw new Exception('This method only supports the `php` response format'); 450 // } 451 452 // $format = strtoupper($format); 453 // // If $format is not 'PNG', default to 'JPEG' 454 // if ($format != 'PNG') $format = 'JPEG'; 455 456 // $size = strtolower($size); 457 // $sizes = array('s', 'm', 'l', 'xl', 'small', 'medium', 'large'); 458 // // If $size is not valid, default to 'small' 459 // if (!in_array($size, $sizes)) $size = 'small'; 460 461 // $call = 'thumbnails/' . $this->root . '/' . $this->encodePath($file); 462 // $params = array('format' => $format, 'size' => $size); 463 // $response = $this->fetch('GET', self::CONTENT_URL, $call, $params); 464 465 // return array( 466 // 'name' => basename($file), 467 // 'mime' => $this->getMimeType($response['body']), 468 // 'meta' => json_decode($response['headers']['x-dropbox-metadata']), 469 // 'data' => $response['body'], 470 // ); 471 // } 472 473 /** 474 * Not used 475 * THIS IS NOT AVAILABLE IN V2. 476 * Creates and returns a copy_ref to a file 477 * This reference string can be used to copy that file to another user's 478 * Dropbox by passing it in as the from_copy_ref parameter on /fileops/copy 479 * @param $path File for which ref should be created, relative to root 480 * @return array 481 */ 482 // public function copyRef($path) 483 // { 484 // $call = 'copy_ref/' . $this->root . '/' . $this->encodePath($path); 485 // $response = $this->fetch('GET', self::API_URL, $call); 486 // return $response; 487 // } 488 489 /** 490 * Not used 491 * Copies a file or folder to a new location 492 * @param string $from File or folder to be copied, relative to root 493 * @param string $to Destination path, relative to root 494 * @param null|string $fromCopyRef Must be used instead of the from_path 495 * @return object stdClass 496 */ 497 // public function copy($from, $to, $fromCopyRef = null) 498 // { 499 // $call = 'fileops/copy'; 500 // $params = array( 501 // 'root' => $this->root, 502 // 'from_path' => $this->normalisePath($from), 503 // 'to_path' => $this->normalisePath($to), 504 // ); 505 506 // if ($fromCopyRef) { 507 // $params['from_path'] = null; 508 // $params['from_copy_ref'] = $fromCopyRef; 509 // } 510 511 // $response = $this->fetch('POST', self::API_URL, $call, $params); 512 // return $response; 513 // } 514 515 /** 516 * Not used 517 * Creates a folder 518 * @param string New folder to create relative to root 519 * @return object stdClass 520 */ 521 // public function create($path) 522 // { 523 // $call = 'fileops/create_folder'; 524 // $params = array('root' => $this->root, 'path' => $this->normalisePath($path)); 525 // $response = $this->fetch('POST', self::API_URL, $call, $params); 526 // return $response; 527 // } 395 396 /** 397 * This method will continue a previous search for all files and folders that match the previous search query 398 * 399 * @param string $cursor - a Dropbox ID to continue the search 400 * 401 * @return array - an array of search results 402 */ 403 private function continue_search($cursor) { 404 $call = '2/files/search/continue_v2'; 405 $params = array( 406 'cursor' => $cursor, 407 'api_v2' => true, 408 ); 409 $response = $this->fetch('POST', self::API_URL_V2, $call, $params); 410 return $response; 411 } 528 412 529 413 /** … … 533 417 */ 534 418 public function delete($path) { 535 $call = '2/files/delete ';419 $call = '2/files/delete_v2'; 536 420 $params = array('path' => '/' . $this->normalisePath($path), 'api_v2' => true); 537 421 $response = $this->fetch('POST', self::API_URL_V2, $call, $params); 538 422 return $response; 539 423 } 540 541 /** 542 * Not used 543 * Moves a file or folder to a new location 544 * @param string $from File or folder to be moved, relative to root 545 * @param string $to Destination path, relative to root 546 * @return object stdClass 547 */ 548 // public function move($from, $to) 549 // { 550 // $call = 'fileops/move'; 551 // $params = array( 552 // 'root' => $this->root, 553 // 'from_path' => $this->normalisePath($from), 554 // 'to_path' => $this->normalisePath($to), 555 // ); 556 // $response = $this->fetch('POST', self::API_URL, $call, $params); 557 // return $response; 558 // } 559 424 560 425 /** 561 426 * Intermediate fetch function … … 619 484 $this->callback = $function; 620 485 } 486 487 public function getFile($file, $outFile = false, $revision = null, $allow_resume = false) { 488 // Only allow php response format for this call 489 if ($this->responseFormat !== 'php') { 490 throw new Exception('This method only supports the `php` response format'); 491 } 492 493 $handle = null; 494 if ($outFile !== false) { 495 // Create a file handle if $outFile is specified 496 if ($allow_resume && file_exists($outFile)) { 497 if (!$handle = fopen($outFile, 'a')) { 498 throw new Exception("Unable to open file handle for $outFile"); 499 } else { 500 $this->OAuth->setOutFile($handle); 501 $params['headers'] = array('Range: bytes='.filesize($outFile).'-'); 502 } 503 } 504 elseif (!$handle = fopen($outFile, 'w')) { 505 throw new Exception("Unable to open file handle for $outFile"); 506 } else { 507 $this->OAuth->setOutFile($handle); 508 } 509 } 510 511 $file = $this->encodePath($file); 512 $call = 'files/download'; 513 $params = array('path' => '/' . $file, 'api_v2' => true, 'content_download' => true); 514 $response = $this->fetch('GET', self::CONTENT_URL_V2, $call, $params); 515 516 // Close the file handle if one was opened 517 if ($handle) fclose($handle); 518 519 return array( 520 'name' => ($outFile) ? $outFile : basename($file), 521 'mime' => $this->getMimeType(($outFile) ? $outFile : $response['body'], $outFile), 522 'meta' => json_decode($response['headers']['dropbox-api-result']), 523 'data' => $response['body'], 524 ); 525 } 621 526 622 527 /** … … 659 564 return $this->normalisePath($path); 660 565 } 566 567 public function metaData($path = null, $rev = null, $limit = 10000, $hash = false, $list = true, $deleted = false) { 568 $call = '2/files/get_metadata' ; 569 $params = array( 570 'path' => '/' . $this->normalisePath($path), 571 'api_v2' => true 572 ); 573 574 return $this->fetch('POST', self::API_URL_V2, $call, $params); 575 } 576 577 public function putFile($file, $path = '', $overwrite = true) { 578 if (!file_exists($file)) { 579 // Throw an Exception if the file does not exist 580 throw new Exception('Local file ' . $file . ' does not exist'); 581 } 582 $filesize = iwp_mmb_get_file_size($file); 583 if ($filesize >= 157286400) { 584 $output = $this->chunked_upload_single_call_new($file, $path,$overwrite); 585 return $output; 586 587 }else{ 588 $handle = @fopen($file, 'r'); 589 //Set the file content to $this->InFile 590 $this->OAuth->setInFile(fread($handle, filesize($file))); 591 fclose($handle); 592 593 $filename = (is_string($filename)) ? $filename : basename($file); 594 $path = '/' . $this->encodePath($path .'/'. $filename); 595 $params = array( 596 'path' => $path, 597 'mute' => true, 598 'mode' => 'overwrite', 599 'api_v2' => true, 600 'content_upload' => true 601 ); 602 $response = $this->fetch('POST', self::CONTENT_URL_V2, 'files/upload', $params); 603 return $response; 604 } 605 606 } 607 608 public function chunked_upload_single_call_new($file, $path = '',$overwrite=true){ 609 $file = str_replace("\\", "/",$file); 610 if (!is_readable($file) or !is_file($file)) 611 throw new Exception("Error: File \"$file\" is not readable or doesn't exist."); 612 $file_handle=fopen($file,'r'); 613 $uploadID=null; 614 $offset=0; 615 $ProgressFunction=null; 616 while ($data=fread($file_handle, (1024*1024*30))) { //1024*1024*30 = 30MB 617 $firstCommit = (0 == $offset); 618 iwp_mmb_auto_print('dropbox_chucked_upload'); 619 $this->OAuth->setInFile($data); 620 621 if ($firstCommit) { 622 $params = array( 623 'close' => false, 624 'api_v2' => true, 625 'content_upload' => true 626 ); 627 $response = $this->fetch('POST', self::CONTENT_URL_V2, 'files/upload_session/start', $params); 628 $firstCommit = false; 629 630 } else { 631 $params = array( 632 'cursor' => array( 633 'session_id' => $uploadID, 634 // If you send it as a string, Dropbox will be unhappy 635 'offset' => (int)$offset 636 ), 637 'api_v2' => true, 638 'content_upload' => true 639 ); 640 $response = $this->append_upload($params, false); 641 } 642 643 // On subsequent chunks, use the upload ID returned by the previous request 644 if (isset($response['body']->session_id)) { 645 $uploadID = $response['body']->session_id; 646 } 647 648 /* 649 API v2 no longer returns the offset, we need to manually work this out. So check that there are no errors and update the offset as well as calling the callback method. 650 */ 651 if (!isset($response['body']->error)) { 652 $offset = ftell($file_handle); 653 $output['response']= $response; 654 if($isCommit ==false){ 655 656 $output['offset']= $offset; 657 $output['upload_id']= $uploadID; 658 } 659 $this->OAuth->setInFile(null); 660 } 661 fseek($file_handle, $offset); 662 } 663 fclose($file_handle); 664 $filename = (is_string($filename)) ? $filename : basename($file); 665 $params = array( 666 'cursor' => array( 667 'session_id' => $uploadID, 668 'offset' => (int)$offset 669 ), 670 'commit' => array( 671 'path' => '/' . $this->encodePath($path .'/'. $filename), 672 'mode' => 'overwrite' 673 ), 674 'api_v2' => true, 675 'content_upload' => true 676 ); 677 $response = $this->append_upload($params, true); 678 679 return $response; 680 } 661 681 } -
iwp-client/trunk/lib/Dropbox2/OAuth/Consumer/ConsumerAbstract.php
r1851728 r2678176 21 21 // The next endpoint only exists with APIv1 22 22 const OAUTH_UPGRADE = 'oauth2/token_from_oauth1'; 23 24 private $scopes = array( 25 'account_info.read', 26 'files.content.write', 27 'files.content.read', 28 'files.metadata.read', 29 ); 23 30 24 31 /** … … 27 34 */ 28 35 private $sigMethod = 'PLAINTEXT'; 29 30 private $token = null;31 36 32 37 /** … … 57 62 $this->upgradeOAuth(); 58 63 $iwp_backup_core->log('OAuth token upgrade successful'); 64 } 65 66 if (!empty($access_token) && isset($access_token->refresh_token) && isset($access_token->expires_in)) { 67 if ($access_token->expires_in < time()) $this->refreshAccessToken(); 59 68 } 60 69 … … 84 93 { 85 94 // N.B. This call only exists under API v1 - i.e. there is no APIv2 equivalent. Hence the APIv1 endpoint (API_URL) is used, and not the v2 (API_URL_V2) 86 $url = IWP_MMB_Dropbox_API::API_URL. self::OAUTH_UPGRADE;95 $url = 'https://api.dropbox.com/1/' . self::OAUTH_UPGRADE; 87 96 $response = $this->fetch('POST', $url, ''); 88 97 $token = new stdClass(); … … 127 136 $this->storage->do_unset('access_token'); 128 137 throw new Dropbox_Exception(sprintf(__('You need to re-authenticate with %s, as your existing credentials are not working.', 'InfiniteWP'), 'Dropbox')); 129 130 138 return false; 131 }132 133 public function setToken($token)134 {135 136 $this->token = $token;137 138 return $this;139 139 } 140 140 … … 151 151 152 152 global $iwp_backup_core; 153 if (!function_exists('crypt_random_string')) $iwp_backup_core->ensure_phpseclib('Crypt_Random' , 'Crypt/Random');153 if (!function_exists('crypt_random_string')) $iwp_backup_core->ensure_phpseclib('Crypt_Random'); 154 154 155 155 $CSRF = base64_encode(crypt_random_string(16)); 156 156 $this->storage->set($CSRF,'CSRF'); 157 157 // Prepare request parameters 158 /* 159 For OAuth v2 Dropbox needs to use a authorisation url that matches one that is set inside the 160 Dropbox developer console. In order to check this it needs the client ID for the OAuth v2 app 161 This will use the default one unless the user is using their own Dropbox App 162 163 Check if the key has dropbox: if so then remove it to stop the request from being invalid 164 */ 158 165 $appkey = $this->storage->get('appkey'); 159 166 … … 163 170 $key = $appkey; 164 171 } 172 173 if ('' != $this->instance_id) $this->instance_id = ':'.$this->instance_id; 165 174 166 175 $params = array( … … 168 177 'response_type' => 'code', 169 178 'redirect_uri' => empty($key) ? $this->callback : $this->callbackhome, 170 'state' => empty($key) ? $CSRF.$this->callbackhome : $CSRF, 179 'state' => empty($key) ? "POST:".$CSRF.$this->instance_id.$this->callbackhome : $CSRF.$this->instance_id, 180 'scope' => implode(' ', $this->scopes), 181 'token_access_type' => 'offline' 171 182 ); 172 183 … … 217 228 } else { 218 229 $code = base64_decode($code); 219 $code = json_decode($code, true); 230 $code = json_decode($code, true); 220 231 } 221 232 … … 227 238 after more testing token secret can be removed. 228 239 */ 229 230 240 $token = new stdClass(); 231 241 $token->oauth_token_secret = $code['access_token']; … … 234 244 $token->token_type = $code['token_type']; 235 245 $token->uid = $code['uid']; 246 $token->refresh_token = $code['refresh_token']; 247 $token->expires_in = time() + $code['expires_in'] - 30; 236 248 $this->storage->set($token, 'access_token'); 237 249 $this->storage->do_unset('upgraded'); … … 243 255 } 244 256 } 257 258 /** 259 * This function will make a request to the auth server sending the users refresh token to get a new access token 260 * 261 * @return void 262 */ 263 public function refreshAccessToken() { 264 global $iwp_backup_core; 265 266 $access_token = $this->storage->get('access_token'); 267 268 $params = array( 269 'grant_type' => 'refresh_token', 270 'refresh_token' => $access_token->refresh_token, 271 ); 272 273 $url = IWP_MMB_Dropbox_API::API_URL_V2 . self::ACCESS_TOKEN_METHOD; 274 275 $response = $this->fetch('POST', $url, '' , $params); 276 277 if ("200" != $response['code']) { 278 $iwp_backup_core->log('Failed to refresh access token error code: '.$response['code']); 279 return; 280 } 281 282 if (empty($response['body'])) { 283 $iwp_backup_core->log('Failed to refresh access token empty response body'); 284 return; 285 } 286 287 $body = $response['body']; 288 289 if (isset($body->access_token) && isset($body->expires_in)) { 290 $access_token->oauth_token_secret = $body->access_token; 291 $access_token->oauth_token = $body->access_token; 292 $access_token->expires_in = time() + $body->expires_in - 30; 293 $this->storage->set($access_token, 'access_token'); 294 $iwp_backup_core->log('Successfully updated and refreshed the access token'); 295 } else { 296 $iwp_backup_core->log('Failed to refresh access token missing token and expiry: '.json_encode($body)); 297 return; 298 } 299 } 245 300 246 301 /** … … 251 306 * @return object stdClass 252 307 */ 253 public function getToken() 254 { 255 return $this->token; 256 } 308 private function getToken() 309 { 310 if (!$token = $this->storage->get('access_token')) { 311 if (!$token = $this->storage->get('request_token')) { 312 $token = new stdClass(); 313 $token->oauth_token = null; 314 $token->oauth_token_secret = null; 315 } 316 } 317 return $token; 318 } 319 257 320 /** 258 321 * Generate signed request URL … … 271 334 272 335 // Prepare the standard request parameters differently for OAuth1 and OAuth2; we still need OAuth1 to make the request to the upgrade token endpoint 273 if (!empty($token)) { 274 $params = array( 275 'access_token' => $token, 276 ); 336 if (isset($token)) { 337 if (isset($token->oauth_token)) { 338 $params = array( 339 'access_token' => $token->oauth_token, 340 ); 341 }else{ 342 $params = array( 343 'access_token' => $token, 344 ); 345 } 277 346 278 347 /* … … 280 349 */ 281 350 282 if (isset($additional['api_v2']) && $additional['api_v2'] == true) { 283 unset($additional['api_v2']); 351 if (isset($additional['api_v2']) && $additional['api_v2'] == true && !isset($additional['refresh_token'])) { 352 unset($additional['api_v2']); 353 if (isset($additional['timeout'])) unset($additional['timeout']); 284 354 if (isset($additional['content_download']) && $additional['content_download'] == true) { 285 355 unset($additional['content_download']); 356 $extra_headers = array(); 357 if (isset($additional['headers'])) { 358 foreach ($additional['headers'] as $key => $header) { 359 $extra_headers[] = $header; 360 } 361 unset($additional['headers']); 362 } 286 363 $headers = array( 287 364 'Authorization: Bearer '.$params['access_token'], … … 289 366 'Dropbox-API-Arg: '.json_encode($additional), 290 367 ); 368 369 $headers = array_merge($headers, $extra_headers); 291 370 $additional = ''; 292 371 } else if (isset($additional['content_upload']) && $additional['content_upload'] == true) { … … 309 388 'headers' => $headers, 310 389 ); 390 } elseif (isset($additional['refresh_token'])) { 391 $extra_headers = array(); 392 if (isset($additional['headers']) && !empty($additional['headers'])) { 393 foreach ($additional['headers'] as $key => $header) { 394 $extra_headers[] = $key.': '.$header; 395 } 396 unset($additional['headers']); 397 } 398 $headers = array(); 399 $headers[] = 'Authorization: Basic ' . base64_encode($this->consumerKey . ':' . $this->consumerSecret); 400 // $headers[] = 'Content-Type: application/x-www-form-urlencoded'; 401 // $headers[] = 'Content-Type: application/json'; 402 $headers = array_merge($headers, $extra_headers); 403 404 return array( 405 'url' => $url . $call, 406 'postfields' => $additional, 407 'headers' => $headers, 408 ); 311 409 } 312 410 } else { -
iwp-client/trunk/lib/Dropbox2/OAuth/Consumer/Curl.php
r2128300 r2678176 36 36 * @param string $callback 37 37 */ 38 public function __construct($key, $oauth2_id, $secret, Dropbox_StorageInterface $storage, $callback = null, $callbackhome = null, $deauthenticate = false )38 public function __construct($key, $oauth2_id, $secret, Dropbox_StorageInterface $storage, $callback = null, $callbackhome = null, $deauthenticate = false, $instance_id = '', $old_auth = false) 39 39 { 40 40 // Check the cURL extension is loaded … … 49 49 $this->callback = $callback; 50 50 $this->callbackhome = $callbackhome; 51 52 // if ($deauthenticate) { 53 // $this->deauthenticate(); 54 // } else { 55 // $this->authenticate(); 56 // } 51 $this->instance_id = $instance_id; 52 53 if ($old_auth == false) { 54 if ($deauthenticate) { 55 $this->deauthenticate(); 56 } else { 57 $this->authenticate(); 58 } 59 } 57 60 } 58 61 … … 66 69 * @return string|object stdClass 67 70 */ 68 public function fetch($method, $url, $call, array $additional = array() )71 public function fetch($method, $url, $call, array $additional = array(), $retry_with_header = false) 69 72 { 70 73 // Get the signed request URL 71 74 $request = $this->getSignedRequest($method, $url, $call, $additional); 72 75 73 76 // Initialise and execute a cURL request 74 77 $handle = curl_init($request['url']); … … 105 108 } 106 109 } 107 108 // if (isset($request['headers'])) $options[CURLOPT_HTTPHEADER] = $request['headers'];109 110 110 111 /* … … 120 121 } 121 122 } 123 122 124 if (isset($request['headers']) && !empty($request['headers'])) $options[CURLOPT_HTTPHEADER] = $request['headers']; 123 125 … … 142 144 } elseif ($method == 'POST') { // POST 143 145 $options[CURLOPT_POST] = true; 144 $options[CURLOPT_POSTFIELDS] = $request['postfields']; 146 if (!empty($request['postfields'])) { 147 $options[CURLOPT_POSTFIELDS] = $request['postfields']; 148 } elseif (empty($additional['content_upload'])) { 149 // JSON representation of nullity 150 $options[CURLOPT_POSTFIELDS] = 'null'; 151 } elseif ($retry_with_header) { 152 // It's a content upload, and there's no data. Versions of php-curl differ as to whether they add a Content-Length header automatically or not. Dropbox complains if it's not there. Here we have had a Dropbox 400 bad request returned so we try again with the header 153 $options[CURLOPT_HTTPHEADER] = array_merge($options[CURLOPT_HTTPHEADER], array('Content-Length: 0')); 154 } 145 155 } elseif ($method == 'PUT' && $this->inFile) { // PUT 146 156 $options[CURLOPT_PUT] = true; … … 152 162 } 153 163 164 if (isset($additional['timeout'])) { 165 $options[CURLOPT_TIMEOUT] = $additional['timeout']; 166 } 167 154 168 // Set the cURL options at once 155 169 curl_setopt_array($handle, $options); … … 168 182 if (is_string($response)) { 169 183 $response = $this->parse($response); 170 $response['code'] = (!empty($response['code'])) ? $response['code'] : $getinfo['http_code'];171 184 } 172 185 … … 192 205 $message = json_encode($array); 193 206 } elseif (strpos($array[0] , 'lookup_failed') !== false ) { 194 // re-structure the array so it is correctly formatted for API195 // Note: Dropbox v2 returns different errors at different stages hence this fix207 // re-structure the array so it is correctly formatted for API 208 // Note: Dropbox v2 returns different errors at different stages hence this fix 196 209 $correctOffset = array( 197 210 '0' => $array[1]->{'.tag'}, 198 '1' => $array[1]->correct_offset199 211 ); 212 // the lookup_failed response doesn't always return a correct_offset this happens when the lookup fails because the session has been closed e.g the file has already been uploaded but the response didn't make it back to the client so we try again 213 if (isset($array[1]->correct_offset)) $correctOffset['1'] = $array[1]->correct_offset; 200 214 201 215 $message = json_encode($correctOffset); … … 217 231 throw new Dropbox_NotModifiedException($message, 304); 218 232 case 400: 233 if (!$retry_with_header) return $this->fetch($method, $url, $call, $additional, true); 219 234 throw new Dropbox_BadRequestException($message, 400); 220 235 case 404: … … 225 240 throw new Dropbox_UnsupportedMediaTypeException($message, 415); 226 241 case 401: 227 228 242 //401 means oauth token is expired continue to manually handle the exception depending on the situation 243 break; 229 244 case 409: 230 245 //409 in API V2 every error will return with a 409 to find out what the error is the error description should be checked. … … 254 269 // If the status code is 100, the API server must send a final response 255 270 // We need to explode the response again to get the actual response 256 if (preg_match('#^HTTP/ 1.1100#i', $lines[0])) {271 if (preg_match('#^HTTP/[\.\d]+ 100#i', $lines[0])) { 257 272 list($headers, $response) = explode("\r\n\r\n", $response, 2); 258 273 $lines = explode("\r\n", $headers); … … 261 276 // Get the HTTP response code from the first line 262 277 $first = array_shift($lines); 263 $pattern = '#^HTTP/ 1.1([0-9]{3})#i';278 $pattern = '#^HTTP/[\.\d]+ ([0-9]{3})#i'; 264 279 preg_match($pattern, $first, $matches); 265 280 $code = $matches[1]; … … 280 295 if (is_string($body)) { 281 296 $body_lines = explode("\r\n", $body); 282 if (preg_match('#^HTTP/ 1.1 100#i', $body_lines[0]) && preg_match('#^HTTP/1.#i', $body_lines[2])) {297 if (preg_match('#^HTTP/[\.\d]+ 100#i', $body_lines[0]) && preg_match('#^HTTP/\d#i', $body_lines[2])) { 283 298 return $this->parse($body); 284 299 } -
iwp-client/trunk/lib/Dropbox2/OAuth/Consumer/WordPress.php
r1851728 r2678176 3 3 /** 4 4 * OAuth consumer using the WordPress API 5 * @author David Anderson <[email protected]>6 5 * @link https://github.com/DavidAnderson684/Dropbox 7 6 * @package Dropbox\OAuth -
iwp-client/trunk/lib/Dropbox2/OAuth/Storage/Encrypter.php
r1851728 r2678176 9 9 * @subpackage Storage 10 10 */ 11 12 /*13 Using this was fairly pointless (it encrypts storage credentials at rest). But, it's implemented now, so needs supporting.14 Investigation shows that mcrypt and phpseclib native encryption using different padding schemes.15 As a result, that which is encrypted by phpseclib native can be decrypted by mcrypt, but not vice-versa. Each can (as you'd expect) decrypt the results of their own encryption.16 As a consequence, it makes sense to always encrypt with phpseclib native, and prefer decrypting with with mcrypt if it is available and otherwise fall back to phpseclib.17 We could deliberately re-encrypt all loaded information with phpseclib native, but there seems little need for that yet. There can only be a problem if mcrypt is disabled - which pre-July-2015 meant that Dropbox wouldn't work at all. Now, it will force a re-authorisation.18 */19 11 20 12 class Dropbox_Encrypter … … 58 50 59 51 // Encryption: we always use phpseclib for this 52 global $iwp_backup_core; 53 $ensure_phpseclib = $iwp_backup_core->ensure_phpseclib('Crypt_AES'); 54 55 if (is_wp_error($ensure_phpseclib)) { 56 $iwp_backup_core->log("Failed to load phpseclib classes (".$ensure_phpseclib->get_error_code()."): ".$ensure_phpseclib->get_error_message()); 57 $iwp_backup_core->log("Failed to load phpseclib classes (".$ensure_phpseclib->get_error_code()."): ".$ensure_phpseclib->get_error_message(), 'error'); 58 return false; 59 } 60 61 $iwp_backup_core->ensure_phpseclib('Crypt_Rijndael'); 60 62 61 global $iwp_backup_core; 62 $iwp_backup_core->ensure_phpseclib('Crypt_AES', 'Crypt/AES'); 63 $iwp_backup_core->ensure_phpseclib('Crypt_Rijndael', 'Crypt/Rijndael'); 64 65 if (!function_exists('crypt_random_string')) require_once($GLOBALS['iwp_mmb_plugin_dir'].'/vendor/phpseclib/phpseclib/phpseclib/Crypt/Random.php'); 63 if (!function_exists('crypt_random_string')) require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/phpseclib/phpseclib/phpseclib/Crypt/Random.php'); 66 64 67 65 $iv = crypt_random_string(self::IV_SIZE); … … 94 92 95 93 if (function_exists('mcrypt_decrypt')) { 94 // @codingStandardsIgnoreLine 96 95 $token = @mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $this->key, $cipherText, MCRYPT_MODE_CBC, $iv); 97 96 } else { 98 97 global $iwp_backup_core; 99 $iwp_backup_core->ensure_phpseclib('Crypt_Rijndael' , 'Crypt/Rijndael');98 $iwp_backup_core->ensure_phpseclib('Crypt_Rijndael'); 100 99 101 100 $rijndael = new Crypt_Rijndael(); -
iwp-client/trunk/lib/Dropbox2/OAuth/Storage/WordPress.php
r2548691 r2678176 5 5 * This can only be used if you have a WordPress environment loaded, such that the (get|update|delete)_option functions are available 6 6 * See an example usage in http://wordpress.org/extend/plugins/updraftplus 7 * @author David Anderson <[email protected]>8 * @link https://updraftplus.com9 7 * @package Dropbox\Oauth 10 8 * @subpackage Storage … … 47 45 } 48 46 49 if ($backup_module_object instanceof IWP_MMB_UploadModule) { 50 $this->backup_module_object = $backup_module_object; 51 } 47 $this->backup_module_object = $backup_module_object; 52 48 53 49 $this->option_name_prefix = $option_name_prefix; … … 71 67 if (!empty($opts[$this->option_name_prefix.$type])) { 72 68 $gettoken = $opts[$this->option_name_prefix.$type]; 73 $token = $gettoken; 69 if (!empty($opts['email'])) { 70 $token = $this->decrypt($gettoken); 71 }else{ 72 $token = $gettoken; 73 } 74 74 return $token; 75 75 } … … 100 100 101 101 if ($type == 'access_token'){ 102 $token = $this->encrypt($token); 102 if (!empty($opts['email'])) { 103 $token = $this->encrypt($token); 104 } 103 105 $opts[$this->option_name_prefix.$type] = $token; 104 106 } else if ($type == 'request_token' ) { -
iwp-client/trunk/lib/sftp.php
r2548691 r2678176 336 336 } 337 337 338 // Ensure phpseclib Crypt_Blowfish is loaded, over PEAR's 339 $iwp_backup_core->ensure_phpseclib('Crypt_Blowfish', 'Crypt/Blowfish'); 338 340 if (!$this->ssh->login($user, $pass)) { 339 341 $error_data = null; -
iwp-client/trunk/pclzip.class.php
r2548691 r2678176 3441 3441 3442 3442 // ----- Read the file content 3443 if ($p_header['size'] > 0) { 3443 3444 $v_content = @fread($v_file, $p_header['size']); 3445 }else{ 3446 $v_content = ''; 3447 } 3444 3448 3445 3449 // ----- Close the file -
iwp-client/trunk/plugin.compatibility.class.php
r1851728 r2678176 140 140 } 141 141 142 public function fix PantheonGlobals()142 public function fixGlobals() 143 143 { 144 if (! empty($_ENV['PANTHEON_ENVIRONMENT']) && !isset($GLOBALS['hook_suffix'])) {144 if (!isset($GLOBALS['hook_suffix'])) { 145 145 $GLOBALS['hook_suffix'] = null; 146 146 } -
iwp-client/trunk/readme.txt
r2548706 r2678176 1 1 === InfiniteWP Client === 2 Contributors: infinitewp 2 Contributors: infinitewp, amritanandh, rajkuppus 3 3 Tags: admin, administration, amazon, api, authentication, automatic, dashboard, dropbox, events, integration, manage, multisite, multiple, notification, performance, s3, security, seo, stats, tracking, infinitewp, updates, backup, restore, iwp, infinite 4 4 Requires at least: 3.1 5 Tested up to: 5. 7.25 Tested up to: 5.9 6 6 Stable tag: trunk 7 7 … … 48 48 49 49 == Changelog == 50 51 = 1.9.6 - Feb 14th 2022 = 52 * Feature: Added support for Litespeed Cache. 53 * Improvement: Ensure phpseclib Crypt_Blowfish is loaded over PEAR’s version. 54 * Improvement: Enabled support for new Dropbox OAuth Authentication. 55 * Fix: Enabled version number for InfiniteWP MU plugin loader. 56 * Fix: Undefined array key “hook_suffix” warning. 57 * Fix: Delete SFTP test backup file on the remote server. 58 * Fix: PPL addon editor image not uploaded. (issue happening from 1.9.4.9). 59 * Fix: Fatal error while backing up a 0kb file using the single call method on site installed on site with php8 server. 50 60 51 61 = 1.9.4.11 - Jun 16th 2021 =
Note: See TracChangeset
for help on using the changeset viewer.