InfiniteWP Client - Version 1.4.1

Version Description

  • Fix: Branding should take effect which we lost in v1.4.0 without making any changes.
Download this release

Release Info

Developer infinitewp
Plugin Icon 128x128 InfiniteWP Client
Version 1.4.1
Comparing to
See all releases

Code changes from version 1.3.16 to 1.4.1

addons/wp_optimize/optimize.class.php CHANGED
@@ -11,35 +11,54 @@ class IWP_MMB_Optimize extends IWP_MMB_Core
11
 
12
  function cleanup_system($cleanupType){
13
 
 
 
 
 
14
  if (isset($cleanupType["clean-revisions"])) {
15
- $text .= self::cleanup_type_process('revisions');
 
 
16
  }
17
 
18
  if (isset($cleanupType["clean-autodraft"])) {
19
- $text .= self::cleanup_type_process('autodraft');
 
 
20
  }
21
 
22
  if (isset($cleanupType["clean-comments"])) {
23
- $text .= self::cleanup_type_process('spam');
 
 
24
  }
25
 
26
  if (isset($cleanupType["unapproved-comments"])) {
27
- $text .= self::cleanup_type_process('unapproved');
 
 
28
  }
29
 
 
 
30
  if (isset($cleanupType["optimize-db"])) {
31
- $text .= self::cleanup_type_process('optimize-db');
 
 
32
  //$text .= DB_NAME.__(" Database Optimized!<br>", 'wp-optimize');
33
  }
34
 
35
  if ($text !==''){
36
- return $text;
 
37
  }
38
  }
39
 
40
  function cleanup_type_process($cleanupType){
41
  global $wpdb;
42
  $clean = ""; $message = "";
 
 
43
  $optimized = array();
44
 
45
  switch ($cleanupType) {
@@ -47,7 +66,9 @@ class IWP_MMB_Optimize extends IWP_MMB_Core
47
  case "revisions":
48
  $clean = "DELETE FROM $wpdb->posts WHERE post_type = 'revision'";
49
  $revisions = $wpdb->query( $clean );
50
- $message .= $revisions.__(' post revisions deleted<br>', 'wp-optimize');
 
 
51
 
52
  break;
53
 
@@ -55,34 +76,46 @@ class IWP_MMB_Optimize extends IWP_MMB_Core
55
  case "autodraft":
56
  $clean = "DELETE FROM $wpdb->posts WHERE post_status = 'auto-draft'";
57
  $autodraft = $wpdb->query( $clean );
58
- $message .= $autodraft.__(' auto drafts deleted<br>', 'wp-optimize');
 
 
59
 
60
  break;
61
 
62
  case "spam":
63
  $clean = "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam';";
64
  $comments = $wpdb->query( $clean );
65
- $message .= $comments.__(' spam comments deleted<br>', 'wp-optimize');
 
 
 
66
  break;
67
 
68
  case "unapproved":
69
  $clean = "DELETE FROM $wpdb->comments WHERE comment_approved = '0';";
70
  $comments = $wpdb->query( $clean );
71
- $message .= $comments.__(' unapproved comments deleted<br>', 'wp-optimize');
 
 
 
72
  break;
73
 
74
  case "optimize-db":
75
  self::optimize_tables(true);
76
- $message .= "Database ".DB_NAME." Optimized!<br>";
 
 
77
  break;
78
 
79
  default:
80
- $message .= __('NO Actions Taken<br>', 'wp-optimize');
 
 
81
  break;
82
  } // end of switch
83
 
84
-
85
- return $message;
86
 
87
  } // end of function
88
 
11
 
12
  function cleanup_system($cleanupType){
13
 
14
+ $cleanup_values = array();
15
+ $cleanup_values['value_array'] = array();
16
+ $text = '';
17
+
18
  if (isset($cleanupType["clean-revisions"])) {
19
+ $values = self::cleanup_type_process('revisions');
20
+ $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";
21
+ $cleanup_values['value_array']['revisions'] = $values['value'];
22
  }
23
 
24
  if (isset($cleanupType["clean-autodraft"])) {
25
+ $values = self::cleanup_type_process('autodraft');
26
+ $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";
27
+ $cleanup_values['value_array']['autodraft'] = $values['value'];
28
  }
29
 
30
  if (isset($cleanupType["clean-comments"])) {
31
+ $values = self::cleanup_type_process('spam');
32
+ $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";
33
+ $cleanup_values['value_array']['spam'] = $values['value'];
34
  }
35
 
36
  if (isset($cleanupType["unapproved-comments"])) {
37
+ $values = self::cleanup_type_process('unapproved');
38
+ $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";
39
+ $cleanup_values['value_array']['unapproved'] = $values['value'];
40
  }
41
 
42
+ $text .= '<br>';
43
+
44
  if (isset($cleanupType["optimize-db"])) {
45
+ $values = self::cleanup_type_process('optimize-db');
46
+ $text .= "<span class='wpm_results_db'>" . $values['message'] . "</span>";
47
+ $cleanup_values['value_array']['optimize-db'] = $values['value'];
48
  //$text .= DB_NAME.__(" Database Optimized!<br>", 'wp-optimize');
49
  }
50
 
51
  if ($text !==''){
52
+ $cleanup_values['message'] = $text;
53
+ return $cleanup_values;
54
  }
55
  }
56
 
57
  function cleanup_type_process($cleanupType){
58
  global $wpdb;
59
  $clean = ""; $message = "";
60
+ $message_array = array();
61
+ //$message_array['value'] = array();
62
  $optimized = array();
63
 
64
  switch ($cleanupType) {
66
  case "revisions":
67
  $clean = "DELETE FROM $wpdb->posts WHERE post_type = 'revision'";
68
  $revisions = $wpdb->query( $clean );
69
+ $message .= __('Post revisions deleted - ', 'wp-optimize') . $revisions;
70
+ $message_array['value'] = $revisions;
71
+ //$message_array['del_post_rev']['message'] = $revisions.__(' post revisions deleted<br>', 'wp-optimize');
72
 
73
  break;
74
 
76
  case "autodraft":
77
  $clean = "DELETE FROM $wpdb->posts WHERE post_status = 'auto-draft'";
78
  $autodraft = $wpdb->query( $clean );
79
+ $message .= __('Auto drafts deleted - ', 'wp-optimize') . $autodraft;
80
+ $message_array['value'] = $autodraft;
81
+ //$message_array['del_auto_drafts']['message'] = $autodraft.__(' auto drafts deleted<br>', 'wp-optimize');
82
 
83
  break;
84
 
85
  case "spam":
86
  $clean = "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam';";
87
  $comments = $wpdb->query( $clean );
88
+ $message .= __('Spam comments deleted - ', 'wp-optimize') . $comments;
89
+ $message_array['value'] = $comments;
90
+ //$message_array['del_spam_comments']['message'] = $comments.__(' spam comments deleted<br>', 'wp-optimize');
91
+
92
  break;
93
 
94
  case "unapproved":
95
  $clean = "DELETE FROM $wpdb->comments WHERE comment_approved = '0';";
96
  $comments = $wpdb->query( $clean );
97
+ $message .= __('Unapproved comments deleted - ', 'wp-optimize') . $comments;
98
+ $message_array['value'] = $comments;
99
+ //$message_array['del_unapproved_comments']['message'] = $comments.__(' unapproved comments deleted<br>', 'wp-optimize');
100
+
101
  break;
102
 
103
  case "optimize-db":
104
  self::optimize_tables(true);
105
+ $message .= "Database ".DB_NAME." Optimized!";
106
+ $message_array['value'] = DB_NAME;
107
+
108
  break;
109
 
110
  default:
111
+ $message .= __('NO Actions Taken', 'wp-optimize');
112
+ $message_array['value'] = $comments;
113
+
114
  break;
115
  } // end of switch
116
 
117
+ $message_array['message'] = $message;
118
+ return $message_array;
119
 
120
  } // end of function
121
 
backup.class.multicall.php CHANGED
@@ -305,7 +305,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
305
  $backup_file_info['backup_file'] = $backup_file;
306
  $backup_file_info['backup_url'] = $backup_url;
307
 
308
- if(!($account_info))
309
  {
310
  $account_info = array();
311
  }
@@ -345,7 +345,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
345
  $backup_file = $responseParams['response_data']['backup_file'];
346
 
347
  //storing the filesize value into settings array - first get the values and then append the value of filesize to it
348
- $this -> backup_settings_vals = get_option('iwp_client_multi_backup_temp_values', $backup_settings_values);
349
  $backup_settings_values = $this -> backup_settings_vals;
350
  $backup_settings_values['actual_file_size'] = iwp_mmb_get_file_size($backup_file);
351
  update_option('iwp_client_multi_backup_temp_values', $backup_settings_values);
@@ -356,8 +356,17 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
356
  $ftp_result = $this->ftp_backup($historyID, $account_info['iwp_ftp']);
357
  if(!$ftp_result)
358
  {
 
 
 
359
  return array('error' => "Unexpected Error", 'error_code' => "unexpected_error");
360
  }
 
 
 
 
 
 
361
  else
362
  {
363
  return $ftp_result;
@@ -369,14 +378,15 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
369
  iwp_mmb_print_flush('Amazon S3 upload: Start');
370
  $amazons3_result = $this->amazons3_backup($historyID,$account_info['iwp_amazon_s3']);
371
  iwp_mmb_print_flush('Amazon S3 upload: End');
372
- if($amazons3_result['status'] == 'partiallyCompleted') //darkCode true loop
373
- {
374
- return $amazons3_result;
375
- }
376
- if ($amazons3_result !== true && $del_host_file) {
377
- //@unlink($backup_file);
378
  }
379
  if (is_array($amazons3_result) && isset($amazons3_result['error'])) {
 
 
 
 
380
  return $amazons3_result;
381
  }
382
  return $amazons3_result;
@@ -389,6 +399,15 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
389
  $gdrive_result = $this->google_drive_backup($historyID, $account_info['iwp_gdrive']);
390
  iwp_mmb_print_flush('google Drive upload: End');
391
 
 
 
 
 
 
 
 
 
 
392
  return $gdrive_result;
393
 
394
  }
@@ -399,23 +418,21 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
399
  $account_info['iwp_dropbox']['backup_file'] = $backup_file;
400
  iwp_mmb_print_flush('Dropbox upload: Start');
401
  $dropbox_result = $this->dropbox_backup($historyID, $account_info['iwp_dropbox']);
402
- if($dropbox_result['status'] == 'partiallyCompleted')
403
- {
404
- return $dropbox_result;
405
- }
406
  iwp_mmb_print_flush('Dropbox upload: End');
407
- if ($dropbox_result !== true && $del_host_file) {
408
- //@unlink($backup_file);
 
409
  }
410
 
411
  if (is_array($dropbox_result) && isset($dropbox_result['error'])) {
 
 
 
 
412
  return $dropbox_result;
413
  }
414
 
415
-
416
-
417
  $this->wpdb_reconnect();
418
-
419
  return $dropbox_result;
420
  }
421
 
@@ -426,6 +443,19 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
426
 
427
  }
428
 
 
 
 
 
 
 
 
 
 
 
 
 
 
429
  function backupDB($historyID,$backup_file,$account_info = array())
