InfiniteWP Client - Version 1.9.4.1

Version Description

  • July 25th 2019 =
  • Feature: Full Support for Multisite Installations.
  • Feature: SSH support - You can use your SSH keys to backup your WordPress sites.
  • Feature: You can Encrypt your DB backups using the Phoenix backup method.
  • Feature: Server Side encryption for Amazon S3 backups is enabled for all three backup mechanisms.
  • Feature: Notifications for WooCommerce DB updates.
  • Improvement: IWP client plugin will add a must-use plugin to WordPress sites.
  • Improvement: Support for WPTC backups to include on IWP Client reports.
  • Improvement: File Iterator process is improved in the Multicall backup method.
  • Improvement: You can now manage the users on your Multisites.
  • Improvement: The activation key will not be shown to subscriber users.
  • Improvement: Enabled support for Autoptimize plugin.
  • Improvement: "site_map.xml" and "virtual files" are excluded from the backup while backing up the site using the single and multicall method.
  • Improvement: Phoenix backup failure retry count decreased as the backup is running for a prolonged time.
  • Improvement: By default, backup logs will be created for the multicall backup method.
  • Improvement: Backup debug chart added.
  • Improvement: Added an option to exclude Database tables on backup.
  • Improvement: Google drive and Dropbox will respect the multicall loop break time.
  • Improvement: Curl version, SSL version are added in server info.
  • Improvement: Response header will now have the correct HTTP version.
  • Improvement: MySQL dump backup process improved.
  • Improvement: Support for manage users, manage comments, broken link checker, iThemes, Wordfence and Malware Scanner addons for v3.
  • Fix: Duo security plugin on WordPress site breaks the IWP client plugin connection while performing open admin action.
  • Fix: Backup is retried when it failed with error "Failed to connect to content.dropboxapi.com port 443: Connection timed out. and Could not resolve host: api.dropboxapi.com.".
  • Fix: Plugin updates count showing in plugin menu on WP admin page while hide plugin updates setting is enabled on InfiniteWP admin panel via Client Plugin Branding.
  • Fix: Phoenix backup SFTP or FTP not using the custom port.
  • Fix: FTP SSL not working on Phoenix backup.
  • Fix: Ithemes security data is not included in the client reports.
  • Fix: Backups failed with error "Database backup failed. Try to enable MySQL dump on your server.".
  • Fix: Table "w1.wp_iwp_backup_status" doesnot exist , IWP will now create the table automatically instead of throwing an error.
  • Fix: Removed FTP credentials from error messages.
  • Fix: Few PHP 7.2 warnings are fixed.
  • Fix: Backups taken with Phoenix method are not erased from Google drive Storage while deleting the backups from via admin panel.
  • Fix: "Number of Backups to Keep" setting was not working for the Phoenix method backups.
  • Fix: Backup entries are not removed on WordPress database table wp_iwp_backup_status while deleting the backup schedules with phoenix method.
  • Fix: S3 verification failed: File may be corrupted.
  • Fix: Broken link checker update link and un-dismiss options throw fatal error.
  • Fix: Submitted input out of alignment: got [4194300] expected [4194304].
  • Fix: Dropbox account/info did not return HTTP 200. (only for specific users).
  • Fix: Open admin not working if iThemes hide backend option enabled.
  • Fix: PHP Fatal error occurred: Uncaught Guzzle\Service\Exception\ValidationException: Validation errors: [Key] is a required string.
  • Fix: If dump fails, the dump .sql file will be deleted.
  • Fix: IWP Client Plugin error, Curl 18 and Curl 92 on updates and install option due to Cloud Flare setup on WordPress sites.
Download this release

Release Info

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

Code changes from version 1.8.6 to 1.9.4.1

activities_log.class.php CHANGED
@@ -94,8 +94,7 @@ class IWP_MMB_Activities_log {
94
  }
95
 
96
  function iwp_mmb_save_iwp_activities($iwp_type, $iwp_action, $activities_type, $params, $userid) {
97
- global $wpdb,$iwp_activities_log_post_type;
98
-
99
  if(!$this->iwp_mmb_get_is_save_activity_log()) {
100
  return false;
101
  }
@@ -110,7 +109,9 @@ class IWP_MMB_Activities_log {
110
  if(!empty($GLOBALS['activities_log_datetime'])) {
111
  $iwp_activities['post_date'] = $iwp_activities['post_date_gmt'] = $iwp_activities['post_modified'] = $iwp_activities['post_modified_gmt'] = $GLOBALS['activities_log_datetime'];
112
  }
113
-
 
 
114
  $post_id = wp_insert_post( $iwp_activities );
115
 
116
  unset($iwp_activities);
@@ -289,7 +290,7 @@ class IWP_MMB_Activities_log {
289
 
290
  $theme = $this->iwp_mmb_get_theme_details($theme_slug);
291
 
292
- if(!count($theme)) {
293
  return false;
294
  }
295
 
@@ -706,6 +707,32 @@ class IWP_MMB_Activities_log {
706
  $logCounts = $wordfence_instance->getLogCounts($params['fromDate'], $params['toDate']);
707
  $return['detailed'][$wordfence]['details'] = $logCounts;
708
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
709
  iwp_mmb_response($return, true);
710
  }
711
 
94
  }
95
 
96
  function iwp_mmb_save_iwp_activities($iwp_type, $iwp_action, $activities_type, $params, $userid) {
97
+ global $wpdb,$iwp_activities_log_post_type, $wpdb;
 
98
  if(!$this->iwp_mmb_get_is_save_activity_log()) {
99
  return false;
100
  }
109
  if(!empty($GLOBALS['activities_log_datetime'])) {
110
  $iwp_activities['post_date'] = $iwp_activities['post_date_gmt'] = $iwp_activities['post_modified'] = $iwp_activities['post_modified_gmt'] = $GLOBALS['activities_log_datetime'];
111
  }
112
+ if (is_multisite() && in_array($iwp_action, array('now', 'schedule','multiCallNow'))) {
113
+ $wpdb->set_blog_id(1);
114
+ }
115
  $post_id = wp_insert_post( $iwp_activities );
116
 
117
  unset($iwp_activities);
290
 
291
  $theme = $this->iwp_mmb_get_theme_details($theme_slug);
292
 
293
+ if(empty($theme) || !is_array($theme)) {
294
  return false;
295
  }
296
 
707
  $logCounts = $wordfence_instance->getLogCounts($params['fromDate'], $params['toDate']);
708
  $return['detailed'][$wordfence]['details'] = $logCounts;
709
  }
710
+ if (in_array($backups_key, $params['actions']) && iwp_mmb_is_WPTC()) {
711
+ $query = "SELECT backup_id from ".$wpdb->base_prefix."wptc_backups WHERE backup_id >='".$params['fromDate']."' AND backup_id<='".$params['toDate']."'";
712
+ $wptc_backup_counts = 0;
713
+ $wptc_backups = $wpdb->get_results($query,ARRAY_A);
714
+ if (!empty($wptc_backups)) {
715
+ $wptc_backups_details = array();
716
+ foreach ($wptc_backups as $key => $backup) {
717
+ $wptc_backup_counts ++;
718
+ $details = array();
719
+ $date = date('M d, y',$backup['backup_id']);
720
+ $time = date('g',$backup['backup_id']).':'.date('i',$backup['backup_id']).' '.date('a',$backup['backup_id']);
721
+ $details['time'] = $time;
722
+ $details['date'] = $date;
723
+ $details['type'] = 'Files & DB';
724
+ $wptc_backups_details[] = $details;
725
+ }
726
+ $parentDetails = $return['detailed']['backups']['details'];
727
+ if (empty($parentDetails)) {
728
+ $parentDetails = array();
729
+ }
730
+ $parentDetails = array_merge($parentDetails,$wptc_backups_details);
731
+ $return['detailed']['backups']['count']+=$wptc_backup_counts;
732
+ $return['detailed']['backups']['details']= $parentDetails;
733
+ $return['count']['backups']+=$wptc_backup_counts;
734
+ }
735
+ }
736
  iwp_mmb_response($return, true);
737
  }
738
 
addons/brokenlinks/brokenlinks.class.php CHANGED
@@ -93,7 +93,8 @@ class IWP_MMB_BLC extends IWP_MMB_Core
93
  {
94
  if($this->_checkBLC()){
95
  global $wpdb;
96
- $sql = "SELECT l.*,i.container_id,i.link_text FROM (SELECT link_id,url,redirect_count,http_code,status_text,broken,false_positive,dismissed FROM ".$wpdb->prefix."blc_links) AS l INNER JOIN (SELECT link_id,container_id,link_text FROM ".$wpdb->prefix."blc_instances) AS i ON l.link_id=i.link_id";
 
97
  $success = $wpdb->get_results($sql);
98
  if(!empty($success)){
99
  foreach ($success as $link) {
@@ -206,7 +207,12 @@ class IWP_MMB_BLC extends IWP_MMB_Core
206
  $redefinedParams = array('linkID'=>$params['linkData'][$i][0],'linkType'=>$params['linkData'][$i][1]);
207
  array_push($result, $this->blc_dismiss_link($redefinedParams));
208
  }
209
- }
 
 
 
 
 
210
  return array($result,$params['action']);
211
  }
212
 
93
  {
94
  if($this->_checkBLC()){
95
  global $wpdb;
96
+ $sql = "SELECT l.*,i.container_id,i.link_text FROM (SELECT link_id,url,redirect_count,http_code,status_text,broken,false_positive,dismissed FROM ".$wpdb->prefix."blc_links) AS l INNER JOIN (SELECT link_id,container_id,link_text FROM ".$wpdb->prefix."blc_instances) AS i ON l.link_id=i.link_id GROUP BY l.link_id";
97
+ // refer file link-query.php get_links()
98
  $success = $wpdb->get_results($sql);
99
  if(!empty($success)){
100
  foreach ($success as $link) {
207
  $redefinedParams = array('linkID'=>$params['linkData'][$i][0],'linkType'=>$params['linkData'][$i][1]);
208
  array_push($result, $this->blc_dismiss_link($redefinedParams));
209
  }
210
+ }else if($params['action'] == 'undismissBroken'){
211
+ for ($i=0; $i < count($params['linkData']); $i++) {
212
+ $redefinedParams = array('linkID'=>$params['linkData'][$i][0],'linkType'=>$params['linkData'][$i][1]);
213
+ array_push($result, $this->blc_undismiss_link($redefinedParams));
214
+ }
215
+ }
216
  return array($result,$params['action']);
217
  }
218
 
addons/manage_users/user.class.php CHANGED
@@ -20,58 +20,88 @@ class IWP_MMB_User extends IWP_MMB_Core
20
  }
21
 
22
  function get_users($args){
23
- global $wpdb;
24
-
25
- //$args: $user_roles;
26
- if(empty($args))
27
- return false;
28
-
29
- extract($args);
30
-
31
- $userlevels = array();
 
 
32
  $level_strings = array();
33
- foreach($user_roles as $user_role){
34
- switch(strtolower($user_role)){
35
- case 'subscriber' : $userlevels[] = 0; $level_strings[] = $user_role; break;
36
- case 'contributor' : $userlevels[] = 1; $level_strings[] = $user_role; break;
37
- case 'author' : $userlevels[] = 2; $level_strings[] = $user_role; break;
38
- case 'editor' : $userlevels[] = 7; $level_strings[] = $user_role; break;
39
- case 'administrator' : $userlevels[] = 10; $level_strings[] = $user_role; break;
40
- default: break;
41
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
43
-
44
- $users = array();
45
- $userlevel_qry = "('".implode("','",$userlevels)."')";
46
- $userlevel_fallback_qry = "('%".implode("%','%",$level_strings)."%')";
47
- $field = $wpdb->base_prefix."capabilities";
48
-
49
- $user_metas = $wpdb->get_results("SELECT * from $wpdb->usermeta WHERE meta_key = '$field' AND meta_value IN $userlevel_fallback_qry");
50
- if($user_metas == false || empty($user_metas)){
51
- $user_metas = $wpdb->get_results("SELECT * from $wpdb->usermeta WHERE meta_key = 'wp_user_level' AND meta_value IN $userlevel_qry");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  }
53
-
54
- $include = array();
55
- if(is_array($user_metas) && !empty($user_metas)){
56
- foreach($user_metas as $user_meta){
57
- $include[] = $user_meta->user_id;
58
- }
59
- }
60
-
61
- $args = array();
62
- $args['include'] = $include;
63
- $args['fields'] = 'all_with_meta';
64
- $temp_users = get_users($args);
65
- $user = array();
66
-
67
- foreach ((array)$temp_users as $temp){
68
-
69
- $user['user_id'] = $temp->ID;
70
- $user['user_login'] = $temp->user_login;
71
- $user['wp_capabilities'] = array_keys($temp->$field);
72
-
73
- $users[] = $user;
74
- }
75
  $users['request_roles'] = $user_roles;
76
  return array('users' => $users);
77
  }
20
  }
21
 
22
  function get_users($args){
23
+ global $wpdb;
24
+
25
+ //$args: $user_roles;
26
+ if (empty($args)) {
27
+ return false;
28
+ }
29
+
30
+ $user_roles = isset($args['user_roles']) ? $args['user_roles'] : array();
31
+ $username_filter = isset($args['username_filter']) ? $args['username_filter'] : '';
32
+
33
+ $userlevels = array();
34
  $level_strings = array();
35
+ foreach ($user_roles as $user_role) {
36
+ switch (strtolower($user_role)) {
37
+ case 'subscriber' :
38
+ $userlevels[] = 0;
39
+ $level_strings[] = $user_role;
40
+ break;
41
+ case 'contributor' :
42
+ $userlevels[] = 1;
43
+ $level_strings[] = $user_role;
44
+ break;
45
+ case 'author' :
46
+ $userlevels[] = 2;
47
+ $level_strings[] = $user_role;
48
+ break;
49
+ case 'editor' :
50
+ $userlevels[] = 7;
51
+ $level_strings[] = $user_role;
52
+ break;
53
+ case 'administrator' :
54
+ $userlevels[] = 10;
55
+ $level_strings[] = $user_role;
56
+ break;
57
+ default:
58
+ break;
59
+ }
60
  }
61
+
62
+ $users = array();
63
+ $userlevel_qry = "('".implode("','", $userlevels)."')";
64
+ $queryOR = '';
65
+ if (!empty($level_strings)) {
66
+ foreach ($level_strings as $level) {
67
+ if (!empty($queryOR)) {
68
+ $queryOR .= ' OR ';
69
+ }
70
+ $queryOR .= "meta_value LIKE '%{$level}%'";
71
+ }
72
+ }
73
+ $field = $wpdb->prefix."capabilities";
74
+ $field2 = $wpdb->prefix."user_level";
75
+
76
+ $metaQuery = "SELECT * from {$wpdb->usermeta} WHERE meta_key = '{$field}' AND ({$queryOR})";
77
+ $user_metas = $wpdb->get_results($metaQuery);
78
+
79
+ if ($user_metas == false || empty($user_metas)) {
80
+ $metaQuery = "SELECT * from {$wpdb->usermeta} WHERE meta_key = '{$field2}' AND meta_value IN {$userlevel_qry}";
81
+ $user_metas = $wpdb->get_results($metaQuery);
82
+ }
83
+
84
+ $include = array(0 => 0);
85
+ if (is_array($user_metas) && !empty($user_metas)) {
86
+ foreach ($user_metas as $user_meta) {
87
+ $include[] = $user_meta->user_id;
88
+ }
89
+ }
90
+
91
+ $args = array(0, 0);
92
+ $args['include'] = $include;
93
+ $args['fields'] = 'all_with_meta';
94
+ if (!empty($username_filter)) {
95
+ $args['search'] = $username_filter;
96
+ }
97
+ $temp_users = get_users($args);
98
+ $user = array();
99
+ foreach ((array) $temp_users as $temp) {
100
+ $user['user_id'] = $temp->ID;
101
+ $user['user_login'] = $temp->user_login;
102
+ $user['wp_capabilities'] = array_keys($temp->$field);
103
+ $users[] = $user;
104
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  $users['request_roles'] = $user_roles;
106
  return array('users' => $users);
107
  }
addons/post_links/link.class.php CHANGED
@@ -21,6 +21,7 @@ class IWP_MMB_Link extends IWP_MMB_Core
21
 
22
  function add_link($args)
23
  {
 
24
  extract($args);
25
 
26
  $params['link_url'] = esc_html($url);
@@ -68,6 +69,9 @@ class IWP_MMB_Link extends IWP_MMB_Core
68
 
69
  $is_success = wp_insert_link($params);
70
 
 
 
 
71
  return $is_success ? true : array('error' => 'Failed to add link.', 'error_code' => 'failed_to_add_link');
72
  }
73
 
@@ -89,12 +93,12 @@ class IWP_MMB_Link extends IWP_MMB_Core
89
 
90
  if(!empty($filter_links))
91
  {
92
- $where.=" AND (link_name LIKE '%".esc_sql($filter_links)."%' OR link_url LIKE '%".esc_sql($filter_links)."%')";
 
93
  }
94
 
95
  $linkcats = $this->getLinkCats();
96
  $sql_query = "$wpdb->links WHERE 1=1 ".$where;
97
-
98
  $links_total = $wpdb->get_results("SELECT count(*) as total_links FROM ".$sql_query);
99
  $total=$links_total[0]->total_links;
100
 
21
 
22
  function add_link($args)
23
  {
24
+ global $wpdb;
25
  extract($args);
26
 
27
  $params['link_url'] = esc_html($url);
69
 
70
  $is_success = wp_insert_link($params);
71
 
72
+ if ($is_success && $Rlink) {
73
+ $is_success = $wpdb->insert($wpdb->base_prefix."links_extrainfo", array('link_id'=> $is_success, 'link_reciprocal' => $Rlink, 'link_submitter_email' => $submitterMail));
74
+ }
75
  return $is_success ? true : array('error' => 'Failed to add link.', 'error_code' => 'failed_to_add_link');
76
  }
77
 
93
 
94
  if(!empty($filter_links))
95
  {
96
+ $cus_sql= " OR link_id IN(SELECT link_id FROM ".$wpdb->prefix."links_extrainfo WHERE 1=1 AND (link_reciprocal LIKE '%".esc_sql($filter_links)."%' OR link_submitter_email LIKE '%".esc_sql($filter_links)."%'))";
97
+ $where.=" AND (link_name LIKE '%".esc_sql($filter_links)."%' OR link_url LIKE '%".esc_sql($filter_links)."%'".$cus_sql.")";
98
  }
99
 
100
  $linkcats = $this->getLinkCats();
101
  $sql_query = "$wpdb->links WHERE 1=1 ".$where;
 
102
  $links_total = $wpdb->get_results("SELECT count(*) as total_links FROM ".$sql_query);
103
  $total=$links_total[0]->total_links;
104
 
addons/post_links/post.class.php CHANGED
@@ -475,7 +475,8 @@ class IWP_MMB_Post extends IWP_MMB_Core
475
 
476
  if(!empty($filter_posts))
477
  {
478
- $where.=" AND post_title LIKE '%".esc_sql($filter_posts)."%'";
 
479
  }
480
 
481
  if(!empty($iwp_get_posts_date_from) && !empty($iwp_get_posts_date_to))
@@ -505,7 +506,7 @@ class IWP_MMB_Post extends IWP_MMB_Core
505
 
506
  $limit = ($iwp_get_posts_range) ? ' LIMIT ' . esc_sql($iwp_get_posts_range) : ' LIMIT 500';
507
 
508
- $sql_query = "$wpdb->posts WHERE post_status!='auto-draft' AND post_status!='inherit' AND post_type='post' ".$where." ORDER BY post_date DESC";
509
 
510
  $total = array();
511
  $posts = array();
@@ -518,7 +519,7 @@ class IWP_MMB_Post extends IWP_MMB_Core
518
  if($iwp_get_posts_range && !empty($iwp_get_posts_date_from) && !empty($iwp_get_posts_date_to) && $total['total_num'] < $iwp_get_posts_range) {
519
 
520
  $sql_query = "$wpdb->posts
521
- WHERE post_status!='auto-draft' AND post_status!='inherit' AND post_type='post' AND post_date <= '".esc_sql($iwp_get_posts_date_to)."'
522
  ORDER BY post_date DESC
523
  LIMIT " . esc_sql($iwp_get_posts_range);
524
 
475
 
476
  if(!empty($filter_posts))
477
  {
478
+ $cus_sql= " OR ID IN(SELECT post_id FROM ".$wpdb->prefix."postmeta WHERE 1=1 AND (meta_value LIKE '%".esc_sql($filter_posts)."%'))";
479
+ $where.=" AND (post_title LIKE '%".esc_sql($filter_posts)."%'".$cus_sql.")";
480
  }
481
 
482
  if(!empty($iwp_get_posts_date_from) && !empty($iwp_get_posts_date_to))
506
 
507
  $limit = ($iwp_get_posts_range) ? ' LIMIT ' . esc_sql($iwp_get_posts_range) : ' LIMIT 500';
508
 
509
+ $sql_query = "$wpdb->posts WHERE post_status!='auto-draft' AND post_status!='inherit' AND (post_type='post' OR post_type = 'link_library_links') ".$where." ORDER BY post_date DESC";
510
 
511
  $total = array();
512
  $posts = array();
519
  if($iwp_get_posts_range && !empty($iwp_get_posts_date_from) && !empty($iwp_get_posts_date_to) && $total['total_num'] < $iwp_get_posts_range) {
520
 
521
  $sql_query = "$wpdb->posts
522
+ WHERE post_status!='auto-draft' AND post_status!='inherit' AND (post_type='post' OR post_type = 'link_library_links') AND post_date <= '".esc_sql($iwp_get_posts_date_to)."'
523
  ORDER BY post_date DESC
524
  LIMIT " . esc_sql($iwp_get_posts_range);
525
 
addons/wp_optimize/optimize.class.php CHANGED
@@ -17,7 +17,7 @@ class IWP_MMB_Optimize extends IWP_MMB_Core
17
  $text = '';
18
 
19
  if (isset($cleanupType["clean-revisions"])) {
20
- $values = self::cleanup_type_process('revisions');
21
  $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";
22
  $cleanup_values['value_array']['revisions'] = $values['value'];
23
  }
@@ -86,17 +86,29 @@ class IWP_MMB_Optimize extends IWP_MMB_Core
86
  }
87
  }
88
 
89
- function cleanup_type_process($cleanupType){
90
  global $wpdb;
91
  $clean = ""; $message = "";
92
  $message_array = array();
93
  //$message_array['value'] = array();
94
  $optimized = array();
95
-
96
  switch ($cleanupType) {
97
 
98
  case "revisions":
99
- $clean = "DELETE FROM $wpdb->posts WHERE post_type = 'revision'";
 
 
 
 
 
 
 
 
 
 
 
 
100
  $revisions = $wpdb->query( $clean );
101
  $message .= __('Post revisions deleted - ', 'wp-optimize') . $revisions;
102
  $message_array['value'] = $revisions;
17
  $text = '';
18
 
19
  if (isset($cleanupType["clean-revisions"])) {
20
+ $values = self::cleanup_type_process('revisions', $cleanupType['numberOfRevisions']);
21
  $text .= "<span class='wpm_results'>" . $values['message'] . "</span>";
22
  $cleanup_values['value_array']['revisions'] = $values['value'];
23
  }
86
  }
87
  }
88
 
89
+ function cleanup_type_process($cleanupType, $numberOfRevisions = 0){
90
  global $wpdb;
91
  $clean = ""; $message = "";
92
  $message_array = array();
93
  //$message_array['value'] = array();
94
  $optimized = array();
95
+
96
  switch ($cleanupType) {
97
 
98
  case "revisions":
99
+ $revisionWhere = '';
100
+ if (!empty($numberOfRevisions) && $numberOfRevisions != 0) {
101
+ $revisionQuery = "SELECT ID FROM $wpdb->posts WHERE post_type = 'revision' order by ID desc LIMIT ". $numberOfRevisions;
102
+ $revisionIDs = $wpdb->get_results( $revisionQuery, ARRAY_N );
103
+ $revisionsIDsArray = array();
104
+ foreach ($revisionIDs as $key => $revisionID) {
105
+ if ($revisionID) {
106
+ $revisionsIDsArray[]= $revisionID[0];
107
+ }
108
+ }
109
+ $revisionWhere = " AND ID NOT IN('".implode("', '", $revisionsIDsArray)."')";
110
+ }
111
+ $clean = "DELETE FROM $wpdb->posts WHERE post_type = 'revision'".$revisionWhere;
112
  $revisions = $wpdb->query( $clean );
113
  $message .= __('Post revisions deleted - ', 'wp-optimize') . $revisions;
114
  $message_array['value'] = $revisions;
addons/wp_optimize/purge-plugins-cache-class.php CHANGED
@@ -68,6 +68,17 @@ class IWP_MMB_PURGE_CACHE extends IWP_MMB_Core
68
  }
69
  }
70
 
 
 
 
 
 
 
 
 
 
 
 
71
  if ($text !==''){
72
  $cleanup_values['message'] = $text;
73
  return $cleanup_values;
@@ -148,6 +159,21 @@ class IWP_MMB_PURGE_CACHE extends IWP_MMB_Core
148
  return false;
149
  }
150
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  /*
152
  * This function will delete all cache files for WP Fastest Plugin
153
  */
@@ -241,6 +267,18 @@ class IWP_MMB_PURGE_CACHE extends IWP_MMB_Core
241
  }
242
  }
243
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  }
245
 
246
  if(class_exists('WpFastestCache')){
68
  }
69
  }
70
 
71
+ if (empty($params) || isset($params['auto_optimize'])) {
72
+ $response = $this->deleteAllautoptimizeCache();
73
+ if (!empty($response['success'])) {
74
+ $text .= "<span class='wpm_results_db'> Autoptimize"." : " . $response['success'] . "</span><br>";
75
+ $cleanup_values['value_array']['auto_optimize'] = $values['value'];
76
+ }elseif(!empty($response['error'])){
77
+ $text .= "<span class='wpm_results_db'> Autoptimize"." : " . $response['error'] . "</span><br>";
78
+ $cleanup_values['value_array']['auto_optimize'] = 'Autoptimize';
79
+ }
80
+ }
81
+
82
  if ($text !==''){
83
  $cleanup_values['message'] = $text;
84
  return $cleanup_values;
159
  return false;
160
  }
161
 
162
+ /*
163
+ * Public function, Will return the Comet cache plugin is loaded or not
164
+ */
165
+
166
+ public function checkAutoptimizePlugin() {
167
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
168
+ if ( is_plugin_active( 'autoptimize/autoptimize.php' ) ) {
169
+ @include_once(WP_PLUGIN_DIR . 'autoptimize/autoptimize.php');
170
+ if (class_exists('autoptimizeCache')) {
171
+ return true;
172
+ }
173
+ }
174
+ return false;
175
+ }
176
+
177
  /*
178
  * This function will delete all cache files for WP Fastest Plugin
179
  */
267
  }
268
  }
269
 
270
+ public function deleteAllautoptimizeCache(){
271
+ if ($this->checkAutoptimizePlugin()) {
272
+ $wp_auto_optimize = autoptimizeCache::clearall();
273
+ if ($wp_auto_optimize == false) {
274
+ return array('error' => 'Unable to perform Autoptimize cache', 'error_code' => 'auto_optimize_cache_plugin_delete_cache');
275
+ }
276
+ return array('success' => 'All cache files have been deleted');
277
+ }else {
278
+ return array('error'=>"Autoptimize not activated", 'error_code' => 'auto_optimize_plugin_is_not_activated');
279
+ }
280
+ }
281
+
282
  }
283
 
