Version Description
- New Features: Scheduled backups are now available.
- New Feature: Allow only a single backup to be run at a time.
- New feature: Automated cleanup feature will perform work file and log cleanup once per day.
- Update: User experience improvements to backup.
- Update: Logging enhancements.
- Fix: Add support for windows MySql database exports. Windows backups always worked but did not take advantage of MySql export tools like other platforms.
Download this release
Release Info
Developer | cssimmon |
Plugin | Backup and Restore WordPress – WPBackItUp Backup Plugin |
Version | 1.9 |
Comparing to | |
See all releases |
Code changes from version 1.8 to 1.9
- js/wpbackitup_admin.js +116 -3
- languages/en-GB.po +333 -333
- lib/includes/backup.php +189 -231
- lib/includes/class-backup.php +311 -13
- lib/includes/class-filesystem.php +34 -15
- lib/includes/class-logger.php +36 -10
- lib/includes/class-scheduler.php +156 -0
- lib/includes/class-sql.php +27 -11
- lib/includes/class-wpbackitup-admin.php +131 -13
- lib/includes/class-zip.php +1 -1
- lib/includes/restore.php +690 -690
- license.txt +673 -673
- readme.txt +33 -19
- views/backup.php +139 -65
- views/test.php +22 -0
- wp-backitup.php +90 -79
js/wpbackitup_admin.js
CHANGED
@@ -11,6 +11,24 @@
|
|
11 |
//Add View Log Click event to backup page
|
12 |
add_viewlog_onclick();
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
//binds to onchange event of the upload file input field
|
15 |
$('#wpbackitup-zip').bind('change', function() {
|
16 |
|
@@ -146,20 +164,26 @@
|
|
146 |
|
147 |
} else { //Error
|
148 |
console.log("JSON error response received.");
|
149 |
-
status_message='An unexpected error has occurred: ' + jsonData.message;
|
150 |
|
151 |
-
|
|
|
|
|
|
|
|
|
152 |
|
153 |
var unexpected_error= $('.backup-unexpected-error');
|
154 |
unexpected_error.html(status_message);
|
155 |
unexpected_error.addClass("isa_error");
|
156 |
unexpected_error.show();
|
157 |
|
|
|
|
|
|
|
158 |
}
|
159 |
|
160 |
} else { //Didnt get any json back
|
161 |
console.log("NON JSON response received.");
|
162 |
-
status_message='An unexpected error has occurred: ' + textStatus + ':' + JSON.stringify(errorThrown);
|
163 |
|
164 |
$('.backup-status').hide();
|
165 |
|
@@ -167,10 +191,70 @@
|
|
167 |
unexpected_error.html(status_message);
|
168 |
unexpected_error.addClass("isa_error");
|
169 |
unexpected_error.show();
|
|
|
|
|
170 |
}
|
171 |
});
|
172 |
}
|
173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
/*BACKUP button click */
|
175 |
$(".backup-button").click(function(e) {
|
176 |
e.preventDefault();
|
@@ -501,4 +585,33 @@
|
|
501 |
return namespace + '_' + action;
|
502 |
}
|
503 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
504 |
})(jQuery);
|
11 |
//Add View Log Click event to backup page
|
12 |
add_viewlog_onclick();
|
13 |
|
14 |
+
|
15 |
+
$( "#scheduled-backups-accordian" ).click(function() {
|
16 |
+
|
17 |
+
scheduled_backups=$("#scheduled-backups");
|
18 |
+
scheduled_backups_button = $( "#scheduled-backups-accordian");
|
19 |
+
|
20 |
+
if ($(this).is(".fa-angle-double-down")){
|
21 |
+
scheduled_backups.fadeIn( "slow" )
|
22 |
+
scheduled_backups_button.toggleClass( "fa-angle-double-down", false);
|
23 |
+
scheduled_backups_button.toggleClass( "fa-angle-double-up", true);
|
24 |
+
} else{
|
25 |
+
scheduled_backups_button.toggleClass( "fa-angle-double-down", true);
|
26 |
+
scheduled_backups_button.toggleClass( "fa-angle-double-up", false);
|
27 |
+
scheduled_backups.fadeOut( "slow" )
|
28 |
+
}
|
29 |
+
|
30 |
+
});
|
31 |
+
|
32 |
//binds to onchange event of the upload file input field
|
33 |
$('#wpbackitup-zip').bind('change', function() {
|
34 |
|
164 |
|
165 |
} else { //Error
|
166 |
console.log("JSON error response received.");
|
|
|
167 |
|
168 |
+
var msg="process unavailable";
|
169 |
+
if (jsonData.message !== undefined){
|
170 |
+
msg= jsonData.message;
|
171 |
+
}
|
172 |
+
status_message='An unexpected error has occurred during process: ' + msg;
|
173 |
|
174 |
var unexpected_error= $('.backup-unexpected-error');
|
175 |
unexpected_error.html(status_message);
|
176 |
unexpected_error.addClass("isa_error");
|
177 |
unexpected_error.show();
|
178 |
|
179 |
+
//fade out all of the spinners
|
180 |
+
$('.status-icon').fadeOut(200);
|
181 |
+
|
182 |
}
|
183 |
|
184 |
} else { //Didnt get any json back
|
185 |
console.log("NON JSON response received.");
|
186 |
+
status_message='An unexpected error has occurred during process: ' + textStatus + ':' + JSON.stringify(errorThrown);
|
187 |
|
188 |
$('.backup-status').hide();
|
189 |
|
191 |
unexpected_error.html(status_message);
|
192 |
unexpected_error.addClass("isa_error");
|
193 |
unexpected_error.show();
|
194 |
+
|
195 |
+
$('.status-icon').fadeOut(200);
|
196 |
}
|
197 |
});
|
198 |
}
|
199 |
|
200 |
+
//Save Schedule CLICK
|
201 |
+
$("#wp-backitup-notification-close").click(function() {
|
202 |
+
dismiss_message();
|
203 |
+
});
|
204 |
+
//Save Schedule CLICK
|
205 |
+
$("#wp-backitup-save_schedule_form").submit(function() {
|
206 |
+
|
207 |
+
var formData = new FormData();
|
208 |
+
formData.append('action', get_action_name('update-schedule'));
|
209 |
+
formData.append('_wpnonce', $('#wp-backitup_nonce-update-schedule').val());
|
210 |
+
formData.append('_wp_http_referer',$("[name='_wp_http_referer']").val());
|
211 |
+
|
212 |
+
var days_selected = [];
|
213 |
+
$.each($("input[name='dow']:checked"), function(){
|
214 |
+
days_selected.push($(this).val());
|
215 |
+
});
|
216 |
+
|
217 |
+
formData.append('days_selected', days_selected);
|
218 |
+
|
219 |
+
jQuery.ajax({
|
220 |
+
url: ajaxurl,
|
221 |
+
type: 'POST',
|
222 |
+
cache: false,
|
223 |
+
contentType: false,
|
224 |
+
processData: false,
|
225 |
+
dataType: "json",
|
226 |
+
data: formData,
|
227 |
+
|
228 |
+
success: function(data, textStatus, jqXHR){
|
229 |
+
response=data.message;
|
230 |
+
console.log("Success:" + response);
|
231 |
+
|
232 |
+
//Turn on the notification bar
|
233 |
+
switch (response)
|
234 |
+
{
|
235 |
+
case 'success':
|
236 |
+
show_success_message("Scheduled has been saved.");
|
237 |
+
break;
|
238 |
+
case 'error':
|
239 |
+
show_error_message("Scheduled was not saved.");
|
240 |
+
break;
|
241 |
+
default:
|
242 |
+
|
243 |
+
}
|
244 |
+
|
245 |
+
},
|
246 |
+
error: function(jqXHR, textStatus, errorThrown){
|
247 |
+
console.log("Error." + textStatus +':' +errorThrown);
|
248 |
+
},
|
249 |
+
complete: function(jqXHR, textStatus){
|
250 |
+
console.log("Complete");
|
251 |
+
}
|
252 |
+
});
|
253 |
+
|
254 |
+
return false;
|
255 |
+
|
256 |
+
});
|
257 |
+
|
258 |
/*BACKUP button click */
|
259 |
$(".backup-button").click(function(e) {
|
260 |
e.preventDefault();
|
585 |
return namespace + '_' + action;
|
586 |
}
|
587 |
|
588 |
+
function dismiss_message(){
|
589 |
+
notification_bar = $( "#wp-backitup-notification-parent");
|
590 |
+
notification_bar.fadeOut( "slow" )
|
591 |
+
}
|
592 |
+
|
593 |
+
function show_success_message(message){
|
594 |
+
notification_bar_message = $( "#wp-backitup-notification-message");
|
595 |
+
notification_bar_message.html("<p>" + message + "</p>");
|
596 |
+
|
597 |
+
notification_bar = $( "#wp-backitup-notification-parent");
|
598 |
+
notification_bar.toggleClass("error",false);
|
599 |
+
notification_bar.toggleClass("updated",true);
|
600 |
+
|
601 |
+
notification_bar.show();
|
602 |
+
$('html, body').animate({ scrollTop: 0 }, 'slow');
|
603 |
+
}
|
604 |
+
|
605 |
+
function show_error_message(message){
|
606 |
+
notification_bar_message = $( "#wp-backitup-notification-message");
|
607 |
+
notification_bar_message.html("<p>" + message + "</p>");
|
608 |
+
|
609 |
+
notification_bar = $( "#wp-backitup-notification-parent");
|
610 |
+
notification_bar.toggleClass("updated",false);
|
611 |
+
notification_bar.toggleClass("error",true);
|
612 |
+
|
613 |
+
notification_bar.show();
|
614 |
+
$('html, body').animate({ scrollTop: 0 }, 'slow');
|
615 |
+
}
|
616 |
+
|
617 |
})(jQuery);
|
languages/en-GB.po
CHANGED
@@ -1,333 +1,333 @@
|
|
1 |
-
msgid ""
|
2 |
-
msgstr ""
|
3 |
-
"Project-Id-Version: WP Backitup\n"
|
4 |
-
"POT-Creation-Date: 2013-09-07 19:24-0000\n"
|
5 |
-
"PO-Revision-Date: 2013-09-07 19:24-0000\n"
|
6 |
-
"Last-Translator: John Peden <john.peden@britishcouncil.org>\n"
|
7 |
-
"Language-Team: John Peden Ltd <mail@johncpeden.com>\n"
|
8 |
-
"Language: English\n"
|
9 |
-
"MIME-Version: 1.0\n"
|
10 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
-
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"X-Generator: Poedit 1.5.4\n"
|
13 |
-
"X-Poedit-KeywordsList: _e;__\n"
|
14 |
-
"X-Poedit-Basepath: .\n"
|
15 |
-
"X-Poedit-SourceCharset: UTF-8\n"
|
16 |
-
"X-Poedit-SearchPath-0: .\n"
|
17 |
-
"X-Poedit-SearchPath-1: ..\n"
|
18 |
-
|
19 |
-
#: ../index.php:312
|
20 |
-
msgid "Manage"
|
21 |
-
msgstr ""
|
22 |
-
|
23 |
-
#: ../views/options.php:6 ../views/options.php:8
|
24 |
-
msgid "Backup"
|
25 |
-
msgstr ""
|
26 |
-
|
27 |
-
#: ../views/options.php:7
|
28 |
-
msgid "Create a backup file of this site's content and settings"
|
29 |
-
msgstr ""
|
30 |
-
|
31 |
-
#: ../views/options.php:9
|
32 |
-
msgid "Download"
|
33 |
-
msgstr ""
|
34 |
-
|
35 |
-
#: ../views/options.php:15 ../views/options.php:30
|
36 |
-
msgid "Restore"
|
37 |
-
msgstr ""
|
38 |
-
|
39 |
-
#: ../views/options.php:17
|
40 |
-
msgid ""
|
41 |
-
"Restore a WP Backitup zip file and overwrite this site's content, themes, "
|
42 |
-
"plugins, uploads and settings"
|
43 |
-
msgstr ""
|
44 |
-
|
45 |
-
#: ../views/options.php:22
|
46 |
-
msgid "The maximum filesize you can upload is "
|
47 |
-
msgstr ""
|
48 |
-
|
49 |
-
#: ../views/options.php:35
|
50 |
-
msgid "Status"
|
51 |
-
msgstr ""
|
52 |
-
|
53 |
-
#: ../views/options.php:40
|
54 |
-
msgid "Nothing to report"
|
55 |
-
msgstr ""
|
56 |
-
|
57 |
-
#: ../views/options.php:45
|
58 |
-
msgid "Preparing to backup"
|
59 |
-
msgstr ""
|
60 |
-
|
61 |
-
#: ../views/options.php:45 ../views/options.php:46 ../views/options.php:47
|
62 |
-
#: ../views/options.php:48 ../views/options.php:49 ../views/options.php:50
|
63 |
-
#: ../views/options.php:67 ../views/options.php:68 ../views/options.php:69
|
64 |
-
#: ../views/options.php:70 ../views/options.php:71 ../views/options.php:72
|
65 |
-
#: ../views/options.php:73
|
66 |
-
msgid "Done"
|
67 |
-
msgstr ""
|
68 |
-
|
69 |
-
#: ../views/options.php:45 ../views/options.php:46 ../views/options.php:47
|
70 |
-
#: ../views/options.php:48 ../views/options.php:49 ../views/options.php:50
|
71 |
-
#: ../views/options.php:67 ../views/options.php:68 ../views/options.php:69
|
72 |
-
#: ../views/options.php:70 ../views/options.php:71 ../views/options.php:72
|
73 |
-
#: ../views/options.php:73
|
74 |
-
msgid "Failed"
|
75 |
-
msgstr ""
|
76 |
-
|
77 |
-
#: ../views/options.php:46
|
78 |
-
msgid "Backing-up database"
|
79 |
-
msgstr ""
|
80 |
-
|
81 |
-
#: ../views/options.php:47
|
82 |
-
msgid "Backing-up /wp-content/"
|
83 |
-
msgstr ""
|
84 |
-
|
85 |
-
#: ../views/options.php:48
|
86 |
-
msgid "Creating backup information file"
|
87 |
-
msgstr ""
|
88 |
-
|
89 |
-
#: ../views/options.php:49
|
90 |
-
msgid "Zipping backup directory"
|
91 |
-
msgstr ""
|
92 |
-
|
93 |
-
#: ../views/options.php:50 ../views/options.php:73
|
94 |
-
msgid "Cleaning up"
|
95 |
-
msgstr ""
|
96 |
-
|
97 |
-
#: ../views/options.php:51
|
98 |
-
msgid ""
|
99 |
-
"Backup file created successfully. You can download your backup file using "
|
100 |
-
"the link above"
|
101 |
-
msgstr ""
|
102 |
-
|
103 |
-
#: ../views/options.php:56
|
104 |
-
msgid ""
|
105 |
-
"Error: Unable to create new directory for backup. Please check your CHMOD "
|
106 |
-
"settings of your wp-backitup plugin directory"
|
107 |
-
msgstr ""
|
108 |
-
|
109 |
-
#: ../views/options.php:57
|
110 |
-
msgid ""
|
111 |
-
"Error: Cannot create backup directory. Please check the CHMOD settings of "
|
112 |
-
"your wp-backitup plugin directory"
|
113 |
-
msgstr ""
|
114 |
-
|
115 |
-
#: ../views/options.php:58
|
116 |
-
msgid "Error: Unable to backup your files. Please try again"
|
117 |
-
msgstr ""
|
118 |
-
|
119 |
-
#: ../views/options.php:59
|
120 |
-
msgid "Error: Unable to backup your database. Please try again"
|
121 |
-
msgstr ""
|
122 |
-
|
123 |
-
#: ../views/options.php:60
|
124 |
-
msgid ""
|
125 |
-
"Error: Your database was accesible but a dump could not be created. Please "
|
126 |
-
"contact support by clicking the link on the right, stating your web host "
|
127 |
-
"when you submit the form."
|
128 |
-
msgstr ""
|
129 |
-
|
130 |
-
#: ../views/options.php:61
|
131 |
-
msgid "Error: Unable to create site information file. Please try again"
|
132 |
-
msgstr ""
|
133 |
-
|
134 |
-
#: ../views/options.php:62
|
135 |
-
msgid "Warning: Unable to cleanup your backup directory"
|
136 |
-
msgstr ""
|
137 |
-
|
138 |
-
#: ../views/options.php:67
|
139 |
-
msgid "Uploading restoration zip"
|
140 |
-
msgstr ""
|
141 |
-
|
142 |
-
#: ../views/options.php:68
|
143 |
-
msgid "Unzipping"
|
144 |
-
msgstr ""
|
145 |
-
|
146 |
-
#: ../views/options.php:69
|
147 |
-
msgid "Validating restoration zip"
|
148 |
-
msgstr ""
|
149 |
-
|
150 |
-
#: ../views/options.php:70
|
151 |
-
msgid "Setting checkpoint"
|
152 |
-
msgstr ""
|
153 |
-
|
154 |
-
#: ../views/options.php:71
|
155 |
-
msgid "Importing database"
|
156 |
-
msgstr ""
|
157 |
-
|
158 |
-
#: ../views/options.php:72
|
159 |
-
msgid "Importing /wp-content/ directory"
|
160 |
-
msgstr ""
|
161 |
-
|
162 |
-
#: ../views/options.php:74
|
163 |
-
msgid ""
|
164 |
-
"Restoration completed successfully. Please refresh the page and login to the "
|
165 |
-
"site again (with your current username and password)"
|
166 |
-
msgstr ""
|
167 |
-
|
168 |
-
#: ../views/options.php:79
|
169 |
-
msgid "Error: No file selected"
|
170 |
-
msgstr ""
|
171 |
-
|
172 |
-
#: ../views/options.php:80
|
173 |
-
msgid "Error: Your file could not be uploaded"
|
174 |
-
msgstr ""
|
175 |
-
|
176 |
-
#: ../views/options.php:81
|
177 |
-
msgid "Error: Your restoration file could not be unzipped"
|
178 |
-
msgstr ""
|
179 |
-
|
180 |
-
#: ../views/options.php:82
|
181 |
-
msgid ""
|
182 |
-
"Error: Your zip file appears to be invalid. Please ensure you chose the "
|
183 |
-
"correct zip file"
|
184 |
-
msgstr ""
|
185 |
-
|
186 |
-
#: ../views/options.php:83
|
187 |
-
msgid "Error: Cannot create restore point"
|
188 |
-
msgstr ""
|
189 |
-
|
190 |
-
#: ../views/options.php:84
|
191 |
-
msgid "Error: Unable to connect to your database"
|
192 |
-
msgstr ""
|
193 |
-
|
194 |
-
#: ../views/options.php:85
|
195 |
-
msgid "Error: Unable to get current site URL from database. Please try again"
|
196 |
-
msgstr ""
|
197 |
-
|
198 |
-
#: ../views/options.php:86
|
199 |
-
msgid "Error: Unable to get current home URL from database. Please try again"
|
200 |
-
msgstr ""
|
201 |
-
|
202 |
-
#: ../views/options.php:87
|
203 |
-
msgid "Error: Unable to get current user ID from database. Please try again"
|
204 |
-
msgstr ""
|
205 |
-
|
206 |
-
#: ../views/options.php:88
|
207 |
-
msgid ""
|
208 |
-
"Error: Unable to get current user password from database. Please try again"
|
209 |
-
msgstr ""
|
210 |
-
|
211 |
-
#: ../views/options.php:89
|
212 |
-
msgid "Error: Unable to get current user email from database. Please try again"
|
213 |
-
msgstr ""
|
214 |
-
|
215 |
-
#: ../views/options.php:90
|
216 |
-
msgid ""
|
217 |
-
"Error: Unable to get import your database. This may require importing the "
|
218 |
-
"file manually"
|
219 |
-
msgstr ""
|
220 |
-
|
221 |
-
#: ../views/options.php:91
|
222 |
-
msgid ""
|
223 |
-
"Error: Unable to update your current site URL value. This may require "
|
224 |
-
"importing the file manually"
|
225 |
-
msgstr ""
|
226 |
-
|
227 |
-
#: ../views/options.php:92
|
228 |
-
msgid ""
|
229 |
-
"Error: Unable to update your current home URL value. This may require "
|
230 |
-
"importing the file manually"
|
231 |
-
msgstr ""
|
232 |
-
|
233 |
-
#: ../views/options.php:93
|
234 |
-
msgid ""
|
235 |
-
"Error: Unable to update your user information. This may require importing "
|
236 |
-
"the file manually"
|
237 |
-
msgstr ""
|
238 |
-
|
239 |
-
#: ../views/options.php:94
|
240 |
-
msgid "Error: Warning: Database not detected in import file"
|
241 |
-
msgstr ""
|
242 |
-
|
243 |
-
#: ../views/options.php:95
|
244 |
-
msgid ""
|
245 |
-
"Error: Unable to remove existing wp-content directory for import. Please "
|
246 |
-
"check your CHMOD settings in /wp-content/"
|
247 |
-
msgstr ""
|
248 |
-
|
249 |
-
#: ../views/options.php:96
|
250 |
-
msgid ""
|
251 |
-
"Error: Unable to create new wp-content directory for import. Please check "
|
252 |
-
"your CHMOD settings in /wp-content/"
|
253 |
-
msgstr ""
|
254 |
-
|
255 |
-
#: ../views/options.php:97
|
256 |
-
msgid "Error: Unable to import wp-content. Please try again"
|
257 |
-
msgstr ""
|
258 |
-
|
259 |
-
#: ../views/options.php:98
|
260 |
-
msgid "Warning: Unable to cleanup import directory"
|
261 |
-
msgstr ""
|
262 |
-
|
263 |
-
#: ../views/options.php:109
|
264 |
-
msgid "License Key"
|
265 |
-
msgstr ""
|
266 |
-
|
267 |
-
#: ../views/options.php:113
|
268 |
-
msgid "Pro features and auto-updates enabled"
|
269 |
-
msgstr ""
|
270 |
-
|
271 |
-
#: ../views/options.php:115
|
272 |
-
msgid "Activate auto-restore and auto-updates by entering your license key"
|
273 |
-
msgstr ""
|
274 |
-
|
275 |
-
#: ../views/options.php:120
|
276 |
-
msgid "Active"
|
277 |
-
msgstr ""
|
278 |
-
|
279 |
-
#: ../views/options.php:121
|
280 |
-
msgid "Update"
|
281 |
-
msgstr ""
|
282 |
-
|
283 |
-
#: ../views/options.php:123
|
284 |
-
msgid "Inactive"
|
285 |
-
msgstr ""
|
286 |
-
|
287 |
-
#: ../views/options.php:124
|
288 |
-
msgid "Activate"
|
289 |
-
msgstr ""
|
290 |
-
|
291 |
-
#: ../views/options.php:125
|
292 |
-
msgid "Purchase a license key"
|
293 |
-
msgstr ""
|
294 |
-
|
295 |
-
#: ../views/options.php:132
|
296 |
-
msgid "WP Backitup support system"
|
297 |
-
msgstr ""
|
298 |
-
|
299 |
-
#: ../views/options.php:135
|
300 |
-
msgid "support system"
|
301 |
-
msgstr ""
|
302 |
-
|
303 |
-
#: ../views/options.php:138
|
304 |
-
msgid "Need Help?"
|
305 |
-
msgstr ""
|
306 |
-
|
307 |
-
#: ../views/options.php:139
|
308 |
-
msgid "Access the"
|
309 |
-
msgstr ""
|
310 |
-
|
311 |
-
#: ../views/options.php:143
|
312 |
-
msgid "Spread the Word"
|
313 |
-
msgstr ""
|
314 |
-
|
315 |
-
#: ../views/options.php:144
|
316 |
-
msgid "Rate WP Backitup"
|
317 |
-
msgstr ""
|
318 |
-
|
319 |
-
#: ../views/options.php:149
|
320 |
-
msgid "Enable"
|
321 |
-
msgstr ""
|
322 |
-
|
323 |
-
#: ../views/options.php:150
|
324 |
-
msgid "Disable"
|
325 |
-
msgstr ""
|
326 |
-
|
327 |
-
#: ../views/options.php:151
|
328 |
-
msgid "Help to improve Easy Webtrends by enabling"
|
329 |
-
msgstr ""
|
330 |
-
|
331 |
-
#: ../views/options.php:152
|
332 |
-
msgid "Save"
|
333 |
-
msgstr ""
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: WP Backitup\n"
|
4 |
+
"POT-Creation-Date: 2013-09-07 19:24-0000\n"
|
5 |
+
"PO-Revision-Date: 2013-09-07 19:24-0000\n"
|
6 |
+
"Last-Translator: John Peden <john.peden@britishcouncil.org>\n"
|
7 |
+
"Language-Team: John Peden Ltd <mail@johncpeden.com>\n"
|
8 |
+
"Language: English\n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"X-Generator: Poedit 1.5.4\n"
|
13 |
+
"X-Poedit-KeywordsList: _e;__\n"
|
14 |
+
"X-Poedit-Basepath: .\n"
|
15 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
16 |
+
"X-Poedit-SearchPath-0: .\n"
|
17 |
+
"X-Poedit-SearchPath-1: ..\n"
|
18 |
+
|
19 |
+
#: ../index.php:312
|
20 |
+
msgid "Manage"
|
21 |
+
msgstr ""
|
22 |
+
|
23 |
+
#: ../views/options.php:6 ../views/options.php:8
|
24 |
+
msgid "Backup"
|
25 |
+
msgstr ""
|
26 |
+
|
27 |
+
#: ../views/options.php:7
|
28 |
+
msgid "Create a backup file of this site's content and settings"
|
29 |
+
msgstr ""
|
30 |
+
|
31 |
+
#: ../views/options.php:9
|
32 |
+
msgid "Download"
|
33 |
+
msgstr ""
|
34 |
+
|
35 |
+
#: ../views/options.php:15 ../views/options.php:30
|
36 |
+
msgid "Restore"
|
37 |
+
msgstr ""
|
38 |
+
|
39 |
+
#: ../views/options.php:17
|
40 |
+
msgid ""
|
41 |
+
"Restore a WP Backitup zip file and overwrite this site's content, themes, "
|
42 |
+
"plugins, uploads and settings"
|
43 |
+
msgstr ""
|
44 |
+
|
45 |
+
#: ../views/options.php:22
|
46 |
+
msgid "The maximum filesize you can upload is "
|
47 |
+
msgstr ""
|
48 |
+
|
49 |
+
#: ../views/options.php:35
|
50 |
+
msgid "Status"
|
51 |
+
msgstr ""
|
52 |
+
|
53 |
+
#: ../views/options.php:40
|
54 |
+
msgid "Nothing to report"
|
55 |
+
msgstr ""
|
56 |
+
|
57 |
+
#: ../views/options.php:45
|
58 |
+
msgid "Preparing to backup"
|
59 |
+
msgstr ""
|
60 |
+
|
61 |
+
#: ../views/options.php:45 ../views/options.php:46 ../views/options.php:47
|
62 |
+
#: ../views/options.php:48 ../views/options.php:49 ../views/options.php:50
|
63 |
+
#: ../views/options.php:67 ../views/options.php:68 ../views/options.php:69
|
64 |
+
#: ../views/options.php:70 ../views/options.php:71 ../views/options.php:72
|
65 |
+
#: ../views/options.php:73
|
66 |
+
msgid "Done"
|
67 |
+
msgstr ""
|
68 |
+
|
69 |
+
#: ../views/options.php:45 ../views/options.php:46 ../views/options.php:47
|
70 |
+
#: ../views/options.php:48 ../views/options.php:49 ../views/options.php:50
|
71 |
+
#: ../views/options.php:67 ../views/options.php:68 ../views/options.php:69
|
72 |
+
#: ../views/options.php:70 ../views/options.php:71 ../views/options.php:72
|
73 |
+
#: ../views/options.php:73
|
74 |
+
msgid "Failed"
|
75 |
+
msgstr ""
|
76 |
+
|
77 |
+
#: ../views/options.php:46
|
78 |
+
msgid "Backing-up database"
|
79 |
+
msgstr ""
|
80 |
+
|
81 |
+
#: ../views/options.php:47
|
82 |
+
msgid "Backing-up /wp-content/"
|
83 |
+
msgstr ""
|
84 |
+
|
85 |
+
#: ../views/options.php:48
|
86 |
+
msgid "Creating backup information file"
|
87 |
+
msgstr ""
|
88 |
+
|
89 |
+
#: ../views/options.php:49
|
90 |
+
msgid "Zipping backup directory"
|
91 |
+
msgstr ""
|
92 |
+
|
93 |
+
#: ../views/options.php:50 ../views/options.php:73
|
94 |
+
msgid "Cleaning up"
|
95 |
+
msgstr ""
|
96 |
+
|
97 |
+
#: ../views/options.php:51
|
98 |
+
msgid ""
|
99 |
+
"Backup file created successfully. You can download your backup file using "
|
100 |
+
"the link above"
|
101 |
+
msgstr ""
|
102 |
+
|
103 |
+
#: ../views/options.php:56
|
104 |
+
msgid ""
|
105 |
+
"Error: Unable to create new directory for backup. Please check your CHMOD "
|
106 |
+
"settings of your wp-backitup plugin directory"
|
107 |
+
msgstr ""
|
108 |
+
|
109 |
+
#: ../views/options.php:57
|
110 |
+
msgid ""
|
111 |
+
"Error: Cannot create backup directory. Please check the CHMOD settings of "
|
112 |
+
"your wp-backitup plugin directory"
|
113 |
+
msgstr ""
|
114 |
+
|
115 |
+
#: ../views/options.php:58
|
116 |
+
msgid "Error: Unable to backup your files. Please try again"
|
117 |
+
msgstr ""
|
118 |
+
|
119 |
+
#: ../views/options.php:59
|
120 |
+
msgid "Error: Unable to backup your database. Please try again"
|
121 |
+
msgstr ""
|
122 |
+
|
123 |
+
#: ../views/options.php:60
|
124 |
+
msgid ""
|
125 |
+
"Error: Your database was accesible but a dump could not be created. Please "
|
126 |
+
"contact support by clicking the link on the right, stating your web host "
|
127 |
+
"when you submit the form."
|
128 |
+
msgstr ""
|
129 |
+
|
130 |
+
#: ../views/options.php:61
|
131 |
+
msgid "Error: Unable to create site information file. Please try again"
|
132 |
+
msgstr ""
|
133 |
+
|
134 |
+
#: ../views/options.php:62
|
135 |
+
msgid "Warning: Unable to cleanup your backup directory"
|
136 |
+
msgstr ""
|
137 |
+
|
138 |
+
#: ../views/options.php:67
|
139 |
+
msgid "Uploading restoration zip"
|
140 |
+
msgstr ""
|
141 |
+
|
142 |
+
#: ../views/options.php:68
|
143 |
+
msgid "Unzipping"
|
144 |
+
msgstr ""
|
145 |
+
|
146 |
+
#: ../views/options.php:69
|
147 |
+
msgid "Validating restoration zip"
|
148 |
+
msgstr ""
|
149 |
+
|
150 |
+
#: ../views/options.php:70
|
151 |
+
msgid "Setting checkpoint"
|
152 |
+
msgstr ""
|
153 |
+
|
154 |
+
#: ../views/options.php:71
|
155 |
+
msgid "Importing database"
|
156 |
+
msgstr ""
|
157 |
+
|
158 |
+
#: ../views/options.php:72
|
159 |
+
msgid "Importing /wp-content/ directory"
|
160 |
+
msgstr ""
|
161 |
+
|
162 |
+
#: ../views/options.php:74
|
163 |
+
msgid ""
|
164 |
+
"Restoration completed successfully. Please refresh the page and login to the "
|
165 |
+
"site again (with your current username and password)"
|
166 |
+
msgstr ""
|
167 |
+
|
168 |
+
#: ../views/options.php:79
|
169 |
+
msgid "Error: No file selected"
|
170 |
+
msgstr ""
|
171 |
+
|
172 |
+
#: ../views/options.php:80
|
173 |
+
msgid "Error: Your file could not be uploaded"
|
174 |
+
msgstr ""
|
175 |
+
|
176 |
+
#: ../views/options.php:81
|
177 |
+
msgid "Error: Your restoration file could not be unzipped"
|
178 |
+
msgstr ""
|
179 |
+
|
180 |
+
#: ../views/options.php:82
|
181 |
+
msgid ""
|
182 |
+
"Error: Your zip file appears to be invalid. Please ensure you chose the "
|
183 |
+
"correct zip file"
|
184 |
+
msgstr ""
|
185 |
+
|
186 |
+
#: ../views/options.php:83
|
187 |
+
msgid "Error: Cannot create restore point"
|
188 |
+
msgstr ""
|
189 |
+
|
190 |
+
#: ../views/options.php:84
|
191 |
+
msgid "Error: Unable to connect to your database"
|
192 |
+
msgstr ""
|
193 |
+
|
194 |
+
#: ../views/options.php:85
|
195 |
+
msgid "Error: Unable to get current site URL from database. Please try again"
|
196 |
+
msgstr ""
|
197 |
+
|
198 |
+
#: ../views/options.php:86
|
199 |
+
msgid "Error: Unable to get current home URL from database. Please try again"
|
200 |
+
msgstr ""
|
201 |
+
|
202 |
+
#: ../views/options.php:87
|
203 |
+
msgid "Error: Unable to get current user ID from database. Please try again"
|
204 |
+
msgstr ""
|
205 |
+
|
206 |
+
#: ../views/options.php:88
|
207 |
+
msgid ""
|
208 |
+
"Error: Unable to get current user password from database. Please try again"
|
209 |
+
msgstr ""
|
210 |
+
|
211 |
+
#: ../views/options.php:89
|
212 |
+
msgid "Error: Unable to get current user email from database. Please try again"
|
213 |
+
msgstr ""
|
214 |
+
|
215 |
+
#: ../views/options.php:90
|
216 |
+
msgid ""
|
217 |
+
"Error: Unable to get import your database. This may require importing the "
|
218 |
+
"file manually"
|
219 |
+
msgstr ""
|
220 |
+
|
221 |
+
#: ../views/options.php:91
|
222 |
+
msgid ""
|
223 |
+
"Error: Unable to update your current site URL value. This may require "
|
224 |
+
"importing the file manually"
|
225 |
+
msgstr ""
|
226 |
+
|
227 |
+
#: ../views/options.php:92
|
228 |
+
msgid ""
|
229 |
+
"Error: Unable to update your current home URL value. This may require "
|
230 |
+
"importing the file manually"
|
231 |
+
msgstr ""
|
232 |
+
|
233 |
+
#: ../views/options.php:93
|
234 |
+
msgid ""
|
235 |
+
"Error: Unable to update your user information. This may require importing "
|
236 |
+
"the file manually"
|
237 |
+
msgstr ""
|
238 |
+
|
239 |
+
#: ../views/options.php:94
|
240 |
+
msgid "Error: Warning: Database not detected in import file"
|
241 |
+
msgstr ""
|
242 |
+
|
243 |
+
#: ../views/options.php:95
|
244 |
+
msgid ""
|
245 |
+
"Error: Unable to remove existing wp-content directory for import. Please "
|
246 |
+
"check your CHMOD settings in /wp-content/"
|
247 |
+
msgstr ""
|
248 |
+
|
249 |
+
#: ../views/options.php:96
|
250 |
+
msgid ""
|
251 |
+
"Error: Unable to create new wp-content directory for import. Please check "
|
252 |
+
"your CHMOD settings in /wp-content/"
|
253 |
+
msgstr ""
|
254 |
+
|
255 |
+
#: ../views/options.php:97
|
256 |
+
msgid "Error: Unable to import wp-content. Please try again"
|
257 |
+
msgstr ""
|
258 |
+
|
259 |
+
#: ../views/options.php:98
|
260 |
+
msgid "Warning: Unable to cleanup import directory"
|
261 |
+
msgstr ""
|
262 |
+
|
263 |
+
#: ../views/options.php:109
|
264 |
+
msgid "License Key"
|
265 |
+
msgstr ""
|
266 |
+
|
267 |
+
#: ../views/options.php:113
|
268 |
+
msgid "Pro features and auto-updates enabled"
|
269 |
+
msgstr ""
|
270 |
+
|
271 |
+
#: ../views/options.php:115
|
272 |
+
msgid "Activate auto-restore and auto-updates by entering your license key"
|
273 |
+
msgstr ""
|
274 |
+
|
275 |
+
#: ../views/options.php:120
|
276 |
+
msgid "Active"
|
277 |
+
msgstr ""
|
278 |
+
|
279 |
+
#: ../views/options.php:121
|
280 |
+
msgid "Update"
|
281 |
+
msgstr ""
|
282 |
+
|
283 |
+
#: ../views/options.php:123
|
284 |
+
msgid "Inactive"
|
285 |
+
msgstr ""
|
286 |
+
|
287 |
+
#: ../views/options.php:124
|
288 |
+
msgid "Activate"
|
289 |
+
msgstr ""
|
290 |
+
|
291 |
+
#: ../views/options.php:125
|
292 |
+
msgid "Purchase a license key"
|
293 |
+
msgstr ""
|
294 |
+
|
295 |
+
#: ../views/options.php:132
|
296 |
+
msgid "WP Backitup support system"
|
297 |
+
msgstr ""
|
298 |
+
|
299 |
+
#: ../views/options.php:135
|
300 |
+
msgid "support system"
|
301 |
+
msgstr ""
|
302 |
+
|
303 |
+
#: ../views/options.php:138
|
304 |
+
msgid "Need Help?"
|
305 |
+
msgstr ""
|
306 |
+
|
307 |
+
#: ../views/options.php:139
|
308 |
+
msgid "Access the"
|
309 |
+
msgstr ""
|
310 |
+
|
311 |
+
#: ../views/options.php:143
|
312 |
+
msgid "Spread the Word"
|
313 |
+
msgstr ""
|
314 |
+
|
315 |
+
#: ../views/options.php:144
|
316 |
+
msgid "Rate WP Backitup"
|
317 |
+
msgstr ""
|
318 |
+
|
319 |
+
#: ../views/options.php:149
|
320 |
+
msgid "Enable"
|
321 |
+
msgstr ""
|
322 |
+
|
323 |
+
#: ../views/options.php:150
|
324 |
+
msgid "Disable"
|
325 |
+
msgstr ""
|
326 |
+
|
327 |
+
#: ../views/options.php:151
|
328 |
+
msgid "Help to improve Easy Webtrends by enabling"
|
329 |
+
msgstr ""
|
330 |
+
|
331 |
+
#: ../views/options.php:152
|
332 |
+
msgid "Save"
|
333 |
+
msgstr ""
|
lib/includes/backup.php
CHANGED
@@ -43,14 +43,6 @@ if( !class_exists( 'WPBackItUp_Filesystem' ) ) {
|
|
43 |
|
44 |
/*** Globals ***/
|
45 |
global $WPBackitup;
|
46 |
-
global $backup_start_time;
|
47 |
-
|
48 |
-
//Get root
|
49 |
-
$url = str_replace('http://','',home_url());
|
50 |
-
$url = str_replace('/','-',$url);
|
51 |
-
$fileUTCDateTime=current_time( 'timestamp' );
|
52 |
-
$localDateTime = date_i18n('Y-m-d-His',$fileUTCDateTime);
|
53 |
-
$backup_name = 'Backup_' . $url .'_' .$localDateTime;
|
54 |
|
55 |
global $status_array,$inactive,$active,$complete,$failure,$warning,$success;
|
56 |
$inactive=0;
|
@@ -71,30 +63,53 @@ $status_array = array(
|
|
71 |
'cleanup'=>$inactive
|
72 |
);
|
73 |
|
|
|
|
|
74 |
global $logger;
|
75 |
-
$
|
76 |
-
//echo "</br>Log Path:" .$log_path ;
|
77 |
-
$logger = new WPBackItUp_Logger(false,$log_path,$backup_name);
|
78 |
|
79 |
-
global $wp_backup;
|
80 |
-
$wp_backup = new WPBackItUp_Backup($logger,$backup_name);
|
81 |
|
82 |
//*****************//
|
83 |
//*** MAIN CODE ***//
|
84 |
//*****************//
|
85 |
$logger->log('***BEGIN BACKUP***');
|
86 |
$logger->logConstants();
|
87 |
-
$backup_start_time = new datetime('now');
|
88 |
|
89 |
-
$
|
90 |
|
91 |
-
//
|
92 |
-
|
93 |
-
$
|
94 |
-
$
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
set_status('preparing',$active,true);
|
99 |
sleep(3);//For UI only
|
100 |
|
@@ -102,251 +117,185 @@ sleep(3);//For UI only
|
|
102 |
|
103 |
//TEST END HERE
|
104 |
|
105 |
-
$logger->log('**CLEANUP**');
|
|
|
106 |
|
107 |
-
|
108 |
-
|
109 |
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
set_status('preparing',$complete,false);
|
114 |
$logger->log('**END CLEANUP**');
|
115 |
|
116 |
//Backup the database
|
117 |
-
$logger->log('**SQL EXPORT**');
|
|
|
118 |
set_status('backupdb',$active,true);
|
119 |
sleep(3);//For UI only
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
|
|
122 |
set_status('backupdb',$complete,false);
|
123 |
$logger->log('**END SQL EXPORT**');
|
124 |
|
125 |
//Extract the site info
|
126 |
$logger->log('**SITE INFO**');
|
|
|
127 |
set_status('infofile',$active,true);
|
128 |
sleep(3);//For UI only
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
set_status('infofile',$complete,false);
|
131 |
$logger->log('**END SITE INFO**');
|
132 |
|
|
|
133 |
//Backup the WP-Content
|
134 |
$logger->log('**WP CONTENT**');
|
|
|
135 |
set_status('backupfiles',$active,true);
|
136 |
sleep(3);//For UI only
|
137 |
-
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
set_status('backupfiles',$complete,false);
|
140 |
$logger->log('**END WP CONTENT**');
|
141 |
|
142 |
//Zip up the backup folder
|
143 |
$logger->log('**BACKUP ZIP**');
|
|
|
144 |
set_status('zipfile',$active,true);
|
145 |
sleep(3);//For UI only
|
146 |
-
|
147 |
-
|
148 |
-
|
|
|
|
|
|
|
149 |
set_status('zipfile',$complete,false);
|
150 |
$logger->log('**END BACKUP ZIP**');
|
151 |
|
152 |
-
|
153 |
-
$jsonResponse = new stdClass();
|
154 |
-
$jsonResponse->message = 'success';
|
155 |
-
$jsonResponse->filedate = $localDateTime;
|
156 |
-
$jsonResponse->file = $wp_backup->backup_filename;
|
157 |
-
$jsonResponse->zip_link = WPBACKITUP__BACKUP_URL . '/' . $wp_backup->backup_filename;
|
158 |
-
$jsonResponse->license = $this->license_active();
|
159 |
-
$jsonResponse->retained = $wp_backup->backup_retained_number;
|
160 |
-
|
161 |
-
if (file_exists($logger->logFilePath)) {
|
162 |
-
$jsonResponse->log_link = basename($logger->logFileName,'.log');
|
163 |
-
}
|
164 |
|
165 |
//Cleanup
|
166 |
$logger->log('**CLEANUP**');
|
|
|
167 |
set_status('cleanup',$active,true);
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
set_status('cleanup',$complete,false);
|
170 |
$logger->log('**END CLEANUP**');
|
171 |
|
172 |
-
//Send success Email to user before cleanup
|
173 |
-
send_backup_notification_email(null,true);
|
174 |
-
|
175 |
//DONE!
|
176 |
set_status_success();
|
177 |
-
|
178 |
|
179 |
$WPBackitup->increment_successful_backup_count();
|
180 |
|
181 |
-
|
182 |
-
$logger->log("*** END BACKUP ***");
|
183 |
-
die();
|
184 |
|
185 |
/******************/
|
186 |
/*** Functions ***/
|
187 |
/******************/
|
188 |
-
function
|
189 |
-
global $logger,$wp_backup;
|
190 |
-
$logger->log('Delete Backup Folder:'.$path);
|
191 |
-
$fileSystem = new WPBackItUp_FileSystem($logger);
|
192 |
-
if(!$fileSystem ->recursive_delete($path)) {
|
193 |
-
write_warning_status('error106');
|
194 |
-
}
|
195 |
-
else
|
196 |
-
{
|
197 |
-
$logger->log('Backup Folder Deleted');
|
198 |
-
}
|
199 |
|
200 |
-
|
201 |
-
|
|
|
|
|
|
|
202 |
|
203 |
-
|
204 |
-
$fileSystem->purge_files(WPBACKITUP__BACKUP_PATH .'/','log',$wp_backup->backup_retained_days);
|
205 |
-
|
206 |
-
}
|
207 |
-
|
208 |
-
function backup_wpcontent(){
|
209 |
-
global $logger,$wp_backup;
|
210 |
|
211 |
-
$fromFolder = WPBACKITUP__CONTENT_PATH . '/';
|
212 |
-
$ignore = array( WPBACKITUP__BACKUP_FOLDER,$wp_backup->backup_name,$wp_backup->restore_folder_root,'upgrade','cache' );
|
213 |
-
|
214 |
-
$logger->log('Recursive Copy FROM:'.$fromFolder);
|
215 |
-
$logger->log('Recursive Copy TO:'.$wp_backup->backup_project_path);
|
216 |
-
$logger->log('Ignore Array:');
|
217 |
-
$logger->log($ignore);
|
218 |
-
|
219 |
-
$fileSystem = new WPBackItUp_FileSystem($logger);
|
220 |
-
if(!$fileSystem->recursive_copy($fromFolder, $wp_backup->backup_project_path, $ignore) ) {
|
221 |
-
write_fatal_error_status('error103');
|
222 |
-
cleanup_on_failure($wp_backup->backup_project_path);
|
223 |
-
send_backup_notification_email(103,false);
|
224 |
-
die();
|
225 |
-
}
|
226 |
-
$logger->log('Recursive Copy completed');
|
227 |
}
|
|
|
|
|
|
|
228 |
|
229 |
-
|
230 |
-
global $logger,$wp_backup;
|
231 |
-
$source_dir_path = WPBACKITUP__CONTENT_PATH . '/';
|
232 |
-
$target_dir_path = $wp_backup->backup_project_path;
|
233 |
-
|
234 |
-
$logger->log('Validate content folder TO:' .$source_dir_path);
|
235 |
-
$logger->log('Validate content folder FROM:' .$target_dir_path);
|
236 |
|
237 |
-
$
|
238 |
-
$
|
239 |
-
if(!$filesystem->recursive_validate($source_dir_path. '/', $target_dir_path . '/',$ignore)) {
|
240 |
-
$logger->log('Error: Content folder is not the same as backup.');
|
241 |
-
}
|
242 |
-
|
243 |
-
$logger->log('Content folder validation complete.');
|
244 |
-
}
|
245 |
-
|
246 |
-
//Create siteinfo in project dir
|
247 |
-
function create_SiteInfoFile($path){
|
248 |
-
global $wpdb,$logger;
|
249 |
-
|
250 |
-
$logger->log('Create Site Info File:'.$path);
|
251 |
-
if (!create_siteinfo($path, $wpdb->prefix) ) {
|
252 |
-
write_fatal_error_status('error105');
|
253 |
-
cleanup_on_failure($path);
|
254 |
-
send_backup_notification_email(105,false);
|
255 |
-
die();
|
256 |
-
}
|
257 |
-
$logger->log('Site Info File Created.');
|
258 |
-
}
|
259 |
-
|
260 |
-
function create_siteinfo($path, $table_prefix) {
|
261 |
-
$siteinfo = $path ."backupsiteinfo.txt";
|
262 |
-
$handle = fopen($siteinfo, 'w+');
|
263 |
|
264 |
-
|
265 |
-
|
266 |
-
fwrite($handle, $entry);
|
267 |
|
268 |
-
|
269 |
-
$entry = $table_prefix ."\n" ;
|
270 |
-
fwrite($handle, $entry);
|
271 |
|
272 |
-
|
273 |
-
|
274 |
-
|
|
|
275 |
|
276 |
-
|
277 |
-
|
278 |
-
}
|
279 |
|
280 |
-
|
281 |
-
|
|
|
282 |
|
283 |
-
|
|
|
|
|
|
|
|
|
|
|
284 |
|
285 |
-
|
286 |
-
|
287 |
-
if(!$SQL->mysqldump_export($sqlFileName) ) {
|
288 |
-
//Try manual extract if sqldump isnt working
|
289 |
-
if(!$SQL->manual_export($sqlFileName) ) {
|
290 |
-
write_fatal_error_status('error104');
|
291 |
-
cleanup_on_failure($wp_backup->backup_project_path);
|
292 |
-
send_backup_notification_email(104,false);
|
293 |
-
die();
|
294 |
-
}
|
295 |
-
}
|
296 |
-
$logger->log('Created the SQL Backup File:'.$sqlFileName);
|
297 |
-
}
|
298 |
-
//Check to see if the directory is writeable
|
299 |
-
function check_BackupFolder($path){
|
300 |
-
global $wp_backup,$logger;
|
301 |
-
$logger->log("Is folder writeable: " .$path);
|
302 |
-
if(!is_writeable($path)) {
|
303 |
-
write_fatal_error_status('error102');
|
304 |
-
send_backup_notification_email(102,false);
|
305 |
-
die();
|
306 |
-
} else {
|
307 |
-
//If the directory is writeable, create the backup folder if it doesn't exist
|
308 |
-
$logger->log("Folder IS writeable: " .$path);
|
309 |
-
if(!is_dir($path) ) {
|
310 |
-
$logger->log("Create Backup Content Folder: " .$path);
|
311 |
-
@mkdir($wp_backup->backup_project_path, 0755);
|
312 |
-
$logger->log('Backup Content Folder Created:'.$path);
|
313 |
-
}
|
314 |
-
}
|
315 |
}
|
316 |
|
317 |
-
function
|
318 |
-
global $logger;
|
319 |
-
|
320 |
-
|
321 |
-
$logger->log("Create Backup Folder: " .$path);
|
322 |
-
if(!$fileSystem->create_dir($path)) {
|
323 |
-
$logger->log('Error: Cant create backup folder :'. $path);
|
324 |
-
write_fatal_error_status('error101');
|
325 |
-
send_backup_notification_email(101, false);
|
326 |
-
die();
|
327 |
-
}
|
328 |
-
$logger->log("Backup Folder Created");
|
329 |
-
}
|
330 |
|
331 |
-
function send_backup_notification_email($err, $status)
|
332 |
-
{
|
333 |
-
global $WPBackitup, $logger, $backup_start_time,$status_array;
|
334 |
$utility = new WPBackItUp_Utility($logger);
|
335 |
|
336 |
-
//$start_date = new DateTime(date( 'Y-m-d H:i:s',$backup_start_time));
|
337 |
-
$backup_end_time = new DateTime('now');
|
338 |
-
|
339 |
$util = new WPBackItUp_Utility($logger);
|
340 |
-
$seconds = $util->date_diff_seconds($backup_start_time,$backup_end_time);
|
341 |
|
342 |
$processing_minutes = round($seconds / 60);
|
343 |
$processing_seconds = $seconds % 60;
|
344 |
|
345 |
-
//PHP 5.3
|
346 |
-
//$interval = $start_date->diff(new DateTime(date( 'Y-m-d H:i:s',$backup_end_time)));
|
347 |
-
|
348 |
-
$logger->log('Script Processing Time:' .$processing_minutes .' Minutes ' .$processing_seconds .' Seconds');
|
349 |
-
|
350 |
$status_description = array(
|
351 |
'preparing'=>'Preparing for backup...Done',
|
352 |
'backupdb'=>'Backing-up database...Done',
|
@@ -363,10 +312,12 @@ function send_backup_notification_email($err, $status)
|
|
363 |
'104'=> 'Error 104: Unable to backup your database. Please try again',
|
364 |
'105'=> 'Error 105: Unable to create site information file. Please try again',
|
365 |
'106'=> 'Warning 106: Unable to cleanup your backup directory',
|
|
|
366 |
'114'=> 'Error 114: Your database was accessible but an export could not be created. Please contact support by clicking the get support link on the right. Please let us know who your host is when you submit the request'
|
|
|
367 |
);
|
368 |
|
369 |
-
if($
|
370 |
{
|
371 |
$subject = 'WP BackItUp - Backup completed successfully.';
|
372 |
$message = '<b>Your backup completed successfully.</b><br/><br/>';
|
@@ -376,9 +327,9 @@ function send_backup_notification_email($err, $status)
|
|
376 |
$message = '<b>Your backup did not complete successfully.</b><br/><br/>';
|
377 |
}
|
378 |
|
379 |
-
$message .= 'Backup started: '
|
380 |
-
$message .= 'Backup ended: '
|
381 |
-
$message .= 'Processing Time: '
|
382 |
|
383 |
$message .= '<br/>';
|
384 |
|
@@ -399,7 +350,7 @@ function send_backup_notification_email($err, $status)
|
|
399 |
}
|
400 |
|
401 |
//Add the errors
|
402 |
-
if(!$
|
403 |
{
|
404 |
$message .= '<br/>';
|
405 |
$message .= 'Errors:<br/>';
|
@@ -412,50 +363,28 @@ function send_backup_notification_email($err, $status)
|
|
412 |
}
|
413 |
|
414 |
$term='success';
|
415 |
-
if(!$
|
416 |
$message .='<br/><br/>Checkout '. $WPBackitup->get_anchor_with_utm('www.wpbackitup.com', '', 'notification+email', $term) .' for info about WP BackItUp and our other products.<br/>';
|
417 |
|
418 |
$notification_email = $WPBackitup->get_option('notification_email');
|
419 |
if($notification_email)
|
420 |
$utility->send_email($notification_email,$subject,$message);
|
|
|
|
|
421 |
}
|
422 |
|
423 |
function cleanup_on_failure($path){
|
424 |
global $logger;
|
|
|
|
|
425 |
if (WPBACKITUP__DEBUG===true){
|
426 |
$logger->log('Cleanup On Fail suspended: debug on.');
|
427 |
}
|
428 |
else{
|
429 |
-
|
430 |
}
|
431 |
}
|
432 |
|
433 |
-
function cleanup_BackupFolder($dir){
|
434 |
-
global $logger;
|
435 |
-
$logger->log('Cleanup Backup Folder:'.$dir);
|
436 |
-
$ignore = array('cgi-bin','.','..','._');
|
437 |
-
if( is_dir($dir) ){
|
438 |
-
if($dh = opendir($dir)) {
|
439 |
-
while( ($file = readdir($dh)) !== false ) {
|
440 |
-
$ext = pathinfo($file, PATHINFO_EXTENSION);
|
441 |
-
if (!in_array($file, $ignore) && substr($file, 0, 1) != '.' && $ext!="zip" && $ext!="log") { //Check the file is not in the ignore array
|
442 |
-
if(!is_dir($dir .'/'. $file)) {
|
443 |
-
unlink($dir .'/'. $file);
|
444 |
-
} else {
|
445 |
-
$fileSystem = new WPBackItUp_FileSystem($logger);
|
446 |
-
$fileSystem->recursive_delete($dir.'/'. $file, $ignore);
|
447 |
-
}
|
448 |
-
}
|
449 |
-
}
|
450 |
-
}
|
451 |
-
@rmdir($dir);
|
452 |
-
closedir($dh);
|
453 |
-
}
|
454 |
-
$logger->log('Cleanup Backup Folder completed:'.$dir);
|
455 |
-
return true;
|
456 |
-
}
|
457 |
-
|
458 |
-
|
459 |
function write_fatal_error_status($status_code) {
|
460 |
global $status_array,$active,$failure;
|
461 |
|
@@ -514,9 +443,38 @@ function getStatusLog() {
|
|
514 |
}
|
515 |
|
516 |
//write Response Log
|
517 |
-
function write_response_file($
|
518 |
-
global $logger;
|
519 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
520 |
$logger->log('Write response file:' . $json_response);
|
521 |
|
522 |
$fh=get_response_file();
|
@@ -527,7 +485,7 @@ function write_response_file($object) {
|
|
527 |
//Get Response Log
|
528 |
function get_response_file() {
|
529 |
global $logger;
|
530 |
-
$response_file_path = WPBACKITUP__PLUGIN_PATH .'
|
531 |
$filesytem = new WPBackItUp_FileSystem($logger);
|
532 |
return $filesytem->get_file_handle($response_file_path,true);
|
533 |
}
|
43 |
|
44 |
/*** Globals ***/
|
45 |
global $WPBackitup;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
global $status_array,$inactive,$active,$complete,$failure,$warning,$success;
|
48 |
$inactive=0;
|
63 |
'cleanup'=>$inactive
|
64 |
);
|
65 |
|
66 |
+
$backup_name = get_backup_name();
|
67 |
+
|
68 |
global $logger;
|
69 |
+
$logger = new WPBackItUp_Logger(false,null,$backup_name);
|
|
|
|
|
70 |
|
71 |
+
global $wp_backup;
|
72 |
+
$wp_backup = new WPBackItUp_Backup($logger,$backup_name,$WPBackitup->backup_type);
|
73 |
|
74 |
//*****************//
|
75 |
//*** MAIN CODE ***//
|
76 |
//*****************//
|
77 |
$logger->log('***BEGIN BACKUP***');
|
78 |
$logger->logConstants();
|
|
|
79 |
|
80 |
+
$logger->log('Backup Type:' .strtoupper($wp_backup->backup_type));
|
81 |
|
82 |
+
//Check to see if a backup is already running
|
83 |
+
if (!$wp_backup->start()) {
|
84 |
+
$logger->log('Backup Already in progress');
|
85 |
+
if ($wp_backup->backup_type=='manual'){
|
86 |
+
$wp_backup->check_lock_status();
|
87 |
+
}
|
88 |
+
end_backup();
|
89 |
+
}
|
90 |
+
|
91 |
+
//Run cleanup only
|
92 |
+
if ($wp_backup->backup_type=='cleanup'){
|
93 |
+
$logger->log('Cleanup requested');
|
94 |
+
$wp_backup->cleanup_unfinished_backups();
|
95 |
+
$wp_backup->purge_old_files();
|
96 |
+
$current_datetime = current_time( 'timestamp' );
|
97 |
+
$WPBackitup->set_cleanup_lastrun_date($current_datetime);
|
98 |
+
end_backup();
|
99 |
+
}
|
100 |
|
101 |
+
//This is neither a scheduled OR manual backup so just run some cleanup
|
102 |
+
if ($wp_backup->backup_type!='scheduled' && $wp_backup->backup_type!='manual'){
|
103 |
+
$logger->log('No backup requested - ending');
|
104 |
+
end_backup();
|
105 |
+
}
|
106 |
+
|
107 |
+
// Run scheduled OR manual backup
|
108 |
+
|
109 |
+
$WPBackitup->increment_backup_count();
|
110 |
+
|
111 |
+
//Cleanup & Validate the backup folded is ready
|
112 |
+
write_response_file("preparing for backup");
|
113 |
set_status('preparing',$active,true);
|
114 |
sleep(3);//For UI only
|
115 |
|
117 |
|
118 |
//TEST END HERE
|
119 |
|
120 |
+
$logger->log('**BEGIN CLEANUP**');
|
121 |
+
write_response_file("Cleanup before backup");
|
122 |
|
123 |
+
//Cleanup any backups that didnt finish normally
|
124 |
+
$wp_backup->cleanup_unfinished_backups();
|
125 |
|
126 |
+
//Make sure wpbackitup_backups exists
|
127 |
+
if (!$wp_backup->backup_root_folder_exists()){
|
128 |
+
write_fatal_error_status('error101');
|
129 |
+
end_backup(101, false);
|
130 |
+
}
|
131 |
+
|
132 |
+
//Create the root folder for the current backup
|
133 |
+
if (!$wp_backup->create_current_backup_folder()){
|
134 |
+
write_fatal_error_status('error101');
|
135 |
+
end_backup(101, false);
|
136 |
+
}
|
137 |
+
|
138 |
+
//Check to see if the directory exists and is writeable
|
139 |
+
if (!$wp_backup->backup_folder_exists()){
|
140 |
+
write_fatal_error_status('error102');
|
141 |
+
end_backup(102,false);
|
142 |
+
}
|
143 |
|
144 |
set_status('preparing',$complete,false);
|
145 |
$logger->log('**END CLEANUP**');
|
146 |
|
147 |
//Backup the database
|
148 |
+
$logger->log('**BEGIN SQL EXPORT**');
|
149 |
+
write_response_file("Create SQL Export");
|
150 |
set_status('backupdb',$active,true);
|
151 |
sleep(3);//For UI only
|
152 |
+
if (!$wp_backup->export_database()){
|
153 |
+
write_fatal_error_status('error104');
|
154 |
+
cleanup_on_failure($wp_backup->backup_project_path);
|
155 |
+
end_backup(104,false);
|
156 |
+
}
|
157 |
+
|
158 |
set_status('backupdb',$complete,false);
|
159 |
$logger->log('**END SQL EXPORT**');
|
160 |
|
161 |
//Extract the site info
|
162 |
$logger->log('**SITE INFO**');
|
163 |
+
write_response_file("Retrieve Site Info");
|
164 |
set_status('infofile',$active,true);
|
165 |
sleep(3);//For UI only
|
166 |
+
|
167 |
+
if (!$wp_backup->create_siteinfo_file()){
|
168 |
+
write_fatal_error_status('error105');
|
169 |
+
cleanup_on_failure($wp_backup->backup_project_path);
|
170 |
+
end_backup(105,false);
|
171 |
+
}
|
172 |
+
|
173 |
set_status('infofile',$complete,false);
|
174 |
$logger->log('**END SITE INFO**');
|
175 |
|
176 |
+
|
177 |
//Backup the WP-Content
|
178 |
$logger->log('**WP CONTENT**');
|
179 |
+
write_response_file("Backup Content");
|
180 |
set_status('backupfiles',$active,true);
|
181 |
sleep(3);//For UI only
|
182 |
+
|
183 |
+
if (!$wp_backup->backup_wpcontent()){
|
184 |
+
write_fatal_error_status('error103');
|
185 |
+
cleanup_on_failure($wp_backup->backup_project_path);
|
186 |
+
end_backup(103,false);
|
187 |
+
}
|
188 |
+
|
189 |
+
//auditing only
|
190 |
+
//If logging is turned on Validate
|
191 |
+
if ($WPBackitup->logging()){
|
192 |
+
$wp_backup->validate_wpcontent();
|
193 |
+
}
|
194 |
set_status('backupfiles',$complete,false);
|
195 |
$logger->log('**END WP CONTENT**');
|
196 |
|
197 |
//Zip up the backup folder
|
198 |
$logger->log('**BACKUP ZIP**');
|
199 |
+
write_response_file("Compress Backup ");
|
200 |
set_status('zipfile',$active,true);
|
201 |
sleep(3);//For UI only
|
202 |
+
if (!$wp_backup->compress_backup()){
|
203 |
+
write_fatal_error_status('error107');
|
204 |
+
cleanup_on_failure($wp_backup->backup_project_path);
|
205 |
+
end_backup(107,false);
|
206 |
+
}
|
207 |
+
|
208 |
set_status('zipfile',$complete,false);
|
209 |
$logger->log('**END BACKUP ZIP**');
|
210 |
|
211 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
|
213 |
//Cleanup
|
214 |
$logger->log('**CLEANUP**');
|
215 |
+
write_response_file("Cleanup after Backup ");
|
216 |
set_status('cleanup',$active,true);
|
217 |
+
|
218 |
+
if (!$wp_backup->cleanup_current_backup()){
|
219 |
+
write_warning_status('error106');
|
220 |
+
}
|
221 |
+
|
222 |
+
//Check retention limits and cleanup
|
223 |
+
$wp_backup->purge_old_files();
|
224 |
+
|
225 |
set_status('cleanup',$complete,false);
|
226 |
$logger->log('**END CLEANUP**');
|
227 |
|
|
|
|
|
|
|
228 |
//DONE!
|
229 |
set_status_success();
|
230 |
+
write_response_file_success();
|
231 |
|
232 |
$WPBackitup->increment_successful_backup_count();
|
233 |
|
234 |
+
end_backup(null,true);
|
|
|
|
|
235 |
|
236 |
/******************/
|
237 |
/*** Functions ***/
|
238 |
/******************/
|
239 |
+
function get_backup_name(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
|
241 |
+
$url = str_replace('http://','',home_url());
|
242 |
+
$url = str_replace('/','-',$url);
|
243 |
+
$fileUTCDateTime=current_time( 'timestamp' );
|
244 |
+
$localDateTime = date_i18n('Y-m-d-His',$fileUTCDateTime);
|
245 |
+
$backup_name = 'Backup_' . $url .'_' .$localDateTime;
|
246 |
|
247 |
+
return $backup_name;
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
}
|
250 |
+
function end_backup($err=null, $success=null){
|
251 |
+
global $wp_backup, $logger;
|
252 |
+
$logger->log_info(__METHOD__,"Begin");
|
253 |
|
254 |
+
$wp_backup->end(); //Release the lock
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
|
256 |
+
$util = new WPBackItUp_Utility($logger);
|
257 |
+
$seconds = $util->date_diff_seconds($wp_backup->backup_start_time,$wp_backup->backup_end_time);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
|
259 |
+
$processing_minutes = round($seconds / 60);
|
260 |
+
$processing_seconds = $seconds % 60;
|
|
|
261 |
|
262 |
+
$logger->log('Script Processing Time:' .$processing_minutes .' Minutes ' .$processing_seconds .' Seconds');
|
|
|
|
|
263 |
|
264 |
+
//if null was passed then this was just a schedule check
|
265 |
+
if (null!=$success){
|
266 |
+
send_backup_notification_email($err, $success);
|
267 |
+
}
|
268 |
|
269 |
+
if ($success) $logger->log("Backup completed successfully");
|
270 |
+
$logger->log("*** END BACKUP ***");
|
|
|
271 |
|
272 |
+
$logFileName = $logger->logFileName;
|
273 |
+
$logFilePath = $logger->logFilePath;
|
274 |
+
$logger->close_file();
|
275 |
|
276 |
+
//Move the log if it exists
|
277 |
+
$newlogFilePath = $wp_backup->backup_folder_root .$logFileName;
|
278 |
+
if (file_exists($logFilePath)){
|
279 |
+
copy ($logFilePath,$newlogFilePath);
|
280 |
+
unlink($logFilePath);
|
281 |
+
}
|
282 |
|
283 |
+
echo('Backup has completed');
|
284 |
+
exit(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
}
|
286 |
|
287 |
+
function send_backup_notification_email($err, $success) {
|
288 |
+
global $WPBackitup, $wp_backup, $logger,$status_array;
|
289 |
+
$logger->log_info(__METHOD__,"Begin");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
|
|
|
|
|
|
|
291 |
$utility = new WPBackItUp_Utility($logger);
|
292 |
|
|
|
|
|
|
|
293 |
$util = new WPBackItUp_Utility($logger);
|
294 |
+
$seconds = $util->date_diff_seconds($wp_backup->backup_start_time,$wp_backup->backup_end_time);
|
295 |
|
296 |
$processing_minutes = round($seconds / 60);
|
297 |
$processing_seconds = $seconds % 60;
|
298 |
|
|
|
|
|
|
|
|
|
|
|
299 |
$status_description = array(
|
300 |
'preparing'=>'Preparing for backup...Done',
|
301 |
'backupdb'=>'Backing-up database...Done',
|
312 |
'104'=> 'Error 104: Unable to backup your database. Please try again',
|
313 |
'105'=> 'Error 105: Unable to create site information file. Please try again',
|
314 |
'106'=> 'Warning 106: Unable to cleanup your backup directory',
|
315 |
+
'107'=> 'Error 107: Unable to compress(zip) your backup. Please try again',
|
316 |
'114'=> 'Error 114: Your database was accessible but an export could not be created. Please contact support by clicking the get support link on the right. Please let us know who your host is when you submit the request'
|
317 |
+
|
318 |
);
|
319 |
|
320 |
+
if($success)
|
321 |
{
|
322 |
$subject = 'WP BackItUp - Backup completed successfully.';
|
323 |
$message = '<b>Your backup completed successfully.</b><br/><br/>';
|
327 |
$message = '<b>Your backup did not complete successfully.</b><br/><br/>';
|
328 |
}
|
329 |
|
330 |
+
$message .= 'Backup started: ' . $wp_backup->backup_start_time->format( 'Y-m-d H:i:s') . '<br/>';
|
331 |
+
$message .= 'Backup ended: ' . $wp_backup->backup_end_time->format( 'Y-m-d H:i:s') . '<br/>';
|
332 |
+
$message .= 'Processing Time: ' . $processing_minutes .' Minutes ' .$processing_seconds .' Seconds <br/>';
|
333 |
|
334 |
$message .= '<br/>';
|
335 |
|
350 |
}
|
351 |
|
352 |
//Add the errors
|
353 |
+
if(!$success)
|
354 |
{
|
355 |
$message .= '<br/>';
|
356 |
$message .= 'Errors:<br/>';
|
363 |
}
|
364 |
|
365 |
$term='success';
|
366 |
+
if(!$success)$term='error';
|
367 |
$message .='<br/><br/>Checkout '. $WPBackitup->get_anchor_with_utm('www.wpbackitup.com', '', 'notification+email', $term) .' for info about WP BackItUp and our other products.<br/>';
|
368 |
|
369 |
$notification_email = $WPBackitup->get_option('notification_email');
|
370 |
if($notification_email)
|
371 |
$utility->send_email($notification_email,$subject,$message);
|
372 |
+
|
373 |
+
$logger->log_info(__function__,"End");
|
374 |
}
|
375 |
|
376 |
function cleanup_on_failure($path){
|
377 |
global $logger;
|
378 |
+
global $wp_backup;
|
379 |
+
|
380 |
if (WPBACKITUP__DEBUG===true){
|
381 |
$logger->log('Cleanup On Fail suspended: debug on.');
|
382 |
}
|
383 |
else{
|
384 |
+
$wp_backup->cleanup_unfinished_backups();
|
385 |
}
|
386 |
}
|
387 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
388 |
function write_fatal_error_status($status_code) {
|
389 |
global $status_array,$active,$failure;
|
390 |
|
443 |
}
|
444 |
|
445 |
//write Response Log
|
446 |
+
function write_response_file($message) {
|
447 |
+
global $wp_backup,$logger;
|
448 |
+
|
449 |
+
$jsonResponse = new stdClass();
|
450 |
+
$jsonResponse->message = $message;
|
451 |
+
$jsonResponse->server_time=$wp_backup->backup_start_time->format('U');
|
452 |
+
|
453 |
+
$json_response = json_encode($jsonResponse);
|
454 |
+
$logger->log('Write response file:' . $json_response);
|
455 |
+
|
456 |
+
$fh=get_response_file();
|
457 |
+
fwrite($fh, $json_response);
|
458 |
+
fclose($fh);
|
459 |
+
}
|
460 |
+
|
461 |
+
//write Response Log
|
462 |
+
function write_response_file_success() {
|
463 |
+
global $WPBackitup,$wp_backup,$logger;
|
464 |
+
|
465 |
+
//Send JSON response
|
466 |
+
$jsonResponse = new stdClass();
|
467 |
+
$jsonResponse->message = 'success';
|
468 |
+
$jsonResponse->file = $wp_backup->backup_filename;
|
469 |
+
$jsonResponse->zip_link = WPBACKITUP__BACKUP_URL . '/' . $wp_backup->backup_filename;
|
470 |
+
$jsonResponse->license = $WPBackitup->license_active();
|
471 |
+
$jsonResponse->retained = $wp_backup->backup_retained_number;
|
472 |
+
|
473 |
+
if (file_exists($logger->logFilePath)) {
|
474 |
+
$jsonResponse->log_link = basename($logger->logFileName,'.log');
|
475 |
+
}
|
476 |
+
|
477 |
+
$json_response = json_encode($jsonResponse);
|
478 |
$logger->log('Write response file:' . $json_response);
|
479 |
|
480 |
$fh=get_response_file();
|
485 |
//Get Response Log
|
486 |
function get_response_file() {
|
487 |
global $logger;
|
488 |
+
$response_file_path = WPBACKITUP__PLUGIN_PATH .'logs/response.log';
|
489 |
$filesytem = new WPBackItUp_FileSystem($logger);
|
490 |
return $filesytem->get_file_handle($response_file_path,true);
|
491 |
}
|
lib/includes/class-backup.php
CHANGED
@@ -7,28 +7,46 @@
|
|
7 |
* @author cssimmon
|
8 |
*
|
9 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
class WPBackItUp_Backup {
|
11 |
|
12 |
private $logger;
|
13 |
|
14 |
//Public Properties
|
15 |
-
public
|
16 |
-
public
|
17 |
-
public
|
18 |
-
public
|
19 |
-
public
|
20 |
-
public
|
21 |
-
public
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
global $WPBackitup;
|
25 |
try {
|
26 |
$this->logger = $logger;
|
|
|
|
|
27 |
$this->backup_name=$backup_name;
|
28 |
$this->backup_filename=$backup_name . '.zip';
|
29 |
|
30 |
$backup_project_path = WPBACKITUP__BACKUP_PATH .'/'. $backup_name .'/';
|
31 |
-
//echo('</br>Backup Proj Path:' .$backup_project_path);
|
32 |
|
33 |
$backup_folder_root =WPBACKITUP__BACKUP_PATH .'/';
|
34 |
$restore_folder_root = WPBACKITUP__RESTORE_FOLDER;
|
@@ -37,20 +55,300 @@ class WPBackItUp_Backup {
|
|
37 |
$this->backup_folder_root=$backup_folder_root;
|
38 |
$this->restore_folder_root=$restore_folder_root;
|
39 |
|
|
|
|
|
40 |
$this->backup_retained_number = $WPBackitup->backup_retained_number();
|
41 |
$this->backup_retained_days = 5; //Prob need to move this to main propery
|
42 |
|
43 |
} catch(Exception $e) {
|
44 |
-
|
45 |
-
|
46 |
}
|
47 |
}
|
48 |
|
49 |
function __destruct() {
|
50 |
-
|
|
|
51 |
}
|
52 |
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
|
|
|
|
|
|
|
|
|
|
55 |
|
|
|
|
|
|
|
56 |
}
|
7 |
* @author cssimmon
|
8 |
*
|
9 |
*/
|
10 |
+
|
11 |
+
/*** Includes ***/
|
12 |
+
// include file system class
|
13 |
+
if( !class_exists( 'WPBackItUp_Filesystem' ) ) {
|
14 |
+
include_once 'class-filesystem.php';
|
15 |
+
}
|
16 |
+
|
17 |
+
|
18 |
+
|
19 |
class WPBackItUp_Backup {
|
20 |
|
21 |
private $logger;
|
22 |
|
23 |
//Public Properties
|
24 |
+
public $backup_name;
|
25 |
+
public $backup_filename;
|
26 |
+
public $backup_project_path;
|
27 |
+
public $backup_folder_root;
|
28 |
+
public $restore_folder_root;
|
29 |
+
public $backup_retained_number;
|
30 |
+
public $backup_retained_days;
|
31 |
+
|
32 |
+
//scheduled,manual,none
|
33 |
+
public $backup_type;
|
34 |
+
public $backup_start_time;
|
35 |
+
public $backup_end_time;
|
36 |
+
|
37 |
+
private $lockFileName;
|
38 |
+
private $lockFile;
|
39 |
+
|
40 |
+
function __construct($logger,$backup_name, $backup_type) {
|
41 |
global $WPBackitup;
|
42 |
try {
|
43 |
$this->logger = $logger;
|
44 |
+
|
45 |
+
$this->backup_type=$backup_type;
|
46 |
$this->backup_name=$backup_name;
|
47 |
$this->backup_filename=$backup_name . '.zip';
|
48 |
|
49 |
$backup_project_path = WPBACKITUP__BACKUP_PATH .'/'. $backup_name .'/';
|
|
|
50 |
|
51 |
$backup_folder_root =WPBACKITUP__BACKUP_PATH .'/';
|
52 |
$restore_folder_root = WPBACKITUP__RESTORE_FOLDER;
|
55 |
$this->backup_folder_root=$backup_folder_root;
|
56 |
$this->restore_folder_root=$restore_folder_root;
|
57 |
|
58 |
+
$this->lockFileName = WPBACKITUP__PLUGIN_PATH .'logs/wpbackitup_lock.lock';
|
59 |
+
|
60 |
$this->backup_retained_number = $WPBackitup->backup_retained_number();
|
61 |
$this->backup_retained_days = 5; //Prob need to move this to main propery
|
62 |
|
63 |
} catch(Exception $e) {
|
64 |
+
$this->logger->log_error(__METHOD__,'Constructor Exception: ' .$e);
|
65 |
+
throw $e;
|
66 |
}
|
67 |
}
|
68 |
|
69 |
function __destruct() {
|
70 |
+
//Call end just in case
|
71 |
+
$this->end();
|
72 |
}
|
73 |
|
74 |
|
75 |
+
/**
|
76 |
+
* Begin backup process - Only one may be running at a time
|
77 |
+
* @return bool
|
78 |
+
*/
|
79 |
+
public function start (){
|
80 |
+
try {
|
81 |
+
$this->logger->log_info(__METHOD__,'Begin - Lock File:' . $this->lockFileName);
|
82 |
+
$this->backup_start_time= new datetime('now');
|
83 |
+
$this->lockFile = fopen( $this->lockFileName ,"w"); // open it for WRITING ("w")
|
84 |
+
if (flock( $this->lockFile, LOCK_EX | LOCK_NB)) {
|
85 |
+
$this->logger->log_info(__METHOD__,'Process LOCK acquired');
|
86 |
+
return true;
|
87 |
+
} else {
|
88 |
+
$this->logger->log_info(__METHOD__,'Process LOCK failed');
|
89 |
+
return false;
|
90 |
+
}
|
91 |
+
|
92 |
+
} catch(Exception $e) {
|
93 |
+
$this->logger->log_info(__METHOD__,'Process Lock error: ' .$e);
|
94 |
+
return false;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* End Backup Process
|
100 |
+
* @return bool
|
101 |
+
*/
|
102 |
+
public function end (){
|
103 |
+
global $WPBackitup;
|
104 |
+
$this->logger->log_info(__METHOD__,'Begin - Unlock File:' . $this->lockFileName);
|
105 |
+
|
106 |
+
$current_datetime = current_time( 'timestamp' );
|
107 |
+
$WPBackitup->set_backup_lastrun_date($current_datetime);
|
108 |
+
|
109 |
+
$this->backup_end_time= new datetime('now');
|
110 |
+
try{
|
111 |
+
$this->logger->log_info(__METHOD__,'LOCK released - backup ending');
|
112 |
+
flock( $this->lockFile, LOCK_UN); // unlock the file
|
113 |
+
return true;
|
114 |
+
|
115 |
+
}catch(Exception $e) {
|
116 |
+
$this->logger->log_error(__METHOD__,'Cant unlock file: ' .$e);
|
117 |
+
return false;
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Check lock status
|
123 |
+
* @return bool
|
124 |
+
*/
|
125 |
+
public function check_lock_status (){
|
126 |
+
//Check for 5 minutes then give up
|
127 |
+
for ($i = 1; $i <= 100; $i++) {
|
128 |
+
if ($this->start()){
|
129 |
+
$this->end();
|
130 |
+
return true;
|
131 |
+
}
|
132 |
+
else{
|
133 |
+
sleep(3); //sleep for 3 seconds
|
134 |
+
}
|
135 |
+
}
|
136 |
+
return false;
|
137 |
+
}
|
138 |
+
|
139 |
+
public function isScheduled(){
|
140 |
+
|
141 |
+
return true;
|
142 |
+
}
|
143 |
+
|
144 |
+
public function cleanup_unfinished_backups(){
|
145 |
+
$dir=$this->backup_folder_root;
|
146 |
+
$this->logger->log_info(__METHOD__,'Begin:'.$dir);
|
147 |
+
$ignore = array('cgi-bin','.','..','._');
|
148 |
+
if( is_dir($dir) ){
|
149 |
+
if($dh = opendir($dir)) {
|
150 |
+
while( ($file = readdir($dh)) !== false ) {
|
151 |
+
$ext = pathinfo($file, PATHINFO_EXTENSION);
|
152 |
+
if (!in_array($file, $ignore) && substr($file, 0, 1) != '.' && $ext!="zip" && $ext!="log") { //Check the file is not in the ignore array
|
153 |
+
if(!is_dir($dir .'/'. $file)) {
|
154 |
+
unlink($dir .'/'. $file);
|
155 |
+
} else {
|
156 |
+
$fileSystem = new WPBackItUp_FileSystem($this->logger);
|
157 |
+
$fileSystem->recursive_delete($dir.'/'. $file, $ignore);
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
+
}
|
162 |
+
closedir($dh);
|
163 |
+
}
|
164 |
+
$this->logger->log_info(__METHOD__,'End');
|
165 |
+
return true;
|
166 |
+
}
|
167 |
+
|
168 |
+
public function cleanup_current_backup(){
|
169 |
+
$path = $this->backup_project_path;
|
170 |
+
$this->logger->log_info(__METHOD__, 'Begin - Cleanup Backup Folder:' . $path);
|
171 |
+
|
172 |
+
$fileSystem = new WPBackItUp_FileSystem($this->logger);
|
173 |
+
if(!$fileSystem ->recursive_delete($path)) {
|
174 |
+
$this->logger->log_error(__METHOD__,'Backup Folder could not be deleted');
|
175 |
+
return false;
|
176 |
+
}
|
177 |
+
|
178 |
+
$this->logger->log_info(__METHOD__,'End - Backup Folder Deleted');
|
179 |
+
return true;
|
180 |
+
}
|
181 |
+
|
182 |
+
public function purge_old_files(){
|
183 |
+
$this->logger->log_info(__METHOD__,'Begin');
|
184 |
+
$fileSystem = new WPBackItUp_FileSystem( $this->logger);
|
185 |
+
|
186 |
+
//Check the retention
|
187 |
+
$fileSystem->purge_FilesByDate($this->backup_retained_number,$this->backup_folder_root);
|
188 |
+
|
189 |
+
//Purge logs older than 5 days
|
190 |
+
$fileSystem->purge_files(WPBACKITUP__BACKUP_PATH .'/','*.log',$this->backup_retained_days);
|
191 |
+
|
192 |
+
//Purge logs in logs older than 5 days
|
193 |
+
$logs_path = WPBACKITUP__PLUGIN_PATH .'/logs/';
|
194 |
+
$fileSystem->purge_files($logs_path,'Backup_*.log',$this->backup_retained_days);
|
195 |
+
|
196 |
+
|
197 |
+
$this->logger->log_info(__METHOD__,'End');
|
198 |
+
|
199 |
+
}
|
200 |
+
|
201 |
+
//Make sure the root backup folder wpbackitup_backups exists
|
202 |
+
public function backup_root_folder_exists(){
|
203 |
+
$this->logger->log_info(__METHOD__,'Begin: ' .$this->backup_folder_root);
|
204 |
+
$fileSystem = new WPBackItUp_FileSystem($this->logger);
|
205 |
+
if(!$fileSystem->create_dir($this->backup_folder_root)) {
|
206 |
+
$this->logger->log_error(__METHOD__,' Cant create backup folder :'. $this->backup_folder_root);
|
207 |
+
return false;
|
208 |
+
}
|
209 |
+
|
210 |
+
$this->logger->log_info(__METHOD__,'End');
|
211 |
+
return true;
|
212 |
+
}
|
213 |
+
|
214 |
+
//Create the root folder for the current backup
|
215 |
+
public function create_current_backup_folder(){
|
216 |
+
$this->logger->log_info(__METHOD__,'Begin: ' .$this->backup_project_path);
|
217 |
+
$fileSystem = new WPBackItUp_FileSystem($this->logger);
|
218 |
+
if(!$fileSystem->create_dir($this->backup_project_path)) {
|
219 |
+
$this->logger->log_error(__METHOD__,'Cant create backup folder :'. $this->backup_project_path);
|
220 |
+
return false;
|
221 |
+
}
|
222 |
+
|
223 |
+
$this->logger->log_info(__METHOD__,'End');
|
224 |
+
return true;
|
225 |
+
}
|
226 |
+
|
227 |
+
//Check to see if the directory exists and is writeable
|
228 |
+
public function backup_folder_exists(){
|
229 |
+
$path=$this->backup_project_path;
|
230 |
+
$this->logger->log_info(__METHOD__,'Is folder writeable: ' .$path);
|
231 |
+
if(is_writeable($path)) {
|
232 |
+
$this->logger->log_info(__METHOD__,'Folder IS writeable');
|
233 |
+
return true;
|
234 |
+
}
|
235 |
+
|
236 |
+
$this->logger->log_error(__METHOD__,'Folder NOT writeable');
|
237 |
+
return false;
|
238 |
+
}
|
239 |
+
|
240 |
+
//Export the SQL database
|
241 |
+
public function export_database(){
|
242 |
+
$sql_file_name=$this->backup_project_path . WPBACKITUP__SQL_DBBACKUP_FILENAME;
|
243 |
+
$sqlUtil = new WPBackItUp_SQL($this->logger);
|
244 |
+
$this->logger->log_info(__METHOD__,'Begin - Export Database: ' .$sql_file_name);
|
245 |
+
|
246 |
+
//Try SQLDump First
|
247 |
+
$this->logger->log_info(__METHOD__,'Export DB with MYSQLDUMP');
|
248 |
+
if(!$sqlUtil->mysqldump_export($sql_file_name) ) {
|
249 |
+
|
250 |
+
$this->logger->log_info(__METHOD__,'Export DB with MYSQLDUMP/PATH');
|
251 |
+
if(!$sqlUtil->mysqldump_export($sql_file_name,true) ) {
|
252 |
+
|
253 |
+
$this->logger->log_info(__METHOD__,'Export DB with Manual SQL EXPORT');
|
254 |
+
if(!$sqlUtil->manual_export($sql_file_name) ) {
|
255 |
+
$this->logger->log_error(__METHOD__,'SQL EXPORT FAILED');
|
256 |
+
return false;
|
257 |
+
}
|
258 |
+
}
|
259 |
+
}
|
260 |
+
$this->logger->log_info(__METHOD__,'Database Exported successfully');
|
261 |
+
return true;
|
262 |
+
}
|
263 |
+
|
264 |
+
//Create siteinfo in project dir
|
265 |
+
public function create_siteinfo_file(){
|
266 |
+
global $table_prefix; //from wp-config
|
267 |
+
$path=$this->backup_project_path;
|
268 |
+
$siteinfo = $path ."backupsiteinfo.txt";
|
269 |
+
|
270 |
+
$this->logger->log_info(__METHOD__,'Create Site Info File:'.$siteinfo);
|
271 |
+
try {
|
272 |
+
$handle = fopen($siteinfo, 'w+');
|
273 |
+
if (false===$handle){
|
274 |
+
$this->logger->log_error(__METHOD__,'Cant open file.');
|
275 |
+
return false;
|
276 |
+
}
|
277 |
+
|
278 |
+
//Write Site URL
|
279 |
+
$entry = site_url( '/' ) ."\n";
|
280 |
+
fwrite($handle, $entry);
|
281 |
+
|
282 |
+
//Write Table Prefix
|
283 |
+
$entry = $table_prefix ."\n" ;
|
284 |
+
fwrite($handle, $entry);
|
285 |
+
|
286 |
+
//write WP version
|
287 |
+
$entry =get_bloginfo( 'version')."\n" ;
|
288 |
+
fwrite($handle, $entry);
|
289 |
+
fclose($handle);
|
290 |
+
|
291 |
+
if (file_exists($siteinfo)){
|
292 |
+
$this->logger->log_info(__METHOD__,'File created successfully.');
|
293 |
+
return true;
|
294 |
+
}
|
295 |
+
|
296 |
+
}catch(Exception $e) {
|
297 |
+
$this->this->logger->log_error(__METHOD__,' Exception: ' .$e);
|
298 |
+
}
|
299 |
+
|
300 |
+
$this->logger->log_error(__METHOD__,'Site Info File NOT Created.');
|
301 |
+
return false;
|
302 |
+
}
|
303 |
+
|
304 |
+
//BackUp WPContent
|
305 |
+
public function backup_wpcontent(){
|
306 |
+
$fromFolder = WPBACKITUP__CONTENT_PATH . '/';
|
307 |
+
$ignore = array( WPBACKITUP__BACKUP_FOLDER,$this->backup_name,$this->restore_folder_root,'upgrade','cache' );
|
308 |
+
|
309 |
+
$this->logger->log_info(__METHOD__,'Begin');
|
310 |
+
|
311 |
+
$this->logger->log_info(__METHOD__,'Recursive Copy FROM:'.$fromFolder);
|
312 |
+
$this->logger->log_info(__METHOD__,'Recursive Copy TO:'.$this->backup_project_path);
|
313 |
+
$this->logger->log_info(__METHOD__,$ignore,'Ignore Array');
|
314 |
+
|
315 |
+
$fileSystem = new WPBackItUp_FileSystem($this->logger);
|
316 |
+
if(!$fileSystem->recursive_copy($fromFolder, $this->backup_project_path, $ignore) ) {
|
317 |
+
$this->logger->log_error(__METHOD__,'Site content was NOT copied successfully.');
|
318 |
+
return false;
|
319 |
+
}
|
320 |
+
$this->logger->log_info(__METHOD__,'Site content copied successfully.');
|
321 |
+
return true;
|
322 |
+
}
|
323 |
+
|
324 |
+
public function validate_wpcontent(){
|
325 |
+
$this->logger->log_info(__METHOD__,'Begin - Validate WPContent');
|
326 |
+
|
327 |
+
$source_dir_path = WPBACKITUP__CONTENT_PATH . '/';
|
328 |
+
$target_dir_path = $this->backup_project_path;
|
329 |
+
|
330 |
+
$this->logger->log_info(__METHOD__,'Validate content folder TO:' .$source_dir_path);
|
331 |
+
$this->logger->log_info(__METHOD__,'Validate content folder FROM:' .$target_dir_path);
|
332 |
+
|
333 |
+
$ignore = array(WPBACKITUP__PLUGIN_FOLDER,'debug.log','backupsiteinfo.txt','db-backup.sql');
|
334 |
+
$filesystem = new WPBackItUp_FileSystem($this->logger);
|
335 |
+
if(!$filesystem->recursive_validate($source_dir_path. '/', $target_dir_path . '/',$ignore)) {
|
336 |
+
$this->logger->log_error(__METHOD__,'Content folder is not the same as backup.');
|
337 |
+
}
|
338 |
+
|
339 |
+
$this->logger->log_info(__METHOD__,'End - Validate WPContent');
|
340 |
+
}
|
341 |
+
|
342 |
+
public function compress_backup(){
|
343 |
+
$this->logger->log_info(__METHOD__, 'Begin - Compress the backup:'.$this->backup_project_path);
|
344 |
|
345 |
+
$zip = new WPBackItUp_Zip($this->logger);
|
346 |
+
if (!$zip->compress($this->backup_project_path, $this->backup_folder_root)){
|
347 |
+
$this->logger->log_error(__METHOD__, 'Could not compress backup folder');
|
348 |
+
return false;
|
349 |
+
}
|
350 |
|
351 |
+
$this->logger->log_info(__METHOD__, 'End - Compress the backup');
|
352 |
+
return true;
|
353 |
+
}
|
354 |
}
|
lib/includes/class-filesystem.php
CHANGED
@@ -121,10 +121,10 @@ class WPBackItUp_FileSystem {
|
|
121 |
}
|
122 |
|
123 |
public function recursive_validate($source_path, $target_path, $ignore = array('') ) {
|
124 |
-
$this->logger->log('(FileSystem.recursive_validate) Recursive validate FROM: ' .$source_path);
|
125 |
-
$this->logger->log('(FileSystem.recursive_validate) Recursive validate TO: '.$target_path);
|
126 |
-
$this->logger->log('(FileSystem.recursive_validate) IGNORE:');
|
127 |
-
$this->logger->log($ignore);
|
128 |
|
129 |
$rtnVal=true;
|
130 |
if( is_dir($source_path) ) { //If the directory exists
|
@@ -176,7 +176,7 @@ class WPBackItUp_FileSystem {
|
|
176 |
}
|
177 |
}
|
178 |
|
179 |
-
|
180 |
return $rtnVal;
|
181 |
}
|
182 |
|
@@ -190,7 +190,7 @@ class WPBackItUp_FileSystem {
|
|
190 |
($file == "._" ) ||
|
191 |
($file == "cgi-bin" )) {
|
192 |
|
193 |
-
|
194 |
return true;
|
195 |
}
|
196 |
|
@@ -283,19 +283,19 @@ class WPBackItUp_FileSystem {
|
|
283 |
$this->logger->log('(FileSytem.purge_FilesByDate) Completed.');
|
284 |
}
|
285 |
|
286 |
-
public function purge_files($path, $
|
287 |
{
|
288 |
$this->logger->log('(FileSytem.purge_files) Purge files days:' . $days);
|
289 |
$this->logger->log('(FileSytem.purge_files) Purge files path:' . $path);
|
290 |
-
$this->logger->log('(FileSytem.purge_files) Purge files extension:' . $
|
291 |
|
292 |
//Check Parms
|
293 |
-
if (empty($path) || empty($
|
294 |
$this->logger->log('(FileSytem.purge_files) Invalid Parm values');
|
295 |
return false;
|
296 |
}
|
297 |
|
298 |
-
$FileList = glob($path .
|
299 |
//Sort by Date Time
|
300 |
usort($FileList, create_function('$a,$b', 'return filemtime($a) - filemtime($b);'));
|
301 |
|
@@ -326,12 +326,31 @@ class WPBackItUp_FileSystem {
|
|
326 |
function get_file_handle($path,$newFile) {
|
327 |
$this->logger->log('(FileSytem.get_file_handle) Path:' . $path);
|
328 |
|
329 |
-
|
330 |
-
|
331 |
-
$
|
332 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
|
334 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
}
|
336 |
|
337 |
|
121 |
}
|
122 |
|
123 |
public function recursive_validate($source_path, $target_path, $ignore = array('') ) {
|
124 |
+
// $this->logger->log('(FileSystem.recursive_validate) Recursive validate FROM: ' .$source_path);
|
125 |
+
// $this->logger->log('(FileSystem.recursive_validate) Recursive validate TO: '.$target_path);
|
126 |
+
// $this->logger->log('(FileSystem.recursive_validate) IGNORE:');
|
127 |
+
// $this->logger->log($ignore);
|
128 |
|
129 |
$rtnVal=true;
|
130 |
if( is_dir($source_path) ) { //If the directory exists
|
176 |
}
|
177 |
}
|
178 |
|
179 |
+
//$this->logger->log('(FileSystem.recursive_validate) Completed:' . ($rtnVal ? 'true' : 'false'));
|
180 |
return $rtnVal;
|
181 |
}
|
182 |
|
190 |
($file == "._" ) ||
|
191 |
($file == "cgi-bin" )) {
|
192 |
|
193 |
+
//$this->logger->log('(FileSystem.ignore) IGNORE:'.$file);
|
194 |
return true;
|
195 |
}
|
196 |
|
283 |
$this->logger->log('(FileSytem.purge_FilesByDate) Completed.');
|
284 |
}
|
285 |
|
286 |
+
public function purge_files($path, $file_pattern, $days)
|
287 |
{
|
288 |
$this->logger->log('(FileSytem.purge_files) Purge files days:' . $days);
|
289 |
$this->logger->log('(FileSytem.purge_files) Purge files path:' . $path);
|
290 |
+
$this->logger->log('(FileSytem.purge_files) Purge files extension:' . $file_pattern);
|
291 |
|
292 |
//Check Parms
|
293 |
+
if (empty($path) || empty($file_pattern) || !is_numeric($days)){
|
294 |
$this->logger->log('(FileSytem.purge_files) Invalid Parm values');
|
295 |
return false;
|
296 |
}
|
297 |
|
298 |
+
$FileList = glob($path . $file_pattern);
|
299 |
//Sort by Date Time
|
300 |
usort($FileList, create_function('$a,$b', 'return filemtime($a) - filemtime($b);'));
|
301 |
|
326 |
function get_file_handle($path,$newFile) {
|
327 |
$this->logger->log('(FileSytem.get_file_handle) Path:' . $path);
|
328 |
|
329 |
+
try {
|
330 |
+
|
331 |
+
if ($newFile && file_exists($path)){
|
332 |
+
if (unlink($path)){
|
333 |
+
$this->logger->log('(FileSytem.get_file_handle) Deleted:' . $path);
|
334 |
+
}
|
335 |
+
else{
|
336 |
+
$this->logger->log('(FileSytem.get_file_handle) File could not be deleted:');
|
337 |
+
$this->logger->log(error_get_last());
|
338 |
+
}
|
339 |
+
}
|
340 |
|
341 |
+
$fh= fopen($path, 'w');
|
342 |
+
if (false===$fh){
|
343 |
+
$this->logger->log('(FileSytem.get_file_handle) File could not be opened:');
|
344 |
+
$this->logger->log(error_get_last());
|
345 |
+
return false;
|
346 |
+
}
|
347 |
+
|
348 |
+
return $fh;
|
349 |
+
|
350 |
+
} catch(Exception $e) {
|
351 |
+
$this->logger->log('(FileSytem.get_file_handle) Exception:' . $e);
|
352 |
+
return false;
|
353 |
+
}
|
354 |
}
|
355 |
|
356 |
|
lib/includes/class-logger.php
CHANGED
@@ -57,18 +57,22 @@ class WPBackItUp_Logger {
|
|
57 |
}
|
58 |
|
59 |
function __destruct() {
|
60 |
-
|
61 |
-
//fwrite($this->dfh,"***file closed***" .PHP_EOL);
|
62 |
-
if (!is_null($this->dfh) && is_resource($this->dfh)){
|
63 |
-
fwrite($this->dfh, "** Close LOG File ** ". PHP_EOL);
|
64 |
-
fclose($this->dfh);
|
65 |
-
}
|
66 |
-
} catch(Exception $e) {
|
67 |
-
//Dont do anything
|
68 |
-
print $e;
|
69 |
-
}
|
70 |
}
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
function log($message) {
|
74 |
try{
|
@@ -88,6 +92,28 @@ class WPBackItUp_Logger {
|
|
88 |
}
|
89 |
}
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
function logConstants() {
|
92 |
global $WPBackitup;
|
93 |
try{
|
57 |
}
|
58 |
|
59 |
function __destruct() {
|
60 |
+
$this->close_file();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
|
63 |
+
public function close_file() {
|
64 |
+
try {
|
65 |
+
if (!is_null($this->dfh) && is_resource($this->dfh)){
|
66 |
+
fwrite($this->dfh, "** Close LOG File ** ". PHP_EOL);
|
67 |
+
fclose($this->dfh);
|
68 |
+
}
|
69 |
+
} catch(Exception $e) {
|
70 |
+
//Dont do anything
|
71 |
+
print $e;
|
72 |
+
}
|
73 |
+
|
74 |
+
$this->dfh=null;
|
75 |
+
}
|
76 |
|
77 |
function log($message) {
|
78 |
try{
|
92 |
}
|
93 |
}
|
94 |
|
95 |
+
//Log Errors
|
96 |
+
public function log_info($function,$message, $additional_message=null) {
|
97 |
+
$function='(' . $function . ') INFO: ' . $additional_message;
|
98 |
+
if( is_array( $message ) || is_object( $message ) ){
|
99 |
+
$this->log($function);
|
100 |
+
$this->log($message);
|
101 |
+
} else {
|
102 |
+
$this->log($function . $message);
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
//Log Errors
|
107 |
+
public function log_error($function,$message,$additional_message=null) {
|
108 |
+
$function='(' . $function . ') ERROR: ' . $additional_message;
|
109 |
+
if( is_array( $message ) || is_object( $message ) ){
|
110 |
+
$this->log($function);
|
111 |
+
$this->log($message);
|
112 |
+
} else {
|
113 |
+
$this->log($function .$message);
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
function logConstants() {
|
118 |
global $WPBackitup;
|
119 |
try{
|
lib/includes/class-scheduler.php
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP BackItUp Scheduler Class
|
4 |
+
*
|
5 |
+
* @package WP Backitup
|
6 |
+
*
|
7 |
+
* @author cssimmon
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
|
11 |
+
class WPBackItUp_Scheduler {
|
12 |
+
|
13 |
+
|
14 |
+
private $logger;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Constructor
|
18 |
+
*/
|
19 |
+
function __construct() {
|
20 |
+
|
21 |
+
$this->logger = new WPBackItUp_Logger(false,null,'task_scheduler');
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Destructor
|
27 |
+
*/
|
28 |
+
function __destruct() {
|
29 |
+
$this->logger->close_file();
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Check to see if task is ready to run
|
35 |
+
*
|
36 |
+
* @param $task
|
37 |
+
* @return bool
|
38 |
+
*/
|
39 |
+
public function isTaskScheduled($task){
|
40 |
+
$this->logger->log('Check schedule for task: ' . $task);
|
41 |
+
switch ($task) {
|
42 |
+
case "backup":
|
43 |
+
return $this->check_backup_schedule();
|
44 |
+
break;
|
45 |
+
case "cleanup":
|
46 |
+
return $this->check_cleanup_schedule();
|
47 |
+
break;
|
48 |
+
}
|
49 |
+
|
50 |
+
$this->logger->log('Task not found:' . $task);
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Check the backup schedule to determine if the backup
|
56 |
+
* task should be run today.
|
57 |
+
*
|
58 |
+
* @return bool
|
59 |
+
*/
|
60 |
+
private function check_backup_schedule(){
|
61 |
+
global $WPBackitup;
|
62 |
+
$this->logger->log('**Check Backup Schedule**');
|
63 |
+
|
64 |
+
try {
|
65 |
+
|
66 |
+
///ONLY active premium get this feature
|
67 |
+
if (!$WPBackitup->license_active() || 'expired'== $WPBackitup->license_status()){
|
68 |
+
$this->logger->log('License is not active');
|
69 |
+
return false;
|
70 |
+
}
|
71 |
+
|
72 |
+
//Get days scheduled to run on.
|
73 |
+
$scheduled_dow = $WPBackitup->backup_schedule();
|
74 |
+
$this->logger->log('Scheduled Days of week: ' .$scheduled_dow); //1=monday, 2=tuesday..
|
75 |
+
|
76 |
+
//What is the current day of the week
|
77 |
+
$current_datetime = current_time( 'timestamp' );
|
78 |
+
$current_date = date("Ymd",$current_datetime);
|
79 |
+
$current_dow = date("N",$current_datetime); //1=monday
|
80 |
+
|
81 |
+
$this->logger->log('Current Date time:' . date( 'Y-m-d H:i:s',$current_datetime));
|
82 |
+
$this->logger->log('Current Day of Week:' . $current_dow );
|
83 |
+
|
84 |
+
//Get Last RUN date
|
85 |
+
$lastrun_datetime = $WPBackitup->backup_lastrun_date();
|
86 |
+
|
87 |
+
$lastrun_date = date("Ymd",$lastrun_datetime);
|
88 |
+
$lastrun_dow =0;//0=none
|
89 |
+
if ($lastrun_datetime!=2147483648){// 1901-12-13:never run
|
90 |
+
$lastrun_dow = date("N",$lastrun_datetime);
|
91 |
+
}
|
92 |
+
|
93 |
+
$this->logger->log('Last Run Date Time:' . date( 'Y-m-d H:i:s',$lastrun_datetime));
|
94 |
+
$this->logger->log('Last Run Day of Week:' . $lastrun_dow);
|
95 |
+
|
96 |
+
//Did backup already run today
|
97 |
+
if ($current_date==$lastrun_date){
|
98 |
+
$this->logger->log('Backup already ran today');
|
99 |
+
return false;
|
100 |
+
}
|
101 |
+
|
102 |
+
//Should it run on this day of the week
|
103 |
+
if (false===strpos($scheduled_dow,$current_dow)){
|
104 |
+
$this->logger->log('Not scheduled for: ' .$current_dow);
|
105 |
+
return false;
|
106 |
+
}
|
107 |
+
|
108 |
+
$this->logger->log('Backup should be run now.');
|
109 |
+
return true;
|
110 |
+
|
111 |
+
}catch(Exception $e) {
|
112 |
+
$this->logger->log_error(__METHOD__,'Exception: ' .$e);
|
113 |
+
return false;
|
114 |
+
}
|
115 |
+
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Check the cleanup schedule to determine if the task should be run today.
|
120 |
+
* Cleanup will be run once per day
|
121 |
+
*
|
122 |
+
* @return bool
|
123 |
+
*/
|
124 |
+
private function check_cleanup_schedule(){
|
125 |
+
global $WPBackitup;
|
126 |
+
$this->logger->log('**Check Cleanup Schedule**');
|
127 |
+
try {
|
128 |
+
|
129 |
+
//What is the current day of the week
|
130 |
+
$current_datetime = current_time( 'timestamp' );
|
131 |
+
$current_date = date("Ymd",$current_datetime);
|
132 |
+
|
133 |
+
$this->logger->log('Current Date time:' . date( 'Y-m-d H:i:s',$current_datetime));
|
134 |
+
|
135 |
+
//Get Last RUN date
|
136 |
+
$lastrun_datetime = $WPBackitup->cleanup_lastrun_date();
|
137 |
+
|
138 |
+
$lastrun_date = date("Ymd",$lastrun_datetime);
|
139 |
+
$this->logger->log('Last Run Date Time:' . date( 'Y-m-d H:i:s',$lastrun_datetime));
|
140 |
+
|
141 |
+
//Did cleanup already run today
|
142 |
+
if ($current_date==$lastrun_date){
|
143 |
+
$this->logger->log('Cleanup already ran today');
|
144 |
+
return false;
|
145 |
+
}
|
146 |
+
|
147 |
+
$this->logger->log('Cleanup should be run now.');
|
148 |
+
return true;
|
149 |
+
|
150 |
+
}catch(Exception $e) {
|
151 |
+
$this->logger->log_error(__METHOD__,'Exception: ' .$e);
|
152 |
+
return false;
|
153 |
+
}
|
154 |
+
|
155 |
+
}
|
156 |
+
}
|
lib/includes/class-sql.php
CHANGED
@@ -29,9 +29,9 @@ class WPBackItUp_SQL {
|
|
29 |
$this->connection->close() ;
|
30 |
}
|
31 |
|
32 |
-
public function mysqldump_export($sql_file_path) {
|
33 |
|
34 |
-
$this->logger->log('(SQL.mysqldump_export)
|
35 |
|
36 |
$db_name = DB_NAME;
|
37 |
$db_user = DB_USER;
|
@@ -42,9 +42,14 @@ class WPBackItUp_SQL {
|
|
42 |
//This is to ensure that exec() is enabled on the server
|
43 |
if(exec('echo EXEC') == 'EXEC') {
|
44 |
try {
|
45 |
-
|
|
|
|
|
|
|
|
|
46 |
|
47 |
-
|
|
|
48 |
. ' --host=' . $db_host;
|
49 |
|
50 |
//Check for port
|
@@ -67,27 +72,28 @@ class WPBackItUp_SQL {
|
|
67 |
|
68 |
//0 is success
|
69 |
if ($rtn_var>0){
|
|
|
70 |
return false;
|
71 |
}
|
72 |
|
73 |
//Did the export work
|
74 |
clearstatcache();
|
75 |
if (!file_exists($sql_file_path) || filesize($sql_file_path)<=0) {
|
76 |
-
$this->logger->log('(SQL.mysqldump_export)
|
77 |
return false;
|
78 |
}
|
79 |
} catch(Exception $e) {
|
80 |
-
$this->logger->log('(SQL.mysqldump_export) Exception: ' .$e);
|
81 |
return false;
|
82 |
}
|
83 |
}
|
84 |
else
|
85 |
{
|
86 |
-
$this->logger->log('(SQL.mysqldump_export)
|
87 |
return false;
|
88 |
}
|
89 |
|
90 |
-
$this->logger->log('(SQL.mysqldump_export) SQL Dump
|
91 |
return true;
|
92 |
}
|
93 |
|
@@ -451,7 +457,6 @@ class WPBackItUp_SQL {
|
|
451 |
|
452 |
//Get SQL scalar value
|
453 |
public function get_sql_scalar($sql){
|
454 |
-
global $logger;
|
455 |
$value='';
|
456 |
if ($result = mysqli_query($this->connection, $sql)) {
|
457 |
while ($row = mysqli_fetch_row($result)) {
|
@@ -464,14 +469,25 @@ class WPBackItUp_SQL {
|
|
464 |
|
465 |
//Run SQL command
|
466 |
public function run_sql_command($sql){
|
467 |
-
global $logger;
|
468 |
if(!mysqli_query($this->connection, $sql) ) {
|
469 |
-
$logger->log('Error:SQL Command Failed:' .$sql);
|
470 |
return false;
|
471 |
}
|
472 |
return true;
|
473 |
}
|
474 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
475 |
//This function is untested
|
476 |
// function get_database_size($dbname) {
|
477 |
// mysqli_select_db($dbname);
|
29 |
$this->connection->close() ;
|
30 |
}
|
31 |
|
32 |
+
public function mysqldump_export($sql_file_path,$with_mysqlpath=false) {
|
33 |
|
34 |
+
$this->logger->log('(SQL.mysqldump_export) Export Database to: ' .$sql_file_path);
|
35 |
|
36 |
$db_name = DB_NAME;
|
37 |
$db_user = DB_USER;
|
42 |
//This is to ensure that exec() is enabled on the server
|
43 |
if(exec('echo EXEC') == 'EXEC') {
|
44 |
try {
|
45 |
+
$mysql_path='';
|
46 |
+
if ($with_mysqlpath) {
|
47 |
+
$mysql_path = $this->get_mysql_path();
|
48 |
+
if ($mysql_path===false) return false;
|
49 |
+
}
|
50 |
|
51 |
+
$process = $mysql_path .'mysqldump';
|
52 |
+
$command = $process
|
53 |
. ' --host=' . $db_host;
|
54 |
|
55 |
//Check for port
|
72 |
|
73 |
//0 is success
|
74 |
if ($rtn_var>0){
|
75 |
+
$this->logger->log('(SQL.mysqldump_export) EXPORT FAILED return Value:' .$rtn_var);
|
76 |
return false;
|
77 |
}
|
78 |
|
79 |
//Did the export work
|
80 |
clearstatcache();
|
81 |
if (!file_exists($sql_file_path) || filesize($sql_file_path)<=0) {
|
82 |
+
$this->logger->log('(SQL.mysqldump_export) EXPORT FAILED: Dump was empty or missing.');
|
83 |
return false;
|
84 |
}
|
85 |
} catch(Exception $e) {
|
86 |
+
$this->logger->log('(SQL.mysqldump_export) EXPORT FAILED Exception: ' .$e);
|
87 |
return false;
|
88 |
}
|
89 |
}
|
90 |
else
|
91 |
{
|
92 |
+
$this->logger->log('(SQL.mysqldump_export) EXPORT FAILED Exec() disabled.');
|
93 |
return false;
|
94 |
}
|
95 |
|
96 |
+
$this->logger->log('(SQL.mysqldump_export) SQL Dump SUCCESS.');
|
97 |
return true;
|
98 |
}
|
99 |
|
457 |
|
458 |
//Get SQL scalar value
|
459 |
public function get_sql_scalar($sql){
|
|
|
460 |
$value='';
|
461 |
if ($result = mysqli_query($this->connection, $sql)) {
|
462 |
while ($row = mysqli_fetch_row($result)) {
|
469 |
|
470 |
//Run SQL command
|
471 |
public function run_sql_command($sql){
|
|
|
472 |
if(!mysqli_query($this->connection, $sql) ) {
|
473 |
+
$this->logger->log('Error:SQL Command Failed:' .$sql);
|
474 |
return false;
|
475 |
}
|
476 |
return true;
|
477 |
}
|
478 |
|
479 |
+
//Get path to MQSQL Bin
|
480 |
+
private function get_mysql_path(){
|
481 |
+
$base_directory = $this->get_sql_scalar('select @@basedir');
|
482 |
+
if (!empty($base_directory)){
|
483 |
+
$base_directory.='/bin/';
|
484 |
+
$this->logger->log('MySQL install path found:' .$base_directory);
|
485 |
+
return $base_directory;
|
486 |
+
}
|
487 |
+
$this->logger->log('MySQL install path NOT found');
|
488 |
+
return false;
|
489 |
+
}
|
490 |
+
|
491 |
//This function is untested
|
492 |
// function get_database_size($dbname) {
|
493 |
// mysqli_select_db($dbname);
|
lib/includes/class-wpbackitup-admin.php
CHANGED
@@ -33,6 +33,9 @@ class WPBackitup_Admin {
|
|
33 |
|
34 |
private $backup_count; //getter will load
|
35 |
private $successful_backup_count;
|
|
|
|
|
|
|
36 |
|
37 |
// Default plugin options
|
38 |
public $defaults = array(
|
@@ -52,6 +55,9 @@ class WPBackitup_Admin {
|
|
52 |
'backup_count'=>0,
|
53 |
'successful_backup_count'=>0,
|
54 |
'stats_last_check_date'=> "1970-01-01 00:00:00",
|
|
|
|
|
|
|
55 |
);
|
56 |
|
57 |
|
@@ -93,7 +99,7 @@ class WPBackitup_Admin {
|
|
93 |
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
94 |
|
95 |
// Route requests for form processing
|
96 |
-
add_action( 'admin_init', array( &$this, 'route' ) );
|
97 |
|
98 |
// Add a settings link next to the "Deactivate" link on the plugin listing page
|
99 |
add_filter( 'plugin_action_links', array( &$this, 'plugin_action_links' ), 10, 2 );
|
@@ -124,8 +130,11 @@ class WPBackitup_Admin {
|
|
124 |
//List Logs Action
|
125 |
add_action('admin_post_nopriv_listlogs', array( &$this,'admin_listlogs'));
|
126 |
|
127 |
-
|
|
|
128 |
|
|
|
|
|
129 |
|
130 |
/**
|
131 |
*
|
@@ -179,7 +188,7 @@ class WPBackitup_Admin {
|
|
179 |
// Admin Stylesheet
|
180 |
wp_register_style( "{$this->namespace}-admin", WPBACKITUP__PLUGIN_URL . "css/wpbackitup_admin.css", array(), $this->version, 'screen' );
|
181 |
|
182 |
-
wp_register_style( 'google-fonts', '//netdna.bootstrapcdn.com/font-awesome/4.0
|
183 |
wp_enqueue_style( 'google-fonts' );
|
184 |
}
|
185 |
|
@@ -260,18 +269,37 @@ class WPBackitup_Admin {
|
|
260 |
// Check if a nonce was passed in the request
|
261 |
if( isset( $_REQUEST['_wpnonce'] ) ) {
|
262 |
$nonce = $_REQUEST['_wpnonce'];
|
263 |
-
|
|
|
|
|
264 |
|
265 |
// Handle POST requests
|
266 |
if( $is_post ) {
|
267 |
|
268 |
if( wp_verify_nonce( $nonce, "{$this->namespace}-update-options" ) ) {
|
|
|
269 |
$this->_admin_options_update();
|
270 |
}
|
271 |
|
272 |
if( wp_verify_nonce( $nonce, "{$this->namespace}-register-lite" ) ) {
|
|
|
273 |
$this->_admin_register_lite();
|
274 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
}
|
276 |
// Handle GET requests
|
277 |
else {
|
@@ -283,8 +311,36 @@ class WPBackitup_Admin {
|
|
283 |
public function initialize(){
|
284 |
$this->check_license();
|
285 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
//load backup
|
287 |
public function ajax_backup() {
|
|
|
288 |
include_once( WPBACKITUP__PLUGIN_PATH.'/lib/includes/backup.php' );
|
289 |
}
|
290 |
|
@@ -426,6 +482,37 @@ class WPBackitup_Admin {
|
|
426 |
}
|
427 |
}
|
428 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
429 |
/**
|
430 |
* Process registration page form submissions
|
431 |
*
|
@@ -595,6 +682,19 @@ class WPBackitup_Admin {
|
|
595 |
return $logging === 'true'? true: false;
|
596 |
}
|
597 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
598 |
/**
|
599 |
* Getter - license active - derived property
|
600 |
*/
|
@@ -749,6 +849,17 @@ class WPBackitup_Admin {
|
|
749 |
$this->set('successful_backup_count', $value);
|
750 |
}
|
751 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
752 |
/**---------- END SETTERS --------------- **/
|
753 |
|
754 |
|
@@ -1002,30 +1113,36 @@ class WPBackitup_Admin {
|
|
1002 |
* Activation action
|
1003 |
*/
|
1004 |
public static function activate() {
|
1005 |
-
// $logger = new WPBackItUp_Logger(true);
|
1006 |
-
|
1007 |
try{
|
|
|
|
|
|
|
|
|
|
|
1008 |
//Check backup folder folders
|
1009 |
$backup_dir = WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__BACKUP_FOLDER;
|
1010 |
if( !is_dir($backup_dir) ) {
|
1011 |
@mkdir($backup_dir, 0755);
|
1012 |
-
// $logger->log('Backup Folder Created:' . $backup_dir);
|
1013 |
}
|
1014 |
|
1015 |
//Check restore folder folders
|
1016 |
$restore_dir = WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__RESTORE_FOLDER;
|
1017 |
if( !is_dir($restore_dir) ) {
|
1018 |
@mkdir($restore_dir, 0755);
|
1019 |
-
// $logger->log('Restore Folder Created:' . $backup_dir);
|
1020 |
}
|
1021 |
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1026 |
|
1027 |
} catch (Exception $e) {
|
1028 |
-
// $logger->log(' Activation Exception:' . $e->getMessage());
|
1029 |
exit ('WP BackItUp encountered an error during activation.</br>' .$e->getMessage());
|
1030 |
}
|
1031 |
}
|
@@ -1036,6 +1153,7 @@ class WPBackitup_Admin {
|
|
1036 |
public static function deactivate() {
|
1037 |
// Do deactivation actions
|
1038 |
|
|
|
1039 |
}
|
1040 |
|
1041 |
/* --------------------- PRIVATES -----------------------------------------*/
|
33 |
|
34 |
private $backup_count; //getter will load
|
35 |
private $successful_backup_count;
|
36 |
+
|
37 |
+
public $backup_type;
|
38 |
+
|
39 |
|
40 |
// Default plugin options
|
41 |
public $defaults = array(
|
55 |
'backup_count'=>0,
|
56 |
'successful_backup_count'=>0,
|
57 |
'stats_last_check_date'=> "1970-01-01 00:00:00",
|
58 |
+
'backup_schedule'=>"",
|
59 |
+
'backup_lastrun_date'=>"2147483648",
|
60 |
+
'cleanup_lastrun_date'=>"2147483648",
|
61 |
);
|
62 |
|
63 |
|
99 |
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
100 |
|
101 |
// Route requests for form processing
|
102 |
+
add_action( 'admin_init', array( &$this, 'route' ) );
|
103 |
|
104 |
// Add a settings link next to the "Deactivate" link on the plugin listing page
|
105 |
add_filter( 'plugin_action_links', array( &$this, 'plugin_action_links' ), 10, 2 );
|
130 |
//List Logs Action
|
131 |
add_action('admin_post_nopriv_listlogs', array( &$this,'admin_listlogs'));
|
132 |
|
133 |
+
//Create Daily backup action
|
134 |
+
add_action( 'wpbackitup_check_scheduled_tasks', array( &$this,'wpbackitup_check_scheduled_tasks'));
|
135 |
|
136 |
+
add_action( 'wpbackitup_resume_backup', array( &$this,'wpbackitup_resume_backup'));
|
137 |
+
}
|
138 |
|
139 |
/**
|
140 |
*
|
188 |
// Admin Stylesheet
|
189 |
wp_register_style( "{$this->namespace}-admin", WPBACKITUP__PLUGIN_URL . "css/wpbackitup_admin.css", array(), $this->version, 'screen' );
|
190 |
|
191 |
+
wp_register_style( 'google-fonts', '//netdna.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.css');
|
192 |
wp_enqueue_style( 'google-fonts' );
|
193 |
}
|
194 |
|
269 |
// Check if a nonce was passed in the request
|
270 |
if( isset( $_REQUEST['_wpnonce'] ) ) {
|
271 |
$nonce = $_REQUEST['_wpnonce'];
|
272 |
+
|
273 |
+
$logger = new WPBackItUp_Logger(false);
|
274 |
+
//$logger->log('NONCE:' .$nonce);
|
275 |
|
276 |
// Handle POST requests
|
277 |
if( $is_post ) {
|
278 |
|
279 |
if( wp_verify_nonce( $nonce, "{$this->namespace}-update-options" ) ) {
|
280 |
+
$logger->log('Update Options Form Post');
|
281 |
$this->_admin_options_update();
|
282 |
}
|
283 |
|
284 |
if( wp_verify_nonce( $nonce, "{$this->namespace}-register-lite" ) ) {
|
285 |
+
$logger->log('Register Lite Form Post');
|
286 |
$this->_admin_register_lite();
|
287 |
}
|
288 |
+
|
289 |
+
if( wp_verify_nonce( $nonce, "{$this->namespace}-update-schedule" ) ) {
|
290 |
+
$logger->log('Update Schedule Form Post');
|
291 |
+
|
292 |
+
$jsonResponse = new stdClass();
|
293 |
+
if ($this->_admin_save_schedule()){
|
294 |
+
$jsonResponse->message = 'success';
|
295 |
+
}else{
|
296 |
+
$jsonResponse->message = 'error';
|
297 |
+
}
|
298 |
+
|
299 |
+
exit(json_encode($jsonResponse));
|
300 |
+
|
301 |
+
}
|
302 |
+
|
303 |
}
|
304 |
// Handle GET requests
|
305 |
else {
|
311 |
public function initialize(){
|
312 |
$this->check_license();
|
313 |
}
|
314 |
+
|
315 |
+
public function wpbackitup_check_scheduled_tasks(){
|
316 |
+
|
317 |
+
if( !class_exists( 'WPBackItUp_Scheduler' ) ) {
|
318 |
+
include_once 'class-scheduler.php';
|
319 |
+
}
|
320 |
+
|
321 |
+
$scheduler = new WPBackItUp_Scheduler();
|
322 |
+
if ($scheduler->isTaskScheduled('backup')){
|
323 |
+
$this->backup_type='scheduled';
|
324 |
+
include_once( WPBACKITUP__PLUGIN_PATH.'/lib/includes/backup.php' );
|
325 |
+
exit(0); //success - don't run anything else after a backup
|
326 |
+
}
|
327 |
+
|
328 |
+
if ($scheduler->isTaskScheduled('cleanup')){
|
329 |
+
$this->backup_type='cleanup';
|
330 |
+
include_once( WPBACKITUP__PLUGIN_PATH.'/lib/includes/backup.php' );
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
//Next Release
|
335 |
+
function wpbackitup_resume_backup(){
|
336 |
+
|
337 |
+
exit(0);
|
338 |
+
|
339 |
+
}
|
340 |
+
|
341 |
//load backup
|
342 |
public function ajax_backup() {
|
343 |
+
$this->backup_type='manual';
|
344 |
include_once( WPBACKITUP__PLUGIN_PATH.'/lib/includes/backup.php' );
|
345 |
}
|
346 |
|
482 |
}
|
483 |
}
|
484 |
|
485 |
+
/**
|
486 |
+
* Save Schedule
|
487 |
+
*
|
488 |
+
*/
|
489 |
+
public function _admin_save_schedule() {
|
490 |
+
// Verify submission for processing using wp_nonce
|
491 |
+
$logger = new WPBackItUp_Logger(false);
|
492 |
+
|
493 |
+
if( wp_verify_nonce( $_REQUEST['_wpnonce'], "{$this->namespace}-update-schedule" ) ) {
|
494 |
+
|
495 |
+
$logger->log("Save Schedule");
|
496 |
+
$logger->log($_POST);
|
497 |
+
|
498 |
+
$val = $_POST['days_selected'];
|
499 |
+
$days_selected = $this->_sanitize($val);
|
500 |
+
$logger->log('Days Selected:' . $days_selected);
|
501 |
+
|
502 |
+
//save option to DB even if empty
|
503 |
+
$this->set_backup_schedule($days_selected);
|
504 |
+
|
505 |
+
//Add backup scheduled if doesnt exist
|
506 |
+
if(!wp_next_scheduled( 'wpbackitup_check_scheduled_tasks' ) ){
|
507 |
+
wp_schedule_event( time()+3600, 'hourly', 'wpbackitup_check_scheduled_tasks');
|
508 |
+
}
|
509 |
+
|
510 |
+
return true;
|
511 |
+
}
|
512 |
+
|
513 |
+
return false;
|
514 |
+
}
|
515 |
+
|
516 |
/**
|
517 |
* Process registration page form submissions
|
518 |
*
|
682 |
return $logging === 'true'? true: false;
|
683 |
}
|
684 |
|
685 |
+
public function backup_schedule(){
|
686 |
+
return $this->get('backup_schedule');
|
687 |
+
}
|
688 |
+
|
689 |
+
public function backup_lastrun_date(){
|
690 |
+
return $this->get('backup_lastrun_date');
|
691 |
+
}
|
692 |
+
|
693 |
+
public function cleanup_lastrun_date(){
|
694 |
+
return $this->get('cleanup_lastrun_date');
|
695 |
+
}
|
696 |
+
|
697 |
+
|
698 |
/**
|
699 |
* Getter - license active - derived property
|
700 |
*/
|
849 |
$this->set('successful_backup_count', $value);
|
850 |
}
|
851 |
|
852 |
+
public function set_backup_schedule($value){
|
853 |
+
$this->set('backup_schedule', $value);
|
854 |
+
}
|
855 |
+
|
856 |
+
public function set_backup_lastrun_date($value){
|
857 |
+
$this->set('backup_lastrun_date', $value);
|
858 |
+
}
|
859 |
+
|
860 |
+
public function set_cleanup_lastrun_date($value){
|
861 |
+
$this->set('cleanup_lastrun_date', $value);
|
862 |
+
}
|
863 |
/**---------- END SETTERS --------------- **/
|
864 |
|
865 |
|
1113 |
* Activation action
|
1114 |
*/
|
1115 |
public static function activate() {
|
|
|
|
|
1116 |
try{
|
1117 |
+
//add cron task for once per hour starting in 1 hour
|
1118 |
+
if(!wp_next_scheduled( 'wpbackitup_check_scheduled_tasks' ) ){
|
1119 |
+
wp_schedule_event( time()+3600, 'hourly', 'wpbackitup_check_scheduled_tasks');
|
1120 |
+
}
|
1121 |
+
|
1122 |
//Check backup folder folders
|
1123 |
$backup_dir = WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__BACKUP_FOLDER;
|
1124 |
if( !is_dir($backup_dir) ) {
|
1125 |
@mkdir($backup_dir, 0755);
|
|
|
1126 |
}
|
1127 |
|
1128 |
//Check restore folder folders
|
1129 |
$restore_dir = WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__RESTORE_FOLDER;
|
1130 |
if( !is_dir($restore_dir) ) {
|
1131 |
@mkdir($restore_dir, 0755);
|
|
|
1132 |
}
|
1133 |
|
1134 |
+
//Check permissions on logs
|
1135 |
+
$logs_dir = WPBACKITUP__PLUGIN_PATH .'/logs';
|
1136 |
+
if(is_dir($logs_dir) ) {
|
1137 |
+
chmod($logs_dir, 0755);
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
//Make sure they exist now
|
1141 |
+
if( !is_dir($backup_dir) || !is_dir($restore_dir)) {
|
1142 |
+
exit ('WP BackItUp was not able to create the required backup and restore folders.');
|
1143 |
+
}
|
1144 |
|
1145 |
} catch (Exception $e) {
|
|
|
1146 |
exit ('WP BackItUp encountered an error during activation.</br>' .$e->getMessage());
|
1147 |
}
|
1148 |
}
|
1153 |
public static function deactivate() {
|
1154 |
// Do deactivation actions
|
1155 |
|
1156 |
+
wp_clear_scheduled_hook( 'wpbackitup_check_scheduled_tasks');
|
1157 |
}
|
1158 |
|
1159 |
/* --------------------- PRIVATES -----------------------------------------*/
|
lib/includes/class-zip.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php if (!defined ('ABSPATH')) die('No direct access allowed');
|
2 |
* WP Backitup Zip Function
|
3 |
*
|
4 |
* @package WP Backitup
|
5 |
*
|
6 |
* @author cssimmon
|
7 |
*
|
8 |
*/
|
9 |
private $zip_file_count;
|
10 |
private $max_file_count=1000;
|
11 |
$this->zip_file_count=0;
|
12 |
}
|
13 |
function __destruct() {
|
14 |
|
15 |
}
|
16 |
}
|
17 |
$zip->addFile($src,substr($src,$path));
|
18 |
}
|
19 |
if(!is_dir($src)){
|
20 |
$zip->close();
|
21 |
@unlink($dst);
|
22 |
$this->logger->log('(Zip.compress) File not found:' . $dst);
|
23 |
echo 'Error: File not found';
|
24 |
exit;
|
25 |
}
|
26 |
$this->recurse_zip($src,$dst,$zip,$path);}
|
27 |
//Reopen the zip when you get to max file count
|
28 |
if($this->zip_file_count>=$this->max_file_count){
|
29 |
$zip->close();
|
30 |
$this->zip_file_count=0;
|
31 |
$zip = new ZipArchive;
|
32 |
$res = $zip->open($dst,ZIPARCHIVE::CREATE);
|
33 |
//Check for error
|
34 |
if($res !== TRUE){
|
35 |
$this->logger->log('(Zip.recurse_zip) Zip open cant be opened:' .$res);
|
36 |
exit('Zip open cant be opened');
|
37 |
}
|
38 |
}
|
39 |
$zipFilePath = substr($src . '/' . $file,$path);
|
40 |
$zip->addEmptyDir($zipFilePath);
|
41 |
$this->zip_file_count++;
|
42 |
$this->recurse_zip($src . '/' . $file,$dst,$zip,$path);
|
43 |
$this->zip_file_count++;
|
|
|
44 |
* WP Backitup Zip Function
|
45 |
*
|
46 |
* @package WP Backitup
|
47 |
*
|
48 |
* @author cssimmon
|
49 |
*
|
50 |
*/
|
51 |
private $zip_file_count;
|
52 |
private $max_file_count=1000;
|
53 |
$this->zip_file_count=0;
|
54 |
}
|
55 |
function __destruct() {
|
56 |
|
57 |
}
|
58 |
}
|
59 |
if (!$zip->addFile($src,substr($src,$path))){
|
60 |
return false;
|
61 |
}
|
62 |
}
|
63 |
if(!is_dir($src)){
|
64 |
$zip->close();
|
65 |
@unlink($dst);
|
66 |
$this->logger->log('(Zip.compress) File not found:' . $dst);
|
67 |
return false;
|
68 |
}
|
69 |
$rtnVal = $this->recurse_zip($src,$dst,$zip,$path);}
|
70 |
//Reopen the zip when you get to max file count
|
71 |
if($this->zip_file_count>=$this->max_file_count){
|
72 |
$zip->close();
|
73 |
$this->zip_file_count=0;
|
74 |
$zip = new ZipArchive;
|
75 |
$res = $zip->open($dst,ZIPARCHIVE::CREATE);
|
76 |
//Check for error
|
77 |
if($res !== TRUE){
|
78 |
$this->logger->log('(Zip.recurse_zip) Zip open cant be opened:' .$res);
|
79 |
return false;
|
80 |
}
|
81 |
}
|
82 |
$zipFilePath = substr($src . '/' . $file,$path);
|
83 |
if (!$zip->addEmptyDir($zipFilePath)){
|
84 |
$this->logger->log('(Zip.recurse_zip) Cant add empty directory' .$zipFilePath);
|
85 |
return false;
|
86 |
}
|
87 |
$this->zip_file_count++;
|
88 |
if (!$this->recurse_zip($src . '/' . $file,$dst,$zip,$path)){
|
89 |
$this->logger->log('(Zip.recurse_zip)Recursive zip error');
|
90 |
return false;
|
91 |
}
|
92 |
$this->logger->log('(Zip.recurse_zip)Cant add file to zip');
|
93 |
return false;
|
94 |
}
|
95 |
$this->zip_file_count++;
|
96 |
return true;
|
|
|
1 |
* WP Backitup Zip Function
|
2 |
*
|
3 |
* @package WP Backitup
|
4 |
*
|
5 |
* @author cssimmon
|
6 |
*
|
7 |
*/
|
8 |
private $zip_file_count;
|
9 |
private $max_file_count=1000;
|
10 |
$this->zip_file_count=0;
|
11 |
}
|
12 |
function __destruct() {
|
13 |
|
14 |
}
|
15 |
}
|
16 |
$zip->addFile($src,substr($src,$path));
|
17 |
}
|
18 |
if(!is_dir($src)){
|
19 |
$zip->close();
|
20 |
@unlink($dst);
|
21 |
$this->logger->log('(Zip.compress) File not found:' . $dst);
|
22 |
echo 'Error: File not found';
|
23 |
exit;
|
24 |
}
|
25 |
$this->recurse_zip($src,$dst,$zip,$path);}
|
26 |
//Reopen the zip when you get to max file count
|
27 |
if($this->zip_file_count>=$this->max_file_count){
|
28 |
$zip->close();
|
29 |
$this->zip_file_count=0;
|
30 |
$zip = new ZipArchive;
|
31 |
$res = $zip->open($dst,ZIPARCHIVE::CREATE);
|
32 |
//Check for error
|
33 |
if($res !== TRUE){
|
34 |
$this->logger->log('(Zip.recurse_zip) Zip open cant be opened:' .$res);
|
35 |
exit('Zip open cant be opened');
|
36 |
}
|
37 |
}
|
38 |
$zipFilePath = substr($src . '/' . $file,$path);
|
39 |
$zip->addEmptyDir($zipFilePath);
|
40 |
$this->zip_file_count++;
|
41 |
$this->recurse_zip($src . '/' . $file,$dst,$zip,$path);
|
42 |
$this->zip_file_count++;
|
43 |
+
<?php if (!defined ('ABSPATH')) die('No direct access allowed');
|
44 |
* WP Backitup Zip Function
|
45 |
*
|
46 |
* @package WP Backitup
|
47 |
*
|
48 |
* @author cssimmon
|
49 |
*
|
50 |
*/
|
51 |
private $zip_file_count;
|
52 |
private $max_file_count=1000;
|
53 |
$this->zip_file_count=0;
|
54 |
}
|
55 |
function __destruct() {
|
56 |
|
57 |
}
|
58 |
}
|
59 |
if (!$zip->addFile($src,substr($src,$path))){
|
60 |
return false;
|
61 |
}
|
62 |
}
|
63 |
if(!is_dir($src)){
|
64 |
$zip->close();
|
65 |
@unlink($dst);
|
66 |
$this->logger->log('(Zip.compress) File not found:' . $dst);
|
67 |
return false;
|
68 |
}
|
69 |
$rtnVal = $this->recurse_zip($src,$dst,$zip,$path);}
|
70 |
//Reopen the zip when you get to max file count
|
71 |
if($this->zip_file_count>=$this->max_file_count){
|
72 |
$zip->close();
|
73 |
$this->zip_file_count=0;
|
74 |
$zip = new ZipArchive;
|
75 |
$res = $zip->open($dst,ZIPARCHIVE::CREATE);
|
76 |
//Check for error
|
77 |
if($res !== TRUE){
|
78 |
$this->logger->log('(Zip.recurse_zip) Zip open cant be opened:' .$res);
|
79 |
return false;
|
80 |
}
|
81 |
}
|
82 |
$zipFilePath = substr($src . '/' . $file,$path);
|
83 |
if (!$zip->addEmptyDir($zipFilePath)){
|
84 |
$this->logger->log('(Zip.recurse_zip) Cant add empty directory' .$zipFilePath);
|
85 |
return false;
|
86 |
}
|
87 |
$this->zip_file_count++;
|
88 |
if (!$this->recurse_zip($src . '/' . $file,$dst,$zip,$path)){
|
89 |
$this->logger->log('(Zip.recurse_zip)Recursive zip error');
|
90 |
return false;
|
91 |
}
|
92 |
$this->logger->log('(Zip.recurse_zip)Cant add file to zip');
|
93 |
return false;
|
94 |
}
|
95 |
$this->zip_file_count++;
|
96 |
return true;
|
lib/includes/restore.php
CHANGED
@@ -1,691 +1,691 @@
|
|
1 |
-
<?php if (!defined ('ABSPATH')) die('No direct access allowed (restore)');
|
2 |
-
@set_time_limit(900);// 15 minutes per image should be PLENTY
|
3 |
-
|
4 |
-
/**
|
5 |
-
* WP Backitup Restore Functions
|
6 |
-
*
|
7 |
-
* @package WP Backitup Pro
|
8 |
-
*
|
9 |
-
* @author cssimmon
|
10 |
-
*
|
11 |
-
*/
|
12 |
-
|
13 |
-
/*** Includes ***/
|
14 |
-
// include backup class
|
15 |
-
if( !class_exists( 'WPBackItUp_Restore' ) ) {
|
16 |
-
include_once 'class-restore.php';
|
17 |
-
}
|
18 |
-
|
19 |
-
// include file system class
|
20 |
-
if( !class_exists( 'WPBackItUp_Filesystem' ) ) {
|
21 |
-
include_once 'class-filesystem.php';
|
22 |
-
}
|
23 |
-
|
24 |
-
// include SQL class
|
25 |
-
if( !class_exists( 'WPBackItUp_SQL' ) ) {
|
26 |
-
include_once 'class-sql.php';
|
27 |
-
}
|
28 |
-
|
29 |
-
/*** Globals ***/
|
30 |
-
global $WPBackitup;
|
31 |
-
global $table_prefix; //this is from wp-config
|
32 |
-
|
33 |
-
global $backup_file_name; //name of the backup file
|
34 |
-
global $backup_file_path; //full path to zip file on server
|
35 |
-
global $RestorePoint_SQL; //path to restore point
|
36 |
-
|
37 |
-
global $status_array,$inactive,$active,$complete,$failure,$warning,$success;
|
38 |
-
$inactive=0;
|
39 |
-
$active=1;
|
40 |
-
$complete=2;
|
41 |
-
$failure=-1;
|
42 |
-
$warning=-2;
|
43 |
-
$success=99;
|
44 |
-
|
45 |
-
//setup the status array
|
46 |
-
global $status_array;
|
47 |
-
$status_array = array(
|
48 |
-
'preparing' =>$inactive ,
|
49 |
-
'unzipping' =>$inactive ,
|
50 |
-
'validation'=>$inactive,
|
51 |
-
'restore_point'=>$inactive,
|
52 |
-
'database'=>$inactive,
|
53 |
-
'wpcontent'=>$inactive,
|
54 |
-
'cleanup'=>$inactive
|
55 |
-
);
|
56 |
-
|
57 |
-
$fileUTCDateTime=current_time( 'timestamp' );
|
58 |
-
$localDateTime = date_i18n('Y-m-d-His',$fileUTCDateTime);
|
59 |
-
$log_filename = 'restorelog_'.'_' .$localDateTime;
|
60 |
-
|
61 |
-
global $logger;
|
62 |
-
$logger = new WPBackItUp_Logger(false,null,$log_filename,true);
|
63 |
-
|
64 |
-
global $wp_restore; //Eventually everything will be migrated to this class
|
65 |
-
$wp_restore = new WPBackItUp_Restore($logger);
|
66 |
-
|
67 |
-
|
68 |
-
//*****************//
|
69 |
-
//*** MAIN CODE ***//
|
70 |
-
//*****************//
|
71 |
-
$logger->log('***BEGIN RESTORE***');
|
72 |
-
$logger->logConstants();
|
73 |
-
|
74 |
-
if (!$this->license_active()){
|
75 |
-
$logger->log('Restore is not available because license is not active.');
|
76 |
-
write_fatal_error_status('error225');
|
77 |
-
die();
|
78 |
-
}
|
79 |
-
|
80 |
-
//--Get form post values
|
81 |
-
$backup_file_name = $_POST['selected_file'];//Get the backup file name
|
82 |
-
if( empty($backup_file_name)) {
|
83 |
-
write_fatal_error_status('error201');
|
84 |
-
die();
|
85 |
-
}
|
86 |
-
|
87 |
-
//Get user ID
|
88 |
-
$user_id = $_POST['user_id'];
|
89 |
-
if( empty($user_id)) {
|
90 |
-
write_fatal_error_status('error201');
|
91 |
-
die();
|
92 |
-
}
|
93 |
-
|
94 |
-
|
95 |
-
//TEST
|
96 |
-
|
97 |
-
//END TEST
|
98 |
-
|
99 |
-
set_status('preparing',$active,true);
|
100 |
-
|
101 |
-
//set path to backup file
|
102 |
-
$backup_file_path = $wp_restore->backup_folder_path .$backup_file_name ;
|
103 |
-
|
104 |
-
$logger->log('**DELETE RESTORE FOLDER**');
|
105 |
-
delete_restore_folder();
|
106 |
-
$logger->log('** END DELETE RESTORE FOLDER**');
|
107 |
-
|
108 |
-
$logger->log('**CREATE RESTORE FOLDER**');
|
109 |
-
create_restore_folder($wp_restore->restore_folder_path);
|
110 |
-
set_status('preparing',$complete,false);
|
111 |
-
$logger->log('**END CREATE RESTORE FOLDER**');
|
112 |
-
|
113 |
-
$logger->log('**UNZIP BACKUP**');
|
114 |
-
set_status('unzipping',$active,true);
|
115 |
-
unzip_backup($backup_file_path,$wp_restore->restore_folder_path);
|
116 |
-
set_status('unzipping',$complete,false);
|
117 |
-
$logger->log('**END UNZIP BACKUP**');
|
118 |
-
|
119 |
-
|
120 |
-
$logger->log('**VALIDATE BACKUP**');
|
121 |
-
set_status('validation',$active,true);
|
122 |
-
$restoration_dir_path=validate_restore_folder($wp_restore->restore_folder_path);
|
123 |
-
$logger->log('**END VALIDATE BACKUP**');
|
124 |
-
|
125 |
-
|
126 |
-
$logger->log('**VALIDATE SQL FILE EXISTS**');
|
127 |
-
$backupSQLFile = $restoration_dir_path . WPBACKITUP__SQL_DBBACKUP_FILENAME;
|
128 |
-
validate_SQL_exists($backupSQLFile);
|
129 |
-
$logger->log('**END VALIDATE SQL FILE EXISTS**');
|
130 |
-
|
131 |
-
|
132 |
-
$logger->log('**GET SITE VALUES FROM DB**');
|
133 |
-
$siteurl = get_siteurl();
|
134 |
-
$homeurl = get_homeurl();
|
135 |
-
$user_login = get_user_login($user_id);
|
136 |
-
$user_pass = get_user_pass($user_id);
|
137 |
-
$user_email = get_user_email($user_id);
|
138 |
-
$logger->log('**END GET SITE VALUES FROM DB**');
|
139 |
-
|
140 |
-
//Collect previous backup site url start
|
141 |
-
$logger->log('**GET backupsiteinfo.txt VALUES**');
|
142 |
-
$import_siteinfo_lines = file($restoration_dir_path .'backupsiteinfo.txt');
|
143 |
-
$import_siteurl = str_replace("\n", '',trim($import_siteinfo_lines[0]));
|
144 |
-
$current_siteurl = trim($siteurl ,'/');
|
145 |
-
$import_table_prefix = str_replace("\n", '',$import_siteinfo_lines[1]);
|
146 |
-
$import_wp_version = str_replace("\n", '',$import_siteinfo_lines[2]);
|
147 |
-
$logger->log($import_siteinfo_lines);
|
148 |
-
|
149 |
-
//Check table prefix values FATAL
|
150 |
-
if($table_prefix !=$import_table_prefix) {
|
151 |
-
$logger->log('Error: Table prefix different from restore.');
|
152 |
-
write_warning_status('error221');
|
153 |
-
}
|
154 |
-
|
155 |
-
$logger->log('**END GET backupsiteinfo.txt VALUES**');
|
156 |
-
|
157 |
-
$logger->log('**CREATE RESTORE POINT**');
|
158 |
-
//Create restore point for DB
|
159 |
-
set_status('validation',$complete,false);
|
160 |
-
set_status('restore_point',$active,true);
|
161 |
-
$RestorePoint_SQL = backup_database($wp_restore->backup_folder_path); //Save in backup folder
|
162 |
-
set_status('restore_point',$complete,false);
|
163 |
-
$logger->log('**END CREATE RESTORE POINT**');
|
164 |
-
|
165 |
-
|
166 |
-
$logger->log('**RESTORE DATABASE**');
|
167 |
-
//Import the backed up database
|
168 |
-
set_status('database',$active,true);
|
169 |
-
import_backedup_database($backupSQLFile,$RestorePoint_SQL);
|
170 |
-
$logger->log('**END RESTORE DATABASE**');
|
171 |
-
|
172 |
-
|
173 |
-
$logger->log('**UPDATE DATABASE VALUES**');
|
174 |
-
//FAILURES AFTER THIS POINT SHOULD REQUIRE ROLLBACK OF DB
|
175 |
-
update_user_credentials($import_table_prefix, $user_login, $user_pass, $user_email, $user_id);
|
176 |
-
update_siteurl($import_table_prefix, $current_siteurl);
|
177 |
-
update_homeurl($import_table_prefix, $homeurl);
|
178 |
-
$logger->log('**END UPDATE DATABASE VALUES**');
|
179 |
-
|
180 |
-
//Done with DB restore
|
181 |
-
set_status('database',$complete,false);
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
//***DEAL WITH WPCONTENT NOW ***
|
186 |
-
set_status('wpcontent',$active,true);
|
187 |
-
$logger->log('**DELETE PLUGINS**');
|
188 |
-
delete_plugins_content();
|
189 |
-
$logger->log('**END DELETE PLUGINS**');
|
190 |
-
|
191 |
-
$logger->log('**DELETE THEMES**');
|
192 |
-
delete_themes_content();
|
193 |
-
$logger->log('**END DELETE THEMES**');
|
194 |
-
|
195 |
-
$logger->log('**DELETE WPCONTENT**');
|
196 |
-
//delete whatever is left
|
197 |
-
$wpcontent_folder=WPBACKITUP__CONTENT_PATH;
|
198 |
-
delete_wpcontent_content($wpcontent_folder);
|
199 |
-
$logger->log('**END DELETE WPCONTENT**');
|
200 |
-
|
201 |
-
$logger->log('**RESTORE WPCONTENT**');
|
202 |
-
restore_wpcontent($restoration_dir_path);
|
203 |
-
set_status('wpcontent',$complete,false);
|
204 |
-
$logger->log('**END DELETE WPCONTENT**');
|
205 |
-
|
206 |
-
$logger->log('**VALIDATE WPCONTENT**');
|
207 |
-
validate_wpcontent($restoration_dir_path,$wpcontent_folder);
|
208 |
-
$logger->log('**END VALIDATE WPCONTENT**');
|
209 |
-
|
210 |
-
$logger->log('**UPDATE PERMALINKS**');
|
211 |
-
update_permalinks();
|
212 |
-
$logger->log('**END UPDATE PERMALINKS**');
|
213 |
-
|
214 |
-
|
215 |
-
$logger->log('**CLEANUP**');
|
216 |
-
set_status('cleanup',$active,true);
|
217 |
-
cleanup_restore_folder($restoration_dir_path);
|
218 |
-
set_status('cleanup',$complete,false);
|
219 |
-
$logger->log('**END CLEANUP**');
|
220 |
-
|
221 |
-
set_status_success();
|
222 |
-
$logger->log('Restore completed successfully');
|
223 |
-
$logger->log('***END RESTORE***');
|
224 |
-
die();
|
225 |
-
|
226 |
-
/******************/
|
227 |
-
/*** Functions ***/
|
228 |
-
/******************/
|
229 |
-
|
230 |
-
//Get Status Log
|
231 |
-
function get_restore_Log() {
|
232 |
-
$log = WPBACKITUP__PLUGIN_PATH .'/logs/status.log';
|
233 |
-
if (file_exists($log)){
|
234 |
-
unlink($log);
|
235 |
-
}
|
236 |
-
$fh = fopen($log, 'w+') or die( "Can't write to log file" );
|
237 |
-
return $fh;
|
238 |
-
}
|
239 |
-
|
240 |
-
function write_fatal_error_status($status_code) {
|
241 |
-
global $status_array,$inactive,$active,$complete,$failure,$warning,$success;
|
242 |
-
|
243 |
-
//Find the active status and set to failure
|
244 |
-
foreach ($status_array as $key => $value) {
|
245 |
-
if ($value==$active){
|
246 |
-
$status_array[$key]=$failure;
|
247 |
-
}
|
248 |
-
}
|
249 |
-
|
250 |
-
//Add failure to array
|
251 |
-
$status_array[$status_code]=$failure;
|
252 |
-
write_restore_status();
|
253 |
-
}
|
254 |
-
|
255 |
-
function write_warning_status($status_code) {
|
256 |
-
global $status_array,$inactive,$active,$complete,$failure,$warning,$success;
|
257 |
-
|
258 |
-
//Add warning to array
|
259 |
-
$status_array[$status_code]=$warning;
|
260 |
-
write_restore_status();
|
261 |
-
}
|
262 |
-
|
263 |
-
function write_restore_status() {
|
264 |
-
global $status_array;
|
265 |
-
$fh=get_restore_Log();
|
266 |
-
|
267 |
-
foreach ($status_array as $key => $value) {
|
268 |
-
fwrite($fh, '<div class="' . $key . '">' . $value .'</div>');
|
269 |
-
}
|
270 |
-
fclose($fh);
|
271 |
-
}
|
272 |
-
|
273 |
-
function set_status($process,$status,$flush){
|
274 |
-
global $status_array;
|
275 |
-
$status_array[$process]=$status;
|
276 |
-
|
277 |
-
if ($flush) write_restore_status();
|
278 |
-
}
|
279 |
-
|
280 |
-
function set_status_success(){
|
281 |
-
global $status_array,$inactive,$active,$complete,$failure,$warning,$success;
|
282 |
-
global $active;
|
283 |
-
|
284 |
-
$status_array['finalinfo']=$success;
|
285 |
-
write_restore_status();
|
286 |
-
}
|
287 |
-
|
288 |
-
//Create an empty restore folder
|
289 |
-
function create_restore_folder($path) {
|
290 |
-
global $logger;
|
291 |
-
$logger->log('Create restore folder:' .$path);
|
292 |
-
|
293 |
-
$fileSystem = new WPBackItUp_FileSystem($logger);
|
294 |
-
if(!$fileSystem->create_dir($path)) {
|
295 |
-
$logger->log('Error: Cant create restore folder :'. $path);
|
296 |
-
write_fatal_error_status('error222');
|
297 |
-
die();
|
298 |
-
}
|
299 |
-
$logger->log('Restore folder created:' .$path);
|
300 |
-
}
|
301 |
-
|
302 |
-
//Delete restore folder and contents
|
303 |
-
function delete_restore_folder() {
|
304 |
-
global $logger;
|
305 |
-
global $wp_restore;
|
306 |
-
//Delete the existing restore directory
|
307 |
-
$logger->log('Delete existing restore folder:' .$wp_restore->restore_folder_path);
|
308 |
-
$fileSystem = new WPBackItUp_FileSystem($logger);
|
309 |
-
return $fileSystem->recursive_delete($wp_restore->restore_folder_path);
|
310 |
-
}
|
311 |
-
|
312 |
-
//Unzip the backup to the restore folder
|
313 |
-
function unzip_backup($backup_file_path,$restore_folder_root){
|
314 |
-
global $logger;
|
315 |
-
//unzip the upload
|
316 |
-
$logger->log('Unzip the backup file source:' .$backup_file_path);
|
317 |
-
$logger->log('Unzip the backup file target:' .$restore_folder_root);
|
318 |
-
$zip = new ZipArchive;
|
319 |
-
$res = $zip->open($backup_file_path);
|
320 |
-
if ($res === TRUE) {
|
321 |
-
$zip->extractTo($restore_folder_root);
|
322 |
-
$zip->close();
|
323 |
-
} else {
|
324 |
-
$logger->log('Error: Cant unzip backup:'.$backup_file_path);
|
325 |
-
write_fatal_error_status('error203');
|
326 |
-
delete_restore_folder();
|
327 |
-
die();
|
328 |
-
}
|
329 |
-
$logger->log('Backup file unzipped: ' .$restore_folder_root);
|
330 |
-
}
|
331 |
-
|
332 |
-
//Validate the restore folder
|
333 |
-
function validate_restore_folder($restore_folder_root){
|
334 |
-
global $logger;
|
335 |
-
$restoration_dir_path='';
|
336 |
-
|
337 |
-
$logger->log('Identify the restoration directory in restore folder: ' .$restore_folder_root.'*');
|
338 |
-
if ( count( glob( $restore_folder_root.'*', GLOB_ONLYDIR ) ) == 1 ) {
|
339 |
-
foreach( glob($restore_folder_root .'*', GLOB_ONLYDIR ) as $dir) {
|
340 |
-
$restoration_dir_path = $dir .'/';
|
341 |
-
$logger->log('Restoration directory Set to: ' .$restoration_dir_path);
|
342 |
-
}
|
343 |
-
}
|
344 |
-
|
345 |
-
if (empty($restoration_dir_path)) {
|
346 |
-
$logger->log('Error: Restore directory INVALID: ' .$restore_folder_root);
|
347 |
-
write_fatal_error_status('error204');
|
348 |
-
delete_restore_folder(); //delete the restore folder if bad
|
349 |
-
die();
|
350 |
-
}
|
351 |
-
|
352 |
-
//Validate the restoration
|
353 |
-
$logger->log('Validate restoration directory: ' . $restoration_dir_path .'backupsiteinfo.txt');
|
354 |
-
if(!glob($restoration_dir_path .'backupsiteinfo.txt') ){
|
355 |
-
$logger->log('Error: backupsiteinfo.txt missing from restore folder: ' .$restoration_dir_path);
|
356 |
-
write_fatal_error_status('error204');
|
357 |
-
delete_restore_folder(); //delete the restore folder if bad
|
358 |
-
die();
|
359 |
-
}
|
360 |
-
$logger->log('Restoration directory validated: ' .$restoration_dir_path);
|
361 |
-
return $restoration_dir_path;
|
362 |
-
}
|
363 |
-
|
364 |
-
// Backup the current database try dump first
|
365 |
-
function backup_database($restore_folder_root){
|
366 |
-
global $logger;
|
367 |
-
$date = date_i18n('Y-m-d-Hi',current_time( 'timestamp' ));
|
368 |
-
$backup_file = $restore_folder_root . 'db-backup-' . $date .'.cur';
|
369 |
-
$logger->log('Backup the current database: ' .$backup_file);
|
370 |
-
|
371 |
-
$dbc = new WPBackItUp_SQL($logger);
|
372 |
-
if(!$dbc->mysqldump_export($backup_file)) {
|
373 |
-
//Try a manual restore since dump didnt work
|
374 |
-
if(!$dbc->manual_export($backup_file)) {
|
375 |
-
$logger->log('Error: Cant backup database:'.$backup_file);
|
376 |
-
write_fatal_error_status('error205');
|
377 |
-
delete_restore_folder();
|
378 |
-
die();
|
379 |
-
}
|
380 |
-
}
|
381 |
-
$logger->log('Current database backed up: ' .$backup_file);
|
382 |
-
return $backup_file;
|
383 |
-
}
|
384 |
-
|
385 |
-
//Make sure there IS a backup to restore
|
386 |
-
function validate_SQL_exists($backupSQLFile){
|
387 |
-
global $logger;
|
388 |
-
$logger->log('Check for database backup file:' . $backupSQLFile);
|
389 |
-
|
390 |
-
if(!file_exists($backupSQLFile) && !empty($backupSQLFile)) {
|
391 |
-
$logger->log('Error: NO Database backups in backup.');
|
392 |
-
write_fatal_error_status('error216');
|
393 |
-
delete_restore_folder();
|
394 |
-
die();
|
395 |
-
}
|
396 |
-
$logger->log('Database backup file exist:' . $backupSQLFile);
|
397 |
-
}
|
398 |
-
|
399 |
-
//Restore DB
|
400 |
-
function restore_database(){
|
401 |
-
global $logger;
|
402 |
-
global $RestorePoint_SQL;
|
403 |
-
$logger->log('Restore the DB to previous state:' . $RestorePoint_SQL);
|
404 |
-
|
405 |
-
$dbc = new WPBackItUp_SQL($logger);
|
406 |
-
if(!$dbc->run_sql_exec($RestorePoint_SQL)) {
|
407 |
-
//Do it manually if the import doesnt work
|
408 |
-
if(!$dbc->run_sql_manual($RestorePoint_SQL)) {
|
409 |
-
$logger->log('Error: Database could not be restored.' .$RestorePoint_SQL);
|
410 |
-
write_fatal_error_status('error223');
|
411 |
-
delete_restore_folder();
|
412 |
-
die();
|
413 |
-
}
|
414 |
-
}
|
415 |
-
write_fatal_error_status('error224');
|
416 |
-
$logger->log('Database restored to previous state.');
|
417 |
-
}
|
418 |
-
|
419 |
-
//Run DB restore
|
420 |
-
function import_backedup_database($backupSQLFile,$restorePoint_SQL){
|
421 |
-
global $logger;
|
422 |
-
|
423 |
-
$logger->log('Import the backed up database.');
|
424 |
-
//Try SQL Import first
|
425 |
-
|
426 |
-
$dbc = new WPBackItUp_SQL($logger);
|
427 |
-
if(!$dbc->run_sql_exec($backupSQLFile)) {
|
428 |
-
//Do it manually if the import doesnt work
|
429 |
-
if(!$dbc->run_sql_manual($backupSQLFile)) {
|
430 |
-
$logger->log('Error: Database import error.');
|
431 |
-
|
432 |
-
//Restore to checkpoint
|
433 |
-
if ($dbc->run_sql_manual($restorePoint_SQL)){
|
434 |
-
$logger->log('Database successfully restored to checkpoint.');
|
435 |
-
write_fatal_error_status('error230');
|
436 |
-
|
437 |
-
}
|
438 |
-
else {
|
439 |
-
$logger->log('Database NOT restored to checkpoint.');
|
440 |
-
write_fatal_error_status('error212');
|
441 |
-
}
|
442 |
-
|
443 |
-
delete_restore_folder();
|
444 |
-
die();
|
445 |
-
}
|
446 |
-
}
|
447 |
-
$logger->log('Backed up database imported.');
|
448 |
-
}
|
449 |
-
|
450 |
-
//get siteurl
|
451 |
-
function get_siteurl(){
|
452 |
-
global $logger;
|
453 |
-
global $table_prefix;
|
454 |
-
$sql = "SELECT option_value FROM " .$table_prefix ."options WHERE option_name ='siteurl';";
|
455 |
-
|
456 |
-
$dbc = new WPBackItUp_SQL($logger);
|
457 |
-
$siteurl = $dbc->get_sql_scalar($sql);
|
458 |
-
if (empty($siteurl)) {
|
459 |
-
$logger->log('Error: Siteurl not found');
|
460 |
-
write_fatal_error_status('error207');
|
461 |
-
delete_restore_folder();
|
462 |
-
die();
|
463 |
-
}
|
464 |
-
$logger->log('Siteurl found:' .$siteurl);
|
465 |
-
return $siteurl;
|
466 |
-
}
|
467 |
-
|
468 |
-
//get homeurl
|
469 |
-
function get_homeurl(){
|
470 |
-
global $logger;
|
471 |
-
global $table_prefix;
|
472 |
-
$sql = "SELECT option_value FROM " .$table_prefix ."options WHERE option_name ='home';";
|
473 |
-
$dbc = new WPBackItUp_SQL($logger);
|
474 |
-
$homeurl = $dbc->get_sql_scalar($sql);
|
475 |
-
if (empty($homeurl)) {
|
476 |
-
$logger->log('Error: Homeurl not found.');
|
477 |
-
write_fatal_error_status('error208');
|
478 |
-
delete_restore_folder();
|
479 |
-
die();
|
480 |
-
}
|
481 |
-
$logger->log('homeurl found:' . $homeurl);
|
482 |
-
return $homeurl;
|
483 |
-
}
|
484 |
-
|
485 |
-
//get user login
|
486 |
-
function get_user_login($user_id){
|
487 |
-
global $logger;
|
488 |
-
global $table_prefix;
|
489 |
-
$sql = "SELECT user_login FROM ". $table_prefix ."users WHERE ID=" .$user_id .";";
|
490 |
-
|
491 |
-
$dbc = new WPBackItUp_SQL($logger);
|
492 |
-
$user_login = $dbc->get_sql_scalar($sql);
|
493 |
-
if (empty($user_login)) {
|
494 |
-
$logger->log('Error: user_login not found.');
|
495 |
-
write_fatal_error_status('error209');
|
496 |
-
delete_restore_folder();
|
497 |
-
die();
|
498 |
-
}
|
499 |
-
$logger->log('user_login found.');
|
500 |
-
return $user_login;
|
501 |
-
}
|
502 |
-
|
503 |
-
//get user pass
|
504 |
-
function get_user_pass($user_id){
|
505 |
-
global $logger;
|
506 |
-
global $table_prefix;
|
507 |
-
$sql = "SELECT user_pass FROM ". $table_prefix ."users WHERE ID=" .$user_id .";";
|
508 |
-
|
509 |
-
$dbc = new WPBackItUp_SQL($logger);
|
510 |
-
$user_pass = $dbc->get_sql_scalar($sql);
|
511 |
-
if (empty($user_pass)) {
|
512 |
-
$logger->log('Error: user_pass not found.');
|
513 |
-
write_fatal_error_status('error210');
|
514 |
-
delete_restore_folder();
|
515 |
-
die();
|
516 |
-
}
|
517 |
-
$logger->log('user_pass found.');
|
518 |
-
return $user_pass;
|
519 |
-
}
|
520 |
-
|
521 |
-
//get user email
|
522 |
-
function get_user_email($user_id){
|
523 |
-
global $logger;
|
524 |
-
global $table_prefix;
|
525 |
-
$sql = "SELECT user_email FROM ". $table_prefix ."users WHERE ID=" .$user_id ."";
|
526 |
-
|
527 |
-
$dbc = new WPBackItUp_SQL($logger);
|
528 |
-
$user_email = $dbc->get_sql_scalar($sql);
|
529 |
-
if (empty($user_email)) {
|
530 |
-
$logger->log('Error: user_email not found.');
|
531 |
-
write_fatal_error_status('error211');
|
532 |
-
delete_restore_folder();
|
533 |
-
die();
|
534 |
-
}
|
535 |
-
$logger->log('user_email found.' . $user_email);
|
536 |
-
return $user_email;
|
537 |
-
}
|
538 |
-
|
539 |
-
//Update user credentials
|
540 |
-
function update_user_credentials($table_prefix, $user_login, $user_pass, $user_email, $user_id){
|
541 |
-
global $logger;
|
542 |
-
$sql = "UPDATE ". $table_prefix ."users SET user_login='" .$user_login ."', user_pass='" .$user_pass ."', user_email='" .$user_email ."' WHERE ID='" .$user_id ."'";
|
543 |
-
|
544 |
-
$dbc = new WPBackItUp_SQL($logger);
|
545 |
-
if (!$dbc->run_sql_command($sql)){
|
546 |
-
$logger->log('Error: User Credential database update failed..');
|
547 |
-
write_warning_status('error215');
|
548 |
-
restore_database();
|
549 |
-
delete_restore_folder();
|
550 |
-
die();
|
551 |
-
}
|
552 |
-
$logger->log('User Credential updated in database.');
|
553 |
-
}
|
554 |
-
|
555 |
-
//update the site URL in the restored database
|
556 |
-
function update_siteurl($table_prefix, $current_siteurl){
|
557 |
-
global $logger;
|
558 |
-
$sql = "UPDATE ". $table_prefix ."options SET option_value='" .$current_siteurl ."' WHERE option_name='siteurl'";
|
559 |
-
|
560 |
-
$dbc = new WPBackItUp_SQL($logger);
|
561 |
-
if (!$dbc->run_sql_command($sql)){
|
562 |
-
$logger->log('Error: SiteURL updated failed.');
|
563 |
-
write_warning_status('error213');
|
564 |
-
restore_database();
|
565 |
-
delete_restore_folder();
|
566 |
-
die();
|
567 |
-
}
|
568 |
-
$logger->log('SiteURL updated in database.');
|
569 |
-
}
|
570 |
-
|
571 |
-
//Update homeURL
|
572 |
-
function update_homeurl($table_prefix, $homeurl){
|
573 |
-
global $logger;
|
574 |
-
$sql = "UPDATE ". $table_prefix ."options SET option_value='" .$homeurl ."' WHERE option_name='home'";
|
575 |
-
$dbc = new WPBackItUp_SQL($logger);
|
576 |
-
if (!$dbc->run_sql_command($sql)){
|
577 |
-
$logger->log('Error: HomeURL database update failed..');
|
578 |
-
write_warning_status('error214');
|
579 |
-
restore_database();
|
580 |
-
delete_restore_folder();
|
581 |
-
die();
|
582 |
-
}
|
583 |
-
$logger->log('HomeURL updated in database.');
|
584 |
-
}
|
585 |
-
|
586 |
-
//Delete wp-content content
|
587 |
-
function delete_wpcontent_content($root_folder){
|
588 |
-
global $logger;
|
589 |
-
$logger->log('Delete the wp_content contents:' .$root_folder);
|
590 |
-
$ignore = array(WPBACKITUP__PLUGIN_FOLDER,WPBACKITUP__RESTORE_FOLDER,WPBACKITUP__BACKUP_FOLDER,'debug.log');
|
591 |
-
$filesystem = new WPBackItUp_FileSystem($logger);
|
592 |
-
if(!$filesystem->recursive_delete($root_folder,$ignore)) {
|
593 |
-
$logger->log('Error: Cant delete WPContent:' .$root_folder);
|
594 |
-
write_warning_status('error217');
|
595 |
-
restore_database();
|
596 |
-
delete_restore_folder();
|
597 |
-
die();
|
598 |
-
}
|
599 |
-
$logger->log('wp-content has been deleted:' .$root_folder);
|
600 |
-
}
|
601 |
-
|
602 |
-
//Delete plugins content
|
603 |
-
function delete_plugins_content(){
|
604 |
-
global $logger;
|
605 |
-
$plugins_folder=WPBACKITUP__PLUGINS_ROOT_PATH;
|
606 |
-
$logger->log('Delete the plugins contents:' .$plugins_folder);
|
607 |
-
$ignore = array(WPBACKITUP__PLUGIN_FOLDER);
|
608 |
-
$filesystem = new WPBackItUp_FileSystem($logger);
|
609 |
-
if(!$filesystem->recursive_delete($plugins_folder,$ignore)) {
|
610 |
-
$logger->log('Error: Cant delete old WPContent:' .$plugins_folder );
|
611 |
-
write_warning_status('error217');
|
612 |
-
restore_database();
|
613 |
-
delete_restore_folder();
|
614 |
-
die();
|
615 |
-
}
|
616 |
-
$logger->log('Plugins content deleted:' .$plugins_folder);
|
617 |
-
}
|
618 |
-
|
619 |
-
|
620 |
-
//Delete themes content
|
621 |
-
function delete_themes_content(){
|
622 |
-
global $logger;
|
623 |
-
$themes_folder=WPBACKITUP__THEMES_ROOT_PATH ;
|
624 |
-
$logger->log('Delete the themes contents:' .$themes_folder);
|
625 |
-
$filesystem = new WPBackItUp_FileSystem($logger);
|
626 |
-
if(!$filesystem->recursive_delete($themes_folder)) {
|
627 |
-
$logger->log('Error: Cant delete old WPContent:' .$themes_folder );
|
628 |
-
write_warning_status('error217');
|
629 |
-
restore_database();
|
630 |
-
delete_restore_folder();
|
631 |
-
die();
|
632 |
-
}
|
633 |
-
$logger->log('Themes content deleted:' .$themes_folder);
|
634 |
-
}
|
635 |
-
|
636 |
-
//Restore all wp content from zip
|
637 |
-
function restore_wpcontent($restoration_dir_path){
|
638 |
-
global $logger;
|
639 |
-
$logger->log('Copy content folder from:' .$restoration_dir_path);
|
640 |
-
$logger->log('Copy content folder to:' .WPBACKITUP__CONTENT_PATH);
|
641 |
-
$ignore = array(WPBACKITUP__PLUGIN_FOLDER, WPBACKITUP__BACKUP_FOLDER,WPBACKITUP__RESTORE_FOLDER, 'status.log','debug.log', WPBACKITUP__SQL_DBBACKUP_FILENAME, 'backupsiteinfo.txt');
|
642 |
-
$filesystem = new WPBackItUp_FileSystem($logger);
|
643 |
-
if(!$filesystem->recursive_copy($restoration_dir_path,WPBACKITUP__CONTENT_PATH. '/',$ignore)) {
|
644 |
-
$logger->log('Error: Content folder was not copied successfully');
|
645 |
-
write_warning_status('error219');
|
646 |
-
restore_database();
|
647 |
-
delete_restore_folder();
|
648 |
-
die();
|
649 |
-
}
|
650 |
-
$logger->log('Content folder copied successfully');
|
651 |
-
}
|
652 |
-
|
653 |
-
//Restore all wp content from zip
|
654 |
-
function validate_wpcontent($source_dir_path,$target_dir_path){
|
655 |
-
global $logger;
|
656 |
-
$logger->log('Validate content folder TO:' .$source_dir_path);
|
657 |
-
$logger->log('Validate content folder FROM:' .$target_dir_path);
|
658 |
-
|
659 |
-
$ignore = array(WPBACKITUP__PLUGIN_FOLDER,'debug.log','backupsiteinfo.txt','db-backup.sql');
|
660 |
-
$filesystem = new WPBackItUp_FileSystem($logger);
|
661 |
-
if(!$filesystem->recursive_validate($source_dir_path. '/', $target_dir_path . '/',$ignore)) {
|
662 |
-
$logger->log('Error: Content folder is not the same as backup.');
|
663 |
-
}
|
664 |
-
|
665 |
-
$logger->log('Content folder validation complete.');
|
666 |
-
}
|
667 |
-
|
668 |
-
//Delete the restoration directory
|
669 |
-
function cleanup_restore_folder($restoration_dir_path){
|
670 |
-
global $logger;
|
671 |
-
$logger->log('Cleanup the restore folder: ' .$restoration_dir_path);
|
672 |
-
if(!delete_restore_folder()) {
|
673 |
-
$logger->log('Error: Cleanup restore folder failed: ' .$restoration_dir_path);
|
674 |
-
write_warning_status('error220'); //NOT fatal
|
675 |
-
} else {
|
676 |
-
$logger->log('Restore folder cleaned successfully: ' .$restoration_dir_path);
|
677 |
-
}
|
678 |
-
}
|
679 |
-
function update_permalinks(){
|
680 |
-
global $wp_rewrite, $logger;
|
681 |
-
try {
|
682 |
-
$old_permalink_structure = $wp_rewrite->permalink_structure;
|
683 |
-
$wp_rewrite->set_permalink_structure($old_permalink_structure);
|
684 |
-
$wp_rewrite->flush_rules( true );//Update permalinks - hard flush
|
685 |
-
}catch(Exception $e) {
|
686 |
-
$logger->log('(restore.update_permalinks) Exception: ' .$e);
|
687 |
-
return false;
|
688 |
-
}
|
689 |
-
$logger->log('(restore.update_permalinks) Permalinks updated.');
|
690 |
-
return true;
|
691 |
}
|
1 |
+
<?php if (!defined ('ABSPATH')) die('No direct access allowed (restore)');
|
2 |
+
@set_time_limit(900);// 15 minutes per image should be PLENTY
|
3 |
+
|
4 |
+
/**
|
5 |
+
* WP Backitup Restore Functions
|
6 |
+
*
|
7 |
+
* @package WP Backitup Pro
|
8 |
+
*
|
9 |
+
* @author cssimmon
|
10 |
+
*
|
11 |
+
*/
|
12 |
+
|
13 |
+
/*** Includes ***/
|
14 |
+
// include backup class
|
15 |
+
if( !class_exists( 'WPBackItUp_Restore' ) ) {
|
16 |
+
include_once 'class-restore.php';
|
17 |
+
}
|
18 |
+
|
19 |
+
// include file system class
|
20 |
+
if( !class_exists( 'WPBackItUp_Filesystem' ) ) {
|
21 |
+
include_once 'class-filesystem.php';
|
22 |
+
}
|
23 |
+
|
24 |
+
// include SQL class
|
25 |
+
if( !class_exists( 'WPBackItUp_SQL' ) ) {
|
26 |
+
include_once 'class-sql.php';
|
27 |
+
}
|
28 |
+
|
29 |
+
/*** Globals ***/
|
30 |
+
global $WPBackitup;
|
31 |
+
global $table_prefix; //this is from wp-config
|
32 |
+
|
33 |
+
global $backup_file_name; //name of the backup file
|
34 |
+
global $backup_file_path; //full path to zip file on server
|
35 |
+
global $RestorePoint_SQL; //path to restore point
|
36 |
+
|
37 |
+
global $status_array,$inactive,$active,$complete,$failure,$warning,$success;
|
38 |
+
$inactive=0;
|
39 |
+
$active=1;
|
40 |
+
$complete=2;
|
41 |
+
$failure=-1;
|
42 |
+
$warning=-2;
|
43 |
+
$success=99;
|
44 |
+
|
45 |
+
//setup the status array
|
46 |
+
global $status_array;
|
47 |
+
$status_array = array(
|
48 |
+
'preparing' =>$inactive ,
|
49 |
+
'unzipping' =>$inactive ,
|
50 |
+
'validation'=>$inactive,
|
51 |
+
'restore_point'=>$inactive,
|
52 |
+
'database'=>$inactive,
|
53 |
+
'wpcontent'=>$inactive,
|
54 |
+
'cleanup'=>$inactive
|
55 |
+
);
|
56 |
+
|
57 |
+
$fileUTCDateTime=current_time( 'timestamp' );
|
58 |
+
$localDateTime = date_i18n('Y-m-d-His',$fileUTCDateTime);
|
59 |
+
$log_filename = 'restorelog_'.'_' .$localDateTime;
|
60 |
+
|
61 |
+
global $logger;
|
62 |
+
$logger = new WPBackItUp_Logger(false,null,$log_filename,true);
|
63 |
+
|
64 |
+
global $wp_restore; //Eventually everything will be migrated to this class
|
65 |
+
$wp_restore = new WPBackItUp_Restore($logger);
|
66 |
+
|
67 |
+
|
68 |
+
//*****************//
|
69 |
+
//*** MAIN CODE ***//
|
70 |
+
//*****************//
|
71 |
+
$logger->log('***BEGIN RESTORE***');
|
72 |
+
$logger->logConstants();
|
73 |
+
|
74 |
+
if (!$this->license_active()){
|
75 |
+
$logger->log('Restore is not available because license is not active.');
|
76 |
+
write_fatal_error_status('error225');
|
77 |
+
die();
|
78 |
+
}
|
79 |
+
|
80 |
+
//--Get form post values
|
81 |
+
$backup_file_name = $_POST['selected_file'];//Get the backup file name
|
82 |
+
if( empty($backup_file_name)) {
|
83 |
+
write_fatal_error_status('error201');
|
84 |
+
die();
|
85 |
+
}
|
86 |
+
|
87 |
+
//Get user ID
|
88 |
+
$user_id = $_POST['user_id'];
|
89 |
+
if( empty($user_id)) {
|
90 |
+
write_fatal_error_status('error201');
|
91 |
+
die();
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
//TEST
|
96 |
+
|
97 |
+
//END TEST
|
98 |
+
|
99 |
+
set_status('preparing',$active,true);
|
100 |
+
|
101 |
+
//set path to backup file
|
102 |
+
$backup_file_path = $wp_restore->backup_folder_path .$backup_file_name ;
|
103 |
+
|
104 |
+
$logger->log('**DELETE RESTORE FOLDER**');
|
105 |
+
delete_restore_folder();
|
106 |
+
$logger->log('** END DELETE RESTORE FOLDER**');
|
107 |
+
|
108 |
+
$logger->log('**CREATE RESTORE FOLDER**');
|
109 |
+
create_restore_folder($wp_restore->restore_folder_path);
|
110 |
+
set_status('preparing',$complete,false);
|
111 |
+
$logger->log('**END CREATE RESTORE FOLDER**');
|
112 |
+
|
113 |
+
$logger->log('**UNZIP BACKUP**');
|
114 |
+
set_status('unzipping',$active,true);
|
115 |
+
unzip_backup($backup_file_path,$wp_restore->restore_folder_path);
|
116 |
+
set_status('unzipping',$complete,false);
|
117 |
+
$logger->log('**END UNZIP BACKUP**');
|
118 |
+
|
119 |
+
|
120 |
+
$logger->log('**VALIDATE BACKUP**');
|
121 |
+
set_status('validation',$active,true);
|
122 |
+
$restoration_dir_path=validate_restore_folder($wp_restore->restore_folder_path);
|
123 |
+
$logger->log('**END VALIDATE BACKUP**');
|
124 |
+
|
125 |
+
|
126 |
+
$logger->log('**VALIDATE SQL FILE EXISTS**');
|
127 |
+
$backupSQLFile = $restoration_dir_path . WPBACKITUP__SQL_DBBACKUP_FILENAME;
|
128 |
+
validate_SQL_exists($backupSQLFile);
|
129 |
+
$logger->log('**END VALIDATE SQL FILE EXISTS**');
|
130 |
+
|
131 |
+
|
132 |
+
$logger->log('**GET SITE VALUES FROM DB**');
|
133 |
+
$siteurl = get_siteurl();
|
134 |
+
$homeurl = get_homeurl();
|
135 |
+
$user_login = get_user_login($user_id);
|
136 |
+
$user_pass = get_user_pass($user_id);
|
137 |
+
$user_email = get_user_email($user_id);
|
138 |
+
$logger->log('**END GET SITE VALUES FROM DB**');
|
139 |
+
|
140 |
+
//Collect previous backup site url start
|
141 |
+
$logger->log('**GET backupsiteinfo.txt VALUES**');
|
142 |
+
$import_siteinfo_lines = file($restoration_dir_path .'backupsiteinfo.txt');
|
143 |
+
$import_siteurl = str_replace("\n", '',trim($import_siteinfo_lines[0]));
|
144 |
+
$current_siteurl = trim($siteurl ,'/');
|
145 |
+
$import_table_prefix = str_replace("\n", '',$import_siteinfo_lines[1]);
|
146 |
+
$import_wp_version = str_replace("\n", '',$import_siteinfo_lines[2]);
|
147 |
+
$logger->log($import_siteinfo_lines);
|
148 |
+
|
149 |
+
//Check table prefix values FATAL
|
150 |
+
if($table_prefix !=$import_table_prefix) {
|
151 |
+
$logger->log('Error: Table prefix different from restore.');
|
152 |
+
write_warning_status('error221');
|
153 |
+
}
|
154 |
+
|
155 |
+
$logger->log('**END GET backupsiteinfo.txt VALUES**');
|
156 |
+
|
157 |
+
$logger->log('**CREATE RESTORE POINT**');
|
158 |
+
//Create restore point for DB
|
159 |
+
set_status('validation',$complete,false);
|
160 |
+
set_status('restore_point',$active,true);
|
161 |
+
$RestorePoint_SQL = backup_database($wp_restore->backup_folder_path); //Save in backup folder
|
162 |
+
set_status('restore_point',$complete,false);
|
163 |
+
$logger->log('**END CREATE RESTORE POINT**');
|
164 |
+
|
165 |
+
|
166 |
+
$logger->log('**RESTORE DATABASE**');
|
167 |
+
//Import the backed up database
|
168 |
+
set_status('database',$active,true);
|
169 |
+
import_backedup_database($backupSQLFile,$RestorePoint_SQL);
|
170 |
+
$logger->log('**END RESTORE DATABASE**');
|
171 |
+
|
172 |
+
|
173 |
+
$logger->log('**UPDATE DATABASE VALUES**');
|
174 |
+
//FAILURES AFTER THIS POINT SHOULD REQUIRE ROLLBACK OF DB
|
175 |
+
update_user_credentials($import_table_prefix, $user_login, $user_pass, $user_email, $user_id);
|
176 |
+
update_siteurl($import_table_prefix, $current_siteurl);
|
177 |
+
update_homeurl($import_table_prefix, $homeurl);
|
178 |
+
$logger->log('**END UPDATE DATABASE VALUES**');
|
179 |
+
|
180 |
+
//Done with DB restore
|
181 |
+
set_status('database',$complete,false);
|
182 |
+
|
183 |
+
|
184 |
+
|
185 |
+
//***DEAL WITH WPCONTENT NOW ***
|
186 |
+
set_status('wpcontent',$active,true);
|
187 |
+
$logger->log('**DELETE PLUGINS**');
|
188 |
+
delete_plugins_content();
|
189 |
+
$logger->log('**END DELETE PLUGINS**');
|
190 |
+
|
191 |
+
$logger->log('**DELETE THEMES**');
|
192 |
+
delete_themes_content();
|
193 |
+
$logger->log('**END DELETE THEMES**');
|
194 |
+
|
195 |
+
$logger->log('**DELETE WPCONTENT**');
|
196 |
+
//delete whatever is left
|
197 |
+
$wpcontent_folder=WPBACKITUP__CONTENT_PATH;
|
198 |
+
delete_wpcontent_content($wpcontent_folder);
|
199 |
+
$logger->log('**END DELETE WPCONTENT**');
|
200 |
+
|
201 |
+
$logger->log('**RESTORE WPCONTENT**');
|
202 |
+
restore_wpcontent($restoration_dir_path);
|
203 |
+
set_status('wpcontent',$complete,false);
|
204 |
+
$logger->log('**END DELETE WPCONTENT**');
|
205 |
+
|
206 |
+
$logger->log('**VALIDATE WPCONTENT**');
|
207 |
+
validate_wpcontent($restoration_dir_path,$wpcontent_folder);
|
208 |
+
$logger->log('**END VALIDATE WPCONTENT**');
|
209 |
+
|
210 |
+
$logger->log('**UPDATE PERMALINKS**');
|
211 |
+
update_permalinks();
|
212 |
+
$logger->log('**END UPDATE PERMALINKS**');
|
213 |
+
|
214 |
+
|
215 |
+
$logger->log('**CLEANUP**');
|
216 |
+
set_status('cleanup',$active,true);
|
217 |
+
cleanup_restore_folder($restoration_dir_path);
|
218 |
+
set_status('cleanup',$complete,false);
|
219 |
+
$logger->log('**END CLEANUP**');
|
220 |
+
|
221 |
+
set_status_success();
|
222 |
+
$logger->log('Restore completed successfully');
|
223 |
+
$logger->log('***END RESTORE***');
|
224 |
+
die();
|
225 |
+
|
226 |
+
/******************/
|
227 |
+
/*** Functions ***/
|
228 |
+
/******************/
|
229 |
+
|
230 |
+
//Get Status Log
|
231 |
+
function get_restore_Log() {
|
232 |
+
$log = WPBACKITUP__PLUGIN_PATH .'/logs/status.log';
|
233 |
+
if (file_exists($log)){
|
234 |
+
unlink($log);
|
235 |
+
}
|
236 |
+
$fh = fopen($log, 'w+') or die( "Can't write to log file" );
|
237 |
+
return $fh;
|
238 |
+
}
|
239 |
+
|
240 |
+
function write_fatal_error_status($status_code) {
|
241 |
+
global $status_array,$inactive,$active,$complete,$failure,$warning,$success;
|
242 |
+
|
243 |
+
//Find the active status and set to failure
|
244 |
+
foreach ($status_array as $key => $value) {
|
245 |
+
if ($value==$active){
|
246 |
+
$status_array[$key]=$failure;
|
247 |
+
}
|
248 |
+
}
|
249 |
+
|
250 |
+
//Add failure to array
|
251 |
+
$status_array[$status_code]=$failure;
|
252 |
+
write_restore_status();
|
253 |
+
}
|
254 |
+
|
255 |
+
function write_warning_status($status_code) {
|
256 |
+
global $status_array,$inactive,$active,$complete,$failure,$warning,$success;
|
257 |
+
|
258 |
+
//Add warning to array
|
259 |
+
$status_array[$status_code]=$warning;
|
260 |
+
write_restore_status();
|
261 |
+
}
|
262 |
+
|
263 |
+
function write_restore_status() {
|
264 |
+
global $status_array;
|
265 |
+
$fh=get_restore_Log();
|
266 |
+
|
267 |
+
foreach ($status_array as $key => $value) {
|
268 |
+
fwrite($fh, '<div class="' . $key . '">' . $value .'</div>');
|
269 |
+
}
|
270 |
+
fclose($fh);
|
271 |
+
}
|
272 |
+
|
273 |
+
function set_status($process,$status,$flush){
|
274 |
+
global $status_array;
|
275 |
+
$status_array[$process]=$status;
|
276 |
+
|
277 |
+
if ($flush) write_restore_status();
|
278 |
+
}
|
279 |
+
|
280 |
+
function set_status_success(){
|
281 |
+
global $status_array,$inactive,$active,$complete,$failure,$warning,$success;
|
282 |
+
global $active;
|
283 |
+
|
284 |
+
$status_array['finalinfo']=$success;
|
285 |
+
write_restore_status();
|
286 |
+
}
|
287 |
+
|
288 |
+
//Create an empty restore folder
|
289 |
+
function create_restore_folder($path) {
|
290 |
+
global $logger;
|
291 |
+
$logger->log('Create restore folder:' .$path);
|
292 |
+
|
293 |
+
$fileSystem = new WPBackItUp_FileSystem($logger);
|
294 |
+
if(!$fileSystem->create_dir($path)) {
|
295 |
+
$logger->log('Error: Cant create restore folder :'. $path);
|
296 |
+
write_fatal_error_status('error222');
|
297 |
+
die();
|
298 |
+
}
|
299 |
+
$logger->log('Restore folder created:' .$path);
|
300 |
+
}
|
301 |
+
|
302 |
+
//Delete restore folder and contents
|
303 |
+
function delete_restore_folder() {
|
304 |
+
global $logger;
|
305 |
+
global $wp_restore;
|
306 |
+
//Delete the existing restore directory
|
307 |
+
$logger->log('Delete existing restore folder:' .$wp_restore->restore_folder_path);
|
308 |
+
$fileSystem = new WPBackItUp_FileSystem($logger);
|
309 |
+
return $fileSystem->recursive_delete($wp_restore->restore_folder_path);
|
310 |
+
}
|
311 |
+
|
312 |
+
//Unzip the backup to the restore folder
|
313 |
+
function unzip_backup($backup_file_path,$restore_folder_root){
|
314 |
+
global $logger;
|
315 |
+
//unzip the upload
|
316 |
+
$logger->log('Unzip the backup file source:' .$backup_file_path);
|
317 |
+
$logger->log('Unzip the backup file target:' .$restore_folder_root);
|
318 |
+
$zip = new ZipArchive;
|
319 |
+
$res = $zip->open($backup_file_path);
|
320 |
+
if ($res === TRUE) {
|
321 |
+
$zip->extractTo($restore_folder_root);
|
322 |
+
$zip->close();
|
323 |
+
} else {
|
324 |
+
$logger->log('Error: Cant unzip backup:'.$backup_file_path);
|
325 |
+
write_fatal_error_status('error203');
|
326 |
+
delete_restore_folder();
|
327 |
+
die();
|
328 |
+
}
|
329 |
+
$logger->log('Backup file unzipped: ' .$restore_folder_root);
|
330 |
+
}
|
331 |
+
|
332 |
+
//Validate the restore folder
|
333 |
+
function validate_restore_folder($restore_folder_root){
|
334 |
+
global $logger;
|
335 |
+
$restoration_dir_path='';
|
336 |
+
|
337 |
+
$logger->log('Identify the restoration directory in restore folder: ' .$restore_folder_root.'*');
|
338 |
+
if ( count( glob( $restore_folder_root.'*', GLOB_ONLYDIR ) ) == 1 ) {
|
339 |
+
foreach( glob($restore_folder_root .'*', GLOB_ONLYDIR ) as $dir) {
|
340 |
+
$restoration_dir_path = $dir .'/';
|
341 |
+
$logger->log('Restoration directory Set to: ' .$restoration_dir_path);
|
342 |
+
}
|
343 |
+
}
|
344 |
+
|
345 |
+
if (empty($restoration_dir_path)) {
|
346 |
+
$logger->log('Error: Restore directory INVALID: ' .$restore_folder_root);
|
347 |
+
write_fatal_error_status('error204');
|
348 |
+
delete_restore_folder(); //delete the restore folder if bad
|
349 |
+
die();
|
350 |
+
}
|
351 |
+
|
352 |
+
//Validate the restoration
|
353 |
+
$logger->log('Validate restoration directory: ' . $restoration_dir_path .'backupsiteinfo.txt');
|
354 |
+
if(!glob($restoration_dir_path .'backupsiteinfo.txt') ){
|
355 |
+
$logger->log('Error: backupsiteinfo.txt missing from restore folder: ' .$restoration_dir_path);
|
356 |
+
write_fatal_error_status('error204');
|
357 |
+
delete_restore_folder(); //delete the restore folder if bad
|
358 |
+
die();
|
359 |
+
}
|
360 |
+
$logger->log('Restoration directory validated: ' .$restoration_dir_path);
|
361 |
+
return $restoration_dir_path;
|
362 |
+
}
|
363 |
+
|
364 |
+
// Backup the current database try dump first
|
365 |
+
function backup_database($restore_folder_root){
|
366 |
+
global $logger;
|
367 |
+
$date = date_i18n('Y-m-d-Hi',current_time( 'timestamp' ));
|
368 |
+
$backup_file = $restore_folder_root . 'db-backup-' . $date .'.cur';
|
369 |
+
$logger->log('Backup the current database: ' .$backup_file);
|
370 |
+
|
371 |
+
$dbc = new WPBackItUp_SQL($logger);
|
372 |
+
if(!$dbc->mysqldump_export($backup_file)) {
|
373 |
+
//Try a manual restore since dump didnt work
|
374 |
+
if(!$dbc->manual_export($backup_file)) {
|
375 |
+
$logger->log('Error: Cant backup database:'.$backup_file);
|
376 |
+
write_fatal_error_status('error205');
|
377 |
+
delete_restore_folder();
|
378 |
+
die();
|
379 |
+
}
|
380 |
+
}
|
381 |
+
$logger->log('Current database backed up: ' .$backup_file);
|
382 |
+
return $backup_file;
|
383 |
+
}
|
384 |
+
|
385 |
+
//Make sure there IS a backup to restore
|
386 |
+
function validate_SQL_exists($backupSQLFile){
|
387 |
+
global $logger;
|
388 |
+
$logger->log('Check for database backup file:' . $backupSQLFile);
|
389 |
+
|
390 |
+
if(!file_exists($backupSQLFile) && !empty($backupSQLFile)) {
|
391 |
+
$logger->log('Error: NO Database backups in backup.');
|
392 |
+
write_fatal_error_status('error216');
|
393 |
+
delete_restore_folder();
|
394 |
+
die();
|
395 |
+
}
|
396 |
+
$logger->log('Database backup file exist:' . $backupSQLFile);
|
397 |
+
}
|
398 |
+
|
399 |
+
//Restore DB
|
400 |
+
function restore_database(){
|
401 |
+
global $logger;
|
402 |
+
global $RestorePoint_SQL;
|
403 |
+
$logger->log('Restore the DB to previous state:' . $RestorePoint_SQL);
|
404 |
+
|
405 |
+
$dbc = new WPBackItUp_SQL($logger);
|
406 |
+
if(!$dbc->run_sql_exec($RestorePoint_SQL)) {
|
407 |
+
//Do it manually if the import doesnt work
|
408 |
+
if(!$dbc->run_sql_manual($RestorePoint_SQL)) {
|
409 |
+
$logger->log('Error: Database could not be restored.' .$RestorePoint_SQL);
|
410 |
+
write_fatal_error_status('error223');
|
411 |
+
delete_restore_folder();
|
412 |
+
die();
|
413 |
+
}
|
414 |
+
}
|
415 |
+
write_fatal_error_status('error224');
|
416 |
+
$logger->log('Database restored to previous state.');
|
417 |
+
}
|
418 |
+
|
419 |
+
//Run DB restore
|
420 |
+
function import_backedup_database($backupSQLFile,$restorePoint_SQL){
|
421 |
+
global $logger;
|
422 |
+
|
423 |
+
$logger->log('Import the backed up database.');
|
424 |
+
//Try SQL Import first
|
425 |
+
|
426 |
+
$dbc = new WPBackItUp_SQL($logger);
|
427 |
+
if(!$dbc->run_sql_exec($backupSQLFile)) {
|
428 |
+
//Do it manually if the import doesnt work
|
429 |
+
if(!$dbc->run_sql_manual($backupSQLFile)) {
|
430 |
+
$logger->log('Error: Database import error.');
|
431 |
+
|
432 |
+
//Restore to checkpoint
|
433 |
+
if ($dbc->run_sql_manual($restorePoint_SQL)){
|
434 |
+
$logger->log('Database successfully restored to checkpoint.');
|
435 |
+
write_fatal_error_status('error230');
|
436 |
+
|
437 |
+
}
|
438 |
+
else {
|
439 |
+
$logger->log('Database NOT restored to checkpoint.');
|
440 |
+
write_fatal_error_status('error212');
|
441 |
+
}
|
442 |
+
|
443 |
+
delete_restore_folder();
|
444 |
+
die();
|
445 |
+
}
|
446 |
+
}
|
447 |
+
$logger->log('Backed up database imported.');
|
448 |
+
}
|
449 |
+
|
450 |
+
//get siteurl
|
451 |
+
function get_siteurl(){
|
452 |
+
global $logger;
|
453 |
+
global $table_prefix;
|
454 |
+
$sql = "SELECT option_value FROM " .$table_prefix ."options WHERE option_name ='siteurl';";
|
455 |
+
|
456 |
+
$dbc = new WPBackItUp_SQL($logger);
|
457 |
+
$siteurl = $dbc->get_sql_scalar($sql);
|
458 |
+
if (empty($siteurl)) {
|
459 |
+
$logger->log('Error: Siteurl not found');
|
460 |
+
write_fatal_error_status('error207');
|
461 |
+
delete_restore_folder();
|
462 |
+
die();
|
463 |
+
}
|
464 |
+
$logger->log('Siteurl found:' .$siteurl);
|
465 |
+
return $siteurl;
|
466 |
+
}
|
467 |
+
|
468 |
+
//get homeurl
|
469 |
+
function get_homeurl(){
|
470 |
+
global $logger;
|
471 |
+
global $table_prefix;
|
472 |
+
$sql = "SELECT option_value FROM " .$table_prefix ."options WHERE option_name ='home';";
|
473 |
+
$dbc = new WPBackItUp_SQL($logger);
|
474 |
+
$homeurl = $dbc->get_sql_scalar($sql);
|
475 |
+
if (empty($homeurl)) {
|
476 |
+
$logger->log('Error: Homeurl not found.');
|
477 |
+
write_fatal_error_status('error208');
|
478 |
+
delete_restore_folder();
|
479 |
+
die();
|
480 |
+
}
|
481 |
+
$logger->log('homeurl found:' . $homeurl);
|
482 |
+
return $homeurl;
|
483 |
+
}
|
484 |
+
|
485 |
+
//get user login
|
486 |
+
function get_user_login($user_id){
|
487 |
+
global $logger;
|
488 |
+
global $table_prefix;
|
489 |
+
$sql = "SELECT user_login FROM ". $table_prefix ."users WHERE ID=" .$user_id .";";
|
490 |
+
|
491 |
+
$dbc = new WPBackItUp_SQL($logger);
|
492 |
+
$user_login = $dbc->get_sql_scalar($sql);
|
493 |
+
if (empty($user_login)) {
|
494 |
+
$logger->log('Error: user_login not found.');
|
495 |
+
write_fatal_error_status('error209');
|
496 |
+
delete_restore_folder();
|
497 |
+
die();
|
498 |
+
}
|
499 |
+
$logger->log('user_login found.');
|
500 |
+
return $user_login;
|
501 |
+
}
|
502 |
+
|
503 |
+
//get user pass
|
504 |
+
function get_user_pass($user_id){
|
505 |
+
global $logger;
|
506 |
+
global $table_prefix;
|
507 |
+
$sql = "SELECT user_pass FROM ". $table_prefix ."users WHERE ID=" .$user_id .";";
|
508 |
+
|
509 |
+
$dbc = new WPBackItUp_SQL($logger);
|
510 |
+
$user_pass = $dbc->get_sql_scalar($sql);
|
511 |
+
if (empty($user_pass)) {
|
512 |
+
$logger->log('Error: user_pass not found.');
|
513 |
+
write_fatal_error_status('error210');
|
514 |
+
delete_restore_folder();
|
515 |
+
die();
|
516 |
+
}
|
517 |
+
$logger->log('user_pass found.');
|
518 |
+
return $user_pass;
|
519 |
+
}
|
520 |
+
|
521 |
+
//get user email
|
522 |
+
function get_user_email($user_id){
|
523 |
+
global $logger;
|
524 |
+
global $table_prefix;
|
525 |
+
$sql = "SELECT user_email FROM ". $table_prefix ."users WHERE ID=" .$user_id ."";
|
526 |
+
|
527 |
+
$dbc = new WPBackItUp_SQL($logger);
|
528 |
+
$user_email = $dbc->get_sql_scalar($sql);
|
529 |
+
if (empty($user_email)) {
|
530 |
+
$logger->log('Error: user_email not found.');
|
531 |
+
write_fatal_error_status('error211');
|
532 |
+
delete_restore_folder();
|
533 |
+
die();
|
534 |
+
}
|
535 |
+
$logger->log('user_email found.' . $user_email);
|
536 |
+
return $user_email;
|
537 |
+
}
|
538 |
+
|
539 |
+
//Update user credentials
|
540 |
+
function update_user_credentials($table_prefix, $user_login, $user_pass, $user_email, $user_id){
|
541 |
+
global $logger;
|
542 |
+
$sql = "UPDATE ". $table_prefix ."users SET user_login='" .$user_login ."', user_pass='" .$user_pass ."', user_email='" .$user_email ."' WHERE ID='" .$user_id ."'";
|
543 |
+
|
544 |
+
$dbc = new WPBackItUp_SQL($logger);
|
545 |
+
if (!$dbc->run_sql_command($sql)){
|
546 |
+
$logger->log('Error: User Credential database update failed..');
|
547 |
+
write_warning_status('error215');
|
548 |
+
restore_database();
|
549 |
+
delete_restore_folder();
|
550 |
+
die();
|
551 |
+
}
|
552 |
+
$logger->log('User Credential updated in database.');
|
553 |
+
}
|
554 |
+
|
555 |
+
//update the site URL in the restored database
|
556 |
+
function update_siteurl($table_prefix, $current_siteurl){
|
557 |
+
global $logger;
|
558 |
+
$sql = "UPDATE ". $table_prefix ."options SET option_value='" .$current_siteurl ."' WHERE option_name='siteurl'";
|
559 |
+
|
560 |
+
$dbc = new WPBackItUp_SQL($logger);
|
561 |
+
if (!$dbc->run_sql_command($sql)){
|
562 |
+
$logger->log('Error: SiteURL updated failed.');
|
563 |
+
write_warning_status('error213');
|
564 |
+
restore_database();
|
565 |
+
delete_restore_folder();
|
566 |
+
die();
|
567 |
+
}
|
568 |
+
$logger->log('SiteURL updated in database.');
|
569 |
+
}
|
570 |
+
|
571 |
+
//Update homeURL
|
572 |
+
function update_homeurl($table_prefix, $homeurl){
|
573 |
+
global $logger;
|
574 |
+
$sql = "UPDATE ". $table_prefix ."options SET option_value='" .$homeurl ."' WHERE option_name='home'";
|
575 |
+
$dbc = new WPBackItUp_SQL($logger);
|
576 |
+
if (!$dbc->run_sql_command($sql)){
|
577 |
+
$logger->log('Error: HomeURL database update failed..');
|
578 |
+
write_warning_status('error214');
|
579 |
+
restore_database();
|
580 |
+
delete_restore_folder();
|
581 |
+
die();
|
582 |
+
}
|
583 |
+
$logger->log('HomeURL updated in database.');
|
584 |
+
}
|
585 |
+
|
586 |
+
//Delete wp-content content
|
587 |
+
function delete_wpcontent_content($root_folder){
|
588 |
+
global $logger;
|
589 |
+
$logger->log('Delete the wp_content contents:' .$root_folder);
|
590 |
+
$ignore = array(WPBACKITUP__PLUGIN_FOLDER,WPBACKITUP__RESTORE_FOLDER,WPBACKITUP__BACKUP_FOLDER,'debug.log');
|
591 |
+
$filesystem = new WPBackItUp_FileSystem($logger);
|
592 |
+
if(!$filesystem->recursive_delete($root_folder,$ignore)) {
|
593 |
+
$logger->log('Error: Cant delete WPContent:' .$root_folder);
|
594 |
+
write_warning_status('error217');
|
595 |
+
restore_database();
|
596 |
+
delete_restore_folder();
|
597 |
+
die();
|
598 |
+
}
|
599 |
+
$logger->log('wp-content has been deleted:' .$root_folder);
|
600 |
+
}
|
601 |
+
|
602 |
+
//Delete plugins content
|
603 |
+
function delete_plugins_content(){
|
604 |
+
global $logger;
|
605 |
+
$plugins_folder=WPBACKITUP__PLUGINS_ROOT_PATH;
|
606 |
+
$logger->log('Delete the plugins contents:' .$plugins_folder);
|
607 |
+
$ignore = array(WPBACKITUP__PLUGIN_FOLDER);
|
608 |
+
$filesystem = new WPBackItUp_FileSystem($logger);
|
609 |
+
if(!$filesystem->recursive_delete($plugins_folder,$ignore)) {
|
610 |
+
$logger->log('Error: Cant delete old WPContent:' .$plugins_folder );
|
611 |
+
write_warning_status('error217');
|
612 |
+
restore_database();
|
613 |
+
delete_restore_folder();
|
614 |
+
die();
|
615 |
+
}
|
616 |
+
$logger->log('Plugins content deleted:' .$plugins_folder);
|
617 |
+
}
|
618 |
+
|
619 |
+
|
620 |
+
//Delete themes content
|
621 |
+
function delete_themes_content(){
|
622 |
+
global $logger;
|
623 |
+
$themes_folder=WPBACKITUP__THEMES_ROOT_PATH ;
|
624 |
+
$logger->log('Delete the themes contents:' .$themes_folder);
|
625 |
+
$filesystem = new WPBackItUp_FileSystem($logger);
|
626 |
+
if(!$filesystem->recursive_delete($themes_folder)) {
|
627 |
+
$logger->log('Error: Cant delete old WPContent:' .$themes_folder );
|
628 |
+
write_warning_status('error217');
|
629 |
+
restore_database();
|
630 |
+
delete_restore_folder();
|
631 |
+
die();
|
632 |
+
}
|
633 |
+
$logger->log('Themes content deleted:' .$themes_folder);
|
634 |
+
}
|
635 |
+
|
636 |
+
//Restore all wp content from zip
|
637 |
+
function restore_wpcontent($restoration_dir_path){
|
638 |
+
global $logger;
|
639 |
+
$logger->log('Copy content folder from:' .$restoration_dir_path);
|
640 |
+
$logger->log('Copy content folder to:' .WPBACKITUP__CONTENT_PATH);
|
641 |
+
$ignore = array(WPBACKITUP__PLUGIN_FOLDER, WPBACKITUP__BACKUP_FOLDER,WPBACKITUP__RESTORE_FOLDER, 'status.log','debug.log', WPBACKITUP__SQL_DBBACKUP_FILENAME, 'backupsiteinfo.txt');
|
642 |
+
$filesystem = new WPBackItUp_FileSystem($logger);
|
643 |
+
if(!$filesystem->recursive_copy($restoration_dir_path,WPBACKITUP__CONTENT_PATH. '/',$ignore)) {
|
644 |
+
$logger->log('Error: Content folder was not copied successfully');
|
645 |
+
write_warning_status('error219');
|
646 |
+
restore_database();
|
647 |
+
delete_restore_folder();
|
648 |
+
die();
|
649 |
+
}
|
650 |
+
$logger->log('Content folder copied successfully');
|
651 |
+
}
|
652 |
+
|
653 |
+
//Restore all wp content from zip
|
654 |
+
function validate_wpcontent($source_dir_path,$target_dir_path){
|
655 |
+
global $logger;
|
656 |
+
$logger->log('Validate content folder TO:' .$source_dir_path);
|
657 |
+
$logger->log('Validate content folder FROM:' .$target_dir_path);
|
658 |
+
|
659 |
+
$ignore = array(WPBACKITUP__PLUGIN_FOLDER,'debug.log','backupsiteinfo.txt','db-backup.sql');
|
660 |
+
$filesystem = new WPBackItUp_FileSystem($logger);
|
661 |
+
if(!$filesystem->recursive_validate($source_dir_path. '/', $target_dir_path . '/',$ignore)) {
|
662 |
+
$logger->log('Error: Content folder is not the same as backup.');
|
663 |
+
}
|
664 |
+
|
665 |
+
$logger->log('Content folder validation complete.');
|
666 |
+
}
|
667 |
+
|
668 |
+
//Delete the restoration directory
|
669 |
+
function cleanup_restore_folder($restoration_dir_path){
|
670 |
+
global $logger;
|
671 |
+
$logger->log('Cleanup the restore folder: ' .$restoration_dir_path);
|
672 |
+
if(!delete_restore_folder()) {
|
673 |
+
$logger->log('Error: Cleanup restore folder failed: ' .$restoration_dir_path);
|
674 |
+
write_warning_status('error220'); //NOT fatal
|
675 |
+
} else {
|
676 |
+
$logger->log('Restore folder cleaned successfully: ' .$restoration_dir_path);
|
677 |
+
}
|
678 |
+
}
|
679 |
+
function update_permalinks(){
|
680 |
+
global $wp_rewrite, $logger;
|
681 |
+
try {
|
682 |
+
$old_permalink_structure = $wp_rewrite->permalink_structure;
|
683 |
+
$wp_rewrite->set_permalink_structure($old_permalink_structure);
|
684 |
+
$wp_rewrite->flush_rules( true );//Update permalinks - hard flush
|
685 |
+
}catch(Exception $e) {
|
686 |
+
$logger->log('(restore.update_permalinks) Exception: ' .$e);
|
687 |
+
return false;
|
688 |
+
}
|
689 |
+
$logger->log('(restore.update_permalinks) Permalinks updated.');
|
690 |
+
return true;
|
691 |
}
|
license.txt
CHANGED
@@ -1,674 +1,674 @@
|
|
1 |
-
GNU GENERAL PUBLIC LICENSE
|
2 |
-
Version 3, 29 June 2007
|
3 |
-
|
4 |
-
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5 |
-
Everyone is permitted to copy and distribute verbatim copies
|
6 |
-
of this license document, but changing it is not allowed.
|
7 |
-
|
8 |
-
Preamble
|
9 |
-
|
10 |
-
The GNU General Public License is a free, copyleft license for
|
11 |
-
software and other kinds of works.
|
12 |
-
|
13 |
-
The licenses for most software and other practical works are designed
|
14 |
-
to take away your freedom to share and change the works. By contrast,
|
15 |
-
the GNU General Public License is intended to guarantee your freedom to
|
16 |
-
share and change all versions of a program--to make sure it remains free
|
17 |
-
software for all its users. We, the Free Software Foundation, use the
|
18 |
-
GNU General Public License for most of our software; it applies also to
|
19 |
-
any other work released this way by its authors. You can apply it to
|
20 |
-
your programs, too.
|
21 |
-
|
22 |
-
When we speak of free software, we are referring to freedom, not
|
23 |
-
price. Our General Public Licenses are designed to make sure that you
|
24 |
-
have the freedom to distribute copies of free software (and charge for
|
25 |
-
them if you wish), that you receive source code or can get it if you
|
26 |
-
want it, that you can change the software or use pieces of it in new
|
27 |
-
free programs, and that you know you can do these things.
|
28 |
-
|
29 |
-
To protect your rights, we need to prevent others from denying you
|
30 |
-
these rights or asking you to surrender the rights. Therefore, you have
|
31 |
-
certain responsibilities if you distribute copies of the software, or if
|
32 |
-
you modify it: responsibilities to respect the freedom of others.
|
33 |
-
|
34 |
-
For example, if you distribute copies of such a program, whether
|
35 |
-
gratis or for a fee, you must pass on to the recipients the same
|
36 |
-
freedoms that you received. You must make sure that they, too, receive
|
37 |
-
or can get the source code. And you must show them these terms so they
|
38 |
-
know their rights.
|
39 |
-
|
40 |
-
Developers that use the GNU GPL protect your rights with two steps:
|
41 |
-
(1) assert copyright on the software, and (2) offer you this License
|
42 |
-
giving you legal permission to copy, distribute and/or modify it.
|
43 |
-
|
44 |
-
For the developers' and authors' protection, the GPL clearly explains
|
45 |
-
that there is no warranty for this free software. For both users' and
|
46 |
-
authors' sake, the GPL requires that modified versions be marked as
|
47 |
-
changed, so that their problems will not be attributed erroneously to
|
48 |
-
authors of previous versions.
|
49 |
-
|
50 |
-
Some devices are designed to deny users access to install or run
|
51 |
-
modified versions of the software inside them, although the manufacturer
|
52 |
-
can do so. This is fundamentally incompatible with the aim of
|
53 |
-
protecting users' freedom to change the software. The systematic
|
54 |
-
pattern of such abuse occurs in the area of products for individuals to
|
55 |
-
use, which is precisely where it is most unacceptable. Therefore, we
|
56 |
-
have designed this version of the GPL to prohibit the practice for those
|
57 |
-
products. If such problems arise substantially in other domains, we
|
58 |
-
stand ready to extend this provision to those domains in future versions
|
59 |
-
of the GPL, as needed to protect the freedom of users.
|
60 |
-
|
61 |
-
Finally, every program is threatened constantly by software patents.
|
62 |
-
States should not allow patents to restrict development and use of
|
63 |
-
software on general-purpose computers, but in those that do, we wish to
|
64 |
-
avoid the special danger that patents applied to a free program could
|
65 |
-
make it effectively proprietary. To prevent this, the GPL assures that
|
66 |
-
patents cannot be used to render the program non-free.
|
67 |
-
|
68 |
-
The precise terms and conditions for copying, distribution and
|
69 |
-
modification follow.
|
70 |
-
|
71 |
-
TERMS AND CONDITIONS
|
72 |
-
|
73 |
-
0. Definitions.
|
74 |
-
|
75 |
-
"This License" refers to version 3 of the GNU General Public License.
|
76 |
-
|
77 |
-
"Copyright" also means copyright-like laws that apply to other kinds of
|
78 |
-
works, such as semiconductor masks.
|
79 |
-
|
80 |
-
"The Program" refers to any copyrightable work licensed under this
|
81 |
-
License. Each licensee is addressed as "you". "Licensees" and
|
82 |
-
"recipients" may be individuals or organizations.
|
83 |
-
|
84 |
-
To "modify" a work means to copy from or adapt all or part of the work
|
85 |
-
in a fashion requiring copyright permission, other than the making of an
|
86 |
-
exact copy. The resulting work is called a "modified version" of the
|
87 |
-
earlier work or a work "based on" the earlier work.
|
88 |
-
|
89 |
-
A "covered work" means either the unmodified Program or a work based
|
90 |
-
on the Program.
|
91 |
-
|
92 |
-
To "propagate" a work means to do anything with it that, without
|
93 |
-
permission, would make you directly or secondarily liable for
|
94 |
-
infringement under applicable copyright law, except executing it on a
|
95 |
-
computer or modifying a private copy. Propagation includes copying,
|
96 |
-
distribution (with or without modification), making available to the
|
97 |
-
public, and in some countries other activities as well.
|
98 |
-
|
99 |
-
To "convey" a work means any kind of propagation that enables other
|
100 |
-
parties to make or receive copies. Mere interaction with a user through
|
101 |
-
a computer network, with no transfer of a copy, is not conveying.
|
102 |
-
|
103 |
-
An interactive user interface displays "Appropriate Legal Notices"
|
104 |
-
to the extent that it includes a convenient and prominently visible
|
105 |
-
feature that (1) displays an appropriate copyright notice, and (2)
|
106 |
-
tells the user that there is no warranty for the work (except to the
|
107 |
-
extent that warranties are provided), that licensees may convey the
|
108 |
-
work under this License, and how to view a copy of this License. If
|
109 |
-
the interface presents a list of user commands or options, such as a
|
110 |
-
menu, a prominent item in the list meets this criterion.
|
111 |
-
|
112 |
-
1. Source Code.
|
113 |
-
|
114 |
-
The "source code" for a work means the preferred form of the work
|
115 |
-
for making modifications to it. "Object code" means any non-source
|
116 |
-
form of a work.
|
117 |
-
|
118 |
-
A "Standard Interface" means an interface that either is an official
|
119 |
-
standard defined by a recognized standards body, or, in the case of
|
120 |
-
interfaces specified for a particular programming language, one that
|
121 |
-
is widely used among developers working in that language.
|
122 |
-
|
123 |
-
The "System Libraries" of an executable work include anything, other
|
124 |
-
than the work as a whole, that (a) is included in the normal form of
|
125 |
-
packaging a Major Component, but which is not part of that Major
|
126 |
-
Component, and (b) serves only to enable use of the work with that
|
127 |
-
Major Component, or to implement a Standard Interface for which an
|
128 |
-
implementation is available to the public in source code form. A
|
129 |
-
"Major Component", in this context, means a major essential component
|
130 |
-
(kernel, window system, and so on) of the specific operating system
|
131 |
-
(if any) on which the executable work runs, or a compiler used to
|
132 |
-
produce the work, or an object code interpreter used to run it.
|
133 |
-
|
134 |
-
The "Corresponding Source" for a work in object code form means all
|
135 |
-
the source code needed to generate, install, and (for an executable
|
136 |
-
work) run the object code and to modify the work, including scripts to
|
137 |
-
control those activities. However, it does not include the work's
|
138 |
-
System Libraries, or general-purpose tools or generally available free
|
139 |
-
programs which are used unmodified in performing those activities but
|
140 |
-
which are not part of the work. For example, Corresponding Source
|
141 |
-
includes interface definition files associated with source files for
|
142 |
-
the work, and the source code for shared libraries and dynamically
|
143 |
-
linked subprograms that the work is specifically designed to require,
|
144 |
-
such as by intimate data communication or control flow between those
|
145 |
-
subprograms and other parts of the work.
|
146 |
-
|
147 |
-
The Corresponding Source need not include anything that users
|
148 |
-
can regenerate automatically from other parts of the Corresponding
|
149 |
-
Source.
|
150 |
-
|
151 |
-
The Corresponding Source for a work in source code form is that
|
152 |
-
same work.
|
153 |
-
|
154 |
-
2. Basic Permissions.
|
155 |
-
|
156 |
-
All rights granted under this License are granted for the term of
|
157 |
-
copyright on the Program, and are irrevocable provided the stated
|
158 |
-
conditions are met. This License explicitly affirms your unlimited
|
159 |
-
permission to run the unmodified Program. The output from running a
|
160 |
-
covered work is covered by this License only if the output, given its
|
161 |
-
content, constitutes a covered work. This License acknowledges your
|
162 |
-
rights of fair use or other equivalent, as provided by copyright law.
|
163 |
-
|
164 |
-
You may make, run and propagate covered works that you do not
|
165 |
-
convey, without conditions so long as your license otherwise remains
|
166 |
-
in force. You may convey covered works to others for the sole purpose
|
167 |
-
of having them make modifications exclusively for you, or provide you
|
168 |
-
with facilities for running those works, provided that you comply with
|
169 |
-
the terms of this License in conveying all material for which you do
|
170 |
-
not control copyright. Those thus making or running the covered works
|
171 |
-
for you must do so exclusively on your behalf, under your direction
|
172 |
-
and control, on terms that prohibit them from making any copies of
|
173 |
-
your copyrighted material outside their relationship with you.
|
174 |
-
|
175 |
-
Conveying under any other circumstances is permitted solely under
|
176 |
-
the conditions stated below. Sublicensing is not allowed; section 10
|
177 |
-
makes it unnecessary.
|
178 |
-
|
179 |
-
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
180 |
-
|
181 |
-
No covered work shall be deemed part of an effective technological
|
182 |
-
measure under any applicable law fulfilling obligations under article
|
183 |
-
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
184 |
-
similar laws prohibiting or restricting circumvention of such
|
185 |
-
measures.
|
186 |
-
|
187 |
-
When you convey a covered work, you waive any legal power to forbid
|
188 |
-
circumvention of technological measures to the extent such circumvention
|
189 |
-
is effected by exercising rights under this License with respect to
|
190 |
-
the covered work, and you disclaim any intention to limit operation or
|
191 |
-
modification of the work as a means of enforcing, against the work's
|
192 |
-
users, your or third parties' legal rights to forbid circumvention of
|
193 |
-
technological measures.
|
194 |
-
|
195 |
-
4. Conveying Verbatim Copies.
|
196 |
-
|
197 |
-
You may convey verbatim copies of the Program's source code as you
|
198 |
-
receive it, in any medium, provided that you conspicuously and
|
199 |
-
appropriately publish on each copy an appropriate copyright notice;
|
200 |
-
keep intact all notices stating that this License and any
|
201 |
-
non-permissive terms added in accord with section 7 apply to the code;
|
202 |
-
keep intact all notices of the absence of any warranty; and give all
|
203 |
-
recipients a copy of this License along with the Program.
|
204 |
-
|
205 |
-
You may charge any price or no price for each copy that you convey,
|
206 |
-
and you may offer support or warranty protection for a fee.
|
207 |
-
|
208 |
-
5. Conveying Modified Source Versions.
|
209 |
-
|
210 |
-
You may convey a work based on the Program, or the modifications to
|
211 |
-
produce it from the Program, in the form of source code under the
|
212 |
-
terms of section 4, provided that you also meet all of these conditions:
|
213 |
-
|
214 |
-
a) The work must carry prominent notices stating that you modified
|
215 |
-
it, and giving a relevant date.
|
216 |
-
|
217 |
-
b) The work must carry prominent notices stating that it is
|
218 |
-
released under this License and any conditions added under section
|
219 |
-
7. This requirement modifies the requirement in section 4 to
|
220 |
-
"keep intact all notices".
|
221 |
-
|
222 |
-
c) You must license the entire work, as a whole, under this
|
223 |
-
License to anyone who comes into possession of a copy. This
|
224 |
-
License will therefore apply, along with any applicable section 7
|
225 |
-
additional terms, to the whole of the work, and all its parts,
|
226 |
-
regardless of how they are packaged. This License gives no
|
227 |
-
permission to license the work in any other way, but it does not
|
228 |
-
invalidate such permission if you have separately received it.
|
229 |
-
|
230 |
-
d) If the work has interactive user interfaces, each must display
|
231 |
-
Appropriate Legal Notices; however, if the Program has interactive
|
232 |
-
interfaces that do not display Appropriate Legal Notices, your
|
233 |
-
work need not make them do so.
|
234 |
-
|
235 |
-
A compilation of a covered work with other separate and independent
|
236 |
-
works, which are not by their nature extensions of the covered work,
|
237 |
-
and which are not combined with it such as to form a larger program,
|
238 |
-
in or on a volume of a storage or distribution medium, is called an
|
239 |
-
"aggregate" if the compilation and its resulting copyright are not
|
240 |
-
used to limit the access or legal rights of the compilation's users
|
241 |
-
beyond what the individual works permit. Inclusion of a covered work
|
242 |
-
in an aggregate does not cause this License to apply to the other
|
243 |
-
parts of the aggregate.
|
244 |
-
|
245 |
-
6. Conveying Non-Source Forms.
|
246 |
-
|
247 |
-
You may convey a covered work in object code form under the terms
|
248 |
-
of sections 4 and 5, provided that you also convey the
|
249 |
-
machine-readable Corresponding Source under the terms of this License,
|
250 |
-
in one of these ways:
|
251 |
-
|
252 |
-
a) Convey the object code in, or embodied in, a physical product
|
253 |
-
(including a physical distribution medium), accompanied by the
|
254 |
-
Corresponding Source fixed on a durable physical medium
|
255 |
-
customarily used for software interchange.
|
256 |
-
|
257 |
-
b) Convey the object code in, or embodied in, a physical product
|
258 |
-
(including a physical distribution medium), accompanied by a
|
259 |
-
written offer, valid for at least three years and valid for as
|
260 |
-
long as you offer spare parts or customer support for that product
|
261 |
-
model, to give anyone who possesses the object code either (1) a
|
262 |
-
copy of the Corresponding Source for all the software in the
|
263 |
-
product that is covered by this License, on a durable physical
|
264 |
-
medium customarily used for software interchange, for a price no
|
265 |
-
more than your reasonable cost of physically performing this
|
266 |
-
conveying of source, or (2) access to copy the
|
267 |
-
Corresponding Source from a network server at no charge.
|
268 |
-
|
269 |
-
c) Convey individual copies of the object code with a copy of the
|
270 |
-
written offer to provide the Corresponding Source. This
|
271 |
-
alternative is allowed only occasionally and noncommercially, and
|
272 |
-
only if you received the object code with such an offer, in accord
|
273 |
-
with subsection 6b.
|
274 |
-
|
275 |
-
d) Convey the object code by offering access from a designated
|
276 |
-
place (gratis or for a charge), and offer equivalent access to the
|
277 |
-
Corresponding Source in the same way through the same place at no
|
278 |
-
further charge. You need not require recipients to copy the
|
279 |
-
Corresponding Source along with the object code. If the place to
|
280 |
-
copy the object code is a network server, the Corresponding Source
|
281 |
-
may be on a different server (operated by you or a third party)
|
282 |
-
that supports equivalent copying facilities, provided you maintain
|
283 |
-
clear directions next to the object code saying where to find the
|
284 |
-
Corresponding Source. Regardless of what server hosts the
|
285 |
-
Corresponding Source, you remain obligated to ensure that it is
|
286 |
-
available for as long as needed to satisfy these requirements.
|
287 |
-
|
288 |
-
e) Convey the object code using peer-to-peer transmission, provided
|
289 |
-
you inform other peers where the object code and Corresponding
|
290 |
-
Source of the work are being offered to the general public at no
|
291 |
-
charge under subsection 6d.
|
292 |
-
|
293 |
-
A separable portion of the object code, whose source code is excluded
|
294 |
-
from the Corresponding Source as a System Library, need not be
|
295 |
-
included in conveying the object code work.
|
296 |
-
|
297 |
-
A "User Product" is either (1) a "consumer product", which means any
|
298 |
-
tangible personal property which is normally used for personal, family,
|
299 |
-
or household purposes, or (2) anything designed or sold for incorporation
|
300 |
-
into a dwelling. In determining whether a product is a consumer product,
|
301 |
-
doubtful cases shall be resolved in favor of coverage. For a particular
|
302 |
-
product received by a particular user, "normally used" refers to a
|
303 |
-
typical or common use of that class of product, regardless of the status
|
304 |
-
of the particular user or of the way in which the particular user
|
305 |
-
actually uses, or expects or is expected to use, the product. A product
|
306 |
-
is a consumer product regardless of whether the product has substantial
|
307 |
-
commercial, industrial or non-consumer uses, unless such uses represent
|
308 |
-
the only significant mode of use of the product.
|
309 |
-
|
310 |
-
"Installation Information" for a User Product means any methods,
|
311 |
-
procedures, authorization keys, or other information required to install
|
312 |
-
and execute modified versions of a covered work in that User Product from
|
313 |
-
a modified version of its Corresponding Source. The information must
|
314 |
-
suffice to ensure that the continued functioning of the modified object
|
315 |
-
code is in no case prevented or interfered with solely because
|
316 |
-
modification has been made.
|
317 |
-
|
318 |
-
If you convey an object code work under this section in, or with, or
|
319 |
-
specifically for use in, a User Product, and the conveying occurs as
|
320 |
-
part of a transaction in which the right of possession and use of the
|
321 |
-
User Product is transferred to the recipient in perpetuity or for a
|
322 |
-
fixed term (regardless of how the transaction is characterized), the
|
323 |
-
Corresponding Source conveyed under this section must be accompanied
|
324 |
-
by the Installation Information. But this requirement does not apply
|
325 |
-
if neither you nor any third party retains the ability to install
|
326 |
-
modified object code on the User Product (for example, the work has
|
327 |
-
been installed in ROM).
|
328 |
-
|
329 |
-
The requirement to provide Installation Information does not include a
|
330 |
-
requirement to continue to provide support service, warranty, or updates
|
331 |
-
for a work that has been modified or installed by the recipient, or for
|
332 |
-
the User Product in which it has been modified or installed. Access to a
|
333 |
-
network may be denied when the modification itself materially and
|
334 |
-
adversely affects the operation of the network or violates the rules and
|
335 |
-
protocols for communication across the network.
|
336 |
-
|
337 |
-
Corresponding Source conveyed, and Installation Information provided,
|
338 |
-
in accord with this section must be in a format that is publicly
|
339 |
-
documented (and with an implementation available to the public in
|
340 |
-
source code form), and must require no special password or key for
|
341 |
-
unpacking, reading or copying.
|
342 |
-
|
343 |
-
7. Additional Terms.
|
344 |
-
|
345 |
-
"Additional permissions" are terms that supplement the terms of this
|
346 |
-
License by making exceptions from one or more of its conditions.
|
347 |
-
Additional permissions that are applicable to the entire Program shall
|
348 |
-
be treated as though they were included in this License, to the extent
|
349 |
-
that they are valid under applicable law. If additional permissions
|
350 |
-
apply only to part of the Program, that part may be used separately
|
351 |
-
under those permissions, but the entire Program remains governed by
|
352 |
-
this License without regard to the additional permissions.
|
353 |
-
|
354 |
-
When you convey a copy of a covered work, you may at your option
|
355 |
-
remove any additional permissions from that copy, or from any part of
|
356 |
-
it. (Additional permissions may be written to require their own
|
357 |
-
removal in certain cases when you modify the work.) You may place
|
358 |
-
additional permissions on material, added by you to a covered work,
|
359 |
-
for which you have or can give appropriate copyright permission.
|
360 |
-
|
361 |
-
Notwithstanding any other provision of this License, for material you
|
362 |
-
add to a covered work, you may (if authorized by the copyright holders of
|
363 |
-
that material) supplement the terms of this License with terms:
|
364 |
-
|
365 |
-
a) Disclaiming warranty or limiting liability differently from the
|
366 |
-
terms of sections 15 and 16 of this License; or
|
367 |
-
|
368 |
-
b) Requiring preservation of specified reasonable legal notices or
|
369 |
-
author attributions in that material or in the Appropriate Legal
|
370 |
-
Notices displayed by works containing it; or
|
371 |
-
|
372 |
-
c) Prohibiting misrepresentation of the origin of that material, or
|
373 |
-
requiring that modified versions of such material be marked in
|
374 |
-
reasonable ways as different from the original version; or
|
375 |
-
|
376 |
-
d) Limiting the use for publicity purposes of names of licensors or
|
377 |
-
authors of the material; or
|
378 |
-
|
379 |
-
e) Declining to grant rights under trademark law for use of some
|
380 |
-
trade names, trademarks, or service marks; or
|
381 |
-
|
382 |
-
f) Requiring indemnification of licensors and authors of that
|
383 |
-
material by anyone who conveys the material (or modified versions of
|
384 |
-
it) with contractual assumptions of liability to the recipient, for
|
385 |
-
any liability that these contractual assumptions directly impose on
|
386 |
-
those licensors and authors.
|
387 |
-
|
388 |
-
All other non-permissive additional terms are considered "further
|
389 |
-
restrictions" within the meaning of section 10. If the Program as you
|
390 |
-
received it, or any part of it, contains a notice stating that it is
|
391 |
-
governed by this License along with a term that is a further
|
392 |
-
restriction, you may remove that term. If a license document contains
|
393 |
-
a further restriction but permits relicensing or conveying under this
|
394 |
-
License, you may add to a covered work material governed by the terms
|
395 |
-
of that license document, provided that the further restriction does
|
396 |
-
not survive such relicensing or conveying.
|
397 |
-
|
398 |
-
If you add terms to a covered work in accord with this section, you
|
399 |
-
must place, in the relevant source files, a statement of the
|
400 |
-
additional terms that apply to those files, or a notice indicating
|
401 |
-
where to find the applicable terms.
|
402 |
-
|
403 |
-
Additional terms, permissive or non-permissive, may be stated in the
|
404 |
-
form of a separately written license, or stated as exceptions;
|
405 |
-
the above requirements apply either way.
|
406 |
-
|
407 |
-
8. Termination.
|
408 |
-
|
409 |
-
You may not propagate or modify a covered work except as expressly
|
410 |
-
provided under this License. Any attempt otherwise to propagate or
|
411 |
-
modify it is void, and will automatically terminate your rights under
|
412 |
-
this License (including any patent licenses granted under the third
|
413 |
-
paragraph of section 11).
|
414 |
-
|
415 |
-
However, if you cease all violation of this License, then your
|
416 |
-
license from a particular copyright holder is reinstated (a)
|
417 |
-
provisionally, unless and until the copyright holder explicitly and
|
418 |
-
finally terminates your license, and (b) permanently, if the copyright
|
419 |
-
holder fails to notify you of the violation by some reasonable means
|
420 |
-
prior to 60 days after the cessation.
|
421 |
-
|
422 |
-
Moreover, your license from a particular copyright holder is
|
423 |
-
reinstated permanently if the copyright holder notifies you of the
|
424 |
-
violation by some reasonable means, this is the first time you have
|
425 |
-
received notice of violation of this License (for any work) from that
|
426 |
-
copyright holder, and you cure the violation prior to 30 days after
|
427 |
-
your receipt of the notice.
|
428 |
-
|
429 |
-
Termination of your rights under this section does not terminate the
|
430 |
-
licenses of parties who have received copies or rights from you under
|
431 |
-
this License. If your rights have been terminated and not permanently
|
432 |
-
reinstated, you do not qualify to receive new licenses for the same
|
433 |
-
material under section 10.
|
434 |
-
|
435 |
-
9. Acceptance Not Required for Having Copies.
|
436 |
-
|
437 |
-
You are not required to accept this License in order to receive or
|
438 |
-
run a copy of the Program. Ancillary propagation of a covered work
|
439 |
-
occurring solely as a consequence of using peer-to-peer transmission
|
440 |
-
to receive a copy likewise does not require acceptance. However,
|
441 |
-
nothing other than this License grants you permission to propagate or
|
442 |
-
modify any covered work. These actions infringe copyright if you do
|
443 |
-
not accept this License. Therefore, by modifying or propagating a
|
444 |
-
covered work, you indicate your acceptance of this License to do so.
|
445 |
-
|
446 |
-
10. Automatic Licensing of Downstream Recipients.
|
447 |
-
|
448 |
-
Each time you convey a covered work, the recipient automatically
|
449 |
-
receives a license from the original licensors, to run, modify and
|
450 |
-
propagate that work, subject to this License. You are not responsible
|
451 |
-
for enforcing compliance by third parties with this License.
|
452 |
-
|
453 |
-
An "entity transaction" is a transaction transferring control of an
|
454 |
-
organization, or substantially all assets of one, or subdividing an
|
455 |
-
organization, or merging organizations. If propagation of a covered
|
456 |
-
work results from an entity transaction, each party to that
|
457 |
-
transaction who receives a copy of the work also receives whatever
|
458 |
-
licenses to the work the party's predecessor in interest had or could
|
459 |
-
give under the previous paragraph, plus a right to possession of the
|
460 |
-
Corresponding Source of the work from the predecessor in interest, if
|
461 |
-
the predecessor has it or can get it with reasonable efforts.
|
462 |
-
|
463 |
-
You may not impose any further restrictions on the exercise of the
|
464 |
-
rights granted or affirmed under this License. For example, you may
|
465 |
-
not impose a license fee, royalty, or other charge for exercise of
|
466 |
-
rights granted under this License, and you may not initiate litigation
|
467 |
-
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
468 |
-
any patent claim is infringed by making, using, selling, offering for
|
469 |
-
sale, or importing the Program or any portion of it.
|
470 |
-
|
471 |
-
11. Patents.
|
472 |
-
|
473 |
-
A "contributor" is a copyright holder who authorizes use under this
|
474 |
-
License of the Program or a work on which the Program is based. The
|
475 |
-
work thus licensed is called the contributor's "contributor version".
|
476 |
-
|
477 |
-
A contributor's "essential patent claims" are all patent claims
|
478 |
-
owned or controlled by the contributor, whether already acquired or
|
479 |
-
hereafter acquired, that would be infringed by some manner, permitted
|
480 |
-
by this License, of making, using, or selling its contributor version,
|
481 |
-
but do not include claims that would be infringed only as a
|
482 |
-
consequence of further modification of the contributor version. For
|
483 |
-
purposes of this definition, "control" includes the right to grant
|
484 |
-
patent sublicenses in a manner consistent with the requirements of
|
485 |
-
this License.
|
486 |
-
|
487 |
-
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
488 |
-
patent license under the contributor's essential patent claims, to
|
489 |
-
make, use, sell, offer for sale, import and otherwise run, modify and
|
490 |
-
propagate the contents of its contributor version.
|
491 |
-
|
492 |
-
In the following three paragraphs, a "patent license" is any express
|
493 |
-
agreement or commitment, however denominated, not to enforce a patent
|
494 |
-
(such as an express permission to practice a patent or covenant not to
|
495 |
-
sue for patent infringement). To "grant" such a patent license to a
|
496 |
-
party means to make such an agreement or commitment not to enforce a
|
497 |
-
patent against the party.
|
498 |
-
|
499 |
-
If you convey a covered work, knowingly relying on a patent license,
|
500 |
-
and the Corresponding Source of the work is not available for anyone
|
501 |
-
to copy, free of charge and under the terms of this License, through a
|
502 |
-
publicly available network server or other readily accessible means,
|
503 |
-
then you must either (1) cause the Corresponding Source to be so
|
504 |
-
available, or (2) arrange to deprive yourself of the benefit of the
|
505 |
-
patent license for this particular work, or (3) arrange, in a manner
|
506 |
-
consistent with the requirements of this License, to extend the patent
|
507 |
-
license to downstream recipients. "Knowingly relying" means you have
|
508 |
-
actual knowledge that, but for the patent license, your conveying the
|
509 |
-
covered work in a country, or your recipient's use of the covered work
|
510 |
-
in a country, would infringe one or more identifiable patents in that
|
511 |
-
country that you have reason to believe are valid.
|
512 |
-
|
513 |
-
If, pursuant to or in connection with a single transaction or
|
514 |
-
arrangement, you convey, or propagate by procuring conveyance of, a
|
515 |
-
covered work, and grant a patent license to some of the parties
|
516 |
-
receiving the covered work authorizing them to use, propagate, modify
|
517 |
-
or convey a specific copy of the covered work, then the patent license
|
518 |
-
you grant is automatically extended to all recipients of the covered
|
519 |
-
work and works based on it.
|
520 |
-
|
521 |
-
A patent license is "discriminatory" if it does not include within
|
522 |
-
the scope of its coverage, prohibits the exercise of, or is
|
523 |
-
conditioned on the non-exercise of one or more of the rights that are
|
524 |
-
specifically granted under this License. You may not convey a covered
|
525 |
-
work if you are a party to an arrangement with a third party that is
|
526 |
-
in the business of distributing software, under which you make payment
|
527 |
-
to the third party based on the extent of your activity of conveying
|
528 |
-
the work, and under which the third party grants, to any of the
|
529 |
-
parties who would receive the covered work from you, a discriminatory
|
530 |
-
patent license (a) in connection with copies of the covered work
|
531 |
-
conveyed by you (or copies made from those copies), or (b) primarily
|
532 |
-
for and in connection with specific products or compilations that
|
533 |
-
contain the covered work, unless you entered into that arrangement,
|
534 |
-
or that patent license was granted, prior to 28 March 2007.
|
535 |
-
|
536 |
-
Nothing in this License shall be construed as excluding or limiting
|
537 |
-
any implied license or other defenses to infringement that may
|
538 |
-
otherwise be available to you under applicable patent law.
|
539 |
-
|
540 |
-
12. No Surrender of Others' Freedom.
|
541 |
-
|
542 |
-
If conditions are imposed on you (whether by court order, agreement or
|
543 |
-
otherwise) that contradict the conditions of this License, they do not
|
544 |
-
excuse you from the conditions of this License. If you cannot convey a
|
545 |
-
covered work so as to satisfy simultaneously your obligations under this
|
546 |
-
License and any other pertinent obligations, then as a consequence you may
|
547 |
-
not convey it at all. For example, if you agree to terms that obligate you
|
548 |
-
to collect a royalty for further conveying from those to whom you convey
|
549 |
-
the Program, the only way you could satisfy both those terms and this
|
550 |
-
License would be to refrain entirely from conveying the Program.
|
551 |
-
|
552 |
-
13. Use with the GNU Affero General Public License.
|
553 |
-
|
554 |
-
Notwithstanding any other provision of this License, you have
|
555 |
-
permission to link or combine any covered work with a work licensed
|
556 |
-
under version 3 of the GNU Affero General Public License into a single
|
557 |
-
combined work, and to convey the resulting work. The terms of this
|
558 |
-
License will continue to apply to the part which is the covered work,
|
559 |
-
but the special requirements of the GNU Affero General Public License,
|
560 |
-
section 13, concerning interaction through a network will apply to the
|
561 |
-
combination as such.
|
562 |
-
|
563 |
-
14. Revised Versions of this License.
|
564 |
-
|
565 |
-
The Free Software Foundation may publish revised and/or new versions of
|
566 |
-
the GNU General Public License from time to time. Such new versions will
|
567 |
-
be similar in spirit to the present version, but may differ in detail to
|
568 |
-
address new problems or concerns.
|
569 |
-
|
570 |
-
Each version is given a distinguishing version number. If the
|
571 |
-
Program specifies that a certain numbered version of the GNU General
|
572 |
-
Public License "or any later version" applies to it, you have the
|
573 |
-
option of following the terms and conditions either of that numbered
|
574 |
-
version or of any later version published by the Free Software
|
575 |
-
Foundation. If the Program does not specify a version number of the
|
576 |
-
GNU General Public License, you may choose any version ever published
|
577 |
-
by the Free Software Foundation.
|
578 |
-
|
579 |
-
If the Program specifies that a proxy can decide which future
|
580 |
-
versions of the GNU General Public License can be used, that proxy's
|
581 |
-
public statement of acceptance of a version permanently authorizes you
|
582 |
-
to choose that version for the Program.
|
583 |
-
|
584 |
-
Later license versions may give you additional or different
|
585 |
-
permissions. However, no additional obligations are imposed on any
|
586 |
-
author or copyright holder as a result of your choosing to follow a
|
587 |
-
later version.
|
588 |
-
|
589 |
-
15. Disclaimer of Warranty.
|
590 |
-
|
591 |
-
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
592 |
-
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
593 |
-
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
594 |
-
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
595 |
-
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
596 |
-
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
597 |
-
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
598 |
-
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
599 |
-
|
600 |
-
16. Limitation of Liability.
|
601 |
-
|
602 |
-
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
603 |
-
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
604 |
-
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
605 |
-
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
606 |
-
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
607 |
-
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
608 |
-
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
609 |
-
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
610 |
-
SUCH DAMAGES.
|
611 |
-
|
612 |
-
17. Interpretation of Sections 15 and 16.
|
613 |
-
|
614 |
-
If the disclaimer of warranty and limitation of liability provided
|
615 |
-
above cannot be given local legal effect according to their terms,
|
616 |
-
reviewing courts shall apply local law that most closely approximates
|
617 |
-
an absolute waiver of all civil liability in connection with the
|
618 |
-
Program, unless a warranty or assumption of liability accompanies a
|
619 |
-
copy of the Program in return for a fee.
|
620 |
-
|
621 |
-
END OF TERMS AND CONDITIONS
|
622 |
-
|
623 |
-
How to Apply These Terms to Your New Programs
|
624 |
-
|
625 |
-
If you develop a new program, and you want it to be of the greatest
|
626 |
-
possible use to the public, the best way to achieve this is to make it
|
627 |
-
free software which everyone can redistribute and change under these terms.
|
628 |
-
|
629 |
-
To do so, attach the following notices to the program. It is safest
|
630 |
-
to attach them to the start of each source file to most effectively
|
631 |
-
state the exclusion of warranty; and each file should have at least
|
632 |
-
the "copyright" line and a pointer to where the full notice is found.
|
633 |
-
|
634 |
-
<one line to give the program's name and a brief idea of what it does.>
|
635 |
-
Copyright (C) <year> <name of author>
|
636 |
-
|
637 |
-
This program is free software: you can redistribute it and/or modify
|
638 |
-
it under the terms of the GNU General Public License as published by
|
639 |
-
the Free Software Foundation, either version 3 of the License, or
|
640 |
-
(at your option) any later version.
|
641 |
-
|
642 |
-
This program is distributed in the hope that it will be useful,
|
643 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
644 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
645 |
-
GNU General Public License for more details.
|
646 |
-
|
647 |
-
You should have received a copy of the GNU General Public License
|
648 |
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
649 |
-
|
650 |
-
Also add information on how to contact you by electronic and paper mail.
|
651 |
-
|
652 |
-
If the program does terminal interaction, make it output a short
|
653 |
-
notice like this when it starts in an interactive mode:
|
654 |
-
|
655 |
-
<program> Copyright (C) <year> <name of author>
|
656 |
-
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
657 |
-
This is free software, and you are welcome to redistribute it
|
658 |
-
under certain conditions; type `show c' for details.
|
659 |
-
|
660 |
-
The hypothetical commands `show w' and `show c' should show the appropriate
|
661 |
-
parts of the General Public License. Of course, your program's commands
|
662 |
-
might be different; for a GUI interface, you would use an "about box".
|
663 |
-
|
664 |
-
You should also get your employer (if you work as a programmer) or school,
|
665 |
-
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
666 |
-
For more information on this, and how to apply and follow the GNU GPL, see
|
667 |
-
<http://www.gnu.org/licenses/>.
|
668 |
-
|
669 |
-
The GNU General Public License does not permit incorporating your program
|
670 |
-
into proprietary programs. If your program is a subroutine library, you
|
671 |
-
may consider it more useful to permit linking proprietary applications with
|
672 |
-
the library. If this is what you want to do, use the GNU Lesser General
|
673 |
-
Public License instead of this License. But first, please read
|
674 |
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 3, 29 June 2007
|
3 |
+
|
4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
6 |
+
of this license document, but changing it is not allowed.
|
7 |
+
|
8 |
+
Preamble
|
9 |
+
|
10 |
+
The GNU General Public License is a free, copyleft license for
|
11 |
+
software and other kinds of works.
|
12 |
+
|
13 |
+
The licenses for most software and other practical works are designed
|
14 |
+
to take away your freedom to share and change the works. By contrast,
|
15 |
+
the GNU General Public License is intended to guarantee your freedom to
|
16 |
+
share and change all versions of a program--to make sure it remains free
|
17 |
+
software for all its users. We, the Free Software Foundation, use the
|
18 |
+
GNU General Public License for most of our software; it applies also to
|
19 |
+
any other work released this way by its authors. You can apply it to
|
20 |
+
your programs, too.
|
21 |
+
|
22 |
+
When we speak of free software, we are referring to freedom, not
|
23 |
+
price. Our General Public Licenses are designed to make sure that you
|
24 |
+
have the freedom to distribute copies of free software (and charge for
|
25 |
+
them if you wish), that you receive source code or can get it if you
|
26 |
+
want it, that you can change the software or use pieces of it in new
|
27 |
+
free programs, and that you know you can do these things.
|
28 |
+
|
29 |
+
To protect your rights, we need to prevent others from denying you
|
30 |
+
these rights or asking you to surrender the rights. Therefore, you have
|
31 |
+
certain responsibilities if you distribute copies of the software, or if
|
32 |
+
you modify it: responsibilities to respect the freedom of others.
|
33 |
+
|
34 |
+
For example, if you distribute copies of such a program, whether
|
35 |
+
gratis or for a fee, you must pass on to the recipients the same
|
36 |
+
freedoms that you received. You must make sure that they, too, receive
|
37 |
+
or can get the source code. And you must show them these terms so they
|
38 |
+
know their rights.
|
39 |
+
|
40 |
+
Developers that use the GNU GPL protect your rights with two steps:
|
41 |
+
(1) assert copyright on the software, and (2) offer you this License
|
42 |
+
giving you legal permission to copy, distribute and/or modify it.
|
43 |
+
|
44 |
+
For the developers' and authors' protection, the GPL clearly explains
|
45 |
+
that there is no warranty for this free software. For both users' and
|
46 |
+
authors' sake, the GPL requires that modified versions be marked as
|
47 |
+
changed, so that their problems will not be attributed erroneously to
|
48 |
+
authors of previous versions.
|
49 |
+
|
50 |
+
Some devices are designed to deny users access to install or run
|
51 |
+
modified versions of the software inside them, although the manufacturer
|
52 |
+
can do so. This is fundamentally incompatible with the aim of
|
53 |
+
protecting users' freedom to change the software. The systematic
|
54 |
+
pattern of such abuse occurs in the area of products for individuals to
|
55 |
+
use, which is precisely where it is most unacceptable. Therefore, we
|
56 |
+
have designed this version of the GPL to prohibit the practice for those
|
57 |
+
products. If such problems arise substantially in other domains, we
|
58 |
+
stand ready to extend this provision to those domains in future versions
|
59 |
+
of the GPL, as needed to protect the freedom of users.
|
60 |
+
|
61 |
+
Finally, every program is threatened constantly by software patents.
|
62 |
+
States should not allow patents to restrict development and use of
|
63 |
+
software on general-purpose computers, but in those that do, we wish to
|
64 |
+
avoid the special danger that patents applied to a free program could
|
65 |
+
make it effectively proprietary. To prevent this, the GPL assures that
|
66 |
+
patents cannot be used to render the program non-free.
|
67 |
+
|
68 |
+
The precise terms and conditions for copying, distribution and
|
69 |
+
modification follow.
|
70 |
+
|
71 |
+
TERMS AND CONDITIONS
|
72 |
+
|
73 |
+
0. Definitions.
|
74 |
+
|
75 |
+
"This License" refers to version 3 of the GNU General Public License.
|
76 |
+
|
77 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
78 |
+
works, such as semiconductor masks.
|
79 |
+
|
80 |
+
"The Program" refers to any copyrightable work licensed under this
|
81 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
82 |
+
"recipients" may be individuals or organizations.
|
83 |
+
|
84 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
85 |
+
in a fashion requiring copyright permission, other than the making of an
|
86 |
+
exact copy. The resulting work is called a "modified version" of the
|
87 |
+
earlier work or a work "based on" the earlier work.
|
88 |
+
|
89 |
+
A "covered work" means either the unmodified Program or a work based
|
90 |
+
on the Program.
|
91 |
+
|
92 |
+
To "propagate" a work means to do anything with it that, without
|
93 |
+
permission, would make you directly or secondarily liable for
|
94 |
+
infringement under applicable copyright law, except executing it on a
|
95 |
+
computer or modifying a private copy. Propagation includes copying,
|
96 |
+
distribution (with or without modification), making available to the
|
97 |
+
public, and in some countries other activities as well.
|
98 |
+
|
99 |
+
To "convey" a work means any kind of propagation that enables other
|
100 |
+
parties to make or receive copies. Mere interaction with a user through
|
101 |
+
a computer network, with no transfer of a copy, is not conveying.
|
102 |
+
|
103 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
104 |
+
to the extent that it includes a convenient and prominently visible
|
105 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
106 |
+
tells the user that there is no warranty for the work (except to the
|
107 |
+
extent that warranties are provided), that licensees may convey the
|
108 |
+
work under this License, and how to view a copy of this License. If
|
109 |
+
the interface presents a list of user commands or options, such as a
|
110 |
+
menu, a prominent item in the list meets this criterion.
|
111 |
+
|
112 |
+
1. Source Code.
|
113 |
+
|
114 |
+
The "source code" for a work means the preferred form of the work
|
115 |
+
for making modifications to it. "Object code" means any non-source
|
116 |
+
form of a work.
|
117 |
+
|
118 |
+
A "Standard Interface" means an interface that either is an official
|
119 |
+
standard defined by a recognized standards body, or, in the case of
|
120 |
+
interfaces specified for a particular programming language, one that
|
121 |
+
is widely used among developers working in that language.
|
122 |
+
|
123 |
+
The "System Libraries" of an executable work include anything, other
|
124 |
+
than the work as a whole, that (a) is included in the normal form of
|
125 |
+
packaging a Major Component, but which is not part of that Major
|
126 |
+
Component, and (b) serves only to enable use of the work with that
|
127 |
+
Major Component, or to implement a Standard Interface for which an
|
128 |
+
implementation is available to the public in source code form. A
|
129 |
+
"Major Component", in this context, means a major essential component
|
130 |
+
(kernel, window system, and so on) of the specific operating system
|
131 |
+
(if any) on which the executable work runs, or a compiler used to
|
132 |
+
produce the work, or an object code interpreter used to run it.
|
133 |
+
|
134 |
+
The "Corresponding Source" for a work in object code form means all
|
135 |
+
the source code needed to generate, install, and (for an executable
|
136 |
+
work) run the object code and to modify the work, including scripts to
|
137 |
+
control those activities. However, it does not include the work's
|
138 |
+
System Libraries, or general-purpose tools or generally available free
|
139 |
+
programs which are used unmodified in performing those activities but
|
140 |
+
which are not part of the work. For example, Corresponding Source
|
141 |
+
includes interface definition files associated with source files for
|
142 |
+
the work, and the source code for shared libraries and dynamically
|
143 |
+
linked subprograms that the work is specifically designed to require,
|
144 |
+
such as by intimate data communication or control flow between those
|
145 |
+
subprograms and other parts of the work.
|
146 |
+
|
147 |
+
The Corresponding Source need not include anything that users
|
148 |
+
can regenerate automatically from other parts of the Corresponding
|
149 |
+
Source.
|
150 |
+
|
151 |
+
The Corresponding Source for a work in source code form is that
|
152 |
+
same work.
|
153 |
+
|
154 |
+
2. Basic Permissions.
|
155 |
+
|
156 |
+
All rights granted under this License are granted for the term of
|
157 |
+
copyright on the Program, and are irrevocable provided the stated
|
158 |
+
conditions are met. This License explicitly affirms your unlimited
|
159 |
+
permission to run the unmodified Program. The output from running a
|
160 |
+
covered work is covered by this License only if the output, given its
|
161 |
+
content, constitutes a covered work. This License acknowledges your
|
162 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
163 |
+
|
164 |
+
You may make, run and propagate covered works that you do not
|
165 |
+
convey, without conditions so long as your license otherwise remains
|
166 |
+
in force. You may convey covered works to others for the sole purpose
|
167 |
+
of having them make modifications exclusively for you, or provide you
|
168 |
+
with facilities for running those works, provided that you comply with
|
169 |
+
the terms of this License in conveying all material for which you do
|
170 |
+
not control copyright. Those thus making or running the covered works
|
171 |
+
for you must do so exclusively on your behalf, under your direction
|
172 |
+
and control, on terms that prohibit them from making any copies of
|
173 |
+
your copyrighted material outside their relationship with you.
|
174 |
+
|
175 |
+
Conveying under any other circumstances is permitted solely under
|
176 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
177 |
+
makes it unnecessary.
|
178 |
+
|
179 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
180 |
+
|
181 |
+
No covered work shall be deemed part of an effective technological
|
182 |
+
measure under any applicable law fulfilling obligations under article
|
183 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
184 |
+
similar laws prohibiting or restricting circumvention of such
|
185 |
+
measures.
|
186 |
+
|
187 |
+
When you convey a covered work, you waive any legal power to forbid
|
188 |
+
circumvention of technological measures to the extent such circumvention
|
189 |
+
is effected by exercising rights under this License with respect to
|
190 |
+
the covered work, and you disclaim any intention to limit operation or
|
191 |
+
modification of the work as a means of enforcing, against the work's
|
192 |
+
users, your or third parties' legal rights to forbid circumvention of
|
193 |
+
technological measures.
|
194 |
+
|
195 |
+
4. Conveying Verbatim Copies.
|
196 |
+
|
197 |
+
You may convey verbatim copies of the Program's source code as you
|
198 |
+
receive it, in any medium, provided that you conspicuously and
|
199 |
+
appropriately publish on each copy an appropriate copyright notice;
|
200 |
+
keep intact all notices stating that this License and any
|
201 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
202 |
+
keep intact all notices of the absence of any warranty; and give all
|
203 |
+
recipients a copy of this License along with the Program.
|
204 |
+
|
205 |
+
You may charge any price or no price for each copy that you convey,
|
206 |
+
and you may offer support or warranty protection for a fee.
|
207 |
+
|
208 |
+
5. Conveying Modified Source Versions.
|
209 |
+
|
210 |
+
You may convey a work based on the Program, or the modifications to
|
211 |
+
produce it from the Program, in the form of source code under the
|
212 |
+
terms of section 4, provided that you also meet all of these conditions:
|
213 |
+
|
214 |
+
a) The work must carry prominent notices stating that you modified
|
215 |
+
it, and giving a relevant date.
|
216 |
+
|
217 |
+
b) The work must carry prominent notices stating that it is
|
218 |
+
released under this License and any conditions added under section
|
219 |
+
7. This requirement modifies the requirement in section 4 to
|
220 |
+
"keep intact all notices".
|
221 |
+
|
222 |
+
c) You must license the entire work, as a whole, under this
|
223 |
+
License to anyone who comes into possession of a copy. This
|
224 |
+
License will therefore apply, along with any applicable section 7
|
225 |
+
additional terms, to the whole of the work, and all its parts,
|
226 |
+
regardless of how they are packaged. This License gives no
|
227 |
+
permission to license the work in any other way, but it does not
|
228 |
+
invalidate such permission if you have separately received it.
|
229 |
+
|
230 |
+
d) If the work has interactive user interfaces, each must display
|
231 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
232 |
+
interfaces that do not display Appropriate Legal Notices, your
|
233 |
+
work need not make them do so.
|
234 |
+
|
235 |
+
A compilation of a covered work with other separate and independent
|
236 |
+
works, which are not by their nature extensions of the covered work,
|
237 |
+
and which are not combined with it such as to form a larger program,
|
238 |
+
in or on a volume of a storage or distribution medium, is called an
|
239 |
+
"aggregate" if the compilation and its resulting copyright are not
|
240 |
+
used to limit the access or legal rights of the compilation's users
|
241 |
+
beyond what the individual works permit. Inclusion of a covered work
|
242 |
+
in an aggregate does not cause this License to apply to the other
|
243 |
+
parts of the aggregate.
|
244 |
+
|
245 |
+
6. Conveying Non-Source Forms.
|
246 |
+
|
247 |
+
You may convey a covered work in object code form under the terms
|
248 |
+
of sections 4 and 5, provided that you also convey the
|
249 |
+
machine-readable Corresponding Source under the terms of this License,
|
250 |
+
in one of these ways:
|
251 |
+
|
252 |
+
a) Convey the object code in, or embodied in, a physical product
|
253 |
+
(including a physical distribution medium), accompanied by the
|
254 |
+
Corresponding Source fixed on a durable physical medium
|
255 |
+
customarily used for software interchange.
|
256 |
+
|
257 |
+
b) Convey the object code in, or embodied in, a physical product
|
258 |
+
(including a physical distribution medium), accompanied by a
|
259 |
+
written offer, valid for at least three years and valid for as
|
260 |
+
long as you offer spare parts or customer support for that product
|
261 |
+
model, to give anyone who possesses the object code either (1) a
|
262 |
+
copy of the Corresponding Source for all the software in the
|
263 |
+
product that is covered by this License, on a durable physical
|
264 |
+
medium customarily used for software interchange, for a price no
|
265 |
+
more than your reasonable cost of physically performing this
|
266 |
+
conveying of source, or (2) access to copy the
|
267 |
+
Corresponding Source from a network server at no charge.
|
268 |
+
|
269 |
+
c) Convey individual copies of the object code with a copy of the
|
270 |
+
written offer to provide the Corresponding Source. This
|
271 |
+
alternative is allowed only occasionally and noncommercially, and
|
272 |
+
only if you received the object code with such an offer, in accord
|
273 |
+
with subsection 6b.
|
274 |
+
|
275 |
+
d) Convey the object code by offering access from a designated
|
276 |
+
place (gratis or for a charge), and offer equivalent access to the
|
277 |
+
Corresponding Source in the same way through the same place at no
|
278 |
+
further charge. You need not require recipients to copy the
|
279 |
+
Corresponding Source along with the object code. If the place to
|
280 |
+
copy the object code is a network server, the Corresponding Source
|
281 |
+
may be on a different server (operated by you or a third party)
|
282 |
+
that supports equivalent copying facilities, provided you maintain
|
283 |
+
clear directions next to the object code saying where to find the
|
284 |
+
Corresponding Source. Regardless of what server hosts the
|
285 |
+
Corresponding Source, you remain obligated to ensure that it is
|
286 |
+
available for as long as needed to satisfy these requirements.
|
287 |
+
|
288 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
289 |
+
you inform other peers where the object code and Corresponding
|
290 |
+
Source of the work are being offered to the general public at no
|
291 |
+
charge under subsection 6d.
|
292 |
+
|
293 |
+
A separable portion of the object code, whose source code is excluded
|
294 |
+
from the Corresponding Source as a System Library, need not be
|
295 |
+
included in conveying the object code work.
|
296 |
+
|
297 |
+
A "User Product" is either (1) a "consumer product", which means any
|
298 |
+
tangible personal property which is normally used for personal, family,
|
299 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
300 |
+
into a dwelling. In determining whether a product is a consumer product,
|
301 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
302 |
+
product received by a particular user, "normally used" refers to a
|
303 |
+
typical or common use of that class of product, regardless of the status
|
304 |
+
of the particular user or of the way in which the particular user
|
305 |
+
actually uses, or expects or is expected to use, the product. A product
|
306 |
+
is a consumer product regardless of whether the product has substantial
|
307 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
308 |
+
the only significant mode of use of the product.
|
309 |
+
|
310 |
+
"Installation Information" for a User Product means any methods,
|
311 |
+
procedures, authorization keys, or other information required to install
|
312 |
+
and execute modified versions of a covered work in that User Product from
|
313 |
+
a modified version of its Corresponding Source. The information must
|
314 |
+
suffice to ensure that the continued functioning of the modified object
|
315 |
+
code is in no case prevented or interfered with solely because
|
316 |
+
modification has been made.
|
317 |
+
|
318 |
+
If you convey an object code work under this section in, or with, or
|
319 |
+
specifically for use in, a User Product, and the conveying occurs as
|
320 |
+
part of a transaction in which the right of possession and use of the
|
321 |
+
User Product is transferred to the recipient in perpetuity or for a
|
322 |
+
fixed term (regardless of how the transaction is characterized), the
|
323 |
+
Corresponding Source conveyed under this section must be accompanied
|
324 |
+
by the Installation Information. But this requirement does not apply
|
325 |
+
if neither you nor any third party retains the ability to install
|
326 |
+
modified object code on the User Product (for example, the work has
|
327 |
+
been installed in ROM).
|
328 |
+
|
329 |
+
The requirement to provide Installation Information does not include a
|
330 |
+
requirement to continue to provide support service, warranty, or updates
|
331 |
+
for a work that has been modified or installed by the recipient, or for
|
332 |
+
the User Product in which it has been modified or installed. Access to a
|
333 |
+
network may be denied when the modification itself materially and
|
334 |
+
adversely affects the operation of the network or violates the rules and
|
335 |
+
protocols for communication across the network.
|
336 |
+
|
337 |
+
Corresponding Source conveyed, and Installation Information provided,
|
338 |
+
in accord with this section must be in a format that is publicly
|
339 |
+
documented (and with an implementation available to the public in
|
340 |
+
source code form), and must require no special password or key for
|
341 |
+
unpacking, reading or copying.
|
342 |
+
|
343 |
+
7. Additional Terms.
|
344 |
+
|
345 |
+
"Additional permissions" are terms that supplement the terms of this
|
346 |
+
License by making exceptions from one or more of its conditions.
|
347 |
+
Additional permissions that are applicable to the entire Program shall
|
348 |
+
be treated as though they were included in this License, to the extent
|
349 |
+
that they are valid under applicable law. If additional permissions
|
350 |
+
apply only to part of the Program, that part may be used separately
|
351 |
+
under those permissions, but the entire Program remains governed by
|
352 |
+
this License without regard to the additional permissions.
|
353 |
+
|
354 |
+
When you convey a copy of a covered work, you may at your option
|
355 |
+
remove any additional permissions from that copy, or from any part of
|
356 |
+
it. (Additional permissions may be written to require their own
|
357 |
+
removal in certain cases when you modify the work.) You may place
|
358 |
+
additional permissions on material, added by you to a covered work,
|
359 |
+
for which you have or can give appropriate copyright permission.
|
360 |
+
|
361 |
+
Notwithstanding any other provision of this License, for material you
|
362 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
363 |
+
that material) supplement the terms of this License with terms:
|
364 |
+
|
365 |
+
a) Disclaiming warranty or limiting liability differently from the
|
366 |
+
terms of sections 15 and 16 of this License; or
|
367 |
+
|
368 |
+
b) Requiring preservation of specified reasonable legal notices or
|
369 |
+
author attributions in that material or in the Appropriate Legal
|
370 |
+
Notices displayed by works containing it; or
|
371 |
+
|
372 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
373 |
+
requiring that modified versions of such material be marked in
|
374 |
+
reasonable ways as different from the original version; or
|
375 |
+
|
376 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
377 |
+
authors of the material; or
|
378 |
+
|
379 |
+
e) Declining to grant rights under trademark law for use of some
|
380 |
+
trade names, trademarks, or service marks; or
|
381 |
+
|
382 |
+
f) Requiring indemnification of licensors and authors of that
|
383 |
+
material by anyone who conveys the material (or modified versions of
|
384 |
+
it) with contractual assumptions of liability to the recipient, for
|
385 |
+
any liability that these contractual assumptions directly impose on
|
386 |
+
those licensors and authors.
|
387 |
+
|
388 |
+
All other non-permissive additional terms are considered "further
|
389 |
+
restrictions" within the meaning of section 10. If the Program as you
|
390 |
+
received it, or any part of it, contains a notice stating that it is
|
391 |
+
governed by this License along with a term that is a further
|
392 |
+
restriction, you may remove that term. If a license document contains
|
393 |
+
a further restriction but permits relicensing or conveying under this
|
394 |
+
License, you may add to a covered work material governed by the terms
|
395 |
+
of that license document, provided that the further restriction does
|
396 |
+
not survive such relicensing or conveying.
|
397 |
+
|
398 |
+
If you add terms to a covered work in accord with this section, you
|
399 |
+
must place, in the relevant source files, a statement of the
|
400 |
+
additional terms that apply to those files, or a notice indicating
|
401 |
+
where to find the applicable terms.
|
402 |
+
|
403 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
404 |
+
form of a separately written license, or stated as exceptions;
|
405 |
+
the above requirements apply either way.
|
406 |
+
|
407 |
+
8. Termination.
|
408 |
+
|
409 |
+
You may not propagate or modify a covered work except as expressly
|
410 |
+
provided under this License. Any attempt otherwise to propagate or
|
411 |
+
modify it is void, and will automatically terminate your rights under
|
412 |
+
this License (including any patent licenses granted under the third
|
413 |
+
paragraph of section 11).
|
414 |
+
|
415 |
+
However, if you cease all violation of this License, then your
|
416 |
+
license from a particular copyright holder is reinstated (a)
|
417 |
+
provisionally, unless and until the copyright holder explicitly and
|
418 |
+
finally terminates your license, and (b) permanently, if the copyright
|
419 |
+
holder fails to notify you of the violation by some reasonable means
|
420 |
+
prior to 60 days after the cessation.
|
421 |
+
|
422 |
+
Moreover, your license from a particular copyright holder is
|
423 |
+
reinstated permanently if the copyright holder notifies you of the
|
424 |
+
violation by some reasonable means, this is the first time you have
|
425 |
+
received notice of violation of this License (for any work) from that
|
426 |
+
copyright holder, and you cure the violation prior to 30 days after
|
427 |
+
your receipt of the notice.
|
428 |
+
|
429 |
+
Termination of your rights under this section does not terminate the
|
430 |
+
licenses of parties who have received copies or rights from you under
|
431 |
+
this License. If your rights have been terminated and not permanently
|
432 |
+
reinstated, you do not qualify to receive new licenses for the same
|
433 |
+
material under section 10.
|
434 |
+
|
435 |
+
9. Acceptance Not Required for Having Copies.
|
436 |
+
|
437 |
+
You are not required to accept this License in order to receive or
|
438 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
439 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
440 |
+
to receive a copy likewise does not require acceptance. However,
|
441 |
+
nothing other than this License grants you permission to propagate or
|
442 |
+
modify any covered work. These actions infringe copyright if you do
|
443 |
+
not accept this License. Therefore, by modifying or propagating a
|
444 |
+
covered work, you indicate your acceptance of this License to do so.
|
445 |
+
|
446 |
+
10. Automatic Licensing of Downstream Recipients.
|
447 |
+
|
448 |
+
Each time you convey a covered work, the recipient automatically
|
449 |
+
receives a license from the original licensors, to run, modify and
|
450 |
+
propagate that work, subject to this License. You are not responsible
|
451 |
+
for enforcing compliance by third parties with this License.
|
452 |
+
|
453 |
+
An "entity transaction" is a transaction transferring control of an
|
454 |
+
organization, or substantially all assets of one, or subdividing an
|
455 |
+
organization, or merging organizations. If propagation of a covered
|
456 |
+
work results from an entity transaction, each party to that
|
457 |
+
transaction who receives a copy of the work also receives whatever
|
458 |
+
licenses to the work the party's predecessor in interest had or could
|
459 |
+
give under the previous paragraph, plus a right to possession of the
|
460 |
+
Corresponding Source of the work from the predecessor in interest, if
|
461 |
+
the predecessor has it or can get it with reasonable efforts.
|
462 |
+
|
463 |
+
You may not impose any further restrictions on the exercise of the
|
464 |
+
rights granted or affirmed under this License. For example, you may
|
465 |
+
not impose a license fee, royalty, or other charge for exercise of
|
466 |
+
rights granted under this License, and you may not initiate litigation
|
467 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
468 |
+
any patent claim is infringed by making, using, selling, offering for
|
469 |
+
sale, or importing the Program or any portion of it.
|
470 |
+
|
471 |
+
11. Patents.
|
472 |
+
|
473 |
+
A "contributor" is a copyright holder who authorizes use under this
|
474 |
+
License of the Program or a work on which the Program is based. The
|
475 |
+
work thus licensed is called the contributor's "contributor version".
|
476 |
+
|
477 |
+
A contributor's "essential patent claims" are all patent claims
|
478 |
+
owned or controlled by the contributor, whether already acquired or
|
479 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
480 |
+
by this License, of making, using, or selling its contributor version,
|
481 |
+
but do not include claims that would be infringed only as a
|
482 |
+
consequence of further modification of the contributor version. For
|
483 |
+
purposes of this definition, "control" includes the right to grant
|
484 |
+
patent sublicenses in a manner consistent with the requirements of
|
485 |
+
this License.
|
486 |
+
|
487 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
488 |
+
patent license under the contributor's essential patent claims, to
|
489 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
490 |
+
propagate the contents of its contributor version.
|
491 |
+
|
492 |
+
In the following three paragraphs, a "patent license" is any express
|
493 |
+
agreement or commitment, however denominated, not to enforce a patent
|
494 |
+
(such as an express permission to practice a patent or covenant not to
|
495 |
+
sue for patent infringement). To "grant" such a patent license to a
|
496 |
+
party means to make such an agreement or commitment not to enforce a
|
497 |
+
patent against the party.
|
498 |
+
|
499 |
+
If you convey a covered work, knowingly relying on a patent license,
|
500 |
+
and the Corresponding Source of the work is not available for anyone
|
501 |
+
to copy, free of charge and under the terms of this License, through a
|
502 |
+
publicly available network server or other readily accessible means,
|
503 |
+
then you must either (1) cause the Corresponding Source to be so
|
504 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
505 |
+
patent license for this particular work, or (3) arrange, in a manner
|
506 |
+
consistent with the requirements of this License, to extend the patent
|
507 |
+
license to downstream recipients. "Knowingly relying" means you have
|
508 |
+
actual knowledge that, but for the patent license, your conveying the
|
509 |
+
covered work in a country, or your recipient's use of the covered work
|
510 |
+
in a country, would infringe one or more identifiable patents in that
|
511 |
+
country that you have reason to believe are valid.
|
512 |
+
|
513 |
+
If, pursuant to or in connection with a single transaction or
|
514 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
515 |
+
covered work, and grant a patent license to some of the parties
|
516 |
+
receiving the covered work authorizing them to use, propagate, modify
|
517 |
+
or convey a specific copy of the covered work, then the patent license
|
518 |
+
you grant is automatically extended to all recipients of the covered
|
519 |
+
work and works based on it.
|
520 |
+
|
521 |
+
A patent license is "discriminatory" if it does not include within
|
522 |
+
the scope of its coverage, prohibits the exercise of, or is
|
523 |
+
conditioned on the non-exercise of one or more of the rights that are
|
524 |
+
specifically granted under this License. You may not convey a covered
|
525 |
+
work if you are a party to an arrangement with a third party that is
|
526 |
+
in the business of distributing software, under which you make payment
|
527 |
+
to the third party based on the extent of your activity of conveying
|
528 |
+
the work, and under which the third party grants, to any of the
|
529 |
+
parties who would receive the covered work from you, a discriminatory
|
530 |
+
patent license (a) in connection with copies of the covered work
|
531 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
532 |
+
for and in connection with specific products or compilations that
|
533 |
+
contain the covered work, unless you entered into that arrangement,
|
534 |
+
or that patent license was granted, prior to 28 March 2007.
|
535 |
+
|
536 |
+
Nothing in this License shall be construed as excluding or limiting
|
537 |
+
any implied license or other defenses to infringement that may
|
538 |
+
otherwise be available to you under applicable patent law.
|
539 |
+
|
540 |
+
12. No Surrender of Others' Freedom.
|
541 |
+
|
542 |
+
If conditions are imposed on you (whether by court order, agreement or
|
543 |
+
otherwise) that contradict the conditions of this License, they do not
|
544 |
+
excuse you from the conditions of this License. If you cannot convey a
|
545 |
+
covered work so as to satisfy simultaneously your obligations under this
|
546 |
+
License and any other pertinent obligations, then as a consequence you may
|
547 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
548 |
+
to collect a royalty for further conveying from those to whom you convey
|
549 |
+
the Program, the only way you could satisfy both those terms and this
|
550 |
+
License would be to refrain entirely from conveying the Program.
|
551 |
+
|
552 |
+
13. Use with the GNU Affero General Public License.
|
553 |
+
|
554 |
+
Notwithstanding any other provision of this License, you have
|
555 |
+
permission to link or combine any covered work with a work licensed
|
556 |
+
under version 3 of the GNU Affero General Public License into a single
|
557 |
+
combined work, and to convey the resulting work. The terms of this
|
558 |
+
License will continue to apply to the part which is the covered work,
|
559 |
+
but the special requirements of the GNU Affero General Public License,
|
560 |
+
section 13, concerning interaction through a network will apply to the
|
561 |
+
combination as such.
|
562 |
+
|
563 |
+
14. Revised Versions of this License.
|
564 |
+
|
565 |
+
The Free Software Foundation may publish revised and/or new versions of
|
566 |
+
the GNU General Public License from time to time. Such new versions will
|
567 |
+
be similar in spirit to the present version, but may differ in detail to
|
568 |
+
address new problems or concerns.
|
569 |
+
|
570 |
+
Each version is given a distinguishing version number. If the
|
571 |
+
Program specifies that a certain numbered version of the GNU General
|
572 |
+
Public License "or any later version" applies to it, you have the
|
573 |
+
option of following the terms and conditions either of that numbered
|
574 |
+
version or of any later version published by the Free Software
|
575 |
+
Foundation. If the Program does not specify a version number of the
|
576 |
+
GNU General Public License, you may choose any version ever published
|
577 |
+
by the Free Software Foundation.
|
578 |
+
|
579 |
+
If the Program specifies that a proxy can decide which future
|
580 |
+
versions of the GNU General Public License can be used, that proxy's
|
581 |
+
public statement of acceptance of a version permanently authorizes you
|
582 |
+
to choose that version for the Program.
|
583 |
+
|
584 |
+
Later license versions may give you additional or different
|
585 |
+
permissions. However, no additional obligations are imposed on any
|
586 |
+
author or copyright holder as a result of your choosing to follow a
|
587 |
+
later version.
|
588 |
+
|
589 |
+
15. Disclaimer of Warranty.
|
590 |
+
|
591 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
592 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
593 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
594 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
595 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
596 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
597 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
598 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
599 |
+
|
600 |
+
16. Limitation of Liability.
|
601 |
+
|
602 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
603 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
604 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
605 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
606 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
607 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
608 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
609 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
610 |
+
SUCH DAMAGES.
|
611 |
+
|
612 |
+
17. Interpretation of Sections 15 and 16.
|
613 |
+
|
614 |
+
If the disclaimer of warranty and limitation of liability provided
|
615 |
+
above cannot be given local legal effect according to their terms,
|
616 |
+
reviewing courts shall apply local law that most closely approximates
|
617 |
+
an absolute waiver of all civil liability in connection with the
|
618 |
+
Program, unless a warranty or assumption of liability accompanies a
|
619 |
+
copy of the Program in return for a fee.
|
620 |
+
|
621 |
+
END OF TERMS AND CONDITIONS
|
622 |
+
|
623 |
+
How to Apply These Terms to Your New Programs
|
624 |
+
|
625 |
+
If you develop a new program, and you want it to be of the greatest
|
626 |
+
possible use to the public, the best way to achieve this is to make it
|
627 |
+
free software which everyone can redistribute and change under these terms.
|
628 |
+
|
629 |
+
To do so, attach the following notices to the program. It is safest
|
630 |
+
to attach them to the start of each source file to most effectively
|
631 |
+
state the exclusion of warranty; and each file should have at least
|
632 |
+
the "copyright" line and a pointer to where the full notice is found.
|
633 |
+
|
634 |
+
<one line to give the program's name and a brief idea of what it does.>
|
635 |
+
Copyright (C) <year> <name of author>
|
636 |
+
|
637 |
+
This program is free software: you can redistribute it and/or modify
|
638 |
+
it under the terms of the GNU General Public License as published by
|
639 |
+
the Free Software Foundation, either version 3 of the License, or
|
640 |
+
(at your option) any later version.
|
641 |
+
|
642 |
+
This program is distributed in the hope that it will be useful,
|
643 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
644 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
645 |
+
GNU General Public License for more details.
|
646 |
+
|
647 |
+
You should have received a copy of the GNU General Public License
|
648 |
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
649 |
+
|
650 |
+
Also add information on how to contact you by electronic and paper mail.
|
651 |
+
|
652 |
+
If the program does terminal interaction, make it output a short
|
653 |
+
notice like this when it starts in an interactive mode:
|
654 |
+
|
655 |
+
<program> Copyright (C) <year> <name of author>
|
656 |
+
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
657 |
+
This is free software, and you are welcome to redistribute it
|
658 |
+
under certain conditions; type `show c' for details.
|
659 |
+
|
660 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
661 |
+
parts of the General Public License. Of course, your program's commands
|
662 |
+
might be different; for a GUI interface, you would use an "about box".
|
663 |
+
|
664 |
+
You should also get your employer (if you work as a programmer) or school,
|
665 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
666 |
+
For more information on this, and how to apply and follow the GNU GPL, see
|
667 |
+
<http://www.gnu.org/licenses/>.
|
668 |
+
|
669 |
+
The GNU General Public License does not permit incorporating your program
|
670 |
+
into proprietary programs. If your program is a subroutine library, you
|
671 |
+
may consider it more useful to permit linking proprietary applications with
|
672 |
+
the library. If this is what you want to do, use the GNU Lesser General
|
673 |
+
Public License instead of this License. But first, please read
|
674 |
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.wpbackitup.com
|
|
4 |
Tags: backup, back up, backups, backup wordpress, backup database, backup plugin, backup and restore, database, database backup, database restore, db, db backup, db restore, download database, full backup, mysql backup, restore, restore database,restore wordpress, restore wordpress backup,restoring wordpress, website backup, wordpress backup, wordpress restore, plugin, backup buddy
|
5 |
Requires at least: 3.8.0
|
6 |
Tested up to: 4.0
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -12,10 +12,10 @@ Simple & complete backups of your WordPress website with this easy to use plugin
|
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
= The Simplest Way to Backup Your
|
16 |
-
Backing up your
|
17 |
|
18 |
-
WP BackItUp creates a backup archive (zip) of your entire website (database, plugins, themes, uploads, content) with a single click. Backup archives can be quickly and easily downloaded so that they can be stored securely and separately from your hosted
|
19 |
|
20 |
Here are just a few of our incredible features.
|
21 |
|
@@ -25,31 +25,31 @@ Here are just a few of our incredible features.
|
|
25 |
* **Easy to setup** because there is no setup required
|
26 |
* **Simple** & easy to understand interface
|
27 |
* **Fast** backups
|
|
|
28 |
* Support if you run into any trouble
|
29 |
-
*
|
30 |
* Works in low memory & shared hosting environments
|
31 |
-
* Works on all
|
32 |
* **Complete backup**, which includes database, plugins, themes, uploads, everything
|
33 |
* Compresses(zip) your backups to **save** you **space**
|
34 |
* Stores backups to a folder on your server
|
35 |
* Download backup archives right from your WordPress dashboard
|
36 |
* Cleans up all work files to save space
|
37 |
-
* Simple **restore** right from your
|
38 |
* Debug mode that provides full logging of the backup
|
39 |
* Tested and supported on all current PHP versions (5.2, 5.3, 5.4, 5.5)
|
40 |
* Premium version and priority support available
|
41 |
|
42 |
-
|
43 |
= Don't Risk Losing Your Website =
|
44 |
-
Does the thought of losing your website keep you up at night? All the time, effort and money you've invested, gone in an instant.
|
45 |
|
46 |
-
In 2012 we created the WP BackItUp plugin and made it freely available to the
|
47 |
|
48 |
= Automatically Restore/Clone/Migrate your Website? =
|
49 |
-
Need to restore, clone or migrate your website to another host, we make that easy too. The premium version of WP BackItUp will allow you to restore your site from backup with a single click. All you need to do is select the backup you want to restore and click restore, right from your
|
50 |
|
51 |
= Free Support =
|
52 |
-
We offer free support via the
|
53 |
|
54 |
= Professional Support =
|
55 |
WP BackItUp is supported by a team of professional developers. If you are using WP BackItUp to secure your business website then professional support is available to our premium customers. Please see [www.wpbackitup.com](http://www.wpbackitup.com/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=description&utm_term=professional+support+a) for details.
|
@@ -117,7 +117,7 @@ Please see [www.wpbackitup.com](https://www.wpbackitup.com/pricing-purchase/?utm
|
|
117 |
Yes, the database export contains everything related to the database.
|
118 |
|
119 |
= Can I make a basic WordPress site, with all my desired plugins and settings, make a few pages, setup permalinks, remove all the default junk and then use it as a template for all my new WordPress sites? =
|
120 |
-
Yes. WP BackItUp is used by many professional designers & developers just this way. Once you have your
|
121 |
|
122 |
= Does WP BackItUp need to be installed? =
|
123 |
Yes, WP BackItUp is just like any other WordPress plugin. You must install it on any site that you wish to perform a backup or restore.
|
@@ -129,7 +129,7 @@ WP Backitup creates a backup of **everything**. This includes plugins, plugin s
|
|
129 |
WP BackItUp can be used to backup very large sites. We`ve tested up to 5 themes, 20 plugins and more than 100 posts/pages without any issues.
|
130 |
|
131 |
= Do you do regularly update this product to match with WP version updates? =
|
132 |
-
Yes. We continually improve WP BackItUp and test it with every new version ow
|
133 |
|
134 |
= I am not running the most recent version of WP BackItUp. Should I upgrade? =
|
135 |
Yes, please make sure you are always running the current version of WP BackItUp.
|
@@ -141,13 +141,27 @@ Our online documentation and full list of FAQs can be found at [www.wpbackitup.c
|
|
141 |
|
142 |
|
143 |
== Screenshots ==
|
144 |
-
1. Once activated, the plugin loads a new menu into your
|
145 |
2. Simply click 'Backup' to generate a backup of your site. The plugin will update you on its progress.
|
146 |
-
3. When the backup
|
|
|
|
|
|
|
|
|
|
|
147 |
|
148 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
= 1.8 =
|
150 |
-
* Updates:
|
151 |
* Feature: Add support for large database restore.
|
152 |
* Feature: Add database checkpoint recovery for database restore failures
|
153 |
* Feature: Add restore logging on all restores
|
@@ -192,11 +206,11 @@ Our online documentation and full list of FAQs can be found at [www.wpbackitup.c
|
|
192 |
* Updates to license activation
|
193 |
|
194 |
= 1.6.7 =
|
195 |
-
*
|
196 |
* Unicode fix to support utf8 content
|
197 |
|
198 |
= 1.6.6 =
|
199 |
-
*
|
200 |
|
201 |
= 1.6.5 =
|
202 |
* Correct issue with subversion tags
|
4 |
Tags: backup, back up, backups, backup wordpress, backup database, backup plugin, backup and restore, database, database backup, database restore, db, db backup, db restore, download database, full backup, mysql backup, restore, restore database,restore wordpress, restore wordpress backup,restoring wordpress, website backup, wordpress backup, wordpress restore, plugin, backup buddy
|
5 |
Requires at least: 3.8.0
|
6 |
Tested up to: 4.0
|
7 |
+
Stable tag: 1.9
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
= The Simplest Way to Backup Your WordPress Site =
|
16 |
+
Backing up your WordPress website is easy with WP BackItUp. Simply install WP BackItUp and within minutes you will have a complete backup of your entire site. No complex configuration to deal with. No advanced knowledge of WordPress required. No FTP, cPanel, MySQL or PHPMyAdmin involved. If you can press a button then you can backup your WordPress site with WP BackItUp.
|
17 |
|
18 |
+
WP BackItUp creates a backup archive (zip) of your entire website (database, plugins, themes, uploads, content) with a single click. Backup archives can be quickly and easily downloaded so that they can be stored securely and separately from your hosted WordPress site.
|
19 |
|
20 |
Here are just a few of our incredible features.
|
21 |
|
25 |
* **Easy to setup** because there is no setup required
|
26 |
* **Simple** & easy to understand interface
|
27 |
* **Fast** backups
|
28 |
+
* Automated backups allow you to **schedule** your backups to run whenever you need them to (premium only)
|
29 |
* Support if you run into any trouble
|
30 |
+
* Backup status notifications by email
|
31 |
* Works in low memory & shared hosting environments
|
32 |
+
* Works on all WordPress platforms (Linux, Windows and even Azure)
|
33 |
* **Complete backup**, which includes database, plugins, themes, uploads, everything
|
34 |
* Compresses(zip) your backups to **save** you **space**
|
35 |
* Stores backups to a folder on your server
|
36 |
* Download backup archives right from your WordPress dashboard
|
37 |
* Cleans up all work files to save space
|
38 |
+
* Simple **restore** right from your WordPress dashboard(premium only)
|
39 |
* Debug mode that provides full logging of the backup
|
40 |
* Tested and supported on all current PHP versions (5.2, 5.3, 5.4, 5.5)
|
41 |
* Premium version and priority support available
|
42 |
|
|
|
43 |
= Don't Risk Losing Your Website =
|
44 |
+
Does the thought of losing your website keep you up at night? All the time, effort and money you've invested, gone in an instant. WordPress is an incredible product but there are many things that can cause you to lose your website. You could get hacked, your hosting company could go out of business, you could install a bad plugin or theme, the list is endless and without good backups, you could lose everything. If this isn't one of the things keeping you up at night, then it really should be. It was keeping us up at night so we decided to do something about it.
|
45 |
|
46 |
+
In 2012 we created the WP BackItUp plugin and made it freely available to the WordPress community so that we can all sleep better at night knowing our content is safe. Since 2012 we have added many incredible features and even created a premium version, but our fundamental goal is still the same. We want to make WordPress backups as **simple**, **effective** and **easy** as possible because we don’t want anything to stop you from backing up your WordPress site regularly. We offer this plugin to you for free so that you will **BackItUp** and sleep better at night.
|
47 |
|
48 |
= Automatically Restore/Clone/Migrate your Website? =
|
49 |
+
Need to restore, clone or migrate your website to another host, we make that easy too. The premium version of WP BackItUp will allow you to restore your site from backup with a single click. All you need to do is select the backup you want to restore and click restore, right from your WordPress dashboard. That’s it, your site is back up and running in minutes.
|
50 |
|
51 |
= Free Support =
|
52 |
+
We offer free support via the WordPress [support forum](http://wordpress.org/support/plugin/wp-backitup) for this plugin but before posting a question please make sure you are running the current version of WP BackItUp. We make frequent releases to add features and fix issues so please make sure you are up to date before posting an issue. We also ask that you review the [online documentation](http://www.wpbackitup.com/documentation/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=description&utm_term=free+support+doc) and [FAQ's](https://www.wpbackitup.com/documentation/faqs/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=description&utm_term=free+support+faq) sections of [www.wpbackitup.com](http://www.wpbackitup.com/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=description&utm_term=free+support+a) before posting your questions.
|
53 |
|
54 |
= Professional Support =
|
55 |
WP BackItUp is supported by a team of professional developers. If you are using WP BackItUp to secure your business website then professional support is available to our premium customers. Please see [www.wpbackitup.com](http://www.wpbackitup.com/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=description&utm_term=professional+support+a) for details.
|
117 |
Yes, the database export contains everything related to the database.
|
118 |
|
119 |
= Can I make a basic WordPress site, with all my desired plugins and settings, make a few pages, setup permalinks, remove all the default junk and then use it as a template for all my new WordPress sites? =
|
120 |
+
Yes. WP BackItUp is used by many professional designers & developers just this way. Once you have your WordPress site setup the way you want, just BackItUp and use that backup archive as a starting point for all your new sites.
|
121 |
|
122 |
= Does WP BackItUp need to be installed? =
|
123 |
Yes, WP BackItUp is just like any other WordPress plugin. You must install it on any site that you wish to perform a backup or restore.
|
129 |
WP BackItUp can be used to backup very large sites. We`ve tested up to 5 themes, 20 plugins and more than 100 posts/pages without any issues.
|
130 |
|
131 |
= Do you do regularly update this product to match with WP version updates? =
|
132 |
+
Yes. We continually improve WP BackItUp and test it with every new version ow WordPress.
|
133 |
|
134 |
= I am not running the most recent version of WP BackItUp. Should I upgrade? =
|
135 |
Yes, please make sure you are always running the current version of WP BackItUp.
|
141 |
|
142 |
|
143 |
== Screenshots ==
|
144 |
+
1. Once activated, the plugin loads a new menu into your WordPress dashboard.
|
145 |
2. Simply click 'Backup' to generate a backup of your site. The plugin will update you on its progress.
|
146 |
+
3. When the backup is complete it will appear in the available backups section where you can download it to store somewhere safe .
|
147 |
+
4. Automated backups may be scheduled for any day of the week. (Premium Only)
|
148 |
+
5. Restore your site from any backup with the one click restore feature. (Premium Only)
|
149 |
+
6. Backups may be uploaded via the upload option.
|
150 |
+
7. Email notifications, backup retention and logging settings are available in settings.
|
151 |
+
|
152 |
|
153 |
== Changelog ==
|
154 |
+
= 1.9 =
|
155 |
+
* New Features: Scheduled backups are now available.
|
156 |
+
* New Feature: Allow only a single backup to be run at a time.
|
157 |
+
* New feature: Automated cleanup feature will perform work file and log cleanup once per day.
|
158 |
+
* Update: User experience improvements to backup.
|
159 |
+
* Update: Logging enhancements.
|
160 |
+
* Fix: Add support for windows MySql database exports. Windows backups always worked but did not take advantage of MySql export tools like other platforms.
|
161 |
+
|
162 |
+
|
163 |
= 1.8 =
|
164 |
+
* Updates: WordPress 4.0 support
|
165 |
* Feature: Add support for large database restore.
|
166 |
* Feature: Add database checkpoint recovery for database restore failures
|
167 |
* Feature: Add restore logging on all restores
|
206 |
* Updates to license activation
|
207 |
|
208 |
= 1.6.7 =
|
209 |
+
* WordPress 3.9.1 support
|
210 |
* Unicode fix to support utf8 content
|
211 |
|
212 |
= 1.6.6 =
|
213 |
+
* WordPress 3.9 support
|
214 |
|
215 |
= 1.6.5 =
|
216 |
* Correct issue with subversion tags
|
views/backup.php
CHANGED
@@ -1,54 +1,73 @@
|
|
1 |
<?php if (!defined ('ABSPATH')) die('No direct access allowed');
|
2 |
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
|
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
$license_type_description = ucfirst($license_type_description);
|
18 |
-
|
19 |
-
|
20 |
-
$license_status = $this->license_status();
|
21 |
-
$license_status_message = $this->license_status_message();
|
22 |
|
23 |
-
|
24 |
-
|
25 |
|
26 |
-
|
27 |
-
|
28 |
|
29 |
-
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
38 |
}
|
39 |
-
}else{
|
40 |
-
$backup_folder_exists=true;
|
41 |
-
}
|
42 |
|
43 |
-
?>
|
44 |
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
-
//
|
48 |
if (!$backup_folder_exists) {
|
49 |
-
echo
|
|
|
|
|
|
|
50 |
echo($this->get_anchor_with_utm('support','support','backup+error','no+backup+folder'));
|
51 |
-
echo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
}
|
53 |
?>
|
54 |
|
@@ -56,11 +75,13 @@ if (!$backup_folder_exists) {
|
|
56 |
<div class="wrap">
|
57 |
<h2><?php echo $page_title; ?></h2>
|
58 |
<div id="content">
|
|
|
|
|
59 |
<div class="widget">
|
60 |
<h3><i class="fa fa-cogs"></i> <?php _e('Backup', $namespace); ?></h3>
|
61 |
<p><b>Click the backup button to create a zipped backup file of this site's database, plugins, themes and settings.</b></p>
|
62 |
-
<p>Once your backup file has been created it will appear in the available backups section below. This file
|
63 |
-
<p>
|
64 |
<p>
|
65 |
<?php if ($backup_folder_exists) :?>
|
66 |
<input type="submit" id="backup-button" class="backup-button button-primary" value="<?php _e("Backup", $namespace) ?>"/><img class="backup-icon status-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></p>
|
@@ -68,10 +89,43 @@ if (!$backup_folder_exists) {
|
|
68 |
<?php
|
69 |
//Display a note for lite customers
|
70 |
if (!$license_active)
|
71 |
-
echo '<p> * WP BackItUp
|
72 |
?>
|
73 |
</div>
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
<!--Available Backups section-->
|
76 |
<div class="widget">
|
77 |
<h3><i class="fa fa-cloud-download"></i> <?php _e('Available Backups', $namespace); ?></h3>
|
@@ -87,45 +141,65 @@ if (!$backup_folder_exists) {
|
|
87 |
<?php
|
88 |
|
89 |
//Get Zip File List
|
90 |
-
$
|
91 |
-
$
|
92 |
-
|
93 |
-
|
|
|
|
|
|
|
|
|
94 |
{
|
95 |
//Sort by Date Time
|
96 |
-
usort($
|
97 |
|
98 |
$i = 0;
|
99 |
-
foreach ($
|
100 |
{
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
$class = $i % 2 == 0 ? 'class="alternate"' : '';
|
116 |
?>
|
117 |
|
118 |
<tr <?php echo $class ?> id="row<?php echo $i; ?>">
|
119 |
-
<td><?php echo $
|
120 |
-
<td><?php echo $
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
<td><a class='viewloglink' href="<?php echo basename($log_filename, ".log") ?>">View Log</a></td>
|
124 |
<?php else: ?>
|
125 |
<td> </td>
|
126 |
<?php endif; ?>
|
127 |
-
<td><a href="#" title="<?php echo $zip_filename; ?>" class="deleteRow" id="deleteRow<?php echo $i; ?>">Delete</a></td>
|
128 |
|
|
|
129 |
</tr>
|
130 |
|
131 |
<?php
|
@@ -142,7 +216,7 @@ if (!$backup_folder_exists) {
|
|
142 |
<?php
|
143 |
//Display restore note for lite customers
|
144 |
if (!$license_active)
|
145 |
-
echo '<p>* The automated restore feature is only available to
|
146 |
?>
|
147 |
</div>
|
148 |
|
@@ -173,11 +247,11 @@ if (!$backup_folder_exists) {
|
|
173 |
<span class="error104"><div class='isa_error'><?php _e('Error 104: Unable to backup your database. Please try again', $namespace); ?>.</div></span>
|
174 |
<span class="error105"><div class='isa_error'><?php _e('Error 105: Unable to create site information file. Please try again', $namespace); ?>.</div></span>
|
175 |
<span class="error106"><div class='isa_warning'><?php _e('Warning 106: Unable to cleanup your backup directory', $namespace); ?>.</div></span>
|
176 |
-
|
177 |
<span class="error114"><div class='isa_error'><?php _e('Error 114: Your database was accessible but an export could not be created. Please contact support by clicking the get support link on the right. Please let us know who your host is when you submit the request', $namespace); ?>.</div></span>
|
178 |
</div>
|
179 |
|
180 |
-
<!--
|
181 |
<ul class="backup-unexpected-error">
|
182 |
<span class='error999'><div class='isa_error'><?php _e('An unexpected error has occurred. ', $namespace); ?></div></span>
|
183 |
</ul>
|
1 |
<?php if (!defined ('ABSPATH')) die('No direct access allowed');
|
2 |
|
3 |
+
$page_title = $this->friendly_name . ' Dashboard';
|
4 |
+
$namespace = $this->namespace;
|
5 |
|
6 |
+
//Path Variables
|
7 |
+
$backup_folder_root = WPBACKITUP__BACKUP_PATH;
|
8 |
+
$logs_folder_root = WPBACKITUP__PLUGIN_PATH .'/logs';
|
9 |
|
10 |
+
//Get license info
|
11 |
+
$version = $this->version;
|
12 |
+
$license_key = $this->license_key();
|
13 |
+
$license_active = $this->license_active();
|
14 |
|
15 |
+
$license_type = $this->license_type();
|
16 |
+
$license_type_description = $this->license_type_description();
|
17 |
+
if (!empty($license_type_description)){
|
18 |
$license_type_description = ucfirst($license_type_description);
|
19 |
+
}
|
|
|
|
|
|
|
20 |
|
21 |
+
$license_status = $this->license_status();
|
22 |
+
$license_status_message = $this->license_status_message();
|
23 |
|
24 |
+
$license_Expires = $this->license_expires();
|
25 |
+
$formatted_expired_date = date('F j, Y',strtotime($license_Expires));
|
26 |
|
27 |
+
// get retention number set
|
28 |
+
$retain_archives = $this->backup_retained_number();
|
29 |
|
30 |
+
$lite_registration_email = $this->lite_registration_email();
|
31 |
+
$is_lite_registered = $this->is_lite_registered();
|
32 |
+
|
33 |
+
$backup_schedule=$this->backup_schedule();
|
34 |
+
|
35 |
+
$schedule_style_disabled='';
|
36 |
+
if (!$license_active || 'expired'== $license_status){
|
37 |
+
$schedule_style_disabled='disabled';
|
38 |
}
|
|
|
|
|
|
|
39 |
|
|
|
40 |
|
41 |
+
//Make sure backup folder exists
|
42 |
+
$backup_dir = WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__BACKUP_FOLDER;
|
43 |
+
$backup_folder_exists=false;
|
44 |
+
if( !is_dir($backup_dir) ) {
|
45 |
+
if (@mkdir($backup_dir, 0755)){
|
46 |
+
$backup_folder_exists=true;
|
47 |
+
}
|
48 |
+
}else{
|
49 |
+
$backup_folder_exists=true;
|
50 |
+
}
|
51 |
+
?>
|
52 |
|
53 |
+
<?php //Add Notification to UI
|
54 |
if (!$backup_folder_exists) {
|
55 |
+
echo(
|
56 |
+
'<div style="overflow: hidden;" class="error" id="wp-backitup-notification-parent" class="updated">
|
57 |
+
<div style="float:left;" id="wp-backitup-notification-message" ><p><strong>Error:</strong> Backup folder does not exist. Please contact ');
|
58 |
+
|
59 |
echo($this->get_anchor_with_utm('support','support','backup+error','no+backup+folder'));
|
60 |
+
echo(' for assistance.</p></div>');
|
61 |
+
|
62 |
+
echo('<div style="float:right;"><p><a id="wp-backitup-notification-close"><i style="float:right" class="fa fa-close"> Close</i></a></p></div>
|
63 |
+
</div>');
|
64 |
+
} else{
|
65 |
+
echo(
|
66 |
+
'<div style="overflow: hidden; display:none" id="wp-backitup-notification-parent" class="updated">
|
67 |
+
<div style="float:left;" id="wp-backitup-notification-message" ></div>
|
68 |
+
<div style="float:right;"><p><a id="wp-backitup-notification-close"><i style="float:right" class="fa fa-close"> Close</i></a></p></div>
|
69 |
+
</div>'
|
70 |
+
);
|
71 |
}
|
72 |
?>
|
73 |
|
75 |
<div class="wrap">
|
76 |
<h2><?php echo $page_title; ?></h2>
|
77 |
<div id="content">
|
78 |
+
|
79 |
+
<!--Manual Backups-->
|
80 |
<div class="widget">
|
81 |
<h3><i class="fa fa-cogs"></i> <?php _e('Backup', $namespace); ?></h3>
|
82 |
<p><b>Click the backup button to create a zipped backup file of this site's database, plugins, themes and settings.</b></p>
|
83 |
+
<p>Once your backup file has been created it will appear in the available backups section below. This file may remain on your hosting providers server but we recommend that you download and save it somewhere safe.</p>
|
84 |
+
<p> WP BackItUp premium customers can use these backup files to perform an automated restore of their site.</p>
|
85 |
<p>
|
86 |
<?php if ($backup_folder_exists) :?>
|
87 |
<input type="submit" id="backup-button" class="backup-button button-primary" value="<?php _e("Backup", $namespace) ?>"/><img class="backup-icon status-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></p>
|
89 |
<?php
|
90 |
//Display a note for lite customers
|
91 |
if (!$license_active)
|
92 |
+
echo '<p> * WP BackItUp lite customers may use these backup files to manually restore their site. Please visit ' .$this->get_anchor_with_utm('www.wpbackitup.com','documentation/restore/how-to-manually-restore-your-wordpress-database','backup','manual+restore') .' for manual restore instructions.</p>';
|
93 |
?>
|
94 |
</div>
|
95 |
|
96 |
+
|
97 |
+
<!--Scheduled Backups-->
|
98 |
+
<div class="widget">
|
99 |
+
<h3><i class="fa fa-clock-o"></i> <?php _e('Backup Schedule', $namespace); ?>
|
100 |
+
<i id="scheduled-backups-accordian" style="float:right" class="fa fa-angle-double-down"></i></h3>
|
101 |
+
<p><b>Select the days of the week you would like your backup to run.</b></p>
|
102 |
+
<div id="scheduled-backups" style="display: none;">
|
103 |
+
<p>Backup your site once per week or every day, it's up to you. If you have email notifications turned on we'll even send you an email when it's done.
|
104 |
+
Once your backup file has been created it will appear in the available backups section below. This file may remain on your hosting providers server but we recommend that you download and save it somewhere safe.</p>
|
105 |
+
<p>
|
106 |
+
<b>Please make sure to schedule your backup for at least once per week.</b>
|
107 |
+
<form action="admin-post.php" method="post" id="<?php echo $namespace; ?>-save_schedule_form">
|
108 |
+
<?php wp_nonce_field($namespace . '-update-schedule',$namespace . '_nonce-update-schedule'); ?>
|
109 |
+
|
110 |
+
<input <?php _e($schedule_style_disabled); ?> type="checkbox" name="dow" <?php (false!==strpos($backup_schedule,'1'))? _e('checked') :_e(''); ?> value="1">Monday<br>
|
111 |
+
<input <?php _e($schedule_style_disabled); ?> type="checkbox" name="dow" <?php (false!==strpos($backup_schedule,'2'))? _e('checked') :_e(''); ?> value="2">Tuesday<br>
|
112 |
+
<input <?php _e($schedule_style_disabled); ?> type="checkbox" name="dow" <?php (false!==strpos($backup_schedule,'3'))? _e('checked') :_e(''); ?> value="3">Wednesday<br>
|
113 |
+
<input <?php _e($schedule_style_disabled); ?> type="checkbox" name="dow" <?php (false!==strpos($backup_schedule,'4'))? _e('checked') :_e(''); ?> value="4">Thursday<br>
|
114 |
+
<input <?php _e($schedule_style_disabled); ?> type="checkbox" name="dow" <?php (false!==strpos($backup_schedule,'5'))? _e('checked') :_e(''); ?> value="5">Friday<br>
|
115 |
+
<input <?php _e($schedule_style_disabled); ?> type="checkbox" name="dow" <?php (false!==strpos($backup_schedule,'6'))? _e('checked') :_e(''); ?> value="6">Saturday<br>
|
116 |
+
<input <?php _e($schedule_style_disabled); ?> type="checkbox" name="dow" <?php (false!==strpos($backup_schedule,'7'))? _e('checked') :_e(''); ?> value="7">Sunday<br>
|
117 |
+
|
118 |
+
<br/>
|
119 |
+
<input <?php _e($schedule_style_disabled); ?> type="submit" id="schedule-button" class="schedule-button button-primary" value="<?php _e("Save Schedule", $namespace) ?>"/>
|
120 |
+
</form>
|
121 |
+
<?php
|
122 |
+
//Display restore note for lite customers
|
123 |
+
if (!$license_active || 'expired'== $license_status)
|
124 |
+
echo '<p>* Scheduled backups are only available to WP BackItUp premium customers. Please visit ' .$this->get_anchor_with_utm('www.wpbackitup.com','pricing-purchase','scheduled+backups','risk+free') . ' to get WP BackItUp risk free for 30 days.</p>';
|
125 |
+
?>
|
126 |
+
</div>
|
127 |
+
</div>
|
128 |
+
|
129 |
<!--Available Backups section-->
|
130 |
<div class="widget">
|
131 |
<h3><i class="fa fa-cloud-download"></i> <?php _e('Available Backups', $namespace); ?></h3>
|
141 |
<?php
|
142 |
|
143 |
//Get Zip File List
|
144 |
+
$file_list = glob($backup_folder_root . "/*.zip");
|
145 |
+
$backup_log_filelist = glob($backup_folder_root . "/*.log");
|
146 |
+
|
147 |
+
//$logs_log_filelist = glob($logs_folder_root . "/Backup_*.log");
|
148 |
+
//$file_list = array_merge($zip_filelist,$logs_log_filelist);
|
149 |
+
//print_r($file_list);
|
150 |
+
|
151 |
+
if (count($file_list)>0)
|
152 |
{
|
153 |
//Sort by Date Time
|
154 |
+
usort($file_list, create_function('$a,$b', 'return filemtime($b) - filemtime($a);'));
|
155 |
|
156 |
$i = 0;
|
157 |
+
foreach ($file_list as $file)
|
158 |
{
|
159 |
+
if( $retain_archives && $retain_archives == $i)
|
160 |
+
break;
|
161 |
+
|
162 |
+
$filename = basename($file);
|
163 |
+
$file_type= substr($filename, -3);
|
164 |
+
//Local Date Time
|
165 |
+
$file_datetime = get_date_from_gmt(date('Y-m-d H:i:s', filemtime($file)), 'Y-m-d g:i a');
|
166 |
+
|
167 |
+
$success_logExists = false;
|
168 |
+
if ('zip'==$file_type) {
|
169 |
+
$zip_exists = true;
|
170 |
+
$log_file = str_replace( '.zip', '.log', $file );
|
171 |
+
$log_filename = basename( $log_file );
|
172 |
+
if ( is_array( $backup_log_filelist ) && in_array( $log_file, $backup_log_filelist ) ) {
|
173 |
+
$logExists = true;
|
174 |
+
}
|
175 |
+
}else{
|
176 |
+
$zip_exists = false;
|
177 |
+
$log_file = $filename;
|
178 |
+
$log_filename = $filename;
|
179 |
+
$logExists = true;
|
180 |
+
}
|
181 |
+
//------
|
182 |
|
183 |
$class = $i % 2 == 0 ? 'class="alternate"' : '';
|
184 |
?>
|
185 |
|
186 |
<tr <?php echo $class ?> id="row<?php echo $i; ?>">
|
187 |
+
<td><?php echo $file_datetime ?></td>
|
188 |
+
<td><?php echo $filename ?></td>
|
189 |
+
|
190 |
+
<?php if ($zip_exists) :?>
|
191 |
+
<td><a href="<?php echo WPBACKITUP__BACKUP_URL ?>/<?php echo $filename; ?>">Download</a></td>
|
192 |
+
<?php else: ?>
|
193 |
+
<td> </td>
|
194 |
+
<?php endif; ?>
|
195 |
+
|
196 |
+
<?php if (($logExists)):?>
|
197 |
<td><a class='viewloglink' href="<?php echo basename($log_filename, ".log") ?>">View Log</a></td>
|
198 |
<?php else: ?>
|
199 |
<td> </td>
|
200 |
<?php endif; ?>
|
|
|
201 |
|
202 |
+
<td><a href="#" title="<?php echo $filename; ?>" class="deleteRow" id="deleteRow<?php echo $i; ?>">Delete</a></td>
|
203 |
</tr>
|
204 |
|
205 |
<?php
|
216 |
<?php
|
217 |
//Display restore note for lite customers
|
218 |
if (!$license_active)
|
219 |
+
echo '<p>* The automated restore feature is only available to WP BackItUp premium customers. Please visit ' .$this->get_anchor_with_utm('www.wpbackitup.com','pricing-purchase','available+backups','risk+free') . ' to get WP BackItUp risk free for 30 days.</p>';
|
220 |
?>
|
221 |
</div>
|
222 |
|
247 |
<span class="error104"><div class='isa_error'><?php _e('Error 104: Unable to backup your database. Please try again', $namespace); ?>.</div></span>
|
248 |
<span class="error105"><div class='isa_error'><?php _e('Error 105: Unable to create site information file. Please try again', $namespace); ?>.</div></span>
|
249 |
<span class="error106"><div class='isa_warning'><?php _e('Warning 106: Unable to cleanup your backup directory', $namespace); ?>.</div></span>
|
250 |
+
<span class="error107"><div class='isa_error'><?php _e('Error 107: Unable to compress(zip) your backup. Please try again', $namespace); ?>.</div></span>
|
251 |
<span class="error114"><div class='isa_error'><?php _e('Error 114: Your database was accessible but an export could not be created. Please contact support by clicking the get support link on the right. Please let us know who your host is when you submit the request', $namespace); ?>.</div></span>
|
252 |
</div>
|
253 |
|
254 |
+
<!--Error status messages-->
|
255 |
<ul class="backup-unexpected-error">
|
256 |
<span class='error999'><div class='isa_error'><?php _e('An unexpected error has occurred. ', $namespace); ?></div></span>
|
257 |
</ul>
|
views/test.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
global $WPBackitup;
|
4 |
+
|
5 |
+
$logger = new WPBackItUp_Logger(false);
|
6 |
+
|
7 |
+
$backupCount = $WPBackitup->backup_count();
|
8 |
+
$logger->log('Count: ' .$backupCount);
|
9 |
+
$WPBackitup->increment_backup_count();
|
10 |
+
|
11 |
+
|
12 |
+
$logger->log('HERE');
|
13 |
+
|
14 |
+
//do_action('wpbackitup_resume_backup',$WPBackitup->backup_count());
|
15 |
+
$current_time = time();
|
16 |
+
//Add backup scheduled if doesnt exist
|
17 |
+
wp_schedule_single_event( time()+30, 'wpbackitup_resume_backup');
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
|
22 |
+
|
wp-backitup.php
CHANGED
@@ -1,79 +1,90 @@
|
|
1 |
-
<?php if (!defined ('ABSPATH')) die('No direct access allowed');
|
2 |
-
|
3 |
-
/**
|
4 |
-
* WP Backitup
|
5 |
-
*
|
6 |
-
* @package WP Backitup
|
7 |
-
*
|
8 |
-
* @author cssimmon
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
/*
|
12 |
-
Plugin Name: WP Backitup
|
13 |
-
Plugin URI: http://www.wpbackitup.com
|
14 |
-
Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
|
15 |
-
Version: 1.
|
16 |
-
Author: Chris Simmons
|
17 |
-
Author URI: http://www.wpbackitup.com
|
18 |
-
License: GPL3
|
19 |
-
|
20 |
-
Copyright 2012-2014 WPBackItUp (email : support@wpbackitup.com)
|
21 |
-
|
22 |
-
This program is free software: you can redistribute it and/or modify
|
23 |
-
it under the terms of the GNU General Public License as published by
|
24 |
-
the Free Software Foundation, either version 3 of the License, or
|
25 |
-
(at your option) any later version.
|
26 |
-
|
27 |
-
This program is distributed in the hope that it will be useful,
|
28 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
29 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
30 |
-
GNU General Public License for more details.
|
31 |
-
|
32 |
-
You should have received a copy of the GNU General Public License
|
33 |
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
34 |
-
*/
|
35 |
-
|
36 |
-
define( 'WPBACKITUP__NAMESPACE', 'wp-backitup' );
|
37 |
-
define( 'WPBACKITUP__VERSION', '1.
|
38 |
-
define( 'WPBACKITUP__DEBUG', false );
|
39 |
-
define( 'WPBACKITUP__MINIMUM_WP_VERSION', '3.0' );
|
40 |
-
define( 'WPBACKITUP__ITEM_NAME', 'WP Backitup' );
|
41 |
-
define( 'WPBACKITUP__FRIENDLY_NAME', 'WP BackItUp' );
|
42 |
-
|
43 |
-
define( 'WPBACKITUP__CONTENT_PATH', WP_CONTENT_DIR );
|
44 |
-
|
45 |
-
define( 'WPBACKITUP__SITE_URL', 'http://www.wpbackitup.com');
|
46 |
-
define( 'WPBACKITUP__SECURESITE_URL', 'https://www.wpbackitup.com' );
|
47 |
-
|
48 |
-
define( 'WPBACKITUP__PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
49 |
-
define( 'WPBACKITUP__PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
|
50 |
-
define( 'WPBACKITUP__PLUGIN_FOLDER',basename(dirname(__FILE__)));
|
51 |
-
|
52 |
-
define( 'WPBACKITUP__BACKUP_FOLDER', 'wpbackitup_backups' );
|
53 |
-
define( 'WPBACKITUP__BACKUP_URL', content_url() . "/" .WPBACKITUP__BACKUP_FOLDER);
|
54 |
-
define( 'WPBACKITUP__BACKUP_PATH',WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__BACKUP_FOLDER);
|
55 |
-
|
56 |
-
define( 'WPBACKITUP__RESTORE_FOLDER', 'wpbackitup_restore' );
|
57 |
-
define( 'WPBACKITUP__RESTORE_PATH',WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__RESTORE_FOLDER);
|
58 |
-
|
59 |
-
define( 'WPBACKITUP__PLUGINS_ROOT_PATH',WP_PLUGIN_DIR );
|
60 |
-
define( 'WPBACKITUP__THEMES_ROOT_PATH',get_theme_root() );
|
61 |
-
|
62 |
-
define( 'WPBACKITUP__SQL_DBBACKUP_FILENAME', 'db-backup.sql');
|
63 |
-
|
64 |
-
register_activation_hook( __FILE__, array( 'WPBackitup_Admin', 'activate' ) );
|
65 |
-
register_deactivation_hook( __FILE__, array( 'WPBackitup_Admin', 'deactivate' ) );
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (!defined ('ABSPATH')) die('No direct access allowed');
|
2 |
+
|
3 |
+
/**
|
4 |
+
* WP Backitup
|
5 |
+
*
|
6 |
+
* @package WP Backitup
|
7 |
+
*
|
8 |
+
* @author cssimmon
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
/*
|
12 |
+
Plugin Name: WP Backitup
|
13 |
+
Plugin URI: http://www.wpbackitup.com
|
14 |
+
Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
|
15 |
+
Version: 1.9
|
16 |
+
Author: Chris Simmons
|
17 |
+
Author URI: http://www.wpbackitup.com
|
18 |
+
License: GPL3
|
19 |
+
|
20 |
+
Copyright 2012-2014 WPBackItUp (email : support@wpbackitup.com)
|
21 |
+
|
22 |
+
This program is free software: you can redistribute it and/or modify
|
23 |
+
it under the terms of the GNU General Public License as published by
|
24 |
+
the Free Software Foundation, either version 3 of the License, or
|
25 |
+
(at your option) any later version.
|
26 |
+
|
27 |
+
This program is distributed in the hope that it will be useful,
|
28 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
29 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
30 |
+
GNU General Public License for more details.
|
31 |
+
|
32 |
+
You should have received a copy of the GNU General Public License
|
33 |
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
34 |
+
*/
|
35 |
+
|
36 |
+
define( 'WPBACKITUP__NAMESPACE', 'wp-backitup' );
|
37 |
+
define( 'WPBACKITUP__VERSION', '1.9');
|
38 |
+
define( 'WPBACKITUP__DEBUG', false );
|
39 |
+
define( 'WPBACKITUP__MINIMUM_WP_VERSION', '3.0' );
|
40 |
+
define( 'WPBACKITUP__ITEM_NAME', 'WP Backitup' );
|
41 |
+
define( 'WPBACKITUP__FRIENDLY_NAME', 'WP BackItUp' );
|
42 |
+
|
43 |
+
define( 'WPBACKITUP__CONTENT_PATH', WP_CONTENT_DIR );
|
44 |
+
|
45 |
+
define( 'WPBACKITUP__SITE_URL', 'http://www.wpbackitup.com');
|
46 |
+
define( 'WPBACKITUP__SECURESITE_URL', 'https://www.wpbackitup.com' );
|
47 |
+
|
48 |
+
define( 'WPBACKITUP__PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
49 |
+
define( 'WPBACKITUP__PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
|
50 |
+
define( 'WPBACKITUP__PLUGIN_FOLDER',basename(dirname(__FILE__)));
|
51 |
+
|
52 |
+
define( 'WPBACKITUP__BACKUP_FOLDER', 'wpbackitup_backups' );
|
53 |
+
define( 'WPBACKITUP__BACKUP_URL', content_url() . "/" .WPBACKITUP__BACKUP_FOLDER);
|
54 |
+
define( 'WPBACKITUP__BACKUP_PATH',WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__BACKUP_FOLDER);
|
55 |
+
|
56 |
+
define( 'WPBACKITUP__RESTORE_FOLDER', 'wpbackitup_restore' );
|
57 |
+
define( 'WPBACKITUP__RESTORE_PATH',WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__RESTORE_FOLDER);
|
58 |
+
|
59 |
+
define( 'WPBACKITUP__PLUGINS_ROOT_PATH',WP_PLUGIN_DIR );
|
60 |
+
define( 'WPBACKITUP__THEMES_ROOT_PATH',get_theme_root() );
|
61 |
+
|
62 |
+
define( 'WPBACKITUP__SQL_DBBACKUP_FILENAME', 'db-backup.sql');
|
63 |
+
|
64 |
+
register_activation_hook( __FILE__, array( 'WPBackitup_Admin', 'activate' ) );
|
65 |
+
register_deactivation_hook( __FILE__, array( 'WPBackitup_Admin', 'deactivate' ) );
|
66 |
+
|
67 |
+
|
68 |
+
function wpbackitup_modify_cron_schedules($schedules) {
|
69 |
+
$schedules['weekly'] = array('interval' => 604800, 'display' => 'Once Weekly');
|
70 |
+
$schedules['monthly'] = array('interval' => 2592000, 'display' => 'Once Monthly');
|
71 |
+
$schedules['every4hours'] = array('interval' => 14400, 'display' => sprintf(__('Every %s hours', 'wpbackitup'), 4));
|
72 |
+
$schedules['every8hours'] = array('interval' => 28800, 'display' => sprintf(__('Every %s hours', 'wpbackitup'), 8));
|
73 |
+
return $schedules;
|
74 |
+
}
|
75 |
+
|
76 |
+
add_filter('cron_schedules', 'wpbackitup_modify_cron_schedules', 30);
|
77 |
+
|
78 |
+
|
79 |
+
// The checks here before loading are for performance only - unless one of those conditions is met, then none of the hooks will ever be used
|
80 |
+
if (!is_admin() && (!defined('DOING_CRON') || !DOING_CRON) && (!defined('XMLRPC_REQUEST') || !XMLRPC_REQUEST) && empty($_SERVER['SHELL']) && empty($_SERVER['USER'])) return;
|
81 |
+
|
82 |
+
require_once( WPBACKITUP__PLUGIN_PATH .'/lib/includes/class-wpbackitup-admin.php' );
|
83 |
+
require_once( WPBACKITUP__PLUGIN_PATH .'/lib/includes/class-logger.php' );
|
84 |
+
|
85 |
+
global $WPBackitup;
|
86 |
+
$WPBackitup = WPBackitup_Admin::get_instance();
|
87 |
+
$WPBackitup->initialize();
|
88 |
+
|
89 |
+
|
90 |
+
|