430
  {
431
  $this->statusLog($historyID, array('stage' => 'backupDB', 'status' => 'processing', 'statusMsg' => 'backupDBInitiated'));
@@ -540,7 +570,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
540
  function backupDBPHP($historyID) //file must be db name alone ; $response_array should be table_name and its fields and callCount
541
  {
542
  //getting the settings first
543
- $this -> backup_settings_vals = get_option('iwp_client_multi_backup_temp_values', $backup_settings_values);
544
  $backup_settings_values = $this -> backup_settings_vals;
545
 
546
  //$file_block_size = $backup_settings_values['file_block_size'];
@@ -870,6 +900,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
870
  $include = $requestParams['args']['include'];
871
  $exclude_extensions = $requestParams['args']['exclude_extensions'];
872
  $exclude_file_size = $requestParams['args']['exclude_file_size'];
 
873
  if(empty($exclude_extensions))
874
  {
875
  $exclude_extensions = array();
@@ -889,6 +920,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
889
  $this->statusLog($this -> hisID, array('stage' => 'backupFiles', 'status' => 'processing', 'statusMsg' => 'backupFilesInitiated'));
890
  }
891
  $backup_url = $this -> backup_url;
 
892
  if($backup_file == '')
893
  {
894
  $responseParams = $this -> getRequiredData($this -> hisID, "responseParams");
@@ -985,7 +1017,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
985
  }
986
 
987
  //Include root files
988
- if ($handle = opendir(ABSPATH)) {
989
  while (false !== ($file = readdir($handle))) {
990
  if ($file != "." && $file != ".." && !is_dir($file) && file_exists(ABSPATH . $file)) {
991
  $include_data[] = ABSPATH . $file;
@@ -1038,7 +1070,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1038
  $files_excluded_by_size = array();
1039
  $start34 = microtime(true);
1040
  //get the backup settings values from options table
1041
- $this -> backup_settings_vals = get_option('iwp_client_multi_backup_temp_values', $backup_settings_values);
1042
  $backup_settings_values = $this -> backup_settings_vals;
1043
  //$file_block_size = $backup_settings_values['file_block_size'];
1044
  //$is_compressed = $backup_settings_values['is_compressed'];
@@ -1051,10 +1083,11 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1051
  $is_compressed = $requestParams['args']['is_compressed'];
1052
  $file_loop_break_time = $requestParams['args']['file_loop_break_time'];
1053
  $task_name = $requestParams['args']['backup_name'];
1054
- $exclude_file_size = $requestParams['args']['exclude_file_size'];
 
1055
  $zip_split_size = $requestParams['args']['zip_split_size'];
1056
 
1057
- if($backup_settings_values['dbFileHashValue'][$historyID])
1058
  {
1059
  $dbFileHashValue = $backup_settings_values['dbFileHashValue'][$historyID];
1060
  }
@@ -1070,17 +1103,17 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1070
  return $this->statusLog($this -> hisID, array('stage' => 'backupFiles', 'status' => 'error', 'statusMsg' => 'Backup of files failed - Error while fetching table data', 'statusCode' => 'backup_of_files_failed_error_while_fetching_table_data'));
1071
  }
1072
 
1073
- $include_data = $responseParams['response_data']['include_data'];
1074
- $exclude_data = $responseParams['response_data']['exclude_data'];
1075
  $backup_file = $responseParams['response_data']['backup_file'];
1076
  $backup_url = $responseParams['response_data']['backup_url'];
1077
- $nextCount = $responseParams['response_data']['nextCount'];
1078
  $account_info = $responseParams['response_data']['account_info'];
1079
- $files_with_error = $responseParams['response_data']['files_with_error'];
1080
- $files_excluded_by_size = $responseParams['response_data']['files_excluded_by_size'];
1081
- $p_filedescr_list = $responseParams['response_data']['p_filedescr_list'];
1082
- $zip_split_part = $responseParams['response_data']['zip_split_part'];
1083
- $is_new_zip = $responseParams['response_data']['is_new_zip'];
1084
  /* if(empty($zip_split_part))
1085
  {
1086
  $zip_split_part = 1;
@@ -1103,15 +1136,15 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1103
  $zip_split_part = 0;
1104
  }
1105
 
1106
- if(!$p_filedescr_list)
1107
  {
1108
  $p_filedescr_list = array();
1109
  }
1110
- if(!$files_with_error)
1111
  {
1112
  $files_with_error = array();
1113
  }
1114
- if(!$files_excluded_by_size)
1115
  {
1116
  $files_excluded_by_size = array();
1117
  }
@@ -1503,6 +1536,25 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1503
  }
1504
  }
1505
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1506
  function get_total_files_size($backup_files)
1507
  {
1508
  if(is_array($backup_files))
@@ -1538,6 +1590,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1538
  $file_loop_break_time = $requestParams['args']['file_loop_break_time'];
1539
  $task_name = $requestParams['args']['backup_name'];
1540
  $exclude_file_size = $requestParams['args']['exclude_file_size'];
 
1541
  $zip_split_size = $requestParams['args']['zip_split_size'];
1542
 
1543
  if($backup_settings_values['dbFileHashValue'][$historyID])
@@ -2186,41 +2239,6 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
2186
  }
2187
 
2188
 
2189
- function get_all_tasks_mine(){
2190
-
2191
- global $wpdb;
2192
-
2193
- $stats = array();
2194
- $table_name = $wpdb->base_prefix . "iwp_backup_status";
2195
-
2196
- $rows = $wpdb->get_results("select * from ".$table_name);
2197
-
2198
- $taskRes = array();
2199
-
2200
- foreach($rows as $key => $value){
2201
- $task_results = unserialize($value->taskResults);
2202
-
2203
- //$taskRes['task_results'][] = $task_results['task_results'];
2204
- $taskRes['task_results'][] = $task_results;
2205
-
2206
- }
2207
-
2208
- $rows = $wpdb->get_col("SELECT taskResults FROM ".$table_name);
2209
- $taskResOld = array();
2210
- foreach($rows as $key => $value){
2211
- $task_results = unserialize($value);
2212
- foreach($task_results['task_results'] as $key => $data){
2213
- $taskResOld['task_results'][$key] = $data;
2214
- }
2215
- }
2216
-
2217
- $taskRes = array_merge($taskResOld,$taskRes);
2218
-
2219
-
2220
-
2221
- return $taskRes;
2222
- }
2223
-
2224
  function get_this_tasks(){
2225
  $this->wpdb_reconnect();
2226
 
@@ -2294,7 +2312,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
2294
  }
2295
  else if((isset($statusArray['responseParams']))||(isset($statusArray['task_result'])))
2296
  {
2297
- $update = $wpdb->update($wpdb->base_prefix.'iwp_backup_status',array( 'responseParams' => $this->maybe_serialize_compress($statusArray['responseParams']),'stage' => $statusArray['stage'], 'status' => $statusArray['status'],'statusMsg' => $statusArray['statusMsg'],'taskResults' => serialize($statusArray['task_result']) ),array( 'historyID' => $historyID),array('%s','%s', '%s', '%s','%s'),array('%d'));
2298
  }
2299
  else
2300
  {
@@ -2313,7 +2331,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
2313
  $returnParams['backupRowID'] = $insertID;
2314
  $returnParams['stage'] = $statusArray['stage'] ;
2315
  $returnParams['status'] = $statusArray['status'];
2316
- $returnParams['nextFunc'] = $statusArray['nextFunc'];
2317
  return array('success' => $returnParams);
2318
  }
2319
  else
@@ -2353,325 +2371,141 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
2353
  }
2354
 
2355
 
2356
- function task_now($task_name){
2357
-
2358
- $settings = $this->tasks;
2359
- if(!array_key_exists($task_name,$settings)){
2360
- return array('error' => $task_name." does not exist.", 'error_code' => 'task_name_doesnt_exists');
2361
- } else {
2362
- $setting = $settings[$task_name];
2363
- }
2364
-
2365
- $this->set_backup_task(array(
2366
- 'task_name' => $task_name,
2367
- 'args' => $settings[$task_name]['task_args'],
2368
- 'time' => time()
2369
- ));
2370
-
2371
- //Run backup
2372
- $result = $this->backup($setting['task_args'], $task_name);
2373
-
2374
- //Check for error
2375
- if (is_array($result) && array_key_exists('error', $result)) {
2376
- $this->set_backup_task(array(
2377
- 'task_name' => $task_name,
2378
- 'args' => $settings[$task_name]['task_args'],
2379
- 'error' => $result['error']
2380
- ));
2381
- return $result;
2382
- } else {
2383
- return $this->get_backup_stats();
2384
- }
2385
-
2386
- }
2387
 
2388
-
2389
-
2390
- function fail_safe_pcl_files($task_name, $backup_file, $exclude, $include, $fail_safe_files, $disable_comp, $add, $remove){ //Try pclZip
2391
- //$this->back_hack($task_name, 'Files ZIP PCL: Start');
2392
- iwp_mmb_print_flush('Files ZIP PCL: Start');
2393
- if (!isset($archive)) {
2394
- //define('IWP_PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
2395
- //require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
2396
- require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
2397
- $archive = new IWPPclZip($backup_file);
2398
- }
2399
-
2400
- //Include paths
2401
- $include_data = array();
2402
- if (!empty($include) && is_array($include)) {
2403
- foreach ($include as $data) {
2404
- if ($data && file_exists(ABSPATH . $data))
2405
- $include_data[] = ABSPATH . $data . '/';
2406
- }
2407
- }
2408
-
2409
- foreach ($add as $data) {
2410
- if (file_exists(ABSPATH . $data))
2411
- $include_data[] = ABSPATH . $data . '/';
2412
- }
2413
-
2414
- //Include root files
2415
- if ($handle = opendir(ABSPATH)) {
2416
- while (false !== ($file = readdir($handle))) {
2417
- if ($file != "." && $file != ".." && !is_dir($file) && file_exists(ABSPATH . $file)) {
2418
- $include_data[] = ABSPATH . $file;
2419
- }
2420
- }
2421
- closedir($handle);
2422
- }
2423
-
2424
- //exclude paths
2425
- $exclude_data = array();
2426
- if (!empty($exclude) && is_array($exclude)) {
2427
- foreach ($exclude as $data) {
2428
- if (is_dir(ABSPATH . $data))
2429
- $exclude_data[] = $data . '/';
2430
- else
2431
- $exclude_data[] = $data;
2432
- }
2433
- }
2434
-
2435
- foreach ($remove as $rem) {
2436
- $exclude_data[] = $rem . '/';
2437
- }
2438
-
2439
- if($fail_safe_files && $disable_comp){
2440
- $result = $archive->add($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, IWP_PCLZIP_OPT_NO_COMPRESSION, IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
2441
- }
2442
- elseif(!$fail_safe_files && $disable_comp){
2443
- $result = $archive->add($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, IWP_PCLZIP_OPT_NO_COMPRESSION);
2444
- }
2445
- elseif($fail_safe_files && !$disable_comp){
2446
- $result = $archive->add($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data, IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
2447
- }
2448
- else{
2449
- $result = $archive->add($include_data, IWP_PCLZIP_OPT_REMOVE_PATH, ABSPATH, IWP_PCLZIP_OPT_IWP_EXCLUDE, $exclude_data);
2450
- }
2451
-
2452
- iwp_mmb_print_flush('Files ZIP PCL: End');
2453
-
2454
- if (!$result) {
2455
- @unlink($backup_file);
2456
- return array(
2457
- 'error' => 'Failed to zip files. pclZip error (' . $archive->error_code . '): .' . $archive->error_string, 'error_code' => 'failed_to_zip_files_pclZip_error'
2458
- );
2459
- }
2460
- //}
2461
- }
2462
- //Reconnect
2463
- function fail_safe_pcl_db($backup_file,$fail_safe_files,$disable_comp){
2464
- //$this->back_hack($task_name, 'DB ZIP PCL: Start');
2465
- iwp_mmb_print_flush('DB ZIP PCL: Start');
2466
- //define('IWP_PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
2467
- require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
2468
- $archive = new IWPPclZip($backup_file);
2469
-
2470
- if($fail_safe_files && $disable_comp){
2471
- $result_db = $archive->add(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, IWP_PCLZIP_OPT_NO_COMPRESSION, IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
2472
- }
2473
- elseif(!$fail_safe_files && $disable_comp){
2474
- $result_db = $archive->add(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, IWP_PCLZIP_OPT_NO_COMPRESSION);
2475
- }
2476
- elseif($fail_safe_files && !$disable_comp){
2477
- $result_db = $archive->add(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
2478
- }
2479
- else{
2480
- $result_db = $archive->add(IWP_DB_DIR, IWP_PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR);
2481
- }
2482
- //$this->back_hack($task_name, 'DB ZIP PCL: End');
2483
- iwp_mmb_print_flush('DB ZIP PCL: End');
2484
-
2485
- @unlink($db_result);
2486
- @unlink(IWP_BACKUP_DIR.'/iwp_db/index.php');
2487
- @rmdir(IWP_DB_DIR);
2488
-
2489
- if (!$result_db) {
2490
- return array(
2491
- 'error' => 'Failed to zip database. pclZip error (' . $archive->error_code . '): .' . $archive->error_string, 'error_code' => 'failed_to_zip database_pclZip_error'
2492
- );
2493
- }
2494
  }
2495
-
 
2496
  /**
2497
- * Zipping whole site root folder and append to backup file with database dump
2498
- * by ZipArchive class, requires php zip extension.
2499
- *
2500
- * @param string $task_name the name of backup task
2501
- * @param string $backup_file absolute path to zip file
2502
- * @param array $exclude array of files of folders to exclude, relative to site's root
2503
- * @param array $include array of folders from site root which are included to backup (wp-admin, wp-content, wp-includes are default)
2504
- * @return array|bool true if successful or an array with error message if not
2505
- */
2506
- function zip_archive_backup($task_name, $backup_file, $exclude, $include, $overwrite = false) {
 
 
2507
 
2508
- $filelist = $this->get_backup_files($exclude, $include);
2509
- $disable_comp = $this->tasks[$task_name]['task_args']['disable_comp'];
2510
- if (!$disable_comp) {
2511
- $this->_log("Compression is not supported by ZipArchive");
2512
- }
2513
- $zip = new ZipArchive();
2514
- if ($overwrite) {
2515
- $result = $zip->open($backup_file, ZipArchive::OVERWRITE); // Tries to open $backup_file for acrhiving
2516
- } else {
2517
- $result = $zip->open($backup_file); // Tries to open $backup_file for acrhiving
2518
- }
2519
- if ($result === true) {
2520
- foreach ($filelist as $file) {
2521
- iwp_mmb_auto_print('zip_archive_backup');
2522
- $result = $result && $zip->addFile($file, sprintf("%s", str_replace(ABSPATH, '', $file))); // Tries to add a new file to $backup_file
2523
- }
2524
- $result = $result && $zip->close(); // Tries to close $backup_file
2525
- } else {
2526
- $result = false;
2527
- }
2528
- return $result; // true if $backup_file iz zipped successfully, false if error is occurred in zip process
2529
- }
2530
-
2531
-
2532
- /**
2533
- * Gets an array of relative paths of all files in site root recursively.
2534
- * By default, there are all files from root folder, all files from folders wp-admin, wp-content, wp-includes recursively.
2535
- * Parameter $include adds other folders from site root, and excludes any file or folder by relative path to site's root.
2536
- *
2537
- * @param array $exclude array of files of folders to exclude, relative to site's root
2538
- * @param array $include array of folders from site root which are included to backup (wp-admin, wp-content, wp-includes are default)
2539
- * @return array array with all files in site root dir
2540
- */
2541
- function get_backup_files($exclude, $include) {
2542
 
2543
- $add = array(
2544
- trim(WPINC),
2545
- trim(basename(WP_CONTENT_DIR)),
2546
- "wp-admin"
2547
- );
2548
-
2549
- $include = array_merge($add, $include);
2550
-
2551
- $filelist = array();
2552
- if ($handle = opendir(ABSPATH)) {
2553
- while (false !== ($file = readdir($handle))) {
2554
- if (is_dir($file) && file_exists(ABSPATH . $file) && !(in_array($file, $include))) {
2555
- $exclude[] = $file;
2556
- }
2557
- }
2558
- closedir($handle);
2559
- }
2560
-
2561
- $filelist = get_all_files_from_dir(ABSPATH, $exclude);
2562
-
2563
- return $filelist;
2564
- }
2565
 
2566
-
2567
-
2568
-
2569
-
2570
-
2571
-
2572
-
2573
- /**
2574
- * Copies a directory from one location to another via the WordPress Filesystem Abstraction.
2575
- * Assumes that WP_Filesystem() has already been called and setup.
2576
- *
2577
- * @since 2.5.0
2578
- *
2579
- * @param string $from source directory
2580
- * @param string $to destination directory
2581
- * @param array $skip_list a list of files/folders to skip copying
2582
- * @return mixed WP_Error on failure, True on success.
2583
- */
2584
- function iwp_mmb_direct_to_any_copy_dir($from, $to, $skip_list = array() ) {//$from => direct file system, $to => automatic filesystem
2585
- global $wp_filesystem;
2586
-
2587
- $wp_temp_direct = new WP_Filesystem_Direct('');
2588
-
2589
 
2590
- $dirlist = $wp_temp_direct->dirlist($from);
 
2591
 
2592
- $from = trailingslashit($from);
2593
- $to = trailingslashit($to);
 
2594
 
2595
- $skip_regex = '';
2596
- foreach ( (array)$skip_list as $key => $skip_file )
2597
- $skip_regex .= preg_quote($skip_file, '!') . '|';
2598
-
2599
- if ( !empty($skip_regex) )
2600
- $skip_regex = '!(' . rtrim($skip_regex, '|') . ')$!i';
2601
-
2602
- foreach ( (array) $dirlist as $filename => $fileinfo ) {
2603
  if ( !empty($skip_regex) )
2604
- if ( preg_match($skip_regex, $from . $filename) )
2605
- continue;
2606
 
2607
- if ( 'f' == $fileinfo['type'] ) {
2608
- if ( ! $this->iwp_mmb_direct_to_any_copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) {
2609
- // If copy failed, chmod file to 0644 and try again.
2610
- $wp_filesystem->chmod($to . $filename, 0644);
2611
- if ( ! $this->iwp_mmb_direct_to_any_copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) )
2612
- {
2613
- continue;
2614
- return new WP_Error('copy_failed', __('Could not copy file.'), $to . $filename);
2615
- }
2616
- }
2617
- } elseif ( 'd' == $fileinfo['type'] ) {
2618
- if ( !$wp_filesystem->is_dir($to . $filename) ) {
2619
- if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )
2620
- return new WP_Error('mkdir_failed', __('Could not create directory.'), $to . $filename);
 
 
 
 
 
 
 
 
 
2621
  }
2622
- $result = $this->iwp_mmb_direct_to_any_copy_dir($from . $filename, $to . $filename, $skip_list);
2623
- if ( is_wp_error($result) )
2624
- return $result;
2625
  }
 
2626
  }
2627
- return true;
2628
- }
2629
 
2630
- function iwp_mmb_direct_to_any_copy($source, $destination, $overwrite = false, $mode = false){
2631
- global $wp_filesystem;
2632
- if($wp_filesystem->method == 'direct'){
2633
- return $wp_filesystem->copy($source, $destination, $overwrite, $mode);
2634
- }
2635
- elseif($wp_filesystem->method == 'ftpext' || $wp_filesystem->method == 'ftpsockets'){
2636
- if ( ! $overwrite && $wp_filesystem->exists($destination) )
2637
- return false;
2638
- //$content = $this->get_contents($source);
2639
- // if ( false === $content)
2640
- // return false;
2641
-
2642
- //put content
2643
- //$tempfile = wp_tempnam($file);
2644
- $source_handle = fopen($source, 'r');
2645
- if ( ! $source_handle )
2646
- return false;
2647
 
2648
- //fwrite($temp, $contents);
2649
- //fseek($temp, 0); //Skip back to the start of the file being written to
2650
-
2651
- $sample_content = fread($source_handle, (1024 * 1024 * 2));//1024 * 1024 * 2 => 2MB
2652
- fseek($source_handle, 0); //Skip back to the start of the file being written to
2653
 
2654
- $type = $wp_filesystem->is_binary($sample_content) ? FTP_BINARY : FTP_ASCII;
2655
- unset($sample_content);
2656
- if($wp_filesystem->method == 'ftpext'){
2657
- $ret = @ftp_fput($wp_filesystem->link, $destination, $source_handle, $type);
2658
- }
2659
- elseif($wp_filesystem->method == 'ftpsockets'){
2660
- $wp_filesystem->ftp->SetType($type);
2661
- $ret = $wp_filesystem->ftp->fput($destination, $source_handle);
2662
- }
2663
 
2664
- fclose($source_handle);
2665
- unlink($source);//to immediately save system space
2666
- //unlink($tempfile);
2667
 
2668
- $wp_filesystem->chmod($destination, $mode);
2669
 
2670
- return $ret;
2671
-
2672
- //return $this->put_contents($destination, $content, $mode);
 
2673
  }
2674
- }
2675
 
2676
 
2677
 
@@ -2690,9 +2524,13 @@ function iwp_mmb_direct_to_any_copy($source, $destination, $overwrite = false, $
2690
  include_once ABSPATH . 'wp-admin/includes/file.php';
2691
 
2692
  //Detect source
2693
- if ($backup_url) {
2694
  //This is for clone (overwrite)
2695
  $backup_file = array();
 
 
 
 
2696
  $backup_url_array = $this->get_files_array_from_iwp_part($backup_url);
2697
  if(!is_array($backup_url_array))
2698
  {
@@ -2711,8 +2549,7 @@ function iwp_mmb_direct_to_any_copy($source, $destination, $overwrite = false, $
2711
  }
2712
  }
2713
  $what = 'full';
2714
- }
2715
- else {
2716
  //manual restore darkPrince
2717
 
2718
  $tasks = array();
@@ -2773,6 +2610,11 @@ function iwp_mmb_direct_to_any_copy($source, $destination, $overwrite = false, $
2773
  'error' => 'Failed to download file from Amazon S3.', 'error_code' => 'failed_to_download_file_from_s3'
2774
  );
2775
  }
 
 
 
 
 
2776
  }
2777
  }
2778
  elseif(isset($backup['dropbox'])){
@@ -2795,6 +2637,11 @@ function iwp_mmb_direct_to_any_copy($source, $destination, $overwrite = false, $
2795
  'error' => 'Failed to download file from Dropbox.', 'error_code' => 'failed_to_download_file_from_dropbox'
2796
  );
2797
  }
 
 
 
 
 
2798
  }
2799
 
2800
  }
@@ -3202,7 +3049,34 @@ function iwp_mmb_direct_to_any_copy($source, $destination, $overwrite = false, $
3202
  $GLOBALS['table_prefix'] = $new_table_prefix;
3203
 
3204
  $this->clone_restore_options($clone_options);
3205
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3206
 
3207
  //Remove hit count
3208
  $query = "DELETE FROM " . $new_table_prefix . "options WHERE option_name = 'iwp_client_user_hit_count'";
@@ -3708,7 +3582,7 @@ function ftp_backup($historyID,$args = '')
3708
  extract($args);
3709
  //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder, $ftp_site_folder
3710
  $port = $ftp_port ? $ftp_port : 21; //default port is 21
3711
- if ($ftp_ssl) {
3712
  if (function_exists('ftp_ssl_connect')) {
3713
  $conn_id = ftp_ssl_connect($ftp_hostname,$port);
3714
  if ($conn_id === false) {
@@ -3749,14 +3623,14 @@ function ftp_backup($historyID,$args = '')
3749
  );
3750
  }
3751
 
3752
- if($ftp_passive){
3753
  @ftp_pasv($conn_id,true);
3754
  }
3755
 
3756
 
3757
 
3758
  @ftp_mkdir($conn_id, $ftp_remote_folder);
3759
- if ($ftp_site_folder) {
3760
  $ftp_remote_folder .= '/' . $this->site_name;
3761
  }
3762
  @ftp_mkdir($conn_id, $ftp_remote_folder);
@@ -4001,7 +3875,8 @@ function ftp_backup($historyID,$args = '')
4001
  if($response == true)
4002
  {
4003
  $meta = $obj -> get_object_headers($as3_bucket, $destFile);
4004
- $meta_response_array = CFUtilities::convert_response_to_array($meta);
 
4005
  $s3_filesize = $meta_response_array['header']['content-length'];
4006
  echo "S3 fileszie during verification - ".$s3_filesize;
4007
  if((($s3_filesize >= $size1 && $s3_filesize <= $actual_file_size) || ($s3_filesize <= $size2 && $s3_filesize >= $actual_file_size) || ($s3_filesize == $actual_file_size)) && ($s3_filesize != 0))
@@ -4221,7 +4096,7 @@ function ftp_backup($historyID,$args = '')
4221
  $dBoxStartTime = $this->iwpScriptStartTime;
4222
 
4223
  //get the settings
4224
- //$this -> backup_settings_vals = get_option('iwp_client_multi_backup_temp_values', $backup_settings_values);
4225
  //$backup_settings_values = $this -> backup_settings_vals;
4226
  //$upload_file_block_size = $backup_settings_values['upload_file_block_size'];
4227
  //$actual_file_size = $backup_settings_values['actual_file_size'];
@@ -4273,143 +4148,147 @@ function ftp_backup($historyID,$args = '')
4273
  $backup_file_size = $actual_file_size;
4274
  //$backup_file_size = 10394909; //darkCode testing purpose
4275
 
4276
-
4277
- if(isset($consumer_secret) && !empty($consumer_secret)){
 
 
 
 
 
4278
 
4279
- require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/dropbox.php';
4280
-
4281
- $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret);
4282
- $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret);
4283
-
4284
- if ($dropbox_site_folder == true)
4285
- $dropbox_destination .= '/' . $this->site_name . '/' . basename($backup_file);
4286
- else
4287
- $dropbox_destination .= '/' . basename($backup_file);
4288
-
4289
- try {
4290
- //$dropbox->upload($backup_file, $dropbox_destination, true); //we are using new multiCAll function
4291
 
4292
- // this is the dropbox loop ..
4293
- $reloop = false;
4294
- $chunkCount = 0;
4295
- $chunkTimeTaken = 0;
4296
- do
4297
- {
4298
- if($chunkCount == 0)
4299
- {
4300
- $chunkStartTime = $dBoxStartTime;
4301
- }
4302
- else
4303
- {
4304
- $chunkStartTime = microtime(true);
4305
- }
4306
- if(($backup_file_size - $offset) >= $upload_file_block_size) //the chunk size is set here
4307
- {
4308
- $readsize = $upload_file_block_size;
4309
- $isCommit = false;
4310
- $status = 'partiallyCompleted';
4311
- }
4312
- else
4313
- {
4314
- $readsize = ($backup_file_size - $offset);
4315
-
4316
- $isCommit = true;
4317
- $status = 'completed';
4318
- }
4319
- $chunkResult = $dropbox->chunked_upload($backup_file, $dropbox_destination, true, $uploadid, $offset, $readsize, $isCommit);
4320
-
4321
- $result_arr = array();
4322
- $result_arr['response_data'] = $chunkResult;
4323
- $result_arr['status'] = $status;
4324
- $result_arr['nextFunc'] = 'dropbox_backup';
4325
- $result_arr['dropboxArgs'] = $tempArgs;
4326
- $result_arr['current_file_num'] = $current_file_num;
4327
-
4328
- //updating offset and uploadid values for relooping.
4329
- $offset = $chunkResult['offset'];
4330
- $uploadid = $chunkResult['upload_id'];
4331
- echo 'completed-size'.($offset/1024/1024);
4332
- //check time
4333
- $chunkCompleteTime = microtime(true);
4334
- $dBoxCompleteTime = microtime(true);
4335
- $chunkTimeTaken = (($chunkTimeTaken + ($chunkCompleteTime - $chunkStartTime))/($chunkCount + 1)); // this is the average chunk time
4336
- echo " thisChunkTimeTaken".$chunkTimeTaken;
4337
- $dBoxTimeTaken = $dBoxCompleteTime - $dBoxStartTime;
4338
- $dBoxTimeLeft = $upload_loop_break_time - $dBoxTimeTaken; //calculating time left for the dBOX upload ..
4339
- $dBoxTimeLeft = $dBoxTimeLeft - 5; //for safe time limit
4340
- echo " dBoxTimeLeft".$dBoxTimeLeft;
4341
- //$halfOfLoopTime = (($upload_loop_break_time / 2) - 1);
4342
- if(($dBoxTimeLeft <= $chunkTimeTaken)||($status == 'completed')) //if the time Left for the dropbox upload is less than the time to upload a single chunk break the loop
4343
- {
4344
- $reloop = false;
4345
- }
4346
- else
4347
- {
4348
- $reloop = true;
4349
- $chunkCount++;
4350
- }
4351
- }while($reloop);
4352
 
4353
- $resArray = array (
4354
- 'status' => $status,
4355
- 'backupParentHID' => $historyID,
4356
- );
4357
 
4358
- if($status == 'completed')
4359
- {
4360
- $current_file_num += 1;
4361
- if($current_file_num == $backup_files_count)
4362
- {
4363
- $result_arr['nextFunc'] = 'dropbox_backup_over';
4364
- iwp_mmb_print_flush('Dropbox upload: End');
4365
- unset($task_result['task_results'][$historyID]['server']);
4366
- }
4367
- else
4368
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4369
  $result_arr['nextFunc'] = 'dropbox_backup';
 
4370
  $result_arr['current_file_num'] = $current_file_num;
4371
- $result_arr['status'] = 'partiallyCompleted';
4372
- $resArray['status'] = 'partiallyCompleted';
4373
- }
4374
- }
4375
- $this->statusLog($historyID, array('stage' => 'dropboxMultiCall', 'status' => 'completed', 'statusMsg' => 'nextCall','nextFunc' => 'dropbox_backup', 'task_result' => $task_result, 'responseParams' => $result_arr));
4376
-
4377
-
4378
- if($status == 'completed')
4379
- {
4380
- //checking file size and comparing
4381
- $verificationResult = $this -> postUploadVerification($dropbox, $backup_file, $dropbox_destination, $type = "dropbox");
4382
- if(!$verificationResult)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4383
  {
4384
- return $this->statusLog($historyID, array('stage' => 'uploadDropBox', 'status' => 'error', 'statusMsg' => 'Dropbox verification failed: File may be corrupted.', 'statusCode' => 'dropbox_verification_failed_file_may_be_corrupted'));
 
 
 
 
 
 
 
 
 
 
 
 
 
4385
  }
4386
- if($del_host_file)
 
 
 
4387
  {
4388
- @unlink($backup_file);
 
 
 
 
 
 
 
 
 
4389
  }
 
 
 
 
 
 
 
 
 
 
4390
  }
4391
 
4392
- return $resArray;
4393
 
4394
- }
4395
- catch (Exception $e) {
4396
- $this->_log($e->getMessage());
4397
- return array(
4398
- 'error' => $e->getMessage(),
4399
- 'partial' => 1
4400
- );
4401
- }
4402
-
4403
- //return true;
4404
-
4405
- }
4406
- else {
4407
- return array(
4408
- 'error' => 'Please connect your InfiniteWP panel with your Dropbox account.', 'error_code' => 'please_connect_your_iwp_panel_with_your_dropbox_account'
4409
- );
4410
  }