284
  if(class_exists('WpFastestCache')){
backup.class.multicall.php CHANGED
@@ -137,6 +137,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
137
 
138
  function trigger_check($datas)
139
  {
 
140
  if(!empty($datas))
141
  {
142
  $this->set_resource_limit();
@@ -167,6 +168,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
167
  $is_s3 = false;
168
  $is_s3 = $this->check_if_s3_backup($action, $datas['backupParentHID']);
169
 
 
170
  if(method_exists('IWP_MMB_Backup_Multicall', $action) || !empty($is_s3)){
171
  manual_debug('', 'triggerStart');
172
  if(empty($is_s3)){
@@ -204,7 +206,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
204
 
205
  function set_backup_task($params)
206
  {
207
- global $iwp_mmb_activities_log;
208
 
209
  if(!empty($params))
210
  {
@@ -212,7 +214,6 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
212
  // if ($disk_space != false) {
213
  // iwp_mmb_response(array('error' => 'Your disk space is very low available space: '.$disk_space.'MB'), false);
214
  // }
215
- initialize_manual_debug();
216
  $this->cleanup();
217
  $initialize_result = refresh_iwp_files_db();
218
  if(is_array($initialize_result) && isset($initialize_result['error'])){
@@ -264,7 +265,9 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
264
  $historyID = $params['args']['parentHID'];
265
 
266
  $this->hisID = $historyID;
 
267
 
 
268
 
269
  $setMemory = $this->set_resource_limit();
270
 
@@ -320,7 +323,13 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
320
  return $this->statusLog($historyID, array('stage' => 'verification', 'status' => 'error', 'statusMsg' => IWP_PCLZIP_TEMPORARY_DIR.' directory is not writable. Please set 755 or 777 file permission and try again.', 'statusCode' => 'pclzip_dir_not_writable'));
321
  }
322
  }
323
-
 
 
 
 
 
 
324
  //if verification is ok then store the settings in the options table
325
  $backup_settings_values = array();
326
  $backup_settings_values['file_block_size'] = $params['args']['file_block_size'];
@@ -390,6 +399,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
390
  {
391
  $requestParams = $this->getRequiredData($historyID, "requestParams");
392
  $db_loop_break_time = $requestParams['args']['db_loop_break_time'];
 
393
  $responseParams = $this -> getRequiredData($historyID,"responseParams");
394
  $file = $responseParams['file_name'];
395
 
@@ -415,11 +425,41 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
415
  $brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
416
  //$command = $brace . $paths['mysqldump'] . $brace . ' --force --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" --add-drop-table --skip-lock-tables "' . DB_NAME . '" > ' . $brace . $file . $brace;
417
  $command0 = $wpdb->get_col('SHOW TABLES LIKE "'.$wpdb->base_prefix.'%"');
418
- $wp_tables = join("\" \"",$command0);
419
- $command = $brace . $paths['mysqldump'] . $brace . ' --force --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" --add-drop-table --skip-lock-tables --extended-insert=FALSE "' . DB_NAME . '" "'.$wp_tables.'" > ' . $brace . $file . $brace;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
420
  iwp_mmb_print_flush('DB DUMP CMD: Start');
421
  ob_start();
422
  update_option('iwp_multical_db_dump_flag', 1);
 
 
 
 
 
 
 
423
  $result = $this->iwp_mmb_exec($command);
424
  ob_get_clean();
425
  iwp_mmb_print_flush('DB DUMP CMD: End');
@@ -429,6 +469,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
429
 
430
  if (!$result) { // Fallback to php
431
  // $result = $this->backup_db_php($file);
 
432
  return $result;
433
  }
434
 
@@ -799,6 +840,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
799
  $file_loop_break_time = $requestParams['args']['file_loop_break_time'];
800
  $db_loop_break_time = $requestParams['args']['db_loop_break_time'];
801
  $zip_split_size = $requestParams['args']['zip_split_size'];
 
802
  $responseParams = $this -> getRequiredData($historyID,"responseParams");
803
  $file = $responseParams['file_name'];
804
  $total_time_part = 0;
@@ -916,8 +958,17 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
916
  //$left_out_count = '';
917
  }
918
  //Skip log tables
919
- if (strpos($table[0], 'wsal_metadata')) {
920
- continue;
 
 
 
 
 
 
 
 
 
921
  }
922
  $count = $wpdb->get_var("SELECT count(*) FROM $table[0]");
923
  $count_field = 1;
@@ -951,8 +1002,18 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
951
  {
952
  $count = 1;
953
  }
954
- $table_description = $wpdb->get_results("DESCRIBE $table[0]", ARRAY_A);
955
- $table_description = iwp_modify_table_description($table_description);
 
 
 
 
 
 
 
 
 
 
956
  for($i = 0; $i < $count; $i++){
957
  if($done_count > 0)
958
  {
@@ -1018,13 +1079,29 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1018
  /*********New Method ends Here******************/
1019
 
1020
  /**********Old Method start here ************/
1021
- $value = addslashes($value);
1022
- $value = preg_replace("/\n/Ui", "\\n", $value);
1023
- $value = str_replace("\n", "\\n", $value);
1024
- $value = str_replace("\r", "\\r", $value);
1025
- $num_values == $j ? $dump_data .= "'" . $value . "'" : $dump_data .= "'" . $value . "', ";
 
1026
  /*************** Old Method ends here ********/
1027
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1028
  $j++;
1029
  unset($value);
1030
  if($total_time_part > $db_loop_break_time)
@@ -1268,6 +1345,8 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1268
  "pgcache",
1269
  "objectcache",
1270
  "wp-snapshots",
 
 
1271
  );
1272
  manual_debug('', 'beforeExclude', 0);
1273
  if((!empty($exclude_file_size))||(!empty($exclude_extensions)))
@@ -1491,6 +1570,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1491
  $time = microtime(true);
1492
  $start = $time;
1493
  //$archive = new IWPPclZip('../archive.zip');
 
1494
  $archive = new IWPPclZip($backup_file);
1495
  if($category == 'dbZip')
1496
  {
@@ -1937,6 +2017,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
1937
  $start = $time;
1938
  //include_once 'pclzip.class.php';
1939
  //include_once 'pclzip.class.split.php';
 
1940
  $archive = new IWPPclZip($backup_file);
1941
  if($category == 'dbZip')
1942
  {
@@ -2711,6 +2792,7 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
2711
  {
2712
  global $wpdb,$insertID;
2713
  $this->wpdb_reconnect();
 
2714
  if(empty($historyID))
2715
  {
2716
  $insert = $wpdb->insert($wpdb->base_prefix.'iwp_backup_status',array( 'stage' => $statusArray['stage'], 'status' => $statusArray['status'], 'action' => $params['args']['action'], 'type' => $params['args']['type'],'category' => $params['args']['what'],'historyID' => $params['args']['parentHID'],'finalStatus' => 'pending','startTime' => microtime(true), 'lastUpdateTime' => microtime(true), 'endTime' => '','statusMsg' => $statusArray['statusMsg'],'requestParams' => serialize($params),'taskName' => $params['task_name']), array( '%s', '%s','%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%s', '%s', '%s' ) );
@@ -4021,7 +4103,7 @@ function ftp_backup($historyID,$args = '')
4021
  $login = @ftp_login($conn_id, $ftp_username, $ftp_password);
4022
  if ($login === false) {
4023
  return array(
4024
- 'error' => 'FTP login failed for ' . $ftp_username . ', ' . $ftp_password,
4025
  'partial' => 1, 'error_code' => 'ftp_login_failed'
4026
  );
4027
  }
@@ -4354,7 +4436,7 @@ function ftp_backup($historyID,$args = '')
4354
  * SFTP section start here phpseclib library is used for this functionality
4355
  */
4356
  $iwp_mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
4357
- $path = $iwp_mmb_plugin_dir.'/lib/phpseclib';
4358
  set_include_path(get_include_path() . PATH_SEPARATOR . $path);
4359
  include_once('Net/SFTP.php');
4360
 
@@ -4368,7 +4450,7 @@ function ftp_backup($historyID,$args = '')
4368
  }
4369
  if (!$sftp->login($ftp_username, $ftp_password)) {
4370
  return array(
4371
- 'error' => 'FTP login failed for ' . $ftp_username . ', ' . $ftp_password,
4372
  'partial' => 1
4373
  );
4374
  } else {
@@ -4669,7 +4751,7 @@ function ftp_backup($historyID,$args = '')
4669
  echo " thisChunkTimeTaken".$chunkTimeTaken;
4670
  $dBoxTimeTaken = $dBoxCompleteTime - $dBoxStartTime;
4671
  $dBoxTimeLeft = $upload_loop_break_time - $dBoxTimeTaken; //calculating time left for the dBOX upload ..
4672
- $dBoxTimeLeft = $dBoxTimeLeft - 5; //for safe time limit
4673
  echo " dBoxTimeLeft".$dBoxTimeLeft;
4674
  //$halfOfLoopTime = (($upload_loop_break_time / 2) - 1);
4675
  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
@@ -4735,17 +4817,18 @@ function ftp_backup($historyID,$args = '')
4735
  // Try the indicated offset
4736
  $we_tried = $matches[1];
4737
  $offset = $matches[2];
4738
- if($oldVersion){
4739
  $chunkResult = $dropbox->chunked_upload($backup_file, $dropbox_destination, true, $uploadid, $offset, $readsize, $isCommit);
4740
  }else{
4741
  $chunkResult = $dropbox->chunked_upload($backup_file ,$dropbox_destination, true, $uploadid, $offset, $isCommit);
4742
- }
 
4743
  $result_arr = array();
4744
- $result_arr['response_data'] = $chunkResult;
4745
  $result_arr['nextFunc'] = 'dropbox_backup';
4746
  $result_arr['dropboxArgs'] = $tempArgs;
4747
- $offset = isset($chunkResult['offset']) ? $chunkResult['offset'] : 0;
4748
- $uploadid = isset($chunkResult['upload_id']) ? $chunkResult['upload_id'] : 0;
 
4749
  $resArray = array (
4750
  'backupParentHID' => $historyID,
4751
  'status' => 'partiallyCompleted'
@@ -5776,7 +5859,7 @@ function ftp_backup($historyID,$args = '')
5776
  $fileSizeUploaded = $statusArray['progress'];
5777
 
5778
  $googleTimeTaken = microtime(1) - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'];
5779
- if(($googleTimeTaken > 10)&&($status != true)){
5780
  $chunkResult['resumeURI'] = $resumeURI;
5781
  $chunkResult['fileSizeUploaded'] = $fileSizeUploaded;
5782
 
@@ -6253,6 +6336,10 @@ function ftp_backup($historyID,$args = '')
6253
  }
6254
  $results[] = $this_backup_file;
6255
  }
 
 
 
 
6256
  }
6257
  }
6258
  }
@@ -6524,29 +6611,44 @@ function ftp_backup($historyID,$args = '')
6524
  if(file_exists(WP_CONTENT_DIR . '/DE_clMemoryPeak.php')){ @unlink(WP_CONTENT_DIR . '/DE_clMemoryPeak.php');}
6525
  if(file_exists(WP_CONTENT_DIR . '/DE_clMemoryUsage.php')){ @unlink(WP_CONTENT_DIR . '/DE_clMemoryUsage.php');}
6526
  if(file_exists(WP_CONTENT_DIR . '/DE_clTimeTaken.php')){ @unlink(WP_CONTENT_DIR . '/DE_clTimeTaken.php');}
6527
- return true;
6528
- global $debug_count, $every_count;
 
 
 
 
 
 
 
 
6529
  $debug_count = 0;
6530
  $every_count = 0;
6531
-
 
 
 
6532
  $this_memory_peak_in_mb = memory_get_peak_usage();
6533
  $this_memory_peak_in_mb = $this_memory_peak_in_mb / 1048576;
6534
  $this_memory_in_mb = memory_get_usage();
6535
  $this_memory_in_mb = $this_memory_in_mb / 1048576;
6536
  $this_time_taken = microtime(true) - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'];
6537
 
6538
- file_put_contents(WP_CONTENT_DIR . '/DE_clMemoryPeak.php',$debug_count . $printText . " " . round($this_memory_peak_in_mb, 2) ."\n");
6539
- file_put_contents(WP_CONTENT_DIR . '/DE_clMemoryUsage.php',$debug_count . $printText . " " . round($this_memory_in_mb, 2) ."\n");
6540
- file_put_contents(WP_CONTENT_DIR . '/DE_clTimeTaken.php',$debug_count . $printText . " " . round($this_time_taken, 2) ."\n");
 
6541
  }
6542
  }
6543
 
6544
  if( !function_exists('manual_debug') ){
6545
  function manual_debug($conditions = '', $printText = '', $forEvery = 0){
6546
- return true;
 
 
 
6547
  global $debug_count;
6548
  $debug_count++;
6549
- $printText = '-' . $printText;
6550
 
6551
  global $every_count;
6552
  //$conditions = 'printOnly';
@@ -6566,23 +6668,36 @@ function ftp_backup($historyID,$args = '')
6566
 
6567
  if( !function_exists('print_memory_debug') ){
6568
  function print_memory_debug($debug_count, $conditions = '', $printText = ''){
6569
-
6570
  $this_memory_peak_in_mb = memory_get_peak_usage();
6571
  $this_memory_peak_in_mb = $this_memory_peak_in_mb / 1048576;
6572
  $this_memory_in_mb = memory_get_usage();
6573
  $this_memory_in_mb = $this_memory_in_mb / 1048576;
6574
  $this_time_taken = microtime(true) - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'];
 
 
 
 
 
 
 
 
 
 
6575
  if($conditions == 'printOnly'){
6576
  if($this_memory_peak_in_mb >= 34){
6577
- file_put_contents(WP_CONTENT_DIR . '/DE_clMemoryPeak.php',$debug_count . $printText . " " . round($this_memory_peak_in_mb, 2) ."\n",FILE_APPEND);
6578
- file_put_contents(WP_CONTENT_DIR . '/DE_clMemoryUsage.php',$debug_count . $printText . " " . round($this_memory_in_mb, 2) ."\n",FILE_APPEND);
6579
- file_put_contents(WP_CONTENT_DIR . '/DE_clTimeTaken.php',$debug_count . $printText . " " . round($this_time_taken, 2) ."\n",FILE_APPEND);
 
6580
  }
6581
  }
6582
  else{
6583
- file_put_contents(WP_CONTENT_DIR . '/DE_clMemoryPeak.php',$debug_count . $printText . " " . round($this_memory_peak_in_mb, 2) ."\n",FILE_APPEND);
6584
- file_put_contents(WP_CONTENT_DIR . '/DE_clMemoryUsage.php',$debug_count . $printText . " " . round($this_memory_in_mb, 2) ."\n",FILE_APPEND);
6585
- file_put_contents(WP_CONTENT_DIR . '/DE_clTimeTaken.php',$debug_count . $printText . " " . round($this_time_taken, 2) ."\n",FILE_APPEND);
 
 
6586
  }
6587
  }
6588
  }
137
 
138
  function trigger_check($datas)
139
  {
140
+ global $iwp_multicall_hisID;
141
  if(!empty($datas))
142
  {
143
  $this->set_resource_limit();
168
  $is_s3 = false;
169
  $is_s3 = $this->check_if_s3_backup($action, $datas['backupParentHID']);
170
 
171
+ $iwp_multicall_hisID = $datas['backupParentHID'];
172
  if(method_exists('IWP_MMB_Backup_Multicall', $action) || !empty($is_s3)){
173
  manual_debug('', 'triggerStart');
174
  if(empty($is_s3)){
206
 
207
  function set_backup_task($params)
208
  {
209
+ global $iwp_mmb_activities_log, $iwp_multicall_hisID;
210
 
211
  if(!empty($params))
212
  {
214
  // if ($disk_space != false) {
215
  // iwp_mmb_response(array('error' => 'Your disk space is very low available space: '.$disk_space.'MB'), false);
216
  // }
 
217
  $this->cleanup();
218
  $initialize_result = refresh_iwp_files_db();
219
  if(is_array($initialize_result) && isset($initialize_result['error'])){
265
  $historyID = $params['args']['parentHID'];
266
 
267
  $this->hisID = $historyID;
268
+ $iwp_multicall_hisID = $historyID;
269
 
270
+ initialize_manual_debug();
271
 
272
  $setMemory = $this->set_resource_limit();
273
 
323
  return $this->statusLog($historyID, array('stage' => 'verification', 'status' => 'error', 'statusMsg' => IWP_PCLZIP_TEMPORARY_DIR.' directory is not writable. Please set 755 or 777 file permission and try again.', 'statusCode' => 'pclzip_dir_not_writable'));
324
  }
325
  }
326
+ if ((!defined('DISABLE_IWP_CLOUD_VERIFICATION')) && (empty($params['args']['disable_iwp_cloud_verification']))) {
327
+ $backup_repo_test_obj = new IWP_BACKUP_REPO_TEST();
328
+ $backup_repo_test_result = $backup_repo_test_obj->repositoryTestConnection($params['account_info']);
329
+ if (!empty($backup_repo_test_result['error']) && $backup_repo_test_result['status'] != 'success') {
330
+ return $this->statusLog($historyID, array('stage' => 'backup_repo_test', 'status' => 'error', 'statusMsg' => $backup_repo_test_result['error'], 'statusCode' => $backup_repo_test_result['error_code']));
331
+ }
332
+ }
333
  //if verification is ok then store the settings in the options table
334
  $backup_settings_values = array();
335
  $backup_settings_values['file_block_size'] = $params['args']['file_block_size'];
399
  {
400
  $requestParams = $this->getRequiredData($historyID, "requestParams");
401
  $db_loop_break_time = $requestParams['args']['db_loop_break_time'];
402
+ $exclude_tables =$requestParams['args']['exclude_tables'];
403
  $responseParams = $this -> getRequiredData($historyID,"responseParams");
404
  $file = $responseParams['file_name'];
405
 
425
  $brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
426
  //$command = $brace . $paths['mysqldump'] . $brace . ' --force --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" --add-drop-table --skip-lock-tables "' . DB_NAME . '" > ' . $brace . $file . $brace;
427
  $command0 = $wpdb->get_col('SHOW TABLES LIKE "'.$wpdb->base_prefix.'%"');
428
+ $full_table = array();
429
+ $structure_only_table = array();
430
+ if (!empty($exclude_tables)) {
431
+ foreach ($command0 as $tk => $table) {
432
+ foreach ($exclude_tables as $ke => $exclude_table) {
433
+ $structure = false;
434
+ if (strpos($table, $exclude_table)) {
435
+ $structure = true;
436
+ break;
437
+ }
438
+ }
439
+ if ($structure) {
440
+ $structure_only_table [] = $table;
441
+ }else{
442
+ $full_table [] = $table;
443
+ }
444
+ }
445
+ }else{
446
+ $full_table = $command0;
447
+ }
448
+ $wp_tables = join("\" \"",$full_table);
449
+ $skipThisTable = false;
450
+ $command = $brace . $paths['mysqldump'] . $brace . ' --force --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" --max_allowed_packet=8M --net_buffer_length=1M --skip-comments --skip-set-charset --allow-keywords --dump-date --add-drop-table --skip-lock-tables --extended-insert "' . DB_NAME . '" "'.$wp_tables.'" > ' . $brace . $file . $brace;
451
+
452
+
453
  iwp_mmb_print_flush('DB DUMP CMD: Start');
454
  ob_start();
455
  update_option('iwp_multical_db_dump_flag', 1);
456
+ if (!empty($structure_only_table)) {
457
+ $wp_tables = join("\" \"",$structure_only_table);
458
+ $structure_command = $brace . $paths['mysqldump'] . $brace . ' --force --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" --add-drop-table --skip-lock-tables --no-data "' . DB_NAME . '" "'.$wp_tables.'" >> ' . $brace . $file . $brace;
459
+ // $result = $this->iwp_mmb_exec($structure_command);
460
+ $command.=' && '.$structure_command;
461
+
462
+ }
463
  $result = $this->iwp_mmb_exec($command);
464
  ob_get_clean();
465
  iwp_mmb_print_flush('DB DUMP CMD: End');
469
 
470
  if (!$result) { // Fallback to php
471
  // $result = $this->backup_db_php($file);
472
+ @unlink($file);
473
  return $result;
474
  }
475
 
840
  $file_loop_break_time = $requestParams['args']['file_loop_break_time'];
841
  $db_loop_break_time = $requestParams['args']['db_loop_break_time'];
842
  $zip_split_size = $requestParams['args']['zip_split_size'];
843
+ $exclude_tables =$requestParams['args']['exclude_tables'];
844
  $responseParams = $this -> getRequiredData($historyID,"responseParams");
845
  $file = $responseParams['file_name'];
846
  $total_time_part = 0;
958
  //$left_out_count = '';
959
  }
960
  //Skip log tables
961
+ $skipThisTable = false;
962
+ if (!empty($exclude_tables)) {
963
+ foreach ($exclude_tables as $ke => $exclude_table) {
964
+ if (strpos($table[0], $exclude_table)) {
965
+ $skipThisTable = true;
966
+ break;
967
+ }
968
+ }
969
+ }
970
+ if ($skipThisTable) {
971
+ continue;
972
  }
973
  $count = $wpdb->get_var("SELECT count(*) FROM $table[0]");
974
  $count_field = 1;
1002
  {
1003
  $count = 1;
1004
  }
1005
+ $table_structure = $wpdb->get_results("DESCRIBE $table[0]");
1006
+ $search = array("\x00", "\x0a", "\x0d", "\x1a");
1007
+ $replace = array('\0', '\n', '\r', '\Z');
1008
+ $defs = array();
1009
+ $integer_fields = array();
1010
+ foreach ($table_structure as $struct) {
1011
+ if ( (0 === strpos($struct->Type, 'tinyint')) || (0 === strpos(strtolower($struct->Type), 'smallint')) ||
1012
+ (0 === strpos(strtolower($struct->Type), 'mediumint')) || (0 === strpos(strtolower($struct->Type), 'int')) || (0 === strpos(strtolower($struct->Type), 'bigint')) ) {
1013
+ $defs[strtolower($struct->Field)] = ( null === $struct->Default ) ? 'NULL' : $struct->Default;
1014
+ $integer_fields[strtolower($struct->Field)] = "1";
1015
+ }
1016
+ }
1017
  for($i = 0; $i < $count; $i++){
1018
  if($done_count > 0)
1019
  {
1079
  /*********New Method ends Here******************/
1080
 
1081
  /**********Old Method start here ************/
1082
+ // $value2 = $value;
1083
+ // $value = addslashes($value);
1084
+ // $value = preg_replace("/\n/Ui", "\\n", $value);
1085
+ // $value = str_replace("\n", "\\n", $value);
1086
+ // $value = str_replace("\r", "\\r", $value);
1087
+ // $num_values == $j ? $dump_data .= "'" . $value . "'" : $dump_data .= "'" . $value . "', ";
1088
  /*************** Old Method ends here ********/
1089
 
1090
+ /**********Phoenix Method start here ************/
1091
+ if (isset($integer_fields[strtolower($key)])) {
1092
+ // make sure there are no blank spots in the insert syntax,
1093
+ // yet try to avoid quotation marks around integers
1094
+ $value = ( null === $value || '' === $value) ? $defs[strtolower($key)] : $value;
1095
+ $value = ( '' === $value ) ? "''" : $value;
1096
+ } else {
1097
+ $value = (null === $value) ? 'NULL' : "'" . str_replace($search, $replace, str_replace('\'', '\\\'', str_replace('\\', '\\\\', $value))) . "'";
1098
+ }
1099
+
1100
+ /**********Phoenix Method end here ************/
1101
+
1102
+ $num_values == $j ? $dump_data .= $value: $dump_data .= $value . ", ";
1103
+
1104
+
1105
  $j++;
1106
  unset($value);
1107
  if($total_time_part > $db_loop_break_time)
1345
  "pgcache",
1346
  "objectcache",
1347
  "wp-snapshots",
1348
+ "site_map.xml",
1349
+ "iwp-clone-log.txt",
1350
  );
1351
  manual_debug('', 'beforeExclude', 0);
1352
  if((!empty($exclude_file_size))||(!empty($exclude_extensions)))
1570
  $time = microtime(true);
1571
  $start = $time;
1572
  //$archive = new IWPPclZip('../archive.zip');
1573
+ global $archive;
1574
  $archive = new IWPPclZip($backup_file);
1575
  if($category == 'dbZip')
1576
  {
2017
  $start = $time;
2018
  //include_once 'pclzip.class.php';
2019
  //include_once 'pclzip.class.split.php';
2020
+ global $archive;
2021
  $archive = new IWPPclZip($backup_file);
2022
  if($category == 'dbZip')
2023
  {
2792
  {
2793
  global $wpdb,$insertID;
2794
  $this->wpdb_reconnect();
2795
+ iwp_mmb_create_backup_status_table();
2796
  if(empty($historyID))
2797
  {
2798
  $insert = $wpdb->insert($wpdb->base_prefix.'iwp_backup_status',array( 'stage' => $statusArray['stage'], 'status' => $statusArray['status'], 'action' => $params['args']['action'], 'type' => $params['args']['type'],'category' => $params['args']['what'],'historyID' => $params['args']['parentHID'],'finalStatus' => 'pending','startTime' => microtime(true), 'lastUpdateTime' => microtime(true), 'endTime' => '','statusMsg' => $statusArray['statusMsg'],'requestParams' => serialize($params),'taskName' => $params['task_name']), array( '%s', '%s','%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%s', '%s', '%s' ) );
4103
  $login = @ftp_login($conn_id, $ftp_username, $ftp_password);
4104
  if ($login === false) {
4105
  return array(
4106
+ 'error' => 'FTP user name and password invalid',
4107
  'partial' => 1, 'error_code' => 'ftp_login_failed'
4108
  );
4109
  }
4436
  * SFTP section start here phpseclib library is used for this functionality
4437
  */
4438
  $iwp_mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
4439
+ $path = $iwp_mmb_plugin_dir.'/lib/phpseclib/phpseclib/phpseclib';
4440
  set_include_path(get_include_path() . PATH_SEPARATOR . $path);
4441
  include_once('Net/SFTP.php');
4442
 
4450
  }
4451
  if (!$sftp->login($ftp_username, $ftp_password)) {
4452
  return array(
4453
+ 'error' => 'FTP user name and password invalid',
4454
  'partial' => 1
4455
  );
4456
  } else {
4751
  echo " thisChunkTimeTaken".$chunkTimeTaken;
4752
  $dBoxTimeTaken = $dBoxCompleteTime - $dBoxStartTime;
4753
  $dBoxTimeLeft = $upload_loop_break_time - $dBoxTimeTaken; //calculating time left for the dBOX upload ..
4754
+ $dBoxTimeLeft = $dBoxTimeLeft; //for safe time limit
4755
  echo " dBoxTimeLeft".$dBoxTimeLeft;
4756
  //$halfOfLoopTime = (($upload_loop_break_time / 2) - 1);
4757
  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
4817
  // Try the indicated offset
4818
  $we_tried = $matches[1];
4819
  $offset = $matches[2];
4820
+ /*if($oldVersion){
4821
  $chunkResult = $dropbox->chunked_upload($backup_file, $dropbox_destination, true, $uploadid, $offset, $readsize, $isCommit);
4822
  }else{
4823
  $chunkResult = $dropbox->chunked_upload($backup_file ,$dropbox_destination, true, $uploadid, $offset, $isCommit);
4824
+ }*/
4825
+ echo "Submitted input out of alignment";
4826
  $result_arr = array();
 
4827
  $result_arr['nextFunc'] = 'dropbox_backup';
4828
  $result_arr['dropboxArgs'] = $tempArgs;
4829
+ $chunkResult['offset'] = isset($offset) ? $offset : 0;
4830
+ $chunkResult['uploadid'] = isset($prevChunkResults['upload_id']) ? $prevChunkResults['upload_id'] : 0;
4831
+ $result_arr['response_data'] = $chunkResult;
4832
  $resArray = array (
4833
  'backupParentHID' => $historyID,
4834
  'status' => 'partiallyCompleted'
5859
  $fileSizeUploaded = $statusArray['progress'];
5860
 
5861
  $googleTimeTaken = microtime(1) - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'];
5862
+ if(($googleTimeTaken > $upload_loop_break_time)&&($status != true)){
5863
  $chunkResult['resumeURI'] = $resumeURI;
5864
  $chunkResult['fileSizeUploaded'] = $fileSizeUploaded;
5865
 
6336
  }
6337
  $results[] = $this_backup_file;
6338
  }
6339
+ $results[] = 'DE_clMemoryPeak.'.$historyID.'.txt';
6340
+ $results[] = 'DE_clMemoryUsage.'.$historyID.'.txt';
6341
+ $results[] = 'DE_clTimeTaken.'.$historyID.'.txt';
6342
+ $results[] = 'DE_clCPUUsage.'.$historyID.'.txt';
6343
  }
6344
  }
6345
  }
6611
  if(file_exists(WP_CONTENT_DIR . '/DE_clMemoryPeak.php')){ @unlink(WP_CONTENT_DIR . '/DE_clMemoryPeak.php');}
6612
  if(file_exists(WP_CONTENT_DIR . '/DE_clMemoryUsage.php')){ @unlink(WP_CONTENT_DIR . '/DE_clMemoryUsage.php');}
6613
  if(file_exists(WP_CONTENT_DIR . '/DE_clTimeTaken.php')){ @unlink(WP_CONTENT_DIR . '/DE_clTimeTaken.php');}
6614
+ if(file_exists(WP_CONTENT_DIR . '/DE_clCPUUsage.php')){ @unlink(WP_CONTENT_DIR . '/DE_clCPUUsage.php');}
6615
+ if (defined('DISABLE_IWP_MULTICALL_DEBUG') && DISABLE_IWP_MULTICALL_DEBUG) {
6616
+ return ;
6617
+ }
6618
+
6619
+ global $debug_count, $every_count, $iwp_multicall_hisID;
6620
+ $memoryPeakLog = 'DE_clMemoryPeak.'.$iwp_multicall_hisID.'.txt';
6621
+ $memoryUsageLog = 'DE_clMemoryUsage.'.$iwp_multicall_hisID.'.txt';
6622
+ $timeTakenLog = 'DE_clTimeTaken.'.$iwp_multicall_hisID.'.txt';
6623
+ $cpuUsageLog = 'DE_clCPUUsage.'.$iwp_multicall_hisID.'.txt';
6624
  $debug_count = 0;
6625
  $every_count = 0;
6626
+ if (function_exists('sys_getloadavg')) {
6627
+ $cpu_load = sys_getloadavg();
6628
+ $current_cpu_load = $cpu_load[0];
6629
+ }
6630
  $this_memory_peak_in_mb = memory_get_peak_usage();
6631
  $this_memory_peak_in_mb = $this_memory_peak_in_mb / 1048576;
6632
  $this_memory_in_mb = memory_get_usage();
6633
  $this_memory_in_mb = $this_memory_in_mb / 1048576;
6634
  $this_time_taken = microtime(true) - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'];
6635
 
6636
+ file_put_contents(IWP_BACKUP_DIR . '/'.$memoryPeakLog,$debug_count . $printText . " " . round($this_memory_peak_in_mb, 2) ."\n");
6637
+ file_put_contents(IWP_BACKUP_DIR . '/'.$memoryUsageLog,$debug_count . $printText . " " . round($this_memory_in_mb, 2) ."\n");
6638
+ file_put_contents(IWP_BACKUP_DIR . '/'.$timeTakenLog,$debug_count . $printText . " " . round($this_time_taken, 2) ."\n");
6639
+ file_put_contents(IWP_BACKUP_DIR . '/'.$cpuUsageLog,$debug_count . $printText . " " . $current_cpu_load ."\n");
6640
  }
6641
  }
6642
 
6643
  if( !function_exists('manual_debug') ){
6644
  function manual_debug($conditions = '', $printText = '', $forEvery = 0){
6645
+ if (defined('DISABLE_IWP_MULTICALL_DEBUG') && DISABLE_IWP_MULTICALL_DEBUG) {
6646
+ return ;
6647
+ }
6648
+
6649
  global $debug_count;
6650
  $debug_count++;
6651
+ $printText = ' ' . $printText;
6652
 
6653
  global $every_count;
6654
  //$conditions = 'printOnly';
6668
 
6669
  if( !function_exists('print_memory_debug') ){
6670
  function print_memory_debug($debug_count, $conditions = '', $printText = ''){
6671
+ global $iwp_multicall_hisID;
6672
  $this_memory_peak_in_mb = memory_get_peak_usage();
6673
  $this_memory_peak_in_mb = $this_memory_peak_in_mb / 1048576;
6674
  $this_memory_in_mb = memory_get_usage();
6675
  $this_memory_in_mb = $this_memory_in_mb / 1048576;
6676
  $this_time_taken = microtime(true) - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'];
6677
+ $current_cpu_load = 0;
6678
+ $memoryPeakLog = 'DE_clMemoryPeak.'.$iwp_multicall_hisID.'.txt';
6679
+ $memoryUsageLog = 'DE_clMemoryUsage.'.$iwp_multicall_hisID.'.txt';
6680
+ $timeTakenLog = 'DE_clTimeTaken.'.$iwp_multicall_hisID.'.txt';
6681
+ $cpuUsageLog = 'DE_clCPUUsage.'.$iwp_multicall_hisID.'.txt';
6682
+ if (function_exists('sys_getloadavg')) {
6683
+ $cpu_load = sys_getloadavg();
6684
+ $current_cpu_load = $cpu_load[0];
6685
+ }
6686
+
6687
  if($conditions == 'printOnly'){
6688
  if($this_memory_peak_in_mb >= 34){
6689
+ file_put_contents(IWP_BACKUP_DIR . '/'.$memoryPeakLog,$debug_count . $printText . " " . round($this_memory_peak_in_mb, 2) ."\n",FILE_APPEND);
6690
+ file_put_contents(IWP_BACKUP_DIR . '/'.$memoryUsageLog,$debug_count . $printText . " " . round($this_memory_in_mb, 2) ."\n",FILE_APPEND);
6691
+ file_put_contents(IWP_BACKUP_DIR . '/'.$timeTakenLog,$debug_count . $printText . " " . round($this_time_taken, 2) ."\n",FILE_APPEND);
6692
+ file_put_contents(IWP_BACKUP_DIR . '/'.$cpuUsageLog,$debug_count . $printText . " " . $current_cpu_load ."\n",FILE_APPEND);
6693
  }
6694
  }
6695
  else{
6696
+ file_put_contents(IWP_BACKUP_DIR . '/'.$memoryPeakLog,$debug_count . $printText . " " . round($this_memory_peak_in_mb, 2) ."\n",FILE_APPEND);
6697
+ file_put_contents(IWP_BACKUP_DIR . '/'.$memoryUsageLog,$debug_count . $printText . " " . round($this_memory_in_mb, 2) ."\n",FILE_APPEND);
6698
+ file_put_contents(IWP_BACKUP_DIR . '/'.$timeTakenLog,$debug_count . $printText . " " . round($this_time_taken, 2) ."\n",FILE_APPEND);
6699
+ file_put_contents(IWP_BACKUP_DIR . '/'.$cpuUsageLog,$debug_count . $printText . " " . $current_cpu_load ."\n",FILE_APPEND);
6700
+
6701
  }
6702
  }
6703
  }
backup.class.singlecall.php CHANGED
@@ -165,6 +165,13 @@ class IWP_MMB_Backup_Singlecall extends IWP_MMB_Core
165
  }
166
  upgradeOldDropBoxBackupList($this->tasks['account_info']['iwp_dropbox']);
167
  }
 
 
 
 
 
 
 
168
 
169
  extract($params);
170
 
@@ -191,14 +198,24 @@ class IWP_MMB_Backup_Singlecall extends IWP_MMB_Core
191
 
192
 
193
  function delete_task_now($task_name){
194
- global $wpdb;
195
 
196
  $table_name = $wpdb->base_prefix . "iwp_backup_status";
197
 
198
  $tasks = $this->tasks;
199
  //unset($tasks[$task_name]);
200
 
201
-
 
 
 
 
 
 
 
 
 
 
202
  $delete_query = "DELETE FROM ".$table_name." WHERE taskName = '".$task_name."' ";
203
  $deleteRes = $wpdb->query($delete_query);
204
 
@@ -615,6 +632,8 @@ function delete_task_now($task_name){
615
  "pgcache",
616
  "objectcache",
617
  "wp-snapshots",
 
 
618
  );
619
 
620
  //removing files which are larger than the specified size
@@ -1081,12 +1100,40 @@ function delete_task_now($task_name){
1081
  global $wpdb;
1082
  $paths = $this->getMySQLPath();
1083
  $brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
 
1084
  //$command = $brace . $paths['mysqldump'] . $brace . ' --force --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" --add-drop-table --skip-lock-tables "' . DB_NAME . '" > ' . $brace . $file . $brace;
1085
  $command0 = $wpdb->get_col('SHOW TABLES LIKE "'.$wpdb->base_prefix.'%"');
1086
- $wp_tables = join("\" \"",$command0);
1087
- $command = $brace . $paths['mysqldump'] . $brace . ' --force --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" --add-drop-table --skip-lock-tables --extended-insert=FALSE "' . DB_NAME . '" "'.$wp_tables.'" > ' . $brace . $file . $brace;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1088
  iwp_mmb_print_flush('DB DUMP CMD: Start');
1089
  ob_start();
 
 
 
 
 
 
 
1090
  $result = $this->iwp_mmb_exec($command);
1091
  ob_get_clean();
1092
  iwp_mmb_print_flush('DB DUMP CMD: End');
@@ -1107,7 +1154,7 @@ function delete_task_now($task_name){
1107
  function backup_db_php($file)
1108
  {
1109
  global $wpdb;
1110
-
1111
  if(empty($GLOBALS['fail_safe_db'])){
1112
  iwp_mmb_print_flush('DB DUMP PHP Normal: Start');
1113
  $fp = fopen( $file, 'w' );
@@ -1137,7 +1184,18 @@ function delete_task_now($task_name){
1137
  $insert_sql .= "\n\n" . $table_descr_query[0][1] . ";\n\n";
1138
  fwrite( $fp, $insert_sql );
1139
  $insert_sql = '';
1140
-
 
 
 
 
 
 
 
 
 
 
 
1141
  $table_query = $wpdb->get_results("SELECT * FROM `$table`", ARRAY_N);
1142
  $num_fields = $wpdb->num_rows;
1143
 
@@ -1193,6 +1251,19 @@ function delete_task_now($task_name){
1193
  $create_table = $wpdb->get_row("SHOW CREATE TABLE $table[0]", ARRAY_N);
1194
  $dump_data = "\n\n" . $create_table[1] . ";\n\n";
1195
  file_put_contents($file, $dump_data, FILE_APPEND);
 
 
 
 
 
 
 
 
 
 
 
 
 
1196
 
1197
  $count = $wpdb->get_var("SELECT count(*) FROM $table[0]");
1198
  if ($count > 100)
@@ -1663,7 +1734,7 @@ function delete_task_now($task_name){
1663
 
1664
  function check_backup_compat()
1665
  {
1666
- global $wpdb;
1667
  $reqs = array();
1668
  $reqs['serverInfo']['server_os']['name'] = 'Server OS';
1669
  if (strpos($_SERVER['DOCUMENT_ROOT'], '/') === 0) {
@@ -1705,28 +1776,28 @@ function delete_task_now($task_name){
1705
  }
1706
 
1707
  if ( !ini_get( 'memory_limit' ) ) {
1708
- $parent_class_val = 'unknown';
1709
- } else {
1710
- $parent_class_val = ini_get( 'memory_limit' );
1711
- }
1712
  $reqs['serverInfo']['php_memory_limit']['name'] = 'PHP Memory Limit';
1713
  $reqs['serverInfo']['php_memory_limit']['status'] = $parent_class_val;
1714
  $reqs['serverInfo']['php_memory_limit']['suggeted'] = '>= 128M (256M+ best)';
1715
 
1716
  if ( preg_match( '/(\d+)(\w*)/', $parent_class_val, $matches ) ) {
1717
- $parent_class_val = $matches[1];
1718
- $unit = $matches[2];
1719
- // Up memory limit if currently lower than 256M.
1720
- if ( 'g' !== strtolower( $unit ) ) {
1721
- if ( ( $parent_class_val < 128 ) || ( 'm' !== strtolower( $unit ) ) ) {
1722
- $reqs['serverInfo']['php_memory_limit']['pass'] = false;
1723
- } else {
1724
- $reqs['serverInfo']['php_memory_limit']['pass'] = true;
1725
- }
1726
- }
1727
- } else {
1728
- $reqs['serverInfo']['php_memory_limit']['pass'] = false;
1729
- }
1730
 
1731
  //$reqs['serverInfo']['Site Information']['status'] = $this->getDirectorySize(ABSPATH);
1732
  $tempInfo = $this->getDirectorySize(ABSPATH);
@@ -1856,7 +1927,46 @@ function delete_task_now($task_name){
1856
  $reqs['functionList']['ftp_functions']['pass'] = false;
1857
  }
1858
  $reqs['functionList']['ftp_functions']['suggeted'] = 'N/A';
1859
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1860
  return $reqs;
1861
  }
1862
 
@@ -2779,7 +2889,9 @@ function ftp_backup($args)
2779
  foreach($rows as $key => $value){
2780
  $task_results = unserialize($value->taskResults);
2781
  $task_res[$value->taskName][$value->historyID] = $task_results['task_results'][$value->historyID];
2782
- $task_res[$value->taskName][$value->historyID]['backhack_status'] = $task_results['backhack_status'];
 
 
2783
  }
2784
  $stats = $task_res;
2785
  return $stats;
@@ -3195,7 +3307,7 @@ function ftp_backup($args)
3195
  function statusLog($historyID = '', $statusArray = array(), $params=array())
3196
  {
3197
  global $wpdb,$insertID;
3198
-
3199
  if(empty($historyID))
3200
  {
3201
  $insert = $wpdb->insert($wpdb->base_prefix.'iwp_backup_status',array( 'stage' => $statusArray['stage'], 'status' => $statusArray['status'], 'action' => $params['args']['action'], 'type' => $params['args']['type'],'category' => $params['args']['what'],'historyID' => $GLOBALS['IWP_CLIENT_HISTORY_ID'],'finalStatus' => 'pending','startTime' => microtime(true),'lastUpdateTime' => microtime(true), 'endTime' => '','statusMsg' => $statusArray['statusMsg'],'requestParams' => serialize($params),'taskName' => $params['task_name']), array( '%s', '%s','%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%s', '%s', '%s' ) );
165
  }
166
  upgradeOldDropBoxBackupList($this->tasks['account_info']['iwp_dropbox']);
167
  }
168
+ if ((!defined('DISABLE_IWP_CLOUD_VERIFICATION')) && (empty($this->tasks['args']['disable_iwp_cloud_verification']))) {
169
+ $backup_repo_test_obj = new IWP_BACKUP_REPO_TEST();
170
+ $backup_repo_test_result = $backup_repo_test_obj->repositoryTestConnection($this->tasks['account_info']);
171
+ if (!empty($backup_repo_test_result['error']) && $backup_repo_test_result['status'] != 'success') {
172
+ return array('error' => $backup_repo_test_result['error'], 'error_code' => $backup_repo_test_result['error_code']);
173
+ }
174
+ }
175
 
176
  extract($params);
177
 
198
 
199
 
200
  function delete_task_now($task_name){
201
+ global $wpdb, $iwp_backup_core;
202
 
203
  $table_name = $wpdb->base_prefix . "iwp_backup_status";
204
 
205
  $tasks = $this->tasks;
206
  //unset($tasks[$task_name]);
207
 
208
+ $stats = array();
209
+ $new_backup_method = $iwp_backup_core->get_backup_history();
210
+ $task_res = array();
211
+ if (!empty($new_backup_method)) {
212
+ foreach ($new_backup_method as $time => $value) {
213
+ if ($value['label'] == $task_name) {
214
+ unset($new_backup_method[$time]);
215
+ }
216
+ }
217
+ }
218
+ $iwp_backup_core->save_history($new_backup_method);
219
  $delete_query = "DELETE FROM ".$table_name." WHERE taskName = '".$task_name."' ";
220
  $deleteRes = $wpdb->query($delete_query);
221
 
632
  "pgcache",
633
  "objectcache",
634
  "wp-snapshots",
635
+ "site_map.xml",
636
+ "iwp-clone-log.txt",
637
  );
638
 
639
  //removing files which are larger than the specified size
1100
  global $wpdb;
1101
  $paths = $this->getMySQLPath();
1102
  $brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
1103
+ $exclude_tables = $this->tasks['args']['exclude_tables'];
1104
  //$command = $brace . $paths['mysqldump'] . $brace . ' --force --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" --add-drop-table --skip-lock-tables "' . DB_NAME . '" > ' . $brace . $file . $brace;
1105
  $command0 = $wpdb->get_col('SHOW TABLES LIKE "'.$wpdb->base_prefix.'%"');
1106
+ $full_table = array();
1107
+ $structure_only_table = array();
1108
+ if (!empty($exclude_tables)) {
1109
+ foreach ($command0 as $tk => $table) {
1110
+ foreach ($exclude_tables as $ke => $exclude_table) {
1111
+ $structure = false;
1112
+ if (strpos($table, $exclude_table)) {
1113
+ $structure = true;
1114
+ break;
1115
+ }
1116
+ }
1117
+ if ($structure) {
1118
+ $structure_only_table [] = $table;
1119
+ }else{
1120
+ $full_table [] = $table;
1121
+ }
1122
+ }
1123
+ }else{
1124
+ $full_table = $command0;
1125
+ }
1126
+ $wp_tables = join("\" \"",$full_table);
1127
+ $command = $brace . $paths['mysqldump'] . $brace . ' --force --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" --max_allowed_packet=8M --net_buffer_length=1M --skip-comments --skip-set-charset --allow-keywords --dump-date --add-drop-table --skip-lock-tables --extended-insert "' . DB_NAME . '" "'.$wp_tables.'" > ' . $brace . $file . $brace;
1128
  iwp_mmb_print_flush('DB DUMP CMD: Start');
1129
  ob_start();
1130
+ if (!empty($structure_only_table)) {
1131
+ $wp_tables = join("\" \"",$structure_only_table);
1132
+ $structure_command = $brace . $paths['mysqldump'] . $brace . ' --force --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" --add-drop-table --skip-lock-tables --no-data "' . DB_NAME . '" "'.$wp_tables.'" >> ' . $brace . $file . $brace;
1133
+ // $result = $this->iwp_mmb_exec($structure_command);
1134
+ $command.=' && '.$structure_command;
1135
+
1136
+ }
1137
  $result = $this->iwp_mmb_exec($command);
1138
  ob_get_clean();
1139
  iwp_mmb_print_flush('DB DUMP CMD: End');
1154
  function backup_db_php($file)
1155
  {
1156
  global $wpdb;
1157
+ $exclude_tables = $this->tasks['args']['exclude_tables'];
1158
  if(empty($GLOBALS['fail_safe_db'])){
1159
  iwp_mmb_print_flush('DB DUMP PHP Normal: Start');
1160
  $fp = fopen( $file, 'w' );
1184
  $insert_sql .= "\n\n" . $table_descr_query[0][1] . ";\n\n";
1185
  fwrite( $fp, $insert_sql );
1186
  $insert_sql = '';
1187
+ $skipThisTable = false;
1188
+ if (!empty($exclude_tables)) {
1189
+ foreach ($exclude_tables as $ke => $exclude_table) {
1190
+ if (strpos($table[0], $exclude_table)) {
1191
+ $skipThisTable = true;
1192
+ break;
1193
+ }
1194
+ }
1195
+ }
1196
+ if ($skipThisTable) {
1197
+ continue;
1198
+ }
1199
  $table_query = $wpdb->get_results("SELECT * FROM `$table`", ARRAY_N);
1200
  $num_fields = $wpdb->num_rows;
1201
 
1251
  $create_table = $wpdb->get_row("SHOW CREATE TABLE $table[0]", ARRAY_N);
1252
  $dump_data = "\n\n" . $create_table[1] . ";\n\n";
1253
  file_put_contents($file, $dump_data, FILE_APPEND);
1254
+
1255
+ $skipThisTable = false;
1256
+ if (!empty($exclude_tables)) {
1257
+ foreach ($exclude_tables as $ke => $exclude_table) {
1258
+ if (strpos($table[0], $exclude_table)) {
1259
+ $skipThisTable = true;
1260
+ break;
1261
+ }
1262
+ }
1263
+ }
1264
+ if ($skipThisTable) {
1265
+ continue;
1266
+ }
1267
 
1268
  $count = $wpdb->get_var("SELECT count(*) FROM $table[0]");
1269
  if ($count > 100)
1734
 
1735
  function check_backup_compat()
1736
  {
1737
+ global $wpdb, $iwp_backup_core;
1738
  $reqs = array();
1739
  $reqs['serverInfo']['server_os']['name'] = 'Server OS';
1740
  if (strpos($_SERVER['DOCUMENT_ROOT'], '/') === 0) {
1776
  }
1777
 
1778
  if ( !ini_get( 'memory_limit' ) ) {
1779
+ $parent_class_val = 'unknown';
1780
+ } else {
1781
+ $parent_class_val = ini_get( 'memory_limit' );
1782
+ }
1783
  $reqs['serverInfo']['php_memory_limit']['name'] = 'PHP Memory Limit';
1784
  $reqs['serverInfo']['php_memory_limit']['status'] = $parent_class_val;
1785
  $reqs['serverInfo']['php_memory_limit']['suggeted'] = '>= 128M (256M+ best)';
1786
 
1787
  if ( preg_match( '/(\d+)(\w*)/', $parent_class_val, $matches ) ) {
1788
+ $parent_class_val = $matches[1];
1789
+ $unit = $matches[2];
1790
+ // Up memory limit if currently lower than 256M.
1791
+ if ( 'g' !== strtolower( $unit ) ) {
1792
+ if ( ( $parent_class_val < 128 ) || ( 'm' !== strtolower( $unit ) ) ) {
1793
+ $reqs['serverInfo']['php_memory_limit']['pass'] = false;
1794
+ } else {
1795
+ $reqs['serverInfo']['php_memory_limit']['pass'] = true;
1796
+ }
1797
+ }
1798
+ } else {
1799
+ $reqs['serverInfo']['php_memory_limit']['pass'] = false;
1800
+ }
1801
 
1802
  //$reqs['serverInfo']['Site Information']['status'] = $this->getDirectorySize(ABSPATH);
1803
  $tempInfo = $this->getDirectorySize(ABSPATH);
1927
  $reqs['functionList']['ftp_functions']['pass'] = false;
1928
  }
1929
  $reqs['functionList']['ftp_functions']['suggeted'] = 'N/A';
1930
+ $curl_info = curl_version();
1931
+ $reqs['serverInfo']['curl_version']['name'] = 'Curl Version';
1932
+ $reqs['serverInfo']['curl_version']['status'] = $curl_info['version'];
1933
+ $reqs['serverInfo']['curl_version']['pass'] = true;
1934
+ $reqs['serverInfo']['curl_version']['suggeted'] = 'N/A';
1935
+
1936
+ $reqs['serverInfo']['ssl_ersion']['name'] = 'SSL Version';
1937
+ $reqs['serverInfo']['ssl_ersion']['status'] = $curl_info['ssl_version'];
1938
+ $reqs['serverInfo']['ssl_ersion']['pass'] = true;
1939
+ $reqs['serverInfo']['ssl_ersion']['suggeted'] = 'N/A';
1940
+
1941
+ //$hosting_bytes_free = $iwp_backup_core->get_hosting_disk_quota_free();
1942
+ $quota_free = 'N/A';
1943
+ $no_low_quota = true;
1944
+ $no_low_disk_space = true;
1945
+ /*if (is_array($hosting_bytes_free)) {
1946
+ $perc = round(100*$hosting_bytes_free[1]/(max($hosting_bytes_free[2], 1)), 1);
1947
+ $quota_free = round($hosting_bytes_free[3]/1048576, 1)." MB";
1948
+ if ($hosting_bytes_free[3] < 1048576*50) {
1949
+ $no_low_quota = true;
1950
+ }
1951
+ }*/
1952
+ $disk_free_space = @disk_free_space(IWP_BACKUP_DIR);
1953
+ if ($disk_free_space == false) {
1954
+ $quota_free = 'Unknown';
1955
+ } else {
1956
+ $disk_free_mb = round($disk_free_space/1048576, 1)." MB";
1957
+ if ($disk_free_space < 50*1048576){
1958
+ $no_low_disk_space = true;
1959
+ }
1960
+ }
1961
+ /*$reqs['serverInfo']['quota_free']['name'] = 'CPanel Quota';
1962
+ $reqs['serverInfo']['quota_free']['status'] = $quota_free;
1963
+ $reqs['serverInfo']['quota_free']['pass'] = $no_low_quota;
1964
+ $reqs['serverInfo']['quota_free']['suggeted'] = 'N/A';*/
1965
+
1966
+ $reqs['serverInfo']['disk_free_space']['name'] = 'Free Disk space';
1967
+ $reqs['serverInfo']['disk_free_space']['status'] = $disk_free_mb;
1968
+ $reqs['serverInfo']['disk_free_space']['pass'] = $no_low_quota;
1969
+ $reqs['serverInfo']['disk_free_space']['suggeted'] = 'N/A';
1970
  return $reqs;
1971
  }
1972
 
2889
  foreach($rows as $key => $value){
2890
  $task_results = unserialize($value->taskResults);
2891
  $task_res[$value->taskName][$value->historyID] = $task_results['task_results'][$value->historyID];
2892
+ if (!empty($task_results['backhack_status'])) {
2893
+ $task_res[$value->taskName][$value->historyID]['backhack_status'] = $task_results['backhack_status'];
2894
+ }
2895
  }
2896
  $stats = $task_res;
2897
  return $stats;
3307
  function statusLog($historyID = '', $statusArray = array(), $params=array())
3308
  {
3309
  global $wpdb,$insertID;
3310
+ iwp_mmb_create_backup_status_table();
3311
  if(empty($historyID))
3312
  {
3313
  $insert = $wpdb->insert($wpdb->base_prefix.'iwp_backup_status',array( 'stage' => $statusArray['stage'], 'status' => $statusArray['status'], 'action' => $params['args']['action'], 'type' => $params['args']['type'],'category' => $params['args']['what'],'historyID' => $GLOBALS['IWP_CLIENT_HISTORY_ID'],'finalStatus' => 'pending','startTime' => microtime(true),'lastUpdateTime' => microtime(true), 'endTime' => '','statusMsg' => $statusArray['statusMsg'],'requestParams' => serialize($params),'taskName' => $params['task_name']), array( '%s', '%s','%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%s', '%s', '%s' ) );
backup/backup-repo-test.php ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class IWP_BACKUP_REPO_TEST {
4
+
5
+ public function repositoryTestConnection($account_info){
6
+ if(isset($account_info['iwp_ftp']) && !empty($account_info)) {
7
+ $return = $this->FTPTestConnection($account_info['iwp_ftp']);
8
+ }
9
+
10
+ if(isset($account_info['iwp_amazon_s3']) && !empty($account_info['iwp_amazon_s3'])) {
11
+ if(phpversion() >= '5.3.3'){
12
+ require_once($GLOBALS['iwp_mmb_plugin_dir'] . '/lib/amazon/s3IWPBackup.php');
13
+ $return = iwpRepositoryAmazons3($account_info['iwp_amazon_s3']);
14
+ }
15
+ else{
16
+ $return = $this->repositoryAmazons3BwdComp($account_info['iwp_amazon_s3']);
17
+ }
18
+ }
19
+
20
+ if (isset($account_info['iwp_dropbox']) && !empty($account_info['iwp_dropbox'])) {
21
+ $return = $this->backupRepositoryDropbox($account_info['iwp_dropbox']);
22
+ }
23
+
24
+ if (isset($account_info['iwp_gdrive']) && !empty($account_info['iwp_gdrive'])) {
25
+ $return = $this->repositoryGDrive($account_info['iwp_gdrive']);
26
+ }
27
+ return $return;
28
+ }
29
+
30
+ public function FTPTestConnection($args){
31
+ extract($args);
32
+ $ftp_hostname = $ftp_hostname ? $ftp_hostname : $hostName;
33
+ $ftp_username = $ftp_username ? $ftp_username : $hostUserName;
34
+ $ftp_password = $ftp_password ? $ftp_password : $hostPassword;
35
+ $FTPBase = $ftp_remote_folder ? $ftp_remote_folder : $FTPBase;
36
+
37
+ if(empty($ftp_hostname)){
38
+ return array('status' => 'error',
39
+ 'errorMsg' => 'Inavlid FTP host',
40
+ );
41
+ }
42
+
43
+ if(isset($use_sftp) && $use_sftp == 1) {
44
+ return $this->SFTPTestConnection($args);
45
+ }
46
+ else{
47
+ return $this->simpleFTPTestConnection($args);
48
+ }
49
+
50
+ }
51
+ public function simpleFTPTestConnection($args){
52
+ global $iwp_mmb_core;
53
+ extract($args);
54
+ //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder, $ftp_site_folder
55
+ $port = $ftp_port ? $ftp_port : 21; //default port is 21
56
+ if (!empty($ftp_ssl)) {
57
+ if (function_exists('ftp_ssl_connect')) {
58
+ $conn_id = ftp_ssl_connect($ftp_hostname,$port);
59
+ if ($conn_id === false) {
60
+ return array(
61
+ 'error' => 'Failed to connect to host',
62
+ 'partial' => 1, 'error_code' => 'failed_to_connect_to_hostname_ftp_ssl_connect'
63
+ );
64
+ }
65
+ } else {
66
+ return array(
67
+ 'error' => 'Your server doesn\'t support FTP SSL',
68
+ 'partial' => 1, 'error_code' => 'your_server_doesnt_support_ftp_ssl'
69
+ );
70
+ }
71
+ }
72
+ else {
73
+ if (function_exists('ftp_connect')) {
74
+ $conn_id = ftp_connect($ftp_hostname,$port);
75
+ if ($conn_id === false) {
76
+ return array(
77
+ 'error' => 'Failed to connect to host',
78
+ 'partial' => 1, 'error_code' => 'failed_to_connect_hostname_ftp_connect'
79
+ );
80
+ }
81
+ } else {
82
+ return array(
83
+ 'error' => 'Your server doesn\'t support FTP',
84
+ 'partial' => 1, 'error_code' => 'your_server_doesnt_support_ftp'
85
+ );
86
+ }
87
+ }
88
+
89
+ $login = @ftp_login($conn_id, $ftp_username, $ftp_password);
90
+ if ($login === false) {
91
+ return array(
92
+ 'error' => 'Invalid FTP Username and password login ',
93
+ 'partial' => 1, 'error_code' => 'ftp_login_failed'
94
+ );
95
+ }else{
96
+ return array('status' => 'success');
97
+ }
98
+
99
+ if(!empty($ftp_passive)){
100
+ @ftp_pasv($conn_id,true);
101
+ }
102
+ @ftp_mkdir($conn_id, $ftp_remote_folder);
103
+ if (!empty($ftp_site_folder)) {
104
+ $ftp_remote_folder .= '/' . $iwp_mmb_core->backup_instance->site_name;
105
+ }
106
+ @ftp_mkdir($conn_id, $ftp_remote_folder);
107
+ $backup_file = IWP_BACKUP_DIR.'/__testFTP2'.time().'.php';
108
+ $test_content = '<?php
109
+ // Silence is golden.
110
+ ';
111
+
112
+ @file_put_contents($backup_file, $test_content); //safe
113
+ $upload = $this -> ftp_multi_upload($conn_id, rtrim($ftp_remote_folder, '/') . '/' . basename($backup_file), $backup_file, FTP_BINARY);
114
+ unlink($backup_file);
115
+ ftp_delete($conn_id, rtrim($ftp_remote_folder, '/') . '/' . basename($backup_file));
116
+ @ftp_close($conn_id);
117
+
118
+ return $upload;
119
+ }
120
+
121
+ public function ftp_multi_upload($conn_id, $remoteFileName, $backup_file, $mode){
122
+ $file_size = 0;
123
+ $fp = fopen($backup_file, 'r');
124
+ fseek($fp,$file_size);
125
+
126
+ $ret = ftp_nb_fput($conn_id, $remoteFileName, $fp, FTP_BINARY, $file_size);
127
+ if(!$ret || $ret == FTP_FAILED){
128
+ return array(
129
+ 'error' => "FTP upload Error. ftp_nb_fput(): Append/Restart not permitted. This feature is required for multi-call backup upload via FTP to work. Please contact your WP site's hosting provider and ask them to fix the problem. You can try dropbox, Amazon S3 or Google Driver as an alternative to it.",
130
+ 'partial' => 1, 'error_code' => 'ftp_nb_fput_not_permitted_error'
131
+ );
132
+ }
133
+
134
+ while ($ret == FTP_MOREDATA) {
135
+ $ret = ftp_nb_continue($conn_id);
136
+ }
137
+
138
+ if ($ret == FTP_FINISHED) {
139
+ fclose($fp);
140
+ return array('status' => 'success');
141
+ }
142
+ }
143
+
144
+ public function SFTPTestConnection($args){
145
+ extract($args);
146
+
147
+ $ftp_hostname = $ftp_hostname ? $ftp_hostname : $hostName;
148
+ $ftp_username = $ftp_username ? $ftp_username : $hostUserName;
149
+ $ftp_password = $ftp_password ? $ftp_password : $hostPassword;
150
+ $FTPBase = $ftp_remote_folder ? $ftp_remote_folder : $FTPBase;
151
+ $port = $ftp_port ? $ftp_port : 22;
152
+ $path = $GLOBALS['iwp_mmb_plugin_dir'].'/lib/phpseclib/phpseclib/phpseclib';
153
+ set_include_path(get_include_path() . PATH_SEPARATOR . $path);
154
+ include_once('Net/SFTP.php');
155
+ $sftp = new Net_SFTP($ftp_hostname, $port);
156
+
157
+ if(!$sftp) {
158
+ return array('status' => 'error',
159
+ 'errorMsg' => 'Failed to connect to host',
160
+ );
161
+ }
162
+ if (!$sftp->login($ftp_username, $ftp_password)) {
163
+ return array('status' => 'error',
164
+ 'errorMsg' => 'Invalid FTP Username and password login ',
165
+ );
166
+ }
167
+ else{
168
+ if(empty($FTPBase)){
169
+ return array('status' => 'error',
170
+ 'errorMsg' => 'Invalid FTP base path..',
171
+ );
172
+ }
173
+ if(!$sftp->chdir($FTPBase)){
174
+ return array('status' => 'error',
175
+ 'errorMsg' => 'FTP upload failed.',
176
+ );
177
+ }
178
+ $backup_file = IWP_BACKUP_DIR.'/__testFTP2'.time().'.php';
179
+ $test_content = '<?php
180
+ // Silence is golden.
181
+ ';
182
+
183
+ @file_put_contents($backup_file, $test_content); //safe
184
+ $remote_loation = basename($backup_file);
185
+ $local_location = $backup_file;
186
+ $sftp->mkdir($ftp_remote_folder,-1,true);
187
+ $sftp->chdir($ftp_remote_folder);
188
+ $uploadFilePath = IWP_BACKUP_DIR;
189
+ $uploadTestFile = $sftp->put(basename($backup_file),$backup_file,NET_SFTP_LOCAL_FILE);
190
+ @unlink($backup_file);
191
+ $appPathFile = APP_ROOT.$testFile;
192
+ if ($uploadTestFile === false) {
193
+ return array('status' => 'error',
194
+ 'errorMsg' => 'FTP upload failed.',
195
+ );
196
+ }else{
197
+ return array('status' => 'success');
198
+ }
199
+ }
200
+ }
201
+
202
+ public function backupRepositoryDropbox($args){
203
+ extract($args);
204
+ if(isset($dropbox_access_token) && !empty($dropbox_access_token)){
205
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/lib/Dropbox/API.php';
206
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/lib/Dropbox/Exception.php';
207
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/lib/Dropbox/OAuth/Consumer/ConsumerAbstract.php';
208
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/lib/Dropbox/OAuth/Consumer/Curl.php';
209
+
210
+ try{
211
+ $oauth = new IWP_Dropbox_OAuth_Consumer_Curl($dropbox_app_key, $dropbox_app_secure_key);
212
+ $oauth->setToken($dropbox_access_token);
213
+ $dropbox = new IWP_Dropbox_API($oauth);
214
+ $oldRoot = 'Apps/InfiniteWP';
215
+ $dropbox_destination = $oldRoot.$dropbox_destination;
216
+ $response = $dropbox->accountInfo();
217
+ return array('status' => 'success');
218
+ }
219
+ catch(Exception $e){
220
+ return array('error' => $e->getMessage(), 'error_code' => 'dropbox_test_failed');
221
+ }
222
+ }
223
+ return array('error' => 'Consumer Secret not available', 'error_code' => 'consumer_secret_not_available');
224
+ }
225
+
226
+ public function repositoryGDrive($gDriveArgs){
227
+ require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/Google/Client.php');
228
+ require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/Google/Http/MediaFileUpload.php');
229
+ require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/Google/Service/Drive.php');
230
+
231
+ if(!empty($gDriveArgs) && !empty($gDriveArgs['clientID']) && !empty($gDriveArgs['clientSecretKey']) )
232
+ {
233
+ $accessToken = $gDriveArgs['token'];
234
+
235
+ $client = new IWP_google_Client();
236
+ $client->setClientId($gDriveArgs['clientID']);
237
+
238
+ $client->setClientSecret($gDriveArgs['clientSecretKey']);
239
+ $client->setRedirectUri($gDriveArgs['redirectURL']);
240
+ $client->setScopes(array(
241
+ 'https://www.googleapis.com/auth/drive',
242
+ 'https://www.googleapis.com/auth/userinfo.email'));
243
+
244
+ $accessToken = $gDriveArgs['token'];
245
+ $refreshToken = $accessToken['refresh_token'];
246
+
247
+ try
248
+ {
249
+ $client->refreshToken($refreshToken);
250
+ return array('status' => 'success');
251
+ }
252
+ catch(Exception $e)
253
+ {
254
+ return array('error' => $e->getMessage(), 'error_code' => 'gdrive_backup_test_failed');
255
+ }
256
+ }
257
+ return array('status' => 'error', 'errorMsg' => 'API key not available.');
258
+ }
259
+
260
+ public function repositoryAmazons3BwdComp($args){
261
+ require_once($GLOBALS['iwp_mmb_plugin_dir']."/lib/S3.php");
262
+ extract($args);
263
+
264
+ if(!empty($as3_bucket_region)){
265
+ $endpoint = 's3-' . $as3_bucket_region . '.amazonaws.com';
266
+ }
267
+ else{
268
+ $endpoint = 's3.amazonaws.com';
269
+ }
270
+ $s3 = new IWP_MMB_S3(trim($as3_access_key), trim(str_replace(' ', '+', $as3_secure_key)), false, $endpoint);
271
+
272
+ try{
273
+ $s3->getBucket($as3_bucket, IWP_MMB_S3::ACL_PUBLIC_READ);
274
+ return array('status' => 'success');
275
+ }
276
+ catch (Exception $e){
277
+ return array('error' => $e->getMessage(), 'error_code' => 's3_backup_test_verify_failed');
278
+ //$e->getMessage();
279
+ }
280
+ }
281
+ }
backup/backup.core.class.php CHANGED
@@ -1245,7 +1245,7 @@ class IWP_MMB_Backup_Core {
1245
  die;
1246
  }
1247
 
1248
- if ($this->current_resumption >= 9 && false == $this->newresumption_scheduled) {
1249
  $this->log("This is resumption ".$this->current_resumption.", but meaningful activity is still taking place; so a new one will be scheduled");
1250
  // We just use max here to make sure we get a number at all
1251
  $resume_interval = max($this->jobdata_get('resume_interval'), 75);
@@ -3683,7 +3683,8 @@ CREATE TABLE $wpdb->signups (
3683
  $cron_disable = true;
3684
  $cron_params = $this->get_cron($job_id);
3685
  }
3686
- return array('success'=>array('status' => 'partiallyCompleted', 'params' => $params['params'], 'jobdata'=>$job_data, 'cron_disable' => $cron_disable, 'cron_params' =>$cron_params, 'wp_content_url' => content_url()));
 
3687
  } elseif ($result == '0') {
3688
  $cron = $this->get_cron($job_id);
3689
  if ($cron == false) {
@@ -3703,7 +3704,13 @@ CREATE TABLE $wpdb->signups (
3703
  wp_cron();
3704
  }
3705
  }
3706
- return array('success'=>array('status' => 'partiallyCompleted', 'params' => $params['params'], 'jobdata'=>$job_data, 'cron_data' => $cron, 'wp_content_url' => content_url()) );
 
 
 
 
 
 
3707
  }
3708
 
3709
  }
@@ -3804,6 +3811,24 @@ CREATE TABLE $wpdb->signups (
3804
  }
3805
  }
3806
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3807
  public function last_backup_staus() {
3808
  $last_backup = array();
3809
  $IWP_last_backup = IWP_MMB_Backup_Options::get_iwp_backup_option('IWP_last_backup');
@@ -3879,6 +3904,11 @@ CREATE TABLE $wpdb->signups (
3879
  if (!empty($params['args']['exclude_extensions']) && !defined('IWP_EXCLUDE_EXTENSIONS')) {
3880
  define('IWP_EXCLUDE_EXTENSIONS', $params['args']['exclude_extensions']);
3881
  }
 
 
 
 
 
3882
 
3883
  if (!empty($params['account_info'])) {
3884
  if (!empty($params['account_info']['iwp_ftp'])) {
@@ -3890,7 +3920,8 @@ CREATE TABLE $wpdb->signups (
3890
  'path' => $ftp_details['ftp_remote_folder'],
3891
  'port' => $ftp_details['ftp_port'],
3892
  'ftp_site_folder' => $ftp_details['ftp_site_folder'],
3893
- 'passive' => $ftp_details['ftp_passive']?true:false
 
3894
  );
3895
  if ($ftp_details['use_sftp']) {
3896
  update_option('IWP_service', 'sftp');
@@ -3959,6 +3990,11 @@ CREATE TABLE $wpdb->signups (
3959
  update_option('IWP_retain', $params['args']['limit']);
3960
  update_option('IWP_retain_db', $params['args']['limit']);
3961
  }
 
 
 
 
 
3962
  }
3963
 
3964
  public function get_remote_file($services, $file, $timestamp, $restore = false) {
@@ -4554,6 +4590,7 @@ CREATE TABLE $wpdb->signups (
4554
  $our_files['backup_meta_file'] = $backup_file_basename;
4555
  $our_files['old_file_path'] = ABSPATH;
4556
  $our_files['old_url'] = get_option('siteurl');
 
4557
  $backup_dir = $this->backups_dir_location();
4558
  $backup_meta_file = $backup_dir.'/'.$backup_file_basename;
4559
  $meta_file_handle = fopen($backup_meta_file, 'w');
@@ -4856,12 +4893,22 @@ CREATE TABLE $wpdb->signups (
4856
  'pass' => $ftp_details['ftp_password'],
4857
  'host' => $ftp_details['ftp_hostname'],
4858
  'path' => $ftp_details['ftp_remote_folder'],
 
4859
  'ftp_site_folder' => $ftp_details['ftp_site_folder'],
4860
  'passive' => $ftp_details['ftp_passive']?true:false
4861
  );
4862
  if ($ftp_details['use_sftp']) {
 
4863
  IWP_MMB_Backup_Options::update_iwp_backup_option('IWP_sftp', $opts);
4864
  }else{
 
 
 
 
 
 
 
 
4865
  IWP_MMB_Backup_Options::update_iwp_backup_option('IWP_ftp', $opts);
4866
  }
4867
  }elseif (!empty($params['account_info']['iwp_amazon_s3'])) {
@@ -4921,4 +4968,29 @@ CREATE TABLE $wpdb->signups (
4921
  }
4922
  }
4923
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4924
  }
1245
  die;
1246
  }
1247
 
1248
+ if ($this->current_resumption >=5 && false == $this->newresumption_scheduled) {
1249
  $this->log("This is resumption ".$this->current_resumption.", but meaningful activity is still taking place; so a new one will be scheduled");
1250
  // We just use max here to make sure we get a number at all
1251
  $resume_interval = max($this->jobdata_get('resume_interval'), 75);
3683
  $cron_disable = true;
3684
  $cron_params = $this->get_cron($job_id);
3685
  }
3686
+ $cron_do_action = $this->is_cron_do_action_need($job_id);
3687
+ return array('success'=>array('status' => 'partiallyCompleted', 'params' => $params['params'], 'jobdata'=>$job_data, 'cron_disable' => $cron_disable, 'cron_params' =>$cron_params, 'wp_content_url' => content_url(),'cron_do_action' =>$cron_do_action));
3688
  } elseif ($result == '0') {
3689
  $cron = $this->get_cron($job_id);
3690
  if ($cron == false) {
3704
  wp_cron();
3705
  }
3706
  }
3707
+ $cron_params = array();
3708
+ if (( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON )) {
3709
+ $cron_disable = true;
3710
+ $cron_params = $this->get_cron($job_id);
3711
+ }
3712
+ $cron_do_action = $this->is_cron_do_action_need($job_id);
3713
+ return array('success'=>array('status' => 'partiallyCompleted', 'params' => $params['params'], 'jobdata'=>$job_data, 'cron_data' => $cron, 'cron_disable' => $cron_disable, 'cron_params' =>$cron_params, 'wp_content_url' => content_url(),'cron_do_action' =>$cron_do_action) );
3714
  }
3715
 
3716
  }
3811
  }
3812
  }
3813
 
3814
+ public function get_cron_data($job_id = false) {
3815
+
3816
+ $cron = get_option('cron');
3817
+ if (!is_array($cron)) $cron = array();
3818
+ if (false === $job_id) return $cron;
3819
+
3820
+ foreach ($cron as $time => $job) {
3821
+ if (isset($job['IWP_backup_resume'])) {
3822
+ foreach ($job['IWP_backup_resume'] as $hook => $info) {
3823
+ if (isset($info['args'][1]) && $job_id == $info['args'][1]) {
3824
+ $jobdata = $this->jobdata_getarray($job_id);
3825
+ return (!is_array($jobdata)) ? false : $info['args'];
3826
+ }
3827
+ }
3828
+ }
3829
+ }
3830
+ }
3831
+
3832
  public function last_backup_staus() {
3833
  $last_backup = array();
3834
  $IWP_last_backup = IWP_MMB_Backup_Options::get_iwp_backup_option('IWP_last_backup');
3904
  if (!empty($params['args']['exclude_extensions']) && !defined('IWP_EXCLUDE_EXTENSIONS')) {
3905
  define('IWP_EXCLUDE_EXTENSIONS', $params['args']['exclude_extensions']);
3906
  }
3907
+ if (!empty($params['args']['IWP_encryptionphrase'])) {
3908
+ IWP_MMB_Backup_Options::update_iwp_backup_option('IWP_encryptionphrase', $params['args']['IWP_encryptionphrase']);
3909
+ }else{
3910
+ IWP_MMB_Backup_Options::update_iwp_backup_option('IWP_encryptionphrase', false);
3911
+ }
3912
 
3913
  if (!empty($params['account_info'])) {
3914
  if (!empty($params['account_info']['iwp_ftp'])) {
3920
  'path' => $ftp_details['ftp_remote_folder'],
3921
  'port' => $ftp_details['ftp_port'],
3922
  'ftp_site_folder' => $ftp_details['ftp_site_folder'],
3923
+ 'passive' => $ftp_details['ftp_passive']?true:false,
3924
+ 'key' => $ftp_details['ftp_key'],
3925
  );
3926
  if ($ftp_details['use_sftp']) {
3927
  update_option('IWP_service', 'sftp');
3990
  update_option('IWP_retain', $params['args']['limit']);
3991
  update_option('IWP_retain_db', $params['args']['limit']);
3992
  }
3993
+
3994
+ if (!empty($params['args']['exclude_tables'])) {
3995
+ $exclude_tables = @implode(',', $params['args']['exclude_tables']);
3996
+ update_option('IWP_default_exclude_tables', $exclude_tables);
3997
+ }
3998
  }
3999
 
4000
  public function get_remote_file($services, $file, $timestamp, $restore = false) {
4590
  $our_files['backup_meta_file'] = $backup_file_basename;
4591
  $our_files['old_file_path'] = ABSPATH;
4592
  $our_files['old_url'] = get_option('siteurl');
4593
+ $our_files['IWP_encryptionphrase'] = IWP_MMB_Backup_Options::get_iwp_backup_option('IWP_encryptionphrase');
4594
  $backup_dir = $this->backups_dir_location();
4595
  $backup_meta_file = $backup_dir.'/'.$backup_file_basename;
4596
  $meta_file_handle = fopen($backup_meta_file, 'w');
4893
  'pass' => $ftp_details['ftp_password'],
4894
  'host' => $ftp_details['ftp_hostname'],
4895
  'path' => $ftp_details['ftp_remote_folder'],
4896
+ 'port' => $ftp_details['ftp_port'],
4897
  'ftp_site_folder' => $ftp_details['ftp_site_folder'],
4898
  'passive' => $ftp_details['ftp_passive']?true:false
4899
  );
4900
  if ($ftp_details['use_sftp']) {
4901
+ update_option('IWP_service', 'sftp');
4902
  IWP_MMB_Backup_Options::update_iwp_backup_option('IWP_sftp', $opts);
4903
  }else{
4904
+ update_option('IWP_service', 'ftp');
4905
+ if(!empty($ftp_details['ftp_ssl'])){
4906
+ $opts['host'] = $opts['host'].':'.$opts['port'];
4907
+ unset($opts['port']);
4908
+ IWP_MMB_Backup_Options::delete_iwp_backup_option('IWP_ssl_nossl');
4909
+ }else{
4910
+ IWP_MMB_Backup_Options::update_iwp_backup_option('IWP_ssl_nossl', 1);
4911
+ }
4912
  IWP_MMB_Backup_Options::update_iwp_backup_option('IWP_ftp', $opts);
4913
  }
4914
  }elseif (!empty($params['account_info']['iwp_amazon_s3'])) {
4968
  }
4969
  }
4970
  }
4971
+
4972
+ public function is_cron_do_action_need($job_id){
4973
+ $time = time();
4974
+ $cron_time = $this->get_cron($job_id);
4975
+ if (empty($cron_time[0]) || $time < $cron_time[0]) {
4976
+ return false;
4977
+ }
4978
+
4979
+ return true;
4980
+ }
4981
+
4982
+ public function iwp_pheonix_backup_cron_do_action($params){
4983
+ $job_id = $params['params']['backup_id'];
4984
+
4985
+ $is_cron_do_action_need = $this->is_cron_do_action_need($job_id);
4986
+ if ($is_cron_do_action_need == false) {
4987
+ return false;
4988
+ }
4989
+ $cron_data = $this->get_cron_data($job_id);
4990
+ if (!empty($cron_data)) {
4991
+ wp_clear_scheduled_hook('IWP_backup_resume', $cron_data);
4992
+ do_action( 'IWP_backup_resume', $cron_data[0], $cron_data[1] );
4993
+ }
4994
+
4995
+ }
4996
  }
backup/backup.php CHANGED
@@ -1120,7 +1120,7 @@ class IWP_MMB_Backup {
1120
  if (is_array($dirlist)) $dirlist=array_shift($dirlist);
1121
  }
1122
 
1123
- if (count($dirlist)>0) {
1124
  $created = $this->create_zip($dirlist, $youwhat, $backup_file_basename, $index);
1125
  # Now, store the results
1126
  if (!is_string($created) && !is_array($created)) $iwp_backup_core->log("$youwhat: create_zip returned an error");
@@ -1510,6 +1510,12 @@ class IWP_MMB_Backup {
1510
  $microtime = microtime(true);
1511
 
1512
  global $iwp_backup_core;
 
 
 
 
 
 
1513
 
1514
  // Deal with Windows/old MySQL setups with erroneous table prefixes differing in case
1515
  // Can't get binary mysqldump to make this transformation
@@ -1635,12 +1641,13 @@ class IWP_MMB_Backup {
1635
 
1636
  # Some tables have optional data, and should be skipped if they do not work
1637
  $table_sans_prefix = substr($table, strlen($this->table_prefix_raw));
1638
- $data_optional_tables = ('wp' == $this->whichdb) ? apply_filters('IWP_data_optional_tables', explode(',', IWP_DATA_OPTIONAL_TABLES)) : array();
1639
  if (in_array($table_sans_prefix, $data_optional_tables)) {
1640
- if (!$iwp_backup_core->something_useful_happened && !empty($iwp_backup_core->current_resumption) && ($iwp_backup_core->current_resumption - $iwp_backup_core->last_successful_resumption > 2)) {
1641
- $iwp_backup_core->log("Table $table: Data skipped (previous attempts failed, and table is marked as non-essential)");
 
1642
  return true;
1643
- }
1644
  }
1645
 
1646
  if('VIEW' != $table_type && ($segment == 'none' || $segment >= 0)) {
@@ -1731,7 +1738,26 @@ class IWP_MMB_Backup {
1731
  $encryption = IWP_MMB_Backup_Options::get_iwp_backup_option('IWP_encryptionphrase');
1732
  if (strlen($encryption) > 0) {
1733
  $iwp_backup_core->log("Attempting to encrypt backup file");
1734
- $result = apply_filters('IWP_encrypt_file', null, $file, $encryption, $this->whichdb, $this->whichdb_suffix);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1735
  if (null === $result) {
1736
  return basename($file);
1737
  }
1120
  if (is_array($dirlist)) $dirlist=array_shift($dirlist);
1121
  }
1122
 
1123
+ if (!empty($dirlist)) {
1124
  $created = $this->create_zip($dirlist, $youwhat, $backup_file_basename, $index);
1125
  # Now, store the results
1126
  if (!is_string($created) && !is_array($created)) $iwp_backup_core->log("$youwhat: create_zip returned an error");
1510
  $microtime = microtime(true);
1511
 
1512
  global $iwp_backup_core;
1513
+ $table_sans_prefix = substr($table_name, strlen($this->table_prefix_raw));
1514
+ $default_exclude_tables = explode(',', IWP_MMB_Backup_Options::get_iwp_backup_option('IWP_default_exclude_tables', IWP_DATA_OPTIONAL_TABLES));
1515
+ if (in_array($table_sans_prefix, $default_exclude_tables)) {
1516
+ $iwp_backup_core->log("Table $table_name: Data skipped (table is marked as non-essential)");
1517
+ return true;
1518
+ }
1519
 
1520
  // Deal with Windows/old MySQL setups with erroneous table prefixes differing in case
1521
  // Can't get binary mysqldump to make this transformation
1641
 
1642
  # Some tables have optional data, and should be skipped if they do not work
1643
  $table_sans_prefix = substr($table, strlen($this->table_prefix_raw));
1644
+ $data_optional_tables = ('wp' == $this->whichdb) ? explode(',', IWP_MMB_Backup_Options::get_iwp_backup_option('IWP_default_exclude_tables', IWP_DATA_OPTIONAL_TABLES)) : array();
1645
  if (in_array($table_sans_prefix, $data_optional_tables)) {
1646
+ //if (!$iwp_backup_core->something_useful_happened && !empty($iwp_backup_core->current_resumption) && ($iwp_backup_core->current_resumption - $iwp_backup_core->last_successful_resumption > 2)) {
1647
+ // $iwp_backup_core->log("Table $table: Data skipped (previous attempts failed, and table is marked as non-essential)");
1648
+ $iwp_backup_core->log("Table $table: Data skipped (table is marked as non-essential)");
1649
  return true;
1650
+ //}
1651
  }
1652
 
1653
  if('VIEW' != $table_type && ($segment == 'none' || $segment >= 0)) {
1738
  $encryption = IWP_MMB_Backup_Options::get_iwp_backup_option('IWP_encryptionphrase');
1739
  if (strlen($encryption) > 0) {
1740
  $iwp_backup_core->log("Attempting to encrypt backup file");
1741
+ try {
1742
+ $result = apply_filters('IWP_encrypt_file', null, $file, $encryption, $this->whichdb, $this->whichdb_suffix);
1743
+ } catch (Exception $e) {
1744
+ $log_message = 'Exception ('.get_class($e).') occurred during encryption: '.$e->getMessage().' (Code: '.$e->getCode().', line '.$e->getLine().' in '.$e->getFile().')';
1745
+ error_log($log_message);
1746
+ // @codingStandardsIgnoreLine
1747
+ if (function_exists('wp_debug_backtrace_summary')) $log_message .= ' Backtrace: '.wp_debug_backtrace_summary();
1748
+ $iwp_backup_core->log($log_message);
1749
+ $iwp_backup_core->log(sprintf(__('A PHP exception (%s) has occurred: %s', 'InfiniteWP'), get_class($e), $e->getMessage()), 'error');
1750
+ die();
1751
+ // @codingStandardsIgnoreLine
1752
+ } catch (Error $e) {
1753
+ $log_message = 'PHP Fatal error ('.get_class($e).') has occurred during encryption. Error Message: '.$e->getMessage().' (Code: '.$e->getCode().', line '.$e->getLine().' in '.$e->getFile().')';
1754
+ error_log($log_message);
1755
+ // @codingStandardsIgnoreLine
1756
+ if (function_exists('wp_debug_backtrace_summary')) $log_message .= ' Backtrace: '.wp_debug_backtrace_summary();
1757
+ $iwp_backup_core->log($log_message);
1758
+ $iwp_backup_core->log(sprintf(__('A PHP fatal error (%s) has occurred: %s', 'InfiniteWP'), get_class($e), $e->getMessage()), 'error');
1759
+ die();
1760
+ }
1761
  if (null === $result) {
1762
  return basename($file);
1763
  }
backup/databaseencrypt.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined('ABSPATH') )
4
+ die();
5
+
6
+ $iwp_addon_moredatabase = new IWP_MMB_Addon_MoreDatabase;
7
+
8
+ class IWP_MMB_Addon_MoreDatabase {
9
+
10
+ private $database_tables;
11
+
12
+ /**
13
+ * Class constructor
14
+ */
15
+ public function __construct() {
16
+ add_filter('IWP_encrypt_file', array($this, 'encrypt_file'), 10, 5);
17
+ }
18
+
19
+ /**
20
+ * This function encrypts the database when specified. Used in backup.php.
21
+ *
22
+ * @param array $result
23
+ * @param string $file this is the file name of the db zip to be encrypted
24
+ * @param string $encryption This is the encryption word (salting) to be used when encrypting the data
25
+ * @param string $whichdb This specifies the correct DB
26
+ * @param string $whichdb_suffix This spcifies the DB suffix
27
+ * @return string returns the encrypted file name
28
+ */
29
+ public function encrypt_file($result, $file, $encryption, $whichdb, $whichdb_suffix) {
30
+
31
+ global $iwp_backup_core;
32
+ $iwp_backup_dir = $iwp_backup_core->backups_dir_location();
33
+ $iwp_backup_core->jobdata_set('jobstatus', 'dbencrypting'.$whichdb_suffix);
34
+ $encryption_result = 0;
35
+ $time_started = microtime(true);
36
+ $file_size = @filesize($iwp_backup_dir.'/'.$file)/1024;
37
+
38
+ $memory_limit = ini_get('memory_limit');
39
+ $memory_usage = round(@memory_get_usage(false)/1048576, 1);
40
+ $memory_usage2 = round(@memory_get_usage(true)/1048576, 1);
41
+ $iwp_backup_core->log("Encryption being requested: file_size: ".round($file_size, 1)." KB memory_limit: $memory_limit (used: ${memory_usage}M | ${memory_usage2}M)");
42
+
43
+ $encrypted_file = IWP_MMB_Encryption::encrypt($iwp_backup_dir.'/'.$file, $encryption);
44
+
45
+ if (false !== $encrypted_file) {
46
+ // return basename($file);
47
+ $time_taken = max(0.000001, microtime(true)-$time_started);
48
+
49
+ $checksums = $iwp_backup_core->which_checksums();
50
+
51
+ foreach ($checksums as $checksum) {
52
+ $cksum = hash_file($checksum, $iwp_backup_dir.'/'.$file.'.crypt');
53
+ $iwp_backup_core->jobdata_set($checksum.'-db'.(('wp' == $whichdb) ? '0' : $whichdb.'0').'.crypt', $cksum);
54
+ $iwp_backup_core->log("$file: encryption successful: ".round($file_size, 1)."KB in ".round($time_taken, 2)."s (".round($file_size/$time_taken, 1)."KB/s) ($checksum checksum: $cksum)");
55
+
56
+ }
57
+
58
+ // Delete unencrypted file
59
+ @unlink($iwp_backup_dir.'/'.$file);
60
+
61
+ $iwp_backup_core->jobdata_set('jobstatus', 'dbencrypted'.$whichdb_suffix);
62
+
63
+ return basename($file.'.crypt');
64
+ } else {
65
+ $iwp_backup_core->log("Encryption error occurred when encrypting database. Encryption aborted.");
66
+ $iwp_backup_core->log(__("Encryption error occurred when encrypting database. Encryption aborted.", 'InfiniteWP'), 'error');
67
+ return basename($file);
68
+ }
69
+ }
70
+
71
+ }
backup/encrypt.php ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined('ABSPATH') )
4
+ die();
5
+
6
+ class IWP_MMB_Encryption {
7
+
8
+ /**
9
+ * This will decrypt an encrypted file
10
+ *
11
+ * @param String $fullpath This is the full filesystem path to the encrypted file location
12
+ * @param String $key This is the key to be used when decrypting
13
+ * @param Boolean $to_temporary_file Use if the resulting file is not intended to be kept
14
+ *
15
+ * @return Boolean|Array -An array with info on the decryption; or false for failure
16
+ */
17
+ public static function decrypt($fullpath, $key, $to_temporary_file = false) {
18
+
19
+ global $iwp_backup_core;
20
+
21
+ $ensure_phpseclib = $iwp_backup_core->ensure_phpseclib('Crypt_Rijndael', 'Crypt/Rijndael');
22
+
23
+ if (is_wp_error($ensure_phpseclib)) {
24
+ $iwp_backup_core->log("Failed to load phpseclib classes (".$ensure_phpseclib->get_error_code()."): ".$ensure_phpseclib->get_error_message());
25
+ $iwp_backup_core->log("Failed to load phpseclib classes (".$ensure_phpseclib->get_error_code()."): ".$ensure_phpseclib->get_error_message(), 'error');
26
+ return false;
27
+ }
28
+
29
+ // open file to read
30
+ if (false === ($file_handle = fopen($fullpath, 'rb'))) return false;
31
+
32
+ $decrypted_path = dirname($fullpath).'/decrypt_'.basename($fullpath).'.tmp';
33
+ // open new file from new path
34
+ if (false === ($decrypted_handle = fopen($decrypted_path, 'wb+'))) return false;
35
+
36
+ // setup encryption
37
+ $rijndael = new Crypt_Rijndael();
38
+ $rijndael->setKey($key);
39
+ $rijndael->disablePadding();
40
+ $rijndael->enableContinuousBuffer();
41
+
42
+ if (defined('IWP_DECRYPTION_ENGINE')) {
43
+ if ('openssl' == IWP_DECRYPTION_ENGINE) {
44
+ $rijndael->setPreferredEngine(CRYPT_ENGINE_OPENSSL);
45
+ } elseif ('mcrypt' == IWP_DECRYPTION_ENGINE) {
46
+ $rijndael->setPreferredEngine(CRYPT_ENGINE_MCRYPT);
47
+ } elseif ('internal' == IWP_DECRYPTION_ENGINE) {
48
+ $rijndael->setPreferredEngine(CRYPT_ENGINE_INTERNAL);
49
+ }
50
+ }
51
+
52
+ $file_size = filesize($fullpath);
53
+ $bytes_decrypted = 0;
54
+ $buffer_size = defined('IWP_CRYPT_BUFFER_SIZE') ? IWP_CRYPT_BUFFER_SIZE : 2097152;
55
+
56
+ // loop around the file
57
+ while ($bytes_decrypted < $file_size) {
58
+ // read buffer sized amount from file
59
+ if (false === ($file_part = fread($file_handle, $buffer_size))) return false;
60
+ // check to ensure padding is needed before decryption
61
+ $length = strlen($file_part);
62
+ if (0 != $length % 16) {
63
+ $pad = 16 - ($length % 16);
64
+ $file_part = str_pad($file_part, $length + $pad, chr($pad));
65
+ }
66
+
67
+ $decrypted_data = $rijndael->decrypt($file_part);
68
+
69
+ if (0 == $bytes_decrypted) {
70
+ if (IWP_MMB_Encryption::str_ends_with($fullpath, '.gz.crypt')) {
71
+ $first_two_chars = unpack('C*', substr($decrypted_data, 0, 2));
72
+ // The first two decrypted bytes of the .gz file should always be 1f 8b
73
+ if (31 != $first_two_chars[1] || 139 != $first_two_chars[2]) {
74
+ return false;
75
+ }
76
+ } elseif (IWP_MMB_Encryption::str_ends_with($fullpath, '.zip.crypt')) {
77
+ $first_four_chars = unpack('C*', substr($decrypted_data, 0, 2));
78
+ // The first four decrypted bytes of the .zip file should always be 50 4B 03 04 or 50 4B 05 06 or 50 4B 07 08
79
+ if (80 != $first_four_chars[1] || 75 != $first_four_chars[2] || !in_array($first_four_chars[3], array(3, 5, 7)) || !in_array($first_four_chars[3], array(4, 6, 8))) {
80
+ return false;
81
+ }
82
+
83
+ }
84
+ }
85
+
86
+ $is_last_block = ($bytes_decrypted + strlen($decrypted_data) >= $file_size);
87
+
88
+ $write_bytes = min($file_size - $bytes_decrypted, strlen($decrypted_data));
89
+ if ($is_last_block) {
90
+ $is_padding = false;
91
+ $last_byte = ord(substr($decrypted_data, -1, 1));
92
+ if ($last_byte < 16) {
93
+ $is_padding = true;
94
+ for ($j = 1; $j<=$last_byte; $j++) {
95
+ if (substr($decrypted_data, -$j, 1) != chr($last_byte)) $is_padding = false;
96
+ }
97
+ }
98
+ if ($is_padding) {
99
+ $write_bytes -= $last_byte;
100
+ }
101
+ }
102
+
103
+ if (false === fwrite($decrypted_handle, $decrypted_data, $write_bytes)) return false;
104
+ $bytes_decrypted += $buffer_size;
105
+ }
106
+
107
+ // close the main file handle
108
+ fclose($decrypted_handle);
109
+ // close original file
110
+ fclose($file_handle);
111
+
112
+ // remove the crypt extension from the end as this causes issues when opening
113
+ $fullpath_new = preg_replace('/\.crypt$/', '', $fullpath, 1);
114
+ // //need to replace original file with tmp file
115
+
116
+ $fullpath_basename = basename($fullpath_new);
117
+
118
+ if ($to_temporary_file) {
119
+ return array(
120
+ 'fullpath' => $decrypted_path,
121
+ 'basename' => $fullpath_basename
122
+ );
123
+ }
124
+
125
+ if (false === rename($decrypted_path, $fullpath_new)) return false;
126
+
127
+ // need to send back the new decrypted path
128
+ $decrypt_return = array(
129
+ 'fullpath' => $fullpath_new,
130
+ 'basename' => $fullpath_basename
131
+ );
132
+
133
+ return $decrypt_return;
134
+ }
135
+
136
+ /**
137
+ * This is the encryption process when encrypting a file
138
+ *
139
+ * @param String $fullpath This is the full path to the DB file that needs ecrypting
140
+ * @param String $key This is the key (salting) to be used when encrypting
141
+ *
142
+ * @return String|Boolean - Return the full path of the encrypted file, or false for an error
143
+ */
144
+ public static function encrypt($fullpath, $key) {
145
+
146
+ global $iwp_backup_core;
147
+
148
+ if (!function_exists('mcrypt_encrypt') && !extension_loaded('openssl')) {
149
+ $iwp_backup_core->log(sprintf(__('Your web-server does not have the %s module installed.', 'InfiniteWP'), 'PHP/mcrypt / PHP/OpenSSL').' '.__('Without it, encryption will be a lot slower.', 'InfiniteWP'), 'warning', 'nocrypt');
150
+ }
151
+
152
+ // include Rijndael library from phpseclib
153
+ $ensure_phpseclib = $iwp_backup_core->ensure_phpseclib('Crypt_Rijndael', 'Crypt/Rijndael');
154
+
155
+ if (is_wp_error($ensure_phpseclib)) {
156
+ $iwp_backup_core->log("Failed to load phpseclib classes (".$ensure_phpseclib->get_error_code()."): ".$ensure_phpseclib->get_error_message());
157
+ return false;
158
+ }
159
+
160
+ // open file to read
161
+ if (false === ($file_handle = fopen($fullpath, 'rb'))) {
162
+ $iwp_backup_core->log("Failed to open file for read access: $fullpath");
163
+ return false;
164
+ }
165
+
166
+ // encrypted path name. The trailing .tmp ensures that it will be cleaned up by the temporary file reaper eventually, if needs be.
167
+ $encrypted_path = dirname($fullpath).'/encrypt_'.basename($fullpath).'.tmp';
168
+
169
+ $data_encrypted = 0;
170
+ $buffer_size = defined('IWP_CRYPT_BUFFER_SIZE') ? IWP_CRYPT_BUFFER_SIZE : 2097152;
171
+
172
+ $time_last_logged = microtime(true);
173
+
174
+ $file_size = filesize($fullpath);
175
+
176
+ // Set initial value to false so we can check it later and decide what to do
177
+ $resumption = false;
178
+
179
+ // setup encryption
180
+ $rijndael = new Crypt_Rijndael();
181
+ $rijndael->setKey($key);
182
+ $rijndael->disablePadding();
183
+ $rijndael->enableContinuousBuffer();
184
+
185
+ // First we need to get the block length, this method returns the length in bits we need to change this back to bytes in order to use it with the file operation methods.
186
+ $block_length = $rijndael->getBlockLength() >> 3;
187
+
188
+ // Check if the path already exists as this could be a resumption
189
+ if (file_exists($encrypted_path)) {
190
+
191
+ $iwp_backup_core->log("Temporary encryption file found, will try to resume the encryption");
192
+
193
+ // The temp file exists so set resumption to true
194
+ $resumption = true;
195
+
196
+ // Get the file size as this is needed to help resume the encryption
197
+ $data_encrypted = filesize($encrypted_path);
198
+ // Get the true file size e.g without padding used for various resumption paths
199
+ $true_data_encrypted = $data_encrypted - ($data_encrypted % $buffer_size);
200
+
201
+ if ($data_encrypted >= $block_length) {
202
+
203
+ // Open existing file from the path
204
+ if (false === ($encrypted_handle = fopen($encrypted_path, 'rb+'))) {
205
+ $iwp_backup_core->log("Failed to open file for write access on resumption: $encrypted_path");
206
+ $resumption = false;
207
+ }
208
+
209
+ // First check if our buffer size needs padding if it does increase buffer size to length that doesn't need padding
210
+ if (0 != $buffer_size % 16) {
211
+ $pad = 16 - ($buffer_size % 16);
212
+ $true_buffer_size = $buffer_size + $pad;
213
+ } else {
214
+ $true_buffer_size = $buffer_size;
215
+ }
216
+
217
+ // Now check if using modulo on data encrypted and buffer size returns 0 if it doesn't then the last block was a partial write and we need to discard that and get the last useable IV by adding this value to the block length
218
+ $partial_data_size = $data_encrypted % $true_buffer_size;
219
+
220
+ // We need to reconstruct the IV from the previous run in order for encryption to resume
221
+ if (-1 === (fseek($encrypted_handle, $data_encrypted - ($block_length + $partial_data_size)))) {
222
+ $iwp_backup_core->log("Failed to move file pointer to correct position to get IV: $encrypted_path");
223
+ $resumption = false;
224
+ }
225
+
226
+ // Read previous block length from file
227
+ if (false === ($iv = fread($encrypted_handle, $block_length))) {
228
+ $iwp_backup_core->log("Failed to read from file to get IV: $encrypted_path");
229
+ $resumption = false;
230
+ }
231
+
232
+ $rijndael->setIV($iv);
233
+
234
+ // Now we need to set the file pointer for the original file to the correct position and take into account the padding added, this padding needs to be removed to get the true amount of bytes read from the original file
235
+ if (-1 === (fseek($file_handle, $true_data_encrypted))) {
236
+ $iwp_backup_core->log("Failed to move file pointer to correct position to resume encryption: $fullpath");
237
+ $resumption = false;
238
+ }
239
+
240
+ } else {
241
+ // If we enter here then the temp file exists but it is either empty or has one incomplete block we may as well start again
242
+ $resumption = false;
243
+ }
244
+
245
+ if (!$resumption) {
246
+ $iwp_backup_core->log("Could not resume the encryption will now try to start again");
247
+ // remove the existing encrypted file as it's no good to us now
248
+ @unlink($encrypted_path);
249
+ // reset the data encrypted so that the loop can be entered
250
+ $data_encrypted = 0;
251
+ // setup encryption to reset the IV
252
+ $rijndael = new Crypt_Rijndael();
253
+ $rijndael->setKey($key);
254
+ $rijndael->disablePadding();
255
+ $rijndael->enableContinuousBuffer();
256
+ // reset the file pointer and then we should be able to start from fresh
257
+ if (-1 === (fseek($file_handle, 0))) {
258
+ $iwp_backup_core->log("Failed to move file pointer to start position to restart encryption: $fullpath");
259
+ $resumption = false;
260
+ }
261
+ }
262
+ }
263
+
264
+ if (!$resumption) {
265
+ // open new file from new path
266
+ if (false === ($encrypted_handle = fopen($encrypted_path, 'wb+'))) {
267
+ $iwp_backup_core->log("Failed to open file for write access: $encrypted_path");
268
+ return false;
269
+ }
270
+ }
271
+
272
+ // loop around the file
273
+ while ($data_encrypted < $file_size) {
274
+
275
+ // read buffer-sized amount from file
276
+ if (false === ($file_part = fread($file_handle, $buffer_size))) {
277
+ $iwp_backup_core->log("Failed to read from file: $fullpath");
278
+ return false;
279
+ }
280
+
281
+ // check to ensure padding is needed before encryption
282
+ $length = strlen($file_part);
283
+ if (0 != $length % 16) {
284
+ $pad = 16 - ($length % 16);
285
+ $file_part = str_pad($file_part, $length + $pad, chr($pad));
286
+ }
287
+
288
+ $encrypted_data = $rijndael->encrypt($file_part);
289
+
290
+ if (false === fwrite($encrypted_handle, $encrypted_data)) {
291
+ $iwp_backup_core->log("Failed to write to file: $encrypted_path");
292
+ return false;
293
+ }
294
+
295
+ $data_encrypted += $buffer_size;
296
+
297
+ $time_since_last_logged = microtime(true) - $time_last_logged;
298
+ if ($time_since_last_logged > 5) {
299
+ $time_since_last_logged = microtime(true);
300
+ $iwp_backup_core->log("Encrypting file: completed $data_encrypted bytes");
301
+ }
302
+
303
+ }
304
+
305
+ // close the main file handle
306
+ fclose($encrypted_handle);
307
+ fclose($file_handle);
308
+
309
+ // encrypted path
310
+ $result_path = $fullpath.'.crypt';
311
+
312
+ // need to replace original file with tmp file
313
+ if (false === rename($encrypted_path, $result_path)) {
314
+ $iwp_backup_core->log("File rename failed: $encrypted_path -> $result_path");
315
+ return false;
316
+ }
317
+
318
+ return $result_path;
319
+ }
320
+
321
+ /**
322
+ * This function spools the decrypted contents of a file to the browser
323
+ *
324
+ * @param String $fullpath This is the full path to the encrypted file
325
+ * @param String $encryption This is the key used to decrypt the file
326
+ *
327
+ * @uses header()
328
+ */
329
+ public static function spool_crypted_file($fullpath, $encryption) {
330
+
331
+ global $iwp_backup_core;
332
+
333
+ if ('' == $encryption) $encryption = IWP_MMB_Backup_Options::get_iwp_backup_option('IWP_encryptionphrase');
334
+
335
+ if ('' == $encryption) {
336
+ header('Content-type: text/plain');
337
+ _e("Decryption failed. The database file is encrypted, but you have no encryption key entered.", 'updraftplus');
338
+ $updraftplus->log('Decryption of database failed: the database file is encrypted, but you have no encryption key entered.', 'error');
339
+ } else {
340
+
341
+ // now decrypt the file and return array
342
+ $decrypted_file = self::decrypt($fullpath, $encryption, true);
343
+
344
+ // check to ensure there is a response back
345
+ if (is_array($decrypted_file)) {
346
+ header('Content-type: application/x-gzip');
347
+ header("Content-Disposition: attachment; filename=\"".$decrypted_file['basename']."\";");
348
+ header("Content-Length: ".filesize($decrypted_file['fullpath']));
349
+ readfile($decrypted_file['fullpath']);
350
+
351
+ // need to remove the file as this is no longer needed on the local server
352
+ unlink($decrypted_file['fullpath']);
353
+ } else {
354
+ header('Content-type: text/plain');
355
+ echo __("Decryption failed. The most likely cause is that you used the wrong key.", 'updraftplus')." ".__('The decryption key used:', 'updraftplus').' '.$encryption;
356
+
357
+ }
358
+ }
359
+ }
360
+
361
+ /**
362
+ * Indicate whether an indicated backup file is encrypted or not, as indicated by the suffix
363
+ *
364
+ * @param String $file - the filename
365
+ *
366
+ * @return Boolean
367
+ */
368
+ public static function is_file_encrypted($file) {
369
+ return preg_match('/\.crypt$/i', $file);
370
+ }
371
+
372
+ public static function str_ends_with($haystack, $needle) {
373
+ if (substr($haystack, - strlen($needle)) == $needle) return true;
374
+ return false;
375
+ }
376
+ }
backup/googledrive.php CHANGED
@@ -477,7 +477,8 @@ class IWP_MMB_UploadModule_googledrive extends IWP_MMB_UploadModule {
477
 
478
  try {
479
  $parent_id = $this->get_parent_id($opts);
480
- $sub_items = $this->get_subitems($parent_id, 'file');
 
481
  } catch (Exception $e) {
482
  $iwp_backup_core->log("Google Drive delete: failed to access parent folder: ".$e->getMessage().' (line: '.$e->getLine().', file: '.$e->getFile().')');
483
  return false;
477
 
478
  try {
479
  $parent_id = $this->get_parent_id($opts);
480
+ $iwp_getSiteName = iwp_getSiteName();
481
+ $sub_items = $this->get_subitems($parent_id, 'file', $files[0]);
482
  } catch (Exception $e) {
483
  $iwp_backup_core->log("Google Drive delete: failed to access parent folder: ".$e->getMessage().' (line: '.$e->getLine().', file: '.$e->getFile().')');
484
  return false;
core.class.php CHANGED
@@ -48,6 +48,7 @@ class IWP_MMB_Core extends IWP_MMB_Helper
48
 
49
  private $action_call;
50
  public $request_params;
 
51
  private $action_params;
52
  private $iwp_mmb_pre_init_actions;
53
  private $iwp_mmb_pre_init_filters;
@@ -79,6 +80,7 @@ class IWP_MMB_Core extends IWP_MMB_Helper
79
  if ( is_multisite() ) {
80
  $this->iwp_mmb_multisite = $blog_id;
81
  $this->network_admin_install = get_option('iwp_client_network_admin_install');
 
82
  }
83
  } else if (!empty($wpmu_version)) {
84
  $this->iwp_mmb_multisite = $blog_id;
@@ -92,11 +94,15 @@ class IWP_MMB_Core extends IWP_MMB_Helper
92
  if ( !get_option('iwp_client_public_key') ){
93
  if( $this->iwp_mmb_multisite ){
94
  if( is_network_admin() && $this->network_admin_install == '1'){
95
- add_action('network_admin_notices', array( &$this, 'network_admin_notice' ));
 
96
  } else if( $this->network_admin_install != '1' ){
97
  //$parent_key = $this->get_parent_blog_option('iwp_client_public_key');//IWP commented to show notice to all subsites of network
98
  //if(empty($parent_key))//IWP commented to show notice to all subsites of network
99
- add_action('admin_notices', array( &$this, 'admin_notice' ));
 
 
 
100
  }
101
  } else {
102
  add_action('admin_notices', array( &$this, 'admin_notice' ));
@@ -200,7 +206,9 @@ class IWP_MMB_Core extends IWP_MMB_Helper
200
  'fetch_activities_log' => 'iwp_mmb_fetch_activities_log',
201
  'sucuri_scan' => 'iwp_mmb_sucuri_scan',
202
  'sucuri_change_alert' => 'iwp_mmb_sucuri_change_alert',
203
- 'backup_downlaod' => 'iwp_mmb_backup_downlaod'
 
 
204
  );
205
 
206
  add_action('rightnow_end', array( &$this, 'add_right_now_info' ));
@@ -211,11 +219,17 @@ class IWP_MMB_Core extends IWP_MMB_Helper
211
  }
212
  add_action('init', array($this,'iwp_cpb_hide_updates'), 10, 1);
213
  add_action('admin_init', array(&$this,'admin_actions'));
 
 
214
  add_filter('deprecated_function_trigger_error', '__return_false');
 
 
 
215
  // add_action('wp_loaded', array( &$this, 'iwp_mmb_remote_action'), 2147483650);
216
- add_action('plugins_loaded', 'iwp_mmb_add_readd_request');
217
  add_action('setup_theme', 'iwp_mmb_set_request');
 
218
  add_action('set_auth_cookie', array( &$this, 'iwp_mmb_set_auth_cookie'));
 
219
  add_action('set_logged_in_cookie', array( &$this, 'iwp_mmb_set_logged_in_cookie'));
220
 
221
  }
@@ -227,7 +241,9 @@ class IWP_MMB_Core extends IWP_MMB_Helper
227
  if (is_multisite() && !defined('WP_NETWORK_ADMIN')) {
228
  define('WP_NETWORK_ADMIN', true);
229
  }
230
- define('WP_BLOG_ADMIN', true);
 
 
231
  require_once ABSPATH.'wp-admin/includes/admin.php';
232
  // define('DOING_AJAX', true);
233
  do_action('admin_init');
@@ -335,7 +351,9 @@ class IWP_MMB_Core extends IWP_MMB_Helper
335
  }
336
 
337
  $iwp_client_activate_key = get_option('iwp_client_activate_key');
338
-
 
 
339
  //check BWP
340
  $bwp = get_option("bit51_bwps");
341
  $notice_display_URL=admin_url();
@@ -650,6 +668,7 @@ class IWP_MMB_Core extends IWP_MMB_Helper
650
  {
651
  require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup.class.singlecall.php");
652
  require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup.class.multicall.php");
 
653
  //$mechanism = 'multiCall';
654
  if (!isset($this->backup_instance)) {
655
  if($mechanism == 'singleCall' || $mechanism == ''){
@@ -728,6 +747,81 @@ class IWP_MMB_Core extends IWP_MMB_Helper
728
  return $this->sucuri_instance;
729
  }
730
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
731
  /**
732
  * Plugin install callback function
733
  * Check PHP version
@@ -736,22 +830,29 @@ class IWP_MMB_Core extends IWP_MMB_Helper
736
 
737
  global $wpdb, $_wp_using_ext_object_cache, $current_user, $iwp_mmb_activities_log;
738
  $_wp_using_ext_object_cache = false;
739
-
 
 
 
 
740
  //delete plugin options, just in case
741
  if ($this->iwp_mmb_multisite != false) {
742
  $network_blogs = $wpdb->get_results("select `blog_id`, `site_id` from `{$wpdb->blogs}`");
743
  if(!empty($network_blogs)){
744
  if( is_network_admin() ){
745
  update_option('iwp_client_network_admin_install', 1);
 
746
  foreach($network_blogs as $details){
747
- if($details->site_id == $details->blog_id)
748
  update_blog_option($details->blog_id, 'iwp_client_network_admin_install', 1);
749
- else
 
750
  update_blog_option($details->blog_id, 'iwp_client_network_admin_install', -1);
751
-
752
- delete_blog_option($blog_id, 'iwp_client_nossl_key');
753
- delete_blog_option($blog_id, 'iwp_client_public_key');
754
- delete_blog_option($blog_id, 'iwp_client_action_message_id');
 
755
  }
756
  } else {
757
  update_option('iwp_client_network_admin_install', -1);
@@ -769,9 +870,10 @@ class IWP_MMB_Core extends IWP_MMB_Helper
769
  //delete_option('iwp_client_backup_tasks');
770
  delete_option('iwp_client_notifications');
771
  delete_option('iwp_client_brand');
 
772
  delete_option('iwp_client_pageview_alerts');
773
 
774
- add_option('iwp_client_activate_key', sha1( rand(1, 99999). uniqid('', true) . get_option('siteurl') ) );
775
 
776
  $iwp_mmb_activities_log->iwp_mmb_save_options_for_activity_log('install');
777
  }
@@ -841,6 +943,24 @@ class IWP_MMB_Core extends IWP_MMB_Helper
841
  delete_option('iwp_client_all_plugins_history');
842
  delete_option('iwp_client_wp_version_old');
843
  delete_option('is_save_activity_log');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
844
  }
845
 
846
 
@@ -928,6 +1048,8 @@ class IWP_MMB_Core extends IWP_MMB_Helper
928
  $username = isset($_GET['username']) ? $_GET['username'] : '';
929
  $auto_login = isset($_GET['auto_login']) ? $_GET['auto_login'] : 0;
930
  $page = isset($_GET['page']) ? '?page='.$_GET['page'] : '';
 
 
931
  $_SERVER['HTTP_REFERER']='';
932
  if( !function_exists('is_user_logged_in') )
933
  include_once( ABSPATH.'wp-includes/pluggable.php' );
@@ -957,7 +1079,7 @@ class IWP_MMB_Core extends IWP_MMB_Helper
957
 
958
  //if((isset($this->iwp_mmb_multisite) && $this->iwp_mmb_multisite ) || isset($_REQUEST['iwpredirect'])){//comment makes force redirect, which fix bug https dashboard
959
  if(function_exists('wp_safe_redirect') && function_exists('admin_url')){
960
- wp_safe_redirect(admin_url($where.$page));
961
  exit();
962
  }
963
  //}
@@ -968,7 +1090,7 @@ class IWP_MMB_Core extends IWP_MMB_Helper
968
  @iwp_mmb_client_header();
969
  if(isset($_REQUEST['iwpredirect'])){
970
  if(function_exists('wp_safe_redirect') && function_exists('admin_url')){
971
- wp_safe_redirect(admin_url($where.$page));
972
  exit();
973
  }
974
  }
@@ -1010,6 +1132,7 @@ class IWP_MMB_Core extends IWP_MMB_Helper
1010
  add_filter('admin_url', array($this, 'iwp_user_admin_url'), 10, 2); //for modifying the link available in plugin's view version details link.
1011
  }
1012
  add_filter('all_plugins', array($this, 'client_replace')); //for replacing name and all.
 
1013
  }
1014
  }
1015
 
@@ -1151,6 +1274,173 @@ class IWP_MMB_Core extends IWP_MMB_Helper
1151
  function add_login_action(){
1152
  add_action('plugins_loaded', array( &$this, 'automatic_login'), 10);
1153
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1154
 
1155
 
1156
  }
48
 
49
  private $action_call;
50
  public $request_params;
51
+ public $error_notice;
52
  private $action_params;
53
  private $iwp_mmb_pre_init_actions;
54
  private $iwp_mmb_pre_init_filters;
80
  if ( is_multisite() ) {
81
  $this->iwp_mmb_multisite = $blog_id;
82
  $this->network_admin_install = get_option('iwp_client_network_admin_install');
83
+ add_action('wpmu_new_blog', array(&$this, 'updateKeys'));
84
  }
85
  } else if (!empty($wpmu_version)) {
86
  $this->iwp_mmb_multisite = $blog_id;
94
  if ( !get_option('iwp_client_public_key') ){
95
  if( $this->iwp_mmb_multisite ){
96
  if( is_network_admin() && $this->network_admin_install == '1'){
97
+ //add_action('network_admin_notices', array( &$this, 'network_admin_notice' ));// We implemented network activation so no need to show this notification
98
+ add_action('network_admin_notices', array( &$this, 'admin_notice' ));
99
  } else if( $this->network_admin_install != '1' ){
100
  //$parent_key = $this->get_parent_blog_option('iwp_client_public_key');//IWP commented to show notice to all subsites of network
101
  //if(empty($parent_key))//IWP commented to show notice to all subsites of network
102
+ $parent_key = $this->get_parent_blog_option('iwp_client_public_key');
103
+ if (empty($parent_key)) {
104
+ add_action('admin_notices', array(&$this, 'admin_notice'));
105
+ }
106
  }
107
  } else {
108
  add_action('admin_notices', array( &$this, 'admin_notice' ));
206
  'fetch_activities_log' => 'iwp_mmb_fetch_activities_log',
207
  'sucuri_scan' => 'iwp_mmb_sucuri_scan',
208
  'sucuri_change_alert' => 'iwp_mmb_sucuri_change_alert',
209
+ 'backup_downlaod' => 'iwp_mmb_backup_downlaod',
210
+ 'cronDoAction' => 'iwp_pheonix_backup_cron_do_action',
211
+ 'get_additional_stats' => 'iwp_get_additional_stats'
212
  );
213
 
214
  add_action('rightnow_end', array( &$this, 'add_right_now_info' ));
219
  }
220
  add_action('init', array($this,'iwp_cpb_hide_updates'), 10, 1);
221
  add_action('admin_init', array(&$this,'admin_actions'));
222
+ add_action('admin_init', array(&$this,'enqueueConnectionModalOpenScripts'));
223
+ add_action('admin_init', array(&$this,'enqueueConnectionModalOpenStyles'));
224
  add_filter('deprecated_function_trigger_error', '__return_false');
225
+ add_filter('plugin_row_meta', array($this, 'addConnectionKeyLink'), 10, 2);
226
+ add_action('admin_head', array($this, 'printConnectionModalOpenScript'));
227
+ add_action('admin_footer', array($this, 'printConnectionModalDialog'));
228
  // add_action('wp_loaded', array( &$this, 'iwp_mmb_remote_action'), 2147483650);
 
229
  add_action('setup_theme', 'iwp_mmb_set_request');
230
+ add_action('setup_theme', 'iwp_mmb_add_readd_request');
231
  add_action('set_auth_cookie', array( &$this, 'iwp_mmb_set_auth_cookie'));
232
+ add_action('wp_loaded', array( &$this, 'load_mu_loader_error'));
233
  add_action('set_logged_in_cookie', array( &$this, 'iwp_mmb_set_logged_in_cookie'));
234
 
235
  }
241
  if (is_multisite() && !defined('WP_NETWORK_ADMIN')) {
242
  define('WP_NETWORK_ADMIN', true);
243
  }
244
+ if (!defined('WP_BLOG_ADMIN')) {
245
+ define('WP_BLOG_ADMIN', true);
246
+ }
247
  require_once ABSPATH.'wp-admin/includes/admin.php';
248
  // define('DOING_AJAX', true);
249
  do_action('admin_init');
351
  }
352
 
353
  $iwp_client_activate_key = get_option('iwp_client_activate_key');
354
+ if (!is_admin()) {
355
+ return false;
356
+ }
357
  //check BWP
358
  $bwp = get_option("bit51_bwps");
359
  $notice_display_URL=admin_url();
668
  {
669
  require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup.class.singlecall.php");
670
  require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup.class.multicall.php");
671
+ require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup/backup-repo-test.php");
672
  //$mechanism = 'multiCall';
673
  if (!isset($this->backup_instance)) {
674
  if($mechanism == 'singleCall' || $mechanism == ''){
747
  return $this->sucuri_instance;
748
  }
749
 
750
+ public function buildLoaderContent($pluginBasename)
751
+ {
752
+ $loader = <<<EOF
753
+ <?php
754
+
755
+ /*
756
+ Plugin Name: InfiniteWP - Client Loader
757
+ Plugin URI: https://infinitewp.com/
758
+ Description: This plugin will be created automatically when you activate your InfiniteWP Client plugin to improve the performance. And it will be deleted when you deactivate the client plugin.
759
+ Author: Revmakx
760
+ Author URI: https://infinitewp.com/
761
+ */
762
+
763
+ if (!function_exists('untrailingslashit') || !defined('WP_PLUGIN_DIR')) {
764
+ // WordPress is probably not bootstrapped.
765
+ exit;
766
+ }
767
+
768
+ if (file_exists(untrailingslashit(WP_PLUGIN_DIR).'/$pluginBasename')) {
769
+ if (in_array('$pluginBasename', (array) get_option('active_plugins')) ||
770
+ (function_exists('get_site_option') && array_key_exists('iwp-client/init.php', (array) get_site_option('active_sitewide_plugins')))) {
771
+ \$GLOBALS['iwp_is_mu'] = true;
772
+ include_once untrailingslashit(WP_PLUGIN_DIR).'/$pluginBasename';
773
+ }
774
+ }
775
+
776
+ EOF;
777
+
778
+ return $loader;
779
+ }
780
+
781
+ public function registerMustUse($loaderName, $loaderContent)
782
+ {
783
+ $mustUsePluginDir = rtrim(WPMU_PLUGIN_DIR, '/');
784
+ $loaderPath = $mustUsePluginDir.'/'.$loaderName;
785
+
786
+ if (file_exists($loaderPath) && md5($loaderContent) === md5_file($loaderPath)) {
787
+ return;
788
+ }
789
+
790
+ if (!is_dir($mustUsePluginDir)) {
791
+ $dirMade = @mkdir($mustUsePluginDir);
792
+
793
+ if (!$dirMade) {
794
+ $error = error_get_last();
795
+ return array('');
796
+ throw new Exception(sprintf('Unable to create loader directory: %s', $error['message']));
797
+ }
798
+ }
799
+
800
+ if (!is_writable($mustUsePluginDir)) {
801
+ throw new Exception('MU-plugin directory is not writable.');
802
+ }
803
+
804
+ $loaderWritten = @file_put_contents($loaderPath, $loaderContent);
805
+
806
+ if (!$loaderWritten) {
807
+ $error = error_get_last();
808
+ throw new Exception(sprintf('Unable to write loader: %s', $error['message']));
809
+ }
810
+ }
811
+
812
+ function error_notices()
813
+ {
814
+ $error_notice = get_transient( 'iwp_mu_plugin_loader' );
815
+ echo '<div class="error" style="text-align: center;"><p style="font-size: 14px; font-weight: bold; color:#c00;">Attention !</p>
816
+ <p>Unable to write InfiniteWP Client loader: '.$error_notice.'</p></div>';
817
+ }
818
+
819
+ function load_mu_loader_error(){
820
+ $error_notice = get_transient( 'iwp_mu_plugin_loader' );
821
+ if( !empty($error_notice) ){
822
+ add_action('admin_notices', array( &$this, 'error_notices' ));
823
+ }
824
+ }
825
  /**
826
  * Plugin install callback function
827
  * Check PHP version
830
 
831
  global $wpdb, $_wp_using_ext_object_cache, $current_user, $iwp_mmb_activities_log;
832
  $_wp_using_ext_object_cache = false;
833
+ try {
834
+ $this->registerMustUse('mu-iwp-client.php', $this->buildLoaderContent('iwp-client/init.php'));
835
+ } catch (Exception $e) {
836
+ set_transient( 'iwp_mu_plugin_loader', $e->getMessage(), 30 );
837
+ }
838
  //delete plugin options, just in case
839
  if ($this->iwp_mmb_multisite != false) {
840
  $network_blogs = $wpdb->get_results("select `blog_id`, `site_id` from `{$wpdb->blogs}`");
841
  if(!empty($network_blogs)){
842
  if( is_network_admin() ){
843
  update_option('iwp_client_network_admin_install', 1);
844
+ $mainBlogId = defined('BLOG_ID_CURRENT_SITE') ? BLOG_ID_CURRENT_SITE : false;
845
  foreach($network_blogs as $details){
846
+ if (($mainBlogId !== false && $details->blog_id == $mainBlogId) || ($mainBlogId === false && $details->site_id == $details->blog_id)) {
847
  update_blog_option($details->blog_id, 'iwp_client_network_admin_install', 1);
848
+ }
849
+ else {
850
  update_blog_option($details->blog_id, 'iwp_client_network_admin_install', -1);
851
+ }
852
+
853
+ update_blog_option($details->blog_id, 'iwp_client_nossl_key', '');
854
+ update_blog_option($details->blog_id, 'iwp_client_public_key', '');
855
+ delete_blog_option($details->blog_id, 'iwp_client_action_message_id');
856
  }
857
  } else {
858
  update_option('iwp_client_network_admin_install', -1);
870
  //delete_option('iwp_client_backup_tasks');
871
  delete_option('iwp_client_notifications');
872
  delete_option('iwp_client_brand');
873
+ delete_option('iwp_client_public_key');
874
  delete_option('iwp_client_pageview_alerts');
875
 
876
+ $this->update_option('iwp_client_activate_key', sha1( rand(1, 99999). uniqid('', true) . get_option('siteurl') ) );
877
 
878
  $iwp_mmb_activities_log->iwp_mmb_save_options_for_activity_log('install');
879
  }
943
  delete_option('iwp_client_all_plugins_history');
944
  delete_option('iwp_client_wp_version_old');
945
  delete_option('is_save_activity_log');
946
+ $loaderName = 'mu-iwp-client.php';
947
+ try {
948
+ $mustUsePluginDir = rtrim(WPMU_PLUGIN_DIR, '/');
949
+ $loaderPath = $mustUsePluginDir.'/'.$loaderName;
950
+
951
+ if (!file_exists($loaderPath)) {
952
+ return;
953
+ }
954
+
955
+ $removed = @unlink($loaderPath);
956
+
957
+ if (!$removed) {
958
+ $error = error_get_last();
959
+ throw new Exception(sprintf('Unable to remove loader: %s', $error['message']));
960
+ }
961
+ } catch (Exception $e) {
962
+ mwp_logger()->error('Unable to remove loader', array('exception' => $e));
963
+ }
964
  }
965
 
966
 
1048
  $username = isset($_GET['username']) ? $_GET['username'] : '';
1049
  $auto_login = isset($_GET['auto_login']) ? $_GET['auto_login'] : 0;
1050
  $page = isset($_GET['page']) ? '?page='.$_GET['page'] : '';
1051
+ $action = isset($_GET['action']) ? '?action='.$_GET['action'] : '';
1052
+ $post = isset($_GET['action']) ? '&post='.$_GET['post'] : '';
1053
  $_SERVER['HTTP_REFERER']='';
1054
  if( !function_exists('is_user_logged_in') )
1055
  include_once( ABSPATH.'wp-includes/pluggable.php' );
1079
 
1080
  //if((isset($this->iwp_mmb_multisite) && $this->iwp_mmb_multisite ) || isset($_REQUEST['iwpredirect'])){//comment makes force redirect, which fix bug https dashboard
1081
  if(function_exists('wp_safe_redirect') && function_exists('admin_url')){
1082
+ wp_safe_redirect(admin_url($where.$page.$action.$post));
1083
  exit();
1084
  }
1085
  //}
1090
  @iwp_mmb_client_header();
1091
  if(isset($_REQUEST['iwpredirect'])){
1092
  if(function_exists('wp_safe_redirect') && function_exists('admin_url')){
1093
+ wp_safe_redirect(admin_url($where.$page.$action.$post));
1094
  exit();
1095
  }
1096
  }
1132
  add_filter('admin_url', array($this, 'iwp_user_admin_url'), 10, 2); //for modifying the link available in plugin's view version details link.
1133
  }
1134
  add_filter('all_plugins', array($this, 'client_replace')); //for replacing name and all.
1135
+ add_filter('show_advanced_plugins', array($this, 'muPluginListFilter'), 10, 2); //for replacing name and all.
1136
  }
1137
  }
1138
 
1274
  function add_login_action(){
1275
  add_action('plugins_loaded', array( &$this, 'automatic_login'), 10);
1276
  }
1277
+
1278
+ function muPluginListFilter($previousValue, $type)
1279
+ {
1280
+ // Drop-in's are filtered after MU plugins.
1281
+ if ($type !== 'dropins') {
1282
+ return $previousValue;
1283
+ }
1284
+
1285
+ if (!empty($previousValue['iwp-client/init.php'])) {
1286
+ return $previousValue;
1287
+ }
1288
+ $replace = get_option("iwp_client_brand");
1289
+
1290
+ if (!empty($replace['hide'])) {
1291
+ unset($GLOBALS['plugins']['mustuse']['mu-iwp-client.php']);
1292
+ } elseif(!empty($replace['doChangesCPB']) || (!isset($replace['doChangesCPB']) && (!empty($replace['name']) || !empty($replace['desc']) || !empty($replace['author']) || !empty($replace['author_url'])))){
1293
+ $GLOBALS['plugins']['mustuse']['mu-iwp-client.php']['Name'] = $replace['name'];
1294
+ $GLOBALS['plugins']['mustuse']['mu-iwp-client.php']['Title'] = $replace['name'];
1295
+ $GLOBALS['plugins']['mustuse']['mu-iwp-client.php']['Description'] = $replace['desc'];
1296
+ $GLOBALS['plugins']['mustuse']['mu-iwp-client.php']['AuthorURI'] = $replace['author_url'];
1297
+ $GLOBALS['plugins']['mustuse']['mu-iwp-client.php']['Author'] = $replace['author'];
1298
+ $GLOBALS['plugins']['mustuse']['mu-iwp-client.php']['AuthorName'] = $replace['author'];
1299
+ $GLOBALS['plugins']['mustuse']['mu-iwp-client.php']['PluginURI'] = '';
1300
+ }
1301
+
1302
+ return $previousValue;
1303
+ }
1304
+ function updateKeys()
1305
+ {
1306
+ if (!$this->iwp_mmb_multisite) {
1307
+ return;
1308
+ }
1309
+
1310
+ global $wpdb;
1311
+
1312
+ $publicKey = $this->get_parent_blog_option('iwp_client_public_key');
1313
+
1314
+ if (empty($publicKey)) {
1315
+ return;
1316
+ }
1317
+
1318
+ $networkBlogs = $wpdb->get_results("select `blog_id` from `{$wpdb->blogs}`");
1319
+
1320
+ if (empty($networkBlogs)) {
1321
+ return;
1322
+ }
1323
+
1324
+ foreach ($networkBlogs as $details) {
1325
+ update_blog_option($details->blog_id, 'iwp_client_public_key', $publicKey);
1326
+ }
1327
+
1328
+ return;
1329
+ }
1330
+
1331
+ function addConnectionKeyLink($meta, $slug)
1332
+ {
1333
+ if (is_multisite() && !is_network_admin()) {
1334
+ return $meta;
1335
+ }
1336
+
1337
+ if ($slug !== 'iwp-client/init.php') {
1338
+ return $meta;
1339
+ }
1340
+
1341
+ if (!current_user_can('activate_plugins')) {
1342
+ return $meta;
1343
+ }
1344
+
1345
+ $meta[] = '<a href="#" id="iwp-view-connection-key" iwp-key="'.get_option('iwp_client_activate_key').'">View activation key</a>';
1346
+
1347
+ return $meta;
1348
+ }
1349
+
1350
+ function printConnectionModalOpenScript()
1351
+ {
1352
+ if (!current_user_can('activate_plugins')) {
1353
+ return;
1354
+ }
1355
+
1356
+ ob_start()
1357
+ ?>
1358
+ <script type="text/javascript">
1359
+ jQuery(document).ready(function($) {
1360
+ var $iwpconnectionKeyDialog = $('#iwp_connection_key_dialog');
1361
+ $('#iwp-view-connection-key').click(function(e) {
1362
+ e.preventDefault();
1363
+ $iwpconnectionKeyDialog.dialog({
1364
+ draggable: false,
1365
+ resizable: false,
1366
+ modal: true,
1367
+ width: '530px',
1368
+ height: 'auto',
1369
+ title: 'Activation Key',
1370
+ close: function() {
1371
+ $(this).dialog("destroy");
1372
+ }
1373
+ });
1374
+ });
1375
+ $('button.copy-key-button').click(function() {
1376
+ $('#activation-key').select();
1377
+ document.execCommand('copy');
1378
+ });
1379
+ });
1380
+ </script>
1381
+ <?php
1382
+
1383
+ $content = ob_get_clean();
1384
+ print $content;
1385
+ }
1386
+
1387
+ function printConnectionModalDialog()
1388
+ {
1389
+ if (is_multisite() && !is_network_admin()) {
1390
+ return;
1391
+ }
1392
+
1393
+ if (!current_user_can('activate_plugins')) {
1394
+ return;
1395
+ }
1396
+
1397
+ ob_start();
1398
+ ?>
1399
+ <div id="iwp_connection_key_dialog" style="display: none;">
1400
+
1401
+ <div style="text-align: center;font-weight: bold;"><p style="margin-bottom: 4px;margin-top: 20px;">Activation Key</p></div>
1402
+ <input id="activation-key" rows="1" style="padding: 10px;background-color: #fafafa;border: 1px solid black;border-radius: 10px;font-weight: bold;font-size: 14px;text-align: center; width: 85%; margin-right: 5px" onclick="this.focus();this.select()" readonly="readonly" value="<?php echo get_option('iwp_client_activate_key'); ?>">
1403
+ <button class="copy-key-button" data-clipboard-target="#activation-key" style="padding: 10px;background-color: #fafafa;border: 1px solid black;border-radius: 10px;font-weight: bold;font-size: 14px;text-align: center;">Copy</button>
1404
+ </div>
1405
+ <?php
1406
+
1407
+ $content = ob_get_clean();
1408
+ print $content;
1409
+ }
1410
+
1411
+ function get_option($option){
1412
+ if (is_multisite()) {
1413
+ return get_site_option($option);
1414
+ }
1415
+
1416
+ return get_option($option);
1417
+ }
1418
+
1419
+ function update_option($option, $option_value){
1420
+ if (is_multisite()) {
1421
+ global $wpdb;
1422
+ $blogIDs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
1423
+ foreach ($blogIDs as $blogID) {
1424
+ update_blog_option($blogID, $option, $option_value);
1425
+ }
1426
+ return true;
1427
+ } else {
1428
+ update_option($option, $option_value);
1429
+ return true;
1430
+ }
1431
+ return false;
1432
+ }
1433
+
1434
+ function enqueueConnectionModalOpenScripts(){
1435
+ wp_enqueue_script('jquery');
1436
+ wp_enqueue_script('jquery-ui-core');
1437
+ wp_enqueue_script('jquery-ui-dialog');
1438
+ }
1439
+
1440
+ function enqueueConnectionModalOpenStyles(){
1441
+ wp_enqueue_style('wp-jquery-ui');
1442
+ wp_enqueue_style('wp-jquery-ui-dialog');
1443
+ }
1444
 
1445
 
1446
  }
debug-chart/index.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ include_once ("src/fusioncharts.php");
3
+ ?>
4
+ <html>
5
+
6
+ <head>
7
+ <title>IWP DEBUG CHART</title>
8
+ <script src="https://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
9
+ </head>
10
+ <body>
11
+ <?php
12
+ if (empty($_GET['historyID'])) {
13
+ exit();
14
+ }
15
+ $iwp_multicall_hisID = $_GET['historyID'];
16
+ $current_dir = dirname( dirname( dirname( dirname(__FILE__) ) ) ).'/infinitewp/backups';
17
+ $memoryPeakLog = 'DE_clMemoryPeak.'.$iwp_multicall_hisID.'.txt';
18
+ $memoryUsageLog = 'DE_clMemoryUsage.'.$iwp_multicall_hisID.'.txt';
19
+ $timeTakenLog = 'DE_clTimeTaken.'.$iwp_multicall_hisID.'.txt';
20
+ $cpuUsageLog = 'DE_clCPUUsage.'.$iwp_multicall_hisID.'.txt';
21
+ new IWP_Debug_Chart('Memory Usage in Real Time', ' MB', $current_dir . '/'.$memoryUsageLog, 'Memory Usage', 'chart-1');
22
+ new IWP_Debug_Chart('Time Taken', ' Sec', $current_dir . '/'.$timeTakenLog, 'Time Taken', 'chart-2');
23
+ new IWP_Debug_Chart('CPU Usage', ' ', $current_dir . '/'.$cpuUsageLog, 'CPU Usage', 'chart-3');
24
+ // new IWP_Debug_Chart('Memory Peak', ' MB', $current_dir . '/'.$memoryPeakLog, 'Memory Peak', 'chart-4');
25
+
26
+ ?>
27
+ <div id="chart-1"><!-- Fusion Charts will render here--></div>
28
+ <div id="chart-2"><!-- Fusion Charts will render here--></div>
29
+ <div id="chart-3"><!-- Fusion Charts will render here--></div>
30
+ <div id="chart-4"><!-- Fusion Charts will render here--></div>
31
+ </body>
32
+ </html>
33
+
34
+
35
+ <?php
36
+
37
+ Class IWP_Debug_Chart{
38
+ private $chart_meta;
39
+ private $dataset;
40
+
41
+ public function __construct($caption, $numbersuffix, $file, $graph_name, $chart_id){
42
+ $this->init_chart_meta($caption, $numbersuffix);
43
+ $this->read_logs($file);
44
+ $this->plot_graph($graph_name, $chart_id);
45
+ }
46
+
47
+ private function plot_graph($graph_name, $chart_id){
48
+ $encoded_data = $this->struct_data();
49
+ $pieChart = new FusionCharts("line", $graph_name , "100%", 300, $chart_id, "json", $encoded_data);
50
+ $pieChart->render();
51
+ }
52
+
53
+ private function struct_data(){
54
+ $this->chart_meta['data'] = $this->dataset;
55
+ return json_encode($this->chart_meta);
56
+ }
57
+
58
+ private function read_logs($file) {
59
+ $file = fopen($file, "r");
60
+
61
+ if(empty($file)){
62
+ return false;
63
+ }
64
+
65
+ while(!feof($file)) {
66
+ $data = explode(' ', fgets($file));
67
+
68
+ if (empty($data[0]) || empty($data[1] ) ) {
69
+ continue;
70
+ }
71
+ $this->dataset[] = array(
72
+ "label" => $data[1],
73
+ "value" => trim($data[2]),
74
+ "color" => "008ee4",
75
+ "stepSkipped" => false,
76
+ "appliedSmartLabel" => true
77
+ );
78
+ }
79
+
80
+ fclose($file);
81
+ }
82
+
83
+ private function init_chart_meta($caption, $numbersuffix){
84
+ $this->chart_meta = array(
85
+ "chart" => array(
86
+ "caption" =>$caption,
87
+ "numbersuffix" => $numbersuffix,
88
+ "bgcolor" => "FFFFFF",
89
+ "showalternatehgridcolor" => "0",
90
+ "plotbordercolor" => "008ee4",
91
+ "plotborderthickness" => "3",
92
+ "showvalues" => "0",
93
+ "divlinecolor" => "CCCCCC",
94
+ "showcanvasborder" => "0",
95
+ "tooltipbgcolor" => "00396d",
96
+ "tooltipcolor" => "FFFFFF",
97
+ "tooltipbordercolor" => "00396d",
98
+ "numdivlines" => "20",
99
+ "yaxisvaluespadding" => "20",
100
+ "anchorbgcolor" => "008ee4",
101
+ "anchorborderthickness" => "0",
102
+ "showshadow" => "0",
103
+ "showLabels" =>"0",
104
+ "anchorradius" => "2",
105
+ "chartrightmargin" => "25",
106
+ "canvasborderalpha" => "0",
107
+ "showborder" => "1",
108
+ )
109
+ );
110
+ }
111
+ }
debug-chart/src/fusioncharts.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class FusionCharts {
4
+
5
+ private $constructorOptions = array();
6
+
7
+ private $constructorTemplate = '
8
+ <script type="text/javascript">
9
+ FusionCharts.ready(function () {
10
+ new FusionCharts(__constructorOptions__);
11
+ });
12
+ </script>';
13
+
14
+ private $renderTemplate = '
15
+ <script type="text/javascript">
16
+ FusionCharts.ready(function () {
17
+ FusionCharts("__chartId__").render();
18
+ });
19
+ </script>
20
+ ';
21
+
22
+ // constructor
23
+ function __construct($type, $id, $width = 400, $height = 300, $renderAt, $dataFormat, $dataSource) {
24
+ isset($type) ? $this->constructorOptions['type'] = $type : '';
25
+ isset($id) ? $this->constructorOptions['id'] = $id : 'php-fc-'.time();
26
+ isset($width) ? $this->constructorOptions['width'] = $width : '';
27
+ isset($height) ? $this->constructorOptions['height'] = $height : '';
28
+ isset($renderAt) ? $this->constructorOptions['renderAt'] = $renderAt : '';
29
+ isset($dataFormat) ? $this->constructorOptions['dataFormat'] = $dataFormat : '';
30
+ isset($dataSource) ? $this->constructorOptions['dataSource'] = $dataSource : '';
31
+
32
+ $tempArray = array();
33
+ foreach($this->constructorOptions as $key => $value) {
34
+ if ($key === 'dataSource') {
35
+ $tempArray['dataSource'] = '__dataSource__';
36
+ } else {
37
+ $tempArray[$key] = $value;
38
+ }
39
+ }
40
+
41
+ $jsonEncodedOptions = json_encode($tempArray);
42
+
43
+ if ($dataFormat === 'json') {
44
+ $jsonEncodedOptions = preg_replace('/\"__dataSource__\"/', $this->constructorOptions['dataSource'], $jsonEncodedOptions);
45
+ } elseif ($dataFormat === 'xml') {
46
+ $jsonEncodedOptions = preg_replace('/\"__dataSource__\"/', '\'__dataSource__\'', $jsonEncodedOptions);
47
+ $jsonEncodedOptions = preg_replace('/__dataSource__/', $this->constructorOptions['dataSource'], $jsonEncodedOptions);
48
+ } elseif ($dataFormat === 'xmlurl') {
49
+ $jsonEncodedOptions = preg_replace('/__dataSource__/', $this->constructorOptions['dataSource'], $jsonEncodedOptions);
50
+ } elseif ($dataFormat === 'jsonurl') {
51
+ $jsonEncodedOptions = preg_replace('/__dataSource__/', $this->constructorOptions['dataSource'], $jsonEncodedOptions);
52
+ }
53
+ $newChartHTML = preg_replace('/__constructorOptions__/', $jsonEncodedOptions, $this->constructorTemplate);
54
+
55
+ echo $newChartHTML;
56
+ }
57
+
58
+ // render the chart created
59
+ // It prints a script and calls the FusionCharts javascript render method of created chart
60
+ function render() {
61
+ $renderHTML = preg_replace('/__chartId__/', $this->constructorOptions['id'], $this->renderTemplate);
62
+ echo $renderHTML;
63
+ }
64
+
65
+ }
66
+ ?>
helper.class.php CHANGED
@@ -293,8 +293,18 @@ class IWP_MMB_Helper
293
  function set_client_message_id($message_id = false)
294
  {
295
  if ($message_id) {
296
- add_option('iwp_client_action_message_id', $message_id) or update_option('iwp_client_action_message_id', $message_id);
297
- return $message_id;
 
 
 
 
 
 
 
 
 
 
298
  }
299
  return false;
300
  }
@@ -306,10 +316,21 @@ class IWP_MMB_Helper
306
 
307
  function set_admin_panel_public_key($public_key = false)
308
  {
309
- if ($public_key && !get_option('iwp_client_public_key')) {
310
- add_option('iwp_client_public_key', base64_encode($public_key));
 
 
 
 
 
311
  return true;
 
 
 
 
 
312
  }
 
313
  return false;
314
  }
315
 
293
  function set_client_message_id($message_id = false)
294
  {
295
  if ($message_id) {
296
+ if (is_multisite()) {
297
+ global $wpdb;
298
+ $blogIDs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
299
+ foreach ($blogIDs as $blogID) {
300
+ update_blog_option($blogID, 'iwp_client_action_message_id', $message_id);
301
+ }
302
+ return true;
303
+ } else {
304
+ update_option('iwp_client_action_message_id', $message_id);
305
+ return $message_id;
306
+ }
307
+
308
  }
309
  return false;
310
  }
316
 
317
  function set_admin_panel_public_key($public_key = false)
318
  {
319
+
320
+ if (is_multisite()) {
321
+ global $wpdb;
322
+ $blogIDs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
323
+ foreach ($blogIDs as $blogID) {
324
+ update_blog_option($blogID, 'iwp_client_public_key', base64_encode($public_key));
325
+ }
326
  return true;
327
+ } else {
328
+ if ($public_key && !get_option('iwp_client_public_key')) {
329
+ add_option('iwp_client_public_key', base64_encode($public_key));
330
+ return true;
331
+ }
332
  }
333
+
334
  return false;
335
  }
336
 
init.php CHANGED
@@ -4,8 +4,9 @@ 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.8.6
8
  Author URI: http://www.revmakx.com
 
9
  */
10
  /************************************************************
11
  * This plugin was modified by Revmakx *
@@ -28,7 +29,7 @@ if(basename($_SERVER['SCRIPT_FILENAME']) == "init.php"):
28
  exit;
29
  endif;
30
  if(!defined('IWP_MMB_CLIENT_VERSION'))
31
- define('IWP_MMB_CLIENT_VERSION', '1.8.6');
32
 
33
 
34
 
@@ -60,6 +61,8 @@ define('IWP_PCLZIP_TEMPORARY_DIR', WP_CONTENT_DIR . '/infinitewp/temp/');
60
  require_once("$iwp_mmb_plugin_dir/helper.class.php");
61
  require_once("$iwp_mmb_plugin_dir/backup/backup.options.php");
62
  require_once("$iwp_mmb_plugin_dir/backup/functions.php");
 
 
63
  require_once("$iwp_mmb_plugin_dir/core.class.php");
64
  require_once("$iwp_mmb_plugin_dir/activities_log.class.php");
65
  require_once("$iwp_mmb_plugin_dir/stats.class.php");
@@ -162,13 +165,12 @@ if( !function_exists ('iwp_mmb_parse_request')) {
162
  error_reporting(0);
163
  @ini_set("display_errors", 0);
164
 
165
- iwp_mmb_backup_db_changes();
166
 
167
  run_hash_change_process();
168
  iwp_plugin_compatibility_fix();
169
  $action = $iwp_action;
170
  $_wp_using_ext_object_cache = false;
171
- // @set_time_limit(600);
172
 
173
  if (!$iwp_mmb_core->check_if_user_exists($params['username']))
174
  iwp_mmb_response(array('error' => 'Username <b>' . $params['username'] . '</b> does not have administrative access. Enter the correct username in the site options.', 'error_code' => 'username_does_not_have_administrative_access'), false);
@@ -187,9 +189,12 @@ if( !function_exists ('iwp_mmb_parse_request')) {
187
 
188
  $auth = $iwp_mmb_core->authenticate_message($action . $id, $signature, $id);
189
  if ($auth === true) {
190
- if (!defined('WP_ADMIN') && $action == 'get_stats' || $action == 'do_upgrade' || $action == 'install_addon' || $action == 'edit_plugins_themes' || $action == 'bulk_actions_processor') {
191
  define('WP_ADMIN', true);
192
  }
 
 
 
193
  if (is_multisite()) {
194
  define('WP_NETWORK_ADMIN', true);
195
  }else{
@@ -251,7 +256,7 @@ if (!function_exists ('iwp_mmb_set_request')) {
251
  }
252
  @ignore_user_abort(true);
253
  $GLOBALS['IWP_CLIENT_HISTORY_ID'] = $iwp_mmb_core->request_params['id'];
254
-
255
  if(isset($params['username']) && !is_user_logged_in()){
256
  $user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : iwp_mmb_get_user_by( 'login', $params['username'] );
257
  if (isset($user) && isset($user->ID)) {
@@ -378,7 +383,11 @@ if( !function_exists ( 'iwp_mmb_response' )) {
378
  }
379
 
380
  if( !headers_sent() ){
381
- header('HTTP/1.0 200 OK');
 
 
 
 
382
  header('Content-Type: text/plain');
383
  }
384
  if (!$send_serialize_response) {
@@ -417,7 +426,7 @@ if( !function_exists ( 'iwp_mmb_add_site' )) {
417
  $num = extract($params);
418
 
419
  if ($num) {
420
- if (!get_option('iwp_client_action_message_id') && !get_option('iwp_client_public_key')) {
421
  $public_key = base64_decode($public_key);
422
 
423
 
@@ -637,6 +646,21 @@ if( !function_exists ( 'iwp_mmb_trigger_check_new' )) {
637
  }
638
  }
639
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
640
  if( !function_exists ( 'iwp_mmb_trigger_check' )) {
641
  //backup multi call trigger and status check.
642
  function iwp_mmb_trigger_check($params)
@@ -671,9 +695,75 @@ if( !function_exists ( 'iwp_mmb_backup_now' )) {
671
  }
672
  }
673
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
674
  if( !function_exists ( 'iwp_mmb_new_scheduled_backup' )) {
675
  function iwp_mmb_new_scheduled_backup($params)
676
  {
 
677
  global $iwp_backup_core;
678
 
679
  if (!empty($params['backup_nounce'])) {
@@ -690,6 +780,15 @@ if( !function_exists ( 'iwp_mmb_new_scheduled_backup' )) {
690
  );
691
  // Close browser connection not working for some servers so we suggest IWP_PHOENIX_BACKUP_CRON
692
  // iwp_closeBrowserConnection( $msg );
 
 
 
 
 
 
 
 
 
693
  if (is_array($msg) && array_key_exists('error', $msg))
694
  iwp_closeBrowserConnection($msg, false);
695
  else {
@@ -792,6 +891,7 @@ if( !function_exists ( 'iwp_mmb_scheduled_backup' )) {
792
  if( !function_exists ( 'iwp_mmb_new_run_task_now' )) {
793
  function iwp_mmb_new_run_task_now($params)
794
  {
 
795
  global $iwp_backup_core;
796
 
797
  if (!empty($params['backup_nounce'])) {
@@ -808,6 +908,15 @@ if( !function_exists ( 'iwp_mmb_new_run_task_now' )) {
808
  );
809
  // Close browser connection not working for some servers so we suggest IWP_PHOENIX_BACKUP_CRON
810
  // iwp_closeBrowserConnection( $msg );
 
 
 
 
 
 
 
 
 
811
  if (is_array($msg) && array_key_exists('error', $msg))
812
  iwp_closeBrowserConnection($msg, false);
813
  else {
@@ -1041,7 +1150,13 @@ if( !function_exists ( 'iwp_mmb_add_user' )) {
1041
  {
1042
  global $iwp_mmb_core;
1043
  $iwp_mmb_core->get_user_instance();
 
 
 
 
1044
  $return = $iwp_mmb_core->user_instance->add_user($params);
 
 
1045
  if (is_array($return) && array_key_exists('error', $return)){
1046
  iwp_mmb_response($return, false);
1047
  }
@@ -1071,7 +1186,14 @@ if( !function_exists ('iwp_mmb_edit_users')) {
1071
  {
1072
  global $iwp_mmb_core;
1073
  $iwp_mmb_core->get_user_instance();
1074
- $return = $iwp_mmb_core->user_instance->edit_users($params);
 
 
 
 
 
 
 
1075
  iwp_mmb_response($return, true);
1076
  }
1077
  }
@@ -1394,8 +1516,12 @@ if( !function_exists ('iwp_mmb_action_comment')) {
1394
  {
1395
  global $iwp_mmb_core;
1396
  $iwp_mmb_core->get_comment_instance();
1397
-
 
 
 
1398
  $return = $iwp_mmb_core->comment_instance->action_comment($params);
 
1399
  if (is_array($return) && array_key_exists('error', $return))
1400
  iwp_mmb_response($return, false);
1401
  else {
@@ -1409,8 +1535,12 @@ if( !function_exists ('iwp_mmb_bulk_action_comments')) {
1409
  {
1410
  global $iwp_mmb_core;
1411
  $iwp_mmb_core->get_comment_instance();
1412
-
 
 
 
1413
  $return = $iwp_mmb_core->comment_instance->bulk_action_comments($params);
 
1414
  if (is_array($return) && array_key_exists('error', $return))
1415
  iwp_mmb_response($return, false);
1416
  else {
@@ -1424,8 +1554,12 @@ if( !function_exists ('iwp_mmb_reply_comment')) {
1424
  {
1425
  global $iwp_mmb_core;
1426
  $iwp_mmb_core->get_comment_instance();
1427
-
1428
- $return = $iwp_mmb_core->comment_instance->reply_comment($params);
 
 
 
 
1429
  if (is_array($return) && array_key_exists('error', $return))
1430
  iwp_mmb_response($return, false);
1431
  else {
@@ -1643,7 +1777,16 @@ if( !function_exists('iwp_mmb_update_broken_link')){
1643
  function iwp_mmb_update_broken_link($params){
1644
  global $iwp_mmb_core;
1645
  $iwp_mmb_core->wp_blc_get_blinks();
1646
- $return = $iwp_mmb_core->blc_get_blinks->blc_update_link($params);
 
 
 
 
 
 
 
 
 
1647
  if (is_array($return) && array_key_exists('error', $return))
1648
  iwp_mmb_response($return, false);
1649
  else {
@@ -1708,12 +1851,22 @@ if( !function_exists('iwp_mmb_bulk_actions_processor')){
1708
  function iwp_mmb_bulk_actions_processor($params){
1709
  global $iwp_mmb_core;
1710
  $iwp_mmb_core->wp_blc_get_blinks();
1711
- $return = $iwp_mmb_core->blc_get_blinks->blc_bulk_actions($params);
 
 
 
 
 
 
 
 
 
1712
  if (is_array($return) && array_key_exists('error', $return))
1713
  iwp_mmb_response($return, false);
1714
  else {
1715
  iwp_mmb_response($return, true);
1716
  }
 
1717
  }
1718
  }
1719
 
@@ -2055,6 +2208,11 @@ if (!function_exists('iwp_mmb_backup_db_changes')) {
2055
  if(version_compare(iwp_mmb_get_site_option('iwp_backup_table_version'), '1.1.4', '<')){
2056
  iwp_mmb_change_stausMsg_column_type_backup_status_table();
2057
  }
 
 
 
 
 
2058
  }
2059
  }
2060
 
@@ -2108,6 +2266,43 @@ if(!function_exists('iwp_mmb_create_backup_status_table')){
2108
  }
2109
  }
2110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2111
  if(!function_exists('iwp_mmb_change_collation_backup_status_table')){
2112
  function iwp_mmb_change_collation_backup_status_table(){
2113
  global $wpdb;
@@ -2194,7 +2389,7 @@ if (!function_exists('iwp_mmb_change_stausMsg_column_type_backup_status_table'))
2194
  function iwp_mmb_change_stausMsg_column_type_backup_status_table(){
2195
  global $wpdb;
2196
  $table_name = $wpdb->base_prefix . "iwp_backup_status";
2197
- $sql = "alter table " . $table_name . " change statusMsg LONGTEXT;";
2198
  $isDone = $wpdb->query($sql);
2199
  if ($isDone) {
2200
  update_option( "iwp_backup_table_version", '1.1.4');
@@ -2936,14 +3131,42 @@ function iwp_plugin_compatibility_fix(){
2936
 
2937
  }
2938
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2939
  iwp_mmb_set_plugin_priority();
2940
  $iwp_mmb_core = new IWP_MMB_Core();
2941
  $GLOBALS['iwp_mmb_activities_log'] = new IWP_MMB_Activities_log();
2942
  $mmb_core = 1;
2943
  $GLOBALS['iwp_activities_log_post_type'] = 'iwp_log';
2944
 
2945
- if(isset($_GET['auto_login']))
2946
- $iwp_mmb_core->add_login_action();
 
 
2947
  if (function_exists('register_activation_hook'))
2948
  register_activation_hook( __FILE__ , array( $iwp_mmb_core, 'install' ));
2949
 
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.9.4.1
8
  Author URI: http://www.revmakx.com
9
+ Network: true
10
  */
11
  /************************************************************
12
  * This plugin was modified by Revmakx *
29
  exit;
30
  endif;
31
  if(!defined('IWP_MMB_CLIENT_VERSION'))
32
+ define('IWP_MMB_CLIENT_VERSION', '1.9.4.1');
33
 
34
 
35
 
61
  require_once("$iwp_mmb_plugin_dir/helper.class.php");
62
  require_once("$iwp_mmb_plugin_dir/backup/backup.options.php");
63
  require_once("$iwp_mmb_plugin_dir/backup/functions.php");
64
+ require_once("$iwp_mmb_plugin_dir/backup/databaseencrypt.php");
65
+ require_once("$iwp_mmb_plugin_dir/backup/encrypt.php");
66
  require_once("$iwp_mmb_plugin_dir/core.class.php");
67
  require_once("$iwp_mmb_plugin_dir/activities_log.class.php");
68
  require_once("$iwp_mmb_plugin_dir/stats.class.php");
165
  error_reporting(0);
166
  @ini_set("display_errors", 0);
167
 
 
168
 
169
  run_hash_change_process();
170
  iwp_plugin_compatibility_fix();
171
  $action = $iwp_action;
172
  $_wp_using_ext_object_cache = false;
173
+ @set_time_limit(600);
174
 
175
  if (!$iwp_mmb_core->check_if_user_exists($params['username']))
176
  iwp_mmb_response(array('error' => 'Username <b>' . $params['username'] . '</b> does not have administrative access. Enter the correct username in the site options.', 'error_code' => 'username_does_not_have_administrative_access'), false);
189
 
190
  $auth = $iwp_mmb_core->authenticate_message($action . $id, $signature, $id);
191
  if ($auth === true) {
192
+ if (!defined('WP_ADMIN') && $action == 'get_stats' || $action == 'do_upgrade' || $action == 'install_addon' || $action == 'edit_plugins_themes' || $action == 'bulk_actions_processor' || $action == 'update_broken_link' || $action == 'undismiss_broken_link') {
193
  define('WP_ADMIN', true);
194
  }
195
+ if ($action == 'get_stats') {
196
+ iwp_mu_plugin_loader();
197
+ }
198
  if (is_multisite()) {
199
  define('WP_NETWORK_ADMIN', true);
200
  }else{
256
  }
257
  @ignore_user_abort(true);
258
  $GLOBALS['IWP_CLIENT_HISTORY_ID'] = $iwp_mmb_core->request_params['id'];
259
+ iwp_mmb_backup_db_changes();
260
  if(isset($params['username']) && !is_user_logged_in()){
261
  $user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : iwp_mmb_get_user_by( 'login', $params['username'] );
262
  if (isset($user) && isset($user->ID)) {
383
  }
384
 
385
  if( !headers_sent() ){
386
+ $protocol = 'HTTP/1.1';
387
+ if (isset($_SERVER['SERVER_PROTOCOL']) && $_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.0') {
388
+ $protocol = 'HTTP/1.0';
389
+ }
390
+ header($protocol.' 200 OK');
391
  header('Content-Type: text/plain');
392
  }
393
  if (!$send_serialize_response) {
426
  $num = extract($params);
427
 
428
  if ($num) {
429
+ if (!$iwp_mmb_core->get_option('iwp_client_action_message_id') && !$iwp_mmb_core->get_option('iwp_client_public_key')) {
430
  $public_key = base64_decode($public_key);
431
 
432
 
646
  }
647
  }
648
 
649
+ if( !function_exists ( 'iwp_pheonix_backup_cron_do_action' )) {
650
+ //backup multi call trigger and status check.
651
+ function iwp_pheonix_backup_cron_do_action($params)
652
+ {
653
+ global $iwp_backup_core;
654
+ $return = $iwp_backup_core->iwp_pheonix_backup_cron_do_action($params);
655
+
656
+ if (is_array($return) && array_key_exists('error', $return))
657
+ iwp_mmb_response($return, false);
658
+ else {
659
+ iwp_mmb_response($return, true);
660
+ }
661
+ }
662
+ }
663
+
664
  if( !function_exists ( 'iwp_mmb_trigger_check' )) {
665
  //backup multi call trigger and status check.
666
  function iwp_mmb_trigger_check($params)
695
  }
696
  }
697
 
698
+ if( !function_exists ( 'iwp_get_additional_stats' )) {
699
+ //backup
700
+ function iwp_get_additional_stats($params)
701
+ {
702
+ global $iwp_mmb_core, $iwp_mmb_plugin_dir;
703
+ $response = array();
704
+ if (!empty($params['requiredActions']) && isset($params['requiredActions']['get_all_links'])) {
705
+ $iwp_mmb_core->wp_blc_get_blinks();
706
+ $brokenlinks = $iwp_mmb_core->blc_get_blinks->blc_get_all_links();
707
+ if (is_array($brokenlinks) && !array_key_exists('error', $brokenlinks))
708
+ $response['get_all_links'] = $brokenlinks;
709
+ }
710
+ if (!empty($params['requiredActions']) && isset($params['requiredActions']['ithemes_security_check'])) {
711
+ if (iwp_mmb_ithemes_security_check()) {
712
+ $ithemessec_instance = $iwp_mmb_core->get_ithemessec_instance();
713
+ $return = $ithemessec_instance->securityCheck();
714
+ if (isset($return['security_check'])) {
715
+ $response['ithemes_security_check'] = $return['security_check'];
716
+ }
717
+ }
718
+ }
719
+ if (!empty($params['requiredActions']) && isset($params['requiredActions']['sucuri_fetch_result'])) {
720
+ require_once("$iwp_mmb_plugin_dir/addons/malware_scanner_sucuri/malware_scanner_sucuri.class.php");
721
+ $iwp_mmb_core->get_sucuri_instance();
722
+
723
+ $return = $iwp_mmb_core->sucuri_instance->getScannedCacheResult();
724
+ if (is_array($return) && !array_key_exists('error', $return))
725
+ $response['sucuri_fetch_result'] = $return;
726
+ }
727
+
728
+ if (!empty($params['requiredActions']) && isset($params['requiredActions']['get_comments'])) {
729
+ require_once("$iwp_mmb_plugin_dir/addons/malware_scanner_sucuri/malware_scanner_sucuri.class.php");
730
+ $iwp_mmb_core->get_comment_instance();
731
+
732
+ $return = $iwp_mmb_core->comment_instance->get_comments($params['requiredActions']['get_comments']);
733
+ if (is_array($return) && !array_key_exists('error', $return))
734
+ $response['get_comments'] = $return;
735
+ }
736
+
737
+ if (!empty($params['requiredActions']) && isset($params['requiredActions']['get_users'])) {
738
+ $iwp_mmb_core->get_user_instance();
739
+
740
+ $return = $iwp_mmb_core->user_instance->get_users($params['requiredActions']['get_users']);
741
+ if (is_array($return) && !array_key_exists('error', $return))
742
+ $response['get_users'] = $return;
743
+ }
744
+
745
+ if (!empty($params['requiredActions']) && isset($params['requiredActions']['wordfence_load'])) {
746
+ global $iwp_mmb_core,$iwp_mmb_plugin_dir;
747
+ require_once("$iwp_mmb_plugin_dir/addons/wordfence/wordfence.class.php");
748
+ $iwp_mmb_core->get_wordfence_instance();
749
+
750
+ $return = $iwp_mmb_core->wordfence_instance->load($params);
751
+ if (is_array($return) && !array_key_exists('error', $return))
752
+ $response['wordfence_load'] = $return;
753
+ }
754
+
755
+ if (is_array($response) && array_key_exists('error', $response))
756
+ iwp_mmb_response($response, false);
757
+ else {
758
+ iwp_mmb_response($response, true);
759
+ }
760
+ }
761
+ }
762
+
763
  if( !function_exists ( 'iwp_mmb_new_scheduled_backup' )) {
764
  function iwp_mmb_new_scheduled_backup($params)
765
  {
766
+ require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup/backup-repo-test.php");
767
  global $iwp_backup_core;
768
 
769
  if (!empty($params['backup_nounce'])) {
780
  );
781
  // Close browser connection not working for some servers so we suggest IWP_PHOENIX_BACKUP_CRON
782
  // iwp_closeBrowserConnection( $msg );
783
+ if ((!defined('DISABLE_IWP_CLOUD_VERIFICATION')) && (empty($params['args']['disable_iwp_cloud_verification']))) {
784
+ require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup.class.multicall.php");
785
+ $backup_repo_test_obj = new IWP_BACKUP_REPO_TEST();
786
+ $backup_repo_test_result = $backup_repo_test_obj->repositoryTestConnection($params['account_info']);
787
+ if (!empty($backup_repo_test_result['error']) && $backup_repo_test_result['status'] != 'success') {
788
+ $return = array('error' => $backup_repo_test_result['error'], 'error_code' => $backup_repo_test_result['error_code']);
789
+ iwp_mmb_response($return, false);
790
+ }
791
+ }
792
  if (is_array($msg) && array_key_exists('error', $msg))
793
  iwp_closeBrowserConnection($msg, false);
794
  else {
891
  if( !function_exists ( 'iwp_mmb_new_run_task_now' )) {
892
  function iwp_mmb_new_run_task_now($params)
893
  {
894
+ require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup/backup-repo-test.php");
895
  global $iwp_backup_core;
896
 
897
  if (!empty($params['backup_nounce'])) {
908
  );
909
  // Close browser connection not working for some servers so we suggest IWP_PHOENIX_BACKUP_CRON
910
  // iwp_closeBrowserConnection( $msg );
911
+ if ((!defined('DISABLE_IWP_CLOUD_VERIFICATION')) && (empty($params['args']['disable_iwp_cloud_verification']))) {
912
+ require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup.class.multicall.php");
913
+ $backup_repo_test_obj = new IWP_BACKUP_REPO_TEST();
914
+ $backup_repo_test_result = $backup_repo_test_obj->repositoryTestConnection($params['account_info']);
915
+ if (!empty($backup_repo_test_result['error']) && $backup_repo_test_result['status'] != 'success') {
916
+ $return = array('error' => $backup_repo_test_result['error'], 'error_code' => $backup_repo_test_result['error_code']);
917
+ iwp_mmb_response($return, false);
918
+ }
919
+ }
920
  if (is_array($msg) && array_key_exists('error', $msg))
921
  iwp_closeBrowserConnection($msg, false);
922
  else {
1150
  {
1151
  global $iwp_mmb_core;
1152
  $iwp_mmb_core->get_user_instance();
1153
+ if(!empty($params['additional_params'])){
1154
+ $return['action_response'] = $iwp_mmb_core->user_instance->add_user($params['action_params']);
1155
+ $return['additional_response'] = $iwp_mmb_core->user_instance->get_users($params['additional_params']);
1156
+ }else{
1157
  $return = $iwp_mmb_core->user_instance->add_user($params);
1158
+ }
1159
+
1160
  if (is_array($return) && array_key_exists('error', $return)){
1161
  iwp_mmb_response($return, false);
1162
  }
1186
  {
1187
  global $iwp_mmb_core;
1188
  $iwp_mmb_core->get_user_instance();
1189
+ if(!empty($params['additional_params'])){
1190
+ $params['action_params']['username'] = $params['username'];
1191
+ $return['action_response'] = $iwp_mmb_core->user_instance->edit_users($params['action_params']);
1192
+ $return['additional_response'] = $iwp_mmb_core->user_instance->get_users($params['additional_params']);
1193
+ }else{
1194
+ $return = $iwp_mmb_core->user_instance->edit_users($params);
1195
+ }
1196
+
1197
  iwp_mmb_response($return, true);
1198
  }
1199
  }
1516
  {
1517
  global $iwp_mmb_core;
1518
  $iwp_mmb_core->get_comment_instance();
1519
+ if(!empty($params['additional_params'])){
1520
+ $return['action_response'] = $iwp_mmb_core->comment_instance->action_comment($params['action_params']);
1521
+ $return['additional_response'] = $iwp_mmb_core->comment_instance->get_comments($params['additional_params']);
1522
+ }else{
1523
  $return = $iwp_mmb_core->comment_instance->action_comment($params);
1524
+ }
1525
  if (is_array($return) && array_key_exists('error', $return))
1526
  iwp_mmb_response($return, false);
1527
  else {
1535
  {
1536
  global $iwp_mmb_core;
1537
  $iwp_mmb_core->get_comment_instance();
1538
+ if(!empty($params['additional_params'])){
1539
+ $return['action_response'] = $iwp_mmb_core->comment_instance->bulk_action_comments($params['action_params']);
1540
+ $return['additional_response'] = $iwp_mmb_core->comment_instance->get_comments($params['additional_params']);
1541
+ }else{
1542
  $return = $iwp_mmb_core->comment_instance->bulk_action_comments($params);
1543
+ }
1544
  if (is_array($return) && array_key_exists('error', $return))
1545
  iwp_mmb_response($return, false);
1546
  else {
1554
  {
1555
  global $iwp_mmb_core;
1556
  $iwp_mmb_core->get_comment_instance();
1557
+ if(!empty($params['additional_params'])){
1558
+ $return['action_response'] = $iwp_mmb_core->comment_instance->reply_comment($params['action_params']);
1559
+ $return['additional_response'] = $iwp_mmb_core->comment_instance->get_comments($params['additional_params']);
1560
+ }else{
1561
+ $return = $iwp_mmb_core->comment_instance->reply_comment($params);
1562
+ }
1563
  if (is_array($return) && array_key_exists('error', $return))
1564
  iwp_mmb_response($return, false);
1565
  else {
1777
  function iwp_mmb_update_broken_link($params){
1778
  global $iwp_mmb_core;
1779
  $iwp_mmb_core->wp_blc_get_blinks();
1780
+ if(!empty($params['additional_params'])){
1781
+ $return['action_response'] = $iwp_mmb_core->blc_get_blinks->blc_update_link($params['action_params']);
1782
+ $brokenlinks = $iwp_mmb_core->blc_get_blinks->blc_get_all_links();
1783
+ if($brokenlinks =='nolinks'){
1784
+ $brokenlinks = array('status'=>'nolinks');
1785
+ }
1786
+ $return['additional_response'] = $brokenlinks;
1787
+ }else{
1788
+ $return = $iwp_mmb_core->blc_get_blinks->blc_update_link($params);
1789
+ }
1790
  if (is_array($return) && array_key_exists('error', $return))
1791
  iwp_mmb_response($return, false);
1792
  else {
1851
  function iwp_mmb_bulk_actions_processor($params){
1852
  global $iwp_mmb_core;
1853
  $iwp_mmb_core->wp_blc_get_blinks();
1854
+ if(!empty($params['additional_params'])){
1855
+ $return['action_response'] = $iwp_mmb_core->blc_get_blinks->blc_bulk_actions($params['action_params']);
1856
+ $brokenlinks = $iwp_mmb_core->blc_get_blinks->blc_get_all_links();
1857
+ if($brokenlinks =='nolinks'){
1858
+ $brokenlinks = array('status'=>'nolinks');
1859
+ }
1860
+ $return['additional_response'] = $brokenlinks;
1861
+ }else{
1862
+ $return = $iwp_mmb_core->blc_get_blinks->blc_bulk_actions($params);
1863
+ }
1864
  if (is_array($return) && array_key_exists('error', $return))
1865
  iwp_mmb_response($return, false);
1866
  else {
1867
  iwp_mmb_response($return, true);
1868
  }
1869
+
1870
  }
1871
  }
1872
 
2208
  if(version_compare(iwp_mmb_get_site_option('iwp_backup_table_version'), '1.1.4', '<')){
2209
  iwp_mmb_change_stausMsg_column_type_backup_status_table();
2210
  }
2211
+
2212
+ $IWP_MMB_BACKUP_PROCESSED_TABLE_VERSION = iwp_mmb_get_site_option('iwp_backup_processed_iterator_version');
2213
+ if (empty($IWP_MMB_BACKUP_PROCESSED_TABLE_VERSION) || $IWP_MMB_BACKUP_PROCESSED_TABLE_VERSION == false ) {
2214
+ iwp_mmb_create_processed_iterator();
2215
+ }
2216
  }
2217
  }
2218
 
2266
  }
2267
  }
2268
 
2269
+ if(!function_exists('iwp_mmb_create_processed_iterator')){
2270
+ //write new backup_status_table changes also in this function.
2271
+ function iwp_mmb_create_processed_iterator(){
2272
+ global $wpdb;
2273
+ if(method_exists($wpdb, 'get_charset_collate')){
2274
+ $charset_collate = $wpdb->get_charset_collate();
2275
+ }
2276
+
2277
+ $table_name = $wpdb->base_prefix . "iwp_processed_iterator";
2278
+
2279
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name){
2280
+ if (!empty($charset_collate)){
2281
+ $cachecollation = $charset_collate;
2282
+ }
2283
+ else{
2284
+ $cachecollation = ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci ';
2285
+ }
2286
+
2287
+ $sql = "
2288
+ CREATE TABLE IF NOT EXISTS $table_name (
2289
+ `id` int(11) NOT NULL AUTO_INCREMENT,
2290
+ `name` longtext,
2291
+ `offset` text,
2292
+ PRIMARY KEY (`id`)
2293
+ )".$cachecollation." ;
2294
+ ";
2295
+
2296
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
2297
+ dbDelta( $sql );
2298
+
2299
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) {
2300
+ update_option( "iwp_backup_processed_iterator_version", '1.0.0');
2301
+ }
2302
+ }
2303
+ }
2304
+ }
2305
+
2306
  if(!function_exists('iwp_mmb_change_collation_backup_status_table')){
2307
  function iwp_mmb_change_collation_backup_status_table(){
2308
  global $wpdb;
2389
  function iwp_mmb_change_stausMsg_column_type_backup_status_table(){
2390
  global $wpdb;
2391
  $table_name = $wpdb->base_prefix . "iwp_backup_status";
2392
+ $sql = "alter table " . $table_name . " change statusMsg statusMsg LONGTEXT;";
2393
  $isDone = $wpdb->query($sql);
2394
  if ($isDone) {
2395
  update_option( "iwp_backup_table_version", '1.1.4');
3131
 
3132
  }
3133
 
3134
+ function iwp_mu_plugin_loader(){
3135
+ global $iwp_mmb_core;
3136
+ $loaderName = 'mu-iwp-client.php';
3137
+ $mustUsePluginDir = rtrim(WPMU_PLUGIN_DIR, '/');
3138
+ $loaderPath = $mustUsePluginDir.'/'.$loaderName;
3139
+
3140
+ if (file_exists($loaderPath)) {
3141
+ return;
3142
+ }
3143
+ try {
3144
+ $iwp_mmb_core->registerMustUse($loaderName, $iwp_mmb_core->buildLoaderContent('iwp-client/init.php'));
3145
+ } catch (Exception $e) {
3146
+ iwp_mmb_response(array('error' => 'Unable to write InfiniteWP Client loader:'.$e->getMessage(), 'error_code' => 'iwp_mu_plugin_loader_failed'), false);
3147
+ }
3148
+ }
3149
+ if(!function_exists('iwp_mmb_is_WPTC')) {
3150
+ function iwp_mmb_is_WPTC() {
3151
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
3152
+ if ( is_plugin_active( 'wp-time-capsule/wp-time-capsule.php' ) ) {
3153
+ return true;
3154
+ } else {
3155
+ return false;
3156
+ }
3157
+ }
3158
+ }
3159
+
3160
  iwp_mmb_set_plugin_priority();
3161
  $iwp_mmb_core = new IWP_MMB_Core();
3162
  $GLOBALS['iwp_mmb_activities_log'] = new IWP_MMB_Activities_log();
3163
  $mmb_core = 1;
3164
  $GLOBALS['iwp_activities_log_post_type'] = 'iwp_log';
3165
 
3166
+ if(isset($_GET['auto_login'])){
3167
+ $GLOBALS['__itsec_core_is_rest_api_request'] = true;
3168
+ $iwp_mmb_core->add_login_action();
3169
+ }
3170
  if (function_exists('register_activation_hook'))
3171
  register_activation_hook( __FILE__ , array( $iwp_mmb_core, 'install' ));
3172
 
installer.class.php CHANGED
@@ -91,8 +91,8 @@ class IWP_MMB_Installer extends IWP_MMB_Core
91
  if (!class_exists('WP_Upgrader'))
92
  include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
93
 
94
- $upgrader_skin = new WP_Upgrader_Skin();
95
- $upgrader_skin->done_header = true;
96
 
97
  $upgrader = new WP_Upgrader($upgrader_skin);
98
  $destination = $type == 'themes' ? WP_CONTENT_DIR . '/themes' : WP_PLUGIN_DIR;
@@ -185,7 +185,6 @@ class IWP_MMB_Installer extends IWP_MMB_Core
185
  }
186
  }
187
  }
188
- ob_clean();
189
  $this->iwp_mmb_maintenance_mode(false);
190
  return $install_info;
191
  }
@@ -294,7 +293,6 @@ class IWP_MMB_Installer extends IWP_MMB_Core
294
  if (!empty($upgrade_translations)) {
295
  $upgrades['translations'] = $this->upgrade_translations($upgrade_translations,$userid);
296
  }
297
- ob_clean();
298
  $this->iwp_mmb_maintenance_mode(false);
299
  return $upgrades;
300
  }
@@ -307,7 +305,8 @@ class IWP_MMB_Installer extends IWP_MMB_Core
307
  global $iwp_activities_log_post_type, $iwp_mmb_activities_log;
308
  $GLOBALS['iwp_client_plugin_translations'] = 1;
309
  include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
310
- $upgrader = new Language_Pack_Upgrader( new Language_Pack_Upgrader_Skin( compact( 'url', 'nonce', 'title', 'context' ) ) );
 
311
  $result = $upgrader->bulk_upgrade();
312
  $upgradeFailed = false;
313
  if (!empty($result)) {
@@ -337,7 +336,6 @@ class IWP_MMB_Installer extends IWP_MMB_Core
337
  ob_start();
338
  $current = (object)$current;
339
 
340
- if (!function_exists('wp_version_check') || !function_exists('get_core_checksums'))
341
  include_once(ABSPATH . '/wp-admin/includes/update.php');
342
 
343
  @wp_version_check();
@@ -388,8 +386,8 @@ class IWP_MMB_Installer extends IWP_MMB_Core
388
  if (version_compare($wp_version, '3.1.9', '>')) {
389
  if (!class_exists('Core_Upgrader'))
390
  include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
391
-
392
- $core = new Core_Upgrader();
393
  $result = $core->upgrade($current_update);
394
  $this->iwp_mmb_maintenance_mode(false);
395
  if (is_wp_error($result)) {
@@ -474,14 +472,12 @@ class IWP_MMB_Installer extends IWP_MMB_Core
474
 
475
 
476
  $update_core = update_core($working_dir, $wp_dir);
477
- ob_end_clean();
478
 
479
  $this->iwp_mmb_maintenance_mode(false);
480
  if (is_wp_error($update_core))
481
  return array(
482
  'error' => $this->iwp_mmb_get_error($update_core), 'error_code' => 'upgrade_core_wp_error'
483
  );
484
- ob_end_flush();
485
  $iwp_mmb_activities_log->iwp_mmb_save_iwp_activities('core', 'update', $iwp_activities_log_post_type, $current, $userid);
486
  return array(
487
  'upgraded' => 'updated'
@@ -516,13 +512,15 @@ class IWP_MMB_Installer extends IWP_MMB_Core
516
  }
517
  }
518
  $return = array();
519
- if (class_exists('Plugin_Upgrader') && class_exists('Bulk_Plugin_Upgrader_Skin')) {
520
 
521
  if (!function_exists('wp_update_plugins'))
522
  include_once(ABSPATH . 'wp-includes/update.php');
 
 
523
 
524
  @wp_update_plugins();
525
- $upgrader = new Plugin_Upgrader(new Bulk_Plugin_Upgrader_Skin(compact('nonce', 'url')));
526
  $result = $upgrader->bulk_upgrade(array_keys($plugins));
527
  $current = $this->iwp_mmb_get_transient('update_plugins');
528
 
@@ -587,7 +585,6 @@ class IWP_MMB_Installer extends IWP_MMB_Core
587
  }
588
  }
589
  }
590
- ob_end_clean();
591
  return array(
592
  'upgraded' => $return
593
  );
@@ -596,7 +593,6 @@ class IWP_MMB_Installer extends IWP_MMB_Core
596
  'error' => 'Upgrade failed.', 'error_code' => 'upgrade_failed_upgrade_plugins'
597
  );
598
  } else {
599
- ob_end_clean();
600
  return array(
601
  'error' => 'WordPress update required first.', 'error_code' => 'upgrade_plugins_wordPress_update_required_first'
602
  );
@@ -620,8 +616,9 @@ class IWP_MMB_Installer extends IWP_MMB_Core
620
  }
621
  }
622
  }
623
- if (class_exists('Theme_Upgrader') && class_exists('Bulk_Theme_Upgrader_Skin')) {
624
- $upgrader = new Theme_Upgrader(new Bulk_Theme_Upgrader_Skin(compact('title', 'nonce', 'url', 'theme')));
 
625
  $result = $upgrader->bulk_upgrade($themes);
626
 
627
  if (!function_exists('wp_update_themes'))
@@ -662,7 +659,6 @@ class IWP_MMB_Installer extends IWP_MMB_Core
662
  'error' => 'Upgrade failed.', 'error_code' => 'upgrade_failed_upgrade_themes'
663
  );
664
  } else {
665
- ob_end_clean();
666
  return array(
667
  'error' => 'WordPress update required first', 'error_code' => 'wordPress_update_required_first_upgrade_themes'
668
  );
@@ -1198,5 +1194,34 @@ class IWP_MMB_Installer extends IWP_MMB_Core
1198
  // Update the download link
1199
  $GLOBALS['ithemes-updater-settings']->flush('forced');
1200
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1201
  }
1202
  ?>
91
  if (!class_exists('WP_Upgrader'))
92
  include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
93
 
94
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/updaterSkin.php';
95
+ $upgrader_skin = new IWP_Updater_TraceableUpdaterSkin;
96
 
97
  $upgrader = new WP_Upgrader($upgrader_skin);
98
  $destination = $type == 'themes' ? WP_CONTENT_DIR . '/themes' : WP_PLUGIN_DIR;
185
  }
186
  }
187
  }
 
188
  $this->iwp_mmb_maintenance_mode(false);
189
  return $install_info;
190
  }
293
  if (!empty($upgrade_translations)) {
294
  $upgrades['translations'] = $this->upgrade_translations($upgrade_translations,$userid);
295
  }
 
296
  $this->iwp_mmb_maintenance_mode(false);
297
  return $upgrades;
298
  }
305
  global $iwp_activities_log_post_type, $iwp_mmb_activities_log;
306
  $GLOBALS['iwp_client_plugin_translations'] = 1;
307
  include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
308
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/updaterSkin.php';
309
+ $upgrader = new Language_Pack_Upgrader( new IWP_Updater_TraceableUpdaterSkin() );
310
  $result = $upgrader->bulk_upgrade();
311
  $upgradeFailed = false;
312
  if (!empty($result)) {
336
  ob_start();
337
  $current = (object)$current;
338
 
 
339
  include_once(ABSPATH . '/wp-admin/includes/update.php');
340
 
341
  @wp_version_check();
386
  if (version_compare($wp_version, '3.1.9', '>')) {
387
  if (!class_exists('Core_Upgrader'))
388
  include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
389
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/updaterSkin.php';
390
+ $core = new Core_Upgrader(new IWP_Updater_TraceableUpdaterSkin());
391
  $result = $core->upgrade($current_update);
392
  $this->iwp_mmb_maintenance_mode(false);
393
  if (is_wp_error($result)) {
472
 
473
 
474
  $update_core = update_core($working_dir, $wp_dir);
 
475
 
476
  $this->iwp_mmb_maintenance_mode(false);
477
  if (is_wp_error($update_core))
478
  return array(
479
  'error' => $this->iwp_mmb_get_error($update_core), 'error_code' => 'upgrade_core_wp_error'
480
  );
 
481
  $iwp_mmb_activities_log->iwp_mmb_save_iwp_activities('core', 'update', $iwp_activities_log_post_type, $current, $userid);
482
  return array(
483
  'upgraded' => 'updated'
512
  }
513
  }
514
  $return = array();
515
+ if (class_exists('Plugin_Upgrader')) {
516
 
517
  if (!function_exists('wp_update_plugins'))
518
  include_once(ABSPATH . 'wp-includes/update.php');
519
+
520
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/updaterSkin.php';
521
 
522
  @wp_update_plugins();
523
+ $upgrader = new Plugin_Upgrader(new IWP_Updater_TraceableUpdaterSkin());
524
  $result = $upgrader->bulk_upgrade(array_keys($plugins));
525
  $current = $this->iwp_mmb_get_transient('update_plugins');
526
 
585
  }
586
  }
587
  }
 
588
  return array(
589
  'upgraded' => $return
590
  );
593
  'error' => 'Upgrade failed.', 'error_code' => 'upgrade_failed_upgrade_plugins'
594
  );
595
  } else {
 
596
  return array(
597
  'error' => 'WordPress update required first.', 'error_code' => 'upgrade_plugins_wordPress_update_required_first'
598
  );
616
  }
617
  }
618
  }
619
+ if (class_exists('Theme_Upgrader')) {
620
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/updaterSkin.php';
621
+ $upgrader = new Theme_Upgrader(new IWP_Updater_TraceableUpdaterSkin());
622
  $result = $upgrader->bulk_upgrade($themes);
623
 
624
  if (!function_exists('wp_update_themes'))
659
  'error' => 'Upgrade failed.', 'error_code' => 'upgrade_failed_upgrade_themes'
660
  );
661
  } else {
 
662
  return array(
663
  'error' => 'WordPress update required first', 'error_code' => 'wordPress_update_required_first_upgrade_themes'
664
  );
1194
  // Update the download link
1195
  $GLOBALS['ithemes-updater-settings']->flush('forced');
1196
  }
1197
+ function get_additional_plugin_updates()
1198
+ {
1199
+
1200
+ $additional_updates = array();
1201
+
1202
+ if (is_plugin_active('woocommerce/woocommerce.php') && $this->has_woocommerce_db_update()) {
1203
+ $additional_updates['woocommerce/woocommerce.php'] = 1;
1204
+ }
1205
+
1206
+ return $additional_updates;
1207
+ }
1208
+
1209
+ function has_woocommerce_db_update()
1210
+ {
1211
+ $current_db_version = get_option('woocommerce_db_version', null);
1212
+ $current_wc_version = get_option('woocommerce_version');
1213
+ if (version_compare($current_wc_version, '3.0.0', '<')) {
1214
+ return true;
1215
+ }
1216
+
1217
+ if (!is_callable('WC_Install::get_db_update_callbacks')) {
1218
+ return false;
1219
+ }
1220
+
1221
+ /** @handled static */
1222
+ $updates = WC_Install::get_db_update_callbacks();
1223
+
1224
+ return !is_null($current_db_version) && version_compare($current_db_version, max(array_keys($updates)), '<');
1225
+ }
1226
  }
1227
  ?>
iwp-file-iterator.php ADDED
@@ -0,0 +1,471 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /************************************************************
3
+ * This plugin was modified by Revmakx *
4
+ * Copyright (c) 2012 Revmakx *
5
+ * www.revmakx.com *
6
+ * *
7
+ ************************************************************/
8
+ /*************************************************************
9
+ *
10
+ * iwp-file-iterator.php
11
+ *
12
+ * Manage Backups
13
+ *
14
+ *
15
+ **************************************************************/
16
+ class IWP_Seek_Iterator{
17
+
18
+ public $iterator_common;
19
+ public $external_obj;
20
+ public $iterator_loop_limit;
21
+ public $path;
22
+ public $type;
23
+ public $query;
24
+ public $processed_files;
25
+ public $app_functions;
26
+ public $is_recursive;
27
+ public $exclude_class_obj;
28
+
29
+ public function __construct($type = false, $iterator_loop_limit = 1000){
30
+ $this->type = $type;
31
+ $this->iterator_loop_limit = $iterator_loop_limit;
32
+ }
33
+
34
+ public function get_seekable_files_obj($path){
35
+
36
+ $temp_path = $path;
37
+
38
+ // IWP_add_abspath($path);
39
+
40
+ $path = is_valid_path($path);
41
+
42
+ if( is_array($path) ) {
43
+ return $path;
44
+ }
45
+
46
+ $this->path = $temp_path;
47
+
48
+ return new DirectoryIterator($path);
49
+ }
50
+
51
+ public function process_iterator($path, $offset = false, $is_recursive = false){
52
+
53
+ $iterator = $this->get_seekable_files_obj($path);
54
+
55
+ if (empty($iterator)) {
56
+ return ;
57
+ }
58
+
59
+ $this->seek = empty($offset) ? array() : explode('-', $offset);
60
+
61
+ $this->counter = 0;
62
+ $this->is_recursive = $is_recursive;
63
+
64
+ if ($is_recursive) {
65
+ $folder_list_result = $this->recursive_iterator($iterator, false);
66
+ } else {
67
+ $folder_list_result = $this->iterator($iterator);
68
+ }
69
+ if(!empty($folder_list_result) && $folder_list_result['break']){
70
+ return $folder_list_result;
71
+ }
72
+ }
73
+
74
+ public function process_file($iterator, $key){
75
+ $folder_list_result = process_file($iterator, $this->is_recursive, $this->path, $key, $this->counter, $this->iterator_loop_limit);
76
+ if(!empty($folder_list_result) && $folder_list_result['break']){
77
+ return $folder_list_result;
78
+ }
79
+ }
80
+
81
+ private function extra_check_query(){
82
+ if (!empty($this->query)) {
83
+ insert_into_current_process($this->query);
84
+ $this->query = '';
85
+ }
86
+ }
87
+
88
+ public function iterator($iterator){
89
+ //Moving satelite into position.
90
+ $this->seek_offset($iterator);
91
+
92
+ while ($iterator->valid()) {
93
+
94
+ $this->counter++;
95
+
96
+ $recursive_path = $iterator->getPathname();
97
+
98
+ //Dont recursive iterator if its a dir or dot
99
+ if ($iterator->isDot() || !$iterator->isReadable() || $iterator->isDir()) {
100
+
101
+ //move to next file
102
+ $iterator->next();
103
+
104
+ continue;
105
+ }
106
+
107
+ $key = $iterator->key();
108
+
109
+ $folder_list_result = $this->process_file( $iterator, $key );
110
+ if(!empty($folder_list_result) && $folder_list_result['break']){
111
+ return $folder_list_result;
112
+ }
113
+
114
+ //move to next file
115
+ $iterator->next();
116
+ }
117
+
118
+ $this->extra_check_query();
119
+ }
120
+
121
+
122
+ public function recursive_iterator($iterator, $key_recursive) {
123
+
124
+ $this->seek_offset($iterator);
125
+
126
+ while ($iterator->valid()) {
127
+
128
+ //Forming current path from iterator
129
+ $recursive_path = $iterator->getPathname();
130
+ $recursive_path = wp_normalize_path($recursive_path);
131
+
132
+ //Mapping keys
133
+ $key = ($key_recursive !== false ) ? $key_recursive . '-' . $iterator->key() : $iterator->key() ;
134
+
135
+ //Do recursive iterator if its a dir
136
+ if (!$iterator->isDot() && $iterator->isReadable() && $iterator->isDir() ) {
137
+
138
+ if (!skip_file($recursive_path)) {//exclude
139
+ //create new object for new dir
140
+ $sub_iterator = new DirectoryIterator($recursive_path);
141
+
142
+ $folder_list_result = $this->recursive_iterator($sub_iterator, $key);
143
+ if(!empty($folder_list_result) && $folder_list_result['break']){
144
+ return $folder_list_result;
145
+ }
146
+
147
+ } else{
148
+ }
149
+
150
+ }
151
+
152
+ //Ignore dots paths
153
+ if(!$iterator->isDot()){
154
+ $folder_list_result = $this->process_file( $iterator, $key );
155
+ if(!empty($folder_list_result) && $folder_list_result['break']){
156
+ return $folder_list_result;
157
+ }
158
+ }
159
+
160
+ //move to next file
161
+ $iterator->next();
162
+ }
163
+
164
+ $this->extra_check_query();
165
+ }
166
+
167
+ private function seek_offset(&$iterator){
168
+
169
+ if(!count($this->seek)){
170
+ return false;
171
+ }
172
+
173
+ //Moving satelite into position.
174
+ $iterator->seek($this->seek[0]);
175
+
176
+ //remove positions from the array after moved satelite
177
+ unset($this->seek[0]);
178
+
179
+ //reset array index
180
+ $this->seek = array_values($this->seek);
181
+
182
+ }
183
+ }
184
+
185
+ function scan_entire_site($v_filedescr_list){
186
+ global $wpdb;
187
+
188
+ $sql = "TRUNCATE TABLE ".$wpdb->base_prefix."iwp_processed_iterator";
189
+ $response = $wpdb->get_results($sql);
190
+ // $dir = get_root_dir_folders();
191
+ // save_dir_list($dir);
192
+ // $dir = get_wp_content_dir_folders();
193
+ // save_dir_list($dir);
194
+ // $dir = get_uploads_dir_folders();
195
+ // save_dir_list($dir);
196
+ // get_db_backup_file();
197
+ // save_dir_list();
198
+ save_deep_dir_list($v_filedescr_list);
199
+ }
200
+
201
+ function get_root_dir_folders(){
202
+ $files_obj = get_files_obj_by_path(ABSPATH);
203
+ return add_dir_list($files_obj);
204
+ }
205
+
206
+ function add_dir_list($files_obj){
207
+ foreach ($files_obj as $key => $file_obj) {
208
+
209
+ $file = $file_obj->getPathname();
210
+
211
+ if (!IWP_is_dir($file)) {
212
+ /// $this->files[] = $file;
213
+ } else {
214
+ // IWP_remove_abspath($file);
215
+ $dir[] = $file;
216
+ }
217
+ }
218
+ return $dir;
219
+ }
220
+
221
+ function get_files_obj_by_path($path, $recursive = false){
222
+
223
+ // IWP_add_abspath($path);
224
+
225
+ $path = is_valid_path($path);
226
+
227
+ if( is_array($path) ) {
228
+ return $path;
229
+ }
230
+
231
+ if($recursive){
232
+ return new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path , RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD);
233
+ }
234
+
235
+ return new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path , RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CATCH_GET_CHILD);
236
+ }
237
+
238
+ function save_dir_list($dir){
239
+ $qry = '';
240
+ $deep_dirs = array(
241
+ ABSPATH
242
+ );
243
+ foreach ($dir as $dir) {
244
+ if (in_array($dir, $deep_dirs)) {
245
+ continue;
246
+ }
247
+
248
+
249
+ $qry .= empty($qry) ? "('" : ",('" ;
250
+ $qry .= wp_normalize_path($dir) . "', '0')";
251
+
252
+ }
253
+ insert_into_iterator_process($qry);
254
+ }
255
+
256
+ function save_deep_dir_list($deep_dirs){
257
+ // $deep_dirs = array(
258
+ // ABSPATH,
259
+ // );
260
+ $qry = '';
261
+ foreach ($deep_dirs as $dir) {
262
+ $qry .= empty($qry) ? "('" : ",('" ;
263
+ $qry .= wp_normalize_path($dir['filename']) . "', '0')";
264
+
265
+ }
266
+
267
+ insert_into_iterator_process($qry);
268
+ }
269
+
270
+ function insert_into_iterator_process($qry){
271
+ global $wpdb;
272
+
273
+ $sql = "insert into ".$wpdb->base_prefix."iwp_processed_iterator ( name, offset ) values $qry";
274
+ $response = $wpdb->get_results($sql);
275
+ }
276
+
277
+ function iwp_iterator(){
278
+ $break = false;
279
+ $deep_dirs_array = array(
280
+
281
+ );
282
+
283
+ while(!$break){
284
+ $dir_meta = get_unfnished_folder();
285
+ $deep_dirs = false;
286
+
287
+ if (empty($dir_meta) || $dir_meta['offset'] === -1) {
288
+ $break = true;
289
+ continue;
290
+ }
291
+
292
+ if( array_search($dir_meta['name'], $deep_dirs_array) !== false ){
293
+ $deep_dirs = true;
294
+ }
295
+
296
+ $file = $dir_meta['name'];
297
+
298
+ if ($deep_dirs === false && skip_file($file) === true) {
299
+ update_iterator($dir_meta['name'], -1);
300
+ continue;
301
+ }
302
+
303
+ if(IWP_is_dir($file)){
304
+ $folder_list_result = iwp_iterate_dir($dir_meta['name'], $dir_meta['offset'], $deep_dirs);
305
+ } else {
306
+ $folder_list_result = iwp_iterate_file($dir_meta['name'], $update_status = true);
307
+ }
308
+ if(!empty($folder_list_result) && $folder_list_result['break']){
309
+ return $folder_list_result;
310
+ }
311
+ }
312
+ }
313
+
314
+ function iwp_iterate_dir($live_path, $offset, $deep_dirs){
315
+
316
+ $is_recursive = ($deep_dirs) ? false : true;
317
+
318
+ try{
319
+ $obj = new IWP_Seek_Iterator();
320
+ $folder_list_result = $obj->process_iterator($live_path, $offset, $is_recursive);
321
+ if(!empty($folder_list_result) && $folder_list_result['break']){
322
+ return $folder_list_result;
323
+ }
324
+ } catch(Exception $e){
325
+
326
+ $exception_msg = $e->getMessage();
327
+
328
+ update_iterator($live_path, 0);
329
+ return;
330
+
331
+ }
332
+ update_iterator($live_path, -1);
333
+ }
334
+
335
+ function iwp_iterate_file($live_file, $update_status = false){
336
+ // initFileSystem();
337
+ // IWP_add_abspath($live_file);
338
+ global $old_next_file_index, $next_file_index,$iwp_v_options,$archive;
339
+ $live_file = wp_normalize_path($live_file);
340
+ $folder_list_result = $archive->fileDetailsExpandManual($live_file, $iwp_v_options, $next_file_index);
341
+ if(!empty($folder_list_result) && $folder_list_result['break']){
342
+ return $folder_list_result;
343
+ }
344
+ if ($update_status) {
345
+ update_iterator($live_file, -1);
346
+ }
347
+
348
+ }
349
+
350
+ function process_file($iterator, $is_recursive, $path, $key, &$counter, $iterator_loop_limit){
351
+ $file = $iterator->getPathname();
352
+
353
+ if (!$iterator->isReadable()) {
354
+ return ;
355
+ }
356
+
357
+ $file = wp_normalize_path($file);
358
+
359
+ if (!$is_recursive && IWP_is_dir($file)){
360
+ return;
361
+ }
362
+
363
+ if (skip_file($file) === true) {
364
+ return;
365
+ }
366
+
367
+ if(IWP_is_dir($file)){
368
+ return;
369
+ }
370
+ $counter++;
371
+ $folder_list_result = iwp_iterate_file($file);
372
+ if(!empty($folder_list_result) && $folder_list_result['break']){
373
+ update_iterator($path, $key);
374
+ $next_file_index = $folder_list_result['loop_count'];
375
+ return $folder_list_result;
376
+ }
377
+
378
+
379
+ }
380
+
381
+ function get_unfnished_folder() {
382
+ global $wpdb;
383
+ $sql = "SELECT * FROM ".$wpdb->base_prefix."iwp_processed_iterator WHERE offset != -1 LIMIT 1";
384
+ $response = $wpdb->get_results($sql, ARRAY_A);
385
+ // IWP_log($response, '--------$response--------');
386
+
387
+ return empty($response) ? false : $response[0];
388
+ }
389
+
390
+ function IWP_is_dir($good_path){
391
+ $good_path = wp_normalize_path($good_path);
392
+
393
+ if (is_dir($good_path)) {
394
+ return true;
395
+ }
396
+
397
+ $ext = pathinfo($good_path, PATHINFO_EXTENSION);
398
+
399
+ if (!empty($ext)) {
400
+ return false;
401
+ }
402
+
403
+ if (is_file($good_path)) {
404
+ return false;
405
+ }
406
+
407
+ return true;
408
+ }
409
+
410
+ function skip_file($file){
411
+ global $iwp_v_options, $archive;
412
+ $exclude_data = $iwp_v_options[IWP_PCLZIP_OPT_IWP_EXCLUDE];
413
+ if(!is_readable($file)){
414
+ return true;
415
+ }
416
+ if( $file == "." && $file == ".." ) {
417
+ return true;
418
+ }
419
+ if ($archive->excludeDirFromScan($file, $exclude_data)) {
420
+ return true;
421
+ }
422
+
423
+ return false;
424
+ }
425
+
426
+ function update_iterator($table, $offset) {
427
+ upsert(array(
428
+ 'name' => $table,
429
+ 'offset' => $offset,
430
+ ));
431
+ }
432
+
433
+ function upsert($data) {
434
+ global $wpdb;
435
+ $this_table_name = 'iwp_processed_iterator'; //in case, if we are changing table name.
436
+ $exists = $wpdb->get_row("SELECT id FROM " . $wpdb->base_prefix. $this_table_name . " WHERE name = '". $data['name']."'" );
437
+
438
+ if ($exists) {
439
+ $result = $wpdb->update($wpdb->base_prefix . $this_table_name, $data, array( 'name' => $data['name']));
440
+ }else{
441
+ $result = $wpdb->insert($wpdb->base_prefix . $this_table_name, $data);
442
+ }
443
+ }
444
+
445
+ function is_valid_path($path){
446
+ $default = array();
447
+
448
+ if (empty($path)) {
449
+ return $default;
450
+ }
451
+
452
+ $path = rtrim($path, '/');
453
+
454
+ $path = wp_normalize_path($path);
455
+
456
+ if (empty($path)) {
457
+ return $default;
458
+ }
459
+
460
+ $basename = basename($path);
461
+
462
+ if ($basename == '..' || $basename == '.') {
463
+ return $default;
464
+ }
465
+
466
+ if (!is_readable($path)) {
467
+ return $default;
468
+ }
469
+
470
+ return $path;
471
+ }
lib/Dropbox/OAuth/Consumer/Curl.php CHANGED
@@ -107,6 +107,8 @@ class IWP_Dropbox_OAuth_Consumer_Curl extends IWP_Dropbox_OAuth_Consumer_Consume
107
  */
108
  if (isset($additional['api_v2']) && !empty($request['postfields'])) {
109
  $request['postfields'] = json_encode($request['postfields']);
 
 
110
  }
111
 
112
  if ($method == 'GET' && $this->outFile) { // GET
107
  */
108
  if (isset($additional['api_v2']) && !empty($request['postfields'])) {
109
  $request['postfields'] = json_encode($request['postfields']);
110
+ }else{
111
+ $request['postfields'] = json_encode(null);
112
  }
113
 
114
  if ($method == 'GET' && $this->outFile) { // GET
lib/Dropbox2/OAuth/Consumer/Curl.php CHANGED
@@ -105,14 +105,21 @@ class Dropbox_Curl extends Dropbox_ConsumerAbstract
105
  }
106
  }
107
 
108
- if (isset($request['headers'])) $options[CURLOPT_HTTPHEADER] = $request['headers'];
109
 
110
  /*
111
  Add check to see if it's an API v2 call if so then json encode the contents. This is so that it is backwards compatible with API v1 endpoints.
112
  */
113
  if (isset($additional['api_v2']) && !empty($request['postfields'])) {
114
  $request['postfields'] = json_encode($request['postfields']);
 
 
 
 
 
 
115
  }
 
116
 
117
  if ($method == 'GET' && $this->outFile) { // GET
118
  $options[CURLOPT_RETURNTRANSFER] = false;
@@ -120,11 +127,6 @@ class Dropbox_Curl extends Dropbox_ConsumerAbstract
120
  $options[CURLOPT_FILE] = $this->outFile;
121
  $options[CURLOPT_BINARYTRANSFER] = true;
122
  $options[CURLOPT_FAILONERROR] = true;
123
- /*
124
- Not sure if this is used, keeping it here for backwards compatibility at the moment.
125
- With API v2 the headers are set in the $request they are set above if they are set.
126
- */
127
- if (isset($additional['headers'])) $options[CURLOPT_HTTPHEADER] = $additional['headers'];
128
  $this->outFile = null;
129
  } elseif ($method == 'POST' && $this->outFile) { // POST
130
  $options[CURLOPT_POST] = true;
@@ -165,6 +167,7 @@ class Dropbox_Curl extends Dropbox_ConsumerAbstract
165
  // Parse the response if it is a string
166
  if (is_string($response)) {
167
  $response = $this->parse($response);
 
168
  }
169
 
170
  // Set the last response
@@ -221,8 +224,8 @@ class Dropbox_Curl extends Dropbox_ConsumerAbstract
221
  case 415:
222
  throw new Dropbox_UnsupportedMediaTypeException($message, 415);
223
  case 401:
224
- //401 means oauth token is expired continue to manually handle the exception depending on the situation
225
- continue;
226
  case 409:
227
  //409 in API V2 every error will return with a 409 to find out what the error is the error description should be checked.
228
  throw new Dropbox_Exception($message, $code);
105
  }
106
  }
107
 
108
+ // if (isset($request['headers'])) $options[CURLOPT_HTTPHEADER] = $request['headers'];
109
 
110
  /*
111
  Add check to see if it's an API v2 call if so then json encode the contents. This is so that it is backwards compatible with API v1 endpoints.
112
  */
113
  if (isset($additional['api_v2']) && !empty($request['postfields'])) {
114
  $request['postfields'] = json_encode($request['postfields']);
115
+ }else{
116
+ // $key = array_search('Content-Type: application/json', $request['headers']);
117
+ // if (false !== $key) unset($request['headers'][$key]);// some users facing more delay.
118
+ if ($call == '2/users/get_space_usage') {
119
+ $request['postfields'] = json_encode(null);
120
+ }
121
  }
122
+ if (isset($request['headers']) && !empty($request['headers'])) $options[CURLOPT_HTTPHEADER] = $request['headers'];
123
 
124
  if ($method == 'GET' && $this->outFile) { // GET
125
  $options[CURLOPT_RETURNTRANSFER] = false;
127
  $options[CURLOPT_FILE] = $this->outFile;
128
  $options[CURLOPT_BINARYTRANSFER] = true;
129
  $options[CURLOPT_FAILONERROR] = true;
 
 
 
 
 
130
  $this->outFile = null;
131
  } elseif ($method == 'POST' && $this->outFile) { // POST
132
  $options[CURLOPT_POST] = true;
167
  // Parse the response if it is a string
168
  if (is_string($response)) {
169
  $response = $this->parse($response);
170
+ $response['code'] = (!empty($response['code'])) ? $response['code'] : $getinfo['http_code'];
171
  }
172
 
173
  // Set the last response
224
  case 415:
225
  throw new Dropbox_UnsupportedMediaTypeException($message, 415);
226
  case 401:
227
+ //401 means oauth token is expired continue to manually handle the exception depending on the situation
228
+ break;
229
  case 409:
230
  //409 in API V2 every error will return with a 409 to find out what the error is the error description should be checked.
231
  throw new Dropbox_Exception($message, $code);
lib/S3.php CHANGED
@@ -1010,6 +1010,23 @@ class IWP_MMB_S3
1010
  return (isset($rest->body[0]) && (string)$rest->body[0] !== '') ? (string)$rest->body[0] : 'US';
1011
  }
1012
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1013
 
1014
  /**
1015
  * Set object or bucket Access Control Policy
1010
  return (isset($rest->body[0]) && (string)$rest->body[0] !== '') ? (string)$rest->body[0] : 'US';
1011
  }
1012
 
1013
+ public static function getBucketLocationNew($bucket)
1014
+ {
1015
+
1016
+ $rest = new IWP_MMB_S3Request('GET', $bucket, '', self::$endpoint, self::$use_dns_bucket_name);
1017
+ $rest->setParameter('location', null);
1018
+ $rest = $rest->getResponse();
1019
+ if ($rest->error === false && $rest->code !== 200)
1020
+ $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
1021
+ if ($rest->error !== false)
1022
+ {
1023
+ self::__triggerError(sprintf("IWP_MMB_S3::getBucketLocation({$bucket}): [%s] %s",
1024
+ $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
1025
+ return false;
1026
+ }
1027
+ return (isset($rest->body[0]) && (string)$rest->body[0] !== '') ? (string)$rest->body[0] : '';
1028
+ }
1029
+
1030
 
1031
  /**
1032
  * Set object or bucket Access Control Policy
lib/amazon/s3IWPBackup.php CHANGED
@@ -120,7 +120,13 @@ class IWP_MMB_S3_MULTICALL extends IWP_MMB_Backup_Multicall
120
  $as3_directory = $this->site_name;
121
  }
122
  }
123
-
 
 
 
 
 
 
124
  if($s3_retrace_count<=3){
125
  try{
126
 
@@ -159,13 +165,16 @@ class IWP_MMB_S3_MULTICALL extends IWP_MMB_Backup_Multicall
159
  if((iwp_mmb_get_file_size($backup_file) <= 5*1024*1024)){
160
  //new starts
161
  echo "<br>small backup so single upload<br>";
162
-
163
- $s3->putObject(array(
164
  'Bucket' => $as3_bucket,
165
  'SourceFile' => $backup_file,
166
  'Key' => $as3_file,
167
  'ACL' => 'private'
168
- ));
 
 
 
 
169
  $current_file_num += 1;
170
  $resArray = array (
171
  'status' => "completed",
@@ -214,12 +223,15 @@ class IWP_MMB_S3_MULTICALL extends IWP_MMB_Backup_Multicall
214
  echo "iwpmsg initiating multiCall upload";
215
  //get the uploadID
216
  $filename = $backup_file;
217
- $result = $s3->createMultipartUpload(array(
218
- 'Bucket' => $as3_bucket,
219
- 'Key' => $as3_file,
220
- 'ACL' => 'private',
221
-
222
- ));
 
 
 
223
 
224
  $parts = array();
225
  $uploadId = $result['UploadId'];
@@ -425,6 +437,12 @@ class IWP_MMB_S3_MULTICALL extends IWP_MMB_Backup_Multicall
425
  }
426
  extract($args);
427
  $temp = '';
 
 
 
 
 
 
428
  try{
429
  if (empty($as3_bucket_region)) {
430
  $s3 = S3Client::factory(array(
@@ -486,7 +504,12 @@ class IWP_MMB_S3_MULTICALL extends IWP_MMB_Backup_Multicall
486
  require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon/autoload.php');
487
  }
488
  extract($args);
489
-
 
 
 
 
 
490
  if(!is_array($backup_file))
491
  {
492
  $temp_backup_file = $backup_file;
@@ -552,11 +575,28 @@ class IWP_MMB_S3_MULTICALL extends IWP_MMB_Backup_Multicall
552
  }
553
 
554
  function postUploadS3Verification($backup_file, $destFile, $type = "", $as3_bucket = "", $as3_access_key = "", $as3_secure_key = "", $as3_bucket_region = "", $size1, $size2, $return_size = false){
555
- $s3 = S3Client::factory(array(
556
- 'key'=>$as3_access_key,
557
- 'secret'=>trim(str_replace(' ', '+', $as3_secure_key)),
558
- 'region' => $as3_bucket_region,
559
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
560
  if(!$s3){
561
  return false;
562
  }
@@ -655,12 +695,17 @@ class IWP_MMB_S3_SINGLECALL extends IWP_MMB_Backup_Multicall
655
 
656
  if(filesize($backup_file) <5*1024*1024){
657
  try{
658
- $s3->putObject(array(
659
- 'Bucket' => $as3_bucket,
660
- 'SourceFile' => $backup_file,
661
- 'Key' => $as3_file,
662
- 'ACL' => 'private'
663
- ));
 
 
 
 
 
664
  return true;
665
  }catch (Exception $e){
666
  $err = $e->getMessage();
@@ -775,6 +820,12 @@ class IWP_MMB_S3_SINGLECALL extends IWP_MMB_Backup_Multicall
775
  $as3_directory = $this->site_name;
776
  }
777
  }
 
 
 
 
 
 
778
  try{
779
  if (empty($as3_bucket_region)) {
780
  $s3 = S3Client::factory(array(
@@ -811,4 +862,46 @@ class IWP_MMB_S3_SINGLECALL extends IWP_MMB_Backup_Multicall
811
  return false;
812
  }
813
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
814
  }
120
  $as3_directory = $this->site_name;
121
  }
122
  }
123
+ if (empty($as3_bucket_region)) {
124
+ require_once($GLOBALS['iwp_mmb_plugin_dir']."/lib/S3.php");
125
+ $s3 = new IWP_MMB_S3(trim($as3_access_key), trim(str_replace(' ', '+', $as3_secure_key)), false, 's3.amazonaws.com');
126
+ $as3_bucket_region = $s3->getBucketLocationNew($as3_bucket);
127
+ if (empty($as3_bucket_region) && false !== $as3_bucket_region) $as3_bucket_region = null;
128
+ }
129
+
130
  if($s3_retrace_count<=3){
131
  try{
132
 
165
  if((iwp_mmb_get_file_size($backup_file) <= 5*1024*1024)){
166
  //new starts
167
  echo "<br>small backup so single upload<br>";
168
+ $putArray = array(
 
169
  'Bucket' => $as3_bucket,
170
  'SourceFile' => $backup_file,
171
  'Key' => $as3_file,
172
  'ACL' => 'private'
173
+ );
174
+ if ($server_side_encryption == 1) {
175
+ $putArray['ServerSideEncryption']='AES256';
176
+ }
177
+ $s3->putObject($putArray);
178
  $current_file_num += 1;
179
  $resArray = array (
180
  'status' => "completed",
223
  echo "iwpmsg initiating multiCall upload";
224
  //get the uploadID
225
  $filename = $backup_file;
226
+ $putArray = array(
227
+ 'Bucket' => $as3_bucket,
228
+ 'Key' => $as3_file,
229
+ 'ACL' => 'private'
230
+ );
231
+ if ($server_side_encryption == 1) {
232
+ $putArray['ServerSideEncryption']='AES256';
233
+ }
234
+ $result = $s3->createMultipartUpload($putArray);
235
 
236
  $parts = array();
237
  $uploadId = $result['UploadId'];
437
  }
438
  extract($args);
439
  $temp = '';
440
+ if (empty($as3_bucket_region)) {
441
+ require_once($GLOBALS['iwp_mmb_plugin_dir']."/lib/S3.php");
442
+ $s3 = new IWP_MMB_S3(trim($as3_access_key), trim(str_replace(' ', '+', $as3_secure_key)), false, 's3.amazonaws.com');
443
+ $as3_bucket_region = $s3->getBucketLocationNew($as3_bucket);
444
+ if (empty($as3_bucket_region) && false !== $as3_bucket_region) $as3_bucket_region = null;
445
+ }
446
  try{
447
  if (empty($as3_bucket_region)) {
448
  $s3 = S3Client::factory(array(
504
  require_once($GLOBALS['iwp_mmb_plugin_dir'].'/lib/amazon/autoload.php');
505
  }
506
  extract($args);
507
+ if (empty($as3_bucket_region)) {
508
+ require_once($GLOBALS['iwp_mmb_plugin_dir']."/lib/S3.php");
509
+ $s3 = new IWP_MMB_S3(trim($as3_access_key), trim(str_replace(' ', '+', $as3_secure_key)), false, 's3.amazonaws.com');
510
+ $as3_bucket_region = $s3->getBucketLocationNew($as3_bucket);
511
+ if (empty($as3_bucket_region) && false !== $as3_bucket_region) $as3_bucket_region = null;
512
+ }
513
  if(!is_array($backup_file))
514
  {
515
  $temp_backup_file = $backup_file;
575
  }
576
 
577
  function postUploadS3Verification($backup_file, $destFile, $type = "", $as3_bucket = "", $as3_access_key = "", $as3_secure_key = "", $as3_bucket_region = "", $size1, $size2, $return_size = false){
578
+ if (empty($as3_bucket_region)) {
579
+ require_once($GLOBALS['iwp_mmb_plugin_dir']."/lib/S3.php");
580
+ $s3 = new IWP_MMB_S3(trim($as3_access_key), trim(str_replace(' ', '+', $as3_secure_key)), false, 's3.amazonaws.com');
581
+ $as3_bucket_region = $s3->getBucketLocationNew($as3_bucket);
582
+ if (empty($as3_bucket_region) && false !== $as3_bucket_region) $as3_bucket_region = null;
583
+ }
584
+ if (empty($as3_bucket_region)) {
585
+ $s3 = S3Client::factory(array(
586
+ 'key' => trim($as3_access_key),
587
+ 'secret' => trim(str_replace(' ', '+', $as3_secure_key)),
588
+ 'region' => $as3_bucket_region,
589
+ 'ssl.certificate_authority' => false
590
+ ));
591
+ }else{
592
+ $s3 = S3Client::factory(array(
593
+ 'key' => trim($as3_access_key),
594
+ 'secret' => trim(str_replace(' ', '+', $as3_secure_key)),
595
+ 'region' => $as3_bucket_region,
596
+ 'signature' => 'v4',
597
+ 'ssl.certificate_authority' => false
598
+ ));
599
+ }
600
  if(!$s3){
601
  return false;
602
  }
695
 
696
  if(filesize($backup_file) <5*1024*1024){
697
  try{
698
+
699
+ $putArray = array(
700
+ 'Bucket' => $as3_bucket,
701
+ 'SourceFile' => $backup_file,
702
+ 'Key' => $as3_file,
703
+ 'ACL' => 'private'
704
+ );
705
+ if ($server_side_encryption == 1) {
706
+ $putArray['ServerSideEncryption']='AES256';
707
+ }
708
+ $s3->putObject($putArray);
709
  return true;
710
  }catch (Exception $e){
711
  $err = $e->getMessage();
820
  $as3_directory = $this->site_name;
821
  }
822
  }
823
+ if (empty($as3_bucket_region)) {
824
+ require_once($GLOBALS['iwp_mmb_plugin_dir']."/lib/S3.php");
825
+ $s3 = new IWP_MMB_S3(trim($as3_access_key), trim(str_replace(' ', '+', $as3_secure_key)), false, 's3.amazonaws.com');
826
+ $as3_bucket_region = $s3->getBucketLocationNew($as3_bucket);
827
+ if (empty($as3_bucket_region) && false !== $as3_bucket_region) $as3_bucket_region = null;
828
+ }
829
  try{
830
  if (empty($as3_bucket_region)) {
831
  $s3 = S3Client::factory(array(
862
  return false;
863
  }
864
  }
865
+ }
866
+
867
+ function iwpRepositoryAmazons3($args){
868
+ require_once($GLOBALS['iwp_mmb_plugin_dir'] . '/lib/amazon/autoload.php');
869
+
870
+ extract($args);
871
+ try{
872
+ if (empty($as3_bucket_region)) {
873
+ require_once($GLOBALS['iwp_mmb_plugin_dir']."/lib/S3.php");
874
+ $s3 = new IWP_MMB_S3(trim($as3_access_key), trim(str_replace(' ', '+', $as3_secure_key)), false, 's3.amazonaws.com');
875
+ $as3_bucket_region = $s3->getBucketLocationNew($as3_bucket);
876
+ if (empty($as3_bucket_region) && false !== $as3_bucket_region) $as3_bucket_region = null;
877
+ }
878
+ if (empty($as3_bucket_region)) {
879
+ $s3 = S3Client::factory(array(
880
+ 'key' => trim($as3_access_key),
881
+ 'secret' => trim(str_replace(' ', '+', $as3_secure_key)),
882
+ 'region' => $as3_bucket_region,
883
+ 'ssl.certificate_authority' => false
884
+ ));
885
+ }else{
886
+ $s3 = S3Client::factory(array(
887
+ 'key' => trim($as3_access_key),
888
+ 'secret' => trim(str_replace(' ', '+', $as3_secure_key)),
889
+ 'region' => $as3_bucket_region,
890
+ 'signature' => 'v4',
891
+ 'ssl.certificate_authority' => false
892
+ ));
893
+ }
894
+
895
+ $objects = $s3->getIterator('ListObjects', array(
896
+ 'Bucket' => $as3_bucket,
897
+ ));
898
+ foreach ($objects as $object){
899
+ echo $s3->getObjectUrl($as3_bucket,$object['Key']);
900
+ break;
901
+ }
902
+ return array('status' => 'success');
903
+ }
904
+ catch (Exception $e){
905
+ return array('error' => $e->getMessage(), 'error_code' => 's3_cloud_backup_verification_failed');
906
+ }
907
  }
pclzip.class.php CHANGED
@@ -438,7 +438,8 @@ endif;
438
  function getFileList($p_filelist) //own function to get the folder and files List
439
  {
440
  $startTime = microtime(true);
441
-
 
442
  $v_result=1;
443
 
444
  // ----- Reset the error handler
@@ -576,7 +577,7 @@ endif;
576
  // ----- Expand the filelist (expand directories)
577
  $startTImeForlist = microtime(true);
578
  $prevFileList = array();
579
- $next_file_index = 0;
580
  $complete_folder_list = array();
581
  $historyID = $v_options[IWP_PCLZIP_OPT_HISTORY_ID];
582
  if($historyID)
@@ -612,17 +613,19 @@ endif;
612
  //if(empty($complete_folder_list))
613
  if(true)
614
  {
615
- global $total_count;
616
  $old_next_file_index = $next_file_index;
617
 
618
-
 
619
  /* $folder_list_result = $this->getFolderListManual('F:\\wamp\\www\\plugin_for_bugs/wp-dark/', $v_options, $next_file_index);
620
  if(!empty($folder_list_result) && $folder_list_result['break']){
621
  $next_file_index = $folder_list_result['loop_count'];
622
  } */
623
 
624
  //first am getting the number of directories and its list
625
- foreach($v_filedescr_list as $value)
 
626
  {
627
  $folder_list = array();
628
  if(is_dir($value['filename']))
@@ -644,6 +647,17 @@ endif;
644
  }
645
  }
646
  }
 
 
 
 
 
 
 
 
 
 
 
647
  }
648
 
649
  if(empty($folder_list_result)){
@@ -791,9 +805,10 @@ endif;
791
  global $total_count;
792
  $total_count++;
793
  $this_result = false;
794
- if($total_count >= $next_file_index){
 
795
  $to_be_expanded_array = array( 0 => array( 'filename' => $absPath ) );
796
- $v_result = $this->privFileDescrExpand($to_be_expanded_array, $v_options, "getFileList");
797
  if($v_result == 1 && !empty($to_be_expanded_array)){
798
  foreach($to_be_expanded_array as $key => $value){
799
  $this_result = save_in_iwp_files_db(0, $value);
@@ -805,7 +820,7 @@ endif;
805
  }
806
  $total_FL_count++;
807
  }
808
- }
809
  return $this_result;
810
  }
811
 
@@ -820,6 +835,7 @@ endif;
820
  }
821
  return false;
822
  }
 
823
 
824
  //---------------------------------------------------------------------------------
825
  // --------------------------------------------------------------------------------
@@ -3199,6 +3215,7 @@ endif;
3199
  if ( ($p_filedescr_list[$j]['type'] != 'virtual_file')
3200
  && (!file_exists($p_filedescr_list[$j]['filename']))) {
3201
  IWPPclZip::privErrorLog(IWP_PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
 
3202
  return IWPPclZip::errorCode();
3203
  }
3204
 
438
  function getFileList($p_filelist) //own function to get the folder and files List
439
  {
440
  $startTime = microtime(true);
441
+ global $next_file_index, $total_count;
442
+
443
  $v_result=1;
444
 
445
  // ----- Reset the error handler
577
  // ----- Expand the filelist (expand directories)
578
  $startTImeForlist = microtime(true);
579
  $prevFileList = array();
580
+ $next_file_index =0;
581
  $complete_folder_list = array();
582
  $historyID = $v_options[IWP_PCLZIP_OPT_HISTORY_ID];
583
  if($historyID)
613
  //if(empty($complete_folder_list))
614
  if(true)
615
  {
616
+ global $old_next_file_index;
617
  $old_next_file_index = $next_file_index;
618
 
619
+ global $iwp_v_options;
620
+ $iwp_v_options = $v_options;
621
  /* $folder_list_result = $this->getFolderListManual('F:\\wamp\\www\\plugin_for_bugs/wp-dark/', $v_options, $next_file_index);
622
  if(!empty($folder_list_result) && $folder_list_result['break']){
623
  $next_file_index = $folder_list_result['loop_count'];
624
  } */
625
 
626
  //first am getting the number of directories and its list
627
+ /* //old method file iterator
628
+ foreach($v_filedescr_list as $value)
629
  {
630
  $folder_list = array();
631
  if(is_dir($value['filename']))
647
  }
648
  }
649
  }
650
+ */
651
+ include_once $GLOBALS['iwp_mmb_plugin_dir'].'/iwp-file-iterator.php';
652
+ if ($next_file_index == 0) {
653
+ # code...
654
+ scan_entire_site($v_filedescr_list);
655
+ }
656
+ $folder_list_result = iwp_iterator();
657
+ if(!empty($folder_list_result) && $folder_list_result['break']){
658
+ $next_file_index = $folder_list_result['loop_count'];
659
+ }
660
+
661
  }
662
 
663
  if(empty($folder_list_result)){
805
  global $total_count;
806
  $total_count++;
807
  $this_result = false;
808
+
809
+ //if($total_count >= $next_file_index){
810
  $to_be_expanded_array = array( 0 => array( 'filename' => $absPath ) );
811
+ $v_result = $this->privFileDescrExpand($to_be_expanded_array, $v_options, "getFileList");
812
  if($v_result == 1 && !empty($to_be_expanded_array)){
813
  foreach($to_be_expanded_array as $key => $value){
814
  $this_result = save_in_iwp_files_db(0, $value);
820
  }
821
  $total_FL_count++;
822
  }
823
+ //}
824
  return $this_result;
825
  }
826
 
835
  }
836
  return false;
837
  }
838
+
839
 
840
  //---------------------------------------------------------------------------------
841
  // --------------------------------------------------------------------------------
3215
  if ( ($p_filedescr_list[$j]['type'] != 'virtual_file')
3216
  && (!file_exists($p_filedescr_list[$j]['filename']))) {
3217
  IWPPclZip::privErrorLog(IWP_PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
3218
+ continue;
3219
  return IWPPclZip::errorCode();
3220
  }
3221
 
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.1
5
- Tested up to: 5.0.3
6
  Stable tag: trunk
7
 
8
  Install this plugin on unlimited sites and manage them all from a central dashboard.
@@ -47,6 +47,50 @@ Credits: [Vladimir Prelovac](http://prelovac.com/vladimir) for his worker plugin
47
  5. One-click updates
48
 
49
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  = 1.8.6 - Feb 11th 2019 =
51
  * Fix: Duo security plugin on WordPress site breaks the IWP client plugin connection while performing open admin action.
52
  * Fix: Backup is retried when it failed with error "Failed to connect to content.dropboxapi.com port 443: Connection timed out. and Could not resolve host: api.dropboxapi.com.".
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.1
5
+ Tested up to: 5.2.2
6
  Stable tag: trunk
7
 
8
  Install this plugin on unlimited sites and manage them all from a central dashboard.
47
  5. One-click updates
48
 
49
  == Changelog ==
50
+ = 1.9.4.1 - July 25th 2019 =
51
+ * Feature: Full Support for Multisite Installations.
52
+ * Feature: SSH support - You can use your SSH keys to backup your WordPress sites.
53
+ * Feature: You can Encrypt your DB backups using the Phoenix backup method.
54
+ * Feature: Server Side encryption for Amazon S3 backups is enabled for all three backup mechanisms.
55
+ * Feature: Notifications for WooCommerce DB updates.
56
+ * Improvement: IWP client plugin will add a must-use plugin to WordPress sites.
57
+ * Improvement: Support for WPTC backups to include on IWP Client reports.
58
+ * Improvement: File Iterator process is improved in the Multicall backup method.
59
+ * Improvement: You can now manage the users on your Multisites.
60
+ * Improvement: The activation key will not be shown to subscriber users.
61
+ * Improvement: Enabled support for Autoptimize plugin.
62
+ * Improvement: "site_map.xml" and "virtual files" are excluded from the backup while backing up the site using the single and multicall method.
63
+ * Improvement: Phoenix backup failure retry count decreased as the backup is running for a prolonged time.
64
+ * Improvement: By default, backup logs will be created for the multicall backup method.
65
+ * Improvement: Backup debug chart added.
66
+ * Improvement: Added an option to exclude Database tables on backup.
67
+ * Improvement: Google drive and Dropbox will respect the multicall loop break time.
68
+ * Improvement: Curl version, SSL version are added in server info.
69
+ * Improvement: Response header will now have the correct HTTP version.
70
+ * Improvement: MySQL dump backup process improved.
71
+ * Improvement: Support for manage users, manage comments, broken link checker, iThemes, Wordfence and Malware Scanner addons for v3.
72
+ * Fix: Duo security plugin on WordPress site breaks the IWP client plugin connection while performing open admin action.
73
+ * Fix: Backup is retried when it failed with error "Failed to connect to content.dropboxapi.com port 443: Connection timed out. and Could not resolve host: api.dropboxapi.com.".
74
+ * Fix: Plugin updates count showing in plugin menu on WP admin page while hide plugin updates setting is enabled on InfiniteWP admin panel via Client Plugin Branding.
75
+ * Fix: Phoenix backup SFTP or FTP not using the custom port.
76
+ * Fix: FTP SSL not working on Phoenix backup.
77
+ * Fix: Ithemes security data is not included in the client reports.
78
+ * Fix: Backups failed with error "Database backup failed. Try to enable MySQL dump on your server.".
79
+ * Fix: Table "w1.wp_iwp_backup_status" doesnot exist , IWP will now create the table automatically instead of throwing an error.
80
+ * Fix: Removed FTP credentials from error messages.
81
+ * Fix: Few PHP 7.2 warnings are fixed.
82
+ * Fix: Backups taken with Phoenix method are not erased from Google drive Storage while deleting the backups from via admin panel.
83
+ * Fix: "*Number of Backups to Keep*" setting was not working for the Phoenix method backups.
84
+ * Fix: Backup entries are not removed on WordPress database table wp_iwp_backup_status while deleting the backup schedules with phoenix method.
85
+ * Fix: S3 verification failed: File may be corrupted.
86
+ * Fix: Broken link checker update link and un-dismiss options throw fatal error.
87
+ * Fix: Submitted input out of alignment: got [4194300] expected [4194304].
88
+ * Fix: Dropbox account/info did not return HTTP 200. (only for specific users).
89
+ * Fix: Open admin not working if iThemes hide backend option enabled.
90
+ * Fix: PHP Fatal error occurred: Uncaught Guzzle\Service\Exception\ValidationException: Validation errors: [Key] is a required string.
91
+ * Fix: If dump fails, the dump .sql file will be deleted.
92
+ * Fix: IWP Client Plugin error, Curl 18 and Curl 92 on updates and install option due to Cloud Flare setup on WordPress sites.
93
+
94
  = 1.8.6 - Feb 11th 2019 =
95
  * Fix: Duo security plugin on WordPress site breaks the IWP client plugin connection while performing open admin action.
96
  * Fix: Backup is retried when it failed with error "Failed to connect to content.dropboxapi.com port 443: Connection timed out. and Could not resolve host: api.dropboxapi.com.".
stats.class.php CHANGED
@@ -299,6 +299,15 @@ class IWP_MMB_Stats extends IWP_MMB_Core
299
  $upgrades = false;
300
  }
301
  }
 
 
 
 
 
 
 
 
 
302
 
303
  return $stats;
304
  }
@@ -440,7 +449,7 @@ class IWP_MMB_Stats extends IWP_MMB_Core
440
  }
441
 
442
  $stats['client_version'] = IWP_MMB_CLIENT_VERSION;
443
- if (!empty($rs)) {
444
  $stats['client_new_version'] = $r->new_version;
445
  $stats['client_new_package'] = $r->package;
446
  }
@@ -452,6 +461,8 @@ class IWP_MMB_Stats extends IWP_MMB_Core
452
  $stats['network_install'] = $this->network_admin_install;
453
  $stats['use_cookie'] = $use_cookie;
454
  $stats['maintenance_mode'] = get_option('iwp_mmb_maintenance_mode');
 
 
455
 
456
  if ( !function_exists('get_filesystem_method') )
457
  include_once(ABSPATH . 'wp-admin/includes/file.php');
@@ -461,7 +472,17 @@ class IWP_MMB_Stats extends IWP_MMB_Core
461
  $stats['maintenance'] = true;
462
  }
463
  $stats['writable'] = $this->is_server_writable();
464
-
 
 
 
 
 
 
 
 
 
 
465
  return $stats;
466
  }
467
 
@@ -582,10 +603,12 @@ class IWP_MMB_Stats extends IWP_MMB_Core
582
  $stats['site_title'] = get_bloginfo('name');
583
  $stats['site_tagline'] = get_bloginfo('description');
584
  $stats['site_home'] = get_option('home');
 
585
  $stats['admin_url'] = $wp_admin_URL;
586
  $stats['wp_multisite'] = $this->iwp_mmb_multisite;
587
  $stats['network_install'] = $this->network_admin_install;
588
  $stats['use_cookie'] = $use_cookie;
 
589
 
590
 
591
  if ($this->iwp_mmb_multisite) {
@@ -600,9 +623,49 @@ class IWP_MMB_Stats extends IWP_MMB_Core
600
  include_once(ABSPATH . 'wp-admin/includes/file.php');
601
 
602
  $stats['writable'] = $this->is_server_writable();
603
-
 
 
604
  return $stats;
605
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
606
 
607
  public static function set_hit_count($fix_count = false)
608
  {
299
  $upgrades = false;
300
  }
301
  }
302
+
303
+ if (isset($options['additional_updates']) && $options['additional_updates']) {
304
+ $this->get_installer_instance();
305
+ $upgrades = $this->installer_instance->get_additional_plugin_updates();
306
+ if (!empty($upgrades)) {
307
+ $stats['additional_updates'] = $upgrades;
308
+ $upgrades = false;
309
+ }
310
+ }
311
 
312
  return $stats;
313
  }
449
  }
450
 
451
  $stats['client_version'] = IWP_MMB_CLIENT_VERSION;
452
+ if (!empty($r)) {
453
  $stats['client_new_version'] = $r->new_version;
454
  $stats['client_new_package'] = $r->package;
455
  }
461
  $stats['network_install'] = $this->network_admin_install;
462
  $stats['use_cookie'] = $use_cookie;
463
  $stats['maintenance_mode'] = get_option('iwp_mmb_maintenance_mode');
464
+ $stats['site_home'] = get_option('home');
465
+ $stats['site_url'] = get_option('siteurl');
466
 
467
  if ( !function_exists('get_filesystem_method') )
468
  include_once(ABSPATH . 'wp-admin/includes/file.php');
472
  $stats['maintenance'] = true;
473
  }
474
  $stats['writable'] = $this->is_server_writable();
475
+ if ($this->iwp_mmb_multisite) {
476
+ $details = get_blog_details($this->iwp_mmb_multisite);
477
+ if (isset($details->site_id)) {
478
+ $details = get_blog_details($details->site_id);
479
+ if (isset($details->siteurl))
480
+ $stats['network_parent'] = $details->siteurl;
481
+ }
482
+ }
483
+ if ($this->iwp_mmb_multisite) {
484
+ $stats = array_merge($stats, $this->get_multisite_stats());
485
+ }
486
  return $stats;
487
  }
488
 
603
  $stats['site_title'] = get_bloginfo('name');
604
  $stats['site_tagline'] = get_bloginfo('description');
605
  $stats['site_home'] = get_option('home');
606
+ $stats['site_url'] = get_option('siteurl');
607
  $stats['admin_url'] = $wp_admin_URL;
608
  $stats['wp_multisite'] = $this->iwp_mmb_multisite;
609
  $stats['network_install'] = $this->network_admin_install;
610
  $stats['use_cookie'] = $use_cookie;
611
+
612
 
613
 
614
  if ($this->iwp_mmb_multisite) {
623
  include_once(ABSPATH . 'wp-admin/includes/file.php');
624
 
625
  $stats['writable'] = $this->is_server_writable();
626
+ if ($this->iwp_mmb_multisite) {
627
+ $stats = array_merge($stats, $this->get_multisite_stats());
628
+ }
629
  return $stats;
630
  }
631
+
632
+ public function get_multisite_stats()
633
+ {
634
+ /** @var $wpdb wpdb */
635
+ global $current_user, $wpdb;
636
+ $user_blogs = get_blogs_of_user($current_user->ID);
637
+ $network_blogs = (array)$wpdb->get_results("select `blog_id`, `site_id` from `{$wpdb->blogs}`");
638
+ $mainBlogId = defined('BLOG_ID_CURRENT_SITE') ? BLOG_ID_CURRENT_SITE : false;
639
+
640
+ if (/*$this->network_admin_install != '1' || !is_super_admin($current_user->ID)||*/ empty($network_blogs)) {
641
+ return array();
642
+ }
643
+
644
+ $stats = array('network_blogs' => array(), 'other_blogs' => array());
645
+ foreach ($network_blogs as $details) {
646
+ if (($mainBlogId !== false && $details->blog_id == $mainBlogId) || ($mainBlogId === false && $details->site_id == $details->blog_id)) {
647
+ continue;
648
+ } else {
649
+ $data = get_blog_details($details->blog_id);
650
+ if (in_array($details->blog_id, array_keys($user_blogs))) {
651
+ $stats['network_blogs'][] = $data->siteurl;
652
+ } else {
653
+ $user = get_users(
654
+ array(
655
+ 'blog_id' => $details->blog_id,
656
+ 'number' => 1,
657
+ )
658
+ );
659
+ if (!empty($user)) {
660
+ $stats['other_blogs'][$data->siteurl] = $user[0]->user_login;
661
+ }
662
+ }
663
+ }
664
+ }
665
+
666
+ return $stats;
667
+ }
668
+
669
 
670
  public static function set_hit_count($fix_count = false)
671
  {
updaterSkin.php ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * This plugin was modified by Revmakx
4
+ * Copyright (c) 2012 Revmakx
5
+ * www.revmakx.com
6
+ *
7
+
8
+ /**
9
+ * Taken from WordPress's automatic updater skin, which was added in version 3.7.
10
+ *
11
+ * @see Automatic_Upgrader_Skin
12
+ */
13
+ class IWP_Updater_TraceableUpdaterSkin
14
+ {
15
+
16
+ public $options = array(
17
+ 'url' => '',
18
+ 'nonce' => '',
19
+ 'title' => '',
20
+ 'context' => false,
21
+ );
22
+
23
+ public $upgrader;
24
+
25
+ public $result;
26
+
27
+ public $done_header = false;
28
+
29
+ protected $messages = array();
30
+
31
+ private $startedImplicit = false;
32
+
33
+ public function request_filesystem_credentials($error = false, $context = '', $allow_relaxed_file_ownership = false)
34
+ {
35
+ if ($error instanceof WP_Error) {
36
+ return array('error' => $error->get_error_message(), 'error_code' => 'upgrade_plugins_wp_error');
37
+ }
38
+
39
+ if ($context) {
40
+ $this->options['context'] = $context;
41
+ }
42
+
43
+ // file.php and template.php are documented to be required; the rest are there to match
44
+ // the list in the MMB_Installer class.
45
+ require_once ABSPATH.'wp-admin/includes/file.php';
46
+ require_once ABSPATH.'wp-admin/includes/plugin.php';
47
+ require_once ABSPATH.'wp-admin/includes/theme.php';
48
+ require_once ABSPATH.'wp-admin/includes/misc.php';
49
+ require_once ABSPATH.'wp-admin/includes/template.php';
50
+ require_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php';
51
+ // This will output a credentials form in event of failure; we don't want that, so just hide with a buffer.
52
+ ob_start();
53
+ /** @handled function */
54
+ $result = request_filesystem_credentials('', '', $error, $context, null, $allow_relaxed_file_ownership);
55
+ ob_end_clean();
56
+
57
+ return $result;
58
+ }
59
+
60
+ public function get_upgrade_messages()
61
+ {
62
+ return $this->messages;
63
+ }
64
+
65
+ /**
66
+ * @param string|array|WP_Error $data
67
+ */
68
+ public function feedback($data)
69
+ {
70
+ if (!$this->startedImplicit) {
71
+ $this->startedImplicit = true;
72
+ @ob_implicit_flush(true);
73
+ }
74
+
75
+ echo ' ';
76
+ @ob_flush();
77
+
78
+ if (is_wp_error($data)) {
79
+ $string = $data->get_error_message();
80
+ } else {
81
+ if (is_array($data)) {
82
+ return;
83
+ } else {
84
+ $string = $data;
85
+ }
86
+ }
87
+
88
+ if (!empty($this->upgrader->strings[$string])) {
89
+ $string = $this->upgrader->strings[$string];
90
+ }
91
+
92
+ if (strpos($string, '%') !== false) {
93
+ $args = func_get_args();
94
+ $args = array_splice($args, 1);
95
+ if (!empty($args)) {
96
+ $string = vsprintf($string, $args);
97
+ }
98
+ }
99
+
100
+ $string = trim($string);
101
+
102
+ /** @handled function */
103
+ // Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output.
104
+ $string = wp_kses($string, array(
105
+ 'a' => array(
106
+ 'href' => true
107
+ ),
108
+ 'br' => true,
109
+ 'em' => true,
110
+ 'strong' => true,
111
+ ));
112
+
113
+ if (empty($string)) {
114
+ return;
115
+ }
116
+
117
+ $this->messages[] = array(
118
+ 'message' => $string,
119
+ 'key' => $data,
120
+ 'args' => isset($args) ? $args : array(),
121
+ );
122
+ }
123
+
124
+ public function header()
125
+ {
126
+ ob_start();
127
+ }
128
+
129
+ public function footer()
130
+ {
131
+ $output = ob_get_contents();
132
+ if (!empty($output)) {
133
+ $this->feedback($output);
134
+ }
135
+ ob_end_clean();
136
+ }
137
+
138
+ public function bulk_header()
139
+ {
140
+ }
141
+
142
+ public function bulk_footer()
143
+ {
144
+ }
145
+
146
+ public function before()
147
+ {
148
+ }
149
+
150
+ public function after()
151
+ {
152
+ }
153
+
154
+ // Below was taken from WP_Upgrader_Skin, so we don't autoload it and cause trouble.
155
+ public function decrement_update_count()
156
+ {
157
+ }
158
+
159
+ public function error($errors)
160
+ {
161
+ if (is_string($errors)) {
162
+ $this->feedback($errors);
163
+
164
+ return;
165
+ }
166
+
167
+ if (!$errors instanceof WP_Error || !$errors->get_error_code()) {
168
+ return;
169
+ }
170
+
171
+ foreach ($errors->get_error_messages() as $message) {
172
+ if ($errors->get_error_data() && is_string($errors->get_error_data())) {
173
+ $this->feedback($message.' '.esc_html(strip_tags($errors->get_error_data())));
174
+ } else {
175
+ $this->feedback($message);
176
+ }
177
+ }
178
+ }
179
+
180
+ /**
181
+ * @param WP_Upgrader $upgrader
182
+ */
183
+ public function set_upgrader($upgrader)
184
+ {
185
+ if (is_object($upgrader)) {
186
+ $this->upgrader = $upgrader;
187
+ }
188
+ $this->add_strings();
189
+ }
190
+
191
+ public function add_strings()
192
+ {
193
+ }
194
+
195
+ public function set_result($result)
196
+ {
197
+ $this->result = $result;
198
+ }
199
+ }