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