4411
-
4412
- }
4413
 
4414
 
4415
 
@@ -4447,32 +4326,37 @@ function ftp_backup($historyID,$args = '')
4447
 
4448
 
4449
  function get_dropbox_backup($args) {
4450
- extract($args);
4451
-
4452
- require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/dropbox.php';
4453
-
4454
- $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret);
4455
- $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret);
4456
-
4457
- if ($dropbox_site_folder == true)
4458
- $dropbox_destination .= '/' . $this->site_name;
4459
-
4460
- //$temp = ABSPATH . 'iwp_temp_backup.zip';
4461
- $temp = wp_tempnam('iwp_temp_backup.zip');
4462
-
4463
- try {
4464
 
4465
- //exception should handle the errors
4466
- $dropbox->download($dropbox_destination.'/'.$backup_file, $temp);
4467
- return $temp;
4468
- } catch (Exception $e) {
4469
- $this->_log($e->getMessage());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4470
  return array(
4471
- 'error' => $e->getMessage(),
4472
- 'partial' => 1
4473
- );
4474
  }
4475
-
4476
  }
4477
 
4478
  /*
@@ -4493,9 +4377,9 @@ function ftp_backup($historyID,$args = '')
4493
  function amazons3_backup($historyID , $args='' )
4494
  {
4495
  $s3StartTime = $this->iwpScriptStartTime;
4496
- $this -> backup_settings_vals = get_option('iwp_client_multi_backup_temp_values', $backup_settings_values);
4497
  $backup_settings_values = $this -> backup_settings_vals;
4498
- if($backup_settings_values['s3_retrace_count'])
4499
  {
4500
  $s3_retrace_count = $backup_settings_values['s3_retrace_count'][$historyID];
4501
  }
@@ -4602,7 +4486,12 @@ function ftp_backup($historyID,$args = '')
4602
 
4603
  //$this->statusLog($this -> hisID, array('stage' => 'uploadingFilesAmazon', 'status' => 'partiallyCompleted', 'statusMsg' => 's3SingleCall'));
4604
 
4605
- if ($this->iwp_mmb_function_exists('curl_init')) {
 
 
 
 
 
4606
  require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon_s3/sdk.class.php');
4607
 
4608
  $tempArgs = $args;
@@ -4639,7 +4528,7 @@ function ftp_backup($historyID,$args = '')
4639
 
4640
  CFCredentials::set(array('development' => array('key' => trim($as3_access_key), 'secret' => trim(str_replace(' ', '+', $as3_secure_key)), 'default_cache_config' => '', 'certificate_authority' => true, 'use_ssl'=>false, 'ssl_verification'=>false), '@default' => 'development'));
4641
  $s3 = new AmazonS3();
4642
-
4643
  //the mulitCall upload starts darkCode starts
4644
 
4645
 
@@ -4719,8 +4608,7 @@ function ftp_backup($historyID,$args = '')
4719
 
4720
 
4721
  //convert the response into an array
4722
- $response_array = CFUtilities::convert_response_to_array($response);
4723
-
4724
 
4725
 
4726
  //get the uploadID
@@ -4782,7 +4670,7 @@ function ftp_backup($historyID,$args = '')
4782
 
4783
  echo "singleUploadResult - ".$singleUploadResult;
4784
 
4785
- $singleUploadResponseArray = CFUtilities::convert_response_to_array($singleUploadResponse);
4786
  /* $response = $s3->complete_multipart_upload($bucket, $filename, $upload_id, array(
4787
  array('PartNumber' => 1, 'ETag' => '"25e317773f308e446cc84c503a6d1f85"'),
4788
  array('PartNumber' => 2, 'ETag' => '"a6d1f85f58498973f308e446cc84c503"'),
@@ -4855,7 +4743,7 @@ function ftp_backup($historyID,$args = '')
4855
 
4856
  $response = $s3->abort_multipart_upload($as3_bucket, $as3_file, $upload_id );
4857
  }
4858
- $response_array = CFUtilities::convert_response_to_array($response);
4859
 
4860
  $current_file_num += 1;
4861
 
@@ -4986,14 +4874,6 @@ function ftp_backup($historyID,$args = '')
4986
  );
4987
  }
4988
  }
4989
-
4990
- }
4991
- else {
4992
- return array(
4993
- 'error' => 'You cannot use Amazon S3 on your server. Please enable curl first.',
4994
- 'partial' => 1, 'error_code' => 'cannot_use_s3_enable_curl_first'
4995
- );
4996
- }
4997
  }
4998
 
4999
 
@@ -5046,39 +4926,46 @@ function ftp_backup($historyID,$args = '')
5046
 
5047
  function get_amazons3_backup($args)
5048
  {
5049
- require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon_s3/sdk.class.php');
5050
- extract($args);
5051
- $temp = '';
5052
- try{
5053
- CFCredentials::set(array('development' => array('key' => trim($as3_access_key), 'secret' => trim(str_replace(' ', '+', $as3_secure_key)), 'default_cache_config' => '', 'certificate_authority' => true), '@default' => 'development'));
5054
- $s3 = new AmazonS3();
5055
- if ($as3_site_folder == true)
5056
- {
5057
- if(!empty($as3_directory))
5058
  {
5059
- $as3_directory .= '/' . $this->site_name;
 
 
 
 
 
 
 
 
 
 
 
5060
  }
5061
  else
5062
  {
5063
- $as3_directory = $this->site_name;
5064
  }
5065
- }
5066
- if(empty($as3_directory))
5067
- {
5068
- $single_as3_file = $backup_file;
5069
- }
5070
- else
5071
- {
5072
- $single_as3_file = $as3_directory . '/' . $backup_file;
5073
- }
5074
-
5075
- //$temp = ABSPATH . 'iwp_temp_backup.zip';
5076
- $temp = wp_tempnam('iwp_temp_backup.zip');
5077
- $s3->get_object($as3_bucket, $single_as3_file, array("fileDownload" => $temp));
5078
- } catch (Exception $e){
5079
- return false;
5080
- }
5081
- return $temp;
5082
  }
5083
  //IWP Remove ends here
5084
 
@@ -5188,8 +5075,9 @@ function ftp_backup($historyID,$args = '')
5188
  //set $args, $uploadid, $offset from the DB
5189
  $responseParams = $this -> getRequiredData($historyID,"responseParams");
5190
 
5191
- if(!$responseParams)
5192
  return $this->statusLog($this -> hisID, array('stage' => 'google_drive_upload', 'status' => 'error', 'statusMsg' => 'google Upload failed: Error while fetching table data.','statusCode' => 'google_upload_failed_error_fetching_data'));
 
5193
 
5194
  $args = $responseParams['gDriveArgs'];
5195
  $prevChunkResults = $responseParams['response_data'];
@@ -5247,7 +5135,7 @@ function ftp_backup($historyID,$args = '')
5247
  try
5248
  {
5249
  $parameters = array();
5250
- $parameters['q'] = "title = 'infinitewp' and trashed = false and mimeType= 'application/vnd.google-apps.folder'";
5251
  $files = $service->files->listFiles($parameters);
5252
  $list_result = array();
5253
  $list_result = array_merge($list_result, $files->getItems());
@@ -5270,19 +5158,21 @@ function ftp_backup($historyID,$args = '')
5270
  }
5271
  else
5272
  {
5273
- $list_result = (array)$list_result[0];
5274
- $iwp_folder_id = $list_result['id'];
 
5275
  }
5276
  }catch (Exception $e){
5277
  print "An error occurred: " . $e->getMessage();
5278
- return array('error' => $e->getMessage(), 'error_code' => 'google_error_occurred_list_results');
5279
  }
5280
 
5281
  //create sub folder by site name
5282
  if($create_sub_folder)
5283
  {
5284
  $parameters = array();
5285
- $parameters['q'] = "title = '$sub_folder_name' and trashed = false and mimeType = 'application/vnd.google-apps.folder'";
 
5286
  $files = $service->files->listFiles($parameters);
5287
  $list_result = array();
5288
  $list_result = array_merge($list_result, $files->getItems());
@@ -5310,8 +5200,9 @@ function ftp_backup($historyID,$args = '')
5310
  }
5311
  else
5312
  {
5313
- $list_result = (array)$list_result[0];
5314
- $sub_folder_id = $list_result['id'];
 
5315
  }
5316
  }
5317
 
@@ -5425,9 +5316,8 @@ function ftp_backup($historyID,$args = '')
5425
  }
5426
 
5427
  $current_file_num += 1;
5428
-
5429
  $result_arr = array();
5430
- $result_arr['response_data'] = $createdFile['id'];
5431
  $result_arr['status'] = "completed";
5432
  $result_arr['nextFunc'] = 'google_drive_completed';
5433
  $result_arr['gDriveArgs'] = $tempArgs;
@@ -5742,8 +5632,10 @@ function ftp_backup($historyID,$args = '')
5742
 
5743
  $backup_folder = WP_CONTENT_DIR . '/' . md5('iwp_mmb-client') . '/iwp_backups/';
5744
  $backup_folder_new = IWP_BACKUP_DIR . '/';
 
5745
  $files = glob($backup_folder . "*");
5746
  $new = glob($backup_folder_new . "*");
 
5747
 
5748
  //Failed db files first
5749
  $db_folder = IWP_DB_DIR . '/';
@@ -5758,8 +5650,8 @@ function ftp_backup($historyID,$args = '')
5758
 
5759
 
5760
  //clean_old folder?
5761
- if ((basename($files[0]) == 'index.php' && count($files) == 1) || (!empty($files))) { //USE (!empty($files)
5762
- foreach ($files as $file) {
5763
  @unlink($file);
5764
  }
5765
  @rmdir(WP_CONTENT_DIR . '/' . md5('iwp_mmb-client') . '/iwp_backups');
@@ -5771,6 +5663,11 @@ function ftp_backup($historyID,$args = '')
5771
  $files[] = $b;
5772
  }
5773
  }
 
 
 
 
 
5774
  $deleted = array();
5775
 
5776
  if (is_array($files) && count($files)) {
@@ -5890,73 +5787,6 @@ function ftp_backup($historyID,$args = '')
5890
 
5891
  }
5892
 
5893
- function cleanup_old_method()
5894
- {
5895
- //$tasks = $this->tasks;
5896
- $tasks = $this->get_all_tasks();
5897
- $backup_folder = WP_CONTENT_DIR . '/' . md5('iwp_mmb-client') . '/iwp_backups/';
5898
- $backup_folder_new = IWP_BACKUP_DIR . '/';
5899
- $files = glob($backup_folder . "*");
5900
- $new = glob($backup_folder_new . "*");
5901
-
5902
- //Failed db files first
5903
- $db_folder = IWP_DB_DIR . '/';
5904
- $db_files = glob($db_folder . "*");
5905
- if (is_array($db_files) && !empty($db_files)) {
5906
- foreach ($db_files as $file) {
5907
- @unlink($file);
5908
- }
5909
- @unlink(IWP_BACKUP_DIR.'/iwp_db/index.php');
5910
- @rmdir(IWP_DB_DIR);
5911
- }
5912
-
5913
-
5914
- //clean_old folder?
5915
- if ((basename($files[0]) == 'index.php' && count($files) == 1) || (!empty($files))) { //USE (!empty($files)
5916
- foreach ($files as $file) {
5917
- @unlink($file);
5918
- }
5919
- @rmdir(WP_CONTENT_DIR . '/' . md5('iwp_mmb-client') . '/iwp_backups');
5920
- @rmdir(WP_CONTENT_DIR . '/' . md5('iwp_mmb-client'));
5921
- }
5922
-
5923
- if (!empty($new)) {
5924
- foreach ($new as $b) {
5925
- $files[] = $b;
5926
- }
5927
- }
5928
- $deleted = array();
5929
-
5930
- if (is_array($files) && count($files)) {
5931
- $results = array();
5932
- if (!empty($tasks)) {
5933
- foreach ((array) $tasks as $task) {
5934
- if (isset($task['task_results']) && count($task['task_results'])) {
5935
- foreach ($task['task_results'] as $backup) {
5936
- if (isset($backup['server'])) {
5937
- $results[] = $backup['server']['file_path'];
5938
- }
5939
- }
5940
- }
5941
- }
5942
- }
5943
-
5944
- $num_deleted = 0;
5945
- foreach ($files as $file) {
5946
- if (!in_array($file, $results) && basename($file) != 'index.php') {
5947
- @unlink($file);
5948
- $deleted[] = basename($file);
5949
- $num_deleted++;
5950
- }
5951
- }
5952
- }
5953
-
5954
-
5955
-
5956
- return $deleted;
5957
- }
5958
-
5959
-
5960
  function wpdb_reconnect(){
5961
  global $wpdb;
5962
  $old_wpdb = $wpdb;
305
  $backup_file_info['backup_file'] = $backup_file;
306
  $backup_file_info['backup_url'] = $backup_url;
307
 
308
+ if(empty($account_info))
309
  {
310
  $account_info = array();
311
  }
345
  $backup_file = $responseParams['response_data']['backup_file'];
346
 
347
  //storing the filesize value into settings array - first get the values and then append the value of filesize to it
348
+ $this -> backup_settings_vals = get_option('iwp_client_multi_backup_temp_values');
349
  $backup_settings_values = $this -> backup_settings_vals;
350
  $backup_settings_values['actual_file_size'] = iwp_mmb_get_file_size($backup_file);
351
  update_option('iwp_client_multi_backup_temp_values', $backup_settings_values);
356
  $ftp_result = $this->ftp_backup($historyID, $account_info['iwp_ftp']);
357
  if(!$ftp_result)
358
  {
359
+ if($del_host_file){
360
+ $this->unlinkBackupFiles($backup_file);
361
+ }
362
  return array('error' => "Unexpected Error", 'error_code' => "unexpected_error");
363
  }
364
+ else if(is_array($ftp_result) && isset($ftp_result['error'])){
365
+ if($del_host_file){
366
+ $this->unlinkBackupFiles($backup_file);
367
+ }
368
+ return $ftp_result;
369
+ }
370
  else
371
  {
372
  return $ftp_result;
378
  iwp_mmb_print_flush('Amazon S3 upload: Start');
379
  $amazons3_result = $this->amazons3_backup($historyID,$account_info['iwp_amazon_s3']);
380
  iwp_mmb_print_flush('Amazon S3 upload: End');
381
+
382
+ if (empty($amazons3_result) && $del_host_file) {
383
+ $this->unlinkBackupFiles($backup_file);
 
 
 
384
  }
385
  if (is_array($amazons3_result) && isset($amazons3_result['error'])) {
386
+ $this->unlinkBackupFiles($backup_file);
387
+ }
388
+ if($amazons3_result['status'] == 'partiallyCompleted') //darkCode true loop
389
+ {
390
  return $amazons3_result;
391
  }
392
  return $amazons3_result;
399
  $gdrive_result = $this->google_drive_backup($historyID, $account_info['iwp_gdrive']);
400
  iwp_mmb_print_flush('google Drive upload: End');
401
 
402
+ if (is_array($gdrive_result) && isset($gdrive_result['error'])){
403
+ if($del_host_file){
404
+ $this->unlinkBackupFiles($backup_file);
405
+ }
406
+ }
407
+ if(empty($gdrive_result) && $del_host_file){
408
+ $this->unlinkBackupFiles($backup_file);
409
+ }
410
+
411
  return $gdrive_result;
412
 
413
  }
418
  $account_info['iwp_dropbox']['backup_file'] = $backup_file;
419
  iwp_mmb_print_flush('Dropbox upload: Start');
420
  $dropbox_result = $this->dropbox_backup($historyID, $account_info['iwp_dropbox']);
 
 
 
 
421
  iwp_mmb_print_flush('Dropbox upload: End');
422
+
423
+ if (empty($dropbox_result) && $del_host_file) {
424
+ $this->unlinkBackupFiles($backup_file);
425
  }
426
 
427
  if (is_array($dropbox_result) && isset($dropbox_result['error'])) {
428
+ $this->unlinkBackupFiles($backup_file);
429
+ }
430
+ if($dropbox_result['status'] == 'partiallyCompleted')
431
+ {
432
  return $dropbox_result;
433
  }
434
 
 
 
435
  $this->wpdb_reconnect();
 
436
  return $dropbox_result;
437
  }
438
 
443
 
444
  }
445
 
446
+ function unlinkBackupFiles($this_files){
447
+ if(is_array($this_files)){
448
+ if(!empty($this_files)){
449
+ foreach($this_files as $this_key => $this_file){
450
+ @unlink($this_file);
451
+ }
452
+ }
453
+ }
454
+ else{
455
+ @unlink($this_files);
456
+ }
457
+ }
458
+
459
  function backupDB($historyID,$backup_file,$account_info = array())
460
  {
461
  $this->statusLog($historyID, array('stage' => 'backupDB', 'status' => 'processing', 'statusMsg' => 'backupDBInitiated'));
570
  function backupDBPHP($historyID) //file must be db name alone ; $response_array should be table_name and its fields and callCount
571
  {
572
  //getting the settings first
573
+ $this -> backup_settings_vals = get_option('iwp_client_multi_backup_temp_values');
574
  $backup_settings_values = $this -> backup_settings_vals;
575
 
576
  //$file_block_size = $backup_settings_values['file_block_size'];
900
  $include = $requestParams['args']['include'];
901
  $exclude_extensions = $requestParams['args']['exclude_extensions'];
902
  $exclude_file_size = $requestParams['args']['exclude_file_size'];
903
+ $category = '';
904
  if(empty($exclude_extensions))
905
  {
906
  $exclude_extensions = array();
920
  $this->statusLog($this -> hisID, array('stage' => 'backupFiles', 'status' => 'processing', 'statusMsg' => 'backupFilesInitiated'));
921
  }
922
  $backup_url = $this -> backup_url;
923
+ $zip_split_part = 0;
924
  if($backup_file == '')
925
  {
926
  $responseParams = $this -> getRequiredData($this -> hisID, "responseParams");
1017
  }
1018
 
1019
  //Include root files
1020
+ if ($handle = @opendir(ABSPATH)) {
1021
  while (false !== ($file = readdir($handle))) {
1022
  if ($file != "." && $file != ".." && !is_dir($file) && file_exists(ABSPATH . $file)) {
1023
  $include_data[] = ABSPATH . $file;
1070
  $files_excluded_by_size = array();
1071
  $start34 = microtime(true);
1072
  //get the backup settings values from options table
1073
+ $this -> backup_settings_vals = get_option('iwp_client_multi_backup_temp_values');
1074
  $backup_settings_values = $this -> backup_settings_vals;
1075
  //$file_block_size = $backup_settings_values['file_block_size'];
1076
  //$is_compressed = $backup_settings_values['is_compressed'];
1083
  $is_compressed = $requestParams['args']['is_compressed'];
1084
  $file_loop_break_time = $requestParams['args']['file_loop_break_time'];
1085
  $task_name = $requestParams['args']['backup_name'];
1086
+ $exclude_file_size = $requestParams['args']['exclude_file_size'];
1087
+ $exclude_extensions = $requestParams['args']['exclude_extensions'];
1088
  $zip_split_size = $requestParams['args']['zip_split_size'];
1089
 
1090
+ if(isset($backup_settings_values['dbFileHashValue']) && !empty($backup_settings_values['dbFileHashValue'][$historyID]))
1091
  {
1092
  $dbFileHashValue = $backup_settings_values['dbFileHashValue'][$historyID];
1093
  }
1103
  return $this->statusLog($this -> hisID, array('stage' => 'backupFiles', 'status' => 'error', 'statusMsg' => 'Backup of files failed - Error while fetching table data', 'statusCode' => 'backup_of_files_failed_error_while_fetching_table_data'));
1104
  }
1105
 
1106
+ $include_data = isset($responseParams['response_data']['include_data']) ? $responseParams['response_data']['include_data'] : array();
1107
+ $exclude_data = isset($responseParams['response_data']['exclude_data']) ? $responseParams['response_data']['exclude_data'] : array();
1108
  $backup_file = $responseParams['response_data']['backup_file'];
1109
  $backup_url = $responseParams['response_data']['backup_url'];
1110
+ $nextCount = isset($responseParams['response_data']['nextCount']) ? $responseParams['response_data']['nextCount'] : 0;
1111
  $account_info = $responseParams['response_data']['account_info'];
1112
+ $files_with_error = isset($responseParams['response_data']['files_with_error']) ? $responseParams['response_data']['files_with_error'] : array();
1113
+ $files_excluded_by_size = isset($responseParams['response_data']['files_excluded_by_size']) ? $responseParams['response_data']['files_excluded_by_size'] : array();
1114
+ $p_filedescr_list = isset($responseParams['response_data']['p_filedescr_list']) ? $responseParams['response_data']['p_filedescr_list'] : array();
1115
+ $zip_split_part = isset($responseParams['response_data']['zip_split_part']) ? $responseParams['response_data']['zip_split_part'] : 0;
1116
+ $is_new_zip = isset($responseParams['response_data']['is_new_zip']) ? $responseParams['response_data']['is_new_zip'] : 0;
1117
  /* if(empty($zip_split_part))
1118
  {
1119
  $zip_split_part = 1;
1136
  $zip_split_part = 0;
1137
  }
1138
 
1139
+ if(empty($p_filedescr_list))
1140
  {
1141
  $p_filedescr_list = array();
1142
  }
1143
+ if(empty($files_with_error))
1144
  {
1145
  $files_with_error = array();
1146
  }
1147
+ if(empty($files_excluded_by_size))
1148
  {
1149
  $files_excluded_by_size = array();
1150
  }
1536
  }
1537
  }
1538
 
1539
+
1540
+ function get_exclude_ext_array($exclude_extensions){
1541
+ if(empty($exclude_extensions))
1542
+ {
1543
+ $exclude_extensions = array();
1544
+ }
1545
+ else if($exclude_extensions == 'eg. .zip,.mp4')
1546
+ {
1547
+ $exclude_extensions = array();
1548
+ }
1549
+ else
1550
+ {
1551
+ $exclude_extensions_array = explode(",",$exclude_extensions);
1552
+ $exclude_extensions = array();
1553
+ $exclude_extensions = $exclude_extensions_array;
1554
+ }
1555
+ return $exclude_extensions;
1556
+ }
1557
+
1558
  function get_total_files_size($backup_files)
1559
  {
1560
  if(is_array($backup_files))
1590
  $file_loop_break_time = $requestParams['args']['file_loop_break_time'];
1591
  $task_name = $requestParams['args']['backup_name'];
1592
  $exclude_file_size = $requestParams['args']['exclude_file_size'];
1593
+ $exclude_extensions = $requestParams['args']['exclude_extensions'];
1594
  $zip_split_size = $requestParams['args']['zip_split_size'];
1595
 
1596
  if($backup_settings_values['dbFileHashValue'][$historyID])
2239
  }
2240
 
2241
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2242
  function get_this_tasks(){
2243
  $this->wpdb_reconnect();
2244
 
2312
  }
2313
  else if((isset($statusArray['responseParams']))||(isset($statusArray['task_result'])))
2314
  {
2315
+ $update = $wpdb->update($wpdb->base_prefix.'iwp_backup_status',array( 'responseParams' => $this->maybe_serialize_compress($statusArray['responseParams']),'stage' => $statusArray['stage'], 'status' => $statusArray['status'],'statusMsg' => $statusArray['statusMsg'],'taskResults' => isset($statusArray['task_result']) ? serialize($statusArray['task_result']) : serialize(array()) ),array( 'historyID' => $historyID),array('%s','%s', '%s', '%s','%s'),array('%d'));
2316
  }
2317
  else
2318
  {
2331
  $returnParams['backupRowID'] = $insertID;
2332
  $returnParams['stage'] = $statusArray['stage'] ;
2333
  $returnParams['status'] = $statusArray['status'];
2334
+ $returnParams['nextFunc'] = isset($statusArray['nextFunc']) ? $statusArray['nextFunc'] : '';
2335
  return array('success' => $returnParams);
2336
  }
2337
  else
2371
  }
2372
 
2373
 
2374
+ function task_now($task_name){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2375
 
2376
+ $settings = $this->tasks;
2377
+ if(!array_key_exists($task_name,$settings)){
2378
+ return array('error' => $task_name." does not exist.", 'error_code' => 'task_name_doesnt_exists');
2379
+ } else {
2380
+ $setting = $settings[$task_name];
2381
+ }
2382
+
2383
+ $this->set_backup_task(array(
2384
+ 'task_name' => $task_name,
2385
+ 'args' => $settings[$task_name]['task_args'],
2386
+ 'time' => time()
2387
+ ));
2388
+
2389
+ //Run backup
2390
+ $result = $this->backup($setting['task_args'], $task_name);
2391
+
2392
+ //Check for error
2393
+ if (is_array($result) && array_key_exists('error', $result)) {
2394
+ $this->set_backup_task(array(
2395
+ 'task_name' => $task_name,
2396
+ 'args' => $settings[$task_name]['task_args'],
2397
+ 'error' => $result['error']
2398
+ ));
2399
+ return $result;
2400
+ } else {
2401
+ return $this->get_backup_stats();
2402
+ }
2403
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2404
  }
2405
+
2406
+
2407
  /**
2408
+ * Copies a directory from one location to another via the WordPress Filesystem Abstraction.
2409
+ * Assumes that WP_Filesystem() has already been called and setup.
2410
+ *
2411
+ * @since 2.5.0
2412
+ *
2413
+ * @param string $from source directory
2414
+ * @param string $to destination directory
2415
+ * @param array $skip_list a list of files/folders to skip copying
2416
+ * @return mixed WP_Error on failure, True on success.
2417
+ */
2418
+ function iwp_mmb_direct_to_any_copy_dir($from, $to, $skip_list = array() ) {//$from => direct file system, $to => automatic filesystem
2419
+ global $wp_filesystem;
2420
 
2421
+ $wp_temp_direct = new WP_Filesystem_Direct('');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2422
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2423
 
2424
+ $dirlist = $wp_temp_direct->dirlist($from);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2425
 
2426
+ $from = trailingslashit($from);
2427
+ $to = trailingslashit($to);
2428
 
2429
+ $skip_regex = '';
2430
+ foreach ( (array)$skip_list as $key => $skip_file )
2431
+ $skip_regex .= preg_quote($skip_file, '!') . '|';
2432
 
 
 
 
 
 
 
 
 
2433
  if ( !empty($skip_regex) )
2434
+ $skip_regex = '!(' . rtrim($skip_regex, '|') . ')$!i';
 
2435
 
2436
+ foreach ( (array) $dirlist as $filename => $fileinfo ) {
2437
+ if ( !empty($skip_regex) )
2438
+ if ( preg_match($skip_regex, $from . $filename) )
2439
+ continue;
2440
+
2441
+ if ( 'f' == $fileinfo['type'] ) {
2442
+ if ( ! $this->iwp_mmb_direct_to_any_copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) {
2443
+ // If copy failed, chmod file to 0644 and try again.
2444
+ $wp_filesystem->chmod($to . $filename, 0644);
2445
+ if ( ! $this->iwp_mmb_direct_to_any_copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) )
2446
+ {
2447
+ continue;
2448
+ return new WP_Error('copy_failed', __('Could not copy file.'), $to . $filename);
2449
+ }
2450
+ }
2451
+ } elseif ( 'd' == $fileinfo['type'] ) {
2452
+ if ( !$wp_filesystem->is_dir($to . $filename) ) {
2453
+ if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )
2454
+ return new WP_Error('mkdir_failed', __('Could not create directory.'), $to . $filename);
2455
+ }
2456
+ $result = $this->iwp_mmb_direct_to_any_copy_dir($from . $filename, $to . $filename, $skip_list);
2457
+ if ( is_wp_error($result) )
2458
+ return $result;
2459
  }
 
 
 
2460
  }
2461
+ return true;
2462
  }
 
 
2463
 
2464
+ function iwp_mmb_direct_to_any_copy($source, $destination, $overwrite = false, $mode = false){
2465
+ global $wp_filesystem;
2466
+ if($wp_filesystem->method == 'direct'){
2467
+ return $wp_filesystem->copy($source, $destination, $overwrite, $mode);
2468
+ }
2469
+ elseif($wp_filesystem->method == 'ftpext' || $wp_filesystem->method == 'ftpsockets'){
2470
+ if ( ! $overwrite && $wp_filesystem->exists($destination) )
2471
+ return false;
2472
+ //$content = $this->get_contents($source);
2473
+ // if ( false === $content)
2474
+ // return false;
2475
+
2476
+ //put content
2477
+ //$tempfile = wp_tempnam($file);
2478
+ $source_handle = fopen($source, 'r');
2479
+ if ( ! $source_handle )
2480
+ return false;
2481
 
2482
+ //fwrite($temp, $contents);
2483
+ //fseek($temp, 0); //Skip back to the start of the file being written to
2484
+
2485
+ $sample_content = fread($source_handle, (1024 * 1024 * 2));//1024 * 1024 * 2 => 2MB
2486
+ fseek($source_handle, 0); //Skip back to the start of the file being written to
2487
 
2488
+ $type = $wp_filesystem->is_binary($sample_content) ? FTP_BINARY : FTP_ASCII;
2489
+ unset($sample_content);
2490
+ if($wp_filesystem->method == 'ftpext'){
2491
+ $ret = @ftp_fput($wp_filesystem->link, $destination, $source_handle, $type);
2492
+ }
2493
+ elseif($wp_filesystem->method == 'ftpsockets'){
2494
+ $wp_filesystem->ftp->SetType($type);
2495
+ $ret = $wp_filesystem->ftp->fput($destination, $source_handle);
2496
+ }
2497
 
2498
+ fclose($source_handle);
2499
+ unlink($source);//to immediately save system space
2500
+ //unlink($tempfile);
2501
 
2502
+ $wp_filesystem->chmod($destination, $mode);
2503
 
2504
+ return $ret;
2505
+
2506
+ //return $this->put_contents($destination, $content, $mode);
2507
+ }
2508
  }
 
2509
 
2510
 
2511
 
2524
  include_once ABSPATH . 'wp-admin/includes/file.php';
2525
 
2526
  //Detect source
2527
+ if ($backup_url || (isset($manualBackupFile) && !empty($manualBackupFile))) {
2528
  //This is for clone (overwrite)
2529
  $backup_file = array();
2530
+ if(!$backup_url) {
2531
+ $site_url = site_url();
2532
+ $backup_url = $site_url."/".$manualBackupFile;
2533
+ }
2534
  $backup_url_array = $this->get_files_array_from_iwp_part($backup_url);
2535
  if(!is_array($backup_url_array))
2536
  {
2549
  }
2550
  }
2551
  $what = 'full';
2552
+ } else {
 
2553
  //manual restore darkPrince
2554
 
2555
  $tasks = array();
2610
  'error' => 'Failed to download file from Amazon S3.', 'error_code' => 'failed_to_download_file_from_s3'
2611
  );
2612
  }
2613
+ else if(is_array($backup_file[$key]) && isset($backup_file[$key]['error'])){
2614
+ return array(
2615
+ 'error' => 'Failed to download file from Amazon S3. Please enable curl first.', 'error_code' => 'failed_to_download_file_from_s3_enable_curl'
2616
+ );
2617
+ }
2618
  }
2619
  }
2620
  elseif(isset($backup['dropbox'])){
2637
  'error' => 'Failed to download file from Dropbox.', 'error_code' => 'failed_to_download_file_from_dropbox'
2638
  );
2639
  }
2640
+ else if(is_array($backup_file[$key]) && isset($backup_file[$key]['error'])){
2641
+ return array(
2642
+ 'error' => 'Failed to download file from Dropbox. Please enable curl first.', 'error_code' => 'failed_to_download_file_from_dbox_enable_curl'
2643
+ );
2644
+ }
2645
  }
2646
 
2647
  }
3049
  $GLOBALS['table_prefix'] = $new_table_prefix;
3050
 
3051
  $this->clone_restore_options($clone_options);
3052
+
3053
+ if(!empty($clone_options['iwp_client_nossl_key'])){
3054
+
3055
+ $query = "SELECT * FROM " . $new_table_prefix . "options WHERE option_name = 'iwp_client_nossl_key'";
3056
+ $temp_row = $wpdb->get_row($query);
3057
+ if (!empty($temp_row)) {
3058
+ $query = "UPDATE " . $new_table_prefix . "options SET option_value = %s WHERE option_name = 'iwp_client_nossl_key'";
3059
+ $wpdb->query($wpdb->prepare($query, $clone_options['iwp_client_nossl_key']));
3060
+ } else {
3061
+ $insert = $wpdb->insert($new_table_prefix."options",array( 'option_name' => 'iwp_client_nossl_key', 'option_value' => $clone_options['iwp_client_nossl_key'], 'autoload' => 'yes'), array( '%s', '%s','%s') );
3062
+ }
3063
+ }
3064
+
3065
+ if(!empty($clone_options['iwp_client_public_key'])){
3066
+
3067
+ $query = "SELECT * FROM " . $new_table_prefix . "options WHERE option_name = 'iwp_client_public_key'";
3068
+ $temp_row = $wpdb->get_row($query);
3069
+ if (!empty($temp_row)) {
3070
+ $query = "UPDATE " . $new_table_prefix . "options SET option_value = %s WHERE option_name = 'iwp_client_public_key'";
3071
+ $wpdb->query($wpdb->prepare($query, $clone_options['iwp_client_public_key']));
3072
+ } else {
3073
+ $insert = $wpdb->insert($new_table_prefix."options",array( 'option_name' => 'iwp_client_public_key', 'option_value' => $clone_options['iwp_client_public_key'], 'autoload' => 'yes'), array( '%s', '%s','%s') );
3074
+ }
3075
+ }
3076
+ }
3077
+ $query = "SELECT * FROM " . $new_table_prefix . "users LIMIT 1";
3078
+ $temp_user = $wpdb->get_row($query);
3079
+ $new_user = $temp_user->user_login;
3080
 
3081
  //Remove hit count
3082
  $query = "DELETE FROM " . $new_table_prefix . "options WHERE option_name = 'iwp_client_user_hit_count'";
3582
  extract($args);
3583
  //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder, $ftp_site_folder
3584
  $port = $ftp_port ? $ftp_port : 21; //default port is 21
3585
+ if (!empty($ftp_ssl)) {
3586
  if (function_exists('ftp_ssl_connect')) {
3587
  $conn_id = ftp_ssl_connect($ftp_hostname,$port);
3588
  if ($conn_id === false) {
3623
  );
3624
  }
3625
 
3626
+ if(!empty($ftp_passive)){
3627
  @ftp_pasv($conn_id,true);
3628
  }
3629
 
3630
 
3631
 
3632
  @ftp_mkdir($conn_id, $ftp_remote_folder);
3633
+ if (!empty($ftp_site_folder)) {
3634
  $ftp_remote_folder .= '/' . $this->site_name;
3635
  }
3636
  @ftp_mkdir($conn_id, $ftp_remote_folder);
3875
  if($response == true)
3876
  {
3877
  $meta = $obj -> get_object_headers($as3_bucket, $destFile);
3878
+ $cfu_obj = new CFUtilities;
3879
+ $meta_response_array = $cfu_obj->convert_response_to_array($meta);
3880
  $s3_filesize = $meta_response_array['header']['content-length'];
3881
  echo "S3 fileszie during verification - ".$s3_filesize;
3882
  if((($s3_filesize >= $size1 && $s3_filesize <= $actual_file_size) || ($s3_filesize <= $size2 && $s3_filesize >= $actual_file_size) || ($s3_filesize == $actual_file_size)) && ($s3_filesize != 0))
4096
  $dBoxStartTime = $this->iwpScriptStartTime;
4097
 
4098
  //get the settings
4099
+ //$this -> backup_settings_vals = get_option('iwp_client_multi_backup_temp_values');
4100
  //$backup_settings_values = $this -> backup_settings_vals;
4101
  //$upload_file_block_size = $backup_settings_values['upload_file_block_size'];
4102
  //$actual_file_size = $backup_settings_values['actual_file_size'];
4148
  $backup_file_size = $actual_file_size;
4149
  //$backup_file_size = 10394909; //darkCode testing purpose
4150
 
4151
+ if (!$this->iwp_mmb_function_exists('curl_init')) {
4152
+ return array(
4153
+ 'error' => 'You cannot use Dropbox on your server. Please enable curl first.',
4154
+ 'partial' => 1, 'error_code' => 'cannot_use_dropbox_enable_curl_first'
4155
+ );
4156
+ }
4157
+ if(isset($consumer_secret) && !empty($consumer_secret)){
4158
 
4159
+ require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/dropbox.php';
 
 
 
 
 
 
 
 
 
 
 
4160
 
4161
+ $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret);
4162
+ $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4163
 
4164
+ if (isset($dropbox_site_folder) && $dropbox_site_folder == true)
4165
+ $dropbox_destination .= '/' . $this->site_name . '/' . basename($backup_file);
4166
+ else
4167
+ $dropbox_destination .= '/' . basename($backup_file);
4168
 
4169
+ try {
4170
+ //$dropbox->upload($backup_file, $dropbox_destination, true); //we are using new multiCAll function
4171
+
4172
+ // this is the dropbox loop ..
4173
+ $reloop = false;
4174
+ $chunkCount = 0;
4175
+ $chunkTimeTaken = 0;
4176
+ do
 
 
4177
  {
4178
+ if($chunkCount == 0)
4179
+ {
4180
+ $chunkStartTime = $dBoxStartTime;
4181
+ }
4182
+ else
4183
+ {
4184
+ $chunkStartTime = microtime(true);
4185
+ }
4186
+ if(($backup_file_size - $offset) >= $upload_file_block_size) //the chunk size is set here
4187
+ {
4188
+ $readsize = $upload_file_block_size;
4189
+ $isCommit = false;
4190
+ $status = 'partiallyCompleted';
4191
+ }
4192
+ else
4193
+ {
4194
+ $readsize = ($backup_file_size - $offset);
4195
+
4196
+ $isCommit = true;
4197
+ $status = 'completed';
4198
+ }
4199
+ $chunkResult = $dropbox->chunked_upload($backup_file, $dropbox_destination, true, $uploadid, $offset, $readsize, $isCommit);
4200
+
4201
+ $result_arr = array();
4202
+ $result_arr['response_data'] = $chunkResult;
4203
+ $result_arr['status'] = $status;
4204
  $result_arr['nextFunc'] = 'dropbox_backup';
4205
+ $result_arr['dropboxArgs'] = $tempArgs;
4206
  $result_arr['current_file_num'] = $current_file_num;
4207
+
4208
+ //updating offset and uploadid values for relooping.
4209
+ $offset = isset($chunkResult['offset']) ? $chunkResult['offset'] : 0;
4210
+ $uploadid = isset($chunkResult['upload_id']) ? $chunkResult['upload_id'] : 0;
4211
+ echo 'completed-size'.($offset/1024/1024);
4212
+ //check time
4213
+ $chunkCompleteTime = microtime(true);
4214
+ $dBoxCompleteTime = microtime(true);
4215
+ $chunkTimeTaken = (($chunkTimeTaken + ($chunkCompleteTime - $chunkStartTime))/($chunkCount + 1)); // this is the average chunk time
4216
+ echo " thisChunkTimeTaken".$chunkTimeTaken;
4217
+ $dBoxTimeTaken = $dBoxCompleteTime - $dBoxStartTime;
4218
+ $dBoxTimeLeft = $upload_loop_break_time - $dBoxTimeTaken; //calculating time left for the dBOX upload ..
4219
+ $dBoxTimeLeft = $dBoxTimeLeft - 5; //for safe time limit
4220
+ echo " dBoxTimeLeft".$dBoxTimeLeft;
4221
+ //$halfOfLoopTime = (($upload_loop_break_time / 2) - 1);
4222
+ if(($dBoxTimeLeft <= $chunkTimeTaken)||($status == 'completed')) //if the time Left for the dropbox upload is less than the time to upload a single chunk break the loop
4223
+ {
4224
+ $reloop = false;
4225
+ }
4226
+ else
4227
+ {
4228
+ $reloop = true;
4229
+ $chunkCount++;
4230
+ }
4231
+ }while($reloop);
4232
+
4233
+ $resArray = array (
4234
+ 'status' => $status,
4235
+ 'backupParentHID' => $historyID,
4236
+ );
4237
+
4238
+ if($status == 'completed')
4239
  {
4240
+ $current_file_num += 1;
4241
+ if($current_file_num == $backup_files_count)
4242
+ {
4243
+ $result_arr['nextFunc'] = 'dropbox_backup_over';
4244
+ iwp_mmb_print_flush('Dropbox upload: End');
4245
+ unset($task_result['task_results'][$historyID]['server']);
4246
+ }
4247
+ else
4248
+ {
4249
+ $result_arr['nextFunc'] = 'dropbox_backup';
4250
+ $result_arr['current_file_num'] = $current_file_num;
4251
+ $result_arr['status'] = 'partiallyCompleted';
4252
+ $resArray['status'] = 'partiallyCompleted';
4253
+ }
4254
  }
4255
+ $this->statusLog($historyID, array('stage' => 'dropboxMultiCall', 'status' => 'completed', 'statusMsg' => 'nextCall','nextFunc' => 'dropbox_backup', 'task_result' => $task_result, 'responseParams' => $result_arr));
4256
+
4257
+
4258
+ if($status == 'completed')
4259
  {
4260
+ //checking file size and comparing
4261
+ $verificationResult = $this -> postUploadVerification($dropbox, $backup_file, $dropbox_destination, $type = "dropbox");
4262
+ if(!$verificationResult)
4263
+ {
4264
+ return $this->statusLog($historyID, array('stage' => 'uploadDropBox', 'status' => 'error', 'statusMsg' => 'Dropbox verification failed: File may be corrupted.', 'statusCode' => 'dropbox_verification_failed_file_may_be_corrupted'));
4265
+ }
4266
+ if($del_host_file)
4267
+ {
4268
+ @unlink($backup_file);
4269
+ }
4270
  }
4271
+
4272
+ return $resArray;
4273
+
4274
+ }
4275
+ catch (Exception $e) {
4276
+ $this->_log($e->getMessage());
4277
+ return array(
4278
+ 'error' => $e->getMessage(),
4279
+ 'partial' => 1
4280
+ );
4281
  }
4282
 
4283
+ //return true;
4284
 
4285
+ }
4286
+ else {
4287
+ return array(
4288
+ 'error' => 'Please connect your InfiniteWP panel with your Dropbox account.', 'error_code' => 'please_connect_your_iwp_panel_with_your_dropbox_account'
4289
+ );
4290
+ }
 
 
 
 
 
 
 
 
 
 
4291
  }
 
 
4292
 
4293
 
4294
 
4326
 
4327
 
4328
  function get_dropbox_backup($args) {
4329
+ if ($this->iwp_mmb_function_exists('curl_init')) {
4330
+ extract($args);
4331
+ require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/dropbox.php';
 
 
 
 
 
 
 
 
 
 
 
4332
 
4333
+ $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret);
4334
+ $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret);
4335
+
4336
+ if ($dropbox_site_folder == true)
4337
+ $dropbox_destination .= '/' . $this->site_name;
4338
+
4339
+ //$temp = ABSPATH . 'iwp_temp_backup.zip';
4340
+ $temp = wp_tempnam('iwp_temp_backup.zip');
4341
+
4342
+ try {
4343
+
4344
+ //exception should handle the errors
4345
+ $dropbox->download($dropbox_destination.'/'.$backup_file, $temp);
4346
+ return $temp;
4347
+ } catch (Exception $e) {
4348
+ $this->_log($e->getMessage());
4349
+ return array(
4350
+ 'error' => $e->getMessage(),
4351
+ 'partial' => 1
4352
+ );
4353
+ }
4354
+ }
4355
+ else{
4356
  return array(
4357
+ 'error' => 1,
4358
+ );
 
4359
  }
 
4360
  }
4361
 
4362
  /*
4377
  function amazons3_backup($historyID , $args='' )
4378
  {
4379
  $s3StartTime = $this->iwpScriptStartTime;
4380
+ $this -> backup_settings_vals = get_option('iwp_client_multi_backup_temp_values');
4381
  $backup_settings_values = $this -> backup_settings_vals;
4382
+ if(isset($backup_settings_values['s3_retrace_count']) && !empty($backup_settings_values['s3_retrace_count']))
4383
  {
4384
  $s3_retrace_count = $backup_settings_values['s3_retrace_count'][$historyID];
4385
  }
4486
 
4487
  //$this->statusLog($this -> hisID, array('stage' => 'uploadingFilesAmazon', 'status' => 'partiallyCompleted', 'statusMsg' => 's3SingleCall'));
4488
 
4489
+ if (!$this->iwp_mmb_function_exists('curl_init')) {
4490
+ return array(
4491
+ 'error' => 'You cannot use Amazon S3 on your server. Please enable curl first.',
4492
+ 'partial' => 1, 'error_code' => 'cannot_use_s3_enable_curl_first'
4493
+ );
4494
+ }
4495
  require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon_s3/sdk.class.php');
4496
 
4497
  $tempArgs = $args;
4528
 
4529
  CFCredentials::set(array('development' => array('key' => trim($as3_access_key), 'secret' => trim(str_replace(' ', '+', $as3_secure_key)), 'default_cache_config' => '', 'certificate_authority' => true, 'use_ssl'=>false, 'ssl_verification'=>false), '@default' => 'development'));
4530
  $s3 = new AmazonS3();
4531
+ $cfu_obj = new CFUtilities;
4532
  //the mulitCall upload starts darkCode starts
4533
 
4534
 
4608
 
4609
 
4610
  //convert the response into an array
4611
+ $response_array = $cfu_obj->convert_response_to_array($response);
 
4612
 
4613
 
4614
  //get the uploadID
4670
 
4671
  echo "singleUploadResult - ".$singleUploadResult;
4672
 
4673
+ $singleUploadResponseArray = $cfu_obj->convert_response_to_array($singleUploadResponse);
4674
  /* $response = $s3->complete_multipart_upload($bucket, $filename, $upload_id, array(
4675
  array('PartNumber' => 1, 'ETag' => '"25e317773f308e446cc84c503a6d1f85"'),
4676
  array('PartNumber' => 2, 'ETag' => '"a6d1f85f58498973f308e446cc84c503"'),
4743
 
4744
  $response = $s3->abort_multipart_upload($as3_bucket, $as3_file, $upload_id );
4745
  }
4746
+ $response_array = $cfu_obj->convert_response_to_array($response);
4747
 
4748
  $current_file_num += 1;
4749
 
4874
  );
4875
  }
4876
  }
 
 
 
 
 
 
 
 
4877
  }
4878
 
4879
 
4926
 
4927
  function get_amazons3_backup($args)
4928
  {
4929
+ if ($this->iwp_mmb_function_exists('curl_init')) {
4930
+ require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon_s3/sdk.class.php');
4931
+ extract($args);
4932
+ $temp = '';
4933
+ try{
4934
+ CFCredentials::set(array('development' => array('key' => trim($as3_access_key), 'secret' => trim(str_replace(' ', '+', $as3_secure_key)), 'default_cache_config' => '', 'certificate_authority' => true), '@default' => 'development'));
4935
+ $s3 = new AmazonS3();
4936
+ if ($as3_site_folder == true)
 
4937
  {
4938
+ if(!empty($as3_directory))
4939
+ {
4940
+ $as3_directory .= '/' . $this->site_name;
4941
+ }
4942
+ else
4943
+ {
4944
+ $as3_directory = $this->site_name;
4945
+ }
4946
+ }
4947
+ if(empty($as3_directory))
4948
+ {
4949
+ $single_as3_file = $backup_file;
4950
  }
4951
  else
4952
  {
4953
+ $single_as3_file = $as3_directory . '/' . $backup_file;
4954
  }
4955
+
4956
+ //$temp = ABSPATH . 'iwp_temp_backup.zip';
4957
+ $temp = wp_tempnam('iwp_temp_backup.zip');
4958
+ $s3->get_object($as3_bucket, $single_as3_file, array("fileDownload" => $temp));
4959
+ } catch (Exception $e){
4960
+ return false;
4961
+ }
4962
+ return $temp;
4963
+ }
4964
+ else{
4965
+ return array(
4966
+ 'error' => 1,
4967
+ );
4968
+ }
 
 
 
4969
  }
4970
  //IWP Remove ends here
4971
 
5075
  //set $args, $uploadid, $offset from the DB
5076
  $responseParams = $this -> getRequiredData($historyID,"responseParams");
5077
 
5078
+ if(!$responseParams){
5079
  return $this->statusLog($this -> hisID, array('stage' => 'google_drive_upload', 'status' => 'error', 'statusMsg' => 'google Upload failed: Error while fetching table data.','statusCode' => 'google_upload_failed_error_fetching_data'));
5080
+ }
5081
 
5082
  $args = $responseParams['gDriveArgs'];
5083
  $prevChunkResults = $responseParams['response_data'];
5135
  try
5136
  {
5137
  $parameters = array();
5138
+ $parameters['q'] = "title = 'infinitewp' and trashed = false and 'root' in parents and 'me' in owners and mimeType= 'application/vnd.google-apps.folder'";
5139
  $files = $service->files->listFiles($parameters);
5140
  $list_result = array();
5141
  $list_result = array_merge($list_result, $files->getItems());
5158
  }
5159
  else
5160
  {
5161
+ foreach($list_result as $k => $v){
5162
+ $iwp_folder_id = $v->id;
5163
+ }
5164
  }
5165
  }catch (Exception $e){
5166
  print "An error occurred: " . $e->getMessage();
5167
+ return array('error' => $e->getMessage(), 'error_code' => 'google_error_occured_list_results');
5168
  }
5169
 
5170
  //create sub folder by site name
5171
  if($create_sub_folder)
5172
  {
5173
  $parameters = array();
5174
+ $parameters['q'] = "title = '$sub_folder_name' and trashed = false and '$iwp_folder_id' in parents and 'me' in owners and mimeType = 'application/vnd.google-apps.folder'";
5175
+ //$parameters['corpus'] = "DEFAULT";
5176
  $files = $service->files->listFiles($parameters);
5177
  $list_result = array();
5178
  $list_result = array_merge($list_result, $files->getItems());
5200
  }
5201
  else
5202
  {
5203
+ foreach($list_result as $k => $v){
5204
+ $sub_folder_id = $v->id;
5205
+ }
5206
  }
5207
  }
5208
 
5316
  }
5317
 
5318
  $current_file_num += 1;
 
5319
  $result_arr = array();
5320
+ $result_arr['response_data'] = (isset($createdFile) && !empty($createdFile['id'])) ? $createdFile['id'] : array();
5321
  $result_arr['status'] = "completed";
5322
  $result_arr['nextFunc'] = 'google_drive_completed';
5323
  $result_arr['gDriveArgs'] = $tempArgs;
5632
 
5633
  $backup_folder = WP_CONTENT_DIR . '/' . md5('iwp_mmb-client') . '/iwp_backups/';
5634
  $backup_folder_new = IWP_BACKUP_DIR . '/';
5635
+ $backup_temp_folder = IWP_PCLZIP_TEMPORARY_DIR;
5636
  $files = glob($backup_folder . "*");
5637
  $new = glob($backup_folder_new . "*");
5638
+ $new_temp = glob($backup_temp_folder . "*");
5639
 
5640
  //Failed db files first
5641
  $db_folder = IWP_DB_DIR . '/';
5650
 
5651
 
5652
  //clean_old folder?
5653
+ if ((count($files) == 1 && basename($files[0]) == 'index.php') || (!empty($files))) { //USE (!empty($files)
5654
+ foreach ($files as $file) {
5655
  @unlink($file);
5656
  }
5657
  @rmdir(WP_CONTENT_DIR . '/' . md5('iwp_mmb-client') . '/iwp_backups');
5663
  $files[] = $b;
5664
  }
5665
  }
5666
+ if (!empty($new_temp)) {
5667
+ foreach ($new_temp as $c) {
5668
+ $files[] = $c;
5669
+ }
5670
+ }
5671
  $deleted = array();
5672
 
5673
  if (is_array($files) && count($files)) {
5787
 
5788
  }
5789
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5790
  function wpdb_reconnect(){
5791
  global $wpdb;
5792
  $old_wpdb = $wpdb;
backup.class.singlecall.php CHANGED
@@ -146,6 +146,7 @@ class IWP_MMB_Backup_Singlecall extends IWP_MMB_Core
146
 
147
  function set_backup_task($params){
148
  if (!empty($params)) {
 
149
  $this->statusLog($historyID, array('stage' => 'verification', 'status' => 'processing', 'statusMsg' => 'verificationInitiated'), $params);
150
 
151
  $this->set_resource_limit();
@@ -172,25 +173,26 @@ class IWP_MMB_Backup_Singlecall extends IWP_MMB_Core
172
 
173
  return false;
174
  }
 
175
 
176
- function delete_task_now($task_name){
177
- global $wpdb;
178
 
179
- $table_name = $wpdb->base_prefix . "iwp_backup_status";
180
-
181
- $tasks = $this->tasks;
182
- //unset($tasks[$task_name]);
183
-
184
-
185
- $delete_query = "DELETE FROM ".$table_name." WHERE taskName = '".$task_name."' ";
186
- $deleteRes = $wpdb->query($delete_query);
187
-
188
- $this->update_tasks($tasks);
189
- $this->cleanup();
190
-
191
- return $task_name;
192
-
193
- }
194
 
195
  /*
196
  * If Task Name not set then it's manual backup
@@ -1155,571 +1157,7 @@ class IWP_MMB_Backup_Singlecall extends IWP_MMB_Core
1155
  * @param array $skip_list a list of files/folders to skip copying
1156
  * @return mixed WP_Error on failure, True on success.
1157
  */
1158
- function iwp_mmb_direct_to_any_copy_dir($from, $to, $skip_list = array() ) {//$from => direct file system, $to => automatic filesystem
1159
- global $wp_filesystem;
1160
-
1161
- $wp_temp_direct = new WP_Filesystem_Direct('');
1162
-
1163
-
1164
- $dirlist = $wp_temp_direct->dirlist($from);
1165
-
1166
- $from = trailingslashit($from);
1167
- $to = trailingslashit($to);
1168
-
1169
- $skip_regex = '';
1170
- foreach ( (array)$skip_list as $key => $skip_file )
1171
- $skip_regex .= preg_quote($skip_file, '!') . '|';
1172
-
1173
- if ( !empty($skip_regex) )
1174
- $skip_regex = '!(' . rtrim($skip_regex, '|') . ')$!i';
1175
-
1176
- foreach ( (array) $dirlist as $filename => $fileinfo ) {
1177
- if ( !empty($skip_regex) )
1178
- if ( preg_match($skip_regex, $from . $filename) )
1179
- continue;
1180
-
1181
- if ( 'f' == $fileinfo['type'] ) {
1182
- if ( ! $this->iwp_mmb_direct_to_any_copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) {
1183
- // If copy failed, chmod file to 0644 and try again.
1184
- $wp_filesystem->chmod($to . $filename, 0644);
1185
- if ( ! $this->iwp_mmb_direct_to_any_copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) )
1186
- return new WP_Error('copy_failed', __('Could not copy file.'), $to . $filename);
1187
- }
1188
- } elseif ( 'd' == $fileinfo['type'] ) {
1189
- if ( !$wp_filesystem->is_dir($to . $filename) ) {
1190
- if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )
1191
- return new WP_Error('mkdir_failed', __('Could not create directory.'), $to . $filename);
1192
- }
1193
- $result = $this->iwp_mmb_direct_to_any_copy_dir($from . $filename, $to . $filename, $skip_list);
1194
- if ( is_wp_error($result) )
1195
- return $result;
1196
- }
1197
- }
1198
- return true;
1199
- }
1200
-
1201
- function iwp_mmb_direct_to_any_copy($source, $destination, $overwrite = false, $mode = false){
1202
- global $wp_filesystem;
1203
- if($wp_filesystem->method == 'direct'){
1204
- return $wp_filesystem->copy($source, $destination, $overwrite, $mode);
1205
- }
1206
- elseif($wp_filesystem->method == 'ftpext' || $wp_filesystem->method == 'ftpsockets'){
1207
- if ( ! $overwrite && $wp_filesystem->exists($destination) )
1208
- return false;
1209
- //$content = $this->get_contents($source);
1210
- // if ( false === $content)
1211
- // return false;
1212
-
1213
- //put content
1214
- //$tempfile = wp_tempnam($file);
1215
- $source_handle = fopen($source, 'r');
1216
- if ( ! $source_handle )
1217
- return false;
1218
-
1219
- //fwrite($temp, $contents);
1220
- //fseek($temp, 0); //Skip back to the start of the file being written to
1221
-
1222
- $sample_content = fread($source_handle, (1024 * 1024 * 2));//1024 * 1024 * 2 => 2MB
1223
- fseek($source_handle, 0); //Skip back to the start of the file being written to
1224
-
1225
- $type = $wp_filesystem->is_binary($sample_content) ? FTP_BINARY : FTP_ASCII;
1226
- unset($sample_content);
1227
- if($wp_filesystem->method == 'ftpext'){
1228
- $ret = @ftp_fput($wp_filesystem->link, $destination, $source_handle, $type);
1229
- }
1230
- elseif($wp_filesystem->method == 'ftpsockets'){
1231
- $wp_filesystem->ftp->SetType($type);
1232
- $ret = $wp_filesystem->ftp->fput($destination, $source_handle);
1233
- }
1234
-
1235
- fclose($source_handle);
1236
- unlink($source);//to immediately save system space
1237
- //unlink($tempfile);
1238
-
1239
- $wp_filesystem->chmod($destination, $mode);
1240
-
1241
- return $ret;
1242
-
1243
- //return $this->put_contents($destination, $content, $mode);
1244
- }
1245
- }
1246
-
1247
-
1248
- function restore($args)
1249
- {
1250
- global $wpdb, $wp_filesystem;
1251
- if (empty($args)) {
1252
- return false;
1253
- }
1254
-
1255
- extract($args);
1256
- $this->set_resource_limit();
1257
-
1258
- $unlink_file = true; //Delete file after restore
1259
-
1260
- include_once ABSPATH . 'wp-admin/includes/file.php';
1261
-
1262
- //Detect source
1263
- if ($backup_url) {
1264
- //This is for clone (overwrite)
1265
-
1266
- $backup_file = download_url($backup_url);
1267
- if (is_wp_error($backup_file)) {
1268
- return array(
1269
- 'error' => 'Unable to download backup file ('.$backup_file->get_error_message().')', 'error_code' => 'unable_to_download_backup_file'
1270
- );
1271
- }
1272
- $what = 'full';
1273
- } else {
1274
- /*$tasks = $this->tasks;
1275
- $task = $tasks[$task_name];*/
1276
- $tasks = $this->get_requested_task($result_id);
1277
- $backup = $tasks['taskResults'][$result_id];
1278
-
1279
- $requestParams = unserialize($tasks['requestParams']);
1280
- $args = $requestParams['secure']['account_info'];
1281
-
1282
- if (isset($backup['server'])) {
1283
- $backup_file = $backup['server']['file_path'];
1284
- $unlink_file = false; //Don't delete file if stored on server
1285
-
1286
- }
1287
- elseif (isset($backup['ftp'])) {
1288
- $ftp_file = $backup['ftp'];
1289
- $args = $args['iwp_ftp'];
1290
-
1291
- $args['backup_file'] = $ftp_file;
1292
-
1293
- iwp_mmb_print_flush('FTP download: Start');
1294
- $backup_file = $this->get_ftp_backup($args);
1295
- iwp_mmb_print_flush('FTP download: End');
1296
-
1297
- if ($backup_file == false) {
1298
- return array(
1299
- 'error' => 'Failed to download file from FTP.', 'error_code' => 'download_failed_ftp'
1300
- );
1301
- }
1302
- }
1303
- elseif (isset($backup['amazons3'])) {
1304
- $amazons3_file = $backup['amazons3'];
1305
- $args = $args['iwp_amazon_s3'];
1306
- $args['backup_file'] = $amazons3_file;
1307
-
1308
- iwp_mmb_print_flush('Amazon S3 download: Start');
1309
- $backup_file = $this->get_amazons3_backup($args);
1310
- iwp_mmb_print_flush('Amazon S3 download: End');
1311
-
1312
- if ($backup_file == false) {
1313
- return array(
1314
- 'error' => 'Failed to download file from Amazon S3.', 'error_code' => 'download_failed_s3'
1315
- );
1316
- }
1317
- }
1318
- elseif(isset($backup['dropbox'])){
1319
- $dropbox_file = $backup['dropbox'];
1320
- $args = $args['iwp_dropbox'];
1321
- $args['backup_file'] = $dropbox_file;
1322
- iwp_mmb_print_flush('Dropbox download: Start');
1323
- $backup_file = $this->get_dropbox_backup($args);
1324
- iwp_mmb_print_flush('Dropbox download: End');
1325
-
1326
- if ($backup_file == false) {
1327
- return array(
1328
- 'error' => 'Failed to download file from Dropbox.', 'error_code' => 'download_failed_dropbox'
1329
- );
1330
- }
1331
- }
1332
- elseif(isset($backup['gDrive'])){
1333
- $gdrive_file = $backup['gDrive'];
1334
- $args = $args['iwp_gdrive'];
1335
- $args['backup_file'] = $gdrive_file;
1336
- iwp_mmb_print_flush('gDrive download: Start');
1337
- $backup_file = $this->get_google_drive_backup($args);
1338
- iwp_mmb_print_flush('gDrive download: End');
1339
-
1340
- if(is_array($backup_file) && array_key_exists('error', $backup_file))
1341
- {
1342
- return $backup_file;
1343
- }
1344
-
1345
- if ($backup_file == false) {
1346
- return array(
1347
- 'error' => 'Failed to download file from gDrive.'
1348
- );
1349
- }
1350
- }
1351
-
1352
- $what = $requestParams['args']['what'];
1353
- }
1354
- $this->wpdb_reconnect();
1355
-
1356
- /////////////////// dev ////////////////////////
1357
-
1358
- if (!$this->is_server_writable()) {
1359
- return array(
1360
- 'error' => 'Failed, please add FTP details', 'error_code' => 'failed_please_add_ftp_details'
1361
- );
1362
- }
1363
-
1364
-
1365
- $url = wp_nonce_url('index.php?page=iwp_no_page','iwp_fs_cred');
1366
- ob_start();
1367
- if (false === ($creds = request_filesystem_credentials($url, '', false, ABSPATH, null) ) ) {
1368
- return array(
1369
- 'error' => 'Unable to get file system credentials', 'error_code' => 'unable_to_get_file_system_credentials'
1370
- ); // stop processing here
1371
- }
1372
- ob_end_clean();
1373
-
1374
- if ( ! WP_Filesystem($creds, ABSPATH) ) {
1375
- //request_filesystem_credentials($url, '', true, false, null);
1376
- return array(
1377
- 'error' => 'Unable to initiate file system. Please check you have entered valid FTP credentials.', 'error_code' => 'unable_to_initiate_file_system__check_FTP_credentials.'
1378
- ); // stop processing here
1379
- //return;
1380
- }
1381
-
1382
- require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php');//will be used to copy from temp directory
1383
-
1384
- // do process
1385
- $temp_dir = get_temp_dir();
1386
- $new_temp_folder = untrailingslashit($temp_dir);
1387
- $temp_uniq = md5(microtime(1));//should be random
1388
- while (is_dir($new_temp_folder .'/'. $temp_uniq )) {
1389
- $temp_uniq = md5(microtime(1));
1390
- }
1391
- $new_temp_folder = trailingslashit($new_temp_folder .'/'. $temp_uniq);
1392
- $is_dir_created = mkdir($new_temp_folder);// new folder should be empty
1393
- if(!$is_dir_created){
1394
- return array(
1395
- 'error' => 'Unable to create a temporary directory.', 'error_code' => 'unable_to_create_a_temp_directory.'
1396
- );
1397
- }
1398
-
1399
-
1400
-
1401
- $remote_abspath = $wp_filesystem->abspath();
1402
- if(!empty($remote_abspath)){
1403
- $remote_abspath = trailingslashit($remote_abspath);
1404
- }else{
1405
- return array(
1406
- 'error' => 'Unable to locate WP root directory using file system.', 'error_code' => 'unable_to_locate_wp_root_directory_using_file_system.'
1407
- );
1408
- }
1409
-
1410
- //global $wp_filesystem;
1411
- // $wp_filesystem->put_contents(
1412
- // '/tmp/example.txt',
1413
- // 'Example contents of a file',
1414
- // FS_CHMOD_FILE // predefined mode settings for WP files
1415
- // );
1416
-
1417
- /////////////////// dev ////////////////////////
1418
-
1419
- if ($backup_file && file_exists($backup_file)) {
1420
- if ($overwrite) {//clone only fresh or existing to existing
1421
- //Keep old db credentials before overwrite
1422
- if (!$wp_filesystem->copy($remote_abspath . 'wp-config.php', $remote_abspath . 'iwp-temp-wp-config.php', true)) {
1423
- if($unlink_file) @unlink($backup_file);
1424
- return array(
1425
- 'error' => 'Error creating wp-config. Please check your write permissions.', 'error_code' => 'error_creating_wpconfig_check_permissions'
1426
- );
1427
- }
1428
-
1429
- $db_host = DB_HOST;
1430
- $db_user = DB_USER;
1431
- $db_password = DB_PASSWORD;
1432
- $home = rtrim(get_option('home'), "/");
1433
- $site_url = get_option('site_url');
1434
-
1435
- $clone_options = array();
1436
- if (trim($clone_from_url) || trim($iwp_clone) || trim($maintain_old_key)) {
1437
-
1438
- $clone_options['iwp_client_nossl_key'] = get_option('iwp_client_nossl_key');
1439
- $clone_options['iwp_client_public_key'] = get_option('iwp_client_public_key');
1440
- $clone_options['iwp_client_action_message_id'] = get_option('iwp_client_action_message_id');
1441
-
1442
- }
1443
-
1444
- //$clone_options['iwp_client_backup_tasks'] = serialize(get_option('iwp_client_backup_tasks'));
1445
- $clone_options['iwp_client_notifications'] = serialize(get_option('iwp_client_notifications'));
1446
- $clone_options['iwp_client_pageview_alerts'] = serialize(get_option('iwp_client_pageview_alerts'));
1447
-
1448
- $clone_options['iwp_client_backup_tasks'] = "selet * from iwp_backup_status";
1449
-
1450
-
1451
- } else {
1452
-
1453
- $restore_options = array();
1454
- $restore_options['iwp_client_notifications'] = serialize(get_option('iwp_client_notifications'));
1455
- $restore_options['iwp_client_pageview_alerts'] = serialize(get_option('iwp_client_pageview_alerts'));
1456
- $restore_options['iwp_client_user_hit_count'] = serialize(get_option('iwp_client_user_hit_count'));
1457
- //$restore_options['iwp_client_backup_tasks'] = serialize(get_option('iwp_client_backup_tasks'));
1458
-
1459
- $restore_options['iwp_client_backup_tasks'] = "selet * from iwp_backup_status";
1460
- }
1461
-
1462
-
1463
-
1464
-
1465
- //Backup file will be extracted to a temporary path
1466
-
1467
- //chdir(ABSPATH);
1468
- $unzip = $this->get_unzip();
1469
- $command = "$unzip -o $backup_file -d $new_temp_folder";
1470
- iwp_mmb_print_flush('ZIP Extract CMD: Start');
1471
- ob_start();
1472
- $result = $this->iwp_mmb_exec($command);
1473
- ob_get_clean();
1474
- iwp_mmb_print_flush('ZIP Extract CMD: End');
1475
-
1476
- if (!$result) { //fallback to pclzip
1477
- define('IWP_PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
1478
- //require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
1479
- require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
1480
- iwp_mmb_print_flush('ZIP Extract PCL: Start');
1481
- $archive = new IWPPclZip($backup_file);
1482
- $result = $archive->extract(IWP_PCLZIP_OPT_PATH, $new_temp_folder, IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1); //actual
1483
- //$result = $archive->extract(IWP_PCLZIP_OPT_PATH, $new_temp_folder, IWP_PCLZIP_OPT_REMOVE_PATH, $GLOBALS['iwp_mmb_plugin_dir'], IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
1484
- iwp_mmb_print_flush('ZIP Extract PCL: End');
1485
- }
1486
- $this->wpdb_reconnect();
1487
-
1488
- if ($unlink_file) {
1489
- @unlink($backup_file);
1490
- }
1491
-
1492
- if (!$result) {
1493
- return array(
1494
- 'error' => 'Failed to unzip files. pclZip error (' . $archive->error_code . '): .' . $archive->error_string, 'error_code' => 'failed_to_unzip_files_pclZip_error'
1495
- );
1496
- }
1497
-
1498
- $db_result = $this->restore_db($new_temp_folder);
1499
-
1500
- if (!$db_result) {
1501
- return array(
1502
- 'error' => 'Error restoring database.', 'error_code' => 'error_restoring_db'
1503
- );
1504
- } else if(is_array($db_result) && isset($db_result['error'])){
1505
- return array(
1506
- 'error' => $db_result['error']
1507
- );
1508
- }
1509
-
1510
- } else {
1511
- return array(
1512
- 'error' => 'Backup file not found.', 'error_code' => 'backup_file_not_found'
1513
- );
1514
- }
1515
-
1516
-
1517
- //copy files from temp to ABSPATH
1518
- $copy_result = $this->iwp_mmb_direct_to_any_copy_dir($new_temp_folder, $remote_abspath);
1519
-
1520
- if ( is_wp_error($copy_result) ){
1521
- $wp_temp_direct2 = new WP_Filesystem_Direct('');
1522
- $wp_temp_direct2->delete($new_temp_folder, true);
1523
- return $copy_result;
1524
- }
1525
-
1526
-
1527
- $this->wpdb_reconnect();
1528
-
1529
-
1530
-
1531
- //Replace options and content urls
1532
- if ($overwrite) {//fresh WP package or existing to existing site
1533
- //Get New Table prefix
1534
- $new_table_prefix = trim($this->get_table_prefix());
1535
- //Retrieve old wp_config
1536
- //@unlink(ABSPATH . 'wp-config.php');
1537
- $wp_filesystem->delete($remote_abspath . 'wp-config.php', false, 'f');
1538
- //Replace table prefix
1539
- //$lines = file(ABSPATH . 'iwp-temp-wp-config.php');
1540
- $lines = $wp_filesystem->get_contents_array($remote_abspath . 'iwp-temp-wp-config.php');
1541
-
1542
- $new_lines = '';
1543
- foreach ($lines as $line) {
1544
- if (strstr($line, '$table_prefix')) {
1545
- $line = '$table_prefix = "' . $new_table_prefix . '";' . PHP_EOL;
1546
- }
1547
- $new_lines .= $line;
1548
- //file_put_contents(ABSPATH . 'wp-config.php', $line, FILE_APPEND);
1549
- }
1550
-
1551
- $wp_filesystem->put_contents($remote_abspath . 'wp-config.php', $new_lines);
1552
-
1553
- //@unlink(ABSPATH . 'iwp-temp-wp-config.php');
1554
- $wp_filesystem->delete($remote_abspath . 'iwp-temp-wp-config.php', false, 'f');
1555
-
1556
- //Replace options
1557
- $query = "SELECT option_value FROM " . $new_table_prefix . "options WHERE option_name = 'home'";
1558
- $old = $wpdb->get_var($query);
1559
- $old = rtrim($old, "/");
1560
- $query = "UPDATE " . $new_table_prefix . "options SET option_value = %s WHERE option_name = 'home'";
1561
- $wpdb->query($wpdb->prepare($query, $home));
1562
- $query = "UPDATE " . $new_table_prefix . "options SET option_value = %s WHERE option_name = 'siteurl'";
1563
- $wpdb->query($wpdb->prepare($query, $home));
1564
- //Replace content urls
1565
-
1566
- $regexp1 = 'src="(.*)'.$old.'(.*)"';
1567
- $regexp2 = 'href="(.*)'.$old.'(.*)"';
1568
- $query = "UPDATE " . $new_table_prefix . "posts SET post_content = REPLACE (post_content, %s,%s) WHERE post_content REGEXP %s OR post_content REGEXP %s";
1569
- $wpdb->query($wpdb->prepare($query, $old, $home, $regexp1, $regexp2));
1570
-
1571
- if (trim($new_password)) {
1572
- $new_password = wp_hash_password($new_password);
1573
- }
1574
- if (!trim($clone_from_url) && !trim($iwp_clone)) {
1575
- if ($new_user && $new_password) {
1576
- $query = "UPDATE " . $new_table_prefix . "users SET user_login = %s, user_pass = %s WHERE user_login = %s";
1577
- $wpdb->query($wpdb->prepare($query, $new_user, $new_password, $old_user));
1578
- }
1579
- } else {
1580
-
1581
- // if ($iwp_clone) {
1582
- if ($admin_email) {
1583
- //Clean Install
1584
- $query = "UPDATE " . $new_table_prefix . "options SET option_value = %s WHERE option_name = 'admin_email'";
1585
- $wpdb->query($wpdb->prepare($query, $admin_email));
1586
- $query = "SELECT * FROM " . $new_table_prefix . "users LIMIT 1";
1587
- $temp_user = $wpdb->get_row($query);
1588
- if (!empty($temp_user)) {
1589
- $query = "UPDATE " . $new_table_prefix . "users SET user_email=%s, user_login = %s, user_pass = %s WHERE user_login = %s";
1590
- $wpdb->query($wpdb->prepare($query, $admin_email, $new_user, $new_password, $temp_user->user_login));
1591
- }
1592
-
1593
- }
1594
- // }
1595
-
1596
- //if ($clone_from_url) {
1597
- if ($new_user && $new_password) {
1598
- $query = "UPDATE " . $new_table_prefix . "users SET user_pass = %s WHERE user_login = %s";
1599
- $wpdb->query($wpdb->prepare($query, $new_password, $new_user));
1600
- }
1601
- // }
1602
-
1603
- }
1604
-
1605
- if (is_array($clone_options) && !empty($clone_options)) {
1606
- foreach ($clone_options as $key => $option) {
1607
- if (!empty($key)) {
1608
- $query = "SELECT option_value FROM " . $new_table_prefix . "options WHERE option_name = %s";
1609
- $res = $wpdb->get_var($wpdb->prepare($query, $key));
1610
- if ($res == false) {
1611
- $query = "INSERT INTO " . $new_table_prefix . "options (option_value,option_name) VALUES(%s,%s)";
1612
- $wpdb->query($wpdb->prepare($query, $option, $key));
1613
- } else {
1614
- $query = "UPDATE " . $new_table_prefix . "options SET option_value = %s WHERE option_name = %s";
1615
- $wpdb->query($wpdb->prepare($query, $option, $key));
1616
- }
1617
- }
1618
- }
1619
- }
1620
-
1621
- //Remove hit count
1622
- $query = "DELETE FROM " . $new_table_prefix . "options WHERE option_name = 'iwp_client_user_hit_count'";
1623
- $wpdb->query($query);
1624
-
1625
- //Check for .htaccess permalinks update
1626
- $this->replace_htaccess($home, $remote_abspath);
1627
- } else {
1628
- //restore client options
1629
- if (is_array($restore_options) && !empty($restore_options)) {
1630
- foreach ($restore_options as $key => $option) {
1631
- if (!empty($key)) {
1632
- $query = "SELECT option_value FROM " . $wpdb->base_prefix . "options WHERE option_name = %s";
1633
- $res = $wpdb->get_var($wpdb->prepare($query, $key));
1634
- if ($res == false) {
1635
- $query = "INSERT INTO " . $wpdb->base_prefix . "options (option_value,option_name) VALUES(%s,%s)";
1636
- $wpdb->query($wpdb->prepare($query, $option, $key));
1637
- } else {
1638
- $query = "UPDATE " . $wpdb->base_prefix . "options SET option_value = %s WHERE option_name = %s";
1639
- $wpdb->query($wpdb->prepare($query, $option, $key));
1640
- }
1641
- }
1642
-
1643
- /*$test = update_option($key,$option);*/
1644
- }
1645
- }
1646
- }
1647
-
1648
- //clear the temp directory
1649
- $wp_temp_direct2 = new WP_Filesystem_Direct('');
1650
- $wp_temp_direct2->delete($new_temp_folder, true);
1651
-
1652
- return !empty($new_user) ? $new_user : true ;
1653
- }
1654
-
1655
- function restore_db($new_temp_folder)
1656
- {
1657
- global $wpdb;
1658
- $paths = $this->check_mysql_paths();
1659
- $file_path = $new_temp_folder . '/iwp_db';
1660
- @chmod($file_path,0755);
1661
- $file_name = glob($file_path . '/*.sql');
1662
- $file_name = $file_name[0];
1663
-
1664
- if(!$file_name){
1665
- return array('error' => 'Cannot access database file.');
1666
- }
1667
-
1668
- $brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
1669
- $command = $brace . $paths['mysql'] . $brace . ' --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" --default-character-set="utf8" ' . DB_NAME . ' < ' . $brace . $file_name . $brace;
1670
- iwp_mmb_print_flush('DB Restore CMD: Start');
1671
- ob_start();
1672
- $result = $this->iwp_mmb_exec($command);
1673
- ob_get_clean();
1674
- iwp_mmb_print_flush('DB Restore CMD: End');
1675
- if (!$result) {
1676
- //try php
1677
- $this->restore_db_php($file_name);
1678
- }
1679
-
1680
-
1681
- @unlink($file_name);
1682
- @unlink(dirname($file_name).'/index.php');
1683
- @rmdir(dirname($file_name));//remove its folder
1684
- return true;
1685
- }
1686
-
1687
- function restore_db_php($file_name)
1688
- {
1689
-
1690
- $this->wpdb_reconnect();
1691
- global $wpdb;
1692
-
1693
- $wpdb->query("SET NAMES 'utf8'");
1694
-
1695
- $current_query = '';
1696
- // Read in entire file
1697
- $lines = file($file_name);
1698
- // Loop through each line
1699
- if(!empty($lines)){
1700
- foreach ($lines as $line) {
1701
- iwp_mmb_auto_print('restore_db_php');
1702
- // Skip it if it's a comment
1703
- if (substr($line, 0, 2) == '--' || $line == '')
1704
- continue;
1705
-
1706
- // Add this line to the current query
1707
- $current_query .= $line;
1708
- // If it has a semicolon at the end, it's the end of the query
1709
- if (substr(trim($line), -1, 1) == ';') {
1710
- // Perform the query
1711
- $result = $wpdb->query($current_query);
1712
- if ($result === false)
1713
- return false;
1714
- // Reset temp variable to empty
1715
- $current_query = '';
1716
- }
1717
- }
1718
- }
1719
-
1720
- return true;
1721
- }
1722
-
1723
  function get_table_prefix()
1724
  {
1725
  $lines = file(ABSPATH . 'wp-config.php');
@@ -2472,126 +1910,49 @@ function ftp_backup($args)
2472
  }
2473
 
2474
  }
2475
-
2476
- function get_ftp_backup($args)
2477
- {
2478
- extract($args);
2479
- //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder
2480
- if(isset($use_sftp) && $use_sftp==1) {
2481
- $port = $ftp_port ? $ftp_port : 22; //default port is 22
2482
- /*
2483
- * SFTP section start here phpseclib library is used for this functionality
2484
- */
2485
- $iwp_mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
2486
- $path = $iwp_mmb_plugin_dir.'/lib/phpseclib';
2487
- set_include_path(get_include_path() . PATH_SEPARATOR . $path);
2488
- include_once('Net/SFTP.php');
2489
-
2490
-
2491
- $sftp = new Net_SFTP($ftp_hostname,$port);
2492
- if(!$sftp) {
2493
- return array(
2494
- 'error' => 'Failed to connect to ' . $ftp_hostname,
2495
- 'partial' => 1
2496
- );
2497
- }
2498
- if (!$sftp->login($ftp_username, $ftp_password)) {
2499
- return array(
2500
- 'error' => 'FTP login failed for ' . $ftp_username . ', ' . $ftp_password,
2501
- 'partial' => 1
2502
- );
2503
- } else {
2504
- if ($ftp_site_folder) {
2505
- $ftp_remote_folder .= '/' . $this->site_name;
2506
- }
2507
- $remote_loation = basename($backup_file);
2508
- $local_location = $backup_file;
2509
-
2510
- $sftp->chdir($ftp_remote_folder);
2511
- //$sftp->delete(basename($backup_file));
2512
- $temp = wp_tempnam('iwp_temp_backup.zip');
2513
-
2514
- $get = $sftp->get(basename($backup_file), $temp);
2515
- if ($get === false) {
2516
- return false;
2517
- } else {
2518
- return $temp;
2519
- }
2520
- //SFTP library has automatic connection closed. So no need to call seperate connection close function
2521
-
2522
- }
2523
-
2524
- } else {
2525
- $port = $ftp_port ? $ftp_port : 21; //default port is 21
2526
- if ($ftp_ssl && function_exists('ftp_ssl_connect')) {
2527
- $conn_id = ftp_ssl_connect($ftp_hostname,$port);
2528
-
2529
- } else if (function_exists('ftp_connect')) {
2530
- $conn_id = ftp_connect($ftp_hostname,$port);
2531
- if ($conn_id === false) {
2532
- return false;
2533
- }
2534
- }
2535
- $login = @ftp_login($conn_id, $ftp_username, $ftp_password);
2536
- if ($login === false) {
2537
- return false;
2538
- }
2539
-
2540
- if ($ftp_site_folder)
2541
- $ftp_remote_folder .= '/' . $this->site_name;
2542
-
2543
- if($ftp_passive){
2544
- @ftp_pasv($conn_id,true);
2545
- }
2546
-
2547
- //$temp = ABSPATH . 'iwp_temp_backup.zip';
2548
- $temp = wp_tempnam('iwp_temp_backup.zip');
2549
-
2550
- $get = ftp_get($conn_id, $temp, $ftp_remote_folder . '/' . $backup_file, FTP_BINARY);
2551
- if ($get === false) {
2552
- return false;
2553
- } else {
2554
- }
2555
- ftp_close($conn_id);
2556
-
2557
- return $temp;
2558
- }
2559
- }
2560
 
2561
 
2562
  function dropbox_backup($args){
2563
  extract($args);
2564
 
2565
- if(isset($consumer_secret) && !empty($consumer_secret)){
2566
-
2567
- require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/dropbox.php';
2568
-
2569
- $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret);
2570
- $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret);
2571
-
2572
- if ($dropbox_site_folder == true)
2573
- $dropbox_destination .= '/' . $this->site_name . '/' . basename($backup_file);
2574
- else
2575
- $dropbox_destination .= '/' . basename($backup_file);
2576
-
2577
- try {
2578
- $dropbox->upload($backup_file, $dropbox_destination, true);
2579
- } catch (Exception $e) {
2580
- $this->_log($e->getMessage());
2581
- return array(
2582
- 'error' => $e->getMessage(),
2583
- 'partial' => 1
2584
- );
2585
- }
2586
-
2587
- return true;
2588
-
2589
- } else {
 
 
 
 
 
 
 
 
2590
  return array(
2591
- 'error' => 'Please connect your InfiniteWP panel with your Dropbox account.',
2592
- 'error_code' => 'please_connect_dropbox_account_with_panel'
2593
  );
2594
- }
2595
 
2596
  }
2597
 
@@ -2629,42 +1990,6 @@ function ftp_backup($args)
2629
  }
2630
 
2631
 
2632
- function get_dropbox_backup($args) {
2633
- extract($args);
2634
-
2635
- require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/dropbox.php';
2636
-
2637
- $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret);
2638
- $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret);
2639
-
2640
- if ($dropbox_site_folder == true)
2641
- $dropbox_destination .= '/' . $this->site_name;
2642
-
2643
- //$temp = ABSPATH . 'iwp_temp_backup.zip';
2644
- $temp = wp_tempnam('iwp_temp_backup.zip');
2645
-
2646
- try {
2647
-
2648
- $file = $dropbox->download($dropbox_destination.'/'.$backup_file);
2649
- $handle = @fopen($temp, 'w');
2650
- $result = fwrite($handle, $file);
2651
- fclose($handle);
2652
-
2653
- if($result)
2654
- return $temp;
2655
- else
2656
- return false;
2657
- } catch (Exception $e) {
2658
- $this->_log($e->getMessage());
2659
- return array(
2660
- 'error' => $e->getMessage(),
2661
- 'erro_code' => 'download_error_s3',
2662
- 'partial' => 1
2663
- );
2664
- }
2665
- }
2666
-
2667
-
2668
  function amazons3_backup($args)
2669
  {
2670
  if ($this->iwp_mmb_function_exists('curl_init')) {
@@ -2777,7 +2102,7 @@ function ftp_backup($args)
2777
  try
2778
  {
2779
  $parameters = array();
2780
- $parameters['q'] = "title = 'infinitewp' and trashed = false and mimeType= 'application/vnd.google-apps.folder'";
2781
  $files = $service->files->listFiles($parameters);
2782
  $list_result = array();
2783
  $list_result = array_merge($list_result, $files->getItems());
@@ -2812,7 +2137,7 @@ function ftp_backup($args)
2812
  if($create_sub_folder)
2813
  {
2814
  $parameters = array();
2815
- $parameters['q'] = "title = '$sub_folder_name' and trashed = false and mimeType = 'application/vnd.google-apps.folder'";
2816
  $files = $service->files->listFiles($parameters);
2817
  $list_result = array();
2818
  $list_result = array_merge($list_result, $files->getItems());
@@ -2989,113 +2314,7 @@ function ftp_backup($args)
2989
  }
2990
  }
2991
 
2992
- function get_amazons3_backup($args)
2993
- {
2994
- require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon_s3/sdk.class.php');
2995
- extract($args);
2996
- $temp = '';
2997
- try{
2998
- CFCredentials::set(array('development' => array('key' => trim($as3_access_key), 'secret' => trim(str_replace(' ', '+', $as3_secure_key)), 'default_cache_config' => '', 'certificate_authority' => true), '@default' => 'development'));
2999
- $s3 = new AmazonS3();
3000
- if ($as3_site_folder == true)
3001
- {
3002
- if(!empty($as3_directory))
3003
- {
3004
- $as3_directory .= '/' . $this->site_name;
3005
- }
3006
- else
3007
- {
3008
- $as3_directory = $this->site_name;
3009
- }
3010
- }
3011
- if(empty($as3_directory))
3012
- {
3013
- $single_as3_file = $backup_file;
3014
- }
3015
- else
3016
- {
3017
- $single_as3_file = $as3_directory . '/' . $backup_file;
3018
- }
3019
-
3020
- //$temp = ABSPATH . 'iwp_temp_backup.zip';
3021
- $temp = wp_tempnam('iwp_temp_backup.zip');
3022
- $s3->get_object($as3_bucket, $as3_directory . '/' . $backup_file, array("fileDownload" => $temp));
3023
- } catch (Exception $e){
3024
- return $temp;
3025
- }
3026
- return $temp;
3027
- }
3028
  //IWP Remove ends here
3029
-
3030
- function get_google_drive_backup($args)
3031
- {
3032
- require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/Google/Client.php');
3033
- require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/Google/Service/Drive.php');
3034
-
3035
- //refresh token
3036
- $client = new IWP_google_Client();
3037
- $client->setClientId($args['clientID']);
3038
- $client->setClientSecret($args['clientSecretKey']);
3039
- $client->setRedirectUri($args['redirectURL']);
3040
- $client->setScopes(array(
3041
- 'https://www.googleapis.com/auth/drive',
3042
- 'https://www.googleapis.com/auth/userinfo.email',
3043
- 'https://www.googleapis.com/auth/userinfo.profile'));
3044
-
3045
- //$client->setUseObjects(true);
3046
-
3047
- $accessToken = $args['token'];
3048
- $refreshToken = $accessToken['refresh_token'];
3049
-
3050
- try
3051
- {
3052
- $client->refreshToken($refreshToken);
3053
- }
3054
- catch(Exception $e)
3055
- {
3056
- echo 'google Error ', $e->getMessage(), "\n";
3057
- return array("error" => $e->getMessage(), "error_code" => "google_error_get_backup_refresh_token");
3058
- }
3059
-
3060
- //downloading the file
3061
- $service = new IWP_google_Service_Drive($client);
3062
-
3063
- $file = $service->files->get($fileId);
3064
-
3065
- $downloadUrl = $file->getDownloadUrl();
3066
-
3067
- $temp = wp_tempnam('iwp_temp_backup.zip');
3068
-
3069
- try
3070
- {
3071
- if ($downloadUrl)
3072
- {
3073
- $request = new IWP_google_Http_Request($downloadUrl, 'GET', null, null);
3074
-
3075
- $signHttpRequest = $client->getAuth()->sign($request);
3076
- $httpRequest = $client->getIo()->makeRequest($signHttpRequest);
3077
-
3078
- if ($httpRequest->getResponseHttpCode() == 200) {
3079
- file_put_contents($temp, $httpRequest->getResponseBody());
3080
- return $temp;
3081
- } else {
3082
- // An error occurred.
3083
- return array("error" => "There is some error.", "error_code" => "google_error_bad_response_code_single_call");
3084
- }
3085
- }
3086
- else
3087
- {
3088
- // The file doesn't have any content stored on Drive.
3089
- return array("error" => "Google Drive file doesnt have any content.", "error_code" => "google_error_no_content_single_call");
3090
- }
3091
- }catch(Exception $e)
3092
- {
3093
- echo 'google Error ', $e->getMessage(), "\n";
3094
- return array("error" => $e->getMessage(), "error_code" => "google_error_get_backup_single_call");
3095
- }
3096
-
3097
-
3098
- }
3099
 
3100
  function remove_google_drive_backup($args)
3101
  {
@@ -3863,5 +3082,4 @@ if (!function_exists('get_all_files_from_dir_recursive')) {
3863
  }
3864
  }
3865
  }
3866
-
3867
  ?>
146
 
147
  function set_backup_task($params){
148
  if (!empty($params)) {
149
+
150
  $this->statusLog($historyID, array('stage' => 'verification', 'status' => 'processing', 'statusMsg' => 'verificationInitiated'), $params);
151
 
152
  $this->set_resource_limit();
173
 
174
  return false;
175
  }
176
+
177
 
178
+ function delete_task_now($task_name){
179
+ global $wpdb;
180
 
181
+ $table_name = $wpdb->base_prefix . "iwp_backup_status";
182
+
183
+ $tasks = $this->tasks;
184
+ //unset($tasks[$task_name]);
185
+
186
+
187
+ $delete_query = "DELETE FROM ".$table_name." WHERE taskName = '".$task_name."' ";
188
+ $deleteRes = $wpdb->query($delete_query);
189
+
190
+ $this->update_tasks($tasks);
191
+ $this->cleanup();
192
+
193
+ return $task_name;
194
+
195
+ }
196
 
197
  /*
198
  * If Task Name not set then it's manual backup
1157
  * @param array $skip_list a list of files/folders to skip copying
1158
  * @return mixed WP_Error on failure, True on success.
1159
  */
1160
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1161
  function get_table_prefix()
1162
  {
1163
  $lines = file(ABSPATH . 'wp-config.php');
1910
  }
1911
 
1912
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1913
 
1914
 
1915
  function dropbox_backup($args){
1916
  extract($args);
1917
 
1918
+ if ($this->iwp_mmb_function_exists('curl_init')) {
1919
+ if(isset($consumer_secret) && !empty($consumer_secret)){
1920
+
1921
+ require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/dropbox.php';
1922
+
1923
+ $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret);
1924
+ $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret);
1925
+
1926
+ if ($dropbox_site_folder == true)
1927
+ $dropbox_destination .= '/' . $this->site_name . '/' . basename($backup_file);
1928
+ else
1929
+ $dropbox_destination .= '/' . basename($backup_file);
1930
+
1931
+ try {
1932
+ $dropbox->upload($backup_file, $dropbox_destination, true);
1933
+ } catch (Exception $e) {
1934
+ $this->_log($e->getMessage());
1935
+ return array(
1936
+ 'error' => $e->getMessage(),
1937
+ 'partial' => 1
1938
+ );
1939
+ }
1940
+
1941
+ return true;
1942
+
1943
+ } else {
1944
+ return array(
1945
+ 'error' => 'Please connect your InfiniteWP panel with your Dropbox account.',
1946
+ 'error_code' => 'please_connect_dropbox_account_with_panel'
1947
+ );
1948
+ }
1949
+ }
1950
+ else {
1951
  return array(
1952
+ 'error' => 'You cannot use Dropbox on your server. Please enable curl first.',
1953
+ 'partial' => 1, 'error_code' => 'cannot_use_dropbox_enable_curl_first'
1954
  );
1955
+ }
1956
 
1957
  }
1958
 
1990
  }
1991
 
1992
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1993
  function amazons3_backup($args)
1994
  {
1995
  if ($this->iwp_mmb_function_exists('curl_init')) {
2102
  try
2103
  {
2104
  $parameters = array();
2105
+ $parameters['q'] = "title = 'infinitewp' and trashed = false and 'root' in parents and 'me' in owners and mimeType= 'application/vnd.google-apps.folder'";
2106
  $files = $service->files->listFiles($parameters);
2107
  $list_result = array();
2108
  $list_result = array_merge($list_result, $files->getItems());
2137
  if($create_sub_folder)
2138
  {
2139
  $parameters = array();
2140
+ $parameters['q'] = "title = '$sub_folder_name' and trashed = false and '$iwp_folder_id' in parents and 'me' in owners and mimeType = 'application/vnd.google-apps.folder'";
2141
  $files = $service->files->listFiles($parameters);
2142
  $list_result = array();
2143
  $list_result = array_merge($list_result, $files->getItems());
2314
  }
2315
  }
2316
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2317
  //IWP Remove ends here
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2318
 
2319
  function remove_google_drive_backup($args)
2320
  {
3082
  }
3083
  }
3084
  }
 
3085
  ?>
core.class.php CHANGED
@@ -186,6 +186,7 @@ class IWP_MMB_Core extends IWP_MMB_Helper
186
  );
187
 
188
  add_action('rightnow_end', array( &$this, 'add_right_now_info' ));
 
189
  add_action('admin_init', array(&$this,'admin_actions'));
190
  add_action('init', array( &$this, 'iwp_mmb_remote_action'), 9999);
191
  add_action('setup_theme', 'iwp_mmb_parse_request');
@@ -915,13 +916,114 @@ class IWP_MMB_Core extends IWP_MMB_Helper
915
  }
916
 
917
  function admin_actions(){
918
- add_filter('all_plugins', array($this, 'client_replace'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
919
  }
920
 
921
  function client_replace($all_plugins){
922
  $replace = get_option("iwp_client_brand");
923
  if(is_array($replace)){
924
- if($replace['name'] || $replace['desc'] || $replace['author'] || $replace['author_url']){
925
  $all_plugins['iwp-client/init.php']['Name'] = $replace['name'];
926
  $all_plugins['iwp-client/init.php']['Title'] = $replace['name'];
927
  $all_plugins['iwp-client/init.php']['Description'] = $replace['desc'];
@@ -931,15 +1033,17 @@ class IWP_MMB_Core extends IWP_MMB_Helper
931
  $all_plugins['iwp-client/init.php']['PluginURI'] = '';
932
  }
933
 
934
- if($replace['hide']){
935
- if (!function_exists('get_plugins')) {
936
- include_once(ABSPATH . 'wp-admin/includes/plugin.php');
937
- }
938
- $activated_plugins = get_option('active_plugins');
939
- if (!$activated_plugins)
940
- $activated_plugins = array();
941
- if(in_array('iwp-client/init.php',$activated_plugins))
942
- unset($all_plugins['iwp-client/init.php']);
 
 
943
  }
944
  }
945
 
186
  );
187
 
188
  add_action('rightnow_end', array( &$this, 'add_right_now_info' ));
189
+ add_action('admin_menu', array($this,'iwp_admin_menu_actions'), 999, 1);
190
  add_action('admin_init', array(&$this,'admin_actions'));
191
  add_action('init', array( &$this, 'iwp_mmb_remote_action'), 9999);
192
  add_action('setup_theme', 'iwp_mmb_parse_request');
916
  }
917
 
918
  function admin_actions(){
919
+ $replace = get_option("iwp_client_brand");
920
+ if(!empty($replace)){
921
+ if(!empty($replace['hideUpdatesCPB'])){
922
+ //define('DISALLOW_FILE_MODS',true); //for hiding updates old method
923
+ }
924
+ if(!empty($replace['hideFWPCPB'])){
925
+ //define('DISALLOW_FILE_EDIT',true); //for hiding file writing permissions old method
926
+ }
927
+ if(!empty($replace['doChangesCPB']) || ( !isset($replace['doChangesCPB']) && (!empty($replace['name']) || !empty($replace['desc']) || !empty($replace['author']) || !empty($replace['author_url'])))){
928
+ add_filter('plugin_row_meta', array($this, 'iwp_client_replace_row_meta'), 10, 2); //for hiding the view details alone.
929
+ add_filter('site_transient_update_plugins', array($this, 'iwp_site_transient_update_plugins'), 10, 2); //for hiding the infiniteWP update details.
930
+ add_filter('admin_url', array($this, 'iwp_user_admin_url'), 10, 2); //for modifying the link available in plugin's view version details link.
931
+ }
932
+ add_filter('all_plugins', array($this, 'client_replace')); //for replacing name and all.
933
+ }
934
+ }
935
+
936
+ function iwp_remove_core_updates($value){
937
+ if(isset($value->response)){
938
+ $old_response = $value->response;
939
+ unset($value->response);
940
+ }
941
+ if(isset($value->updates)){
942
+ unset($value->updates);
943
+ }
944
+ return $value;
945
+ }
946
+
947
+ function iwp_admin_menu_actions($args){
948
+ //to hide all updates
949
+ $replace = get_option("iwp_client_brand");
950
+ if(!empty($replace)){
951
+ if(!empty($replace['hideUpdatesCPB'])){
952
+ //add_filter('wp_get_update_data', array($this, 'iwp_wp_get_update_data'), 10, 2);
953
+ $page = remove_submenu_page( 'index.php', 'update-core.php' );
954
+ add_filter('site_transient_update_core', array($this, 'iwp_remove_core_updates'), 10, 1);
955
+ add_filter('site_transient_update_plugins', array($this, 'iwp_remove_core_updates'), 10, 1);
956
+ add_filter('site_transient_update_themes', array($this, 'iwp_remove_core_updates'), 10, 1);
957
+ }
958
+ if(!empty($replace['hideFWPCPB'])){
959
+ remove_submenu_page('themes.php','theme-editor.php');
960
+ remove_submenu_page('plugins.php','plugin-editor.php');
961
+ add_filter('plugin_action_links', array($this, 'iwp_client_replace_action_links'), 10, 2);
962
+ }
963
+ }
964
+ }
965
+
966
+ function iwp_user_admin_url($args, $args2){
967
+ //for modifying the link available in plugin's view version details link.
968
+ if(strpos($args2, 'plugin-install.php?tab=plugin-information&plugin') !== false){
969
+ $replace = get_option("iwp_client_brand");
970
+ if(!empty($replace) && is_array($replace)){
971
+ if(!empty($replace['name'])){
972
+ $search_str = 'plugin-install.php?tab=plugin-information&plugin='.$replace['name'].'&section=changelog';
973
+ if(strpos($args2, $search_str) !== false){
974
+ $return_var = plugins_url( '/iwp-client/readme.txt' ) . 'TB_iframe=true&width=600&height=550';
975
+ return $return_var;
976
+ }
977
+ }
978
+ }
979
+ }
980
+ return $args;
981
+ }
982
+
983
+ function iwp_site_transient_update_plugins($value){
984
+ if(!empty($value->response['iwp-client/init.php'])){
985
+ $replace = get_option("iwp_client_brand");
986
+ if(!empty($replace) && is_array($replace)){
987
+ if(!empty($replace['name'])){
988
+ $file_traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
989
+ $called_by_file = array_pop($file_traces);
990
+ $called_by_file = basename($called_by_file['file']);
991
+ if($called_by_file == "update-core.php"){
992
+ unset($value->response['iwp-client/init.php']); //for hiding the updates available in updates dashboard section
993
+ }
994
+ else if($called_by_file == "plugins.php"){
995
+ $value->response['iwp-client/init.php']->slug = $replace['name']; ////for hiding the updates available in plugins section
996
+ $value->response['iwp-client/init.php']->Name = $replace['name'];
997
+ //unset($value->response['iwp-client/init.php']);
998
+ }
999
+ }
1000
+ }
1001
+ }
1002
+ return $value;
1003
+ }
1004
+
1005
+ function iwp_client_replace_action_links($links, $file){
1006
+ //for hiding edit on plugins page.
1007
+ if(!empty($links['edit'])){
1008
+ unset($links['edit']);
1009
+ }
1010
+ return $links;
1011
+ }
1012
+
1013
+ function iwp_client_replace_row_meta($links, $file) {
1014
+ //for hiding the view details alone.
1015
+ if($file == 'iwp-client/init.php'){
1016
+ if(!empty($links[2])){
1017
+ unset($links[2]);
1018
+ }
1019
+ }
1020
+ return $links;
1021
  }
1022
 
1023
  function client_replace($all_plugins){
1024
  $replace = get_option("iwp_client_brand");
1025
  if(is_array($replace)){
1026
+ if(!empty($replace['doChangesCPB']) || (!isset($replace['doChangesCPB']) && (!empty($replace['name']) || !empty($replace['desc']) || !empty($replace['author']) || !empty($replace['author_url'])))){
1027
  $all_plugins['iwp-client/init.php']['Name'] = $replace['name'];
1028
  $all_plugins['iwp-client/init.php']['Title'] = $replace['name'];
1029
  $all_plugins['iwp-client/init.php']['Description'] = $replace['desc'];
1033
  $all_plugins['iwp-client/init.php']['PluginURI'] = '';
1034
  }
1035
 
1036
+ if(!empty($replace['hide'])){
1037
+ if (!function_exists('get_plugins')){
1038
+ include_once(ABSPATH . 'wp-admin/includes/plugin.php');
1039
+ }
1040
+ $activated_plugins = get_option('active_plugins');
1041
+ if (!$activated_plugins){
1042
+ $activated_plugins = array();
1043
+ }
1044
+ if(in_array('iwp-client/init.php',$activated_plugins)){
1045
+ unset($all_plugins['iwp-client/init.php']);
1046
+ }
1047
  }
1048
  }
1049
 
init.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: InfiniteWP - Client
4
  Plugin URI: http://infinitewp.com/
5
  Description: This is the client plugin of InfiniteWP that communicates with the InfiniteWP Admin panel.
6
  Author: Revmakx
7
- Version: 1.3.16
8
  Author URI: http://www.revmakx.com
9
  */
10
  /************************************************************
@@ -26,7 +26,7 @@ Author URI: http://www.revmakx.com
26
  **************************************************************/
27
 
28
  if(!defined('IWP_MMB_CLIENT_VERSION'))
29
- define('IWP_MMB_CLIENT_VERSION', '1.3.16');
30
 
31
 
32
 
@@ -89,14 +89,19 @@ if( !function_exists ( 'iwp_mmb_filter_params' )) {
89
  if( !function_exists ('iwp_mmb_parse_request')) {
90
  function iwp_mmb_parse_request()
91
  {
92
- if (!isset($HTTP_RAW_POST_DATA)) {
93
- $HTTP_RAW_POST_DATA = file_get_contents('php://input');
 
 
 
 
 
94
  }
95
 
96
  ob_start();
97
 
98
  global $current_user, $iwp_mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache;
99
- $data = base64_decode($HTTP_RAW_POST_DATA);
100
  if ($data){
101
  //$num = @extract(unserialize($data));
102
  $unserialized_data = @unserialize($data);
@@ -153,11 +158,14 @@ if( !function_exists ('iwp_mmb_parse_request')) {
153
  if(isset($params['username']) && !is_user_logged_in()){
154
  $user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : get_userdatabylogin( $params['username'] );
155
  wp_set_current_user($user->ID);
156
- //For WPE
157
- if(@getenv('IS_WPE'))
158
- wp_set_auth_cookie($user->ID);
 
 
 
 
159
  }
160
-
161
  /* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
162
  if( strlen(trim($wp_db_version)) && !defined('ACX_PLUGIN_DIR') ){
163
  if ( get_option('db_version') != $wp_db_version ) {
@@ -203,7 +211,8 @@ if( !function_exists ('iwp_mmb_parse_request')) {
203
  }
204
  } else {
205
  //IWP_MMB_Stats::set_hit_count();
206
- $GLOBALS['HTTP_RAW_POST_DATA'] = $HTTP_RAW_POST_DATA;
 
207
  }
208
  ob_end_clean();
209
  }
4
  Plugin URI: http://infinitewp.com/
5
  Description: This is the client plugin of InfiniteWP that communicates with the InfiniteWP Admin panel.
6
  Author: Revmakx
7
+ Version: 1.4.1
8
  Author URI: http://www.revmakx.com
9
  */
10
  /************************************************************
26
  **************************************************************/
27
 
28
  if(!defined('IWP_MMB_CLIENT_VERSION'))
29
+ define('IWP_MMB_CLIENT_VERSION', '1.4.1');
30
 
31
 
32
 
89
  if( !function_exists ('iwp_mmb_parse_request')) {
90
  function iwp_mmb_parse_request()
91
  {
92
+ global $HTTP_RAW_POST_DATA;
93
+ $HTTP_RAW_POST_DATA_LOCAL = NULL;
94
+ $HTTP_RAW_POST_DATA_LOCAL = file_get_contents('php://input');
95
+ if(empty($HTTP_RAW_POST_DATA_LOCAL)){
96
+ if (isset($HTTP_RAW_POST_DATA)) {
97
+ $HTTP_RAW_POST_DATA_LOCAL = $HTTP_RAW_POST_DATA;
98
+ }
99
  }
100
 
101
  ob_start();
102
 
103
  global $current_user, $iwp_mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache;
104
+ $data = base64_decode($HTTP_RAW_POST_DATA_LOCAL);
105
  if ($data){
106
  //$num = @extract(unserialize($data));
107
  $unserialized_data = @unserialize($data);
158
  if(isset($params['username']) && !is_user_logged_in()){
159
  $user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : get_userdatabylogin( $params['username'] );
160
  wp_set_current_user($user->ID);
161
+ //For WPE or Reload Data
162
+ //if(@getenv('IS_WPE') || $iwp_action == 'get_stats')
163
+ $SET_14_DAYS_VALIDITY = true;
164
+ wp_set_auth_cookie($user->ID, $SET_14_DAYS_VALIDITY);
165
+ }
166
+ if ($action == 'get_cookie') {
167
+ iwp_mmb_response(true, true);
168
  }
 
169
  /* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
170
  if( strlen(trim($wp_db_version)) && !defined('ACX_PLUGIN_DIR') ){
171
  if ( get_option('db_version') != $wp_db_version ) {
211
  }
212
  } else {
213
  //IWP_MMB_Stats::set_hit_count();
214
+ // $GLOBALS['HTTP_RAW_POST_DATA'] = $HTTP_RAW_POST_DATA_LOCAL;
215
+ $HTTP_RAW_POST_DATA = $HTTP_RAW_POST_DATA_LOCAL;
216
  }
217
  ob_end_clean();
218
  }
pclzip.class.php CHANGED
@@ -157,6 +157,7 @@
157
  define( 'IWP_PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
158
  define( 'IWP_PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
159
  define( 'IWP_PCLZIP_OPT_IWP_EXCLUDE', 77999 );//IWP Mod
 
160
 
161
 
162
  // ----- File description attributes
@@ -287,6 +288,7 @@
287
  $v_options[IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE] = 15*1024*1024*1024;
288
  $v_options[IWP_PCLZIP_OPT_FILE_EXCLUDE_SIZE] = 15*1024*1024*1024;
289
  $v_options[IWP_PCLZIP_OPT_IWP_EXCLUDE] = array();
 
290
  $v_options[IWP_PCLZIP_OPT_HISTORY_ID] = 0;
291
 
292
  // ----- Look for variable options arguments
@@ -320,6 +322,7 @@
320
  IWP_PCLZIP_OPT_FILE_EXCLUDE_SIZE => 'optional',
321
  IWP_PCLZIP_OPT_HISTORY_ID => 'optional',
322
  IWP_PCLZIP_OPT_IWP_EXCLUDE => 'optional',
 
323
  //, IWP_PCLZIP_OPT_CRYPT => 'optional'
324
  ));
325
  if ($v_result != 1) {
@@ -476,6 +479,7 @@
476
  IWP_PCLZIP_OPT_FILE_EXCLUDE_SIZE => 'optional',
477
  IWP_PCLZIP_OPT_HISTORY_ID => 'optional',
478
  IWP_PCLZIP_OPT_IWP_EXCLUDE => 'optional',
 
479
  //, IWP_PCLZIP_OPT_CRYPT => 'optional'
480
  ));
481
  if ($v_result != 1) {
@@ -579,9 +583,9 @@
579
  }
580
  if(!(empty($responseParams)))
581
  {
582
- $prevFileList = $responseParams['response_data']['p_filedescr_list'];
583
- $next_file_index = $responseParams['response_data']['next_file_index'];
584
- $complete_folder_list = $responseParams['response_data']['complete_folder_list'];
585
  }
586
  else
587
  {
@@ -799,6 +803,7 @@
799
  $v_options[IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE] = 15*1024*1024*1024;
800
  $v_options[IWP_PCLZIP_OPT_FILE_EXCLUDE_SIZE] = 15*1024*1024*1024;
801
  $v_options[IWP_PCLZIP_OPT_IWP_EXCLUDE] = array();
 
802
  $v_options[IWP_PCLZIP_OPT_HISTORY_ID] = 0;
803
 
804
  // ----- Look for variable options arguments
@@ -834,6 +839,7 @@
834
  IWP_PCLZIP_OPT_HISTORY_ID => 'optional',
835
  IWP_PCLZIP_OPT_TEMP_FILE_OFF => 'optional',
836
  IWP_PCLZIP_OPT_IWP_EXCLUDE => 'optional',
 
837
  //, IWP_PCLZIP_OPT_CRYPT => 'optional'
838
  ));
839
  if ($v_result != 1) {
@@ -1801,6 +1807,12 @@
1801
  }
1802
  $i++;
1803
  break;
 
 
 
 
 
 
1804
  case IWP_PCLZIP_OPT_PATH :
1805
  case IWP_PCLZIP_OPT_REMOVE_PATH :
1806
  case IWP_PCLZIP_OPT_ADD_PATH :
@@ -2441,7 +2453,8 @@
2441
  if (@is_file($v_descr['filename'])) {
2442
  if($is_get_file_list == 'getFileList')
2443
  {
2444
- $exclude = $p_options[IWP_PCLZIP_OPT_IWP_EXCLUDE];
 
2445
  $skip_this = false;
2446
  if(!empty($exclude)){
2447
  foreach($exclude as $item)
@@ -2466,9 +2479,34 @@
2466
  }
2467
  }
2468
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2469
  //$excludeFileSize = 200;
2470
  //exclude the file if the filesize is larger than the specified file size
2471
- if(iwp_mmb_get_file_size($v_descr['filename']) >= $excludeFileSize)
2472
  {
2473
  continue;
2474
  }
@@ -2627,7 +2665,7 @@
2627
 
2628
  //exclude IWP Mod
2629
  $skip_this = false;
2630
- $exclude = $p_options[IWP_PCLZIP_OPT_IWP_EXCLUDE];
2631
  if(!empty($exclude)){
2632
  foreach($exclude as $item){
2633
  if(strpos($v_descr['stored_filename'], $item) === 0){
157
  define( 'IWP_PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
158
  define( 'IWP_PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
159
  define( 'IWP_PCLZIP_OPT_IWP_EXCLUDE', 77999 );//IWP Mod
160
+ define( 'IWP_PCLZIP_OPT_IWP_EXCLUDE_EXT', 78998 );//darkCode
161
 
162
 
163
  // ----- File description attributes
288
  $v_options[IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE] = 15*1024*1024*1024;
289
  $v_options[IWP_PCLZIP_OPT_FILE_EXCLUDE_SIZE] = 15*1024*1024*1024;
290
  $v_options[IWP_PCLZIP_OPT_IWP_EXCLUDE] = array();
291
+ $v_options[IWP_PCLZIP_OPT_IWP_EXCLUDE_EXT] = array();
292
  $v_options[IWP_PCLZIP_OPT_HISTORY_ID] = 0;
293
 
294
  // ----- Look for variable options arguments
322
  IWP_PCLZIP_OPT_FILE_EXCLUDE_SIZE => 'optional',
323
  IWP_PCLZIP_OPT_HISTORY_ID => 'optional',
324
  IWP_PCLZIP_OPT_IWP_EXCLUDE => 'optional',
325
+ IWP_PCLZIP_OPT_IWP_EXCLUDE_EXT => 'optional',
326
  //, IWP_PCLZIP_OPT_CRYPT => 'optional'
327
  ));
328
  if ($v_result != 1) {
479
  IWP_PCLZIP_OPT_FILE_EXCLUDE_SIZE => 'optional',
480
  IWP_PCLZIP_OPT_HISTORY_ID => 'optional',
481
  IWP_PCLZIP_OPT_IWP_EXCLUDE => 'optional',
482
+ IWP_PCLZIP_OPT_IWP_EXCLUDE_EXT => 'optional',
483
  //, IWP_PCLZIP_OPT_CRYPT => 'optional'
484
  ));
485
  if ($v_result != 1) {
583
  }
584
  if(!(empty($responseParams)))
585
  {
586
+ $prevFileList = isset($responseParams['response_data']['p_filedescr_list']) ? $responseParams['response_data']['p_filedescr_list'] : array();
587
+ $next_file_index = isset($responseParams['response_data']['next_file_index']) ? $responseParams['response_data']['next_file_index'] : 0;
588
+ $complete_folder_list = isset($responseParams['response_data']['complete_folder_list']) ? $responseParams['response_data']['complete_folder_list'] : array();
589
  }
590
  else
591
  {
803
  $v_options[IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE] = 15*1024*1024*1024;
804
  $v_options[IWP_PCLZIP_OPT_FILE_EXCLUDE_SIZE] = 15*1024*1024*1024;
805
  $v_options[IWP_PCLZIP_OPT_IWP_EXCLUDE] = array();
806
+ $v_options[IWP_PCLZIP_OPT_IWP_EXCLUDE_EXT] = array();
807
  $v_options[IWP_PCLZIP_OPT_HISTORY_ID] = 0;
808
 
809
  // ----- Look for variable options arguments
839
  IWP_PCLZIP_OPT_HISTORY_ID => 'optional',
840
  IWP_PCLZIP_OPT_TEMP_FILE_OFF => 'optional',
841
  IWP_PCLZIP_OPT_IWP_EXCLUDE => 'optional',
842
+ IWP_PCLZIP_OPT_IWP_EXCLUDE_EXT => 'optional',
843
  //, IWP_PCLZIP_OPT_CRYPT => 'optional'
844
  ));
845
  if ($v_result != 1) {
1807
  }
1808
  $i++;
1809
  break;
1810
+ case IWP_PCLZIP_OPT_IWP_EXCLUDE_EXT :
1811
+ if (is_array($p_options_list[$i+1])) {
1812
+ $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1813
+ }
1814
+ $i++;
1815
+ break;
1816
  case IWP_PCLZIP_OPT_PATH :
1817
  case IWP_PCLZIP_OPT_REMOVE_PATH :
1818
  case IWP_PCLZIP_OPT_ADD_PATH :
2453
  if (@is_file($v_descr['filename'])) {
2454
  if($is_get_file_list == 'getFileList')
2455
  {
2456
+ $exclude = isset($p_options[IWP_PCLZIP_OPT_IWP_EXCLUDE]) ? $p_options[IWP_PCLZIP_OPT_IWP_EXCLUDE] : array();
2457
+ $exclude_extensions = isset($p_options[IWP_PCLZIP_OPT_IWP_EXCLUDE_EXT]) ? $p_options[IWP_PCLZIP_OPT_IWP_EXCLUDE_EXT] : array();
2458
  $skip_this = false;
2459
  if(!empty($exclude)){
2460
  foreach($exclude as $item)
2479
  }
2480
  }
2481
 
2482
+ //to exclude files based on extensions
2483
+ $this_base_name = basename($v_descr['filename']);
2484
+ $skip_after_ext = false;
2485
+ //file extension based exclude
2486
+ if((!empty($exclude_extensions)) && is_array($exclude_extensions))
2487
+ {
2488
+ foreach($exclude_extensions as $ext)
2489
+ {
2490
+ $this_pos = strrpos($this_base_name, $ext);
2491
+ if($this_pos !== false)
2492
+ {
2493
+ if(substr($this_base_name, $this_pos) == $ext)
2494
+ {
2495
+ //$files_excluded_by_size[] = substr($value, strlen(ABSPATH));
2496
+ $skip_after_ext = true; //to skip the file exclude by size
2497
+ break;
2498
+ }
2499
+ }
2500
+ }
2501
+ }
2502
+ if($skip_after_ext)
2503
+ {
2504
+ continue;
2505
+ }
2506
+
2507
  //$excludeFileSize = 200;
2508
  //exclude the file if the filesize is larger than the specified file size
2509
+ if(!empty($excludeFileSize) && (iwp_mmb_get_file_size($v_descr['filename']) >= $excludeFileSize))
2510
  {
2511
  continue;
2512
  }
2665
 
2666
  //exclude IWP Mod
2667
  $skip_this = false;
2668
+ $exclude = isset($p_options[IWP_PCLZIP_OPT_IWP_EXCLUDE]) ? $p_options[IWP_PCLZIP_OPT_IWP_EXCLUDE] : array();
2669
  if(!empty($exclude)){
2670
  foreach($exclude as $item){
2671
  if(strpos($v_descr['stored_filename'], $item) === 0){
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: infinitewp
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
  Requires at least: 3.0
5
- Tested up to: 4.2.3
6
  Stable tag: trunk
7
 
8
  Install this plugin on unlimited sites and manage them all from a central dashboard.
@@ -48,6 +48,15 @@ Credits: [Vladimir Prelovac](http://prelovac.com/vladimir) for his worker plugin
48
 
49
  == Changelog ==
50
 
 
 
 
 
 
 
 
 
 
51
  = 1.3.16 =
52
  * Fix: Dropbox download while restore create memory issue Fatal Error: Allowed Memory Size of __ Bytes Exhausted
53
 
2
  Contributors: infinitewp
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
  Requires at least: 3.0
5
+ Tested up to: 4.3
6
  Stable tag: trunk
7
 
8
  Install this plugin on unlimited sites and manage them all from a central dashboard.
48
 
49
  == Changelog ==
50
 
51
+ = 1.4.1 =
52
+ * Fix: Branding should take effect which we lost in v1.4.0 without making any changes.
53
+
54
+ = 1.4.0 =
55
+ * Improvement: Compatibility with v2.5.0 and latest versions of addons.
56
+ * Fix: Updates-related conflict with iThemes Security plugin and InfiniteWP fix.
57
+ * Fix: Google Drive backups uploaded to some other infinitewp folder instead one present in main directory.
58
+ * Fix: Clearing temp files created by PCLZip which is left because of timeout issue.
59
+
60
  = 1.3.16 =
61
  * Fix: Dropbox download while restore create memory issue Fatal Error: Allowed Memory Size of __ Bytes Exhausted
62