BackWPup – WordPress Backup Plugin - Version 3.1.3

Version Description

= After an upgrade from version 2 =

Please check all settings after the update:

  • Dropbox authentication must be done again
  • SugarSync authentication must be done again
  • S3 Settings
  • Google Storage is now in S3
  • Check all your passwords
Download this release

Release Info

Developer danielhuesken
Plugin Icon 128x128 BackWPup – WordPress Backup Plugin
Version 3.1.3
Comparing to
See all releases

Code changes from version 3.1.2 to 3.1.3

Files changed (57) hide show
  1. assets/css/backwpup.css +359 -359
  2. assets/css/backwpup.min.css +1 -1
  3. assets/css/lower_wp38.css +59 -59
  4. assets/css/lower_wp38.min.css +1 -1
  5. assets/fonts/backwpup.svg +10 -10
  6. assets/js/general.js +40 -40
  7. assets/js/general.min.js +1 -1
  8. assets/js/jquery.tipTip.js +175 -176
  9. assets/js/jquery.tipTip.min.js +1 -1
  10. assets/js/page_edit_jobtype_dbdump.js +97 -77
  11. assets/js/page_edit_jobtype_dbdump.min.js +1 -1
  12. assets/js/page_edit_jobtype_file.js +72 -72
  13. assets/js/page_edit_jobtype_file.min.js +1 -1
  14. assets/js/page_edit_tab_cron.js +156 -156
  15. assets/js/page_edit_tab_cron.min.js +1 -1
  16. assets/js/page_edit_tab_job.js +321 -346
  17. assets/js/page_edit_tab_job.min.js +1 -1
  18. assets/js/page_settings.js +26 -26
  19. assets/js/page_settings.min.js +1 -1
  20. backwpup.php +40 -30
  21. inc/class-admin.php +574 -573
  22. inc/class-adminbar.php +136 -132
  23. inc/class-create-archive.php +157 -111
  24. inc/class-cron.php +313 -313
  25. inc/class-destination-dropbox.php +162 -259
  26. inc/class-destination-email.php +436 -429
  27. inc/class-destination-folder.php +215 -215
  28. inc/class-destination-ftp.php +410 -410
  29. inc/class-destination-msazure.php +8 -6
  30. inc/class-destination-rsc.php +465 -466
  31. inc/class-destination-s3-v1.php +8 -5
  32. inc/class-destination-s3.php +12 -11
  33. inc/class-destination-sugarsync.php +879 -879
  34. inc/class-destinations.php +143 -145
  35. inc/class-encryption.php +37 -13
  36. inc/class-file.php +96 -87
  37. inc/class-help.php +48 -48
  38. inc/class-install.php +313 -313
  39. inc/class-job.php +269 -154
  40. inc/class-jobtype-dbcheck.php +151 -151
  41. inc/class-jobtype-dbdump.php +273 -275
  42. inc/class-jobtype-file.php +600 -600
  43. inc/class-jobtype-wpexp.php +571 -126
  44. inc/class-jobtype-wpplugin.php +148 -148
  45. inc/class-jobtypes.php +111 -111
  46. inc/class-mysqldump.php +480 -472
  47. inc/class-option.php +285 -282
  48. inc/class-page-about.php +2 -2
  49. inc/class-page-backups.php +472 -472
  50. inc/class-page-backwpup.php +387 -387
  51. inc/class-page-editjob.php +897 -897
  52. inc/class-page-jobs.php +20 -42
  53. inc/class-page-logs.php +400 -400
  54. inc/class-page-settings.php +11 -19
  55. inc/class-wp-cli.php +84 -84
  56. languages/backwpup-de_DE.mo +0 -0
  57. languages/backwpup-de_DE.po +560 -696
assets/css/backwpup.css CHANGED
@@ -1,360 +1,360 @@
1
- @font-face {
2
- font-family: 'backwpup';
3
- src:url('../fonts/backwpup.eot');
4
- src:url('../fonts/backwpup.eot?#iefix') format('embedded-opentype'),
5
- url('../fonts/backwpup.ttf') format('truetype'),
6
- url('../fonts/backwpup.woff') format('woff'),
7
- url('../fonts/backwpup.svg#backwpup') format('svg');
8
- font-weight: normal;
9
- font-style: normal;
10
- }
11
-
12
- /* Adminbar icon */
13
- #wp-admin-bar-backwpup .ab-icon {
14
- font: normal 20px/1 'backwpup' !important;
15
- }
16
- #wp-admin-bar-backwpup .ab-icon:before {
17
- content: "\e600";
18
- top: 2px;
19
- }
20
-
21
- @media screen and (max-width: 782px) {
22
- #wp-admin-bar-backwpup .ab-icon {
23
- font: normal 32px/1 'backwpup' !important;
24
- display: block;
25
- text-indent: 0;
26
- speak: none;
27
- top: 7px;
28
- width: 50px;
29
- text-align: center;
30
- -webkit-font-smoothing: antialiased;
31
- -moz-osx-font-smoothing: grayscale;
32
- }
33
- #wp-admin-bar-backwpup .ab-icon:before {
34
- top: 0;
35
- }
36
- }
37
-
38
- /* Menu icon */
39
- #adminmenu #toplevel_page_backwpup div.wp-menu-image:before {
40
- font: normal 20px/1 'backwpup' !important;
41
- content: "\e600";
42
- }
43
- #backwpup-page-icon,
44
- #backwpup-page-icon:before {
45
- display: none;
46
- }
47
-
48
-
49
- /* TipTip CSS - Version 1.3 for all backwpup pages */
50
-
51
- #backwpup_tiptip_holder {
52
- display: none;
53
- position: absolute;
54
- top: 0;
55
- left: 0;
56
- z-index: 99999;
57
- }
58
- #backwpup_tiptip_holder.tip_top {
59
- padding-bottom: 5px;
60
- }
61
- #backwpup_tiptip_holder.tip_bottom {
62
- padding-top: 5px;
63
- }
64
- #backwpup_tiptip_holder.tip_right {
65
- padding-left: 5px;
66
- }
67
- #backwpup_tiptip_holder.tip_left {
68
- padding-right: 5px;
69
- }
70
- #backwpup_tiptip_content {
71
- font-size: 11px;
72
- color: #fff;
73
- text-shadow: 0 0 2px #000;
74
- padding: 4px 8px;
75
- border: 1px solid rgba(255, 255, 255, 0.25);
76
- background-color: rgb(25, 25, 25);
77
- background-color: rgba(25, 25, 25, 0.92);
78
- background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(transparent), to(#000));
79
- border-radius: 3px;
80
- -webkit-border-radius: 3px;
81
- -moz-border-radius: 3px;
82
- box-shadow: 0 0 3px #555;
83
- -webkit-box-shadow: 0 0 3px #555;
84
- -moz-box-shadow: 0 0 3px #555;
85
- }
86
- #backwpup_tiptip_content code {
87
- background:#1d94cf;
88
- color:#fff;
89
- text-shadow:none;
90
- padding:2px;
91
- font-size:12px;
92
- }
93
- #backwpup_tiptip_content a{
94
- color: #0CF;
95
- }
96
- #backwpup_tiptip_content a:hover{
97
- color: #F93;
98
- }
99
- #backwpup_tiptip_arrow, #backwpup_tiptip_arrow_inner {
100
- position: absolute;
101
- border: 6px solid transparent;
102
- height: 0;
103
- width: 0;
104
- }
105
- #backwpup_tiptip_holder.tip_top #backwpup_tiptip_arrow {
106
- border-top-color: #fff;
107
- border-top-color: rgba(255, 255, 255, 0.35);
108
- }
109
- #backwpup_tiptip_holder.tip_bottom #backwpup_tiptip_arrow {
110
- border-bottom-color: #fff;
111
- border-bottom-color: rgba(255, 255, 255, 0.35);
112
- }
113
- #backwpup_tiptip_holder.tip_right #backwpup_tiptip_arrow {
114
- border-right-color: #fff;
115
- border-right-color: rgba(255, 255, 255, 0.35);
116
- }
117
- #backwpup_tiptip_holder.tip_left #backwpup_tiptip_arrow {
118
- border-left-color: #fff;
119
- border-left-color: rgba(255, 255, 255, 0.35);
120
- }
121
- #backwpup_tiptip_holder.tip_top #backwpup_tiptip_arrow_inner {
122
- margin-top: -7px;
123
- margin-left: -6px;
124
- border-top-color: rgb(25, 25, 25);
125
- border-top-color: rgba(25, 25, 25, 0.92);
126
- }
127
- #backwpup_tiptip_holder.tip_bottom #backwpup_tiptip_arrow_inner {
128
- margin-top: -5px;
129
- margin-left: -6px;
130
- border-bottom-color: rgb(25, 25, 25);
131
- border-bottom-color: rgba(25, 25, 25, 0.92);
132
- }
133
- #backwpup_tiptip_holder.tip_right #backwpup_tiptip_arrow_inner {
134
- margin-top: -6px;
135
- margin-left: -5px;
136
- border-right-color: rgb(25, 25, 25);
137
- border-right-color: rgba(25, 25, 25, 0.92);
138
- }
139
- #backwpup_tiptip_holder.tip_left #backwpup_tiptip_arrow_inner {
140
- margin-top: -6px;
141
- margin-left: -7px;
142
- border-left-color: rgb(25, 25, 25);
143
- border-left-color: rgba(25, 25, 25, 0.92);
144
- }
145
-
146
- /* Webkit Hacks */
147
- @media screen and ( -webkit-min-device-pixel-ratio:0 ) {
148
- #backwpup_tiptip_content {
149
- padding: 4px 8px 5px 8px;
150
- background-color: rgba(45, 45, 45, 0.88);
151
- }
152
-
153
- #backwpup_tiptip_holder.tip_bottom #backwpup_tiptip_arrow_inner {
154
- border-bottom-color: rgba(45, 45, 45, 0.88);
155
- }
156
-
157
- #backwpup_tiptip_holder.tip_top #backwpup_tiptip_arrow_inner {
158
- border-top-color: rgba(20, 20, 20, 0.92);
159
- }
160
- }
161
-
162
- /* UI Boxes */
163
- #backwpup-page .backwpup-floated-postbox {
164
- margin: 25px 0 0;
165
- max-width: 100%;
166
- overflow: hidden;
167
- padding: 15px;
168
- position: relative;
169
- }
170
- #backwpup-page .backwpup-cleared-postbox {
171
- clear: both;
172
- margin: 25px 0 0;
173
- padding: 10px;
174
- }
175
- #backwpup-page .postbox ul {
176
- padding-left: 10px;
177
- }
178
- #backwpup-page .postbox table {
179
- caption-side: top;
180
- margin-bottom: 25px;
181
- }
182
- #backwpup-page .postbox .hndle {
183
- cursor: auto;
184
- }
185
- #backwpup-page .postbox table caption {
186
- color: #222;
187
- font-weight: 600;
188
- font-size: 14px;
189
- padding: 8px 12px;
190
- margin: 0;
191
- line-height: 1.4;
192
- text-align: left;
193
- }
194
- #backwpup-page .wizardbox {
195
- color: #fff;
196
- background: #1d94cf url('../images/hgbox.png') no-repeat right bottom;
197
- min-height: 20em;
198
- }
199
- #backwpup-page .wizardbox:hover {
200
- background-color: #0f79ae;
201
- }
202
- #backwpup-page .button-bwp,
203
- #backwpup-page .button-primary-bwp {
204
- border-radius: 0;
205
- -webkit-box-shadow: none;
206
- box-shadow: none;
207
- }
208
- #backwpup-page .button-primary-bwp {
209
- border: none;
210
- background: #38b0eb;
211
- color: #fff;
212
- min-width: 8em;
213
- }
214
- #backwpup-page .button-primary-bwp:hover {
215
- background: #064565;
216
- }
217
- #backwpup-page .wizardbox .wizardbox_name {
218
- color: #fff;
219
- margin-top: 0;
220
- }
221
- #backwpup-page .wizardbox .wizardbox_start {
222
- position: absolute;
223
- bottom: 10px;
224
- left: 10px;
225
- }
226
- #backwpup-page .wizardbox select{
227
- max-width: 100%;
228
- width: 100%;
229
- }
230
- #backwpup-page .backwpup-table-wrap {
231
- overflow-x: auto;
232
- }
233
- #backwpup-page .backwpup-banner-img {
234
- display: block;
235
- height: auto;
236
- margin: 26px auto;
237
- max-width: 100%;
238
- }
239
- #backwpup-page .backwpup-text-center {
240
- text-align: center;
241
- }
242
- #backwpup-page ul.backwpup-text-center {
243
- padding-left: 0;
244
- }
245
- #backwpup-page .postbox .backwpup-bullet-list {
246
- padding-left: 16px;
247
- list-style: disc;
248
- }
249
- #backwpup-page .postbox ol.backwpup-bullet-list {
250
- list-style: decimal;
251
- }
252
- #backwpup-page .backwpup-message { /* copied from WP 3.8 CSS */
253
- margin: 5px 0 15px;
254
- border: none;
255
- padding: 1px 12px;
256
- background-color: #fff;
257
- border-left: 4px solid #ccc;
258
- -webkit-box-shadow: 0px 1px 1px 0px rgba(0,0,0,0.1);
259
- box-shadow: 0px 1px 1px 0px rgba(0,0,0,0.1);
260
- }
261
- #backwpup-page .backwpup-message p {
262
- margin: 0.5em 0;
263
- padding: 2px;
264
- }
265
- #backwpup-page .backwpup-info {
266
- border-left: 4px solid #38b0eb; /* BackWPup button-primary color */
267
- }
268
- #backwpup-page .backwpup-warning {
269
- border-left: 4px solid #ffba00; /* UI color .update-nag */
270
- }
271
-
272
- @media screen and (min-width: 720px) {
273
- #backwpup-page .backwpup-floated-postbox {
274
- float: left;
275
- margin: 25px 25px 25px 0;
276
- width: 290px;
277
- }
278
- #backwpup-page #backwpup-one-click-backup,
279
- #backwpup-page #wizard-jobimport,
280
- #backwpup-page #backwpup-thank-you,
281
- #backwpup-page #backwpup-stats {
282
- margin-right: 0;
283
- }
284
- #backwpup-page #backwpup-one-click-backup + .backwpup-floated-postbox,
285
- #backwpup-page #backwpup-thank-you,
286
- #backwpup-page #backwpup-stats {
287
- clear: left;
288
- }
289
- }
290
-
291
- @media screen and (min-width: 1024px) {
292
- #backwpup-page .backwpup-floated-postbox {
293
- width: 362px;
294
- }
295
- #backwpup-page .wizardbox {
296
- width: 225px;
297
- min-height: 225px;
298
- }
299
- #backwpup-page .backwpup-max-width {
300
- max-width: 800px;
301
- }
302
- body[class*="_backwpupabout"] #backwpup-page .backwpup-welcome {
303
- max-width: none;
304
- }
305
- }
306
-
307
- /* Company specific */
308
- #wpfooter #footer-left,
309
- #wpfooter #footer-right {
310
- overflow: hidden;
311
- }
312
- #wpfooter .mp_logo {
313
- background: url('../images/mp_logo_small.png') no-repeat;
314
- display: block;
315
- float: left;
316
- margin-right: 15px;
317
- line-height: 26px;
318
- width: 145px;
319
- text-indent: -9999em;
320
- }
321
- #wpfooter #footer-left .backwpup-get-pro {
322
- display: block;
323
- float: left;
324
- line-height: 36px;
325
- margin-right: 15px;
326
- }
327
- #wpfooter #footer-upgrade .backwpup-update-footer {
328
- display: block;
329
- line-height: 36px;
330
- }
331
- #wpfooter #footer-left #footer-thankyou {
332
- clear: both;
333
- display: block;
334
- padding-top: .5em;
335
-
336
- }
337
- #wpbody-content {
338
- padding-bottom: 10em;
339
- }
340
- #wpfooter {
341
- overflow: hidden;
342
- }
343
-
344
- /* DOKU */
345
- #documentation_content p{
346
- font-size:14px;
347
- line-height:20px;
348
- color:#333;
349
- }
350
- #documentation_content h3{
351
- padding:7px 0;
352
- font-size:22px;
353
- }
354
- #documentation_content h4{
355
- padding:7px 0;
356
- font-size:18px;
357
- }
358
- #documentation_content img.size-full {
359
- border:10px #f6f6f6 solid;
360
  }
1
+ @font-face {
2
+ font-family: 'backwpup';
3
+ src:url('../fonts/backwpup.eot');
4
+ src:url('../fonts/backwpup.eot?#iefix') format('embedded-opentype'),
5
+ url('../fonts/backwpup.ttf') format('truetype'),
6
+ url('../fonts/backwpup.woff') format('woff'),
7
+ url('../fonts/backwpup.svg#backwpup') format('svg');
8
+ font-weight: normal;
9
+ font-style: normal;
10
+ }
11
+
12
+ /* Adminbar icon */
13
+ #wp-admin-bar-backwpup .ab-icon {
14
+ font: normal 20px/1 'backwpup' !important;
15
+ }
16
+ #wp-admin-bar-backwpup .ab-icon:before {
17
+ content: "\e600";
18
+ top: 2px;
19
+ }
20
+
21
+ @media screen and (max-width: 782px) {
22
+ #wp-admin-bar-backwpup .ab-icon {
23
+ font: normal 32px/1 'backwpup' !important;
24
+ display: block;
25
+ text-indent: 0;
26
+ speak: none;
27
+ top: 7px;
28
+ width: 50px;
29
+ text-align: center;
30
+ -webkit-font-smoothing: antialiased;
31
+ -moz-osx-font-smoothing: grayscale;
32
+ }
33
+ #wp-admin-bar-backwpup .ab-icon:before {
34
+ top: 0;
35
+ }
36
+ }
37
+
38
+ /* Menu icon */
39
+ #adminmenu #toplevel_page_backwpup div.wp-menu-image:before {
40
+ font: normal 20px/1 'backwpup' !important;
41
+ content: "\e600";
42
+ }
43
+ #backwpup-page-icon,
44
+ #backwpup-page-icon:before {
45
+ display: none;
46
+ }
47
+
48
+
49
+ /* TipTip CSS - Version 1.3 for all backwpup pages */
50
+
51
+ #backwpup_tiptip_holder {
52
+ display: none;
53
+ position: absolute;
54
+ top: 0;
55
+ left: 0;
56
+ z-index: 99999;
57
+ }
58
+ #backwpup_tiptip_holder.tip_top {
59
+ padding-bottom: 5px;
60
+ }
61
+ #backwpup_tiptip_holder.tip_bottom {
62
+ padding-top: 5px;
63
+ }
64
+ #backwpup_tiptip_holder.tip_right {
65
+ padding-left: 5px;
66
+ }
67
+ #backwpup_tiptip_holder.tip_left {
68
+ padding-right: 5px;
69
+ }
70
+ #backwpup_tiptip_content {
71
+ font-size: 11px;
72
+ color: #fff;
73
+ text-shadow: 0 0 2px #000;
74
+ padding: 4px 8px;
75
+ border: 1px solid rgba(255, 255, 255, 0.25);
76
+ background-color: rgb(25, 25, 25);
77
+ background-color: rgba(25, 25, 25, 0.92);
78
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(transparent), to(#000));
79
+ border-radius: 3px;
80
+ -webkit-border-radius: 3px;
81
+ -moz-border-radius: 3px;
82
+ box-shadow: 0 0 3px #555;
83
+ -webkit-box-shadow: 0 0 3px #555;
84
+ -moz-box-shadow: 0 0 3px #555;
85
+ }
86
+ #backwpup_tiptip_content code {
87
+ background:#1d94cf;
88
+ color:#fff;
89
+ text-shadow:none;
90
+ padding:2px;
91
+ font-size:12px;
92
+ }
93
+ #backwpup_tiptip_content a{
94
+ color: #0CF;
95
+ }
96
+ #backwpup_tiptip_content a:hover{
97
+ color: #F93;
98
+ }
99
+ #backwpup_tiptip_arrow, #backwpup_tiptip_arrow_inner {
100
+ position: absolute;
101
+ border: 6px solid transparent;
102
+ height: 0;
103
+ width: 0;
104
+ }
105
+ #backwpup_tiptip_holder.tip_top #backwpup_tiptip_arrow {
106
+ border-top-color: #fff;
107
+ border-top-color: rgba(255, 255, 255, 0.35);
108
+ }
109
+ #backwpup_tiptip_holder.tip_bottom #backwpup_tiptip_arrow {
110
+ border-bottom-color: #fff;
111
+ border-bottom-color: rgba(255, 255, 255, 0.35);
112
+ }
113
+ #backwpup_tiptip_holder.tip_right #backwpup_tiptip_arrow {
114
+ border-right-color: #fff;
115
+ border-right-color: rgba(255, 255, 255, 0.35);
116
+ }
117
+ #backwpup_tiptip_holder.tip_left #backwpup_tiptip_arrow {
118
+ border-left-color: #fff;
119
+ border-left-color: rgba(255, 255, 255, 0.35);
120
+ }
121
+ #backwpup_tiptip_holder.tip_top #backwpup_tiptip_arrow_inner {
122
+ margin-top: -7px;
123
+ margin-left: -6px;
124
+ border-top-color: rgb(25, 25, 25);
125
+ border-top-color: rgba(25, 25, 25, 0.92);
126
+ }
127
+ #backwpup_tiptip_holder.tip_bottom #backwpup_tiptip_arrow_inner {
128
+ margin-top: -5px;
129
+ margin-left: -6px;
130
+ border-bottom-color: rgb(25, 25, 25);
131
+ border-bottom-color: rgba(25, 25, 25, 0.92);
132
+ }
133
+ #backwpup_tiptip_holder.tip_right #backwpup_tiptip_arrow_inner {
134
+ margin-top: -6px;
135
+ margin-left: -5px;
136
+ border-right-color: rgb(25, 25, 25);
137
+ border-right-color: rgba(25, 25, 25, 0.92);
138
+ }
139
+ #backwpup_tiptip_holder.tip_left #backwpup_tiptip_arrow_inner {
140
+ margin-top: -6px;
141
+ margin-left: -7px;
142
+ border-left-color: rgb(25, 25, 25);
143
+ border-left-color: rgba(25, 25, 25, 0.92);
144
+ }
145
+
146
+ /* Webkit Hacks */
147
+ @media screen and ( -webkit-min-device-pixel-ratio:0 ) {
148
+ #backwpup_tiptip_content {
149
+ padding: 4px 8px 5px 8px;
150
+ background-color: rgba(45, 45, 45, 0.88);
151
+ }
152
+
153
+ #backwpup_tiptip_holder.tip_bottom #backwpup_tiptip_arrow_inner {
154
+ border-bottom-color: rgba(45, 45, 45, 0.88);
155
+ }
156
+
157
+ #backwpup_tiptip_holder.tip_top #backwpup_tiptip_arrow_inner {
158
+ border-top-color: rgba(20, 20, 20, 0.92);
159
+ }
160
+ }
161
+
162
+ /* UI Boxes */
163
+ #backwpup-page .backwpup-floated-postbox {
164
+ margin: 25px 0 0;
165
+ max-width: 100%;
166
+ overflow: hidden;
167
+ padding: 15px;
168
+ position: relative;
169
+ }
170
+ #backwpup-page .backwpup-cleared-postbox {
171
+ clear: both;
172
+ margin: 25px 0 0;
173
+ padding: 10px;
174
+ }
175
+ #backwpup-page .postbox ul {
176
+ padding-left: 10px;
177
+ }
178
+ #backwpup-page .postbox table {
179
+ caption-side: top;
180
+ margin-bottom: 25px;
181
+ }
182
+ #backwpup-page .postbox .hndle {
183
+ cursor: auto;
184
+ }
185
+ #backwpup-page .postbox table caption {
186
+ color: #222;
187
+ font-weight: 600;
188
+ font-size: 14px;
189
+ padding: 8px 12px;
190
+ margin: 0;
191
+ line-height: 1.4;
192
+ text-align: left;
193
+ }
194
+ #backwpup-page .wizardbox {
195
+ color: #fff;
196
+ background: #1d94cf url('../images/hgbox.png') no-repeat right bottom;
197
+ min-height: 20em;
198
+ }
199
+ #backwpup-page .wizardbox:hover {
200
+ background-color: #0f79ae;
201
+ }
202
+ #backwpup-page .button-bwp,
203
+ #backwpup-page .button-primary-bwp {
204
+ border-radius: 0;
205
+ -webkit-box-shadow: none;
206
+ box-shadow: none;
207
+ }
208
+ #backwpup-page .button-primary-bwp {
209
+ border: none;
210
+ background: #38b0eb;
211
+ color: #fff;
212
+ min-width: 8em;
213
+ }
214
+ #backwpup-page .button-primary-bwp:hover {
215
+ background: #064565;
216
+ }
217
+ #backwpup-page .wizardbox .wizardbox_name {
218
+ color: #fff;
219
+ margin-top: 0;
220
+ }
221
+ #backwpup-page .wizardbox .wizardbox_start {
222
+ position: absolute;
223
+ bottom: 10px;
224
+ left: 10px;
225
+ }
226
+ #backwpup-page .wizardbox select{
227
+ max-width: 100%;
228
+ width: 100%;
229
+ }
230
+ #backwpup-page .backwpup-table-wrap {
231
+ overflow-x: auto;
232
+ }
233
+ #backwpup-page .backwpup-banner-img {
234
+ display: block;
235
+ height: auto;
236
+ margin: 26px auto;
237
+ max-width: 100%;
238
+ }
239
+ #backwpup-page .backwpup-text-center {
240
+ text-align: center;
241
+ }
242
+ #backwpup-page ul.backwpup-text-center {
243
+ padding-left: 0;
244
+ }
245
+ #backwpup-page .postbox .backwpup-bullet-list {
246
+ padding-left: 16px;
247
+ list-style: disc;
248
+ }
249
+ #backwpup-page .postbox ol.backwpup-bullet-list {
250
+ list-style: decimal;
251
+ }
252
+ #backwpup-page .backwpup-message { /* copied from WP 3.8 CSS */
253
+ margin: 5px 0 15px;
254
+ border: none;
255
+ padding: 1px 12px;
256
+ background-color: #fff;
257
+ border-left: 4px solid #ccc;
258
+ -webkit-box-shadow: 0px 1px 1px 0px rgba(0,0,0,0.1);
259
+ box-shadow: 0px 1px 1px 0px rgba(0,0,0,0.1);
260
+ }
261
+ #backwpup-page .backwpup-message p {
262
+ margin: 0.5em 0;
263
+ padding: 2px;
264
+ }
265
+ #backwpup-page .backwpup-info {
266
+ border-left: 4px solid #38b0eb; /* BackWPup button-primary color */
267
+ }
268
+ #backwpup-page .backwpup-warning {
269
+ border-left: 4px solid #ffba00; /* UI color .update-nag */
270
+ }
271
+
272
+ @media screen and (min-width: 720px) {
273
+ #backwpup-page .backwpup-floated-postbox {
274
+ float: left;
275
+ margin: 25px 25px 25px 0;
276
+ width: 290px;
277
+ }
278
+ #backwpup-page #backwpup-one-click-backup,
279
+ #backwpup-page #wizard-jobimport,
280
+ #backwpup-page #backwpup-thank-you,
281
+ #backwpup-page #backwpup-stats {
282
+ margin-right: 0;
283
+ }
284
+ #backwpup-page #backwpup-one-click-backup + .backwpup-floated-postbox,
285
+ #backwpup-page #backwpup-thank-you,
286
+ #backwpup-page #backwpup-stats {
287
+ clear: left;
288
+ }
289
+ }
290
+
291
+ @media screen and (min-width: 1024px) {
292
+ #backwpup-page .backwpup-floated-postbox {
293
+ width: 362px;
294
+ }
295
+ #backwpup-page .wizardbox {
296
+ width: 225px;
297
+ min-height: 225px;
298
+ }
299
+ #backwpup-page .backwpup-max-width {
300
+ max-width: 800px;
301
+ }
302
+ body[class*="_backwpupabout"] #backwpup-page .backwpup-welcome {
303
+ max-width: none;
304
+ }
305
+ }
306
+
307
+ /* Company specific */
308
+ #wpfooter #footer-left,
309
+ #wpfooter #footer-right {
310
+ overflow: hidden;
311
+ }
312
+ #wpfooter .mp_logo {
313
+ background: url('../images/mp_logo_small.png') no-repeat;
314
+ display: block;
315
+ float: left;
316
+ margin-right: 15px;
317
+ line-height: 26px;
318
+ width: 145px;
319
+ text-indent: -9999em;
320
+ }
321
+ #wpfooter #footer-left .backwpup-get-pro {
322
+ display: block;
323
+ float: left;
324
+ line-height: 36px;
325
+ margin-right: 15px;
326
+ }
327
+ #wpfooter #footer-upgrade .backwpup-update-footer {
328
+ display: block;
329
+ line-height: 36px;
330
+ }
331
+ #wpfooter #footer-left #footer-thankyou {
332
+ clear: both;
333
+ display: block;
334
+ padding-top: .5em;
335
+
336
+ }
337
+ #wpbody-content {
338
+ padding-bottom: 10em;
339
+ }
340
+ #wpfooter {
341
+ overflow: hidden;
342
+ }
343
+
344
+ /* DOKU */
345
+ #documentation_content p{
346
+ font-size:14px;
347
+ line-height:20px;
348
+ color:#333;
349
+ }
350
+ #documentation_content h3{
351
+ padding:7px 0;
352
+ font-size:22px;
353
+ }
354
+ #documentation_content h4{
355
+ padding:7px 0;
356
+ font-size:18px;
357
+ }
358
+ #documentation_content img.size-full {
359
+ border:10px #f6f6f6 solid;
360
  }
assets/css/backwpup.min.css CHANGED
@@ -1 +1 @@
1
- @font-face{font-family:'backwpup';src:url('../fonts/backwpup.eot');src:url('../fonts/backwpup.eot?#iefix') format('embedded-opentype'),url('../fonts/backwpup.ttf') format('truetype'),url('../fonts/backwpup.woff') format('woff'),url('../fonts/backwpup.svg#backwpup') format('svg');font-weight:normal;font-style:normal}#wp-admin-bar-backwpup .ab-icon{font:normal 20px/1 'backwpup' !important}#wp-admin-bar-backwpup .ab-icon:before{content:"\e600";top:2px}@media screen and (max-width:782px){#wp-admin-bar-backwpup .ab-icon{font:normal 32px/1 'backwpup' !important;display:block;text-indent:0;speak:none;top:7px;width:50px;text-align:center;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#wp-admin-bar-backwpup .ab-icon:before{top:0}}#adminmenu #toplevel_page_backwpup div.wp-menu-image:before{font:normal 20px/1 'backwpup' !important;content:"\e600"}#backwpup-page-icon,#backwpup-page-icon:before{display:none}#backwpup_tiptip_holder{display:none;position:absolute;top:0;left:0;z-index:99999}#backwpup_tiptip_holder.tip_top{padding-bottom:5px}#backwpup_tiptip_holder.tip_bottom{padding-top:5px}#backwpup_tiptip_holder.tip_right{padding-left:5px}#backwpup_tiptip_holder.tip_left{padding-right:5px}#backwpup_tiptip_content{font-size:11px;color:#fff;text-shadow:0 0 2px #000;padding:4px 8px;border:1px solid rgba(255,255,255,0.25);background-color:#191919;background-color:rgba(25,25,25,0.92);background-image:-webkit-gradient(linear,0 0,0 100%,from(transparent),to(#000));border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;box-shadow:0 0 3px #555;-webkit-box-shadow:0 0 3px #555;-moz-box-shadow:0 0 3px #555}#backwpup_tiptip_content code{background:#1d94cf;color:#fff;text-shadow:none;padding:2px;font-size:12px}#backwpup_tiptip_content a{color:#0CF}#backwpup_tiptip_content a:hover{color:#F93}#backwpup_tiptip_arrow,#backwpup_tiptip_arrow_inner{position:absolute;border:6px solid transparent;height:0;width:0}#backwpup_tiptip_holder.tip_top #backwpup_tiptip_arrow{border-top-color:#fff;border-top-color:rgba(255,255,255,0.35)}#backwpup_tiptip_holder.tip_bottom #backwpup_tiptip_arrow{border-bottom-color:#fff;border-bottom-color:rgba(255,255,255,0.35)}#backwpup_tiptip_holder.tip_right #backwpup_tiptip_arrow{border-right-color:#fff;border-right-color:rgba(255,255,255,0.35)}#backwpup_tiptip_holder.tip_left #backwpup_tiptip_arrow{border-left-color:#fff;border-left-color:rgba(255,255,255,0.35)}#backwpup_tiptip_holder.tip_top #backwpup_tiptip_arrow_inner{margin-top:-7px;margin-left:-6px;border-top-color:#191919;border-top-color:rgba(25,25,25,0.92)}#backwpup_tiptip_holder.tip_bottom #backwpup_tiptip_arrow_inner{margin-top:-5px;margin-left:-6px;border-bottom-color:#191919;border-bottom-color:rgba(25,25,25,0.92)}#backwpup_tiptip_holder.tip_right #backwpup_tiptip_arrow_inner{margin-top:-6px;margin-left:-5px;border-right-color:#191919;border-right-color:rgba(25,25,25,0.92)}#backwpup_tiptip_holder.tip_left #backwpup_tiptip_arrow_inner{margin-top:-6px;margin-left:-7px;border-left-color:#191919;border-left-color:rgba(25,25,25,0.92)}@media screen and (-webkit-min-device-pixel-ratio:0){#backwpup_tiptip_content{padding:4px 8px 5px 8px;background-color:rgba(45,45,45,0.88)}#backwpup_tiptip_holder.tip_bottom #backwpup_tiptip_arrow_inner{border-bottom-color:rgba(45,45,45,0.88)}#backwpup_tiptip_holder.tip_top #backwpup_tiptip_arrow_inner{border-top-color:rgba(20,20,20,0.92)}}#backwpup-page .backwpup-floated-postbox{margin:25px 0 0;max-width:100%;overflow:hidden;padding:15px;position:relative}#backwpup-page .backwpup-cleared-postbox{clear:both;margin:25px 0 0;padding:10px}#backwpup-page .postbox ul{padding-left:10px}#backwpup-page .postbox table{caption-side:top;margin-bottom:25px}#backwpup-page .postbox .hndle{cursor:auto}#backwpup-page .postbox table caption{color:#222;font-weight:600;font-size:14px;padding:8px 12px;margin:0;line-height:1.4;text-align:left}#backwpup-page .wizardbox{color:#fff;background:#1d94cf url('../images/hgbox.png') no-repeat right bottom;min-height:20em}#backwpup-page .wizardbox:hover{background-color:#0f79ae}#backwpup-page .button-bwp,#backwpup-page .button-primary-bwp{border-radius:0;-webkit-box-shadow:none;box-shadow:none}#backwpup-page .button-primary-bwp{border:0;background:#38b0eb;color:#fff;min-width:8em}#backwpup-page .button-primary-bwp:hover{background:#064565}#backwpup-page .wizardbox .wizardbox_name{color:#fff;margin-top:0}#backwpup-page .wizardbox .wizardbox_start{position:absolute;bottom:10px;left:10px}#backwpup-page .wizardbox select{max-width:100%;width:100%}#backwpup-page .backwpup-table-wrap{overflow-x:auto}#backwpup-page .backwpup-banner-img{display:block;height:auto;margin:26px auto;max-width:100%}#backwpup-page .backwpup-text-center{text-align:center}#backwpup-page ul.backwpup-text-center{padding-left:0}#backwpup-page .postbox .backwpup-bullet-list{padding-left:16px;list-style:disc}#backwpup-page .postbox ol.backwpup-bullet-list{list-style:decimal}#backwpup-page .backwpup-message{margin:5px 0 15px;border:0;padding:1px 12px;background-color:#fff;border-left:4px solid #ccc;-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);box-shadow:0 1px 1px 0 rgba(0,0,0,0.1)}#backwpup-page .backwpup-message p{margin:.5em 0;padding:2px}#backwpup-page .backwpup-info{border-left:4px solid #38b0eb}#backwpup-page .backwpup-warning{border-left:4px solid #ffba00}@media screen and (min-width:720px){#backwpup-page .backwpup-floated-postbox{float:left;margin:25px 25px 25px 0;width:290px}#backwpup-page #backwpup-one-click-backup,#backwpup-page #wizard-jobimport,#backwpup-page #backwpup-thank-you,#backwpup-page #backwpup-stats{margin-right:0}#backwpup-page #backwpup-one-click-backup+.backwpup-floated-postbox,#backwpup-page #backwpup-thank-you,#backwpup-page #backwpup-stats{clear:left}}@media screen and (min-width:1024px){#backwpup-page .backwpup-floated-postbox{width:362px}#backwpup-page .wizardbox{width:225px;min-height:225px}#backwpup-page .backwpup-max-width{max-width:800px}body[class*="_backwpupabout"] #backwpup-page .backwpup-welcome{max-width:none}}#wpfooter #footer-left,#wpfooter #footer-right{overflow:hidden}#wpfooter .mp_logo{background:url('../images/mp_logo_small.png') no-repeat;display:block;float:left;margin-right:15px;line-height:26px;width:145px;text-indent:-9999em}#wpfooter #footer-left .backwpup-get-pro{display:block;float:left;line-height:36px;margin-right:15px}#wpfooter #footer-upgrade .backwpup-update-footer{display:block;line-height:36px}#wpfooter #footer-left #footer-thankyou{clear:both;display:block;padding-top:.5em}#wpbody-content{padding-bottom:10em}#wpfooter{overflow:hidden}#documentation_content p{font-size:14px;line-height:20px;color:#333}#documentation_content h3{padding:7px 0;font-size:22px}#documentation_content h4{padding:7px 0;font-size:18px}#documentation_content img.size-full{border:10px #f6f6f6 solid}
1
+ @font-face{font-family:backwpup;src:url(../fonts/backwpup.eot);src:url(../fonts/backwpup.eot?#iefix) format('embedded-opentype'),url(../fonts/backwpup.ttf) format('truetype'),url(../fonts/backwpup.woff) format('woff'),url(../fonts/backwpup.svg#backwpup) format('svg');font-weight:400;font-style:normal}#wp-admin-bar-backwpup .ab-icon{font:400 20px/1 backwpup!important}#wp-admin-bar-backwpup .ab-icon:before{content:"\e600";top:2px}@media screen and (max-width:782px){#wp-admin-bar-backwpup .ab-icon{font:400 32px/1 backwpup!important;display:block;text-indent:0;speak:none;top:7px;width:50px;text-align:center;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#wp-admin-bar-backwpup .ab-icon:before{top:0}}#adminmenu #toplevel_page_backwpup div.wp-menu-image:before{font:400 20px/1 backwpup!important;content:"\e600"}#backwpup-page-icon,#backwpup-page-icon:before{display:none}#backwpup_tiptip_holder{display:none;position:absolute;top:0;left:0;z-index:99999}#backwpup_tiptip_holder.tip_top{padding-bottom:5px}#backwpup_tiptip_holder.tip_bottom{padding-top:5px}#backwpup_tiptip_holder.tip_right{padding-left:5px}#backwpup_tiptip_holder.tip_left{padding-right:5px}#backwpup_tiptip_content{font-size:11px;color:#fff;text-shadow:0 0 2px #000;padding:4px 8px;border:1px solid rgba(255,255,255,.25);background-color:#191919;background-color:rgba(25,25,25,.92);background-image:-webkit-gradient(linear,0 0,0 100%,from(transparent),to(#000));border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;box-shadow:0 0 3px #555;-webkit-box-shadow:0 0 3px #555;-moz-box-shadow:0 0 3px #555}#backwpup_tiptip_content code{background:#1d94cf;color:#fff;text-shadow:none;padding:2px;font-size:12px}#backwpup_tiptip_content a{color:#0CF}#backwpup_tiptip_content a:hover{color:#F93}#backwpup_tiptip_arrow,#backwpup_tiptip_arrow_inner{position:absolute;border:6px solid transparent;height:0;width:0}#backwpup_tiptip_holder.tip_top #backwpup_tiptip_arrow{border-top-color:#fff;border-top-color:rgba(255,255,255,.35)}#backwpup_tiptip_holder.tip_bottom #backwpup_tiptip_arrow{border-bottom-color:#fff;border-bottom-color:rgba(255,255,255,.35)}#backwpup_tiptip_holder.tip_right #backwpup_tiptip_arrow{border-right-color:#fff;border-right-color:rgba(255,255,255,.35)}#backwpup_tiptip_holder.tip_left #backwpup_tiptip_arrow{border-left-color:#fff;border-left-color:rgba(255,255,255,.35)}#backwpup_tiptip_holder.tip_top #backwpup_tiptip_arrow_inner{margin-top:-7px;margin-left:-6px;border-top-color:#191919;border-top-color:rgba(25,25,25,.92)}#backwpup_tiptip_holder.tip_bottom #backwpup_tiptip_arrow_inner{margin-top:-5px;margin-left:-6px;border-bottom-color:#191919;border-bottom-color:rgba(25,25,25,.92)}#backwpup_tiptip_holder.tip_right #backwpup_tiptip_arrow_inner{margin-top:-6px;margin-left:-5px;border-right-color:#191919;border-right-color:rgba(25,25,25,.92)}#backwpup_tiptip_holder.tip_left #backwpup_tiptip_arrow_inner{margin-top:-6px;margin-left:-7px;border-left-color:#191919;border-left-color:rgba(25,25,25,.92)}@media screen and (-webkit-min-device-pixel-ratio:0){#backwpup_tiptip_content{padding:4px 8px 5px;background-color:rgba(45,45,45,.88)}#backwpup_tiptip_holder.tip_bottom #backwpup_tiptip_arrow_inner{border-bottom-color:rgba(45,45,45,.88)}#backwpup_tiptip_holder.tip_top #backwpup_tiptip_arrow_inner{border-top-color:rgba(20,20,20,.92)}}#backwpup-page .backwpup-floated-postbox{margin:25px 0 0;max-width:100%;overflow:hidden;padding:15px;position:relative}#backwpup-page .backwpup-cleared-postbox{clear:both;margin:25px 0 0;padding:10px}#backwpup-page .postbox ul{padding-left:10px}#backwpup-page .postbox table{caption-side:top;margin-bottom:25px}#backwpup-page .postbox .hndle{cursor:auto}#backwpup-page .postbox table caption{color:#222;font-weight:600;font-size:14px;padding:8px 12px;margin:0;line-height:1.4;text-align:left}#backwpup-page .wizardbox{color:#fff;background:url(../images/hgbox.png) right bottom no-repeat #1d94cf;min-height:20em}#backwpup-page .wizardbox:hover{background-color:#0f79ae}#backwpup-page .button-bwp,#backwpup-page .button-primary-bwp{border-radius:0;-webkit-box-shadow:none;box-shadow:none}#backwpup-page .button-primary-bwp{border:none;background:#38b0eb;color:#fff;min-width:8em}#backwpup-page .button-primary-bwp:hover{background:#064565}#backwpup-page .wizardbox .wizardbox_name{color:#fff;margin-top:0}#backwpup-page .wizardbox .wizardbox_start{position:absolute;bottom:10px;left:10px}#backwpup-page .wizardbox select{max-width:100%;width:100%}#backwpup-page .backwpup-table-wrap{overflow-x:auto}#backwpup-page .backwpup-banner-img{display:block;height:auto;margin:26px auto;max-width:100%}#backwpup-page .backwpup-text-center{text-align:center}#backwpup-page ul.backwpup-text-center{padding-left:0}#backwpup-page .postbox .backwpup-bullet-list{padding-left:16px;list-style:disc}#backwpup-page .postbox ol.backwpup-bullet-list{list-style:decimal}#backwpup-page .backwpup-message{margin:5px 0 15px;border:none;padding:1px 12px;background-color:#fff;border-left:4px solid #ccc;-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,.1);box-shadow:0 1px 1px 0 rgba(0,0,0,.1)}#backwpup-page .backwpup-message p{margin:.5em 0;padding:2px}#backwpup-page .backwpup-info{border-left:4px solid #38b0eb}#backwpup-page .backwpup-warning{border-left:4px solid #ffba00}@media screen and (min-width:720px){#backwpup-page .backwpup-floated-postbox{float:left;margin:25px 25px 25px 0;width:290px}#backwpup-page #backwpup-one-click-backup,#backwpup-page #backwpup-stats,#backwpup-page #backwpup-thank-you,#backwpup-page #wizard-jobimport{margin-right:0}#backwpup-page #backwpup-one-click-backup+.backwpup-floated-postbox,#backwpup-page #backwpup-stats,#backwpup-page #backwpup-thank-you{clear:left}}@media screen and (min-width:1024px){#backwpup-page .backwpup-floated-postbox{width:362px}#backwpup-page .wizardbox{width:225px;min-height:225px}#backwpup-page .backwpup-max-width{max-width:800px}body[class*="_backwpupabout"] #backwpup-page .backwpup-welcome{max-width:none}}#wpfooter #footer-left,#wpfooter #footer-right{overflow:hidden}#wpfooter .mp_logo{background:url(../images/mp_logo_small.png) no-repeat;display:block;float:left;margin-right:15px;line-height:26px;width:145px;text-indent:-9999em}#wpfooter #footer-left .backwpup-get-pro{display:block;float:left;line-height:36px;margin-right:15px}#wpfooter #footer-upgrade .backwpup-update-footer{display:block;line-height:36px}#wpfooter #footer-left #footer-thankyou{clear:both;display:block;padding-top:.5em}#wpbody-content{padding-bottom:10em}#wpfooter{overflow:hidden}#documentation_content p{font-size:14px;line-height:20px;color:#333}#documentation_content h3{padding:7px 0;font-size:22px}#documentation_content h4{padding:7px 0;font-size:18px}#documentation_content img.size-full{border:10px solid #f6f6f6}
assets/css/lower_wp38.css CHANGED
@@ -1,60 +1,60 @@
1
- #adminmenu #toplevel_page_backwpup div.wp-menu-image:before {
2
- speak: none;
3
- font-size: 16px !important;
4
- color: #999;
5
- padding-top: 6px;
6
- padding-left: 7px;
7
- height: 20px;
8
- width: 20px;
9
- display: inline-block;
10
- -webkit-font-smoothing: antialiased;
11
- -moz-osx-font-smoothing: grayscale;
12
- -moz-transition: all .1s ease-in-out;
13
- -webkit-transition: all .1s ease-in-out;
14
- transition: all .1s ease-in-out;
15
- }
16
-
17
-
18
- #adminmenu #toplevel_page_backwpup.wp-has-current-submenu div.wp-menu-image:before {
19
- color: #ffffff;
20
- }
21
-
22
- #wp-admin-bar-backwpup .ab-icon {
23
- margin-top: 3px;
24
- }
25
-
26
- #wp-admin-bar-backwpup .ab-icon:before {
27
- top: 0;
28
- font-size: 16px !important;
29
- speak: none;
30
- display: inline-block;
31
- -webkit-font-smoothing: antialiased;
32
- -moz-osx-font-smoothing: grayscale;
33
- -moz-transition: all .1s ease-in-out;
34
- -webkit-transition: all .1s ease-in-out;
35
- transition: all .1s ease-in-out;
36
- }
37
-
38
- @media screen and (max-width: 782px) {
39
- #wp-admin-bar-backwpup .ab-icon {
40
- position: relative;
41
- float: left;
42
- width: 16px;
43
- height: 16px;
44
- font-size: 16px !important;
45
- top: 4px;
46
- }
47
- }
48
-
49
- #backwpup-page-icon:before {
50
- font-family: 'backwpup' !important;
51
- content: "\e600";
52
- }
53
-
54
- #backwpup-page .backwpup-floated-postbox {
55
- padding: 0;
56
- }
57
- #backwpup-page .backwpup-floated-postbox > .inside,
58
- #backwpup-page .wizardbox > form {
59
- margin: 15px;
60
  }
1
+ #adminmenu #toplevel_page_backwpup div.wp-menu-image:before {
2
+ speak: none;
3
+ font-size: 16px !important;
4
+ color: #999;
5
+ padding-top: 6px;
6
+ padding-left: 7px;
7
+ height: 20px;
8
+ width: 20px;
9
+ display: inline-block;
10
+ -webkit-font-smoothing: antialiased;
11
+ -moz-osx-font-smoothing: grayscale;
12
+ -moz-transition: all .1s ease-in-out;
13
+ -webkit-transition: all .1s ease-in-out;
14
+ transition: all .1s ease-in-out;
15
+ }
16
+
17
+
18
+ #adminmenu #toplevel_page_backwpup.wp-has-current-submenu div.wp-menu-image:before {
19
+ color: #ffffff;
20
+ }
21
+
22
+ #wp-admin-bar-backwpup .ab-icon {
23
+ margin-top: 3px;
24
+ }
25
+
26
+ #wp-admin-bar-backwpup .ab-icon:before {
27
+ top: 0;
28
+ font-size: 16px !important;
29
+ speak: none;
30
+ display: inline-block;
31
+ -webkit-font-smoothing: antialiased;
32
+ -moz-osx-font-smoothing: grayscale;
33
+ -moz-transition: all .1s ease-in-out;
34
+ -webkit-transition: all .1s ease-in-out;
35
+ transition: all .1s ease-in-out;
36
+ }
37
+
38
+ @media screen and (max-width: 782px) {
39
+ #wp-admin-bar-backwpup .ab-icon {
40
+ position: relative;
41
+ float: left;
42
+ width: 16px;
43
+ height: 16px;
44
+ font-size: 16px !important;
45
+ top: 4px;
46
+ }
47
+ }
48
+
49
+ #backwpup-page-icon:before {
50
+ font-family: 'backwpup' !important;
51
+ content: "\e600";
52
+ }
53
+
54
+ #backwpup-page .backwpup-floated-postbox {
55
+ padding: 0;
56
+ }
57
+ #backwpup-page .backwpup-floated-postbox > .inside,
58
+ #backwpup-page .wizardbox > form {
59
+ margin: 15px;
60
  }
assets/css/lower_wp38.min.css CHANGED
@@ -1 +1 @@
1
- #adminmenu #toplevel_page_backwpup div.wp-menu-image:before{speak:none;font-size:16px !important;color:#999;padding-top:6px;padding-left:7px;height:20px;width:20px;display:inline-block;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-moz-transition:all .1s ease-in-out;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}#adminmenu #toplevel_page_backwpup.wp-has-current-submenu div.wp-menu-image:before{color:#fff}#wp-admin-bar-backwpup .ab-icon{margin-top:3px}#wp-admin-bar-backwpup .ab-icon:before{top:0;font-size:16px !important;speak:none;display:inline-block;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-moz-transition:all .1s ease-in-out;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}@media screen and (max-width:782px){#wp-admin-bar-backwpup .ab-icon{position:relative;float:left;width:16px;height:16px;font-size:16px !important;top:4px}}#backwpup-page-icon:before{font-family:'backwpup' !important;content:"\e600"}#backwpup-page .backwpup-floated-postbox{padding:0}#backwpup-page .backwpup-floated-postbox>.inside,#backwpup-page .wizardbox>form{margin:15px}
1
+ #adminmenu #toplevel_page_backwpup div.wp-menu-image:before{speak:none;font-size:16px!important;color:#999;padding-top:6px;padding-left:7px;height:20px;width:20px;display:inline-block;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-moz-transition:all .1s ease-in-out;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}#adminmenu #toplevel_page_backwpup.wp-has-current-submenu div.wp-menu-image:before{color:#fff}#wp-admin-bar-backwpup .ab-icon{margin-top:3px}#wp-admin-bar-backwpup .ab-icon:before{top:0;font-size:16px!important;speak:none;display:inline-block;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-moz-transition:all .1s ease-in-out;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}@media screen and (max-width:782px){#wp-admin-bar-backwpup .ab-icon{position:relative;float:left;width:16px;height:16px;font-size:16px!important;top:4px}}#backwpup-page-icon:before{font-family:backwpup!important;content:"\e600"}#backwpup-page .backwpup-floated-postbox{padding:0}#backwpup-page .backwpup-floated-postbox>.inside,#backwpup-page .wizardbox>form{margin:15px}
assets/fonts/backwpup.svg CHANGED
@@ -1,11 +1,11 @@
1
- <?xml version="1.0" standalone="no"?>
2
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
- <svg xmlns="http://www.w3.org/2000/svg">
4
- <metadata>Generated by IcoMoon</metadata>
5
- <defs>
6
- <font id="backwpup" horiz-adv-x="1024">
7
- <font-face units-per-em="1024" ascent="960" descent="-64" />
8
- <missing-glyph horiz-adv-x="1024" />
9
- <glyph unicode="&#x20;" d="" horiz-adv-x="512" />
10
- <glyph unicode="&#xe600;" d="M586.172 856.61c-225.655 0-408.61-182.955-408.61-408.61s182.955-408.61 408.61-408.61c225.655 0 408.61 182.921 408.61 408.61 0 225.655-182.955 408.61-408.61 408.61zM389.837 304.162l-77.039-40.823 10.684 294.537 249.719-156.501-83.934-44.476c68.54-155.136 173.124-149.47 173.124-149.47s-154.249-134.656-272.555 96.734zM860.74 336.384l-249.719 156.501 83.934 44.476c-68.54 155.136-173.124 149.47-173.124 149.47s154.283 134.656 272.589-96.768l77.039 40.823-10.718-294.502zM1031.27 637.815c-24.576 58.061-59.733 110.217-104.516 154.999-44.783 44.783-96.939 79.94-154.999 104.516-60.143 25.429-124.006 38.332-189.815 38.332-65.843 0-129.707-12.902-189.815-38.332-58.061-24.576-110.217-59.733-154.999-104.516-44.783-44.783-79.94-96.939-104.516-154.999-25.463-60.109-38.366-123.972-38.366-189.815 0-65.843 12.902-129.707 38.332-189.85 24.576-58.061 59.733-110.217 104.516-154.999 44.783-44.783 96.939-79.94 154.999-104.516 60.143-25.429 124.006-38.332 189.815-38.332 65.843 0 129.707 12.902 189.815 38.332 58.061 24.576 110.217 59.733 154.999 104.516 44.783 44.783 79.94 96.939 104.516 154.999 25.429 60.143 38.332 124.006 38.332 189.85 0.034 65.843-12.868 129.707-38.298 189.815zM581.939-13.141c-254.259 0-461.141 206.882-461.141 461.141 0 254.259 206.882 461.141 461.141 461.141 254.259 0 461.141-206.848 461.141-461.141 0-254.259-206.882-461.141-461.141-461.141zM1047.142 644.54c-25.429 60.109-61.85 114.108-108.203 160.461-46.353 46.353-100.352 82.773-160.495 108.203-62.259 26.317-128.375 39.697-196.54 39.697-68.164 0-134.281-13.346-196.54-39.697-60.075-25.429-114.074-61.815-160.461-108.203-46.353-46.353-82.773-100.352-108.203-160.461-26.317-62.259-39.663-128.375-39.663-196.54 0-68.164 13.346-134.281 39.697-196.54 25.429-60.109 61.85-114.108 108.203-160.495 46.353-46.353 100.352-82.773 160.495-108.203 62.259-26.351 128.375-39.697 196.54-39.697 68.164 0 134.281 13.346 196.54 39.697 60.109 25.429 114.108 61.815 160.495 108.203 46.353 46.353 82.773 100.352 108.203 160.495 26.317 62.259 39.663 128.375 39.663 196.54-0.068 68.164-13.414 134.281-39.731 196.54zM581.939-29.423c-263.27 0-477.423 214.187-477.423 477.423s214.153 477.423 477.423 477.423c263.236 0 477.423-214.153 477.423-477.423 0-263.236-214.187-477.423-477.423-477.423z" horiz-adv-x="1161" />
11
  </font></defs></svg>
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
+ <svg xmlns="http://www.w3.org/2000/svg">
4
+ <metadata>Generated by IcoMoon</metadata>
5
+ <defs>
6
+ <font id="backwpup" horiz-adv-x="1024">
7
+ <font-face units-per-em="1024" ascent="960" descent="-64" />
8
+ <missing-glyph horiz-adv-x="1024" />
9
+ <glyph unicode="&#x20;" d="" horiz-adv-x="512" />
10
+ <glyph unicode="&#xe600;" d="M586.172 856.61c-225.655 0-408.61-182.955-408.61-408.61s182.955-408.61 408.61-408.61c225.655 0 408.61 182.921 408.61 408.61 0 225.655-182.955 408.61-408.61 408.61zM389.837 304.162l-77.039-40.823 10.684 294.537 249.719-156.501-83.934-44.476c68.54-155.136 173.124-149.47 173.124-149.47s-154.249-134.656-272.555 96.734zM860.74 336.384l-249.719 156.501 83.934 44.476c-68.54 155.136-173.124 149.47-173.124 149.47s154.283 134.656 272.589-96.768l77.039 40.823-10.718-294.502zM1031.27 637.815c-24.576 58.061-59.733 110.217-104.516 154.999-44.783 44.783-96.939 79.94-154.999 104.516-60.143 25.429-124.006 38.332-189.815 38.332-65.843 0-129.707-12.902-189.815-38.332-58.061-24.576-110.217-59.733-154.999-104.516-44.783-44.783-79.94-96.939-104.516-154.999-25.463-60.109-38.366-123.972-38.366-189.815 0-65.843 12.902-129.707 38.332-189.85 24.576-58.061 59.733-110.217 104.516-154.999 44.783-44.783 96.939-79.94 154.999-104.516 60.143-25.429 124.006-38.332 189.815-38.332 65.843 0 129.707 12.902 189.815 38.332 58.061 24.576 110.217 59.733 154.999 104.516 44.783 44.783 79.94 96.939 104.516 154.999 25.429 60.143 38.332 124.006 38.332 189.85 0.034 65.843-12.868 129.707-38.298 189.815zM581.939-13.141c-254.259 0-461.141 206.882-461.141 461.141 0 254.259 206.882 461.141 461.141 461.141 254.259 0 461.141-206.848 461.141-461.141 0-254.259-206.882-461.141-461.141-461.141zM1047.142 644.54c-25.429 60.109-61.85 114.108-108.203 160.461-46.353 46.353-100.352 82.773-160.495 108.203-62.259 26.317-128.375 39.697-196.54 39.697-68.164 0-134.281-13.346-196.54-39.697-60.075-25.429-114.074-61.815-160.461-108.203-46.353-46.353-82.773-100.352-108.203-160.461-26.317-62.259-39.663-128.375-39.663-196.54 0-68.164 13.346-134.281 39.697-196.54 25.429-60.109 61.85-114.108 108.203-160.495 46.353-46.353 100.352-82.773 160.495-108.203 62.259-26.351 128.375-39.697 196.54-39.697 68.164 0 134.281 13.346 196.54 39.697 60.109 25.429 114.108 61.815 160.495 108.203 46.353 46.353 82.773 100.352 108.203 160.495 26.317 62.259 39.663 128.375 39.663 196.54-0.068 68.164-13.414 134.281-39.731 196.54zM581.939-29.423c-263.27 0-477.423 214.187-477.423 477.423s214.153 477.423 477.423 477.423c263.236 0 477.423-214.153 477.423-477.423 0-263.236-214.187-477.423-477.423-477.423z" horiz-adv-x="1161" />
11
  </font></defs></svg>
assets/js/general.js CHANGED
@@ -1,40 +1,40 @@
1
- jQuery(document).ready(function ($) {
2
-
3
- backwpup_htmlspecialchars = function( string ) {
4
- return jQuery('<span>').text( string ).html()
5
- };
6
-
7
- $('.help-tip').backwpup_tipTip({
8
- 'attribute':'title',
9
- 'activation': 'hover'
10
- });
11
-
12
- /* change size of thickbox */
13
- backwpup_tb_position = function() {
14
- var tbWindow = $('#TB_window'), width = $(window).width(), height = $(window).height(), W = ( 720 < width ) ? 720 : width, H = ( 525 < height ) ? 525 : height, adminbar_height = 0;
15
-
16
- if ( $('body.admin-bar').length )
17
- adminbar_height = 28;
18
-
19
- if ( tbWindow.size() ) {
20
- tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
21
- $('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
22
- tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
23
- if ( typeof document.body.style.maxWidth != 'undefined' )
24
- tbWindow.css({'top': 20 + adminbar_height + 'px','margin-top':'0'});
25
- }
26
-
27
- return $('a.thickbox').each( function() {
28
- var href = $(this).attr('href');
29
- if ( ! href )
30
- return;
31
- href = href.replace(/&width=[0-9]+/g, '');
32
- href = href.replace(/&height=[0-9]+/g, '');
33
- $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 - adminbar_height ) );
34
- });
35
- };
36
-
37
- $(window).resize(function(){ backwpup_tb_position(); });
38
- backwpup_tb_position();
39
-
40
- });
1
+ jQuery(document).ready(function ($) {
2
+
3
+ backwpup_htmlspecialchars = function( string ) {
4
+ return jQuery('<span>').text( string ).html();
5
+ };
6
+
7
+ $('.help-tip').backwpup_tipTip({
8
+ 'attribute':'title',
9
+ 'activation': 'hover'
10
+ });
11
+
12
+ /* change size of thickbox */
13
+ backwpup_tb_position = function() {
14
+ var tbWindow = $('#TB_window'), width = $(window).width(), height = $(window).height(), W = ( 720 < width ) ? 720 : width, H = ( 525 < height ) ? 525 : height, adminbar_height = 0;
15
+
16
+ if ( $('body.admin-bar').length )
17
+ adminbar_height = 28;
18
+
19
+ if ( tbWindow.size() ) {
20
+ tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
21
+ $('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
22
+ tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
23
+ if ( typeof document.body.style.maxWidth != 'undefined' )
24
+ tbWindow.css({'top': 20 + adminbar_height + 'px','margin-top':'0'});
25
+ }
26
+
27
+ return $('a.thickbox').each( function() {
28
+ var href = $(this).attr('href');
29
+ if ( ! href )
30
+ return;
31
+ href = href.replace(/&width=[0-9]+/g, '');
32
+ href = href.replace(/&height=[0-9]+/g, '');
33
+ $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 - adminbar_height ) );
34
+ });
35
+ };
36
+
37
+ $(window).resize(function(){ backwpup_tb_position(); });
38
+ backwpup_tb_position();
39
+
40
+ });
assets/js/general.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(a){backwpup_htmlspecialchars=function(b){return jQuery("<span>").text(b).html()};a(".help-tip").backwpup_tipTip({attribute:"title",activation:"hover"});backwpup_tb_position=function(){var g=a("#TB_window"),f=a(window).width(),d=a(window).height(),c=(720<f)?720:f,e=(525<d)?525:d,b=0;if(a("body.admin-bar").length){b=28}if(g.size()){g.width(c-50).height(e-45-b);a("#TB_iframeContent").width(c-50).height(e-75-b);g.css({"margin-left":"-"+parseInt(((c-50)/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){g.css({top:20+b+"px","margin-top":"0"})}}return a("a.thickbox").each(function(){var h=a(this).attr("href");if(!h){return}h=h.replace(/&width=[0-9]+/g,"");h=h.replace(/&height=[0-9]+/g,"");a(this).attr("href",h+"&width="+(c-80)+"&height="+(e-85-b))})};a(window).resize(function(){backwpup_tb_position()});backwpup_tb_position()});
1
+ jQuery(document).ready(function(a){backwpup_htmlspecialchars=function(a){return jQuery("<span>").text(a).html()},a(".help-tip").backwpup_tipTip({attribute:"title",activation:"hover"}),backwpup_tb_position=function(){var b=a("#TB_window"),c=a(window).width(),d=a(window).height(),e=c>720?720:c,f=d>525?525:d,g=0;return a("body.admin-bar").length&&(g=28),b.size()&&(b.width(e-50).height(f-45-g),a("#TB_iframeContent").width(e-50).height(f-75-g),b.css({"margin-left":"-"+parseInt((e-50)/2,10)+"px"}),"undefined"!=typeof document.body.style.maxWidth&&b.css({top:20+g+"px","margin-top":"0"})),a("a.thickbox").each(function(){var b=a(this).attr("href");b&&(b=b.replace(/&width=[0-9]+/g,""),b=b.replace(/&height=[0-9]+/g,""),a(this).attr("href",b+"&width="+(e-80)+"&height="+(f-85-g)))})},a(window).resize(function(){backwpup_tb_position()}),backwpup_tb_position()});
assets/js/jquery.tipTip.js CHANGED
@@ -1,176 +1,175 @@
1
- /*
2
- * TipTip
3
- * Copyright 2010 Drew Wilson
4
- * www.drewwilson.com
5
- * code.drewwilson.com/entry/tiptip-jquery-plugin
6
- *
7
- * Version 1.3 - Updated: Mar. 23, 2010
8
- * Version 1.3.1 - Updated: Dez. 03, 2013 added backwpup_ prefix
9
- *
10
- * This Plug-In will create a custom tooltip to replace the default
11
- * browser tooltip. It is extremely lightweight and very smart in
12
- * that it detects the edges of the browser window and will make sure
13
- * the tooltip stays within the current window size. As a result the
14
- * tooltip will adjust itself to be displayed above, below, to the left
15
- * or to the right depending on what is necessary to stay within the
16
- * browser window. It is completely customizable as well via CSS.
17
- *
18
- * This TipTip jQuery plug-in is dual licensed under the MIT and GPL licenses:
19
- * http://www.opensource.org/licenses/mit-license.php
20
- * http://www.gnu.org/licenses/gpl.html
21
- */
22
- (function ($) {
23
- $.fn.backwpup_tipTip = function (options) {
24
- var defaults = {activation:"hover", keepAlive:false, maxWidth:"200px", edgeOffset:3, defaultPosition:"bottom", delay:400, fadeIn:200, fadeOut:200, attribute:"title", content:false, enter:function () {
25
- }, exit:function () {
26
- }};
27
- var opts = $.extend(defaults, options);
28
- if ($("#backwpup_tiptip_holder").length <= 0) {
29
- var tiptip_holder = $('<div id="backwpup_tiptip_holder" style="max-width:' + opts.maxWidth + ';"></div>');
30
- var tiptip_content = $('<div id="backwpup_tiptip_content"></div>');
31
- var tiptip_arrow = $('<div id="backwpup_tiptip_arrow"></div>');
32
- $("body").append(tiptip_holder.html(tiptip_content).prepend(tiptip_arrow.html('<div id="backwpup_tiptip_arrow_inner"></div>')))
33
- } else {
34
- var tiptip_holder = $("#backwpup_tiptip_holder");
35
- var tiptip_content = $("#backwpup_tiptip_content");
36
- var tiptip_arrow = $("#backwpup_tiptip_arrow")
37
- }
38
- return this.each(function () {
39
- var org_elem = $(this);
40
- if (opts.content) {
41
- var org_title = opts.content
42
- } else {
43
- var org_title = org_elem.attr(opts.attribute)
44
- }
45
- if (org_title != "") {
46
- if (!opts.content) {
47
- org_elem.removeAttr(opts.attribute)
48
- }
49
- var timeout = false;
50
- if (opts.activation == "hover") {
51
- org_elem.hover(function () {
52
- active_tiptip()
53
- }, function () {
54
- if (!opts.keepAlive) {
55
- deactive_tiptip()
56
- }
57
- });
58
- if (opts.keepAlive) {
59
- tiptip_holder.hover(function () {
60
- }, function () {
61
- deactive_tiptip()
62
- })
63
- }
64
- } else if (opts.activation == "focus") {
65
- org_elem.focus(function () {
66
- active_tiptip()
67
- }).blur(function () {
68
- deactive_tiptip()
69
- })
70
- } else if (opts.activation == "click") {
71
- org_elem.click(function () {
72
- active_tiptip();
73
- return false
74
- }).hover(function () {
75
- }, function () {
76
- if (!opts.keepAlive) {
77
- deactive_tiptip()
78
- }
79
- });
80
- if (opts.keepAlive) {
81
- tiptip_holder.hover(function () {
82
- }, function () {
83
- deactive_tiptip()
84
- })
85
- }
86
- }
87
- function active_tiptip() {
88
- opts.enter.call(this);
89
- tiptip_content.html(org_title);
90
- tiptip_holder.hide().removeAttr("class").css("margin", "0");
91
- tiptip_arrow.removeAttr("style");
92
- var top = parseInt(org_elem.offset()['top']);
93
- var left = parseInt(org_elem.offset()['left']);
94
- var org_width = parseInt(org_elem.outerWidth());
95
- var org_height = parseInt(org_elem.outerHeight());
96
- var tip_w = tiptip_holder.outerWidth();
97
- var tip_h = tiptip_holder.outerHeight();
98
- var w_compare = Math.round((org_width - tip_w) / 2);
99
- var h_compare = Math.round((org_height - tip_h) / 2);
100
- var marg_left = Math.round(left + w_compare);
101
- var marg_top = Math.round(top + org_height + opts.edgeOffset);
102
- var t_class = "";
103
- var arrow_top = "";
104
- var arrow_left = Math.round(tip_w - 12) / 2;
105
- if (opts.defaultPosition == "bottom") {
106
- t_class = "_bottom"
107
- } else if (opts.defaultPosition == "top") {
108
- t_class = "_top"
109
- } else if (opts.defaultPosition == "left") {
110
- t_class = "_left"
111
- } else if (opts.defaultPosition == "right") {
112
- t_class = "_right"
113
- }
114
- var right_compare = (w_compare + left) < parseInt($(window).scrollLeft());
115
- var left_compare = (tip_w + left) > parseInt($(window).width());
116
- if ((right_compare && w_compare < 0) || (t_class == "_right" && !left_compare) || (t_class == "_left" && left < (tip_w + opts.edgeOffset + 5))) {
117
- t_class = "_right";
118
- arrow_top = Math.round(tip_h - 13) / 2;
119
- arrow_left = -12;
120
- marg_left = Math.round(left + org_width + opts.edgeOffset);
121
- marg_top = Math.round(top + h_compare)
122
- } else if ((left_compare && w_compare < 0) || (t_class == "_left" && !right_compare)) {
123
- t_class = "_left";
124
- arrow_top = Math.round(tip_h - 13) / 2;
125
- arrow_left = Math.round(tip_w);
126
- marg_left = Math.round(left - (tip_w + opts.edgeOffset + 5));
127
- marg_top = Math.round(top + h_compare)
128
- }
129
- var top_compare = (top + org_height + opts.edgeOffset + tip_h + 8) > parseInt($(window).height() + $(window).scrollTop());
130
- var bottom_compare = ((top + org_height) - (opts.edgeOffset + tip_h + 8)) < 0;
131
- if (top_compare || (t_class == "_bottom" && top_compare) || (t_class == "_top" && !bottom_compare)) {
132
- if (t_class == "_top" || t_class == "_bottom") {
133
- t_class = "_top"
134
- } else {
135
- t_class = t_class + "_top"
136
- }
137
- arrow_top = tip_h;
138
- marg_top = Math.round(top - (tip_h + 5 + opts.edgeOffset))
139
- } else if (bottom_compare | (t_class == "_top" && bottom_compare) || (t_class == "_bottom" && !top_compare)) {
140
- if (t_class == "_top" || t_class == "_bottom") {
141
- t_class = "_bottom"
142
- } else {
143
- t_class = t_class + "_bottom"
144
- }
145
- arrow_top = -12;
146
- marg_top = Math.round(top + org_height + opts.edgeOffset)
147
- }
148
- if (t_class == "_right_top" || t_class == "_left_top") {
149
- marg_top = marg_top + 5
150
- } else if (t_class == "_right_bottom" || t_class == "_left_bottom") {
151
- marg_top = marg_top - 5
152
- }
153
- if (t_class == "_left_top" || t_class == "_left_bottom") {
154
- marg_left = marg_left + 5
155
- }
156
- tiptip_arrow.css({"margin-left":arrow_left + "px", "margin-top":arrow_top + "px"});
157
- tiptip_holder.css({"margin-left":marg_left + "px", "margin-top":marg_top + "px"}).attr("class", "tip" + t_class);
158
- if (timeout) {
159
- clearTimeout(timeout)
160
- }
161
- timeout = setTimeout(function () {
162
- tiptip_holder.stop(true, true).fadeIn(opts.fadeIn)
163
- }, opts.delay)
164
- }
165
-
166
- function deactive_tiptip() {
167
- opts.exit.call(this);
168
- if (timeout) {
169
- clearTimeout(timeout)
170
- }
171
- tiptip_holder.fadeOut(opts.fadeOut)
172
- }
173
- }
174
- })
175
- }
176
- })(jQuery);
1
+ /*
2
+ * TipTip
3
+ * Copyright 2010 Drew Wilson
4
+ * www.drewwilson.com
5
+ * code.drewwilson.com/entry/tiptip-jquery-plugin
6
+ *
7
+ * Version 1.3 - Updated: Mar. 23, 2010
8
+ * Version 1.3.1 - Updated: Dez. 03, 2013 added backwpup_ prefix
9
+ *
10
+ * This Plug-In will create a custom tooltip to replace the default
11
+ * browser tooltip. It is extremely lightweight and very smart in
12
+ * that it detects the edges of the browser window and will make sure
13
+ * the tooltip stays within the current window size. As a result the
14
+ * tooltip will adjust itself to be displayed above, below, to the left
15
+ * or to the right depending on what is necessary to stay within the
16
+ * browser window. It is completely customizable as well via CSS.
17
+ *
18
+ * This TipTip jQuery plug-in is dual licensed under the MIT and GPL licenses:
19
+ * http://www.opensource.org/licenses/mit-license.php
20
+ * http://www.gnu.org/licenses/gpl.html
21
+ */
22
+ (function ($) {
23
+ $.fn.backwpup_tipTip = function (options) {
24
+ var defaults = {activation:"hover", keepAlive:false, maxWidth:"200px", edgeOffset:3, defaultPosition:"bottom", delay:400, fadeIn:200, fadeOut:200, attribute:"title", content:false, enter:function () {
25
+ }, exit:function () {
26
+ }};
27
+ var opts = $.extend(defaults, options);
28
+ var tiptip_holder = $("#backwpup_tiptip_holder");
29
+ var tiptip_content = $("#backwpup_tiptip_content");
30
+ var tiptip_arrow = $("#backwpup_tiptip_arrow");
31
+ if ( tiptip_holder.length <= 0) {
32
+ tiptip_holder = $('<div id="backwpup_tiptip_holder" style="max-width:' + opts.maxWidth + ';"></div>');
33
+ tiptip_content = $('<div id="backwpup_tiptip_content"></div>');
34
+ tiptip_arrow = $('<div id="backwpup_tiptip_arrow"></div>');
35
+ $("body").append(tiptip_holder.html(tiptip_content).prepend(tiptip_arrow.html('<div id="backwpup_tiptip_arrow_inner"></div>')));
36
+ }
37
+ return this.each(function () {
38
+ var org_elem = $(this);
39
+ var org_title;
40
+ if (opts.content) {
41
+ org_title = opts.content;
42
+ } else {
43
+ org_title = org_elem.attr(opts.attribute);
44
+ }
45
+ if (org_title !== "") {
46
+ if (!opts.content) {
47
+ org_elem.removeAttr(opts.attribute);
48
+ }
49
+ var timeout = false;
50
+ if (opts.activation == "hover") {
51
+ org_elem.hover(function () {
52
+ active_tiptip();
53
+ }, function () {
54
+ if (!opts.keepAlive) {
55
+ deactive_tiptip();
56
+ }
57
+ });
58
+ if (opts.keepAlive) {
59
+ tiptip_holder.hover(function () {
60
+ }, function () {
61
+ deactive_tiptip();
62
+ });
63
+ }
64
+ } else if (opts.activation == "focus") {
65
+ org_elem.focus(function () {
66
+ active_tiptip();
67
+ }).blur(function () {
68
+ deactive_tiptip();
69
+ });
70
+ } else if (opts.activation == "click") {
71
+ org_elem.click(function () {
72
+ active_tiptip();
73
+ return false;
74
+ }).hover(function () {
75
+ }, function () {
76
+ if (!opts.keepAlive) {
77
+ deactive_tiptip();
78
+ }
79
+ });
80
+ if (opts.keepAlive) {
81
+ tiptip_holder.hover(function () {
82
+ }, function () {
83
+ deactive_tiptip();
84
+ });
85
+ }
86
+ }
87
+ }
88
+ function active_tiptip() {
89
+ opts.enter.call(this);
90
+ tiptip_content.html(org_title);
91
+ tiptip_holder.hide().removeAttr("class").css("margin", "0");
92
+ tiptip_arrow.removeAttr("style");
93
+ var top = parseInt(org_elem.offset().top);
94
+ var left = parseInt(org_elem.offset().left);
95
+ var org_width = parseInt(org_elem.outerWidth());
96
+ var org_height = parseInt(org_elem.outerHeight());
97
+ var tip_w = tiptip_holder.outerWidth();
98
+ var tip_h = tiptip_holder.outerHeight();
99
+ var w_compare = Math.round((org_width - tip_w) / 2);
100
+ var h_compare = Math.round((org_height - tip_h) / 2);
101
+ var marg_left = Math.round(left + w_compare);
102
+ var marg_top = Math.round(top + org_height + opts.edgeOffset);
103
+ var t_class = "";
104
+ var arrow_top = "";
105
+ var arrow_left = Math.round(tip_w - 12) / 2;
106
+ if (opts.defaultPosition == "bottom") {
107
+ t_class = "_bottom";
108
+ } else if (opts.defaultPosition == "top") {
109
+ t_class = "_top";
110
+ } else if (opts.defaultPosition == "left") {
111
+ t_class = "_left";
112
+ } else if (opts.defaultPosition == "right") {
113
+ t_class = "_right";
114
+ }
115
+ var right_compare = (w_compare + left) < parseInt($(window).scrollLeft());
116
+ var left_compare = (tip_w + left) > parseInt($(window).width());
117
+ if ((right_compare && w_compare < 0) || (t_class == "_right" && !left_compare) || (t_class == "_left" && left < (tip_w + opts.edgeOffset + 5))) {
118
+ t_class = "_right";
119
+ arrow_top = Math.round(tip_h - 13) / 2;
120
+ arrow_left = -12;
121
+ marg_left = Math.round(left + org_width + opts.edgeOffset);
122
+ marg_top = Math.round(top + h_compare);
123
+ } else if ((left_compare && w_compare < 0) || (t_class == "_left" && !right_compare)) {
124
+ t_class = "_left";
125
+ arrow_top = Math.round(tip_h - 13) / 2;
126
+ arrow_left = Math.round(tip_w);
127
+ marg_left = Math.round(left - (tip_w + opts.edgeOffset + 5));
128
+ marg_top = Math.round(top + h_compare);
129
+ }
130
+ var top_compare = (top + org_height + opts.edgeOffset + tip_h + 8) > parseInt($(window).height() + $(window).scrollTop());
131
+ var bottom_compare = ((top + org_height) - (opts.edgeOffset + tip_h + 8)) < 0;
132
+ if (top_compare || (t_class == "_bottom" && top_compare) || (t_class == "_top" && !bottom_compare)) {
133
+ if (t_class == "_top" || t_class == "_bottom") {
134
+ t_class = "_top";
135
+ } else {
136
+ t_class = t_class + "_top";
137
+ }
138
+ arrow_top = tip_h;
139
+ marg_top = Math.round(top - (tip_h + 5 + opts.edgeOffset));
140
+ } else if (bottom_compare | (t_class == "_top" && bottom_compare) || (t_class == "_bottom" && !top_compare)) {
141
+ if (t_class == "_top" || t_class == "_bottom") {
142
+ t_class = "_bottom";
143
+ } else {
144
+ t_class = t_class + "_bottom";
145
+ }
146
+ arrow_top = -12;
147
+ marg_top = Math.round(top + org_height + opts.edgeOffset);
148
+ }
149
+ if (t_class == "_right_top" || t_class == "_left_top") {
150
+ marg_top = marg_top + 5;
151
+ } else if (t_class == "_right_bottom" || t_class == "_left_bottom") {
152
+ marg_top = marg_top - 5;
153
+ }
154
+ if (t_class == "_left_top" || t_class == "_left_bottom") {
155
+ marg_left = marg_left + 5; }
156
+ tiptip_arrow.css({"margin-left":arrow_left + "px", "margin-top":arrow_top + "px"});
157
+ tiptip_holder.css({"margin-left":marg_left + "px", "margin-top":marg_top + "px"}).attr("class", "tip" + t_class);
158
+ if (timeout) {
159
+ clearTimeout(timeout);
160
+ }
161
+ timeout = setTimeout(function () {
162
+ tiptip_holder.stop(true, true).fadeIn(opts.fadeIn);
163
+ }, opts.delay);
164
+ }
165
+
166
+ function deactive_tiptip() {
167
+ opts.exit.call(this);
168
+ if (timeout) {
169
+ clearTimeout(timeout);
170
+ }
171
+ tiptip_holder.fadeOut(opts.fadeOut);
172
+ }
173
+ });
174
+ };
175
+ })(jQuery);
 
assets/js/jquery.tipTip.min.js CHANGED
@@ -1 +1 @@
1
- (function(a){a.fn.backwpup_tipTip=function(c){var g={activation:"hover",keepAlive:false,maxWidth:"200px",edgeOffset:3,defaultPosition:"bottom",delay:400,fadeIn:200,fadeOut:200,attribute:"title",content:false,enter:function(){},exit:function(){}};var e=a.extend(g,c);if(a("#backwpup_tiptip_holder").length<=0){var b=a('<div id="backwpup_tiptip_holder" style="max-width:'+e.maxWidth+';"></div>');var d=a('<div id="backwpup_tiptip_content"></div>');var f=a('<div id="backwpup_tiptip_arrow"></div>');a("body").append(b.html(d).prepend(f.html('<div id="backwpup_tiptip_arrow_inner"></div>')))}else{var b=a("#backwpup_tiptip_holder");var d=a("#backwpup_tiptip_content");var f=a("#backwpup_tiptip_arrow")}return this.each(function(){var i=a(this);if(e.content){var l=e.content}else{var l=i.attr(e.attribute)}if(l!=""){if(!e.content){i.removeAttr(e.attribute)}var h=false;if(e.activation=="hover"){i.hover(function(){k()},function(){if(!e.keepAlive){j()}});if(e.keepAlive){b.hover(function(){},function(){j()})}}else{if(e.activation=="focus"){i.focus(function(){k()}).blur(function(){j()})}else{if(e.activation=="click"){i.click(function(){k();return false}).hover(function(){},function(){if(!e.keepAlive){j()}});if(e.keepAlive){b.hover(function(){},function(){j()})}}}}function k(){e.enter.call(this);d.html(l);b.hide().removeAttr("class").css("margin","0");f.removeAttr("style");var y=parseInt(i.offset()["top"]);var p=parseInt(i.offset()["left"]);var v=parseInt(i.outerWidth());var A=parseInt(i.outerHeight());var x=b.outerWidth();var s=b.outerHeight();var w=Math.round((v-x)/2);var o=Math.round((A-s)/2);var n=Math.round(p+w);var m=Math.round(y+A+e.edgeOffset);var t="";var C="";var u=Math.round(x-12)/2;if(e.defaultPosition=="bottom"){t="_bottom"}else{if(e.defaultPosition=="top"){t="_top"}else{if(e.defaultPosition=="left"){t="_left"}else{if(e.defaultPosition=="right"){t="_right"}}}}var r=(w+p)<parseInt(a(window).scrollLeft());var q=(x+p)>parseInt(a(window).width());if((r&&w<0)||(t=="_right"&&!q)||(t=="_left"&&p<(x+e.edgeOffset+5))){t="_right";C=Math.round(s-13)/2;u=-12;n=Math.round(p+v+e.edgeOffset);m=Math.round(y+o)}else{if((q&&w<0)||(t=="_left"&&!r)){t="_left";C=Math.round(s-13)/2;u=Math.round(x);n=Math.round(p-(x+e.edgeOffset+5));m=Math.round(y+o)}}var z=(y+A+e.edgeOffset+s+8)>parseInt(a(window).height()+a(window).scrollTop());var B=((y+A)-(e.edgeOffset+s+8))<0;if(z||(t=="_bottom"&&z)||(t=="_top"&&!B)){if(t=="_top"||t=="_bottom"){t="_top"}else{t=t+"_top"}C=s;m=Math.round(y-(s+5+e.edgeOffset))}else{if(B|(t=="_top"&&B)||(t=="_bottom"&&!z)){if(t=="_top"||t=="_bottom"){t="_bottom"}else{t=t+"_bottom"}C=-12;m=Math.round(y+A+e.edgeOffset)}}if(t=="_right_top"||t=="_left_top"){m=m+5}else{if(t=="_right_bottom"||t=="_left_bottom"){m=m-5}}if(t=="_left_top"||t=="_left_bottom"){n=n+5}f.css({"margin-left":u+"px","margin-top":C+"px"});b.css({"margin-left":n+"px","margin-top":m+"px"}).attr("class","tip"+t);if(h){clearTimeout(h)}h=setTimeout(function(){b.stop(true,true).fadeIn(e.fadeIn)},e.delay)}function j(){e.exit.call(this);if(h){clearTimeout(h)}b.fadeOut(e.fadeOut)}}})}})(jQuery);
1
+ !function(a){a.fn.backwpup_tipTip=function(b){var c={activation:"hover",keepAlive:!1,maxWidth:"200px",edgeOffset:3,defaultPosition:"bottom",delay:400,fadeIn:200,fadeOut:200,attribute:"title",content:!1,enter:function(){},exit:function(){}},d=a.extend(c,b),e=a("#backwpup_tiptip_holder"),f=a("#backwpup_tiptip_content"),g=a("#backwpup_tiptip_arrow");return e.length<=0&&(e=a('<div id="backwpup_tiptip_holder" style="max-width:'+d.maxWidth+';"></div>'),f=a('<div id="backwpup_tiptip_content"></div>'),g=a('<div id="backwpup_tiptip_arrow"></div>'),a("body").append(e.html(f).prepend(g.html('<div id="backwpup_tiptip_arrow_inner"></div>')))),this.each(function(){function b(){d.enter.call(this),f.html(h),e.hide().removeAttr("class").css("margin","0"),g.removeAttr("style");var b=parseInt(i.offset().top),c=parseInt(i.offset().left),k=parseInt(i.outerWidth()),l=parseInt(i.outerHeight()),m=e.outerWidth(),n=e.outerHeight(),o=Math.round((k-m)/2),p=Math.round((l-n)/2),q=Math.round(c+o),r=Math.round(b+l+d.edgeOffset),s="",t="",u=Math.round(m-12)/2;"bottom"==d.defaultPosition?s="_bottom":"top"==d.defaultPosition?s="_top":"left"==d.defaultPosition?s="_left":"right"==d.defaultPosition&&(s="_right");var v=o+c<parseInt(a(window).scrollLeft()),w=m+c>parseInt(a(window).width());v&&0>o||"_right"==s&&!w||"_left"==s&&c<m+d.edgeOffset+5?(s="_right",t=Math.round(n-13)/2,u=-12,q=Math.round(c+k+d.edgeOffset),r=Math.round(b+p)):(w&&0>o||"_left"==s&&!v)&&(s="_left",t=Math.round(n-13)/2,u=Math.round(m),q=Math.round(c-(m+d.edgeOffset+5)),r=Math.round(b+p));var x=b+l+d.edgeOffset+n+8>parseInt(a(window).height()+a(window).scrollTop()),y=b+l-(d.edgeOffset+n+8)<0;x||"_bottom"==s&&x||"_top"==s&&!y?("_top"==s||"_bottom"==s?s="_top":s+="_top",t=n,r=Math.round(b-(n+5+d.edgeOffset))):(y|("_top"==s&&y)||"_bottom"==s&&!x)&&("_top"==s||"_bottom"==s?s="_bottom":s+="_bottom",t=-12,r=Math.round(b+l+d.edgeOffset)),"_right_top"==s||"_left_top"==s?r+=5:("_right_bottom"==s||"_left_bottom"==s)&&(r-=5),("_left_top"==s||"_left_bottom"==s)&&(q+=5),g.css({"margin-left":u+"px","margin-top":t+"px"}),e.css({"margin-left":q+"px","margin-top":r+"px"}).attr("class","tip"+s),j&&clearTimeout(j),j=setTimeout(function(){e.stop(!0,!0).fadeIn(d.fadeIn)},d.delay)}function c(){d.exit.call(this),j&&clearTimeout(j),e.fadeOut(d.fadeOut)}var h,i=a(this);if(h=d.content?d.content:i.attr(d.attribute),""!==h){d.content||i.removeAttr(d.attribute);var j=!1;"hover"==d.activation?(i.hover(function(){b()},function(){d.keepAlive||c()}),d.keepAlive&&e.hover(function(){},function(){c()})):"focus"==d.activation?i.focus(function(){b()}).blur(function(){c()}):"click"==d.activation&&(i.click(function(){return b(),!1}).hover(function(){},function(){d.keepAlive||c()}),d.keepAlive&&e.hover(function(){},function(){c()}))}})}}(jQuery);
assets/js/page_edit_jobtype_dbdump.js CHANGED
@@ -1,77 +1,97 @@
1
- jQuery(document).ready(function ($) {
2
-
3
- $('#dball').click(function () {
4
- $('input[name="tabledb[]"]').prop("checked", true).change();;
5
- });
6
-
7
- $('#dbnone').click(function () {
8
- $('input[name="tabledb[]"]').prop("checked", false).change();;
9
- });
10
-
11
- $('#dbwp').click(function () {
12
- $('input[name="tabledb[]"]').prop("checked", false).change();;
13
- $('input[name="tabledb[]"][value^="' + $('#dbwp').val() + '"]').prop("checked", true).change();;
14
- });
15
-
16
- $('input[name="dbdumpwpdbsettings"]').change(function () {
17
- if ( $('input[name="dbdumpwpdbsettings"]').prop("checked") ) {
18
- $('#dbconnection').hide();
19
- } else {
20
- $('#dbconnection').show();
21
- }
22
- });
23
-
24
- function db_tables() {
25
- var data = {
26
- action:'backwpup_jobtype_dbdump',
27
- action2:'tables',
28
- dbname:$('#dbdumpdbname').val(),
29
- dbhost:$('#dbdumpdbhost').val(),
30
- dbuser:$('#dbdumpdbuser').val(),
31
- dbpassword:$('#dbdumpdbpassword').val(),
32
- wpdbsettings:$('#dbdumpwpdbsettings:checked').val(),
33
- jobid:$('#jobid').val(),
34
- _ajax_nonce:$('#backwpupajaxnonce').val()
35
- };
36
- $.post(ajaxurl, data, function (response) {
37
- $('#dbtables').replaceWith(response);
38
- });
39
- }
40
- $('#dbdumpdbname').change(function () {
41
- db_tables();
42
- });
43
- $('#dbdumpwpdbsettings').change(function () {
44
- db_tables();
45
- db_databases();
46
- });
47
-
48
- function db_databases() {
49
- var data = {
50
- action:'backwpup_jobtype_dbdump',
51
- action2:'databases',
52
- dbhost:$('#dbdumpdbhost').val(),
53
- dbuser:$('#dbdumpdbuser').val(),
54
- dbpassword:$('#dbdumpdbpassword').val(),
55
- dbname:$('input[name="dbselected"]').val(),
56
- wpdbsettings:$('#dbdumpwpdbsettings:checked').val(),
57
- _ajax_nonce:$('#backwpupajaxnonce').val()
58
-
59
- };
60
- $.post(ajaxurl, data, function (response) {
61
- $('#dbdumpdbname').replaceWith(response);
62
- db_tables();
63
- $('#dbdumpdbname').change(function () {
64
- db_tables();
65
- });
66
- });
67
- }
68
- $('#dbdumpdbhost').change(function () {
69
- db_databases();
70
- });
71
- $('#dbdumpdbuser').change(function () {
72
- db_databases();
73
- });
74
- $('#dbdumpdbpassword').change(function () {
75
- db_databases();
76
- });
77
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function ($) {
2
+
3
+ $('#dball').click(function () {
4
+ $('input[name="tabledb[]"]').prop("checked", true).change();
5
+ });
6
+
7
+ $('#dbnone').click(function () {
8
+ $('input[name="tabledb[]"]').prop("checked", false).change();
9
+ });
10
+
11
+ $('#dbwp').click(function () {
12
+ $('input[name="tabledb[]"]').prop("checked", false).change();
13
+ $('input[name="tabledb[]"][value^="' + $('#dbwp').val() + '"]').prop("checked", true).change();
14
+ });
15
+
16
+ var dbdumpwpdbsettings = $('input[name="dbdumpwpdbsettings"]');
17
+ if ( dbdumpwpdbsettings.length > 0 ) {
18
+ dbdumpwpdbsettings.change(function () {
19
+ if ( dbdumpwpdbsettings.prop("checked") ) {
20
+ $('#dbconnection').hide();
21
+ } else {
22
+ $('#dbconnection').show();
23
+ }
24
+ });
25
+ }
26
+
27
+ var trdbdumpmysqlfolder = $('#trdbdumpmysqlfolder');
28
+ if ( trdbdumpmysqlfolder.length > 0 ) {
29
+ $('input[name="dbdumptype"]').change(function () {
30
+ if ( $('#iddbdumptype-syssql').prop("checked") ) {
31
+ trdbdumpmysqlfolder.show();
32
+ } else {
33
+ trdbdumpmysqlfolder.hide();
34
+ }
35
+ });
36
+
37
+ if ( $('#iddbdumptype-syssql').prop("checked") ) {
38
+ trdbdumpmysqlfolder.show();
39
+ } else {
40
+ trdbdumpmysqlfolder.hide();
41
+ }
42
+ }
43
+
44
+ function db_tables() {
45
+ var data = {
46
+ action:'backwpup_jobtype_dbdump',
47
+ action2:'tables',
48
+ dbname:$('#dbdumpdbname').val(),
49
+ dbhost:$('#dbdumpdbhost').val(),
50
+ dbuser:$('#dbdumpdbuser').val(),
51
+ dbpassword:$('#dbdumpdbpassword').val(),
52
+ wpdbsettings:$('#dbdumpwpdbsettings:checked').val(),
53
+ jobid:$('#jobid').val(),
54
+ _ajax_nonce:$('#backwpupajaxnonce').val()
55
+ };
56
+ $.post(ajaxurl, data, function (response) {
57
+ $('#dbtables').replaceWith(response);
58
+ });
59
+ }
60
+ $('#dbdumpdbname').change(function () {
61
+ db_tables();
62
+ });
63
+ $('#dbdumpwpdbsettings').change(function () {
64
+ db_tables();
65
+ db_databases();
66
+ });
67
+
68
+ function db_databases() {
69
+ var data = {
70
+ action:'backwpup_jobtype_dbdump',
71
+ action2:'databases',
72
+ dbhost:$('#dbdumpdbhost').val(),
73
+ dbuser:$('#dbdumpdbuser').val(),
74
+ dbpassword:$('#dbdumpdbpassword').val(),
75
+ dbname:$('input[name="dbselected"]').val(),
76
+ wpdbsettings:$('#dbdumpwpdbsettings:checked').val(),
77
+ _ajax_nonce:$('#backwpupajaxnonce').val()
78
+
79
+ };
80
+ $.post(ajaxurl, data, function (response) {
81
+ $('#dbdumpdbname').replaceWith(response);
82
+ db_tables();
83
+ $('#dbdumpdbname').change(function () {
84
+ db_tables();
85
+ });
86
+ });
87
+ }
88
+ $('#dbdumpdbhost').change(function () {
89
+ db_databases();
90
+ });
91
+ $('#dbdumpdbuser').change(function () {
92
+ db_databases();
93
+ });
94
+ $('#dbdumpdbpassword').change(function () {
95
+ db_databases();
96
+ });
97
+ });
assets/js/page_edit_jobtype_dbdump.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(b){b("#dball").click(function(){b('input[name="tabledb[]"]').prop("checked",true).change()});b("#dbnone").click(function(){b('input[name="tabledb[]"]').prop("checked",false).change()});b("#dbwp").click(function(){b('input[name="tabledb[]"]').prop("checked",false).change();b('input[name="tabledb[]"][value^="'+b("#dbwp").val()+'"]').prop("checked",true).change()});b('input[name="dbdumpwpdbsettings"]').change(function(){if(b('input[name="dbdumpwpdbsettings"]').prop("checked")){b("#dbconnection").hide()}else{b("#dbconnection").show()}});function a(){var d={action:"backwpup_jobtype_dbdump",action2:"tables",dbname:b("#dbdumpdbname").val(),dbhost:b("#dbdumpdbhost").val(),dbuser:b("#dbdumpdbuser").val(),dbpassword:b("#dbdumpdbpassword").val(),wpdbsettings:b("#dbdumpwpdbsettings:checked").val(),jobid:b("#jobid").val(),_ajax_nonce:b("#backwpupajaxnonce").val()};b.post(ajaxurl,d,function(e){b("#dbtables").replaceWith(e)})}b("#dbdumpdbname").change(function(){a()});b("#dbdumpwpdbsettings").change(function(){a();c()});function c(){var d={action:"backwpup_jobtype_dbdump",action2:"databases",dbhost:b("#dbdumpdbhost").val(),dbuser:b("#dbdumpdbuser").val(),dbpassword:b("#dbdumpdbpassword").val(),dbname:b('input[name="dbselected"]').val(),wpdbsettings:b("#dbdumpwpdbsettings:checked").val(),_ajax_nonce:b("#backwpupajaxnonce").val()};b.post(ajaxurl,d,function(e){b("#dbdumpdbname").replaceWith(e);a();b("#dbdumpdbname").change(function(){a()})})}b("#dbdumpdbhost").change(function(){c()});b("#dbdumpdbuser").change(function(){c()});b("#dbdumpdbpassword").change(function(){c()})});
1
+ jQuery(document).ready(function(a){function b(){var b={action:"backwpup_jobtype_dbdump",action2:"tables",dbname:a("#dbdumpdbname").val(),dbhost:a("#dbdumpdbhost").val(),dbuser:a("#dbdumpdbuser").val(),dbpassword:a("#dbdumpdbpassword").val(),wpdbsettings:a("#dbdumpwpdbsettings:checked").val(),jobid:a("#jobid").val(),_ajax_nonce:a("#backwpupajaxnonce").val()};a.post(ajaxurl,b,function(b){a("#dbtables").replaceWith(b)})}function c(){var c={action:"backwpup_jobtype_dbdump",action2:"databases",dbhost:a("#dbdumpdbhost").val(),dbuser:a("#dbdumpdbuser").val(),dbpassword:a("#dbdumpdbpassword").val(),dbname:a('input[name="dbselected"]').val(),wpdbsettings:a("#dbdumpwpdbsettings:checked").val(),_ajax_nonce:a("#backwpupajaxnonce").val()};a.post(ajaxurl,c,function(c){a("#dbdumpdbname").replaceWith(c),b(),a("#dbdumpdbname").change(function(){b()})})}a("#dball").click(function(){a('input[name="tabledb[]"]').prop("checked",!0).change()}),a("#dbnone").click(function(){a('input[name="tabledb[]"]').prop("checked",!1).change()}),a("#dbwp").click(function(){a('input[name="tabledb[]"]').prop("checked",!1).change(),a('input[name="tabledb[]"][value^="'+a("#dbwp").val()+'"]').prop("checked",!0).change()});var d=a('input[name="dbdumpwpdbsettings"]');d.length>0&&d.change(function(){d.prop("checked")?a("#dbconnection").hide():a("#dbconnection").show()});var e=a("#trdbdumpmysqlfolder");e.length>0&&(a('input[name="dbdumptype"]').change(function(){a("#iddbdumptype-syssql").prop("checked")?e.show():e.hide()}),a("#iddbdumptype-syssql").prop("checked")?e.show():e.hide()),a("#dbdumpdbname").change(function(){b()}),a("#dbdumpwpdbsettings").change(function(){b(),c()}),a("#dbdumpdbhost").change(function(){c()}),a("#dbdumpdbuser").change(function(){c()}),a("#dbdumpdbpassword").change(function(){c()})});
assets/js/page_edit_jobtype_file.js CHANGED
@@ -1,73 +1,73 @@
1
- jQuery(document).ready(function ($) {
2
-
3
- $('input[name="backuproot"]').change(function () {
4
- if ($('input[name="backuproot"]').prop("checked")) {
5
- $('#backuprootexcludedirs').show();
6
- } else {
7
- $('#backuprootexcludedirs').hide();
8
- }
9
- });
10
-
11
- if ($('input[name="backuproot"]').prop("checked")) {
12
- $('#backuprootexcludedirs').show();
13
- } else {
14
- $('#backuprootexcludedirs').hide();
15
- }
16
-
17
- $('input[name="backupcontent"]').change(function () {
18
- if ($('input[name="backupcontent"]').prop("checked")) {
19
- $('#backupcontentexcludedirs').show();
20
- } else {
21
- $('#backupcontentexcludedirs').hide();
22
- }
23
- });
24
-
25
- if ($('input[name="backupcontent"]').prop("checked")) {
26
- $('#backupcontentexcludedirs').show();
27
- } else {
28
- $('#backupcontentexcludedirs').hide();
29
- }
30
-
31
- $('input[name="backupplugins"]').change(function () {
32
- if ($('input[name="backupplugins"]').prop("checked")) {
33
- $('#backuppluginsexcludedirs').show();
34
- } else {
35
- $('#backuppluginsexcludedirs').hide();
36
- }
37
- });
38
-
39
- if ($('input[name="backupplugins"]').prop("checked")) {
40
- $('#backuppluginsexcludedirs').show();
41
- } else {
42
- $('#backuppluginsexcludedirs').hide();
43
- }
44
-
45
- $('input[name="backupthemes"]').change(function () {
46
- if ($('input[name="backupthemes"]').prop("checked")) {
47
- $('#backupthemesexcludedirs').show();
48
- } else {
49
- $('#backupthemesexcludedirs').hide();
50
- }
51
- });
52
-
53
- if ($('input[name="backupthemes"]').prop("checked")) {
54
- $('#backupthemesexcludedirs').show();
55
- } else {
56
- $('#backupthemesexcludedirs').hide();
57
- }
58
-
59
- $('input[name="backupuploads"]').change(function () {
60
- if ($('input[name="backupuploads"]').prop("checked")) {
61
- $('#backupuploadsexcludedirs').show();
62
- } else {
63
- $('#backupuploadsexcludedirs').hide();
64
- }
65
- });
66
-
67
- if ($('input[name="backupuploads"]').prop("checked")) {
68
- $('#backupuploadsexcludedirs').show();
69
- } else {
70
- $('#backupuploadsexcludedirs').hide();
71
- }
72
-
73
  });
1
+ jQuery(document).ready(function ($) {
2
+
3
+ $('input[name="backuproot"]').change(function () {
4
+ if ($('input[name="backuproot"]').prop("checked")) {
5
+ $('#backuprootexcludedirs').show();
6
+ } else {
7
+ $('#backuprootexcludedirs').hide();
8
+ }
9
+ });
10
+
11
+ if ($('input[name="backuproot"]').prop("checked")) {
12
+ $('#backuprootexcludedirs').show();
13
+ } else {
14
+ $('#backuprootexcludedirs').hide();
15
+ }
16
+
17
+ $('input[name="backupcontent"]').change(function () {
18
+ if ($('input[name="backupcontent"]').prop("checked")) {
19
+ $('#backupcontentexcludedirs').show();
20
+ } else {
21
+ $('#backupcontentexcludedirs').hide();
22
+ }
23
+ });
24
+
25
+ if ($('input[name="backupcontent"]').prop("checked")) {
26
+ $('#backupcontentexcludedirs').show();
27
+ } else {
28
+ $('#backupcontentexcludedirs').hide();
29
+ }
30
+
31
+ $('input[name="backupplugins"]').change(function () {
32
+ if ($('input[name="backupplugins"]').prop("checked")) {
33
+ $('#backuppluginsexcludedirs').show();
34
+ } else {
35
+ $('#backuppluginsexcludedirs').hide();
36
+ }
37
+ });
38
+
39
+ if ($('input[name="backupplugins"]').prop("checked")) {
40
+ $('#backuppluginsexcludedirs').show();
41
+ } else {
42
+ $('#backuppluginsexcludedirs').hide();
43
+ }
44
+
45
+ $('input[name="backupthemes"]').change(function () {
46
+ if ($('input[name="backupthemes"]').prop("checked")) {
47
+ $('#backupthemesexcludedirs').show();
48
+ } else {
49
+ $('#backupthemesexcludedirs').hide();
50
+ }
51
+ });
52
+
53
+ if ($('input[name="backupthemes"]').prop("checked")) {
54
+ $('#backupthemesexcludedirs').show();
55
+ } else {
56
+ $('#backupthemesexcludedirs').hide();
57
+ }
58
+
59
+ $('input[name="backupuploads"]').change(function () {
60
+ if ($('input[name="backupuploads"]').prop("checked")) {
61
+ $('#backupuploadsexcludedirs').show();
62
+ } else {
63
+ $('#backupuploadsexcludedirs').hide();
64
+ }
65
+ });
66
+
67
+ if ($('input[name="backupuploads"]').prop("checked")) {
68
+ $('#backupuploadsexcludedirs').show();
69
+ } else {
70
+ $('#backupuploadsexcludedirs').hide();
71
+ }
72
+
73
  });
assets/js/page_edit_jobtype_file.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(a){a('input[name="backuproot"]').change(function(){if(a('input[name="backuproot"]').prop("checked")){a("#backuprootexcludedirs").show()}else{a("#backuprootexcludedirs").hide()}});if(a('input[name="backuproot"]').prop("checked")){a("#backuprootexcludedirs").show()}else{a("#backuprootexcludedirs").hide()}a('input[name="backupcontent"]').change(function(){if(a('input[name="backupcontent"]').prop("checked")){a("#backupcontentexcludedirs").show()}else{a("#backupcontentexcludedirs").hide()}});if(a('input[name="backupcontent"]').prop("checked")){a("#backupcontentexcludedirs").show()}else{a("#backupcontentexcludedirs").hide()}a('input[name="backupplugins"]').change(function(){if(a('input[name="backupplugins"]').prop("checked")){a("#backuppluginsexcludedirs").show()}else{a("#backuppluginsexcludedirs").hide()}});if(a('input[name="backupplugins"]').prop("checked")){a("#backuppluginsexcludedirs").show()}else{a("#backuppluginsexcludedirs").hide()}a('input[name="backupthemes"]').change(function(){if(a('input[name="backupthemes"]').prop("checked")){a("#backupthemesexcludedirs").show()}else{a("#backupthemesexcludedirs").hide()}});if(a('input[name="backupthemes"]').prop("checked")){a("#backupthemesexcludedirs").show()}else{a("#backupthemesexcludedirs").hide()}a('input[name="backupuploads"]').change(function(){if(a('input[name="backupuploads"]').prop("checked")){a("#backupuploadsexcludedirs").show()}else{a("#backupuploadsexcludedirs").hide()}});if(a('input[name="backupuploads"]').prop("checked")){a("#backupuploadsexcludedirs").show()}else{a("#backupuploadsexcludedirs").hide()}});
1
+ jQuery(document).ready(function(a){a('input[name="backuproot"]').change(function(){a('input[name="backuproot"]').prop("checked")?a("#backuprootexcludedirs").show():a("#backuprootexcludedirs").hide()}),a('input[name="backuproot"]').prop("checked")?a("#backuprootexcludedirs").show():a("#backuprootexcludedirs").hide(),a('input[name="backupcontent"]').change(function(){a('input[name="backupcontent"]').prop("checked")?a("#backupcontentexcludedirs").show():a("#backupcontentexcludedirs").hide()}),a('input[name="backupcontent"]').prop("checked")?a("#backupcontentexcludedirs").show():a("#backupcontentexcludedirs").hide(),a('input[name="backupplugins"]').change(function(){a('input[name="backupplugins"]').prop("checked")?a("#backuppluginsexcludedirs").show():a("#backuppluginsexcludedirs").hide()}),a('input[name="backupplugins"]').prop("checked")?a("#backuppluginsexcludedirs").show():a("#backuppluginsexcludedirs").hide(),a('input[name="backupthemes"]').change(function(){a('input[name="backupthemes"]').prop("checked")?a("#backupthemesexcludedirs").show():a("#backupthemesexcludedirs").hide()}),a('input[name="backupthemes"]').prop("checked")?a("#backupthemesexcludedirs").show():a("#backupthemesexcludedirs").hide(),a('input[name="backupuploads"]').change(function(){a('input[name="backupuploads"]').prop("checked")?a("#backupuploadsexcludedirs").show():a("#backupuploadsexcludedirs").hide()}),a('input[name="backupuploads"]').prop("checked")?a("#backupuploadsexcludedirs").show():a("#backupuploadsexcludedirs").hide()});
assets/js/page_edit_tab_cron.js CHANGED
@@ -1,157 +1,157 @@
1
- jQuery(document).ready(function ($) {
2
- $('input[name="activetype"]').change(function () {
3
- if ($(this).val() == 'wpcron') {
4
- $('.wpcron').show();
5
- } else {
6
- $('.wpcron').hide();
7
- }
8
- });
9
-
10
- if ($('input[name="activetype"]:checked').val() == 'wpcron') {
11
- $('.wpcron').show();
12
- } else {
13
- $('.wpcron').hide();
14
- }
15
-
16
- $('input[name="cronselect"]').change(function () {
17
- if ('basic' == $('input[name="cronselect"]:checked').val()) {
18
- $('.wpcronadvanced').hide();
19
- $('.wpcronbasic').show();
20
- cronstampbasic();
21
- } else {
22
- $('.wpcronadvanced').show();
23
- $('.wpcronbasic').hide();
24
- cronstampadvanced();
25
- }
26
- });
27
-
28
- function cronstampadvanced() {
29
- var cronminutes = [];
30
- var cronhours = [];
31
- var cronmday = [];
32
- var cronmon = [];
33
- var cronwday = [];
34
- $('input[name="cronminutes[]"]:checked').each(function () {
35
- cronminutes.push($(this).val());
36
- });
37
- $('input[name="cronhours[]"]:checked').each(function () {
38
- cronhours.push($(this).val());
39
- });
40
- $('input[name="cronmday[]"]:checked').each(function () {
41
- cronmday.push($(this).val());
42
- });
43
- $('input[name="cronmon[]"]:checked').each(function () {
44
- cronmon.push($(this).val());
45
- });
46
- $('input[name="cronwday[]"]:checked').each(function () {
47
- cronwday.push($(this).val());
48
- });
49
- var data = {
50
- action:'backwpup_cron_text',
51
- cronminutes:cronminutes,
52
- cronhours:cronhours,
53
- cronmday:cronmday,
54
- cronmon:cronmon,
55
- cronwday:cronwday,
56
- crontype:'advanced',
57
- _ajax_nonce:$('#backwpupajaxnonce').val()
58
- };
59
- $.post(ajaxurl, data, function (response) {
60
- $('#schedulecron').replaceWith(response);
61
- });
62
- }
63
- $('input[name="cronminutes[]"]').change(function () {
64
- cronstampadvanced();
65
- });
66
- $('input[name="cronhours[]"]').change(function () {
67
- cronstampadvanced();
68
- });
69
- $('input[name="cronmday[]"]').change(function () {
70
- cronstampadvanced();
71
- });
72
- $('input[name="cronmon[]"]').change(function () {
73
- cronstampadvanced();
74
- });
75
- $('input[name="cronwday[]"]').change(function () {
76
- cronstampadvanced();
77
- });
78
-
79
- function cronstampbasic() {
80
- var cronminutes = [];
81
- var cronhours = [];
82
- var cronmday = [];
83
- var cronmon = [];
84
- var cronwday = [];
85
- if ('mon' == $('input[name="cronbtype"]:checked').val()) {
86
- cronminutes.push($('select[name="moncronminutes"]').val());
87
- cronhours.push($('select[name="moncronhours"]').val());
88
- cronmday.push($('select[name="moncronmday"]').val());
89
- cronmon.push('*');
90
- cronwday.push('*');
91
- }
92
- if ('week' == $('input[name="cronbtype"]:checked').val()) {
93
- cronminutes.push($('select[name="weekcronminutes"]').val());
94
- cronhours.push($('select[name="weekcronhours"]').val());
95
- cronmday.push('*');
96
- cronmon.push('*');
97
- cronwday.push($('select[name="weekcronwday"]').val());
98
- }
99
- if ('day' == $('input[name="cronbtype"]:checked').val()) {
100
- cronminutes.push($('select[name="daycronminutes"]').val());
101
- cronhours.push($('select[name="daycronhours"]').val());
102
- cronmday.push('*');
103
- cronmon.push('*');
104
- cronwday.push('*');
105
- }
106
- if ('hour' == $('input[name="cronbtype"]:checked').val()) {
107
- cronminutes.push($('select[name="hourcronminutes"]').val());
108
- cronhours.push('*');
109
- cronmday.push('*');
110
- cronmon.push('*');
111
- cronwday.push('*');
112
- }
113
- var data = {
114
- action:'backwpup_cron_text',
115
- cronminutes:cronminutes,
116
- cronhours:cronhours,
117
- cronmday:cronmday,
118
- cronmon:cronmon,
119
- cronwday:cronwday,
120
- crontype:'basic',
121
- _ajax_nonce:$('#backwpupajaxnonce').val()
122
- };
123
- $.post(ajaxurl, data, function (response) {
124
- $('#schedulecron').replaceWith(response);
125
- });
126
- }
127
- $('input[name="cronbtype"]').change(function () {
128
- cronstampbasic();
129
- });
130
- $('select[name="moncronmday"]').change(function () {
131
- cronstampbasic();
132
- });
133
- $('select[name="moncronhours"]').change(function () {
134
- cronstampbasic();
135
- });
136
- $('select[name="moncronminutes"]').change(function () {
137
- cronstampbasic();
138
- });
139
- $('select[name="weekcronwday"]').change(function () {
140
- cronstampbasic();
141
- });
142
- $('select[name="weekcronhours"]').change(function () {
143
- cronstampbasic();
144
- });
145
- $('select[name="weekcronminutes"]').change(function () {
146
- cronstampbasic();
147
- });
148
- $('select[name="daycronhours"]').change(function () {
149
- cronstampbasic();
150
- });
151
- $('select[name="daycronminutes"]').change(function () {
152
- cronstampbasic();
153
- });
154
- $('select[name="hourcronminutes"]').change(function () {
155
- cronstampbasic();
156
- });
157
  });
1
+ jQuery(document).ready(function ($) {
2
+ $('input[name="activetype"]').change(function () {
3
+ if ($(this).val() == 'wpcron') {
4
+ $('.wpcron').show();
5
+ } else {
6
+ $('.wpcron').hide();
7
+ }
8
+ });
9
+
10
+ if ($('input[name="activetype"]:checked').val() == 'wpcron') {
11
+ $('.wpcron').show();
12
+ } else {
13
+ $('.wpcron').hide();
14
+ }
15
+
16
+ $('input[name="cronselect"]').change(function () {
17
+ if ('basic' == $('input[name="cronselect"]:checked').val()) {
18
+ $('.wpcronadvanced').hide();
19
+ $('.wpcronbasic').show();
20
+ cronstampbasic();
21
+ } else {
22
+ $('.wpcronadvanced').show();
23
+ $('.wpcronbasic').hide();
24
+ cronstampadvanced();
25
+ }
26
+ });
27
+
28
+ function cronstampadvanced() {
29
+ var cronminutes = [];
30
+ var cronhours = [];
31
+ var cronmday = [];
32
+ var cronmon = [];
33
+ var cronwday = [];
34
+ $('input[name="cronminutes[]"]:checked').each(function () {
35
+ cronminutes.push($(this).val());
36
+ });
37
+ $('input[name="cronhours[]"]:checked').each(function () {
38
+ cronhours.push($(this).val());
39
+ });
40
+ $('input[name="cronmday[]"]:checked').each(function () {
41
+ cronmday.push($(this).val());
42
+ });
43
+ $('input[name="cronmon[]"]:checked').each(function () {
44
+ cronmon.push($(this).val());
45
+ });
46
+ $('input[name="cronwday[]"]:checked').each(function () {
47
+ cronwday.push($(this).val());
48
+ });
49
+ var data = {
50
+ action:'backwpup_cron_text',
51
+ cronminutes:cronminutes,
52
+ cronhours:cronhours,
53
+ cronmday:cronmday,
54
+ cronmon:cronmon,
55
+ cronwday:cronwday,
56
+ crontype:'advanced',
57
+ _ajax_nonce:$('#backwpupajaxnonce').val()
58
+ };
59
+ $.post(ajaxurl, data, function (response) {
60
+ $('#schedulecron').replaceWith(response);
61
+ });
62
+ }
63
+ $('input[name="cronminutes[]"]').change(function () {
64
+ cronstampadvanced();
65
+ });
66
+ $('input[name="cronhours[]"]').change(function () {
67
+ cronstampadvanced();
68
+ });
69
+ $('input[name="cronmday[]"]').change(function () {
70
+ cronstampadvanced();
71
+ });
72
+ $('input[name="cronmon[]"]').change(function () {
73
+ cronstampadvanced();
74
+ });
75
+ $('input[name="cronwday[]"]').change(function () {
76
+ cronstampadvanced();
77
+ });
78
+
79
+ function cronstampbasic() {
80
+ var cronminutes = [];
81
+ var cronhours = [];
82
+ var cronmday = [];
83
+ var cronmon = [];
84
+ var cronwday = [];
85
+ if ('mon' == $('input[name="cronbtype"]:checked').val()) {
86
+ cronminutes.push($('select[name="moncronminutes"]').val());
87
+ cronhours.push($('select[name="moncronhours"]').val());
88
+ cronmday.push($('select[name="moncronmday"]').val());
89
+ cronmon.push('*');
90
+ cronwday.push('*');
91
+ }
92
+ if ('week' == $('input[name="cronbtype"]:checked').val()) {
93
+ cronminutes.push($('select[name="weekcronminutes"]').val());
94
+ cronhours.push($('select[name="weekcronhours"]').val());
95
+ cronmday.push('*');
96
+ cronmon.push('*');
97
+ cronwday.push($('select[name="weekcronwday"]').val());
98
+ }
99
+ if ('day' == $('input[name="cronbtype"]:checked').val()) {
100
+ cronminutes.push($('select[name="daycronminutes"]').val());
101
+ cronhours.push($('select[name="daycronhours"]').val());
102
+ cronmday.push('*');
103
+ cronmon.push('*');
104
+ cronwday.push('*');
105
+ }
106
+ if ('hour' == $('input[name="cronbtype"]:checked').val()) {
107
+ cronminutes.push($('select[name="hourcronminutes"]').val());
108
+ cronhours.push('*');
109
+ cronmday.push('*');
110
+ cronmon.push('*');
111
+ cronwday.push('*');
112
+ }
113
+ var data = {
114
+ action:'backwpup_cron_text',
115
+ cronminutes:cronminutes,
116
+ cronhours:cronhours,
117
+ cronmday:cronmday,
118
+ cronmon:cronmon,
119
+ cronwday:cronwday,
120
+ crontype:'basic',
121
+ _ajax_nonce:$('#backwpupajaxnonce').val()
122
+ };
123
+ $.post(ajaxurl, data, function (response) {
124
+ $('#schedulecron').replaceWith(response);
125
+ });
126
+ }
127
+ $('input[name="cronbtype"]').change(function () {
128
+ cronstampbasic();
129
+ });
130
+ $('select[name="moncronmday"]').change(function () {
131
+ cronstampbasic();
132
+ });
133
+ $('select[name="moncronhours"]').change(function () {
134
+ cronstampbasic();
135
+ });
136
+ $('select[name="moncronminutes"]').change(function () {
137
+ cronstampbasic();
138
+ });
139
+ $('select[name="weekcronwday"]').change(function () {
140
+ cronstampbasic();
141
+ });
142
+ $('select[name="weekcronhours"]').change(function () {
143
+ cronstampbasic();
144
+ });
145
+ $('select[name="weekcronminutes"]').change(function () {
146
+ cronstampbasic();
147
+ });
148
+ $('select[name="daycronhours"]').change(function () {
149
+ cronstampbasic();
150
+ });
151
+ $('select[name="daycronminutes"]').change(function () {
152
+ cronstampbasic();
153
+ });
154
+ $('select[name="hourcronminutes"]').change(function () {
155
+ cronstampbasic();
156
+ });
157
  });
assets/js/page_edit_tab_cron.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(c){c('input[name="activetype"]').change(function(){if(c(this).val()=="wpcron"){c(".wpcron").show()}else{c(".wpcron").hide()}});if(c('input[name="activetype"]:checked').val()=="wpcron"){c(".wpcron").show()}else{c(".wpcron").hide()}c('input[name="cronselect"]').change(function(){if("basic"==c('input[name="cronselect"]:checked').val()){c(".wpcronadvanced").hide();c(".wpcronbasic").show();b()}else{c(".wpcronadvanced").show();c(".wpcronbasic").hide();a()}});function a(){var d=[];var i=[];var f=[];var e=[];var h=[];c('input[name="cronminutes[]"]:checked').each(function(){d.push(c(this).val())});c('input[name="cronhours[]"]:checked').each(function(){i.push(c(this).val())});c('input[name="cronmday[]"]:checked').each(function(){f.push(c(this).val())});c('input[name="cronmon[]"]:checked').each(function(){e.push(c(this).val())});c('input[name="cronwday[]"]:checked').each(function(){h.push(c(this).val())});var g={action:"backwpup_cron_text",cronminutes:d,cronhours:i,cronmday:f,cronmon:e,cronwday:h,crontype:"advanced",_ajax_nonce:c("#backwpupajaxnonce").val()};c.post(ajaxurl,g,function(j){c("#schedulecron").replaceWith(j)})}c('input[name="cronminutes[]"]').change(function(){a()});c('input[name="cronhours[]"]').change(function(){a()});c('input[name="cronmday[]"]').change(function(){a()});c('input[name="cronmon[]"]').change(function(){a()});c('input[name="cronwday[]"]').change(function(){a()});function b(){var d=[];var i=[];var f=[];var e=[];var h=[];if("mon"==c('input[name="cronbtype"]:checked').val()){d.push(c('select[name="moncronminutes"]').val());i.push(c('select[name="moncronhours"]').val());f.push(c('select[name="moncronmday"]').val());e.push("*");h.push("*")}if("week"==c('input[name="cronbtype"]:checked').val()){d.push(c('select[name="weekcronminutes"]').val());i.push(c('select[name="weekcronhours"]').val());f.push("*");e.push("*");h.push(c('select[name="weekcronwday"]').val())}if("day"==c('input[name="cronbtype"]:checked').val()){d.push(c('select[name="daycronminutes"]').val());i.push(c('select[name="daycronhours"]').val());f.push("*");e.push("*");h.push("*")}if("hour"==c('input[name="cronbtype"]:checked').val()){d.push(c('select[name="hourcronminutes"]').val());i.push("*");f.push("*");e.push("*");h.push("*")}var g={action:"backwpup_cron_text",cronminutes:d,cronhours:i,cronmday:f,cronmon:e,cronwday:h,crontype:"basic",_ajax_nonce:c("#backwpupajaxnonce").val()};c.post(ajaxurl,g,function(j){c("#schedulecron").replaceWith(j)})}c('input[name="cronbtype"]').change(function(){b()});c('select[name="moncronmday"]').change(function(){b()});c('select[name="moncronhours"]').change(function(){b()});c('select[name="moncronminutes"]').change(function(){b()});c('select[name="weekcronwday"]').change(function(){b()});c('select[name="weekcronhours"]').change(function(){b()});c('select[name="weekcronminutes"]').change(function(){b()});c('select[name="daycronhours"]').change(function(){b()});c('select[name="daycronminutes"]').change(function(){b()});c('select[name="hourcronminutes"]').change(function(){b()})});
1
+ jQuery(document).ready(function(a){function b(){var b=[],c=[],d=[],e=[],f=[];a('input[name="cronminutes[]"]:checked').each(function(){b.push(a(this).val())}),a('input[name="cronhours[]"]:checked').each(function(){c.push(a(this).val())}),a('input[name="cronmday[]"]:checked').each(function(){d.push(a(this).val())}),a('input[name="cronmon[]"]:checked').each(function(){e.push(a(this).val())}),a('input[name="cronwday[]"]:checked').each(function(){f.push(a(this).val())});var g={action:"backwpup_cron_text",cronminutes:b,cronhours:c,cronmday:d,cronmon:e,cronwday:f,crontype:"advanced",_ajax_nonce:a("#backwpupajaxnonce").val()};a.post(ajaxurl,g,function(b){a("#schedulecron").replaceWith(b)})}function c(){var b=[],c=[],d=[],e=[],f=[];"mon"==a('input[name="cronbtype"]:checked').val()&&(b.push(a('select[name="moncronminutes"]').val()),c.push(a('select[name="moncronhours"]').val()),d.push(a('select[name="moncronmday"]').val()),e.push("*"),f.push("*")),"week"==a('input[name="cronbtype"]:checked').val()&&(b.push(a('select[name="weekcronminutes"]').val()),c.push(a('select[name="weekcronhours"]').val()),d.push("*"),e.push("*"),f.push(a('select[name="weekcronwday"]').val())),"day"==a('input[name="cronbtype"]:checked').val()&&(b.push(a('select[name="daycronminutes"]').val()),c.push(a('select[name="daycronhours"]').val()),d.push("*"),e.push("*"),f.push("*")),"hour"==a('input[name="cronbtype"]:checked').val()&&(b.push(a('select[name="hourcronminutes"]').val()),c.push("*"),d.push("*"),e.push("*"),f.push("*"));var g={action:"backwpup_cron_text",cronminutes:b,cronhours:c,cronmday:d,cronmon:e,cronwday:f,crontype:"basic",_ajax_nonce:a("#backwpupajaxnonce").val()};a.post(ajaxurl,g,function(b){a("#schedulecron").replaceWith(b)})}a('input[name="activetype"]').change(function(){"wpcron"==a(this).val()?a(".wpcron").show():a(".wpcron").hide()}),"wpcron"==a('input[name="activetype"]:checked').val()?a(".wpcron").show():a(".wpcron").hide(),a('input[name="cronselect"]').change(function(){"basic"==a('input[name="cronselect"]:checked').val()?(a(".wpcronadvanced").hide(),a(".wpcronbasic").show(),c()):(a(".wpcronadvanced").show(),a(".wpcronbasic").hide(),b())}),a('input[name="cronminutes[]"]').change(function(){b()}),a('input[name="cronhours[]"]').change(function(){b()}),a('input[name="cronmday[]"]').change(function(){b()}),a('input[name="cronmon[]"]').change(function(){b()}),a('input[name="cronwday[]"]').change(function(){b()}),a('input[name="cronbtype"]').change(function(){c()}),a('select[name="moncronmday"]').change(function(){c()}),a('select[name="moncronhours"]').change(function(){c()}),a('select[name="moncronminutes"]').change(function(){c()}),a('select[name="weekcronwday"]').change(function(){c()}),a('select[name="weekcronhours"]').change(function(){c()}),a('select[name="weekcronminutes"]').change(function(){c()}),a('select[name="daycronhours"]').change(function(){c()}),a('select[name="daycronminutes"]').change(function(){c()}),a('select[name="hourcronminutes"]').change(function(){c()})});
assets/js/page_edit_tab_job.js CHANGED
@@ -1,346 +1,321 @@
1
- function date(format, timestamp) {
2
- // http://kevin.vanzonneveld.net
3
- // + original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com)
4
- // + parts by: Peter-Paul Koch (http://www.quirksmode.org/js/beat.html)
5
- // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
6
- // + improved by: MeEtc (http://yass.meetcweb.com)
7
- // + improved by: Brad Touesnard
8
- // + improved by: Tim Wiel
9
- // + improved by: Bryan Elliott
10
- //
11
- // + improved by: Brett Zamir (http://brett-zamir.me)
12
- // + improved by: David Randall
13
- // + input by: Brett Zamir (http://brett-zamir.me)
14
- // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
15
- // + improved by: Brett Zamir (http://brett-zamir.me)
16
- // + improved by: Brett Zamir (http://brett-zamir.me)
17
- // + improved by: Theriault
18
- // + derived from: gettimeofday
19
- // + input by: majak
20
- // + bugfixed by: majak
21
- // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
22
- // + input by: Alex
23
- // + bugfixed by: Brett Zamir (http://brett-zamir.me)
24
- // + improved by: Theriault
25
- // + improved by: Brett Zamir (http://brett-zamir.me)
26
- // + improved by: Theriault
27
- // + improved by: Thomas Beaucourt (http://www.webapp.fr)
28
- // + improved by: JT
29
- // + improved by: Theriault
30
- // + improved by: Rafał Kukawski (http://blog.kukawski.pl)
31
- // + bugfixed by: omid (http://phpjs.org/functions/380:380#comment_137122)
32
- // + input by: Martin
33
- // + input by: Alex Wilson
34
- // + bugfixed by: Chris (http://www.devotis.nl/)
35
- // % note 1: Uses global: php_js to store the default timezone
36
- // % note 2: Although the function potentially allows timezone info (see notes), it currently does not set
37
- // % note 2: per a timezone specified by date_default_timezone_set(). Implementers might use
38
- // % note 2: this.php_js.currentTimezoneOffset and this.php_js.currentTimezoneDST set by that function
39
- // % note 2: in order to adjust the dates in this function (or our other date functions!) accordingly
40
- // * example 1: date('H:m:s \\m \\i\\s \\m\\o\\n\\t\\h', 1062402400);
41
- // * returns 1: '09:09:40 m is month'
42
- // * example 2: date('F j, Y, g:i a', 1062462400);
43
- // * returns 2: 'September 2, 2003, 2:26 am'
44
- // * example 3: date('Y W o', 1062462400);
45
- // * returns 3: '2003 36 2003'
46
- // * example 4: x = date('Y m d', (new Date()).getTime()/1000);
47
- // * example 4: (x+'').length == 10 // 2009 01 09
48
- // * returns 4: true
49
- // * example 5: date('W', 1104534000);
50
- // * returns 5: '53'
51
- // * example 6: date('B t', 1104534000);
52
- // * returns 6: '999 31'
53
- // * example 7: date('W U', 1293750000.82); // 2010-12-31
54
- // * returns 7: '52 1293750000'
55
- // * example 8: date('W', 1293836400); // 2011-01-01
56
- // * returns 8: '52'
57
- // * example 9: date('W Y-m-d', 1293974054); // 2011-01-02
58
- // * returns 9: '52 2011-01-02'
59
- var that = this,
60
- jsdate,
61
- f,
62
- formatChr = /\\?([a-z])/gi,
63
- formatChrCb,
64
- // Keep this here (works, but for code commented-out
65
- // below for file size reasons)
66
- //, tal= [],
67
- _pad = function (n, c) {
68
- n = n.toString();
69
- return n.length < c ? _pad('0' + n, c, '0') : n;
70
- },
71
- txt_words = ["Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
72
- formatChrCb = function (t, s) {
73
- return f[t] ? f[t]() : s;
74
- };
75
- f = {
76
- // Day
77
- d: function () { // Day of month w/leading 0; 01..31
78
- return _pad(f.j(), 2);
79
- },
80
- D: function () { // Shorthand day name; Mon...Sun
81
- return f.l().slice(0, 3);
82
- },
83
- j: function () { // Day of month; 1..31
84
- return jsdate.getDate();
85
- },
86
- l: function () { // Full day name; Monday...Sunday
87
- return txt_words[f.w()] + 'day';
88
- },
89
- N: function () { // ISO-8601 day of week; 1[Mon]..7[Sun]
90
- return f.w() || 7;
91
- },
92
- S: function(){ // Ordinal suffix for day of month; st, nd, rd, th
93
- var j = f.j()
94
- i = j%10;
95
- if (i <= 3 && parseInt((j%100)/10) == 1) i = 0;
96
- return ['st', 'nd', 'rd'][i - 1] || 'th';
97
- },
98
- w: function () { // Day of week; 0[Sun]..6[Sat]
99
- return jsdate.getDay();
100
- },
101
- z: function () { // Day of year; 0..365
102
- var a = new Date(f.Y(), f.n() - 1, f.j()),
103
- b = new Date(f.Y(), 0, 1);
104
- return Math.round((a - b) / 864e5);
105
- },
106
-
107
- // Week
108
- W: function () { // ISO-8601 week number
109
- var a = new Date(f.Y(), f.n() - 1, f.j() - f.N() + 3),
110
- b = new Date(a.getFullYear(), 0, 4);
111
- return _pad(1 + Math.round((a - b) / 864e5 / 7), 2);
112
- },
113
-
114
- // Month
115
- F: function () { // Full month name; January...December
116
- return txt_words[6 + f.n()];
117
- },
118
- m: function () { // Month w/leading 0; 01...12
119
- return _pad(f.n(), 2);
120
- },
121
- M: function () { // Shorthand month name; Jan...Dec
122
- return f.F().slice(0, 3);
123
- },
124
- n: function () { // Month; 1...12
125
- return jsdate.getMonth() + 1;
126
- },
127
- t: function () { // Days in month; 28...31
128
- return (new Date(f.Y(), f.n(), 0)).getDate();
129
- },
130
-
131
- // Year
132
- L: function () { // Is leap year?; 0 or 1
133
- var j = f.Y();
134
- return j % 4 === 0 & j % 100 !== 0 | j % 400 === 0;
135
- },
136
- o: function () { // ISO-8601 year
137
- var n = f.n(),
138
- W = f.W(),
139
- Y = f.Y();
140
- return Y + (n === 12 && W < 9 ? 1 : n === 1 && W > 9 ? -1 : 0);
141
- },
142
- Y: function () { // Full year; e.g. 1980...2010
143
- return jsdate.getFullYear();
144
- },
145
- y: function () { // Last two digits of year; 00...99
146
- return f.Y().toString().slice(-2);
147
- },
148
-
149
- // Time
150
- a: function () { // am or pm
151
- return jsdate.getHours() > 11 ? "pm" : "am";
152
- },
153
- A: function () { // AM or PM
154
- return f.a().toUpperCase();
155
- },
156
- B: function () { // Swatch Internet time; 000..999
157
- var H = jsdate.getUTCHours() * 36e2,
158
- // Hours
159
- i = jsdate.getUTCMinutes() * 60,
160
- // Minutes
161
- s = jsdate.getUTCSeconds(); // Seconds
162
- return _pad(Math.floor((H + i + s + 36e2) / 86.4) % 1e3, 3);
163
- },
164
- g: function () { // 12-Hours; 1..12
165
- return f.G() % 12 || 12;
166
- },
167
- G: function () { // 24-Hours; 0..23
168
- return jsdate.getHours();
169
- },
170
- h: function () { // 12-Hours w/leading 0; 01..12
171
- return _pad(f.g(), 2);
172
- },
173
- H: function () { // 24-Hours w/leading 0; 00..23
174
- return _pad(f.G(), 2);
175
- },
176
- i: function () { // Minutes w/leading 0; 00..59
177
- return _pad(jsdate.getMinutes(), 2);
178
- },
179
- s: function () { // Seconds w/leading 0; 00..59
180
- return _pad(jsdate.getSeconds(), 2);
181
- },
182
- u: function () { // Microseconds; 000000-999000
183
- return _pad(jsdate.getMilliseconds() * 1000, 6);
184
- },
185
-
186
- // Timezone
187
- e: function () { // Timezone identifier; e.g. Atlantic/Azores, ...
188
- // The following works, but requires inclusion of the very large
189
- // timezone_abbreviations_list() function.
190
- /* return that.date_default_timezone_get();
191
- */
192
- throw 'Not supported (see source code of date() for timezone on how to add support)';
193
- },
194
- I: function () { // DST observed?; 0 or 1
195
- // Compares Jan 1 minus Jan 1 UTC to Jul 1 minus Jul 1 UTC.
196
- // If they are not equal, then DST is observed.
197
- var a = new Date(f.Y(), 0),
198
- // Jan 1
199
- c = Date.UTC(f.Y(), 0),
200
- // Jan 1 UTC
201
- b = new Date(f.Y(), 6),
202
- // Jul 1
203
- d = Date.UTC(f.Y(), 6); // Jul 1 UTC
204
- return ((a - c) !== (b - d)) ? 1 : 0;
205
- },
206
- O: function () { // Difference to GMT in hour format; e.g. +0200
207
- var tzo = jsdate.getTimezoneOffset(),
208
- a = Math.abs(tzo);
209
- return (tzo > 0 ? "-" : "+") + _pad(Math.floor(a / 60) * 100 + a % 60, 4);
210
- },
211
- P: function () { // Difference to GMT w/colon; e.g. +02:00
212
- var O = f.O();
213
- return (O.substr(0, 3) + ":" + O.substr(3, 2));
214
- },
215
- T: function () { // Timezone abbreviation; e.g. EST, MDT, ...
216
- // The following works, but requires inclusion of the very
217
- // large timezone_abbreviations_list() function.
218
- /* var abbr = '', i = 0, os = 0, default = 0;
219
- if (!tal.length) {
220
- tal = that.timezone_abbreviations_list();
221
- }
222
- if (that.php_js && that.php_js.default_timezone) {
223
- default = that.php_js.default_timezone;
224
- for (abbr in tal) {
225
- for (i=0; i < tal[abbr].length; i++) {
226
- if (tal[abbr][i].timezone_id === default) {
227
- return abbr.toUpperCase();
228
- }
229
- }
230
- }
231
- }
232
- for (abbr in tal) {
233
- for (i = 0; i < tal[abbr].length; i++) {
234
- os = -jsdate.getTimezoneOffset() * 60;
235
- if (tal[abbr][i].offset === os) {
236
- return abbr.toUpperCase();
237
- }
238
- }
239
- }
240
- */
241
- return 'UTC';
242
- },
243
- Z: function () { // Timezone offset in seconds (-43200...50400)
244
- return -jsdate.getTimezoneOffset() * 60;
245
- },
246
-
247
- // Full Date/Time
248
- c: function () { // ISO-8601 date.
249
- return 'Y-m-d\\TH:i:sP'.replace(formatChr, formatChrCb);
250
- },
251
- r: function () { // RFC 2822
252
- return 'D, d M Y H:i:s O'.replace(formatChr, formatChrCb);
253
- },
254
- U: function () { // Seconds since UNIX epoch
255
- return jsdate / 1000 | 0;
256
- }
257
- };
258
- this.date = function (format, timestamp) {
259
- that = this;
260
- jsdate = (timestamp === undefined ? new Date() : // Not provided
261
- (timestamp instanceof Date) ? new Date(timestamp) : // JS Date()
262
- new Date(timestamp * 1000) // UNIX timestamp (auto-convert to int)
263
- );
264
- return format.replace(formatChr, formatChrCb);
265
- };
266
- return this.date(format, timestamp);
267
- }
268
-
269
- jQuery(document).ready(function ($) {
270
- $('input[name="type[]"]').change(function () {
271
- if ($('input[name="type[]"]:checked').hasClass('filetype')) {
272
- $('.hasdests').show();
273
- } else {
274
- $('.hasdests').hide();
275
- }
276
- $( '#tab-jobtype-' + $(this).val().toLowerCase() ).toggle( );
277
- });
278
-
279
- if ($('input[name="type[]"]:checked').hasClass('filetype')) {
280
- $('.hasdests').show();
281
- } else {
282
- $('.hasdests').hide();
283
- }
284
-
285
- $('input[name="destinations[]"]').change(function () {
286
- $( '#tab-dest-' + $(this).val().toLowerCase() ).toggle( );
287
- });
288
-
289
- $('input[name="name"]').keyup(function () {
290
- $('#h2jobtitle').replaceWith('<span id="h2jobtitle">' + backwpup_htmlspecialchars( $(this).val() ) + '</span>');
291
- });
292
-
293
- $('input[name="name"]').focus( function () {
294
- if ( $(this).val() == $(this).data( 'empty' ) ) {
295
- $(this).val( '' );
296
- }
297
- });
298
-
299
- $('input[name="name"]').blur( function () {
300
- if ( $(this).val() == '' ) {
301
- $(this).val( $(this).data( 'empty' ) );
302
- }
303
- });
304
-
305
- $('input[name="backuptype"]').change(function () {
306
- if ($(this).val() == 'sync') {
307
- $('.nosync').hide();
308
- $('.sync').show();
309
- } else {
310
- $('.nosync').show();
311
- $('.sync').hide();
312
- }
313
- });
314
-
315
- if ($('input[name="backuptype"]:checked').val() == 'sync') {
316
- $('.nosync').hide();
317
- $('.sync').show();
318
- } else {
319
- $('.nosync').show();
320
- $('.sync').hide();
321
- }
322
-
323
- $('input[name="archivename"]').keyup(function () {
324
- var filename = $(this).val();
325
- filename = filename.replace( '%d', date( 'd' ) );
326
- filename = filename.replace( '%j', date( 'j' ) );
327
- filename = filename.replace( '%m', date( 'm' ) );
328
- filename = filename.replace( '%n', date( 'n' ) );
329
- filename = filename.replace( '%Y', date( 'Y' ) );
330
- filename = filename.replace( '%y', date( 'y' ) );
331
- filename = filename.replace( '%a', date( 'a' ) );
332
- filename = filename.replace( '%A', date( 'A' ) );
333
- filename = filename.replace( '%B', date( 'B' ) );
334
- filename = filename.replace( '%g', date( 'g' ) );
335
- filename = filename.replace( '%G', date( 'G' ) );
336
- filename = filename.replace( '%h', date( 'h' ) );
337
- filename = filename.replace( '%H', date( 'H' ) );
338
- filename = filename.replace( '%i', date( 'i' ) );
339
- filename = filename.replace( '%s', date( 's' ) );
340
- $('#archivefilename').replaceWith('<span id="archivefilename">' + backwpup_htmlspecialchars( filename ) + '</span>');
341
- });
342
-
343
- $('input[name="archiveformart"]').change(function () {
344
- $('#archiveformart').replaceWith('<span id="archiveformart">' + $(this).val() + '</span>');
345
- });
346
- });
1
+ function date(format, timestamp) {
2
+ // http://kevin.vanzonneveld.net
3
+ // + original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com)
4
+ // + parts by: Peter-Paul Koch (http://www.quirksmode.org/js/beat.html)
5
+ // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
6
+ // + improved by: MeEtc (http://yass.meetcweb.com)
7
+ // + improved by: Brad Touesnard
8
+ // + improved by: Tim Wiel
9
+ // + improved by: Bryan Elliott
10
+ //
11
+ // + improved by: Brett Zamir (http://brett-zamir.me)
12
+ // + improved by: David Randall
13
+ // + input by: Brett Zamir (http://brett-zamir.me)
14
+ // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
15
+ // + improved by: Brett Zamir (http://brett-zamir.me)
16
+ // + improved by: Brett Zamir (http://brett-zamir.me)
17
+ // + improved by: Theriault
18
+ // + derived from: gettimeofday
19
+ // + input by: majak
20
+ // + bugfixed by: majak
21
+ // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
22
+ // + input by: Alex
23
+ // + bugfixed by: Brett Zamir (http://brett-zamir.me)
24
+ // + improved by: Theriault
25
+ // + improved by: Brett Zamir (http://brett-zamir.me)
26
+ // + improved by: Theriault
27
+ // + improved by: Thomas Beaucourt (http://www.webapp.fr)
28
+ // + improved by: JT
29
+ // + improved by: Theriault
30
+ // + improved by: Rafał Kukawski (http://blog.kukawski.pl)
31
+ // + bugfixed by: omid (http://phpjs.org/functions/380:380#comment_137122)
32
+ // + input by: Martin
33
+ // + input by: Alex Wilson
34
+ // + bugfixed by: Chris (http://www.devotis.nl/)
35
+ // % note 1: Uses global: php_js to store the default timezone
36
+ // % note 2: Although the function potentially allows timezone info (see notes), it currently does not set
37
+ // % note 2: per a timezone specified by date_default_timezone_set(). Implementers might use
38
+ // % note 2: this.php_js.currentTimezoneOffset and this.php_js.currentTimezoneDST set by that function
39
+ // % note 2: in order to adjust the dates in this function (or our other date functions!) accordingly
40
+ // * example 1: date('H:m:s \\m \\i\\s \\m\\o\\n\\t\\h', 1062402400);
41
+ // * returns 1: '09:09:40 m is month'
42
+ // * example 2: date('F j, Y, g:i a', 1062462400);
43
+ // * returns 2: 'September 2, 2003, 2:26 am'
44
+ // * example 3: date('Y W o', 1062462400);
45
+ // * returns 3: '2003 36 2003'
46
+ // * example 4: x = date('Y m d', (new Date()).getTime()/1000);
47
+ // * example 4: (x+'').length == 10 // 2009 01 09
48
+ // * returns 4: true
49
+ // * example 5: date('W', 1104534000);
50
+ // * returns 5: '53'
51
+ // * example 6: date('B t', 1104534000);
52
+ // * returns 6: '999 31'
53
+ // * example 7: date('W U', 1293750000.82); // 2010-12-31
54
+ // * returns 7: '52 1293750000'
55
+ // * example 8: date('W', 1293836400); // 2011-01-01
56
+ // * returns 8: '52'
57
+ // * example 9: date('W Y-m-d', 1293974054); // 2011-01-02
58
+ // * returns 9: '52 2011-01-02'
59
+ var that = this,
60
+ jsdate,
61
+ f,
62
+ formatChr = /\\?([a-z])/gi,
63
+ formatChrCb,
64
+ // Keep this here (works, but for code commented-out
65
+ // below for file size reasons)
66
+ //, tal= [],
67
+ _pad = function (n, c) {
68
+ n = n.toString();
69
+ return n.length < c ? _pad('0' + n, c, '0') : n;
70
+ },
71
+ txt_words = ["Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
72
+ formatChrCb = function (t, s) {
73
+ return f[t] ? f[t]() : s;
74
+ };
75
+ f = {
76
+ // Day
77
+ d: function () { // Day of month w/leading 0; 01..31
78
+ return _pad(f.j(), 2);
79
+ },
80
+ D: function () { // Shorthand day name; Mon...Sun
81
+ return f.l().slice(0, 3);
82
+ },
83
+ j: function () { // Day of month; 1..31
84
+ return jsdate.getDate();
85
+ },
86
+ l: function () { // Full day name; Monday...Sunday
87
+ return txt_words[f.w()] + 'day';
88
+ },
89
+ N: function () { // ISO-8601 day of week; 1[Mon]..7[Sun]
90
+ return f.w() || 7;
91
+ },
92
+ S: function(){ // Ordinal suffix for day of month; st, nd, rd, th
93
+ var j = f.j(),
94
+ i = j%10;
95
+ if (i <= 3 && parseInt((j%100)/10) == 1) i = 0;
96
+ return ['st', 'nd', 'rd'][i - 1] || 'th';
97
+ },
98
+ w: function () { // Day of week; 0[Sun]..6[Sat]
99
+ return jsdate.getDay();
100
+ },
101
+ z: function () { // Day of year; 0..365
102
+ var a = new Date(f.Y(), f.n() - 1, f.j()),
103
+ b = new Date(f.Y(), 0, 1);
104
+ return Math.round((a - b) / 864e5);
105
+ },
106
+
107
+ // Week
108
+ W: function () { // ISO-8601 week number
109
+ var a = new Date(f.Y(), f.n() - 1, f.j() - f.N() + 3),
110
+ b = new Date(a.getFullYear(), 0, 4);
111
+ return _pad(1 + Math.round((a - b) / 864e5 / 7), 2);
112
+ },
113
+
114
+ // Month
115
+ F: function () { // Full month name; January...December
116
+ return txt_words[6 + f.n()];
117
+ },
118
+ m: function () { // Month w/leading 0; 01...12
119
+ return _pad(f.n(), 2);
120
+ },
121
+ M: function () { // Shorthand month name; Jan...Dec
122
+ return f.F().slice(0, 3);
123
+ },
124
+ n: function () { // Month; 1...12
125
+ return jsdate.getMonth() + 1;
126
+ },
127
+ t: function () { // Days in month; 28...31
128
+ return (new Date(f.Y(), f.n(), 0)).getDate();
129
+ },
130
+
131
+ // Year
132
+ L: function () { // Is leap year?; 0 or 1
133
+ var j = f.Y();
134
+ return j % 4 === 0 & j % 100 !== 0 | j % 400 === 0;
135
+ },
136
+ o: function () { // ISO-8601 year
137
+ var n = f.n(),
138
+ W = f.W(),
139
+ Y = f.Y();
140
+ return Y + (n === 12 && W < 9 ? 1 : n === 1 && W > 9 ? -1 : 0);
141
+ },
142
+ Y: function () { // Full year; e.g. 1980...2010
143
+ return jsdate.getFullYear();
144
+ },
145
+ y: function () { // Last two digits of year; 00...99
146
+ return f.Y().toString().slice(-2);
147
+ },
148
+
149
+ // Time
150
+ a: function () { // am or pm
151
+ return jsdate.getHours() > 11 ? "pm" : "am";
152
+ },
153
+ A: function () { // AM or PM
154
+ return f.a().toUpperCase();
155
+ },
156
+ B: function () { // Swatch Internet time; 000..999
157
+ var H = jsdate.getUTCHours() * 36e2,
158
+ // Hours
159
+ i = jsdate.getUTCMinutes() * 60,
160
+ // Minutes
161
+ s = jsdate.getUTCSeconds(); // Seconds
162
+ return _pad(Math.floor((H + i + s + 36e2) / 86.4) % 1e3, 3);
163
+ },
164
+ g: function () { // 12-Hours; 1..12
165
+ return f.G() % 12 || 12;
166
+ },
167
+ G: function () { // 24-Hours; 0..23
168
+ return jsdate.getHours();
169
+ },
170
+ h: function () { // 12-Hours w/leading 0; 01..12
171
+ return _pad(f.g(), 2);
172
+ },
173
+ H: function () { // 24-Hours w/leading 0; 00..23
174
+ return _pad(f.G(), 2);
175
+ },
176
+ i: function () { // Minutes w/leading 0; 00..59
177
+ return _pad(jsdate.getMinutes(), 2);
178
+ },
179
+ s: function () { // Seconds w/leading 0; 00..59
180
+ return _pad(jsdate.getSeconds(), 2);
181
+ },
182
+ u: function () { // Microseconds; 000000-999000
183
+ return _pad(jsdate.getMilliseconds() * 1000, 6);
184
+ },
185
+
186
+ // Timezone
187
+ e: function () { // Timezone identifier; e.g. Atlantic/Azores, ...
188
+ // The following works, but requires inclusion of the very large
189
+ // timezone_abbreviations_list() function.
190
+ /* return that.date_default_timezone_get();
191
+ */
192
+ throw 'Not supported (see source code of date() for timezone on how to add support)';
193
+ },
194
+ I: function () { // DST observed?; 0 or 1
195
+ // Compares Jan 1 minus Jan 1 UTC to Jul 1 minus Jul 1 UTC.
196
+ // If they are not equal, then DST is observed.
197
+ var a = new Date(f.Y(), 0),
198
+ // Jan 1
199
+ c = Date.UTC(f.Y(), 0),
200
+ // Jan 1 UTC
201
+ b = new Date(f.Y(), 6),
202
+ // Jul 1
203
+ d = Date.UTC(f.Y(), 6); // Jul 1 UTC
204
+ return ((a - c) !== (b - d)) ? 1 : 0;
205
+ },
206
+ O: function () { // Difference to GMT in hour format; e.g. +0200
207
+ var tzo = jsdate.getTimezoneOffset(),
208
+ a = Math.abs(tzo);
209
+ return (tzo > 0 ? "-" : "+") + _pad(Math.floor(a / 60) * 100 + a % 60, 4);
210
+ },
211
+ P: function () { // Difference to GMT w/colon; e.g. +02:00
212
+ var O = f.O();
213
+ return (O.substr(0, 3) + ":" + O.substr(3, 2));
214
+ },
215
+ T: function () {
216
+ return 'UTC';
217
+ },
218
+ Z: function () { // Timezone offset in seconds (-43200...50400)
219
+ return -jsdate.getTimezoneOffset() * 60;
220
+ },
221
+
222
+ // Full Date/Time
223
+ c: function () { // ISO-8601 date.
224
+ return 'Y-m-d\\TH:i:sP'.replace(formatChr, formatChrCb);
225
+ },
226
+ r: function () { // RFC 2822
227
+ return 'D, d M Y H:i:s O'.replace(formatChr, formatChrCb);
228
+ },
229
+ U: function () { // Seconds since UNIX epoch
230
+ return jsdate / 1000 | 0;
231
+ }
232
+ };
233
+ this.date = function (format, timestamp) {
234
+ that = this;
235
+ jsdate = (timestamp === undefined ? new Date() : // Not provided
236
+ (timestamp instanceof Date) ? new Date(timestamp) : // JS Date()
237
+ new Date(timestamp * 1000) // UNIX timestamp (auto-convert to int)
238
+ );
239
+ return format.replace(formatChr, formatChrCb);
240
+ };
241
+ return this.date(format, timestamp);
242
+ }
243
+
244
+ jQuery(document).ready(function ($) {
245
+ $('input[name="type[]"]').change(function () {
246
+ if ($('input[name="type[]"]:checked').hasClass('filetype')) {
247
+ $('.hasdests').show();
248
+ } else {
249
+ $('.hasdests').hide();
250
+ }
251
+ $( '#tab-jobtype-' + $(this).val().toLowerCase() ).toggle( );
252
+ });
253
+
254
+ if ($('input[name="type[]"]:checked').hasClass('filetype')) {
255
+ $('.hasdests').show();
256
+ } else {
257
+ $('.hasdests').hide();
258
+ }
259
+
260
+ $('input[name="destinations[]"]').change(function () {
261
+ $( '#tab-dest-' + $(this).val().toLowerCase() ).toggle( );
262
+ });
263
+
264
+ $('input[name="name"]').keyup(function () {
265
+ $('#h2jobtitle').replaceWith('<span id="h2jobtitle">' + backwpup_htmlspecialchars( $(this).val() ) + '</span>');
266
+ });
267
+
268
+ $('input[name="name"]').focus( function () {
269
+ if ( $(this).val() == $(this).data( 'empty' ) ) {
270
+ $(this).val( '' );
271
+ }
272
+ });
273
+
274
+ $('input[name="name"]').blur( function () {
275
+ if ( $(this).val() === '' ) {
276
+ $(this).val( $(this).data( 'empty' ) );
277
+ }
278
+ });
279
+
280
+ $('input[name="backuptype"]').change(function () {
281
+ if ($(this).val() == 'sync') {
282
+ $('.nosync').hide();
283
+ $('.sync').show();
284
+ } else {
285
+ $('.nosync').show();
286
+ $('.sync').hide();
287
+ }
288
+ });
289
+
290
+ if ($('input[name="backuptype"]:checked').val() == 'sync') {
291
+ $('.nosync').hide();
292
+ $('.sync').show();
293
+ } else {
294
+ $('.nosync').show();
295
+ $('.sync').hide();
296
+ }
297
+
298
+ $('input[name="archivename"]').keyup(function () {
299
+ var filename = $(this).val();
300
+ filename = filename.replace( '%d', date( 'd' ) );
301
+ filename = filename.replace( '%j', date( 'j' ) );
302
+ filename = filename.replace( '%m', date( 'm' ) );
303
+ filename = filename.replace( '%n', date( 'n' ) );
304
+ filename = filename.replace( '%Y', date( 'Y' ) );
305
+ filename = filename.replace( '%y', date( 'y' ) );
306
+ filename = filename.replace( '%a', date( 'a' ) );
307
+ filename = filename.replace( '%A', date( 'A' ) );
308
+ filename = filename.replace( '%B', date( 'B' ) );
309
+ filename = filename.replace( '%g', date( 'g' ) );
310
+ filename = filename.replace( '%G', date( 'G' ) );
311
+ filename = filename.replace( '%h', date( 'h' ) );
312
+ filename = filename.replace( '%H', date( 'H' ) );
313
+ filename = filename.replace( '%i', date( 'i' ) );
314
+ filename = filename.replace( '%s', date( 's' ) );
315
+ $('#archivefilename').replaceWith('<span id="archivefilename">' + backwpup_htmlspecialchars( filename ) + '</span>');
316
+ });
317
+
318
+ $('input[name="archiveformart"]').change(function () {
319
+ $('#archiveformart').replaceWith('<span id="archiveformart">' + $(this).val() + '</span>');
320
+ });
321
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/page_edit_tab_job.min.js CHANGED
@@ -1 +1 @@
1
- function date(k,h){var g=this,j,e,b=/\\?([a-z])/gi,a,c=function(l,f){l=l.toString();return l.length<f?c("0"+l,f,"0"):l},d=["Sun","Mon","Tues","Wednes","Thurs","Fri","Satur","January","February","March","April","May","June","July","August","September","October","November","December"];a=function(f,l){return e[f]?e[f]():l};e={d:function(){return c(e.j(),2)},D:function(){return e.l().slice(0,3)},j:function(){return j.getDate()},l:function(){return d[e.w()]+"day"},N:function(){return e.w()||7},S:function(){var f=e.j();i=f%10;if(i<=3&&parseInt((f%100)/10)==1){i=0}return["st","nd","rd"][i-1]||"th"},w:function(){return j.getDay()},z:function(){var l=new Date(e.Y(),e.n()-1,e.j()),f=new Date(e.Y(),0,1);return Math.round((l-f)/86400000)},W:function(){var l=new Date(e.Y(),e.n()-1,e.j()-e.N()+3),f=new Date(l.getFullYear(),0,4);return c(1+Math.round((l-f)/86400000/7),2)},F:function(){return d[6+e.n()]},m:function(){return c(e.n(),2)},M:function(){return e.F().slice(0,3)},n:function(){return j.getMonth()+1},t:function(){return(new Date(e.Y(),e.n(),0)).getDate()},L:function(){var f=e.Y();return f%4===0&f%100!==0|f%400===0},o:function(){var m=e.n(),f=e.W(),l=e.Y();return l+(m===12&&f<9?1:m===1&&f>9?-1:0)},Y:function(){return j.getFullYear()},y:function(){return e.Y().toString().slice(-2)},a:function(){return j.getHours()>11?"pm":"am"},A:function(){return e.a().toUpperCase()},B:function(){var l=j.getUTCHours()*3600,f=j.getUTCMinutes()*60,m=j.getUTCSeconds();return c(Math.floor((l+f+m+3600)/86.4)%1000,3)},g:function(){return e.G()%12||12},G:function(){return j.getHours()},h:function(){return c(e.g(),2)},H:function(){return c(e.G(),2)},i:function(){return c(j.getMinutes(),2)},s:function(){return c(j.getSeconds(),2)},u:function(){return c(j.getMilliseconds()*1000,6)},e:function(){throw"Not supported (see source code of date() for timezone on how to add support)"},I:function(){var l=new Date(e.Y(),0),n=Date.UTC(e.Y(),0),f=new Date(e.Y(),6),m=Date.UTC(e.Y(),6);return((l-n)!==(f-m))?1:0},O:function(){var l=j.getTimezoneOffset(),f=Math.abs(l);return(l>0?"-":"+")+c(Math.floor(f/60)*100+f%60,4)},P:function(){var f=e.O();return(f.substr(0,3)+":"+f.substr(3,2))},T:function(){return"UTC"},Z:function(){return -j.getTimezoneOffset()*60},c:function(){return"Y-m-d\\TH:i:sP".replace(b,a)},r:function(){return"D, d M Y H:i:s O".replace(b,a)},U:function(){return j/1000|0}};this.date=function(l,f){g=this;j=(f===undefined?new Date():(f instanceof Date)?new Date(f):new Date(f*1000));return l.replace(b,a)};return this.date(k,h)}jQuery(document).ready(function(a){a('input[name="type[]"]').change(function(){if(a('input[name="type[]"]:checked').hasClass("filetype")){a(".hasdests").show()}else{a(".hasdests").hide()}a("#tab-jobtype-"+a(this).val().toLowerCase()).toggle()});if(a('input[name="type[]"]:checked').hasClass("filetype")){a(".hasdests").show()}else{a(".hasdests").hide()}a('input[name="destinations[]"]').change(function(){a("#tab-dest-"+a(this).val().toLowerCase()).toggle()});a('input[name="name"]').keyup(function(){a("#h2jobtitle").replaceWith('<span id="h2jobtitle">'+backwpup_htmlspecialchars(a(this).val())+"</span>")});a('input[name="name"]').focus(function(){if(a(this).val()==a(this).data("empty")){a(this).val("")}});a('input[name="name"]').blur(function(){if(a(this).val()==""){a(this).val(a(this).data("empty"))}});a('input[name="backuptype"]').change(function(){if(a(this).val()=="sync"){a(".nosync").hide();a(".sync").show()}else{a(".nosync").show();a(".sync").hide()}});if(a('input[name="backuptype"]:checked').val()=="sync"){a(".nosync").hide();a(".sync").show()}else{a(".nosync").show();a(".sync").hide()}a('input[name="archivename"]').keyup(function(){var b=a(this).val();b=b.replace("%d",date("d"));b=b.replace("%j",date("j"));b=b.replace("%m",date("m"));b=b.replace("%n",date("n"));b=b.replace("%Y",date("Y"));b=b.replace("%y",date("y"));b=b.replace("%a",date("a"));b=b.replace("%A",date("A"));b=b.replace("%B",date("B"));b=b.replace("%g",date("g"));b=b.replace("%G",date("G"));b=b.replace("%h",date("h"));b=b.replace("%H",date("H"));b=b.replace("%i",date("i"));b=b.replace("%s",date("s"));a("#archivefilename").replaceWith('<span id="archivefilename">'+backwpup_htmlspecialchars(b)+"</span>")});a('input[name="archiveformart"]').change(function(){a("#archiveformart").replaceWith('<span id="archiveformart">'+a(this).val()+"</span>")})});
1
+ function date(a,b){var c,d,e,f=this,g=/\\?([a-z])/gi,h=function(a,b){return a=a.toString(),a.length<b?h("0"+a,b,"0"):a},i=["Sun","Mon","Tues","Wednes","Thurs","Fri","Satur","January","February","March","April","May","June","July","August","September","October","November","December"];return e=function(a,b){return d[a]?d[a]():b},d={d:function(){return h(d.j(),2)},D:function(){return d.l().slice(0,3)},j:function(){return c.getDate()},l:function(){return i[d.w()]+"day"},N:function(){return d.w()||7},S:function(){var a=d.j(),b=a%10;return 3>=b&&1==parseInt(a%100/10)&&(b=0),["st","nd","rd"][b-1]||"th"},w:function(){return c.getDay()},z:function(){var a=new Date(d.Y(),d.n()-1,d.j()),b=new Date(d.Y(),0,1);return Math.round((a-b)/864e5)},W:function(){var a=new Date(d.Y(),d.n()-1,d.j()-d.N()+3),b=new Date(a.getFullYear(),0,4);return h(1+Math.round((a-b)/864e5/7),2)},F:function(){return i[6+d.n()]},m:function(){return h(d.n(),2)},M:function(){return d.F().slice(0,3)},n:function(){return c.getMonth()+1},t:function(){return new Date(d.Y(),d.n(),0).getDate()},L:function(){var a=d.Y();return a%4===0&a%100!==0|a%400===0},o:function(){var a=d.n(),b=d.W(),c=d.Y();return c+(12===a&&9>b?1:1===a&&b>9?-1:0)},Y:function(){return c.getFullYear()},y:function(){return d.Y().toString().slice(-2)},a:function(){return c.getHours()>11?"pm":"am"},A:function(){return d.a().toUpperCase()},B:function(){var a=3600*c.getUTCHours(),b=60*c.getUTCMinutes(),d=c.getUTCSeconds();return h(Math.floor((a+b+d+3600)/86.4)%1e3,3)},g:function(){return d.G()%12||12},G:function(){return c.getHours()},h:function(){return h(d.g(),2)},H:function(){return h(d.G(),2)},i:function(){return h(c.getMinutes(),2)},s:function(){return h(c.getSeconds(),2)},u:function(){return h(1e3*c.getMilliseconds(),6)},e:function(){throw"Not supported (see source code of date() for timezone on how to add support)"},I:function(){var a=new Date(d.Y(),0),b=Date.UTC(d.Y(),0),c=new Date(d.Y(),6),e=Date.UTC(d.Y(),6);return a-b!==c-e?1:0},O:function(){var a=c.getTimezoneOffset(),b=Math.abs(a);return(a>0?"-":"+")+h(100*Math.floor(b/60)+b%60,4)},P:function(){var a=d.O();return a.substr(0,3)+":"+a.substr(3,2)},T:function(){return"UTC"},Z:function(){return 60*-c.getTimezoneOffset()},c:function(){return"Y-m-d\\TH:i:sP".replace(g,e)},r:function(){return"D, d M Y H:i:s O".replace(g,e)},U:function(){return c/1e3|0}},this.date=function(a,b){return f=this,c=void 0===b?new Date:new Date(b instanceof Date?b:1e3*b),a.replace(g,e)},this.date(a,b)}jQuery(document).ready(function(a){a('input[name="type[]"]').change(function(){a('input[name="type[]"]:checked').hasClass("filetype")?a(".hasdests").show():a(".hasdests").hide(),a("#tab-jobtype-"+a(this).val().toLowerCase()).toggle()}),a('input[name="type[]"]:checked').hasClass("filetype")?a(".hasdests").show():a(".hasdests").hide(),a('input[name="destinations[]"]').change(function(){a("#tab-dest-"+a(this).val().toLowerCase()).toggle()}),a('input[name="name"]').keyup(function(){a("#h2jobtitle").replaceWith('<span id="h2jobtitle">'+backwpup_htmlspecialchars(a(this).val())+"</span>")}),a('input[name="name"]').focus(function(){a(this).val()==a(this).data("empty")&&a(this).val("")}),a('input[name="name"]').blur(function(){""===a(this).val()&&a(this).val(a(this).data("empty"))}),a('input[name="backuptype"]').change(function(){"sync"==a(this).val()?(a(".nosync").hide(),a(".sync").show()):(a(".nosync").show(),a(".sync").hide())}),"sync"==a('input[name="backuptype"]:checked').val()?(a(".nosync").hide(),a(".sync").show()):(a(".nosync").show(),a(".sync").hide()),a('input[name="archivename"]').keyup(function(){var b=a(this).val();b=b.replace("%d",date("d")),b=b.replace("%j",date("j")),b=b.replace("%m",date("m")),b=b.replace("%n",date("n")),b=b.replace("%Y",date("Y")),b=b.replace("%y",date("y")),b=b.replace("%a",date("a")),b=b.replace("%A",date("A")),b=b.replace("%B",date("B")),b=b.replace("%g",date("g")),b=b.replace("%G",date("G")),b=b.replace("%h",date("h")),b=b.replace("%H",date("H")),b=b.replace("%i",date("i")),b=b.replace("%s",date("s")),a("#archivefilename").replaceWith('<span id="archivefilename">'+backwpup_htmlspecialchars(b)+"</span>")}),a('input[name="archiveformart"]').change(function(){a("#archiveformart").replaceWith('<span id="archiveformart">'+a(this).val()+"</span>")})});
assets/js/page_settings.js CHANGED
@@ -1,27 +1,27 @@
1
- jQuery(document).ready(function ($) {
2
- $('.table').addClass('ui-tabs-hide');
3
- $((window.location.hash || "#backwpup-tab-general")).removeClass('ui-tabs-hide');
4
- $('.nav-tab-wrapper>a').removeClass('nav-tab-active');
5
- $('.nav-tab-wrapper>a').each(function (index) {
6
- if ($(this).attr('href') == (window.location.hash || "#backwpup-tab-general")) {
7
- $(this).addClass('nav-tab-active');
8
- }
9
- });
10
- $('.nav-tab-wrapper>a').click(function () {
11
- var clickedid = $(this).attr('href');
12
- $('.nav-tab-wrapper>a').removeClass('nav-tab-active');
13
- $(this).addClass('nav-tab-active');
14
- $('.table').addClass('ui-tabs-hide');
15
- $(clickedid).removeClass('ui-tabs-hide');
16
- $('#message').hide();
17
- $('input[name="anchor"]').val(clickedid);
18
- if ( clickedid == '#backwpup-tab-information' ) {
19
- $('#submit').hide();
20
- $('#default_settings').hide();
21
- } else {
22
- $('#submit').show();
23
- $('#default_settings').show();
24
- }
25
- return false;
26
- });
27
  });
1
+ jQuery(document).ready(function ($) {
2
+ $('.table').addClass('ui-tabs-hide');
3
+ $((window.location.hash || "#backwpup-tab-general")).removeClass('ui-tabs-hide');
4
+ $('.nav-tab-wrapper>a').removeClass('nav-tab-active');
5
+ $('.nav-tab-wrapper>a').each(function (index) {
6
+ if ($(this).attr('href') == (window.location.hash || "#backwpup-tab-general")) {
7
+ $(this).addClass('nav-tab-active');
8
+ }
9
+ });
10
+ $('.nav-tab-wrapper>a').click(function () {
11
+ var clickedid = $(this).attr('href');
12
+ $('.nav-tab-wrapper>a').removeClass('nav-tab-active');
13
+ $(this).addClass('nav-tab-active');
14
+ $('.table').addClass('ui-tabs-hide');
15
+ $(clickedid).removeClass('ui-tabs-hide');
16
+ $('#message').hide();
17
+ $('input[name="anchor"]').val(clickedid);
18
+ if ( clickedid == '#backwpup-tab-information' ) {
19
+ $('#submit').hide();
20
+ $('#default_settings').hide();
21
+ } else {
22
+ $('#submit').show();
23
+ $('#default_settings').show();
24
+ }
25
+ return false;
26
+ });
27
  });
assets/js/page_settings.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(a){a(".table").addClass("ui-tabs-hide");a((window.location.hash||"#backwpup-tab-general")).removeClass("ui-tabs-hide");a(".nav-tab-wrapper>a").removeClass("nav-tab-active");a(".nav-tab-wrapper>a").each(function(b){if(a(this).attr("href")==(window.location.hash||"#backwpup-tab-general")){a(this).addClass("nav-tab-active")}});a(".nav-tab-wrapper>a").click(function(){var b=a(this).attr("href");a(".nav-tab-wrapper>a").removeClass("nav-tab-active");a(this).addClass("nav-tab-active");a(".table").addClass("ui-tabs-hide");a(b).removeClass("ui-tabs-hide");a("#message").hide();a('input[name="anchor"]').val(b);if(b=="#backwpup-tab-information"){a("#submit").hide();a("#default_settings").hide()}else{a("#submit").show();a("#default_settings").show()}return false})});
1
+ jQuery(document).ready(function(a){a(".table").addClass("ui-tabs-hide"),a(window.location.hash||"#backwpup-tab-general").removeClass("ui-tabs-hide"),a(".nav-tab-wrapper>a").removeClass("nav-tab-active"),a(".nav-tab-wrapper>a").each(function(){a(this).attr("href")==(window.location.hash||"#backwpup-tab-general")&&a(this).addClass("nav-tab-active")}),a(".nav-tab-wrapper>a").click(function(){var b=a(this).attr("href");return a(".nav-tab-wrapper>a").removeClass("nav-tab-active"),a(this).addClass("nav-tab-active"),a(".table").addClass("ui-tabs-hide"),a(b).removeClass("ui-tabs-hide"),a("#message").hide(),a('input[name="anchor"]').val(b),"#backwpup-tab-information"==b?(a("#submit").hide(),a("#default_settings").hide()):(a("#submit").show(),a("#default_settings").show()),!1})});
backwpup.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: WordPress Backup Plugin
6
  * Author: Inpsyde GmbH
7
  * Author URI: http://inpsyde.com
8
- * Version: 3.1.2
9
  * Text Domain: backwpup
10
  * Domain Path: /languages/
11
  * Network: true
@@ -15,7 +15,7 @@
15
  */
16
 
17
  /**
18
- * Copyright (C) 2012-2013 Inpsyde GmbH (email: info@inpsyde.com)
19
  *
20
  * This program is free software; you can redistribute it and/or
21
  * modify it under the terms of the GNU General Public License
@@ -34,17 +34,19 @@
34
 
35
  if ( ! class_exists( 'BackWPup' ) ) {
36
 
37
- // Don't activate on anything less than PHP 5.2.4 or WordPress 3.1
38
- if ( version_compare( PHP_VERSION, '5.2.6', '<' ) || version_compare( get_bloginfo( 'version' ), '3.4', '<' ) || ! function_exists( 'spl_autoload_register' ) ) {
39
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
40
  deactivate_plugins( basename( __FILE__ ) );
41
- if ( isset( $_GET['action'] ) && ( $_GET['action'] == 'activate' || $_GET['action'] == 'error_scrape' ) )
42
- die( __( 'BackWPup requires PHP version 5.2.6 with spl extension or greater and WordPress 3.4 or greater.', 'backwpup' ) );
 
43
  }
44
 
45
  //Start Plugin
46
- if ( function_exists( 'add_filter' ) )
47
  add_action( 'plugins_loaded', array( 'BackWPup', 'get_instance' ), 11 );
 
48
 
49
  /**
50
  * Main BackWPup Plugin Class
@@ -65,40 +67,48 @@ if ( ! class_exists( 'BackWPup' ) ) {
65
  private function __construct() {
66
 
67
  // Nothing else matters if we're not on the main site
68
- if ( ! is_main_site() )
69
  return;
 
70
  //auto loader
71
  spl_autoload_register( array( $this, 'autoloader' ) );
72
  //start upgrade if needed
73
- if ( get_site_option( 'backwpup_version' ) != self::get_plugin_data( 'Version' ) )
74
  BackWPup_Install::activate();
 
75
  //load pro features
76
- if ( class_exists( 'BackWPup_Pro' ) )
77
  BackWPup_Pro::get_instance();
 
78
  //WP-Cron
79
  if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
80
  //early disable caches
81
- if ( ! empty( $_GET[ 'backwpup_run' ] ) && class_exists( 'BackWPup_Job' ) )
82
  BackWPup_Job::disable_caches();
 
83
  // add normal cron actions
84
  add_action( 'backwpup_cron', array( 'BackWPup_Cron', 'run' ) );
85
  add_action( 'backwpup_check_cleanup', array( 'BackWPup_Cron', 'check_cleanup' ) );
86
  // add action for doing thinks if cron active
87
- // must done in int before wp-cron control
88
- add_action( 'init', array( 'BackWPup_Cron', 'cron_active' ), 1 );
89
  // if in cron the rest must not needed
90
  return;
91
  }
92
  //deactivation hook
93
  register_deactivation_hook( __FILE__, array( 'BackWPup_Install', 'deactivate' ) );
94
- //Things that must do in plugin init
95
- add_action( 'init', array( $this, 'plugin_init' ) );
 
 
96
  //only in backend
97
- if ( is_admin() && class_exists( 'BackWPup_Admin' ) )
98
  BackWPup_Admin::get_instance();
 
99
  //work with wp-cli
100
- if ( defined( 'WP_CLI' ) && WP_CLI && method_exists( 'WP_CLI', 'add_command' ) )
101
  WP_CLI::add_command( 'backwpup', 'BackWPup_WP_CLI' );
 
102
  }
103
 
104
  /**
@@ -222,18 +232,18 @@ if ( ! class_exists( 'BackWPup' ) ) {
222
  }
223
  }
224
 
225
- }
226
-
227
- /**
228
- * Plugin init function
229
- *
230
- * @return void
231
- */
232
- public function plugin_init() {
 
 
 
233
 
234
- //Add Admin Bar
235
- if ( ! defined( 'DOING_CRON' ) && current_user_can( 'backwpup' ) && current_user_can( 'backwpup' ) && is_admin_bar_showing() && get_site_option( 'backwpup_cfg_showadminbar' ) )
236
- BackWPup_Adminbar::get_instance();
237
  }
238
 
239
  /**
@@ -297,11 +307,11 @@ if ( ! class_exists( 'BackWPup' ) ) {
297
  ),
298
  'can_sync' => FALSE,
299
  'needed' => array(
300
- 'php_version' => '',
301
  'functions' => array(),
302
  'classes' => array()
303
  ),
304
- 'autoload' => array( 'Swift_Preferences' => dirname( __FILE__ ) . '/vendor/SwiftMailer/swift_required.php' )
305
  );
306
  // backup to ftp
307
  self::$registered_destinations[ 'FTP' ] = array(
5
  * Description: WordPress Backup Plugin
6
  * Author: Inpsyde GmbH
7
  * Author URI: http://inpsyde.com
8
+ * Version: 3.1.3
9
  * Text Domain: backwpup
10
  * Domain Path: /languages/
11
  * Network: true
15
  */
16
 
17
  /**
18
+ * Copyright (C) 2012-2014 Inpsyde GmbH (email: info@inpsyde.com)
19
  *
20
  * This program is free software; you can redistribute it and/or
21
  * modify it under the terms of the GNU General Public License
34
 
35
  if ( ! class_exists( 'BackWPup' ) ) {
36
 
37
+ // Don't activate on anything less than PHP 5.2.7 or WordPress 3.1
38
+ if ( version_compare( PHP_VERSION, '5.2.7', '<' ) || version_compare( get_bloginfo( 'version' ), '3.4', '<' ) || ! function_exists( 'spl_autoload_register' ) ) {
39
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
40
  deactivate_plugins( basename( __FILE__ ) );
41
+ if ( isset( $_GET['action'] ) && ( $_GET['action'] == 'activate' || $_GET['action'] == 'error_scrape' ) ) {
42
+ die( __( 'BackWPup requires PHP version 5.2.7 with spl extension or greater and WordPress 3.4 or greater.', 'backwpup' ) );
43
+ }
44
  }
45
 
46
  //Start Plugin
47
+ if ( function_exists( 'add_filter' ) ) {
48
  add_action( 'plugins_loaded', array( 'BackWPup', 'get_instance' ), 11 );
49
+ }
50
 
51
  /**
52
  * Main BackWPup Plugin Class
67
  private function __construct() {
68
 
69
  // Nothing else matters if we're not on the main site
70
+ if ( ! is_main_site() ) {
71
  return;
72
+ }
73
  //auto loader
74
  spl_autoload_register( array( $this, 'autoloader' ) );
75
  //start upgrade if needed
76
+ if ( get_site_option( 'backwpup_version' ) != self::get_plugin_data( 'Version' ) ) {
77
  BackWPup_Install::activate();
78
+ }
79
  //load pro features
80
+ if ( class_exists( 'BackWPup_Pro' ) ) {
81
  BackWPup_Pro::get_instance();
82
+ }
83
  //WP-Cron
84
  if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
85
  //early disable caches
86
+ if ( ! empty( $_GET[ 'backwpup_run' ] ) && class_exists( 'BackWPup_Job' ) ) {
87
  BackWPup_Job::disable_caches();
88
+ }
89
  // add normal cron actions
90
  add_action( 'backwpup_cron', array( 'BackWPup_Cron', 'run' ) );
91
  add_action( 'backwpup_check_cleanup', array( 'BackWPup_Cron', 'check_cleanup' ) );
92
  // add action for doing thinks if cron active
93
+ // must done in wp_loaded so that all is really loaded and initiated
94
+ add_action( 'wp_loaded', array( 'BackWPup_Cron', 'cron_active' ), 999 );
95
  // if in cron the rest must not needed
96
  return;
97
  }
98
  //deactivation hook
99
  register_deactivation_hook( __FILE__, array( 'BackWPup_Install', 'deactivate' ) );
100
+ //Admin bar
101
+ if ( is_admin_bar_showing() && current_user_can( 'backwpup' ) && get_site_option( 'backwpup_cfg_showadminbar' ) ) {
102
+ add_action( 'init', array( 'BackWPup_Adminbar', 'get_instance' ) );
103
+ }
104
  //only in backend
105
+ if ( is_admin() && class_exists( 'BackWPup_Admin' ) ) {
106
  BackWPup_Admin::get_instance();
107
+ }
108
  //work with wp-cli
109
+ if ( defined( 'WP_CLI' ) && WP_CLI && method_exists( 'WP_CLI', 'add_command' ) ) {
110
  WP_CLI::add_command( 'backwpup', 'BackWPup_WP_CLI' );
111
+ }
112
  }
113
 
114
  /**
232
  }
233
  }
234
 
235
+ //Google SDK Auto loading
236
+ $classPath = explode( '_', $class );
237
+ if ( $classPath[0] == 'Google' ) {
238
+ if ( count( $classPath ) > 3 ) {
239
+ $classPath = array_slice( $classPath, 0, 3 );
240
+ }
241
+ $filePath = self::get_plugin_data( 'plugindir' ) . '/vendor/' . implode( '/', $classPath ) . '.php';
242
+ if ( file_exists( $filePath ) ) {
243
+ require $filePath;
244
+ }
245
+ }
246
 
 
 
 
247
  }
248
 
249
  /**
307
  ),
308
  'can_sync' => FALSE,
309
  'needed' => array(
310
+ 'php_version' => '5.2.4',
311
  'functions' => array(),
312
  'classes' => array()
313
  ),
314
+ 'autoload' => array()
315
  );
316
  // backup to ftp
317
  self::$registered_destinations[ 'FTP' ] = array(
inc/class-admin.php CHANGED
@@ -1,573 +1,574 @@
1
- <?php
2
- /**
3
- *
4
- */
5
- final class BackWPup_Admin {
6
-
7
- private static $instance = NULL;
8
- public $page_hooks = array();
9
-
10
- /**
11
- *
12
- * Set needed filters and actions and load all needed
13
- *
14
- * @return \BackWPup_Admin
15
- */
16
- public function __construct() {
17
-
18
- //Load text domain
19
- if ( ! is_textdomain_loaded( 'backwpup' ) )
20
- load_plugin_textdomain( 'backwpup', FALSE, BackWPup::get_plugin_data( 'BaseName' ) . '/languages' );
21
-
22
- //Add menu pages
23
- add_filter( 'backwpup_admin_pages', array( $this, 'admin_page_jobs' ), 2 );
24
- add_filter( 'backwpup_admin_pages', array( $this, 'admin_page_editjob' ), 3 );
25
- add_filter( 'backwpup_admin_pages', array( $this, 'admin_page_logs' ), 4 );
26
- add_filter( 'backwpup_admin_pages', array( $this, 'admin_page_backups' ), 5 );
27
- add_filter( 'backwpup_admin_pages', array( $this, 'admin_page_settings' ), 6 );
28
- add_filter( 'backwpup_admin_pages', array( $this, 'admin_page_about' ), 20 );
29
-
30
- //Add Menu
31
- if ( is_multisite() )
32
- add_action( 'network_admin_menu', array( $this, 'admin_menu' ) );
33
- else
34
- add_action( 'admin_menu', array( $this, 'admin_menu' ) );
35
- //add Plugin links
36
- add_filter( 'plugin_row_meta', array( $this, 'plugin_links' ), 10, 2 );
37
- //add more actions
38
- add_action( 'admin_init', array( $this, 'admin_init' ) );
39
- //add more actions
40
- add_action( 'admin_head', array( $this, 'admin_head' ) );
41
- //Save Form posts general
42
- add_action( 'admin_post_backwpup', array( $this, 'save_post_form' ) );
43
- //Save Form posts wizard
44
- add_action( 'admin_post_backwpup_wizard', array( 'BackWPup_Pro_Page_Wizard', 'save_post_form' ) );
45
- //Admin Footer Text replacement
46
- add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 100 );
47
- add_filter( 'update_footer', array( $this, 'update_footer' ), 100 );
48
- //User Profile fields
49
- add_action( 'show_user_profile', array( $this, 'user_profile_fields' ) );
50
- add_action( 'edit_user_profile', array( $this, 'user_profile_fields' ) );
51
- add_action( 'profile_update', array( $this, 'save_profile_update' ) );
52
- add_filter( 'editable_roles', array( $this, 'editable_roles' ) );
53
- add_filter( 'manage_users_columns', array( $this, 'manage_users_columns' ) );
54
- add_filter( 'manage_users_custom_column', array( $this, 'manage_users_custom_column' ), 10, 3 );
55
- //Change Backup message on core updates
56
- add_filter( 'gettext', array( $this, 'gettext' ), 10, 3 );
57
- }
58
-
59
- /**
60
- * @static
61
- * @return \BackWPup
62
- */
63
- public static function get_instance() {
64
-
65
- if (NULL === self::$instance) {
66
- self::$instance = new self;
67
- }
68
- return self::$instance;
69
- }
70
-
71
- private function __clone() {}
72
-
73
- /**
74
- * Admin init function
75
- */
76
- public function admin_init() {
77
-
78
- //only add action if ajax call
79
- if ( defined( 'DOING_AJAX' ) && DOING_AJAX && defined( 'WP_ADMIN' ) && WP_ADMIN ) {
80
- //ajax calls
81
- add_action( 'wp_ajax_backwpup_working', array( 'BackWPup_Page_Jobs', 'ajax_working' ) );
82
- add_action( 'wp_ajax_backwpup_cron_text', array( 'BackWPup_Page_Editjob', 'ajax_cron_text' ) );
83
- //ajax or view logs
84
- add_action( 'wp_ajax_backwpup_view_log', array( 'BackWPup_Page_Logs', 'ajax_view_log' ) );
85
- //ajax calls for job types
86
- if ( $jobtypes = BackWPup::get_job_types() ) {
87
- foreach ( $jobtypes as $id => $jobtypeclass ) {
88
- add_action( 'wp_ajax_backwpup_jobtype_' . strtolower( $id ), array( $jobtypeclass, 'edit_ajax' ) );
89
- }
90
- }
91
- //ajax calls for destinations
92
- if ( $dests = BackWPup::get_registered_destinations() ) {
93
- foreach ( $dests as $id => $dest ) {
94
- if ( ! empty( $dest[ 'class' ] ) )
95
- add_action( 'wp_ajax_backwpup_dest_' . strtolower( $id ), array( BackWPup::get_destination( $id ), 'edit_ajax' ) );
96
- }
97
- }
98
- }
99
-
100
- //display about page after Update
101
- if ( ! defined( 'DOING_AJAX' ) && ! get_site_option( 'backwpup_about_page', FALSE ) && ! isset( $_GET['activate-multi'] ) ) {
102
- update_site_option( 'backwpup_about_page', TRUE );
103
- wp_redirect( network_admin_url( 'admin.php' ) . '?page=backwpupabout' );
104
- exit();
105
- }
106
- }
107
-
108
- /**
109
- * Admin init function
110
- */
111
- public static function admin_head() {
112
-
113
- //register js and css for BackWPup
114
- if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
115
- wp_enqueue_style( 'backwpup', BackWPup::get_plugin_data( 'URL' ) . '/assets/css/backwpup.css', array(), time(), 'screen' );
116
- if ( version_compare( BackWPup::get_plugin_data( 'wp_version' ), '3.8-beta-1', '<' ) )
117
- wp_enqueue_style( 'backwpup-wplt38', BackWPup::get_plugin_data( 'URL' ) . '/assets/css/lower_wp38.css', array( 'backwpup' ), time(), 'screen' );
118
- } else {
119
- wp_enqueue_style( 'backwpup', BackWPup::get_plugin_data( 'URL' ) . '/assets/css/backwpup.min.css', array(), BackWPup::get_plugin_data( 'Version' ), 'screen' );
120
- if ( version_compare( BackWPup::get_plugin_data( 'wp_version' ), '3.8-beta-1', '<' ) )
121
- wp_enqueue_style( 'backwpup-wplt38', BackWPup::get_plugin_data( 'URL' ) . '/assets/css/lower_wp38.min.css', array( 'backwpup' ), BackWPup::get_plugin_data( 'Version' ), 'screen' );
122
- }
123
- }
124
-
125
- /**
126
- *
127
- * Add Links in Plugins Menu to BackWPup
128
- *
129
- * @param $links
130
- * @param $file
131
- * @return array
132
- */
133
- public function plugin_links( $links, $file ) {
134
-
135
- if ( $file == plugin_basename( BackWPup::get_plugin_data( 'MainFile' ) ) ) {
136
- $links[ ] = '<a href="' . __( 'https://marketpress.com/documentation/backwpup-pro/', 'backwpup' ) . '">' . __( 'Documentation', 'backwpup' ) . '</a>';
137
- if ( class_exists( 'BackWPup_Pro', FALSE ) )
138
- $links[ ] = '<a href="' . __( 'https://marketpress.com/support/forum/plugins/backwpup-pro/', 'backwpup' ) . '">' . __( 'Pro Support', 'backwpup' ) . '</a>';
139
- else
140
- $links[ ] = '<a href="' . __( 'http://wordpress.org/support/plugin/backwpup/', 'backwpup' ) . '">' . __( 'Support', 'backwpup' ) . '</a>';
141
-
142
- }
143
-
144
- return $links;
145
- }
146
-
147
- /**
148
- * Add menu entries
149
- */
150
- public function admin_menu() {
151
-
152
- add_menu_page( BackWPup::get_plugin_data( 'name' ), BackWPup::get_plugin_data( 'name' ), 'backwpup', 'backwpup', array( 'BackWPup_Page_Backwpup', 'page' ), 'div' );
153
- $this->page_hooks[ 'backwpup' ] = add_submenu_page( 'backwpup', __( 'BackWPup Dashboard', 'backwpup' ), __( 'Dashboard', 'backwpup' ), 'backwpup', 'backwpup', array( 'BackWPup_Page_Backwpup', 'page' ) );
154
- add_action( 'load-' . $this->page_hooks[ 'backwpup' ], array( 'BackWPup_Admin', 'init_generel' ) );
155
- add_action( 'load-' . $this->page_hooks[ 'backwpup' ], array( 'BackWPup_Page_Backwpup', 'load' ) );
156
- add_action( 'admin_print_scripts-' . $this->page_hooks[ 'backwpup' ], array( 'BackWPup_Page_Backwpup', 'admin_print_scripts' ) );
157
-
158
- //Add pages form plugins
159
- $this->page_hooks = apply_filters( 'backwpup_admin_pages' ,$this->page_hooks );
160
-
161
- }
162
-
163
-
164
- /**
165
- * @param $page_hooks
166
- * @return mixed
167
- */
168
- public function admin_page_jobs( $page_hooks ) {
169
-
170
- $this->page_hooks[ 'backwpupjobs' ] = add_submenu_page( 'backwpup', __( 'Jobs', 'backwpup' ), __( 'Jobs', 'backwpup' ), 'backwpup_jobs', 'backwpupjobs', array( 'BackWPup_Page_Jobs', 'page' ) );
171
- add_action( 'load-' . $this->page_hooks[ 'backwpupjobs' ], array( 'BackWPup_Admin', 'init_generel' ) );
172
- add_action( 'load-' . $this->page_hooks[ 'backwpupjobs' ], array( 'BackWPup_Page_Jobs', 'load' ) );
173
- add_action( 'admin_print_styles-' . $this->page_hooks[ 'backwpupjobs' ], array( 'BackWPup_Page_Jobs', 'admin_print_styles' ) );
174
- add_action( 'admin_print_scripts-' . $this->page_hooks[ 'backwpupjobs' ], array( 'BackWPup_Page_Jobs', 'admin_print_scripts' ) );
175
-
176
- return $page_hooks;
177
- }
178
-
179
- /**
180
- * @param $page_hooks
181
- * @return mixed
182
- */
183
- public function admin_page_editjob( $page_hooks ) {
184
-
185
- $this->page_hooks[ 'backwpupeditjob' ] = add_submenu_page( 'backwpup', __( 'Add new job', 'backwpup' ), __( 'Add new job', 'backwpup' ), 'backwpup_jobs_edit', 'backwpupeditjob', array( 'BackWPup_Page_Editjob', 'page' ) );
186
- add_action( 'load-' . $this->page_hooks[ 'backwpupeditjob' ], array( 'BackWPup_Admin', 'init_generel' ) );
187
- add_action( 'load-' . $this->page_hooks[ 'backwpupeditjob' ], array( 'BackWPup_Page_Editjob', 'auth' ) );
188
- add_action( 'load-' . $this->page_hooks[ 'backwpupeditjob' ], array( 'BackWPup_Page_Editjob', 'load' ) );
189
- add_action( 'admin_print_styles-' . $this->page_hooks[ 'backwpupeditjob' ], array( 'BackWPup_Page_Editjob', 'admin_print_styles' ) );
190
- add_action( 'admin_print_scripts-' . $this->page_hooks[ 'backwpupeditjob' ], array( 'BackWPup_Page_Editjob', 'admin_print_scripts' ) );
191
-
192
- return $page_hooks;
193
- }
194
-
195
- /**
196
- * @param $page_hooks
197
- * @return mixed
198
- */
199
- public function admin_page_logs( $page_hooks ) {
200
-
201
- $this->page_hooks[ 'backwpuplogs' ] = add_submenu_page( 'backwpup', __( 'Logs', 'backwpup' ), __( 'Logs', 'backwpup' ), 'backwpup_logs', 'backwpuplogs', array( 'BackWPup_Page_Logs', 'page' ) );
202
- add_action( 'load-' . $this->page_hooks[ 'backwpuplogs' ], array( 'BackWPup_Admin', 'init_generel' ) );
203
- add_action( 'load-' . $this->page_hooks[ 'backwpuplogs' ], array( 'BackWPup_Page_Logs', 'load' ) );
204
- add_action( 'admin_print_styles-' . $this->page_hooks[ 'backwpuplogs' ], array( 'BackWPup_Page_Logs', 'admin_print_styles' ) );
205
- add_action( 'admin_print_scripts-' . $this->page_hooks[ 'backwpuplogs' ], array( 'BackWPup_Page_Logs', 'admin_print_scripts' ) );
206
-
207
- return $page_hooks;
208
- }
209
-
210
- /**
211
- * @param $page_hooks
212
- * @return mixed
213
- */
214
- public function admin_page_backups( $page_hooks ) {
215
-
216
- $this->page_hooks[ 'backwpupbackups' ] = add_submenu_page( 'backwpup', __( 'Backups', 'backwpup' ), __( 'Backups', 'backwpup' ), 'backwpup_backups', 'backwpupbackups', array( 'BackWPup_Page_Backups', 'page' ) );
217
- add_action( 'load-' . $this->page_hooks[ 'backwpupbackups' ], array( 'BackWPup_Admin', 'init_generel' ) );
218
- add_action( 'load-' . $this->page_hooks[ 'backwpupbackups' ], array( 'BackWPup_Page_Backups', 'load' ) );
219
- add_action( 'admin_print_styles-' . $this->page_hooks[ 'backwpupbackups' ], array( 'BackWPup_Page_Backups', 'admin_print_styles' ) );
220
- add_action( 'admin_print_scripts-' . $this->page_hooks[ 'backwpupbackups' ], array( 'BackWPup_Page_Backups', 'admin_print_scripts' ) );
221
-
222
- return $page_hooks;
223
- }
224
-
225
- /**
226
- * @param $page_hooks
227
- * @return mixed
228
- */
229
- public function admin_page_settings( $page_hooks ) {
230
-
231
- $this->page_hooks[ 'backwpupsettings' ] = add_submenu_page( 'backwpup', __( 'Settings', 'backwpup' ), __( 'Settings', 'backwpup' ), 'backwpup_settings', 'backwpupsettings', array( 'BackWPup_Page_Settings', 'page' ) );
232
- add_action( 'load-' . $this->page_hooks[ 'backwpupsettings' ], array( 'BackWPup_Admin', 'init_generel' ) );
233
- add_action( 'admin_print_scripts-' . $this->page_hooks[ 'backwpupsettings' ], array( 'BackWPup_Page_Settings', 'admin_print_scripts' ) );
234
-
235
- return $page_hooks;
236
- }
237
-
238
- /**
239
- * @param $page_hooks
240
- * @return mixed
241
- */
242
- public function admin_page_about( $page_hooks ) {
243
-
244
- $this->page_hooks[ 'backwpupabout' ] = add_submenu_page( 'backwpup', __( 'About', 'backwpup' ), __( 'About', 'backwpup' ), 'backwpup', 'backwpupabout', array( 'BackWPup_Page_About', 'page' ) );
245
- add_action( 'load-' . $this->page_hooks[ 'backwpupabout' ], array( 'BackWPup_Admin', 'init_generel' ) );
246
- add_action( 'admin_print_styles-' . $this->page_hooks[ 'backwpupabout' ], array( 'BackWPup_Page_About', 'admin_print_styles' ) );
247
- add_action( 'admin_print_scripts-' . $this->page_hooks[ 'backwpupabout' ], array( 'BackWPup_Page_About', 'admin_print_scripts' ) );
248
-
249
- return $page_hooks;
250
- }
251
-
252
-
253
- /**
254
- * Load for all BackWPup pages
255
- */
256
- public static function init_generel() {
257
-
258
- add_thickbox();
259
-
260
- //register js and css for BackWPup
261
- if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
262
- wp_register_script( 'backwpuptiptip', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/jquery.tipTip.js', array( 'jquery' ), '1.3.1', TRUE );
263
- wp_register_script( 'backwpupgeneral', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/general.js', array( 'jquery', 'backwpuptiptip' ), time(), TRUE );
264
- } else {
265
- wp_register_script( 'backwpuptiptip', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3.1', TRUE );
266
- wp_register_script( 'backwpupgeneral', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/general.min.js', array( 'jquery', 'backwpuptiptip' ), BackWPup::get_plugin_data( 'Version' ), TRUE );
267
- }
268
-
269
- //add Help
270
- BackWPup_Help::help();
271
- }
272
-
273
-
274
- /**
275
- * Called on save form. Only POST allowed.
276
- */
277
- public function save_post_form() {
278
-
279
- //Allowed Pages
280
- if ( ! in_array( $_POST[ 'page' ], array ( 'backwpupeditjob', 'backwpupinformation', 'backwpupsettings' ) ) )
281
- wp_die( __( 'Cheating, huh?', 'backwpup' ) );
282
-
283
- //nonce check
284
- check_admin_referer( $_POST[ 'page' ] . '_page' );
285
-
286
- if ( ! current_user_can( 'backwpup' ) )
287
- wp_die( __( 'Cheating, huh?', 'backwpup' ) );
288
-
289
- //build query for redirect
290
- if ( ! isset( $_POST[ 'anchor' ] ) )
291
- $_POST[ 'anchor' ] = NULL;
292
- $query_args=array();
293
- if ( isset( $_POST[ 'page' ] ) )
294
- $query_args[ 'page' ] = $_POST[ 'page' ];
295
- if ( isset( $_POST[ 'tab' ] ) )
296
- $query_args[ 'tab' ] = $_POST[ 'tab' ];
297
- if ( isset( $_POST[ 'tab' ] ) && isset( $_POST[ 'nexttab' ] ) && $_POST[ 'tab' ] != $_POST[ 'nexttab' ] )
298
- $query_args[ 'tab' ] = $_POST[ 'nexttab' ];
299
-
300
- $jobid = NULL;
301
- if ( isset( $_POST[ 'jobid' ] ) ) {
302
- $jobid = (int) $_POST[ 'jobid' ];
303
- $query_args[ 'jobid' ] = $jobid;
304
- }
305
-
306
- //Call method to save data
307
- if ( $_POST[ 'page' ] == 'backwpupeditjob' )
308
- BackWPup_Page_Editjob::save_post_form( $_POST[ 'tab' ], $jobid );
309
- elseif ( $_POST[ 'page' ] == 'backwpupsettings' ) {
310
- BackWPup_Page_Settings::save_post_form();
311
- }
312
-
313
- //Back to topic
314
- wp_safe_redirect( add_query_arg( $query_args, network_admin_url( 'admin.php' ) ) . $_POST[ 'anchor' ] );
315
- exit;
316
- }
317
-
318
- /**
319
- * Add Message (across site loadings)
320
- *
321
- * @param $message string Message test
322
- * @param $error bool ist it a error message
323
- */
324
- public static function message( $message, $error = FALSE ) {
325
-
326
-
327
- $saved_message = self::get_messages();
328
-
329
- if ( $error )
330
- $saved_message[ 'error' ][] = $message;
331
- else
332
- $saved_message[ 'updated' ][] = $message;
333
-
334
- update_site_option( 'backwpup_messages', $saved_message );
335
- }
336
-
337
- /**
338
- * Get all Message that not displayed
339
- *
340
- * @return array
341
- */
342
- public static function get_messages() {
343
-
344
- return get_site_option( 'backwpup_messages', array() );
345
- }
346
-
347
- /**
348
- * Display Messages
349
- *
350
- * @param bool $echo
351
- * @return string
352
- */
353
- public static function display_messages( $echo = TRUE ) {
354
-
355
- $message_updated= '';
356
- $message_error = '';
357
- $saved_message = self::get_messages();
358
- $message_id = ' id="message"';
359
-
360
- if( empty( $saved_message ) )
361
- return '';
362
-
363
- if ( ! empty( $saved_message[ 'updated' ] ) ) {
364
- foreach( $saved_message[ 'updated' ] as $msg )
365
- $message_updated .= '<p>' . $msg . '</p>';
366
- }
367
- if ( ! empty( $saved_message[ 'error' ] ) ) {
368
- foreach( $saved_message[ 'error' ] as $msg )
369
- $message_error .= '<p>' . $msg . '</p>';
370
- }
371
-
372
- update_site_option( 'backwpup_messages', array() );
373
-
374
- if ( ! empty( $message_updated ) ) {
375
- $message_updated = '<div' . $message_id . ' class="updated">' . $message_updated . '</div>';
376
- $message_id = '';
377
- }
378
- if ( ! empty( $message_error ) ) {
379
- $message_error = '<div' . $message_id . ' class="error">' . $message_error . '</div>';
380
- }
381
-
382
- if ( $echo )
383
- echo $message_updated . $message_error;
384
-
385
- return $message_updated . $message_error;
386
- }
387
-
388
- /**
389
- * Overrides WordPress text in Footer
390
- *
391
- * @param $admin_footer_text string
392
- * @return string
393
- */
394
- public function admin_footer_text( $admin_footer_text ) {
395
-
396
- $default_text = $admin_footer_text;
397
-
398
- if ( isset( $_REQUEST[ 'page' ] ) && strstr( $_REQUEST[ 'page' ], 'backwpup' ) ) {
399
- $admin_footer_text = '<a href="' . __( 'http://marketpress.com', 'backwpup' ) . '" class="mp_logo" title="' . __( 'MarketPress', 'backwpup' ) . '">' . __( 'MarketPress', 'backwpup' ) . '</a>';
400
- if ( ! class_exists( 'BackWPup_Pro', FALSE ) )
401
- $admin_footer_text .= sprintf( __( '<a class="backwpup-get-pro" href="%s">Get BackWPup Pro now.</a>', 'backwpup' ), __( 'http://marketpress.com/product/backwpup-pro/', 'backwpup' ) );
402
-
403
- return $admin_footer_text . $default_text;
404
- }
405
-
406
- return $admin_footer_text;
407
- }
408
-
409
- /**
410
- * Overrides WordPress Version in Footer
411
- *
412
- * @param $update_footer_text string
413
- * @return string
414
- */
415
- public function update_footer( $update_footer_text ) {
416
-
417
- $default_text = $update_footer_text;
418
-
419
- if ( isset( $_REQUEST[ 'page' ] ) && strstr( $_REQUEST[ 'page' ], 'backwpup') ) {
420
- $update_footer_text = '<span class="backwpup-update-footer"><a href="' . translate( BackWPup::get_plugin_data( 'PluginURI' ), 'backwpup' ) . '">' . BackWPup::get_plugin_data( 'Name' ) . '</a> '. sprintf( __( 'version %s' ,'backwpup'), BackWPup::get_plugin_data( 'Version' ) ) . '</span>';
421
-
422
- return $update_footer_text . $default_text;
423
- }
424
-
425
- return $update_footer_text;
426
- }
427
-
428
-
429
- /**
430
- * Add filed for selecting user role in user section
431
- *
432
- * @param $user WP_User
433
- */
434
- public function user_profile_fields( $user ) {
435
- global $wp_roles;
436
-
437
- if ( ! is_super_admin() && ! current_user_can( 'backwpup_admin' ) )
438
- return;
439
- ?>
440
- <h3><?php echo BackWPup::get_plugin_data( 'name' ); ?></h3>
441
- <table class="form-table">
442
- <tr>
443
- <th>
444
- <label for="backwpup_role"><?php _e( 'BackWPup Role', 'backwpup' ); ?>
445
- </label></th>
446
- <td>
447
- <select name="backwpup_role" id="backwpup_role" style="display:inline-block; float:none;">
448
- <option value=""><?php _e( '&mdash; No role for BackWPup &mdash;', 'backwpup' ); ?></option>
449
- <?php
450
- foreach ( $wp_roles->roles as $role => $rolevalue ) {
451
- if ( substr( $role, 0, 8 ) != 'backwpup' )
452
- continue;
453
- echo '<option value="'.$role.'" '. selected( in_array( $role, $user->roles ), TRUE, FALSE ) .'>'. $rolevalue[ 'name' ] . '</option>';
454
- }
455
- ?>
456
- </select>
457
- <br />
458
- <span class="description"><?php _e( 'Role that the user have on BackWPup', 'backwpup' ); ?></span>
459
- </td>
460
- </tr>
461
- </table>
462
- <?php
463
- }
464
-
465
- /**
466
- * Save for user role adding
467
- *
468
- * @param $user_id int
469
- */
470
- public function save_profile_update( $user_id ) {
471
- global $wp_roles;
472
-
473
- if ( ! is_super_admin() && ! current_user_can( 'backwpup_admin' ) )
474
- return;
475
-
476
- if ( empty( $user_id ) )
477
- return;
478
-
479
- if ( ! isset( $_POST['backwpup_role'] ) )
480
- return;
481
-
482
- // get BackWPup roles
483
- $backwpup_roles = array();
484
- foreach ( array_keys( $wp_roles->roles ) as $role ) {
485
- if ( ! strstr( $role, 'backwpup_' ) )
486
- continue;
487
- $backwpup_roles[] = $role;
488
- }
489
-
490
- //get user for adding/removing role
491
- $user = new WP_User( $user_id );
492
- //remove BackWPup role from user
493
- foreach ( $user->roles as $role ) {
494
- if ( ! strstr( $role, 'backwpup_' ) )
495
- continue;
496
- $user->remove_role( $role );
497
- }
498
- //add new role to user
499
- if ( ! empty( $_POST['backwpup_role'] ) && in_array( $_POST['backwpup_role'], $backwpup_roles ) )
500
- $user->add_role( $_POST['backwpup_role'] );
501
-
502
- return;
503
- }
504
-
505
- public function gettext( $translations, $text, $domain ) {
506
-
507
- if ( strstr( $text, '<a href="http://codex.wordpress.org/WordPress_Backups">back up your database and files</a>' ) )
508
- return sprintf( __( '<strong>Important:</strong> before updating, please <a href="%1$s">back up your database and files</a> with <a href="http://marketpress.de/product/backwpup-pro/">%2$s</a>. For help with updates, visit the <a href="http://codex.wordpress.org/Updating_WordPress">Updating WordPress</a> Codex page.', 'backwpup' ), network_admin_url( 'admin.php?page=backwpupjobs' ), BackWPup::get_plugin_data( 'name' ) );
509
-
510
- if ( strstr( $text, 'This plugin has <strong>not been tested</strong> with your current version of WordPress.' ) )
511
- return $translations . '</p></div><div class="updated"><p>' .sprintf( __( '<strong>Important:</strong> before installing this plugin, please <a href="%1$s">back up your database and files</a> with <a href="http://marketpress.de/product/backwpup-pro/">%2$s</a>.', 'backwpup' ), network_admin_url( 'admin.php?page=backwpupjobs' ), BackWPup::get_plugin_data( 'name' ) );
512
-
513
- if ( strstr( $text, 'This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.' ) )
514
- return $translations . '</p></div><div class="updated"><p>' .sprintf( __( '<strong>Important:</strong> before installing this plugin, please <a href="%1$s">back up your database and files</a> with <a href="http://marketpress.de/product/backwpup-pro/">%2$s</a>.', 'backwpup' ), network_admin_url( 'admin.php?page=backwpupjobs' ), BackWPup::get_plugin_data( 'name' ) );
515
-
516
-
517
- return $translations;
518
- }
519
-
520
- /**
521
- * Filter BackWPup roles from displaying in normal WP roles selection
522
- *
523
- * @param $all_roles
524
- * @return mixed
525
- */
526
- public function editable_roles( $all_roles ) {
527
-
528
- foreach( $all_roles AS $key => $role ) {
529
- if ( substr( $key, 0, 8 ) == 'backwpup' )
530
- unset( $all_roles[$key] );
531
- }
532
-
533
- return $all_roles;
534
- }
535
-
536
- /**
537
- * Add column for displaying BAckWPup user role
538
- *
539
- * @param $columns
540
- * @return mixed
541
- */
542
- public function manage_users_columns( $columns ) {
543
-
544
- $columns[ 'backwpup_role' ] = __( 'BackWPup Role', 'backwpup' );
545
- return $columns;
546
- }
547
-
548
- /**
549
- * Display BackWPup user role in column
550
- *
551
- * @param $value
552
- * @param $column_name
553
- * @param $user_id
554
- * @return string
555
- */
556
- public function manage_users_custom_column( $value, $column_name, $user_id ) {
557
- global $wp_roles;
558
-
559
- if ( 'backwpup_role' != $column_name )
560
- return $value;
561
-
562
- $user = get_userdata( $user_id );
563
-
564
- foreach ( $user->roles as $role ) {
565
- if ( substr( $role, 0, 8 ) == 'backwpup' ) {
566
- $value .= $wp_roles->roles[ $role ][ 'name' ]. '<br />';
567
- }
568
- }
569
-
570
- return $value;
571
- }
572
-
573
- }
 
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ final class BackWPup_Admin {
6
+
7
+ private static $instance = NULL;
8
+ public $page_hooks = array();
9
+
10
+ /**
11
+ *
12
+ * Set needed filters and actions and load all needed
13
+ *
14
+ * @return \BackWPup_Admin
15
+ */
16
+ public function __construct() {
17
+
18
+ //Load text domain
19
+ if ( ! is_textdomain_loaded( 'backwpup' ) )
20
+ load_plugin_textdomain( 'backwpup', FALSE, BackWPup::get_plugin_data( 'BaseName' ) . '/languages' );
21
+
22
+ //Add menu pages
23
+ add_filter( 'backwpup_admin_pages', array( $this, 'admin_page_jobs' ), 2 );
24
+ add_filter( 'backwpup_admin_pages', array( $this, 'admin_page_editjob' ), 3 );
25
+ add_filter( 'backwpup_admin_pages', array( $this, 'admin_page_logs' ), 4 );
26
+ add_filter( 'backwpup_admin_pages', array( $this, 'admin_page_backups' ), 5 );
27
+ add_filter( 'backwpup_admin_pages', array( $this, 'admin_page_settings' ), 6 );
28
+ add_filter( 'backwpup_admin_pages', array( $this, 'admin_page_about' ), 20 );
29
+
30
+ //Add Menu
31
+ if ( is_multisite() )
32
+ add_action( 'network_admin_menu', array( $this, 'admin_menu' ) );
33
+ else
34
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
35
+ //add Plugin links
36
+ add_filter( 'plugin_row_meta', array( $this, 'plugin_links' ), 10, 2 );
37
+ //add more actions
38
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
39
+ add_action( 'admin_init', array( __CLASS__, 'admin_css' ) );
40
+ //Save Form posts general
41
+ add_action( 'admin_post_backwpup', array( $this, 'save_post_form' ) );
42
+ //Save Form posts wizard
43
+ add_action( 'admin_post_backwpup_wizard', array( 'BackWPup_Pro_Page_Wizard', 'save_post_form' ) );
44
+ //Admin Footer Text replacement
45
+ add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 100 );
46
+ add_filter( 'update_footer', array( $this, 'update_footer' ), 100 );
47
+ //User Profile fields
48
+ add_action( 'show_user_profile', array( $this, 'user_profile_fields' ) );
49
+ add_action( 'edit_user_profile', array( $this, 'user_profile_fields' ) );
50
+ add_action( 'profile_update', array( $this, 'save_profile_update' ) );
51
+ add_filter( 'editable_roles', array( $this, 'editable_roles' ) );
52
+ add_filter( 'manage_users_columns', array( $this, 'manage_users_columns' ) );
53
+ add_filter( 'manage_users_custom_column', array( $this, 'manage_users_custom_column' ), 10, 3 );
54
+ //Change Backup message on core updates
55
+ add_filter( 'gettext', array( $this, 'gettext' ), 10, 3 );
56
+ }
57
+
58
+ /**
59
+ * @static
60
+ * @return \BackWPup
61
+ */
62
+ public static function get_instance() {
63
+
64
+ if (NULL === self::$instance) {
65
+ self::$instance = new self;
66
+ }
67
+ return self::$instance;
68
+ }
69
+
70
+ private function __clone() {}
71
+
72
+ /**
73
+ * Admin init function
74
+ */
75
+ public function admin_init() {
76
+
77
+ //only add action if ajax call
78
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX && defined( 'WP_ADMIN' ) && WP_ADMIN ) {
79
+ //ajax calls
80
+ add_action( 'wp_ajax_backwpup_working', array( 'BackWPup_Page_Jobs', 'ajax_working' ) );
81
+ add_action( 'wp_ajax_backwpup_cron_text', array( 'BackWPup_Page_Editjob', 'ajax_cron_text' ) );
82
+ //ajax or view logs
83
+ add_action( 'wp_ajax_backwpup_view_log', array( 'BackWPup_Page_Logs', 'ajax_view_log' ) );
84
+ //ajax calls for job types
85
+ if ( $jobtypes = BackWPup::get_job_types() ) {
86
+ foreach ( $jobtypes as $id => $jobtypeclass ) {
87
+ add_action( 'wp_ajax_backwpup_jobtype_' . strtolower( $id ), array( $jobtypeclass, 'edit_ajax' ) );
88
+ }
89
+ }
90
+ //ajax calls for destinations
91
+ if ( $dests = BackWPup::get_registered_destinations() ) {
92
+ foreach ( $dests as $id => $dest ) {
93
+ if ( ! empty( $dest[ 'class' ] ) )
94
+ add_action( 'wp_ajax_backwpup_dest_' . strtolower( $id ), array( BackWPup::get_destination( $id ), 'edit_ajax' ) );
95
+ }
96
+ }
97
+ }
98
+
99
+ //display about page after Update
100
+ if ( ! defined( 'DOING_AJAX' ) && ! get_site_option( 'backwpup_about_page', FALSE ) && ! isset( $_GET['activate-multi'] ) ) {
101
+ update_site_option( 'backwpup_about_page', TRUE );
102
+ wp_redirect( network_admin_url( 'admin.php' ) . '?page=backwpupabout' );
103
+ exit();
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Admin init function
109
+ */
110
+ public static function admin_css() {
111
+
112
+ //register js and css for BackWPup
113
+ if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
114
+ wp_enqueue_style( 'backwpup', BackWPup::get_plugin_data( 'URL' ) . '/assets/css/backwpup.css', array(), time(), 'screen' );
115
+ if ( version_compare( BackWPup::get_plugin_data( 'wp_version' ), '3.8-beta-1', '<' ) ) {
116
+ wp_enqueue_style( 'backwpup-wplt38', BackWPup::get_plugin_data( 'URL' ) . '/assets/css/lower_wp38.css', array( 'backwpup' ), time(), 'screen' );
117
+ }
118
+ } else {
119
+ wp_enqueue_style( 'backwpup', BackWPup::get_plugin_data( 'URL' ) . '/assets/css/backwpup.min.css', array(), BackWPup::get_plugin_data( 'Version' ), 'screen' );
120
+ if ( version_compare( BackWPup::get_plugin_data( 'wp_version' ), '3.8-beta-1', '<' ) ) {
121
+ wp_enqueue_style( 'backwpup-wplt38', BackWPup::get_plugin_data( 'URL' ) . '/assets/css/lower_wp38.min.css', array( 'backwpup' ), BackWPup::get_plugin_data( 'Version' ), 'screen' );
122
+ }
123
+ }
124
+ }
125
+
126
+ /**
127
+ *
128
+ * Add Links in Plugins Menu to BackWPup
129
+ *
130
+ * @param $links
131
+ * @param $file
132
+ * @return array
133
+ */
134
+ public function plugin_links( $links, $file ) {
135
+
136
+ if ( $file == plugin_basename( BackWPup::get_plugin_data( 'MainFile' ) ) ) {
137
+ $links[ ] = '<a href="' . __( 'https://marketpress.com/documentation/backwpup-pro/', 'backwpup' ) . '">' . __( 'Documentation', 'backwpup' ) . '</a>';
138
+ if ( class_exists( 'BackWPup_Pro', FALSE ) )
139
+ $links[ ] = '<a href="' . __( 'https://marketpress.com/support/forum/plugins/backwpup-pro/', 'backwpup' ) . '">' . __( 'Pro Support', 'backwpup' ) . '</a>';
140
+ else
141
+ $links[ ] = '<a href="' . __( 'http://wordpress.org/support/plugin/backwpup/', 'backwpup' ) . '">' . __( 'Support', 'backwpup' ) . '</a>';
142
+
143
+ }
144
+
145
+ return $links;
146
+ }
147
+
148
+ /**
149
+ * Add menu entries
150
+ */
151
+ public function admin_menu() {
152
+
153
+ add_menu_page( BackWPup::get_plugin_data( 'name' ), BackWPup::get_plugin_data( 'name' ), 'backwpup', 'backwpup', array( 'BackWPup_Page_Backwpup', 'page' ), 'div' );
154
+ $this->page_hooks[ 'backwpup' ] = add_submenu_page( 'backwpup', __( 'BackWPup Dashboard', 'backwpup' ), __( 'Dashboard', 'backwpup' ), 'backwpup', 'backwpup', array( 'BackWPup_Page_Backwpup', 'page' ) );
155
+ add_action( 'load-' . $this->page_hooks[ 'backwpup' ], array( 'BackWPup_Admin', 'init_generel' ) );
156
+ add_action( 'load-' . $this->page_hooks[ 'backwpup' ], array( 'BackWPup_Page_Backwpup', 'load' ) );
157
+ add_action( 'admin_print_scripts-' . $this->page_hooks[ 'backwpup' ], array( 'BackWPup_Page_Backwpup', 'admin_print_scripts' ) );
158
+
159
+ //Add pages form plugins
160
+ $this->page_hooks = apply_filters( 'backwpup_admin_pages' ,$this->page_hooks );
161
+
162
+ }
163
+
164
+
165
+ /**
166
+ * @param $page_hooks
167
+ * @return mixed
168
+ */
169
+ public function admin_page_jobs( $page_hooks ) {
170
+
171
+ $this->page_hooks[ 'backwpupjobs' ] = add_submenu_page( 'backwpup', __( 'Jobs', 'backwpup' ), __( 'Jobs', 'backwpup' ), 'backwpup_jobs', 'backwpupjobs', array( 'BackWPup_Page_Jobs', 'page' ) );
172
+ add_action( 'load-' . $this->page_hooks[ 'backwpupjobs' ], array( 'BackWPup_Admin', 'init_generel' ) );
173
+ add_action( 'load-' . $this->page_hooks[ 'backwpupjobs' ], array( 'BackWPup_Page_Jobs', 'load' ) );
174
+ add_action( 'admin_print_styles-' . $this->page_hooks[ 'backwpupjobs' ], array( 'BackWPup_Page_Jobs', 'admin_print_styles' ) );
175
+ add_action( 'admin_print_scripts-' . $this->page_hooks[ 'backwpupjobs' ], array( 'BackWPup_Page_Jobs', 'admin_print_scripts' ) );
176
+
177
+ return $page_hooks;
178
+ }
179
+
180
+ /**
181
+ * @param $page_hooks
182
+ * @return mixed
183
+ */
184
+ public function admin_page_editjob( $page_hooks ) {
185
+
186
+ $this->page_hooks[ 'backwpupeditjob' ] = add_submenu_page( 'backwpup', __( 'Add new job', 'backwpup' ), __( 'Add new job', 'backwpup' ), 'backwpup_jobs_edit', 'backwpupeditjob', array( 'BackWPup_Page_Editjob', 'page' ) );
187
+ add_action( 'load-' . $this->page_hooks[ 'backwpupeditjob' ], array( 'BackWPup_Admin', 'init_generel' ) );
188
+ add_action( 'load-' . $this->page_hooks[ 'backwpupeditjob' ], array( 'BackWPup_Page_Editjob', 'auth' ) );
189
+ add_action( 'load-' . $this->page_hooks[ 'backwpupeditjob' ], array( 'BackWPup_Page_Editjob', 'load' ) );
190
+ add_action( 'admin_print_styles-' . $this->page_hooks[ 'backwpupeditjob' ], array( 'BackWPup_Page_Editjob', 'admin_print_styles' ) );
191
+ add_action( 'admin_print_scripts-' . $this->page_hooks[ 'backwpupeditjob' ], array( 'BackWPup_Page_Editjob', 'admin_print_scripts' ) );
192
+
193
+ return $page_hooks;
194
+ }
195
+
196
+ /**
197
+ * @param $page_hooks
198
+ * @return mixed
199
+ */
200
+ public function admin_page_logs( $page_hooks ) {
201
+
202
+ $this->page_hooks[ 'backwpuplogs' ] = add_submenu_page( 'backwpup', __( 'Logs', 'backwpup' ), __( 'Logs', 'backwpup' ), 'backwpup_logs', 'backwpuplogs', array( 'BackWPup_Page_Logs', 'page' ) );
203
+ add_action( 'load-' . $this->page_hooks[ 'backwpuplogs' ], array( 'BackWPup_Admin', 'init_generel' ) );
204
+ add_action( 'load-' . $this->page_hooks[ 'backwpuplogs' ], array( 'BackWPup_Page_Logs', 'load' ) );
205
+ add_action( 'admin_print_styles-' . $this->page_hooks[ 'backwpuplogs' ], array( 'BackWPup_Page_Logs', 'admin_print_styles' ) );
206
+ add_action( 'admin_print_scripts-' . $this->page_hooks[ 'backwpuplogs' ], array( 'BackWPup_Page_Logs', 'admin_print_scripts' ) );
207
+
208
+ return $page_hooks;
209
+ }
210
+
211
+ /**
212
+ * @param $page_hooks
213
+ * @return mixed
214
+ */
215
+ public function admin_page_backups( $page_hooks ) {
216
+
217
+ $this->page_hooks[ 'backwpupbackups' ] = add_submenu_page( 'backwpup', __( 'Backups', 'backwpup' ), __( 'Backups', 'backwpup' ), 'backwpup_backups', 'backwpupbackups', array( 'BackWPup_Page_Backups', 'page' ) );
218
+ add_action( 'load-' . $this->page_hooks[ 'backwpupbackups' ], array( 'BackWPup_Admin', 'init_generel' ) );
219
+ add_action( 'load-' . $this->page_hooks[ 'backwpupbackups' ], array( 'BackWPup_Page_Backups', 'load' ) );
220
+ add_action( 'admin_print_styles-' . $this->page_hooks[ 'backwpupbackups' ], array( 'BackWPup_Page_Backups', 'admin_print_styles' ) );
221
+ add_action( 'admin_print_scripts-' . $this->page_hooks[ 'backwpupbackups' ], array( 'BackWPup_Page_Backups', 'admin_print_scripts' ) );
222
+
223
+ return $page_hooks;
224
+ }
225
+
226
+ /**
227
+ * @param $page_hooks
228
+ * @return mixed
229
+ */
230
+ public function admin_page_settings( $page_hooks ) {
231
+
232
+ $this->page_hooks[ 'backwpupsettings' ] = add_submenu_page( 'backwpup', __( 'Settings', 'backwpup' ), __( 'Settings', 'backwpup' ), 'backwpup_settings', 'backwpupsettings', array( 'BackWPup_Page_Settings', 'page' ) );
233
+ add_action( 'load-' . $this->page_hooks[ 'backwpupsettings' ], array( 'BackWPup_Admin', 'init_generel' ) );
234
+ add_action( 'admin_print_scripts-' . $this->page_hooks[ 'backwpupsettings' ], array( 'BackWPup_Page_Settings', 'admin_print_scripts' ) );
235
+
236
+ return $page_hooks;
237
+ }
238
+
239
+ /**
240
+ * @param $page_hooks
241
+ * @return mixed
242
+ */
243
+ public function admin_page_about( $page_hooks ) {
244
+
245
+ $this->page_hooks[ 'backwpupabout' ] = add_submenu_page( 'backwpup', __( 'About', 'backwpup' ), __( 'About', 'backwpup' ), 'backwpup', 'backwpupabout', array( 'BackWPup_Page_About', 'page' ) );
246
+ add_action( 'load-' . $this->page_hooks[ 'backwpupabout' ], array( 'BackWPup_Admin', 'init_generel' ) );
247
+ add_action( 'admin_print_styles-' . $this->page_hooks[ 'backwpupabout' ], array( 'BackWPup_Page_About', 'admin_print_styles' ) );
248
+ add_action( 'admin_print_scripts-' . $this->page_hooks[ 'backwpupabout' ], array( 'BackWPup_Page_About', 'admin_print_scripts' ) );
249
+
250
+ return $page_hooks;
251
+ }
252
+
253
+
254
+ /**
255
+ * Load for all BackWPup pages
256
+ */
257
+ public static function init_generel() {
258
+
259
+ add_thickbox();
260
+
261
+ //register js and css for BackWPup
262
+ if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
263
+ wp_register_script( 'backwpuptiptip', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/jquery.tipTip.js', array( 'jquery' ), '1.3.1', TRUE );
264
+ wp_register_script( 'backwpupgeneral', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/general.js', array( 'jquery', 'backwpuptiptip' ), time(), TRUE );
265
+ } else {
266
+ wp_register_script( 'backwpuptiptip', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3.1', TRUE );
267
+ wp_register_script( 'backwpupgeneral', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/general.min.js', array( 'jquery', 'backwpuptiptip' ), BackWPup::get_plugin_data( 'Version' ), TRUE );
268
+ }
269
+
270
+ //add Help
271
+ BackWPup_Help::help();
272
+ }
273
+
274
+
275
+ /**
276
+ * Called on save form. Only POST allowed.
277
+ */
278
+ public function save_post_form() {
279
+
280
+ //Allowed Pages
281
+ if ( ! in_array( $_POST[ 'page' ], array ( 'backwpupeditjob', 'backwpupinformation', 'backwpupsettings' ) ) )
282
+ wp_die( __( 'Cheating, huh?', 'backwpup' ) );
283
+
284
+ //nonce check
285
+ check_admin_referer( $_POST[ 'page' ] . '_page' );
286
+
287
+ if ( ! current_user_can( 'backwpup' ) )
288
+ wp_die( __( 'Cheating, huh?', 'backwpup' ) );
289
+
290
+ //build query for redirect
291
+ if ( ! isset( $_POST[ 'anchor' ] ) )
292
+ $_POST[ 'anchor' ] = NULL;
293
+ $query_args=array();
294
+ if ( isset( $_POST[ 'page' ] ) )
295
+ $query_args[ 'page' ] = $_POST[ 'page' ];
296
+ if ( isset( $_POST[ 'tab' ] ) )
297
+ $query_args[ 'tab' ] = $_POST[ 'tab' ];
298
+ if ( isset( $_POST[ 'tab' ] ) && isset( $_POST[ 'nexttab' ] ) && $_POST[ 'tab' ] != $_POST[ 'nexttab' ] )
299
+ $query_args[ 'tab' ] = $_POST[ 'nexttab' ];
300
+
301
+ $jobid = NULL;
302
+ if ( isset( $_POST[ 'jobid' ] ) ) {
303
+ $jobid = (int) $_POST[ 'jobid' ];
304
+ $query_args[ 'jobid' ] = $jobid;
305
+ }
306
+
307
+ //Call method to save data
308
+ if ( $_POST[ 'page' ] == 'backwpupeditjob' )
309
+ BackWPup_Page_Editjob::save_post_form( $_POST[ 'tab' ], $jobid );
310
+ elseif ( $_POST[ 'page' ] == 'backwpupsettings' ) {
311
+ BackWPup_Page_Settings::save_post_form();
312
+ }
313
+
314
+ //Back to topic
315
+ wp_safe_redirect( add_query_arg( $query_args, network_admin_url( 'admin.php' ) ) . $_POST[ 'anchor' ] );
316
+ exit;
317
+ }
318
+
319
+ /**
320
+ * Add Message (across site loadings)
321
+ *
322
+ * @param $message string Message test
323
+ * @param $error bool ist it a error message
324
+ */
325
+ public static function message( $message, $error = FALSE ) {
326
+
327
+
328
+ $saved_message = self::get_messages();
329
+
330
+ if ( $error )
331
+ $saved_message[ 'error' ][] = $message;
332
+ else
333
+ $saved_message[ 'updated' ][] = $message;
334
+
335
+ update_site_option( 'backwpup_messages', $saved_message );
336
+ }
337
+
338
+ /**
339
+ * Get all Message that not displayed
340
+ *
341
+ * @return array
342
+ */
343
+ public static function get_messages() {
344
+
345
+ return get_site_option( 'backwpup_messages', array() );
346
+ }
347
+
348
+ /**
349
+ * Display Messages
350
+ *
351
+ * @param bool $echo
352
+ * @return string
353
+ */
354
+ public static function display_messages( $echo = TRUE ) {
355
+
356
+ $message_updated= '';
357
+ $message_error = '';
358
+ $saved_message = self::get_messages();
359
+ $message_id = ' id="message"';
360
+
361
+ if( empty( $saved_message ) )
362
+ return '';
363
+
364
+ if ( ! empty( $saved_message[ 'updated' ] ) ) {
365
+ foreach( $saved_message[ 'updated' ] as $msg )
366
+ $message_updated .= '<p>' . $msg . '</p>';
367
+ }
368
+ if ( ! empty( $saved_message[ 'error' ] ) ) {
369
+ foreach( $saved_message[ 'error' ] as $msg )
370
+ $message_error .= '<p>' . $msg . '</p>';
371
+ }
372
+
373
+ update_site_option( 'backwpup_messages', array() );
374
+
375
+ if ( ! empty( $message_updated ) ) {
376
+ $message_updated = '<div' . $message_id . ' class="updated">' . $message_updated . '</div>';
377
+ $message_id = '';
378
+ }
379
+ if ( ! empty( $message_error ) ) {
380
+ $message_error = '<div' . $message_id . ' class="error">' . $message_error . '</div>';
381
+ }
382
+
383
+ if ( $echo )
384
+ echo $message_updated . $message_error;
385
+
386
+ return $message_updated . $message_error;
387
+ }
388
+
389
+ /**
390
+ * Overrides WordPress text in Footer
391
+ *
392
+ * @param $admin_footer_text string
393
+ * @return string
394
+ */
395
+ public function admin_footer_text( $admin_footer_text ) {
396
+
397
+ $default_text = $admin_footer_text;
398
+
399
+ if ( isset( $_REQUEST[ 'page' ] ) && strstr( $_REQUEST[ 'page' ], 'backwpup' ) ) {
400
+ $admin_footer_text = '<a href="' . __( 'http://marketpress.com', 'backwpup' ) . '" class="mp_logo" title="' . __( 'MarketPress', 'backwpup' ) . '">' . __( 'MarketPress', 'backwpup' ) . '</a>';
401
+ if ( ! class_exists( 'BackWPup_Pro', FALSE ) )
402
+ $admin_footer_text .= sprintf( __( '<a class="backwpup-get-pro" href="%s">Get BackWPup Pro now.</a>', 'backwpup' ), __( 'http://marketpress.com/product/backwpup-pro/', 'backwpup' ) );
403
+
404
+ return $admin_footer_text . $default_text;
405
+ }
406
+
407
+ return $admin_footer_text;
408
+ }
409
+
410
+ /**
411
+ * Overrides WordPress Version in Footer
412
+ *
413
+ * @param $update_footer_text string
414
+ * @return string
415
+ */
416
+ public function update_footer( $update_footer_text ) {
417
+
418
+ $default_text = $update_footer_text;
419
+
420
+ if ( isset( $_REQUEST[ 'page' ] ) && strstr( $_REQUEST[ 'page' ], 'backwpup') ) {
421
+ $update_footer_text = '<span class="backwpup-update-footer"><a href="' . translate( BackWPup::get_plugin_data( 'PluginURI' ), 'backwpup' ) . '">' . BackWPup::get_plugin_data( 'Name' ) . '</a> '. sprintf( __( 'version %s' ,'backwpup'), BackWPup::get_plugin_data( 'Version' ) ) . '</span>';
422
+
423
+ return $update_footer_text . $default_text;
424
+ }
425
+
426
+ return $update_footer_text;
427
+ }
428
+
429
+
430
+ /**
431
+ * Add filed for selecting user role in user section
432
+ *
433
+ * @param $user WP_User
434
+ */
435
+ public function user_profile_fields( $user ) {
436
+ global $wp_roles;
437
+
438
+ if ( ! is_super_admin() && ! current_user_can( 'backwpup_admin' ) )
439
+ return;
440
+ ?>
441
+ <h3><?php echo BackWPup::get_plugin_data( 'name' ); ?></h3>
442
+ <table class="form-table">
443
+ <tr>
444
+ <th>
445
+ <label for="backwpup_role"><?php _e( 'BackWPup Role', 'backwpup' ); ?>
446
+ </label></th>
447
+ <td>
448
+ <select name="backwpup_role" id="backwpup_role" style="display:inline-block; float:none;">
449
+ <option value=""><?php _e( '&mdash; No role for BackWPup &mdash;', 'backwpup' ); ?></option>
450
+ <?php
451
+ foreach ( $wp_roles->roles as $role => $rolevalue ) {
452
+ if ( substr( $role, 0, 8 ) != 'backwpup' )
453
+ continue;
454
+ echo '<option value="'.$role.'" '. selected( in_array( $role, $user->roles ), TRUE, FALSE ) .'>'. $rolevalue[ 'name' ] . '</option>';
455
+ }
456
+ ?>
457
+ </select>
458
+ <br />
459
+ <span class="description"><?php _e( 'Role that the user have on BackWPup', 'backwpup' ); ?></span>
460
+ </td>
461
+ </tr>
462
+ </table>
463
+ <?php
464
+ }
465
+
466
+ /**
467
+ * Save for user role adding
468
+ *
469
+ * @param $user_id int
470
+ */
471
+ public function save_profile_update( $user_id ) {
472
+ global $wp_roles;
473
+
474
+ if ( ! is_super_admin() && ! current_user_can( 'backwpup_admin' ) )
475
+ return;
476
+
477
+ if ( empty( $user_id ) )
478
+ return;
479
+
480
+ if ( ! isset( $_POST['backwpup_role'] ) )
481
+ return;
482
+
483
+ // get BackWPup roles
484
+ $backwpup_roles = array();
485
+ foreach ( array_keys( $wp_roles->roles ) as $role ) {
486
+ if ( ! strstr( $role, 'backwpup_' ) )
487
+ continue;
488
+ $backwpup_roles[] = $role;
489
+ }
490
+
491
+ //get user for adding/removing role
492
+ $user = new WP_User( $user_id );
493
+ //remove BackWPup role from user
494
+ foreach ( $user->roles as $role ) {
495
+ if ( ! strstr( $role, 'backwpup_' ) )
496
+ continue;
497
+ $user->remove_role( $role );
498
+ }
499
+ //add new role to user
500
+ if ( ! empty( $_POST['backwpup_role'] ) && in_array( $_POST['backwpup_role'], $backwpup_roles ) )
501
+ $user->add_role( $_POST['backwpup_role'] );
502
+
503
+ return;
504
+ }
505
+
506
+ public function gettext( $translations, $text, $domain ) {
507
+
508
+ if ( strstr( $text, '<a href="http://codex.wordpress.org/WordPress_Backups">back up your database and files</a>' ) )
509
+ return sprintf( __( '<strong>Important:</strong> before updating, please <a href="%1$s">back up your database and files</a> with <a href="http://marketpress.de/product/backwpup-pro/">%2$s</a>. For help with updates, visit the <a href="http://codex.wordpress.org/Updating_WordPress">Updating WordPress</a> Codex page.', 'backwpup' ), network_admin_url( 'admin.php?page=backwpupjobs' ), BackWPup::get_plugin_data( 'name' ) );
510
+
511
+ if ( strstr( $text, 'This plugin has <strong>not been tested</strong> with your current version of WordPress.' ) )
512
+ return $translations . '</p></div><div class="updated"><p>' .sprintf( __( '<strong>Important:</strong> before installing this plugin, please <a href="%1$s">back up your database and files</a> with <a href="http://marketpress.de/product/backwpup-pro/">%2$s</a>.', 'backwpup' ), network_admin_url( 'admin.php?page=backwpupjobs' ), BackWPup::get_plugin_data( 'name' ) );
513
+
514
+ if ( strstr( $text, 'This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.' ) )
515
+ return $translations . '</p></div><div class="updated"><p>' .sprintf( __( '<strong>Important:</strong> before installing this plugin, please <a href="%1$s">back up your database and files</a> with <a href="http://marketpress.de/product/backwpup-pro/">%2$s</a>.', 'backwpup' ), network_admin_url( 'admin.php?page=backwpupjobs' ), BackWPup::get_plugin_data( 'name' ) );
516
+
517
+
518
+ return $translations;
519
+ }
520
+
521
+ /**
522
+ * Filter BackWPup roles from displaying in normal WP roles selection
523
+ *
524
+ * @param $all_roles
525
+ * @return mixed
526
+ */
527
+ public function editable_roles( $all_roles ) {
528
+
529
+ foreach( $all_roles AS $key => $role ) {
530
+ if ( substr( $key, 0, 8 ) == 'backwpup' )
531
+ unset( $all_roles[$key] );
532
+ }
533
+
534
+ return $all_roles;
535
+ }
536
+
537
+ /**
538
+ * Add column for displaying BAckWPup user role
539
+ *
540
+ * @param $columns
541
+ * @return mixed
542
+ */
543
+ public function manage_users_columns( $columns ) {
544
+
545
+ $columns[ 'backwpup_role' ] = __( 'BackWPup Role', 'backwpup' );
546
+ return $columns;
547
+ }
548
+
549
+ /**
550
+ * Display BackWPup user role in column
551
+ *
552
+ * @param $value
553
+ * @param $column_name
554
+ * @param $user_id
555
+ * @return string
556
+ */
557
+ public function manage_users_custom_column( $value, $column_name, $user_id ) {
558
+ global $wp_roles;
559
+
560
+ if ( 'backwpup_role' != $column_name )
561
+ return $value;
562
+
563
+ $user = get_userdata( $user_id );
564
+
565
+ foreach ( $user->roles as $role ) {
566
+ if ( substr( $role, 0, 8 ) == 'backwpup' ) {
567
+ $value .= $wp_roles->roles[ $role ][ 'name' ]. '<br />';
568
+ }
569
+ }
570
+
571
+ return $value;
572
+ }
573
+
574
+ }
inc/class-adminbar.php CHANGED
@@ -1,132 +1,136 @@
1
- <?php
2
- /**
3
- * Class to display BackWPup in Adminbar
4
- */
5
- class BackWPup_Adminbar {
6
-
7
- private static $instance = NULL;
8
-
9
- private function __construct() {
10
-
11
- if ( defined( 'DOING_CRON' ) || ! current_user_can( 'backwpup' ) || ! is_admin_bar_showing() || ! get_site_option( 'backwpup_cfg_showadminbar' ) )
12
- return;
13
-
14
- //load text domain
15
- if ( ! is_textdomain_loaded( 'backwpup' ) )
16
- load_plugin_textdomain( 'backwpup', FALSE, BackWPup::get_plugin_data( 'BaseName' ) . '/languages' );
17
- //add admin bar. Works only in init
18
- add_action( 'admin_bar_menu', array( $this, 'adminbar' ), 100 );
19
- //admin css
20
- add_action( 'wp_head', array( 'BackWPup_Admin', 'admin_head' ) );
21
- }
22
-
23
- /**
24
- * @static
25
- * @return \BackWPup_Adminbar
26
- */
27
- public static function get_instance() {
28
-
29
- if (NULL === self::$instance) {
30
- self::$instance = new self;
31
- }
32
- return self::$instance;
33
- }
34
-
35
-
36
- private function __clone() {}
37
-
38
-
39
- /**
40
- * @global $wp_admin_bar WP_Admin_Bar
41
- */
42
- public function adminbar() {
43
- global $wp_admin_bar;
44
- /* @var WP_Admin_Bar $wp_admin_bar */
45
-
46
- $menu_title = '<span class="ab-icon"></span><span class="ab-label">' . BackWPup::get_plugin_data( 'name' ) . '</span>';
47
- $menu_herf = network_admin_url( 'admin.php' ) . '?page=backwpup';
48
- if ( file_exists( BackWPup::get_plugin_data( 'running_file' ) ) && current_user_can( 'backwpup_jobs_start' ) ) {
49
- $menu_title = '<span class="ab-icon"></span><span class="ab-label">' . BackWPup::get_plugin_data( 'name' ) . ' <span id="backwpup-adminbar-running">' . __( 'running', 'backwpup' ) . '</span></span>';
50
- $menu_herf = network_admin_url( 'admin.php' ) . '?page=backwpupjobs';
51
- }
52
-
53
- if ( current_user_can( 'backwpup' ) )
54
- $wp_admin_bar->add_menu( array(
55
- 'id' => 'backwpup',
56
- 'title' => $menu_title,
57
- 'href' => $menu_herf,
58
- 'meta' => array( 'title' => BackWPup::get_plugin_data( 'name' ) )
59
- ) );
60
-
61
- if ( file_exists( BackWPup::get_plugin_data( 'running_file' ) ) && current_user_can( 'backwpup_jobs_start' ) ) {
62
- $wp_admin_bar->add_menu( array(
63
- 'id' => 'backwpup_working',
64
- 'parent' => 'backwpup_jobs',
65
- 'title' => __( 'Now Running', 'backwpup' ),
66
- 'href' => network_admin_url( 'admin.php' ) . '?page=backwpupjobs'
67
- ) );
68
- $wp_admin_bar->add_menu( array(
69
- 'id' => 'backwpup_working_abort',
70
- 'parent' => 'backwpup_working',
71
- 'title' => __( 'Abort!', 'backwpup' ),
72
- 'href' => wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpup&action=abort', 'abort-job' )
73
- ) );
74
- }
75
-
76
- if ( current_user_can( 'backwpup_jobs' ) )
77
- $wp_admin_bar->add_menu( array(
78
- 'id' => 'backwpup_jobs',
79
- 'parent' => 'backwpup',
80
- 'title' => __( 'Jobs', 'backwpup' ),
81
- 'href' => network_admin_url( 'admin.php' ) . '?page=backwpupjobs'
82
- ) );
83
-
84
- if ( current_user_can( 'backwpup_jobs_edit' ) )
85
- $wp_admin_bar->add_menu( array(
86
- 'id' => 'backwpup_jobs_new',
87
- 'parent' => 'backwpup_jobs',
88
- 'title' => __( 'Add new', 'backwpup' ),
89
- 'href' => network_admin_url( 'admin.php' ) . '?page=backwpupeditjob&tab=job'
90
- ) );
91
-
92
- if ( current_user_can( 'backwpup_logs' ) )
93
- $wp_admin_bar->add_menu( array(
94
- 'id' => 'backwpup_logs',
95
- 'parent' => 'backwpup',
96
- 'title' => __( 'Logs', 'backwpup' ),
97
- 'href' => network_admin_url( 'admin.php' ) . '?page=backwpuplogs'
98
- ) );
99
-
100
- if ( current_user_can( 'backwpup_backups' ) )
101
- $wp_admin_bar->add_menu( array(
102
- 'id' => 'backwpup_backups',
103
- 'parent' => 'backwpup',
104
- 'title' => __( 'Backups', 'backwpup' ),
105
- 'href' => network_admin_url( 'admin.php' ) . '?page=backwpupbackups'
106
- ) );
107
-
108
-
109
- //add jobs
110
- $jobs = (array)BackWPup_Option::get_job_ids();
111
- foreach ( $jobs as $jobid ) {
112
- if ( current_user_can( 'backwpup_jobs_edit' ) ) {
113
- $name = BackWPup_Option::get( $jobid, 'name' );
114
- $wp_admin_bar->add_menu( array(
115
- 'id' => 'backwpup_jobs_' . $jobid,
116
- 'parent' => 'backwpup_jobs',
117
- 'title' => $name,
118
- 'href' => wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupeditjob&tab=job&jobid=' . $jobid, 'edit-job' )
119
- ) );
120
- }
121
- if ( current_user_can( 'backwpup_jobs_start' ) ) {
122
- $url = BackWPup_Job::get_jobrun_url( 'runnowlink', $jobid );
123
- $wp_admin_bar->add_menu( array(
124
- 'id' => 'backwpup_jobs_runnow_' . $jobid,
125
- 'parent' => 'backwpup_jobs_' . $jobid,
126
- 'title' => __( 'Run Now', 'backwpup' ),
127
- 'href' => $url[ 'url' ]
128
- ) );
129
- }
130
- }
131
- }
132
- }
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class to display BackWPup in Adminbar
4
+ */
5
+ class BackWPup_Adminbar {
6
+
7
+ private static $instance = NULL;
8
+
9
+ private function __construct() {
10
+
11
+ if ( ! is_admin_bar_showing() || ! current_user_can( 'backwpup' ) || ! get_site_option( 'backwpup_cfg_showadminbar' ) ) {
12
+ return;
13
+ }
14
+
15
+ //load text domain
16
+ if ( ! is_textdomain_loaded( 'backwpup' ) ) {
17
+ load_plugin_textdomain( 'backwpup', FALSE, BackWPup::get_plugin_data( 'BaseName' ) . '/languages' );
18
+ }
19
+
20
+ //add admin bar. Works only in init
21
+ add_action( 'admin_bar_menu', array( $this, 'adminbar' ), 100 );
22
+
23
+ //admin css
24
+ add_action( 'wp_head', array( 'BackWPup_Admin', 'admin_css' ) );
25
+ }
26
+
27
+ /**
28
+ * @static
29
+ * @return \BackWPup_Adminbar
30
+ */
31
+ public static function get_instance() {
32
+
33
+ if (NULL === self::$instance) {
34
+ self::$instance = new self;
35
+ }
36
+ return self::$instance;
37
+ }
38
+
39
+
40
+ private function __clone() {}
41
+
42
+
43
+ /**
44
+ * @global $wp_admin_bar WP_Admin_Bar
45
+ */
46
+ public function adminbar() {
47
+ global $wp_admin_bar;
48
+ /* @var WP_Admin_Bar $wp_admin_bar */
49
+
50
+ $menu_title = '<span class="ab-icon"></span><span class="ab-label">' . BackWPup::get_plugin_data( 'name' ) . '</span>';
51
+ $menu_herf = network_admin_url( 'admin.php' ) . '?page=backwpup';
52
+ if ( file_exists( BackWPup::get_plugin_data( 'running_file' ) ) && current_user_can( 'backwpup_jobs_start' ) ) {
53
+ $menu_title = '<span class="ab-icon"></span><span class="ab-label">' . BackWPup::get_plugin_data( 'name' ) . ' <span id="backwpup-adminbar-running">' . __( 'running', 'backwpup' ) . '</span></span>';
54
+ $menu_herf = network_admin_url( 'admin.php' ) . '?page=backwpupjobs';
55
+ }
56
+
57
+ if ( current_user_can( 'backwpup' ) )
58
+ $wp_admin_bar->add_menu( array(
59
+ 'id' => 'backwpup',
60
+ 'title' => $menu_title,
61
+ 'href' => $menu_herf,
62
+ 'meta' => array( 'title' => BackWPup::get_plugin_data( 'name' ) )
63
+ ) );
64
+
65
+ if ( file_exists( BackWPup::get_plugin_data( 'running_file' ) ) && current_user_can( 'backwpup_jobs_start' ) ) {
66
+ $wp_admin_bar->add_menu( array(
67
+ 'id' => 'backwpup_working',
68
+ 'parent' => 'backwpup_jobs',
69
+ 'title' => __( 'Now Running', 'backwpup' ),
70
+ 'href' => network_admin_url( 'admin.php' ) . '?page=backwpupjobs'
71
+ ) );
72
+ $wp_admin_bar->add_menu( array(
73
+ 'id' => 'backwpup_working_abort',
74
+ 'parent' => 'backwpup_working',
75
+ 'title' => __( 'Abort!', 'backwpup' ),
76
+ 'href' => wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpup&action=abort', 'abort-job' )
77
+ ) );
78
+ }
79
+
80
+ if ( current_user_can( 'backwpup_jobs' ) )
81
+ $wp_admin_bar->add_menu( array(
82
+ 'id' => 'backwpup_jobs',
83
+ 'parent' => 'backwpup',
84
+ 'title' => __( 'Jobs', 'backwpup' ),
85
+ 'href' => network_admin_url( 'admin.php' ) . '?page=backwpupjobs'
86
+ ) );
87
+
88
+ if ( current_user_can( 'backwpup_jobs_edit' ) )
89
+ $wp_admin_bar->add_menu( array(
90
+ 'id' => 'backwpup_jobs_new',
91
+ 'parent' => 'backwpup_jobs',
92
+ 'title' => __( 'Add new', 'backwpup' ),
93
+ 'href' => network_admin_url( 'admin.php' ) . '?page=backwpupeditjob&tab=job'
94
+ ) );
95
+
96
+ if ( current_user_can( 'backwpup_logs' ) )
97
+ $wp_admin_bar->add_menu( array(
98
+ 'id' => 'backwpup_logs',
99
+ 'parent' => 'backwpup',
100
+ 'title' => __( 'Logs', 'backwpup' ),
101
+ 'href' => network_admin_url( 'admin.php' ) . '?page=backwpuplogs'
102
+ ) );
103
+
104
+ if ( current_user_can( 'backwpup_backups' ) )
105
+ $wp_admin_bar->add_menu( array(
106
+ 'id' => 'backwpup_backups',
107
+ 'parent' => 'backwpup',
108
+ 'title' => __( 'Backups', 'backwpup' ),
109
+ 'href' => network_admin_url( 'admin.php' ) . '?page=backwpupbackups'
110
+ ) );
111
+
112
+
113
+ //add jobs
114
+ $jobs = (array)BackWPup_Option::get_job_ids();
115
+ foreach ( $jobs as $jobid ) {
116
+ if ( current_user_can( 'backwpup_jobs_edit' ) ) {
117
+ $name = BackWPup_Option::get( $jobid, 'name' );
118
+ $wp_admin_bar->add_menu( array(
119
+ 'id' => 'backwpup_jobs_' . $jobid,
120
+ 'parent' => 'backwpup_jobs',
121
+ 'title' => $name,
122
+ 'href' => wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupeditjob&tab=job&jobid=' . $jobid, 'edit-job' )
123
+ ) );
124
+ }
125
+ if ( current_user_can( 'backwpup_jobs_start' ) ) {
126
+ $url = BackWPup_Job::get_jobrun_url( 'runnowlink', $jobid );
127
+ $wp_admin_bar->add_menu( array(
128
+ 'id' => 'backwpup_jobs_runnow_' . $jobid,
129
+ 'parent' => 'backwpup_jobs_' . $jobid,
130
+ 'title' => __( 'Run Now', 'backwpup' ),
131
+ 'href' => $url[ 'url' ]
132
+ ) );
133
+ }
134
+ }
135
+ }
136
+ }
inc/class-create-archive.php CHANGED
@@ -85,14 +85,14 @@ class BackWPup_Create_Archive {
85
  throw new BackWPup_Create_Archive_Exception( __( 'Functions for gz compression not available', 'backwpup' ) );
86
  }
87
  $this->method = 'TarGz';
88
- $this->filehandel = fopen( substr( $this->file, 0, -3 ), 'ab' );
89
  }
90
  elseif ( strtolower( substr( $this->file, -8 ) ) == '.tar.bz2' ) {
91
  if ( ! function_exists( 'bzcompress' ) ) {
92
  throw new BackWPup_Create_Archive_Exception( __( 'Functions for bz2 compression not available', 'backwpup' ) );
93
  }
94
  $this->method = 'TarBz2';
95
- $this->filehandel = fopen( substr( $this->file, 0, -4 ), 'ab');
96
  }
97
  elseif ( strtolower( substr( $this->file, -4 ) ) == '.tar' ) {
98
  $this->method = 'Tar';
@@ -112,7 +112,7 @@ class BackWPup_Create_Archive {
112
  $this->ziparchive = new ZipArchive();
113
  $ziparchive_open = $this->ziparchive->open( $this->file, ZipArchive::CREATE );
114
  if ( $ziparchive_open !== TRUE ) {
115
- $this->ziparchive_status( $ziparchive_open );
116
  throw new BackWPup_Create_Archive_Exception( sprintf( _x( 'Cannot create zip archive: %d','ZipArchive open() result', 'backwpup' ), $ziparchive_open ) );
117
  }
118
  }
@@ -179,10 +179,18 @@ class BackWPup_Create_Archive {
179
 
180
  //close ZipArchive Class
181
  if ( is_object( $this->ziparchive ) ) {
182
- $this->ziparchive_status( $this->ziparchive->status );
183
- $this->ziparchive->close();
184
- unset( $this->ziparchive );
185
- $this->ziparchive_delete_temp_files();
 
 
 
 
 
 
 
 
186
  }
187
 
188
  //close file if open
@@ -198,31 +206,15 @@ class BackWPup_Create_Archive {
198
 
199
  //write tar file end
200
  if ( in_array( $this->get_method(), array( 'Tar', 'TarGz', 'TarBz2' ) ) ) {
201
- fwrite( $this->filehandel, pack( "a1024", "" ) );
202
- }
203
-
204
- if ( $this->get_method() == 'TarGz' ) {
205
- fclose( $this->filehandel );
206
- $this->filehandel = fopen( 'compress.zlib://' . $this->file, 'wb' );
207
- $fd = fopen( substr( $this->file, 0, -3 ), 'rb' );
208
- while ( ! feof( $fd ) ) {
209
- fwrite( $this->filehandel, fread( $fd, 8192 ) );
210
  }
211
- fclose( $fd );
212
- unlink( substr( $this->file, 0, -3 ) );
213
- }
214
-
215
- if ( $this->get_method() == 'TarBz2' ) {
216
- fclose( $this->filehandel );
217
- $this->filehandel = fopen( 'compress.bzip2://' . $this->file, 'wb' );
218
- $fd = fopen( substr( $this->file, 0, -4 ), 'rb' );
219
- while ( ! feof( $fd ) ) {
220
- fwrite( $this->filehandel, fread( $fd, 8192 ) );
221
  }
222
- fclose( $fd );
223
- unlink( substr( $this->file, 0, -4 ) );
224
  }
225
-
226
  }
227
 
228
  /**
@@ -242,7 +234,6 @@ class BackWPup_Create_Archive {
242
  * @param $file_name string
243
  * @param $name_in_archive string
244
  * @return bool Add worked or not
245
- * @throws BackWPup_Create_Archive_Exception
246
  */
247
  public function add_file( $file_name, $name_in_archive = '' ) {
248
 
@@ -254,9 +245,13 @@ class BackWPup_Create_Archive {
254
  return FALSE;
255
  }
256
 
 
 
 
 
257
  if ( ! is_readable( $file_name ) ) {
258
  trigger_error( sprintf( _x( 'File %s does not exist or is not readable', 'File to add to archive', 'backwpup' ), $file_name ), E_USER_WARNING );
259
- return FALSE;
260
  }
261
 
262
  if ( empty( $name_in_archive ) )
@@ -280,6 +275,7 @@ class BackWPup_Create_Archive {
280
  fwrite( $this->filehandel, fread( $fd, 8192 ) );
281
  }
282
  fclose( $fd );
 
283
  break;
284
  case 'bz':
285
  if ( $this->file_count > 0 ) {
@@ -295,30 +291,55 @@ class BackWPup_Create_Archive {
295
  fwrite( $this->filehandel, bzcompress( fread( $fd, 8192 ) ) );
296
  }
297
  fclose( $fd );
 
298
  break;
299
  case 'Tar':
300
  case 'TarGz':
301
  case 'TarBz2':
302
- if ( ! $this->tar_file( $file_name, $name_in_archive ) ) {
303
- return FALSE;
304
- }
305
  break;
306
  case 'ZipArchive':
307
  //close and reopen, all added files are open on fs
308
- if ( $this->file_count >= 20 ) { //35 works with PHP 5.2.4 on win
309
- $this->ziparchive_status( $this->ziparchive->status );
310
- $this->ziparchive->close();
311
- $this->ziparchive_delete_temp_files();
 
 
 
 
 
 
 
 
 
 
 
 
 
312
  $ziparchive_open = $this->ziparchive->open( $this->file, ZipArchive::CREATE );
313
  if ( $ziparchive_open !== TRUE ) {
314
- $this->ziparchive_status( $ziparchive_open );
315
  return FALSE;
316
  }
317
  $this->file_count = 0;
318
  }
319
- if ( ! $this->ziparchive->addFile( $file_name, $name_in_archive ) ) {
320
- trigger_error( sprintf( __( 'Cannot add "%s" to zip archive!', 'backwpup' ), $name_in_archive ), E_USER_ERROR );
321
- return FALSE;
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  }
323
  break;
324
  case 'PclZip':
@@ -333,8 +354,6 @@ class BackWPup_Create_Archive {
333
  break;
334
  }
335
 
336
- $this->file_count++;
337
-
338
  return TRUE;
339
  }
340
 
@@ -358,7 +377,7 @@ class BackWPup_Create_Archive {
358
 
359
  if ( ! is_dir( $folder_name ) || ! is_readable( $folder_name ) ) {
360
  trigger_error( sprintf( _x( 'Folder %s does not exist or is not readable', 'Folder path to add to archive', 'backwpup' ), $folder_name ), E_USER_WARNING );
361
- return FALSE;
362
  }
363
 
364
  if ( empty( $name_in_archive ) ) {
@@ -400,46 +419,14 @@ class BackWPup_Create_Archive {
400
  /**
401
  * Output status of ZipArchive
402
  *
403
- * @param $code int ZipArchive Error code
404
  * @return bool
405
  */
406
- private function ziparchive_status( $code ) {
407
 
408
- if ( $code == 0 )
409
  return TRUE;
410
 
411
- //define error messages
412
- $zip_errors[ ZipArchive::ER_MULTIDISK ] = __( '(ER_MULTIDISK) Multi-disk zip archives not supported', 'backwpup' );
413
- $zip_errors[ ZipArchive::ER_RENAME ] = __( '(ER_RENAME) Renaming temporary file failed', 'backwpup' );
414
- $zip_errors[ ZipArchive::ER_CLOSE ] = __( '(ER_CLOSE) Closing zip archive failed', 'backwpup' );
415
- $zip_errors[ ZipArchive::ER_SEEK ] = __( '(ER_SEEK) Seek error', 'backwpup' );
416
- $zip_errors[ ZipArchive::ER_READ ] = __( '(ER_READ) Read error', 'backwpup' );
417
- $zip_errors[ ZipArchive::ER_WRITE ] = __( '(ER_WRITE) Write error', 'backwpup' );
418
- $zip_errors[ ZipArchive::ER_CRC ] = __( '(ER_CRC) CRC error', 'backwpup' );
419
- $zip_errors[ ZipArchive::ER_ZIPCLOSED ] = __( '(ER_ZIPCLOSED) Containing zip archive was closed', 'backwpup' );
420
- $zip_errors[ ZipArchive::ER_NOENT ] = __( '(ER_NOENT) No such file', 'backwpup' );
421
- $zip_errors[ ZipArchive::ER_EXISTS ] = __( '(ER_EXISTS) File already exists', 'backwpup' );
422
- $zip_errors[ ZipArchive::ER_OPEN ] = __( '(ER_OPEN) Can\'t open file', 'backwpup' );
423
- $zip_errors[ ZipArchive::ER_TMPOPEN ] = __( '(ER_TMPOPEN) Failure to create temporary file', 'backwpup' );
424
- $zip_errors[ ZipArchive::ER_ZLIB ] = __( '(ER_ZLIB) Zlib error', 'backwpup' );
425
- $zip_errors[ ZipArchive::ER_MEMORY ] = __( '(ER_MEMORY) Malloc failure', 'backwpup' );
426
- $zip_errors[ ZipArchive::ER_MULTIDISK ] = __( '(ER_CHANGED) Entry has been changed', 'backwpup' );
427
- $zip_errors[ ZipArchive::ER_CHANGED ] = __( '(ER_COMPNOTSUPP) Compression method not supported', 'backwpup' );
428
- $zip_errors[ ZipArchive::ER_EOF ] = __( '(ER_EOF) Premature EOF', 'backwpup' );
429
- $zip_errors[ ZipArchive::ER_INVAL ] = __( '(ER_INVAL) Invalid argument', 'backwpup' );
430
- $zip_errors[ ZipArchive::ER_NOZIP ] = __( '(ER_NOZIP) Not a zip archive', 'backwpup' );
431
- $zip_errors[ ZipArchive::ER_INTERNAL ] = __( '(ER_INTERNAL) Internal error', 'backwpup' );
432
- $zip_errors[ ZipArchive::ER_INCONS ] = __( '(ER_INCONS) Zip archive inconsistent', 'backwpup' );
433
- $zip_errors[ ZipArchive::ER_REMOVE ] = __( '(ER_REMOVE) Can\'t remove file', 'backwpup' );
434
- $zip_errors[ ZipArchive::ER_DELETED ] = __( '(ER_DELETED) Entry has been deleted', 'backwpup' );
435
-
436
- //ste error message
437
- $zip_error = $code;
438
- if ( isset( $zip_errors[ $zip_error ] ) ) {
439
- $zip_error = $zip_errors[ $zip_error ];
440
- }
441
-
442
- trigger_error( sprintf( _x( 'ZipArchive returns status: %s','Text of ZipArchive status Message', 'backwpup' ), $zip_error ), E_USER_ERROR );
443
  return FALSE;
444
  }
445
 
@@ -448,6 +435,12 @@ class BackWPup_Create_Archive {
448
  */
449
  private function tar_file( $file_name, $name_in_archive ) {
450
 
 
 
 
 
 
 
451
  //split filename larger than 100 chars
452
  if ( strlen( $name_in_archive ) <= 100 ) {
453
  $filename = $name_in_archive;
@@ -456,19 +449,31 @@ class BackWPup_Create_Archive {
456
  else {
457
  $filename_offset = strlen( $name_in_archive ) - 100;
458
  $split_pos = strpos( $name_in_archive, '/', $filename_offset );
 
 
 
459
  $filename = substr( $name_in_archive, $split_pos + 1 );
460
  $filename_prefix = substr( $name_in_archive, 0, $split_pos );
461
- if ( strlen( $filename ) > 100 )
 
462
  trigger_error( sprintf( __( 'File name "%1$s" is too long to be saved correctly in %2$s archive!', 'backwpup' ), $name_in_archive, $this->get_method() ), E_USER_WARNING );
463
- if ( strlen( $filename_prefix ) > 155 )
 
464
  trigger_error( sprintf( __( 'File path "%1$s" is too long to be saved correctly in %2$s archive!', 'backwpup' ), $name_in_archive, $this->get_method() ), E_USER_WARNING );
 
465
  }
466
  //get file stat
467
- $file_stat = @stat( $file_name );
 
 
 
 
468
  //open file
469
- if ( ! ( $fd = fopen( $file_name, 'rb' ) ) ) {
470
- trigger_error( sprintf( __( 'Cannot open source file %s to archive', 'backwpup' ), $file_name ), E_USER_WARNING );
471
- return FALSE;
 
 
472
  }
473
  //Set file user/group name if linux
474
  $fileowner = __( "Unknown", "backwpup" );
@@ -480,7 +485,7 @@ class BackWPup_Create_Archive {
480
  $filegroup = $info[ 'name' ];
481
  }
482
  // Generate the TAR header for this file
483
- $header = pack( "a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155a12",
484
  $filename, //name of file 100
485
  sprintf( "%07o", $file_stat[ 'mode' ] ), //file mode 8
486
  sprintf( "%07o", $file_stat[ 'uid' ] ), //owner user ID 8
@@ -501,22 +506,40 @@ class BackWPup_Create_Archive {
501
 
502
  // Computes the unsigned Checksum of a file's header
503
  $checksum = 0;
504
- for ( $i = 0; $i < 512; $i ++ )
505
- $checksum += ord( substr( $header, $i, 1 ) );
 
506
 
507
  $checksum = pack( "a8", sprintf( "%07o", $checksum ) );
508
- $header = substr_replace( $header, $checksum, 148, 8 );
509
- //write header
510
- fwrite( $this->filehandel, $header );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
511
 
512
- // read/write files in 512 bite Blocks
513
- while ( ! feof( $fd ) ) {
514
- $file_data = fread( $fd, 512 );
515
- if ( strlen( $file_data ) > 0 ) {
516
- fwrite( $this->filehandel, pack( "a512", $file_data ) );
 
517
  }
 
518
  }
519
- fclose( $fd );
520
 
521
  return TRUE;
522
  }
@@ -537,12 +560,18 @@ class BackWPup_Create_Archive {
537
  else {
538
  $filename_offset = strlen( $name_in_archive ) - 100;
539
  $split_pos = strpos( $name_in_archive, '/', $filename_offset );
 
 
 
540
  $tar_filename = substr( $name_in_archive, $split_pos + 1 );
541
  $tar_filename_prefix = substr( $name_in_archive, 0, $split_pos );
542
- if ( strlen( $tar_filename ) > 100 )
 
543
  trigger_error( sprintf( __( 'Folder name "%1$s" is too long to be saved correctly in %2$s archive!', 'backwpup' ), $name_in_archive, $this->get_method() ), E_USER_WARNING );
544
- if ( strlen( $tar_filename_prefix ) > 155 )
 
545
  trigger_error( sprintf( __( 'Folder path "%1$s" is too long to be saved correctly in %2$s archive!', 'backwpup' ), $name_in_archive, $this->get_method() ), E_USER_WARNING );
 
546
  }
547
  //get file stat
548
  $file_stat = @stat( $folder_name );
@@ -584,32 +613,49 @@ class BackWPup_Create_Archive {
584
  $checksum = pack( "a8", sprintf( "%07o", $checksum ) );
585
  $header = substr_replace( $header, $checksum, 148, 8 );
586
  //write header
 
 
 
 
 
 
587
  fwrite( $this->filehandel, $header );
588
 
589
  return TRUE;
590
  }
591
 
592
  /**
593
- * Deleting Temporary files after Zip file generation with zipArchive
 
 
594
  */
595
- private function ziparchive_delete_temp_files() {
 
 
596
 
597
- if ( $this->get_method() != 'ZipArchive' ) {
598
- return;
 
 
599
  }
600
 
601
- usleep( 250000 );
 
 
 
 
 
602
 
603
- $temp_files = glob( $this->file . '.*' );
 
 
604
 
605
- if ( empty( $temp_files ) ) {
606
- return;
607
  }
608
 
609
- foreach( $temp_files AS $temp_file ) {
610
- @unlink( $temp_file );
611
- }
612
  }
 
613
  }
614
 
615
  /**
85
  throw new BackWPup_Create_Archive_Exception( __( 'Functions for gz compression not available', 'backwpup' ) );
86
  }
87
  $this->method = 'TarGz';
88
+ $this->filehandel = fopen( $this->file, 'ab' );
89
  }
90
  elseif ( strtolower( substr( $this->file, -8 ) ) == '.tar.bz2' ) {
91
  if ( ! function_exists( 'bzcompress' ) ) {
92
  throw new BackWPup_Create_Archive_Exception( __( 'Functions for bz2 compression not available', 'backwpup' ) );
93
  }
94
  $this->method = 'TarBz2';
95
+ $this->filehandel = fopen( $this->file, 'ab' );
96
  }
97
  elseif ( strtolower( substr( $this->file, -4 ) ) == '.tar' ) {
98
  $this->method = 'Tar';
112
  $this->ziparchive = new ZipArchive();
113
  $ziparchive_open = $this->ziparchive->open( $this->file, ZipArchive::CREATE );
114
  if ( $ziparchive_open !== TRUE ) {
115
+ $this->ziparchive_status();
116
  throw new BackWPup_Create_Archive_Exception( sprintf( _x( 'Cannot create zip archive: %d','ZipArchive open() result', 'backwpup' ), $ziparchive_open ) );
117
  }
118
  }
179
 
180
  //close ZipArchive Class
181
  if ( is_object( $this->ziparchive ) ) {
182
+ $this->ziparchive_status();
183
+ if ( ! $this->ziparchive->close() ) {
184
+ sleep( 1 );
185
+ if ( ! $this->ziparchive->close() ) {
186
+ sleep( 1 );
187
+ if ( ! $this->ziparchive->close() ) {
188
+ $this->ziparchive_status();
189
+ trigger_error( __( 'ZIP archive cannot be closed correctly.', 'backwpup' ), E_USER_ERROR );
190
+ }
191
+ }
192
+ }
193
+ $this->ziparchive = NULL;
194
  }
195
 
196
  //close file if open
206
 
207
  //write tar file end
208
  if ( in_array( $this->get_method(), array( 'Tar', 'TarGz', 'TarBz2' ) ) ) {
209
+ $footer = pack( "a1024", "" );
210
+ if ( $this->method == 'TarGz' ) {
211
+ $footer = gzencode( $footer );
 
 
 
 
 
 
212
  }
213
+ if ( $this->method == 'TarBz2' ) {
214
+ $footer = bzcompress( $footer );
 
 
 
 
 
 
 
 
215
  }
216
+ fwrite( $this->filehandel, $footer );
 
217
  }
 
218
  }
219
 
220
  /**
234
  * @param $file_name string
235
  * @param $name_in_archive string
236
  * @return bool Add worked or not
 
237
  */
238
  public function add_file( $file_name, $name_in_archive = '' ) {
239
 
245
  return FALSE;
246
  }
247
 
248
+ if ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
249
+ clearstatcache( TRUE, $file_name );
250
+ }
251
+
252
  if ( ! is_readable( $file_name ) ) {
253
  trigger_error( sprintf( _x( 'File %s does not exist or is not readable', 'File to add to archive', 'backwpup' ), $file_name ), E_USER_WARNING );
254
+ return TRUE;
255
  }
256
 
257
  if ( empty( $name_in_archive ) )
275
  fwrite( $this->filehandel, fread( $fd, 8192 ) );
276
  }
277
  fclose( $fd );
278
+ $this->file_count++;
279
  break;
280
  case 'bz':
281
  if ( $this->file_count > 0 ) {
291
  fwrite( $this->filehandel, bzcompress( fread( $fd, 8192 ) ) );
292
  }
293
  fclose( $fd );
294
+ $this->file_count++;
295
  break;
296
  case 'Tar':
297
  case 'TarGz':
298
  case 'TarBz2':
299
+ return $this->tar_file( $file_name, $name_in_archive );
 
 
300
  break;
301
  case 'ZipArchive':
302
  //close and reopen, all added files are open on fs
303
+ if ( $this->file_count > 20 ) { //35 works with PHP 5.2.4 on win
304
+ $this->ziparchive_status();
305
+ if ( ! $this->ziparchive->close() ) {
306
+ sleep( 1 );
307
+ if ( ! $this->ziparchive->close() ) {
308
+ sleep( 1 );
309
+ if ( ! $this->ziparchive->close() ) {
310
+ $this->ziparchive_status();
311
+ trigger_error(__( 'ZipArchive can not closed correctly', 'backwpup' ), E_USER_ERROR );
312
+ }
313
+ }
314
+ }
315
+ $this->ziparchive = NULL;
316
+ if ( ! $this->check_archive_filesize() ) {
317
+ return FALSE;
318
+ }
319
+ $this->ziparchive = new ZipArchive();
320
  $ziparchive_open = $this->ziparchive->open( $this->file, ZipArchive::CREATE );
321
  if ( $ziparchive_open !== TRUE ) {
322
+ $this->ziparchive_status();
323
  return FALSE;
324
  }
325
  $this->file_count = 0;
326
  }
327
+ $file_size = abs( (int) filesize( $file_name ) );
328
+ if ( $file_size < ( 1024 * 1024 * 2 ) ) {
329
+ if ( ! $this->ziparchive->addFromString( $name_in_archive, file_get_contents( $file_name ) ) ) {
330
+ trigger_error( sprintf( __( 'Cannot add "%s" to zip archive!', 'backwpup' ), $name_in_archive ), E_USER_ERROR );
331
+ return FALSE;
332
+ } else {
333
+ $file_factor = round( $file_size / ( 1024 * 1024 ), 4 ) * 2;
334
+ $this->file_count = $this->file_count + $file_factor;
335
+ }
336
+ } else {
337
+ if ( ! $this->ziparchive->addFile( $file_name, $name_in_archive ) ) {
338
+ trigger_error( sprintf( __( 'Cannot add "%s" to zip archive!', 'backwpup' ), $name_in_archive ), E_USER_ERROR );
339
+ return FALSE;
340
+ } else {
341
+ $this->file_count++;
342
+ }
343
  }
344
  break;
345
  case 'PclZip':
354
  break;
355
  }
356
 
 
 
357
  return TRUE;
358
  }
359
 
377
 
378
  if ( ! is_dir( $folder_name ) || ! is_readable( $folder_name ) ) {
379
  trigger_error( sprintf( _x( 'Folder %s does not exist or is not readable', 'Folder path to add to archive', 'backwpup' ), $folder_name ), E_USER_WARNING );
380
+ return TRUE;
381
  }
382
 
383
  if ( empty( $name_in_archive ) ) {
419
  /**
420
  * Output status of ZipArchive
421
  *
 
422
  * @return bool
423
  */
424
+ private function ziparchive_status() {
425
 
426
+ if ( $this->ziparchive->status == 0 )
427
  return TRUE;
428
 
429
+ trigger_error( sprintf( _x( 'ZipArchive returns status: %s','Text of ZipArchive status Message', 'backwpup' ), $this->ziparchive->getStatusString() ), E_USER_ERROR );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
430
  return FALSE;
431
  }
432
 
435
  */
436
  private function tar_file( $file_name, $name_in_archive ) {
437
 
438
+ if ( ! $this->check_archive_filesize( $file_name ) ) {
439
+ return FALSE;
440
+ }
441
+
442
+ $chunk_size = 1024 * 1024 * 4;
443
+
444
  //split filename larger than 100 chars
445
  if ( strlen( $name_in_archive ) <= 100 ) {
446
  $filename = $name_in_archive;
449
  else {
450
  $filename_offset = strlen( $name_in_archive ) - 100;
451
  $split_pos = strpos( $name_in_archive, '/', $filename_offset );
452
+ if ( $split_pos === FALSE ) {
453
+ $split_pos = strrpos( $name_in_archive, '/' );
454
+ }
455
  $filename = substr( $name_in_archive, $split_pos + 1 );
456
  $filename_prefix = substr( $name_in_archive, 0, $split_pos );
457
+ if ( strlen( $filename ) > 100 ) {
458
+ $filename = substr( $filename, -100 );
459
  trigger_error( sprintf( __( 'File name "%1$s" is too long to be saved correctly in %2$s archive!', 'backwpup' ), $name_in_archive, $this->get_method() ), E_USER_WARNING );
460
+ }
461
+ if ( strlen( $filename_prefix ) > 155 ) {
462
  trigger_error( sprintf( __( 'File path "%1$s" is too long to be saved correctly in %2$s archive!', 'backwpup' ), $name_in_archive, $this->get_method() ), E_USER_WARNING );
463
+ }
464
  }
465
  //get file stat
466
+ $file_stat = stat( $file_name );
467
+ if ( ! $file_stat ) {
468
+ return TRUE;
469
+ }
470
+ $file_stat[ 'size' ] = abs( (int) $file_stat[ 'size' ] );
471
  //open file
472
+ if ( $file_stat[ 'size' ] > 0 ) {
473
+ if ( ! ( $fd = fopen( $file_name, 'rb' ) ) ) {
474
+ trigger_error( sprintf( __( 'Cannot open source file %s for archiving', 'backwpup' ), $file_name ), E_USER_WARNING );
475
+ return TRUE;
476
+ }
477
  }
478
  //Set file user/group name if linux
479
  $fileowner = __( "Unknown", "backwpup" );
485
  $filegroup = $info[ 'name' ];
486
  }
487
  // Generate the TAR header for this file
488
+ $chunk = pack( "a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155a12",
489
  $filename, //name of file 100
490
  sprintf( "%07o", $file_stat[ 'mode' ] ), //file mode 8
491
  sprintf( "%07o", $file_stat[ 'uid' ] ), //owner user ID 8
506
 
507
  // Computes the unsigned Checksum of a file's header
508
  $checksum = 0;
509
+ for ( $i = 0; $i < 512; $i ++ ) {
510
+ $checksum += ord( substr( $chunk, $i, 1 ) );
511
+ }
512
 
513
  $checksum = pack( "a8", sprintf( "%07o", $checksum ) );
514
+ $chunk = substr_replace( $chunk, $checksum, 148, 8 );
515
+
516
+ if ( isset( $fd ) && is_resource( $fd ) ) {
517
+ // read/write files in 512 bite Blocks
518
+ while ( ( $content = fread( $fd, 512 ) ) != '' ) {
519
+ $chunk .= pack( "a512", $content );
520
+ if ( strlen( $chunk ) >= $chunk_size ) {
521
+ if ( $this->method == 'TarGz' ) {
522
+ $chunk = gzencode( $chunk );
523
+ }
524
+ if ( $this->method == 'TarBz2' ) {
525
+ $chunk = bzcompress( $chunk );
526
+ }
527
+ fwrite( $this->filehandel, $chunk );
528
+ $chunk = '';
529
+ }
530
+ }
531
+ fclose( $fd );
532
+ }
533
 
534
+ if ( ! empty( $chunk ) ) {
535
+ if ( $this->method == 'TarGz' ) {
536
+ $chunk = gzencode( $chunk );
537
+ }
538
+ if ( $this->method == 'TarBz2' ) {
539
+ $chunk = bzcompress( $chunk );
540
  }
541
+ fwrite( $this->filehandel, $chunk );
542
  }
 
543
 
544
  return TRUE;
545
  }
560
  else {
561
  $filename_offset = strlen( $name_in_archive ) - 100;
562
  $split_pos = strpos( $name_in_archive, '/', $filename_offset );
563
+ if ( $split_pos === FALSE ) {
564
+ $split_pos = strrpos( untrailingslashit( $name_in_archive ), '/' );
565
+ }
566
  $tar_filename = substr( $name_in_archive, $split_pos + 1 );
567
  $tar_filename_prefix = substr( $name_in_archive, 0, $split_pos );
568
+ if ( strlen( $tar_filename ) > 100 ) {
569
+ $tar_filename = substr( $tar_filename, - 100 );
570
  trigger_error( sprintf( __( 'Folder name "%1$s" is too long to be saved correctly in %2$s archive!', 'backwpup' ), $name_in_archive, $this->get_method() ), E_USER_WARNING );
571
+ }
572
+ if ( strlen( $tar_filename_prefix ) > 155 ) {
573
  trigger_error( sprintf( __( 'Folder path "%1$s" is too long to be saved correctly in %2$s archive!', 'backwpup' ), $name_in_archive, $this->get_method() ), E_USER_WARNING );
574
+ }
575
  }
576
  //get file stat
577
  $file_stat = @stat( $folder_name );
613
  $checksum = pack( "a8", sprintf( "%07o", $checksum ) );
614
  $header = substr_replace( $header, $checksum, 148, 8 );
615
  //write header
616
+ if ( $this->method == 'TarGz' ) {
617
+ $header = gzencode( $header );
618
+ }
619
+ if ( $this->method == 'TarBz2' ) {
620
+ $header = bzcompress( $header );
621
+ }
622
  fwrite( $this->filehandel, $header );
623
 
624
  return TRUE;
625
  }
626
 
627
  /**
628
+ * @param string $file_to_add
629
+ *
630
+ * @return bool
631
  */
632
+ private function check_archive_filesize( $file_to_add = '' ) {
633
+
634
+ $two_gb_in_bytes = 2147483647;
635
 
636
+ if ( ! empty( $file_to_add ) ) {
637
+ $file_to_add_size = abs( (int) filesize( $file_to_add ) );
638
+ } else {
639
+ $file_to_add_size = 0;
640
  }
641
 
642
+ if ( is_resource( $this->filehandel ) ) {
643
+ $stats = fstat( $this->filehandel );
644
+ $archive_size = $stats[ 'size' ];
645
+ } else {
646
+ $archive_size = filesize( $this->file );
647
+ }
648
 
649
+ $archive_size = $archive_size + $file_to_add_size;
650
+ if ( $archive_size > $two_gb_in_bytes ) {
651
+ trigger_error( sprintf( __( 'If %s will be added to your backup archive, the archive will be too large for many file systems (over 2GB). You might want to consider splitting the backup job in multiple jobs with less files each.', 'backwpup' ), $file_to_add ), E_USER_ERROR );
652
 
653
+ return FALSE;
 
654
  }
655
 
656
+ return TRUE;
 
 
657
  }
658
+
659
  }
660
 
661
  /**
inc/class-cron.php CHANGED
@@ -1,313 +1,313 @@
1
- <?php
2
- /**
3
- * Class for BackWPup cron methods
4
- */
5
- class BackWPup_Cron {
6
-
7
- /**
8
- * @static
9
- *
10
- * @param $arg
11
- * @internal param $args
12
- */
13
- public static function run( $arg ) {
14
-
15
- $job_object = BackWPup_Job::get_working_data();
16
-
17
- if ( $arg == 'restart' && ! empty( $job_object ) ) {
18
- //reschedule restart
19
- wp_schedule_single_event( time() + 60, 'backwpup_cron', array( 'id' => 'restart' ) );
20
- //restart job if not working or a restart imitated
21
- $not_worked_time = microtime( TRUE ) - $job_object->timestamp_last_update;
22
- if ( empty( $job_object->pid ) || $not_worked_time > 300 )
23
- BackWPup_Job::start_wp_cron();
24
- return;
25
- }
26
-
27
- if ( empty( $arg ) || $arg == 'restart' )
28
- return;
29
-
30
- //check that job exits
31
- $jobids = BackWPup_Option::get_job_ids( 'activetype', 'wpcron' );
32
- if ( ! in_array( $arg, $jobids ) )
33
- return;
34
-
35
- //delay other job start for 5 minutes if already one is running
36
- if ( ! empty( $job_object ) ) {
37
- wp_schedule_single_event( time() + 300 , 'backwpup_cron', array( 'id' => $arg ) );
38
- return;
39
- }
40
-
41
- //reschedule next job run
42
- $cron_next = self::cron_next( BackWPup_Option::get( $arg, 'cron' ) );
43
- wp_schedule_single_event( $cron_next, 'backwpup_cron', array( 'id' => $arg ) );
44
-
45
- //start job
46
- BackWPup_Job::start_wp_cron( $arg );
47
-
48
- }
49
-
50
-
51
- /**
52
- * Check Jobs worked and Cleanup logs and so on
53
- */
54
- public static function check_cleanup() {
55
-
56
- $job_object = BackWPup_Job::get_working_data();
57
-
58
- // check aborted jobs for longer than a tow hours, abort them courtly and send mail
59
- if ( is_object( $job_object ) && ! empty( $job_object->logfile ) ) {
60
- $not_worked_time = microtime( TRUE ) - $job_object->timestamp_last_update;
61
- if ( $not_worked_time > 3600 ) {
62
- $job_object->log( E_USER_ERROR, __( 'Aborted, because no progress for one hour!', 'backwpup' ), __FILE__, __LINE__ );
63
- unlink( BackWPup::get_plugin_data( 'running_file' ) );
64
- $job_object->update_working_data();
65
- }
66
- }
67
-
68
- //Compress not compressed logs
69
- if ( function_exists( 'gzopen' ) && get_site_option( 'backwpup_cfg_gzlogs' ) &&! is_object( $job_object ) ) {
70
- //Compress old not compressed logs
71
- if ( $dir = opendir( get_site_option( 'backwpup_cfg_logfolder' ) ) ) {
72
- $jobids = BackWPup_Option::get_job_ids();
73
- while ( FALSE !== ( $file = readdir( $dir ) ) ) {
74
- if ( is_writeable( get_site_option( 'backwpup_cfg_logfolder' ) . $file ) && '.html' == substr( $file, -5 ) ) {
75
- $compress = new BackWPup_Create_Archive( get_site_option( 'backwpup_cfg_logfolder' ) . $file . '.gz' );
76
- if ( $compress->add_file( get_site_option( 'backwpup_cfg_logfolder' ) . $file ) ) {
77
- unlink( get_site_option( 'backwpup_cfg_logfolder' ) . $file );
78
- //change last logfile in jobs
79
- foreach( $jobids as $jobid ) {
80
- $job_logfile = BackWPup_Option::get( $jobid, 'logfile' );
81
- if ( ! empty( $job_logfile ) && $job_logfile == get_site_option( 'backwpup_cfg_logfolder' ) . $file )
82
- BackWPup_Option::update( $jobid, 'logfile', get_site_option( 'backwpup_cfg_logfolder' ) . $file . '.gz' );
83
- }
84
- }
85
- unset( $compress );
86
- }
87
- }
88
- closedir( $dir );
89
- }
90
- }
91
-
92
- //Jobs cleanings
93
- if ( ! is_object( $job_object ) ) {
94
- //remove restart cron
95
- wp_clear_scheduled_hook( 'backwpup_cron', array( 'id' => 'restart' ) );
96
- //temp cleanup
97
- BackWPup_Job::clean_temp_folder();
98
- }
99
-
100
- //check scheduling jobs that not found will removed because there are single scheduled
101
- $activejobs = BackWPup_Option::get_job_ids( 'activetype', 'wpcron' );
102
- if ( ! empty( $activejobs ) ) {
103
- foreach ( $activejobs as $jobid ) {
104
- $cron_next = wp_next_scheduled( 'backwpup_cron', array( 'id' => $jobid ) );
105
- if ( ! $cron_next || $cron_next < time() ) {
106
- wp_unschedule_event( $cron_next, 'backwpup_cron', array( 'id' => $jobid ) );
107
- $cron_next = BackWPup_Cron::cron_next( BackWPup_Option::get( $jobid, 'cron') );
108
- wp_schedule_single_event( $cron_next, 'backwpup_cron', array( 'id' => $jobid ) );
109
- }
110
- }
111
- }
112
-
113
- }
114
-
115
-
116
- /**
117
- * Start job if in cron and run query args are set.
118
- */
119
- public static function cron_active() {
120
-
121
- //only if cron active
122
- if ( ! defined( 'DOING_CRON' ) || ! DOING_CRON )
123
- return;
124
-
125
- //only work if backwpup_run as query var ist set and nothing else and the value ist right
126
- if ( empty( $_GET[ 'backwpup_run' ] ) || ! in_array( $_GET[ 'backwpup_run' ], array( 'test','restart', 'runnow', 'runnowalt', 'runext', 'cronrun' ) ) )
127
- return;
128
-
129
- //special header
130
- @session_write_close();
131
- @header( 'Content-Type: text/html; charset=' . get_bloginfo( 'charset' ), TRUE );
132
- @header( 'X-Robots-Tag: noindex, nofollow', TRUE );
133
- @header( 'X-BackWPup-Version: ' . BackWPup::get_plugin_data( 'version' ), TRUE );
134
- nocache_headers();
135
-
136
- //on test die for fast feedback
137
- if ( $_GET[ 'backwpup_run' ] == 'test' )
138
- die( 'BackWPup Test' );
139
-
140
- // generate normal nonce
141
- $nonce = substr( wp_hash( wp_nonce_tick() . 'backwpup_job_run-' . $_GET[ 'backwpup_run' ], 'nonce' ), - 12, 10 );
142
- //special nonce on external start
143
- if ( $_GET[ 'backwpup_run' ] == 'runext' )
144
- $nonce = get_site_option( 'backwpup_cfg_jobrunauthkey' );
145
- // check nonce
146
- if ( empty( $_GET['_nonce'] ) || $nonce != $_GET['_nonce'] )
147
- return;
148
-
149
- //check runext is allowed for job
150
- if ( $_GET[ 'backwpup_run' ] == 'runext' ) {
151
- $jobids_external = BackWPup_Option::get_job_ids( 'activetype', 'link' );
152
- if ( !isset( $_GET[ 'jobid' ] ) || ! in_array( $_GET[ 'jobid' ], $jobids_external ) )
153
- return;
154
- }
155
-
156
- //run BackWPup job
157
- BackWPup_Job::start_http( $_GET[ 'backwpup_run' ] );
158
- die();
159
- }
160
-
161
-
162
- /**
163
- *
164
- * Get the local time timestamp of the next cron execution
165
- *
166
- * @param string $cronstring cron (* * * * *)
167
- * @return int timestamp
168
- */
169
- public static function cron_next( $cronstring ) {
170
-
171
- $cron = array();
172
- $cronarray = array();
173
- //Cron string
174
- list( $cronstr[ 'minutes' ], $cronstr[ 'hours' ], $cronstr[ 'mday' ], $cronstr[ 'mon' ], $cronstr[ 'wday' ] ) = explode( ' ', $cronstring, 5 );
175
-
176
- //make arrays form string
177
- foreach ( $cronstr as $key => $value ) {
178
- if ( strstr( $value, ',' ) )
179
- $cronarray[ $key ] = explode( ',', $value );
180
- else
181
- $cronarray[ $key ] = array( 0 => $value );
182
- }
183
-
184
- //make arrays complete with ranges and steps
185
- foreach ( $cronarray as $cronarraykey => $cronarrayvalue ) {
186
- $cron[ $cronarraykey ] = array();
187
- foreach ( $cronarrayvalue as $value ) {
188
- //steps
189
- $step = 1;
190
- if ( strstr( $value, '/' ) )
191
- list( $value, $step ) = explode( '/', $value, 2 );
192
- //replace weekday 7 with 0 for sundays
193
- if ( $cronarraykey == 'wday' )
194
- $value = str_replace( '7', '0', $value );
195
- //ranges
196
- if ( strstr( $value, '-' ) ) {
197
- list( $first, $last ) = explode( '-', $value, 2 );
198
- if ( ! is_numeric( $first ) || ! is_numeric( $last ) || $last > 60 || $first > 60 ) //check
199
- return 2147483647;
200
- if ( $cronarraykey == 'minutes' && $step < 5 ) //set step minimum to 5 min.
201
- $step = 5;
202
- $range = array();
203
- for ( $i = $first; $i <= $last; $i = $i + $step ) {
204
- $range[ ] = $i;
205
- }
206
- $cron[ $cronarraykey ] = array_merge( $cron[ $cronarraykey ], $range );
207
- }
208
- elseif ( $value == '*' ) {
209
- $range = array();
210
- if ( $cronarraykey == 'minutes' ) {
211
- if ( $step < 10 ) //set step minimum to 5 min.
212
- $step = 10;
213
- for ( $i = 0; $i <= 59; $i = $i + $step ) {
214
- $range[ ] = $i;
215
- }
216
- }
217
- if ( $cronarraykey == 'hours' ) {
218
- for ( $i = 0; $i <= 23; $i = $i + $step ) {
219
- $range[ ] = $i;
220
- }
221
- }
222
- if ( $cronarraykey == 'mday' ) {
223
- for ( $i = $step; $i <= 31; $i = $i + $step ) {
224
- $range[ ] = $i;
225
- }
226
- }
227
- if ( $cronarraykey == 'mon' ) {
228
- for ( $i = $step; $i <= 12; $i = $i + $step ) {
229
- $range[ ] = $i;
230
- }
231
- }
232
- if ( $cronarraykey == 'wday' ) {
233
- for ( $i = 0; $i <= 6; $i = $i + $step ) {
234
- $range[ ] = $i;
235
- }
236
- }
237
- $cron[ $cronarraykey ] = array_merge( $cron[ $cronarraykey ], $range );
238
- }
239
- else {
240
- //Month names
241
- if ( strtolower( $value ) == 'jan' )
242
- $value = 1;
243
- if ( strtolower( $value ) == 'feb' )
244
- $value = 2;
245
- if ( strtolower( $value ) == 'mar' )
246
- $value = 3;
247
- if ( strtolower( $value ) == 'apr' )
248
- $value = 4;
249
- if ( strtolower( $value ) == 'may' )
250
- $value = 5;
251
- if ( strtolower( $value ) == 'jun' )
252
- $value = 6;
253
- if ( strtolower( $value ) == 'jul' )
254
- $value = 7;
255
- if ( strtolower( $value ) == 'aug' )
256
- $value = 8;
257
- if ( strtolower( $value ) == 'sep' )
258
- $value = 9;
259
- if ( strtolower( $value ) == 'oct' )
260
- $value = 10;
261
- if ( strtolower( $value ) == 'nov' )
262
- $value = 11;
263
- if ( strtolower( $value ) == 'dec' )
264
- $value = 12;
265
- //Week Day names
266
- if ( strtolower( $value ) == 'sun' )
267
- $value = 0;
268
- if ( strtolower( $value ) == 'sat' )
269
- $value = 6;
270
- if ( strtolower( $value ) == 'mon' )
271
- $value = 1;
272
- if ( strtolower( $value ) == 'tue' )
273
- $value = 2;
274
- if ( strtolower( $value ) == 'wed' )
275
- $value = 3;
276
- if ( strtolower( $value ) == 'thu' )
277
- $value = 4;
278
- if ( strtolower( $value ) == 'fri' )
279
- $value = 5;
280
- if ( ! is_numeric( $value ) || $value > 60 ) //check
281
- return 2147483647;
282
- $cron[ $cronarraykey ] = array_merge( $cron[ $cronarraykey ], array( 0 => $value ) );
283
- }
284
- }
285
- }
286
-
287
- //generate years
288
- for ( $i = gmdate( 'Y' ); $i < gmdate( 'Y', 2147483647 ); $i ++ ) {
289
- $cron[ 'year' ][ ] = $i;
290
- }
291
-
292
- //calc next timestamp
293
- $current_timestamp = current_time( 'timestamp' );
294
- foreach ( $cron[ 'year' ] as $year ) {
295
- foreach ( $cron[ 'mon' ] as $mon ) {
296
- foreach ( $cron[ 'mday' ] as $mday ) {
297
- if ( ! checkdate( $mon, $mday, $year ) )
298
- continue;
299
- foreach ( $cron[ 'hours' ] as $hours ) {
300
- foreach ( $cron[ 'minutes' ] as $minutes ) {
301
- $timestamp = gmmktime( $hours, $minutes, 0, $mon, $mday, $year );
302
- if ( $timestamp && in_array( gmdate( 'j', $timestamp ), $cron[ 'mday' ] ) && in_array( gmdate( 'w', $timestamp ), $cron[ 'wday' ] ) && $timestamp > $current_timestamp )
303
- return $timestamp - ( get_option( 'gmt_offset' ) * 3600 );
304
- }
305
- }
306
- }
307
- }
308
- }
309
-
310
- return 2147483647;
311
- }
312
-
313
- }
1
+ <?php
2
+ /**
3
+ * Class for BackWPup cron methods
4
+ */
5
+ class BackWPup_Cron {
6
+
7
+ /**
8
+ * @static
9
+ *
10
+ * @param $arg
11
+ * @internal param $args
12
+ */
13
+ public static function run( $arg ) {
14
+
15
+ $job_object = BackWPup_Job::get_working_data();
16
+
17
+ if ( $arg == 'restart' && ! empty( $job_object ) ) {
18
+ //reschedule restart
19
+ wp_schedule_single_event( time() + 60, 'backwpup_cron', array( 'id' => 'restart' ) );
20
+ //restart job if not working or a restart imitated
21
+ $not_worked_time = microtime( TRUE ) - $job_object->timestamp_last_update;
22
+ if ( empty( $job_object->pid ) || $not_worked_time > 300 )
23
+ BackWPup_Job::start_wp_cron();
24
+ return;
25
+ }
26
+
27
+ if ( empty( $arg ) || $arg == 'restart' )
28
+ return;
29
+
30
+ //check that job exits
31
+ $jobids = BackWPup_Option::get_job_ids( 'activetype', 'wpcron' );
32
+ if ( ! in_array( $arg, $jobids ) )
33
+ return;
34
+
35
+ //delay other job start for 5 minutes if already one is running
36
+ if ( ! empty( $job_object ) ) {
37
+ wp_schedule_single_event( time() + 300 , 'backwpup_cron', array( 'id' => $arg ) );
38
+ return;
39
+ }
40
+
41
+ //reschedule next job run
42
+ $cron_next = self::cron_next( BackWPup_Option::get( $arg, 'cron' ) );
43
+ wp_schedule_single_event( $cron_next, 'backwpup_cron', array( 'id' => $arg ) );
44
+
45
+ //start job
46
+ BackWPup_Job::start_wp_cron( $arg );
47
+
48
+ }
49
+
50
+
51
+ /**
52
+ * Check Jobs worked and Cleanup logs and so on
53
+ */
54
+ public static function check_cleanup() {
55
+
56
+ $job_object = BackWPup_Job::get_working_data();
57
+
58
+ // check aborted jobs for longer than a tow hours, abort them courtly and send mail
59
+ if ( is_object( $job_object ) && ! empty( $job_object->logfile ) ) {
60
+ $not_worked_time = microtime( TRUE ) - $job_object->timestamp_last_update;
61
+ if ( $not_worked_time > 3600 ) {
62
+ $job_object->log( E_USER_ERROR, __( 'Aborted, because no progress for one hour!', 'backwpup' ), __FILE__, __LINE__ );
63
+ unlink( BackWPup::get_plugin_data( 'running_file' ) );
64
+ $job_object->update_working_data();
65
+ }
66
+ }
67
+
68
+ //Compress not compressed logs
69
+ if ( function_exists( 'gzopen' ) && get_site_option( 'backwpup_cfg_gzlogs' ) &&! is_object( $job_object ) ) {
70
+ //Compress old not compressed logs
71
+ if ( $dir = opendir( get_site_option( 'backwpup_cfg_logfolder' ) ) ) {
72
+ $jobids = BackWPup_Option::get_job_ids();
73
+ while ( FALSE !== ( $file = readdir( $dir ) ) ) {
74
+ if ( is_writeable( get_site_option( 'backwpup_cfg_logfolder' ) . $file ) && '.html' == substr( $file, -5 ) ) {
75
+ $compress = new BackWPup_Create_Archive( get_site_option( 'backwpup_cfg_logfolder' ) . $file . '.gz' );
76
+ if ( $compress->add_file( get_site_option( 'backwpup_cfg_logfolder' ) . $file ) ) {
77
+ unlink( get_site_option( 'backwpup_cfg_logfolder' ) . $file );
78
+ //change last logfile in jobs
79
+ foreach( $jobids as $jobid ) {
80
+ $job_logfile = BackWPup_Option::get( $jobid, 'logfile' );
81
+ if ( ! empty( $job_logfile ) && $job_logfile == get_site_option( 'backwpup_cfg_logfolder' ) . $file )
82
+ BackWPup_Option::update( $jobid, 'logfile', get_site_option( 'backwpup_cfg_logfolder' ) . $file . '.gz' );
83
+ }
84
+ }
85
+ unset( $compress );
86
+ }
87
+ }
88
+ closedir( $dir );
89
+ }
90
+ }
91
+
92
+ //Jobs cleanings
93
+ if ( ! is_object( $job_object ) ) {
94
+ //remove restart cron
95
+ wp_clear_scheduled_hook( 'backwpup_cron', array( 'id' => 'restart' ) );
96
+ //temp cleanup
97
+ BackWPup_Job::clean_temp_folder();
98
+ }
99
+
100
+ //check scheduling jobs that not found will removed because there are single scheduled
101
+ $activejobs = BackWPup_Option::get_job_ids( 'activetype', 'wpcron' );
102
+ if ( ! empty( $activejobs ) ) {
103
+ foreach ( $activejobs as $jobid ) {
104
+ $cron_next = wp_next_scheduled( 'backwpup_cron', array( 'id' => $jobid ) );
105
+ if ( ! $cron_next || $cron_next < time() ) {
106
+ wp_unschedule_event( $cron_next, 'backwpup_cron', array( 'id' => $jobid ) );
107
+ $cron_next = BackWPup_Cron::cron_next( BackWPup_Option::get( $jobid, 'cron') );
108
+ wp_schedule_single_event( $cron_next, 'backwpup_cron', array( 'id' => $jobid ) );
109
+ }
110
+ }
111
+ }
112
+
113
+ }
114
+
115
+
116
+ /**
117
+ * Start job if in cron and run query args are set.
118
+ */
119
+ public static function cron_active() {
120
+
121
+ //only if cron active
122
+ if ( ! defined( 'DOING_CRON' ) || ! DOING_CRON )
123
+ return;
124
+
125
+ //only work if backwpup_run as query var ist set and nothing else and the value ist right
126
+ if ( empty( $_GET[ 'backwpup_run' ] ) || ! in_array( $_GET[ 'backwpup_run' ], array( 'test','restart', 'runnow', 'runnowalt', 'runext', 'cronrun' ) ) )
127
+ return;
128
+
129
+ //special header
130
+ @session_write_close();
131
+ @header( 'Content-Type: text/html; charset=' . get_bloginfo( 'charset' ), TRUE );
132
+ @header( 'X-Robots-Tag: noindex, nofollow', TRUE );
133
+ @header( 'X-BackWPup-Version: ' . BackWPup::get_plugin_data( 'version' ), TRUE );
134
+ nocache_headers();
135
+
136
+ //on test die for fast feedback
137
+ if ( $_GET[ 'backwpup_run' ] == 'test' )
138
+ die( 'BackWPup Test' );
139
+
140
+ // generate normal nonce
141
+ $nonce = substr( wp_hash( wp_nonce_tick() . 'backwpup_job_run-' . $_GET[ 'backwpup_run' ], 'nonce' ), - 12, 10 );
142
+ //special nonce on external start
143
+ if ( $_GET[ 'backwpup_run' ] == 'runext' )
144
+ $nonce = get_site_option( 'backwpup_cfg_jobrunauthkey' );
145
+ // check nonce
146
+ if ( empty( $_GET['_nonce'] ) || $nonce != $_GET['_nonce'] )
147
+ return;
148
+
149
+ //check runext is allowed for job
150
+ if ( $_GET[ 'backwpup_run' ] == 'runext' ) {
151
+ $jobids_external = BackWPup_Option::get_job_ids( 'activetype', 'link' );
152
+ if ( !isset( $_GET[ 'jobid' ] ) || ! in_array( $_GET[ 'jobid' ], $jobids_external ) )
153
+ return;
154
+ }
155
+
156
+ //run BackWPup job
157
+ BackWPup_Job::start_http( $_GET[ 'backwpup_run' ] );
158
+ die();
159
+ }
160
+
161
+
162
+ /**
163
+ *
164
+ * Get the local time timestamp of the next cron execution
165
+ *
166
+ * @param string $cronstring cron (* * * * *)
167
+ * @return int timestamp
168
+ */
169
+ public static function cron_next( $cronstring ) {
170
+
171
+ $cron = array();
172
+ $cronarray = array();
173
+ //Cron string
174
+ list( $cronstr[ 'minutes' ], $cronstr[ 'hours' ], $cronstr[ 'mday' ], $cronstr[ 'mon' ], $cronstr[ 'wday' ] ) = explode( ' ', $cronstring, 5 );
175
+
176
+ //make arrays form string
177
+ foreach ( $cronstr as $key => $value ) {
178
+ if ( strstr( $value, ',' ) )
179
+ $cronarray[ $key ] = explode( ',', $value );
180
+ else
181
+ $cronarray[ $key ] = array( 0 => $value );
182
+ }
183
+
184
+ //make arrays complete with ranges and steps
185
+ foreach ( $cronarray as $cronarraykey => $cronarrayvalue ) {
186
+ $cron[ $cronarraykey ] = array();
187
+ foreach ( $cronarrayvalue as $value ) {
188
+ //steps
189
+ $step = 1;
190
+ if ( strstr( $value, '/' ) )
191
+ list( $value, $step ) = explode( '/', $value, 2 );
192
+ //replace weekday 7 with 0 for sundays
193
+ if ( $cronarraykey == 'wday' )
194
+ $value = str_replace( '7', '0', $value );
195
+ //ranges
196
+ if ( strstr( $value, '-' ) ) {
197
+ list( $first, $last ) = explode( '-', $value, 2 );
198
+ if ( ! is_numeric( $first ) || ! is_numeric( $last ) || $last > 60 || $first > 60 ) //check
199
+ return 2147483647;
200
+ if ( $cronarraykey == 'minutes' && $step < 5 ) //set step minimum to 5 min.
201
+ $step = 5;
202
+ $range = array();
203
+ for ( $i = $first; $i <= $last; $i = $i + $step ) {
204
+ $range[ ] = $i;
205
+ }
206
+ $cron[ $cronarraykey ] = array_merge( $cron[ $cronarraykey ], $range );
207
+ }
208
+ elseif ( $value == '*' ) {
209
+ $range = array();
210
+ if ( $cronarraykey == 'minutes' ) {
211
+ if ( $step < 10 ) //set step minimum to 5 min.
212
+ $step = 10;
213
+ for ( $i = 0; $i <= 59; $i = $i + $step ) {
214
+ $range[ ] = $i;
215
+ }
216
+ }
217
+ if ( $cronarraykey == 'hours' ) {
218
+ for ( $i = 0; $i <= 23; $i = $i + $step ) {
219
+ $range[ ] = $i;
220
+ }
221
+ }
222
+ if ( $cronarraykey == 'mday' ) {
223
+ for ( $i = $step; $i <= 31; $i = $i + $step ) {
224
+ $range[ ] = $i;
225
+ }
226
+ }
227
+ if ( $cronarraykey == 'mon' ) {
228
+ for ( $i = $step; $i <= 12; $i = $i + $step ) {
229
+ $range[ ] = $i;
230
+ }
231
+ }
232
+ if ( $cronarraykey == 'wday' ) {
233
+ for ( $i = 0; $i <= 6; $i = $i + $step ) {
234
+ $range[ ] = $i;
235
+ }
236
+ }
237
+ $cron[ $cronarraykey ] = array_merge( $cron[ $cronarraykey ], $range );
238
+ }
239
+ else {
240
+ //Month names
241
+ if ( strtolower( $value ) == 'jan' )
242
+ $value = 1;
243
+ if ( strtolower( $value ) == 'feb' )
244
+ $value = 2;
245
+ if ( strtolower( $value ) == 'mar' )
246
+ $value = 3;
247
+ if ( strtolower( $value ) == 'apr' )
248
+ $value = 4;
249
+ if ( strtolower( $value ) == 'may' )
250
+ $value = 5;
251
+ if ( strtolower( $value ) == 'jun' )
252
+ $value = 6;
253
+ if ( strtolower( $value ) == 'jul' )
254
+ $value = 7;
255
+ if ( strtolower( $value ) == 'aug' )
256
+ $value = 8;
257
+ if ( strtolower( $value ) == 'sep' )
258
+ $value = 9;
259
+ if ( strtolower( $value ) == 'oct' )
260
+ $value = 10;
261
+ if ( strtolower( $value ) == 'nov' )
262
+ $value = 11;
263
+ if ( strtolower( $value ) == 'dec' )
264
+ $value = 12;
265
+ //Week Day names
266
+ if ( strtolower( $value ) == 'sun' )
267
+ $value = 0;
268
+ if ( strtolower( $value ) == 'sat' )
269
+ $value = 6;
270
+ if ( strtolower( $value ) == 'mon' )
271
+ $value = 1;
272
+ if ( strtolower( $value ) == 'tue' )
273
+ $value = 2;
274
+ if ( strtolower( $value ) == 'wed' )
275
+ $value = 3;
276
+ if ( strtolower( $value ) == 'thu' )
277
+ $value = 4;
278
+ if ( strtolower( $value ) == 'fri' )
279
+ $value = 5;
280
+ if ( ! is_numeric( $value ) || $value > 60 ) //check
281
+ return 2147483647;
282
+ $cron[ $cronarraykey ] = array_merge( $cron[ $cronarraykey ], array( 0 => $value ) );
283
+ }
284
+ }
285
+ }
286
+
287
+ //generate years
288
+ for ( $i = gmdate( 'Y' ); $i < gmdate( 'Y', 2147483647 ); $i ++ ) {
289
+ $cron[ 'year' ][ ] = $i;
290
+ }
291
+
292
+ //calc next timestamp
293
+ $current_timestamp = current_time( 'timestamp' );
294
+ foreach ( $cron[ 'year' ] as $year ) {
295
+ foreach ( $cron[ 'mon' ] as $mon ) {
296
+ foreach ( $cron[ 'mday' ] as $mday ) {
297
+ if ( ! checkdate( $mon, $mday, $year ) )
298
+ continue;
299
+ foreach ( $cron[ 'hours' ] as $hours ) {
300
+ foreach ( $cron[ 'minutes' ] as $minutes ) {
301
+ $timestamp = gmmktime( $hours, $minutes, 0, $mon, $mday, $year );
302
+ if ( $timestamp && in_array( gmdate( 'j', $timestamp ), $cron[ 'mday' ] ) && in_array( gmdate( 'w', $timestamp ), $cron[ 'wday' ] ) && $timestamp > $current_timestamp )
303
+ return $timestamp - ( get_option( 'gmt_offset' ) * 3600 );
304
+ }
305
+ }
306
+ }
307
+ }
308
+ }
309
+
310
+ return 2147483647;
311
+ }
312
+
313
+ }
inc/class-destination-dropbox.php CHANGED
@@ -14,7 +14,7 @@ class BackWPup_Destination_Dropbox extends BackWPup_Destinations {
14
  */
15
  public function option_defaults() {
16
 
17
- return array( 'dropboxtoken' => '', 'dropboxsecret' => '', 'dropboxroot' => 'sandbox', 'dropboxmaxbackups' => 15, 'dropboxsyncnodelete' => TRUE, 'dropboxdir' => trailingslashit( sanitize_file_name( get_bloginfo( 'name' ) ) ) );
18
  }
19
 
20
 
@@ -23,47 +23,68 @@ class BackWPup_Destination_Dropbox extends BackWPup_Destinations {
23
  */
24
  public function edit_tab( $jobid ) {
25
 
26
- //Dropbox auth keys from Dropbox
27
- // if cancelled auth
28
- if ( ! empty( $_GET[ 'not_approved' ] ) ) {
29
- echo '<div id="message" class="error"><p>' .__( 'Dropbox authentication not approved', 'backwpup' ) . '</p></div>';
30
- delete_site_transient( 'backwpup_dropbox_auth_' . $jobid );
31
- }
32
- // if Auth data exists
33
- $auth_data = get_site_transient( 'backwpup_dropbox_auth_' . $jobid );
34
- if ( $auth_data ) {
35
- $oAuthStuff = array();
36
  try {
37
- $dropbox = new BackWPup_Destination_Dropbox_API( $auth_data[ 'type' ] );
38
- $oAuthStuff = $dropbox->oAuthAccessToken( $auth_data[ 'oauth_token' ], $auth_data[ 'oauth_token_secret' ] );
39
- if ( ! empty( $oAuthStuff ) ) {
40
- echo '<div id="message" class="updated below-h2"><p>' . __( 'Dropbox authentication complete!', 'backwpup' ) . '</p></div>';
41
- BackWPup_Option::update( $jobid, 'dropboxtoken', $oAuthStuff[ 'oauth_token' ] );
42
- BackWPup_Option::update( $jobid, 'dropboxsecret', BackWPup_Encryption::encrypt( $oAuthStuff[ 'oauth_token_secret' ] ) );
43
- BackWPup_Option::update( $jobid, 'dropboxroot', $auth_data[ 'type' ] );
44
- delete_site_transient( 'backwpup_dropbox_auth_' . $jobid );
45
- }
46
  } catch ( Exception $e ) {
47
- echo '<div id="message" class="error"><p>' . sprintf( __( 'Dropbox API: %s', 'backwpup' ), $e->getMessage() ) . '</p></div>';
48
- delete_site_transient( 'backwpup_dropbox_auth_' . $jobid );
49
  }
 
 
 
50
  }
 
 
 
 
 
 
 
51
  ?>
52
 
53
  <h3 class="title"><?php _e( 'Login', 'backwpup' ); ?></h3>
54
  <p></p>
55
  <table class="form-table">
56
  <tr>
57
- <th scope="row"><?php _e( 'Authenticate', 'backwpup' ); ?></th>
58
- <td><?php if ( ! BackWPup_Option::get( $jobid, 'dropboxtoken' ) && ! BackWPup_Option::get( $jobid, 'dropboxsecret' ) && ! isset( $oAuthStuff[ 'oauth_token' ] ) ) { ?>
59
- <span style="color:red;"><?php _e( 'Not authenticated!', 'backwpup' ); ?></span>&nbsp;<a href="http://db.tt/8irM1vQ0"><?php _e( 'Create Account', 'backwpup' ); ?></a><br />
 
60
  <?php } else { ?>
61
- <span style="color:green;"><?php _e( 'Authenticated!', 'backwpup' ); ?></span><br />
 
62
  <?php } ?>
63
- <a class="button secondary" href="<?php echo admin_url( 'admin-ajax.php', 'relative' );?>?action=backwpup_dest_dropbox&type=sandbox&jobid=<?php echo $jobid ?>"><?php _e( 'Reauthenticate (Sandbox)', 'backwpup' ); ?></a>&nbsp;
64
- <a class="button secondary" href="<?php echo admin_url( 'admin-ajax.php', 'relative' );?>?action=backwpup_dest_dropbox&type=dropbox&jobid=<?php echo $jobid ?>"><?php _e( 'Reauthenticate (full Dropbox)', 'backwpup' ); ?></a>
65
  </td>
66
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  </table>
68
 
69
 
@@ -71,9 +92,10 @@ class BackWPup_Destination_Dropbox extends BackWPup_Destinations {
71
  <p></p>
72
  <table class="form-table">
73
  <tr>
74
- <th scope="row"><label for="iddropboxdir"><?php _e( 'Folder in Dropbox', 'backwpup' ); ?></label></th>
75
  <td>
76
- <input id="iddropboxdir" name="dropboxdir" type="text" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'dropboxdir' ) ); ?>" class="regular-text" />
 
77
  </td>
78
  </tr>
79
  <tr>
@@ -82,8 +104,8 @@ class BackWPup_Destination_Dropbox extends BackWPup_Destinations {
82
  <?php
83
  if ( BackWPup_Option::get( $jobid, 'backuptype' ) == 'archive' ) {
84
  ?>
85
- <label for="iddropboxmaxbackups"><input id="iddropboxmaxbackups" name="dropboxmaxbackups" title="<?php esc_attr_e( 'Oldest files will be deleted first. 0 = no deletion', 'backwpup' ); ?>" type="text" size="3" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'dropboxmaxbackups' ) );?>" class="small-text help-tip" />&nbsp;
86
- <?php _e( 'Number of files to keep in folder.', 'backwpup' ); ?></label>
87
  <?php } else { ?>
88
  <label for="iddropboxsyncnodelete" ><input class="checkbox" value="1"
89
  type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'dropboxsyncnodelete' ), TRUE ); ?>
@@ -97,61 +119,33 @@ class BackWPup_Destination_Dropbox extends BackWPup_Destinations {
97
  }
98
 
99
  /**
100
- * Authentication over ajax
 
101
  */
102
- public function edit_ajax() {
103
-
104
- $_GET[ 'jobid' ] = (int) $_GET[ 'jobid' ];
105
 
106
- // dropbox auth
107
- if ( $_GET[ 'type' ] == 'dropbox' ) {
108
  try {
109
- $dropbox = new BackWPup_Destination_Dropbox_API( 'dropbox' );
110
- // let the user authorize (user will be redirected)
111
- $response = $dropbox->oAuthAuthorize( network_admin_url( 'admin.php' ) . '?page=backwpupeditjob&jobid=' .$_GET[ 'jobid' ] .'&tab=dest-dropbox&_wpnonce=' . wp_create_nonce( 'edit-job' ) );
112
- // save oauth_token_secret
113
- $auth_data = array(
114
- 'oauth_token' => $response[ 'oauth_token' ],
115
- 'oauth_token_secret' => $response[ 'oauth_token_secret' ],
116
- 'type' => 'dropbox'
117
- );
118
- set_site_transient( 'backwpup_dropbox_auth_' . $_GET[ 'jobid' ], $auth_data, 3600 );
119
- wp_redirect( $response[ 'authurl' ] );
120
-
121
- }
122
- catch ( Exception $e ) {
123
- BackWPup_Admin::message( sprintf( __( 'Dropbox API: %s', 'backwpup' ), $e->getMessage() ), true );
124
- wp_redirect( network_admin_url( 'admin.php' ) . '?page=backwpupeditjob&jobid=' .$_GET[ 'jobid' ] .'&tab=dest-dropbox&_wpnonce=' . wp_create_nonce( 'edit-job' ) );
125
  }
126
  }
127
- // sandbox auth
128
- elseif ( $_GET[ 'type' ] == 'sandbox' ) {
129
  try {
130
- $dropbox = new BackWPup_Destination_Dropbox_API( 'sandbox' );
131
- // let the user authorize (user will be redirected)
132
- $response = $dropbox->oAuthAuthorize( network_admin_url( 'admin.php' ) . '?page=backwpupeditjob&jobid=' .$_GET[ 'jobid' ] .'&tab=dest-dropbox&_wpnonce=' . wp_create_nonce( 'edit-job' ) );
133
- // save oauth_token_secret
134
- $auth_data = array(
135
- 'oauth_token' => $response[ 'oauth_token' ],
136
- 'oauth_token_secret' => $response[ 'oauth_token_secret' ],
137
- 'type' => 'sandbox'
138
- );
139
- set_site_transient( 'backwpup_dropbox_auth_' . $_GET[ 'jobid' ], $auth_data, 3600 );
140
- wp_redirect( $response[ 'authurl' ] );
141
- }
142
- catch ( Exception $e ) {
143
- BackWPup_Admin::message( sprintf( __( 'Dropbox API: %s', 'backwpup' ), $e->getMessage() ), true );
144
- wp_redirect( network_admin_url( 'admin.php' ) . '?page=backwpupeditjob&jobid=' .$_GET[ 'jobid' ] .'&tab=dest-dropbox&_wpnonce=' . wp_create_nonce( 'edit-job' ) );
145
  }
146
  }
147
- }
148
-
149
-
150
- /**
151
- * @param $jobid
152
- * @return string|void
153
- */
154
- public function edit_form_post_save( $jobid ) {
155
 
156
  BackWPup_Option::update( $jobid, 'dropboxsyncnodelete', ( isset( $_POST[ 'dropboxsyncnodelete' ] ) && $_POST[ 'dropboxsyncnodelete' ] == 1 ) ? TRUE : FALSE );
157
  BackWPup_Option::update( $jobid, 'dropboxmaxbackups', isset( $_POST[ 'dropboxmaxbackups' ] ) ? (int)$_POST[ 'dropboxmaxbackups' ] : 0 );
@@ -177,7 +171,7 @@ class BackWPup_Destination_Dropbox extends BackWPup_Destinations {
177
  if ( BackWPup_Option::get( $jobid, 'dropboxtoken' ) && BackWPup_Option::get( $jobid, 'dropboxsecret' ) ) {
178
  try {
179
  $dropbox = new BackWPup_Destination_Dropbox_API( BackWPup_Option::get( $jobid, 'dropboxroot' ) );
180
- $dropbox->setOAuthTokens( BackWPup_Option::get( $jobid, 'dropboxtoken' ), BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'dropboxsecret' ) ) );
181
  $dropbox->fileopsDelete( $backupfile );
182
  //update file list
183
  foreach ( $files as $key => $file ) {
@@ -201,7 +195,7 @@ class BackWPup_Destination_Dropbox extends BackWPup_Destinations {
201
 
202
  try {
203
  $dropbox = new BackWPup_Destination_Dropbox_API( BackWPup_Option::get( $jobid, 'dropboxroot' ) );
204
- $dropbox->setOAuthTokens( BackWPup_Option::get( $jobid, 'dropboxtoken' ), BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'dropboxsecret' ) ) );
205
  $media = $dropbox->media( $get_file );
206
  if ( ! empty( $media[ 'url' ] ) )
207
  header( "Location: " . $media[ 'url' ] );
@@ -232,21 +226,32 @@ class BackWPup_Destination_Dropbox extends BackWPup_Destinations {
232
 
233
  try {
234
  $dropbox = new BackWPup_Destination_Dropbox_API( $job_object->job[ 'dropboxroot' ] );
 
 
 
 
 
 
 
235
  // set the tokens
236
- $dropbox->setOAuthTokens( $job_object->job[ 'dropboxtoken' ], BackWPup_Encryption::decrypt( $job_object->job[ 'dropboxsecret' ] ) );
 
237
  //get account info
238
  if ( $job_object->steps_data[ $job_object->step_working ]['SAVE_STEP_TRY'] != $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ) {
239
  $info = $dropbox->accountInfo();
240
  if ( ! empty( $info[ 'uid' ] ) ) {
241
  $job_object->log( sprintf( __( 'Authenticated with Dropbox of user %s', 'backwpup' ), $info[ 'display_name' ] . ' (' . $info[ 'email' ] . ')' ), E_USER_NOTICE );
 
 
 
242
  } else {
243
  $job_object->log( __( 'Not Authenticated with Dropbox!', 'backwpup' ), E_USER_ERROR );
244
  return FALSE;
245
  }
246
- // put the file
247
  $job_object->log( __( 'Uploading to Dropbox&#160;&hellip;', 'backwpup' ), E_USER_NOTICE );
248
  }
249
 
 
250
  self::$backwpup_job_object = &$job_object;
251
 
252
  if ( $job_object->substeps_done < $job_object->backup_filesize ) { //only if upload not complete
@@ -335,9 +340,6 @@ class BackWPup_Destination_Dropbox extends BackWPup_Destinations {
335
  if ( empty( $job_object->job[ 'dropboxtoken' ] ) )
336
  return FALSE;
337
 
338
- if ( empty( $job_object->job[ 'dropboxsecret' ] ) )
339
- return FALSE;
340
-
341
  return TRUE;
342
  }
343
 
@@ -392,10 +394,6 @@ final class BackWPup_Destination_Dropbox_API {
392
  */
393
  private $oauth_token = '';
394
 
395
- /**
396
- * @var string
397
- */
398
- private $oauth_token_secret = '';
399
 
400
 
401
  /**
@@ -415,22 +413,27 @@ final class BackWPup_Destination_Dropbox_API {
415
  $this->root = 'sandbox';
416
  }
417
 
418
- if ( empty( $this->oauth_app_key ) or empty( $this->oauth_app_secret ) )
419
  throw new BackWPup_Destination_Dropbox_API_Exception( "No App key or App Secret specified." );
420
  }
421
 
422
  /**
423
  * @param $token
424
- * @param $secret
425
  * @throws BackWPup_Destination_Dropbox_API_Exception
426
  */
427
- public function setOAuthTokens( $token, $secret ) {
428
 
429
- $this->oauth_token = $token;
430
- $this->oauth_token_secret = $secret;
431
 
432
- if ( empty( $this->oauth_token ) or empty( $this->oauth_token_secret ) )
433
- throw new BackWPup_Destination_Dropbox_API_Exception( "No oAuth token or secret specified." );
 
 
 
 
 
 
434
  }
435
 
436
  /**
@@ -443,6 +446,13 @@ final class BackWPup_Destination_Dropbox_API {
443
  return $this->request( $url );
444
  }
445
 
 
 
 
 
 
 
 
446
  /**
447
  * @param $file
448
  * @param string $path
@@ -592,142 +602,26 @@ final class BackWPup_Destination_Dropbox_API {
592
  ) );
593
  }
594
 
595
- /**
596
- * @param $callback_url
597
- * @return array
598
- * @throws BackWPup_Destination_Dropbox_API_Exception
599
- */
600
- public function oAuthAuthorize( $callback_url ) {
601
 
602
- $headers[ ] = 'Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="' . $this->oauth_app_key . '", oauth_signature="' . $this->oauth_app_secret . '&"';
603
- $ch = curl_init();
604
- curl_setopt( $ch, CURLOPT_URL, self::API_URL . self::API_VERSION_URL . 'oauth/request_token' );
605
- curl_setopt( $ch, CURLOPT_USERAGENT, BackWPup::get_plugin_data( 'User-Agent' ) );
606
- if ( BackWPup::get_plugin_data( 'cacert' ) ) {
607
- curl_setopt( $ch, CURLOPT_SSLVERSION, 3 );
608
- curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, TRUE );
609
- curl_setopt( $ch, CURLOPT_SSL_CIPHER_LIST,
610
- 'ECDHE-RSA-AES256-GCM-SHA384:'.
611
- 'ECDHE-RSA-AES128-GCM-SHA256:'.
612
- 'ECDHE-RSA-AES256-SHA384:'.
613
- 'ECDHE-RSA-AES128-SHA256:'.
614
- 'ECDHE-RSA-AES256-SHA:'.
615
- 'ECDHE-RSA-AES128-SHA:'.
616
- 'ECDHE-RSA-RC4-SHA:'.
617
- 'DHE-RSA-AES256-GCM-SHA384:'.
618
- 'DHE-RSA-AES128-GCM-SHA256:'.
619
- 'DHE-RSA-AES256-SHA256:'.
620
- 'DHE-RSA-AES128-SHA256:'.
621
- 'DHE-RSA-AES256-SHA:'.
622
- 'DHE-RSA-AES128-SHA:'.
623
- 'AES256-GCM-SHA384:'.
624
- 'AES128-GCM-SHA256:'.
625
- 'AES256-SHA256:'.
626
- 'AES128-SHA256:'.
627
- 'AES256-SHA:'.
628
- 'AES128-SHA'
629
- );
630
- if ( defined( 'CURLOPT_PROTOCOLS' ) )
631
- curl_setopt( $ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS );
632
- if ( defined( 'CURLOPT_REDIR_PROTOCOLS' ) )
633
- curl_setopt( $ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS );
634
- curl_setopt( $ch, CURLOPT_CAINFO, BackWPup::get_plugin_data( 'cacert' ) );
635
- curl_setopt( $ch, CURLOPT_CAPATH, dirname( BackWPup::get_plugin_data( 'cacert' ) ) );
636
- } else {
637
- curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
638
- }
639
- curl_setopt( $ch, CURLOPT_AUTOREFERER, TRUE );
640
- curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
641
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, TRUE );
642
- $content = curl_exec( $ch );
643
- $status = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
644
- if ( $status >= 200 && $status < 300 && 0 == curl_errno( $ch ) ) {
645
- parse_str( $content, $oauth_token );
646
- }
647
- else {
648
- $output = json_decode( $content, TRUE );
649
- if ( isset( $output[ 'error' ] ) && is_string( $output[ 'error' ] ) ) $message = $output[ 'error' ];
650
- elseif ( isset( $output[ 'error' ][ 'hash' ] ) && $output[ 'error' ][ 'hash' ] != '' ) $message = (string)$output[ 'error' ][ 'hash' ];
651
- elseif ( 0 != curl_errno( $ch ) ) $message = '(' . curl_errno( $ch ) . ') ' . curl_error( $ch );
652
- else $message = '(' . $status . ') Invalid response.';
653
- throw new BackWPup_Destination_Dropbox_API_Exception( $message );
654
- }
655
- curl_close( $ch );
656
-
657
- return array(
658
- 'authurl' => self::API_WWW_URL . self::API_VERSION_URL . 'oauth/authorize?oauth_token=' . $oauth_token[ 'oauth_token' ] . '&oauth_callback=' . urlencode( $callback_url ),
659
- 'oauth_token' => $oauth_token[ 'oauth_token' ],
660
- 'oauth_token_secret' => $oauth_token[ 'oauth_token_secret' ]
661
- );
662
  }
663
 
664
- /**
665
- * @param $oauth_token
666
- * @param $oauth_token_secret
667
- *
668
- * @return array|null
669
- * @throws BackWPup_Destination_Dropbox_API_Exception
670
- */
671
- public function oAuthAccessToken( $oauth_token, $oauth_token_secret ) {
672
 
673
- $headers[ ] = 'Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="' . $this->oauth_app_key . '", oauth_token="' . $oauth_token . '", oauth_signature="' . $this->oauth_app_secret . '&' . $oauth_token_secret . '"';
674
- $ch = curl_init();
675
- curl_setopt( $ch, CURLOPT_URL, self::API_URL . self::API_VERSION_URL . 'oauth/access_token' );
676
- curl_setopt( $ch, CURLOPT_USERAGENT, BackWPup::get_plugin_data( 'User-Agent' ) );
677
- if ( BackWPup::get_plugin_data( 'cacert' ) ) {
678
- curl_setopt( $ch, CURLOPT_SSLVERSION, 3 );
679
- curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, TRUE );
680
- curl_setopt( $ch, CURLOPT_SSL_CIPHER_LIST,
681
- 'ECDHE-RSA-AES256-GCM-SHA384:'.
682
- 'ECDHE-RSA-AES128-GCM-SHA256:'.
683
- 'ECDHE-RSA-AES256-SHA384:'.
684
- 'ECDHE-RSA-AES128-SHA256:'.
685
- 'ECDHE-RSA-AES256-SHA:'.
686
- 'ECDHE-RSA-AES128-SHA:'.
687
- 'ECDHE-RSA-RC4-SHA:'.
688
- 'DHE-RSA-AES256-GCM-SHA384:'.
689
- 'DHE-RSA-AES128-GCM-SHA256:'.
690
- 'DHE-RSA-AES256-SHA256:'.
691
- 'DHE-RSA-AES128-SHA256:'.
692
- 'DHE-RSA-AES256-SHA:'.
693
- 'DHE-RSA-AES128-SHA:'.
694
- 'AES256-GCM-SHA384:'.
695
- 'AES128-GCM-SHA256:'.
696
- 'AES256-SHA256:'.
697
- 'AES128-SHA256:'.
698
- 'AES256-SHA:'.
699
- 'AES128-SHA'
700
- );
701
- if ( defined( 'CURLOPT_PROTOCOLS' ) )
702
- curl_setopt( $ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS );
703
- if ( defined( 'CURLOPT_REDIR_PROTOCOLS' ) )
704
- curl_setopt( $ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS );
705
- curl_setopt( $ch, CURLOPT_CAINFO, BackWPup::get_plugin_data( 'cacert' ) );
706
- curl_setopt( $ch, CURLOPT_CAPATH, dirname( BackWPup::get_plugin_data( 'cacert' ) ) );
707
- } else {
708
- curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
709
- }
710
- curl_setopt( $ch, CURLOPT_AUTOREFERER, TRUE );
711
- curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
712
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, TRUE );
713
- $content = curl_exec( $ch );
714
- $status = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
715
- if ( $status >= 200 && $status < 300 && 0 == curl_errno( $ch ) ) {
716
- parse_str( $content, $oauth_token );
717
- $this->setOAuthTokens( $oauth_token[ 'oauth_token' ], $oauth_token[ 'oauth_token_secret' ] );
718
 
719
- return $oauth_token;
720
- }
721
- else {
722
- $output = json_decode( $content, TRUE );
723
- if ( isset( $output[ 'error' ] ) && is_string( $output[ 'error' ] ) ) $message = $output[ 'error' ];
724
- elseif ( isset( $output[ 'error' ][ 'hash' ] ) && $output[ 'error' ][ 'hash' ] != '' ) $message = (string)$output[ 'error' ][ 'hash' ];
725
- elseif ( 0 != curl_errno( $ch ) ) $message = '(' . curl_errno( $ch ) . ') ' . curl_error( $ch );
726
- else $message = '(' . $status . ') Invalid response.';
727
- throw new BackWPup_Destination_Dropbox_API_Exception( $message );
728
- }
729
  }
730
 
 
731
  /**
732
  * @param $url
733
  * @param array $args
@@ -742,7 +636,13 @@ final class BackWPup_Destination_Dropbox_API {
742
  private function request( $url, $args = array(), $method = 'GET', $data = '', $echo = FALSE ) {
743
 
744
  /* Header*/
745
- $headers[ ] = 'Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="' . $this->oauth_app_key . '", oauth_token="' . $this->oauth_token . '", oauth_signature="' . $this->oauth_app_secret . '&' . $this->oauth_token_secret . '"';
 
 
 
 
 
 
746
  $headers[ ] = 'Expect:';
747
 
748
  /* Build cURL Request */
@@ -767,29 +667,32 @@ final class BackWPup_Destination_Dropbox_API {
767
  curl_setopt( $ch, CURLOPT_USERAGENT, BackWPup::get_plugin_data( 'User-Agent' ) );
768
  curl_setopt( $ch, CURLOPT_RETURNTRANSFER, TRUE );
769
  if ( BackWPup::get_plugin_data( 'cacert' ) ) {
770
- curl_setopt( $ch, CURLOPT_SSLVERSION, 3 );
771
  curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, TRUE );
772
- curl_setopt( $ch, CURLOPT_SSL_CIPHER_LIST,
773
- 'ECDHE-RSA-AES256-GCM-SHA384:'.
774
- 'ECDHE-RSA-AES128-GCM-SHA256:'.
775
- 'ECDHE-RSA-AES256-SHA384:'.
776
- 'ECDHE-RSA-AES128-SHA256:'.
777
- 'ECDHE-RSA-AES256-SHA:'.
778
- 'ECDHE-RSA-AES128-SHA:'.
779
- 'ECDHE-RSA-RC4-SHA:'.
780
- 'DHE-RSA-AES256-GCM-SHA384:'.
781
- 'DHE-RSA-AES128-GCM-SHA256:'.
782
- 'DHE-RSA-AES256-SHA256:'.
783
- 'DHE-RSA-AES128-SHA256:'.
784
- 'DHE-RSA-AES256-SHA:'.
785
- 'DHE-RSA-AES128-SHA:'.
786
- 'AES256-GCM-SHA384:'.
787
- 'AES128-GCM-SHA256:'.
788
- 'AES256-SHA256:'.
789
- 'AES128-SHA256:'.
790
- 'AES256-SHA:'.
791
- 'AES128-SHA'
792
- );
 
 
 
793
  if ( defined( 'CURLOPT_PROTOCOLS' ) )
794
  curl_setopt( $ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS );
795
  if ( defined( 'CURLOPT_REDIR_PROTOCOLS' ) )
@@ -825,7 +728,7 @@ final class BackWPup_Destination_Dropbox_API {
825
  trigger_error( sprintf( '(503) Your app is making too many requests and is being rate limited. Error 503 can be triggered on a per-app or per-user basis. Wait for %d seconds.', $wait ), E_USER_WARNING );
826
  sleep( $wait );
827
  } else {
828
- trigger_error( '(503) Service unavailable. Retrying.', E_USER_WARNING );
829
  }
830
  //redo request
831
  return $this->request( $url, $args, $method, $data, $echo );
@@ -845,15 +748,15 @@ final class BackWPup_Destination_Dropbox_API {
845
  elseif ( 0 != curl_errno( $ch ) ) $message = '(' . curl_errno( $ch ) . ') ' . curl_error( $ch );
846
  elseif ( $status[ 'http_code' ] == 304 ) $message = '(304) Folder contents have not changed (relies on hash parameter).';
847
  elseif ( $status[ 'http_code' ] == 400 ) $message = '(400) Bad input parameter: ' . strip_tags( $responce[ 1 ] );
848
- elseif ( $status[ 'http_code' ] == 401 ) $message = '(401) Bad or expired token. Please re-authenticate the user.';
849
- elseif ( $status[ 'http_code' ] == 403 ) $message = '(403) Bad OAuth request (wrong consumer key, bad nonce, expired timestamp,&hellip;)';
850
- elseif ( $status[ 'http_code' ] == 404 ) $message = '(404) File could not be found at the specified path or rev.';
851
- elseif ( $status[ 'http_code' ] == 405 ) $message = '(405) Request method not expected (generally should be GET,PUT or POST).';
852
  elseif ( $status[ 'http_code' ] == 406 ) $message = '(406) There are too many file entries to return.';
853
- elseif ( $status[ 'http_code' ] == 411 ) $message = '(411) Chunked encoding was attempted for this upload, but is not supported by Dropbox.';
854
- elseif ( $status[ 'http_code' ] == 415 ) $message = '(415) The image is invalid and cannot be thumbnailed.';
855
- elseif ( $status[ 'http_code' ] == 503 ) $message = '(503) Service unavailable.';
856
- elseif ( $status[ 'http_code' ] == 507 ) $message = '(507) User exceeding Dropbox storage quota.';
857
  else $message = '(' . $status[ 'http_code' ] . ') Invalid response.';
858
  throw new BackWPup_Destination_Dropbox_API_Exception( $message );
859
  }
@@ -885,4 +788,4 @@ final class BackWPup_Destination_Dropbox_API {
885
  */
886
  class BackWPup_Destination_Dropbox_API_Exception extends Exception {
887
 
888
- }
14
  */
15
  public function option_defaults() {
16
 
17
+ return array( 'dropboxtoken' => array(), 'dropboxroot' => 'sandbox', 'dropboxmaxbackups' => 15, 'dropboxsyncnodelete' => TRUE, 'dropboxdir' => trailingslashit( sanitize_file_name( get_bloginfo( 'name' ) ) ) );
18
  }
19
 
20
 
23
  */
24
  public function edit_tab( $jobid ) {
25
 
26
+ if ( ! empty( $_GET[ 'deleteauth' ] ) && $_GET[ 'deleteauth' ] == 1 ) {
27
+ //disable token on dropbox
 
 
 
 
 
 
 
 
28
  try {
29
+ $dropbox = new BackWPup_Destination_Dropbox_API( BackWPup_Option::get( $jobid, 'dropboxroot' ) );
30
+ if ( BackWPup_Option::get( $jobid, 'dropboxsecret' ) )
31
+ $dropbox->setOAuthTokens( array( 'access_token' => BackWPup_Option::get( $jobid, 'dropboxtoken' ), 'oauth_token_secret' => BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'dropboxsecret' ) ) ) );
32
+ else
33
+ $dropbox->setOAuthTokens( BackWPup_Option::get( $jobid, 'dropboxtoken' ) );
34
+ $dropbox->disable_access_token();
 
 
 
35
  } catch ( Exception $e ) {
36
+ echo '<div id="message" class="error"><p>' . sprintf( __( 'Dropbox API: %s', 'backwpup' ), $e->getMessage() ) . '</p></div>';
 
37
  }
38
+ BackWPup_Option::update( $jobid, 'dropboxtoken', array() );
39
+ BackWPup_Option::update( $jobid, 'dropboxroot', 'sandbox' );
40
+ BackWPup_Option::delete( $jobid, 'dropboxsecret' );
41
  }
42
+
43
+ $dropbox = new BackWPup_Destination_Dropbox_API( 'dropbox' );
44
+ $dropbox_auth_url = $dropbox->oAuthAuthorize();
45
+ $dropbox = new BackWPup_Destination_Dropbox_API( 'sandbox' );
46
+ $sandbox_auth_url = $dropbox->oAuthAuthorize();
47
+
48
+ $dropboxtoken = BackWPup_Option::get( $jobid, 'dropboxtoken' );
49
  ?>
50
 
51
  <h3 class="title"><?php _e( 'Login', 'backwpup' ); ?></h3>
52
  <p></p>
53
  <table class="form-table">
54
  <tr>
55
+ <th scope="row"><?php _e( 'Authentication', 'backwpup' ); ?></th>
56
+ <td><?php if ( empty( $dropboxtoken[ 'access_token' ] ) ) { ?>
57
+ <span style="color:red;"><?php _e( 'Not authenticated!', 'backwpup' ); ?></span><br />&nbsp;<br />
58
+ <a class="button secondary" href="http://db.tt/8irM1vQ0"><?php _e( 'Create Account', 'backwpup' ); ?></a>
59
  <?php } else { ?>
60
+ <span style="color:green;"><?php _e( 'Authenticated!', 'backwpup' ); ?></span><br />&nbsp;<br />
61
+ <a class="button secondary" href="<?php echo network_admin_url( 'admin.php' ) . '?page=backwpupeditjob&deleteauth=1&jobid=' . $jobid .'&tab=dest-dropbox&_wpnonce=' . wp_create_nonce( 'edit-job' ); ?>" title="<?php _e( 'Delete Dropbox Authentication', 'backwpup' ); ?>"><?php _e( 'Delete Dropbox Authentication', 'backwpup' ); ?></a>
62
  <?php } ?>
 
 
63
  </td>
64
  </tr>
65
+
66
+ <?php if ( empty( $dropboxtoken[ 'access_token' ] ) ) { ?>
67
+ <tr>
68
+ <th scope="row"><label for="id_sandbox_code"><?php _e( 'App Access to Dropbox', 'backwpup' ); ?></label></th>
69
+ <td>
70
+ <input id="id_sandbox_code" name="sandbox_code" type="text" value="" class="regular-text code help-tip" title="<?php esc_attr_e( 'A dedicated folder named BackWPup will be created inside of the Apps folder in your Dropbox. BackWPup will get read and write access to that folder only. You can specify a subfolder as your backup destination for this job in the destination field below.', 'backwpup' ); ?>" />&nbsp;
71
+ <a class="button secondary" href="<?php echo $sandbox_auth_url;?>" target="_blank"><?php _e( 'Get Dropbox App auth code', 'backwpup' ); ?></a>
72
+ <p><em><?php _e( 'Allows restricted access to Apps/BackWPup folder only.', 'backwpup' ); ?></em></p>
73
+ </td>
74
+ </tr>
75
+ <tr>
76
+ <th></th>
77
+ <td><?php _e( '— OR —', 'backwpup' ); ?></td>
78
+ </tr>
79
+ <tr>
80
+ <th scope="row"><label for="id_dropbbox_code"><?php _e( 'Full Access to Dropbox', 'backwpup' ); ?></label></th>
81
+ <td>
82
+ <input id="id_dropbbox_code" name="dropbbox_code" type="text" value="" class="regular-text code help-tip" title="<?php _e( 'BackWPup will have full read and write access to your entire Dropbox. You can specify your backup destination wherever you want, just be aware that ANY files or folders inside of your Dropbox can be overridden or deleted by BackWPup.', 'backwpup' ); ?>" />&nbsp;
83
+ <a class="button secondary" href="<?php echo $dropbox_auth_url;?>" target="_blank"><?php _e( 'Get full Dropbox auth code ', 'backwpup' ); ?></a>
84
+ <p><em><?php _e( 'Allows full access to your entire Dropbox.', 'backwpup' ); ?></em></p>
85
+ </td>
86
+ </tr>
87
+ <?php } ?>
88
  </table>
89
 
90
 
92
  <p></p>
93
  <table class="form-table">
94
  <tr>
95
+ <th scope="row"><label for="iddropboxdir"><?php _e( 'Destination Folder', 'backwpup' ); ?></label></th>
96
  <td>
97
+ <input id="iddropboxdir" name="dropboxdir" type="text" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'dropboxdir' ) ); ?>" class="regular-text help-tip" title="<?php esc_attr_e( 'Specify a subfolder where your backup archives will be stored. If you use the App option from above, this folder will be created inside of Apps/BackWPup. Otherwise it will be created at the root of your Dropbox. Already exisiting folders with the same name will not be overriden.', 'backwpup' ); ?>" />
98
+ <p><em><?php _e( 'Folder inside your Dropbox where your backup archives will be stored.', 'theme_hamburg_textdomain' );?></em></p>
99
  </td>
100
  </tr>
101
  <tr>
104
  <?php
105
  if ( BackWPup_Option::get( $jobid, 'backuptype' ) == 'archive' ) {
106
  ?>
107
+ <label for="iddropboxmaxbackups"><input id="iddropboxmaxbackups" name="dropboxmaxbackups" title="<?php esc_attr_e( 'Older files will be deleted first. 0 = no files will be deleted.', 'backwpup' ); ?>" type="text" size="3" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'dropboxmaxbackups' ) );?>" class="small-text help-tip" />&nbsp;
108
+ <em><?php _e( 'Number of files to keep in folder.', 'backwpup' ); ?></em></label>
109
  <?php } else { ?>
110
  <label for="iddropboxsyncnodelete" ><input class="checkbox" value="1"
111
  type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'dropboxsyncnodelete' ), TRUE ); ?>
119
  }
120
 
121
  /**
122
+ * @param $jobid
123
+ * @return string|void
124
  */
125
+ public function edit_form_post_save( $jobid ) {
 
 
126
 
127
+ // get auth
128
+ if ( ! empty( $_POST[ 'sandbox_code' ] ) ) {
129
  try {
130
+ $dropbox = new BackWPup_Destination_Dropbox_API( 'sandbox' );
131
+ $dropboxtoken = $dropbox->oAuthToken( $_POST[ 'sandbox_code' ] );
132
+ BackWPup_Option::update( $jobid, 'dropboxtoken', $dropboxtoken );
133
+ BackWPup_Option::update( $jobid, 'dropboxroot', 'sandbox' );
134
+ } catch ( Exception $e ) {
135
+ BackWPup_Admin::message( 'DROPBOX: ' . $e->getMessage(), TRUE );
 
 
 
 
 
 
 
 
 
 
136
  }
137
  }
138
+
139
+ if ( ! empty( $_POST[ 'dropbbox_code' ] ) ) {
140
  try {
141
+ $dropbox = new BackWPup_Destination_Dropbox_API( 'dropbox' );
142
+ $dropboxtoken = $dropbox->oAuthToken( $_POST[ 'dropbbox_code' ] );
143
+ BackWPup_Option::update( $jobid, 'dropboxtoken', $dropboxtoken );
144
+ BackWPup_Option::update( $jobid, 'dropboxroot', 'dropbox' );
145
+ } catch ( Exception $e ) {
146
+ BackWPup_Admin::message( 'DROPBOX: ' . $e->getMessage(), TRUE );
 
 
 
 
 
 
 
 
 
147
  }
148
  }
 
 
 
 
 
 
 
 
149
 
150
  BackWPup_Option::update( $jobid, 'dropboxsyncnodelete', ( isset( $_POST[ 'dropboxsyncnodelete' ] ) && $_POST[ 'dropboxsyncnodelete' ] == 1 ) ? TRUE : FALSE );
151
  BackWPup_Option::update( $jobid, 'dropboxmaxbackups', isset( $_POST[ 'dropboxmaxbackups' ] ) ? (int)$_POST[ 'dropboxmaxbackups' ] : 0 );
171
  if ( BackWPup_Option::get( $jobid, 'dropboxtoken' ) && BackWPup_Option::get( $jobid, 'dropboxsecret' ) ) {
172
  try {
173
  $dropbox = new BackWPup_Destination_Dropbox_API( BackWPup_Option::get( $jobid, 'dropboxroot' ) );
174
+ $dropbox->setOAuthTokens( BackWPup_Option::get( $jobid, 'dropboxtoken' ) );
175
  $dropbox->fileopsDelete( $backupfile );
176
  //update file list
177
  foreach ( $files as $key => $file ) {
195
 
196
  try {
197
  $dropbox = new BackWPup_Destination_Dropbox_API( BackWPup_Option::get( $jobid, 'dropboxroot' ) );
198
+ $dropbox->setOAuthTokens( BackWPup_Option::get( $jobid, 'dropboxtoken' ) );
199
  $media = $dropbox->media( $get_file );
200
  if ( ! empty( $media[ 'url' ] ) )
201
  header( "Location: " . $media[ 'url' ] );
226
 
227
  try {
228
  $dropbox = new BackWPup_Destination_Dropbox_API( $job_object->job[ 'dropboxroot' ] );
229
+ // cahnge oauth1 to oauth2 token
230
+ if ( ! empty( $job_object->job[ 'dropboxsecret' ] ) && empty( $job_object->job[ 'dropboxtoken' ][ 'access_token' ] ) ) {
231
+ $dropbox->setOAuthTokens( array( 'access_token' => $job_object->job[ 'dropboxtoken' ], 'oauth_token_secret' => BackWPup_Encryption::decrypt( $job_object->job[ 'dropboxsecret' ] ) ) );
232
+ $job_object->job[ 'dropboxtoken' ] = $dropbox->token_from_oauth1();
233
+ BackWPup_Option::update( $job_object->job[ 'jobid' ], 'dropboxtoken', $job_object->job[ 'dropboxtoken' ] );
234
+ BackWPup_Option::delete( $job_object->job[ 'jobid' ], 'dropboxsecret' );
235
+ }
236
  // set the tokens
237
+ $dropbox->setOAuthTokens( $job_object->job[ 'dropboxtoken' ] );
238
+
239
  //get account info
240
  if ( $job_object->steps_data[ $job_object->step_working ]['SAVE_STEP_TRY'] != $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ) {
241
  $info = $dropbox->accountInfo();
242
  if ( ! empty( $info[ 'uid' ] ) ) {
243
  $job_object->log( sprintf( __( 'Authenticated with Dropbox of user %s', 'backwpup' ), $info[ 'display_name' ] . ' (' . $info[ 'email' ] . ')' ), E_USER_NOTICE );
244
+ //Quota
245
+ $dropboxfreespase = $info[ 'quota_info' ][ 'quota' ] - $info[ 'quota_info' ][ 'shared' ] - $info[ 'quota_info' ][ 'normal' ];
246
+ $job_object->log( sprintf( __( '%s available on your Dropbox', 'backwpup' ), size_format( $dropboxfreespase, 2 ) ), E_USER_NOTICE );
247
  } else {
248
  $job_object->log( __( 'Not Authenticated with Dropbox!', 'backwpup' ), E_USER_ERROR );
249
  return FALSE;
250
  }
 
251
  $job_object->log( __( 'Uploading to Dropbox&#160;&hellip;', 'backwpup' ), E_USER_NOTICE );
252
  }
253
 
254
+ // put the file
255
  self::$backwpup_job_object = &$job_object;
256
 
257
  if ( $job_object->substeps_done < $job_object->backup_filesize ) { //only if upload not complete
340
  if ( empty( $job_object->job[ 'dropboxtoken' ] ) )
341
  return FALSE;
342
 
 
 
 
343
  return TRUE;
344
  }
345
 
394
  */
395
  private $oauth_token = '';
396
 
 
 
 
 
397
 
398
 
399
  /**
413
  $this->root = 'sandbox';
414
  }
415
 
416
+ if ( empty( $this->oauth_app_key ) || empty( $this->oauth_app_secret ) )
417
  throw new BackWPup_Destination_Dropbox_API_Exception( "No App key or App Secret specified." );
418
  }
419
 
420
  /**
421
  * @param $token
 
422
  * @throws BackWPup_Destination_Dropbox_API_Exception
423
  */
424
+ public function setOAuthTokens( $token ) {
425
 
426
+ if ( empty( $token[ 'access_token' ] ) )
427
+ throw new BackWPup_Destination_Dropbox_API_Exception( "No oAuth token specified." );
428
 
429
+ $this->oauth_token = $token;
430
+ }
431
+
432
+ public function token_from_oauth1( ) {
433
+
434
+ $url = self::API_URL . self::API_VERSION_URL . 'oauth2/token_from_oauth1';
435
+
436
+ return $this->request( $url, array(), 'POST' );
437
  }
438
 
439
  /**
446
  return $this->request( $url );
447
  }
448
 
449
+ public function disable_access_token() {
450
+
451
+ $url = self::API_URL . self::API_VERSION_URL . 'disable_access_token';
452
+
453
+ return $this->request( $url, array(), 'POST' );
454
+ }
455
+
456
  /**
457
  * @param $file
458
  * @param string $path
602
  ) );
603
  }
604
 
605
+ public function oAuthAuthorize( ) {
 
 
 
 
 
606
 
607
+ return self::API_WWW_URL . self::API_VERSION_URL . 'oauth2/authorize?response_type=code&client_id=' . $this->oauth_app_key;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
608
  }
609
 
 
 
 
 
 
 
 
 
610
 
611
+ public function oAuthToken( $code ) {
612
+
613
+ $url = self::API_URL . self::API_VERSION_URL . 'oauth2/token';
614
+
615
+ return $this->request( $url, array(
616
+ 'code' => trim( $code ),
617
+ 'grant_type' => 'authorization_code',
618
+ 'client_id' => $this->oauth_app_key,
619
+ 'client_secret' => $this->oauth_app_secret
620
+ ), 'POST' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
621
 
 
 
 
 
 
 
 
 
 
 
622
  }
623
 
624
+
625
  /**
626
  * @param $url
627
  * @param array $args
636
  private function request( $url, $args = array(), $method = 'GET', $data = '', $echo = FALSE ) {
637
 
638
  /* Header*/
639
+ // oAuth 2
640
+ if ( ! empty( $this->oauth_token[ 'access_token' ] ) && ! empty( $this->oauth_token[ 'token_type' ] ) && strtolower( $this->oauth_token[ 'token_type' ] ) == 'bearer' )
641
+ $headers[ ] = 'Authorization: Bearer ' . $this->oauth_token[ 'access_token' ] ;
642
+ // oAuth 1
643
+ elseif ( ! empty( $this->oauth_token[ 'access_token' ] ) && ! empty( $this->oauth_token[ 'oauth_token_secret' ] ) )
644
+ $headers[ ] = 'Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="' . $this->oauth_app_key . '", oauth_token="' . $this->oauth_token[ 'access_token' ] . '", oauth_signature="' . $this->oauth_app_secret . '&' . $this->oauth_token[ 'oauth_token_secret' ] . '"';
645
+
646
  $headers[ ] = 'Expect:';
647
 
648
  /* Build cURL Request */
667
  curl_setopt( $ch, CURLOPT_USERAGENT, BackWPup::get_plugin_data( 'User-Agent' ) );
668
  curl_setopt( $ch, CURLOPT_RETURNTRANSFER, TRUE );
669
  if ( BackWPup::get_plugin_data( 'cacert' ) ) {
670
+ curl_setopt( $ch, CURLOPT_SSLVERSION, 1 );
671
  curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, TRUE );
672
+ $curl_version = curl_version();
673
+ if ( strstr( $curl_version[ 'ssl_version' ], 'NSS/' ) === FALSE ) {
674
+ curl_setopt( $ch, CURLOPT_SSL_CIPHER_LIST,
675
+ 'ECDHE-RSA-AES256-GCM-SHA384:'.
676
+ 'ECDHE-RSA-AES128-GCM-SHA256:'.
677
+ 'ECDHE-RSA-AES256-SHA384:'.
678
+ 'ECDHE-RSA-AES128-SHA256:'.
679
+ 'ECDHE-RSA-AES256-SHA:'.
680
+ 'ECDHE-RSA-AES128-SHA:'.
681
+ 'ECDHE-RSA-RC4-SHA:'.
682
+ 'DHE-RSA-AES256-GCM-SHA384:'.
683
+ 'DHE-RSA-AES128-GCM-SHA256:'.
684
+ 'DHE-RSA-AES256-SHA256:'.
685
+ 'DHE-RSA-AES128-SHA256:'.
686
+ 'DHE-RSA-AES256-SHA:'.
687
+ 'DHE-RSA-AES128-SHA:'.
688
+ 'AES256-GCM-SHA384:'.
689
+ 'AES128-GCM-SHA256:'.
690
+ 'AES256-SHA256:'.
691
+ 'AES128-SHA256:'.
692
+ 'AES256-SHA:'.
693
+ 'AES128-SHA'
694
+ );
695
+ }
696
  if ( defined( 'CURLOPT_PROTOCOLS' ) )
697
  curl_setopt( $ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS );
698
  if ( defined( 'CURLOPT_REDIR_PROTOCOLS' ) )
728
  trigger_error( sprintf( '(503) Your app is making too many requests and is being rate limited. Error 503 can be triggered on a per-app or per-user basis. Wait for %d seconds.', $wait ), E_USER_WARNING );
729
  sleep( $wait );
730
  } else {
731
+ throw new BackWPup_Destination_Dropbox_API_Exception( '(503) This indicates a transient server error.' );
732
  }
733
  //redo request
734
  return $this->request( $url, $args, $method, $data, $echo );
748
  elseif ( 0 != curl_errno( $ch ) ) $message = '(' . curl_errno( $ch ) . ') ' . curl_error( $ch );
749
  elseif ( $status[ 'http_code' ] == 304 ) $message = '(304) Folder contents have not changed (relies on hash parameter).';
750
  elseif ( $status[ 'http_code' ] == 400 ) $message = '(400) Bad input parameter: ' . strip_tags( $responce[ 1 ] );
751
+ elseif ( $status[ 'http_code' ] == 401 ) $message = '(401) Bad or expired token. This can happen if the user or Dropbox revoked or expired an access token. To fix, you should re-authenticate the user.';
752
+ elseif ( $status[ 'http_code' ] == 403 ) $message = '(403) Bad OAuth request (wrong consumer key, bad nonce, expired timestamp...). Unfortunately, re-authenticating the user won\'t help here.';
753
+ elseif ( $status[ 'http_code' ] == 404 ) $message = '(404) File or folder not found at the specified path.';
754
+ elseif ( $status[ 'http_code' ] == 405 ) $message = '(405) Request method not expected (generally should be GET or POST).';
755
  elseif ( $status[ 'http_code' ] == 406 ) $message = '(406) There are too many file entries to return.';
756
+ elseif ( $status[ 'http_code' ] == 411 ) $message = '(411) Missing Content-Length header (this endpoint doesn\'t support HTTP chunked transfer encoding).';
757
+ elseif ( $status[ 'http_code' ] == 415 ) $message = '(415) The image is invalid and cannot be converted to a thumbnail.';
758
+ elseif ( $status[ 'http_code' ] == 429 ) $message = '(429) Your app is making too many requests and is being rate limited. 429s can trigger on a per-app or per-user basis.';
759
+ elseif ( $status[ 'http_code' ] == 507 ) $message = '(507) User is over Dropbox storage quota.';
760
  else $message = '(' . $status[ 'http_code' ] . ') Invalid response.';
761
  throw new BackWPup_Destination_Dropbox_API_Exception( $message );
762
  }
788
  */
789
  class BackWPup_Destination_Dropbox_API_Exception extends Exception {
790
 
791
+ }
inc/class-destination-email.php CHANGED
@@ -1,429 +1,436 @@
1
- <?php
2
- // Swift Mailer v5.0.1
3
- // http://swiftmailer.org/
4
- // https://github.com/swiftmailer/swiftmailer
5
-
6
- /**
7
- *
8
- */
9
- class BackWPup_Destination_Email extends BackWPup_Destinations {
10
-
11
- /**
12
- * @return array
13
- */
14
- public function option_defaults() {
15
-
16
- $default=array();
17
- $default[ 'emailaddress' ] = sanitize_email( get_bloginfo( 'admin_email' ) );
18
- $default[ 'emailefilesize' ] = 20;
19
- $default[ 'emailsndemail' ] = sanitize_email( get_bloginfo( 'admin_email' ) );
20
- $default[ 'emailsndemailname' ] = 'BackWPup ' . get_bloginfo( 'name' );
21
- $default[ 'emailmethod' ] = '';
22
- $default[ 'emailsendmail' ] = ini_get( 'sendmail_path' );
23
- $default[ 'emailhost' ] = isset($_SERVER[ 'SERVER_NAME' ]) ? $_SERVER[ 'SERVER_NAME' ] : '';
24
- $default[ 'emailhostport' ] = 25;
25
- $default[ 'emailsecure' ] = '';
26
- $default[ 'emailuser' ] = '';
27
- $default[ 'emailpass' ] = '';
28
-
29
- return $default;
30
- }
31
-
32
-
33
- /**
34
- * @param $jobid
35
- */
36
- public function edit_tab( $jobid ) {
37
- ?>
38
- <h3 class="title"><?php _e( 'Email address', 'backwpup' ); ?></h3>
39
- <table class="form-table">
40
- <tr>
41
- <th scope="row"><label for="emailaddress"><?php _e( 'Email address', 'backwpup' ); ?></label></th>
42
- <td>
43
- <input name="emailaddress" id="emailaddress" type="text" title="<?php esc_attr_e('Email address to which Backups are sent.','backwpup'); ?>"
44
- value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'emailaddress' ) );?>" class="regular-text help-tip" />
45
- </td>
46
- </tr>
47
- <tr>
48
- <th scope="row"><label for="sendemailtest"><?php _e( 'Send test email', 'backwpup' ); ?></label></th>
49
- <td>
50
- <button id="sendemailtest" class="button secondary"><?php _e( 'Send test email', 'backwpup' ); ?></button>
51
- </td>
52
- </tr>
53
- </table>
54
-
55
- <h3 class="title"><?php _e( 'Send email settings', 'backwpup' ); ?></h3>
56
- <table class="form-table">
57
- <tr>
58
- <th scope="row"><label for="idemailefilesize"><?php _e( 'Maximum file size', 'backwpup' ); ?></label></th>
59
- <td><input id="idemailefilesize" name="emailefilesize" type="text" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'emailefilesize' ) ); ?>" class="small-text help-tip" title="<?php esc_attr_e('Maximum file size to be included in an email. 0 = unlimited','backwpup'); ?>" /><?php _e('MB','backwpup'); ?>
60
- </td>
61
- </tr>
62
- <tr>
63
- <th scope="row"><label for="emailsndemail"><?php _e( 'Sender email address', 'backwpup' ); ?></label></th>
64
- <td><input name="emailsndemail" type="text" id="emailsndemail" title="<?php esc_attr_e( 'Sender email address', 'backwpup' ); ?>"
65
- value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'emailsndemail' ) );?>"
66
- class="regular-text help-tip" />
67
- </td>
68
- </tr>
69
- <tr>
70
- <th scope="row"><label for="emailsndemailname"><?php _e( 'Sender name', 'backwpup' ); ?></label></th>
71
- <td><input name="emailsndemailname" type="text" id="emailsndemailname" title="<?php esc_attr_e( 'Name of email sender', 'backwpup' ); ?>"
72
- value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'emailsndemailname' ) );?>"
73
- class="regular-text help-tip" />
74
- </td>
75
- </tr>
76
- <tr>
77
- <th scope="row"><label for="emailmethod"><?php _e( 'Sending method', 'backwpup' ); ?></label></th>
78
- <td>
79
- <select id="emailmethod" name="emailmethod" class="help-tip" title="<?php esc_attr_e('- Use site settings: retrieve the email settings of your site.<br />-PHP mail(): needs more PHP memory','backwpup'); ?>">
80
- <?php
81
- echo '<option value=""' . selected( '', BackWPup_Option::get( $jobid, 'emailmethod' ), FALSE ) . '>' . __( 'Use site settings', 'backwpup' ) . '</option>';
82
- echo '<option value="mail"' . selected( 'mail', BackWPup_Option::get( $jobid, 'emailmethod' ), FALSE ) . '>' . __( 'PHP: mail()', 'backwpup' ) . '</option>';
83
- echo '<option value="sendmail"' . selected( 'sendmail', BackWPup_Option::get( $jobid, 'emailmethod' ), FALSE ) . '>' . __( 'Sendmail', 'backwpup' ) . '</option>';
84
- echo '<option value="smtp"' . selected( 'smtp', BackWPup_Option::get( $jobid, 'emailmethod' ), FALSE ) . '>' . __( 'SMTP', 'backwpup' ) . '</option>';
85
- ?>
86
- </select>
87
-
88
- </td>
89
- </tr>
90
- <tr id="emailsendmail" <?php if ( BackWPup_Option::get( $jobid, 'emailmethod' ) != 'sendmail' ) echo 'style="display:none;"';?>>
91
- <th scope="row"><label for="emailsendmail"><?php _e( 'Sendmail path', 'backwpup' ); ?></label></th>
92
- <td>
93
- <input name="emailsendmail" id="emailsendmail" type="text"
94
- value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'emailsendmail' ) );?>"
95
- class="regular-text code" />
96
- </td>
97
- </tr>
98
- <tr class="emailsmtp" <?php if ( BackWPup_Option::get( $jobid, 'emailmethod' ) != 'smtp' ) echo 'style="display:none;"';?>>
99
- <th scope="row"><label for="emailhost"><?php _e( 'SMTP host name', 'backwpup' ); ?></label></th>
100
- <td>
101
- <input name="emailhost" id="emailhost" type="text"
102
- value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'emailhost' ) );?>"
103
- class="regular-text code"/>&nbsp;
104
- <label for="emailhostport"><?php _e( 'Port:', 'backwpup' ); ?><input name="emailhostport" id="emailhostport" type="text"
105
- value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'emailhostport' ) );?>"
106
- class="small-text code" /></label>
107
- </td>
108
- </tr>
109
- <tr class="emailsmtp" <?php if ( BackWPup_Option::get( $jobid, 'emailmethod' ) != 'smtp' ) echo 'style="display:none;"';?>>
110
- <th scope="row"><label for="emailsecure"><?php _e( 'SMTP secure connection', 'backwpup' ); ?></label>
111
- </th>
112
- <td>
113
- <select id="emailsecure" name="emailsecure">
114
- <option value=""<?php selected( '', BackWPup_Option::get( $jobid, 'emailsecure' ), TRUE ); ?>><?php _e( 'none', 'backwpup' ); ?></option>
115
- <option value="ssl"<?php selected( 'ssl', BackWPup_Option::get( $jobid, 'emailsecure' ), TRUE ); ?>><?php _e( 'SSL', 'backwpup' ); ?></option>
116
- <option value="tls"<?php selected( 'tls', BackWPup_Option::get( $jobid, 'emailsecure' ), TRUE ); ?>><?php _e( 'TLS', 'backwpup' ); ?></option>
117
- </select>
118
- </td>
119
- </tr>
120
- <tr class="emailsmtp" <?php if ( BackWPup_Option::get( $jobid, 'emailmethod' ) != 'smtp' ) echo 'style="display:none;"';?>>
121
- <th scope="row"><label for="emailuser"><?php _e( 'SMTP username', 'backwpup' ); ?></label></th>
122
- <td>
123
- <input name="emailuser" id="emailuser" type="text"
124
- value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'emailuser' ) );?>" class="regular-text" autocomplete="off" />
125
- </td>
126
- </tr>
127
- <tr class="emailsmtp" <?php if ( BackWPup_Option::get( $jobid, 'emailmethod' ) != 'smtp' ) echo 'style="display:none;"';?>>
128
- <th scope="row"><label for="emailpass"><?php _e( 'SMTP password', 'backwpup' ); ?></label></th>
129
- <td>
130
- <input name="emailpass" id="emailpass" type="password"
131
- value="<?php echo esc_attr( BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'emailpass' ) ) );?>"
132
- class="regular-text" autocomplete="off" />
133
- </td>
134
- </tr>
135
- </table>
136
- <?php
137
- }
138
-
139
-
140
- public function edit_inline_js() {
141
- //<script type="text/javascript">
142
- ?>
143
- $('#emailmethod').change(function () {
144
- if ('smtp' == $('#emailmethod').val()) {
145
- $('.emailsmtp').show();
146
- $('#emailsendmail').hide();
147
- } else if ('sendmail' == $('#emailmethod').val()) {
148
- $('.emailsmtp').hide();
149
- $('#emailsendmail').show();
150
- } else {
151
- $('.emailsmtp').hide();
152
- $('#emailsendmail').hide();
153
- }
154
- });
155
- $('#sendemailtest').live('click', function() {
156
- $('#sendemailtest').after('&nbsp;<img id="emailsendtext" src="<?php echo get_admin_url().'images/loading.gif'; ?>" width="16" height="16" />');
157
- var data = {
158
- action: 'backwpup_dest_email',
159
- emailaddress: $('input[name="emailaddress"]').val(),
160
- emailsndemail: $('input[name="emailsndemail"]').val(),
161
- emailmethod: $('#emailmethod').val(),
162
- emailsendmail: $('input[name="emailsendmail"]').val(),
163
- emailsndemailname: $('input[name="emailsndemailname"]').val(),
164
- emailhost: $('input[name="emailhost"]').val(),
165
- emailhostport: $('input[name="emailhostport"]').val(),
166
- emailsecure: $('#emailsecure').val(),
167
- emailuser: $('input[name="emailuser"]').val(),
168
- emailpass: $('input[name="emailpass"]').val(),
169
- _ajax_nonce: $('#backwpupajaxnonce').val()
170
- };
171
- $.post(ajaxurl, data, function(response) {
172
- $('#emailsendtext').replaceWith( response );
173
- });
174
- return false;
175
- });
176
- <?php
177
- }
178
-
179
- /**
180
- * @param $jobid
181
- */
182
- public function edit_form_post_save( $jobid ) {
183
-
184
- BackWPup_Option::update( $jobid, 'emailaddress', isset( $_POST[ 'emailaddress' ] ) ? sanitize_email( $_POST[ 'emailaddress' ] ) : '' );
185
- BackWPup_Option::update( $jobid, 'emailefilesize', isset( $_POST[ 'emailefilesize' ] ) ? (int)$_POST[ 'emailefilesize' ] : 0 );
186
- BackWPup_Option::update( $jobid, 'emailsndemail', sanitize_email( $_POST[ 'emailsndemail' ] ) );
187
- BackWPup_Option::update( $jobid, 'emailmethod', ( $_POST[ 'emailmethod' ] == '' || $_POST[ 'emailmethod' ] == 'mail' || $_POST[ 'emailmethod' ] == 'sendmail' || $_POST[ 'emailmethod' ] == 'smtp' ) ? $_POST[ 'emailmethod' ] : '' );
188
- BackWPup_Option::update( $jobid, 'emailsendmail', $_POST[ 'emailsendmail' ] );
189
- BackWPup_Option::update( $jobid, 'emailsndemailname', $_POST[ 'emailsndemailname' ] );
190
- BackWPup_Option::update( $jobid, 'emailhost', $_POST[ 'emailhost' ] );
191
- BackWPup_Option::update( $jobid, 'emailhostport', (int)$_POST[ 'emailhostport' ] );
192
- BackWPup_Option::update( $jobid, 'emailsecure', ( $_POST[ 'emailsecure' ] == 'ssl' || $_POST[ 'emailsecure' ] == 'tls' ) ? $_POST[ 'emailsecure' ] : '' );
193
- BackWPup_Option::update( $jobid, 'emailuser', $_POST[ 'emailuser' ] );
194
- BackWPup_Option::update( $jobid, 'emailpass', BackWPup_Encryption::encrypt( $_POST[ 'emailpass' ] ) );
195
- }
196
-
197
- /**
198
- * @param $job_object
199
- * @return bool
200
- */
201
- public function job_run_archive( &$job_object ) {
202
-
203
- $job_object->substeps_todo = 1;
204
- $job_object->log( sprintf( __( '%d. Try to send backup with email&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ), E_USER_NOTICE );
205
-
206
- //check file Size
207
- if ( !empty( $job_object->job[ 'emailefilesize' ] ) ) {
208
- if ( $job_object->backup_filesize > $job_object->job[ 'emailefilesize' ] * 1024 * 1024 ) {
209
- $job_object->log( __( 'Backup archive too big to be sent by email!', 'backwpup' ), E_USER_ERROR );
210
- $job_object->substeps_done = 1;
211
-
212
- return TRUE;
213
- }
214
- }
215
-
216
- $job_object->log( sprintf( __( 'Sending email to %s&hellip;', 'backwpup' ), $job_object->job[ 'emailaddress' ] ), E_USER_NOTICE );
217
-
218
- //get mail settings
219
- $emailmethod='mail';
220
- $emailsendmail='';
221
- $emailhost='';
222
- $emailhostport='';
223
- $emailsecure='';
224
- $emailuser='';
225
- $emailpass='';
226
-
227
- if ( empty( $job_object->job[ 'emailmethod' ] ) ) {
228
- //do so if i'm the wp_mail to get the settings
229
- global $phpmailer;
230
- // (Re)create it, if it's gone missing
231
- if ( !is_object( $phpmailer ) || ! $phpmailer instanceof PHPMailer ) {
232
- require_once ABSPATH . WPINC . '/class-phpmailer.php';
233
- require_once ABSPATH . WPINC . '/class-smtp.php';
234
- $phpmailer = new PHPMailer( true );
235
- }
236
- //only if PHPMailer really used
237
- if ( is_object( $phpmailer ) ) {
238
- do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
239
- //get settings from PHPMailer
240
- $emailmethod=$phpmailer->Mailer;
241
- $emailsendmail=$phpmailer->Sendmail;
242
- $emailhost=$phpmailer->Host;
243
- $emailhostport=$phpmailer->Port;
244
- $emailsecure=$phpmailer->SMTPSecure;
245
- $emailuser=$phpmailer->Username;
246
- $emailpass=$phpmailer->Password;
247
- }
248
- } else {
249
- $emailmethod = $job_object->job[ 'emailmethod' ];
250
- $emailsendmail = $job_object->job[ 'emailsendmail' ];
251
- $emailhost = $job_object->job[ 'emailhost' ];
252
- $emailhostport = $job_object->job[ 'emailhostport' ];
253
- $emailsecure = $job_object->job[ 'emailsecure' ];
254
- $emailuser = $job_object->job[ 'emailuser' ];
255
- $emailpass = BackWPup_Encryption::decrypt( $job_object->job[ 'emailpass' ] );
256
- }
257
-
258
- //Generate mail with Swift Mailer
259
- if ( function_exists( 'mb_internal_encoding' ) && ( (int)ini_get( 'mbstring.func_overload' ) ) & 2 ) {
260
- $mbEncoding = mb_internal_encoding();
261
- mb_internal_encoding( 'ASCII' );
262
- }
263
-
264
- try {
265
- //Set Temp dir for mailing
266
- Swift_Preferences::getInstance()->setTempDir( untrailingslashit( BackWPup::get_plugin_data( 'TEMP' ) ) )->setCacheType( 'disk' );
267
- // Create the Transport
268
- if ( $emailmethod == 'smtp' ) {
269
- $transport = Swift_SmtpTransport::newInstance( $emailhost, $emailhostport );
270
- $transport->setUsername( $emailuser );
271
- $transport->setPassword( $emailpass );
272
- if ( $emailsecure == 'ssl' )
273
- $transport->setEncryption( 'ssl' );
274
- if ( $emailsecure == 'tls' )
275
- $transport->setEncryption( 'tls' );
276
- }
277
- elseif ( $emailmethod == 'sendmail' ) {
278
- $transport = Swift_SendmailTransport::newInstance( $emailsendmail );
279
- }
280
- else {
281
- $job_object->need_free_memory( $job_object->backup_filesize * 8 );
282
- $transport = Swift_MailTransport::newInstance();
283
- }
284
- // Create the Mailer using your created Transport
285
- $emailer = Swift_Mailer::newInstance( $transport );
286
-
287
- // Create a message
288
- $message = Swift_Message::newInstance( sprintf( __( 'BackWPup archive from %1$s: %2$s', 'backwpup' ), date_i18n( 'd-M-Y H:i', $job_object->start_time, TRUE ), esc_attr($job_object->job[ 'name' ] ) ) );
289
- $message->setFrom( array( $job_object->job[ 'emailsndemail' ] => $job_object->job[ 'emailsndemailname' ] ) );
290
- $message->setTo( array( $job_object->job[ 'emailaddress' ] ) );
291
- $message->setBody( sprintf( __( 'Backup archive: %s', 'backwpup' ), $job_object->backup_file ), 'text/plain', strtolower( get_bloginfo( 'charset' ) ) );
292
- $message->attach( Swift_Attachment::fromPath( $job_object->backup_folder . $job_object->backup_file, $job_object->get_mime_type( $job_object->backup_folder . $job_object->backup_file ) ) );
293
- // Send the message
294
- $result = $emailer->send( $message );
295
- }
296
- catch ( Exception $e ) {
297
- $job_object->log( 'Swift Mailer: ' . $e->getMessage(), E_USER_ERROR );
298
- }
299
-
300
- if ( isset( $mbEncoding ) ) {
301
- mb_internal_encoding( $mbEncoding );
302
- }
303
-
304
- if ( isset( $result ) && ! $result ) {
305
- $job_object->log( __( 'Error while sending email!', 'backwpup' ), E_USER_ERROR );
306
-
307
- return FALSE;
308
- }
309
- else {
310
- $job_object->substeps_done = 1;
311
- $job_object->log( __( 'Email sent.', 'backwpup' ), E_USER_NOTICE );
312
-
313
- return TRUE;
314
- }
315
- }
316
-
317
- /**
318
- * @param $job_object
319
- * @return bool
320
- */
321
- public function can_run( $job_object ) {
322
-
323
- if ( empty( $job_object->job[ 'emailaddress' ] ) )
324
- return FALSE;
325
-
326
- if ( $job_object->job[ 'backuptype' ] != 'archive' )
327
- return FALSE;
328
-
329
- return TRUE;
330
- }
331
-
332
-
333
- /**
334
- * sends test mail
335
- */
336
- public function edit_ajax() {
337
-
338
- check_ajax_referer( 'backwpup_ajax_nonce' );
339
-
340
- //get mail settings
341
- $emailmethod='mail';
342
- $emailsendmail='';
343
- $emailhost='';
344
- $emailhostport='';
345
- $emailsecure='';
346
- $emailuser='';
347
- $emailpass='';
348
-
349
- if ( empty( $_POST[ 'emailmethod' ] ) ) {
350
- //do so if i'm the wp_mail to get the settings
351
- global $phpmailer;
352
- // (Re)create it, if it's gone missing
353
- if ( ! is_object( $phpmailer ) || ! $phpmailer instanceof PHPMailer ) {
354
- require_once ABSPATH . WPINC . '/class-phpmailer.php';
355
- require_once ABSPATH . WPINC . '/class-smtp.php';
356
- $phpmailer = new PHPMailer( true );
357
- }
358
- //only if PHPMailer really used
359
- if ( is_object( $phpmailer ) ) {
360
- do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
361
- //get settings from PHPMailer
362
- $emailmethod=$phpmailer->Mailer;
363
- $emailsendmail=$phpmailer->Sendmail;
364
- $emailhost=$phpmailer->Host;
365
- $emailhostport=$phpmailer->Port;
366
- $emailsecure=$phpmailer->SMTPSecure;
367
- $emailuser=$phpmailer->Username;
368
- $emailpass=$phpmailer->Password;
369
- }
370
- } else {
371
- $emailmethod = $_POST[ 'emailmethod' ];
372
- $emailsendmail = $_POST[ 'emailsendmail' ];
373
- $emailhost = $_POST[ 'emailhost' ];
374
- $emailhostport = $_POST[ 'emailhostport' ];
375
- $emailsecure = $_POST[ 'emailsecure' ];
376
- $emailuser = $_POST[ 'emailuser' ];
377
- $emailpass = BackWPup_Encryption::decrypt( $_POST[ 'emailpass' ] );
378
- }
379
-
380
- //Generate mail with Swift Mailer
381
-
382
- if ( function_exists( 'mb_internal_encoding' ) && ( (int)ini_get( 'mbstring.func_overload' ) ) & 2 ) {
383
- $mbEncoding = mb_internal_encoding();
384
- mb_internal_encoding( 'ASCII' );
385
- }
386
-
387
- try {
388
- // Create the Transport
389
- if ( $emailmethod == 'smtp' ) {
390
- $transport = Swift_SmtpTransport::newInstance( $emailhost, $emailhostport );
391
- $transport->setUsername( $emailuser );
392
- $transport->setPassword( $emailpass );
393
- if ( $emailsecure == 'ssl' )
394
- $transport->setEncryption( 'ssl' );
395
- if ( $emailsecure == 'tls' )
396
- $transport->setEncryption( 'tls' );
397
- }
398
- elseif ( $emailmethod == 'sendmail' ) {
399
- $transport = Swift_SendmailTransport::newInstance( $emailsendmail );
400
- }
401
- else {
402
- $transport = Swift_MailTransport::newInstance();
403
- }
404
- // Create the Mailer using your created Transport
405
- $emailer = Swift_Mailer::newInstance( $transport );
406
-
407
- // Create a message
408
- $message = Swift_Message::newInstance( __( 'BackWPup archive sending TEST Message', 'backwpup' ) );
409
- $message->setFrom( array( $_POST[ 'emailsndemail' ] => isset( $_POST[ 'emailsndemailname' ]) ? $_POST[ 'emailsndemailname' ] : '' ) );
410
- $message->setTo( array( $_POST[ 'emailaddress' ] ) );
411
- $message->setBody( __( 'If this message reaches your inbox, sending backup archives via email should work for you.', 'backwpup' ) );
412
- // Send the message
413
- $result = $emailer->send( $message );
414
- }
415
- catch ( Exception $e ) {
416
- echo '<span id="emailsendtext" style="color:red;">Swift Mailer: ' . $e->getMessage() . '</span>';
417
- }
418
-
419
- if ( isset( $mbEncoding ) ) {
420
- mb_internal_encoding( $mbEncoding );
421
- }
422
-
423
- if ( ! isset( $result ) || ! $result )
424
- echo '<span id="emailsendtext" style="color:red;">' . __( 'Error while sending email!', 'backwpup' ) . '</span>';
425
- else
426
- echo '<span id="emailsendtext" style="color:green;">' . __( 'Email sent.', 'backwpup' ) . '</span>';
427
- die();
428
- }
429
- }
 
 
 
 
 
 
 
1
+ <?php
2
+ // Swift Mailer v5.2.0
3
+ // http://swiftmailer.org/
4
+ // https://github.com/swiftmailer/swiftmailer
5
+
6
+ /**
7
+ *
8
+ */
9
+ class BackWPup_Destination_Email extends BackWPup_Destinations {
10
+
11
+ /**
12
+ * @return array
13
+ */
14
+ public function option_defaults() {
15
+
16
+ $default=array();
17
+ $default[ 'emailaddress' ] = sanitize_email( get_bloginfo( 'admin_email' ) );
18
+ $default[ 'emailefilesize' ] = 20;
19
+ $default[ 'emailsndemail' ] = sanitize_email( get_bloginfo( 'admin_email' ) );
20
+ $default[ 'emailsndemailname' ] = 'BackWPup ' . get_bloginfo( 'name' );
21
+ $default[ 'emailmethod' ] = '';
22
+ $default[ 'emailsendmail' ] = ini_get( 'sendmail_path' );
23
+ $default[ 'emailhost' ] = isset($_SERVER[ 'SERVER_NAME' ]) ? $_SERVER[ 'SERVER_NAME' ] : '';
24
+ $default[ 'emailhostport' ] = 25;
25
+ $default[ 'emailsecure' ] = '';
26
+ $default[ 'emailuser' ] = '';
27
+ $default[ 'emailpass' ] = '';
28
+
29
+ return $default;
30
+ }
31
+
32
+
33
+ /**
34
+ * @param $jobid
35
+ */
36
+ public function edit_tab( $jobid ) {
37
+ ?>
38
+ <h3 class="title"><?php _e( 'Email address', 'backwpup' ); ?></h3>
39
+ <table class="form-table">
40
+ <tr>
41
+ <th scope="row"><label for="emailaddress"><?php _e( 'Email address', 'backwpup' ); ?></label></th>
42
+ <td>
43
+ <input name="emailaddress" id="emailaddress" type="text" title="<?php esc_attr_e('Email address to which Backups are sent.','backwpup'); ?>"
44
+ value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'emailaddress' ) );?>" class="regular-text help-tip" />
45
+ </td>
46
+ </tr>
47
+ <tr>
48
+ <th scope="row"><label for="sendemailtest"><?php _e( 'Send test email', 'backwpup' ); ?></label></th>
49
+ <td>
50
+ <button id="sendemailtest" class="button secondary"><?php _e( 'Send test email', 'backwpup' ); ?></button>
51
+ </td>
52
+ </tr>
53
+ </table>
54
+
55
+ <h3 class="title"><?php _e( 'Send email settings', 'backwpup' ); ?></h3>
56
+ <table class="form-table">
57
+ <tr>
58
+ <th scope="row"><label for="idemailefilesize"><?php _e( 'Maximum file size', 'backwpup' ); ?></label></th>
59
+ <td><input id="idemailefilesize" name="emailefilesize" type="text" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'emailefilesize' ) ); ?>" class="small-text help-tip" title="<?php esc_attr_e('Maximum file size to be included in an email. 0 = unlimited','backwpup'); ?>" /><?php _e('MB','backwpup'); ?>
60
+ </td>
61
+ </tr>
62
+ <tr>
63
+ <th scope="row"><label for="emailsndemail"><?php _e( 'Sender email address', 'backwpup' ); ?></label></th>
64
+ <td><input name="emailsndemail" type="text" id="emailsndemail" title="<?php esc_attr_e( 'Sender email address', 'backwpup' ); ?>"
65
+ value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'emailsndemail' ) );?>"
66
+ class="regular-text help-tip" />
67
+ </td>
68
+ </tr>
69
+ <tr>
70
+ <th scope="row"><label for="emailsndemailname"><?php _e( 'Sender name', 'backwpup' ); ?></label></th>
71
+ <td><input name="emailsndemailname" type="text" id="emailsndemailname" title="<?php esc_attr_e( 'Name of email sender', 'backwpup' ); ?>"
72
+ value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'emailsndemailname' ) );?>"
73
+ class="regular-text help-tip" />
74
+ </td>
75
+ </tr>
76
+ <tr>
77
+ <th scope="row"><label for="emailmethod"><?php _e( 'Sending method', 'backwpup' ); ?></label></th>
78
+ <td>
79
+ <select id="emailmethod" name="emailmethod" class="help-tip" title="<?php esc_attr_e('- Use site settings: retrieve the email settings of your site.<br />-PHP mail(): needs more PHP memory','backwpup'); ?>">
80
+ <?php
81
+ echo '<option value=""' . selected( '', BackWPup_Option::get( $jobid, 'emailmethod' ), FALSE ) . '>' . __( 'Use site settings', 'backwpup' ) . '</option>';
82
+ echo '<option value="mail"' . selected( 'mail', BackWPup_Option::get( $jobid, 'emailmethod' ), FALSE ) . '>' . __( 'PHP: mail()', 'backwpup' ) . '</option>';
83
+ echo '<option value="sendmail"' . selected( 'sendmail', BackWPup_Option::get( $jobid, 'emailmethod' ), FALSE ) . '>' . __( 'Sendmail', 'backwpup' ) . '</option>';
84
+ echo '<option value="smtp"' . selected( 'smtp', BackWPup_Option::get( $jobid, 'emailmethod' ), FALSE ) . '>' . __( 'SMTP', 'backwpup' ) . '</option>';
85
+ ?>
86
+ </select>
87
+
88
+ </td>
89
+ </tr>
90
+ <tr id="emailsendmail" <?php if ( BackWPup_Option::get( $jobid, 'emailmethod' ) != 'sendmail' ) echo 'style="display:none;"';?>>
91
+ <th scope="row"><label for="emailsendmail"><?php _e( 'Sendmail path', 'backwpup' ); ?></label></th>
92
+ <td>
93
+ <input name="emailsendmail" id="emailsendmail" type="text"
94
+ value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'emailsendmail' ) );?>"
95
+ class="regular-text code" />
96
+ </td>
97
+ </tr>
98
+ <tr class="emailsmtp" <?php if ( BackWPup_Option::get( $jobid, 'emailmethod' ) != 'smtp' ) echo 'style="display:none;"';?>>
99
+ <th scope="row"><label for="emailhost"><?php _e( 'SMTP host name', 'backwpup' ); ?></label></th>
100
+ <td>
101
+ <input name="emailhost" id="emailhost" type="text"
102
+ value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'emailhost' ) );?>"
103
+ class="regular-text code"/>&nbsp;
104
+ <label for="emailhostport"><?php _e( 'Port:', 'backwpup' ); ?><input name="emailhostport" id="emailhostport" type="text"
105
+ value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'emailhostport' ) );?>"
106
+ class="small-text code" /></label>
107
+ </td>
108
+ </tr>
109
+ <tr class="emailsmtp" <?php if ( BackWPup_Option::get( $jobid, 'emailmethod' ) != 'smtp' ) echo 'style="display:none;"';?>>
110
+ <th scope="row"><label for="emailsecure"><?php _e( 'SMTP secure connection', 'backwpup' ); ?></label>
111
+ </th>
112
+ <td>
113
+ <select id="emailsecure" name="emailsecure">
114
+ <option value=""<?php selected( '', BackWPup_Option::get( $jobid, 'emailsecure' ), TRUE ); ?>><?php _e( 'none', 'backwpup' ); ?></option>
115
+ <option value="ssl"<?php selected( 'ssl', BackWPup_Option::get( $jobid, 'emailsecure' ), TRUE ); ?>><?php _e( 'SSL', 'backwpup' ); ?></option>
116
+ <option value="tls"<?php selected( 'tls', BackWPup_Option::get( $jobid, 'emailsecure' ), TRUE ); ?>><?php _e( 'TLS', 'backwpup' ); ?></option>
117
+ </select>
118
+ </td>
119
+ </tr>
120
+ <tr class="emailsmtp" <?php if ( BackWPup_Option::get( $jobid, 'emailmethod' ) != 'smtp' ) echo 'style="display:none;"';?>>
121
+ <th scope="row"><label for="emailuser"><?php _e( 'SMTP username', 'backwpup' ); ?></label></th>
122
+ <td>
123
+ <input name="emailuser" id="emailuser" type="text"
124
+ value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'emailuser' ) );?>" class="regular-text" autocomplete="off" />
125
+ </td>
126
+ </tr>
127
+ <tr class="emailsmtp" <?php if ( BackWPup_Option::get( $jobid, 'emailmethod' ) != 'smtp' ) echo 'style="display:none;"';?>>
128
+ <th scope="row"><label for="emailpass"><?php _e( 'SMTP password', 'backwpup' ); ?></label></th>
129
+ <td>
130
+ <input name="emailpass" id="emailpass" type="password"
131
+ value="<?php echo esc_attr( BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'emailpass' ) ) );?>"
132
+ class="regular-text" autocomplete="off" />
133
+ </td>
134
+ </tr>
135
+ </table>
136
+ <?php
137
+ }
138
+
139
+
140
+ public function edit_inline_js() {
141
+ //<script type="text/javascript">
142
+ ?>
143
+ $('#emailmethod').change(function () {
144
+ if ('smtp' == $('#emailmethod').val()) {
145
+ $('.emailsmtp').show();
146
+ $('#emailsendmail').hide();
147
+ } else if ('sendmail' == $('#emailmethod').val()) {
148
+ $('.emailsmtp').hide();
149
+ $('#emailsendmail').show();
150
+ } else {
151
+ $('.emailsmtp').hide();
152
+ $('#emailsendmail').hide();
153
+ }
154
+ });
155
+ $('#sendemailtest').live('click', function() {
156
+ $('#sendemailtest').after('&nbsp;<img id="emailsendtext" src="<?php echo get_admin_url().'images/loading.gif'; ?>" width="16" height="16" />');
157
+ var data = {
158
+ action: 'backwpup_dest_email',
159
+ emailaddress: $('input[name="emailaddress"]').val(),
160
+ emailsndemail: $('input[name="emailsndemail"]').val(),
161
+ emailmethod: $('#emailmethod').val(),
162
+ emailsendmail: $('input[name="emailsendmail"]').val(),
163
+ emailsndemailname: $('input[name="emailsndemailname"]').val(),
164
+ emailhost: $('input[name="emailhost"]').val(),
165
+ emailhostport: $('input[name="emailhostport"]').val(),
166
+ emailsecure: $('#emailsecure').val(),
167
+ emailuser: $('input[name="emailuser"]').val(),
168
+ emailpass: $('input[name="emailpass"]').val(),
169
+ _ajax_nonce: $('#backwpupajaxnonce').val()
170
+ };
171
+ $.post(ajaxurl, data, function(response) {
172
+ $('#emailsendtext').replaceWith( response );
173
+ });
174
+ return false;
175
+ });
176
+ <?php
177
+ }
178
+
179
+ /**
180
+ * @param $jobid
181
+ */
182
+ public function edit_form_post_save( $jobid ) {
183
+
184
+ BackWPup_Option::update( $jobid, 'emailaddress', isset( $_POST[ 'emailaddress' ] ) ? sanitize_email( $_POST[ 'emailaddress' ] ) : '' );
185
+ BackWPup_Option::update( $jobid, 'emailefilesize', isset( $_POST[ 'emailefilesize' ] ) ? (int)$_POST[ 'emailefilesize' ] : 0 );
186
+ BackWPup_Option::update( $jobid, 'emailsndemail', sanitize_email( $_POST[ 'emailsndemail' ] ) );
187
+ BackWPup_Option::update( $jobid, 'emailmethod', ( $_POST[ 'emailmethod' ] == '' || $_POST[ 'emailmethod' ] == 'mail' || $_POST[ 'emailmethod' ] == 'sendmail' || $_POST[ 'emailmethod' ] == 'smtp' ) ? $_POST[ 'emailmethod' ] : '' );
188
+ BackWPup_Option::update( $jobid, 'emailsendmail', $_POST[ 'emailsendmail' ] );
189
+ BackWPup_Option::update( $jobid, 'emailsndemailname', $_POST[ 'emailsndemailname' ] );
190
+ BackWPup_Option::update( $jobid, 'emailhost', $_POST[ 'emailhost' ] );
191
+ BackWPup_Option::update( $jobid, 'emailhostport', (int)$_POST[ 'emailhostport' ] );
192
+ BackWPup_Option::update( $jobid, 'emailsecure', ( $_POST[ 'emailsecure' ] == 'ssl' || $_POST[ 'emailsecure' ] == 'tls' ) ? $_POST[ 'emailsecure' ] : '' );
193
+ BackWPup_Option::update( $jobid, 'emailuser', $_POST[ 'emailuser' ] );
194
+ BackWPup_Option::update( $jobid, 'emailpass', BackWPup_Encryption::encrypt( $_POST[ 'emailpass' ] ) );
195
+ }
196
+
197
+ /**
198
+ * @param $job_object
199
+ * @return bool
200
+ */
201
+ public function job_run_archive( &$job_object ) {
202
+
203
+ $job_object->substeps_todo = 1;
204
+ $job_object->log( sprintf( __( '%d. Try to send backup with email&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ), E_USER_NOTICE );
205
+
206
+ //check file Size
207
+ if ( !empty( $job_object->job[ 'emailefilesize' ] ) ) {
208
+ if ( $job_object->backup_filesize > $job_object->job[ 'emailefilesize' ] * 1024 * 1024 ) {
209
+ $job_object->log( __( 'Backup archive too big to be sent by email!', 'backwpup' ), E_USER_ERROR );
210
+ $job_object->substeps_done = 1;
211
+
212
+ return TRUE;
213
+ }
214
+ }
215
+
216
+ $job_object->log( sprintf( __( 'Sending email to %s&hellip;', 'backwpup' ), $job_object->job[ 'emailaddress' ] ), E_USER_NOTICE );
217
+
218
+ //get mail settings
219
+ $emailmethod='mail';
220
+ $emailsendmail='';
221
+ $emailhost='';
222
+ $emailhostport='';
223
+ $emailsecure='';
224
+ $emailuser='';
225
+ $emailpass='';
226
+
227
+ if ( empty( $job_object->job[ 'emailmethod' ] ) ) {
228
+ //do so if i'm the wp_mail to get the settings
229
+ global $phpmailer;
230
+ // (Re)create it, if it's gone missing
231
+ if ( !is_object( $phpmailer ) || ! $phpmailer instanceof PHPMailer ) {
232
+ require_once ABSPATH . WPINC . '/class-phpmailer.php';
233
+ require_once ABSPATH . WPINC . '/class-smtp.php';
234
+ $phpmailer = new PHPMailer( true );
235
+ }
236
+ //only if PHPMailer really used
237
+ if ( is_object( $phpmailer ) ) {
238
+ do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
239
+ //get settings from PHPMailer
240
+ $emailmethod=$phpmailer->Mailer;
241
+ $emailsendmail=$phpmailer->Sendmail;
242
+ $emailhost=$phpmailer->Host;
243
+ $emailhostport=$phpmailer->Port;
244
+ $emailsecure=$phpmailer->SMTPSecure;
245
+ $emailuser=$phpmailer->Username;
246
+ $emailpass=$phpmailer->Password;
247
+ }
248
+ } else {
249
+ $emailmethod = $job_object->job[ 'emailmethod' ];
250
+ $emailsendmail = $job_object->job[ 'emailsendmail' ];
251
+ $emailhost = $job_object->job[ 'emailhost' ];
252
+ $emailhostport = $job_object->job[ 'emailhostport' ];
253
+ $emailsecure = $job_object->job[ 'emailsecure' ];
254
+ $emailuser = $job_object->job[ 'emailuser' ];
255
+ $emailpass = BackWPup_Encryption::decrypt( $job_object->job[ 'emailpass' ] );
256
+ }
257
+
258
+ //Generate mail with Swift Mailer
259
+ if ( ! class_exists( 'Swift', FALSE ) ) {
260
+ require BackWPup::get_plugin_data( 'plugindir' ) . '/vendor/SwiftMailer/swift_required.php';
261
+ }
262
+
263
+ if ( function_exists( 'mb_internal_encoding' ) && ( (int)ini_get( 'mbstring.func_overload' ) ) & 2 ) {
264
+ $mbEncoding = mb_internal_encoding();
265
+ mb_internal_encoding( 'ASCII' );
266
+ }
267
+
268
+ try {
269
+ //Set Temp dir for mailing
270
+ Swift_Preferences::getInstance()->setTempDir( untrailingslashit( BackWPup::get_plugin_data( 'TEMP' ) ) )->setCacheType( 'disk' );
271
+ // Create the Transport
272
+ if ( $emailmethod == 'smtp' ) {
273
+ $transport = Swift_SmtpTransport::newInstance( $emailhost, $emailhostport );
274
+ $transport->setUsername( $emailuser );
275
+ $transport->setPassword( $emailpass );
276
+ if ( $emailsecure == 'ssl' )
277
+ $transport->setEncryption( 'ssl' );
278
+ if ( $emailsecure == 'tls' )
279
+ $transport->setEncryption( 'tls' );
280
+ }
281
+ elseif ( $emailmethod == 'sendmail' ) {
282
+ $transport = Swift_SendmailTransport::newInstance( $emailsendmail );
283
+ }
284
+ else {
285
+ $job_object->need_free_memory( $job_object->backup_filesize * 8 );
286
+ $transport = Swift_MailTransport::newInstance();
287
+ }
288
+ // Create the Mailer using your created Transport
289
+ $emailer = Swift_Mailer::newInstance( $transport );
290
+
291
+ // Create a message
292
+ $message = Swift_Message::newInstance( sprintf( __( 'BackWPup archive from %1$s: %2$s', 'backwpup' ), date_i18n( 'd-M-Y H:i', $job_object->start_time, TRUE ), esc_attr($job_object->job[ 'name' ] ) ) );
293
+ $message->setFrom( array( $job_object->job[ 'emailsndemail' ] => $job_object->job[ 'emailsndemailname' ] ) );
294
+ $message->setTo( array( $job_object->job[ 'emailaddress' ] ) );
295
+ $message->setBody( sprintf( __( 'Backup archive: %s', 'backwpup' ), $job_object->backup_file ), 'text/plain', strtolower( get_bloginfo( 'charset' ) ) );
296
+ $message->attach( Swift_Attachment::fromPath( $job_object->backup_folder . $job_object->backup_file, $job_object->get_mime_type( $job_object->backup_folder . $job_object->backup_file ) ) );
297
+ // Send the message
298
+ $result = $emailer->send( $message );
299
+ }
300
+ catch ( Exception $e ) {
301
+ $job_object->log( 'Swift Mailer: ' . $e->getMessage(), E_USER_ERROR );
302
+ }
303
+
304
+ if ( isset( $mbEncoding ) ) {
305
+ mb_internal_encoding( $mbEncoding );
306
+ }
307
+
308
+ if ( isset( $result ) && ! $result ) {
309
+ $job_object->log( __( 'Error while sending email!', 'backwpup' ), E_USER_ERROR );
310
+
311
+ return FALSE;
312
+ }
313
+ else {
314
+ $job_object->substeps_done = 1;
315
+ $job_object->log( __( 'Email sent.', 'backwpup' ), E_USER_NOTICE );
316
+
317
+ return TRUE;
318
+ }
319
+ }
320
+
321
+ /**
322
+ * @param $job_object
323
+ * @return bool
324
+ */
325
+ public function can_run( $job_object ) {
326
+
327
+ if ( empty( $job_object->job[ 'emailaddress' ] ) )
328
+ return FALSE;
329
+
330
+ if ( $job_object->job[ 'backuptype' ] != 'archive' )
331
+ return FALSE;
332
+
333
+ return TRUE;
334
+ }
335
+
336
+
337
+ /**
338
+ * sends test mail
339
+ */
340
+ public function edit_ajax() {
341
+
342
+ check_ajax_referer( 'backwpup_ajax_nonce' );
343
+
344
+ //get mail settings
345
+ $emailmethod='mail';
346
+ $emailsendmail='';
347
+ $emailhost='';
348
+ $emailhostport='';
349
+ $emailsecure='';
350
+ $emailuser='';
351
+ $emailpass='';
352
+
353
+ if ( empty( $_POST[ 'emailmethod' ] ) ) {
354
+ //do so if i'm the wp_mail to get the settings
355
+ global $phpmailer;
356
+ // (Re)create it, if it's gone missing
357
+ if ( ! is_object( $phpmailer ) || ! $phpmailer instanceof PHPMailer ) {
358
+ require_once ABSPATH . WPINC . '/class-phpmailer.php';
359
+ require_once ABSPATH . WPINC . '/class-smtp.php';
360
+ $phpmailer = new PHPMailer( true );
361
+ }
362
+ //only if PHPMailer really used
363
+ if ( is_object( $phpmailer ) ) {
364
+ do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
365
+ //get settings from PHPMailer
366
+ $emailmethod=$phpmailer->Mailer;
367
+ $emailsendmail=$phpmailer->Sendmail;
368
+ $emailhost=$phpmailer->Host;
369
+ $emailhostport=$phpmailer->Port;
370
+ $emailsecure=$phpmailer->SMTPSecure;
371
+ $emailuser=$phpmailer->Username;
372
+ $emailpass=$phpmailer->Password;
373
+ }
374
+ } else {
375
+ $emailmethod = $_POST[ 'emailmethod' ];
376
+ $emailsendmail = $_POST[ 'emailsendmail' ];
377
+ $emailhost = $_POST[ 'emailhost' ];
378
+ $emailhostport = $_POST[ 'emailhostport' ];
379
+ $emailsecure = $_POST[ 'emailsecure' ];
380
+ $emailuser = $_POST[ 'emailuser' ];
381
+ $emailpass = BackWPup_Encryption::decrypt( $_POST[ 'emailpass' ] );
382
+ }
383
+
384
+ //Generate mail with Swift Mailer
385
+ if ( ! class_exists( 'Swift', FALSE ) ) {
386
+ require BackWPup::get_plugin_data( 'plugindir' ) . '/vendor/SwiftMailer/swift_required.php';
387
+ }
388
+
389
+ if ( function_exists( 'mb_internal_encoding' ) && ( (int)ini_get( 'mbstring.func_overload' ) ) & 2 ) {
390
+ $mbEncoding = mb_internal_encoding();
391
+ mb_internal_encoding( 'ASCII' );
392
+ }
393
+
394
+ try {
395
+ // Create the Transport
396
+ if ( $emailmethod == 'smtp' ) {
397
+ $transport = Swift_SmtpTransport::newInstance( $emailhost, $emailhostport );
398
+ $transport->setUsername( $emailuser );
399
+ $transport->setPassword( $emailpass );
400
+ if ( $emailsecure == 'ssl' )
401
+ $transport->setEncryption( 'ssl' );
402
+ if ( $emailsecure == 'tls' )
403
+ $transport->setEncryption( 'tls' );
404
+ }
405
+ elseif ( $emailmethod == 'sendmail' ) {
406
+ $transport = Swift_SendmailTransport::newInstance( $emailsendmail );
407
+ }
408
+ else {
409
+ $transport = Swift_MailTransport::newInstance();
410
+ }
411
+ // Create the Mailer using your created Transport
412
+ $emailer = Swift_Mailer::newInstance( $transport );
413
+
414
+ // Create a message
415
+ $message = Swift_Message::newInstance( __( 'BackWPup archive sending TEST Message', 'backwpup' ) );
416
+ $message->setFrom( array( $_POST[ 'emailsndemail' ] => isset( $_POST[ 'emailsndemailname' ]) ? $_POST[ 'emailsndemailname' ] : '' ) );
417
+ $message->setTo( array( $_POST[ 'emailaddress' ] ) );
418
+ $message->setBody( __( 'If this message reaches your inbox, sending backup archives via email should work for you.', 'backwpup' ) );
419
+ // Send the message
420
+ $result = $emailer->send( $message );
421
+ }
422
+ catch ( Exception $e ) {
423
+ echo '<span id="emailsendtext" style="color:red;">Swift Mailer: ' . $e->getMessage() . '</span>';
424
+ }
425
+
426
+ if ( isset( $mbEncoding ) ) {
427
+ mb_internal_encoding( $mbEncoding );
428
+ }
429
+
430
+ if ( ! isset( $result ) || ! $result )
431
+ echo '<span id="emailsendtext" style="color:red;">' . __( 'Error while sending email!', 'backwpup' ) . '</span>';
432
+ else
433
+ echo '<span id="emailsendtext" style="color:green;">' . __( 'Email sent.', 'backwpup' ) . '</span>';
434
+ die();
435
+ }
436
+ }
inc/class-destination-folder.php CHANGED
@@ -1,215 +1,215 @@
1
- <?php
2
- /**
3
- *
4
- */
5
- class BackWPup_Destination_Folder extends BackWPup_Destinations {
6
-
7
-
8
- /**
9
- * @return array
10
- */
11
- public function option_defaults() {
12
-
13
- $upload_dir = wp_upload_dir();
14
-
15
- return array( 'maxbackups' => 15, 'backupdir' => trailingslashit( str_replace( '\\', '/',$upload_dir[ 'basedir' ] ) ) . 'backwpup-' . BackWPup::get_plugin_data( 'hash' ) . '-backups/', 'backupsyncnodelete' => TRUE );
16
- }
17
-
18
-
19
- /**
20
- * @param $jobid
21
- * @return void
22
- * @internal param $main
23
- */
24
- public function edit_tab( $jobid ) {
25
- ?>
26
- <h3 class="title"><?php _e( 'Backup settings', 'backwpup' ); ?></h3>
27
- <p></p>
28
- <table class="form-table">
29
- <tr>
30
- <th scope="row"><label for="idbackupdir"><?php _e( 'Folder to store backups in', 'backwpup' ); ?></label></th>
31
- <td>
32
- <input name="backupdir" id="idbackupdir" type="text" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'backupdir' ) ); ?>" class="regular-text" />
33
- </td>
34
- </tr>
35
- <tr>
36
- <th scope="row"><?php _e( 'File Deletion', 'backwpup' ); ?></th>
37
- <td>
38
- <?php
39
- if ( BackWPup_Option::get( $jobid, 'backuptype' ) == 'archive' ) {
40
- ?>
41
- <label for="idmaxbackups"><input name="maxbackups" id="idmaxbackups" type="text" size="3" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'maxbackups' ) ) ;?>" class="small-text help-tip" title="<?php esc_attr_e( 'Oldest files will be deleted first. 0 = no deletion', 'backwpup' ); ?>" />&nbsp;
42
- <?php _e( 'Number of files to keep in folder.', 'backwpup' ); ?></label>
43
- <?php } else { ?>
44
- <label for="idbackupsyncnodelete"><input class="checkbox" value="1"
45
- type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'backupsyncnodelete' ), TRUE ); ?>
46
- name="backupsyncnodelete" id="idbackupsyncnodelete" /> <?php _e( 'Do not delete files while syncing to destination!', 'backwpup' ); ?></label>
47
- <?php } ?>
48
- </td>
49
- </tr>
50
- </table>
51
- <?php
52
- }
53
-
54
-
55
- /**
56
- * @param $jobid
57
- */
58
- public function edit_form_post_save( $jobid ) {
59
-
60
- $_POST[ 'backupdir' ] = trailingslashit( str_replace( '//', '/', str_replace( '\\', '/', trim( stripslashes( $_POST[ 'backupdir' ] ) ) ) ) );
61
- if ( $_POST[ 'backupdir' ][ 0 ] == '.' || ( $_POST[ 'backupdir' ][ 0 ] != '/' && ! preg_match( '#^[a-zA-Z]:/#', $_POST[ 'backupdir' ] ) ) )
62
- $_POST[ 'backupdir' ] = trailingslashit( str_replace( '\\', '/', ABSPATH ) ) . $_POST[ 'backupdir' ];
63
- if ( $_POST[ 'backupdir' ] == '/' )
64
- $_POST[ 'backupdir' ] = '';
65
- BackWPup_Option::update( $jobid, 'backupdir', $_POST[ 'backupdir' ] );
66
-
67
- BackWPup_Option::update( $jobid, 'maxbackups', isset( $_POST[ 'maxbackups' ] ) ? (int)$_POST[ 'maxbackups' ] : 0 );
68
- BackWPup_Option::update( $jobid, 'backupsyncnodelete', ( isset( $_POST[ 'backupsyncnodelete' ] ) && $_POST[ 'backupsyncnodelete' ] == 1 ) ? TRUE : FALSE );
69
- }
70
-
71
- /**
72
- * @param $jobdest
73
- * @param $backupfile
74
- */
75
- public function file_delete( $jobdest, $backupfile ) {
76
-
77
- if ( is_writeable( $backupfile ) && !is_dir( $backupfile ) && !is_link( $backupfile ) )
78
- unlink( $backupfile );
79
-
80
- }
81
-
82
- /**
83
- * @param $jobid
84
- * @param $get_file
85
- */
86
- public function file_download( $jobid, $get_file ) {
87
-
88
- if ( is_readable( $get_file ) ) {
89
- header( "Pragma: public" );
90
- header( "Expires: 0" );
91
- header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
92
- header( "Content-Type: application/octet-stream" );
93
- header( "Content-Disposition: attachment; filename=" . basename( $get_file ) . ";" );
94
- header( "Content-Transfer-Encoding: binary" );
95
- header( "Content-Length: " . filesize( $get_file ) );
96
- @set_time_limit( 0 );
97
- //chunked readfile
98
- @ob_end_clean();
99
- $handle = fopen( $get_file, 'rb' );
100
- if ( $handle ) {
101
- while ( ! feof( $handle ) ) {
102
- echo fread( $handle, 20482048 ); //2MB chunkes
103
- @ob_flush();
104
- @flush();
105
- }
106
- fclose( $handle );
107
- }
108
- die();
109
- }
110
- else {
111
- header( $_SERVER[ "SERVER_PROTOCOL" ] . " 404 Not Found" );
112
- header( "Status: 404 Not Found" );
113
- die();
114
- }
115
- }
116
-
117
- /**
118
- * @param $jobdest
119
- * @return mixed
120
- */
121
- public function file_get_list( $jobdest ) {
122
-
123
- list( $jobid, $dest ) = explode( '_', $jobdest );
124
- $filecounter = 0;
125
- $files = array();
126
- $backup_folder = BackWPup_Option::get( $jobid, 'backupdir' );
127
- if ( is_dir( $backup_folder ) && $dir = opendir( $backup_folder ) ) { //make file list
128
- while ( FALSE !== ( $file = readdir( $dir ) ) ) {
129
- if ( in_array( $file, array( '.', '..', 'index.php', '.htaccess', '.donotbackup' ) ) || is_dir( $backup_folder . $file ) || is_link( $backup_folder . $file ) )
130
- continue;
131
- if ( is_readable( $backup_folder . $file ) ) {
132
- //file list for backups
133
- $files[ $filecounter ][ 'folder' ] = $backup_folder;
134
- $files[ $filecounter ][ 'file' ] = $backup_folder . $file;
135
- $files[ $filecounter ][ 'filename' ] = $file;
136
- $files[ $filecounter ][ 'downloadurl' ] = add_query_arg( array(
137
- 'page' => 'backwpupbackups',
138
- 'action' => 'downloadfolder',
139
- 'file' => $backup_folder . $file,
140
- 'jobid' => $jobid
141
- ), network_admin_url( 'admin.php' ) );
142
- $files[ $filecounter ][ 'filesize' ] = filesize( $backup_folder . $file );
143
- $files[ $filecounter ][ 'time' ] = filemtime( $backup_folder . $file );
144
- $filecounter ++;
145
- }
146
- }
147
- @closedir( $dir );
148
- }
149
-
150
- return $files;
151
- }
152
-
153
- /**
154
- * @param $job_object
155
- * @return bool
156
- */
157
- public function job_run_archive( &$job_object ) {
158
-
159
- $job_object->substeps_todo = 1;
160
- if ( ! empty( $job_object->job[ 'jobid' ] ) )
161
- BackWPup_Option::update( $job_object->job[ 'jobid' ], 'lastbackupdownloadurl', add_query_arg( array(
162
- 'page' => 'backwpupbackups',
163
- 'action' => 'downloadfolder',
164
- 'file' => $job_object->backup_folder . $job_object->backup_file
165
- ), network_admin_url( 'admin.php' ) ) );
166
- //Delete old Backupfiles
167
- $backupfilelist = array();
168
- $files = array();
169
- if ( $dir = opendir( $job_object->backup_folder ) ) { //make file list
170
- while ( FALSE !== ( $file = readdir( $dir ) ) ) {
171
- if ( is_writeable( $job_object->backup_folder . $file ) && ! is_dir( $job_object->backup_folder . $file ) && ! is_link( $job_object->backup_folder . $file ) ) {
172
- //list for deletion
173
- if ( $job_object->is_backup_archive( $file ) )
174
- $backupfilelist[ filemtime( $job_object->backup_folder . $file ) ] = $file;
175
- }
176
- }
177
- @closedir( $dir );
178
- }
179
- if ( $job_object->job[ 'maxbackups' ] > 0 ) {
180
- if ( count( $backupfilelist ) > $job_object->job[ 'maxbackups' ] ) {
181
- ksort( $backupfilelist );
182
- $numdeltefiles = 0;
183
- while ( $file = array_shift( $backupfilelist ) ) {
184
- if ( count( $backupfilelist ) < $job_object->job[ 'maxbackups' ] )
185
- break;
186
- unlink( $job_object->backup_folder . $file );
187
- foreach ( $files as $key => $filedata ) {
188
- if ( $filedata[ 'file' ] == $job_object->backup_folder . $file )
189
- unset( $files[ $key ] );
190
- }
191
- $numdeltefiles ++;
192
- }
193
- if ( $numdeltefiles > 0 )
194
- $job_object->log( sprintf( _n( 'One backup file deleted', '%d backup files deleted', $numdeltefiles, 'backwpup' ), $numdeltefiles ), E_USER_NOTICE );
195
- }
196
- }
197
-
198
- $job_object->substeps_done ++;
199
-
200
- return TRUE;
201
- }
202
-
203
- /**
204
- * @param $job_object
205
- * @return bool
206
- */
207
- public function can_run( $job_object ) {
208
-
209
- if ( empty( $job_object->job[ 'backupdir' ] ) || $job_object->job[ 'backupdir' ] == '/' )
210
- return FALSE;
211
-
212
- return TRUE;
213
- }
214
-
215
- }
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ class BackWPup_Destination_Folder extends BackWPup_Destinations {
6
+
7
+
8
+ /**
9
+ * @return array
10
+ */
11
+ public function option_defaults() {
12
+
13
+ $upload_dir = wp_upload_dir();
14
+
15
+ return array( 'maxbackups' => 15, 'backupdir' => trailingslashit( str_replace( '\\', '/',$upload_dir[ 'basedir' ] ) ) . 'backwpup-' . BackWPup::get_plugin_data( 'hash' ) . '-backups/', 'backupsyncnodelete' => TRUE );
16
+ }
17
+
18
+
19
+ /**
20
+ * @param $jobid
21
+ * @return void
22
+ * @internal param $main
23
+ */
24
+ public function edit_tab( $jobid ) {
25
+ ?>
26
+ <h3 class="title"><?php _e( 'Backup settings', 'backwpup' ); ?></h3>
27
+ <p></p>
28
+ <table class="form-table">
29
+ <tr>
30
+ <th scope="row"><label for="idbackupdir"><?php _e( 'Folder to store backups in', 'backwpup' ); ?></label></th>
31
+ <td>
32
+ <input name="backupdir" id="idbackupdir" type="text" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'backupdir' ) ); ?>" class="regular-text" />
33
+ </td>
34
+ </tr>
35
+ <tr>
36
+ <th scope="row"><?php _e( 'File Deletion', 'backwpup' ); ?></th>
37
+ <td>
38
+ <?php
39
+ if ( BackWPup_Option::get( $jobid, 'backuptype' ) == 'archive' ) {
40
+ ?>
41
+ <label for="idmaxbackups"><input name="maxbackups" id="idmaxbackups" type="text" size="3" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'maxbackups' ) ) ;?>" class="small-text help-tip" title="<?php esc_attr_e( 'Oldest files will be deleted first. 0 = no deletion', 'backwpup' ); ?>" />&nbsp;
42
+ <?php _e( 'Number of files to keep in folder.', 'backwpup' ); ?></label>
43
+ <?php } else { ?>
44
+ <label for="idbackupsyncnodelete"><input class="checkbox" value="1"
45
+ type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'backupsyncnodelete' ), TRUE ); ?>
46
+ name="backupsyncnodelete" id="idbackupsyncnodelete" /> <?php _e( 'Do not delete files while syncing to destination!', 'backwpup' ); ?></label>
47
+ <?php } ?>
48
+ </td>
49
+ </tr>
50
+ </table>
51
+ <?php
52
+ }
53
+
54
+
55
+ /**
56
+ * @param $jobid
57
+ */
58
+ public function edit_form_post_save( $jobid ) {
59
+
60
+ $_POST[ 'backupdir' ] = trailingslashit( str_replace( '//', '/', str_replace( '\\', '/', trim( stripslashes( $_POST[ 'backupdir' ] ) ) ) ) );
61
+ if ( $_POST[ 'backupdir' ][ 0 ] == '.' || ( $_POST[ 'backupdir' ][ 0 ] != '/' && ! preg_match( '#^[a-zA-Z]:/#', $_POST[ 'backupdir' ] ) ) )
62
+ $_POST[ 'backupdir' ] = trailingslashit( str_replace( '\\', '/', ABSPATH ) ) . $_POST[ 'backupdir' ];
63
+ if ( $_POST[ 'backupdir' ] == '/' )
64
+ $_POST[ 'backupdir' ] = '';
65
+ BackWPup_Option::update( $jobid, 'backupdir', $_POST[ 'backupdir' ] );
66
+
67
+ BackWPup_Option::update( $jobid, 'maxbackups', isset( $_POST[ 'maxbackups' ] ) ? (int)$_POST[ 'maxbackups' ] : 0 );
68
+ BackWPup_Option::update( $jobid, 'backupsyncnodelete', ( isset( $_POST[ 'backupsyncnodelete' ] ) && $_POST[ 'backupsyncnodelete' ] == 1 ) ? TRUE : FALSE );
69
+ }
70
+
71
+ /**
72
+ * @param $jobdest
73
+ * @param $backupfile
74
+ */
75
+ public function file_delete( $jobdest, $backupfile ) {
76
+
77
+ if ( is_writeable( $backupfile ) && !is_dir( $backupfile ) && !is_link( $backupfile ) )
78
+ unlink( $backupfile );
79
+
80
+ }
81
+
82
+ /**
83
+ * @param $jobid
84
+ * @param $get_file
85
+ */
86
+ public function file_download( $jobid, $get_file ) {
87
+
88
+ if ( is_readable( $get_file ) ) {
89
+ header( "Pragma: public" );
90
+ header( "Expires: 0" );
91
+ header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
92
+ header( "Content-Type: application/octet-stream" );
93
+ header( "Content-Disposition: attachment; filename=" . basename( $get_file ) . ";" );
94
+ header( "Content-Transfer-Encoding: binary" );
95
+ header( "Content-Length: " . filesize( $get_file ) );
96
+ @set_time_limit( 300 );
97
+ //chunked readfile
98
+ @ob_end_clean();
99
+ $handle = fopen( $get_file, 'rb' );
100
+ if ( $handle ) {
101
+ while ( ! feof( $handle ) ) {
102
+ echo fread( $handle, 20482048 ); //2MB chunkes
103
+ @ob_flush();
104
+ @flush();
105
+ }
106
+ fclose( $handle );
107
+ }
108
+ die();
109
+ }
110
+ else {
111
+ header( $_SERVER[ "SERVER_PROTOCOL" ] . " 404 Not Found" );
112
+ header( "Status: 404 Not Found" );
113
+ die();
114
+ }
115
+ }
116
+
117
+ /**
118
+ * @param $jobdest
119
+ * @return mixed
120
+ */
121
+ public function file_get_list( $jobdest ) {
122
+
123
+ list( $jobid, $dest ) = explode( '_', $jobdest );
124
+ $filecounter = 0;
125
+ $files = array();
126
+ $backup_folder = BackWPup_Option::get( $jobid, 'backupdir' );
127
+ if ( is_dir( $backup_folder ) && $dir = opendir( $backup_folder ) ) { //make file list
128
+ while ( FALSE !== ( $file = readdir( $dir ) ) ) {
129
+ if ( in_array( $file, array( '.', '..', 'index.php', '.htaccess', '.donotbackup' ) ) || is_dir( $backup_folder . $file ) || is_link( $backup_folder . $file ) )
130
+ continue;
131
+ if ( is_readable( $backup_folder . $file ) ) {
132
+ //file list for backups
133
+ $files[ $filecounter ][ 'folder' ] = $backup_folder;
134
+ $files[ $filecounter ][ 'file' ] = $backup_folder . $file;
135
+ $files[ $filecounter ][ 'filename' ] = $file;
136
+ $files[ $filecounter ][ 'downloadurl' ] = add_query_arg( array(
137
+ 'page' => 'backwpupbackups',
138
+ 'action' => 'downloadfolder',
139
+ 'file' => $backup_folder . $file,
140
+ 'jobid' => $jobid
141
+ ), network_admin_url( 'admin.php' ) );
142
+ $files[ $filecounter ][ 'filesize' ] = filesize( $backup_folder . $file );
143
+ $files[ $filecounter ][ 'time' ] = filemtime( $backup_folder . $file );
144
+ $filecounter ++;
145
+ }
146
+ }
147
+ @closedir( $dir );
148
+ }
149
+
150
+ return $files;
151
+ }
152
+
153
+ /**
154
+ * @param $job_object
155
+ * @return bool
156
+ */
157
+ public function job_run_archive( &$job_object ) {
158
+
159
+ $job_object->substeps_todo = 1;
160
+ if ( ! empty( $job_object->job[ 'jobid' ] ) )
161
+ BackWPup_Option::update( $job_object->job[ 'jobid' ], 'lastbackupdownloadurl', add_query_arg( array(
162
+ 'page' => 'backwpupbackups',
163
+ 'action' => 'downloadfolder',
164
+ 'file' => $job_object->backup_folder . $job_object->backup_file
165
+ ), network_admin_url( 'admin.php' ) ) );
166
+ //Delete old Backupfiles
167
+ $backupfilelist = array();
168
+ $files = array();
169
+ if ( $dir = opendir( $job_object->backup_folder ) ) { //make file list
170
+ while ( FALSE !== ( $file = readdir( $dir ) ) ) {
171
+ if ( is_writeable( $job_object->backup_folder . $file ) && ! is_dir( $job_object->backup_folder . $file ) && ! is_link( $job_object->backup_folder . $file ) ) {
172
+ //list for deletion
173
+ if ( $job_object->is_backup_archive( $file ) )
174
+ $backupfilelist[ filemtime( $job_object->backup_folder . $file ) ] = $file;
175
+ }
176
+ }
177
+ @closedir( $dir );
178
+ }
179
+ if ( $job_object->job[ 'maxbackups' ] > 0 ) {
180
+ if ( count( $backupfilelist ) > $job_object->job[ 'maxbackups' ] ) {
181
+ ksort( $backupfilelist );
182
+ $numdeltefiles = 0;
183
+ while ( $file = array_shift( $backupfilelist ) ) {
184
+ if ( count( $backupfilelist ) < $job_object->job[ 'maxbackups' ] )
185
+ break;
186
+ unlink( $job_object->backup_folder . $file );
187
+ foreach ( $files as $key => $filedata ) {
188
+ if ( $filedata[ 'file' ] == $job_object->backup_folder . $file )
189
+ unset( $files[ $key ] );
190
+ }
191
+ $numdeltefiles ++;
192
+ }
193
+ if ( $numdeltefiles > 0 )
194
+ $job_object->log( sprintf( _n( 'One backup file deleted', '%d backup files deleted', $numdeltefiles, 'backwpup' ), $numdeltefiles ), E_USER_NOTICE );
195
+ }
196
+ }
197
+
198
+ $job_object->substeps_done ++;
199
+
200
+ return TRUE;
201
+ }
202
+
203
+ /**
204
+ * @param $job_object
205
+ * @return bool
206
+ */
207
+ public function can_run( $job_object ) {
208
+
209
+ if ( empty( $job_object->job[ 'backupdir' ] ) || $job_object->job[ 'backupdir' ] == '/' )
210
+ return FALSE;
211
+
212
+ return TRUE;
213
+ }
214
+
215
+ }
inc/class-destination-ftp.php CHANGED
@@ -1,410 +1,410 @@
1
- <?php
2
- /**
3
- *
4
- */
5
- class BackWPup_Destination_Ftp extends BackWPup_Destinations {
6
-
7
- /**
8
- * @return array
9
- */
10
- public function option_defaults() {
11
-
12
- return array( 'ftphost' => '', 'ftphostport' => 21, 'ftptimeout' => 90, 'ftpuser' => '', 'ftppass' => '', 'ftpdir' => trailingslashit( sanitize_title_with_dashes( get_bloginfo( 'name' ) ) ), 'ftpmaxbackups' => 15, 'ftppasv' => TRUE, 'ftpssl' => FALSE );
13
- }
14
-
15
-
16
-
17
- /**
18
- * @param $jobid
19
- */
20
- public function edit_tab( $jobid ) {
21
- ?>
22
-
23
- <h3 class="title"><?php _e( 'FTP server and login', 'backwpup' ); ?></h3>
24
- <p></p>
25
- <table class="form-table">
26
- <tr>
27
- <th scope="row"><label for="idftphost"><?php _e( 'FTP server', 'backwpup' ); ?></label></th>
28
- <td>
29
- <input id="idftphost" name="ftphost" type="text" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'ftphost' ) );?>"
30
- class="regular-text" autocomplete="off" />&nbsp;&nbsp;
31
- <label for="idftphostport"><?php _e( 'Port:', 'backwpup' ); ?>
32
- <input name="ftphostport" id="idftphostport" type="text" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'ftphostport' ) ); ?>"
33
- class="small-text" /></label>
34
- </td>
35
- </tr>
36
- <tr>
37
- <th scope="row"><label for="idftpuser"><?php _e( 'Username', 'backwpup' ); ?></label></th>
38
- <td>
39
- <input id="idftpuser" name="ftpuser" type="text" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'ftpuser' ) ); ?>"
40
- class="user regular-text" autocomplete="off" />
41
- </td>
42
- </tr>
43
- <tr>
44
- <th scope="row"><label for="idftppass"><?php _e( 'Password', 'backwpup' ); ?></label></th>
45
- <td>
46
- <input id="idftppass" name="ftppass" type="password" value="<?php echo esc_attr( BackWPup_Encryption::decrypt(BackWPup_Option::get( $jobid, 'ftppass' ) ) ); ?>"
47
- class="password regular-text" autocomplete="off" />
48
- </td>
49
- </tr>
50
- </table>
51
-
52
- <h3 class="title"><?php _e( 'Backup settings', 'backwpup' ); ?></h3>
53
- <p></p>
54
- <table class="form-table">
55
- <tr>
56
- <th scope="row"><label for="idftpdir"><?php _e( 'Folder to store files in', 'backwpup' ); ?></label></th>
57
- <td>
58
- <input id="idftpdir" name="ftpdir" type="text" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'ftpdir' ) ); ?>" class="regular-text" />
59
- </td>
60
- </tr>
61
- <tr>
62
- <th scope="row"><?php _e( 'File Deletion', 'backwpup' ); ?></th>
63
- <td>
64
- <?php
65
- if ( BackWPup_Option::get( $jobid, 'backuptype' ) == 'archive' ) {
66
- ?>
67
- <label for="idftpmaxbackups"><input id="idftpmaxbackups" name="ftpmaxbackups" type="text" size="3" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'ftpmaxbackups' ) ); ?>" class="small-text help-tip" title="<?php esc_attr_e( 'Oldest files will be deleted first. 0 = no deletion', 'backwpup' ); ?>" />&nbsp;
68
- <?php _e( 'Maximum number of files to keep in folder.', 'backwpup' ); ?></label>
69
- <?php } else { ?>
70
- <label for="idftpsyncnodelete"><input class="checkbox" value="1"
71
- type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'ftpsyncnodelete' ), TRUE ); ?>
72
- name="ftpsyncnodelete" id="idftpsyncnodelete" /> <?php _e( 'Do not delete files while syncing to destination!', 'backwpup' ); ?></label>
73
- <?php } ?>
74
- </td>
75
- </tr>
76
- </table>
77
-
78
- <h3 class="title"><?php _e( 'FTP specific settings', 'backwpup' ); ?></h3>
79
- <p></p>
80
- <table class="form-table">
81
- <tr>
82
- <th scope="row"><label for="idftptimeout"><?php _e( 'Timeout for FTP connection', 'backwpup' ); ?></label></th>
83
- <td>
84
- <input id="idftptimeout" name="ftptimeout" type="text" size="3"
85
- value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'ftptimeout' ) ); ?>"
86
- class="small-text" /> <?php _e( 'seconds', 'backwpup' ); ?>
87
- </td>
88
- </tr>
89
- <tr>
90
- <th scope="row"><?php _e( 'SSL-FTP connection', 'backwpup' ); ?></th>
91
- <td>
92
- <label for="idftpssl"><input class="checkbox" value="1"
93
- type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'ftpssl' ), TRUE ); ?>
94
- id="idftpssl" name="ftpssl"<?php if ( ! function_exists( 'ftp_ssl_connect' ) ) echo " disabled=\"disabled\""; ?> /> <?php _e( 'Use explicit SSL-FTP connection.', 'backwpup' ); ?></label>
95
-
96
- </td>
97
- </tr>
98
- <tr>
99
- <th scope="row"><?php _e( 'FTP Passive Mode', 'backwpup' ); ?></th>
100
- <td>
101
- <label for="idftppasv"><input class="checkbox" value="1"
102
- type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'ftppasv' ), TRUE ); ?>
103
- name="ftppasv" id="idftppasv" /> <?php _e( 'Use FTP Passive Mode.', 'backwpup' ); ?></label>
104
- </td>
105
- </tr>
106
- </table>
107
-
108
- <?php
109
- }
110
-
111
-
112
- /**
113
- * @param $id
114
- */
115
- public function edit_form_post_save( $id ) {
116
-
117
- $_POST[ 'ftphost' ] = str_replace( array( 'http://', 'ftp://' ), '', $_POST[ 'ftphost' ] );
118
- BackWPup_Option::update( $id, 'ftphost', isset( $_POST[ 'ftphost' ] ) ? $_POST[ 'ftphost' ] : '' );
119
-
120
- BackWPup_Option::update( $id, 'ftphostport', ! empty( $_POST[ 'ftphostport' ] ) ? (int)$_POST[ 'ftphostport' ] : 21 );
121
- BackWPup_Option::update( $id, 'ftptimeout', ! empty( $_POST[ 'ftptimeout' ] ) ? (int)$_POST[ 'ftptimeout' ] : 90 );
122
- BackWPup_Option::update( $id, 'ftpuser', isset( $_POST[ 'ftpuser' ] ) ? $_POST[ 'ftpuser' ] : '' );
123
- BackWPup_Option::update( $id, 'ftppass', isset( $_POST[ 'ftppass' ] ) ? BackWPup_Encryption::encrypt( $_POST[ 'ftppass' ] ) : '' );
124
-
125
- if ( ! empty( $_POST[ 'ftpdir' ] ) )
126
- $_POST[ 'ftpdir' ] = trailingslashit( str_replace( '//', '/', str_replace( '\\', '/', trim( stripslashes( $_POST[ 'ftpdir' ] ) ) ) ) );
127
- BackWPup_Option::update( $id, 'ftpdir', $_POST[ 'ftpdir' ] );
128
-
129
- BackWPup_Option::update( $id, 'ftpmaxbackups', isset( $_POST[ 'ftpmaxbackups' ] ) ? (int)$_POST[ 'ftpmaxbackups' ] : 0 );
130
-
131
- if ( function_exists( 'ftp_ssl_connect' ) )
132
- BackWPup_Option::update( $id, 'ftpssl', ( isset( $_POST[ 'ftpssl' ] ) && $_POST[ 'ftpssl' ] == 1 ) ? TRUE : FALSE );
133
- else
134
- BackWPup_Option::update( $id, 'ftpssl', FALSE );
135
-
136
- BackWPup_Option::update( $id, 'ftppasv', ( isset( $_POST[ 'ftppasv' ] ) && $_POST[ 'ftppasv' ] == 1 ) ? TRUE : FALSE );
137
- }
138
-
139
- /**
140
- * @param $jobdest
141
- * @param $backupfile
142
- */
143
- public function file_delete( $jobdest, $backupfile ) {
144
-
145
- $files = get_site_transient( 'backwpup_'. strtolower( $jobdest ), FALSE );
146
- list( $jobid, $dest ) = explode( '_', $jobdest );
147
-
148
- if ( BackWPup_Option::get( $jobid, 'ftphost' ) && BackWPup_Option::get( $jobid, 'ftpuser' ) && BackWPup_Option::get( $jobid, 'ftppass' ) && function_exists( 'ftp_connect' ) ) {
149
- $ftp_conn_id = FALSE;
150
- if ( function_exists( 'ftp_ssl_connect' ) && BackWPup_Option::get( $jobid, 'ftpssl' ) ) { //make SSL FTP connection
151
- $ftp_conn_id = ftp_ssl_connect( BackWPup_Option::get( $jobid, 'ftphost' ), BackWPup_Option::get( $jobid, 'ftphostport' ), BackWPup_Option::get( $jobid, 'ftptimeout' ) );
152
- }
153
- elseif ( ! BackWPup_Option::get( $jobid, 'ftpssl' ) ) { //make normal FTP conection if SSL not work
154
- $ftp_conn_id = ftp_connect( BackWPup_Option::get( $jobid, 'ftphost' ), BackWPup_Option::get( $jobid, 'ftphostport' ), BackWPup_Option::get( $jobid, 'ftptimeout' ) );
155
- }
156
- $loginok = FALSE;
157
- if ( $ftp_conn_id ) {
158
- //FTP Login
159
- if ( @ftp_login( $ftp_conn_id, BackWPup_Option::get( $jobid, 'ftpuser' ), BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'ftppass' ) ) ) ) {
160
- $loginok = TRUE;
161
- }
162
- else { //if PHP ftp login don't work use raw login
163
- ftp_raw( $ftp_conn_id, 'USER ' . BackWPup_Option::get( $jobid, 'ftpuser' ) );
164
- $return = ftp_raw( $ftp_conn_id, 'PASS ' . BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'ftppass' ) ) );
165
- if ( substr( trim( $return[ 0 ] ), 0, 3 ) <= 400 )
166
- $loginok = TRUE;
167
- }
168
- }
169
- if ( $loginok ) {
170
- ftp_pasv( $ftp_conn_id, BackWPup_Option::get( $jobid, 'ftppasv' ) );
171
- ftp_delete( $ftp_conn_id, $backupfile );
172
- //update file list
173
- foreach ( $files as $key => $file ) {
174
- if ( is_array( $file ) && $file[ 'file' ] == $backupfile )
175
- unset( $files[ $key ] );
176
- }
177
- }
178
- else {
179
- BackWPup_Admin::message( __( 'FTP: Login failure!', 'backwpup' ), TRUE );
180
- }
181
- }
182
-
183
- set_site_transient( 'backwpup_'. strtolower( $jobdest ), $files, 60 * 60 * 24 * 7 );
184
- }
185
-
186
- /**
187
- * @param $jobdest
188
- * @return mixed
189
- */
190
- public function file_get_list( $jobdest ) {
191
-
192
- return get_site_transient( 'backwpup_' . strtolower( $jobdest ) );
193
- }
194
-
195
- /**
196
- * @param $job_object
197
- * @return bool
198
- */
199
- public function job_run_archive( &$job_object ) {
200
-
201
- $job_object->substeps_todo = 2 + $job_object->backup_filesize;
202
- if ( $job_object->steps_data[ $job_object->step_working ]['SAVE_STEP_TRY'] != $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] )
203
- $job_object->log( sprintf( __( '%d. Try to send backup file to an FTP server&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ), E_USER_NOTICE );
204
-
205
- if ( ! empty( $job_object->job[ 'ftpssl' ] ) ) { //make SSL FTP connection
206
- if ( function_exists( 'ftp_ssl_connect' ) ) {
207
- $ftp_conn_id = ftp_ssl_connect( $job_object->job[ 'ftphost' ], $job_object->job[ 'ftphostport' ], $job_object->job[ 'ftptimeout' ] );
208
- if ( $ftp_conn_id )
209
- $job_object->log( sprintf( __( 'Connected via explicit SSL-FTP to server: %s', 'backwpup' ), $job_object->job[ 'ftphost' ] . ':' . $job_object->job[ 'ftphostport' ] ), E_USER_NOTICE );
210
- else {
211
- $job_object->log( sprintf( __( 'Cannot connect via explicit SSL-FTP to server: %s', 'backwpup' ), $job_object->job[ 'ftphost' ] . ':' . $job_object->job[ 'ftphostport' ] ), E_USER_ERROR );
212
-
213
- return FALSE;
214
- }
215
- }
216
- else {
217
- $job_object->log( __( 'PHP function to connect with explicit SSL-FTP to server does not exist!', 'backwpup' ), E_USER_ERROR );
218
-
219
- return TRUE;
220
- }
221
- }
222
- else { //make normal FTP connection if SSL not work
223
- $ftp_conn_id = ftp_connect( $job_object->job[ 'ftphost' ], $job_object->job[ 'ftphostport' ], $job_object->job[ 'ftptimeout' ] );
224
- if ( $ftp_conn_id )
225
- $job_object->log( sprintf( __( 'Connected to FTP server: %s', 'backwpup' ), $job_object->job[ 'ftphost' ] . ':' . $job_object->job[ 'ftphostport' ] ), E_USER_NOTICE );
226
- else {
227
- $job_object->log( sprintf( __( 'Cannot connect to FTP server: %s', 'backwpup' ), $job_object->job[ 'ftphost' ] . ':' . $job_object->job[ 'ftphostport' ] ), E_USER_ERROR );
228
-
229
- return FALSE;
230
- }
231
- }
232
-
233
- //FTP Login
234
- $job_object->log( sprintf( __( 'FTP client command: %s', 'backwpup' ), 'USER ' . $job_object->job[ 'ftpuser' ] ), E_USER_NOTICE );
235
- if ( $loginok = @ftp_login( $ftp_conn_id, $job_object->job[ 'ftpuser' ], BackWPup_Encryption::decrypt( $job_object->job[ 'ftppass' ] ) ) ) {
236
- $job_object->log( sprintf( __( 'FTP server response: %s', 'backwpup' ), 'User ' . $job_object->job[ 'ftpuser' ] . ' logged in.' ), E_USER_NOTICE );
237
- }
238
- else { //if PHP ftp login don't work use raw login
239
- $return = ftp_raw( $ftp_conn_id, 'USER ' . $job_object->job[ 'ftpuser' ] );
240
- $job_object->log( sprintf( __( 'FTP server reply: %s', 'backwpup' ), $return[ 0 ] ), E_USER_NOTICE );
241
- if ( substr( trim( $return[ 0 ] ), 0, 3 ) <= 400 ) {
242
- $job_object->log( sprintf( __( 'FTP client command: %s', 'backwpup' ), 'PASS *******' ), E_USER_NOTICE );
243
- $return = ftp_raw( $ftp_conn_id, 'PASS ' . BackWPup_Encryption::decrypt( $job_object->job[ 'ftppass' ] ) );
244
- $job_object->log( sprintf( __( 'FTP server reply: %s', 'backwpup' ), $return[ 0 ] ), E_USER_NOTICE );
245
- if ( substr( trim( $return[ 0 ] ), 0, 3 ) <= 400 )
246
- $loginok = TRUE;
247
- }
248
- }
249
- if ( ! $loginok )
250
- return FALSE;
251
-
252
- //SYSTYPE
253
- $job_object->log( sprintf( __( 'FTP client command: %s', 'backwpup' ), 'SYST' ), E_USER_NOTICE );
254
- $systype = ftp_systype( $ftp_conn_id );
255
- if ( $systype )
256
- $job_object->log( sprintf( __( 'FTP server reply: %s', 'backwpup' ), $systype ), E_USER_NOTICE );
257
- else
258
- $job_object->log( sprintf( __( 'FTP server reply: %s', 'backwpup' ), __( 'Error getting SYSTYPE', 'backwpup' ) ), E_USER_ERROR );
259
-
260
- //set actual ftp dir to ftp dir
261
- if ( empty( $job_object->job[ 'ftpdir' ] ) )
262
- $job_object->job[ 'ftpdir' ] = trailingslashit( ftp_pwd( $ftp_conn_id ) );
263
- // prepend actual ftp dir if relative dir
264
- if ( substr( $job_object->job[ 'ftpdir' ], 0, 1 ) != '/' )
265
- $job_object->job[ 'ftpdir' ] = trailingslashit( ftp_pwd( $ftp_conn_id ) ) . $job_object->job[ 'ftpdir' ];
266
-
267
- //test ftp dir and create it if not exists
268
- if ( $job_object->job[ 'ftpdir' ] != '/' ) {
269
- @ftp_chdir( $ftp_conn_id, '/' ); //go to root
270
- $ftpdirs = explode( '/', trim( $job_object->job[ 'ftpdir' ], '/' ) );
271
- foreach ( $ftpdirs as $ftpdir ) {
272
- if ( empty( $ftpdir ) )
273
- continue;
274
- if ( ! @ftp_chdir( $ftp_conn_id, $ftpdir ) ) {
275
- if ( @ftp_mkdir( $ftp_conn_id, $ftpdir ) ) {
276
- $job_object->log( sprintf( __( 'FTP Folder "%s" created!', 'backwpup' ), $ftpdir ), E_USER_NOTICE );
277
- ftp_chdir( $ftp_conn_id, $ftpdir );
278
- }
279
- else {
280
- $job_object->log( sprintf( __( 'FTP Folder "%s" cannot be created!', 'backwpup' ), $ftpdir ), E_USER_ERROR );
281
-
282
- return FALSE;
283
- }
284
- }
285
- }
286
- }
287
-
288
- // Get the current working directory
289
- $current_ftp_dir = trailingslashit( ftp_pwd( $ftp_conn_id ) );
290
- if ( $job_object->substeps_done == 0 )
291
- $job_object->log( sprintf( __( 'FTP current folder is: %s', 'backwpup' ), $current_ftp_dir ), E_USER_NOTICE );
292
-
293
- //get file size to resume upload
294
- @clearstatcache();
295
- $job_object->substeps_done = @ftp_size( $ftp_conn_id, $job_object->job[ 'ftpdir' ] . $job_object->backup_file );
296
- if ( $job_object->substeps_done == -1 )
297
- $job_object->substeps_done = 0;
298
-
299
- //PASV
300
- $job_object->log( sprintf( __( 'FTP client command: %s', 'backwpup' ), 'PASV' ), E_USER_NOTICE );
301
- if ( $job_object->job[ 'ftppasv' ] ) {
302
- if ( ftp_pasv( $ftp_conn_id, TRUE ) )
303
- $job_object->log( sprintf( __( 'FTP server reply: %s', 'backwpup' ), __( 'Entering passive mode', 'backwpup' ) ), E_USER_NOTICE );
304
- else
305
- $job_object->log( sprintf( __( 'FTP server reply: %s', 'backwpup' ), __( 'Cannot enter passive mode', 'backwpup' ) ), E_USER_WARNING );
306
- }
307
- else {
308
- if ( ftp_pasv( $ftp_conn_id, FALSE ) )
309
- $job_object->log( sprintf( __( 'FTP server reply: %s', 'backwpup' ), __( 'Entering normal mode', 'backwpup' ) ), E_USER_NOTICE );
310
- else
311
- $job_object->log( sprintf( __( 'FTP server reply: %s', 'backwpup' ), __( 'Cannot enter normal mode', 'backwpup' ) ), E_USER_WARNING );
312
- }
313
-
314
- if ( $job_object->substeps_done < $job_object->backup_filesize ) {
315
- $job_object->log( __( 'Starting upload to FTP &#160;&hellip;', 'backwpup' ), E_USER_NOTICE );
316
- $fp = fopen( $job_object->backup_folder . $job_object->backup_file, 'r' );
317
- //go to actual file pos
318
- fseek( $fp, $job_object->substeps_done );
319
- $ret = ftp_nb_fput( $ftp_conn_id, $current_ftp_dir . $job_object->backup_file, $fp, FTP_BINARY, $job_object->substeps_done );
320
- while ( $ret == FTP_MOREDATA ) {
321
- $job_object->substeps_done = ftell( $fp );
322
- $job_object->update_working_data();
323
- $job_object->do_restart_time();
324
- $ret = ftp_nb_continue( $ftp_conn_id );
325
- }
326
- if ( $ret != FTP_FINISHED ) {
327
- $job_object->log( __( 'Cannot transfer backup to FTP server!', 'backwpup' ), E_USER_ERROR );
328
-
329
- return FALSE;
330
- }
331
- else {
332
- $job_object->substeps_done = $job_object->backup_filesize + 1;
333
- $job_object->log( sprintf( __( 'Backup transferred to FTP server: %s', 'backwpup' ), $current_ftp_dir . $job_object->backup_file ), E_USER_NOTICE );
334
- if ( ! empty( $job_object->job[ 'jobid' ] ) )
335
- BackWPup_Option::update( $job_object->job[ 'jobid' ], 'lastbackupdownloadurl', "ftp://" . $job_object->job[ 'ftpuser' ] . ":" . BackWPup_Encryption::decrypt( $job_object->job[ 'ftppass' ] ) . "@" . $job_object->job[ 'ftphost' ] . ':' . $job_object->job[ 'ftphostport' ] . $current_ftp_dir . $job_object->backup_file );
336
- }
337
- fclose( $fp );
338
- }
339
-
340
- $backupfilelist = array();
341
- $filecounter = 0;
342
- $files = array();
343
- if ( $filelist = ftp_nlist( $ftp_conn_id, '.' ) ) {
344
- foreach ( $filelist as $file ) {
345
- if ( basename( $file ) != '.' && basename( $file ) != '..' ) {
346
- if ( $job_object->is_backup_archive( $file ) ) {
347
- $time = ftp_mdtm( $ftp_conn_id, $file );
348
- if ( $time != - 1 )
349
- $backupfilelist[ $time ] = basename( $file );
350
- else
351
- $backupfilelist[ ] = basename( $file );
352
- }
353
- $files[ $filecounter ][ 'folder' ] = 'ftp://' . $job_object->job[ 'ftphost' ] . ':' . $job_object->job[ 'ftphostport' ] . $job_object->job[ 'ftpdir' ];
354
- $files[ $filecounter ][ 'file' ] = $job_object->job[ 'ftpdir' ] . basename( $file );
355
- $files[ $filecounter ][ 'filename' ] = basename( $file );
356
- $files[ $filecounter ][ 'downloadurl' ] = 'ftp://' . rawurlencode( $job_object->job[ 'ftpuser' ] ) . ':' . rawurlencode( BackWPup_Encryption::decrypt( $job_object->job[ 'ftppass' ] ) ) . '@' . $job_object->job[ 'ftphost' ] . ':' . $job_object->job[ 'ftphostport' ] . $job_object->job[ 'ftpdir' ] . basename( $file );
357
- $files[ $filecounter ][ 'filesize' ] = ftp_size( $ftp_conn_id, $file );
358
- $files[ $filecounter ][ 'time' ] = ftp_mdtm( $ftp_conn_id, $file );
359
- $filecounter ++;
360
- }
361
- }
362
- }
363
-
364
- if ( ! empty( $job_object->job[ 'ftpmaxbackups' ] ) && $job_object->job[ 'ftpmaxbackups' ] > 0 ) { //Delete old backups
365
- if ( count( $backupfilelist ) > $job_object->job[ 'ftpmaxbackups' ] ) {
366
- ksort( $backupfilelist );
367
- $numdeltefiles = 0;
368
- while ( $file = array_shift( $backupfilelist ) ) {
369
- if ( count( $backupfilelist ) < $job_object->job[ 'ftpmaxbackups' ] )
370
- break;
371
- if ( ftp_delete( $ftp_conn_id, $file ) ) { //delete files on ftp
372
- foreach ( $files as $key => $filedata ) {
373
- if ( $filedata[ 'file' ] == $job_object->job[ 'ftpdir' ] . $file )
374
- unset( $files[ $key ] );
375
- }
376
- $numdeltefiles ++;
377
- }
378
- else
379
- $job_object->log( sprintf( __( 'Cannot delete "%s" on FTP server!', 'backwpup' ), $job_object->job[ 'ftpdir' ] . $file ), E_USER_ERROR );
380
- }
381
- if ( $numdeltefiles > 0 )
382
- $job_object->log( sprintf( _n( 'One file deleted on FTP server', '%d files deleted on FTP server', $numdeltefiles, 'backwpup' ), $numdeltefiles ), E_USER_NOTICE );
383
- }
384
- }
385
- set_site_transient( 'backwpup_' . $job_object->job[ 'jobid' ] . '_ftp', $files, 60 * 60 * 24 * 7 );
386
-
387
- ftp_close( $ftp_conn_id );
388
-
389
- return TRUE;
390
- }
391
-
392
- /**
393
- * @param $job_object
394
- * @return bool
395
- */
396
- public function can_run( $job_object ) {
397
-
398
- if ( empty( $job_object->job[ 'ftphost' ] ) )
399
- return FALSE;
400
-
401
- if ( empty( $job_object->job[ 'ftpuser' ] ) )
402
- return FALSE;
403
-
404
- if ( empty( $job_object->job[ 'ftppass' ] ) )
405
- return FALSE;
406
-
407
- return TRUE;
408
- }
409
-
410
- }
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ class BackWPup_Destination_Ftp extends BackWPup_Destinations {
6
+
7
+ /**
8
+ * @return array
9
+ */
10
+ public function option_defaults() {
11
+
12
+ return array( 'ftphost' => '', 'ftphostport' => 21, 'ftptimeout' => 90, 'ftpuser' => '', 'ftppass' => '', 'ftpdir' => trailingslashit( sanitize_title_with_dashes( get_bloginfo( 'name' ) ) ), 'ftpmaxbackups' => 15, 'ftppasv' => TRUE, 'ftpssl' => FALSE );
13
+ }
14
+
15
+
16
+
17
+ /**
18
+ * @param $jobid
19
+ */
20
+ public function edit_tab( $jobid ) {
21
+ ?>
22
+
23
+ <h3 class="title"><?php _e( 'FTP server and login', 'backwpup' ); ?></h3>
24
+ <p></p>
25
+ <table class="form-table">
26
+ <tr>
27
+ <th scope="row"><label for="idftphost"><?php _e( 'FTP server', 'backwpup' ); ?></label></th>
28
+ <td>
29
+ <input id="idftphost" name="ftphost" type="text" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'ftphost' ) );?>"
30
+ class="regular-text" autocomplete="off" />&nbsp;&nbsp;
31
+ <label for="idftphostport"><?php _e( 'Port:', 'backwpup' ); ?>
32
+ <input name="ftphostport" id="idftphostport" type="text" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'ftphostport' ) ); ?>"
33
+ class="small-text" /></label>
34
+ </td>
35
+ </tr>
36
+ <tr>
37
+ <th scope="row"><label for="idftpuser"><?php _e( 'Username', 'backwpup' ); ?></label></th>
38
+ <td>
39
+ <input id="idftpuser" name="ftpuser" type="text" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'ftpuser' ) ); ?>"
40
+ class="user regular-text" autocomplete="off" />
41
+ </td>
42
+ </tr>
43
+ <tr>
44
+ <th scope="row"><label for="idftppass"><?php _e( 'Password', 'backwpup' ); ?></label></th>
45
+ <td>
46
+ <input id="idftppass" name="ftppass" type="password" value="<?php echo esc_attr( BackWPup_Encryption::decrypt(BackWPup_Option::get( $jobid, 'ftppass' ) ) ); ?>"
47
+ class="password regular-text" autocomplete="off" />
48
+ </td>
49
+ </tr>
50
+ </table>
51
+
52
+ <h3 class="title"><?php _e( 'Backup settings', 'backwpup' ); ?></h3>
53
+ <p></p>
54
+ <table class="form-table">
55
+ <tr>
56
+ <th scope="row"><label for="idftpdir"><?php _e( 'Folder to store files in', 'backwpup' ); ?></label></th>
57
+ <td>
58
+ <input id="idftpdir" name="ftpdir" type="text" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'ftpdir' ) ); ?>" class="regular-text" />
59
+ </td>
60
+ </tr>
61
+ <tr>
62
+ <th scope="row"><?php _e( 'File Deletion', 'backwpup' ); ?></th>
63
+ <td>
64
+ <?php
65
+ if ( BackWPup_Option::get( $jobid, 'backuptype' ) == 'archive' ) {
66
+ ?>
67
+ <label for="idftpmaxbackups"><input id="idftpmaxbackups" name="ftpmaxbackups" type="text" size="3" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'ftpmaxbackups' ) ); ?>" class="small-text help-tip" title="<?php esc_attr_e( 'Oldest files will be deleted first. 0 = no deletion', 'backwpup' ); ?>" />&nbsp;
68
+ <?php _e( 'Maximum number of files to keep in folder.', 'backwpup' ); ?></label>
69
+ <?php } else { ?>
70
+ <label for="idftpsyncnodelete"><input class="checkbox" value="1"
71
+ type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'ftpsyncnodelete' ), TRUE ); ?>
72
+ name="ftpsyncnodelete" id="idftpsyncnodelete" /> <?php _e( 'Do not delete files while syncing to destination!', 'backwpup' ); ?></label>
73
+ <?php } ?>
74
+ </td>
75
+ </tr>
76
+ </table>
77
+
78
+ <h3 class="title"><?php _e( 'FTP specific settings', 'backwpup' ); ?></h3>
79
+ <p></p>
80
+ <table class="form-table">
81
+ <tr>
82
+ <th scope="row"><label for="idftptimeout"><?php _e( 'Timeout for FTP connection', 'backwpup' ); ?></label></th>
83
+ <td>
84
+ <input id="idftptimeout" name="ftptimeout" type="text" size="3"
85
+ value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'ftptimeout' ) ); ?>"
86
+ class="small-text" /> <?php _e( 'seconds', 'backwpup' ); ?>
87
+ </td>
88
+ </tr>
89
+ <tr>
90
+ <th scope="row"><?php _e( 'SSL-FTP connection', 'backwpup' ); ?></th>
91
+ <td>
92
+ <label for="idftpssl"><input class="checkbox" value="1"
93
+ type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'ftpssl' ), TRUE ); ?>
94
+ id="idftpssl" name="ftpssl"<?php if ( ! function_exists( 'ftp_ssl_connect' ) ) echo " disabled=\"disabled\""; ?> /> <?php _e( 'Use explicit SSL-FTP connection.', 'backwpup' ); ?></label>
95
+
96
+ </td>
97
+ </tr>
98
+ <tr>
99
+ <th scope="row"><?php _e( 'FTP Passive Mode', 'backwpup' ); ?></th>
100
+ <td>
101
+ <label for="idftppasv"><input class="checkbox" value="1"
102
+ type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'ftppasv' ), TRUE ); ?>
103
+ name="ftppasv" id="idftppasv" /> <?php _e( 'Use FTP Passive Mode.', 'backwpup' ); ?></label>
104
+ </td>
105
+ </tr>
106
+ </table>
107
+
108
+ <?php
109
+ }
110
+
111
+
112
+ /**
113
+ * @param $id
114
+ */
115
+ public function edit_form_post_save( $id ) {
116
+
117
+ $_POST[ 'ftphost' ] = str_replace( array( 'http://', 'ftp://' ), '', $_POST[ 'ftphost' ] );
118
+ BackWPup_Option::update( $id, 'ftphost', isset( $_POST[ 'ftphost' ] ) ? $_POST[ 'ftphost' ] : '' );
119
+
120
+ BackWPup_Option::update( $id, 'ftphostport', ! empty( $_POST[ 'ftphostport' ] ) ? (int)$_POST[ 'ftphostport' ] : 21 );
121
+ BackWPup_Option::update( $id, 'ftptimeout', ! empty( $_POST[ 'ftptimeout' ] ) ? (int)$_POST[ 'ftptimeout' ] : 90 );
122
+ BackWPup_Option::update( $id, 'ftpuser', isset( $_POST[ 'ftpuser' ] ) ? $_POST[ 'ftpuser' ] : '' );
123
+ BackWPup_Option::update( $id, 'ftppass', isset( $_POST[ 'ftppass' ] ) ? BackWPup_Encryption::encrypt( $_POST[ 'ftppass' ] ) : '' );
124
+
125
+ if ( ! empty( $_POST[ 'ftpdir' ] ) )
126
+ $_POST[ 'ftpdir' ] = trailingslashit( str_replace( '//', '/', str_replace( '\\', '/', trim( stripslashes( $_POST[ 'ftpdir' ] ) ) ) ) );
127
+ BackWPup_Option::update( $id, 'ftpdir', $_POST[ 'ftpdir' ] );
128
+
129
+ BackWPup_Option::update( $id, 'ftpmaxbackups', isset( $_POST[ 'ftpmaxbackups' ] ) ? (int)$_POST[ 'ftpmaxbackups' ] : 0 );
130
+
131
+ if ( function_exists( 'ftp_ssl_connect' ) )
132
+ BackWPup_Option::update( $id, 'ftpssl', ( isset( $_POST[ 'ftpssl' ] ) && $_POST[ 'ftpssl' ] == 1 ) ? TRUE : FALSE );
133
+ else
134
+ BackWPup_Option::update( $id, 'ftpssl', FALSE );
135
+
136
+ BackWPup_Option::update( $id, 'ftppasv', ( isset( $_POST[ 'ftppasv' ] ) && $_POST[ 'ftppasv' ] == 1 ) ? TRUE : FALSE );
137
+ }
138
+
139
+ /**
140
+ * @param $jobdest
141
+ * @param $backupfile
142
+ */
143
+ public function file_delete( $jobdest, $backupfile ) {
144
+
145
+ $files = get_site_transient( 'backwpup_'. strtolower( $jobdest ), FALSE );
146
+ list( $jobid, $dest ) = explode( '_', $jobdest );
147
+
148
+ if ( BackWPup_Option::get( $jobid, 'ftphost' ) && BackWPup_Option::get( $jobid, 'ftpuser' ) && BackWPup_Option::get( $jobid, 'ftppass' ) && function_exists( 'ftp_connect' ) ) {
149
+ $ftp_conn_id = FALSE;
150
+ if ( function_exists( 'ftp_ssl_connect' ) && BackWPup_Option::get( $jobid, 'ftpssl' ) ) { //make SSL FTP connection
151
+ $ftp_conn_id = ftp_ssl_connect( BackWPup_Option::get( $jobid, 'ftphost' ), BackWPup_Option::get( $jobid, 'ftphostport' ), BackWPup_Option::get( $jobid, 'ftptimeout' ) );
152
+ }
153
+ elseif ( ! BackWPup_Option::get( $jobid, 'ftpssl' ) ) { //make normal FTP conection if SSL not work
154
+ $ftp_conn_id = ftp_connect( BackWPup_Option::get( $jobid, 'ftphost' ), BackWPup_Option::get( $jobid, 'ftphostport' ), BackWPup_Option::get( $jobid, 'ftptimeout' ) );
155
+ }
156
+ $loginok = FALSE;
157
+ if ( $ftp_conn_id ) {
158
+ //FTP Login
159
+ if ( @ftp_login( $ftp_conn_id, BackWPup_Option::get( $jobid, 'ftpuser' ), BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'ftppass' ) ) ) ) {
160
+ $loginok = TRUE;
161
+ }
162
+ else { //if PHP ftp login don't work use raw login
163
+ ftp_raw( $ftp_conn_id, 'USER ' . BackWPup_Option::get( $jobid, 'ftpuser' ) );
164
+ $return = ftp_raw( $ftp_conn_id, 'PASS ' . BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'ftppass' ) ) );
165
+ if ( substr( trim( $return[ 0 ] ), 0, 3 ) <= 400 )
166
+ $loginok = TRUE;
167
+ }
168
+ }
169
+ if ( $loginok ) {
170
+ ftp_pasv( $ftp_conn_id, BackWPup_Option::get( $jobid, 'ftppasv' ) );
171
+ ftp_delete( $ftp_conn_id, $backupfile );
172
+ //update file list
173
+ foreach ( $files as $key => $file ) {
174
+ if ( is_array( $file ) && $file[ 'file' ] == $backupfile )
175
+ unset( $files[ $key ] );
176
+ }
177
+ }
178
+ else {
179
+ BackWPup_Admin::message( __( 'FTP: Login failure!', 'backwpup' ), TRUE );
180
+ }
181
+ }
182
+
183
+ set_site_transient( 'backwpup_'. strtolower( $jobdest ), $files, 60 * 60 * 24 * 7 );
184
+ }
185
+
186
+ /**
187
+ * @param $jobdest
188
+ * @return mixed
189
+ */
190
+ public function file_get_list( $jobdest ) {
191
+
192
+ return get_site_transient( 'backwpup_' . strtolower( $jobdest ) );
193
+ }
194
+
195
+ /**
196
+ * @param $job_object
197
+ * @return bool
198
+ */
199
+ public function job_run_archive( &$job_object ) {
200
+
201
+ $job_object->substeps_todo = 2 + $job_object->backup_filesize;
202
+ if ( $job_object->steps_data[ $job_object->step_working ]['SAVE_STEP_TRY'] != $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] )
203
+ $job_object->log( sprintf( __( '%d. Try to send backup file to an FTP server&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ), E_USER_NOTICE );
204
+
205
+ if ( ! empty( $job_object->job[ 'ftpssl' ] ) ) { //make SSL FTP connection
206
+ if ( function_exists( 'ftp_ssl_connect' ) ) {
207
+ $ftp_conn_id = ftp_ssl_connect( $job_object->job[ 'ftphost' ], $job_object->job[ 'ftphostport' ], $job_object->job[ 'ftptimeout' ] );
208
+ if ( $ftp_conn_id )
209
+ $job_object->log( sprintf( __( 'Connected via explicit SSL-FTP to server: %s', 'backwpup' ), $job_object->job[ 'ftphost' ] . ':' . $job_object->job[ 'ftphostport' ] ), E_USER_NOTICE );
210
+ else {
211
+ $job_object->log( sprintf( __( 'Cannot connect via explicit SSL-FTP to server: %s', 'backwpup' ), $job_object->job[ 'ftphost' ] . ':' . $job_object->job[ 'ftphostport' ] ), E_USER_ERROR );
212
+
213
+ return FALSE;
214
+ }
215
+ }
216
+ else {
217
+ $job_object->log( __( 'PHP function to connect with explicit SSL-FTP to server does not exist!', 'backwpup' ), E_USER_ERROR );
218
+
219
+ return TRUE;
220
+ }
221
+ }
222
+ else { //make normal FTP connection if SSL not work
223
+ $ftp_conn_id = ftp_connect( $job_object->job[ 'ftphost' ], $job_object->job[ 'ftphostport' ], $job_object->job[ 'ftptimeout' ] );
224
+ if ( $ftp_conn_id )
225
+ $job_object->log( sprintf( __( 'Connected to FTP server: %s', 'backwpup' ), $job_object->job[ 'ftphost' ] . ':' . $job_object->job[ 'ftphostport' ] ), E_USER_NOTICE );
226
+ else {
227
+ $job_object->log( sprintf( __( 'Cannot connect to FTP server: %s', 'backwpup' ), $job_object->job[ 'ftphost' ] . ':' . $job_object->job[ 'ftphostport' ] ), E_USER_ERROR );
228
+
229
+ return FALSE;
230
+ }
231
+ }
232
+
233
+ //FTP Login
234
+ $job_object->log( sprintf( __( 'FTP client command: %s', 'backwpup' ), 'USER ' . $job_object->job[ 'ftpuser' ] ), E_USER_NOTICE );
235
+ if ( $loginok = @ftp_login( $ftp_conn_id, $job_object->job[ 'ftpuser' ], BackWPup_Encryption::decrypt( $job_object->job[ 'ftppass' ] ) ) ) {
236
+ $job_object->log( sprintf( __( 'FTP server response: %s', 'backwpup' ), 'User ' . $job_object->job[ 'ftpuser' ] . ' logged in.' ), E_USER_NOTICE );
237
+ }
238
+ else { //if PHP ftp login don't work use raw login
239
+ $return = ftp_raw( $ftp_conn_id, 'USER ' . $job_object->job[ 'ftpuser' ] );
240
+ $job_object->log( sprintf( __( 'FTP server reply: %s', 'backwpup' ), $return[ 0 ] ), E_USER_NOTICE );
241
+ if ( substr( trim( $return[ 0 ] ), 0, 3 ) <= 400 ) {
242
+ $job_object->log( sprintf( __( 'FTP client command: %s', 'backwpup' ), 'PASS *******' ), E_USER_NOTICE );
243
+ $return = ftp_raw( $ftp_conn_id, 'PASS ' . BackWPup_Encryption::decrypt( $job_object->job[ 'ftppass' ] ) );
244
+ $job_object->log( sprintf( __( 'FTP server reply: %s', 'backwpup' ), $return[ 0 ] ), E_USER_NOTICE );
245
+ if ( substr( trim( $return[ 0 ] ), 0, 3 ) <= 400 )
246
+ $loginok = TRUE;
247
+ }
248
+ }
249
+ if ( ! $loginok )
250
+ return FALSE;
251
+
252
+ //SYSTYPE
253
+ $job_object->log( sprintf( __( 'FTP client command: %s', 'backwpup' ), 'SYST' ), E_USER_NOTICE );
254
+ $systype = ftp_systype( $ftp_conn_id );
255
+ if ( $systype )
256
+ $job_object->log( sprintf( __( 'FTP server reply: %s', 'backwpup' ), $systype ), E_USER_NOTICE );
257
+ else
258
+ $job_object->log( sprintf( __( 'FTP server reply: %s', 'backwpup' ), __( 'Error getting SYSTYPE', 'backwpup' ) ), E_USER_ERROR );
259
+
260
+ //set actual ftp dir to ftp dir
261
+ if ( empty( $job_object->job[ 'ftpdir' ] ) )
262
+ $job_object->job[ 'ftpdir' ] = trailingslashit( ftp_pwd( $ftp_conn_id ) );
263
+ // prepend actual ftp dir if relative dir
264
+ if ( substr( $job_object->job[ 'ftpdir' ], 0, 1 ) != '/' )
265
+ $job_object->job[ 'ftpdir' ] = trailingslashit( ftp_pwd( $ftp_conn_id ) ) . $job_object->job[ 'ftpdir' ];
266
+
267
+ //test ftp dir and create it if not exists
268
+ if ( $job_object->job[ 'ftpdir' ] != '/' ) {
269
+ @ftp_chdir( $ftp_conn_id, '/' ); //go to root
270
+ $ftpdirs = explode( '/', trim( $job_object->job[ 'ftpdir' ], '/' ) );
271
+ foreach ( $ftpdirs as $ftpdir ) {
272
+ if ( empty( $ftpdir ) )
273
+ continue;
274
+ if ( ! @ftp_chdir( $ftp_conn_id, $ftpdir ) ) {
275
+ if ( @ftp_mkdir( $ftp_conn_id, $ftpdir ) ) {
276
+ $job_object->log( sprintf( __( 'FTP Folder "%s" created!', 'backwpup' ), $ftpdir ), E_USER_NOTICE );
277
+ ftp_chdir( $ftp_conn_id, $ftpdir );
278
+ }
279
+ else {
280
+ $job_object->log( sprintf( __( 'FTP Folder "%s" cannot be created!', 'backwpup' ), $ftpdir ), E_USER_ERROR );
281
+
282
+ return FALSE;
283
+ }
284
+ }
285
+ }
286
+ }
287
+
288
+ // Get the current working directory
289
+ $current_ftp_dir = trailingslashit( ftp_pwd( $ftp_conn_id ) );
290
+ if ( $job_object->substeps_done == 0 )
291
+ $job_object->log( sprintf( __( 'FTP current folder is: %s', 'backwpup' ), $current_ftp_dir ), E_USER_NOTICE );
292
+
293
+ //get file size to resume upload
294
+ @clearstatcache();
295
+ $job_object->substeps_done = @ftp_size( $ftp_conn_id, $job_object->job[ 'ftpdir' ] . $job_object->backup_file );
296
+ if ( $job_object->substeps_done == -1 )
297
+ $job_object->substeps_done = 0;
298
+
299
+ //PASV
300
+ $job_object->log( sprintf( __( 'FTP client command: %s', 'backwpup' ), 'PASV' ), E_USER_NOTICE );
301
+ if ( $job_object->job[ 'ftppasv' ] ) {
302
+ if ( ftp_pasv( $ftp_conn_id, TRUE ) )
303
+ $job_object->log( sprintf( __( 'FTP server reply: %s', 'backwpup' ), __( 'Entering passive mode', 'backwpup' ) ), E_USER_NOTICE );
304
+ else
305
+ $job_object->log( sprintf( __( 'FTP server reply: %s', 'backwpup' ), __( 'Cannot enter passive mode', 'backwpup' ) ), E_USER_WARNING );
306
+ }
307
+ else {
308
+ if ( ftp_pasv( $ftp_conn_id, FALSE ) )
309
+ $job_object->log( sprintf( __( 'FTP server reply: %s', 'backwpup' ), __( 'Entering normal mode', 'backwpup' ) ), E_USER_NOTICE );
310
+ else
311
+ $job_object->log( sprintf( __( 'FTP server reply: %s', 'backwpup' ), __( 'Cannot enter normal mode', 'backwpup' ) ), E_USER_WARNING );
312
+ }
313
+
314
+ if ( $job_object->substeps_done < $job_object->backup_filesize ) {
315
+ $job_object->log( __( 'Starting upload to FTP &#160;&hellip;', 'backwpup' ), E_USER_NOTICE );
316
+ $fp = fopen( $job_object->backup_folder . $job_object->backup_file, 'r' );
317
+ //go to actual file pos
318
+ fseek( $fp, $job_object->substeps_done );
319
+ $ret = ftp_nb_fput( $ftp_conn_id, $current_ftp_dir . $job_object->backup_file, $fp, FTP_BINARY, $job_object->substeps_done );
320
+ while ( $ret == FTP_MOREDATA ) {
321
+ $job_object->substeps_done = ftell( $fp );
322
+ $job_object->update_working_data();
323
+ $job_object->do_restart_time();
324
+ $ret = ftp_nb_continue( $ftp_conn_id );
325
+ }
326
+ if ( $ret != FTP_FINISHED ) {
327
+ $job_object->log( __( 'Cannot transfer backup to FTP server!', 'backwpup' ), E_USER_ERROR );
328
+
329
+ return FALSE;
330
+ }
331
+ else {
332
+ $job_object->substeps_done = $job_object->backup_filesize + 1;
333
+ $job_object->log( sprintf( __( 'Backup transferred to FTP server: %s', 'backwpup' ), $current_ftp_dir . $job_object->backup_file ), E_USER_NOTICE );
334
+ if ( ! empty( $job_object->job[ 'jobid' ] ) )
335
+ BackWPup_Option::update( $job_object->job[ 'jobid' ], 'lastbackupdownloadurl', "ftp://" . $job_object->job[ 'ftpuser' ] . ":" . BackWPup_Encryption::decrypt( $job_object->job[ 'ftppass' ] ) . "@" . $job_object->job[ 'ftphost' ] . ':' . $job_object->job[ 'ftphostport' ] . $current_ftp_dir . $job_object->backup_file );
336
+ }
337
+ fclose( $fp );
338
+ }
339
+
340
+ $backupfilelist = array();
341
+ $filecounter = 0;
342
+ $files = array();
343
+ if ( $filelist = ftp_nlist( $ftp_conn_id, '.' ) ) {
344
+ foreach ( $filelist as $file ) {
345
+ if ( basename( $file ) != '.' && basename( $file ) != '..' ) {
346
+ if ( $job_object->is_backup_archive( $file ) ) {
347
+ $time = ftp_mdtm( $ftp_conn_id, $file );
348
+ if ( $time != - 1 )
349
+ $backupfilelist[ $time ] = basename( $file );
350
+ else
351
+ $backupfilelist[ ] = basename( $file );
352
+ }
353
+ $files[ $filecounter ][ 'folder' ] = 'ftp://' . $job_object->job[ 'ftphost' ] . ':' . $job_object->job[ 'ftphostport' ] . $job_object->job[ 'ftpdir' ];
354
+ $files[ $filecounter ][ 'file' ] = $job_object->job[ 'ftpdir' ] . basename( $file );
355
+ $files[ $filecounter ][ 'filename' ] = basename( $file );
356
+ $files[ $filecounter ][ 'downloadurl' ] = 'ftp://' . rawurlencode( $job_object->job[ 'ftpuser' ] ) . ':' . rawurlencode( BackWPup_Encryption::decrypt( $job_object->job[ 'ftppass' ] ) ) . '@' . $job_object->job[ 'ftphost' ] . ':' . $job_object->job[ 'ftphostport' ] . $job_object->job[ 'ftpdir' ] . basename( $file );
357
+ $files[ $filecounter ][ 'filesize' ] = ftp_size( $ftp_conn_id, $file );
358
+ $files[ $filecounter ][ 'time' ] = ftp_mdtm( $ftp_conn_id, $file );
359
+ $filecounter ++;
360
+ }
361
+ }
362
+ }
363
+
364
+ if ( ! empty( $job_object->job[ 'ftpmaxbackups' ] ) && $job_object->job[ 'ftpmaxbackups' ] > 0 ) { //Delete old backups
365
+ if ( count( $backupfilelist ) > $job_object->job[ 'ftpmaxbackups' ] ) {
366
+ ksort( $backupfilelist );
367
+ $numdeltefiles = 0;
368
+ while ( $file = array_shift( $backupfilelist ) ) {
369
+ if ( count( $backupfilelist ) < $job_object->job[ 'ftpmaxbackups' ] )
370
+ break;
371
+ if ( ftp_delete( $ftp_conn_id, $file ) ) { //delete files on ftp
372
+ foreach ( $files as $key => $filedata ) {
373
+ if ( $filedata[ 'file' ] == $job_object->job[ 'ftpdir' ] . $file )
374
+ unset( $files[ $key ] );
375
+ }
376
+ $numdeltefiles ++;
377
+ }
378
+ else
379
+ $job_object->log( sprintf( __( 'Cannot delete "%s" on FTP server!', 'backwpup' ), $job_object->job[ 'ftpdir' ] . $file ), E_USER_ERROR );
380
+ }
381
+ if ( $numdeltefiles > 0 )
382
+ $job_object->log( sprintf( _n( 'One file deleted on FTP server', '%d files deleted on FTP server', $numdeltefiles, 'backwpup' ), $numdeltefiles ), E_USER_NOTICE );
383
+ }
384
+ }
385
+ set_site_transient( 'backwpup_' . $job_object->job[ 'jobid' ] . '_ftp', $files, 60 * 60 * 24 * 7 );
386
+
387
+ ftp_close( $ftp_conn_id );
388
+
389
+ return TRUE;
390
+ }
391
+
392
+ /**
393
+ * @param $job_object
394
+ * @return bool
395
+ */
396
+ public function can_run( $job_object ) {
397
+
398
+ if ( empty( $job_object->job[ 'ftphost' ] ) )
399
+ return FALSE;
400
+
401
+ if ( empty( $job_object->job[ 'ftpuser' ] ) )
402
+ return FALSE;
403
+
404
+ if ( empty( $job_object->job[ 'ftppass' ] ) )
405
+ return FALSE;
406
+
407
+ return TRUE;
408
+ }
409
+
410
+ }
inc/class-destination-msazure.php CHANGED
@@ -1,9 +1,7 @@
1
  <?php
2
- // Windows Azure SDK v0.3.1_2011-08
3
  // http://www.windowsazure.com/en-us/develop/php/
4
  // https://github.com/WindowsAzure/azure-sdk-for-php
5
- if ( ! class_exists( 'HTTP_Request2' ) )
6
- set_include_path( get_include_path() . PATH_SEPARATOR . BackWPup::get_plugin_data( 'plugindir' ) .'/vendor/PEAR/');
7
 
8
  /**
9
  * Documentation: http://www.windowsazure.com/en-us/develop/php/how-to-guides/blob-service/
@@ -118,6 +116,7 @@ class BackWPup_Destination_MSAzure extends BackWPup_Destinations {
118
  //create a new container
119
  if ( ! empty( $_POST[ 'newmsazurecontainer' ] ) && ! empty( $_POST[ 'msazureaccname' ] ) && ! empty( $_POST[ 'msazurekey' ] ) ) {
120
  try {
 
121
  $blobRestProxy = WindowsAzure\Common\ServicesBuilder::getInstance()->createBlobService( 'DefaultEndpointsProtocol=https;AccountName=' . $_POST[ 'msazureaccname' ] . ';AccountKey=' . $_POST[ 'msazurekey' ] );
122
  $container_options = new WindowsAzure\Blob\Models\CreateContainerOptions();
123
  $container_options->setPublicAccess( WindowsAzure\Blob\Models\PublicAccessType::NONE );
@@ -143,6 +142,7 @@ class BackWPup_Destination_MSAzure extends BackWPup_Destinations {
143
 
144
  if ( BackWPup_Option::get( $jobid, 'msazureaccname' ) && BackWPup_Option::get( $jobid, 'msazurekey' ) && BackWPup_Option::get( $jobid, 'msazurecontainer' ) ) {
145
  try {
 
146
  $blobRestProxy = WindowsAzure\Common\ServicesBuilder::getInstance()->createBlobService( 'DefaultEndpointsProtocol=https;AccountName=' . BackWPup_Option::get( $jobid, 'msazureaccname' ) . ';AccountKey=' . BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'msazurekey' ) ) );
147
  $blobRestProxy->deleteBlob( BackWPup_Option::get( $jobid, 'msazurecontainer' ), $backupfile );
148
  //update file list
@@ -165,6 +165,7 @@ class BackWPup_Destination_MSAzure extends BackWPup_Destinations {
165
  */
166
  public function file_download( $jobid, $get_file ) {
167
  try {
 
168
  $blobRestProxy = WindowsAzure\Common\ServicesBuilder::getInstance()->createBlobService( 'DefaultEndpointsProtocol=https;AccountName=' . BackWPup_Option::get( $jobid, 'msazureaccname' ) . ';AccountKey=' . BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'msazurekey' ) ) );
169
  $blob = $blobRestProxy->getBlob( BackWPup_Option::get( $jobid, 'msazurecontainer' ), $get_file );
170
  header( "Pragma: public" );
@@ -174,7 +175,7 @@ class BackWPup_Destination_MSAzure extends BackWPup_Destinations {
174
  header( "Content-Disposition: attachment; filename=" . basename( $get_file ) . ";" );
175
  header( "Content-Transfer-Encoding: binary" );
176
  header( "Content-Length: " . $blob->getProperties()->getContentLength() );
177
- @set_time_limit( 0 );
178
  fpassthru( $blob->getContentStream() );
179
  die();
180
  }
@@ -203,7 +204,7 @@ class BackWPup_Destination_MSAzure extends BackWPup_Destinations {
203
  $job_object->log( sprintf( __( '%d. Try sending backup to a Microsoft Azure (Blob)&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ), E_USER_NOTICE );
204
 
205
  try {
206
-
207
  /* @var $blobRestProxy WindowsAzure\Blob\BlobRestProxy */ //https causes an error SSL: Connection reset by peer that is why http
208
  $blobRestProxy = WindowsAzure\Common\ServicesBuilder::getInstance()->createBlobService('DefaultEndpointsProtocol=http;AccountName=' . $job_object->job[ 'msazureaccname' ] . ';AccountKey=' . BackWPup_Encryption::decrypt( $job_object->job[ 'msazurekey' ] ) );
209
 
@@ -272,7 +273,7 @@ class BackWPup_Destination_MSAzure extends BackWPup_Destinations {
272
  $job_object->log( E_USER_ERROR, sprintf( __( 'Microsoft Azure API: %s', 'backwpup' ), htmlentities( $e->getMessage() ) ), $e->getFile(), $e->getLine() );
273
  $job_object->substeps_done = 0;
274
  unset( $job_object->steps_data[ $job_object->step_working ][ 'BlockList' ] );
275
- if ( is_resource( $file_handel ) )
276
  fclose( $file_handel );
277
 
278
  return FALSE;
@@ -401,6 +402,7 @@ class BackWPup_Destination_MSAzure extends BackWPup_Destinations {
401
 
402
  if ( ! empty( $args[ 'msazureaccname' ] ) && ! empty( $args[ 'msazurekey' ] ) ) {
403
  try {
 
404
  $blobRestProxy = WindowsAzure\Common\ServicesBuilder::getInstance()->createBlobService( 'DefaultEndpointsProtocol=https;AccountName=' . $args[ 'msazureaccname' ] . ';AccountKey=' . BackWPup_Encryption::decrypt( $args[ 'msazurekey' ] ) );
405
  $containers = $blobRestProxy->listContainers()->getContainers();
406
  }
1
  <?php
2
+ // Windows Azure SDK v0.4.0_2014-01
3
  // http://www.windowsazure.com/en-us/develop/php/
4
  // https://github.com/WindowsAzure/azure-sdk-for-php
 
 
5
 
6
  /**
7
  * Documentation: http://www.windowsazure.com/en-us/develop/php/how-to-guides/blob-service/
116
  //create a new container
117
  if ( ! empty( $_POST[ 'newmsazurecontainer' ] ) && ! empty( $_POST[ 'msazureaccname' ] ) && ! empty( $_POST[ 'msazurekey' ] ) ) {
118
  try {
119
+ set_include_path( get_include_path() . PATH_SEPARATOR . BackWPup::get_plugin_data( 'plugindir' ) .'/vendor/PEAR/');
120
  $blobRestProxy = WindowsAzure\Common\ServicesBuilder::getInstance()->createBlobService( 'DefaultEndpointsProtocol=https;AccountName=' . $_POST[ 'msazureaccname' ] . ';AccountKey=' . $_POST[ 'msazurekey' ] );
121
  $container_options = new WindowsAzure\Blob\Models\CreateContainerOptions();
122
  $container_options->setPublicAccess( WindowsAzure\Blob\Models\PublicAccessType::NONE );
142
 
143
  if ( BackWPup_Option::get( $jobid, 'msazureaccname' ) && BackWPup_Option::get( $jobid, 'msazurekey' ) && BackWPup_Option::get( $jobid, 'msazurecontainer' ) ) {
144
  try {
145
+ set_include_path( get_include_path() . PATH_SEPARATOR . BackWPup::get_plugin_data( 'plugindir' ) .'/vendor/PEAR/');
146
  $blobRestProxy = WindowsAzure\Common\ServicesBuilder::getInstance()->createBlobService( 'DefaultEndpointsProtocol=https;AccountName=' . BackWPup_Option::get( $jobid, 'msazureaccname' ) . ';AccountKey=' . BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'msazurekey' ) ) );
147
  $blobRestProxy->deleteBlob( BackWPup_Option::get( $jobid, 'msazurecontainer' ), $backupfile );
148
  //update file list
165
  */
166
  public function file_download( $jobid, $get_file ) {
167
  try {
168
+ set_include_path( get_include_path() . PATH_SEPARATOR . BackWPup::get_plugin_data( 'plugindir' ) .'/vendor/PEAR/');
169
  $blobRestProxy = WindowsAzure\Common\ServicesBuilder::getInstance()->createBlobService( 'DefaultEndpointsProtocol=https;AccountName=' . BackWPup_Option::get( $jobid, 'msazureaccname' ) . ';AccountKey=' . BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'msazurekey' ) ) );
170
  $blob = $blobRestProxy->getBlob( BackWPup_Option::get( $jobid, 'msazurecontainer' ), $get_file );
171
  header( "Pragma: public" );
175
  header( "Content-Disposition: attachment; filename=" . basename( $get_file ) . ";" );
176
  header( "Content-Transfer-Encoding: binary" );
177
  header( "Content-Length: " . $blob->getProperties()->getContentLength() );
178
+ @set_time_limit( 300 );
179
  fpassthru( $blob->getContentStream() );
180
  die();
181
  }
204
  $job_object->log( sprintf( __( '%d. Try sending backup to a Microsoft Azure (Blob)&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ), E_USER_NOTICE );
205
 
206
  try {
207
+ set_include_path( get_include_path() . PATH_SEPARATOR . BackWPup::get_plugin_data( 'plugindir' ) .'/vendor/PEAR/');
208
  /* @var $blobRestProxy WindowsAzure\Blob\BlobRestProxy */ //https causes an error SSL: Connection reset by peer that is why http
209
  $blobRestProxy = WindowsAzure\Common\ServicesBuilder::getInstance()->createBlobService('DefaultEndpointsProtocol=http;AccountName=' . $job_object->job[ 'msazureaccname' ] . ';AccountKey=' . BackWPup_Encryption::decrypt( $job_object->job[ 'msazurekey' ] ) );
210
 
273
  $job_object->log( E_USER_ERROR, sprintf( __( 'Microsoft Azure API: %s', 'backwpup' ), htmlentities( $e->getMessage() ) ), $e->getFile(), $e->getLine() );
274
  $job_object->substeps_done = 0;
275
  unset( $job_object->steps_data[ $job_object->step_working ][ 'BlockList' ] );
276
+ if ( isset( $file_handel ) && is_resource( $file_handel ) )
277
  fclose( $file_handel );
278
 
279
  return FALSE;
402
 
403
  if ( ! empty( $args[ 'msazureaccname' ] ) && ! empty( $args[ 'msazurekey' ] ) ) {
404
  try {
405
+ set_include_path( get_include_path() . PATH_SEPARATOR . BackWPup::get_plugin_data( 'plugindir' ) .'/vendor/PEAR/');
406
  $blobRestProxy = WindowsAzure\Common\ServicesBuilder::getInstance()->createBlobService( 'DefaultEndpointsProtocol=https;AccountName=' . $args[ 'msazureaccname' ] . ';AccountKey=' . BackWPup_Encryption::decrypt( $args[ 'msazurekey' ] ) );
407
  $containers = $blobRestProxy->listContainers()->getContainers();
408
  }
inc/class-destination-rsc.php CHANGED
@@ -1,466 +1,465 @@
1
- <?php
2
- // Rackspace OpenCloud SDK v1.7.3
3
- // http://www.rackspace.com/cloud/files/
4
- // https://github.com/rackspace/php-opencloud
5
-
6
- /**
7
- *
8
- */
9
- class BackWPup_Destination_RSC extends BackWPup_Destinations {
10
-
11
-
12
- /**
13
- * @return array
14
- */
15
- public function option_defaults() {
16
-
17
- return array( 'rscusername' => '', 'rscapikey' => '', 'rsccontainer' => '', 'rscregion' => 'DFW', 'rscdir' => trailingslashit( sanitize_file_name( get_bloginfo( 'name' ) ) ), 'rscmaxbackups' => 15, 'rscsyncnodelete' => TRUE );
18
- }
19
-
20
- /**
21
- * Get Auht url by region code
22
- *
23
- * @param $region region code
24
- * @return string
25
- */
26
- public static function get_auth_url_by_region( $region ) {
27
-
28
- $region = strtoupper( $region );
29
-
30
- if ( $region == 'LON' )
31
- return RACKSPACE_UK;
32
-
33
- return RACKSPACE_US;
34
- }
35
-
36
- /**
37
- * @param $jobid
38
- */
39
- public function edit_tab( $jobid ) {
40
- ?>
41
- <h3 class="title"><?php _e( 'Rack Space Cloud Keys', 'backwpup' ); ?></h3>
42
- <p></p>
43
- <table class="form-table">
44
- <tr>
45
- <th scope="row"><label for="rscusername"><?php _e( 'Username', 'backwpup' ); ?></label></th>
46
- <td>
47
- <input id="rscusername" name="rscusername" type="text"
48
- value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'rscusername' ) );?>" class="regular-text" autocomplete="off" />
49
- </td>
50
- </tr>
51
- <tr>
52
- <th scope="row"><label for="rscapikey"><?php _e( 'API Key', 'backwpup' ); ?></label></th>
53
- <td>
54
- <input id="rscapikey" name="rscapikey" type="password"
55
- value="<?php echo esc_attr( BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'rscapikey' ) ) ); ?>" class="regular-text" autocomplete="off" />
56
- </td>
57
- </tr>
58
- </table>
59
-
60
- <h3 class="title"><?php _e( 'Select region', 'backwpup' ); ?></h3>
61
- <p></p>
62
- <table class="form-table">
63
- <tr>
64
- <th scope="row"><label for="rscregion"><?php _e( 'Rackspace Cloud Files Region', 'backwpup' ); ?></label></th>
65
- <td>
66
- <select name="rscregion" id="rscregion" title="<?php _e( 'Rackspace Cloud Files Region', 'backwpup' ); ?>">
67
- <option value="DFW" <?php selected( 'DFW', BackWPup_Option::get( $jobid, 'rscregion' ), TRUE ) ?>><?php _e( 'Dallas (DFW)', 'backwpup' ); ?></option>
68
- <option value="ORD" <?php selected( 'ORD', BackWPup_Option::get( $jobid, 'rscregion' ), TRUE ) ?>><?php _e( 'Chicago (ORD)', 'backwpup' ); ?></option>
69
- <option value="SYD" <?php selected( 'SYD', BackWPup_Option::get( $jobid, 'rscregion' ), TRUE ) ?>><?php _e( 'Sydney (SYD)', 'backwpup' ); ?></option>
70
- <option value="LON" <?php selected( 'LON', BackWPup_Option::get( $jobid, 'rscregion' ), TRUE ) ?>><?php _e( 'London (LON)', 'backwpup' ); ?></option>
71
- <option value="IAD" <?php selected( 'IAD', BackWPup_Option::get( $jobid, 'rscregion' ), TRUE ) ?>><?php _e( 'Northern Virginia (IAD)', 'backwpup' ); ?></option>
72
- <option value="HKG" <?php selected( 'HKG', BackWPup_Option::get( $jobid, 'rscregion' ), TRUE ) ?>><?php _e( 'Hong Kong (HKG)', 'backwpup' ); ?></option>
73
- </select><br/>
74
- </td>
75
- </tr>
76
- <tr>
77
- <th scope="row"><label for="rsccontainerselected"><?php _e( 'Container selection', 'backwpup' ); ?></label></th>
78
- <td>
79
- <input id="rsccontainerselected" name="rsccontainerselected" type="hidden" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'rsccontainer' ) ); ?>" />
80
- <?php if ( BackWPup_Option::get( $jobid, 'rscusername' ) && BackWPup_Option::get( $jobid, 'rscapikey' ) ) $this->edit_ajax( array(
81
- 'rscusername' => BackWPup_Option::get( $jobid, 'rscusername' ),
82
- 'rscregion' => BackWPup_Option::get( $jobid, 'rscregion' ),
83
- 'rscapikey' => BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'rscapikey' ) ),
84
- 'rscselected' => BackWPup_Option::get( $jobid, 'rsccontainer' )
85
- ) ); ?>
86
- </td>
87
- </tr>
88
- <tr>
89
- <th scope="row"><label for="idnewrsccontainer"><?php _e( 'Create a new container', 'backwpup' ); ?></label></th>
90
- <td>
91
- <input id="idnewrsccontainer" name="newrsccontainer" type="text" value="" class="text" />
92
- </td>
93
- </tr>
94
- </table>
95
-
96
- <h3 class="title"><?php _e( 'Backup settings', 'backwpup' ); ?></h3>
97
- <p></p>
98
- <table class="form-table">
99
- <tr>
100
- <th scope="row"><label for="idrscdir"><?php _e( 'Folder in bucket', 'backwpup' ); ?></label></th>
101
- <td>
102
- <input id="idrscdir" name="rscdir" type="text" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'rscdir' ) ); ?>" class="regular-text" />
103
- </td>
104
- </tr>
105
- <tr>
106
- <th scope="row"><?php _e( 'File deletion', 'backwpup' ); ?></th>
107
- <td>
108
- <?php
109
- if ( BackWPup_Option::get( $jobid, 'backuptype' ) == 'archive' ) {
110
- ?>
111
- <label for="idrscmaxbackups"><input id="idrscmaxbackups" name="rscmaxbackups" type="text" size="3" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'rscmaxbackups' ) ); ?>" class="small-text help-tip" title="<?php esc_attr_e( 'Oldest files will be deleted first. 0 = no deletion', 'backwpup' ); ?>" />&nbsp;
112
- <?php _e( 'Number of files to keep in folder.', 'backwpup' ); ?></label>
113
- <?php } else { ?>
114
- <label for="idrscsyncnodelete"><input class="checkbox" value="1"
115
- type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'rscsyncnodelete' ), TRUE ); ?>
116
- name="rscsyncnodelete" id="idrscsyncnodelete" /> <?php _e( 'Do not delete files while syncing to destination!', 'backwpup' ); ?></label>
117
- <?php } ?>
118
- </td>
119
- </tr>
120
- </table>
121
- <?php
122
- }
123
-
124
- /**
125
- * @param $id
126
- */
127
- public function edit_form_post_save( $id ) {
128
-
129
- BackWPup_Option::update( $id, 'rscusername', isset( $_POST[ 'rscusername' ] ) ? $_POST[ 'rscusername' ] : '' );
130
- BackWPup_Option::update( $id, 'rscapikey', isset( $_POST[ 'rscapikey' ] ) ? BackWPup_Encryption::encrypt( $_POST[ 'rscapikey' ] ) : '' );
131
- BackWPup_Option::update( $id, 'rsccontainer', isset( $_POST[ 'rsccontainer' ] ) ? $_POST[ 'rsccontainer' ] : '' );
132
- BackWPup_Option::update( $id, 'rscregion', ! empty( $_POST[ 'rscregion' ] ) ? $_POST[ 'rscregion' ] : 'DFW' );
133
-
134
- $_POST[ 'rscdir' ] = trailingslashit( str_replace( '//', '/', str_replace( '\\', '/', trim( stripslashes( $_POST[ 'rscdir' ] ) ) ) ) );
135
- if ( substr( $_POST[ 'rscdir' ], 0, 1 ) == '/' )
136
- $_POST[ 'rscdir' ] = substr( $_POST[ 'rscdir' ], 1 );
137
- if ( $_POST[ 'rscdir' ] == '/' )
138
- $_POST[ 'rscdir' ] = '';
139
- BackWPup_Option::update( $id, 'rscdir', $_POST[ 'rscdir' ] );
140
-
141
- BackWPup_Option::update( $id, 'rscmaxbackups', isset( $_POST[ 'rscmaxbackups' ] ) ? (int)$_POST[ 'rscmaxbackups' ] : 0 );
142
- BackWPup_Option::update( $id, 'rscsyncnodelete', ( isset( $_POST[ 'rscsyncnodelete' ] ) && $_POST[ 'rscsyncnodelete' ] == 1 ) ? TRUE : FALSE );
143
-
144
- if ( ! empty( $_POST[ 'rscusername' ] ) && ! empty( $_POST[ 'rscapikey' ] ) && ! empty( $_POST[ 'newrsccontainer' ] ) ) {
145
- try {
146
- $conn = new OpenCloud\Rackspace(
147
- self::get_auth_url_by_region( $_POST[ 'rscregion' ] ),
148
- array(
149
- 'username' => $_POST[ 'rscusername' ],
150
- 'apiKey' => $_POST[ 'rscapikey' ]
151
- ));
152
- $ostore = $conn->objectStoreService( 'cloudFiles' , $_POST[ 'rscregion' ], 'publicURL');
153
- $ostore->createContainer( $_POST[ 'newrsccontainer' ] );
154
- BackWPup_Option::update( $id, 'rsccontainer', $_POST[ 'newrsccontainer' ] );
155
- BackWPup_Admin::message( sprintf( __( 'Rackspace Cloud container "%s" created.', 'backwpup' ), $_POST[ 'newrsccontainer' ] ) );
156
-
157
- }
158
- catch ( Exception $e ) {
159
- BackWPup_Admin::message( sprintf( __( 'Rackspace Cloud API: %s', 'backwpup' ), $e->getMessage() ), TRUE );
160
- }
161
- }
162
- }
163
-
164
- /**
165
- * @param $jobdest
166
- * @param $backupfile
167
- */
168
- public function file_delete( $jobdest, $backupfile ) {
169
-
170
- $files = get_site_transient( 'backwpup_'. strtolower( $jobdest ), FALSE );
171
- list( $jobid, $dest ) = explode( '_', $jobdest );
172
-
173
- if ( BackWPup_Option::get( $jobid, 'rscusername' ) && BackWPup_Option::get( $jobid, 'rscapikey' ) && BackWPup_Option::get( $jobid, 'rsccontainer' ) ) {
174
- try {
175
- $conn = new OpenCloud\Rackspace(
176
- self::get_auth_url_by_region( BackWPup_Option::get( $jobid, 'rscregion' ) ),
177
- array(
178
- 'username' => BackWPup_Option::get( $jobid, 'rscusername' ),
179
- 'apiKey' => BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'rscapikey' ) )
180
- ));
181
- $conn->
182
- $ostore = $conn->objectStoreService( 'cloudFiles' , BackWPup_Option::get( $jobid, 'rscregion' ), 'publicURL');
183
- $container = $ostore->getContainer( BackWPup_Option::get( $jobid, 'rsccontainer' ) );
184
- $fileobject = $container->getObject( $backupfile );
185
- $fileobject->delete();
186
- //update file list
187
- foreach ( $files as $key => $file ) {
188
- if ( is_array( $file ) && $file[ 'file' ] == $backupfile )
189
- unset( $files[ $key ] );
190
- }
191
-
192
- }
193
- catch ( Exception $e ) {
194
- BackWPup_Admin::message( 'RSC: ' . $e->getMessage(), TRUE );
195
- }
196
- }
197
-
198
- set_site_transient( 'backwpup_'. strtolower( $jobdest ), $files, 60 * 60 * 24 * 7 );
199
- }
200
-
201
- /**
202
- * @param $jobid
203
- * @param $get_file
204
- */
205
- public function file_download( $jobid, $get_file ) {
206
-
207
- try {
208
- $conn = new OpenCloud\Rackspace(
209
- self::get_auth_url_by_region( BackWPup_Option::get( $jobid, 'rscregion' ) ),
210
- array(
211
- 'username' => BackWPup_Option::get( $jobid, 'rscusername' ),
212
- 'apiKey' => BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'rscapikey' ) )
213
- ));
214
- $ostore = $conn->objectStoreService( 'cloudFiles' , BackWPup_Option::get( $jobid, 'rscregion' ), 'publicURL');
215
- $container = $ostore->getContainer( BackWPup_Option::get( $jobid, 'rsccontainer' ) );
216
- $backupfile = $container->getObject( $get_file );
217
- header( "Pragma: public" );
218
- header( "Expires: 0" );
219
- header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
220
- header( "Content-Type: application/octet-stream" );
221
- header( "Content-Disposition: attachment; filename=" . basename( $get_file ) . ";" );
222
- header( "Content-Transfer-Encoding: binary" );
223
- header( "Content-Length: " . $backupfile->getContentLength() );
224
- @set_time_limit( 0 );
225
- echo $backupfile->getContent();
226
- die();
227
- }
228
- catch ( Exception $e ) {
229
- die( $e->getMessage() );
230
- }
231
- }
232
-
233
- /**
234
- * @param $jobdest
235
- * @return mixed
236
- */
237
- public function file_get_list( $jobdest ) {
238
-
239
- return get_site_transient( 'backwpup_' . strtolower( $jobdest ) );
240
- }
241
-
242
- /**
243
- * @param $job_object
244
- * @return bool
245
- */
246
- public function job_run_archive( &$job_object ) {
247
-
248
- $job_object->substeps_todo = 2 + $job_object->backup_filesize;
249
- $job_object->substeps_done = 0;
250
- $job_object->log( sprintf( __( '%d. Trying to send backup file to Rackspace cloud &hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ), E_USER_NOTICE );
251
-
252
- try {
253
-
254
- $conn = new OpenCloud\Rackspace(
255
- self::get_auth_url_by_region( $job_object->job[ 'rscregion' ] ),
256
- array(
257
- 'username' => $job_object->job[ 'rscusername' ],
258
- 'apiKey' => BackWPup_Encryption::decrypt( $job_object->job[ 'rscapikey' ] )
259
- ));
260
- //connect to cloud files
261
- $ostore = $conn->objectStoreService( 'cloudFiles' , $job_object->job[ 'rscregion' ], 'publicURL' );
262
-
263
- $container = $ostore->getContainer( $job_object->job[ 'rsccontainer' ] );
264
- $job_object->log( sprintf(__( 'Connected to Rackspace cloud files container %s', 'backwpup' ), $job_object->job[ 'rsccontainer' ] ) );
265
- }
266
- catch ( Exception $e ) {
267
- $job_object->log( E_USER_ERROR, sprintf( __( 'Rackspace Cloud API: %s', 'backwpup' ), htmlentities( $e->getMessage() ) ), $e->getFile(), $e->getLine() );
268
-
269
- return FALSE;
270
- }
271
-
272
-
273
- try {
274
- //Transfer Backup to Rackspace Cloud
275
- $job_object->substeps_done = 0;
276
- $job_object->log( __( 'Upload to Rackspace cloud started &hellip;', 'backwpup' ), E_USER_NOTICE );
277
- @set_time_limit( 0 );
278
-
279
- $handle = fopen( $job_object->backup_folder . $job_object->backup_file, 'rb' );
280
- $uploded = $container->uploadObject( $job_object->job[ 'rscdir' ] . $job_object->backup_file, $handle );
281
- fclose( $handle );
282
-
283
- // $transfer = $container->setupObjectTransfer( array(
284
- // 'name' => $job_object->job[ 'rscdir' ] . $job_object->backup_file,
285
- // 'path' => $job_object->backup_folder . $job_object->backup_file,
286
- // 'concurrency' => 1,
287
- // 'partSize' => 4 * 1024 * 1024
288
- // ) );
289
- // $uploded = $transfer->upload();
290
-
291
- if ( $uploded ) {
292
- $job_object->substeps_todo = 1 + $job_object->backup_filesize;
293
- $job_object->log( __( 'Backup File transferred to RSC://', 'backwpup' ) . $job_object->job[ 'rsccontainer' ] . '/' . $job_object->job[ 'rscdir' ] . $job_object->backup_file, E_USER_NOTICE );
294
- if ( !empty( $job_object->job[ 'jobid' ] ) )
295
- BackWPup_Option::update( $job_object->job[ 'jobid' ], 'lastbackupdownloadurl', network_admin_url( 'admin.php' ) . '?page=backwpupbackups&action=downloadrsc&file=' . $job_object->job[ 'rscdir' ] . $job_object->backup_file . '&jobid=' . $job_object->job[ 'jobid' ] );
296
- } else {
297
- $job_object->log( __( 'Cannot transfer backup to Rackspace cloud.', 'backwpup' ), E_USER_ERROR );
298
-
299
- return FALSE;
300
- }
301
- }
302
- catch ( Exception $e ) {
303
- $job_object->log( E_USER_ERROR, sprintf( __( 'Rackspace Cloud API: %s', 'backwpup' ), htmlentities( $e->getMessage() ) ), $e->getFile(), $e->getLine() );
304
-
305
- return FALSE;
306
- }
307
-
308
- try {
309
- $backupfilelist = array();
310
- $filecounter = 0;
311
- $files = array();
312
- $objlist = $container->objectList( array( 'prefix' => $job_object->job[ 'rscdir' ] ) );
313
- while ( $object = $objlist->next() ) {
314
- $file = basename( $object->getName() );
315
- if ( $job_object->job[ 'rscdir' ] . $file == $object->getName() ) { //only in the folder and not in complete bucket
316
- if ( $job_object->is_backup_archive( $file ) )
317
- $backupfilelist[ strtotime( $object->getLastModified() ) ] = $object;
318
- }
319
- $files[ $filecounter ][ 'folder' ] = "RSC://" . $job_object->job[ 'rsccontainer' ] . "/" . dirname( $object->getName() ) . "/";
320
- $files[ $filecounter ][ 'file' ] = $object->getName();
321
- $files[ $filecounter ][ 'filename' ] = basename( $object->getName() );
322
- $files[ $filecounter ][ 'downloadurl' ] = network_admin_url( 'admin.php' ) . '?page=backwpupbackups&action=downloadrsc&file=' . $object->getName() . '&jobid=' . $job_object->job[ 'jobid' ];
323
- $files[ $filecounter ][ 'filesize' ] = $object->getContentLength();
324
- $files[ $filecounter ][ 'time' ] = strtotime( $object->getLastModified() );
325
- $filecounter ++;
326
- }
327
- if ( ! empty( $job_object->job[ 'rscmaxbackups' ] ) && $job_object->job[ 'rscmaxbackups' ] > 0 ) { //Delete old backups
328
- if ( count( $backupfilelist ) > $job_object->job[ 'rscmaxbackups' ] ) {
329
- ksort( $backupfilelist );
330
- $numdeltefiles = 0;
331
- while ( $file = array_shift( $backupfilelist ) ) {
332
- if ( count( $backupfilelist ) < $job_object->job[ 'rscmaxbackups' ] )
333
- break;
334
- foreach ( $files as $key => $filedata ) {
335
- if ( $filedata[ 'file' ] == $file->getName() )
336
- unset( $files[ $key ] );
337
- }
338
- $file->delete();
339
- $numdeltefiles ++;
340
- }
341
- if ( $numdeltefiles > 0 )
342
- $job_object->log( sprintf( _n( 'One file deleted on Rackspace cloud container.', '%d files deleted on Rackspace cloud container.', $numdeltefiles, 'backwpup' ), $numdeltefiles ), E_USER_NOTICE );
343
- }
344
- }
345
- set_site_transient( 'backwpup_' . $job_object->job[ 'jobid' ] . '_rsc', $files, 60 * 60 * 24 * 7 );
346
- }
347
- catch ( Exception $e ) {
348
- $job_object->log( E_USER_ERROR, sprintf( __( 'Rackspace Cloud API: %s', 'backwpup' ), htmlentities( $e->getMessage() ) ), $e->getFile(), $e->getLine() );
349
-
350
- return FALSE;
351
- }
352
- $job_object->substeps_done ++;
353
-
354
- return TRUE;
355
- }
356
-
357
- /**
358
- * @param $job_object
359
- * @return bool
360
- */
361
- public function can_run( $job_object ) {
362
-
363
- if ( empty( $job_object->job[ 'rscusername'] ) )
364
- return FALSE;
365
-
366
- if ( empty( $job_object->job[ 'rscapikey'] ) )
367
- return FALSE;
368
-
369
- if ( empty( $job_object->job[ 'rsccontainer'] ) )
370
- return FALSE;
371
-
372
- return TRUE;
373
- }
374
-
375
- /**
376
- *
377
- */
378
- public function edit_inline_js() {
379
- //<script type="text/javascript">
380
- ?>
381
- function rscgetcontainer() {
382
- var data = {
383
- action: 'backwpup_dest_rsc',
384
- rscusername: $('#rscusername').val(),
385
- rscapikey: $('#rscapikey').val(),
386
- rscregion: $('#rscregion').val(),
387
- rscselected: $('#rsccontainerselected').val(),
388
- _ajax_nonce: $('#backwpupajaxnonce').val()
389
- };
390
- $.post(ajaxurl, data, function(response) {
391
- $('#rsccontainererror').remove();
392
- $('#rsccontainer').remove();
393
- $('#rsccontainerselected').after(response);
394
- });
395
- }
396
- $('#rscregion').change(function() {rscgetcontainer();});
397
- $('#rscusername').change(function() {rscgetcontainer();});
398
- $('#rscapikey').change(function() {rscgetcontainer();});
399
- <?php
400
- }
401
-
402
- /**
403
- * @param string $args
404
- */
405
- public function edit_ajax( $args = '' ) {
406
-
407
- $error = '';
408
-
409
- if ( is_array( $args ) ) {
410
- $ajax = FALSE;
411
- } else {
412
- if ( ! current_user_can( 'backwpup_jobs_edit' ) )
413
- wp_die( -1 );
414
- check_ajax_referer( 'backwpup_ajax_nonce' );
415
- $args[ 'rscusername' ] = $_POST[ 'rscusername' ];
416
- $args[ 'rscapikey' ] = $_POST[ 'rscapikey' ];
417
- $args[ 'rscselected' ] = $_POST[ 'rscselected' ];
418
- $args[ 'rscregion' ] = $_POST[ 'rscregion' ];
419
- $ajax = TRUE;
420
- }
421
- echo '<span id="rsccontainererror" style="color:red;">';
422
-
423
- $container_list = array();
424
- if ( ! empty( $args[ 'rscusername' ] ) && ! empty( $args[ 'rscapikey' ] ) && ! empty( $args[ 'rscregion' ] ) ) {
425
- try {
426
- $conn = new OpenCloud\Rackspace(
427
- self::get_auth_url_by_region( $args[ 'rscregion' ] ),
428
- array(
429
- 'username' => $args[ 'rscusername' ],
430
- 'apiKey' => BackWPup_Encryption::decrypt( $args[ 'rscapikey' ] )
431
- ));
432
-
433
- $ostore = $conn->objectStoreService( 'cloudFiles' , $args[ 'rscregion' ], 'publicURL' );
434
- $containerlist = $ostore->listContainers();
435
- while( $container = $containerlist->next() ) {
436
- $container_list[] = $container->name;
437
- }
438
- }
439
- catch ( Exception $e ) {
440
- $error = $e->getMessage();
441
- }
442
- }
443
-
444
- if ( empty( $args[ 'rscusername' ] ) )
445
- _e( 'Missing username!', 'backwpup' );
446
- elseif ( empty( $args[ 'rscapikey' ] ) )
447
- _e( 'Missing API Key!', 'backwpup' );
448
- elseif ( ! empty( $error ) )
449
- echo esc_html( $error );
450
- elseif ( empty( $container_list ) )
451
- _e( "A container could not be found!", 'backwpup' );
452
- echo '</span>';
453
-
454
- if ( ! empty( $container_list ) ) {
455
- echo '<select name="rsccontainer" id="rsccontainer">';
456
- foreach( $container_list as $container_name )
457
- echo "<option " . selected( strtolower( $args[ 'rscselected' ] ), strtolower( $container_name ), FALSE ) . ">" . $container_name . "</option>";
458
- echo '</select>';
459
- }
460
-
461
- if ( $ajax )
462
- die();
463
- else
464
- return;
465
- }
466
- }
1
+ <?php
2
+ // Rackspace OpenCloud SDK v1.9.2
3
+ // http://www.rackspace.com/cloud/files/
4
+ // https://github.com/rackspace/php-opencloud
5
+
6
+ /**
7
+ *
8
+ */
9
+ class BackWPup_Destination_RSC extends BackWPup_Destinations {
10
+
11
+
12
+ /**
13
+ * @return array
14
+ */
15
+ public function option_defaults() {
16
+
17
+ return array( 'rscusername' => '', 'rscapikey' => '', 'rsccontainer' => '', 'rscregion' => 'DFW', 'rscdir' => trailingslashit( sanitize_file_name( get_bloginfo( 'name' ) ) ), 'rscmaxbackups' => 15, 'rscsyncnodelete' => TRUE );
18
+ }
19
+
20
+ /**
21
+ * Get Auht url by region code
22
+ *
23
+ * @param $region string region code
24
+ * @return string
25
+ */
26
+ public static function get_auth_url_by_region( $region ) {
27
+
28
+ $region = strtoupper( $region );
29
+
30
+ if ( $region == 'LON' )
31
+ return RACKSPACE_UK;
32
+
33
+ return RACKSPACE_US;
34
+ }
35
+
36
+ /**
37
+ * @param $jobid
38
+ */
39
+ public function edit_tab( $jobid ) {
40
+ ?>
41
+ <h3 class="title"><?php _e( 'Rack Space Cloud Keys', 'backwpup' ); ?></h3>
42
+ <p></p>
43
+ <table class="form-table">
44
+ <tr>
45
+ <th scope="row"><label for="rscusername"><?php _e( 'Username', 'backwpup' ); ?></label></th>
46
+ <td>
47
+ <input id="rscusername" name="rscusername" type="text"
48
+ value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'rscusername' ) );?>" class="regular-text" autocomplete="off" />
49
+ </td>
50
+ </tr>
51
+ <tr>
52
+ <th scope="row"><label for="rscapikey"><?php _e( 'API Key', 'backwpup' ); ?></label></th>
53
+ <td>
54
+ <input id="rscapikey" name="rscapikey" type="password"
55
+ value="<?php echo esc_attr( BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'rscapikey' ) ) ); ?>" class="regular-text" autocomplete="off" />
56
+ </td>
57
+ </tr>
58
+ </table>
59
+
60
+ <h3 class="title"><?php _e( 'Select region', 'backwpup' ); ?></h3>
61
+ <p></p>
62
+ <table class="form-table">
63
+ <tr>
64
+ <th scope="row"><label for="rscregion"><?php _e( 'Rackspace Cloud Files Region', 'backwpup' ); ?></label></th>
65
+ <td>
66
+ <select name="rscregion" id="rscregion" title="<?php _e( 'Rackspace Cloud Files Region', 'backwpup' ); ?>">
67
+ <option value="DFW" <?php selected( 'DFW', BackWPup_Option::get( $jobid, 'rscregion' ), TRUE ) ?>><?php _e( 'Dallas (DFW)', 'backwpup' ); ?></option>
68
+ <option value="ORD" <?php selected( 'ORD', BackWPup_Option::get( $jobid, 'rscregion' ), TRUE ) ?>><?php _e( 'Chicago (ORD)', 'backwpup' ); ?></option>
69
+ <option value="SYD" <?php selected( 'SYD', BackWPup_Option::get( $jobid, 'rscregion' ), TRUE ) ?>><?php _e( 'Sydney (SYD)', 'backwpup' ); ?></option>
70
+ <option value="LON" <?php selected( 'LON', BackWPup_Option::get( $jobid, 'rscregion' ), TRUE ) ?>><?php _e( 'London (LON)', 'backwpup' ); ?></option>
71
+ <option value="IAD" <?php selected( 'IAD', BackWPup_Option::get( $jobid, 'rscregion' ), TRUE ) ?>><?php _e( 'Northern Virginia (IAD)', 'backwpup' ); ?></option>
72
+ <option value="HKG" <?php selected( 'HKG', BackWPup_Option::get( $jobid, 'rscregion' ), TRUE ) ?>><?php _e( 'Hong Kong (HKG)', 'backwpup' ); ?></option>
73
+ </select><br/>
74
+ </td>
75
+ </tr>
76
+ <tr>
77
+ <th scope="row"><label for="rsccontainerselected"><?php _e( 'Container selection', 'backwpup' ); ?></label></th>
78
+ <td>
79
+ <input id="rsccontainerselected" name="rsccontainerselected" type="hidden" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'rsccontainer' ) ); ?>" />
80
+ <?php if ( BackWPup_Option::get( $jobid, 'rscusername' ) && BackWPup_Option::get( $jobid, 'rscapikey' ) ) $this->edit_ajax( array(
81
+ 'rscusername' => BackWPup_Option::get( $jobid, 'rscusername' ),
82
+ 'rscregion' => BackWPup_Option::get( $jobid, 'rscregion' ),
83
+ 'rscapikey' => BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'rscapikey' ) ),
84
+ 'rscselected' => BackWPup_Option::get( $jobid, 'rsccontainer' )
85
+ ) ); ?>
86
+ </td>
87
+ </tr>
88
+ <tr>
89
+ <th scope="row"><label for="idnewrsccontainer"><?php _e( 'Create a new container', 'backwpup' ); ?></label></th>
90
+ <td>
91
+ <input id="idnewrsccontainer" name="newrsccontainer" type="text" value="" class="text" />
92
+ </td>
93
+ </tr>
94
+ </table>
95
+
96
+ <h3 class="title"><?php _e( 'Backup settings', 'backwpup' ); ?></h3>
97
+ <p></p>
98
+ <table class="form-table">
99
+ <tr>
100
+ <th scope="row"><label for="idrscdir"><?php _e( 'Folder in bucket', 'backwpup' ); ?></label></th>
101
+ <td>
102
+ <input id="idrscdir" name="rscdir" type="text" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'rscdir' ) ); ?>" class="regular-text" />
103
+ </td>
104
+ </tr>
105
+ <tr>
106
+ <th scope="row"><?php _e( 'File deletion', 'backwpup' ); ?></th>
107
+ <td>
108
+ <?php
109
+ if ( BackWPup_Option::get( $jobid, 'backuptype' ) == 'archive' ) {
110
+ ?>
111
+ <label for="idrscmaxbackups"><input id="idrscmaxbackups" name="rscmaxbackups" type="text" size="3" value="<?php echo esc_attr( BackWPup_Option::get( $jobid, 'rscmaxbackups' ) ); ?>" class="small-text help-tip" title="<?php esc_attr_e( 'Oldest files will be deleted first. 0 = no deletion', 'backwpup' ); ?>" />&nbsp;
112
+ <?php _e( 'Number of files to keep in folder.', 'backwpup' ); ?></label>
113
+ <?php } else { ?>
114
+ <label for="idrscsyncnodelete"><input class="checkbox" value="1"
115
+ type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'rscsyncnodelete' ), TRUE ); ?>
116
+ name="rscsyncnodelete" id="idrscsyncnodelete" /> <?php _e( 'Do not delete files while syncing to destination!', 'backwpup' ); ?></label>
117
+ <?php } ?>
118
+ </td>
119
+ </tr>
120
+ </table>
121
+ <?php
122
+ }
123
+
124
+ /**
125
+ * @param $id
126
+ */
127
+ public function edit_form_post_save( $id ) {
128
+
129
+ BackWPup_Option::update( $id, 'rscusername', isset( $_POST[ 'rscusername' ] ) ? $_POST[ 'rscusername' ] : '' );
130
+ BackWPup_Option::update( $id, 'rscapikey', isset( $_POST[ 'rscapikey' ] ) ? BackWPup_Encryption::encrypt( $_POST[ 'rscapikey' ] ) : '' );
131
+ BackWPup_Option::update( $id, 'rsccontainer', isset( $_POST[ 'rsccontainer' ] ) ? $_POST[ 'rsccontainer' ] : '' );
132
+ BackWPup_Option::update( $id, 'rscregion', ! empty( $_POST[ 'rscregion' ] ) ? $_POST[ 'rscregion' ] : 'DFW' );
133
+
134
+ $_POST[ 'rscdir' ] = trailingslashit( str_replace( '//', '/', str_replace( '\\', '/', trim( stripslashes( $_POST[ 'rscdir' ] ) ) ) ) );
135
+ if ( substr( $_POST[ 'rscdir' ], 0, 1 ) == '/' )
136
+ $_POST[ 'rscdir' ] = substr( $_POST[ 'rscdir' ], 1 );
137
+ if ( $_POST[ 'rscdir' ] == '/' )
138
+ $_POST[ 'rscdir' ] = '';
139
+ BackWPup_Option::update( $id, 'rscdir', $_POST[ 'rscdir' ] );
140
+
141
+ BackWPup_Option::update( $id, 'rscmaxbackups', isset( $_POST[ 'rscmaxbackups' ] ) ? (int)$_POST[ 'rscmaxbackups' ] : 0 );
142
+ BackWPup_Option::update( $id, 'rscsyncnodelete', ( isset( $_POST[ 'rscsyncnodelete' ] ) && $_POST[ 'rscsyncnodelete' ] == 1 ) ? TRUE : FALSE );
143
+
144
+ if ( ! empty( $_POST[ 'rscusername' ] ) && ! empty( $_POST[ 'rscapikey' ] ) && ! empty( $_POST[ 'newrsccontainer' ] ) ) {
145
+ try {
146
+ $conn = new OpenCloud\Rackspace(
147
+ self::get_auth_url_by_region( $_POST[ 'rscregion' ] ),
148
+ array(
149
+ 'username' => $_POST[ 'rscusername' ],
150
+ 'apiKey' => $_POST[ 'rscapikey' ]
151
+ ));
152
+ $ostore = $conn->objectStoreService( 'cloudFiles' , $_POST[ 'rscregion' ], 'publicURL');
153
+ $ostore->createContainer( $_POST[ 'newrsccontainer' ] );
154
+ BackWPup_Option::update( $id, 'rsccontainer', $_POST[ 'newrsccontainer' ] );
155
+ BackWPup_Admin::message( sprintf( __( 'Rackspace Cloud container "%s" created.', 'backwpup' ), $_POST[ 'newrsccontainer' ] ) );
156
+
157
+ }
158
+ catch ( Exception $e ) {
159
+ BackWPup_Admin::message( sprintf( __( 'Rackspace Cloud API: %s', 'backwpup' ), $e->getMessage() ), TRUE );
160
+ }
161
+ }
162
+ }
163
+
164
+ /**
165
+ * @param $jobdest
166
+ * @param $backupfile
167
+ */
168
+ public function file_delete( $jobdest, $backupfile ) {
169
+
170
+ $files = get_site_transient( 'backwpup_'. strtolower( $jobdest ), FALSE );
171
+ list( $jobid, $dest ) = explode( '_', $jobdest );
172
+
173
+ if ( BackWPup_Option::get( $jobid, 'rscusername' ) && BackWPup_Option::get( $jobid, 'rscapikey' ) && BackWPup_Option::get( $jobid, 'rsccontainer' ) ) {
174
+ try {
175
+ $conn = new OpenCloud\Rackspace(
176
+ self::get_auth_url_by_region( BackWPup_Option::get( $jobid, 'rscregion' ) ),
177
+ array(
178
+ 'username' => BackWPup_Option::get( $jobid, 'rscusername' ),
179
+ 'apiKey' => BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'rscapikey' ) )
180
+ ));
181
+ $conn->
182
+ $ostore = $conn->objectStoreService( 'cloudFiles' , BackWPup_Option::get( $jobid, 'rscregion' ), 'publicURL');
183
+ $container = $ostore->getContainer( BackWPup_Option::get( $jobid, 'rsccontainer' ) );
184
+ $fileobject = $container->getObject( $backupfile );
185
+ $fileobject->delete();
186
+ //update file list
187
+ foreach ( $files as $key => $file ) {
188
+ if ( is_array( $file ) && $file[ 'file' ] == $backupfile )
189
+ unset( $files[ $key ] );
190
+ }
191
+
192
+ }
193
+ catch ( Exception $e ) {
194
+ BackWPup_Admin::message( 'RSC: ' . $e->getMessage(), TRUE );
195
+ }
196
+ }
197
+
198
+ set_site_transient( 'backwpup_'. strtolower( $jobdest ), $files, 60 * 60 * 24 * 7 );
199
+ }
200
+
201
+ /**
202
+ * @param $jobid
203
+ * @param $get_file
204
+ */
205
+ public function file_download( $jobid, $get_file ) {
206
+
207
+ try {
208
+ $conn = new OpenCloud\Rackspace(
209
+ self::get_auth_url_by_region( BackWPup_Option::get( $jobid, 'rscregion' ) ),
210
+ array(
211
+ 'username' => BackWPup_Option::get( $jobid, 'rscusername' ),
212
+ 'apiKey' => BackWPup_Encryption::decrypt( BackWPup_Option::get( $jobid, 'rscapikey' ) )
213
+ ));
214
+ $ostore = $conn->objectStoreService( 'cloudFiles' , BackWPup_Option::get( $jobid, 'rscregion' ), 'publicURL');
215
+ $container = $ostore->getContainer( BackWPup_Option::get( $jobid, 'rsccontainer' ) );
216
+ $backupfile = $container->getObject( $get_file );
217
+ header( "Pragma: public" );
218
+ header( "Expires: 0" );
219
+ header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
220
+ header( "Content-Type: application/octet-stream" );
221
+ header( "Content-Disposition: attachment; filename=" . basename( $get_file ) . ";" );
222
+ header( "Content-Transfer-Encoding: binary" );
223
+ header( "Content-Length: " . $backupfile->getContentLength() );
224
+ @set_time_limit( 300 );
225
+ echo $backupfile->getContent();
226
+ die();
227
+ }
228
+ catch ( Exception $e ) {
229
+ die( $e->getMessage() );
230
+ }
231
+ }
232
+
233
+ /**
234
+ * @param $jobdest
235
+ * @return mixed
236
+ */
237
+ public function file_get_list( $jobdest ) {
238
+
239
+ return get_site_transient( 'backwpup_' . strtolower( $jobdest ) );
240
+ }
241
+
242
+ /**
243
+ * @param $job_object
244
+ * @return bool
245
+ */
246
+ public function job_run_archive( &$job_object ) {
247
+
248
+ $job_object->substeps_todo = 2 + $job_object->backup_filesize;
249
+ $job_object->substeps_done = 0;
250
+ $job_object->log( sprintf( __( '%d. Trying to send backup file to Rackspace cloud &hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ), E_USER_NOTICE );
251
+
252
+ try {
253
+
254
+ $conn = new OpenCloud\Rackspace(
255
+ self::get_auth_url_by_region( $job_object->job[ 'rscregion' ] ),
256
+ array(
257
+ 'username' => $job_object->job[ 'rscusername' ],
258
+ 'apiKey' => BackWPup_Encryption::decrypt( $job_object->job[ 'rscapikey' ] )
259
+ ));
260
+ //connect to cloud files
261
+ $ostore = $conn->objectStoreService( 'cloudFiles' , $job_object->job[ 'rscregion' ], 'publicURL' );
262
+
263
+ $container = $ostore->getContainer( $job_object->job[ 'rsccontainer' ] );
264
+ $job_object->log( sprintf(__( 'Connected to Rackspace cloud files container %s', 'backwpup' ), $job_object->job[ 'rsccontainer' ] ) );
265
+ }
266
+ catch ( Exception $e ) {
267
+ $job_object->log( E_USER_ERROR, sprintf( __( 'Rackspace Cloud API: %s', 'backwpup' ), htmlentities( $e->getMessage() ) ), $e->getFile(), $e->getLine() );
268
+
269
+ return FALSE;
270
+ }
271
+
272
+
273
+ try {
274
+ //Transfer Backup to Rackspace Cloud
275
+ $job_object->substeps_done = 0;
276
+ $job_object->log( __( 'Upload to Rackspace cloud started &hellip;', 'backwpup' ), E_USER_NOTICE );
277
+
278
+ $handle = fopen( $job_object->backup_folder . $job_object->backup_file, 'rb' );
279
+ $uploded = $container->uploadObject( $job_object->job[ 'rscdir' ] . $job_object->backup_file, $handle );
280
+ fclose( $handle );
281
+
282
+ // $transfer = $container->setupObjectTransfer( array(
283
+ // 'name' => $job_object->job[ 'rscdir' ] . $job_object->backup_file,
284
+ // 'path' => $job_object->backup_folder . $job_object->backup_file,
285
+ // 'concurrency' => 1,
286
+ // 'partSize' => 4 * 1024 * 1024
287
+ // ) );
288
+ // $uploded = $transfer->upload();
289
+
290
+ if ( $uploded ) {
291
+ $job_object->substeps_todo = 1 + $job_object->backup_filesize;
292
+ $job_object->log( __( 'Backup File transferred to RSC://', 'backwpup' ) . $job_object->job[ 'rsccontainer' ] . '/' . $job_object->job[ 'rscdir' ] . $job_object->backup_file, E_USER_NOTICE );
293
+ if ( !empty( $job_object->job[ 'jobid' ] ) )
294
+ BackWPup_Option::update( $job_object->job[ 'jobid' ], 'lastbackupdownloadurl', network_admin_url( 'admin.php' ) . '?page=backwpupbackups&action=downloadrsc&file=' . $job_object->job[ 'rscdir' ] . $job_object->backup_file . '&jobid=' . $job_object->job[ 'jobid' ] );
295
+ } else {
296
+ $job_object->log( __( 'Cannot transfer backup to Rackspace cloud.', 'backwpup' ), E_USER_ERROR );
297
+
298
+ return FALSE;
299
+ }
300
+ }
301
+ catch ( Exception $e ) {
302
+ $job_object->log( E_USER_ERROR, sprintf( __( 'Rackspace Cloud API: %s', 'backwpup' ), htmlentities( $e->getMessage() ) ), $e->getFile(), $e->getLine() );
303
+
304
+ return FALSE;
305
+ }
306
+
307
+ try {
308
+ $backupfilelist = array();
309
+ $filecounter = 0;
310
+ $files = array();
311
+ $objlist = $container->objectList( array( 'prefix' => $job_object->job[ 'rscdir' ] ) );
312
+ while ( $object = $objlist->next() ) {
313
+ $file = basename( $object->getName() );
314
+ if ( $job_object->job[ 'rscdir' ] . $file == $object->getName() ) { //only in the folder and not in complete bucket
315
+ if ( $job_object->is_backup_archive( $file ) )
316
+ $backupfilelist[ strtotime( $object->getLastModified() ) ] = $object;
317
+ }
318
+ $files[ $filecounter ][ 'folder' ] = "RSC://" . $job_object->job[ 'rsccontainer' ] . "/" . dirname( $object->getName() ) . "/";
319
+ $files[ $filecounter ][ 'file' ] = $object->getName();
320
+ $files[ $filecounter ][ 'filename' ] = basename( $object->getName() );
321
+ $files[ $filecounter ][ 'downloadurl' ] = network_admin_url( 'admin.php' ) . '?page=backwpupbackups&action=downloadrsc&file=' . $object->getName() . '&jobid=' . $job_object->job[ 'jobid' ];
322
+ $files[ $filecounter ][ 'filesize' ] = $object->getContentLength();
323
+ $files[ $filecounter ][ 'time' ] = strtotime( $object->getLastModified() );
324
+ $filecounter ++;
325
+ }
326
+ if ( ! empty( $job_object->job[ 'rscmaxbackups' ] ) && $job_object->job[ 'rscmaxbackups' ] > 0 ) { //Delete old backups
327
+ if ( count( $backupfilelist ) > $job_object->job[ 'rscmaxbackups' ] ) {
328
+ ksort( $backupfilelist );
329
+ $numdeltefiles = 0;
330
+ while ( $file = array_shift( $backupfilelist ) ) {
331
+ if ( count( $backupfilelist ) < $job_object->job[ 'rscmaxbackups' ] )
332
+ break;
333
+ foreach ( $files as $key => $filedata ) {
334
+ if ( $filedata[ 'file' ] == $file->getName() )
335
+ unset( $files[ $key ] );
336
+ }
337
+ $file->delete();
338
+ $numdeltefiles ++;
339
+ }
340
+ if ( $numdeltefiles > 0 )
341
+ $job_object->log( sprintf( _n( 'One file deleted on Rackspace cloud container.', '%d files deleted on Rackspace cloud container.', $numdeltefiles, 'backwpup' ), $numdeltefiles ), E_USER_NOTICE );
342
+ }
343
+ }
344
+ set_site_transient( 'backwpup_' . $job_object->job[ 'jobid' ] . '_rsc', $files, 60 * 60 * 24 * 7 );
345
+ }
346
+ catch ( Exception $e ) {
347
+ $job_object->log( E_USER_ERROR, sprintf( __( 'Rackspace Cloud API: %s', 'backwpup' ), htmlentities( $e->getMessage() ) ), $e->getFile(), $e->getLine() );
348
+
349
+ return FALSE;
350
+ }
351
+ $job_object->substeps_done ++;
352
+
353
+ return TRUE;
354
+ }
355
+
356
+ /**
357
+ * @param $job_object
358
+ * @return bool
359
+ */
360
+ public function can_run( $job_object ) {
361
+
362
+ if ( empty( $job_object->job[ 'rscusername'] ) )
363
+ return FALSE;
364
+
365
+ if ( empty( $job_object->job[ 'rscapikey'] ) )
366
+ return FALSE;
367
+
368
+ if ( empty( $job_object->job[ 'rsccontainer'] ) )
369
+ return FALSE;
370
+
371
+ return TRUE;
372
+ }
373
+
374
+ /**
375
+ *
376
+ */
377
+ public function edit_inline_js() {
378
+ //<script type="text/javascript">
379
+ ?>
380
+ function rscgetcontainer() {
381
+ var data = {
382
+ action: 'backwpup_dest_rsc',
383
+ rscusername: $('#rscusername').val(),
384
+ rscapikey: $('#rscapikey').val(),
385
+ rscregion: $('#rscregion').val(),
386
+ rscselected: $('#rsccontainerselected').val(),
387
+ _ajax_nonce: $('#backwpupajaxnonce').val()
388
+ };
389
+ $.post(ajaxurl, data, function(response) {
390
+ $('#rsccontainererror').remove();
391
+ $('#rsccontainer').remove();
392
+ $('#rsccontainerselected').after(response);
393
+ });
394
+ }
395
+ $('#rscregion').change(function() {rscgetcontainer();});
396
+ $('#rscusername').change(function() {rscgetcontainer();});
397
+ $('#rscapikey').change(function() {rscgetcontainer();});
398
+ <?php
399
+ }
400
+
401
+ /**
402
+ * @param string $args
403
+ */
404
+ public function edit_ajax( $args = '' ) {
405
+
406
+ $error = '';
407
+
408
+ if ( is_array( $args ) ) {
409
+ $ajax = FALSE;
410
+ } else {
411
+ if ( ! current_user_can( 'backwpup_jobs_edit' ) )
412
+ wp_die( -1 );
413
+ check_ajax_referer( 'backwpup_ajax_nonce' );
414
+ $args[ 'rscusername' ] = $_POST[ 'rscusername' ];
415
+ $args[ 'rscapikey' ] = $_POST[ 'rscapikey' ];
416
+ $args[ 'rscselected' ] = $_POST[ 'rscselected' ];
417
+ $args[ 'rscregion' ] = $_POST[ 'rscregion' ];
418
+ $ajax = TRUE;
419
+ }
420
+ echo '<span id="rsccontainererror" style="color:red;">';
421
+
422
+ $container_list = array();
423
+ if ( ! empty( $args[ 'rscusername' ] ) && ! empty( $args[ 'rscapikey' ] ) && ! empty( $args[ 'rscregion' ] ) ) {
424
+ try {
425
+ $conn = new OpenCloud\Rackspace(
426
+ self::get_auth_url_by_region( $args[ 'rscregion' ] ),
427
+ array(
428
+ 'username' => $args[ 'rscusername' ],
429
+ 'apiKey' => BackWPup_Encryption::decrypt( $args[ 'rscapikey' ] )
430
+ ));
431
+
432
+ $ostore = $conn->objectStoreService( 'cloudFiles' , $args[ 'rscregion' ], 'publicURL' );
433
+ $containerlist = $ostore->listContainers();
434
+ while( $container = $containerlist->next() ) {
435
+ $container_list[] = $container->name;
436
+ }
437
+ }
438
+ catch ( Exception $e ) {
439
+ $error = $e->getMessage();
440
+ }
441
+ }
442
+
443
+ if ( empty( $args[ 'rscusername' ] ) )
444
+ _e( 'Missing username!', 'backwpup' );
445
+ elseif ( empty( $args[ 'rscapikey' ] ) )
446
+ _e( 'Missing API Key!', 'backwpup' );
447
+ elseif ( ! empty( $error ) )
448
+ echo esc_html( $error );
449
+ elseif ( empty( $container_list ) )
450
+ _e( "A container could not be found!", 'backwpup' );
451
+ echo '</span>';
452
+
453
+ if ( ! empty( $container_list ) ) {
454
+ echo '<select name="rsccontainer" id="rsccontainer">';
455
+ foreach( $container_list as $container_name )
456
+ echo "<option " . selected( strtolower( $args[ 'rscselected' ] ), strtolower( $container_name ), FALSE ) . ">" . $container_name . "</option>";
457
+ echo '</select>';
458
+ }
459
+
460
+ if ( $ajax )
461
+ die();
462
+ else
463
+ return;
464
+ }
465
+ }
 
inc/class-destination-s3-v1.php CHANGED
@@ -29,6 +29,8 @@ class BackWPup_Destination_S3_V1 extends BackWPup_Destinations {
29
  return 'https://s3-us-west-2.amazonaws.com';
30
  case 'eu-west-1':
31
  return 'https://s3-eu-west-1.amazonaws.com';
 
 
32
  case 'ap-northeast-1':
33
  return 'https://s3-ap-northeast-1.amazonaws.com';
34
  case 'ap-southeast-1':
@@ -41,10 +43,10 @@ class BackWPup_Destination_S3_V1 extends BackWPup_Destinations {
41
  return 'https://cn-north-1.amazonaws.com';
42
  case 'google-storage':
43
  return 'https://storage.googleapis.com';
44
- case 'hosteurope':
45
- return 'https://cs.hosteurope.de';
46
  case 'dreamhost':
47
  return 'https://objects.dreamhost.com';
 
 
48
  default:
49
  return '';
50
  }
@@ -77,14 +79,15 @@ class BackWPup_Destination_S3_V1 extends BackWPup_Destinations {
77
  <option value="us-west-1" <?php selected( 'us-west-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: US West (Northern California)', 'backwpup' ); ?></option>
78
  <option value="us-west-2" <?php selected( 'us-west-2', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: US West (Oregon)', 'backwpup' ); ?></option>
79
  <option value="eu-west-1" <?php selected( 'eu-west-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: EU (Ireland)', 'backwpup' ); ?></option>
 
80
  <option value="ap-northeast-1" <?php selected( 'ap-northeast-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: Asia Pacific (Tokyo)', 'backwpup' ); ?></option>
81
  <option value="ap-southeast-1" <?php selected( 'ap-southeast-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: Asia Pacific (Singapore)', 'backwpup' ); ?></option>
82
  <option value="ap-southeast-2" <?php selected( 'ap-southeast-2', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: Asia Pacific (Sydney)', 'backwpup' ); ?></option>
83
  <option value="sa-east-1" <?php selected( 'sa-east-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: South America (Sao Paulo)', 'backwpup' ); ?></option>
84
  <option value="cn-north-1" <?php selected( 'cn-north-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: China (Beijing)', 'backwpup' ); ?></option>
85
  <option value="google-storage" <?php selected( 'google-storage', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Google Storage (Interoperable Access)', 'backwpup' ); ?></option>
86
- <option value="hosteurope" <?php selected( 'hosteurope', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Hosteurope Cloud Storage', 'backwpup' ); ?></option>
87
  <option value="dreamhost" <?php selected( 'dreamhost', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Dream Host Cloud Storage', 'backwpup' ); ?></option>
 
88
  </select>
89
  </td>
90
  </tr>
@@ -243,7 +246,7 @@ class BackWPup_Destination_S3_V1 extends BackWPup_Destinations {
243
  $bucket = $s3->create_bucket( $_POST[ 's3newbucket' ], $region, 'private' );
244
 
245
  if ( $bucket->status == 200 )
246
- BackWPup_Admin::message( sprintf( __( 'Bucket %1$s created in %2$s.','backwpup'), $_POST[ 's3newbucket' ], $bucket[ 'Location' ] ) );
247
  else
248
  BackWPup_Admin::message( sprintf( __( 'Bucket %s could not be created.','backwpup'), $_POST[ 's3newbucket' ] ), TRUE );
249
 
@@ -333,7 +336,7 @@ class BackWPup_Destination_S3_V1 extends BackWPup_Destinations {
333
  header( "Content-Disposition: attachment; filename=" . basename( $get_file ) . ";" );
334
  header( "Content-Transfer-Encoding: binary" );
335
  header( "Content-Length: " . $s3file->header->_info->size_download );
336
- @set_time_limit( 0 );
337
  echo $s3file->body;
338
  die();
339
  }
29
  return 'https://s3-us-west-2.amazonaws.com';
30
  case 'eu-west-1':
31
  return 'https://s3-eu-west-1.amazonaws.com';
32
+ case 'eu-central-1':
33
+ return 'https://s3-eu-central-1.amazonaws.com';
34
  case 'ap-northeast-1':
35
  return 'https://s3-ap-northeast-1.amazonaws.com';
36
  case 'ap-southeast-1':
43
  return 'https://cn-north-1.amazonaws.com';
44
  case 'google-storage':
45
  return 'https://storage.googleapis.com';
 
 
46
  case 'dreamhost':
47
  return 'https://objects.dreamhost.com';
48
+ case 'greenqloud':
49
+ return 'http://s.greenqloud.com';
50
  default:
51
  return '';
52
  }
79
  <option value="us-west-1" <?php selected( 'us-west-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: US West (Northern California)', 'backwpup' ); ?></option>
80
  <option value="us-west-2" <?php selected( 'us-west-2', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: US West (Oregon)', 'backwpup' ); ?></option>
81
  <option value="eu-west-1" <?php selected( 'eu-west-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: EU (Ireland)', 'backwpup' ); ?></option>
82
+ <option value="eu-central-1" <?php selected( 'eu-central-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: EU (Germany)', 'backwpup' ); ?></option>
83
  <option value="ap-northeast-1" <?php selected( 'ap-northeast-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: Asia Pacific (Tokyo)', 'backwpup' ); ?></option>
84
  <option value="ap-southeast-1" <?php selected( 'ap-southeast-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: Asia Pacific (Singapore)', 'backwpup' ); ?></option>
85
  <option value="ap-southeast-2" <?php selected( 'ap-southeast-2', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: Asia Pacific (Sydney)', 'backwpup' ); ?></option>
86
  <option value="sa-east-1" <?php selected( 'sa-east-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: South America (Sao Paulo)', 'backwpup' ); ?></option>
87
  <option value="cn-north-1" <?php selected( 'cn-north-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: China (Beijing)', 'backwpup' ); ?></option>
88
  <option value="google-storage" <?php selected( 'google-storage', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Google Storage (Interoperable Access)', 'backwpup' ); ?></option>
 
89
  <option value="dreamhost" <?php selected( 'dreamhost', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Dream Host Cloud Storage', 'backwpup' ); ?></option>
90
+ <option value="greenqloud" <?php selected( 'greenqloud', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'GreenQloud Storage Qloud', 'backwpup' ); ?></option>
91
  </select>
92
  </td>
93
  </tr>
246
  $bucket = $s3->create_bucket( $_POST[ 's3newbucket' ], $region, 'private' );
247
 
248
  if ( $bucket->status == 200 )
249
+ BackWPup_Admin::message( sprintf( __( 'Bucket %1$s created.','backwpup'), $_POST[ 's3newbucket' ] ) );
250
  else
251
  BackWPup_Admin::message( sprintf( __( 'Bucket %s could not be created.','backwpup'), $_POST[ 's3newbucket' ] ), TRUE );
252
 
336
  header( "Content-Disposition: attachment; filename=" . basename( $get_file ) . ";" );
337
  header( "Content-Transfer-Encoding: binary" );
338
  header( "Content-Length: " . $s3file->header->_info->size_download );
339
+ @set_time_limit( 300 );
340
  echo $s3file->body;
341
  die();
342
  }
inc/class-destination-s3.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- // Amazon S3 SDK v2.5.1
3
  // http://aws.amazon.com/de/sdkforphp2/
4
  // https://github.com/aws/aws-sdk-php
5
 
@@ -28,6 +28,8 @@ class BackWPup_Destination_S3 extends BackWPup_Destinations {
28
  return 'https://s3-us-west-2.amazonaws.com';
29
  case 'eu-west-1':
30
  return 'https://s3-eu-west-1.amazonaws.com';
 
 
31
  case 'ap-northeast-1':
32
  return 'https://s3-ap-northeast-1.amazonaws.com';
33
  case 'ap-southeast-1':
@@ -40,10 +42,10 @@ class BackWPup_Destination_S3 extends BackWPup_Destinations {
40
  return 'https:/cn-north-1.amazonaws.com';
41
  case 'google-storage':
42
  return 'https://storage.googleapis.com';
43
- case 'hosteurope':
44
- return 'https://cs.hosteurope.de';
45
  case 'dreamhost':
46
  return 'https://objects.dreamhost.com';
 
 
47
  default:
48
  return '';
49
  }
@@ -76,14 +78,15 @@ class BackWPup_Destination_S3 extends BackWPup_Destinations {
76
  <option value="us-west-1" <?php selected( 'us-west-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: US West (Northern California)', 'backwpup' ); ?></option>
77
  <option value="us-west-2" <?php selected( 'us-west-2', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: US West (Oregon)', 'backwpup' ); ?></option>
78
  <option value="eu-west-1" <?php selected( 'eu-west-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: EU (Ireland)', 'backwpup' ); ?></option>
 
79
  <option value="ap-northeast-1" <?php selected( 'ap-northeast-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: Asia Pacific (Tokyo)', 'backwpup' ); ?></option>
80
  <option value="ap-southeast-1" <?php selected( 'ap-southeast-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: Asia Pacific (Singapore)', 'backwpup' ); ?></option>
81
  <option value="ap-southeast-2" <?php selected( 'ap-southeast-2', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: Asia Pacific (Sydney)', 'backwpup' ); ?></option>
82
  <option value="sa-east-1" <?php selected( 'sa-east-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: South America (Sao Paulo)', 'backwpup' ); ?></option>
83
  <option value="cn-north-1" <?php selected( 'cn-north-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: China (Beijing)', 'backwpup' ); ?></option>
84
  <option value="google-storage" <?php selected( 'google-storage', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Google Storage (Interoperable Access)', 'backwpup' ); ?></option>
85
- <option value="hosteurope" <?php selected( 'hosteurope', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Hosteurope Cloud Storage', 'backwpup' ); ?></option>
86
  <option value="dreamhost" <?php selected( 'dreamhost', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Dream Host Cloud Storage', 'backwpup' ); ?></option>
 
87
  </select>
88
  </td>
89
  </tr>
@@ -328,7 +331,7 @@ class BackWPup_Destination_S3 extends BackWPup_Destinations {
328
  header( "Content-Disposition: attachment; filename=" . basename( $get_file ) . ";" );
329
  header( "Content-Transfer-Encoding: binary" );
330
  header( "Content-Length: " . $s3file[ 'ContentLength' ] );
331
- @set_time_limit( 0 );
332
  $body = $s3file->get( 'Body' );
333
  $body->rewind();
334
  while ( $filedata = $body->read( 1024 ) ) {
@@ -376,17 +379,15 @@ class BackWPup_Destination_S3 extends BackWPup_Destinations {
376
  return TRUE;
377
  }
378
 
379
- if ( $job_object->job[ 's3multipart' ] ) {
380
  //Check for aboded Multipart Uploads
381
  $job_object->log( __( 'Checking for not aborted multipart Uploads&#160;&hellip;', 'backwpup' ) );
382
- $multipart_uploads = $s3->listMultipartUploads( array( 'Bucket' => $job_object->job[ 's3bucket' ] ) );
383
  $uploads = $multipart_uploads->get( 'Uploads' );
384
  if ( ! empty( $uploads ) ) {
385
  foreach( $uploads as $upload ) {
386
- if ( empty( $job_object->steps_data[ $job_object->step_working ][ 'UploadId' ] ) || $job_object->steps_data[ $job_object->step_working ][ 'UploadId' ] != $upload[ 'UploadId' ] ) {
387
- $s3->abortMultipartUpload( array( 'Bucket' => $job_object->job[ 's3bucket' ], 'Key' => $upload[ 'Key' ], 'UploadId' => $upload[ 'UploadId' ] ) );
388
- $job_object->log( sprintf( __( 'Upload for %s aborted.', 'backwpup' ), $upload[ 'Key' ] ) );
389
- }
390
  }
391
  }
392
  }
1
  <?php
2
+ // Amazon S3 SDK v2.6.1
3
  // http://aws.amazon.com/de/sdkforphp2/
4
  // https://github.com/aws/aws-sdk-php
5
 
28
  return 'https://s3-us-west-2.amazonaws.com';
29
  case 'eu-west-1':
30
  return 'https://s3-eu-west-1.amazonaws.com';
31
+ case 'eu-central-1':
32
+ return 'https://s3-eu-central-1.amazonaws.com';
33
  case 'ap-northeast-1':
34
  return 'https://s3-ap-northeast-1.amazonaws.com';
35
  case 'ap-southeast-1':
42
  return 'https:/cn-north-1.amazonaws.com';
43
  case 'google-storage':
44
  return 'https://storage.googleapis.com';
 
 
45
  case 'dreamhost':
46
  return 'https://objects.dreamhost.com';
47
+ case 'greenqloud':
48
+ return 'http://s.greenqloud.com';
49
  default:
50
  return '';
51
  }
78
  <option value="us-west-1" <?php selected( 'us-west-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: US West (Northern California)', 'backwpup' ); ?></option>
79
  <option value="us-west-2" <?php selected( 'us-west-2', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: US West (Oregon)', 'backwpup' ); ?></option>
80
  <option value="eu-west-1" <?php selected( 'eu-west-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: EU (Ireland)', 'backwpup' ); ?></option>
81
+ <option value="eu-central-1" <?php selected( 'eu-central-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: EU (Germany)', 'backwpup' ); ?></option>
82
  <option value="ap-northeast-1" <?php selected( 'ap-northeast-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: Asia Pacific (Tokyo)', 'backwpup' ); ?></option>
83
  <option value="ap-southeast-1" <?php selected( 'ap-southeast-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: Asia Pacific (Singapore)', 'backwpup' ); ?></option>
84
  <option value="ap-southeast-2" <?php selected( 'ap-southeast-2', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: Asia Pacific (Sydney)', 'backwpup' ); ?></option>
85
  <option value="sa-east-1" <?php selected( 'sa-east-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: South America (Sao Paulo)', 'backwpup' ); ?></option>
86
  <option value="cn-north-1" <?php selected( 'cn-north-1', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Amazon S3: China (Beijing)', 'backwpup' ); ?></option>
87
  <option value="google-storage" <?php selected( 'google-storage', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Google Storage (Interoperable Access)', 'backwpup' ); ?></option>
 
88
  <option value="dreamhost" <?php selected( 'dreamhost', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'Dream Host Cloud Storage', 'backwpup' ); ?></option>
89
+ <option value="greenqloud" <?php selected( 'greenqloud', BackWPup_Option::get( $jobid, 's3region' ), TRUE ) ?>><?php _e( 'GreenQloud Storage Qloud', 'backwpup' ); ?></option>
90
  </select>
91
  </td>
92
  </tr>
331
  header( "Content-Disposition: attachment; filename=" . basename( $get_file ) . ";" );
332
  header( "Content-Transfer-Encoding: binary" );
333
  header( "Content-Length: " . $s3file[ 'ContentLength' ] );
334
+ @set_time_limit( 300 );
335
  $body = $s3file->get( 'Body' );
336
  $body->rewind();
337
  while ( $filedata = $body->read( 1024 ) ) {
379
  return TRUE;
380
  }
381
 
382
+ if ( $job_object->job[ 's3multipart' ] && empty( $job_object->steps_data[ $job_object->step_working ][ 'UploadId' ] ) ) {
383
  //Check for aboded Multipart Uploads
384
  $job_object->log( __( 'Checking for not aborted multipart Uploads&#160;&hellip;', 'backwpup' ) );
385
+ $multipart_uploads = $s3->listMultipartUploads( array( 'Bucket' => $job_object->job[ 's3bucket' ], 'Prefix' => $job_object->job[ 's3dir' ] ) );
386
  $uploads = $multipart_uploads->get( 'Uploads' );
387
  if ( ! empty( $uploads ) ) {
388
  foreach( $uploads as $upload ) {
389
+ $s3->abortMultipartUpload( array( 'Bucket' => $job_object->job[ 's3bucket' ], 'Key' => $upload[ 'Key' ], 'UploadId' => $upload[ 'UploadId' ] ) );
390
+ $job_object->log( sprintf( __( 'Upload for %s aborted.', 'backwpup' ), $upload[ 'Key' ] ) );
 
 
391
  }
392
  }
393
  }
inc/class-destination-sugarsync.php CHANGED
@@ -1,879 +1,879 @@
1
- <?php
2
- /**
3
- *
4
- */
5
- class BackWPup_Destination_SugarSync extends BackWPup_Destinations {
6
-
7
- public static $backwpup_job_object = NULL;
8
-
9
- /**
10
- * @return array
11
- */
12
- public function option_defaults() {
13
- return array( 'sugarrefreshtoken' => '', 'sugarroot' => '', 'sugardir' => trailingslashit( sanitize_file_name( get_bloginfo( 'name' ) ) ), 'sugarmaxbackups' => 15 );
14
- }
15
-
16
-
17
- /**
18
- * @param $jobid
19
- */
20
- public function edit_tab( $jobid ) {
21
- ?>
22
- <h3 class="title"><?php _e( 'Sugarsync Login', 'backwpup' ); ?></h3>
23
- <p></p>
24
- <table class="form-table">
25
-
26
- <?php if ( ! BackWPup_Option::get( $jobid, 'sugarrefreshtoken' ) ) { ?>
27
- <tr>
28
- <th scope="row"><?php _e( 'Authentication', 'backwpup' ); ?></th>
29
- <td>
30
- <label for="sugaremail"><?php _e( 'Email address:', 'backwpup' ); ?><br/>
31
- <input id="sugaremail" name="sugaremail" type="text"
32
- value="<?php if ( isset( $_POST[ 'sugaremail' ] ) ) echo $_POST[ 'sugaremail' ];?>" class="large-text" autocomplete="off" /></label>
33
- <br/>
34
- <label for="sugarpass"><?php _e( 'Password:', 'backwpup' ); ?><br/>
35
- <input id="sugarpass" name="sugarpass" type="password"
36
- value="<?php if ( isset( $_POST[ 'sugarpass' ] ) ) echo $_POST[ 'sugarpass' ];?>" class="large-text" autocomplete="off" /></label>
37
- <br/>
38
- <br/>
39
- <input type="submit" id="idauthbutton" name="authbutton" class="button-primary" accesskey="d"
40
- value="<?php _e( 'Authenticate with Sugarsync!', 'backwpup' ); ?>"/>
41
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="authbutton" class="button"
42
- value="<?php _e( 'Create Sugarsync account', 'backwpup' ); ?>"/>
43
- </td>
44
- </tr>
45
- <?php } else { ?>
46
- <tr>
47
- <th scope="row"><label for="idauthbutton"><?php _e( 'Authentication', 'backwpup' ); ?></label></th>
48
- <td>
49
- <span style="color:green;"><?php _e( 'Authenticated!', 'backwpup' ); ?></span>
50
- <input type="submit" id="idauthbutton" name="authbutton" class="button-primary" accesskey="d"
51
- value="<?php _e( 'Delete Sugarsync authentication!', 'backwpup' ); ?>" />
52
- </td>
53
- </tr>
54
- <?php } ?>
55
- </table>
56
-
57
- <h3 class="title"><?php _e( 'SugarSync Root', 'backwpup' ); ?></h3>
58
- <p></p>
59
- <table class="form-table">
60
- <tr>
61
- <th scope="row"><label for="sugarroot"><?php _e( 'Sync folder selection', 'backwpup' ); ?></label></th>
62
- <td>
63
- <?php
64
- try {
65
- $sugarsync = new BackWPup_Destination_SugarSync_API( BackWPup_Option::get( $jobid, 'sugarrefreshtoken' ) );
66
- $user = $sugarsync->user();
67
- $syncfolders = $sugarsync->get( $user->syncfolders );
68
- if ( ! is_object( $syncfolders ) )
69
- echo '<span style="color:red;">' . __( 'No Syncfolders found!', 'backwpup' ) . '</span>';
70
- }
71
- catch ( Exception $e ) {
72
- echo '<span style="color:red;">' . $e->getMessage() . '</span>';
73
- }
74
- if ( isset( $syncfolders ) && is_object( $syncfolders ) ) {
75
- echo '<select name="sugarroot" id="sugarroot">';
76
- foreach ( $syncfolders->collection as $roots ) {
77
- echo "<option " . selected( strtolower( BackWPup_Option::get( $jobid, 'sugarroot' ) ), strtolower( $roots->ref ), FALSE ) . " value=\"" . $roots->ref . "\">" . $roots->displayName . "</option>";
78
- }
79
- echo '</select>';
80
- }
81
- ?>
82
- </td>
83
- </tr>
84
- </table>
85
-
86
- <h3 class="title"><?php _e( 'Backup settings', 'backwpup' ); ?></h3>
87
- <p></p>
88
- <table class="form-table">
89
- <tr>
90
- <th scope="row"><label for="idsugardir"><?php _e( 'Folder in root', 'backwpup' ); ?></label></th>
91
- <td>
92
- <input id="idsugardir" name="sugardir" type="text" value="<?php echo BackWPup_Option::get( $jobid, 'sugardir' ); ?>" class="regular-text" />
93
- </td>
94
- </tr>
95
- <tr>
96
- <th scope="row"><?php _e( 'File Deletion', 'backwpup' ); ?></th>
97
- <td>
98
- <?php
99
- if ( BackWPup_Option::get( $jobid, 'backuptype' ) == 'archive' ) {
100
- ?>
101
- <label for="idsugarmaxbackups"><input id="idsugarmaxbackups" name="sugarmaxbackups" type="text" size="3" value="<?php echo BackWPup_Option::get( $jobid, 'sugarmaxbackups' );?>" class="small-text help-tip" title="<?php esc_attr_e( 'Oldest files will be deleted first. 0 = no deletion', 'backwpup' ); ?>" />&nbsp;
102
- <?php _e( 'Number of files to keep in folder.', 'backwpup' ); ?></label>
103
- <?php } else { ?>
104
- <label for="idsugarsyncnodelete"><input class="checkbox" value="1"
105
- type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'sugarsyncnodelete' ), TRUE ); ?>
106
- name="sugarsyncnodelete" id="idsugarsyncnodelete" /> <?php _e( 'Do not delete files while syncing to destination!', 'backwpup' ); ?></label>
107
- <?php } ?>
108
- </td>
109
- </tr>
110
- </table>
111
- <?php
112
- }
113
-
114
-
115
- /**
116
- * @param $jobid
117
- */
118
- public function edit_form_post_save( $jobid ) {
119
-
120
-
121
- if ( ! empty( $_POST[ 'sugaremail' ] ) && ! empty( $_POST[ 'sugarpass' ] ) && $_POST[ 'authbutton' ] == __( 'Authenticate with Sugarsync!', 'backwpup' ) ) {
122
- try {
123
- $sugarsync = new BackWPup_Destination_SugarSync_API();
124
- $refresh_token = $sugarsync->get_Refresh_Token( $_POST[ 'sugaremail' ], $_POST[ 'sugarpass' ] );
125
- if ( ! empty( $refresh_token ) )
126
- BackWPup_Option::update( $jobid, 'sugarrefreshtoken', $refresh_token );
127
- }
128
- catch ( Exception $e ) {
129
- BackWPup_Admin::message( 'SUGARSYNC: ' . $e->getMessage(), TRUE );
130
- }
131
- }
132
-
133
- if ( isset( $_POST[ 'authbutton' ] ) && $_POST[ 'authbutton' ] == __( 'Delete Sugarsync authentication!', 'backwpup' ) ) {
134
- BackWPup_Option::delete( $jobid, 'sugarrefreshtoken' );
135
- }
136
-
137
- if ( isset( $_POST[ 'authbutton' ] ) && $_POST[ 'authbutton' ] == __( 'Create Sugarsync account', 'backwpup' ) ) {
138
- try {
139
- $sugarsync = new BackWPup_Destination_SugarSync_API();
140
- $sugarsync->create_account( $_POST[ 'sugaremail' ], $_POST[ 'sugarpass' ] );
141
- }
142
- catch ( Exception $e ) {
143
- BackWPup_Admin::message( 'SUGARSYNC: ' . $e->getMessage(), TRUE );
144
- }
145
- }
146
-
147
- $_POST[ 'sugardir' ] = trailingslashit( str_replace( '//', '/', str_replace( '\\', '/', trim( stripslashes( $_POST[ 'sugardir' ] ) ) ) ) );
148
- if ( substr( $_POST[ 'sugardir' ], 0, 1 ) == '/' )
149
- $_POST[ 'sugardir' ] = substr( $_POST[ 'sugardir' ], 1 );
150
- if ( $_POST[ 'sugardir' ] == '/' )
151
- $_POST[ 'sugardir' ] = '';
152
- BackWPup_Option::update( $jobid, 'sugardir', $_POST[ 'sugardir' ] );
153
-
154
- BackWPup_Option::update( $jobid, 'sugarroot', isset( $_POST[ 'sugarroot' ] ) ? $_POST[ 'sugarroot' ] : '' );
155
- BackWPup_Option::update( $jobid, 'sugarmaxbackups', isset( $_POST[ 'sugarmaxbackups' ] ) ? (int)$_POST[ 'sugarmaxbackups' ] : 0 );
156
- }
157
-
158
- /**
159
- * @param $jobdest
160
- * @param $backupfile
161
- */
162
- public function file_delete( $jobdest, $backupfile ) {
163
-
164
- $files = get_site_transient( 'backwpup_' . strtolower( $jobdest ) );
165
- list( $jobid, $dest ) = explode( '_', $jobdest );
166
-
167
- if ( BackWPup_Option::get( $jobid, 'sugarrefreshtoken' ) ) {
168
- try {
169
- $sugarsync = new BackWPup_Destination_SugarSync_API( BackWPup_Option::get( $jobid, 'sugarrefreshtoken' ) );
170
- $sugarsync->delete( urldecode( $backupfile ) );
171
- //update file list
172
- foreach ( $files as $key => $file ) {
173
- if ( is_array( $file ) && $file[ 'file' ] == $backupfile )
174
- unset( $files[ $key ] );
175
- }
176
- unset( $sugarsync );
177
- }
178
- catch ( Exception $e ) {
179
- BackWPup_Admin::message( 'SUGARSYNC: ' . $e->getMessage(), TRUE );
180
- }
181
- }
182
-
183
- set_site_transient( 'backwpup_' . strtolower( $jobdest ), $files, 60 * 60 * 24 * 7 );
184
- }
185
-
186
- /**
187
- * @param $jobid
188
- * @param $get_file
189
- */
190
- public function file_download( $jobid, $get_file ) {
191
-
192
- try {
193
- $sugarsync = new BackWPup_Destination_SugarSync_API( BackWPup_Option::get( $jobid, 'sugarrefreshtoken' ) );
194
- $response = $sugarsync->get( urldecode( $get_file ) );
195
- header( "Pragma: public" );
196
- header( "Expires: 0" );
197
- header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
198
- header( "Content-Type: application/octet-stream" );
199
- header( "Content-Disposition: attachment; filename=" . (string)$response->displayName . ";" );
200
- header( "Content-Transfer-Encoding: binary" );
201
- header( "Content-Length: " . (int)$response->size );
202
- @set_time_limit( 0 );
203
- echo $sugarsync->download( urldecode( $get_file ) );
204
- die();
205
- }
206
- catch ( Exception $e ) {
207
- die( $e->getMessage() );
208
- }
209
- }
210
-
211
- /**
212
- * @param $jobdest
213
- * @return mixed
214
- */
215
- public function file_get_list( $jobdest ) {
216
-
217
- return get_site_transient( 'backwpup_' . strtolower( $jobdest ) );
218
- }
219
-
220
- /**
221
- * @param $job_object
222
- * @return bool
223
- */
224
- public function job_run_archive( &$job_object ) {
225
-
226
- $job_object->substeps_todo = 2 + $job_object->backup_filesize;
227
- $job_object->log( sprintf( __( '%d. Try to send backup to SugarSync&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ), E_USER_NOTICE );
228
-
229
- try {
230
- $sugarsync = new BackWPup_Destination_SugarSync_API( $job_object->job[ 'sugarrefreshtoken' ] );
231
- //Check Quota
232
- $user = $sugarsync->user();
233
- if ( ! empty( $user->nickname ) )
234
- $job_object->log( sprintf( __( 'Authenticated to SugarSync with nickname %s', 'backwpup' ), $user->nickname ), E_USER_NOTICE );
235
- $sugarsyncfreespase = (float)$user->quota->limit - (float)$user->quota->usage; //float fixes bug for display of no free space
236
- if ( $job_object->backup_filesize > $sugarsyncfreespase ) {
237
- $job_object->log( sprintf( _x( 'Not enough disk space available on SugarSync. Available: %s.','Available space on SugarSync', 'backwpup' ), size_format( $sugarsyncfreespase, 2 ) ), E_USER_ERROR );
238
- $job_object->substeps_todo = 1 + $job_object->backup_filesize;
239
-
240
- return TRUE;
241
- }
242
- else {
243
- $job_object->log( sprintf( __( '%s available at SugarSync', 'backwpup' ), size_format( $sugarsyncfreespase, 2 ) ), E_USER_NOTICE );
244
- }
245
- //Create and change folder
246
- $sugarsync->mkdir( $job_object->job[ 'sugardir' ], $job_object->job[ 'sugarroot' ] );
247
- $dirid = $sugarsync->chdir( $job_object->job[ 'sugardir' ], $job_object->job[ 'sugarroot' ] );
248
- //Upload to SugarSync
249
- $job_object->substeps_done = 0;
250
- $job_object->log( __( 'Starting upload to SugarSync&#160;&hellip;', 'backwpup' ), E_USER_NOTICE );
251
- self::$backwpup_job_object = &$job_object;
252
- $reponse = $sugarsync->upload( $job_object->backup_folder . $job_object->backup_file );
253
- if ( is_object( $reponse ) ) {
254
- if ( ! empty( $job_object->job[ 'jobid' ] ) )
255
- BackWPup_Option::update( $job_object->job[ 'jobid' ], 'lastbackupdownloadurl', network_admin_url( 'admin.php' ) . '?page=backwpupbackups&action=downloadsugarsync&file=' . (string)$reponse . '&jobid=' . $job_object->job[ 'jobid' ] );
256
- $job_object->substeps_done ++;
257
- $job_object->log( sprintf( __( 'Backup transferred to %s', 'backwpup' ), 'https://' . $user->nickname . '.sugarsync.com/' . $sugarsync->showdir( $dirid ) . $job_object->backup_file ), E_USER_NOTICE );
258
- }
259
- else {
260
- $job_object->log( __( 'Cannot transfer backup to SugarSync!', 'backwpup' ), E_USER_ERROR );
261
-
262
- return FALSE;
263
- }
264
-
265
- $backupfilelist = array();
266
- $files = array();
267
- $filecounter = 0;
268
- $dir = $sugarsync->showdir( $dirid );
269
- $getfiles = $sugarsync->getcontents( 'file' );
270
- if ( is_object( $getfiles ) ) {
271
- foreach ( $getfiles->file as $getfile ) {
272
- $getfile->displayName = utf8_decode( (string)$getfile->displayName );
273
- if ( $job_object->is_backup_archive( $getfile->displayName ) )
274
- $backupfilelist[ strtotime( (string)$getfile->lastModified ) ] = (string)$getfile->ref;
275
- $files[ $filecounter ][ 'folder' ] = 'https://' . (string)$user->nickname . '.sugarsync.com/' . $dir;
276
- $files[ $filecounter ][ 'file' ] = (string)$getfile->ref;
277
- $files[ $filecounter ][ 'filename' ] = (string)$getfile->displayName;
278
- $files[ $filecounter ][ 'downloadurl' ] = network_admin_url( 'admin.php' ) . '?page=backwpupbackups&action=downloadsugarsync&file=' . (string)$getfile->ref . '&jobid=' . $job_object->job[ 'jobid' ];
279
- $files[ $filecounter ][ 'filesize' ] = (int)$getfile->size;
280
- $files[ $filecounter ][ 'time' ] = strtotime( (string)$getfile->lastModified ) + ( get_option( 'gmt_offset' ) * 3600 );
281
- $filecounter ++;
282
- }
283
- }
284
- if ( ! empty( $job_object->job[ 'sugarmaxbackups' ] ) && $job_object->job[ 'sugarmaxbackups' ] > 0 ) { //Delete old backups
285
- if ( count( $backupfilelist ) > $job_object->job[ 'sugarmaxbackups' ] ) {
286
- ksort( $backupfilelist );
287
- $numdeltefiles = 0;
288
- while ( $file = array_shift( $backupfilelist ) ) {
289
- if ( count( $backupfilelist ) < $job_object->job[ 'sugarmaxbackups' ] )
290
- break;
291
- $sugarsync->delete( $file ); //delete files on Cloud
292
- foreach ( $files as $key => $filedata ) {
293
- if ( $filedata[ 'file' ] == $file )
294
- unset( $files[ $key ] );
295
- }
296
- $numdeltefiles ++;
297
- }
298
- if ( $numdeltefiles > 0 )
299
- $job_object->log( sprintf( _n( 'One file deleted on SugarSync folder', '%d files deleted on SugarSync folder', $numdeltefiles, 'backwpup' ), $numdeltefiles ), E_USER_NOTICE );
300
- }
301
- }
302
- set_site_transient( 'BackWPup_' . $job_object->job[ 'jobid' ] . '_SUGARSYNC', $files, 60 * 60 * 24 * 7 );
303
- }
304
- catch ( Exception $e ) {
305
- $job_object->log( E_USER_ERROR, sprintf( __( 'SugarSync API: %s', 'backwpup' ), htmlentities( $e->getMessage() ) ), $e->getFile(), $e->getLine() );
306
-
307
- return FALSE;
308
- }
309
- $job_object->substeps_done ++;
310
-
311
- return TRUE;
312
- }
313
-
314
- /**
315
- * @param $job_object
316
- * @return bool
317
- */
318
- public function can_run( $job_object ) {
319
-
320
- if ( empty( $job_object->job[ 'sugarrefreshtoken' ] ) )
321
- return FALSE;
322
-
323
- if ( empty( $job_object->job[ 'sugarroot' ] ) )
324
- return FALSE;
325
-
326
- return TRUE;
327
- }
328
- }
329
-
330
- /**
331
- *
332
- */
333
- class BackWPup_Destination_SugarSync_API {
334
-
335
- /**
336
- * url for the sugarsync-api
337
- */
338
- const API_URL = 'https://api.sugarsync.com';
339
-
340
- /**
341
- *
342
- * @var string
343
- */
344
- protected $folder = '';
345
-
346
- /**
347
- * @var mixed|string
348
- */
349
- protected $encoding = 'UTF-8';
350
-
351
- /**
352
- * @var null|string
353
- */
354
- protected $refresh_token = '';
355
-
356
- /**
357
- * The Auth-token
358
- *
359
- * @var string
360
- */
361
- protected $access_token = '';
362
-
363
- // class methods
364
- /**
365
- * Default constructor/Auth
366
- */
367
- public function __construct( $refresh_token = NULL ) {
368
-
369
- //auth xml
370
- $this->encoding = mb_internal_encoding();
371
-
372
- //get access token
373
- if ( isset( $refresh_token ) and ! empty( $refresh_token ) ) {
374
- $this->refresh_token = $refresh_token;
375
- $this->get_Access_Token();
376
- }
377
- }
378
-
379
- /**
380
- * Make the call
381
- *
382
- * @return string
383
- *
384
- * @param string $url The url to call.
385
- * @param string $data
386
- * @param string $method
387
- * @throws BackWPup_Destination_SugarSync_API_Exception
388
- * @internal param $string [optiona] $data File on put, xml on post.
389
- * @internal param $string [optional] $method The method to use. Possible values are GET, POST, PUT, DELETE.
390
- */
391
- private function doCall( $url, $data = '', $method = 'GET' ) {
392
-
393
- // allowed methods
394
- $allowedMethods = array( 'GET', 'POST', 'PUT', 'DELETE' );
395
-
396
- // redefine
397
- $url = (string)$url;
398
- $method = (string)$method;
399
-
400
- // validate method
401
- if ( ! in_array( $method, $allowedMethods ) )
402
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Unknown method (' . $method . '). Allowed methods are: ' . implode( ', ', $allowedMethods ) );
403
-
404
- // check auth token
405
- if ( empty( $this->access_token ) )
406
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Auth Token not set correctly!' );
407
- else
408
- $headers[ ] = 'Authorization: ' . $this->access_token;
409
- $headers[ ] = 'Expect:';
410
-
411
- // init
412
- $curl = curl_init();
413
- //set options
414
- curl_setopt( $curl, CURLOPT_URL, $url );
415
- curl_setopt( $curl, CURLOPT_USERAGENT, BackWPup::get_plugin_data( 'User-Agent' ) );
416
- if ( ini_get( 'open_basedir' ) == '' ) curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, TRUE );
417
- curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE );
418
- if ( BackWPup::get_plugin_data( 'cacert' ) ) {
419
- curl_setopt( $curl, CURLOPT_SSLVERSION, 3 );
420
- curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, TRUE );
421
- curl_setopt( $curl, CURLOPT_CAINFO, BackWPup::get_plugin_data( 'cacert' ) );
422
- curl_setopt( $curl, CURLOPT_CAPATH, dirname( BackWPup::get_plugin_data( 'cacert' ) ) );
423
- } else {
424
- curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, FALSE );
425
- }
426
-
427
- if ( $method == 'POST' ) {
428
- $headers[ ] = 'Content-Type: application/xml; charset=UTF-8';
429
- curl_setopt( $curl, CURLOPT_POSTFIELDS, $data );
430
- curl_setopt( $curl, CURLOPT_POST, TRUE );
431
- $headers[ ] = 'Content-Length: ' . strlen( $data );
432
- }
433
- elseif ( $method == 'PUT' ) {
434
- if ( is_readable( $data ) ) {
435
- $headers[ ] = 'Content-Length: ' . filesize( $data );
436
- $datafilefd = fopen( $data, 'r' );
437
- curl_setopt( $curl, CURLOPT_PUT, TRUE );
438
- curl_setopt( $curl, CURLOPT_INFILE, $datafilefd );
439
- curl_setopt( $curl, CURLOPT_INFILESIZE, filesize( $data ) );
440
- curl_setopt( $curl, CURLOPT_READFUNCTION, array( BackWPup_Destination_SugarSync::$backwpup_job_object, 'curl_read_callback' ) );
441
- }
442
- else {
443
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Is not a readable file:' . $data );
444
- }
445
- }
446
- elseif ( $method == 'DELETE' ) {
447
- curl_setopt( $curl, CURLOPT_CUSTOMREQUEST, 'DELETE' );
448
- }
449
- else {
450
- curl_setopt( $curl, CURLOPT_POST, FALSE );
451
- }
452
-
453
- // set headers
454
- curl_setopt( $curl, CURLOPT_HTTPHEADER, $headers );
455
- curl_setopt( $curl, CURLINFO_HEADER_OUT, TRUE );
456
- // execute
457
- $response = curl_exec( $curl );
458
- $curlgetinfo = curl_getinfo( $curl );
459
-
460
- // fetch curl errors
461
- if ( curl_errno( $curl ) != 0 )
462
- throw new BackWPup_Destination_SugarSync_API_Exception( 'cUrl Error: ' . curl_error( $curl ) );
463
- curl_close( $curl );
464
- if ( ! empty( $datafilefd ) && is_resource( $datafilefd ) )
465
- fclose( $datafilefd );
466
-
467
- if ( $curlgetinfo[ 'http_code' ] >= 200 && $curlgetinfo[ 'http_code' ] < 300 ) {
468
- if ( FALSE !== stripos( $curlgetinfo[ 'content_type' ], 'xml' ) && ! empty( $response ) )
469
- return simplexml_load_string( $response );
470
- else
471
- return $response;
472
- }
473
- else {
474
- if ( $curlgetinfo[ 'http_code' ] == 401 )
475
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' Authorization required.' );
476
- elseif ( $curlgetinfo[ 'http_code' ] == 403 )
477
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' (Forbidden) Authentication failed.' );
478
- elseif ( $curlgetinfo[ 'http_code' ] == 404 )
479
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' Not found' );
480
- else
481
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] );
482
- }
483
- }
484
-
485
-
486
- /**
487
- * @return string
488
- * @throws BackWPup_Destination_SugarSync_API_Exception
489
- */
490
- private function get_Access_Token() {
491
-
492
- $auth = '<?xml version="1.0" encoding="UTF-8" ?>';
493
- $auth .= '<tokenAuthRequest>';
494
- $auth .= '<accessKeyId>' . get_site_option( 'backwpup_cfg_sugarsynckey', base64_decode( "TlRBek1EY3lOakV6TkRrMk1URXhNemM0TWpJ" ) ) . '</accessKeyId>';
495
- $auth .= '<privateAccessKey>' . BackWPup_Encryption::decrypt( get_site_option( 'backwpup_cfg_sugarsyncsecret', base64_decode( "TkRFd01UazRNVEpqTW1Ga05EaG1NR0k1TVRFNFpqa3lPR1V6WlRVMk1tTQ==" ) ) ) . '</privateAccessKey>';
496
- $auth .= '<refreshToken>' . trim( $this->refresh_token ) . '</refreshToken>';
497
- $auth .= '</tokenAuthRequest>';
498
- // init
499
- $curl = curl_init();
500
- //set options
501
- curl_setopt( $curl, CURLOPT_URL, self::API_URL . '/authorization' );
502
- curl_setopt( $curl, CURLOPT_USERAGENT, BackWPup::get_plugin_data( 'User-Agent' ) );
503
- if ( ini_get( 'open_basedir' ) == '' ) curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, TRUE );
504
- curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE );
505
- if ( BackWPup::get_plugin_data( 'cacert' ) ) {
506
- curl_setopt( $curl, CURLOPT_SSLVERSION, 3 );
507
- curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, TRUE );
508
- curl_setopt( $curl, CURLOPT_CAINFO, BackWPup::get_plugin_data( 'cacert' ) );
509
- curl_setopt( $curl, CURLOPT_CAPATH, dirname( BackWPup::get_plugin_data( 'cacert' ) ) );
510
- } else {
511
- curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, FALSE );
512
- }
513
- curl_setopt( $curl, CURLOPT_HEADER, TRUE );
514
- curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Content-Type: application/xml; charset=UTF-8', 'Content-Length: ' . strlen( $auth ) ) );
515
- curl_setopt( $curl, CURLOPT_POSTFIELDS, $auth );
516
- curl_setopt( $curl, CURLOPT_POST, TRUE );
517
- // execute
518
- $response = curl_exec( $curl );
519
- $curlgetinfo = curl_getinfo( $curl );
520
- // fetch curl errors
521
- if ( curl_errno( $curl ) != 0 )
522
- throw new BackWPup_Destination_SugarSync_API_Exception( 'cUrl Error: ' . curl_error( $curl ) );
523
-
524
- curl_close( $curl );
525
-
526
- if ( $curlgetinfo[ 'http_code' ] >= 200 && $curlgetinfo[ 'http_code' ] < 300 ) {
527
- if ( preg_match( '/Location:(.*?)\r/i', $response, $matches ) )
528
- $this->access_token = trim( $matches[ 1 ] );
529
-
530
- return $this->access_token;
531
- }
532
- else {
533
- if ( $curlgetinfo[ 'http_code' ] == 401 )
534
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' Authorization required.' );
535
- elseif ( $curlgetinfo[ 'http_code' ] == 403 )
536
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' (Forbidden) Authentication failed.' );
537
- elseif ( $curlgetinfo[ 'http_code' ] == 404 )
538
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' Not found' );
539
- else
540
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] );
541
- }
542
- }
543
-
544
- /**
545
- * @param $email
546
- * @param $password
547
- * @return null|string
548
- * @throws BackWPup_Destination_SugarSync_API_Exception
549
- */
550
- public function get_Refresh_Token( $email, $password ) {
551
-
552
- $auth = '<?xml version="1.0" encoding="UTF-8" ?>';
553
- $auth .= '<appAuthorization>';
554
- $auth .= '<username>' . mb_convert_encoding( $email, 'UTF-8', $this->encoding ) . '</username>';
555
- $auth .= '<password>' . mb_convert_encoding( $password, 'UTF-8', $this->encoding ) . '</password>';
556
- $auth .= '<application>' . get_site_option( 'backwpup_cfg_sugarsyncappid', "/sc/5030726/449_18207099" ) . '</application>';
557
- $auth .= '<accessKeyId>' . get_site_option( 'backwpup_cfg_sugarsynckey',base64_decode( "TlRBek1EY3lOakV6TkRrMk1URXhNemM0TWpJ" ) ) . '</accessKeyId>';
558
- $auth .= '<privateAccessKey>' . BackWPup_Encryption::decrypt( get_site_option( 'backwpup_cfg_sugarsyncsecret', base64_decode( "TkRFd01UazRNVEpqTW1Ga05EaG1NR0k1TVRFNFpqa3lPR1V6WlRVMk1tTQ==" ) ) ) . '</privateAccessKey>';
559
- $auth .= '</appAuthorization>';
560
- // init
561
- $curl = curl_init();
562
- //set options
563
- curl_setopt( $curl, CURLOPT_URL, self::API_URL . '/app-authorization' );
564
- curl_setopt( $curl, CURLOPT_USERAGENT, BackWPup::get_plugin_data( 'User-Agent' ) );
565
- if ( ini_get( 'open_basedir' ) == '' ) curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, TRUE );
566
- curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE );
567
- if ( BackWPup::get_plugin_data( 'cacert' ) ) {
568
- curl_setopt( $curl, CURLOPT_SSLVERSION, 3 );
569
- curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, TRUE );
570
- curl_setopt( $curl, CURLOPT_CAINFO, BackWPup::get_plugin_data( 'cacert' ) );
571
- curl_setopt( $curl, CURLOPT_CAPATH, dirname( BackWPup::get_plugin_data( 'cacert' ) ) );
572
- } else {
573
- curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, FALSE );
574
- }
575
- curl_setopt( $curl, CURLOPT_HEADER, TRUE );
576
- curl_setopt( $curl, CURLOPT_POSTFIELDS, $auth );
577
- curl_setopt( $curl, CURLOPT_POST, TRUE );
578
- curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Content-Type: application/xml; charset=UTF-8', 'Content-Length: ' . strlen( $auth ) ) );
579
- // execute
580
- $response = curl_exec( $curl );
581
- $curlgetinfo = curl_getinfo( $curl );
582
- // fetch curl errors
583
- if ( curl_errno( $curl ) != 0 )
584
- throw new BackWPup_Destination_SugarSync_API_Exception( 'cUrl Error: ' . curl_error( $curl ) );
585
-
586
- curl_close( $curl );
587
-
588
- if ( $curlgetinfo[ 'http_code' ] >= 200 && $curlgetinfo[ 'http_code' ] < 300 ) {
589
- if ( preg_match( '/Location:(.*?)\r/i', $response, $matches ) )
590
- $this->refresh_token = trim( $matches[ 1 ] );
591
-
592
- return $this->refresh_token;
593
- }
594
- else {
595
- if ( $curlgetinfo[ 'http_code' ] == 401 )
596
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' Authorization required.' );
597
- elseif ( $curlgetinfo[ 'http_code' ] == 403 )
598
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' (Forbidden) Authentication failed.' );
599
- elseif ( $curlgetinfo[ 'http_code' ] == 404 )
600
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' Not found' );
601
- else
602
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] );
603
- }
604
- }
605
-
606
- /**
607
- * @param $email
608
- * @param $password
609
- * @throws BackWPup_Destination_SugarSync_API_Exception
610
- */
611
- public function create_account( $email, $password ) {
612
-
613
- $auth = '<?xml version="1.0" encoding="UTF-8" ?>';
614
- $auth .= '<user>';
615
- $auth .= '<email>' . mb_convert_encoding( $email, 'UTF-8', $this->encoding ) . '</email>';
616
- $auth .= '<password>' . mb_convert_encoding( $password, 'UTF-8', $this->encoding ) . '</password>';
617
- $auth .= '<accessKeyId>' . get_site_option( 'backwpup_cfg_sugarsynckey', base64_decode( "TlRBek1EY3lOakV6TkRrMk1URXhNemM0TWpJ" ) ) . '</accessKeyId>';
618
- $auth .= '<privateAccessKey>' . BackWPup_Encryption::decrypt( get_site_option( 'backwpup_cfg_sugarsyncsecret', base64_decode( "TkRFd01UazRNVEpqTW1Ga05EaG1NR0k1TVRFNFpqa3lPR1V6WlRVMk1tTQ==" ) ) ) . '</privateAccessKey>';
619
- $auth .= '</user>';
620
- // init
621
- $curl = curl_init();
622
- //set options
623
- curl_setopt( $curl, CURLOPT_URL, 'https://provisioning-api.sugarsync.com/users' );
624
- curl_setopt( $curl, CURLOPT_USERAGENT, BackWPup::get_plugin_data( 'User-Agent' ) );
625
- if ( ini_get( 'open_basedir' ) == '' ) curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, TRUE );
626
- curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE );
627
- if ( BackWPup::get_plugin_data( 'cacert' ) ) {
628
- curl_setopt( $curl, CURLOPT_SSLVERSION, 3 );
629
- curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, TRUE );
630
- curl_setopt( $curl, CURLOPT_CAINFO, BackWPup::get_plugin_data( 'cacert' ) );
631
- curl_setopt( $curl, CURLOPT_CAPATH, dirname( BackWPup::get_plugin_data( 'cacert' ) ) );
632
- } else {
633
- curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, FALSE );
634
- } curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, FALSE );
635
- curl_setopt( $curl, CURLOPT_HEADER, TRUE );
636
- curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Content-Type: application/xml; charset=UTF-8', 'Content-Length: ' . strlen( $auth ) ) );
637
- curl_setopt( $curl, CURLOPT_POSTFIELDS, $auth );
638
- curl_setopt( $curl, CURLOPT_POST, TRUE );
639
- // execute
640
- $response = curl_exec( $curl );
641
- $curlgetinfo = curl_getinfo( $curl );
642
- // fetch curl errors
643
- if ( curl_errno( $curl ) != 0 )
644
- throw new BackWPup_Destination_SugarSync_API_Exception( 'cUrl Error: ' . curl_error( $curl ) );
645
-
646
- curl_close( $curl );
647
-
648
- if ( $curlgetinfo[ 'http_code' ] == 201 ) {
649
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Account created.' );
650
- }
651
- else {
652
- if ( $curlgetinfo[ 'http_code' ] == 400 )
653
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' ' . substr( $response, $curlgetinfo[ 'header_size' ] ) );
654
- elseif ( $curlgetinfo[ 'http_code' ] == 401 )
655
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' Developer credentials cannot be verified. Either a developer with the specified accessKeyId does not exist or the privateKeyID does not match an assigned accessKeyId.' );
656
- elseif ( $curlgetinfo[ 'http_code' ] == 403 )
657
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' ' . substr( $response, $curlgetinfo[ 'header_size' ] ) );
658
- elseif ( $curlgetinfo[ 'http_code' ] == 503 )
659
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' ' . substr( $response, $curlgetinfo[ 'header_size' ] ) );
660
- else
661
- throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] );
662
- }
663
- }
664
-
665
- /**
666
- * @param $folder
667
- * @param string $root
668
- * @return string
669
- * @throws BackWPup_Destination_SugarSync_API_Exception
670
- */
671
- public function chdir( $folder, $root = '' ) {
672
-
673
- $folder = rtrim( $folder, '/' );
674
- if ( substr( $folder, 0, 1 ) == '/' || empty( $this->folder ) ) {
675
- if ( ! empty( $root ) )
676
- $this->folder = $root;
677
- else
678
- throw new BackWPup_Destination_SugarSync_API_Exception( 'chdir: root folder must set!' );
679
- }
680
- $folders = explode( '/', $folder );
681
- foreach ( $folders as $dir ) {
682
- if ( $dir == '..' ) {
683
- $contents = $this->doCall( $this->folder );
684
- if ( ! empty( $contents->parent ) )
685
- $this->folder = $contents->parent;
686
- }
687
- elseif ( ! empty( $dir ) && $dir != '.' ) {
688
- $isdir = FALSE;
689
- $contents = $this->getcontents( 'folder' );
690
- foreach ( $contents->collection as $collection ) {
691
- if ( strtolower( $collection->displayName ) == strtolower( $dir ) ) {
692
- $isdir = TRUE;
693
- $this->folder = $collection->ref;
694
- break;
695
- }
696
- }
697
- if ( ! $isdir )
698
- throw new BackWPup_Destination_SugarSync_API_Exception( 'chdir: Folder ' . $folder . ' not exitst' );
699
- }
700
- }
701
-
702
- return $this->folder;
703
- }
704
-
705
- /**
706
- * @param $folderid
707
- * @return string
708
- */
709
- public function showdir( $folderid ) {
710
-
711
- $showfolder = '';
712
- while ( $folderid ) {
713
- $contents = $this->doCall( $folderid );
714
- $showfolder = $contents->displayName . '/' . $showfolder;
715
- if ( isset( $contents->parent ) )
716
- $folderid = $contents->parent;
717
- else
718
- break;
719
- }
720
-
721
- return $showfolder;
722
- }
723
-
724
- /**
725
- * @param $folder
726
- * @param string $root
727
- * @return bool
728
- * @throws BackWPup_Destination_SugarSync_API_Exception
729
- */
730
- public function mkdir( $folder, $root = '' ) {
731
-
732
- $savefolder = $this->folder;
733
- $folder = rtrim( $folder, '/' );
734
- if ( substr( $folder, 0, 1 ) == '/' || empty( $this->folder ) ) {
735
- if ( ! empty( $root ) )
736
- $this->folder = $root;
737
- else
738
- throw new BackWPup_Destination_SugarSync_API_Exception( 'mkdir: root folder must set!' );
739
- }
740
- $folders = explode( '/', $folder );
741
- foreach ( $folders as $dir ) {
742
- if ( $dir == '..' ) {
743
- $contents = $this->doCall( $this->folder );
744
- if ( ! empty( $contents->parent ) )
745
- $this->folder = $contents->parent;
746
- }
747
- elseif ( ! empty( $dir ) && $dir != '.' ) {
748
- $isdir = FALSE;
749
- $contents = $this->getcontents( 'folder' );
750
- foreach ( $contents->collection as $collection ) {
751
- if ( strtolower( $collection->displayName ) == strtolower( $dir ) ) {
752
- $isdir = TRUE;
753
- $this->folder = $collection->ref;
754
- break;
755
- }
756
- }
757
- if ( ! $isdir ) {
758
- $this->doCall( $this->folder, '<?xml version="1.0" encoding="UTF-8"?><folder><displayName>' . mb_convert_encoding( $dir, 'UTF-8', $this->encoding ) . '</displayName></folder>', 'POST' );
759
- $contents = $this->getcontents( 'folder' );
760
- foreach ( $contents->collection as $collection ) {
761
- if ( strtolower( $collection->displayName ) == strtolower( $dir ) ) {
762
- $isdir = TRUE;
763
- $this->folder = $collection->ref;
764
- break;
765
- }
766
- }
767
- }
768
- }
769
- }
770
- $this->folder = $savefolder;
771
-
772
- return TRUE;
773
- }
774
-
775
-
776
- /**
777
- * @return string
778
- */
779
- public function user() {
780
- return $this->doCall( self::API_URL . '/user' );
781
- }
782
-
783
-
784
- /**
785
- * @param $url
786
- * @return string
787
- */
788
- public function get( $url ) {
789
- return $this->doCall( $url, '', 'GET' );
790
- }
791
-
792
- /**
793
- * @param $url
794
- * @return string
795
- */
796
- public function download( $url ) {
797
- return $this->doCall( $url . '/data' );
798
- }
799
-
800
- /**
801
- * @param $url
802
- * @return string
803
- */
804
- public function delete( $url ) {
805
- return $this->doCall( $url, '', 'DELETE' );
806
- }
807
-
808
-
809
- /**
810
- * @param string $type
811
- * @param int $start
812
- * @param int $max
813
- * @return string
814
- */
815
- public function getcontents( $type = '', $start = 0, $max = 500 ) {
816
-
817
- $parameters = '';
818
-
819
- if ( strtolower( $type ) == 'folder' || strtolower( $type ) == 'file' )
820
- $parameters .= 'type=' . strtolower( $type );
821
- if ( ! empty( $start ) && is_integer( $start ) ) {
822
- if ( ! empty( $parameters ) )
823
- $parameters .= '&';
824
- $parameters .= 'start=' . $start;
825
-
826
- }
827
- if ( ! empty( $max ) && is_integer( $max ) ) {
828
- if ( ! empty( $parameters ) )
829
- $parameters .= '&';
830
- $parameters .= 'max=' . $max;
831
- }
832
-
833
- $request = $this->doCall( $this->folder . '/contents?' . $parameters );
834
-
835
- return $request;
836
- }
837
-
838
- /**
839
- * @param $file
840
- * @param string $name
841
- * @return mixed
842
- */
843
- public function upload( $file, $name = '' ) {
844
-
845
- if ( empty( $name ) )
846
- $name = basename( $file );
847
-
848
- $xmlrequest = '<?xml version="1.0" encoding="UTF-8"?>';
849
- $xmlrequest .= '<file>';
850
- $xmlrequest .= '<displayName>' . mb_convert_encoding( $name, 'UTF-8', $this->encoding ) . '</displayName>';
851
-
852
- if ( ! is_readable( $file ) ) {
853
- $finfo = fopen( $file, 'r' );
854
- $xmlrequest .= '<mediaType>' . mime_content_type( $finfo ) . '</mediaType>';
855
- fclose( $finfo );
856
- }
857
-
858
- $xmlrequest .= '</file>';
859
-
860
- $this->doCall( $this->folder, $xmlrequest, 'POST' );
861
- $getfiles = $this->getcontents( 'file' );
862
- foreach ( $getfiles->file as $getfile ) {
863
- if ( $getfile->displayName == $name ) {
864
- $this->doCall( $getfile->ref . '/data', $file, 'PUT' );
865
-
866
- return $getfile->ref;
867
- }
868
- }
869
- }
870
- }
871
-
872
- /**
873
- * SugarSync Exception class
874
- *
875
- * @author Daniel Hüsken <daniel@huesken-net.de>
876
- */
877
- class BackWPup_Destination_SugarSync_API_Exception extends Exception {
878
-
879
- }
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ class BackWPup_Destination_SugarSync extends BackWPup_Destinations {
6
+
7
+ public static $backwpup_job_object = NULL;
8
+
9
+ /**
10
+ * @return array
11
+ */
12
+ public function option_defaults() {
13
+ return array( 'sugarrefreshtoken' => '', 'sugarroot' => '', 'sugardir' => trailingslashit( sanitize_file_name( get_bloginfo( 'name' ) ) ), 'sugarmaxbackups' => 15 );
14
+ }
15
+
16
+
17
+ /**
18
+ * @param $jobid
19
+ */
20
+ public function edit_tab( $jobid ) {
21
+ ?>
22
+ <h3 class="title"><?php _e( 'Sugarsync Login', 'backwpup' ); ?></h3>
23
+ <p></p>
24
+ <table class="form-table">
25
+
26
+ <?php if ( ! BackWPup_Option::get( $jobid, 'sugarrefreshtoken' ) ) { ?>
27
+ <tr>
28
+ <th scope="row"><?php _e( 'Authentication', 'backwpup' ); ?></th>
29
+ <td>
30
+ <label for="sugaremail"><?php _e( 'Email address:', 'backwpup' ); ?><br/>
31
+ <input id="sugaremail" name="sugaremail" type="text"
32
+ value="<?php if ( isset( $_POST[ 'sugaremail' ] ) ) echo $_POST[ 'sugaremail' ];?>" class="large-text" autocomplete="off" /></label>
33
+ <br/>
34
+ <label for="sugarpass"><?php _e( 'Password:', 'backwpup' ); ?><br/>
35
+ <input id="sugarpass" name="sugarpass" type="password"
36
+ value="<?php if ( isset( $_POST[ 'sugarpass' ] ) ) echo $_POST[ 'sugarpass' ];?>" class="large-text" autocomplete="off" /></label>
37
+ <br/>
38
+ <br/>
39
+ <input type="submit" id="idauthbutton" name="authbutton" class="button-primary" accesskey="d"
40
+ value="<?php _e( 'Authenticate with Sugarsync!', 'backwpup' ); ?>"/>
41
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="authbutton" class="button"
42
+ value="<?php _e( 'Create Sugarsync account', 'backwpup' ); ?>"/>
43
+ </td>
44
+ </tr>
45
+ <?php } else { ?>
46
+ <tr>
47
+ <th scope="row"><label for="idauthbutton"><?php _e( 'Authentication', 'backwpup' ); ?></label></th>
48
+ <td>
49
+ <span style="color:green;"><?php _e( 'Authenticated!', 'backwpup' ); ?></span>
50
+ <input type="submit" id="idauthbutton" name="authbutton" class="button-primary" accesskey="d"
51
+ value="<?php _e( 'Delete Sugarsync authentication!', 'backwpup' ); ?>" />
52
+ </td>
53
+ </tr>
54
+ <?php } ?>
55
+ </table>
56
+
57
+ <h3 class="title"><?php _e( 'SugarSync Root', 'backwpup' ); ?></h3>
58
+ <p></p>
59
+ <table class="form-table">
60
+ <tr>
61
+ <th scope="row"><label for="sugarroot"><?php _e( 'Sync folder selection', 'backwpup' ); ?></label></th>
62
+ <td>
63
+ <?php
64
+ try {
65
+ $sugarsync = new BackWPup_Destination_SugarSync_API( BackWPup_Option::get( $jobid, 'sugarrefreshtoken' ) );
66
+ $user = $sugarsync->user();
67
+ $syncfolders = $sugarsync->get( $user->syncfolders );
68
+ if ( ! is_object( $syncfolders ) )
69
+ echo '<span style="color:red;">' . __( 'No Syncfolders found!', 'backwpup' ) . '</span>';
70
+ }
71
+ catch ( Exception $e ) {
72
+ echo '<span style="color:red;">' . $e->getMessage() . '</span>';
73
+ }
74
+ if ( isset( $syncfolders ) && is_object( $syncfolders ) ) {
75
+ echo '<select name="sugarroot" id="sugarroot">';
76
+ foreach ( $syncfolders->collection as $roots ) {
77
+ echo "<option " . selected( strtolower( BackWPup_Option::get( $jobid, 'sugarroot' ) ), strtolower( $roots->ref ), FALSE ) . " value=\"" . $roots->ref . "\">" . $roots->displayName . "</option>";
78
+ }
79
+ echo '</select>';
80
+ }
81
+ ?>
82
+ </td>
83
+ </tr>
84
+ </table>
85
+
86
+ <h3 class="title"><?php _e( 'Backup settings', 'backwpup' ); ?></h3>
87
+ <p></p>
88
+ <table class="form-table">
89
+ <tr>
90
+ <th scope="row"><label for="idsugardir"><?php _e( 'Folder in root', 'backwpup' ); ?></label></th>
91
+ <td>
92
+ <input id="idsugardir" name="sugardir" type="text" value="<?php echo BackWPup_Option::get( $jobid, 'sugardir' ); ?>" class="regular-text" />
93
+ </td>
94
+ </tr>
95
+ <tr>
96
+ <th scope="row"><?php _e( 'File Deletion', 'backwpup' ); ?></th>
97
+ <td>
98
+ <?php
99
+ if ( BackWPup_Option::get( $jobid, 'backuptype' ) == 'archive' ) {
100
+ ?>
101
+ <label for="idsugarmaxbackups"><input id="idsugarmaxbackups" name="sugarmaxbackups" type="text" size="3" value="<?php echo BackWPup_Option::get( $jobid, 'sugarmaxbackups' );?>" class="small-text help-tip" title="<?php esc_attr_e( 'Oldest files will be deleted first. 0 = no deletion', 'backwpup' ); ?>" />&nbsp;
102
+ <?php _e( 'Number of files to keep in folder.', 'backwpup' ); ?></label>
103
+ <?php } else { ?>
104
+ <label for="idsugarsyncnodelete"><input class="checkbox" value="1"
105
+ type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'sugarsyncnodelete' ), TRUE ); ?>
106
+ name="sugarsyncnodelete" id="idsugarsyncnodelete" /> <?php _e( 'Do not delete files while syncing to destination!', 'backwpup' ); ?></label>
107
+ <?php } ?>
108
+ </td>
109
+ </tr>
110
+ </table>
111
+ <?php
112
+ }
113
+
114
+
115
+ /**
116
+ * @param $jobid
117
+ */
118
+ public function edit_form_post_save( $jobid ) {
119
+
120
+
121
+ if ( ! empty( $_POST[ 'sugaremail' ] ) && ! empty( $_POST[ 'sugarpass' ] ) && $_POST[ 'authbutton' ] == __( 'Authenticate with Sugarsync!', 'backwpup' ) ) {
122
+ try {
123
+ $sugarsync = new BackWPup_Destination_SugarSync_API();
124
+ $refresh_token = $sugarsync->get_Refresh_Token( $_POST[ 'sugaremail' ], $_POST[ 'sugarpass' ] );
125
+ if ( ! empty( $refresh_token ) )
126
+ BackWPup_Option::update( $jobid, 'sugarrefreshtoken', $refresh_token );
127
+ }
128
+ catch ( Exception $e ) {
129
+ BackWPup_Admin::message( 'SUGARSYNC: ' . $e->getMessage(), TRUE );
130
+ }
131
+ }
132
+
133
+ if ( isset( $_POST[ 'authbutton' ] ) && $_POST[ 'authbutton' ] == __( 'Delete Sugarsync authentication!', 'backwpup' ) ) {
134
+ BackWPup_Option::delete( $jobid, 'sugarrefreshtoken' );
135
+ }
136
+
137
+ if ( isset( $_POST[ 'authbutton' ] ) && $_POST[ 'authbutton' ] == __( 'Create Sugarsync account', 'backwpup' ) ) {
138
+ try {
139
+ $sugarsync = new BackWPup_Destination_SugarSync_API();
140
+ $sugarsync->create_account( $_POST[ 'sugaremail' ], $_POST[ 'sugarpass' ] );
141
+ }
142
+ catch ( Exception $e ) {
143
+ BackWPup_Admin::message( 'SUGARSYNC: ' . $e->getMessage(), TRUE );
144
+ }
145
+ }
146
+
147
+ $_POST[ 'sugardir' ] = trailingslashit( str_replace( '//', '/', str_replace( '\\', '/', trim( stripslashes( $_POST[ 'sugardir' ] ) ) ) ) );
148
+ if ( substr( $_POST[ 'sugardir' ], 0, 1 ) == '/' )
149
+ $_POST[ 'sugardir' ] = substr( $_POST[ 'sugardir' ], 1 );
150
+ if ( $_POST[ 'sugardir' ] == '/' )
151
+ $_POST[ 'sugardir' ] = '';
152
+ BackWPup_Option::update( $jobid, 'sugardir', $_POST[ 'sugardir' ] );
153
+
154
+ BackWPup_Option::update( $jobid, 'sugarroot', isset( $_POST[ 'sugarroot' ] ) ? $_POST[ 'sugarroot' ] : '' );
155
+ BackWPup_Option::update( $jobid, 'sugarmaxbackups', isset( $_POST[ 'sugarmaxbackups' ] ) ? (int)$_POST[ 'sugarmaxbackups' ] : 0 );
156
+ }
157
+
158
+ /**
159
+ * @param $jobdest
160
+ * @param $backupfile
161
+ */
162
+ public function file_delete( $jobdest, $backupfile ) {
163
+
164
+ $files = get_site_transient( 'backwpup_' . strtolower( $jobdest ) );
165
+ list( $jobid, $dest ) = explode( '_', $jobdest );
166
+
167
+ if ( BackWPup_Option::get( $jobid, 'sugarrefreshtoken' ) ) {
168
+ try {
169
+ $sugarsync = new BackWPup_Destination_SugarSync_API( BackWPup_Option::get( $jobid, 'sugarrefreshtoken' ) );
170
+ $sugarsync->delete( urldecode( $backupfile ) );
171
+ //update file list
172
+ foreach ( $files as $key => $file ) {
173
+ if ( is_array( $file ) && $file[ 'file' ] == $backupfile )
174
+ unset( $files[ $key ] );
175
+ }
176
+ unset( $sugarsync );
177
+ }
178
+ catch ( Exception $e ) {
179
+ BackWPup_Admin::message( 'SUGARSYNC: ' . $e->getMessage(), TRUE );
180
+ }
181
+ }
182
+
183
+ set_site_transient( 'backwpup_' . strtolower( $jobdest ), $files, 60 * 60 * 24 * 7 );
184
+ }
185
+
186
+ /**
187
+ * @param $jobid
188
+ * @param $get_file
189
+ */
190
+ public function file_download( $jobid, $get_file ) {
191
+
192
+ try {
193
+ $sugarsync = new BackWPup_Destination_SugarSync_API( BackWPup_Option::get( $jobid, 'sugarrefreshtoken' ) );
194
+ $response = $sugarsync->get( urldecode( $get_file ) );
195
+ header( "Pragma: public" );
196
+ header( "Expires: 0" );
197
+ header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
198
+ header( "Content-Type: application/octet-stream" );
199
+ header( "Content-Disposition: attachment; filename=" . (string)$response->displayName . ";" );
200
+ header( "Content-Transfer-Encoding: binary" );
201
+ header( "Content-Length: " . (int)$response->size );
202
+ @set_time_limit( 300 );
203
+ echo $sugarsync->download( urldecode( $get_file ) );
204
+ die();
205
+ }
206
+ catch ( Exception $e ) {
207
+ die( $e->getMessage() );
208
+ }
209
+ }
210
+
211
+ /**
212
+ * @param $jobdest
213
+ * @return mixed
214
+ */
215
+ public function file_get_list( $jobdest ) {
216
+
217
+ return get_site_transient( 'backwpup_' . strtolower( $jobdest ) );
218
+ }
219
+
220
+ /**
221
+ * @param $job_object
222
+ * @return bool
223
+ */
224
+ public function job_run_archive( &$job_object ) {
225
+
226
+ $job_object->substeps_todo = 2 + $job_object->backup_filesize;
227
+ $job_object->log( sprintf( __( '%d. Try to send backup to SugarSync&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ), E_USER_NOTICE );
228
+
229
+ try {
230
+ $sugarsync = new BackWPup_Destination_SugarSync_API( $job_object->job[ 'sugarrefreshtoken' ] );
231
+ //Check Quota
232
+ $user = $sugarsync->user();
233
+ if ( ! empty( $user->nickname ) )
234
+ $job_object->log( sprintf( __( 'Authenticated to SugarSync with nickname %s', 'backwpup' ), $user->nickname ), E_USER_NOTICE );
235
+ $sugarsyncfreespase = (float)$user->quota->limit - (float)$user->quota->usage; //float fixes bug for display of no free space
236
+ if ( $job_object->backup_filesize > $sugarsyncfreespase ) {
237
+ $job_object->log( sprintf( _x( 'Not enough disk space available on SugarSync. Available: %s.','Available space on SugarSync', 'backwpup' ), size_format( $sugarsyncfreespase, 2 ) ), E_USER_ERROR );
238
+ $job_object->substeps_todo = 1 + $job_object->backup_filesize;
239
+
240
+ return TRUE;
241
+ }
242
+ else {
243
+ $job_object->log( sprintf( __( '%s available at SugarSync', 'backwpup' ), size_format( $sugarsyncfreespase, 2 ) ), E_USER_NOTICE );
244
+ }
245
+ //Create and change folder
246
+ $sugarsync->mkdir( $job_object->job[ 'sugardir' ], $job_object->job[ 'sugarroot' ] );
247
+ $dirid = $sugarsync->chdir( $job_object->job[ 'sugardir' ], $job_object->job[ 'sugarroot' ] );
248
+ //Upload to SugarSync
249
+ $job_object->substeps_done = 0;
250
+ $job_object->log( __( 'Starting upload to SugarSync&#160;&hellip;', 'backwpup' ), E_USER_NOTICE );
251
+ self::$backwpup_job_object = &$job_object;
252
+ $reponse = $sugarsync->upload( $job_object->backup_folder . $job_object->backup_file );
253
+ if ( is_object( $reponse ) ) {
254
+ if ( ! empty( $job_object->job[ 'jobid' ] ) )
255
+ BackWPup_Option::update( $job_object->job[ 'jobid' ], 'lastbackupdownloadurl', network_admin_url( 'admin.php' ) . '?page=backwpupbackups&action=downloadsugarsync&file=' . (string)$reponse . '&jobid=' . $job_object->job[ 'jobid' ] );
256
+ $job_object->substeps_done ++;
257
+ $job_object->log( sprintf( __( 'Backup transferred to %s', 'backwpup' ), 'https://' . $user->nickname . '.sugarsync.com/' . $sugarsync->showdir( $dirid ) . $job_object->backup_file ), E_USER_NOTICE );
258
+ }
259
+ else {
260
+ $job_object->log( __( 'Cannot transfer backup to SugarSync!', 'backwpup' ), E_USER_ERROR );
261
+
262
+ return FALSE;
263
+ }
264
+
265
+ $backupfilelist = array();
266
+ $files = array();
267
+ $filecounter = 0;
268
+ $dir = $sugarsync->showdir( $dirid );
269
+ $getfiles = $sugarsync->getcontents( 'file' );
270
+ if ( is_object( $getfiles ) ) {
271
+ foreach ( $getfiles->file as $getfile ) {
272
+ $getfile->displayName = utf8_decode( (string)$getfile->displayName );
273
+ if ( $job_object->is_backup_archive( $getfile->displayName ) )
274
+ $backupfilelist[ strtotime( (string)$getfile->lastModified ) ] = (string)$getfile->ref;
275
+ $files[ $filecounter ][ 'folder' ] = 'https://' . (string)$user->nickname . '.sugarsync.com/' . $dir;
276
+ $files[ $filecounter ][ 'file' ] = (string)$getfile->ref;
277
+ $files[ $filecounter ][ 'filename' ] = (string)$getfile->displayName;
278
+ $files[ $filecounter ][ 'downloadurl' ] = network_admin_url( 'admin.php' ) . '?page=backwpupbackups&action=downloadsugarsync&file=' . (string)$getfile->ref . '&jobid=' . $job_object->job[ 'jobid' ];
279
+ $files[ $filecounter ][ 'filesize' ] = (int)$getfile->size;
280
+ $files[ $filecounter ][ 'time' ] = strtotime( (string)$getfile->lastModified ) + ( get_option( 'gmt_offset' ) * 3600 );
281
+ $filecounter ++;
282
+ }
283
+ }
284
+ if ( ! empty( $job_object->job[ 'sugarmaxbackups' ] ) && $job_object->job[ 'sugarmaxbackups' ] > 0 ) { //Delete old backups
285
+ if ( count( $backupfilelist ) > $job_object->job[ 'sugarmaxbackups' ] ) {
286
+ ksort( $backupfilelist );
287
+ $numdeltefiles = 0;
288
+ while ( $file = array_shift( $backupfilelist ) ) {
289
+ if ( count( $backupfilelist ) < $job_object->job[ 'sugarmaxbackups' ] )
290
+ break;
291
+ $sugarsync->delete( $file ); //delete files on Cloud
292
+ foreach ( $files as $key => $filedata ) {
293
+ if ( $filedata[ 'file' ] == $file )
294
+ unset( $files[ $key ] );
295
+ }
296
+ $numdeltefiles ++;
297
+ }
298
+ if ( $numdeltefiles > 0 )
299
+ $job_object->log( sprintf( _n( 'One file deleted on SugarSync folder', '%d files deleted on SugarSync folder', $numdeltefiles, 'backwpup' ), $numdeltefiles ), E_USER_NOTICE );
300
+ }
301
+ }
302
+ set_site_transient( 'BackWPup_' . $job_object->job[ 'jobid' ] . '_SUGARSYNC', $files, 60 * 60 * 24 * 7 );
303
+ }
304
+ catch ( Exception $e ) {
305
+ $job_object->log( E_USER_ERROR, sprintf( __( 'SugarSync API: %s', 'backwpup' ), htmlentities( $e->getMessage() ) ), $e->getFile(), $e->getLine() );
306
+
307
+ return FALSE;
308
+ }
309
+ $job_object->substeps_done ++;
310
+
311
+ return TRUE;
312
+ }
313
+
314
+ /**
315
+ * @param $job_object
316
+ * @return bool
317
+ */
318
+ public function can_run( $job_object ) {
319
+
320
+ if ( empty( $job_object->job[ 'sugarrefreshtoken' ] ) )
321
+ return FALSE;
322
+
323
+ if ( empty( $job_object->job[ 'sugarroot' ] ) )
324
+ return FALSE;
325
+
326
+ return TRUE;
327
+ }
328
+ }
329
+
330
+ /**
331
+ *
332
+ */
333
+ class BackWPup_Destination_SugarSync_API {
334
+
335
+ /**
336
+ * url for the sugarsync-api
337
+ */
338
+ const API_URL = 'https://api.sugarsync.com';
339
+
340
+ /**
341
+ *
342
+ * @var string
343
+ */
344
+ protected $folder = '';
345
+
346
+ /**
347
+ * @var mixed|string
348
+ */
349
+ protected $encoding = 'UTF-8';
350
+
351
+ /**
352
+ * @var null|string
353
+ */
354
+ protected $refresh_token = '';
355
+
356
+ /**
357
+ * The Auth-token
358
+ *
359
+ * @var string
360
+ */
361
+ protected $access_token = '';
362
+
363
+ // class methods
364
+ /**
365
+ * Default constructor/Auth
366
+ */
367
+ public function __construct( $refresh_token = NULL ) {
368
+
369
+ //auth xml
370
+ $this->encoding = mb_internal_encoding();
371
+
372
+ //get access token
373
+ if ( isset( $refresh_token ) and ! empty( $refresh_token ) ) {
374
+ $this->refresh_token = $refresh_token;
375
+ $this->get_Access_Token();
376
+ }
377
+ }
378
+
379
+ /**
380
+ * Make the call
381
+ *
382
+ * @return string
383
+ *
384
+ * @param string $url The url to call.
385
+ * @param string $data
386
+ * @param string $method
387
+ * @throws BackWPup_Destination_SugarSync_API_Exception
388
+ * @internal param $string [optiona] $data File on put, xml on post.
389
+ * @internal param $string [optional] $method The method to use. Possible values are GET, POST, PUT, DELETE.
390
+ */
391
+ private function doCall( $url, $data = '', $method = 'GET' ) {
392
+
393
+ // allowed methods
394
+ $allowedMethods = array( 'GET', 'POST', 'PUT', 'DELETE' );
395
+
396
+ // redefine
397
+ $url = (string)$url;
398
+ $method = (string)$method;
399
+
400
+ // validate method
401
+ if ( ! in_array( $method, $allowedMethods ) )
402
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Unknown method (' . $method . '). Allowed methods are: ' . implode( ', ', $allowedMethods ) );
403
+
404
+ // check auth token
405
+ if ( empty( $this->access_token ) )
406
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Auth Token not set correctly!' );
407
+ else
408
+ $headers[ ] = 'Authorization: ' . $this->access_token;
409
+ $headers[ ] = 'Expect:';
410
+
411
+ // init
412
+ $curl = curl_init();
413
+ //set options
414
+ curl_setopt( $curl, CURLOPT_URL, $url );
415
+ curl_setopt( $curl, CURLOPT_USERAGENT, BackWPup::get_plugin_data( 'User-Agent' ) );
416
+ if ( ini_get( 'open_basedir' ) == '' ) curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, TRUE );
417
+ curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE );
418
+ if ( BackWPup::get_plugin_data( 'cacert' ) ) {
419
+ curl_setopt( $curl, CURLOPT_SSLVERSION, 3 );
420
+ curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, TRUE );
421
+ curl_setopt( $curl, CURLOPT_CAINFO, BackWPup::get_plugin_data( 'cacert' ) );
422
+ curl_setopt( $curl, CURLOPT_CAPATH, dirname( BackWPup::get_plugin_data( 'cacert' ) ) );
423
+ } else {
424
+ curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, FALSE );
425
+ }
426
+
427
+ if ( $method == 'POST' ) {
428
+ $headers[ ] = 'Content-Type: application/xml; charset=UTF-8';
429
+ curl_setopt( $curl, CURLOPT_POSTFIELDS, $data );
430
+ curl_setopt( $curl, CURLOPT_POST, TRUE );
431
+ $headers[ ] = 'Content-Length: ' . strlen( $data );
432
+ }
433
+ elseif ( $method == 'PUT' ) {
434
+ if ( is_readable( $data ) ) {
435
+ $headers[ ] = 'Content-Length: ' . filesize( $data );
436
+ $datafilefd = fopen( $data, 'r' );
437
+ curl_setopt( $curl, CURLOPT_PUT, TRUE );
438
+ curl_setopt( $curl, CURLOPT_INFILE, $datafilefd );
439
+ curl_setopt( $curl, CURLOPT_INFILESIZE, filesize( $data ) );
440
+ curl_setopt( $curl, CURLOPT_READFUNCTION, array( BackWPup_Destination_SugarSync::$backwpup_job_object, 'curl_read_callback' ) );
441
+ }
442
+ else {
443
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Is not a readable file:' . $data );
444
+ }
445
+ }
446
+ elseif ( $method == 'DELETE' ) {
447
+ curl_setopt( $curl, CURLOPT_CUSTOMREQUEST, 'DELETE' );
448
+ }
449
+ else {
450
+ curl_setopt( $curl, CURLOPT_POST, FALSE );
451
+ }
452
+
453
+ // set headers
454
+ curl_setopt( $curl, CURLOPT_HTTPHEADER, $headers );
455
+ curl_setopt( $curl, CURLINFO_HEADER_OUT, TRUE );
456
+ // execute
457
+ $response = curl_exec( $curl );
458
+ $curlgetinfo = curl_getinfo( $curl );
459
+
460
+ // fetch curl errors
461
+ if ( curl_errno( $curl ) != 0 )
462
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'cUrl Error: ' . curl_error( $curl ) );
463
+ curl_close( $curl );
464
+ if ( ! empty( $datafilefd ) && is_resource( $datafilefd ) )
465
+ fclose( $datafilefd );
466
+
467
+ if ( $curlgetinfo[ 'http_code' ] >= 200 && $curlgetinfo[ 'http_code' ] < 300 ) {
468
+ if ( FALSE !== stripos( $curlgetinfo[ 'content_type' ], 'xml' ) && ! empty( $response ) )
469
+ return simplexml_load_string( $response );
470
+ else
471
+ return $response;
472
+ }
473
+ else {
474
+ if ( $curlgetinfo[ 'http_code' ] == 401 )
475
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' Authorization required.' );
476
+ elseif ( $curlgetinfo[ 'http_code' ] == 403 )
477
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' (Forbidden) Authentication failed.' );
478
+ elseif ( $curlgetinfo[ 'http_code' ] == 404 )
479
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' Not found' );
480
+ else
481
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] );
482
+ }
483
+ }
484
+
485
+
486
+ /**
487
+ * @return string
488
+ * @throws BackWPup_Destination_SugarSync_API_Exception
489
+ */
490
+ private function get_Access_Token() {
491
+
492
+ $auth = '<?xml version="1.0" encoding="UTF-8" ?>';
493
+ $auth .= '<tokenAuthRequest>';
494
+ $auth .= '<accessKeyId>' . get_site_option( 'backwpup_cfg_sugarsynckey', base64_decode( "TlRBek1EY3lOakV6TkRrMk1URXhNemM0TWpJ" ) ) . '</accessKeyId>';
495
+ $auth .= '<privateAccessKey>' . BackWPup_Encryption::decrypt( get_site_option( 'backwpup_cfg_sugarsyncsecret', base64_decode( "TkRFd01UazRNVEpqTW1Ga05EaG1NR0k1TVRFNFpqa3lPR1V6WlRVMk1tTQ==" ) ) ) . '</privateAccessKey>';
496
+ $auth .= '<refreshToken>' . trim( $this->refresh_token ) . '</refreshToken>';
497
+ $auth .= '</tokenAuthRequest>';
498
+ // init
499
+ $curl = curl_init();
500
+ //set options
501
+ curl_setopt( $curl, CURLOPT_URL, self::API_URL . '/authorization' );
502
+ curl_setopt( $curl, CURLOPT_USERAGENT, BackWPup::get_plugin_data( 'User-Agent' ) );
503
+ if ( ini_get( 'open_basedir' ) == '' ) curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, TRUE );
504
+ curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE );
505
+ if ( BackWPup::get_plugin_data( 'cacert' ) ) {
506
+ curl_setopt( $curl, CURLOPT_SSLVERSION, 3 );
507
+ curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, TRUE );
508
+ curl_setopt( $curl, CURLOPT_CAINFO, BackWPup::get_plugin_data( 'cacert' ) );
509
+ curl_setopt( $curl, CURLOPT_CAPATH, dirname( BackWPup::get_plugin_data( 'cacert' ) ) );
510
+ } else {
511
+ curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, FALSE );
512
+ }
513
+ curl_setopt( $curl, CURLOPT_HEADER, TRUE );
514
+ curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Content-Type: application/xml; charset=UTF-8', 'Content-Length: ' . strlen( $auth ) ) );
515
+ curl_setopt( $curl, CURLOPT_POSTFIELDS, $auth );
516
+ curl_setopt( $curl, CURLOPT_POST, TRUE );
517
+ // execute
518
+ $response = curl_exec( $curl );
519
+ $curlgetinfo = curl_getinfo( $curl );
520
+ // fetch curl errors
521
+ if ( curl_errno( $curl ) != 0 )
522
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'cUrl Error: ' . curl_error( $curl ) );
523
+
524
+ curl_close( $curl );
525
+
526
+ if ( $curlgetinfo[ 'http_code' ] >= 200 && $curlgetinfo[ 'http_code' ] < 300 ) {
527
+ if ( preg_match( '/Location:(.*?)\r/i', $response, $matches ) )
528
+ $this->access_token = trim( $matches[ 1 ] );
529
+
530
+ return $this->access_token;
531
+ }
532
+ else {
533
+ if ( $curlgetinfo[ 'http_code' ] == 401 )
534
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' Authorization required.' );
535
+ elseif ( $curlgetinfo[ 'http_code' ] == 403 )
536
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' (Forbidden) Authentication failed.' );
537
+ elseif ( $curlgetinfo[ 'http_code' ] == 404 )
538
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' Not found' );
539
+ else
540
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] );
541
+ }
542
+ }
543
+
544
+ /**
545
+ * @param $email
546
+ * @param $password
547
+ * @return null|string
548
+ * @throws BackWPup_Destination_SugarSync_API_Exception
549
+ */
550
+ public function get_Refresh_Token( $email, $password ) {
551
+
552
+ $auth = '<?xml version="1.0" encoding="UTF-8" ?>';
553
+ $auth .= '<appAuthorization>';
554
+ $auth .= '<username>' . mb_convert_encoding( $email, 'UTF-8', $this->encoding ) . '</username>';
555
+ $auth .= '<password>' . mb_convert_encoding( $password, 'UTF-8', $this->encoding ) . '</password>';
556
+ $auth .= '<application>' . get_site_option( 'backwpup_cfg_sugarsyncappid', "/sc/5030726/449_18207099" ) . '</application>';
557
+ $auth .= '<accessKeyId>' . get_site_option( 'backwpup_cfg_sugarsynckey',base64_decode( "TlRBek1EY3lOakV6TkRrMk1URXhNemM0TWpJ" ) ) . '</accessKeyId>';
558
+ $auth .= '<privateAccessKey>' . BackWPup_Encryption::decrypt( get_site_option( 'backwpup_cfg_sugarsyncsecret', base64_decode( "TkRFd01UazRNVEpqTW1Ga05EaG1NR0k1TVRFNFpqa3lPR1V6WlRVMk1tTQ==" ) ) ) . '</privateAccessKey>';
559
+ $auth .= '</appAuthorization>';
560
+ // init
561
+ $curl = curl_init();
562
+ //set options
563
+ curl_setopt( $curl, CURLOPT_URL, self::API_URL . '/app-authorization' );
564
+ curl_setopt( $curl, CURLOPT_USERAGENT, BackWPup::get_plugin_data( 'User-Agent' ) );
565
+ if ( ini_get( 'open_basedir' ) == '' ) curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, TRUE );
566
+ curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE );
567
+ if ( BackWPup::get_plugin_data( 'cacert' ) ) {
568
+ curl_setopt( $curl, CURLOPT_SSLVERSION, 3 );
569
+ curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, TRUE );
570
+ curl_setopt( $curl, CURLOPT_CAINFO, BackWPup::get_plugin_data( 'cacert' ) );
571
+ curl_setopt( $curl, CURLOPT_CAPATH, dirname( BackWPup::get_plugin_data( 'cacert' ) ) );
572
+ } else {
573
+ curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, FALSE );
574
+ }
575
+ curl_setopt( $curl, CURLOPT_HEADER, TRUE );
576
+ curl_setopt( $curl, CURLOPT_POSTFIELDS, $auth );
577
+ curl_setopt( $curl, CURLOPT_POST, TRUE );
578
+ curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Content-Type: application/xml; charset=UTF-8', 'Content-Length: ' . strlen( $auth ) ) );
579
+ // execute
580
+ $response = curl_exec( $curl );
581
+ $curlgetinfo = curl_getinfo( $curl );
582
+ // fetch curl errors
583
+ if ( curl_errno( $curl ) != 0 )
584
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'cUrl Error: ' . curl_error( $curl ) );
585
+
586
+ curl_close( $curl );
587
+
588
+ if ( $curlgetinfo[ 'http_code' ] >= 200 && $curlgetinfo[ 'http_code' ] < 300 ) {
589
+ if ( preg_match( '/Location:(.*?)\r/i', $response, $matches ) )
590
+ $this->refresh_token = trim( $matches[ 1 ] );
591
+
592
+ return $this->refresh_token;
593
+ }
594
+ else {
595
+ if ( $curlgetinfo[ 'http_code' ] == 401 )
596
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' Authorization required.' );
597
+ elseif ( $curlgetinfo[ 'http_code' ] == 403 )
598
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' (Forbidden) Authentication failed.' );
599
+ elseif ( $curlgetinfo[ 'http_code' ] == 404 )
600
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' Not found' );
601
+ else
602
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] );
603
+ }
604
+ }
605
+
606
+ /**
607
+ * @param $email
608
+ * @param $password
609
+ * @throws BackWPup_Destination_SugarSync_API_Exception
610
+ */
611
+ public function create_account( $email, $password ) {
612
+
613
+ $auth = '<?xml version="1.0" encoding="UTF-8" ?>';
614
+ $auth .= '<user>';
615
+ $auth .= '<email>' . mb_convert_encoding( $email, 'UTF-8', $this->encoding ) . '</email>';
616
+ $auth .= '<password>' . mb_convert_encoding( $password, 'UTF-8', $this->encoding ) . '</password>';
617
+ $auth .= '<accessKeyId>' . get_site_option( 'backwpup_cfg_sugarsynckey', base64_decode( "TlRBek1EY3lOakV6TkRrMk1URXhNemM0TWpJ" ) ) . '</accessKeyId>';
618
+ $auth .= '<privateAccessKey>' . BackWPup_Encryption::decrypt( get_site_option( 'backwpup_cfg_sugarsyncsecret', base64_decode( "TkRFd01UazRNVEpqTW1Ga05EaG1NR0k1TVRFNFpqa3lPR1V6WlRVMk1tTQ==" ) ) ) . '</privateAccessKey>';
619
+ $auth .= '</user>';
620
+ // init
621
+ $curl = curl_init();
622
+ //set options
623
+ curl_setopt( $curl, CURLOPT_URL, 'https://provisioning-api.sugarsync.com/users' );
624
+ curl_setopt( $curl, CURLOPT_USERAGENT, BackWPup::get_plugin_data( 'User-Agent' ) );
625
+ if ( ini_get( 'open_basedir' ) == '' ) curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, TRUE );
626
+ curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE );
627
+ if ( BackWPup::get_plugin_data( 'cacert' ) ) {
628
+ curl_setopt( $curl, CURLOPT_SSLVERSION, 3 );
629
+ curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, TRUE );
630
+ curl_setopt( $curl, CURLOPT_CAINFO, BackWPup::get_plugin_data( 'cacert' ) );
631
+ curl_setopt( $curl, CURLOPT_CAPATH, dirname( BackWPup::get_plugin_data( 'cacert' ) ) );
632
+ } else {
633
+ curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, FALSE );
634
+ } curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, FALSE );
635
+ curl_setopt( $curl, CURLOPT_HEADER, TRUE );
636
+ curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Content-Type: application/xml; charset=UTF-8', 'Content-Length: ' . strlen( $auth ) ) );
637
+ curl_setopt( $curl, CURLOPT_POSTFIELDS, $auth );
638
+ curl_setopt( $curl, CURLOPT_POST, TRUE );
639
+ // execute
640
+ $response = curl_exec( $curl );
641
+ $curlgetinfo = curl_getinfo( $curl );
642
+ // fetch curl errors
643
+ if ( curl_errno( $curl ) != 0 )
644
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'cUrl Error: ' . curl_error( $curl ) );
645
+
646
+ curl_close( $curl );
647
+
648
+ if ( $curlgetinfo[ 'http_code' ] == 201 ) {
649
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Account created.' );
650
+ }
651
+ else {
652
+ if ( $curlgetinfo[ 'http_code' ] == 400 )
653
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' ' . substr( $response, $curlgetinfo[ 'header_size' ] ) );
654
+ elseif ( $curlgetinfo[ 'http_code' ] == 401 )
655
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' Developer credentials cannot be verified. Either a developer with the specified accessKeyId does not exist or the privateKeyID does not match an assigned accessKeyId.' );
656
+ elseif ( $curlgetinfo[ 'http_code' ] == 403 )
657
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' ' . substr( $response, $curlgetinfo[ 'header_size' ] ) );
658
+ elseif ( $curlgetinfo[ 'http_code' ] == 503 )
659
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] . ' ' . substr( $response, $curlgetinfo[ 'header_size' ] ) );
660
+ else
661
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'Http Error: ' . $curlgetinfo[ 'http_code' ] );
662
+ }
663
+ }
664
+
665
+ /**
666
+ * @param $folder
667
+ * @param string $root
668
+ * @return string
669
+ * @throws BackWPup_Destination_SugarSync_API_Exception
670
+ */
671
+ public function chdir( $folder, $root = '' ) {
672
+
673
+ $folder = rtrim( $folder, '/' );
674
+ if ( substr( $folder, 0, 1 ) == '/' || empty( $this->folder ) ) {
675
+ if ( ! empty( $root ) )
676
+ $this->folder = $root;
677
+ else
678
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'chdir: root folder must set!' );
679
+ }
680
+ $folders = explode( '/', $folder );
681
+ foreach ( $folders as $dir ) {
682
+ if ( $dir == '..' ) {
683
+ $contents = $this->doCall( $this->folder );
684
+ if ( ! empty( $contents->parent ) )
685
+ $this->folder = $contents->parent;
686
+ }
687
+ elseif ( ! empty( $dir ) && $dir != '.' ) {
688
+ $isdir = FALSE;
689
+ $contents = $this->getcontents( 'folder' );
690
+ foreach ( $contents->collection as $collection ) {
691
+ if ( strtolower( $collection->displayName ) == strtolower( $dir ) ) {
692
+ $isdir = TRUE;
693
+ $this->folder = $collection->ref;
694
+ break;
695
+ }
696
+ }
697
+ if ( ! $isdir )
698
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'chdir: Folder ' . $folder . ' not exitst' );
699
+ }
700
+ }
701
+
702
+ return $this->folder;
703
+ }
704
+
705
+ /**
706
+ * @param $folderid
707
+ * @return string
708
+ */
709
+ public function showdir( $folderid ) {
710
+
711
+ $showfolder = '';
712
+ while ( $folderid ) {
713
+ $contents = $this->doCall( $folderid );
714
+ $showfolder = $contents->displayName . '/' . $showfolder;
715
+ if ( isset( $contents->parent ) )
716
+ $folderid = $contents->parent;
717
+ else
718
+ break;
719
+ }
720
+
721
+ return $showfolder;
722
+ }
723
+
724
+ /**
725
+ * @param $folder
726
+ * @param string $root
727
+ * @return bool
728
+ * @throws BackWPup_Destination_SugarSync_API_Exception
729
+ */
730
+ public function mkdir( $folder, $root = '' ) {
731
+
732
+ $savefolder = $this->folder;
733
+ $folder = rtrim( $folder, '/' );
734
+ if ( substr( $folder, 0, 1 ) == '/' || empty( $this->folder ) ) {
735
+ if ( ! empty( $root ) )
736
+ $this->folder = $root;
737
+ else
738
+ throw new BackWPup_Destination_SugarSync_API_Exception( 'mkdir: root folder must set!' );
739
+ }
740
+ $folders = explode( '/', $folder );
741
+ foreach ( $folders as $dir ) {
742
+ if ( $dir == '..' ) {
743
+ $contents = $this->doCall( $this->folder );
744
+ if ( ! empty( $contents->parent ) )
745
+ $this->folder = $contents->parent;
746
+ }
747
+ elseif ( ! empty( $dir ) && $dir != '.' ) {
748
+ $isdir = FALSE;
749
+ $contents = $this->getcontents( 'folder' );
750
+ foreach ( $contents->collection as $collection ) {
751
+ if ( strtolower( $collection->displayName ) == strtolower( $dir ) ) {
752
+ $isdir = TRUE;
753
+ $this->folder = $collection->ref;
754
+ break;
755
+ }
756
+ }
757
+ if ( ! $isdir ) {
758
+ $this->doCall( $this->folder, '<?xml version="1.0" encoding="UTF-8"?><folder><displayName>' . mb_convert_encoding( $dir, 'UTF-8', $this->encoding ) . '</displayName></folder>', 'POST' );
759
+ $contents = $this->getcontents( 'folder' );
760
+ foreach ( $contents->collection as $collection ) {
761
+ if ( strtolower( $collection->displayName ) == strtolower( $dir ) ) {
762
+ $isdir = TRUE;
763
+ $this->folder = $collection->ref;
764
+ break;
765
+ }
766
+ }
767
+ }
768
+ }
769
+ }
770
+ $this->folder = $savefolder;
771
+
772
+ return TRUE;
773
+ }
774
+
775
+
776
+ /**
777
+ * @return string
778
+ */
779
+ public function user() {
780
+ return $this->doCall( self::API_URL . '/user' );
781
+ }
782
+
783
+
784
+ /**
785
+ * @param $url
786
+ * @return string
787
+ */
788
+ public function get( $url ) {
789
+ return $this->doCall( $url, '', 'GET' );
790
+ }
791
+
792
+ /**
793
+ * @param $url
794
+ * @return string
795
+ */
796
+ public function download( $url ) {
797
+ return $this->doCall( $url . '/data' );
798
+ }
799
+
800
+ /**
801
+ * @param $url
802
+ * @return string
803
+ */
804
+ public function delete( $url ) {
805
+ return $this->doCall( $url, '', 'DELETE' );
806
+ }
807
+
808
+
809
+ /**
810
+ * @param string $type
811
+ * @param int $start
812
+ * @param int $max
813
+ * @return string
814
+ */
815
+ public function getcontents( $type = '', $start = 0, $max = 500 ) {
816
+
817
+ $parameters = '';
818
+
819
+ if ( strtolower( $type ) == 'folder' || strtolower( $type ) == 'file' )
820
+ $parameters .= 'type=' . strtolower( $type );
821
+ if ( ! empty( $start ) && is_integer( $start ) ) {
822
+ if ( ! empty( $parameters ) )
823
+ $parameters .= '&';
824
+ $parameters .= 'start=' . $start;
825
+
826
+ }
827
+ if ( ! empty( $max ) && is_integer( $max ) ) {
828
+ if ( ! empty( $parameters ) )
829
+ $parameters .= '&';
830
+ $parameters .= 'max=' . $max;
831
+ }
832
+
833
+ $request = $this->doCall( $this->folder . '/contents?' . $parameters );
834
+
835
+ return $request;
836
+ }
837
+
838
+ /**
839
+ * @param $file
840
+ * @param string $name
841
+ * @return mixed
842
+ */
843
+ public function upload( $file, $name = '' ) {
844
+
845
+ if ( empty( $name ) )
846
+ $name = basename( $file );
847
+
848
+ $xmlrequest = '<?xml version="1.0" encoding="UTF-8"?>';
849
+ $xmlrequest .= '<file>';
850
+ $xmlrequest .= '<displayName>' . mb_convert_encoding( $name, 'UTF-8', $this->encoding ) . '</displayName>';
851
+
852
+ if ( ! is_readable( $file ) ) {
853
+ $finfo = fopen( $file, 'r' );
854
+ $xmlrequest .= '<mediaType>' . mime_content_type( $finfo ) . '</mediaType>';
855
+ fclose( $finfo );
856
+ }
857
+
858
+ $xmlrequest .= '</file>';
859
+
860
+ $this->doCall( $this->folder, $xmlrequest, 'POST' );
861
+ $getfiles = $this->getcontents( 'file' );
862
+ foreach ( $getfiles->file as $getfile ) {
863
+ if ( $getfile->displayName == $name ) {
864
+ $this->doCall( $getfile->ref . '/data', $file, 'PUT' );
865
+
866
+ return $getfile->ref;
867
+ }
868
+ }
869
+ }
870
+ }
871
+
872
+ /**
873
+ * SugarSync Exception class
874
+ *
875
+ * @author Daniel Hüsken <daniel@huesken-net.de>
876
+ */
877
+ class BackWPup_Destination_SugarSync_API_Exception extends Exception {
878
+
879
+ }
inc/class-destinations.php CHANGED
@@ -1,145 +1,143 @@
1
- <?php
2
- /**
3
- * Base class for adding BackWPup destinations.
4
- *
5
- * @package BackWPup
6
- * @subpackage BackWPup_Destinations
7
- * @since 3.0.0
8
- * @access private
9
- */
10
- abstract class BackWPup_Destinations {
11
-
12
- public $info = array();
13
-
14
- /**
15
- * @return array
16
- */
17
- abstract public function option_defaults();
18
-
19
- /**
20
- * @param $jobid
21
- */
22
- abstract public function edit_tab( $jobid );
23
-
24
- /**
25
- * @param $jobid
26
- */
27
- public function edit_auth( $jobid ) {
28
-
29
- }
30
-
31
- /**
32
- * @param $jobid
33
- */
34
- abstract public function edit_form_post_save( $jobid );
35
-
36
- /**
37
- * use wp_enqueue_script() here to load js for tab
38
- */
39
- public function admin_print_scripts() {
40
-
41
- }
42
-
43
- /**
44
- *
45
- */
46
- public function edit_inline_js() {
47
-
48
- }
49
-
50
- /**
51
- *
52
- */
53
- public function edit_ajax() {
54
-
55
- }
56
-
57
- /**
58
- *
59
- */
60
- public function wizard_admin_print_styles() {
61
-
62
- }
63
-
64
- /**
65
- *
66
- */
67
- public function wizard_admin_print_scripts() {
68
-
69
- }
70
-
71
- /**
72
- *
73
- */
74
- public function wizard_inline_js() {
75
-
76
- }
77
-
78
- /**
79
- * @param $job_settings
80
- */
81
- public function wizard_page( $job_settings ) {
82
-
83
- echo '<br /><pre>';
84
- print_r( $job_settings );
85
- echo '</pre>';
86
- }
87
-
88
- /**
89
- * @param $job_settings
90
- */
91
- public function wizard_save( $job_settings ) {
92
-
93
- return $job_settings;
94
- }
95
-
96
- /**
97
- *
98
- */
99
- public function admin_print_styles() {
100
-
101
- }
102
-
103
- /**
104
- * @param $jobdest
105
- * @param $backupfile
106
- */
107
- public function file_delete( $jobdest, $backupfile ) {
108
-
109
- }
110
-
111
- /**
112
- * @param $jobid
113
- * @param $get_file
114
- */
115
- public function file_download( $jobid, $get_file ) {
116
-
117
- }
118
-
119
- /**
120
- * @param $jobdest
121
- * @return bool
122
- */
123
- public function file_get_list( $jobdest ) {
124
-
125
- return FALSE;
126
- }
127
-
128
- /**
129
- * @param $job_object BackWPup_Job Object
130
- */
131
- abstract public function job_run_archive( &$job_object );
132
-
133
- /**
134
- * @param $job_object BackWPup_Job Object
135
- */
136
- public function job_run_sync( &$job_object ) {
137
-
138
- }
139
-
140
- /**
141
- * @param $job_object BackWPup_Job Object
142
- * @return bool
143
- */
144
- abstract public function can_run( $job_object );
145
- }
1
+ <?php
2
+ /**
3
+ * Base class for adding BackWPup destinations.
4
+ *
5
+ * @package BackWPup
6
+ * @subpackage BackWPup_Destinations
7
+ * @since 3.0.0
8
+ * @access private
9
+ */
10
+ abstract class BackWPup_Destinations {
11
+
12
+ /**
13
+ * @return array
14
+ */
15
+ abstract public function option_defaults();
16
+
17
+ /**
18
+ * @param $jobid
19
+ */
20
+ abstract public function edit_tab( $jobid );
21
+
22
+ /**
23
+ * @param $jobid
24
+ */
25
+ public function edit_auth( $jobid ) {
26
+
27
+ }
28
+
29
+ /**
30
+ * @param $jobid
31
+ */
32
+ abstract public function edit_form_post_save( $jobid );
33
+
34
+ /**
35
+ * use wp_enqueue_script() here to load js for tab
36
+ */
37
+ public function admin_print_scripts() {
38
+
39
+ }
40
+
41
+ /**
42
+ *
43
+ */
44
+ public function edit_inline_js() {
45
+
46
+ }
47
+
48
+ /**
49
+ *
50
+ */
51
+ public function edit_ajax() {
52
+
53
+ }
54
+
55
+ /**
56
+ *
57
+ */
58
+ public function wizard_admin_print_styles() {
59
+
60
+ }
61
+
62
+ /**
63
+ *
64
+ */
65
+ public function wizard_admin_print_scripts() {
66
+
67
+ }
68
+
69
+ /**
70
+ *
71
+ */
72
+ public function wizard_inline_js() {
73
+
74
+ }
75
+
76
+ /**
77
+ * @param $job_settings
78
+ */
79
+ public function wizard_page( $job_settings ) {
80
+
81
+ echo '<br /><pre>';
82
+ print_r( $job_settings );
83
+ echo '</pre>';
84
+ }
85
+
86
+ /**
87
+ * @param $job_settings
88
+ */
89
+ public function wizard_save( $job_settings ) {
90
+
91
+ return $job_settings;
92
+ }
93
+
94
+ /**
95
+ *
96
+ */
97
+ public function admin_print_styles() {
98
+
99
+ }
100
+
101
+ /**
102
+ * @param $jobdest
103
+ * @param $backupfile
104
+ */
105
+ public function file_delete( $jobdest, $backupfile ) {
106
+
107
+ }
108
+
109
+ /**
110
+ * @param $jobid
111
+ * @param $get_file
112
+ */
113
+ public function file_download( $jobid, $get_file ) {
114
+
115
+ }
116
+
117
+ /**
118
+ * @param $jobdest
119
+ * @return bool
120
+ */
121
+ public function file_get_list( $jobdest ) {
122
+
123
+ return FALSE;
124
+ }
125
+
126
+ /**
127
+ * @param $job_object BackWPup_Job Object
128
+ */
129
+ abstract public function job_run_archive( &$job_object );
130
+
131
+ /**
132
+ * @param $job_object BackWPup_Job Object
133
+ */
134
+ public function job_run_sync( &$job_object ) {
135
+
136
+ }
137
+
138
+ /**
139
+ * @param $job_object BackWPup_Job Object
140
+ * @return bool
141
+ */
142
+ abstract public function can_run( $job_object );
143
+ }
 
 
inc/class-encryption.php CHANGED
@@ -14,14 +14,28 @@ class BackWPup_Encryption {
14
  */
15
  public static function encrypt( $string ) {
16
 
17
- if ( empty( $string ) )
18
  return $string;
 
19
 
20
  //only encrypt if needed
21
- if ( strpos( $string, '$BackWPup$ENC1$' ) !== FALSE or strpos( $string, '$BackWPup$RIJNDAEL$' ) !== FALSE )
22
- return $string;
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
- $key = md5( DB_NAME . DB_USER . DB_PASSWORD );
25
 
26
  if ( ! function_exists( 'mcrypt_encrypt' ) ) {
27
  $result = '';
@@ -32,10 +46,10 @@ class BackWPup_Encryption {
32
  $result .= $char;
33
  }
34
 
35
- return '$BackWPup$ENC1$' . base64_encode( $result );
36
  }
37
 
38
- return '$BackWPup$RIJNDAEL$' . base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, md5( $key ), $string, MCRYPT_MODE_CBC, md5( md5( $key ) ) ) );
39
  }
40
 
41
  /**
@@ -48,13 +62,23 @@ class BackWPup_Encryption {
48
  */
49
  public static function decrypt( $string ) {
50
 
51
- if ( empty( $string ) )
52
  return $string;
 
 
 
 
 
 
 
 
 
 
53
 
54
- $key = md5( DB_NAME . DB_USER . DB_PASSWORD );
55
 
56
- if ( strpos( $string, '$BackWPup$ENC1$' ) !== FALSE ) {
57
- $string = str_replace( '$BackWPup$ENC1$', '', $string );
58
  $result = '';
59
  $string = base64_decode( $string );
60
  for ( $i = 0; $i < strlen( $string ); $i ++ ) {
@@ -67,10 +91,10 @@ class BackWPup_Encryption {
67
  return $result;
68
  }
69
 
70
- if ( function_exists( 'mcrypt_encrypt' ) && strpos( $string, '$BackWPup$RIJNDAEL$' ) !== FALSE) {
71
- $string = str_replace( '$BackWPup$RIJNDAEL$', '', $string );
72
 
73
- return rtrim( mcrypt_decrypt( MCRYPT_RIJNDAEL_256, md5( $key ), base64_decode( $string ), MCRYPT_MODE_CBC, md5( md5( $key ) ) ), "\0" );
74
  }
75
 
76
  return $string;
14
  */
15
  public static function encrypt( $string ) {
16
 
17
+ if ( empty( $string ) ) {
18
  return $string;
19
+ }
20
 
21
  //only encrypt if needed
22
+ if ( strpos( $string, '$BackWPup$ENC1$' ) !== FALSE || strpos( $string, '$BackWPup$RIJNDAEL$' ) !== FALSE ) {
23
+ if ( strpos( $string, '$BackWPup$ENC1$O$' ) !== FALSE && strpos( $string, '$BackWPup$RIJNDAEL$O$' ) !== FALSE && defined( 'BACKWPUP_ENC_KEY' ) && BACKWPUP_ENC_KEY ) {
24
+ $string = self::decrypt( $string );
25
+ } else {
26
+ return $string;
27
+ }
28
+ }
29
+
30
+ if ( defined( 'BACKWPUP_ENC_KEY' ) && BACKWPUP_ENC_KEY ) {
31
+ $key = BACKWPUP_ENC_KEY;
32
+ $key_type = 'O$';
33
+ } else {
34
+ $key = DB_NAME . DB_USER . DB_PASSWORD;
35
+ $key_type = '';
36
+ }
37
 
38
+ $key = md5( $key );
39
 
40
  if ( ! function_exists( 'mcrypt_encrypt' ) ) {
41
  $result = '';
46
  $result .= $char;
47
  }
48
 
49
+ return '$BackWPup$ENC1$' . $key_type . base64_encode( $result );
50
  }
51
 
52
+ return '$BackWPup$RIJNDAEL$' . $key_type . base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, md5( $key ), trim( $string ), MCRYPT_MODE_CBC, md5( md5( $key ) ) ) );
53
  }
54
 
55
  /**
62
  */
63
  public static function decrypt( $string ) {
64
 
65
+ if ( empty( $string ) ) {
66
  return $string;
67
+ }
68
+
69
+
70
+ if ( strpos( $string, '$BackWPup$ENC1$O$' ) !== FALSE || strpos( $string, '$BackWPup$RIJNDAEL$O$' ) !== FALSE ) {
71
+ $key_type = 'O$';
72
+ $key = BACKWPUP_ENC_KEY;
73
+ } else {
74
+ $key_type = '';
75
+ $key = DB_NAME . DB_USER . DB_PASSWORD;
76
+ }
77
 
78
+ $key = md5( $key );
79
 
80
+ if ( strpos( $string, '$BackWPup$ENC1$' . $key_type ) !== FALSE ) {
81
+ $string = str_replace( '$BackWPup$ENC1$' . $key_type, '', $string );
82
  $result = '';
83
  $string = base64_decode( $string );
84
  for ( $i = 0; $i < strlen( $string ); $i ++ ) {
91
  return $result;
92
  }
93
 
94
+ if ( function_exists( 'mcrypt_encrypt' ) && strpos( $string, '$BackWPup$RIJNDAEL$' . $key_type ) !== FALSE ) {
95
+ $string = str_replace( '$BackWPup$RIJNDAEL$' . $key_type, '', $string );
96
 
97
+ return trim( mcrypt_decrypt( MCRYPT_RIJNDAEL_256, md5( $key ), base64_decode( $string ), MCRYPT_MODE_CBC, md5( md5( $key ) ) ), "\0" );
98
  }
99
 
100
  return $string;
inc/class-file.php CHANGED
@@ -1,87 +1,96 @@
1
- <?php
2
- /**
3
- * Class for methods for file/folder related things
4
- */
5
- class BackWPup_File {
6
-
7
- /**
8
- *
9
- * Get the folder for blog uploads
10
- *
11
- * @return string
12
- */
13
- public static function get_upload_dir() {
14
-
15
- if ( is_multisite() ) {
16
- if ( defined( 'UPLOADBLOGSDIR' ) )
17
- return trailingslashit( str_replace( '\\', '/',ABSPATH . UPLOADBLOGSDIR ) );
18
- elseif ( is_dir( trailingslashit( WP_CONTENT_DIR ) . 'uploads/sites') )
19
- return str_replace( '\\', '/', trailingslashit( WP_CONTENT_DIR ) . 'uploads/sites/' );
20
- elseif ( is_dir( trailingslashit( WP_CONTENT_DIR ) . 'uploads' ) )
21
- return str_replace( '\\', '/', trailingslashit( WP_CONTENT_DIR ) . 'uploads/' );
22
- else
23
- return trailingslashit( str_replace( '\\', '/', WP_CONTENT_DIR ) );
24
- } else {
25
- $upload_dir = wp_upload_dir();
26
- return trailingslashit( str_replace( '\\', '/', $upload_dir[ 'basedir' ] ) );
27
- }
28
-
29
- }
30
-
31
- /**
32
- *
33
- * check if path in open basedir
34
- *
35
- * @param string $dir the folder to check
36
- *
37
- * @return bool is it in open basedir
38
- */
39
- public static function is_in_open_basedir( $dir ) {
40
-
41
- $ini_open_basedir = str_replace( '\\', '/',ini_get( 'open_basedir' ) );
42
-
43
- if ( empty( $ini_open_basedir ) )
44
- return TRUE;
45
-
46
- $open_base_dirs = explode( PATH_SEPARATOR, $ini_open_basedir );
47
- $dir = trailingslashit( str_replace( '\\', '/', $dir ) );
48
-
49
- foreach ( $open_base_dirs as $open_base_dir ) {
50
- if ( stripos( $dir, trailingslashit( $open_base_dir ) <= 1 ) )
51
- return TRUE;
52
- }
53
-
54
- return FALSE;
55
- }
56
-
57
- /**
58
- *
59
- * get size of files in folder
60
- *
61
- * @param string $folder the folder to calculate
62
- * @param bool $deep went thrue suborders
63
- * @return int folder size in byte
64
- */
65
- public static function get_folder_size( $folder, $deep = TRUE ) {
66
-
67
- $files_size = 0;
68
-
69
- if ( ! is_readable( $folder ) )
70
- return $files_size;
71
-
72
- if ( $dir = opendir( $folder ) ) {
73
- while ( FALSE !== ( $file = readdir( $dir ) ) ) {
74
- if ( in_array( $file, array( '.', '..' ) ) || is_link( $folder . '/' . $file ) )
75
- continue;
76
- if ( $deep && is_dir( $folder . '/' . $file ) )
77
- $files_size = $files_size + self::get_folder_size( $folder . '/' . $file, TRUE );
78
- elseif ( is_readable( $folder . '/' . $file ) )
79
- $files_size = $files_size + @filesize( $folder . '/' . $file );
80
-
81
- }
82
- closedir( $dir );
83
- }
84
-
85
- return $files_size;
86
- }
87
- }
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class for methods for file/folder related things
4
+ */
5
+ class BackWPup_File {
6
+
7
+ /**
8
+ *
9
+ * Get the folder for blog uploads
10
+ *
11
+ * @return string
12
+ */
13
+ public static function get_upload_dir() {
14
+
15
+ if ( is_multisite() ) {
16
+ if ( defined( 'UPLOADBLOGSDIR' ) )
17
+ return trailingslashit( str_replace( '\\', '/',ABSPATH . UPLOADBLOGSDIR ) );
18
+ elseif ( is_dir( trailingslashit( WP_CONTENT_DIR ) . 'uploads/sites') )
19
+ return str_replace( '\\', '/', trailingslashit( WP_CONTENT_DIR ) . 'uploads/sites/' );
20
+ elseif ( is_dir( trailingslashit( WP_CONTENT_DIR ) . 'uploads' ) )
21
+ return str_replace( '\\', '/', trailingslashit( WP_CONTENT_DIR ) . 'uploads/' );
22
+ else
23
+ return trailingslashit( str_replace( '\\', '/', WP_CONTENT_DIR ) );
24
+ } else {
25
+ $upload_dir = wp_upload_dir();
26
+ return trailingslashit( str_replace( '\\', '/', $upload_dir[ 'basedir' ] ) );
27
+ }
28
+
29
+ }
30
+
31
+ /**
32
+ *
33
+ * check if path in open basedir
34
+ *
35
+ * @param string $dir the folder to check
36
+ *
37
+ * @return bool is it in open basedir
38
+ */
39
+ public static function is_in_open_basedir( $dir ) {
40
+
41
+ $ini_open_basedir = str_replace( '\\', '/',ini_get( 'open_basedir' ) );
42
+
43
+ if ( empty( $ini_open_basedir ) )
44
+ return TRUE;
45
+
46
+ $open_base_dirs = explode( PATH_SEPARATOR, $ini_open_basedir );
47
+ $dir = trailingslashit( str_replace( '\\', '/', $dir ) );
48
+
49
+ foreach ( $open_base_dirs as $open_base_dir ) {
50
+ if ( stripos( $dir, trailingslashit( $open_base_dir ) <= 1 ) )
51
+ return TRUE;
52
+ }
53
+
54
+ return FALSE;
55
+ }
56
+
57
+ /**
58
+ *
59
+ * get size of files in folder
60
+ *
61
+ * @param string $folder the folder to calculate
62
+ * @param bool $deep went thrue suborders
63
+ * @return int folder size in byte
64
+ */
65
+ public static function get_folder_size( $folder, $deep = TRUE ) {
66
+
67
+ $files_size = 0;
68
+
69
+ if ( ! is_readable( $folder ) )
70
+ return $files_size;
71
+
72
+ if ( $dir = opendir( $folder ) ) {
73
+ while ( FALSE !== ( $file = readdir( $dir ) ) ) {
74
+ if ( in_array( $file, array( '.', '..' ) ) || is_link( $folder . '/' . $file ) ) {
75
+ continue;
76
+ }
77
+ if ( $deep && is_dir( $folder . '/' . $file ) ) {
78
+ $files_size = $files_size + self::get_folder_size( $folder . '/' . $file, TRUE );
79
+ }
80
+ elseif ( is_link( $folder . '/' . $file ) ) {
81
+ continue;
82
+ }
83
+ elseif ( is_readable( $folder . '/' . $file ) ) {
84
+ $file_size = filesize( $folder . '/' . $file );
85
+ if ( empty( $file_size ) || ! is_int( $file_size ) ) {
86
+ continue;
87
+ }
88
+ $files_size = $files_size + $file_size;
89
+ }
90
+ }
91
+ closedir( $dir );
92
+ }
93
+
94
+ return $files_size;
95
+ }
96
+ }
inc/class-help.php CHANGED
@@ -1,48 +1,48 @@
1
- <?php
2
- /**
3
- *
4
- */
5
- class BackWPup_Help {
6
-
7
- /**
8
- *
9
- */
10
- public static function help() {
11
-
12
- if ( method_exists( get_current_screen(), 'add_help_tab' ) ) {
13
- get_current_screen()->add_help_tab( array(
14
- 'id' => 'plugininfo',
15
- 'title' => __( 'Plugin Info', 'backwpup' ),
16
- 'content' =>
17
- '<p> '.str_replace( '\"','"', sprintf( _x( '%1$s version %2$s. A project by <a href="http://inpsyde.com">Inpsyde GmbH</a>.','Plugin name and link; Plugin Version','backwpup' ), '<a href="' . translate( BackWPup::get_plugin_data( 'PluginURI' ), 'backwpup' ) . '">' . BackWPup::get_plugin_data( 'Name' ) . '</a>' , BackWPup::get_plugin_data( 'Version' ) ) ) . '</p>'
18
- . '<p>' . __( 'BackWPup comes with ABSOLUTELY NO WARRANTY. This is a free software, and you are welcome to redistribute it under certain conditions.', 'backwpup' ) . '</p>'
19
- ) );
20
-
21
- $text_help_sidebar = '<p><strong>' . __( 'For more information:', 'backwpup' ) . '</strong></p>';
22
- $text_help_sidebar .= '<p><a href="' . translate( BackWPup::get_plugin_data( 'PluginURI' ), 'backwpup' ) . '">' . BackWPup::get_plugin_data( 'Name' ) . '</a></p>';
23
- $text_help_sidebar .= '<p><a href="http://wordpress.org/extend/plugins/backwpup/">' . __( 'Plugin on wordpress.org', 'backwpup' ) . '</a></p>';
24
- $text_help_sidebar .= '<p><a href="' . __( 'https://marketpress.com/news/', 'backwpup' ) . '">' . __( 'News', 'backwpup' ) . '</a></p>';
25
- if ( class_exists( 'BackWPup_Pro', FALSE ) )
26
- $text_help_sidebar .= '<p><a href="' . __( 'https://marketpress.com/support/forum/plugins/backwpup-pro/', 'backwpup' ) . '">' . __( 'Pro Support', 'backwpup' ) . '</a></p>';
27
- else
28
- $text_help_sidebar .= '<p><a href="' . __( 'http://wordpress.org/support/plugin/backwpup/', 'backwpup' ) . '">' . __( 'Support', 'backwpup' ) . '</a></p>';
29
- $text_help_sidebar .= '<p><a href="' . __( 'https://marketpress.com/documentation/backwpup-pro/', 'backwpup' ) . '">' . __( 'Manual', 'backwpup' ) . '</a></p>';
30
-
31
- get_current_screen()->set_help_sidebar( $text_help_sidebar );
32
- }
33
-
34
- }
35
-
36
- /**
37
- * @static
38
- *
39
- * @param array $tab
40
- */
41
- public static function add_tab( $tab = array() ) {
42
-
43
- if ( method_exists( get_current_screen(), 'add_help_tab' ) )
44
- get_current_screen()->add_help_tab( $tab );
45
-
46
- }
47
-
48
- }
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ class BackWPup_Help {
6
+
7
+ /**
8
+ *
9
+ */
10
+ public static function help() {
11
+
12
+ if ( method_exists( get_current_screen(), 'add_help_tab' ) ) {
13
+ get_current_screen()->add_help_tab( array(
14
+ 'id' => 'plugininfo',
15
+ 'title' => __( 'Plugin Info', 'backwpup' ),
16
+ 'content' =>
17
+ '<p> '.str_replace( '\"','"', sprintf( _x( '%1$s version %2$s. A project by <a href="http://inpsyde.com">Inpsyde GmbH</a>.','Plugin name and link; Plugin Version','backwpup' ), '<a href="' . translate( BackWPup::get_plugin_data( 'PluginURI' ), 'backwpup' ) . '">' . BackWPup::get_plugin_data( 'Name' ) . '</a>' , BackWPup::get_plugin_data( 'Version' ) ) ) . '</p>'
18
+ . '<p>' . __( 'BackWPup comes with ABSOLUTELY NO WARRANTY. This is a free software, and you are welcome to redistribute it under certain conditions.', 'backwpup' ) . '</p>'
19
+ ) );
20
+
21
+ $text_help_sidebar = '<p><strong>' . __( 'For more information:', 'backwpup' ) . '</strong></p>';
22
+ $text_help_sidebar .= '<p><a href="' . translate( BackWPup::get_plugin_data( 'PluginURI' ), 'backwpup' ) . '">' . BackWPup::get_plugin_data( 'Name' ) . '</a></p>';
23
+ $text_help_sidebar .= '<p><a href="http://wordpress.org/extend/plugins/backwpup/">' . __( 'Plugin on wordpress.org', 'backwpup' ) . '</a></p>';
24
+ $text_help_sidebar .= '<p><a href="' . __( 'https://marketpress.com/news/', 'backwpup' ) . '">' . __( 'News', 'backwpup' ) . '</a></p>';
25
+ if ( class_exists( 'BackWPup_Pro', FALSE ) )
26
+ $text_help_sidebar .= '<p><a href="' . __( 'https://marketpress.com/support/forum/plugins/backwpup-pro/', 'backwpup' ) . '">' . __( 'Pro Support', 'backwpup' ) . '</a></p>';
27
+ else
28
+ $text_help_sidebar .= '<p><a href="' . __( 'http://wordpress.org/support/plugin/backwpup/', 'backwpup' ) . '">' . __( 'Support', 'backwpup' ) . '</a></p>';
29
+ $text_help_sidebar .= '<p><a href="' . __( 'https://marketpress.com/documentation/backwpup-pro/', 'backwpup' ) . '">' . __( 'Manual', 'backwpup' ) . '</a></p>';
30
+
31
+ get_current_screen()->set_help_sidebar( $text_help_sidebar );
32
+ }
33
+
34
+ }
35
+
36
+ /**
37
+ * @static
38
+ *
39
+ * @param array $tab
40
+ */
41
+ public static function add_tab( $tab = array() ) {
42
+
43
+ if ( method_exists( get_current_screen(), 'add_help_tab' ) )
44
+ get_current_screen()->add_help_tab( $tab );
45
+
46
+ }
47
+
48
+ }
inc/class-install.php CHANGED
@@ -1,313 +1,313 @@
1
- <?php
2
- /**
3
- * Class for upgrade / deactivation / uninstall
4
- */
5
- class BackWPup_Install {
6
-
7
- /**
8
- * Creates DB und updates settings
9
- */
10
- public static function activate() {
11
-
12
- //convert inactive version to active
13
- if ( $incative_version = get_site_option( 'backwpup_version' ) ) {
14
- update_site_option( 'backwpup_version', str_replace( '-inactive', '', $incative_version ) );
15
- }
16
-
17
- //changes for version before 3.0.0
18
- if ( ! get_site_option( 'backwpup_version' ) && get_option( 'backwpup' ) && get_option( 'backwpup_jobs' ) )
19
- self::upgrade_from_version_two();
20
-
21
- //changes for version before 3.0.14
22
- if ( version_compare( '3.0.13', get_site_option( 'backwpup_version' ), '>' ) && version_compare( '3.0', get_site_option( 'backwpup_version' ), '<' ) ) {
23
- $upload_dir = wp_upload_dir();
24
- $logfolder = get_site_option( 'backwpup_cfg_logfolder' );
25
- if ( empty( $logfolder ) ) {
26
- $old_log_folder = trailingslashit( str_replace( '\\', '/',$upload_dir[ 'basedir' ] ) ) . 'backwpup-' . substr( md5( md5( SECURE_AUTH_KEY ) ), 9, 5 ) . '-logs/';
27
- update_site_option( 'backwpup_cfg_logfolder', $old_log_folder );
28
- }
29
- }
30
-
31
- //changes for version before 3.1.2
32
- if ( version_compare( '3.1.2', get_site_option( 'backwpup_version' ), '>' ) ) {
33
- BackWPup_Job::check_folder( get_site_option( 'backwpup_cfg_logfolder' ), TRUE );
34
- }
35
-
36
- //create new options
37
- if ( is_multisite() )
38
- add_site_option( 'backwpup_jobs', array() );
39
- else
40
- add_option( 'backwpup_jobs', array(), NULL, 'no' );
41
-
42
- //remove old schedule
43
- wp_clear_scheduled_hook( 'backwpup_cron' );
44
- //make new schedule
45
- $activejobs = BackWPup_Option::get_job_ids( 'activetype', 'wpcron' );
46
- if ( ! empty( $activejobs ) ) {
47
- foreach ( $activejobs as $id ) {
48
- $cron_next = BackWPup_Cron::cron_next( BackWPup_Option::get( $id, 'cron') );
49
- wp_schedule_single_event( $cron_next, 'backwpup_cron', array( 'id' => $id ) );
50
- }
51
- }
52
-
53
- //add check Cleanup schedule
54
- wp_clear_scheduled_hook( 'backwpup_check_cleanup' );
55
- wp_schedule_event( time(), 'twicedaily', 'backwpup_check_cleanup' );
56
-
57
- //remove old roles pre v.3.0.9
58
- $role = get_role( 'administrator' );
59
- $role->remove_cap( 'backwpup' );
60
- $role->remove_cap( 'backwpup_jobs' );
61
- $role->remove_cap( 'backwpup_jobs_edit' );
62
- $role->remove_cap( 'backwpup_jobs_start' );
63
- $role->remove_cap( 'backwpup_backups' );
64
- $role->remove_cap( 'backwpup_backups_download' );
65
- $role->remove_cap( 'backwpup_backups_delete' );
66
- $role->remove_cap( 'backwpup_logs' );
67
- $role->remove_cap( 'backwpup_logs_delete' );
68
- $role->remove_cap( 'backwpup_settings' );
69
-
70
- //add/overwrite roles
71
- add_role( 'backwpup_admin', __( 'BackWPup Admin', 'backwpup' ), array(
72
- 'backwpup' => TRUE, // BackWPup general accesses (like Dashboard)
73
- 'backwpup_jobs' => TRUE, // accesses for job page
74
- 'backwpup_jobs_edit' => TRUE, // user can edit/delete/copy/export jobs
75
- 'backwpup_jobs_start' => TRUE, // user can start jobs
76
- 'backwpup_backups' => TRUE, // accesses for backups page
77
- 'backwpup_backups_download' => TRUE, // user can download backup files
78
- 'backwpup_backups_delete' => TRUE, // user can delete backup files
79
- 'backwpup_logs' => TRUE, // accesses for logs page
80
- 'backwpup_logs_delete' => TRUE, // user can delete log files
81
- 'backwpup_settings' => TRUE, // accesses for settings page
82
- ) );
83
-
84
- add_role( 'backwpup_check', __( 'BackWPup jobs checker', 'backwpup' ), array(
85
- 'backwpup' => TRUE,
86
- 'backwpup_jobs' => TRUE,
87
- 'backwpup_jobs_edit' => FALSE,
88
- 'backwpup_jobs_start' => FALSE,
89
- 'backwpup_backups' => TRUE,
90
- 'backwpup_backups_download' => FALSE,
91
- 'backwpup_backups_delete' => FALSE,
92
- 'backwpup_logs' => TRUE,
93
- 'backwpup_logs_delete' => FALSE,
94
- 'backwpup_settings' => FALSE,
95
- ) );
96
-
97
- add_role( 'backwpup_helper', __( 'BackWPup jobs helper', 'backwpup' ), array(
98
- 'backwpup' => TRUE,
99
- 'backwpup_jobs' => TRUE,
100
- 'backwpup_jobs_edit' => FALSE,
101
- 'backwpup_jobs_start' => TRUE,
102
- 'backwpup_backups' => TRUE,
103
- 'backwpup_backups_download' => TRUE,
104
- 'backwpup_backups_delete' => TRUE,
105
- 'backwpup_logs' => TRUE,
106
- 'backwpup_logs_delete' => TRUE,
107
- 'backwpup_settings' => FALSE,
108
- ) );
109
-
110
- //add role to admin user if no one
111
- $users_backwpup = get_users( array( 'blog_id' => 1, 'role' => 'backwpup_admin' ) );
112
- if ( empty( $users_backwpup ) ) {
113
- /* @var WP_User $user */
114
- $users = get_users( array( 'blog_id' => 1, 'role' => 'administrator', 'fields' => 'all_with_meta' ) );
115
- foreach ( $users as $user ) {
116
- $user->add_role( 'backwpup_admin' );
117
- }
118
- }
119
-
120
- //add default options
121
- BackWPup_Option::default_site_options();
122
-
123
- //update version
124
- update_site_option( 'backwpup_version', BackWPup::get_plugin_data( 'Version' ) );
125
- }
126
-
127
- /**
128
- *
129
- * Cleanup on Plugin deactivation
130
- *
131
- * @return void
132
- */
133
- public static function deactivate() {
134
-
135
- wp_clear_scheduled_hook( 'backwpup_cron' );
136
- $activejobs = BackWPup_Option::get_job_ids( 'activetype', 'wpcron' );
137
- if ( ! empty( $activejobs ) ) {
138
- foreach ( $activejobs as $id ) {
139
- wp_clear_scheduled_hook( 'backwpup_cron', array( 'id' => $id ) );
140
- }
141
- }
142
- wp_clear_scheduled_hook( 'backwpup_check_cleanup' );
143
- //to reschedule on activation and so on
144
- update_site_option( 'backwpup_version', get_site_option( 'backwpup_version' ) .'-inactive' );
145
- }
146
-
147
-
148
- private static function upgrade_from_version_two() {
149
-
150
- //load options
151
- $cfg = get_option( 'backwpup' ); //only exists in Version 2
152
- $jobs = get_option( 'backwpup_jobs' );
153
-
154
- //delete old options
155
- delete_option( 'backwpup' );
156
- delete_option( 'backwpup_jobs' );
157
-
158
- //add new option default structure and without auto load cache
159
- if ( ! is_multisite() )
160
- add_option( 'backwpup_jobs', array(), NULL, 'no' );
161
-
162
- //upgrade cfg
163
- //if old value switch it to new
164
- if ( ! empty( $cfg[ 'dirlogs' ] ) )
165
- $cfg[ 'logfolder' ] = $cfg[ 'dirlogs' ];
166
- if ( ! empty( $cfg[ 'httpauthpassword' ] ) ) {
167
- if ( preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $cfg[ 'httpauthpassword' ] ) )
168
- $cfg[ 'httpauthpassword' ] = base64_decode( $cfg[ 'httpauthpassword' ] );
169
- $cfg[ 'httpauthpassword' ] = BackWPup_Encryption::encrypt( $cfg[ 'httpauthpassword' ] );
170
- }
171
- // delete old not needed vars
172
- unset( $cfg[ 'dirtemp' ], $cfg[ 'dirlogs' ], $cfg[ 'logfilelist' ], $cfg[ 'jobscriptruntime' ], $cfg[ 'jobscriptruntimelong' ], $cfg[ 'last_activate' ], $cfg[ 'disablewpcron' ], $cfg[ 'phpzip' ], $cfg[ 'apicronservice' ], $cfg[ 'mailsndemail' ], $cfg[ 'mailsndname' ], $cfg[ 'mailmethod' ], $cfg[ 'mailsendmail' ], $cfg[ 'mailhost' ], $cfg[ 'mailpass' ], $cfg[ 'mailhostport' ], $cfg[ 'mailsecure' ], $cfg[ 'mailuser' ] );
173
- //save in options
174
- foreach ( $cfg as $cfgname => $cfgvalue )
175
- update_site_option( 'backwpup_cfg_' . $cfgname, $cfgvalue );
176
-
177
- //Put old jobs to new if exists
178
- foreach ( $jobs as $jobid => $jobvalue ) {
179
- //convert general settings
180
- if ( empty( $jobvalue[ 'jobid' ] ) )
181
- $jobvalue[ 'jobid' ] = $jobid;
182
- if ( empty( $jobvalue[ 'activated' ] ) )
183
- $jobvalue[ 'activetype' ] = '';
184
- else
185
- $jobvalue[ 'activetype' ] = 'wpcron';
186
- if ( ! isset( $jobvalue[ 'cronselect' ] ) && ! isset( $jobvalue[ 'cron' ] ) )
187
- $jobvalue[ 'cronselect' ] = 'basic';
188
- elseif ( ! isset( $jobvalue[ 'cronselect' ] ) && isset( $jobvalue[ 'cron' ] ) )
189
- $jobvalue[ 'cronselect' ] = 'advanced';
190
- $jobvalue[ 'backuptype' ] = 'archive';
191
- $jobvalue[ 'type' ] = explode( '+', $jobvalue[ 'type' ] ); //save as array
192
- foreach ( $jobvalue[ 'type' ] as $key => $type ) {
193
- if ( $type == 'DB' )
194
- $jobvalue[ 'type' ][ $key ] = 'DBDUMP';
195
- if ( $type == 'OPTIMIZE' )
196
- unset( $jobvalue[ 'type' ][ $key ] );
197
- if ( $type == 'CHECK' )
198
- $jobvalue[ 'type' ][ $key ] = 'DBCHECK';
199
- if ( $type == 'MAIL' )
200
- $jobvalue[ 'type' ][ $key ] = 'EMAIL';
201
- }
202
- $jobvalue[ 'archivename' ] = $jobvalue[ 'fileprefix' ] . '%Y-%m-%d_%H-%i-%s';
203
- $jobvalue[ 'archiveformat' ] = $jobvalue[ 'fileformart' ];
204
- //convert active destinations
205
- $jobvalue[ 'destinations' ] = array();
206
- if ( ! empty( $jobvalue[ 'backupdir' ] ) and $jobvalue[ 'backupdir' ] != '/' )
207
- $jobvalue[ 'destinations' ][ ] = 'FOLDER';
208
- if ( ! empty( $jobvalue[ 'mailaddress' ] ) )
209
- $jobvalue[ 'destinations' ][ ] = 'MAIL';
210
- if ( ! empty( $jobvalue[ 'ftphost' ] ) and ! empty( $jobvalue[ 'ftpuser' ] ) and ! empty( $jobvalue[ 'ftppass' ] ) )
211
- $jobvalue[ 'destinations' ][ ] = 'FTP';
212
- if ( ! empty( $jobvalue[ 'dropetoken' ] ) and ! empty( $jobvalue[ 'dropesecret' ] ) )
213
- $jobvalue[ 'destinations' ][ ] = 'DROPBOX';
214
- if ( ! empty( $jobvalue[ 'sugarrefreshtoken' ] ) and ! empty( $jobvalue[ 'sugarroot' ] ) )
215
- $jobvalue[ 'destinations' ][ ] = 'SUGARSYNC';
216
- if ( ! empty( $jobvalue[ 'awsAccessKey' ] ) and ! empty( $jobvalue[ 'awsSecretKey' ] ) and ! empty( $jobvalue[ 'awsBucket' ] ) )
217
- $jobvalue[ 'destinations' ][ ] = 'S3';
218
- if ( ! empty( $jobvalue[ 'GStorageAccessKey' ] ) and ! empty( $jobvalue[ 'GStorageSecret' ] ) and ! empty( $jobvalue[ 'GStorageBucket' ] ) and !in_array( 'S3', $jobvalue[ 'destinations' ] ) )
219
- $jobvalue[ 'destinations' ][ ] = 'S3';
220
- if ( ! empty( $jobvalue[ 'rscUsername' ] ) and ! empty( $jobvalue[ 'rscAPIKey' ] ) and ! empty( $jobvalue[ 'rscContainer' ] ) )
221
- $jobvalue[ 'destinations' ][ ] = 'RSC';
222
- if ( ! empty( $jobvalue[ 'msazureHost' ] ) and ! empty( $jobvalue[ 'msazureAccName' ] ) and ! empty( $jobvalue[ 'msazureKey' ] ) and ! empty( $jobvalue[ 'msazureContainer' ] ) )
223
- $jobvalue[ 'destinations' ][ ] = 'MSAZURE';
224
- //convert dropbox
225
- $jobvalue[ 'dropboxtoken' ] = ''; //new app key are set must reauth
226
- $jobvalue[ 'dropboxsecret' ] = '';
227
- $jobvalue[ 'dropboxroot' ] = 'dropbox';
228
- $jobvalue[ 'dropboxmaxbackups' ] = $jobvalue[ 'dropemaxbackups' ];
229
- $jobvalue[ 'dropboxdir' ] = $jobvalue[ 'dropedir' ];
230
- unset( $jobvalue[ 'dropetoken' ], $jobvalue[ 'dropesecret' ], $jobvalue[ 'droperoot' ], $jobvalue[ 'dropemaxbackups' ], $jobvalue[ 'dropedir' ] );
231
- //convert amazon S3
232
- $jobvalue[ 's3accesskey' ] = $jobvalue[ 'awsAccessKey' ];
233
- $jobvalue[ 's3secretkey' ] = BackWPup_Encryption::encrypt( $jobvalue[ 'awsSecretKey' ] );
234
- $jobvalue[ 's3bucket' ] = $jobvalue[ 'awsBucket' ];
235
- //get aws region
236
- $jobvalue[ 's3region' ] = 'us-east-1';
237
- $jobvalue[ 's3base_url' ] = '';
238
- $jobvalue[ 's3storageclass' ] = !empty( $jobvalue[ 'awsrrs' ] ) ? 'REDUCED_REDUNDANCY' : '';
239
- $jobvalue[ 's3dir' ] = $jobvalue[ 'awsdir' ];
240
- $jobvalue[ 's3maxbackups' ] = $jobvalue[ 'awsmaxbackups' ];
241
- unset( $jobvalue[ 'awsAccessKey' ], $jobvalue[ 'awsSecretKey' ], $jobvalue[ 'awsBucket' ], $jobvalue[ 'awsrrs' ], $jobvalue[ 'awsdir' ], $jobvalue[ 'awsmaxbackups' ] );
242
- //convert google storage
243
- $jobvalue[ 's3accesskey' ] = $jobvalue[ 'GStorageAccessKey' ];
244
- $jobvalue[ 's3secretkey' ] = BackWPup_Encryption::encrypt( $jobvalue[ 'GStorageSecret' ] );
245
- $jobvalue[ 's3bucket' ] = $jobvalue[ 'GStorageBucket' ];
246
- $jobvalue[ 's3region' ] = 'google-storage';
247
- $jobvalue[ 's3base_url' ] = '';
248
- $jobvalue[ 's3ssencrypt' ] = '';
249
- $jobvalue[ 's3dir' ] = $jobvalue[ 'GStoragedir' ];
250
- $jobvalue[ 's3maxbackups' ] = $jobvalue[ 'GStoragemaxbackups' ];
251
- unset( $jobvalue[ 'GStorageAccessKey' ], $jobvalue[ 'GStorageSecret' ], $jobvalue[ 'GStorageBucket' ], $jobvalue[ 'GStoragedir' ], $jobvalue[ 'GStoragemaxbackups' ] );
252
- //convert MS Azure storage
253
- $jobvalue[ 'msazureaccname' ] = $jobvalue[ 'msazureAccName' ];
254
- $jobvalue[ 'msazurekey' ] = BackWPup_Encryption::encrypt( $jobvalue[ 'msazureKey' ] );
255
- $jobvalue[ 'msazurecontainer' ] = $jobvalue[ 'msazureContainer' ];
256
- unset( $jobvalue[ 'msazureHost' ], $jobvalue[ 'msazureAccName' ], $jobvalue[ 'msazureKey' ], $jobvalue[ 'msazureContainer' ] );
257
- //convert FTP
258
- if ( preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $jobvalue[ 'ftppass' ]) )
259
- $jobvalue[ 'ftppass' ] = base64_decode( $jobvalue[ 'ftppass' ] );
260
- $jobvalue[ 'ftppass' ] = BackWPup_Encryption::encrypt( $jobvalue[ 'ftppass' ] );
261
- if ( ! empty( $jobvalue[ 'ftphost' ] ) && strstr( $jobvalue[ 'ftphost' ], ':' ) )
262
- list( $jobvalue[ 'ftphost' ], $jobvalue[ 'ftphostport' ] ) = explode( ':', $jobvalue[ 'ftphost' ], 2 );
263
- //convert Sugarsync
264
- //convert Mail
265
- $jobvalue[ 'emailaddress' ] = $jobvalue[ 'mailaddress' ];
266
- $jobvalue[ 'emailefilesize' ] = $jobvalue[ 'mailefilesize' ];
267
- unset( $jobvalue[ 'mailaddress' ], $jobvalue[ 'mailefilesize' ] );
268
- //convert RSC
269
- $jobvalue[ 'rscusername' ] = $jobvalue[ 'rscUsername' ];
270
- $jobvalue[ 'rscapikey' ] = $jobvalue[ 'rscAPIKey' ];
271
- $jobvalue[ 'rsccontainer' ] = $jobvalue[ 'rscContainer' ];
272
- //convert jobtype DB Dump
273
- $jobvalue[ 'dbdumpexclude' ] = $jobvalue[ 'dbexclude' ];
274
- unset( $jobvalue[ 'dbexclude' ], $jobvalue['dbshortinsert'] );
275
- //convert jobtype DBDUMP, DBCHECK
276
- $jobvalue[ 'dbcheckrepair' ] = TRUE;
277
- unset( $jobvalue[ 'maintenance' ] );
278
- //convert jobtype wpexport
279
- //convert jobtype file
280
- $excludes = array();
281
- foreach ( $jobvalue[ 'backuprootexcludedirs' ] as $folder ) {
282
- $excludes[] = basename( $folder );
283
- }
284
- $jobvalue[ 'backuprootexcludedirs' ] = $excludes;
285
- $excludes = array();
286
- foreach ( $jobvalue[ 'backupcontentexcludedirs' ] as $folder ) {
287
- $excludes[] = basename( $folder );
288
- }
289
- $jobvalue[ 'backupcontentexcludedirs' ] = $excludes;
290
- $excludes = array();
291
- foreach ( $jobvalue[ 'backuppluginsexcludedirs' ] as $folder ) {
292
- $excludes[] = basename( $folder );
293
- }
294
- $jobvalue[ 'backuppluginsexcludedirs' ]= $excludes;
295
- $excludes = array();
296
- foreach ( $jobvalue[ 'backupthemesexcludedirs' ] as $folder ) {
297
- $excludes[] = basename( $folder );
298
- }
299
- $jobvalue[ 'backupthemesexcludedirs' ] = $excludes;
300
- $excludes = array();
301
- foreach ( $jobvalue[ 'backupuploadsexcludedirs' ] as $folder ) {
302
- $excludes[] = basename( $folder );
303
- }
304
- $jobvalue[ 'backupuploadsexcludedirs' ] = $excludes;
305
- //delete not longer needed
306
- unset( $jobvalue[ 'cronnextrun' ], $jobvalue[ 'fileprefix' ], $jobvalue[ 'fileformart' ], $jobvalue[ 'scheduleintervaltype' ], $jobvalue[ 'scheduleintervalteimes' ], $jobvalue[ 'scheduleinterval' ], $jobvalue[ 'dropemail' ], $jobvalue[ 'dropepass' ], $jobvalue[ 'dropesignmethod' ] );
307
- //save in options
308
- foreach ( $jobvalue as $jobvaluename => $jobvaluevalue )
309
- BackWPup_Option::update( $jobvalue[ 'jobid' ], $jobvaluename, $jobvaluevalue );
310
- }
311
- set_site_transient( 'backwpup_upgrade_from_version_two', TRUE, 3600*24*7);
312
- }
313
- }
1
+ <?php
2
+ /**
3
+ * Class for upgrade / deactivation / uninstall
4
+ */
5
+ class BackWPup_Install {
6
+
7
+ /**
8
+ * Creates DB und updates settings
9
+ */
10
+ public static function activate() {
11
+
12
+ //convert inactive version to active
13
+ if ( $incative_version = get_site_option( 'backwpup_version' ) ) {
14
+ update_site_option( 'backwpup_version', str_replace( '-inactive', '', $incative_version ) );
15
+ }
16
+
17
+ //changes for version before 3.0.0
18
+ if ( ! get_site_option( 'backwpup_version' ) && get_option( 'backwpup' ) && get_option( 'backwpup_jobs' ) )
19
+ self::upgrade_from_version_two();
20
+
21
+ //changes for version before 3.0.14
22
+ if ( version_compare( '3.0.13', get_site_option( 'backwpup_version' ), '>' ) && version_compare( '3.0', get_site_option( 'backwpup_version' ), '<' ) ) {
23
+ $upload_dir = wp_upload_dir();
24
+ $logfolder = get_site_option( 'backwpup_cfg_logfolder' );
25
+ if ( empty( $logfolder ) ) {
26
+ $old_log_folder = trailingslashit( str_replace( '\\', '/',$upload_dir[ 'basedir' ] ) ) . 'backwpup-' . substr( md5( md5( SECURE_AUTH_KEY ) ), 9, 5 ) . '-logs/';
27
+ update_site_option( 'backwpup_cfg_logfolder', $old_log_folder );
28
+ }
29
+ }
30
+
31
+ //changes for version before 3.1.2
32
+ if ( version_compare( '3.1.2', get_site_option( 'backwpup_version' ), '>' ) ) {
33
+ BackWPup_Job::check_folder( get_site_option( 'backwpup_cfg_logfolder' ), TRUE );
34
+ }
35
+
36
+ //create new options
37
+ if ( is_multisite() )
38
+ add_site_option( 'backwpup_jobs', array() );
39
+ else
40
+ add_option( 'backwpup_jobs', array(), NULL, 'no' );
41
+
42
+ //remove old schedule
43
+ wp_clear_scheduled_hook( 'backwpup_cron' );
44
+ //make new schedule
45
+ $activejobs = BackWPup_Option::get_job_ids( 'activetype', 'wpcron' );
46
+ if ( ! empty( $activejobs ) ) {
47
+ foreach ( $activejobs as $id ) {
48
+ $cron_next = BackWPup_Cron::cron_next( BackWPup_Option::get( $id, 'cron') );
49
+ wp_schedule_single_event( $cron_next, 'backwpup_cron', array( 'id' => $id ) );
50
+ }
51
+ }
52
+
53
+ //add check Cleanup schedule
54
+ wp_clear_scheduled_hook( 'backwpup_check_cleanup' );
55
+ wp_schedule_event( time(), 'twicedaily', 'backwpup_check_cleanup' );
56
+
57
+ //remove old roles pre v.3.0.9
58
+ $role = get_role( 'administrator' );
59
+ $role->remove_cap( 'backwpup' );
60
+ $role->remove_cap( 'backwpup_jobs' );
61
+ $role->remove_cap( 'backwpup_jobs_edit' );
62
+ $role->remove_cap( 'backwpup_jobs_start' );
63
+ $role->remove_cap( 'backwpup_backups' );
64
+ $role->remove_cap( 'backwpup_backups_download' );
65
+ $role->remove_cap( 'backwpup_backups_delete' );
66
+ $role->remove_cap( 'backwpup_logs' );
67
+ $role->remove_cap( 'backwpup_logs_delete' );
68
+ $role->remove_cap( 'backwpup_settings' );
69
+
70
+ //add/overwrite roles
71
+ add_role( 'backwpup_admin', __( 'BackWPup Admin', 'backwpup' ), array(
72
+ 'backwpup' => TRUE, // BackWPup general accesses (like Dashboard)
73
+ 'backwpup_jobs' => TRUE, // accesses for job page
74
+ 'backwpup_jobs_edit' => TRUE, // user can edit/delete/copy/export jobs
75
+ 'backwpup_jobs_start' => TRUE, // user can start jobs
76
+ 'backwpup_backups' => TRUE, // accesses for backups page
77
+ 'backwpup_backups_download' => TRUE, // user can download backup files
78
+ 'backwpup_backups_delete' => TRUE, // user can delete backup files
79
+ 'backwpup_logs' => TRUE, // accesses for logs page
80
+ 'backwpup_logs_delete' => TRUE, // user can delete log files
81
+ 'backwpup_settings' => TRUE, // accesses for settings page
82
+ ) );
83
+
84
+ add_role( 'backwpup_check', __( 'BackWPup jobs checker', 'backwpup' ), array(
85
+ 'backwpup' => TRUE,
86
+ 'backwpup_jobs' => TRUE,
87
+ 'backwpup_jobs_edit' => FALSE,
88
+ 'backwpup_jobs_start' => FALSE,
89
+ 'backwpup_backups' => TRUE,
90
+ 'backwpup_backups_download' => FALSE,
91
+ 'backwpup_backups_delete' => FALSE,
92
+ 'backwpup_logs' => TRUE,
93
+ 'backwpup_logs_delete' => FALSE,
94
+ 'backwpup_settings' => FALSE,
95
+ ) );
96
+
97
+ add_role( 'backwpup_helper', __( 'BackWPup jobs helper', 'backwpup' ), array(
98
+ 'backwpup' => TRUE,
99
+ 'backwpup_jobs' => TRUE,
100
+ 'backwpup_jobs_edit' => FALSE,
101
+ 'backwpup_jobs_start' => TRUE,
102
+ 'backwpup_backups' => TRUE,
103
+ 'backwpup_backups_download' => TRUE,
104
+ 'backwpup_backups_delete' => TRUE,
105
+ 'backwpup_logs' => TRUE,
106
+ 'backwpup_logs_delete' => TRUE,
107
+ 'backwpup_settings' => FALSE,
108
+ ) );
109
+
110
+ //add role to admin user if no one
111
+ $users_backwpup = get_users( array( 'blog_id' => 1, 'role' => 'backwpup_admin' ) );
112
+ if ( empty( $users_backwpup ) ) {
113
+ /* @var WP_User $user */
114
+ $users = get_users( array( 'blog_id' => 1, 'role' => 'administrator', 'fields' => 'all_with_meta' ) );
115
+ foreach ( $users as $user ) {
116
+ $user->add_role( 'backwpup_admin' );
117
+ }
118
+ }
119
+
120
+ //add default options
121
+ BackWPup_Option::default_site_options();
122
+
123
+ //update version
124
+ update_site_option( 'backwpup_version', BackWPup::get_plugin_data( 'Version' ) );
125
+ }
126
+
127
+ /**
128
+ *
129
+ * Cleanup on Plugin deactivation
130
+ *
131
+ * @return void
132
+ */
133
+ public static function deactivate() {
134
+
135
+ wp_clear_scheduled_hook( 'backwpup_cron' );
136
+ $activejobs = BackWPup_Option::get_job_ids( 'activetype', 'wpcron' );
137
+ if ( ! empty( $activejobs ) ) {
138
+ foreach ( $activejobs as $id ) {
139
+ wp_clear_scheduled_hook( 'backwpup_cron', array( 'id' => $id ) );
140
+ }
141
+ }
142
+ wp_clear_scheduled_hook( 'backwpup_check_cleanup' );
143
+ //to reschedule on activation and so on
144
+ update_site_option( 'backwpup_version', get_site_option( 'backwpup_version' ) .'-inactive' );
145
+ }
146
+
147
+
148
+ private static function upgrade_from_version_two() {
149
+
150
+ //load options
151
+ $cfg = get_option( 'backwpup' ); //only exists in Version 2
152
+ $jobs = get_option( 'backwpup_jobs' );
153
+
154
+ //delete old options
155
+ delete_option( 'backwpup' );
156
+ delete_option( 'backwpup_jobs' );
157
+
158
+ //add new option default structure and without auto load cache
159
+ if ( ! is_multisite() )
160
+ add_option( 'backwpup_jobs', array(), NULL, 'no' );
161
+
162
+ //upgrade cfg
163
+ //if old value switch it to new
164
+ if ( ! empty( $cfg[ 'dirlogs' ] ) )
165
+ $cfg[ 'logfolder' ] = $cfg[ 'dirlogs' ];
166
+ if ( ! empty( $cfg[ 'httpauthpassword' ] ) ) {
167
+ if ( preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $cfg[ 'httpauthpassword' ] ) )
168
+ $cfg[ 'httpauthpassword' ] = base64_decode( $cfg[ 'httpauthpassword' ] );
169
+ $cfg[ 'httpauthpassword' ] = BackWPup_Encryption::encrypt( $cfg[ 'httpauthpassword' ] );
170
+ }
171
+ // delete old not needed vars
172
+ unset( $cfg[ 'dirtemp' ], $cfg[ 'dirlogs' ], $cfg[ 'logfilelist' ], $cfg[ 'jobscriptruntime' ], $cfg[ 'jobscriptruntimelong' ], $cfg[ 'last_activate' ], $cfg[ 'disablewpcron' ], $cfg[ 'phpzip' ], $cfg[ 'apicronservice' ], $cfg[ 'mailsndemail' ], $cfg[ 'mailsndname' ], $cfg[ 'mailmethod' ], $cfg[ 'mailsendmail' ], $cfg[ 'mailhost' ], $cfg[ 'mailpass' ], $cfg[ 'mailhostport' ], $cfg[ 'mailsecure' ], $cfg[ 'mailuser' ] );
173
+ //save in options
174
+ foreach ( $cfg as $cfgname => $cfgvalue )
175
+ update_site_option( 'backwpup_cfg_' . $cfgname, $cfgvalue );
176
+
177
+ //Put old jobs to new if exists
178
+ foreach ( $jobs as $jobid => $jobvalue ) {
179
+ //convert general settings
180
+ if ( empty( $jobvalue[ 'jobid' ] ) )
181
+ $jobvalue[ 'jobid' ] = $jobid;
182
+ if ( empty( $jobvalue[ 'activated' ] ) )
183
+ $jobvalue[ 'activetype' ] = '';
184
+ else
185
+ $jobvalue[ 'activetype' ] = 'wpcron';
186
+ if ( ! isset( $jobvalue[ 'cronselect' ] ) && ! isset( $jobvalue[ 'cron' ] ) )
187
+ $jobvalue[ 'cronselect' ] = 'basic';
188
+ elseif ( ! isset( $jobvalue[ 'cronselect' ] ) && isset( $jobvalue[ 'cron' ] ) )
189
+ $jobvalue[ 'cronselect' ] = 'advanced';
190
+ $jobvalue[ 'backuptype' ] = 'archive';
191
+ $jobvalue[ 'type' ] = explode( '+', $jobvalue[ 'type' ] ); //save as array
192
+ foreach ( $jobvalue[ 'type' ] as $key => $type ) {
193
+ if ( $type == 'DB' )
194
+ $jobvalue[ 'type' ][ $key ] = 'DBDUMP';
195
+ if ( $type == 'OPTIMIZE' )
196
+ unset( $jobvalue[ 'type' ][ $key ] );
197
+ if ( $type == 'CHECK' )
198
+ $jobvalue[ 'type' ][ $key ] = 'DBCHECK';
199
+ if ( $type == 'MAIL' )
200
+ $jobvalue[ 'type' ][ $key ] = 'EMAIL';
201
+ }
202
+ $jobvalue[ 'archivename' ] = $jobvalue[ 'fileprefix' ] . '%Y-%m-%d_%H-%i-%s';
203
+ $jobvalue[ 'archiveformat' ] = $jobvalue[ 'fileformart' ];
204
+ //convert active destinations
205
+ $jobvalue[ 'destinations' ] = array();
206
+ if ( ! empty( $jobvalue[ 'backupdir' ] ) and $jobvalue[ 'backupdir' ] != '/' )
207
+ $jobvalue[ 'destinations' ][ ] = 'FOLDER';
208
+ if ( ! empty( $jobvalue[ 'mailaddress' ] ) )
209
+ $jobvalue[ 'destinations' ][ ] = 'MAIL';
210
+ if ( ! empty( $jobvalue[ 'ftphost' ] ) and ! empty( $jobvalue[ 'ftpuser' ] ) and ! empty( $jobvalue[ 'ftppass' ] ) )
211
+ $jobvalue[ 'destinations' ][ ] = 'FTP';
212
+ if ( ! empty( $jobvalue[ 'dropetoken' ] ) and ! empty( $jobvalue[ 'dropesecret' ] ) )
213
+ $jobvalue[ 'destinations' ][ ] = 'DROPBOX';
214
+ if ( ! empty( $jobvalue[ 'sugarrefreshtoken' ] ) and ! empty( $jobvalue[ 'sugarroot' ] ) )
215
+ $jobvalue[ 'destinations' ][ ] = 'SUGARSYNC';
216
+ if ( ! empty( $jobvalue[ 'awsAccessKey' ] ) and ! empty( $jobvalue[ 'awsSecretKey' ] ) and ! empty( $jobvalue[ 'awsBucket' ] ) )
217
+ $jobvalue[ 'destinations' ][ ] = 'S3';
218
+ if ( ! empty( $jobvalue[ 'GStorageAccessKey' ] ) and ! empty( $jobvalue[ 'GStorageSecret' ] ) and ! empty( $jobvalue[ 'GStorageBucket' ] ) and !in_array( 'S3', $jobvalue[ 'destinations' ] ) )
219
+ $jobvalue[ 'destinations' ][ ] = 'S3';
220
+ if ( ! empty( $jobvalue[ 'rscUsername' ] ) and ! empty( $jobvalue[ 'rscAPIKey' ] ) and ! empty( $jobvalue[ 'rscContainer' ] ) )
221
+ $jobvalue[ 'destinations' ][ ] = 'RSC';
222
+ if ( ! empty( $jobvalue[ 'msazureHost' ] ) and ! empty( $jobvalue[ 'msazureAccName' ] ) and ! empty( $jobvalue[ 'msazureKey' ] ) and ! empty( $jobvalue[ 'msazureContainer' ] ) )
223
+ $jobvalue[ 'destinations' ][ ] = 'MSAZURE';
224
+ //convert dropbox
225
+ $jobvalue[ 'dropboxtoken' ] = ''; //new app key are set must reauth
226
+ $jobvalue[ 'dropboxsecret' ] = '';
227
+ $jobvalue[ 'dropboxroot' ] = 'dropbox';
228
+ $jobvalue[ 'dropboxmaxbackups' ] = $jobvalue[ 'dropemaxbackups' ];
229
+ $jobvalue[ 'dropboxdir' ] = $jobvalue[ 'dropedir' ];
230
+ unset( $jobvalue[ 'dropetoken' ], $jobvalue[ 'dropesecret' ], $jobvalue[ 'droperoot' ], $jobvalue[ 'dropemaxbackups' ], $jobvalue[ 'dropedir' ] );
231
+ //convert amazon S3
232
+ $jobvalue[ 's3accesskey' ] = $jobvalue[ 'awsAccessKey' ];
233
+ $jobvalue[ 's3secretkey' ] = BackWPup_Encryption::encrypt( $jobvalue[ 'awsSecretKey' ] );
234
+ $jobvalue[ 's3bucket' ] = $jobvalue[ 'awsBucket' ];
235
+ //get aws region
236
+ $jobvalue[ 's3region' ] = 'us-east-1';
237
+ $jobvalue[ 's3base_url' ] = '';
238
+ $jobvalue[ 's3storageclass' ] = !empty( $jobvalue[ 'awsrrs' ] ) ? 'REDUCED_REDUNDANCY' : '';
239
+ $jobvalue[ 's3dir' ] = $jobvalue[ 'awsdir' ];
240
+ $jobvalue[ 's3maxbackups' ] = $jobvalue[ 'awsmaxbackups' ];
241
+ unset( $jobvalue[ 'awsAccessKey' ], $jobvalue[ 'awsSecretKey' ], $jobvalue[ 'awsBucket' ], $jobvalue[ 'awsrrs' ], $jobvalue[ 'awsdir' ], $jobvalue[ 'awsmaxbackups' ] );
242
+ //convert google storage
243
+ $jobvalue[ 's3accesskey' ] = $jobvalue[ 'GStorageAccessKey' ];
244
+ $jobvalue[ 's3secretkey' ] = BackWPup_Encryption::encrypt( $jobvalue[ 'GStorageSecret' ] );
245
+ $jobvalue[ 's3bucket' ] = $jobvalue[ 'GStorageBucket' ];
246
+ $jobvalue[ 's3region' ] = 'google-storage';
247
+ $jobvalue[ 's3base_url' ] = '';
248
+ $jobvalue[ 's3ssencrypt' ] = '';
249
+ $jobvalue[ 's3dir' ] = $jobvalue[ 'GStoragedir' ];
250
+ $jobvalue[ 's3maxbackups' ] = $jobvalue[ 'GStoragemaxbackups' ];
251
+ unset( $jobvalue[ 'GStorageAccessKey' ], $jobvalue[ 'GStorageSecret' ], $jobvalue[ 'GStorageBucket' ], $jobvalue[ 'GStoragedir' ], $jobvalue[ 'GStoragemaxbackups' ] );
252
+ //convert MS Azure storage
253
+ $jobvalue[ 'msazureaccname' ] = $jobvalue[ 'msazureAccName' ];
254
+ $jobvalue[ 'msazurekey' ] = BackWPup_Encryption::encrypt( $jobvalue[ 'msazureKey' ] );
255
+ $jobvalue[ 'msazurecontainer' ] = $jobvalue[ 'msazureContainer' ];
256
+ unset( $jobvalue[ 'msazureHost' ], $jobvalue[ 'msazureAccName' ], $jobvalue[ 'msazureKey' ], $jobvalue[ 'msazureContainer' ] );
257
+ //convert FTP
258
+ if ( preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $jobvalue[ 'ftppass' ]) )
259
+ $jobvalue[ 'ftppass' ] = base64_decode( $jobvalue[ 'ftppass' ] );
260
+ $jobvalue[ 'ftppass' ] = BackWPup_Encryption::encrypt( $jobvalue[ 'ftppass' ] );
261
+ if ( ! empty( $jobvalue[ 'ftphost' ] ) && strstr( $jobvalue[ 'ftphost' ], ':' ) )
262
+ list( $jobvalue[ 'ftphost' ], $jobvalue[ 'ftphostport' ] ) = explode( ':', $jobvalue[ 'ftphost' ], 2 );
263
+ //convert Sugarsync
264
+ //convert Mail
265
+ $jobvalue[ 'emailaddress' ] = $jobvalue[ 'mailaddress' ];
266
+ $jobvalue[ 'emailefilesize' ] = $jobvalue[ 'mailefilesize' ];
267
+ unset( $jobvalue[ 'mailaddress' ], $jobvalue[ 'mailefilesize' ] );
268
+ //convert RSC
269
+ $jobvalue[ 'rscusername' ] = $jobvalue[ 'rscUsername' ];
270
+ $jobvalue[ 'rscapikey' ] = $jobvalue[ 'rscAPIKey' ];
271
+ $jobvalue[ 'rsccontainer' ] = $jobvalue[ 'rscContainer' ];
272
+ //convert jobtype DB Dump
273
+ $jobvalue[ 'dbdumpexclude' ] = $jobvalue[ 'dbexclude' ];
274
+ unset( $jobvalue[ 'dbexclude' ], $jobvalue['dbshortinsert'] );
275
+ //convert jobtype DBDUMP, DBCHECK
276
+ $jobvalue[ 'dbcheckrepair' ] = TRUE;
277
+ unset( $jobvalue[ 'maintenance' ] );
278
+ //convert jobtype wpexport
279
+ //convert jobtype file
280
+ $excludes = array();
281
+ foreach ( $jobvalue[ 'backuprootexcludedirs' ] as $folder ) {
282
+ $excludes[] = basename( $folder );
283
+ }
284
+ $jobvalue[ 'backuprootexcludedirs' ] = $excludes;
285
+ $excludes = array();
286
+ foreach ( $jobvalue[ 'backupcontentexcludedirs' ] as $folder ) {
287
+ $excludes[] = basename( $folder );
288
+ }
289
+ $jobvalue[ 'backupcontentexcludedirs' ] = $excludes;
290
+ $excludes = array();
291
+ foreach ( $jobvalue[ 'backuppluginsexcludedirs' ] as $folder ) {
292
+ $excludes[] = basename( $folder );
293
+ }
294
+ $jobvalue[ 'backuppluginsexcludedirs' ]= $excludes;
295
+ $excludes = array();
296
+ foreach ( $jobvalue[ 'backupthemesexcludedirs' ] as $folder ) {
297
+ $excludes[] = basename( $folder );
298
+ }
299
+ $jobvalue[ 'backupthemesexcludedirs' ] = $excludes;
300
+ $excludes = array();
301
+ foreach ( $jobvalue[ 'backupuploadsexcludedirs' ] as $folder ) {
302
+ $excludes[] = basename( $folder );
303
+ }
304
+ $jobvalue[ 'backupuploadsexcludedirs' ] = $excludes;
305
+ //delete not longer needed
306
+ unset( $jobvalue[ 'cronnextrun' ], $jobvalue[ 'fileprefix' ], $jobvalue[ 'fileformart' ], $jobvalue[ 'scheduleintervaltype' ], $jobvalue[ 'scheduleintervalteimes' ], $jobvalue[ 'scheduleinterval' ], $jobvalue[ 'dropemail' ], $jobvalue[ 'dropepass' ], $jobvalue[ 'dropesignmethod' ] );
307
+ //save in options
308
+ foreach ( $jobvalue as $jobvaluename => $jobvaluevalue )
309
+ BackWPup_Option::update( $jobvalue[ 'jobid' ], $jobvaluename, $jobvaluevalue );
310
+ }
311
+ set_site_transient( 'backwpup_upgrade_from_version_two', TRUE, 3600*24*7);
312
+ }
313
+ }
inc/class-job.php CHANGED
@@ -134,30 +134,25 @@ final class BackWPup_Job {
134
  public $user_abort = FALSE;
135
 
136
  /**
137
- * Setting Working data
138
- * @param $working_data array
139
  */
140
- private function __construct( $working_data = array() ) {
141
 
142
- if ( is_array( $working_data ) && ! empty( $working_data ) ) {
143
- //restore object properties from working data
144
- foreach ( $working_data as $var => $value )
145
- $this->{$var} = $value;
146
- //delete Temp
147
- $this->temp = array();
148
- }
149
 
150
- }
151
 
152
  /**
153
- * Create Job object from state
154
- *
155
- * @param array $working_data
156
- * @return \BackWPup_Job
157
  */
158
- private static function __set_state( $working_data = array() ) {
159
 
160
- return new self( $working_data );
 
161
  }
162
 
163
  /**
@@ -182,7 +177,7 @@ final class BackWPup_Job {
182
  else
183
  return;
184
  $this->start_time = current_time( 'timestamp' );
185
- $this->lastmsg = '<samp>' . __( 'Starting job', 'backwpup' ) . '</samp>';
186
  //set Logfile
187
  $this->logfile = get_site_option( 'backwpup_cfg_logfolder' ) . 'backwpup_log_' . BackWPup::get_plugin_data( 'hash' ) . '_' . date_i18n( 'Y-m-d_H-i-s' ) . '.html';
188
  //write settings to job
@@ -280,7 +275,9 @@ final class BackWPup_Job {
280
  }
281
  $this->steps_todo[] = 'END';
282
  $this->steps_data[ 'END' ][ 'NAME' ] = __( 'End of Job', 'backwpup' );
283
- $this->steps_data[ 'END' ][ 'STEP_TRY' ] = 0;
 
 
284
  //create log file
285
  $head = '';
286
  $head .= "<!DOCTYPE html>" . PHP_EOL;
@@ -304,11 +301,11 @@ final class BackWPup_Job {
304
  $head .= str_pad( '<meta name="backwpup_backupfilesize" content="0" />', 100 ) . PHP_EOL;
305
  $head .= str_pad( '<meta name="backwpup_jobruntime" content="0" />', 100 ) . PHP_EOL;
306
  $head .= "</head>" . PHP_EOL;
307
- $head .= "<body style=\"margin:0;padding:3px;font-family:Fixedsys,Courier,monospace;font-size:12px;line-height:15px;background-color:#000;color:#fff;white-space:pre;\">" . PHP_EOL;
308
- $head .= sprintf( _x( '[INFO] %1$s version %2$s; A project of Inpsyde GmbH', 'Plugin name; Plugin Version','backwpup' ), BackWPup::get_plugin_data( 'name' ) , BackWPup::get_plugin_data( 'Version' ) ) . PHP_EOL;
309
- $head .= sprintf( _x( '[INFO] WordPress version %s', 'WordPress Version', 'backwpup' ), BackWPup::get_plugin_data( 'wp_version' ) ) . PHP_EOL;
310
- $head .= sprintf( __( '[INFO] Blog url: %s', 'backwpup' ), esc_attr( site_url( '/' ) ) ). PHP_EOL;
311
- $head .= sprintf( __( '[INFO] BackWPup job: %1$s; %2$s', 'backwpup' ), esc_attr( $this->job[ 'name' ] ) , implode( '+', $this->job[ 'type' ] ) ) . PHP_EOL;
312
  if ( $this->job[ 'activetype' ] == 'wpcron' ) {
313
  //check next run
314
  $cron_next = wp_next_scheduled( 'backwpup_cron', array( 'id' => $this->job[ 'jobid' ] ) );
@@ -323,40 +320,48 @@ final class BackWPup_Job {
323
  $cron_next = __( 'Not scheduled!', 'backwpup' );
324
  else
325
  $cron_next = date_i18n( 'D, j M Y @ H:i', $cron_next + ( get_option( 'gmt_offset' ) * 3600 ) , TRUE ) ;
326
- $head .= sprintf( __( '[INFO] BackWPup cron: %s; Next: %s ', 'backwpup' ), $this->job[ 'cron' ] , $cron_next ) . PHP_EOL;
327
  }
328
  elseif ( $this->job[ 'activetype' ] == 'link' )
329
- $head .= __( '[INFO] BackWPup job start with link is active', 'backwpup' ) . PHP_EOL;
330
  else
331
- $head .= __( '[INFO] BackWPup no automatic job start configured', 'backwpup' ) . PHP_EOL;
332
  if ( $start_type == 'cronrun' )
333
- $head .= __( '[INFO] BackWPup job started from wp-cron', 'backwpup' ) . PHP_EOL;
334
  elseif ( $start_type == 'runnow' or $start_type == 'runnowalt' )
335
- $head .= __( '[INFO] BackWPup job started manually', 'backwpup' ) . PHP_EOL;
336
  elseif ( $start_type == 'runext' )
337
- $head .= __( '[INFO] BackWPup job started from external url', 'backwpup' ) . PHP_EOL;
338
  elseif ( $start_type == 'runcli' )
339
- $head .= __( '[INFO] BackWPup job started form commandline interface', 'backwpup' ) . PHP_EOL;
340
- $head .= __( '[INFO] PHP ver.:', 'backwpup' ) . ' ' . PHP_VERSION . '; ' . PHP_SAPI . '; ' . PHP_OS . PHP_EOL;
341
- $head .= sprintf( __( '[INFO] Maximum PHP script execution time is %1$d seconds', 'backwpup' ), ini_get( 'max_execution_time' ) ) . PHP_EOL;
342
- $job_max_execution_time = get_site_option( 'backwpup_cfg_jobmaxexecutiontime' );
343
- if ( ! empty( $job_max_execution_time ) )
344
- $head .= sprintf( __( '[INFO] Script restart time is configured to %1$d seconds', 'backwpup' ), $job_max_execution_time ) . PHP_EOL;
345
- if ( get_site_option( 'backwpup_cfg_jobsteprestart' ) )
346
- $head .= __( '[INFO] Script restarts on every main step is activated', 'backwpup' ) . PHP_EOL;
347
- $head .= sprintf( __( '[INFO] MySQL ver.: %s', 'backwpup' ), $wpdb->get_var( "SELECT VERSION() AS version" ) ) . PHP_EOL;
 
 
 
 
 
 
 
 
348
  if ( function_exists( 'curl_init' ) ) {
349
  $curlversion = curl_version();
350
- $head .= sprintf( __( '[INFO] curl ver.: %1$s; %2$s', 'backwpup' ), $curlversion[ 'version' ], $curlversion[ 'ssl_version' ] ) . PHP_EOL;
351
  }
352
- $head .= sprintf( __( '[INFO] Temp folder is: %s', 'backwpup' ), BackWPup::get_plugin_data( 'TEMP' ) ) . PHP_EOL;
353
- $head .= sprintf( __( '[INFO] Logfile is: %s', 'backwpup' ), $this->logfile ) . PHP_EOL;
354
- $head .= sprintf( __( '[INFO] Backup type is: %s', 'backwpup' ), $this->job[ 'backuptype' ] ) . PHP_EOL;
355
  if ( ! empty( $this->backup_file ) && $this->job[ 'backuptype' ] == 'archive' )
356
- $head .= sprintf( __( '[INFO] Backup file is: %s', 'backwpup' ), $this->backup_folder . $this->backup_file ) . PHP_EOL;
357
  file_put_contents( $this->logfile, $head, FILE_APPEND );
358
  //output info on cli
359
- if ( defined( 'STDIN' ) && defined( 'STDOUT' ) )
360
  fwrite( STDOUT, strip_tags( $head ) ) ;
361
  //test for destinations
362
  if ( $job_need_dest ) {
@@ -372,8 +377,6 @@ final class BackWPup_Job {
372
  }
373
  //Set start as done
374
  $this->steps_done[] = 'CREATE';
375
- //must write working data
376
- file_put_contents( BackWPup::get_plugin_data( 'running_file' ),'<?php return '. var_export( $this, true ) . ';' );
377
  }
378
 
379
 
@@ -381,7 +384,7 @@ final class BackWPup_Job {
381
  *
382
  * Get a url to run a job of BackWPup
383
  *
384
- * @param string $starttype Start types are 'runnow', 'runnowlink', 'cronrun', 'runext', 'runcmd', 'restart'
385
  * @param int $jobid The id of job to start else 0
386
  * @return array|object [url] is the job url [header] for auth header or object form wp_remote_get()
387
  */
@@ -428,6 +431,22 @@ final class BackWPup_Job {
428
  $query_args[ 'doing_wp_cron' ] = NULL;
429
  }
430
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
431
  $cron_request = apply_filters( 'cron_request', array(
432
  'url' => add_query_arg( $query_args, $url ),
433
  'key' => $query_args[ 'doing_wp_cron' ],
@@ -444,7 +463,7 @@ final class BackWPup_Job {
444
  )
445
  ) );
446
 
447
- if( $starttype == 'test' ) {
448
  $cron_request[ 'args' ][ 'timeout' ] = 15;
449
  $cron_request[ 'args' ][ 'blocking' ] = TRUE;
450
  }
@@ -493,6 +512,10 @@ final class BackWPup_Job {
493
  flush();
494
  }
495
 
 
 
 
 
496
  //check running job
497
  $backwpup_job_object = self::get_working_data();
498
  //start class
@@ -512,7 +535,7 @@ final class BackWPup_Job {
512
  */
513
  public static function start_cli( $jobid ) {
514
 
515
- if ( ! defined( 'STDIN' ) )
516
  return;
517
 
518
  //define DOING_CRON to prevent caching
@@ -562,6 +585,10 @@ final class BackWPup_Job {
562
  return;
563
  }
564
 
 
 
 
 
565
  //get running job
566
  $backwpup_job_object = self::get_working_data();
567
  //start/restart class
@@ -616,17 +643,24 @@ final class BackWPup_Job {
616
  $this->timestamp_script_start = microtime( TRUE );
617
  //set Pid
618
  $this->pid = self::get_pid();
 
 
 
619
  //set function for PHP user defined error handling
620
- $this->temp[ 'PHP' ][ 'INI' ][ 'ERROR_LOG' ] = ini_get( 'error_log' );
621
- $this->temp[ 'PHP' ][ 'INI' ][ 'ERROR_REPORTING' ]= ini_get( 'error_reporting' );
622
- $this->temp[ 'PHP' ][ 'INI' ][ 'LOG_ERRORS' ] = ini_get( 'log_errors' );
623
- $this->temp[ 'PHP' ][ 'INI' ][ 'DISPLAY_ERRORS' ] = ini_get( 'display_errors' );
624
- $this->temp[ 'PHP' ][ 'INI' ][ 'HTML_ERRORS' ] = ini_get( 'html_errors' );
625
- $this->temp[ 'PHP' ][ 'INI' ][ 'REPORT_MEMLEAKS' ]= ini_get( 'report_memleaks' );
626
- $this->temp[ 'PHP' ][ 'INI' ][ 'ZLIB_OUTPUT_COMPRESSION' ] = ini_get( 'zlib.output_compression' );
627
- $this->temp[ 'PHP' ][ 'INI' ][ 'IMPLICIT_FLUSH' ] = ini_get( 'implicit_flush' );
628
  @ini_set( 'error_log', $this->logfile );
629
- error_reporting( E_ALL ^ E_STRICT );
 
 
 
 
630
  @ini_set( 'display_errors', 'Off' );
631
  @ini_set( 'log_errors', 'On' );
632
  @ini_set( 'html_errors', 'Off' );
@@ -644,7 +678,7 @@ final class BackWPup_Job {
644
  $can_set_temp_env = FALSE;
645
  }
646
  if ( $can_set_temp_env ) {
647
- $this->temp[ 'PHP' ][ 'ENV' ][ 'TEMPDIR' ] = getenv( 'TMPDIR' );
648
  @putenv( 'TMPDIR='.BackWPup::get_plugin_data( 'TEMP') );
649
  }
650
  //Write Wordpress DB errors to log
@@ -653,7 +687,11 @@ final class BackWPup_Job {
653
  //set wp max memory limit
654
  @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
655
  //set error handler
656
- set_error_handler( array( $this, 'log' ), E_ALL ^ E_STRICT );
 
 
 
 
657
  set_exception_handler( array( $this, 'exception_handler' ) );
658
  //not loading Textdomains and unload loaded
659
  if ( get_site_option( 'backwpup_cfg_jobnotranslate' ) ) {
@@ -684,47 +722,58 @@ final class BackWPup_Job {
684
  else
685
  $this->step_percent = 1;
686
  // do step tries
687
- while ( $this->steps_data[ $this->step_working ][ 'STEP_TRY' ] < get_site_option( 'backwpup_cfg_jobstepretry' ) ) {
688
- // break if try has marked as done for no more tries
689
- if ( in_array( $this->step_working, $this->steps_done ) )
 
 
 
 
 
690
  break;
 
 
691
  $this->steps_data[ $this->step_working ][ 'STEP_TRY' ] ++;
692
- $this->update_working_data( TRUE );
693
  $done = FALSE;
 
694
  //executes the methods of job process
695
- if ( $this->step_working == 'CREATE_ARCHIVE')
696
  $done = $this->create_archive();
697
- elseif ( $this->step_working == 'CREATE_MANIFEST')
 
698
  $done = $this->create_manifest();
 
699
  elseif ( $this->step_working == 'END' ) {
700
  $this->end();
701
  break 2;
702
  }
703
- elseif ( strstr( $this->step_working, 'JOB_' ) )
704
  $done = $job_types[ str_replace( 'JOB_', '', $this->step_working ) ]->job_run( $this );
705
- elseif ( strstr( $this->step_working, 'DEST_SYNC_' ) )
 
706
  $done = BackWPup::get_destination( str_replace( 'DEST_SYNC_', '', $this->step_working ) )->job_run_sync( $this );
707
- elseif ( strstr( $this->step_working, 'DEST_' ) )
 
708
  $done = BackWPup::get_destination( str_replace( 'DEST_', '', $this->step_working ) )->job_run_archive( $this );
709
- elseif ( ! empty( $this->steps_data[ $this->step_working ][ 'CALLBACK' ] ) )
 
710
  $done = $this->steps_data[ $this->step_working ][ 'CALLBACK' ]( $this );
711
- // set step as done or if step has too many tries
712
- if ( $done === TRUE ) {
713
- $this->temp = array(); //Clean temp
714
- $this->steps_done[] = $this->step_working;
715
- $this->substeps_done = 0;
716
- $this->substeps_todo = 0;
717
  }
718
- if ( ! $done && $this->steps_data[ $this->step_working ][ 'STEP_TRY' ] >= get_site_option( 'backwpup_cfg_jobstepretry' ) ) {
719
- $this->log( __( 'Step aborted: too many attempts!', 'backwpup' ), E_USER_ERROR );
720
- $this->temp = array(); //Clean temp
 
721
  $this->steps_done[] = $this->step_working;
722
  $this->substeps_done = 0;
723
  $this->substeps_todo = 0;
 
724
  }
725
- //restart on every job step expect end and only on http connection
726
- if ( get_site_option( 'backwpup_cfg_jobsteprestart' ) )
727
  $this->do_restart();
 
 
 
 
728
  }
729
  }
730
  }
@@ -742,7 +791,7 @@ final class BackWPup_Job {
742
  return;
743
 
744
  //no restart on cli usage
745
- if ( defined( 'STDIN' ) )
746
  return;
747
 
748
  //no restart when restart was 3 Seconds before
@@ -760,7 +809,8 @@ final class BackWPup_Job {
760
 
761
  //do things for a clean restart
762
  $this->pid = 0;
763
- $this->update_working_data( TRUE );
 
764
  remove_action( 'shutdown', array( $this, 'shutdown' ) );
765
  //do restart
766
  wp_clear_scheduled_hook( 'backwpup_cron', array( 'id' => 'restart' ) );
@@ -818,29 +868,39 @@ final class BackWPup_Job {
818
  *
819
  * @return bool|object BackWPup_Job Object or Bool if file not exits
820
  */
821
- public static function get_working_data() {
822
 
823
- if ( ! file_exists( BackWPup::get_plugin_data( 'running_file' ) ) )
824
- return FALSE;
 
 
 
825
 
826
- if ( $job_object = include BackWPup::get_plugin_data( 'running_file' ) ) {
827
- if ( $job_object instanceof BackWPup_Job )
828
- return $job_object;
829
- }
830
 
 
 
831
  return FALSE;
832
 
 
 
 
833
  }
834
 
835
- /**
836
- *
837
- * Reads a BackWPup logfile header and gives back a array of information
838
- *
839
- * @param string $logfile full logfile path
840
- *
841
- * @return array|bool
842
- */
843
- public static function read_logheader( $logfile ) {
 
 
 
 
844
 
845
  $usedmetas = array(
846
  "date" => "logtime",
@@ -1017,7 +1077,7 @@ final class BackWPup_Job {
1017
  switch ( $args[ 0 ] ) {
1018
  case E_NOTICE:
1019
  case E_USER_NOTICE:
1020
- $messagetype = '<samp>';
1021
  break;
1022
  case E_WARNING:
1023
  case E_CORE_WARNING:
@@ -1025,7 +1085,7 @@ final class BackWPup_Job {
1025
  case E_USER_WARNING:
1026
  $this->warnings ++;
1027
  $error_or_warning = TRUE;
1028
- $messagetype = '<samp style="background-color:#ffc000;color:#fff">' . __( 'WARNING:', 'backwpup' ) . ' ';
1029
  break;
1030
  case E_ERROR:
1031
  case E_PARSE:
@@ -1034,40 +1094,42 @@ final class BackWPup_Job {
1034
  case E_USER_ERROR:
1035
  $this->errors ++;
1036
  $error_or_warning = TRUE;
1037
- $messagetype = '<samp style="background-color:red;color:#fff">' . __( 'ERROR:', 'backwpup' ) . ' ';
1038
  break;
1039
  case 8192: //E_DEPRECATED comes with php 5.3
1040
  case 16384: //E_USER_DEPRECATED comes with php 5.3
1041
- $messagetype = '<samp>' . __( 'DEPRECATED:', 'backwpup' ) . ' ';
1042
  break;
1043
  case E_STRICT:
1044
- $messagetype = '<samp>' . __( 'STRICT NOTICE:', 'backwpup' ) . ' ';
1045
  break;
1046
  case E_RECOVERABLE_ERROR:
1047
  $this->errors ++;
1048
  $error_or_warning = TRUE;
1049
- $messagetype = '<samp style="background-color:red;color:#fff">' . __( 'RECOVERABLE ERROR:', 'backwpup' ) . ' ';
1050
  break;
1051
  default:
1052
- $messagetype = '<samp>' . $args[ 0 ] . ": ";
1053
  break;
1054
  }
1055
 
1056
  $in_file = str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', $args[ 2 ] ) );
1057
 
1058
  //print message to cli
1059
- if ( defined( 'STDIN' ) && defined( 'STDOUT' ) )
1060
  fwrite( STDOUT, '[' . date_i18n( 'd-M-Y H:i:s' ) . '] ' . strip_tags( $messagetype ) . str_replace( '&hellip;', '...', strip_tags( $args[ 1 ] ) ) . PHP_EOL ) ;
1061
  //log line
1062
- $timestamp = '<span datetime="' . date_i18n( 'c' ) . '" title="[Type: ' . $args[ 0 ] . '|Line: ' . $args[ 3 ] . '|File: ' . $in_file . '|Mem: ' . size_format( @memory_get_usage( TRUE ), 2 ) . '|Mem Max: ' . size_format( @memory_get_peak_usage( TRUE ), 2 ) . '|Mem Limit: ' . ini_get( 'memory_limit' ) . '|PID: ' . self::get_pid() . '|Query\'s: ' . get_num_queries() . ']">[' . date_i18n( 'd-M-Y H:i:s' ) . ']</span> ';
1063
- //ste last Message
1064
- $message = htmlentities( $args[ 1 ], ENT_COMPAT , get_bloginfo( 'charset' ), FALSE );
 
 
1065
  if ( $args[ 0 ] == E_NOTICE || $args[ 0 ] == E_USER_NOTICE )
1066
- $this->lastmsg = $messagetype . $message . '</samp>';
1067
  if ( $error_or_warning )
1068
- $this->lasterrormsg = $messagetype . $message . '</samp>';
1069
  //write log file
1070
- file_put_contents( $this->logfile, $timestamp . $messagetype . $message . '</samp>' . PHP_EOL, FILE_APPEND );
1071
 
1072
  //write new log header
1073
  if ( $error_or_warning ) {
@@ -1103,11 +1165,11 @@ final class BackWPup_Job {
1103
  /**
1104
  *
1105
  * Write the Working data to display the process or that i can executes again
 
1106
  *
1107
  * @global wpdb $wpdb
1108
- * @param bool $must_write overwrite the only ever 1 sec writing
1109
  */
1110
- public function update_working_data( $must_write = FALSE ) {
1111
  global $wpdb;
1112
  /* @var wpdb $wpdb */
1113
 
@@ -1120,12 +1182,12 @@ final class BackWPup_Job {
1120
 
1121
  //only run every 1 sec.
1122
  $time_to_update = microtime( TRUE ) - $this->timestamp_last_update;
1123
- if ( ! $must_write && $time_to_update < 1 )
1124
  return;
1125
 
1126
  //FCGI must have a permanent output so that it not broke
1127
  if ( stristr( PHP_SAPI, 'fcgi' ) || stristr( PHP_SAPI, 'litespeed' ) ) {
1128
- //inly if no output buffering is active
1129
  if ( ob_get_level() == 0 ) {
1130
  echo ' ';
1131
  flush();
@@ -1152,7 +1214,19 @@ final class BackWPup_Job {
1152
  $this->end();
1153
  } else {
1154
  $this->timestamp_last_update = microtime( TRUE ); //last update of working file
1155
- file_put_contents( BackWPup::get_plugin_data( 'running_file' ),'<?php return '. var_export( $this, true ) . ';' );
 
 
 
 
 
 
 
 
 
 
 
 
1156
  }
1157
  }
1158
 
@@ -1262,7 +1336,7 @@ final class BackWPup_Job {
1262
  $subject = sprintf( __( '[%3$s] BackWPup log %1$s: %2$s', 'backwpup' ), date_i18n( 'd-M-Y H:i', $this->start_time, TRUE ), esc_attr( $this->job[ 'name' ] ), $status );
1263
  $headers = array();
1264
  $headers[] = 'Content-Type: text/html; charset='. get_bloginfo( 'charset' );
1265
- $headers[] = 'X-Priority: '.$priority;
1266
  if ( ! empty( $this->job[ 'mailaddresssenderlog' ] ) ) {
1267
  if ( FALSE === $start_mail = strpos( $this->job[ 'mailaddresssenderlog' ], '<' ) ) {
1268
  if ( FALSE === strpos( $this->job[ 'mailaddresssenderlog' ], '@' ) ) {
@@ -1290,16 +1364,19 @@ final class BackWPup_Job {
1290
  remove_action( 'shutdown', array( $this, 'shutdown' ) );
1291
  restore_exception_handler();
1292
  restore_error_handler();
1293
- @ini_set( 'log_errors', $this->temp[ 'PHP' ][ 'INI' ][ 'LOG_ERRORS' ] );
1294
- @ini_set( 'error_log', $this->temp[ 'PHP' ][ 'INI' ][ 'ERROR_LOG' ] );
1295
- @ini_set( 'display_errors', $this->temp[ 'PHP' ][ 'INI' ][ 'DISPLAY_ERRORS' ] );
1296
- @ini_set( 'html_errors', $this->temp[ 'PHP' ][ 'INI' ][ 'HTML_ERRORS' ] );
1297
- @ini_set( 'zlib.output_compression', $this->temp[ 'PHP' ][ 'INI' ][ 'ZLIB_OUTPUT_COMPRESSION' ] );
1298
- @ini_set( 'implicit_flush', $this->temp[ 'PHP' ][ 'INI' ][ 'IMPLICIT_FLUSH' ] );
1299
- @ini_set( 'error_reporting', $this->temp[ 'PHP' ][ 'INI' ][ 'ERROR_REPORTING' ] );
1300
- @ini_set( 'report_memleaks', $this->temp[ 'PHP' ][ 'INI' ][ 'REPORT_MEMLEAKS' ] );
1301
- if ( $this->temp[ 'PHP' ][ 'ENV' ][ 'TEMPDIR' ] )
1302
- @putenv('TMPDIR=' . $this->temp[ 'PHP' ][ 'ENV' ][ 'TEMPDIR' ] );
 
 
 
1303
 
1304
  BackWPup_Cron::check_cleanup();
1305
 
@@ -1642,16 +1719,22 @@ final class BackWPup_Job {
1642
  if ( FALSE !== stripos( $folder . $file, trim( $exclusion ) ) && ! empty( $exclusion ) )
1643
  continue 2;
1644
  }
1645
- if ( $this->job[ 'backupexcludethumbs' ] && strpos( $folder, BackWPup_File::get_upload_dir() ) !== FALSE && preg_match( "/\-[0-9]{2,4}x[0-9]{2,4}\.(jpg|png|gif)$/i", $file ) )
1646
  continue;
1647
- if ( is_link( $folder . $file ) )
 
1648
  $this->log( sprintf( __( 'Link "%s" not following.', 'backwpup' ), $folder . $file ), E_USER_WARNING );
1649
- elseif ( ! is_readable( $folder . $file ) )
1650
  $this->log( sprintf( __( 'File "%s" is not readable!', 'backwpup' ), $folder . $file ), E_USER_WARNING );
1651
- else {
 
 
 
 
 
1652
  $files[ ] = $folder . $file;
1653
  $this->count_files_in_folder ++;
1654
- $this->count_filesize_in_folder = $this->count_filesize_in_folder + @filesize( $folder . $file );
1655
  }
1656
  }
1657
  closedir( $dir );
@@ -1731,8 +1814,8 @@ final class BackWPup_Job {
1731
  $this->count_files ++;
1732
  $this->additional_files_to_backup[ ] = BackWPup::get_plugin_data( 'TEMP' ) . 'backwpup_readme.txt';
1733
  $this->count_files ++;
1734
- $this->count_filesize = $this->count_filesize + @filesize( BackWPup::get_plugin_data( 'TEMP' ) . 'manifest.json' );
1735
- $this->count_filesize = $this->count_filesize + @filesize( BackWPup::get_plugin_data( 'TEMP' ) . 'backwpup_readme.txt' );
1736
  $this->log( sprintf( __( 'Added manifest.json file with %1$s to backup file list.', 'backwpup' ), size_format( filesize( BackWPup::get_plugin_data( 'TEMP' ) . 'manifest.json' ), 2 ) ) );
1737
  }
1738
  $this->substeps_done = 3;
@@ -1751,10 +1834,16 @@ final class BackWPup_Job {
1751
  $this->substeps_todo = $this->count_folder + 1;
1752
 
1753
  //initial settings for restarts in archiving
1754
- if ( ! isset( $this->steps_data[ $this->step_working ]['on_file'] ) )
1755
  $this->steps_data[ $this->step_working ]['on_file'] = '';
1756
- if ( ! isset( $this->steps_data[ $this->step_working ]['on_folder'] ) )
 
1757
  $this->steps_data[ $this->step_working ]['on_folder'] = '';
 
 
 
 
 
1758
 
1759
  if ( $this->steps_data[ $this->step_working ]['SAVE_STEP_TRY'] != $this->steps_data[ $this->step_working ][ 'STEP_TRY' ] )
1760
  $this->log( sprintf( __( '%d. Trying to create backup archive &hellip;', 'backwpup' ), $this->steps_data[ $this->step_working ][ 'STEP_TRY' ] ), E_USER_NOTICE );
@@ -1770,10 +1859,17 @@ final class BackWPup_Job {
1770
  if ( $this->substeps_done == 0 ) {
1771
  if ( ! empty( $this->additional_files_to_backup ) && $this->substeps_done == 0 ) {
1772
  foreach ( $this->additional_files_to_backup as $file ) {
1773
- $backup_archive->add_file( $file, basename( $file ) );
1774
- $this->count_files ++;
1775
- $this->count_filesize = filesize( $file );
1776
- $this->update_working_data();
 
 
 
 
 
 
 
1777
  }
1778
  }
1779
  $this->substeps_done ++;
@@ -1808,8 +1904,21 @@ final class BackWPup_Job {
1808
  //generate filename in archive
1809
  $in_archive_filename = ltrim( str_replace( $this->remove_path, '', $file ), '/' );
1810
  //add file to archive
1811
- $backup_archive->add_file( $file, $in_archive_filename );
1812
- $this->update_working_data();
 
 
 
 
 
 
 
 
 
 
 
 
 
1813
  }
1814
  $this->steps_data[ $this->step_working ]['on_file'] = '';
1815
  $this->substeps_done ++;
@@ -1851,8 +1960,8 @@ final class BackWPup_Job {
1851
  if ( ! empty( $suffix ) && substr( $suffix, 0, 1 ) != '.' )
1852
  $suffix = '.' . $suffix;
1853
 
1854
- $name = str_replace( $datevars, $datevalues, $name );
1855
- $name = sanitize_file_name( $name ) . $suffix; //prevent _ in extension name that sanitize_file_name add.
1856
  if ( $delete_temp_file && is_writeable( BackWPup::get_plugin_data( 'TEMP' ) . $name ) && !is_dir( BackWPup::get_plugin_data( 'TEMP' ) . $name ) && !is_link( BackWPup::get_plugin_data( 'TEMP' ) . $name ) )
1857
  unlink( BackWPup::get_plugin_data( 'TEMP' ) . $name );
1858
 
@@ -1870,12 +1979,14 @@ final class BackWPup_Job {
1870
  if ( ! substr( $filename, -3 ) == '.gz' || ! substr( $filename, -4 ) == '.bz2' || ! substr( $filename, -4 ) == '.tar' || ! substr( $filename, -4 ) == '.zip' )
1871
  return FALSE;
1872
 
 
 
1873
  $datevars = array( '%d', '%j', '%m', '%n', '%Y', '%y', '%a', '%A', '%B', '%g', '%G', '%h', '%H', '%i', '%s' );
1874
  $dateregex = array( '(0[1-9]|[12][0-9]|3[01])', '([1-9]|[12][0-9]|3[01])', '(0[1-9]|1[012])', '([1-9]|1[012])', '((19|20|21)[0-9]{2})', '([0-9]{2})', '(am|pm)', '(AM|PM)', '([0-9]{3})', '([1-9]|1[012])', '([0-9]|1[0-9]|2[0-3])', '(0[1-9]|1[012])', '(0[0-9]|1[0-9]|2[0-3])', '([0-5][0-9])', '([0-5][0-9])' );
1875
 
1876
- $regex = "/^" . str_replace( $datevars, $dateregex, str_replace( "\/", "/", $this->job[ 'archivename' ] ) . $this->job[ 'archiveformat' ] ) . "$/";
1877
 
1878
- preg_match( $regex, basename( $filename ), $matches );
1879
  if ( ! empty( $matches[ 0 ] ) && $matches[ 0 ] == $filename )
1880
  return TRUE;
1881
 
@@ -1982,25 +2093,29 @@ final class BackWPup_Job {
1982
  }
1983
 
1984
  /**
1985
- * Check whether shell_exec has been disabled.
1986
  *
1987
  * @access public
1988
  * @static
1989
  * @return bool
1990
  */
1991
- public static function is_shell_exec() {
1992
 
1993
  // Is function avail
1994
- if ( ! function_exists( 'shell_exec' ) )
1995
  return FALSE;
 
1996
 
1997
  // Is shell_exec disabled?
1998
- if ( in_array( 'shell_exec', array_map( 'trim', explode( ',', @ini_get( 'disable_functions' ) ) ) ) )
1999
  return FALSE;
 
2000
 
2001
  // Can we issue a simple echo command?
2002
- if ( ! @shell_exec( 'echo backwpup' ) )
 
2003
  return FALSE;
 
2004
 
2005
  return TRUE;
2006
 
134
  public $user_abort = FALSE;
135
 
136
  /**
137
+ * Stores data that will only used in a single run
138
+ * @var array
139
  */
140
+ private $run = array();
141
 
142
+ /**
143
+ * A uniqid ID uniqid('', true); to identify process
144
+ * @var string
145
+ */
146
+ private $uniqid = '';
 
 
147
 
 
148
 
149
  /**
150
+ * Delete some data on cloned objects
 
 
 
151
  */
152
+ public function __clone( ) {
153
 
154
+ $this->temp = array();
155
+ $this->run = array();
156
  }
157
 
158
  /**
177
  else
178
  return;
179
  $this->start_time = current_time( 'timestamp' );
180
+ $this->lastmsg = __( 'Starting job', 'backwpup' );
181
  //set Logfile
182
  $this->logfile = get_site_option( 'backwpup_cfg_logfolder' ) . 'backwpup_log_' . BackWPup::get_plugin_data( 'hash' ) . '_' . date_i18n( 'Y-m-d_H-i-s' ) . '.html';
183
  //write settings to job
275
  }
276
  $this->steps_todo[] = 'END';
277
  $this->steps_data[ 'END' ][ 'NAME' ] = __( 'End of Job', 'backwpup' );
278
+ $this->steps_data[ 'END' ][ 'STEP_TRY' ] = 1;
279
+ //must write working data
280
+ $this->write_running_file();
281
  //create log file
282
  $head = '';
283
  $head .= "<!DOCTYPE html>" . PHP_EOL;
301
  $head .= str_pad( '<meta name="backwpup_backupfilesize" content="0" />', 100 ) . PHP_EOL;
302
  $head .= str_pad( '<meta name="backwpup_jobruntime" content="0" />', 100 ) . PHP_EOL;
303
  $head .= "</head>" . PHP_EOL;
304
+ $head .= "<body style=\"margin:0;padding:3px;font-family:monospace;font-size:12px;line-height:15px;background-color:#000;color:#fff;white-space:nowrap;\">" . PHP_EOL;
305
+ $head .= sprintf( _x( '[INFO] %1$s version %2$s; A project of Inpsyde GmbH', 'Plugin name; Plugin Version','backwpup' ), BackWPup::get_plugin_data( 'name' ) , BackWPup::get_plugin_data( 'Version' ) ) . '<br />' . PHP_EOL;
306
+ $head .= sprintf( _x( '[INFO] WordPress version %s', 'WordPress Version', 'backwpup' ), BackWPup::get_plugin_data( 'wp_version' ) ). '<br />' . PHP_EOL;
307
+ $head .= sprintf( __( '[INFO] Blog url: %s', 'backwpup' ), esc_attr( site_url( '/' ) ) ). '<br />' . PHP_EOL;
308
+ $head .= sprintf( __( '[INFO] BackWPup job: %1$s; %2$s', 'backwpup' ), esc_attr( $this->job[ 'name' ] ) , implode( '+', $this->job[ 'type' ] ) ) . '<br />' . PHP_EOL;
309
  if ( $this->job[ 'activetype' ] == 'wpcron' ) {
310
  //check next run
311
  $cron_next = wp_next_scheduled( 'backwpup_cron', array( 'id' => $this->job[ 'jobid' ] ) );
320
  $cron_next = __( 'Not scheduled!', 'backwpup' );
321
  else
322
  $cron_next = date_i18n( 'D, j M Y @ H:i', $cron_next + ( get_option( 'gmt_offset' ) * 3600 ) , TRUE ) ;
323
+ $head .= sprintf( __( '[INFO] BackWPup cron: %s; Next: %s ', 'backwpup' ), $this->job[ 'cron' ] , $cron_next ) . '<br />' . PHP_EOL;
324
  }
325
  elseif ( $this->job[ 'activetype' ] == 'link' )
326
+ $head .= __( '[INFO] BackWPup job start with link is active', 'backwpup' ) . '<br />' . PHP_EOL;
327
  else
328
+ $head .= __( '[INFO] BackWPup no automatic job start configured', 'backwpup' ) . '<br />' . PHP_EOL;
329
  if ( $start_type == 'cronrun' )
330
+ $head .= __( '[INFO] BackWPup job started from wp-cron', 'backwpup' ) . '<br />' . PHP_EOL;
331
  elseif ( $start_type == 'runnow' or $start_type == 'runnowalt' )
332
+ $head .= __( '[INFO] BackWPup job started manually', 'backwpup' ) . '<br />' . PHP_EOL;
333
  elseif ( $start_type == 'runext' )
334
+ $head .= __( '[INFO] BackWPup job started from external url', 'backwpup' ) . '<br />' . PHP_EOL;
335
  elseif ( $start_type == 'runcli' )
336
+ $head .= __( '[INFO] BackWPup job started form commandline interface', 'backwpup' ) . '<br />' . PHP_EOL;
337
+ $bit = '';
338
+ if ( PHP_INT_SIZE === 4 )
339
+ $bit = ' (32bit)';
340
+ if ( PHP_INT_SIZE === 8 )
341
+ $bit = ' (64bit)';
342
+ $head .= __( '[INFO] PHP ver.:', 'backwpup' ) . ' ' . PHP_VERSION . $bit .'; ' . PHP_SAPI . '; ' . PHP_OS . '<br />' . PHP_EOL;
343
+ $head .= sprintf( __( '[INFO] Maximum PHP script execution time is %1$d seconds', 'backwpup' ), ini_get( 'max_execution_time' ) ) . '<br />' . PHP_EOL;
344
+ if ( php_sapi_name() != 'cli' ) {
345
+ $job_max_execution_time = get_site_option( 'backwpup_cfg_jobmaxexecutiontime' );
346
+ if ( ! empty( $job_max_execution_time ) ) {
347
+ $head .= sprintf( __( '[INFO] Script restart time is configured to %1$d seconds', 'backwpup' ), $job_max_execution_time ) . '<br />' . PHP_EOL;
348
+ }
349
+ }
350
+ $head .= sprintf( __( '[INFO] MySQL ver.: %s', 'backwpup' ), $wpdb->get_var( "SELECT VERSION() AS version" ) ) . '<br />' . PHP_EOL;
351
+ if ( isset( $_SERVER[ 'SERVER_SOFTWARE' ] ) )
352
+ $head .= sprintf( __( '[INFO] Web Server: %s', 'backwpup' ), $_SERVER[ 'SERVER_SOFTWARE' ] ) . '<br />' . PHP_EOL;
353
  if ( function_exists( 'curl_init' ) ) {
354
  $curlversion = curl_version();
355
+ $head .= sprintf( __( '[INFO] curl ver.: %1$s; %2$s', 'backwpup' ), $curlversion[ 'version' ], $curlversion[ 'ssl_version' ] ) . '<br />' . PHP_EOL;
356
  }
357
+ $head .= sprintf( __( '[INFO] Temp folder is: %s', 'backwpup' ), BackWPup::get_plugin_data( 'TEMP' ) ) . '<br />' . PHP_EOL;
358
+ $head .= sprintf( __( '[INFO] Logfile is: %s', 'backwpup' ), $this->logfile ) . '<br />' . PHP_EOL;
359
+ $head .= sprintf( __( '[INFO] Backup type is: %s', 'backwpup' ), $this->job[ 'backuptype' ] ) . '<br />' . PHP_EOL;
360
  if ( ! empty( $this->backup_file ) && $this->job[ 'backuptype' ] == 'archive' )
361
+ $head .= sprintf( __( '[INFO] Backup file is: %s', 'backwpup' ), $this->backup_folder . $this->backup_file ) . '<br />' . PHP_EOL;
362
  file_put_contents( $this->logfile, $head, FILE_APPEND );
363
  //output info on cli
364
+ if ( php_sapi_name() == 'cli' && defined( 'STDOUT' ) )
365
  fwrite( STDOUT, strip_tags( $head ) ) ;
366
  //test for destinations
367
  if ( $job_need_dest ) {
377
  }
378
  //Set start as done
379
  $this->steps_done[] = 'CREATE';
 
 
380
  }
381
 
382
 
384
  *
385
  * Get a url to run a job of BackWPup
386
  *
387
+ * @param string $starttype Start types are 'runnow', 'runnowlink', 'cronrun', 'runext', 'restart', 'test'
388
  * @param int $jobid The id of job to start else 0
389
  * @return array|object [url] is the job url [header] for auth header or object form wp_remote_get()
390
  */
431
  $query_args[ 'doing_wp_cron' ] = NULL;
432
  }
433
 
434
+ //Extra for WP-Cron control
435
+ if ( class_exists( 'WP_Cron_Control' ) && ( $starttype == 'runext' || $starttype == 'runnow' || $starttype == 'restart' ) ) {
436
+ $wp_cron_control_settings = get_option( 'wpcroncontrol_settings', array() );
437
+ if ( empty( $wp_cron_control_settings[ 'secret_string' ] ) && file_exists( WP_PLUGIN_DIR . '/wp-cron-control/wp-cron-control.php' ) ) {
438
+ $wp_cron_control_settings[ 'secret_string' ] = md5( realpath( WP_PLUGIN_DIR . '/wp-cron-control/wp-cron-control.php' ) . get_current_blog_id() );
439
+ $wp_cron_control_settings[ 'enable' ] = 1;
440
+ }
441
+ if ( isset( $wp_cron_control_settings[ 'enable' ] ) && $wp_cron_control_settings[ 'enable' ] == 1 ) {
442
+ if ( defined( 'WP_CRON_CONTROL_SECRET' ) ) {
443
+ $wp_cron_control_settings[ 'secret_string' ] = WP_CRON_CONTROL_SECRET;
444
+ }
445
+ $query_args[ $wp_cron_control_settings[ 'secret_string' ] ] = '';
446
+ $query_args[ 'doing_wp_cron' ] = NULL;
447
+ }
448
+ }
449
+
450
  $cron_request = apply_filters( 'cron_request', array(
451
  'url' => add_query_arg( $query_args, $url ),
452
  'key' => $query_args[ 'doing_wp_cron' ],
463
  )
464
  ) );
465
 
466
+ if( $starttype == 'test' ) {
467
  $cron_request[ 'args' ][ 'timeout' ] = 15;
468
  $cron_request[ 'args' ][ 'blocking' ] = TRUE;
469
  }
512
  flush();
513
  }
514
 
515
+ // Should be preventing doubled running job's on http requests
516
+ $random = rand( 1, 9 ) * 100000;
517
+ usleep( $random );
518
+
519
  //check running job
520
  $backwpup_job_object = self::get_working_data();
521
  //start class
535
  */
536
  public static function start_cli( $jobid ) {
537
 
538
+ if ( php_sapi_name() != 'cli' )
539
  return;
540
 
541
  //define DOING_CRON to prevent caching
585
  return;
586
  }
587
 
588
+ // Should be preventing doubled running job's on http requests
589
+ $random = rand( 1, 9 ) * 100000;
590
+ usleep( $random );
591
+
592
  //get running job
593
  $backwpup_job_object = self::get_working_data();
594
  //start/restart class
643
  $this->timestamp_script_start = microtime( TRUE );
644
  //set Pid
645
  $this->pid = self::get_pid();
646
+ $this->uniqid = uniqid( '', TRUE );
647
+ //Early write new working file
648
+ $this->write_running_file();
649
  //set function for PHP user defined error handling
650
+ $this->run[ 'PHP' ][ 'INI' ][ 'ERROR_LOG' ] = ini_get( 'error_log' );
651
+ $this->run[ 'PHP' ][ 'INI' ][ 'ERROR_REPORTING' ]= ini_get( 'error_reporting' );
652
+ $this->run[ 'PHP' ][ 'INI' ][ 'LOG_ERRORS' ] = ini_get( 'log_errors' );
653
+ $this->run[ 'PHP' ][ 'INI' ][ 'DISPLAY_ERRORS' ] = ini_get( 'display_errors' );
654
+ $this->run[ 'PHP' ][ 'INI' ][ 'HTML_ERRORS' ] = ini_get( 'html_errors' );
655
+ $this->run[ 'PHP' ][ 'INI' ][ 'REPORT_MEMLEAKS' ]= ini_get( 'report_memleaks' );
656
+ $this->run[ 'PHP' ][ 'INI' ][ 'ZLIB_OUTPUT_COMPRESSION' ] = ini_get( 'zlib.output_compression' );
657
+ $this->run[ 'PHP' ][ 'INI' ][ 'IMPLICIT_FLUSH' ] = ini_get( 'implicit_flush' );
658
  @ini_set( 'error_log', $this->logfile );
659
+ if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
660
+ error_reporting( -1 );
661
+ } else {
662
+ error_reporting( E_ALL ^ E_NOTICE );
663
+ }
664
  @ini_set( 'display_errors', 'Off' );
665
  @ini_set( 'log_errors', 'On' );
666
  @ini_set( 'html_errors', 'Off' );
678
  $can_set_temp_env = FALSE;
679
  }
680
  if ( $can_set_temp_env ) {
681
+ $this->run[ 'PHP' ][ 'ENV' ][ 'TEMPDIR' ] = getenv( 'TMPDIR' );
682
  @putenv( 'TMPDIR='.BackWPup::get_plugin_data( 'TEMP') );
683
  }
684
  //Write Wordpress DB errors to log
687
  //set wp max memory limit
688
  @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
689
  //set error handler
690
+ if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
691
+ set_error_handler( array( $this, 'log' ), -1 );
692
+ } else {
693
+ set_error_handler( array( $this, 'log' ), E_ALL ^ E_NOTICE );
694
+ }
695
  set_exception_handler( array( $this, 'exception_handler' ) );
696
  //not loading Textdomains and unload loaded
697
  if ( get_site_option( 'backwpup_cfg_jobnotranslate' ) ) {
722
  else
723
  $this->step_percent = 1;
724
  // do step tries
725
+ while ( TRUE ) {
726
+ if ( $this->steps_data[ $this->step_working ][ 'STEP_TRY' ] >= get_site_option( 'backwpup_cfg_jobstepretry' ) ) {
727
+ $this->log( __( 'Step aborted: too many attempts!', 'backwpup' ), E_USER_ERROR );
728
+ $this->temp = array();
729
+ $this->steps_done[ ] = $this->step_working;
730
+ $this->substeps_done = 0;
731
+ $this->substeps_todo = 0;
732
+ $this->do_restart();
733
  break;
734
+ }
735
+
736
  $this->steps_data[ $this->step_working ][ 'STEP_TRY' ] ++;
 
737
  $done = FALSE;
738
+
739
  //executes the methods of job process
740
+ if ( $this->step_working == 'CREATE_ARCHIVE' ) {
741
  $done = $this->create_archive();
742
+ }
743
+ elseif ( $this->step_working == 'CREATE_MANIFEST' ) {
744
  $done = $this->create_manifest();
745
+ }
746
  elseif ( $this->step_working == 'END' ) {
747
  $this->end();
748
  break 2;
749
  }
750
+ elseif ( strstr( $this->step_working, 'JOB_' ) ) {
751
  $done = $job_types[ str_replace( 'JOB_', '', $this->step_working ) ]->job_run( $this );
752
+ }
753
+ elseif ( strstr( $this->step_working, 'DEST_SYNC_' ) ) {
754
  $done = BackWPup::get_destination( str_replace( 'DEST_SYNC_', '', $this->step_working ) )->job_run_sync( $this );
755
+ }
756
+ elseif ( strstr( $this->step_working, 'DEST_' ) ) {
757
  $done = BackWPup::get_destination( str_replace( 'DEST_', '', $this->step_working ) )->job_run_archive( $this );
758
+ }
759
+ elseif ( ! empty( $this->steps_data[ $this->step_working ][ 'CALLBACK' ] ) ) {
760
  $done = $this->steps_data[ $this->step_working ][ 'CALLBACK' ]( $this );
 
 
 
 
 
 
761
  }
762
+
763
+ // set step as done
764
+ if ( $done === TRUE ) {
765
+ $this->temp = array();
766
  $this->steps_done[] = $this->step_working;
767
  $this->substeps_done = 0;
768
  $this->substeps_todo = 0;
769
+ $this->write_running_file();
770
  }
771
+ if ( count( $this->steps_done ) < count( $this->steps_todo ) -1 ) {
 
772
  $this->do_restart();
773
+ }
774
+ if ( $done === TRUE ) {
775
+ break;
776
+ }
777
  }
778
  }
779
  }
791
  return;
792
 
793
  //no restart on cli usage
794
+ if ( php_sapi_name() == 'cli' )
795
  return;
796
 
797
  //no restart when restart was 3 Seconds before
809
 
810
  //do things for a clean restart
811
  $this->pid = 0;
812
+ $this->uniqid = '';
813
+ $this->write_running_file();
814
  remove_action( 'shutdown', array( $this, 'shutdown' ) );
815
  //do restart
816
  wp_clear_scheduled_hook( 'backwpup_cron', array( 'id' => 'restart' ) );
868
  *
869
  * @return bool|object BackWPup_Job Object or Bool if file not exits
870
  */
871
+ public static function get_working_data() {
872
 
873
+ if ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
874
+ clearstatcache( TRUE, BackWPup::get_plugin_data( 'running_file' ) );
875
+ } else {
876
+ clearstatcache();
877
+ }
878
 
879
+ if ( ! file_exists( BackWPup::get_plugin_data( 'running_file' ) ) )
880
+ return FALSE;
 
 
881
 
882
+ $file_data = file_get_contents( BackWPup::get_plugin_data( 'running_file' ), FALSE, NULL, 8 );
883
+ if ( $file_data === FALSE )
884
  return FALSE;
885
 
886
+ if ( $job_object = unserialize( $file_data ) ) {
887
+ if ( $job_object instanceof BackWPup_Job )
888
+ return $job_object;
889
  }
890
 
891
+ return FALSE;
892
+
893
+ }
894
+
895
+ /**
896
+ *
897
+ * Reads a BackWPup logfile header and gives back a array of information
898
+ *
899
+ * @param string $logfile full logfile path
900
+ *
901
+ * @return array|bool
902
+ */
903
+ public static function read_logheader( $logfile ) {
904
 
905
  $usedmetas = array(
906
  "date" => "logtime",
1077
  switch ( $args[ 0 ] ) {
1078
  case E_NOTICE:
1079
  case E_USER_NOTICE:
1080
+ $messagetype = '';
1081
  break;
1082
  case E_WARNING:
1083
  case E_CORE_WARNING:
1085
  case E_USER_WARNING:
1086
  $this->warnings ++;
1087
  $error_or_warning = TRUE;
1088
+ $messagetype = '<span style="background-color:#ffc000;color:#fff">' . __( 'WARNING:', 'backwpup' ) . ' ';
1089
  break;
1090
  case E_ERROR:
1091
  case E_PARSE:
1094
  case E_USER_ERROR:
1095
  $this->errors ++;
1096
  $error_or_warning = TRUE;
1097
+ $messagetype = '<span style="background-color:red;color:#fff">' . __( 'ERROR:', 'backwpup' ) . ' ';
1098
  break;
1099
  case 8192: //E_DEPRECATED comes with php 5.3
1100
  case 16384: //E_USER_DEPRECATED comes with php 5.3
1101
+ $messagetype = __( 'DEPRECATED:', 'backwpup' ) . ' ';
1102
  break;
1103
  case E_STRICT:
1104
+ $messagetype = __( 'STRICT NOTICE:', 'backwpup' ) . ' ';
1105
  break;
1106
  case E_RECOVERABLE_ERROR:
1107
  $this->errors ++;
1108
  $error_or_warning = TRUE;
1109
+ $messagetype = '<span style="background-color:red;color:#fff">' . __( 'RECOVERABLE ERROR:', 'backwpup' ) . ' ';
1110
  break;
1111
  default:
1112
+ $messagetype = $args[ 0 ] . ": ";
1113
  break;
1114
  }
1115
 
1116
  $in_file = str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', $args[ 2 ] ) );
1117
 
1118
  //print message to cli
1119
+ if ( php_sapi_name() == 'cli' && defined( 'STDOUT' ) )
1120
  fwrite( STDOUT, '[' . date_i18n( 'd-M-Y H:i:s' ) . '] ' . strip_tags( $messagetype ) . str_replace( '&hellip;', '...', strip_tags( $args[ 1 ] ) ) . PHP_EOL ) ;
1121
  //log line
1122
+ $timestamp = '<span datetime="' . date_i18n( 'c' ) . '" title="[Type: ' . $args[ 0 ] . '|Line: ' . $args[ 3 ] . '|File: ' . $in_file . '|Mem: ' . size_format( @memory_get_usage( TRUE ), 2 ) . '|Mem Max: ' . size_format( @memory_get_peak_usage( TRUE ), 2 ) . '|Mem Limit: ' . ini_get( 'memory_limit' ) . '|PID: ' . self::get_pid() . ' | UniqID: ' . $this->uniqid . '|Query\'s: ' . get_num_queries() . ']">[' . date_i18n( 'd-M-Y H:i:s' ) . ']</span> ';
1123
+ //set last Message
1124
+ $message = $messagetype . htmlentities( $args[ 1 ], ENT_COMPAT , get_bloginfo( 'charset' ), FALSE );
1125
+ if ( strstr( $message, '<span' ) )
1126
+ $message .= '</span>';
1127
  if ( $args[ 0 ] == E_NOTICE || $args[ 0 ] == E_USER_NOTICE )
1128
+ $this->lastmsg = $message;
1129
  if ( $error_or_warning )
1130
+ $this->lasterrormsg = $message;
1131
  //write log file
1132
+ file_put_contents( $this->logfile, $timestamp . $message . '<br />' . PHP_EOL, FILE_APPEND );
1133
 
1134
  //write new log header
1135
  if ( $error_or_warning ) {
1165
  /**
1166
  *
1167
  * Write the Working data to display the process or that i can executes again
1168
+ * The write will only done every second
1169
  *
1170
  * @global wpdb $wpdb
 
1171
  */
1172
+ public function update_working_data() {
1173
  global $wpdb;
1174
  /* @var wpdb $wpdb */
1175
 
1182
 
1183
  //only run every 1 sec.
1184
  $time_to_update = microtime( TRUE ) - $this->timestamp_last_update;
1185
+ if ( $time_to_update < 1 )
1186
  return;
1187
 
1188
  //FCGI must have a permanent output so that it not broke
1189
  if ( stristr( PHP_SAPI, 'fcgi' ) || stristr( PHP_SAPI, 'litespeed' ) ) {
1190
+ //only if no output buffering is active
1191
  if ( ob_get_level() == 0 ) {
1192
  echo ' ';
1193
  flush();
1214
  $this->end();
1215
  } else {
1216
  $this->timestamp_last_update = microtime( TRUE ); //last update of working file
1217
+ $this->write_running_file();
1218
+ }
1219
+ }
1220
+
1221
+ public function write_running_file() {
1222
+
1223
+ $clone = clone $this;
1224
+ $data = '<?php //' . serialize( $clone );
1225
+
1226
+ $write = file_put_contents( BackWPup::get_plugin_data( 'running_file' ), $data );
1227
+ if ( !$write || $write < strlen( $data ) ) {
1228
+ unlink( BackWPup::get_plugin_data( 'running_file' ) );
1229
+ $this->log( __( 'Cannot write progress to working file. Job will be aborted.', 'backwpup' ), E_USER_ERROR );
1230
  }
1231
  }
1232
 
1336
  $subject = sprintf( __( '[%3$s] BackWPup log %1$s: %2$s', 'backwpup' ), date_i18n( 'd-M-Y H:i', $this->start_time, TRUE ), esc_attr( $this->job[ 'name' ] ), $status );
1337
  $headers = array();
1338
  $headers[] = 'Content-Type: text/html; charset='. get_bloginfo( 'charset' );
1339
+ /* $headers[] = 'X-Priority: ' . $priority; */ // Priority not working with header setting
1340
  if ( ! empty( $this->job[ 'mailaddresssenderlog' ] ) ) {
1341
  if ( FALSE === $start_mail = strpos( $this->job[ 'mailaddresssenderlog' ], '<' ) ) {
1342
  if ( FALSE === strpos( $this->job[ 'mailaddresssenderlog' ], '@' ) ) {
1364
  remove_action( 'shutdown', array( $this, 'shutdown' ) );
1365
  restore_exception_handler();
1366
  restore_error_handler();
1367
+ if ( ! empty( $this->run[ 'PHP' ] ) ) {
1368
+ @ini_set( 'log_errors', $this->run[ 'PHP' ][ 'INI' ][ 'LOG_ERRORS' ] );
1369
+ @ini_set( 'error_log', $this->run[ 'PHP' ][ 'INI' ][ 'ERROR_LOG' ] );
1370
+ @ini_set( 'display_errors', $this->run[ 'PHP' ][ 'INI' ][ 'DISPLAY_ERRORS' ] );
1371
+ @ini_set( 'html_errors', $this->run[ 'PHP' ][ 'INI' ][ 'HTML_ERRORS' ] );
1372
+ @ini_set( 'zlib.output_compression', $this->run[ 'PHP' ][ 'INI' ][ 'ZLIB_OUTPUT_COMPRESSION' ] );
1373
+ @ini_set( 'implicit_flush', $this->run[ 'PHP' ][ 'INI' ][ 'IMPLICIT_FLUSH' ] );
1374
+ @ini_set( 'error_reporting', $this->run[ 'PHP' ][ 'INI' ][ 'ERROR_REPORTING' ] );
1375
+ @ini_set( 'report_memleaks', $this->run[ 'PHP' ][ 'INI' ][ 'REPORT_MEMLEAKS' ] );
1376
+ if ( !empty( $this->run[ 'PHP' ][ 'ENV' ][ 'TEMPDIR' ] ) ) {
1377
+ @putenv('TMPDIR=' . $this->run[ 'PHP' ][ 'ENV' ][ 'TEMPDIR' ] );
1378
+ }
1379
+ }
1380
 
1381
  BackWPup_Cron::check_cleanup();
1382
 
1719
  if ( FALSE !== stripos( $folder . $file, trim( $exclusion ) ) && ! empty( $exclusion ) )
1720
  continue 2;
1721
  }
1722
+ if ( $this->job[ 'backupexcludethumbs' ] && strpos( $folder, BackWPup_File::get_upload_dir() ) !== FALSE && preg_match( "/\-[0-9]{1,4}x[0-9]{1,4}.+\.(jpg|png|gif)$/i", $file ) ) {
1723
  continue;
1724
+ }
1725
+ if ( is_link( $folder . $file ) ) {
1726
  $this->log( sprintf( __( 'Link "%s" not following.', 'backwpup' ), $folder . $file ), E_USER_WARNING );
1727
+ } elseif ( ! is_readable( $folder . $file ) ) {
1728
  $this->log( sprintf( __( 'File "%s" is not readable!', 'backwpup' ), $folder . $file ), E_USER_WARNING );
1729
+ } else {
1730
+ $file_size = filesize( $folder . $file );
1731
+ if ( ! is_int( $file_size ) || $file_size < 0 || $file_size > 2147483647 ) {
1732
+ $this->log( sprintf( __( 'File size of “%s” cannot be retrieved. File might be too large and will not be added to queue.', 'backwpup' ), $folder . $file . ' ' . $file_size ), E_USER_WARNING );
1733
+ continue;
1734
+ }
1735
  $files[ ] = $folder . $file;
1736
  $this->count_files_in_folder ++;
1737
+ $this->count_filesize_in_folder = $this->count_filesize_in_folder + $file_size;
1738
  }
1739
  }
1740
  closedir( $dir );
1814
  $this->count_files ++;
1815
  $this->additional_files_to_backup[ ] = BackWPup::get_plugin_data( 'TEMP' ) . 'backwpup_readme.txt';
1816
  $this->count_files ++;
1817
+ $this->count_filesize = $this->count_filesize + filesize( BackWPup::get_plugin_data( 'TEMP' ) . 'manifest.json' );
1818
+ $this->count_filesize = $this->count_filesize + filesize( BackWPup::get_plugin_data( 'TEMP' ) . 'backwpup_readme.txt' );
1819
  $this->log( sprintf( __( 'Added manifest.json file with %1$s to backup file list.', 'backwpup' ), size_format( filesize( BackWPup::get_plugin_data( 'TEMP' ) . 'manifest.json' ), 2 ) ) );
1820
  }
1821
  $this->substeps_done = 3;
1834
  $this->substeps_todo = $this->count_folder + 1;
1835
 
1836
  //initial settings for restarts in archiving
1837
+ if ( ! isset( $this->steps_data[ $this->step_working ]['on_file'] ) ) {
1838
  $this->steps_data[ $this->step_working ]['on_file'] = '';
1839
+ }
1840
+ if ( ! isset( $this->steps_data[ $this->step_working ]['on_folder'] ) ) {
1841
  $this->steps_data[ $this->step_working ]['on_folder'] = '';
1842
+ }
1843
+
1844
+ if ( $this->steps_data[ $this->step_working ][ 'on_folder' ] == '' && $this->steps_data[ $this->step_working ][ 'on_file' ] == '' && is_file( $this->backup_folder . $this->backup_file ) ) {
1845
+ unlink( $this->backup_folder . $this->backup_file );
1846
+ }
1847
 
1848
  if ( $this->steps_data[ $this->step_working ]['SAVE_STEP_TRY'] != $this->steps_data[ $this->step_working ][ 'STEP_TRY' ] )
1849
  $this->log( sprintf( __( '%d. Trying to create backup archive &hellip;', 'backwpup' ), $this->steps_data[ $this->step_working ][ 'STEP_TRY' ] ), E_USER_NOTICE );
1859
  if ( $this->substeps_done == 0 ) {
1860
  if ( ! empty( $this->additional_files_to_backup ) && $this->substeps_done == 0 ) {
1861
  foreach ( $this->additional_files_to_backup as $file ) {
1862
+ if ( $backup_archive->add_file( $file, basename( $file ) ) ) {;
1863
+ $this->count_files ++;
1864
+ $this->count_filesize = filesize( $file );
1865
+ $this->update_working_data();
1866
+ } else {
1867
+ $backup_archive->close();
1868
+ $this->steps_data[ $this->step_working ][ 'on_file' ] = '';
1869
+ $this->steps_data[ $this->step_working ][ 'on_folder' ] = '';
1870
+ $this->log( __( 'Cannot create backup archive correctly. Aborting creation.', 'backwpup' ), E_USER_ERROR );
1871
+ return FALSE;
1872
+ }
1873
  }
1874
  }
1875
  $this->substeps_done ++;
1904
  //generate filename in archive
1905
  $in_archive_filename = ltrim( str_replace( $this->remove_path, '', $file ), '/' );
1906
  //add file to archive
1907
+ if ( $backup_archive->add_file( $file, $in_archive_filename ) ) {
1908
+ $this->update_working_data();
1909
+ } else {
1910
+ $backup_archive->close();
1911
+ $this->steps_data[ $this->step_working ][ 'on_file' ] = '';
1912
+ $this->steps_data[ $this->step_working ][ 'on_folder' ] = '';
1913
+ $this->substeps_done = 0;
1914
+ $this->backup_filesize = filesize( $this->backup_folder . $this->backup_file );
1915
+ if ( ( $this->backup_filesize + filesize( $file ) ) >= 2147483647 ) {
1916
+ $this->log( __( 'Aborting creation.', 'backwpup' ), E_USER_ERROR );
1917
+ return TRUE;
1918
+ }
1919
+ $this->log( __( 'Cannot create backup archive correctly. Aborting creation.', 'backwpup' ), E_USER_ERROR );
1920
+ return FALSE;
1921
+ }
1922
  }
1923
  $this->steps_data[ $this->step_working ]['on_file'] = '';
1924
  $this->substeps_done ++;
1960
  if ( ! empty( $suffix ) && substr( $suffix, 0, 1 ) != '.' )
1961
  $suffix = '.' . $suffix;
1962
 
1963
+ $name = str_replace( $datevars, $datevalues, sanitize_file_name( $name ) );
1964
+ $name .= $suffix; //prevent _ in extension name that sanitize_file_name add.
1965
  if ( $delete_temp_file && is_writeable( BackWPup::get_plugin_data( 'TEMP' ) . $name ) && !is_dir( BackWPup::get_plugin_data( 'TEMP' ) . $name ) && !is_link( BackWPup::get_plugin_data( 'TEMP' ) . $name ) )
1966
  unlink( BackWPup::get_plugin_data( 'TEMP' ) . $name );
1967
 
1979
  if ( ! substr( $filename, -3 ) == '.gz' || ! substr( $filename, -4 ) == '.bz2' || ! substr( $filename, -4 ) == '.tar' || ! substr( $filename, -4 ) == '.zip' )
1980
  return FALSE;
1981
 
1982
+ $filename = str_replace( array( '.gz', '.bz2', '.tar', '.zip' ), '', $filename );
1983
+
1984
  $datevars = array( '%d', '%j', '%m', '%n', '%Y', '%y', '%a', '%A', '%B', '%g', '%G', '%h', '%H', '%i', '%s' );
1985
  $dateregex = array( '(0[1-9]|[12][0-9]|3[01])', '([1-9]|[12][0-9]|3[01])', '(0[1-9]|1[012])', '([1-9]|1[012])', '((19|20|21)[0-9]{2})', '([0-9]{2})', '(am|pm)', '(AM|PM)', '([0-9]{3})', '([1-9]|1[012])', '([0-9]|1[0-9]|2[0-3])', '(0[1-9]|1[012])', '(0[0-9]|1[0-9]|2[0-3])', '([0-5][0-9])', '([0-5][0-9])' );
1986
 
1987
+ $regex = "/^" . str_replace( $datevars, $dateregex, str_replace( "\/", "/", sanitize_file_name( $this->job[ 'archivename' ] ) ) ) . "$/";
1988
 
1989
+ preg_match( $regex, $filename, $matches );
1990
  if ( ! empty( $matches[ 0 ] ) && $matches[ 0 ] == $filename )
1991
  return TRUE;
1992
 
2093
  }
2094
 
2095
  /**
2096
+ * Check whether exec has been disabled.
2097
  *
2098
  * @access public
2099
  * @static
2100
  * @return bool
2101
  */
2102
+ public static function is_exec() {
2103
 
2104
  // Is function avail
2105
+ if ( ! function_exists( 'exec' ) ) {
2106
  return FALSE;
2107
+ }
2108
 
2109
  // Is shell_exec disabled?
2110
+ if ( in_array( 'exec', array_map( 'trim', explode( ',', @ini_get( 'disable_functions' ) ) ) ) ) {
2111
  return FALSE;
2112
+ }
2113
 
2114
  // Can we issue a simple echo command?
2115
+ $output = exec( 'echo backwpupechotest' );
2116
+ if ( $output != 'backwpupechotest' ) {
2117
  return FALSE;
2118
+ }
2119
 
2120
  return TRUE;
2121
 
inc/class-jobtype-dbcheck.php CHANGED
@@ -1,151 +1,151 @@
1
- <?php
2
- /**
3
- *
4
- */
5
- class BackWPup_JobType_DBCheck extends BackWPup_JobTypes {
6
-
7
- /**
8
- *
9
- */
10
- public function __construct() {
11
-
12
- $this->info[ 'ID' ] = 'DBCHECK';
13
- $this->info[ 'name' ] = __( 'DB Check', 'backwpup' );
14
- $this->info[ 'description' ] = __( 'Check database tables', 'backwpup' );
15
- $this->info[ 'URI' ] = translate( BackWPup::get_plugin_data( 'PluginURI' ), 'backwpup' );
16
- $this->info[ 'author' ] = BackWPup::get_plugin_data( 'Author' );
17
- $this->info[ 'authorURI' ] = translate( BackWPup::get_plugin_data( 'AuthorURI' ), 'backwpup' );
18
- $this->info[ 'version' ] = BackWPup::get_plugin_data( 'Version' );
19
-
20
- }
21
-
22
- /**
23
- * @return array
24
- */
25
- public function option_defaults() {
26
- return array( 'dbcheckwponly' => TRUE, 'dbcheckrepair' => FALSE );
27
- }
28
-
29
-
30
- /**
31
- * @param $jobid
32
- */
33
- public function edit_tab( $jobid ) {
34
- ?>
35
- <h3 class="title"><?php _e( 'Settings for database check', 'backwpup' ) ?></h3>
36
- <p></p>
37
- <table class="form-table">
38
- <tr>
39
- <th scope="row"><?php _e( 'WordPress tables only', 'backwpup' ); ?></th>
40
- <td>
41
- <label for="iddbcheckwponly">
42
- <input class="checkbox" value="1" id="iddbcheckwponly"
43
- type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'dbcheckwponly' ), TRUE ); ?>
44
- name="dbcheckwponly"/> <?php _e( 'Check WordPress database tables only', 'backwpup' ); ?>
45
- </label>
46
- </td>
47
- </tr>
48
- <tr>
49
- <th scope="row"><?php _e( 'Repair', 'backwpup' ); ?></th>
50
- <td>
51
- <label for="iddbcheckrepair">
52
- <input class="checkbox" value="1" id="iddbcheckrepair"
53
- type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'dbcheckrepair' ), TRUE ); ?>
54
- name="dbcheckrepair" /> <?php _e( 'Try to repair defect table', 'backwpup' ); ?>
55
- </label>
56
- </td>
57
- </tr>
58
- </table>
59
- <?php
60
- }
61
-
62
-
63
- /**
64
- * @param $jobid
65
- */
66
- public function edit_form_post_save( $jobid ) {
67
- BackWPup_Option::update( $jobid, 'dbcheckwponly', ( isset( $_POST[ 'dbcheckwponly' ] ) && $_POST[ 'dbcheckwponly' ] == 1 ) ? TRUE : FALSE );
68
- BackWPup_Option::update( $jobid, 'dbcheckrepair', ( isset( $_POST[ 'dbcheckrepair' ] ) && $_POST[ 'dbcheckrepair' ] == 1 ) ? TRUE : FALSE );
69
- }
70
-
71
- /**
72
- * @param $job_object
73
- * @return bool
74
- */
75
- public function job_run( &$job_object ) {
76
- global $wpdb;
77
- /* @var wpdb $wpdb */
78
-
79
- $job_object->log( sprintf( __( '%d. Trying to check database&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ) );
80
- if ( ! isset( $job_object->steps_data[ $job_object->step_working ][ 'DONETABLE' ] ) || ! is_array( $job_object->steps_data[ $job_object->step_working ][ 'DONETABLE' ] ) )
81
- $job_object->steps_data[ $job_object->step_working ][ 'DONETABLE' ] = array();
82
-
83
- //to check
84
- $tables = array();
85
- $tablestype = array();
86
- $restables = $wpdb->get_results( 'SHOW FULL TABLES FROM `' . DB_NAME . '`', ARRAY_N );
87
- foreach ( $restables as $table ) {
88
- if ( $job_object->job[ 'dbcheckwponly' ] && substr( $table[ 0 ], 0, strlen( $wpdb->prefix ) ) != $wpdb->prefix )
89
- continue;
90
- $tables[ ] = $table[ 0 ];
91
- $tablestype[ $table[ 0 ] ] = $table[ 1 ];
92
- }
93
-
94
- //Set num
95
- $job_object->substeps_todo = sizeof( $tables );
96
-
97
- //Get table status
98
- $status = array();
99
- $resstatus = $wpdb->get_results( "SHOW TABLE STATUS FROM `" . DB_NAME . "`", ARRAY_A );
100
- foreach ( $resstatus as $tablestatus ) {
101
- $status[ $tablestatus[ 'Name' ] ] = $tablestatus;
102
- }
103
-
104
- //check tables
105
- if ( $job_object->substeps_todo > 0 ) {
106
- foreach ( $tables as $table ) {
107
- if ( in_array( $table, $job_object->steps_data[ $job_object->step_working ][ 'DONETABLE' ] ) )
108
- continue;
109
-
110
- if ( $tablestype[ $table ] == 'VIEW' ) {
111
- $job_object->log( sprintf( __( 'Table %1$s is a view. Not checked.', 'backwpup' ), $table ) );
112
- continue;
113
- }
114
-
115
- if ( $status[ $table ][ 'Engine' ] != 'MyISAM' && $status[ $table ][ 'Engine' ] != 'InnoDB' ) {
116
- $job_object->log( sprintf( __( 'Table %1$s is not a MyISAM/InnoDB table. Not checked.', 'backwpup' ), $table ) );
117
- continue;
118
- }
119
-
120
- //CHECK TABLE funktioniert bei MyISAM- und InnoDB-Tabellen (http://dev.mysql.com/doc/refman/5.1/de/check-table.html)
121
- $check = $wpdb->get_row( "CHECK TABLE `" . $table . "` MEDIUM", OBJECT );
122
- if ( $check->Msg_text == 'OK' )
123
- $job_object->log( sprintf( __( 'Result of table check for %1$s is: %2$s', 'backwpup' ), $table, $check->Msg_text ) );
124
- elseif ( strtolower( $check->Msg_type ) == 'warning' )
125
- $job_object->log( sprintf( __( 'Result of table check for %1$s is: %2$s', 'backwpup' ), $table, $check->Msg_text ), E_USER_WARNING );
126
- else
127
- $job_object->log( sprintf( __( 'Result of table check for %1$s is: %2$s', 'backwpup' ), $table, $check->Msg_text ), E_USER_ERROR );
128
-
129
- //Try to Repair table
130
- if ( ! empty( $job_object->job[ 'dbcheckrepair' ] ) && $check->Msg_text != 'OK' && $status[ $table ][ 'Engine' ] == 'MyISAM' ) {
131
- $repair = $wpdb->get_row( 'REPAIR TABLE `' . $table . '` EXTENDED', OBJECT );
132
- if ( $repair->Msg_type == 'OK' )
133
- $job_object->log( sprintf( __( 'Result of table repair for %1$s is: %2$s', 'backwpup' ), $table, $repair->Msg_text ) );
134
- elseif ( strtolower( $repair->Msg_type ) == 'warning' )
135
- $job_object->log( sprintf( __( 'Result of table repair for %1$s is: %2$s', 'backwpup' ), $table, $repair->Msg_text ), E_USER_WARNING );
136
- else
137
- $job_object->log( sprintf( __( 'Result of table repair for %1$s is: %2$s', 'backwpup' ), $table, $repair->Msg_text ), E_USER_ERROR );
138
- }
139
- $job_object->steps_data[ $job_object->step_working ][ 'DONETABLE' ][ ] = $table;
140
- $job_object->substeps_done ++;
141
- }
142
- $job_object->log( __( 'Database check done!', 'backwpup' ) );
143
- }
144
- else {
145
- $job_object->log( __( 'No tables to check.', 'backwpup' ) );
146
- }
147
-
148
- unset( $job_object->steps_data[ $job_object->step_working ][ 'DONETABLE' ] );
149
- return TRUE;
150
- }
151
- }
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ class BackWPup_JobType_DBCheck extends BackWPup_JobTypes {
6
+
7
+ /**
8
+ *
9
+ */
10
+ public function __construct() {
11
+
12
+ $this->info[ 'ID' ] = 'DBCHECK';
13
+ $this->info[ 'name' ] = __( 'DB Check', 'backwpup' );
14
+ $this->info[ 'description' ] = __( 'Check database tables', 'backwpup' );
15
+ $this->info[ 'URI' ] = translate( BackWPup::get_plugin_data( 'PluginURI' ), 'backwpup' );
16
+ $this->info[ 'author' ] = BackWPup::get_plugin_data( 'Author' );
17
+ $this->info[ 'authorURI' ] = translate( BackWPup::get_plugin_data( 'AuthorURI' ), 'backwpup' );
18
+ $this->info[ 'version' ] = BackWPup::get_plugin_data( 'Version' );
19
+
20
+ }
21
+
22
+ /**
23
+ * @return array
24
+ */
25
+ public function option_defaults() {
26
+ return array( 'dbcheckwponly' => TRUE, 'dbcheckrepair' => FALSE );
27
+ }
28
+
29
+
30
+ /**
31
+ * @param $jobid
32
+ */
33
+ public function edit_tab( $jobid ) {
34
+ ?>
35
+ <h3 class="title"><?php _e( 'Settings for database check', 'backwpup' ) ?></h3>
36
+ <p></p>
37
+ <table class="form-table">
38
+ <tr>
39
+ <th scope="row"><?php _e( 'WordPress tables only', 'backwpup' ); ?></th>
40
+ <td>
41
+ <label for="iddbcheckwponly">
42
+ <input class="checkbox" value="1" id="iddbcheckwponly"
43
+ type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'dbcheckwponly' ), TRUE ); ?>
44
+ name="dbcheckwponly"/> <?php _e( 'Check WordPress database tables only', 'backwpup' ); ?>
45
+ </label>
46
+ </td>
47
+ </tr>
48
+ <tr>
49
+ <th scope="row"><?php _e( 'Repair', 'backwpup' ); ?></th>
50
+ <td>
51
+ <label for="iddbcheckrepair">
52
+ <input class="checkbox" value="1" id="iddbcheckrepair"
53
+ type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'dbcheckrepair' ), TRUE ); ?>
54
+ name="dbcheckrepair" /> <?php _e( 'Try to repair defect table', 'backwpup' ); ?>
55
+ </label>
56
+ </td>
57
+ </tr>
58
+ </table>
59
+ <?php
60
+ }
61
+
62
+
63
+ /**
64
+ * @param $jobid
65
+ */
66
+ public function edit_form_post_save( $jobid ) {
67
+ BackWPup_Option::update( $jobid, 'dbcheckwponly', ( isset( $_POST[ 'dbcheckwponly' ] ) && $_POST[ 'dbcheckwponly' ] == 1 ) ? TRUE : FALSE );
68
+ BackWPup_Option::update( $jobid, 'dbcheckrepair', ( isset( $_POST[ 'dbcheckrepair' ] ) && $_POST[ 'dbcheckrepair' ] == 1 ) ? TRUE : FALSE );
69
+ }
70
+
71
+ /**
72
+ * @param $job_object
73
+ * @return bool
74
+ */
75
+ public function job_run( &$job_object ) {
76
+ global $wpdb;
77
+ /* @var wpdb $wpdb */
78
+
79
+ $job_object->log( sprintf( __( '%d. Trying to check database&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ) );
80
+ if ( ! isset( $job_object->steps_data[ $job_object->step_working ][ 'DONETABLE' ] ) || ! is_array( $job_object->steps_data[ $job_object->step_working ][ 'DONETABLE' ] ) )
81
+ $job_object->steps_data[ $job_object->step_working ][ 'DONETABLE' ] = array();
82
+
83
+ //to check
84
+ $tables = array();
85
+ $tablestype = array();
86
+ $restables = $wpdb->get_results( 'SHOW FULL TABLES FROM `' . DB_NAME . '`', ARRAY_N );
87
+ foreach ( $restables as $table ) {
88
+ if ( $job_object->job[ 'dbcheckwponly' ] && substr( $table[ 0 ], 0, strlen( $wpdb->prefix ) ) != $wpdb->prefix )
89
+ continue;
90
+ $tables[ ] = $table[ 0 ];
91
+ $tablestype[ $table[ 0 ] ] = $table[ 1 ];
92
+ }
93
+
94
+ //Set num
95
+ $job_object->substeps_todo = sizeof( $tables );
96
+
97
+ //Get table status
98
+ $status = array();
99
+ $resstatus = $wpdb->get_results( "SHOW TABLE STATUS FROM `" . DB_NAME . "`", ARRAY_A );
100
+ foreach ( $resstatus as $tablestatus ) {
101
+ $status[ $tablestatus[ 'Name' ] ] = $tablestatus;
102
+ }
103
+
104
+ //check tables
105
+ if ( $job_object->substeps_todo > 0 ) {
106
+ foreach ( $tables as $table ) {
107
+ if ( in_array( $table, $job_object->steps_data[ $job_object->step_working ][ 'DONETABLE' ] ) )
108
+ continue;
109
+
110
+ if ( $tablestype[ $table ] == 'VIEW' ) {
111
+ $job_object->log( sprintf( __( 'Table %1$s is a view. Not checked.', 'backwpup' ), $table ) );
112
+ continue;
113
+ }
114
+
115
+ if ( $status[ $table ][ 'Engine' ] != 'MyISAM' && $status[ $table ][ 'Engine' ] != 'InnoDB' ) {
116
+ $job_object->log( sprintf( __( 'Table %1$s is not a MyISAM/InnoDB table. Not checked.', 'backwpup' ), $table ) );
117
+ continue;
118
+ }
119
+
120
+ //CHECK TABLE funktioniert bei MyISAM- und InnoDB-Tabellen (http://dev.mysql.com/doc/refman/5.1/de/check-table.html)
121
+ $check = $wpdb->get_row( "CHECK TABLE `" . $table . "` MEDIUM", OBJECT );
122
+ if ( $check->Msg_text == 'OK' )
123
+ $job_object->log( sprintf( __( 'Result of table check for %1$s is: %2$s', 'backwpup' ), $table, $check->Msg_text ) );
124
+ elseif ( strtolower( $check->Msg_type ) == 'warning' )
125
+ $job_object->log( sprintf( __( 'Result of table check for %1$s is: %2$s', 'backwpup' ), $table, $check->Msg_text ), E_USER_WARNING );
126
+ else
127
+ $job_object->log( sprintf( __( 'Result of table check for %1$s is: %2$s', 'backwpup' ), $table, $check->Msg_text ), E_USER_ERROR );
128
+
129
+ //Try to Repair table
130
+ if ( ! empty( $job_object->job[ 'dbcheckrepair' ] ) && $check->Msg_text != 'OK' && $status[ $table ][ 'Engine' ] == 'MyISAM' ) {
131
+ $repair = $wpdb->get_row( 'REPAIR TABLE `' . $table . '` EXTENDED', OBJECT );
132
+ if ( $repair->Msg_type == 'OK' )
133
+ $job_object->log( sprintf( __( 'Result of table repair for %1$s is: %2$s', 'backwpup' ), $table, $repair->Msg_text ) );
134
+ elseif ( strtolower( $repair->Msg_type ) == 'warning' )
135
+ $job_object->log( sprintf( __( 'Result of table repair for %1$s is: %2$s', 'backwpup' ), $table, $repair->Msg_text ), E_USER_WARNING );
136
+ else
137
+ $job_object->log( sprintf( __( 'Result of table repair for %1$s is: %2$s', 'backwpup' ), $table, $repair->Msg_text ), E_USER_ERROR );
138
+ }
139
+ $job_object->steps_data[ $job_object->step_working ][ 'DONETABLE' ][ ] = $table;
140
+ $job_object->substeps_done ++;
141
+ }
142
+ $job_object->log( __( 'Database check done!', 'backwpup' ) );
143
+ }
144
+ else {
145
+ $job_object->log( __( 'No tables to check.', 'backwpup' ) );
146
+ }
147
+
148
+ unset( $job_object->steps_data[ $job_object->step_working ][ 'DONETABLE' ] );
149
+ return TRUE;
150
+ }
151
+ }
inc/class-jobtype-dbdump.php CHANGED
@@ -1,275 +1,273 @@
1
- <?php
2
- /**
3
- *
4
- */
5
- class BackWPup_JobType_DBDump extends BackWPup_JobTypes {
6
-
7
- /**
8
- *
9
- */
10
- public function __construct() {
11
-
12
- $this->info[ 'ID' ] = 'DBDUMP';
13
- $this->info[ 'name' ] = __( 'DB Backup', 'backwpup' );
14
- $this->info[ 'description' ] = __( 'Database backup', 'backwpup' );
15
- $this->info[ 'help' ] = __( 'Creates an .sql database backup file', 'backwpup' );
16
- $this->info[ 'URI' ] = translate( BackWPup::get_plugin_data( 'PluginURI' ), 'backwpup' );
17
- $this->info[ 'author' ] = BackWPup::get_plugin_data( 'Author' );
18
- $this->info[ 'authorURI' ] = translate( BackWPup::get_plugin_data( 'AuthorURI' ), 'backwpup' );
19
- $this->info[ 'version' ] = BackWPup::get_plugin_data( 'Version' );
20
-
21
- }
22
-
23
- /**
24
- * @return bool
25
- */
26
- public function creates_file() {
27
-
28
- return TRUE;
29
- }
30
-
31
- /**
32
- * @return array
33
- */
34
- public function option_defaults() {
35
- global $wpdb;
36
- /* @var wpdb $wpdb */
37
-
38
- $defaults = array(
39
- 'dbdumpexclude' => array(), 'dbdumpfile' => sanitize_file_name( DB_NAME ), 'dbdumptype' => 'sql', 'dbdumpfilecompression' => ''
40
- );
41
- //set only wordpress tables as default
42
- $dbtables = $wpdb->get_results( 'SHOW TABLES FROM `' . DB_NAME . '`', ARRAY_N );
43
- foreach ( $dbtables as $dbtable) {
44
- if ( $wpdb->prefix != substr( $dbtable[ 0 ], 0, strlen( $wpdb->prefix ) ) )
45
- $defaults[ 'dbdumpexclude' ][] = $dbtable[ 0 ];
46
- }
47
-
48
- return $defaults;
49
- }
50
-
51
-
52
- /**
53
- * @param $jobid
54
- */
55
- public function edit_tab( $jobid ) {
56
- global $wpdb;
57
- /* @var wpdb $wpdb */
58
-
59
- ?>
60
- <input name="dbdumpwpony" type="hidden" value="1" />
61
- <h3 class="title"><?php _e( 'Settings for database backup', 'backwpup' ) ?></h3>
62
- <p></p>
63
- <table class="form-table">
64
- <tr>
65
- <th scope="row"><?php _e( 'Tables to backup', 'backwpup' ); ?></th>
66
- <td>
67
- <input type="button" class="button-secondary" id="dball" value="<?php _e( 'all', 'backwpup' ); ?>">&nbsp;
68
- <input type="button" class="button-secondary" id="dbnone" value="<?php _e( 'none', 'backwpup' ); ?>">&nbsp;
69
- <input type="button" class="button-secondary" id="dbwp" value="<?php echo $wpdb->prefix; ?>">
70
- <?php
71
- $tables = $wpdb->get_results( 'SHOW FULL TABLES FROM `' . DB_NAME . '`', ARRAY_N );
72
- echo '<fieldset id="dbtables"><div style="width: 30%; float:left; min-width: 250px; margin-right: 10px;">';
73
- $next_row = ceil( count( $tables ) / 3 );
74
- $counter = 0;
75
- foreach ( $tables as $table ) {
76
- $tabletype = '';
77
- if ( $table[ 1 ] != 'BASE TABLE' )
78
- $tabletype = ' <i>(' . strtolower( $table[ 1 ] ) . ')</i>';
79
- echo '<label for="idtabledb-' . rawurlencode( $table[ 0 ] ) . '""><input class="checkbox" type="checkbox"' . checked( ! in_array( $table[ 0 ], BackWPup_Option::get( $jobid, 'dbdumpexclude' ) ), TRUE, FALSE ) . ' name="tabledb[]" id="idtabledb-' . rawurlencode( $table[ 0 ] ) . '" value="' . rawurlencode( $table[ 0 ] ) . '"/> ' . $table[ 0 ] . $tabletype . '</label><br />';
80
- $counter++;
81
- if ($next_row <= $counter) {
82
- echo '</div><div style="width: 30%; float:left; min-width: 250px; margin-right: 10px;">';
83
- $counter = 0;
84
- }
85
- }
86
- echo '</div></fieldset>';
87
- ?>
88
- </td>
89
- </tr>
90
- <tr>
91
- <th scope="row"><label for="iddbdumpfile"><?php _e( 'Backup file name', 'backwpup' ) ?></label></th>
92
- <td>
93
- <input id="iddbdumpfile" name="dbdumpfile" type="text"
94
- value="<?php echo BackWPup_Option::get( $jobid, 'dbdumpfile' );?>"
95
- class="medium-text code"/>.sql
96
- </td>
97
- </tr>
98
- <tr>
99
- <th scope="row"><?php _e( 'Backup file compression', 'backwpup' ) ?></th>
100
- <td>
101
- <fieldset>
102
- <?php
103
- echo '<label for="iddbdumpfilecompression"><input class="radio" type="radio"' . checked( '', BackWPup_Option::get( $jobid, 'dbdumpfilecompression' ), FALSE ) . ' name="dbdumpfilecompression" id="iddbdumpfilecompression" value="" /> ' . __( 'none', 'backwpup' ). '</label><br />';
104
- if ( function_exists( 'gzopen' ) )
105
- echo '<label for="iddbdumpfilecompression-gz"><input class="radio" type="radio"' . checked( '.gz', BackWPup_Option::get( $jobid, 'dbdumpfilecompression' ), FALSE ) . ' name="dbdumpfilecompression" id="iddbdumpfilecompression-gz" value=".gz" /> ' . __( 'GZip', 'backwpup' ). '</label><br />';
106
- else
107
- echo '<label for="iddbdumpfilecompression-gz"><input class="radio" type="radio"' . checked( '.gz', BackWPup_Option::get( $jobid, 'dbdumpfilecompression' ), FALSE ) . ' name="dbdumpfilecompression" id="iddbdumpfilecompression-gz" value=".gz" disabled="disabled" /> ' . __( 'GZip', 'backwpup' ). '</label><br />';
108
- ?>
109
- </fieldset>
110
- </td>
111
- </tr>
112
- </table>
113
- <?php
114
- }
115
-
116
-
117
- /**
118
- * @param $id
119
- */
120
- public function edit_form_post_save( $id ) {
121
- global $wpdb;
122
- /* @var wpdb $wpdb */
123
-
124
- if ( $_POST[ 'dbdumpfilecompression' ] == '' || $_POST[ 'dbdumpfilecompression' ] == '.gz' )
125
- BackWPup_Option::update( $id, 'dbdumpfilecompression', $_POST[ 'dbdumpfilecompression' ] );
126
- BackWPup_Option::update( $id, 'dbdumpfile', sanitize_file_name( $_POST[ 'dbdumpfile' ]) );
127
- //selected tables
128
- $dbdumpexclude = array();
129
- $checked_db_tables = array();
130
- if ( isset( $_POST[ 'tabledb' ] ) ) {
131
- foreach ( $_POST[ 'tabledb' ] as $dbtable )
132
- $checked_db_tables[ ] = rawurldecode( $dbtable );
133
- }
134
- $dbtables = $wpdb->get_results( 'SHOW TABLES FROM `' . DB_NAME . '`', ARRAY_N );
135
- foreach ( $dbtables as $dbtable ) {
136
- if ( ! in_array( $dbtable[ 0 ], $checked_db_tables ) )
137
- $dbdumpexclude[ ] = $dbtable[ 0 ];
138
- }
139
- BackWPup_Option::update( $id, 'dbdumpexclude', $dbdumpexclude );
140
-
141
- }
142
-
143
- /**
144
- * Dumps the Database
145
- *
146
- * @param $job_object BackWPup_Job
147
- *
148
- * @return bool
149
- */
150
- public function job_run( &$job_object ) {
151
-
152
- $job_object->substeps_todo = 1;
153
-
154
- if ( $job_object->steps_data[ $job_object->step_working ]['SAVE_STEP_TRY'] != $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] )
155
- $job_object->log( sprintf( __( '%d. Try to backup database&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ) );
156
-
157
- //build filename
158
- if ( empty( $job_object->steps_data[ $job_object->step_working ][ 'dbdumpfile' ] ) )
159
- $job_object->steps_data[ $job_object->step_working ][ 'dbdumpfile' ] = $job_object->generate_filename( $job_object->job[ 'dbdumpfile' ], 'sql' ) . $job_object->job[ 'dbdumpfilecompression' ];
160
-
161
- try {
162
-
163
- //Connect to Database
164
- $sql_dump = new BackWPup_MySQLDump( array(
165
- 'dumpfile' => BackWPup::get_plugin_data( 'TEMP' ) . $job_object->steps_data[ $job_object->step_working ][ 'dbdumpfile' ],
166
- ) );
167
-
168
- if ( $job_object->steps_data[ $job_object->step_working ]['SAVE_STEP_TRY'] != $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] )
169
- $job_object->log( sprintf( __( 'Connected to database %1$s on %2$s', 'backwpup' ), DB_NAME, DB_HOST ) );
170
-
171
-
172
- //Exclude Tables
173
- foreach ( $sql_dump->tables_to_dump as $key => $table ) {
174
- if ( in_array( $table, $job_object->job[ 'dbdumpexclude' ] ) )
175
- unset( $sql_dump->tables_to_dump[ $key ] );
176
- }
177
-
178
- //set steps must done
179
- $job_object->substeps_todo = count( $sql_dump->tables_to_dump );
180
-
181
- if ( $job_object->substeps_todo == 0 ) {
182
- $job_object->log( __( 'No tables to backup.', 'backwpup' ), E_USER_WARNING );
183
- unset( $sql_dump );
184
-
185
- return TRUE;
186
- }
187
-
188
- //dump head
189
- if ( ! isset( $job_object->steps_data[ $job_object->step_working ][ 'is_head' ] ) ) {
190
- $sql_dump->dump_head( TRUE );
191
- $job_object->steps_data[ $job_object->step_working ][ 'is_head' ] = TRUE;
192
- }
193
- //dump tables
194
- $i = 0;
195
- foreach( $sql_dump->tables_to_dump as $table ) {
196
- if ( $i < $job_object->substeps_done ) {
197
- $i++;
198
- continue;
199
- }
200
- if ( empty( $job_object->steps_data[ $job_object->step_working ][ 'tables' ][ $table ] ) ) {
201
- $num_records = $sql_dump->dump_table_head( $table );
202
- $job_object->steps_data[ $job_object->step_working ][ 'tables' ][ $table ] = array( 'start' => 0,
203
- 'length' => 1000 );
204
- $job_object->log( sprintf( __( 'Backup database table "%s" with "%d" records', 'backwpup' ), $table, $num_records ) );
205
- if ( empty( $num_records ) ) {
206
- $job_object->substeps_done++;
207
- $i++;
208
- continue;
209
- }
210
- }
211
- $while = true;
212
- while ( $while ) {
213
- $dump_start_time = microtime( TRUE );
214
- $done_records = $sql_dump->dump_table( $table ,$job_object->steps_data[ $job_object->step_working ][ 'tables' ][ $table ][ 'start' ], $job_object->steps_data[ $job_object->step_working ][ 'tables' ][ $table ][ 'length' ] );
215
- $dump_time = microtime( TRUE ) - $dump_start_time;
216
- if ( empty( $dump_time ) )
217
- $dump_time = 0.01;
218
- if ( $done_records < $job_object->steps_data[ $job_object->step_working ][ 'tables' ][ $table ][ 'length' ] ) //that is the last chunk
219
- $while = FALSE;
220
- $job_object->steps_data[ $job_object->step_working ][ 'tables' ][ $table ][ 'start' ] = $job_object->steps_data[ $job_object->step_working ][ 'tables' ][ $table ][ 'start' ] + $done_records;
221
- // dump time per record and set next length
222
- $length = ceil( ( $done_records / $dump_time ) * $job_object->get_restart_time() );
223
- if ( $length > 25000 || 0 >= $job_object->get_restart_time() )
224
- $length = 25000;
225
- if ( $length < 1000 )
226
- $length = 1000;
227
- $job_object->steps_data[ $job_object->step_working ][ 'tables' ][ $table ][ 'length' ] = $length;
228
- $job_object->do_restart_time();
229
- }
230
- if ( $job_object->steps_data[ $job_object->step_working ][ 'tables' ][ $table ][ 'start' ] > 0 )
231
- $sql_dump->dump_table_footer( $table );
232
- $job_object->substeps_done++;
233
- $i++;
234
- $job_object->update_working_data();
235
- }
236
- //dump footer
237
- $sql_dump->dump_footer();
238
- unset( $sql_dump );
239
-
240
- } catch ( Exception $e ) {
241
- $job_object->log( $e->getMessage(), E_USER_ERROR, $e->getFile(), $e->getLine() );
242
- unset( $sql_dump );
243
- return FALSE;
244
- }
245
-
246
- //add database file to backup files
247
- if ( is_readable( BackWPup::get_plugin_data( 'TEMP' ) .$job_object->steps_data[ $job_object->step_working ][ 'dbdumpfile' ] ) ) {
248
- $job_object->additional_files_to_backup[ ] = BackWPup::get_plugin_data( 'TEMP' ) . $job_object->steps_data[ $job_object->step_working ][ 'dbdumpfile' ];
249
- $job_object->count_files ++;
250
- $job_object->count_filesize = $job_object->count_filesize + @filesize( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->steps_data[ $job_object->step_working ][ 'dbdumpfile' ] );
251
- $job_object->log( sprintf( __( 'Added database dump "%1$s" with %2$s to backup file list', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'dbdumpfile' ], size_format( filesize( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->steps_data[ $job_object->step_working ][ 'dbdumpfile' ] ), 2 ) ) );
252
- }
253
-
254
- //cleanups
255
- unset( $job_object->steps_data[ $job_object->step_working ][ 'tables' ] );
256
-
257
- $job_object->log( __( 'Database backup done!', 'backwpup' ) );
258
-
259
- return TRUE;
260
- }
261
-
262
- /**
263
- *
264
- */
265
- public function admin_print_scripts() {
266
-
267
- if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
268
- wp_enqueue_script( 'backwpupjobtypedbdump', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_edit_jobtype_dbdump.js', array('jquery'), time(), TRUE );
269
- } else {
270
- wp_enqueue_script( 'backwpupjobtypedbdump', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_edit_jobtype_dbdump.min.js', array('jquery'), BackWPup::get_plugin_data( 'Version' ), TRUE );
271
- }
272
- }
273
-
274
-
275
- }
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ class BackWPup_JobType_DBDump extends BackWPup_JobTypes {
6
+
7
+ /**
8
+ *
9
+ */
10
+ public function __construct() {
11
+
12
+ $this->info[ 'ID' ] = 'DBDUMP';
13
+ $this->info[ 'name' ] = __( 'DB Backup', 'backwpup' );
14
+ $this->info[ 'description' ] = __( 'Database backup', 'backwpup' );
15
+ $this->info[ 'help' ] = __( 'Creates an .sql database backup file', 'backwpup' );
16
+ $this->info[ 'URI' ] = translate( BackWPup::get_plugin_data( 'PluginURI' ), 'backwpup' );
17
+ $this->info[ 'author' ] = BackWPup::get_plugin_data( 'Author' );
18
+ $this->info[ 'authorURI' ] = translate( BackWPup::get_plugin_data( 'AuthorURI' ), 'backwpup' );
19
+ $this->info[ 'version' ] = BackWPup::get_plugin_data( 'Version' );
20
+
21
+ }
22
+
23
+ /**
24
+ * @return bool
25
+ */
26
+ public function creates_file() {
27
+
28
+ return TRUE;
29
+ }
30
+
31
+ /**
32
+ * @return array
33
+ */
34
+ public function option_defaults() {
35
+ global $wpdb;
36
+ /* @var wpdb $wpdb */
37
+
38
+ $defaults = array(
39
+ 'dbdumpexclude' => array(), 'dbdumpfile' => sanitize_file_name( DB_NAME ), 'dbdumptype' => 'sql', 'dbdumpfilecompression' => ''
40
+ );
41
+ //set only wordpress tables as default
42
+ $dbtables = $wpdb->get_results( 'SHOW TABLES FROM `' . DB_NAME . '`', ARRAY_N );
43
+ foreach ( $dbtables as $dbtable) {
44
+ if ( $wpdb->prefix != substr( $dbtable[ 0 ], 0, strlen( $wpdb->prefix ) ) )
45
+ $defaults[ 'dbdumpexclude' ][] = $dbtable[ 0 ];
46
+ }
47
+
48
+ return $defaults;
49
+ }
50
+
51
+
52
+ /**
53
+ * @param $jobid
54
+ */
55
+ public function edit_tab( $jobid ) {
56
+ global $wpdb;
57
+ /* @var wpdb $wpdb */
58
+
59
+ ?>
60
+ <input name="dbdumpwpony" type="hidden" value="1" />
61
+ <h3 class="title"><?php _e( 'Settings for database backup', 'backwpup' ) ?></h3>
62
+ <p></p>
63
+ <table class="form-table">
64
+ <tr>
65
+ <th scope="row"><?php _e( 'Tables to backup', 'backwpup' ); ?></th>
66
+ <td>
67
+ <input type="button" class="button-secondary" id="dball" value="<?php _e( 'all', 'backwpup' ); ?>">&nbsp;
68
+ <input type="button" class="button-secondary" id="dbnone" value="<?php _e( 'none', 'backwpup' ); ?>">&nbsp;
69
+ <input type="button" class="button-secondary" id="dbwp" value="<?php echo $wpdb->prefix; ?>">
70
+ <?php
71
+ $tables = $wpdb->get_results( 'SHOW FULL TABLES FROM `' . DB_NAME . '`', ARRAY_N );
72
+ echo '<fieldset id="dbtables"><div style="width: 30%; float:left; min-width: 250px; margin-right: 10px;">';
73
+ $next_row = ceil( count( $tables ) / 3 );
74
+ $counter = 0;
75
+ foreach ( $tables as $table ) {
76
+ $tabletype = '';
77
+ if ( $table[ 1 ] != 'BASE TABLE' )
78
+ $tabletype = ' <i>(' . strtolower( $table[ 1 ] ) . ')</i>';
79
+ echo '<label for="idtabledb-' . rawurlencode( $table[ 0 ] ) . '""><input class="checkbox" type="checkbox"' . checked( ! in_array( $table[ 0 ], BackWPup_Option::get( $jobid, 'dbdumpexclude' ) ), TRUE, FALSE ) . ' name="tabledb[]" id="idtabledb-' . rawurlencode( $table[ 0 ] ) . '" value="' . rawurlencode( $table[ 0 ] ) . '"/> ' . $table[ 0 ] . $tabletype . '</label><br />';
80
+ $counter++;
81
+ if ($next_row <= $counter) {
82
+ echo '</div><div style="width: 30%; float:left; min-width: 250px; margin-right: 10px;">';
83
+ $counter = 0;
84
+ }
85
+ }
86
+ echo '</div></fieldset>';
87
+ ?>
88
+ </td>
89
+ </tr>
90
+ <tr>
91
+ <th scope="row"><label for="iddbdumpfile"><?php _e( 'Backup file name', 'backwpup' ) ?></label></th>
92
+ <td>
93
+ <input id="iddbdumpfile" name="dbdumpfile" type="text"
94
+ value="<?php echo BackWPup_Option::get( $jobid, 'dbdumpfile' );?>"
95
+ class="medium-text code"/>.sql
96
+ </td>
97
+ </tr>
98
+ <tr>
99
+ <th scope="row"><?php _e( 'Backup file compression', 'backwpup' ) ?></th>
100
+ <td>
101
+ <fieldset>
102
+ <?php
103
+ echo '<label for="iddbdumpfilecompression"><input class="radio" type="radio"' . checked( '', BackWPup_Option::get( $jobid, 'dbdumpfilecompression' ), FALSE ) . ' name="dbdumpfilecompression" id="iddbdumpfilecompression" value="" /> ' . __( 'none', 'backwpup' ). '</label><br />';
104
+ if ( function_exists( 'gzopen' ) )
105
+ echo '<label for="iddbdumpfilecompression-gz"><input class="radio" type="radio"' . checked( '.gz', BackWPup_Option::get( $jobid, 'dbdumpfilecompression' ), FALSE ) . ' name="dbdumpfilecompression" id="iddbdumpfilecompression-gz" value=".gz" /> ' . __( 'GZip', 'backwpup' ). '</label><br />';
106
+ else
107
+ echo '<label for="iddbdumpfilecompression-gz"><input class="radio" type="radio"' . checked( '.gz', BackWPup_Option::get( $jobid, 'dbdumpfilecompression' ), FALSE ) . ' name="dbdumpfilecompression" id="iddbdumpfilecompression-gz" value=".gz" disabled="disabled" /> ' . __( 'GZip', 'backwpup' ). '</label><br />';
108
+ ?>
109
+ </fieldset>
110
+ </td>
111
+ </tr>
112
+ </table>
113
+ <?php
114
+ }
115
+
116
+
117
+ /**
118
+ * @param $id
119
+ */
120
+ public function edit_form_post_save( $id ) {
121
+ global $wpdb;
122
+ /* @var wpdb $wpdb */
123
+
124
+ if ( $_POST[ 'dbdumpfilecompression' ] == '' || $_POST[ 'dbdumpfilecompression' ] == '.gz' )
125
+ BackWPup_Option::update( $id, 'dbdumpfilecompression', $_POST[ 'dbdumpfilecompression' ] );
126
+ BackWPup_Option::update( $id, 'dbdumpfile', sanitize_file_name( $_POST[ 'dbdumpfile' ]) );
127
+ //selected tables
128
+ $dbdumpexclude = array();
129
+ $checked_db_tables = array();
130
+ if ( isset( $_POST[ 'tabledb' ] ) ) {
131
+ foreach ( $_POST[ 'tabledb' ] as $dbtable )
132
+ $checked_db_tables[ ] = rawurldecode( $dbtable );
133
+ }
134
+ $dbtables = $wpdb->get_results( 'SHOW TABLES FROM `' . DB_NAME . '`', ARRAY_N );
135
+ foreach ( $dbtables as $dbtable ) {
136
+ if ( ! in_array( $dbtable[ 0 ], $checked_db_tables ) )
137
+ $dbdumpexclude[ ] = $dbtable[ 0 ];
138
+ }
139
+ BackWPup_Option::update( $id, 'dbdumpexclude', $dbdumpexclude );
140
+
141
+ }
142
+
143
+ /**
144
+ * Dumps the Database
145
+ *
146
+ * @param $job_object BackWPup_Job
147
+ *
148
+ * @return bool
149
+ */
150
+ public function job_run( &$job_object ) {
151
+
152
+ $job_object->substeps_todo = 1;
153
+
154
+ if ( $job_object->steps_data[ $job_object->step_working ]['SAVE_STEP_TRY'] != $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] )
155
+ $job_object->log( sprintf( __( '%d. Try to backup database&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ) );
156
+
157
+ //build filename
158
+ if ( empty( $job_object->steps_data[ $job_object->step_working ][ 'dbdumpfile' ] ) )
159
+ $job_object->steps_data[ $job_object->step_working ][ 'dbdumpfile' ] = $job_object->generate_filename( $job_object->job[ 'dbdumpfile' ], 'sql' ) . $job_object->job[ 'dbdumpfilecompression' ];
160
+
161
+ try {
162
+
163
+ //Connect to Database
164
+ $sql_dump = new BackWPup_MySQLDump( array(
165
+ 'dumpfile' => BackWPup::get_plugin_data( 'TEMP' ) . $job_object->steps_data[ $job_object->step_working ][ 'dbdumpfile' ],
166
+ ) );
167
+
168
+ if ( $job_object->steps_data[ $job_object->step_working ]['SAVE_STEP_TRY'] != $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] )
169
+ $job_object->log( sprintf( __( 'Connected to database %1$s on %2$s', 'backwpup' ), DB_NAME, DB_HOST ) );
170
+
171
+
172
+ //Exclude Tables
173
+ foreach ( $sql_dump->tables_to_dump as $key => $table ) {
174
+ if ( in_array( $table, $job_object->job[ 'dbdumpexclude' ] ) )
175
+ unset( $sql_dump->tables_to_dump[ $key ] );
176
+ }
177
+
178
+ //set steps must done
179
+ $job_object->substeps_todo = count( $sql_dump->tables_to_dump );
180
+
181
+ if ( $job_object->substeps_todo == 0 ) {
182
+ $job_object->log( __( 'No tables to backup.', 'backwpup' ), E_USER_WARNING );
183
+ unset( $sql_dump );
184
+
185
+ return TRUE;
186
+ }
187
+
188
+ //dump head
189
+ if ( ! isset( $job_object->steps_data[ $job_object->step_working ][ 'is_head' ] ) ) {
190
+ $sql_dump->dump_head( TRUE );
191
+ $job_object->steps_data[ $job_object->step_working ][ 'is_head' ] = TRUE;
192
+ }
193
+ //dump tables
194
+ $i = 0;
195
+ foreach( $sql_dump->tables_to_dump as $table ) {
196
+ if ( $i < $job_object->substeps_done ) {
197
+ $i++;
198
+ continue;
199
+ }
200
+ if ( empty( $job_object->steps_data[ $job_object->step_working ][ 'tables' ][ $table ] ) ) {
201
+ $num_records = $sql_dump->dump_table_head( $table );
202
+ $job_object->steps_data[ $job_object->step_working ][ 'tables' ][ $table ] = array( 'start' => 0,
203
+ 'length' => 1000 );
204
+ $job_object->log( sprintf( __( 'Backup database table "%s" with "%s" records', 'backwpup' ), $table, $num_records ) );
205
+ }
206
+ $while = true;
207
+ while ( $while ) {
208
+ $dump_start_time = microtime( TRUE );
209
+ $done_records = $sql_dump->dump_table( $table ,$job_object->steps_data[ $job_object->step_working ][ 'tables' ][ $table ][ 'start' ], $job_object->steps_data[ $job_object->step_working ][ 'tables' ][ $table ][ 'length' ] );
210
+ $dump_time = microtime( TRUE ) - $dump_start_time;
211
+ if ( empty( $dump_time ) )
212
+ $dump_time = 0.01;
213
+ if ( $done_records < $job_object->steps_data[ $job_object->step_working ][ 'tables' ][ $table ][ 'length' ] ) //that is the last chunk
214
+ $while = FALSE;
215
+ $job_object->steps_data[ $job_object->step_working ][ 'tables' ][ $table ][ 'start' ] = $job_object->steps_data[ $job_object->step_working ][ 'tables' ][ $table ][ 'start' ] + $done_records;
216
+ // dump time per record and set next length
217
+ $length = ceil( ( $done_records / $dump_time ) * $job_object->get_restart_time() );
218
+ if ( $length > 25000 || 0 >= $job_object->get_restart_time() )
219
+ $length = 25000;
220
+ if ( $length < 1000 )
221
+ $length = 1000;
222
+ $job_object->steps_data[ $job_object->step_working ][ 'tables' ][ $table ][ 'length' ] = $length;
223
+ $job_object->do_restart_time();
224
+ }
225
+ $sql_dump->dump_table_footer( $table );
226
+ $job_object->substeps_done++;
227
+ $i++;
228
+ $job_object->update_working_data();
229
+ }
230
+ //dump footer
231
+ $sql_dump->dump_footer();
232
+ unset( $sql_dump );
233
+
234
+ } catch ( Exception $e ) {
235
+ $job_object->log( $e->getMessage(), E_USER_ERROR, $e->getFile(), $e->getLine() );
236
+ unset( $sql_dump );
237
+ return FALSE;
238
+ }
239
+
240
+ $filesize = filesize( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->steps_data[ $job_object->step_working ][ 'dbdumpfile' ] );
241
+
242
+ if ( ! is_file( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->steps_data[ $job_object->step_working ][ 'dbdumpfile' ] ) || $filesize < 1 ) {
243
+ $job_object->log( __( 'MySQL backup file not created', 'backwpup' ), E_USER_ERROR );
244
+ return FALSE;
245
+ } else {
246
+ $job_object->additional_files_to_backup[ ] = BackWPup::get_plugin_data( 'TEMP' ) . $job_object->steps_data[ $job_object->step_working ][ 'dbdumpfile' ];
247
+ $job_object->count_files ++;
248
+ $job_object->count_filesize = $job_object->count_filesize + $filesize;
249
+ $job_object->log( sprintf( __( 'Added database dump "%1$s" with %2$s to backup file list', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'dbdumpfile' ], size_format( filesize( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->steps_data[ $job_object->step_working ][ 'dbdumpfile' ] ), 2 ) ) );
250
+ }
251
+
252
+ //cleanups
253
+ unset( $job_object->steps_data[ $job_object->step_working ][ 'tables' ] );
254
+
255
+ $job_object->log( __( 'Database backup done!', 'backwpup' ) );
256
+
257
+ return TRUE;
258
+ }
259
+
260
+ /**
261
+ *
262
+ */
263
+ public function admin_print_scripts() {
264
+
265
+ if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
266
+ wp_enqueue_script( 'backwpupjobtypedbdump', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_edit_jobtype_dbdump.js', array('jquery'), time(), TRUE );
267
+ } else {
268
+ wp_enqueue_script( 'backwpupjobtypedbdump', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_edit_jobtype_dbdump.min.js', array('jquery'), BackWPup::get_plugin_data( 'Version' ), TRUE );
269
+ }
270
+ }
271
+
272
+
273
+ }
 
 
inc/class-jobtype-file.php CHANGED
@@ -1,600 +1,600 @@
1
- <?php
2
- /**
3
- *
4
- */
5
- class BackWPup_JobType_File extends BackWPup_JobTypes {
6
-
7
- private $folers_to_backup = array();
8
-
9
- /**
10
- *
11
- */
12
- public function __construct() {
13
-
14
- $this->info[ 'ID' ] = 'FILE';
15
- $this->info[ 'name' ] = __( 'Files', 'backwpup' );
16
- $this->info[ 'description' ] = __( 'File backup', 'backwpup' );
17
- $this->info[ 'URI' ] = translate( BackWPup::get_plugin_data( 'PluginURI' ), 'backwpup' );
18
- $this->info[ 'author' ] = BackWPup::get_plugin_data( 'Author' );
19
- $this->info[ 'authorURI' ] = translate( BackWPup::get_plugin_data( 'AuthorURI' ), 'backwpup' );
20
- $this->info[ 'version' ] = BackWPup::get_plugin_data( 'Version' );
21
-
22
- }
23
-
24
- /**
25
- *
26
- */
27
- public function admin_print_scripts() {
28
-
29
- if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
30
- wp_enqueue_script( 'backwpupjobtypefile', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_edit_jobtype_file.js', array( 'jquery' ), time(), TRUE );
31
- } else {
32
- wp_enqueue_script( 'backwpupjobtypefile', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_edit_jobtype_file.min.js', array( 'jquery' ), BackWPup::get_plugin_data( 'Version' ), TRUE );
33
- }
34
- }
35
-
36
- /**
37
- * @return bool
38
- */
39
- public function creates_file() {
40
-
41
- return TRUE;
42
- }
43
-
44
- /**
45
- * @return array
46
- */
47
- public function option_defaults() {
48
-
49
- return array(
50
- 'backupexcludethumbs' => FALSE, 'backupspecialfiles' => TRUE,
51
- 'backuproot' => TRUE, 'backupcontent' => TRUE, 'backupplugins' => TRUE, 'backupthemes' => TRUE, 'backupuploads' => TRUE,
52
- 'backuprootexcludedirs' => array( 'logs', 'usage' ), 'backupcontentexcludedirs' => array( 'cache', 'upgrade', 'w3tc' ), 'backuppluginsexcludedirs' => array( 'backwpup', 'backwpup-pro' ), 'backupthemesexcludedirs' => array(), 'backupuploadsexcludedirs' => array( basename( get_site_option( 'backwpup_cfg_logfolder' ) ) ),
53
- 'fileexclude' => '.tmp,.svn,.git,desktop.ini,.DS_Store', 'dirinclude' => ''
54
- );
55
- }
56
-
57
- /**
58
- * @param $main
59
- */
60
- public function edit_tab( $main ) {
61
-
62
- @set_time_limit( 300 );
63
- ?>
64
- <h3 class="title"><?php _e( 'Folders to backup', 'backwpup' ) ?></h3>
65
- <p></p>
66
- <table class="form-table">
67
- <tr>
68
- <th scope="row"><label for="idbackuproot"><?php _e( 'Backup root folder', 'backwpup' ); ?></label></th>
69
- <td>
70
- <?php
71
- $folder = realpath( ABSPATH );
72
- if ( $folder ) {
73
- $folder = untrailingslashit( str_replace( '\\', '/', $folder ) );
74
- $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder, FALSE ), 2 ) . ')' : '';
75
- }
76
- ?>
77
- <input class="checkbox"
78
- type="checkbox"<?php checked( BackWPup_Option::get( $main, 'backuproot' ), TRUE, TRUE );?>
79
- name="backuproot" id="idbackuproot" value="1" /> <code title="<?php echo sprintf( __( 'Path as set by user (symlink?): %s', 'backwpup' ), esc_attr( ABSPATH ) ); ?>"><?php echo esc_attr( $folder ); ?></code><?php echo $folder_size; ?>
80
-
81
- <fieldset id="backuprootexcludedirs" style="padding-left:15px; margin:2px;">
82
- <legend><strong><?php _e( 'Exclude:', 'backwpup' ); ?></strong></legend>
83
- <?php
84
- if ( $folder && $dir = @opendir( $folder ) ) {
85
- while ( ( $file = readdir( $dir ) ) !== FALSE ) {
86
- $excludes = BackWPup_Option::get( $main, 'backuprootexcludedirs' );
87
- if ( ! in_array( $file, array( '.', '..' ) ) && is_dir( $folder . '/' . $file ) && ! in_array( trailingslashit( $folder . '/' . $file ), $this->get_exclude_dirs( $folder ) ) ) {
88
- $donotbackup = file_exists( $folder . '/' . $file . '/.donotbackup' );
89
- $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder . '/' . $file ), 2 ) . ')' : '';
90
- $title = '';
91
- if ( $donotbackup ) {
92
- $excludes[] = $file;
93
- $title = ' title="' . __( 'Excluded by .donotbackup file!', 'backwpup' ) . '"';
94
- }
95
- echo '<nobr><label for="idrootexcludedirs-'.sanitize_file_name( $file ).'"><input class="checkbox" type="checkbox"' . checked( in_array( $file, $excludes ), TRUE, FALSE ) . ' name="backuprootexcludedirs[]" id="idrootexcludedirs-' . sanitize_file_name( $file ) . '" value="' . $file . '"' . disabled( $donotbackup, TRUE, FALSE ) . $title . ' /> ' . esc_attr( $file ) . $folder_size . '</label><br /></nobr>';
96
- }
97
- }
98
- @closedir( $dir );
99
- }
100
- ?>
101
- </fieldset>
102
- </td>
103
- </tr>
104
- <tr>
105
- <th scope="row"><label for="idbackupcontent"><?php _e( 'Backup content folder', 'backwpup' ); ?></label></th>
106
- <td>
107
- <?php
108
- $folder = realpath( WP_CONTENT_DIR );
109
- if ( $folder ) {
110
- $folder = untrailingslashit( str_replace( '\\', '/', $folder ) );
111
- $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder, FALSE ), 2 ) . ')' : '';
112
- }
113
- ?>
114
- <input class="checkbox"
115
- type="checkbox"<?php checked( BackWPup_Option::get( $main, 'backupcontent' ), TRUE, TRUE );?>
116
- name="backupcontent" id="idbackupcontent" value="1" /> <code title="<?php echo sprintf( __( 'Path as set by user (symlink?): %s', 'backwpup' ), esc_attr( WP_CONTENT_DIR ) ); ?>"><?php echo esc_attr( $folder ); ?></code><?php echo $folder_size; ?>
117
-
118
- <fieldset id="backupcontentexcludedirs" style="padding-left:15px; margin:2px;">
119
- <legend><strong><?php _e( 'Exclude:', 'backwpup' ); ?></strong></legend>
120
- <?php
121
- if ( $folder && $dir = @opendir( $folder ) ) {
122
- $excludes = BackWPup_Option::get( $main, 'backupcontentexcludedirs' );
123
- while ( ( $file = readdir( $dir ) ) !== FALSE ) {
124
- if ( ! in_array( $file, array( '.', '..' ) ) && is_dir( $folder . '/' . $file ) && ! in_array( trailingslashit( $folder . '/' . $file ), $this->get_exclude_dirs( $folder ) ) ) {
125
- $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder . '/' . $file ), 2 ) . ')' : '';
126
- $donotbackup = file_exists( $folder . '/' . $file . '/.donotbackup' );
127
- $title = '';
128
- if ( $donotbackup ) {
129
- $excludes[] = $file;
130
- $title = ' title="' . __( 'Excluded by .donotbackup file!', 'backwpup' ) . '"';
131
- }
132
- echo '<nobr><label for="idcontentexcludedirs-'.sanitize_file_name( $file ).'"><input class="checkbox" type="checkbox"' . checked( in_array( $file, $excludes ), TRUE, FALSE ) . ' name="backupcontentexcludedirs[]" id="idcontentexcludedirs-'.sanitize_file_name( $file ).'" value="' . $file . '"' . disabled( $donotbackup, TRUE, FALSE ) . $title . ' /> ' . esc_attr( $file ) . $folder_size . '</label><br /></nobr>';
133
- }
134
- }
135
- @closedir( $dir );
136
- }
137
- ?>
138
- </fieldset>
139
- </td>
140
- </tr>
141
- <tr>
142
- <th scope="row"><label for="idbackupplugins"><?php _e( 'Backup plugins', 'backwpup' ); ?></label></th>
143
- <td>
144
- <?php
145
- $folder = realpath( WP_PLUGIN_DIR );
146
- if ( $folder ) {
147
- $folder = untrailingslashit( str_replace( '\\', '/', $folder ) );
148
- $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder, FALSE ), 2 ) . ')' : '';
149
- }
150
- ?>
151
- <input class="checkbox"
152
- type="checkbox"<?php checked( BackWPup_Option::get( $main, 'backupplugins' ), TRUE, TRUE );?>
153
- name="backupplugins" id="idbackupplugins" value="1" /> <code title="<?php echo sprintf( __( 'Path as set by user (symlink?): %s', 'backwpup' ), esc_attr( WP_PLUGIN_DIR ) ); ?>"><?php echo esc_attr( $folder ); ?></code><?php echo $folder_size; ?>
154
-
155
- <fieldset id="backuppluginsexcludedirs" style="padding-left:15px; margin:2px;">
156
- <legend><strong><?php _e( 'Exclude:', 'backwpup' ); ?></strong></legend>
157
- <?php
158
- if ( $folder && $dir = @opendir( $folder ) ) {
159
- $excludes = BackWPup_Option::get( $main, 'backuppluginsexcludedirs' );
160
- while ( ( $file = readdir( $dir ) ) !== FALSE ) {
161
- if ( ! in_array( $file, array( '.', '..' ) ) && is_dir( $folder . '/' . $file ) && ! in_array( trailingslashit( $folder . '/' . $file ), $this->get_exclude_dirs( $folder ) ) ) {
162
- $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder . '/' . $file ), 2 ) . ')' : '';
163
- $donotbackup = file_exists( $folder . '/' . $file . '/.donotbackup' );
164
- $title = '';
165
- if ( $donotbackup ) {
166
- $excludes[] = $file;
167
- $title = ' title="' . __( 'Excluded by .donotbackup file!', 'backwpup' ) . '"';
168
- }
169
- echo '<nobr><label for="idpluginexcludedirs-'.sanitize_file_name( $file ).'"><input class="checkbox" type="checkbox"' . checked( in_array( $file, $excludes ), TRUE, FALSE ) . ' name="backuppluginsexcludedirs[]" id="idpluginexcludedirs-'.sanitize_file_name( $file ).'" value="' . $file . '"' . disabled( $donotbackup, TRUE, FALSE ) . $title . ' /> ' . esc_attr( $file ) . $folder_size . '</label><br /></nobr>';
170
- }
171
- }
172
- @closedir( $dir );
173
- }
174
- ?>
175
- </fieldset>
176
- </td>
177
- </tr>
178
- <tr>
179
- <th scope="row"><label for="idbackupthemes"><?php _e( 'Backup themes', 'backwpup' ); ?></label></th>
180
- <td>
181
- <?php
182
- $folder = realpath( get_theme_root() );
183
- if ( $folder ) {
184
- $folder = untrailingslashit( str_replace( '\\', '/', $folder ) );
185
- $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder, FALSE ), 2 ) . ')' : '';
186
- }
187
- ?>
188
- <input class="checkbox"
189
- type="checkbox"<?php checked( BackWPup_Option::get( $main, 'backupthemes' ), TRUE, TRUE );?>
190
- name="backupthemes" id="idbackupthemes" value="1" /> <code title="<?php echo sprintf( __( 'Path as set by user (symlink?): %s', 'backwpup' ), esc_attr( get_theme_root() ) ); ?>"><?php echo esc_attr( $folder ); ?></code><?php echo $folder_size; ?>
191
-
192
- <fieldset id="backupthemesexcludedirs" style="padding-left:15px; margin:2px;">
193
- <legend><strong><?php _e( 'Exclude:', 'backwpup' ); ?></strong></legend>
194
- <?php
195
- if ( $folder && $dir = @opendir( $folder ) ) {
196
- $excludes = BackWPup_Option::get( $main, 'backupthemesexcludedirs' );
197
- while ( ( $file = readdir( $dir ) ) !== FALSE ) {
198
- if ( ! in_array( $file, array( '.', '..' ) ) && is_dir( $folder . '/' . $file ) && ! in_array( trailingslashit( $folder . '/' . $file ), $this->get_exclude_dirs( $folder ) ) ) {
199
- $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder . '/' . $file ), 2 ) . ')' : '';
200
- $donotbackup = file_exists( $folder . '/' . $file . '/.donotbackup' );
201
- $title = '';
202
- if ( $donotbackup ) {
203
- $excludes[] = $file;
204
- $title = ' title="' . __( 'Excluded by .donotbackup file!', 'backwpup' ) . '"';
205
- }
206
- echo '<nobr><label for="idthemesexcludedirs-'.sanitize_file_name( $file ).'"><input class="checkbox" type="checkbox"' . checked( in_array( $file, $excludes ), TRUE, FALSE ) . ' name="backupthemesexcludedirs[]" id="idthemesexcludedirs-'.sanitize_file_name( $file ).'" value="' . $file . '"' . disabled( $donotbackup, TRUE, FALSE ) . $title . ' /> ' . esc_attr( $file ) . $folder_size . '</label><br /></nobr>';
207
- }
208
- }
209
- @closedir( $dir );
210
- }
211
- ?>
212
- </fieldset>
213
- </td>
214
- </tr>
215
- <tr>
216
- <th scope="row"><label for="idbackupuploads"><?php _e( 'Backup uploads folder', 'backwpup' ); ?></label></th>
217
- <td>
218
- <?php
219
- $folder = realpath( BackWPup_File::get_upload_dir() );
220
- if ( $folder ) {
221
- $folder = untrailingslashit( str_replace( '\\', '/', $folder ) );
222
- $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder, FALSE ), 2 ) . ')' : '';
223
- }
224
- ?>
225
- <input class="checkbox"
226
- type="checkbox"<?php checked( BackWPup_Option::get( $main, 'backupuploads' ), TRUE, TRUE );?>
227
- name="backupuploads" id="idbackupuploads" value="1" /> <code title="<?php echo sprintf( __( 'Path as set by user (symlink?): %s', 'backwpup' ), esc_attr( BackWPup_File::get_upload_dir() ) ); ?>"><?php echo esc_html( $folder ); ?></code><?php echo $folder_size; ?>
228
-
229
- <fieldset id="backupuploadsexcludedirs" style="padding-left:15px; margin:2px;">
230
- <legend><strong><?php _e( 'Exclude:', 'backwpup' ); ?></strong></legend>
231
- <?php
232
- if ( $folder && $dir = @opendir( $folder ) ) {
233
- $excludes = BackWPup_Option::get( $main, 'backupuploadsexcludedirs' );
234
- while ( ( $file = readdir( $dir ) ) !== FALSE ) {
235
- if ( ! in_array( $file, array( '.', '..' ) ) && is_dir( $folder . '/' . $file ) && ! in_array( trailingslashit( $folder . '/' . $file ), $this->get_exclude_dirs( $folder ) ) ) {
236
- $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder . '/' . $file ), 2 ) . ')' : '';
237
- $donotbackup = file_exists( $folder . '/' . $file . '/.donotbackup' );
238
- $title = '';
239
- if ( $donotbackup ) {
240
- $excludes[] = $file;
241
- $title = ' title="' . __( 'Excluded by .donotbackup file!', 'backwpup' ) . '"';
242
- }
243
- echo '<nobr><label for="iduploadexcludedirs-'.sanitize_file_name( $file ).'"><input class="checkbox" type="checkbox"' . checked( in_array( $file, $excludes ), TRUE, FALSE ) . ' name="backupuploadsexcludedirs[]" id="iduploadexcludedirs-'.sanitize_file_name( $file ).'" value="' . $file . '"' . disabled( $donotbackup, TRUE, FALSE ) . $title . ' /> ' . esc_attr( $file ) . $folder_size . '</label><br /></nobr>';
244
- }
245
- }
246
- @closedir( $dir );
247
- }
248
- ?>
249
- </fieldset>
250
- </td>
251
- </tr>
252
- <tr>
253
- <th scope="row"><label for="dirinclude"><?php _e( 'Extra folders to backup', 'backwpup' ); ?></label></th>
254
- <td>
255
- <textarea name="dirinclude" id="dirinclude" class="text code help-tip" rows="7" cols="50" title="<?php esc_attr_e( 'Separate folder names with a line-break or a comma. Folders must be set with their absolute path!', 'backwpup' )?>"><?php echo BackWPup_Option::get( $main, 'dirinclude' ); ?></textarea>
256
- </td>
257
- </tr>
258
- </table>
259
-
260
- <h3 class="title"><?php _e( 'Exclude from backup', 'backwpup' ) ?></h3>
261
- <p></p>
262
- <table class="form-table">
263
- <tr>
264
- <th scope="row"><?php _e( 'Thumbnails in uploads', 'backwpup' ); ?></th>
265
- <td>
266
- <label for="idbackupexcludethumbs"><input class="checkbox"
267
- type="checkbox"<?php checked( BackWPup_Option::get( $main, 'backupexcludethumbs' ), TRUE, TRUE );?>
268
- name="backupexcludethumbs" id="idbackupexcludethumbs" value="1" /> <?php _e( 'Don\'t backup thumbnails from the site\'s uploads folder.', 'backwpup' ); BackWPup_Help::add_tab( __( 'All images with -???x???. will be excluded. Use a plugin like Regenerate Thumbnails to rebuild them after a restore.', 'backwpup' ) );?></label>
269
- </td>
270
- </tr>
271
- <tr>
272
- <th scope="row"><label for="idfileexclude"><?php _e( 'Exclude files/folders from backup', 'backwpup' ); ?></label></th>
273
- <td>
274
- <textarea name="fileexclude" id="idfileexclude" class="text code help-tip" rows="7" cols="50" title="<?php esc_attr_e( 'Separate file / folder name parts with a line-break or a comma. For example /logs/,.log,.tmp', 'backwpup' ); ?>"><?php echo BackWPup_Option::get( $main, 'fileexclude' ); ?></textarea>
275
- </td>
276
- </tr>
277
- </table>
278
-
279
- <h3 class="title"><?php _e( 'Special option', 'backwpup' ) ?></h3>
280
- <p></p>
281
- <table class="form-table">
282
- <tr>
283
- <th scope="row"><?php _e( 'Include special files', 'backwpup' ); ?></th>
284
- <td>
285
- <label for="idbackupspecialfiles"><input class="checkbox" id="idbackupspecialfiles"
286
- type="checkbox"<?php checked( BackWPup_Option::get( $main, 'backupspecialfiles' ), TRUE, TRUE );?>
287
- name="backupspecialfiles" value="1" /> <?php _e( 'Backup wp-config.php, robots.txt, .htaccess, .htpasswd and favicon.ico from root.', 'backwpup' ); BackWPup_Help::add_tab( __( 'If the WordPress root folder is not included in this backup job, check this option to additionally include wp-config.php, robots.txt, .htaccess, .htpasswd and favicon.ico into the backup. Your wp-config.php will be included even if you placed it in the parent directory of your root folder.', 'backwpup' ) ); ?></label>
288
- </td>
289
- </tr>
290
- </table>
291
- <?php
292
- }
293
-
294
-
295
- /**
296
- * @param $id
297
- */
298
- public function edit_form_post_save( $id ) {
299
-
300
- $fileexclude = explode( ',', stripslashes( str_replace( array( "\r\n", "\r" ), ',', $_POST[ 'fileexclude' ] ) ) );
301
-
302
- foreach ( $fileexclude as $key => $value ) {
303
- $fileexclude[ $key ] = str_replace( '//', '/', str_replace( '\\', '/', trim( $value ) ) );
304
- if ( empty( $fileexclude[ $key ] ) )
305
- unset( $fileexclude[ $key ] );
306
- }
307
- sort( $fileexclude );
308
- BackWPup_Option::update( $id, 'fileexclude', implode( ',', $fileexclude ) );
309
-
310
- $dirinclude = explode( ',', stripslashes( str_replace( array( "\r\n", "\r" ), ',', $_POST[ 'dirinclude' ] ) ) );
311
- foreach ( $dirinclude as $key => $value ) {
312
- $dirinclude[ $key ] = trailingslashit( str_replace( '//', '/', str_replace( '\\', '/', trim( $value ) ) ) );
313
- if ( $dirinclude[ $key ] == '/' || empty( $dirinclude[ $key ] ) || ! is_dir( $dirinclude[ $key ] ) )
314
- unset( $dirinclude[ $key ] );
315
- }
316
- sort( $dirinclude );
317
- BackWPup_Option::update( $id, 'dirinclude', implode( ',', $dirinclude ) );
318
-
319
- BackWPup_Option::update( $id, 'backupexcludethumbs', ( isset( $_POST[ 'backupexcludethumbs' ] ) && $_POST[ 'backupexcludethumbs' ] == 1 ) ? TRUE : FALSE );
320
- BackWPup_Option::update( $id, 'backupspecialfiles', ( isset( $_POST[ 'backupspecialfiles' ] ) && $_POST[ 'backupspecialfiles' ] == 1 ) ? TRUE : FALSE );
321
- BackWPup_Option::update( $id, 'backuproot', ( isset( $_POST[ 'backuproot' ] ) && $_POST[ 'backuproot' ] == 1 ) ? TRUE : FALSE );
322
-
323
-
324
- if ( ! isset( $_POST[ 'backuprootexcludedirs' ] ) || ! is_array( $_POST[ 'backuprootexcludedirs' ] ) )
325
- $_POST[ 'backuprootexcludedirs' ] = array();
326
- sort( $_POST[ 'backuprootexcludedirs' ] );
327
- BackWPup_Option::update( $id, 'backuprootexcludedirs', $_POST[ 'backuprootexcludedirs' ] );
328
-
329
- BackWPup_Option::update( $id, 'backupcontent', ( isset( $_POST[ 'backupcontent' ] ) && $_POST[ 'backupcontent' ] == 1 ) ? TRUE : FALSE );
330
-
331
- if ( ! isset( $_POST[ 'backupcontentexcludedirs' ] ) || ! is_array( $_POST[ 'backupcontentexcludedirs' ] ) )
332
- $_POST[ 'backupcontentexcludedirs' ] = array();
333
- sort( $_POST[ 'backupcontentexcludedirs' ] );
334
- BackWPup_Option::update( $id, 'backupcontentexcludedirs', $_POST[ 'backupcontentexcludedirs' ] );
335
-
336
- BackWPup_Option::update( $id, 'backupplugins', ( isset( $_POST[ 'backupplugins' ] ) && $_POST[ 'backupplugins' ] == 1 ) ? TRUE : FALSE );
337
-
338
- if ( ! isset( $_POST[ 'backuppluginsexcludedirs' ] ) || ! is_array( $_POST[ 'backuppluginsexcludedirs' ] ) )
339
- $_POST[ 'backuppluginsexcludedirs' ] = array();
340
- sort( $_POST[ 'backuppluginsexcludedirs' ] );
341
- BackWPup_Option::update( $id, 'backuppluginsexcludedirs', $_POST[ 'backuppluginsexcludedirs' ] );
342
-
343
- BackWPup_Option::update( $id, 'backupthemes', ( isset( $_POST[ 'backupthemes' ] ) && $_POST[ 'backupthemes' ] == 1 ) ? TRUE : FALSE );
344
-
345
- if ( ! isset( $_POST[ 'backupthemesexcludedirs' ] ) || ! is_array( $_POST[ 'backupthemesexcludedirs' ] ) )
346
- $_POST[ 'backupthemesexcludedirs' ] = array();
347
- sort( $_POST[ 'backupthemesexcludedirs' ] );
348
- BackWPup_Option::update( $id, 'backupthemesexcludedirs', $_POST[ 'backupthemesexcludedirs' ] );
349
-
350
- BackWPup_Option::update( $id, 'backupuploads', ( isset( $_POST[ 'backupuploads' ] ) && $_POST[ 'backupuploads' ] == 1 ) ? TRUE : FALSE );
351
-
352
- if ( ! isset( $_POST[ 'backupuploadsexcludedirs' ] ) || ! is_array( $_POST[ 'backupuploadsexcludedirs' ] ) )
353
- $_POST[ 'backupuploadsexcludedirs' ] = array();
354
- sort( $_POST[ 'backupuploadsexcludedirs' ] );
355
- BackWPup_Option::update( $id, 'backupuploadsexcludedirs', $_POST[ 'backupuploadsexcludedirs' ] );
356
- }
357
-
358
- /**
359
- * @param $job_object
360
- * @return bool
361
- */
362
- public function job_run( &$job_object ) {
363
-
364
- $job_object->log( sprintf( __( '%d. Trying to make a list of folders to back up&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ) );
365
- $job_object->substeps_todo = 8;
366
-
367
- $job_object->temp[ 'folders_to_backup' ]=array();
368
-
369
- //Folder lists for blog folders
370
- if ( $job_object->substeps_done == 0 ) {
371
- $abs_path = realpath( ABSPATH );
372
- if ( $abs_path && ! empty( $job_object->job[ 'backuproot'] ) ) {
373
- $abs_path = trailingslashit( str_replace( '\\', '/', $abs_path ) );
374
- $excludes = $this->get_exclude_dirs( $abs_path );
375
- foreach( $job_object->job[ 'backuprootexcludedirs' ] as $folder )
376
- $excludes[] = trailingslashit( $abs_path . $folder );
377
- $this->get_folder_list( $job_object, $abs_path, $excludes );
378
- $job_object->add_folders_to_backup( $this->folers_to_backup );
379
- $this->folers_to_backup = array();
380
- }
381
- $job_object->substeps_done = 1;
382
- $job_object->update_working_data();
383
- $job_object->do_restart_time();
384
- }
385
-
386
- if ( $job_object->substeps_done == 1 ) {
387
- $wp_content_dir = realpath( WP_CONTENT_DIR );
388
- if ( $wp_content_dir && ! empty( $job_object->job[ 'backupcontent'] ) ) {
389
- $wp_content_dir = trailingslashit( str_replace( '\\', '/', $wp_content_dir ) );
390
- $excludes = $this->get_exclude_dirs( $wp_content_dir );
391
- foreach( $job_object->job[ 'backupcontentexcludedirs' ] as $folder )
392
- $excludes[] = trailingslashit( $wp_content_dir . $folder );
393
- $this->get_folder_list( $job_object, $wp_content_dir, $excludes );
394
- $job_object->add_folders_to_backup( $this->folers_to_backup );
395
- $this->folers_to_backup = array();
396
- }
397
- $job_object->substeps_done = 2;
398
- $job_object->update_working_data();
399
- $job_object->do_restart_time();
400
- }
401
-
402
- if ( $job_object->substeps_done == 2 ) {
403
- $wp_plugin_dir = realpath( WP_PLUGIN_DIR );
404
- if ( $wp_plugin_dir && ! empty( $job_object->job[ 'backupplugins'] ) ) {
405
- $wp_plugin_dir = trailingslashit( str_replace( '\\', '/', $wp_plugin_dir ) );
406
- $excludes = $this->get_exclude_dirs( $wp_plugin_dir );
407
- foreach( $job_object->job[ 'backuppluginsexcludedirs' ] as $folder )
408
- $excludes[] = trailingslashit( $wp_plugin_dir . $folder );
409
- $this->get_folder_list( $job_object, $wp_plugin_dir, $excludes );
410
- $job_object->add_folders_to_backup( $this->folers_to_backup );
411
- $this->folers_to_backup = array();
412
- }
413
- $job_object->substeps_done = 3;
414
- $job_object->update_working_data();
415
- $job_object->do_restart_time();
416
- }
417
-
418
- if ( $job_object->substeps_done == 3 ) {
419
- $theme_root = realpath( get_theme_root() );
420
- if ( $theme_root && ! empty( $job_object->job[ 'backupthemes'] ) ) {
421
- $theme_root = trailingslashit( str_replace( '\\', '/', $theme_root ) );
422
- $excludes = $this->get_exclude_dirs( $theme_root );
423
- foreach( $job_object->job[ 'backupthemesexcludedirs' ] as $folder )
424
- $excludes[] = trailingslashit( $theme_root . $folder );
425
- $this->get_folder_list( $job_object, $theme_root, $excludes );
426
- $job_object->add_folders_to_backup( $this->folers_to_backup );
427
- $this->folers_to_backup = array();
428
- }
429
- $job_object->substeps_done = 4;
430
- $job_object->update_working_data();
431
- $job_object->do_restart_time();
432
- }
433
-
434
- if( $job_object->substeps_done == 4 ) {
435
- $upload_dir = realpath( BackWPup_File::get_upload_dir() );
436
- if ( $upload_dir && ! empty( $job_object->job[ 'backupuploads'] ) ) {
437
- $upload_dir = trailingslashit( str_replace( '\\', '/', $upload_dir ) );
438
- $excludes = $this->get_exclude_dirs( $upload_dir );
439
- foreach( $job_object->job[ 'backupuploadsexcludedirs' ] as $folder )
440
- $excludes[] = trailingslashit( $upload_dir . $folder );
441
- $this->get_folder_list( $job_object, $upload_dir, $excludes );
442
- $job_object->add_folders_to_backup( $this->folers_to_backup );
443
- $this->folers_to_backup = array();
444
- }
445
- $job_object->substeps_done = 5;
446
- $job_object->update_working_data();
447
- $job_object->do_restart_time();
448
- }
449
-
450
- if( $job_object->substeps_done == 5 ) {
451
- //include dirs
452
- if ( $job_object->job[ 'dirinclude' ] ) {
453
- $dirinclude = explode( ',', $job_object->job[ 'dirinclude' ] );
454
- $dirinclude = array_unique( $dirinclude );
455
- //Crate file list for includes
456
- foreach ( $dirinclude as $dirincludevalue ) {
457
- if ( is_dir( $dirincludevalue ) )
458
- $this->get_folder_list( $job_object, $dirincludevalue );
459
- }
460
- $job_object->add_folders_to_backup( $this->folers_to_backup );
461
- $this->folers_to_backup = array();
462
- }
463
- $job_object->substeps_done = 6;
464
- $job_object->update_working_data();
465
- $job_object->do_restart_time();
466
- }
467
-
468
- if( $job_object->substeps_done == 6 ) {
469
- //clean up folder list
470
- $folders = $job_object->get_folders_to_backup();
471
- $job_object->add_folders_to_backup( $folders, TRUE );
472
- $job_object->update_working_data();
473
- $job_object->do_restart_time();
474
- $job_object->substeps_done = 7;
475
- }
476
-
477
- //add extra files if selected
478
- if ( ! empty( $job_object->job[ 'backupspecialfiles'] ) ) {
479
- if ( is_readable( ABSPATH . 'wp-config.php' ) && empty( $job_object->job[ 'backuproot' ] ) ) {
480
- $job_object->additional_files_to_backup[ ] = str_replace( '\\', '/', ABSPATH . 'wp-config.php' );
481
- $job_object->count_files ++;
482
- $job_object->count_filesize = $job_object->count_filesize + @filesize( ABSPATH . 'wp-config.php' );
483
- $job_object->log( sprintf( __( 'Added "%s" to backup file list', 'backwpup' ), 'wp-config.php' ) );
484
- }
485
- elseif ( BackWPup_File::is_in_open_basedir( dirname( ABSPATH ) . '/wp-config.php' ) ) {
486
- if ( is_readable( dirname( ABSPATH ) . '/wp-config.php' ) && ! is_readable( dirname( ABSPATH ) . '/wp-settings.php' ) ) {
487
- $job_object->additional_files_to_backup[ ] = str_replace( '\\', '/', dirname( ABSPATH ) . '/wp-config.php' );
488
- $job_object->count_files ++;
489
- $job_object->count_filesize = $job_object->count_filesize + @filesize( dirname( ABSPATH ) . '/wp-config.php' );
490
- $job_object->log( sprintf( __( 'Added "%s" to backup file list', 'backwpup' ), 'wp-config.php' ) );
491
- }
492
- }
493
- if ( is_readable( ABSPATH . '.htaccess' ) && empty( $job_object->job[ 'backuproot' ] ) ) {
494
- $job_object->additional_files_to_backup[ ] = str_replace( '\\', '/', ABSPATH . '.htaccess' );
495
- $job_object->count_files ++;
496
- $job_object->count_filesize = $job_object->count_filesize + @filesize( ABSPATH . '.htaccess' );
497
- $job_object->log( sprintf( __( 'Added "%s" to backup file list', 'backwpup' ), '.htaccess' ) );
498
- }
499
- if ( is_readable( ABSPATH . '.htpasswd' ) && empty( $job_object->job[ 'backuproot' ] ) ) {
500
- $job_object->additional_files_to_backup[ ] = str_replace( '\\', '/', ABSPATH . '.htpasswd' );
501
- $job_object->count_files ++;
502
- $job_object->count_filesize = $job_object->count_filesize + @filesize( ABSPATH . '.htpasswd' );
503
- $job_object->log( sprintf( __( 'Added "%s" to backup file list', 'backwpup' ), '.htpasswd' ) );
504
- }
505
- if ( is_readable( ABSPATH . 'robots.txt' ) && empty( $job_object->job[ 'backuproot' ] ) ) {
506
- $job_object->additional_files_to_backup[ ] = str_replace( '\\', '/', ABSPATH . 'robots.txt' );
507
- $job_object->count_files ++;
508
- $job_object->count_filesize = $job_object->count_filesize + @filesize( ABSPATH . 'robots.txt' );
509
- $job_object->log( sprintf( __( 'Added "%s" to backup file list', 'backwpup' ), 'robots.txt' ) );
510
- }
511
- if ( is_readable( ABSPATH . 'favicon.ico' ) && empty( $job_object->job[ 'backuproot' ] ) ) {
512
- $job_object->additional_files_to_backup[ ] = str_replace( '\\', '/', ABSPATH . 'favicon.ico' );
513
- $job_object->count_files ++;
514
- $job_object->count_filesize = $job_object->count_filesize + @filesize( ABSPATH . 'favicon.ico' );
515
- $job_object->log( sprintf( __( 'Added "%s" to backup file list', 'backwpup' ), 'favicon.ico' ) );
516
- }
517
- }
518
-
519
- if ( $job_object->count_folder == 0 && count( $job_object->additional_files_to_backup ) == 0 )
520
- $job_object->log( __( 'No files/folder for the backup.', 'backwpup' ), E_USER_WARNING );
521
- elseif ( $job_object->count_folder > 1 )
522
- $job_object->log( sprintf( __( '%1$d folders to backup.', 'backwpup' ), $job_object->count_folder ) );
523
-
524
- $job_object->substeps_done = 8;
525
-
526
- return TRUE;
527
- }
528
-
529
- /**
530
- *
531
- * Helper function for folder_list()
532
- *
533
- * @param $job_object BackWPup_Job
534
- * @param string $folder
535
- * @param array $excludedirs
536
- *
537
- * @return bool
538
- */
539
- private function get_folder_list( &$job_object, $folder, $excludedirs = array() ) {
540
-
541
- $folder = trailingslashit( $folder );
542
-
543
- if ( $dir = opendir( $folder ) ) {
544
- //add folder to folder list
545
- $this->folers_to_backup[] = $folder;
546
- //scan folder
547
- while ( FALSE !== ( $file = readdir( $dir ) ) ) {
548
- if ( in_array( $file, array( '.', '..' ) ) )
549
- continue;
550
- foreach ( $job_object->exclude_from_backup as $exclusion ) { //exclude files
551
- $exclusion = trim( $exclusion );
552
- if ( FALSE !== stripos( $folder . $file, trim( $exclusion ) ) && ! empty( $exclusion ) )
553
- continue 2;
554
- }
555
- if ( is_dir( $folder . $file ) ) {
556
- if ( in_array( trailingslashit( $folder . $file ), $excludedirs ) )
557
- continue;
558
- if ( @file_exists( trailingslashit( $folder . $file ) . '.donotbackup' ) )
559
- continue;
560
- if ( ! is_readable( $folder . $file ) ) {
561
- $job_object->log( sprintf( __( 'Folder "%s" is not readable!', 'backwpup' ), $folder . $file ), E_USER_WARNING );
562
- continue;
563
- }
564
- $this->get_folder_list( $job_object, trailingslashit( $folder . $file ), $excludedirs );
565
- }
566
- }
567
- closedir( $dir );
568
- }
569
-
570
- return TRUE;
571
- }
572
-
573
-
574
- /**
575
- *
576
- * Get folder to exclude from a given folder for file backups
577
- *
578
- * @param $folder string folder to check for excludes
579
- *
580
- * @return array of folder to exclude
581
- */
582
- private function get_exclude_dirs( $folder ) {
583
-
584
- $folder = trailingslashit( str_replace( '\\', '/', realpath( $folder ) ) );
585
- $excludedir = array();
586
-
587
- if ( FALSE !== strpos( trailingslashit( str_replace( '\\', '/', realpath( ABSPATH ) ) ), $folder ) && trailingslashit( str_replace( '\\', '/', realpath( ABSPATH ) ) ) != $folder )
588
- $excludedir[ ] = trailingslashit( str_replace( '\\', '/', realpath( ABSPATH ) ) );
589
- if ( FALSE !== strpos( trailingslashit( str_replace( '\\', '/', realpath( WP_CONTENT_DIR ) ) ), $folder ) && trailingslashit( str_replace( '\\', '/', realpath( WP_CONTENT_DIR ) ) ) != $folder )
590
- $excludedir[ ] = trailingslashit( str_replace( '\\', '/', realpath( WP_CONTENT_DIR ) ) );
591
- if ( FALSE !== strpos( trailingslashit( str_replace( '\\', '/', realpath( WP_PLUGIN_DIR ) ) ), $folder ) && trailingslashit( str_replace( '\\', '/', realpath( WP_PLUGIN_DIR ) ) ) != $folder )
592
- $excludedir[ ] = trailingslashit( str_replace( '\\', '/', realpath( WP_PLUGIN_DIR ) ) );
593
- if ( FALSE !== strpos( trailingslashit( str_replace( '\\', '/', realpath( get_theme_root() ) ) ), $folder ) && trailingslashit( str_replace( '\\', '/', realpath( get_theme_root() ) ) ) != $folder )
594
- $excludedir[ ] = trailingslashit( str_replace( '\\', '/', realpath( get_theme_root() ) ) );
595
- if ( FALSE !== strpos( trailingslashit( str_replace( '\\', '/', realpath( BackWPup_File::get_upload_dir() ) ) ), $folder ) && trailingslashit( str_replace( '\\', '/', realpath( BackWPup_File::get_upload_dir() ) ) ) != $folder )
596
- $excludedir[ ] = trailingslashit( str_replace( '\\', '/', realpath( BackWPup_File::get_upload_dir() ) ) );
597
-
598
- return array_unique( $excludedir );
599
- }
600
- }
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ class BackWPup_JobType_File extends BackWPup_JobTypes {
6
+
7
+ private $folers_to_backup = array();
8
+
9
+ /**
10
+ *
11
+ */
12
+ public function __construct() {
13
+
14
+ $this->info[ 'ID' ] = 'FILE';
15
+ $this->info[ 'name' ] = __( 'Files', 'backwpup' );
16
+ $this->info[ 'description' ] = __( 'File backup', 'backwpup' );
17
+ $this->info[ 'URI' ] = translate( BackWPup::get_plugin_data( 'PluginURI' ), 'backwpup' );
18
+ $this->info[ 'author' ] = BackWPup::get_plugin_data( 'Author' );
19
+ $this->info[ 'authorURI' ] = translate( BackWPup::get_plugin_data( 'AuthorURI' ), 'backwpup' );
20
+ $this->info[ 'version' ] = BackWPup::get_plugin_data( 'Version' );
21
+
22
+ }
23
+
24
+ /**
25
+ *
26
+ */
27
+ public function admin_print_scripts() {
28
+
29
+ if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
30
+ wp_enqueue_script( 'backwpupjobtypefile', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_edit_jobtype_file.js', array( 'jquery' ), time(), TRUE );
31
+ } else {
32
+ wp_enqueue_script( 'backwpupjobtypefile', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_edit_jobtype_file.min.js', array( 'jquery' ), BackWPup::get_plugin_data( 'Version' ), TRUE );
33
+ }
34
+ }
35
+
36
+ /**
37
+ * @return bool
38
+ */
39
+ public function creates_file() {
40
+
41
+ return TRUE;
42
+ }
43
+
44
+ /**
45
+ * @return array
46
+ */
47
+ public function option_defaults() {
48
+
49
+ return array(
50
+ 'backupexcludethumbs' => FALSE, 'backupspecialfiles' => TRUE,
51
+ 'backuproot' => TRUE, 'backupcontent' => TRUE, 'backupplugins' => TRUE, 'backupthemes' => TRUE, 'backupuploads' => TRUE,
52
+ 'backuprootexcludedirs' => array( 'logs', 'usage' ), 'backupcontentexcludedirs' => array( 'cache', 'upgrade', 'w3tc' ), 'backuppluginsexcludedirs' => array( 'backwpup', 'backwpup-pro' ), 'backupthemesexcludedirs' => array(), 'backupuploadsexcludedirs' => array( basename( get_site_option( 'backwpup_cfg_logfolder' ) ) ),
53
+ 'fileexclude' => '.tmp,.svn,.git,desktop.ini,.DS_Store', 'dirinclude' => ''
54
+ );
55
+ }
56
+
57
+ /**
58
+ * @param $main
59
+ */
60
+ public function edit_tab( $main ) {
61
+
62
+ @set_time_limit( 300 );
63
+ ?>
64
+ <h3 class="title"><?php _e( 'Folders to backup', 'backwpup' ) ?></h3>
65
+ <p></p>
66
+ <table class="form-table">
67
+ <tr>
68
+ <th scope="row"><label for="idbackuproot"><?php _e( 'Backup root folder', 'backwpup' ); ?></label></th>
69
+ <td>
70
+ <?php
71
+ $folder = realpath( ABSPATH );
72
+ if ( $folder ) {
73
+ $folder = untrailingslashit( str_replace( '\\', '/', $folder ) );
74
+ $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder, FALSE ), 2 ) . ')' : '';
75
+ }
76
+ ?>
77
+ <input class="checkbox"
78
+ type="checkbox"<?php checked( BackWPup_Option::get( $main, 'backuproot' ), TRUE, TRUE );?>
79
+ name="backuproot" id="idbackuproot" value="1" /> <code title="<?php echo sprintf( __( 'Path as set by user (symlink?): %s', 'backwpup' ), esc_attr( ABSPATH ) ); ?>"><?php echo esc_attr( $folder ); ?></code><?php echo $folder_size; ?>
80
+
81
+ <fieldset id="backuprootexcludedirs" style="padding-left:15px; margin:2px;">
82
+ <legend><strong><?php _e( 'Exclude:', 'backwpup' ); ?></strong></legend>
83
+ <?php
84
+ if ( $folder && $dir = @opendir( $folder ) ) {
85
+ while ( ( $file = readdir( $dir ) ) !== FALSE ) {
86
+ $excludes = BackWPup_Option::get( $main, 'backuprootexcludedirs' );
87
+ if ( ! in_array( $file, array( '.', '..' ) ) && is_dir( $folder . '/' . $file ) && ! in_array( trailingslashit( $folder . '/' . $file ), $this->get_exclude_dirs( $folder ) ) ) {
88
+ $donotbackup = file_exists( $folder . '/' . $file . '/.donotbackup' );
89
+ $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder . '/' . $file ), 2 ) . ')' : '';
90
+ $title = '';
91
+ if ( $donotbackup ) {
92
+ $excludes[] = $file;
93
+ $title = ' title="' . __( 'Excluded by .donotbackup file!', 'backwpup' ) . '"';
94
+ }
95
+ echo '<nobr><label for="idrootexcludedirs-'.sanitize_file_name( $file ).'"><input class="checkbox" type="checkbox"' . checked( in_array( $file, $excludes ), TRUE, FALSE ) . ' name="backuprootexcludedirs[]" id="idrootexcludedirs-' . sanitize_file_name( $file ) . '" value="' . $file . '"' . disabled( $donotbackup, TRUE, FALSE ) . $title . ' /> ' . esc_attr( $file ) . $folder_size . '</label><br /></nobr>';
96
+ }
97
+ }
98
+ @closedir( $dir );
99
+ }
100
+ ?>
101
+ </fieldset>
102
+ </td>
103
+ </tr>
104
+ <tr>
105
+ <th scope="row"><label for="idbackupcontent"><?php _e( 'Backup content folder', 'backwpup' ); ?></label></th>
106
+ <td>
107
+ <?php
108
+ $folder = realpath( WP_CONTENT_DIR );
109
+ if ( $folder ) {
110
+ $folder = untrailingslashit( str_replace( '\\', '/', $folder ) );
111
+ $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder, FALSE ), 2 ) . ')' : '';
112
+ }
113
+ ?>
114
+ <input class="checkbox"
115
+ type="checkbox"<?php checked( BackWPup_Option::get( $main, 'backupcontent' ), TRUE, TRUE );?>
116
+ name="backupcontent" id="idbackupcontent" value="1" /> <code title="<?php echo sprintf( __( 'Path as set by user (symlink?): %s', 'backwpup' ), esc_attr( WP_CONTENT_DIR ) ); ?>"><?php echo esc_attr( $folder ); ?></code><?php echo $folder_size; ?>
117
+
118
+ <fieldset id="backupcontentexcludedirs" style="padding-left:15px; margin:2px;">
119
+ <legend><strong><?php _e( 'Exclude:', 'backwpup' ); ?></strong></legend>
120
+ <?php
121
+ if ( $folder && $dir = @opendir( $folder ) ) {
122
+ $excludes = BackWPup_Option::get( $main, 'backupcontentexcludedirs' );
123
+ while ( ( $file = readdir( $dir ) ) !== FALSE ) {
124
+ if ( ! in_array( $file, array( '.', '..' ) ) && is_dir( $folder . '/' . $file ) && ! in_array( trailingslashit( $folder . '/' . $file ), $this->get_exclude_dirs( $folder ) ) ) {
125
+ $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder . '/' . $file ), 2 ) . ')' : '';
126
+ $donotbackup = file_exists( $folder . '/' . $file . '/.donotbackup' );
127
+ $title = '';
128
+ if ( $donotbackup ) {
129
+ $excludes[] = $file;
130
+ $title = ' title="' . __( 'Excluded by .donotbackup file!', 'backwpup' ) . '"';
131
+ }
132
+ echo '<nobr><label for="idcontentexcludedirs-'.sanitize_file_name( $file ).'"><input class="checkbox" type="checkbox"' . checked( in_array( $file, $excludes ), TRUE, FALSE ) . ' name="backupcontentexcludedirs[]" id="idcontentexcludedirs-'.sanitize_file_name( $file ).'" value="' . $file . '"' . disabled( $donotbackup, TRUE, FALSE ) . $title . ' /> ' . esc_attr( $file ) . $folder_size . '</label><br /></nobr>';
133
+ }
134
+ }
135
+ @closedir( $dir );
136
+ }
137
+ ?>
138
+ </fieldset>
139
+ </td>
140
+ </tr>
141
+ <tr>
142
+ <th scope="row"><label for="idbackupplugins"><?php _e( 'Backup plugins', 'backwpup' ); ?></label></th>
143
+ <td>
144
+ <?php
145
+ $folder = realpath( WP_PLUGIN_DIR );
146
+ if ( $folder ) {
147
+ $folder = untrailingslashit( str_replace( '\\', '/', $folder ) );
148
+ $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder, FALSE ), 2 ) . ')' : '';
149
+ }
150
+ ?>
151
+ <input class="checkbox"
152
+ type="checkbox"<?php checked( BackWPup_Option::get( $main, 'backupplugins' ), TRUE, TRUE );?>
153
+ name="backupplugins" id="idbackupplugins" value="1" /> <code title="<?php echo sprintf( __( 'Path as set by user (symlink?): %s', 'backwpup' ), esc_attr( WP_PLUGIN_DIR ) ); ?>"><?php echo esc_attr( $folder ); ?></code><?php echo $folder_size; ?>
154
+
155
+ <fieldset id="backuppluginsexcludedirs" style="padding-left:15px; margin:2px;">
156
+ <legend><strong><?php _e( 'Exclude:', 'backwpup' ); ?></strong></legend>
157
+ <?php
158
+ if ( $folder && $dir = @opendir( $folder ) ) {
159
+ $excludes = BackWPup_Option::get( $main, 'backuppluginsexcludedirs' );
160
+ while ( ( $file = readdir( $dir ) ) !== FALSE ) {
161
+ if ( ! in_array( $file, array( '.', '..' ) ) && is_dir( $folder . '/' . $file ) && ! in_array( trailingslashit( $folder . '/' . $file ), $this->get_exclude_dirs( $folder ) ) ) {
162
+ $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder . '/' . $file ), 2 ) . ')' : '';
163
+ $donotbackup = file_exists( $folder . '/' . $file . '/.donotbackup' );
164
+ $title = '';
165
+ if ( $donotbackup ) {
166
+ $excludes[] = $file;
167
+ $title = ' title="' . __( 'Excluded by .donotbackup file!', 'backwpup' ) . '"';
168
+ }
169
+ echo '<nobr><label for="idpluginexcludedirs-'.sanitize_file_name( $file ).'"><input class="checkbox" type="checkbox"' . checked( in_array( $file, $excludes ), TRUE, FALSE ) . ' name="backuppluginsexcludedirs[]" id="idpluginexcludedirs-'.sanitize_file_name( $file ).'" value="' . $file . '"' . disabled( $donotbackup, TRUE, FALSE ) . $title . ' /> ' . esc_attr( $file ) . $folder_size . '</label><br /></nobr>';
170
+ }
171
+ }
172
+ @closedir( $dir );
173
+ }
174
+ ?>
175
+ </fieldset>
176
+ </td>
177
+ </tr>
178
+ <tr>
179
+ <th scope="row"><label for="idbackupthemes"><?php _e( 'Backup themes', 'backwpup' ); ?></label></th>
180
+ <td>
181
+ <?php
182
+ $folder = realpath( get_theme_root() );
183
+ if ( $folder ) {
184
+ $folder = untrailingslashit( str_replace( '\\', '/', $folder ) );
185
+ $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder, FALSE ), 2 ) . ')' : '';
186
+ }
187
+ ?>
188
+ <input class="checkbox"
189
+ type="checkbox"<?php checked( BackWPup_Option::get( $main, 'backupthemes' ), TRUE, TRUE );?>
190
+ name="backupthemes" id="idbackupthemes" value="1" /> <code title="<?php echo sprintf( __( 'Path as set by user (symlink?): %s', 'backwpup' ), esc_attr( get_theme_root() ) ); ?>"><?php echo esc_attr( $folder ); ?></code><?php echo $folder_size; ?>
191
+
192
+ <fieldset id="backupthemesexcludedirs" style="padding-left:15px; margin:2px;">
193
+ <legend><strong><?php _e( 'Exclude:', 'backwpup' ); ?></strong></legend>
194
+ <?php
195
+ if ( $folder && $dir = @opendir( $folder ) ) {
196
+ $excludes = BackWPup_Option::get( $main, 'backupthemesexcludedirs' );
197
+ while ( ( $file = readdir( $dir ) ) !== FALSE ) {
198
+ if ( ! in_array( $file, array( '.', '..' ) ) && is_dir( $folder . '/' . $file ) && ! in_array( trailingslashit( $folder . '/' . $file ), $this->get_exclude_dirs( $folder ) ) ) {
199
+ $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder . '/' . $file ), 2 ) . ')' : '';
200
+ $donotbackup = file_exists( $folder . '/' . $file . '/.donotbackup' );
201
+ $title = '';
202
+ if ( $donotbackup ) {
203
+ $excludes[] = $file;
204
+ $title = ' title="' . __( 'Excluded by .donotbackup file!', 'backwpup' ) . '"';
205
+ }
206
+ echo '<nobr><label for="idthemesexcludedirs-'.sanitize_file_name( $file ).'"><input class="checkbox" type="checkbox"' . checked( in_array( $file, $excludes ), TRUE, FALSE ) . ' name="backupthemesexcludedirs[]" id="idthemesexcludedirs-'.sanitize_file_name( $file ).'" value="' . $file . '"' . disabled( $donotbackup, TRUE, FALSE ) . $title . ' /> ' . esc_attr( $file ) . $folder_size . '</label><br /></nobr>';
207
+ }
208
+ }
209
+ @closedir( $dir );
210
+ }
211
+ ?>
212
+ </fieldset>
213
+ </td>
214
+ </tr>
215
+ <tr>
216
+ <th scope="row"><label for="idbackupuploads"><?php _e( 'Backup uploads folder', 'backwpup' ); ?></label></th>
217
+ <td>
218
+ <?php
219
+ $folder = realpath( BackWPup_File::get_upload_dir() );
220
+ if ( $folder ) {
221
+ $folder = untrailingslashit( str_replace( '\\', '/', $folder ) );
222
+ $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder, FALSE ), 2 ) . ')' : '';
223
+ }
224
+ ?>
225
+ <input class="checkbox"
226
+ type="checkbox"<?php checked( BackWPup_Option::get( $main, 'backupuploads' ), TRUE, TRUE );?>
227
+ name="backupuploads" id="idbackupuploads" value="1" /> <code title="<?php echo sprintf( __( 'Path as set by user (symlink?): %s', 'backwpup' ), esc_attr( BackWPup_File::get_upload_dir() ) ); ?>"><?php echo esc_html( $folder ); ?></code><?php echo $folder_size; ?>
228
+
229
+ <fieldset id="backupuploadsexcludedirs" style="padding-left:15px; margin:2px;">
230
+ <legend><strong><?php _e( 'Exclude:', 'backwpup' ); ?></strong></legend>
231
+ <?php
232
+ if ( $folder && $dir = @opendir( $folder ) ) {
233
+ $excludes = BackWPup_Option::get( $main, 'backupuploadsexcludedirs' );
234
+ while ( ( $file = readdir( $dir ) ) !== FALSE ) {
235
+ if ( ! in_array( $file, array( '.', '..' ) ) && is_dir( $folder . '/' . $file ) && ! in_array( trailingslashit( $folder . '/' . $file ), $this->get_exclude_dirs( $folder ) ) ) {
236
+ $folder_size = ( get_site_option( 'backwpup_cfg_showfoldersize') ) ? ' (' . size_format( BackWPup_File::get_folder_size( $folder . '/' . $file ), 2 ) . ')' : '';
237
+ $donotbackup = file_exists( $folder . '/' . $file . '/.donotbackup' );
238
+ $title = '';
239
+ if ( $donotbackup ) {
240
+ $excludes[] = $file;
241
+ $title = ' title="' . __( 'Excluded by .donotbackup file!', 'backwpup' ) . '"';
242
+ }
243
+ echo '<nobr><label for="iduploadexcludedirs-'.sanitize_file_name( $file ).'"><input class="checkbox" type="checkbox"' . checked( in_array( $file, $excludes ), TRUE, FALSE ) . ' name="backupuploadsexcludedirs[]" id="iduploadexcludedirs-'.sanitize_file_name( $file ).'" value="' . $file . '"' . disabled( $donotbackup, TRUE, FALSE ) . $title . ' /> ' . esc_attr( $file ) . $folder_size . '</label><br /></nobr>';
244
+ }
245
+ }
246
+ @closedir( $dir );
247
+ }
248
+ ?>
249
+ </fieldset>
250
+ </td>
251
+ </tr>
252
+ <tr>
253
+ <th scope="row"><label for="dirinclude"><?php _e( 'Extra folders to backup', 'backwpup' ); ?></label></th>
254
+ <td>
255
+ <textarea name="dirinclude" id="dirinclude" class="text code help-tip" rows="7" cols="50" title="<?php esc_attr_e( 'Separate folder names with a line-break or a comma. Folders must be set with their absolute path!', 'backwpup' )?>"><?php echo BackWPup_Option::get( $main, 'dirinclude' ); ?></textarea>
256
+ </td>
257
+ </tr>
258
+ </table>
259
+
260
+ <h3 class="title"><?php _e( 'Exclude from backup', 'backwpup' ) ?></h3>
261
+ <p></p>
262
+ <table class="form-table">
263
+ <tr>
264
+ <th scope="row"><?php _e( 'Thumbnails in uploads', 'backwpup' ); ?></th>
265
+ <td>
266
+ <label for="idbackupexcludethumbs"><input class="checkbox"
267
+ type="checkbox"<?php checked( BackWPup_Option::get( $main, 'backupexcludethumbs' ), TRUE, TRUE );?>
268
+ name="backupexcludethumbs" id="idbackupexcludethumbs" value="1" /> <?php _e( 'Don\'t backup thumbnails from the site\'s uploads folder.', 'backwpup' ); BackWPup_Help::add_tab( __( 'All images with -???x???. will be excluded. Use a plugin like Regenerate Thumbnails to rebuild them after a restore.', 'backwpup' ) );?></label>
269
+ </td>
270
+ </tr>
271
+ <tr>
272
+ <th scope="row"><label for="idfileexclude"><?php _e( 'Exclude files/folders from backup', 'backwpup' ); ?></label></th>
273
+ <td>
274
+ <textarea name="fileexclude" id="idfileexclude" class="text code help-tip" rows="7" cols="50" title="<?php esc_attr_e( 'Separate file / folder name parts with a line-break or a comma. For example /logs/,.log,.tmp', 'backwpup' ); ?>"><?php echo BackWPup_Option::get( $main, 'fileexclude' ); ?></textarea>
275
+ </td>
276
+ </tr>
277
+ </table>
278
+
279
+ <h3 class="title"><?php _e( 'Special option', 'backwpup' ) ?></h3>
280
+ <p></p>
281
+ <table class="form-table">
282
+ <tr>
283
+ <th scope="row"><?php _e( 'Include special files', 'backwpup' ); ?></th>
284
+ <td>
285
+ <label for="idbackupspecialfiles"><input class="checkbox" id="idbackupspecialfiles"
286
+ type="checkbox"<?php checked( BackWPup_Option::get( $main, 'backupspecialfiles' ), TRUE, TRUE );?>
287
+ name="backupspecialfiles" value="1" /> <?php _e( 'Backup wp-config.php, robots.txt, .htaccess, .htpasswd and favicon.ico from root.', 'backwpup' ); BackWPup_Help::add_tab( __( 'If the WordPress root folder is not included in this backup job, check this option to additionally include wp-config.php, robots.txt, .htaccess, .htpasswd and favicon.ico into the backup. Your wp-config.php will be included even if you placed it in the parent directory of your root folder.', 'backwpup' ) ); ?></label>
288
+ </td>
289
+ </tr>
290
+ </table>
291
+ <?php
292
+ }
293
+
294
+
295
+ /**
296
+ * @param $id
297
+ */
298
+ public function edit_form_post_save( $id ) {
299
+
300
+ $fileexclude = explode( ',', stripslashes( str_replace( array( "\r\n", "\r" ), ',', $_POST[ 'fileexclude' ] ) ) );
301
+
302
+ foreach ( $fileexclude as $key => $value ) {
303
+ $fileexclude[ $key ] = str_replace( '//', '/', str_replace( '\\', '/', trim( $value ) ) );
304
+ if ( empty( $fileexclude[ $key ] ) )
305
+ unset( $fileexclude[ $key ] );
306
+ }
307
+ sort( $fileexclude );
308
+ BackWPup_Option::update( $id, 'fileexclude', implode( ',', $fileexclude ) );
309
+
310
+ $dirinclude = explode( ',', stripslashes( str_replace( array( "\r\n", "\r" ), ',', $_POST[ 'dirinclude' ] ) ) );
311
+ foreach ( $dirinclude as $key => $value ) {
312
+ $dirinclude[ $key ] = trailingslashit( str_replace( '//', '/', str_replace( '\\', '/', trim( $value ) ) ) );
313
+ if ( $dirinclude[ $key ] == '/' || empty( $dirinclude[ $key ] ) || ! is_dir( $dirinclude[ $key ] ) )
314
+ unset( $dirinclude[ $key ] );
315
+ }
316
+ sort( $dirinclude );
317
+ BackWPup_Option::update( $id, 'dirinclude', implode( ',', $dirinclude ) );
318
+
319
+ BackWPup_Option::update( $id, 'backupexcludethumbs', ( isset( $_POST[ 'backupexcludethumbs' ] ) && $_POST[ 'backupexcludethumbs' ] == 1 ) ? TRUE : FALSE );
320
+ BackWPup_Option::update( $id, 'backupspecialfiles', ( isset( $_POST[ 'backupspecialfiles' ] ) && $_POST[ 'backupspecialfiles' ] == 1 ) ? TRUE : FALSE );
321
+ BackWPup_Option::update( $id, 'backuproot', ( isset( $_POST[ 'backuproot' ] ) && $_POST[ 'backuproot' ] == 1 ) ? TRUE : FALSE );
322
+
323
+
324
+ if ( ! isset( $_POST[ 'backuprootexcludedirs' ] ) || ! is_array( $_POST[ 'backuprootexcludedirs' ] ) )
325
+ $_POST[ 'backuprootexcludedirs' ] = array();
326
+ sort( $_POST[ 'backuprootexcludedirs' ] );
327
+ BackWPup_Option::update( $id, 'backuprootexcludedirs', $_POST[ 'backuprootexcludedirs' ] );
328
+
329
+ BackWPup_Option::update( $id, 'backupcontent', ( isset( $_POST[ 'backupcontent' ] ) && $_POST[ 'backupcontent' ] == 1 ) ? TRUE : FALSE );
330
+
331
+ if ( ! isset( $_POST[ 'backupcontentexcludedirs' ] ) || ! is_array( $_POST[ 'backupcontentexcludedirs' ] ) )
332
+ $_POST[ 'backupcontentexcludedirs' ] = array();
333
+ sort( $_POST[ 'backupcontentexcludedirs' ] );
334
+ BackWPup_Option::update( $id, 'backupcontentexcludedirs', $_POST[ 'backupcontentexcludedirs' ] );
335
+
336
+ BackWPup_Option::update( $id, 'backupplugins', ( isset( $_POST[ 'backupplugins' ] ) && $_POST[ 'backupplugins' ] == 1 ) ? TRUE : FALSE );
337
+
338
+ if ( ! isset( $_POST[ 'backuppluginsexcludedirs' ] ) || ! is_array( $_POST[ 'backuppluginsexcludedirs' ] ) )
339
+ $_POST[ 'backuppluginsexcludedirs' ] = array();
340
+ sort( $_POST[ 'backuppluginsexcludedirs' ] );
341
+ BackWPup_Option::update( $id, 'backuppluginsexcludedirs', $_POST[ 'backuppluginsexcludedirs' ] );
342
+
343
+ BackWPup_Option::update( $id, 'backupthemes', ( isset( $_POST[ 'backupthemes' ] ) && $_POST[ 'backupthemes' ] == 1 ) ? TRUE : FALSE );
344
+
345
+ if ( ! isset( $_POST[ 'backupthemesexcludedirs' ] ) || ! is_array( $_POST[ 'backupthemesexcludedirs' ] ) )
346
+ $_POST[ 'backupthemesexcludedirs' ] = array();
347
+ sort( $_POST[ 'backupthemesexcludedirs' ] );
348
+ BackWPup_Option::update( $id, 'backupthemesexcludedirs', $_POST[ 'backupthemesexcludedirs' ] );
349
+
350
+ BackWPup_Option::update( $id, 'backupuploads', ( isset( $_POST[ 'backupuploads' ] ) && $_POST[ 'backupuploads' ] == 1 ) ? TRUE : FALSE );
351
+
352
+ if ( ! isset( $_POST[ 'backupuploadsexcludedirs' ] ) || ! is_array( $_POST[ 'backupuploadsexcludedirs' ] ) )
353
+ $_POST[ 'backupuploadsexcludedirs' ] = array();
354
+ sort( $_POST[ 'backupuploadsexcludedirs' ] );
355
+ BackWPup_Option::update( $id, 'backupuploadsexcludedirs', $_POST[ 'backupuploadsexcludedirs' ] );
356
+ }
357
+
358
+ /**
359
+ * @param $job_object
360
+ * @return bool
361
+ */
362
+ public function job_run( &$job_object ) {
363
+
364
+ $job_object->log( sprintf( __( '%d. Trying to make a list of folders to back up&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ) );
365
+ $job_object->substeps_todo = 8;
366
+
367
+ $job_object->temp[ 'folders_to_backup' ]=array();
368
+
369
+ //Folder lists for blog folders
370
+ if ( $job_object->substeps_done == 0 ) {
371
+ $abs_path = realpath( ABSPATH );
372
+ if ( $abs_path && ! empty( $job_object->job[ 'backuproot'] ) ) {
373
+ $abs_path = trailingslashit( str_replace( '\\', '/', $abs_path ) );
374
+ $excludes = $this->get_exclude_dirs( $abs_path );
375
+ foreach( $job_object->job[ 'backuprootexcludedirs' ] as $folder )
376
+ $excludes[] = trailingslashit( $abs_path . $folder );
377
+ $this->get_folder_list( $job_object, $abs_path, $excludes );
378
+ $job_object->add_folders_to_backup( $this->folers_to_backup );
379
+ $this->folers_to_backup = array();
380
+ }
381
+ $job_object->substeps_done = 1;
382
+ $job_object->update_working_data();
383
+ $job_object->do_restart_time();
384
+ }
385
+
386
+ if ( $job_object->substeps_done == 1 ) {
387
+ $wp_content_dir = realpath( WP_CONTENT_DIR );
388
+ if ( $wp_content_dir && ! empty( $job_object->job[ 'backupcontent'] ) ) {
389
+ $wp_content_dir = trailingslashit( str_replace( '\\', '/', $wp_content_dir ) );
390
+ $excludes = $this->get_exclude_dirs( $wp_content_dir );
391
+ foreach( $job_object->job[ 'backupcontentexcludedirs' ] as $folder )
392
+ $excludes[] = trailingslashit( $wp_content_dir . $folder );
393
+ $this->get_folder_list( $job_object, $wp_content_dir, $excludes );
394
+ $job_object->add_folders_to_backup( $this->folers_to_backup );
395
+ $this->folers_to_backup = array();
396
+ }
397
+ $job_object->substeps_done = 2;
398
+ $job_object->update_working_data();
399
+ $job_object->do_restart_time();
400
+ }
401
+
402
+ if ( $job_object->substeps_done == 2 ) {
403
+ $wp_plugin_dir = realpath( WP_PLUGIN_DIR );
404
+ if ( $wp_plugin_dir && ! empty( $job_object->job[ 'backupplugins'] ) ) {
405
+ $wp_plugin_dir = trailingslashit( str_replace( '\\', '/', $wp_plugin_dir ) );
406
+ $excludes = $this->get_exclude_dirs( $wp_plugin_dir );
407
+ foreach( $job_object->job[ 'backuppluginsexcludedirs' ] as $folder )
408
+ $excludes[] = trailingslashit( $wp_plugin_dir . $folder );
409
+ $this->get_folder_list( $job_object, $wp_plugin_dir, $excludes );
410
+ $job_object->add_folders_to_backup( $this->folers_to_backup );
411
+ $this->folers_to_backup = array();
412
+ }
413
+ $job_object->substeps_done = 3;
414
+ $job_object->update_working_data();
415
+ $job_object->do_restart_time();
416
+ }
417
+
418
+ if ( $job_object->substeps_done == 3 ) {
419
+ $theme_root = realpath( get_theme_root() );
420
+ if ( $theme_root && ! empty( $job_object->job[ 'backupthemes'] ) ) {
421
+ $theme_root = trailingslashit( str_replace( '\\', '/', $theme_root ) );
422
+ $excludes = $this->get_exclude_dirs( $theme_root );
423
+ foreach( $job_object->job[ 'backupthemesexcludedirs' ] as $folder )
424
+ $excludes[] = trailingslashit( $theme_root . $folder );
425
+ $this->get_folder_list( $job_object, $theme_root, $excludes );
426
+ $job_object->add_folders_to_backup( $this->folers_to_backup );
427
+ $this->folers_to_backup = array();
428
+ }
429
+ $job_object->substeps_done = 4;
430
+ $job_object->update_working_data();
431
+ $job_object->do_restart_time();
432
+ }
433
+
434
+ if( $job_object->substeps_done == 4 ) {
435
+ $upload_dir = realpath( BackWPup_File::get_upload_dir() );
436
+ if ( $upload_dir && ! empty( $job_object->job[ 'backupuploads'] ) ) {
437
+ $upload_dir = trailingslashit( str_replace( '\\', '/', $upload_dir ) );
438
+ $excludes = $this->get_exclude_dirs( $upload_dir );
439
+ foreach( $job_object->job[ 'backupuploadsexcludedirs' ] as $folder )
440
+ $excludes[] = trailingslashit( $upload_dir . $folder );
441
+ $this->get_folder_list( $job_object, $upload_dir, $excludes );
442
+ $job_object->add_folders_to_backup( $this->folers_to_backup );
443
+ $this->folers_to_backup = array();
444
+ }
445
+ $job_object->substeps_done = 5;
446
+ $job_object->update_working_data();
447
+ $job_object->do_restart_time();
448
+ }
449
+
450
+ if( $job_object->substeps_done == 5 ) {
451
+ //include dirs
452
+ if ( $job_object->job[ 'dirinclude' ] ) {
453
+ $dirinclude = explode( ',', $job_object->job[ 'dirinclude' ] );
454
+ $dirinclude = array_unique( $dirinclude );
455
+ //Crate file list for includes
456
+ foreach ( $dirinclude as $dirincludevalue ) {
457
+ if ( is_dir( $dirincludevalue ) )
458
+ $this->get_folder_list( $job_object, $dirincludevalue );
459
+ }
460
+ $job_object->add_folders_to_backup( $this->folers_to_backup );
461
+ $this->folers_to_backup = array();
462
+ }
463
+ $job_object->substeps_done = 6;
464
+ $job_object->update_working_data();
465
+ $job_object->do_restart_time();
466
+ }
467
+
468
+ if( $job_object->substeps_done == 6 ) {
469
+ //clean up folder list
470
+ $folders = $job_object->get_folders_to_backup();
471
+ $job_object->add_folders_to_backup( $folders, TRUE );
472
+ $job_object->update_working_data();
473
+ $job_object->do_restart_time();
474
+ $job_object->substeps_done = 7;
475
+ }
476
+
477
+ //add extra files if selected
478
+ if ( ! empty( $job_object->job[ 'backupspecialfiles'] ) ) {
479
+ if ( is_readable( ABSPATH . 'wp-config.php' ) && empty( $job_object->job[ 'backuproot' ] ) ) {
480
+ $job_object->additional_files_to_backup[ ] = str_replace( '\\', '/', ABSPATH . 'wp-config.php' );
481
+ $job_object->count_files ++;
482
+ $job_object->count_filesize = $job_object->count_filesize + filesize( ABSPATH . 'wp-config.php' );
483
+ $job_object->log( sprintf( __( 'Added "%s" to backup file list', 'backwpup' ), 'wp-config.php' ) );
484
+ }
485
+ elseif ( BackWPup_File::is_in_open_basedir( dirname( ABSPATH ) . '/wp-config.php' ) ) {
486
+ if ( is_readable( dirname( ABSPATH ) . '/wp-config.php' ) && ! is_readable( dirname( ABSPATH ) . '/wp-settings.php' ) ) {
487
+ $job_object->additional_files_to_backup[ ] = str_replace( '\\', '/', dirname( ABSPATH ) . '/wp-config.php' );
488
+ $job_object->count_files ++;
489
+ $job_object->count_filesize = $job_object->count_filesize + filesize( dirname( ABSPATH ) . '/wp-config.php' );
490
+ $job_object->log( sprintf( __( 'Added "%s" to backup file list', 'backwpup' ), 'wp-config.php' ) );
491
+ }
492
+ }
493
+ if ( is_readable( ABSPATH . '.htaccess' ) && empty( $job_object->job[ 'backuproot' ] ) ) {
494
+ $job_object->additional_files_to_backup[ ] = str_replace( '\\', '/', ABSPATH . '.htaccess' );
495
+ $job_object->count_files ++;
496
+ $job_object->count_filesize = $job_object->count_filesize + filesize( ABSPATH . '.htaccess' );
497
+ $job_object->log( sprintf( __( 'Added "%s" to backup file list', 'backwpup' ), '.htaccess' ) );
498
+ }
499
+ if ( is_readable( ABSPATH . '.htpasswd' ) && empty( $job_object->job[ 'backuproot' ] ) ) {
500
+ $job_object->additional_files_to_backup[ ] = str_replace( '\\', '/', ABSPATH . '.htpasswd' );
501
+ $job_object->count_files ++;
502
+ $job_object->count_filesize = $job_object->count_filesize + filesize( ABSPATH . '.htpasswd' );
503
+ $job_object->log( sprintf( __( 'Added "%s" to backup file list', 'backwpup' ), '.htpasswd' ) );
504
+ }
505
+ if ( is_readable( ABSPATH . 'robots.txt' ) && empty( $job_object->job[ 'backuproot' ] ) ) {
506
+ $job_object->additional_files_to_backup[ ] = str_replace( '\\', '/', ABSPATH . 'robots.txt' );
507
+ $job_object->count_files ++;
508
+ $job_object->count_filesize = $job_object->count_filesize + filesize( ABSPATH . 'robots.txt' );
509
+ $job_object->log( sprintf( __( 'Added "%s" to backup file list', 'backwpup' ), 'robots.txt' ) );
510
+ }
511
+ if ( is_readable( ABSPATH . 'favicon.ico' ) && empty( $job_object->job[ 'backuproot' ] ) ) {
512
+ $job_object->additional_files_to_backup[ ] = str_replace( '\\', '/', ABSPATH . 'favicon.ico' );
513
+ $job_object->count_files ++;
514
+ $job_object->count_filesize = $job_object->count_filesize + filesize( ABSPATH . 'favicon.ico' );
515
+ $job_object->log( sprintf( __( 'Added "%s" to backup file list', 'backwpup' ), 'favicon.ico' ) );
516
+ }
517
+ }
518
+
519
+ if ( $job_object->count_folder == 0 && count( $job_object->additional_files_to_backup ) == 0 )
520
+ $job_object->log( __( 'No files/folder for the backup.', 'backwpup' ), E_USER_WARNING );
521
+ elseif ( $job_object->count_folder > 1 )
522
+ $job_object->log( sprintf( __( '%1$d folders to backup.', 'backwpup' ), $job_object->count_folder ) );
523
+
524
+ $job_object->substeps_done = 8;
525
+
526
+ return TRUE;
527
+ }
528
+
529
+ /**
530
+ *
531
+ * Helper function for folder_list()
532
+ *
533
+ * @param $job_object BackWPup_Job
534
+ * @param string $folder
535
+ * @param array $excludedirs
536
+ *
537
+ * @return bool
538
+ */
539
+ private function get_folder_list( &$job_object, $folder, $excludedirs = array() ) {
540
+
541
+ $folder = trailingslashit( $folder );
542
+
543
+ if ( $dir = opendir( $folder ) ) {
544
+ //add folder to folder list
545
+ $this->folers_to_backup[] = $folder;
546
+ //scan folder
547
+ while ( FALSE !== ( $file = readdir( $dir ) ) ) {
548
+ if ( in_array( $file, array( '.', '..' ) ) )
549
+ continue;
550
+ foreach ( $job_object->exclude_from_backup as $exclusion ) { //exclude files
551
+ $exclusion = trim( $exclusion );
552
+ if ( FALSE !== stripos( $folder . $file, trim( $exclusion ) ) && ! empty( $exclusion ) )
553
+ continue 2;
554
+ }
555
+ if ( is_dir( $folder . $file ) ) {
556
+ if ( in_array( trailingslashit( $folder . $file ), $excludedirs ) )
557
+ continue;
558
+ if ( @file_exists( trailingslashit( $folder . $file ) . '.donotbackup' ) )
559
+ continue;
560
+ if ( ! is_readable( $folder . $file ) ) {
561
+ $job_object->log( sprintf( __( 'Folder "%s" is not readable!', 'backwpup' ), $folder . $file ), E_USER_WARNING );
562
+ continue;
563
+ }
564
+ $this->get_folder_list( $job_object, trailingslashit( $folder . $file ), $excludedirs );
565
+ }
566
+ }
567
+ closedir( $dir );
568
+ }
569
+
570
+ return TRUE;
571
+ }
572
+
573
+
574
+ /**
575
+ *
576
+ * Get folder to exclude from a given folder for file backups
577
+ *
578
+ * @param $folder string folder to check for excludes
579
+ *
580
+ * @return array of folder to exclude
581
+ */
582
+ private function get_exclude_dirs( $folder ) {
583
+
584
+ $folder = trailingslashit( str_replace( '\\', '/', realpath( $folder ) ) );
585
+ $excludedir = array();
586
+
587
+ if ( FALSE !== strpos( trailingslashit( str_replace( '\\', '/', realpath( ABSPATH ) ) ), $folder ) && trailingslashit( str_replace( '\\', '/', realpath( ABSPATH ) ) ) != $folder )
588
+ $excludedir[ ] = trailingslashit( str_replace( '\\', '/', realpath( ABSPATH ) ) );
589
+ if ( FALSE !== strpos( trailingslashit( str_replace( '\\', '/', realpath( WP_CONTENT_DIR ) ) ), $folder ) && trailingslashit( str_replace( '\\', '/', realpath( WP_CONTENT_DIR ) ) ) != $folder )
590
+ $excludedir[ ] = trailingslashit( str_replace( '\\', '/', realpath( WP_CONTENT_DIR ) ) );
591
+ if ( FALSE !== strpos( trailingslashit( str_replace( '\\', '/', realpath( WP_PLUGIN_DIR ) ) ), $folder ) && trailingslashit( str_replace( '\\', '/', realpath( WP_PLUGIN_DIR ) ) ) != $folder )
592
+ $excludedir[ ] = trailingslashit( str_replace( '\\', '/', realpath( WP_PLUGIN_DIR ) ) );
593
+ if ( FALSE !== strpos( trailingslashit( str_replace( '\\', '/', realpath( get_theme_root() ) ) ), $folder ) && trailingslashit( str_replace( '\\', '/', realpath( get_theme_root() ) ) ) != $folder )
594
+ $excludedir[ ] = trailingslashit( str_replace( '\\', '/', realpath( get_theme_root() ) ) );
595
+ if ( FALSE !== strpos( trailingslashit( str_replace( '\\', '/', realpath( BackWPup_File::get_upload_dir() ) ) ), $folder ) && trailingslashit( str_replace( '\\', '/', realpath( BackWPup_File::get_upload_dir() ) ) ) != $folder )
596
+ $excludedir[ ] = trailingslashit( str_replace( '\\', '/', realpath( BackWPup_File::get_upload_dir() ) ) );
597
+
598
+ return array_unique( $excludedir );
599
+ }
600
+ }
inc/class-jobtype-wpexp.php CHANGED
@@ -4,11 +4,6 @@
4
  */
5
  class BackWPup_JobType_WPEXP extends BackWPup_JobTypes {
6
 
7
- /**
8
- * @var $job_object BackWPup_Job
9
- */
10
- private $job_object = null;
11
-
12
  /**
13
  *
14
  */
@@ -52,8 +47,8 @@ class BackWPup_JobType_WPEXP extends BackWPup_JobTypes {
52
  <td>
53
  <fieldset>
54
  <label for="idwpexportcontent-all"><input type="radio" name="wpexportcontent" id="idwpexportcontent-all" value="all" <?php checked( BackWPup_Option::get( $jobid, 'wpexportcontent' ), 'all' ); ?> /> <?php _e( 'All content', 'backwpup' ); ?></label><br />
55
- <label for="idwpexportcontent-posts"><input type="radio" name="wpexportcontent" id="idwpexportcontent-posts" value="posts" <?php checked( BackWPup_Option::get( $jobid, 'wpexportcontent' ), 'posts' ); ?> /> <?php _e( 'Posts', 'backwpup' ); ?></label><br />
56
- <label for="idwpexportcontent-pages"><input type="radio" name="wpexportcontent" id="idwpexportcontent-pages" value="pages" <?php checked( BackWPup_Option::get( $jobid, 'wpexportcontent' ), 'pages' ); ?> /> <?php _e( 'Pages', 'backwpup' ); ?></label><br />
57
  <?php
58
  foreach ( get_post_types( array( '_builtin' => FALSE, 'can_export' => TRUE ), 'objects' ) as $post_type ) {
59
  ?>
@@ -98,7 +93,7 @@ class BackWPup_JobType_WPEXP extends BackWPup_JobTypes {
98
  public function edit_form_post_save( $id ) {
99
 
100
  BackWPup_Option::update( $id, 'wpexportcontent', $_POST[ 'wpexportcontent' ] );
101
- BackWPup_Option::update( $id, 'wpexportfile', $_POST[ 'wpexportfile' ] );
102
  if ( $_POST[ 'wpexportfilecompression' ] == '' || $_POST[ 'wpexportfilecompression' ] == '.gz' || $_POST[ 'wpexportfilecompression' ] == '.bz2' )
103
  BackWPup_Option::update( $id, 'wpexportfilecompression', $_POST[ 'wpexportfilecompression' ] );
104
  }
@@ -108,167 +103,617 @@ class BackWPup_JobType_WPEXP extends BackWPup_JobTypes {
108
  * @return bool
109
  */
110
  public function job_run( &$job_object ) {
 
 
 
 
 
 
 
 
 
 
 
 
111
 
112
- $job_object->substeps_todo = 2;
113
 
114
- $job_object->log( sprintf( __( '%d. Trying to create a WordPress export to XML file&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ) );
115
- //build filename
116
- $job_object->temp[ 'wpexportfile' ] = $job_object->generate_filename( $job_object->job[ 'wpexportfile' ], 'xml' );
117
 
118
- //check export file for writing
119
- if ( ! touch( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'wpexportfile' ] ) ) {
120
- $job_object->log( __( 'WP Export file could not generated.', 'backwpup' ), E_USER_ERROR );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
 
122
- return FALSE;
 
 
 
 
 
 
123
  }
124
- //include WP export function
125
- $this->job_object = &$job_object;
126
- $this->job_object->temp[ 'wp_export_part' ] = 0;
127
- require_once ABSPATH . 'wp-admin/includes/export.php';
128
- ob_start( array( $this, 'ob_callback' ), 1024 * 1024 ); //start output buffering
129
- $args = array(
130
- 'content' => $job_object->job[ 'wpexportcontent' ]
131
- );
132
- @export_wp( $args ); //WP export
133
- ob_end_clean(); //End output buffering
134
-
135
-
136
- if ( filesize( BackWPup::get_plugin_data( 'TEMP' ) . $this->job_object->temp[ 'wpexportfile' ] ) < 1500 ) {
137
- $job_object->log( __( 'Could not generate a WordPress export file.', 'backwpup' ), E_USER_ERROR );
138
-
139
- return FALSE;
140
  }
141
 
142
- if ( extension_loaded( 'simplexml' ) && class_exists( 'DOMDocument' ) ) {
143
- $job_object->log( __( 'Check WP Export file&#160;&hellip;', 'backwpup' ) );
144
- $job_object->need_free_memory( filesize( BackWPup::get_plugin_data( 'TEMP' ) . $this->job_object->temp[ 'wpexportfile' ] ) * 2 );
145
- $valid = TRUE;
146
-
147
- $internal_errors = libxml_use_internal_errors( TRUE );
148
- $dom = new DOMDocument;
149
- $old_value = NULL;
150
- if ( function_exists( 'libxml_disable_entity_loader' ) )
151
- $old_value = libxml_disable_entity_loader( TRUE );
152
- $success = $dom->loadXML( file_get_contents( BackWPup::get_plugin_data( 'TEMP' ) . $this->job_object->temp[ 'wpexportfile' ] ) );
153
- if ( ! is_null( $old_value ) )
154
- libxml_disable_entity_loader( $old_value );
155
-
156
- if ( ! $success || isset( $dom->doctype ) ) {
157
- $errors = libxml_get_errors();
158
- $valid = FALSE;
159
-
160
- foreach ( $errors as $error ) {
161
- switch ( $error->level ) {
162
- case LIBXML_ERR_WARNING:
163
- $job_object->log( E_USER_WARNING, sprintf( __( 'XML WARNING (%s): %s', 'backwpup' ), $error->code, trim( $error->message ) ), BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'wpexportfile' ], $error->line );
164
- break;
165
- case LIBXML_ERR_ERROR:
166
- $job_object->log( E_USER_WARNING, sprintf( __( 'XML RECOVERABLE (%s): %s', 'backwpup' ), $error->code, trim( $error->message ) ), BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'wpexportfile' ], $error->line );
167
- break;
168
- case LIBXML_ERR_FATAL:
169
- $job_object->log( E_USER_WARNING, sprintf( __( 'XML ERROR (%s): %s', 'backwpup' ),$error->code, trim( $error->message ) ), BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'wpexportfile' ], $error->line );
170
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  }
 
 
 
 
 
 
 
172
  }
173
- } else {
174
- $xml = simplexml_import_dom( $dom );
175
- unset( $dom );
 
 
 
 
 
 
 
 
 
 
 
176
 
177
- // halt if loading produces an error
178
- if ( ! $xml ) {
179
- $job_object->log( __( 'There was an error when reading this WXR file', 'backwpup' ), E_USER_ERROR );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  $valid = FALSE;
181
- } else {
182
 
183
- $wxr_version = $xml->xpath('/rss/channel/wp:wxr_version');
184
- if ( ! $wxr_version ) {
185
- $job_object->log( __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'backwpup' ), E_USER_ERROR );
186
- $valid = FALSE;
 
 
 
 
 
 
 
 
187
  }
 
 
 
188
 
189
- $wxr_version = (string) trim( $wxr_version[0] );
190
- // confirm that we are dealing with the correct file format
191
- if ( ! preg_match( '/^\d+\.\d+$/', $wxr_version ) ) {
192
- $job_object->log( __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'backwpup' ), E_USER_ERROR );
193
  $valid = FALSE;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  }
195
  }
196
- }
197
 
198
- libxml_use_internal_errors( $internal_errors );
199
 
200
- if ( $valid )
201
- $job_object->log( __( 'WP Export file is a valid WXR file.', 'backwpup' ) );
202
- } else {
203
- $job_object->log( __( 'WP Export file can not checked, because no XML extension loaded with the file can checked.', 'backwpup' ) );
204
- }
205
 
206
- $job_object->substeps_done ++;
 
 
 
 
207
 
208
  //Compress file
209
- if ( ! empty( $job_object->job[ 'wpexportfilecompression' ] ) ) {
210
- $job_object->log( __( 'Compressing file&#160;&hellip;', 'backwpup' ) );
211
- try {
212
- $compress = new BackWPup_Create_Archive( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'wpexportfile' ] . $job_object->job[ 'wpexportfilecompression' ] );
213
- if ( $compress->add_file( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'wpexportfile' ] ) ) {
 
 
 
 
 
 
 
 
214
  unset( $compress );
215
- unlink( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'wpexportfile' ] );
216
- $job_object->temp[ 'wpexportfile' ] .= $job_object->job[ 'wpexportfilecompression' ];
217
- $job_object->log( __( 'Compressing done.', 'backwpup' ) );
218
  }
219
- } catch ( Exception $e ) {
220
- $job_object->log( $e->getMessage(), E_USER_ERROR, $e->getFile(), $e->getLine() );
221
- unset( $compress );
222
- return FALSE;
223
  }
 
 
 
 
224
  }
225
- $job_object->substeps_done ++;
226
-
227
- //add XML file to backup files
228
- if ( is_readable( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'wpexportfile' ] ) ) {
229
- $job_object->additional_files_to_backup[ ] = BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'wpexportfile' ];
230
- $job_object->count_files ++;
231
- $job_object->count_filesize = $job_object->count_filesize + @filesize( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'wpexportfile' ] );
232
- $job_object->log( sprintf( __( 'Added XML export "%1$s" with %2$s to backup file list.', 'backwpup' ), $job_object->temp[ 'wpexportfile' ], size_format( filesize( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'wpexportfile' ] ), 2 ) ) );
 
 
 
 
233
  }
234
- $job_object->substeps_done = 1;
235
 
236
  return TRUE;
237
  }
238
 
239
  /**
240
- * Callback for ob buffer of xml file
 
 
241
  *
242
- * @param $buffer string the buffer
 
243
  */
244
- public function ob_callback( $buffer ) {
 
 
245
 
246
  // not allowed UTF-8 chars in XML
247
- $buffer = preg_replace( '/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', '', $buffer );
248
 
249
- // chop not needed from first part
250
- if ( empty( $this->job_object->temp[ 'wp_export_part' ] ) ) {
251
- $start_pos = strpos( $buffer, '<?xml' );
252
- if ( ! empty( $start_pos ) )
253
- $buffer = substr( $buffer, $start_pos );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  }
255
 
256
- // chop not needed from last part
257
- if ( strlen( $buffer ) < 1024 * 1024 ) {
258
- $end_pos = strpos( $buffer, '</rss>' );
259
- if ( !empty( $end_pos ) )
260
- $buffer = substr( $buffer, 0, $end_pos + 6 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
  }
262
 
263
- // write buffer to export file
264
- if ( ! empty( $buffer ) ) {
265
- if ( FALSE === file_put_contents( BackWPup::get_plugin_data( 'TEMP' ) . $this->job_object->temp[ 'wpexportfile' ], $buffer, FILE_APPEND ) ) {
266
- $this->job_object->log( __( 'WP Export file could not be written.', 'backwpup' ), E_USER_ERROR );
267
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  }
269
 
270
- $this->job_object->temp[ 'wp_export_part' ] ++;
271
- $this->job_object->update_working_data();
272
  }
273
 
 
 
 
 
 
 
 
 
274
  }
4
  */
5
  class BackWPup_JobType_WPEXP extends BackWPup_JobTypes {
6
 
 
 
 
 
 
7
  /**
8
  *
9
  */
47
  <td>
48
  <fieldset>
49
  <label for="idwpexportcontent-all"><input type="radio" name="wpexportcontent" id="idwpexportcontent-all" value="all" <?php checked( BackWPup_Option::get( $jobid, 'wpexportcontent' ), 'all' ); ?> /> <?php _e( 'All content', 'backwpup' ); ?></label><br />
50
+ <label for="idwpexportcontent-post"><input type="radio" name="wpexportcontent" id="idwpexportcontent-post" value="post" <?php checked( BackWPup_Option::get( $jobid, 'wpexportcontent' ), 'post' ); ?> /> <?php _e( 'Posts', 'backwpup' ); ?></label><br />
51
+ <label for="idwpexportcontent-page"><input type="radio" name="wpexportcontent" id="idwpexportcontent-page" value="page" <?php checked( BackWPup_Option::get( $jobid, 'wpexportcontent' ), 'page' ); ?> /> <?php _e( 'Pages', 'backwpup' ); ?></label><br />
52
  <?php
53
  foreach ( get_post_types( array( '_builtin' => FALSE, 'can_export' => TRUE ), 'objects' ) as $post_type ) {
54
  ?>
93
  public function edit_form_post_save( $id ) {
94
 
95
  BackWPup_Option::update( $id, 'wpexportcontent', $_POST[ 'wpexportcontent' ] );
96
+ BackWPup_Option::update( $id, 'wpexportfile', sanitize_file_name( $_POST[ 'wpexportfile' ] ) );
97
  if ( $_POST[ 'wpexportfilecompression' ] == '' || $_POST[ 'wpexportfilecompression' ] == '.gz' || $_POST[ 'wpexportfilecompression' ] == '.bz2' )
98
  BackWPup_Option::update( $id, 'wpexportfilecompression', $_POST[ 'wpexportfilecompression' ] );
99
  }
103
  * @return bool
104
  */
105
  public function job_run( &$job_object ) {
106
+ global $wpdb, $post, $wp_query;
107
+
108
+ $wxr_version = '1.2';
109
+
110
+ if ( $job_object->steps_data[ $job_object->step_working ]['SAVE_STEP_TRY'] != $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ) {
111
+ $job_object->log( sprintf( __( '%d. Trying to create a WordPress export to XML file&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ) );
112
+ $job_object->steps_data[ $job_object->step_working ]['wpexportfile'] = BackWPup::get_plugin_data( 'TEMP' ) . $job_object->generate_filename( $job_object->job[ 'wpexportfile' ], 'xml', TRUE );
113
+ $job_object->steps_data[ $job_object->step_working ]['substep'] = 'header';
114
+ $job_object->steps_data[ $job_object->step_working ]['post_ids'] = array();
115
+ $job_object->substeps_todo = 10;
116
+ $job_object->substeps_done = 0;
117
+ }
118
 
119
+ add_filter( 'wxr_export_skip_postmeta', array( $this, 'wxr_filter_postmeta' ), 10, 2 );
120
 
121
+ if ( $job_object->steps_data[ $job_object->step_working ]['substep'] == 'header' ) {
 
 
122
 
123
+ if ( 'all' != $job_object->job[ 'wpexportcontent' ] && post_type_exists( $job_object->job[ 'wpexportcontent' ] ) ) {
124
+ $ptype = get_post_type_object( $job_object->job[ 'wpexportcontent' ] );
125
+ if ( ! $ptype->can_export ) {
126
+ $job_object->log( sprintf( __( 'WP Export: Post type “%s” does not allow export.', 'backwpup' ), $job_object->job[ 'wpexportcontent' ] ), E_USER_ERROR );
127
+ return FALSE;
128
+ }
129
+ $where = $wpdb->prepare( "{$wpdb->posts}.post_type = %s", $job_object->job[ 'wpexportcontent' ] );
130
+ } else {
131
+ $post_types = get_post_types( array( 'can_export' => true ) );
132
+ $esses = array_fill( 0, count($post_types), '%s' );
133
+ $where = $wpdb->prepare( "{$wpdb->posts}.post_type IN (" . implode( ',', $esses ) . ')', $post_types );
134
+ $job_object->job[ 'wpexportcontent' ] = 'all';
135
+ }
136
+ $where .= " AND {$wpdb->posts}.post_status != 'auto-draft'";
137
+
138
+ // grab a snapshot of post IDs, just in case it changes during the export
139
+ $job_object->steps_data[ $job_object->step_working ]['post_ids'] = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE $where" );
140
+ $job_object->substeps_todo = $job_object->substeps_todo + count( $job_object->steps_data[ $job_object->step_working ]['post_ids'] );
141
+
142
+ $header = '<?xml version="1.0" encoding="' . get_bloginfo('charset') . "\" ?>\n";
143
+ $header .= "<!-- This is a WordPress eXtended RSS file generated by the WordPress plugin BackWPup as an export of your site. -->\n";
144
+ $header .= "<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->\n";
145
+ $header .= "<!-- You may use this file to transfer that content from one site to another. -->\n";
146
+ $header .= "<!-- This file is not intended to serve as a complete backup of your site. -->\n\n";
147
+ $header .= "<!-- To import this information into a WordPress site follow these steps: -->\n";
148
+ $header .= "<!-- 1. Log in to that site as an administrator. -->\n";
149
+ $header .= "<!-- 2. Go to Tools: Import in the WordPress admin panel. -->\n";
150
+ $header .= "<!-- 3. Install the \"WordPress\" importer from the list. -->\n";
151
+ $header .= "<!-- 4. Activate & Run Importer. -->\n";
152
+ $header .= "<!-- 5. Upload this file using the form provided on that page. -->\n";
153
+ $header .= "<!-- 6. You will first be asked to map the authors in this export file to users -->\n";
154
+ $header .= "<!-- on the site. For each author, you may choose to map to an -->\n";
155
+ $header .= "<!-- existing user on the site or to create a new user. -->\n";
156
+ $header .= "<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->\n";
157
+ $header .= "<!-- contained in this file into your site. -->\n\n";
158
+ $header .= "<!-- generator=\"WordPress/" . get_bloginfo_rss('version') . "\" created=\"". date('Y-m-d H:i') . "\" -->\n";
159
+ $header .= "<rss version=\"2.0\" xmlns:excerpt=\"http://wordpress.org/export/$wxr_version/excerpt/\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\" xmlns:wfw=\"http://wellformedweb.org/CommentAPI/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:wp=\"http://wordpress.org/export/$wxr_version/\">\n";
160
+ $header .= "<channel>\n";
161
+ $header .= "\t<title>" . get_bloginfo_rss( 'name' ) ."</title>\n";
162
+ $header .= "\t<link>" . get_bloginfo_rss( 'url' ) ."</link>\n";
163
+ $header .= "\t<description>" . get_bloginfo_rss( 'description' ) ."</description>\n";
164
+ $header .= "\t<pubDate>" . date( 'D, d M Y H:i:s +0000' ) ."</pubDate>\n";
165
+ $header .= "\t<language>" . get_bloginfo_rss( 'language' ) ."</language>\n";
166
+ $header .= "\t<wp:wxr_version>" . $wxr_version ."</wp:wxr_version>\n";
167
+ $header .= "\t<wp:base_site_url>" . $this->wxr_site_url() ."</wp:base_site_url>\n";
168
+ $header .= "\t<wp:base_blog_url>" . get_bloginfo_rss( 'url' ) ."</wp:base_blog_url>\n";
169
+ $written = file_put_contents( $job_object->steps_data[ $job_object->step_working ][ 'wpexportfile' ], $header, FILE_APPEND );
170
+ if ( $written === FALSE ) {
171
+ $job_object->log( __( 'WP Export file could not written.', 'backwpup' ), E_USER_ERROR );
172
 
173
+ return FALSE;
174
+ }
175
+ unset( $header );
176
+ $job_object->steps_data[ $job_object->step_working ]['substep'] = 'authors';
177
+ $job_object->substeps_done ++;
178
+ $job_object->update_working_data();
179
+ $job_object->do_restart_time();
180
  }
181
+
182
+ if ( $job_object->steps_data[ $job_object->step_working ]['substep'] == 'authors' ) {
183
+ $written = file_put_contents( $job_object->steps_data[ $job_object->step_working ][ 'wpexportfile' ], $this->wxr_authors_list(), FILE_APPEND );
184
+ if ( $written === FALSE ) {
185
+ $job_object->log( __( 'WP Export file could not written.', 'backwpup' ), E_USER_ERROR );
186
+
187
+ return FALSE;
188
+ }
189
+ $job_object->steps_data[ $job_object->step_working ]['substep'] = 'cats';
190
+ $job_object->substeps_done ++;
191
+ $job_object->update_working_data();
192
+ $job_object->do_restart_time();
 
 
 
 
193
  }
194
 
195
+
196
+ if ( $job_object->steps_data[ $job_object->step_working ]['substep'] == 'cats' ) {
197
+ if ( 'all' == $job_object->job[ 'wpexportcontent' ] ) {
198
+ $cats = array();
199
+ $categories = (array) get_categories( array( 'get' => 'all' ) );
200
+ // put categories in order with no child going before its parent
201
+ while ( $cat = array_shift( $categories ) ) {
202
+ if ( $cat->parent == 0 || isset( $cats[$cat->parent] ) )
203
+ $cats[$cat->term_id] = $cat;
204
+ else
205
+ $categories[] = $cat;
206
+ }
207
+ $cats_xml = '';
208
+ foreach ( $cats as $c ) {
209
+ $parent_slug = $c->parent ? $cats[$c->parent]->slug : '';
210
+ $cats_xml .= "\t<wp:category><wp:term_id>" . $c->term_id ."</wp:term_id><wp:category_nicename>" . $c->slug . "</wp:category_nicename><wp:category_parent>" . $parent_slug . "</wp:category_parent>" . $this->wxr_cat_name( $c ) . $this->wxr_category_description( $c ) ."</wp:category>\n";
211
+ }
212
+ $written = file_put_contents( $job_object->steps_data[ $job_object->step_working ][ 'wpexportfile' ], $cats_xml, FILE_APPEND );
213
+ if ( $written === FALSE ) {
214
+ $job_object->log( __( 'WP Export file could not written.', 'backwpup' ), E_USER_ERROR );
215
+
216
+ return FALSE;
217
+ }
218
+ unset( $cats_xml );
219
+ }
220
+ $job_object->steps_data[ $job_object->step_working ]['substep'] = 'tags';
221
+ $job_object->substeps_done ++;
222
+ $job_object->update_working_data();
223
+ $job_object->do_restart_time();
224
+ }
225
+
226
+ if ( $job_object->steps_data[ $job_object->step_working ]['substep'] == 'tags' ) {
227
+ if ( 'all' == $job_object->job[ 'wpexportcontent' ] ) {
228
+ $tags = (array) get_tags( array( 'get' => 'all' ) );
229
+ $tags_xml = '';
230
+ foreach ( $tags as $t ) {
231
+ $tags_xml .= "\t<wp:tag><wp:term_id>" . $t->term_id ."</wp:term_id><wp:tag_slug>" . $t->slug ."</wp:tag_slug>" . $this->wxr_tag_name( $t ) . $this->wxr_tag_description( $t ) ."</wp:tag>\n";
232
+ }
233
+ $written = file_put_contents( $job_object->steps_data[ $job_object->step_working ][ 'wpexportfile' ], $tags_xml, FILE_APPEND );
234
+ if ( $written === FALSE ) {
235
+ $job_object->log( __( 'WP Export file could not written.', 'backwpup' ), E_USER_ERROR );
236
+
237
+ return FALSE;
238
+ }
239
+ unset( $tags_xml );
240
+ }
241
+ $job_object->steps_data[ $job_object->step_working ]['substep'] = 'terms';
242
+ $job_object->substeps_done ++;
243
+ $job_object->update_working_data();
244
+ $job_object->do_restart_time();
245
+ }
246
+
247
+ if ( $job_object->steps_data[ $job_object->step_working ]['substep'] == 'terms' ) {
248
+ if ( 'all' == $job_object->job[ 'wpexportcontent' ] ) {
249
+
250
+ $terms = array();
251
+ $custom_taxonomies = get_taxonomies( array( '_builtin' => false ) );
252
+ $custom_terms = (array) get_terms( $custom_taxonomies, array( 'get' => 'all' ) );
253
+
254
+ // put terms in order with no child going before its parent
255
+ while ( $t = array_shift( $custom_terms ) ) {
256
+ if ( $t->parent == 0 || isset( $terms[$t->parent] ) )
257
+ $terms[$t->term_id] = $t;
258
+ else
259
+ $custom_terms[] = $t;
260
+ }
261
+ $terms_xml = '';
262
+ foreach ( $terms as $t ) {
263
+ $parent_slug = $t->parent ? $terms[$t->parent]->slug : '';
264
+ $terms_xml .= "\t<wp:term><wp:term_id>" . $t->term_id ."</wp:term_id><wp:term_taxonomy>" . $t->taxonomy . "</wp:term_taxonomy><wp:term_slug>" . $t->slug ."</wp:term_slug><wp:term_parent>" . $parent_slug ."</wp:term_parent>" . $this->wxr_term_name( $t ) . $this->wxr_term_description( $t ) ."</wp:term>\n";
265
+ }
266
+ $written = file_put_contents( $job_object->steps_data[ $job_object->step_working ][ 'wpexportfile' ], $terms_xml, FILE_APPEND );
267
+ if ( $written === FALSE ) {
268
+ $job_object->log( __( 'WP Export file could not written.', 'backwpup' ), E_USER_ERROR );
269
+
270
+ return FALSE;
271
+ }
272
+ unset( $terms_xml );
273
+ }
274
+ $job_object->steps_data[ $job_object->step_working ]['substep'] = 'menus';
275
+ $job_object->substeps_done ++;
276
+ $job_object->update_working_data();
277
+ $job_object->do_restart_time();
278
+ }
279
+
280
+ if ( $job_object->steps_data[ $job_object->step_working ]['substep'] == 'menus' ) {
281
+ $menu_xml = '';
282
+ if ( 'all' == $job_object->job[ 'wpexportcontent' ] ) {
283
+ $menu_xml .= $this->wxr_nav_menu_terms();
284
+ }
285
+ $menu_xml .= "\t<generator>http://wordpress.org/?v=" . get_bloginfo_rss( 'version' ) . "</generator>\n";
286
+ $written = file_put_contents( $job_object->steps_data[ $job_object->step_working ][ 'wpexportfile' ], $menu_xml, FILE_APPEND );
287
+ if ( $written === FALSE ) {
288
+ $job_object->log( __( 'WP Export file could not written.', 'backwpup' ), E_USER_ERROR );
289
+
290
+ return FALSE;
291
+ }
292
+ unset( $menu_xml );
293
+
294
+ $job_object->steps_data[ $job_object->step_working ]['substep'] = 'posts';
295
+ $job_object->substeps_done ++;
296
+ $job_object->update_working_data();
297
+ $job_object->do_restart_time();
298
+ }
299
+
300
+
301
+ if ( $job_object->steps_data[ $job_object->step_working ]['substep'] == 'posts' ) {
302
+
303
+ if ( ! empty( $job_object->steps_data[ $job_object->step_working ]['post_ids'] ) ) {
304
+ $wp_query->in_the_loop = true; // Fake being in the loop.
305
+
306
+ // fetch 20 posts at a time rather than loading the entire table into memory
307
+ while ( $next_posts = array_splice( $job_object->steps_data[ $job_object->step_working ]['post_ids'], 0, 20 ) ) {
308
+ $where = 'WHERE ID IN (' . join( ',', $next_posts ) . ')';
309
+ $posts = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} $where" );
310
+ $wxr_post = '';
311
+ // Begin Loop
312
+ foreach ( $posts as $post ) {
313
+ /* @var WP_Post $post */
314
+
315
+ $is_sticky = is_sticky( $post->ID ) ? 1 : 0;
316
+
317
+ $wxr_post .= "\t<item>\n";
318
+ $wxr_post .= "\t\t<title>" . apply_filters( 'the_title_rss', $post->post_title ) ."</title>\n";
319
+ $wxr_post .= "\t\t<link>" . esc_url( apply_filters( 'the_permalink_rss', get_permalink( $post ) ) ) ."</link>\n";
320
+ $wxr_post .= "\t\t<pubDate>" . mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true, $post ), false ) ."</pubDate>\n";
321
+ $wxr_post .= "\t\t<dc:creator>" . $this->wxr_cdata( get_the_author_meta( 'login', $post->post_author ) ) ."</dc:creator>\n";
322
+ $wxr_post .= "\t\t<guid isPermaLink=\"false\">" . esc_url( get_the_guid( $post->ID ) ) ."</guid>\n";
323
+ $wxr_post .= "\t\t<description></description>\n";
324
+ $wxr_post .= "\t\t<content:encoded>" . $this->wxr_cdata( apply_filters( 'the_content_export', $post->post_content ) ) . "</content:encoded>\n";
325
+ $wxr_post .= "\t\t<excerpt:encoded>" . $this->wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) ) . "</excerpt:encoded>\n";
326
+ $wxr_post .= "\t\t<wp:post_id>" . $post->ID . "</wp:post_id>\n";
327
+ $wxr_post .= "\t\t<wp:post_date>" . $post->post_date . "</wp:post_date>\n";
328
+ $wxr_post .= "\t\t<wp:post_date_gmt>" . $post->post_date_gmt . "</wp:post_date_gmt>\n";
329
+ $wxr_post .= "\t\t<wp:comment_status>" . $post->comment_status . "</wp:comment_status>\n";
330
+ $wxr_post .= "\t\t<wp:ping_status>" . $post->ping_status . "</wp:ping_status>\n";
331
+ $wxr_post .= "\t\t<wp:post_name>" . $post->post_name . "</wp:post_name>\n";
332
+ $wxr_post .= "\t\t<wp:status>" . $post->post_status . "</wp:status>\n";
333
+ $wxr_post .= "\t\t<wp:post_parent>" . $post->post_parent . "</wp:post_parent>\n";
334
+ $wxr_post .= "\t\t<wp:menu_order>" . $post->menu_order . "</wp:menu_order>\n";
335
+ $wxr_post .= "\t\t<wp:post_type>" . $post->post_type . "</wp:post_type>\n";
336
+ $wxr_post .= "\t\t<wp:post_password>" . $post->post_password . "</wp:post_password>\n";
337
+ $wxr_post .= "\t\t<wp:is_sticky>" . $is_sticky . "</wp:is_sticky>\n";
338
+ if ( $post->post_type == 'attachment' ) {
339
+ $wxr_post .= "\t\t<wp:attachment_url>" . wp_get_attachment_url( $post->ID ) . "</wp:attachment_url>\n";
340
+ }
341
+ $wxr_post .= $this->wxr_post_taxonomy();
342
+
343
+ $postmeta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) );
344
+ foreach ( $postmeta as $meta ) {
345
+ if ( apply_filters( 'wxr_export_skip_postmeta', false, $meta->meta_key, $meta ) ) {
346
+ continue;
347
+ }
348
+ $wxr_post .= "\t\t<wp:postmeta>\n\t\t\t<wp:meta_key>" . $meta->meta_key ."</wp:meta_key>\n\t\t\t<wp:meta_value>" .$this->wxr_cdata( $meta->meta_value ) ."</wp:meta_value>\n\t\t</wp:postmeta>\n";
349
+ }
350
+
351
+ $comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
352
+ foreach ( $comments as $c ) {
353
+ $wxr_post .= "\t\t<wp:comment>\n";
354
+ $wxr_post .= "\t\t\t<wp:comment_id>" . $c->comment_ID . "</wp:comment_id>\n";
355
+ $wxr_post .= "\t\t\t<wp:comment_author>" . $this->wxr_cdata( $c->comment_author ) . "</wp:comment_author>\n";
356
+ $wxr_post .= "\t\t\t<wp:comment_author_email>" . $c->comment_author_email . "</wp:comment_author_email>\n";
357
+ $wxr_post .= "\t\t\t<wp:comment_author_url>" . esc_url_raw( $c->comment_author_url ) . "</wp:comment_author_url>\n";
358
+ $wxr_post .= "\t\t\t<wp:comment_author_IP>" . $c->comment_author_IP . "</wp:comment_author_IP>\n";
359
+ $wxr_post .= "\t\t\t<wp:comment_date>" . $c->comment_date . "</wp:comment_date>\n";
360
+ $wxr_post .= "\t\t\t<wp:comment_date_gmt>" . $c->comment_date_gmt . "</wp:comment_date_gmt>\n";
361
+ $wxr_post .= "\t\t\t<wp:comment_content>" . $this->wxr_cdata( $c->comment_content ) . "</wp:comment_content>\n";
362
+ $wxr_post .= "\t\t\t<wp:comment_approved>" . $c->comment_approved . "</wp:comment_approved>\n";
363
+ $wxr_post .= "\t\t\t<wp:comment_type>" . $c->comment_type . "</wp:comment_type>\n";
364
+ $wxr_post .= "\t\t\t<wp:comment_parent>" . $c->comment_parent . "</wp:comment_parent>\n";
365
+ $wxr_post .= "\t\t\t<wp:comment_user_id>" . $c->user_id . "</wp:comment_user_id>\n";
366
+ $c_meta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID ) );
367
+ foreach ( $c_meta as $meta ) {
368
+ $wxr_post .= "\t\t\t<wp:commentmeta>\n\t\t\t\t<wp:meta_key>" . $meta->meta_key ."</wp:meta_key>\n\t\t\t\t<wp:meta_value>" .$this->wxr_cdata( $meta->meta_value ) ."</wp:meta_value>\n\t\t\t</wp:commentmeta>\n";
369
+ }
370
+ $wxr_post .= "\t\t</wp:comment>\n";
371
+ }
372
+ $wxr_post .= "\t</item>\n";
373
+ $job_object->substeps_done ++;
374
  }
375
+ $written = file_put_contents( $job_object->steps_data[ $job_object->step_working ][ 'wpexportfile' ], $wxr_post, FILE_APPEND );
376
+ if ( $written === FALSE ) {
377
+ $job_object->log( __( 'WP Export file could not written.', 'backwpup' ), E_USER_ERROR );
378
+
379
+ return FALSE;
380
+ }
381
+ $job_object->do_restart_time();
382
  }
383
+ }
384
+ $written = file_put_contents( $job_object->steps_data[ $job_object->step_working ][ 'wpexportfile' ], "</channel>\n</rss>", FILE_APPEND );
385
+ if ( $written === FALSE ) {
386
+ $job_object->log( __( 'WP Export file could not written.', 'backwpup' ), E_USER_ERROR );
387
+
388
+ return FALSE;
389
+ }
390
+ $job_object->steps_data[ $job_object->step_working ]['substep'] = 'check';
391
+ $job_object->substeps_done ++;
392
+ $job_object->update_working_data();
393
+ $job_object->do_restart_time();
394
+ }
395
+
396
+ remove_filter( 'wxr_export_skip_postmeta', array( $this, 'wxr_filter_postmeta' ), 10, 2 );
397
 
398
+ if ( $job_object->steps_data[ $job_object->step_working ]['substep'] == 'check' ) {
399
+
400
+ if ( extension_loaded( 'simplexml' ) && class_exists( 'DOMDocument' ) ) {
401
+ $job_object->log( __( 'Check WP Export file&#160;&hellip;', 'backwpup' ) );
402
+ $job_object->need_free_memory( filesize( $job_object->steps_data[ $job_object->step_working ]['wpexportfile'] ) * 2 );
403
+ $valid = TRUE;
404
+
405
+ $internal_errors = libxml_use_internal_errors( TRUE );
406
+ $dom = new DOMDocument;
407
+ $old_value = NULL;
408
+ if ( function_exists( 'libxml_disable_entity_loader' ) )
409
+ $old_value = libxml_disable_entity_loader( TRUE );
410
+ $success = $dom->loadXML( file_get_contents( $job_object->steps_data[ $job_object->step_working ]['wpexportfile'] ) );
411
+ if ( ! is_null( $old_value ) )
412
+ libxml_disable_entity_loader( $old_value );
413
+
414
+ if ( ! $success || isset( $dom->doctype ) ) {
415
+ $errors = libxml_get_errors();
416
  $valid = FALSE;
 
417
 
418
+ foreach ( $errors as $error ) {
419
+ switch ( $error->level ) {
420
+ case LIBXML_ERR_WARNING:
421
+ $job_object->log( E_USER_WARNING, sprintf( __( 'XML WARNING (%s): %s', 'backwpup' ), $error->code, trim( $error->message ) ), $job_object->steps_data[ $job_object->step_working ]['wpexportfile'], $error->line );
422
+ break;
423
+ case LIBXML_ERR_ERROR:
424
+ $job_object->log( E_USER_WARNING, sprintf( __( 'XML RECOVERABLE (%s): %s', 'backwpup' ), $error->code, trim( $error->message ) ), $job_object->steps_data[ $job_object->step_working ]['wpexportfile'], $error->line );
425
+ break;
426
+ case LIBXML_ERR_FATAL:
427
+ $job_object->log( E_USER_WARNING, sprintf( __( 'XML ERROR (%s): %s', 'backwpup' ),$error->code, trim( $error->message ) ), $job_object->steps_data[ $job_object->step_working ]['wpexportfile'], $error->line );
428
+ break;
429
+ }
430
  }
431
+ } else {
432
+ $xml = simplexml_import_dom( $dom );
433
+ unset( $dom );
434
 
435
+ // halt if loading produces an error
436
+ if ( ! $xml ) {
437
+ $job_object->log( __( 'There was an error when reading this WXR file', 'backwpup' ), E_USER_ERROR );
 
438
  $valid = FALSE;
439
+ } else {
440
+
441
+ $wxr_version = $xml->xpath('/rss/channel/wp:wxr_version');
442
+ if ( ! $wxr_version ) {
443
+ $job_object->log( __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'backwpup' ), E_USER_ERROR );
444
+ $valid = FALSE;
445
+ }
446
+
447
+ $wxr_version = (string) trim( $wxr_version[0] );
448
+ // confirm that we are dealing with the correct file format
449
+ if ( ! preg_match( '/^\d+\.\d+$/', $wxr_version ) ) {
450
+ $job_object->log( __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'backwpup' ), E_USER_ERROR );
451
+ $valid = FALSE;
452
+ }
453
  }
454
  }
 
455
 
456
+ libxml_use_internal_errors( $internal_errors );
457
 
458
+ if ( $valid )
459
+ $job_object->log( __( 'WP Export file is a valid WXR file.', 'backwpup' ) );
460
+ } else {
461
+ $job_object->log( __( 'WP Export file can not checked, because no XML extension loaded with the file can checked.', 'backwpup' ) );
462
+ }
463
 
464
+ $job_object->steps_data[ $job_object->step_working ]['substep'] = 'compress';
465
+ $job_object->substeps_done ++;
466
+ $job_object->update_working_data();
467
+ $job_object->do_restart_time();
468
+ }
469
 
470
  //Compress file
471
+ if ( $job_object->steps_data[ $job_object->step_working ]['substep'] == 'compress' ) {
472
+ if ( ! empty( $job_object->job[ 'wpexportfilecompression' ] ) ) {
473
+ $job_object->log( __( 'Compressing file&#160;&hellip;', 'backwpup' ) );
474
+ try {
475
+ $compress = new BackWPup_Create_Archive( $job_object->steps_data[ $job_object->step_working ]['wpexportfile'] . $job_object->job[ 'wpexportfilecompression' ] );
476
+ if ( $compress->add_file( $job_object->steps_data[ $job_object->step_working ]['wpexportfile'] ) ) {
477
+ unset( $compress );
478
+ unlink( $job_object->steps_data[ $job_object->step_working ]['wpexportfile'] );
479
+ $job_object->steps_data[ $job_object->step_working ]['wpexportfile'] .= $job_object->job[ 'wpexportfilecompression' ];
480
+ $job_object->log( __( 'Compressing done.', 'backwpup' ) );
481
+ }
482
+ } catch ( Exception $e ) {
483
+ $job_object->log( $e->getMessage(), E_USER_ERROR, $e->getFile(), $e->getLine() );
484
  unset( $compress );
485
+ return FALSE;
 
 
486
  }
 
 
 
 
487
  }
488
+ $job_object->steps_data[ $job_object->step_working ]['substep'] = 'addfile';
489
+ $job_object->substeps_done ++;
490
+ $job_object->update_working_data();
491
+ $job_object->do_restart_time();
492
  }
493
+
494
+ if ( $job_object->steps_data[ $job_object->step_working ]['substep'] == 'addfile' ) {
495
+ //add XML file to backup files
496
+ if ( is_readable( $job_object->steps_data[ $job_object->step_working ]['wpexportfile'] ) ) {
497
+ $job_object->additional_files_to_backup[ ] = $job_object->steps_data[ $job_object->step_working ]['wpexportfile'];
498
+ $job_object->count_files ++;
499
+ $filesize = filesize( $job_object->steps_data[ $job_object->step_working ][ 'wpexportfile' ] );
500
+ $job_object->count_filesize = $job_object->count_filesize + $filesize;
501
+ $job_object->log( sprintf( __( 'Added XML export "%1$s" with %2$s to backup file list.', 'backwpup' ), basename( $job_object->steps_data[ $job_object->step_working ]['wpexportfile'] ), size_format( $filesize, 2 ) ) );
502
+ }
503
+ $job_object->substeps_done ++;
504
+ $job_object->update_working_data();
505
  }
 
506
 
507
  return TRUE;
508
  }
509
 
510
  /**
511
+ * Wrap given string in XML CDATA tag.
512
+ *
513
+ * @since WordPress 2.1.0
514
  *
515
+ * @param string $str String to wrap in XML CDATA tag.
516
+ * @return string
517
  */
518
+ private function wxr_cdata( $str ) {
519
+ if ( seems_utf8( $str ) == false )
520
+ $str = utf8_encode( $str );
521
 
522
  // not allowed UTF-8 chars in XML
523
+ $str = preg_replace( '/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', '', $str );
524
 
525
+ // $str = ent2ncr(esc_html($str));
526
+ $str = '<![CDATA[' . str_replace( ']]>', ']]]]><![CDATA[>', $str ) . ']]>';
527
+
528
+ return $str;
529
+ }
530
+
531
+ /**
532
+ * Return the URL of the site
533
+ *
534
+ * @since WordPress 2.5.0
535
+ *
536
+ * @return string Site URL.
537
+ */
538
+ private function wxr_site_url() {
539
+ // ms: the base url
540
+ if ( is_multisite() )
541
+ return network_home_url();
542
+ // wp: the blog url
543
+ else
544
+ return get_bloginfo_rss( 'url' );
545
+ }
546
+
547
+ /**
548
+ * Output a cat_name XML tag from a given category object
549
+ *
550
+ * @since WordPress 2.1.0
551
+ *
552
+ * @param object $category Category Object
553
+ * @return string
554
+ */
555
+ private function wxr_cat_name( $category ) {
556
+ if ( empty( $category->name ) )
557
+ return '';
558
+
559
+ return '<wp:cat_name>' . $this->wxr_cdata( $category->name ) . '</wp:cat_name>';
560
+ }
561
+
562
+ /**
563
+ * Output a category_description XML tag from a given category object
564
+ *
565
+ * @since WordPress 2.1.0
566
+ *
567
+ * @param object $category Category Object
568
+ * @return string
569
+ */
570
+ private function wxr_category_description( $category ) {
571
+ if ( empty( $category->description ) )
572
+ return '';
573
+
574
+ return '<wp:category_description>' . $this->wxr_cdata( $category->description ) . '</wp:category_description>';
575
+ }
576
+
577
+ /**
578
+ * Output a tag_name XML tag from a given tag object
579
+ *
580
+ * @since WordPress 2.3.0
581
+ *
582
+ * @param object $tag Tag Object
583
+ * @return string
584
+ */
585
+ private function wxr_tag_name( $tag ) {
586
+ if ( empty( $tag->name ) )
587
+ return '';
588
+
589
+ return '<wp:tag_name>' . $this->wxr_cdata( $tag->name ) . '</wp:tag_name>';
590
+ }
591
+
592
+ /**
593
+ * Output a tag_description XML tag from a given tag object
594
+ *
595
+ * @since WordPress 2.3.0
596
+ *
597
+ * @param object $tag Tag Object
598
+ * @return string
599
+ */
600
+ private function wxr_tag_description( $tag ) {
601
+ if ( empty( $tag->description ) )
602
+ return '';
603
+
604
+ return '<wp:tag_description>' . $this->wxr_cdata( $tag->description ) . '</wp:tag_description>';
605
+ }
606
+
607
+ /**
608
+ * Output a term_name XML tag from a given term object
609
+ *
610
+ * @since WordPress 2.9.0
611
+ *
612
+ * @param object $term Term Object
613
+ * @return string
614
+ */
615
+ private function wxr_term_name( $term ) {
616
+ if ( empty( $term->name ) )
617
+ return '';
618
+
619
+ return '<wp:term_name>' . $this->wxr_cdata( $term->name ) . '</wp:term_name>';
620
+ }
621
+
622
+ /**
623
+ * Output a term_description XML tag from a given term object
624
+ *
625
+ * @since WordPress 2.9.0
626
+ *
627
+ * @param object $term Term Object
628
+ * @return string
629
+ */
630
+ private function wxr_term_description( $term ) {
631
+ if ( empty( $term->description ) )
632
+ return '';
633
+
634
+ return '<wp:term_description>' . $this->wxr_cdata( $term->description ) . '</wp:term_description>';
635
+ }
636
+
637
+ /**
638
+ * Output list of authors with posts
639
+ *
640
+ * @since WordPress 3.1.0
641
+ */
642
+ private function wxr_authors_list() {
643
+ global $wpdb;
644
+
645
+ $authors = array();
646
+ $results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status != 'auto-draft'" );
647
+ foreach ( (array) $results as $result )
648
+ $authors[] = get_userdata( $result->post_author );
649
+
650
+ $authors = array_filter( $authors );
651
+
652
+ $wxr_authors = '';
653
+
654
+ foreach ( $authors as $author ) {
655
+ $wxr_authors .= "\t<wp:author>";
656
+ $wxr_authors .= '<wp:author_id>' . $author->ID . '</wp:author_id>';
657
+ $wxr_authors .= '<wp:author_login>' . $author->user_login . '</wp:author_login>';
658
+ $wxr_authors .= '<wp:author_email>' . $author->user_email . '</wp:author_email>';
659
+ $wxr_authors .= '<wp:author_display_name>' . $this->wxr_cdata( $author->display_name ) . '</wp:author_display_name>';
660
+ $wxr_authors .= '<wp:author_first_name>' . $this->wxr_cdata( $author->user_firstname ) . '</wp:author_first_name>';
661
+ $wxr_authors .= '<wp:author_last_name>' . $this->wxr_cdata( $author->user_lastname ) . '</wp:author_last_name>';
662
+ $wxr_authors .= "</wp:author>\n";
663
  }
664
 
665
+ return $wxr_authors;
666
+ }
667
+
668
+ /**
669
+ * Ouput all navigation menu terms
670
+ *
671
+ * @since WordPress 3.1.0
672
+ */
673
+ private function wxr_nav_menu_terms() {
674
+ $nav_menus = wp_get_nav_menus();
675
+ if ( empty( $nav_menus ) || ! is_array( $nav_menus ) )
676
+ return '';
677
+
678
+ $wxr_nav_meuns = '';
679
+
680
+ foreach ( $nav_menus as $menu ) {
681
+ $wxr_nav_meuns .= "\t<wp:term><wp:term_id>{$menu->term_id}</wp:term_id><wp:term_taxonomy>nav_menu</wp:term_taxonomy><wp:term_slug>{$menu->slug}</wp:term_slug>";
682
+ $wxr_nav_meuns .= $this->wxr_term_name( $menu );
683
+ $wxr_nav_meuns .= "</wp:term>\n";
684
  }
685
 
686
+ return $wxr_nav_meuns;
687
+ }
688
+
689
+ /**
690
+ * Output list of taxonomy terms, in XML tag format, associated with a post
691
+ *
692
+ * @since WordPress 2.3.0
693
+ */
694
+ private function wxr_post_taxonomy() {
695
+ $post = get_post();
696
+
697
+ $taxonomies = get_object_taxonomies( $post->post_type );
698
+ if ( empty( $taxonomies ) )
699
+ return '';
700
+ $terms = wp_get_object_terms( $post->ID, $taxonomies );
701
+
702
+ $wxr_post_tags = '';
703
+
704
+ foreach ( (array) $terms as $term ) {
705
+ $wxr_post_tags .= "\t\t<category domain=\"{$term->taxonomy}\" nicename=\"{$term->slug}\">" . $this->wxr_cdata( $term->name ) . "</category>\n";
706
  }
707
 
708
+ return $wxr_post_tags;
 
709
  }
710
 
711
+ public function wxr_filter_postmeta( $return_me, $meta_key ) {
712
+ if ( '_edit_lock' == $meta_key )
713
+ $return_me = true;
714
+ return $return_me;
715
+ }
716
+
717
+
718
+
719
  }
inc/class-jobtype-wpplugin.php CHANGED
@@ -1,148 +1,148 @@
1
- <?php
2
- /**
3
- *
4
- */
5
- class BackWPup_JobType_WPPlugin extends BackWPup_JobTypes {
6
-
7
- /**
8
- *
9
- */
10
- public function __construct() {
11
-
12
- $this->info[ 'ID' ] = 'WPPLUGIN';
13
- $this->info[ 'name' ] = __( 'Plugins', 'backwpup' );
14
- $this->info[ 'description' ] = __( 'Installed plugins list', 'backwpup' );
15
- $this->info[ 'URI' ] = translate( BackWPup::get_plugin_data( 'PluginURI' ), 'backwpup' );
16
- $this->info[ 'author' ] = BackWPup::get_plugin_data( 'Author' );
17
- $this->info[ 'authorURI' ] = translate( BackWPup::get_plugin_data( 'AuthorURI' ), 'backwpup' );
18
- $this->info[ 'version' ] = BackWPup::get_plugin_data( 'Version' );
19
-
20
- }
21
-
22
- /**
23
- * @return bool
24
- */
25
- public function creates_file() {
26
-
27
- return TRUE;
28
- }
29
-
30
- /**
31
- * @return array
32
- */
33
- public function option_defaults() {
34
- return array( 'pluginlistfilecompression' => '', 'pluginlistfile' => sanitize_file_name( get_bloginfo( 'name' ) ) . '.pluginlist.%Y-%m-%d' );
35
- }
36
-
37
- /**
38
- * @param $jobid
39
- * @return void
40
- */
41
- public function edit_tab( $jobid ) {
42
- ?>
43
- <table class="form-table">
44
- <tr>
45
- <th scope="row"><label for="idpluginlistfile"><?php _e( 'Plugin list file name', 'backwpup' ) ?></label></th>
46
- <td>
47
- <input name="pluginlistfile" type="text" id="idpluginlistfile"
48
- value="<?php echo BackWPup_Option::get( $jobid, 'pluginlistfile' );?>"
49
- class="medium-text code"/>.txt
50
- </td>
51
- </tr>
52
- <tr>
53
- <th scope="row"><?php _e( 'File compression', 'backwpup' ) ?></th>
54
- <td>
55
- <fieldset>
56
- <?php
57
- echo '<label for="idpluginlistfilecompression"><input class="radio" type="radio"' . checked( '', BackWPup_Option::get( $jobid, 'pluginlistfilecompression' ), FALSE ) . ' name="pluginlistfilecompression" id="idpluginlistfilecompression" value="" /> ' . __( 'none', 'backwpup' ). '</label><br />';
58
- if ( function_exists( 'gzopen' ) )
59
- echo '<label for="idpluginlistfilecompression-gz"><input class="radio" type="radio"' . checked( '.gz', BackWPup_Option::get( $jobid, 'pluginlistfilecompression' ), FALSE ) . ' name="pluginlistfilecompression" id="idpluginlistfilecompression-gz" value=".gz" /> ' . __( 'GZip', 'backwpup' ). '</label><br />';
60
- else
61
- echo '<label for="idpluginlistfilecompression-gz"><input class="radio" type="radio"' . checked( '.gz', BackWPup_Option::get( $jobid, 'pluginlistfilecompression' ), FALSE ) . ' name="pluginlistfilecompression" id="idpluginlistfilecompression-gz" value=".gz" disabled="disabled" /> ' . __( 'GZip', 'backwpup' ). '</label><br />';
62
- if ( function_exists( 'bzopen' ) )
63
- echo '<label for="idpluginlistfilecompression-bz2"><input class="radio" type="radio"' . checked( '.bz2', BackWPup_Option::get( $jobid, 'pluginlistfilecompression' ), FALSE ) . ' name="pluginlistfilecompression" id="idpluginlistfilecompression-bz2" value=".bz2" /> ' . __( 'BZip2', 'backwpup' ). '</label><br />';
64
- else
65
- echo '<label for="idpluginlistfilecompression-bz2"><input class="radio" type="radio"' . checked( '.bz2', BackWPup_Option::get( $jobid, 'pluginlistfilecompression' ), FALSE ) . ' name="pluginlistfilecompression" id="idpluginlistfilecompression-bz2" value=".bz2" disabled="disabled" /> ' . __( 'BZip2', 'backwpup' ). '</label><br />';
66
- ?>
67
- </fieldset>
68
- </td>
69
- </tr>
70
- </table>
71
- <?php
72
- }
73
-
74
-
75
- /**
76
- * @param $id
77
- */
78
- public function edit_form_post_save( $id ) {
79
-
80
- BackWPup_Option::update( $id, 'pluginlistfile', $_POST[ 'pluginlistfile' ] );
81
- if ( $_POST[ 'pluginlistfilecompression' ] == '' || $_POST[ 'pluginlistfilecompression' ] == '.gz' || $_POST[ 'pluginlistfilecompression' ] == '.bz2' )
82
- BackWPup_Option::update( $id, 'pluginlistfilecompression', $_POST[ 'pluginlistfilecompression' ] );
83
- }
84
-
85
- /**
86
- * @param $job_object
87
- * @return bool
88
- */
89
- public function job_run( &$job_object ) {
90
-
91
- $job_object->substeps_todo = 1;
92
-
93
- $job_object->log( sprintf( __( '%d. Trying to generate a file with installed plugin names&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ) );
94
- //build filename
95
- if ( empty( $job_object->temp[ 'pluginlistfile' ] ) )
96
- $job_object->temp[ 'pluginlistfile' ] = $job_object->generate_filename( $job_object->job[ 'pluginlistfile' ], 'txt' ) . $job_object->job[ 'pluginlistfilecompression' ];
97
-
98
- if ( $job_object->job[ 'pluginlistfilecompression' ] == '.gz' )
99
- $handle = fopen( 'compress.zlib://' . BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'pluginlistfile' ], 'w' );
100
- elseif ( $job_object->job[ 'pluginlistfilecompression' ] == '.bz2' )
101
- $handle = fopen( 'compress.bzip2://' . BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'pluginlistfile' ], 'w' );
102
- else
103
- $handle = fopen( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'pluginlistfile' ], 'w' );
104
-
105
- //open file
106
- $header = "------------------------------------------------------------" . PHP_EOL;
107
- $header .= " Plugin list generated with BackWPup version: " . BackWPup::get_plugin_data( 'Version' ) . PHP_EOL;
108
- $header .= " " . translate( BackWPup::get_plugin_data( 'pluginuri' ), 'backwpup' ) . PHP_EOL;
109
- $header .= " Blog Name: " . get_bloginfo( 'name' ) . PHP_EOL;
110
- $header .= " Blog URL: " . get_bloginfo( 'url' ) . PHP_EOL;
111
- $header .= " Generated on: " . date_i18n( 'Y-m-d H:i.s' ) . PHP_EOL;
112
- $header .= "------------------------------------------------------------" . PHP_EOL . PHP_EOL;
113
- fwrite( $handle, $header );
114
- //get Plugins
115
- if ( ! function_exists( 'get_plugins' ) )
116
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
117
- $plugins = get_plugins();
118
- $plugins_active = get_option( 'active_plugins' );
119
- //write it to file
120
- fwrite( $handle, PHP_EOL . __( 'All plugin information:', 'backwpup' ) . PHP_EOL . '------------------------------' . PHP_EOL );
121
- foreach ( $plugins as $plugin ) {
122
- fwrite( $handle, $plugin[ 'Name' ] . ' (v.' . $plugin[ 'Version' ] . ') ' . html_entity_decode( sprintf( __( 'from %s', 'backwpup' ), $plugin[ 'Author' ] ), ENT_QUOTES ) . PHP_EOL . "\t" . $plugin[ 'PluginURI' ] . PHP_EOL );
123
- }
124
- fwrite( $handle, PHP_EOL . __( 'Active plugins:', 'backwpup' ) . PHP_EOL . '------------------------------' . PHP_EOL );
125
-
126
- foreach ( $plugins as $key => $plugin ) {
127
- if ( in_array( $key, $plugins_active ) )
128
- fwrite( $handle, $plugin[ 'Name' ] . PHP_EOL );
129
- }
130
- fwrite( $handle, PHP_EOL . __( 'Inactive plugins:', 'backwpup' ) . PHP_EOL . '------------------------------' . PHP_EOL );
131
- foreach ( $plugins as $key => $plugin ) {
132
- if ( ! in_array( $key, $plugins_active ) )
133
- fwrite( $handle, $plugin[ 'Name' ] . PHP_EOL );
134
- }
135
- fclose( $handle );
136
-
137
- //add file to backup files
138
- if ( is_readable( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'pluginlistfile' ] ) ) {
139
- $job_object->additional_files_to_backup[ ] = BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'pluginlistfile' ];
140
- $job_object->count_files ++;
141
- $job_object->count_filesize = $job_object->count_filesize + @filesize( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'pluginlistfile' ] );
142
- $job_object->log( sprintf( __( 'Added plugin list file "%1$s" with %2$s to backup file list.', 'backwpup' ), $job_object->temp[ 'pluginlistfile' ], size_format( filesize( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'pluginlistfile' ] ), 2 ) ) );
143
- }
144
- $job_object->substeps_done = 1;
145
-
146
- return TRUE;
147
- }
148
- }
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ class BackWPup_JobType_WPPlugin extends BackWPup_JobTypes {
6
+
7
+ /**
8
+ *
9
+ */
10
+ public function __construct() {
11
+
12
+ $this->info[ 'ID' ] = 'WPPLUGIN';
13
+ $this->info[ 'name' ] = __( 'Plugins', 'backwpup' );
14
+ $this->info[ 'description' ] = __( 'Installed plugins list', 'backwpup' );
15
+ $this->info[ 'URI' ] = translate( BackWPup::get_plugin_data( 'PluginURI' ), 'backwpup' );
16
+ $this->info[ 'author' ] = BackWPup::get_plugin_data( 'Author' );
17
+ $this->info[ 'authorURI' ] = translate( BackWPup::get_plugin_data( 'AuthorURI' ), 'backwpup' );
18
+ $this->info[ 'version' ] = BackWPup::get_plugin_data( 'Version' );
19
+
20
+ }
21
+
22
+ /**
23
+ * @return bool
24
+ */
25
+ public function creates_file() {
26
+
27
+ return TRUE;
28
+ }
29
+
30
+ /**
31
+ * @return array
32
+ */
33
+ public function option_defaults() {
34
+ return array( 'pluginlistfilecompression' => '', 'pluginlistfile' => sanitize_file_name( get_bloginfo( 'name' ) ) . '.pluginlist.%Y-%m-%d' );
35
+ }
36
+
37
+ /**
38
+ * @param $jobid
39
+ * @return void
40
+ */
41
+ public function edit_tab( $jobid ) {
42
+ ?>
43
+ <table class="form-table">
44
+ <tr>
45
+ <th scope="row"><label for="idpluginlistfile"><?php _e( 'Plugin list file name', 'backwpup' ) ?></label></th>
46
+ <td>
47
+ <input name="pluginlistfile" type="text" id="idpluginlistfile"
48
+ value="<?php echo BackWPup_Option::get( $jobid, 'pluginlistfile' );?>"
49
+ class="medium-text code"/>.txt
50
+ </td>
51
+ </tr>
52
+ <tr>
53
+ <th scope="row"><?php _e( 'File compression', 'backwpup' ) ?></th>
54
+ <td>
55
+ <fieldset>
56
+ <?php
57
+ echo '<label for="idpluginlistfilecompression"><input class="radio" type="radio"' . checked( '', BackWPup_Option::get( $jobid, 'pluginlistfilecompression' ), FALSE ) . ' name="pluginlistfilecompression" id="idpluginlistfilecompression" value="" /> ' . __( 'none', 'backwpup' ). '</label><br />';
58
+ if ( function_exists( 'gzopen' ) )
59
+ echo '<label for="idpluginlistfilecompression-gz"><input class="radio" type="radio"' . checked( '.gz', BackWPup_Option::get( $jobid, 'pluginlistfilecompression' ), FALSE ) . ' name="pluginlistfilecompression" id="idpluginlistfilecompression-gz" value=".gz" /> ' . __( 'GZip', 'backwpup' ). '</label><br />';
60
+ else
61
+ echo '<label for="idpluginlistfilecompression-gz"><input class="radio" type="radio"' . checked( '.gz', BackWPup_Option::get( $jobid, 'pluginlistfilecompression' ), FALSE ) . ' name="pluginlistfilecompression" id="idpluginlistfilecompression-gz" value=".gz" disabled="disabled" /> ' . __( 'GZip', 'backwpup' ). '</label><br />';
62
+ if ( function_exists( 'bzopen' ) )
63
+ echo '<label for="idpluginlistfilecompression-bz2"><input class="radio" type="radio"' . checked( '.bz2', BackWPup_Option::get( $jobid, 'pluginlistfilecompression' ), FALSE ) . ' name="pluginlistfilecompression" id="idpluginlistfilecompression-bz2" value=".bz2" /> ' . __( 'BZip2', 'backwpup' ). '</label><br />';
64
+ else
65
+ echo '<label for="idpluginlistfilecompression-bz2"><input class="radio" type="radio"' . checked( '.bz2', BackWPup_Option::get( $jobid, 'pluginlistfilecompression' ), FALSE ) . ' name="pluginlistfilecompression" id="idpluginlistfilecompression-bz2" value=".bz2" disabled="disabled" /> ' . __( 'BZip2', 'backwpup' ). '</label><br />';
66
+ ?>
67
+ </fieldset>
68
+ </td>
69
+ </tr>
70
+ </table>
71
+ <?php
72
+ }
73
+
74
+
75
+ /**
76
+ * @param $id
77
+ */
78
+ public function edit_form_post_save( $id ) {
79
+
80
+ BackWPup_Option::update( $id, 'pluginlistfile', sanitize_file_name( $_POST[ 'pluginlistfile' ] ) );
81
+ if ( $_POST[ 'pluginlistfilecompression' ] == '' || $_POST[ 'pluginlistfilecompression' ] == '.gz' || $_POST[ 'pluginlistfilecompression' ] == '.bz2' )
82
+ BackWPup_Option::update( $id, 'pluginlistfilecompression', $_POST[ 'pluginlistfilecompression' ] );
83
+ }
84
+
85
+ /**
86
+ * @param $job_object
87
+ * @return bool
88
+ */
89
+ public function job_run( &$job_object ) {
90
+
91
+ $job_object->substeps_todo = 1;
92
+
93
+ $job_object->log( sprintf( __( '%d. Trying to generate a file with installed plugin names&#160;&hellip;', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'STEP_TRY' ] ) );
94
+ //build filename
95
+ if ( empty( $job_object->temp[ 'pluginlistfile' ] ) )
96
+ $job_object->temp[ 'pluginlistfile' ] = $job_object->generate_filename( $job_object->job[ 'pluginlistfile' ], 'txt' ) . $job_object->job[ 'pluginlistfilecompression' ];
97
+
98
+ if ( $job_object->job[ 'pluginlistfilecompression' ] == '.gz' )
99
+ $handle = fopen( 'compress.zlib://' . BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'pluginlistfile' ], 'w' );
100
+ elseif ( $job_object->job[ 'pluginlistfilecompression' ] == '.bz2' )
101
+ $handle = fopen( 'compress.bzip2://' . BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'pluginlistfile' ], 'w' );
102
+ else
103
+ $handle = fopen( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'pluginlistfile' ], 'w' );
104
+
105
+ //open file
106
+ $header = "------------------------------------------------------------" . PHP_EOL;
107
+ $header .= " Plugin list generated with BackWPup version: " . BackWPup::get_plugin_data( 'Version' ) . PHP_EOL;
108
+ $header .= " " . translate( BackWPup::get_plugin_data( 'pluginuri' ), 'backwpup' ) . PHP_EOL;
109
+ $header .= " Blog Name: " . get_bloginfo( 'name' ) . PHP_EOL;
110
+ $header .= " Blog URL: " . get_bloginfo( 'url' ) . PHP_EOL;
111
+ $header .= " Generated on: " . date_i18n( 'Y-m-d H:i.s' ) . PHP_EOL;
112
+ $header .= "------------------------------------------------------------" . PHP_EOL . PHP_EOL;
113
+ fwrite( $handle, $header );
114
+ //get Plugins
115
+ if ( ! function_exists( 'get_plugins' ) )
116
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
117
+ $plugins = get_plugins();
118
+ $plugins_active = get_option( 'active_plugins' );
119
+ //write it to file
120
+ fwrite( $handle, PHP_EOL . __( 'All plugin information:', 'backwpup' ) . PHP_EOL . '------------------------------' . PHP_EOL );
121
+ foreach ( $plugins as $plugin ) {
122
+ fwrite( $handle, $plugin[ 'Name' ] . ' (v.' . $plugin[ 'Version' ] . ') ' . html_entity_decode( sprintf( __( 'from %s', 'backwpup' ), $plugin[ 'Author' ] ), ENT_QUOTES ) . PHP_EOL . "\t" . $plugin[ 'PluginURI' ] . PHP_EOL );
123
+ }
124
+ fwrite( $handle, PHP_EOL . __( 'Active plugins:', 'backwpup' ) . PHP_EOL . '------------------------------' . PHP_EOL );
125
+
126
+ foreach ( $plugins as $key => $plugin ) {
127
+ if ( in_array( $key, $plugins_active ) )
128
+ fwrite( $handle, $plugin[ 'Name' ] . PHP_EOL );
129
+ }
130
+ fwrite( $handle, PHP_EOL . __( 'Inactive plugins:', 'backwpup' ) . PHP_EOL . '------------------------------' . PHP_EOL );
131
+ foreach ( $plugins as $key => $plugin ) {
132
+ if ( ! in_array( $key, $plugins_active ) )
133
+ fwrite( $handle, $plugin[ 'Name' ] . PHP_EOL );
134
+ }
135
+ fclose( $handle );
136
+
137
+ //add file to backup files
138
+ if ( is_readable( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'pluginlistfile' ] ) ) {
139
+ $job_object->additional_files_to_backup[ ] = BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'pluginlistfile' ];
140
+ $job_object->count_files ++;
141
+ $job_object->count_filesize = $job_object->count_filesize + filesize( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'pluginlistfile' ] );
142
+ $job_object->log( sprintf( __( 'Added plugin list file "%1$s" with %2$s to backup file list.', 'backwpup' ), $job_object->temp[ 'pluginlistfile' ], size_format( filesize( BackWPup::get_plugin_data( 'TEMP' ) . $job_object->temp[ 'pluginlistfile' ] ), 2 ) ) );
143
+ }
144
+ $job_object->substeps_done = 1;
145
+
146
+ return TRUE;
147
+ }
148
+ }
inc/class-jobtypes.php CHANGED
@@ -1,111 +1,111 @@
1
- <?php
2
- /**
3
- *
4
- */
5
- abstract class BackWPup_JobTypes {
6
-
7
- public $info = array();
8
-
9
- /**
10
- *
11
- */
12
- abstract public function __construct();
13
-
14
- /**
15
- * Get the default Options
16
- *
17
- * @return array of default options
18
- */
19
- abstract public function option_defaults();
20
-
21
- /**
22
- * @param $jobid
23
- */
24
- abstract public function edit_tab( $jobid );
25
-
26
- /**
27
- * @param $jobid
28
- */
29
- abstract public function edit_form_post_save( $jobid );
30
-
31
- /**
32
- * use wp_enqueue_script() here to load js for tab
33
- */
34
- public function admin_print_scripts() {
35
-
36
- }
37
-
38
- /**
39
- *
40
- */
41
- public function edit_inline_js() {
42
-
43
- }
44
-
45
- /**
46
- *
47
- */
48
- public function edit_ajax() {
49
-
50
- }
51
-
52
- /**
53
- *
54
- */
55
- public function wizard_admin_print_styles() {
56
-
57
- }
58
-
59
- /**
60
- *
61
- */
62
- public function wizard_admin_print_scripts() {
63
-
64
- }
65
-
66
- /**
67
- *
68
- */
69
- public function wizard_inline_js() {
70
-
71
- }
72
-
73
- /**
74
- * @param $job_settings
75
- */
76
- public function wizard_page( $job_settings ) {
77
-
78
- echo '<br /><pre>';
79
- print_r( $job_settings );
80
- echo '</pre>';
81
- }
82
-
83
- /**
84
- * @param $job_settings
85
- */
86
- public function wizard_save( $job_settings ) {
87
-
88
- return $job_settings;
89
- }
90
-
91
- /**
92
- *
93
- */
94
- public function admin_print_styles() {
95
-
96
- }
97
-
98
- /**
99
- * @return bool
100
- */
101
- public function creates_file() {
102
-
103
- return FALSE;
104
- }
105
-
106
- /**
107
- * @param $job_object BackWPup_Job Object
108
- * @return bool
109
- */
110
- abstract public function job_run( &$job_object );
111
- }
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ abstract class BackWPup_JobTypes {
6
+
7
+ public $info = array();
8
+
9
+ /**
10
+ *
11
+ */
12
+ abstract public function __construct();
13
+
14
+ /**
15
+ * Get the default Options
16
+ *
17
+ * @return array of default options
18
+ */
19
+ abstract public function option_defaults();
20
+
21
+ /**
22
+ * @param $jobid
23
+ */
24
+ abstract public function edit_tab( $jobid );
25
+
26
+ /**
27
+ * @param $jobid
28
+ */
29
+ abstract public function edit_form_post_save( $jobid );
30
+
31
+ /**
32
+ * use wp_enqueue_script() here to load js for tab
33
+ */
34
+ public function admin_print_scripts() {
35
+
36
+ }
37
+
38
+ /**
39
+ *
40
+ */
41
+ public function edit_inline_js() {
42
+
43
+ }
44
+
45
+ /**
46
+ *
47
+ */
48
+ public function edit_ajax() {
49
+
50
+ }
51
+
52
+ /**
53
+ *
54
+ */
55
+ public function wizard_admin_print_styles() {
56
+
57
+ }
58
+
59
+ /**
60
+ *
61
+ */
62
+ public function wizard_admin_print_scripts() {
63
+
64
+ }
65
+
66
+ /**
67
+ *
68
+ */
69
+ public function wizard_inline_js() {
70
+
71
+ }
72
+
73
+ /**
74
+ * @param $job_settings
75
+ */
76
+ public function wizard_page( $job_settings ) {
77
+
78
+ echo '<br /><pre>';
79
+ print_r( $job_settings );
80
+ echo '</pre>';
81
+ }
82
+
83
+ /**
84
+ * @param $job_settings
85
+ */
86
+ public function wizard_save( $job_settings ) {
87
+
88
+ return $job_settings;
89
+ }
90
+
91
+ /**
92
+ *
93
+ */
94
+ public function admin_print_styles() {
95
+
96
+ }
97
+
98
+ /**
99
+ * @return bool
100
+ */
101
+ public function creates_file() {
102
+
103
+ return FALSE;
104
+ }
105
+
106
+ /**
107
+ * @param $job_object BackWPup_Job Object
108
+ * @return bool
109
+ */
110
+ abstract public function job_run( &$job_object );
111
+ }
inc/class-mysqldump.php CHANGED
@@ -1,472 +1,480 @@
1
- <?php
2
- /**
3
- * Class to create a MYSQL dump with mysqli as sql file
4
- */
5
- class BackWPup_MySQLDump {
6
-
7
- /**
8
- * Holder for mysqli recourse
9
- */
10
- private $mysqli = NULL;
11
-
12
- /**
13
- * Holder for dump file handle
14
- */
15
- private $handle = NULL;
16
-
17
- /**
18
- * Table names of Tables in Database
19
- */
20
- public $tables_to_dump = array();
21
-
22
- /**
23
- * Table names of Tables in Database
24
- */
25
- private $table_types = array();
26
-
27
- /**
28
- * Table information of Tables in Database
29
- */
30
- private $table_status = array();
31
-
32
- /**
33
- * Database name
34
- */
35
- private $dbname = '';
36
-
37
- /**
38
- * Compression to use
39
- * empty for none
40
- * gz for Gzip
41
- */
42
- private $compression = '';
43
-
44
- /**
45
- * Check params and makes confections
46
- * gets the table information too
47
- *
48
- * @param $args array with arguments
49
- * @throws BackWPup_MySQLDump_Exception
50
- * @global $wpdb wpdb
51
- */
52
- public function __construct( $args = array() ) {
53
-
54
- if ( ! class_exists( 'mysqli' ) )
55
- throw new BackWPup_MySQLDump_Exception( __( 'No MySQLi extension found. Please install it.', 'backwpup' ) );
56
-
57
- $default_args = array(
58
- 'dbhost' => DB_HOST,
59
- 'dbname' => DB_NAME,
60
- 'dbuser' => DB_USER,
61
- 'dbpassword' => DB_PASSWORD,
62
- 'dbcharset' => defined( 'DB_CHARSET' ) ? DB_CHARSET : '',
63
- 'dumpfilehandle' => fopen( 'php://output', 'wb' ),
64
- 'dumpfile' => NULL,
65
- 'compression' => ''
66
- );
67
-
68
- $args = wp_parse_args( $args , $default_args );
69
-
70
- //set empty host to localhost
71
- if ( empty( $args[ 'dbhost' ] ) )
72
- $args[ 'dbhost' ] = NULL;
73
-
74
- //check if port or socket in hostname and set port and socket
75
- $args[ 'dbport' ] = NULL;
76
- $args[ 'dbsocket' ] = NULL;
77
- if ( strstr( $args[ 'dbhost' ], ':' ) ) {
78
- $hostparts = explode( ':', $args[ 'dbhost' ], 2 );
79
- $hostparts[ 0 ] = trim( $hostparts[ 0 ] );
80
- $hostparts[ 1 ] = trim( $hostparts[ 1 ] );
81
- if ( empty( $hostparts[ 0 ] ) )
82
- $args[ 'dbhost' ] = NULL;
83
- else
84
- $args[ 'dbhost' ] = $hostparts[ 0 ];
85
- if ( is_numeric( $hostparts[ 1 ] ) )
86
- $args[ 'dbport' ] = (int) $hostparts[ 1 ];
87
- else
88
- $args[ 'dbsocket' ] = $hostparts[ 1 ];
89
- }
90
-
91
- $this->mysqli = mysqli_init();
92
- if ( ! $this->mysqli )
93
- throw new BackWPup_MySQLDump_Exception( __( 'Cannot init MySQLi database connection', 'backwpup' ) );
94
-
95
- if ( ! empty( $args[ 'dbcharset' ] ) ) {
96
- if ( ! $this->mysqli->options( MYSQLI_INIT_COMMAND, 'SET NAMES ' . $args[ 'dbcharset' ] . ';' ) )
97
- throw new BackWPup_MySQLDump_Exception( sprintf( __( 'Setting of MySQLi init command "%s" failed', 'backwpup' ), 'SET NAMES ' . $args[ 'dbcharset' ] . ';' ) );
98
- }
99
-
100
- if ( ! $this->mysqli->options( MYSQLI_OPT_CONNECT_TIMEOUT, 5 ) )
101
- throw new BackWPup_MySQLDump_Exception( __( 'Setting of MySQLi connection timeout failed', 'backwpup' ) );
102
-
103
- //connect to Database
104
- if ( ! $this->mysqli->real_connect( $args[ 'dbhost' ], $args[ 'dbuser' ], $args[ 'dbpassword' ], $args[ 'dbname' ], $args[ 'dbport' ], $args[ 'dbsocket' ] ) )
105
- throw new BackWPup_MySQLDump_Exception( sprintf( __( 'Cannot connect to MySQL database %1$d: %2$s', 'backwpup' ), mysqli_connect_errno(), mysqli_connect_error() ) );
106
-
107
- //set charset
108
- if ( ! empty( $args[ 'dbcharset' ] ) && method_exists( $this->mysqli, 'set_charset' ) ) {
109
- $res = $this->mysqli->set_charset( $args[ 'dbcharset' ] );
110
- if ( ! $res )
111
- throw new BackWPup_MySQLDump_Exception( sprintf( _x( 'Cannot set DB charset to %s','Database Charset', 'backwpup' ), $args[ 'dbcharset' ] ) );
112
- }
113
-
114
- //set db name
115
- $this->dbname = $args[ 'dbname' ];
116
-
117
- //set compression
118
- if ( ! empty( $args[ 'compression' ] ) && in_array( $args[ 'compression' ], array( 'gz' ) ) )
119
- $this->compression = $args[ 'compression' ];
120
-
121
- //open file if set
122
- if ( $args[ 'dumpfile' ] ) {
123
- if ( substr( strtolower( $args[ 'dumpfile' ] ), -3 ) == '.gz' ) {
124
- if ( ! function_exists( 'gzencode' ) )
125
- throw new BackWPup_MySQLDump_Exception( __( 'Functions for gz compression not available', 'backwpup' ) );
126
- $this->compression = 'gz';
127
- $this->handle = fopen( 'compress.zlib://' . $args[ 'dumpfile' ], 'ab' );
128
- } else {
129
- $this->compression = '';
130
- $this->handle = fopen( $args[ 'dumpfile' ], 'ab' );
131
- }
132
- } else {
133
- $this->handle = $args[ 'dumpfilehandle' ];
134
- }
135
-
136
- //check file handle
137
- if ( ! is_resource( $this->handle ) )
138
- throw new BackWPup_MySQLDump_Exception( __( 'Cannot open SQL backup file', 'backwpup' ) );
139
-
140
- //get table names and types from Database
141
- $res = $this->mysqli->query( 'SHOW FULL TABLES FROM `' . $this->dbname . '`' );
142
- $GLOBALS[ 'wpdb' ]->num_queries ++;
143
- if ( $this->mysqli->error )
144
- throw new BackWPup_MySQLDump_Exception( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, 'SHOW FULL TABLES FROM `' . $this->dbname . '`' ) );
145
- while ( $table = $res->fetch_array( MYSQLI_NUM ) ) {
146
- $this->tables_to_dump[] = $table[ 0 ];
147
- $this->table_types[ $table[ 0 ] ] = $table[ 1 ];
148
- }
149
- $res->close();
150
-
151
- //get table info
152
- $res = $this->mysqli->query( "SHOW TABLE STATUS FROM `" . $this->dbname . "`" );
153
- $GLOBALS[ 'wpdb' ]->num_queries ++;
154
- if ( $this->mysqli->error )
155
- throw new BackWPup_MySQLDump_Exception( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, "SHOW TABLE STATUS FROM `" .$this->dbname . "`" ) );
156
- while ( $tablestatus = $res->fetch_assoc() ) {
157
- $this->table_status[ $tablestatus[ 'Name' ] ] = $tablestatus;
158
- }
159
- $res->close();
160
- }
161
-
162
- /**
163
- * Start the dump
164
- */
165
- public function execute() {
166
-
167
- //increase time limit
168
- @set_time_limit( 0 );
169
- //write dump head
170
- $this->dump_head();
171
- //write tables
172
- foreach( $this->tables_to_dump as $table ) {
173
- $records = $this->dump_table_head( $table );
174
- if ( $records > 0 ) {
175
- $this->dump_table( $table, 0 , $records );
176
- $this->dump_table_footer( $table );
177
- }
178
- }
179
- //write footer
180
- $this->dump_footer();
181
-
182
- }
183
-
184
- /**
185
- * Write Dump Header
186
- *
187
- * @param bool $wp_info Dump WordPress info in dump head
188
- */
189
- public function dump_head( $wp_info = FALSE ) {
190
-
191
- // get sql timezone
192
- $res = $this->mysqli->query( "SELECT @@time_zone" );
193
- $GLOBALS[ 'wpdb' ]->num_queries ++;
194
- $mysqltimezone = $res->fetch_row();
195
- $mysqltimezone = $mysqltimezone[0];
196
- $res->close();
197
-
198
-
199
- //For SQL always use \n as MySQL wants this on all platforms.
200
- $dbdumpheader = "-- ---------------------------------------------------------\n";
201
- $dbdumpheader .= "-- Backup with BackWPup ver.: " . BackWPup::get_plugin_data( 'Version' ) . "\n";
202
- $dbdumpheader .= "-- https://marketpress.de/product/backwpup-pro/\n";
203
- if ( $wp_info ) {
204
- $dbdumpheader .= "-- Blog Name: " . get_bloginfo( 'name' ) . "\n";
205
- $dbdumpheader .= "-- Blog URL: " . trailingslashit( get_bloginfo( 'url' ) ) . "\n";
206
- $dbdumpheader .= "-- Blog ABSPATH: " . trailingslashit( str_replace( '\\', '/', ABSPATH ) ) . "\n";
207
- $dbdumpheader .= "-- Blog Charset: " . get_bloginfo( 'charset' ) . "\n";
208
- $dbdumpheader .= "-- Table Prefix: " . $GLOBALS[ 'wpdb' ]->prefix . "\n";
209
- }
210
- $dbdumpheader .= "-- Database Name: " . $this->dbname . "\n";
211
- $dbdumpheader .= "-- Backup on: " . date_i18n( 'Y-m-d H:i.s' ) . "\n";
212
- $dbdumpheader .= "-- ---------------------------------------------------------\n\n";
213
- //for better import with mysql client
214
- $dbdumpheader .= "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n";
215
- $dbdumpheader .= "/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\n";
216
- $dbdumpheader .= "/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\n";
217
- $dbdumpheader .= "/*!40101 SET NAMES " . $this->mysqli->character_set_name() . " */;\n";
218
- $dbdumpheader .= "/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;\n";
219
- $dbdumpheader .= "/*!40103 SET TIME_ZONE='" . $mysqltimezone . "' */;\n";
220
- $dbdumpheader .= "/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;\n";
221
- $dbdumpheader .= "/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;\n";
222
- $dbdumpheader .= "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;\n";
223
- $dbdumpheader .= "/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;\n\n";
224
- $this->write( $dbdumpheader );
225
- }
226
-
227
- /**
228
- * Write Dump Footer with dump of functions and procedures
229
- */
230
- public function dump_footer() {
231
-
232
- //dump procedures and functions
233
- $this->write( "\n--\n-- Backup routines for database '" . $this->dbname . "'\n--\n" );
234
-
235
- //dump Functions
236
- $res = $this->mysqli->query( "SHOW FUNCTION STATUS" );
237
- $GLOBALS[ 'wpdb' ]->num_queries ++;
238
- if ( $this->mysqli->error ) {
239
- trigger_error( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, "SHOW FUNCTION STATUS" ), E_USER_WARNING );
240
- } else {
241
- while ( $function_status = $res->fetch_assoc() ) {
242
- if ( $this->dbname != $function_status[ 'Db' ] )
243
- continue;
244
- $create = "\n--\n-- Function structure for " . $function_status[ 'Name' ] . "\n--\n\n";
245
- $create .= "DROP FUNCTION IF EXISTS `" . $function_status[ 'Name' ] . "`;\n";
246
- $create .= "/*!40101 SET @saved_cs_client = @@character_set_client */;\n";
247
- $create .= "/*!40101 SET character_set_client = '" . $this->mysqli->character_set_name() . "' */;\n";
248
- //Dump the view structure
249
- $res2 = $this->mysqli->query( "SHOW CREATE FUNCTION `" . $function_status[ 'Db' ] . "`.`" . $function_status[ 'Name' ] . "`" );
250
- $GLOBALS[ 'wpdb' ]->num_queries ++;
251
- if ( $this->mysqli->error )
252
- trigger_error( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, "SHOW CREATE FUNCTION `" . $function_status[ 'Db' ] . "`.`" . $function_status[ 'Name' ] . "`" ), E_USER_WARNING );
253
- $create_function = $res2->fetch_assoc();
254
- $res2->close();
255
- $create .= $create_function[ 'Create Function' ] . ";\n";
256
- $create .= "/*!40101 SET character_set_client = @saved_cs_client */;\n";
257
- $this->write( $create );
258
- }
259
- $res->close();
260
- }
261
-
262
- //dump Procedures
263
- $res = $this->mysqli->query( "SHOW PROCEDURE STATUS" );
264
- $GLOBALS[ 'wpdb' ]->num_queries ++;
265
- if ( $this->mysqli->error ) {
266
- trigger_error( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, "SHOW PROCEDURE STATUS" ), E_USER_WARNING );
267
- } else {
268
- while ( $procedure_status = $res->fetch_assoc() ) {
269
- if ( $this->dbname != $procedure_status[ 'Db' ] )
270
- continue;
271
- $create = "\n--\n-- Procedure structure for " . $procedure_status[ 'Name' ] . "\n--\n\n";
272
- $create .= "DROP PROCEDURE IF EXISTS `" . $procedure_status[ 'Name' ] . "`;\n";
273
- $create .= "/*!40101 SET @saved_cs_client = @@character_set_client */;\n";
274
- $create .= "/*!40101 SET character_set_client = '" . $this->mysqli->character_set_name() . "' */;\n";
275
- //Dump the view structure
276
- $res2 = $this->mysqli->query( "SHOW CREATE PROCEDURE `" . $procedure_status[ 'Db' ] . "`.`" . $procedure_status[ 'Name' ] . "`" );
277
- $GLOBALS[ 'wpdb' ]->num_queries ++;
278
- if ( $this->mysqli->error )
279
- trigger_error( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, "SHOW CREATE PROCEDURE `" . $procedure_status[ 'Db' ] . "`.`" . $procedure_status[ 'Name' ] . "`" ), E_USER_WARNING );
280
- $create_procedure = $res2->fetch_assoc();
281
- $res2->close();
282
- $create .= $create_procedure[ 'Create Procedure' ] . ";\n";
283
- $create .= "/*!40101 SET character_set_client = @saved_cs_client */;\n";
284
- $this->write( $create );
285
- }
286
- $res->close();
287
- }
288
-
289
- //for better import with mysql client
290
- $dbdumpfooter = "\n/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;\n";
291
- $dbdumpfooter .= "/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;\n";
292
- $dbdumpfooter .= "/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;\n";
293
- $dbdumpfooter .= "/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;\n";
294
- $dbdumpfooter .= "/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n";
295
- $dbdumpfooter .= "/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\n";
296
- $dbdumpfooter .= "/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;\n";
297
- $dbdumpfooter .= "/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;\n";
298
- $dbdumpfooter .= "\n-- Backup completed on " . date_i18n( 'Y-m-d H:i:s' ). "\n";
299
- $this->write( $dbdumpfooter );
300
- }
301
-
302
-
303
- /**
304
- * Dump table structure
305
- *
306
- * @param string $table name of Table to dump
307
- * @throws BackWPup_MySQLDump_Exception
308
- * @return int Size of table
309
- */
310
- public function dump_table_head( $table ) {
311
-
312
- //dump View
313
- if ( $this->table_types[ $table ] == 'VIEW' ) {
314
- $tablecreate = "\n--\n-- View structure for `" . $table . "`\n--\n\n";
315
- $tablecreate .= "DROP VIEW IF EXISTS `" . $table . "`;\n";
316
- $tablecreate .= "/*!40101 SET @saved_cs_client = @@character_set_client */;\n";
317
- $tablecreate .= "/*!40101 SET character_set_client = '" . $this->mysqli->character_set_name() . "' */;\n";
318
- //Dump the view structure
319
- $res = $this->mysqli->query( "SHOW CREATE VIEW `" . $table . "`" );
320
- $GLOBALS[ 'wpdb' ]->num_queries ++;
321
- if ( $this->mysqli->error )
322
- trigger_error( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, "SHOW CREATE VIEW `" . $table . "`" ), E_USER_WARNING );
323
- $createview = $res->fetch_assoc();
324
- $res->close();
325
- $tablecreate .= $createview[ 'Create View' ] . ";\n";
326
- $tablecreate .= "/*!40101 SET character_set_client = @saved_cs_client */;\n";
327
- $this->write( $tablecreate );
328
-
329
- return 0;
330
- }
331
-
332
- if ( $this->table_types[ $table ] != 'BASE TABLE' )
333
- return 0;
334
-
335
- //dump normal Table
336
- $tablecreate = "\n--\n-- Table structure for `" . $table . "`\n--\n\n";
337
- $tablecreate .= "DROP TABLE IF EXISTS `" . $table . "`;\n";
338
- $tablecreate .= "/*!40101 SET @saved_cs_client = @@character_set_client */;\n";
339
- $tablecreate .= "/*!40101 SET character_set_client = '" . $this->mysqli->character_set_name() . "' */;\n";
340
- //Dump the table structure
341
- $res = $this->mysqli->query( "SHOW CREATE TABLE `" . $table . "`" );
342
- $GLOBALS[ 'wpdb' ]->num_queries ++;
343
- if ( $this->mysqli->error )
344
- trigger_error( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, "SHOW CREATE TABLE `" . $table . "`" ), E_USER_WARNING );
345
- $createtable = $res->fetch_assoc();
346
- $res->close();
347
- $tablecreate .= $createtable[ 'Create Table' ] . ";\n";
348
- $tablecreate .= "/*!40101 SET character_set_client = @saved_cs_client */;\n";
349
- $this->write( $tablecreate );
350
-
351
- if ( $this->table_status[ $table ][ 'Rows' ] > 0 ) {
352
- //Dump Table data
353
- $this->write( "\n--\n-- Backup data for table `" . $table . "`\n--\n\nLOCK TABLES `" . $table . "` WRITE;\n/*!40000 ALTER TABLE `" . $table . "` DISABLE KEYS */;\n" );
354
- }
355
-
356
- return $this->table_status[ $table ][ 'Rows' ];
357
-
358
- }
359
-
360
- /**
361
- * Dump table footer
362
- *
363
- * @param string $table name of Table to dump
364
- * @return int Size of table
365
- */
366
- public function dump_table_footer( $table ) {
367
-
368
- $this->write( "/*!40000 ALTER TABLE `" . $table . "` ENABLE KEYS */;\nUNLOCK TABLES;\n" );
369
- }
370
-
371
- /**
372
- * Dump table Data
373
- *
374
- * @param string $table name of Table to dump
375
- * @param int $start Start of lengh paramter
376
- * @param int $length how many
377
- * @return int done records in this backup
378
- * @throws BackWPup_MySQLDump_Exception
379
- */
380
- public function dump_table( $table, $start, $length = 100 ) {
381
-
382
- if ( ! is_numeric( $start ) )
383
- throw new BackWPup_MySQLDump_Exception( sprintf( __( 'Start for table backup is not correctly set: %1$s ', 'backwpup' ), $start ) );
384
-
385
- if ( ! is_numeric( $length ) )
386
- throw new BackWPup_MySQLDump_Exception( sprintf( __( 'Length for table backup is not correctly set: %1$s ', 'backwpup' ), $length ) );
387
-
388
- if ( $length == 0 )
389
- return;
390
-
391
- $done_records = 0;
392
- //get data from table
393
- $res = $this->mysqli->query( "SELECT * FROM `" . $table . "` LIMIT " . $start . ", " . $length, MYSQLI_USE_RESULT );
394
- $GLOBALS[ 'wpdb' ]->num_queries ++;
395
- if ( $this->mysqli->error )
396
- trigger_error( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, "SELECT * FROM `" . $table . "`" ), E_USER_WARNING );
397
-
398
- $fieldsarray = array();
399
- $fieldinfo = array();
400
- $fields = $res->fetch_fields();
401
- $i = 0;
402
- foreach ( $fields as $filed ) {
403
- $fieldsarray[ $i ] = $filed->orgname;
404
- $fieldinfo[ $fieldsarray[ $i ] ] = $filed;
405
- $i ++;
406
- }
407
-
408
- $dump = '';
409
- while ( $data = $res->fetch_assoc() ) {
410
- $values = array();
411
- foreach ( $data as $key => $value ) {
412
- if ( is_null( $value ) || ! isset( $value ) ) // Make Value NULL to string NULL
413
- $value = "NULL";
414
- elseif ( in_array($fieldinfo[ $key ]->type, array( MYSQLI_TYPE_DECIMAL, MYSQLI_TYPE_TINY, MYSQLI_TYPE_SHORT, MYSQLI_TYPE_LONG, MYSQLI_TYPE_FLOAT, MYSQLI_TYPE_DOUBLE, MYSQLI_TYPE_LONGLONG, MYSQLI_TYPE_INT24 ) ) ) //is value numeric no esc
415
- $value = empty( $value ) ? 0 : $value;
416
- else
417
- $value = "'" . $this->mysqli->real_escape_string( $value ) . "'";
418
- $values[ ] = $value;
419
- }
420
- //new query in dump on more than 50000 chars.
421
- if ( empty( $dump ) )
422
- $dump = "INSERT INTO `" . $table . "` (`" . implode( "`, `", $fieldsarray ) . "`) VALUES \n";
423
- if ( strlen( $dump ) <= 50000 ) {
424
- $dump .= "(" . implode( ", ", $values ) . "),\n";
425
- } else {
426
- $dump .= "(" . implode( ", ", $values ) . ");\n";
427
- $this->write( $dump );
428
- $dump = '';
429
- }
430
- $done_records ++;
431
- }
432
- if ( ! empty( $dump ) ) {
433
- $dump = substr( $dump, 0, -2 ) . ";\n" ;
434
- $this->write( $dump );
435
- }
436
- $res->close();
437
-
438
- return $done_records;
439
- }
440
-
441
- /**
442
- * Writes data to handle and compress
443
- *
444
- * @param $data string to write
445
- * @throws BackWPup_MySQLDump_Exception
446
- */
447
- private function write( $data ) {
448
-
449
- $written = fwrite( $this->handle, $data );
450
-
451
- if ( ! $written )
452
- throw new BackWPup_MySQLDump_Exception( __( 'Error while writing file!', 'backwpup' ) );
453
- }
454
-
455
- /**
456
- * Closes all confections on shutdown.
457
- */
458
- public function __destruct() {
459
-
460
- //close MySQL connection
461
- $this->mysqli->close();
462
- //close file handle
463
- if ( is_resource( $this->handle ) )
464
- fclose( $this->handle );
465
- }
466
-
467
- }
468
-
469
- /**
470
- * Exception Handler
471
- */
472
- class BackWPup_MySQLDump_Exception extends Exception { }
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class to create a MYSQL dump with mysqli as sql file
4
+ */
5
+ class BackWPup_MySQLDump {
6
+
7
+ /**
8
+ * Holder for mysqli recourse
9
+ */
10
+ private $mysqli = NULL;
11
+
12
+ /**
13
+ * Holder for dump file handle
14
+ */
15
+ private $handle = NULL;
16
+
17
+ /**
18
+ * Table names of Tables in Database
19
+ */
20
+ public $tables_to_dump = array();
21
+
22
+ /**
23
+ * Table names of Tables in Database
24
+ */
25
+ private $table_types = array();
26
+
27
+ /**
28
+ * Table information of Tables in Database
29
+ */
30
+ private $table_status = array();
31
+
32
+ /**
33
+ * Database name
34
+ */
35
+ private $dbname = '';
36
+
37
+ /**
38
+ * Compression to use
39
+ * empty for none
40
+ * gz for Gzip
41
+ */
42
+ private $compression = '';
43
+
44
+ /**
45
+ * Check params and makes confections
46
+ * gets the table information too
47
+ *
48
+ * @param $args array with arguments
49
+ * @throws BackWPup_MySQLDump_Exception
50
+ * @global $wpdb wpdb
51
+ */
52
+ public function __construct( $args = array() ) {
53
+
54
+ if ( ! class_exists( 'mysqli' ) )
55
+ throw new BackWPup_MySQLDump_Exception( __( 'No MySQLi extension found. Please install it.', 'backwpup' ) );
56
+
57
+ $default_args = array(
58
+ 'dbhost' => DB_HOST,
59
+ 'dbname' => DB_NAME,
60
+ 'dbuser' => DB_USER,
61
+ 'dbpassword' => DB_PASSWORD,
62
+ 'dbcharset' => defined( 'DB_CHARSET' ) ? DB_CHARSET : '',
63
+ 'dumpfilehandle' => fopen( 'php://output', 'wb' ),
64
+ 'dumpfile' => NULL,
65
+ 'compression' => ''
66
+ );
67
+
68
+ $args = wp_parse_args( $args , $default_args );
69
+
70
+ //set empty host to localhost
71
+ if ( empty( $args[ 'dbhost' ] ) )
72
+ $args[ 'dbhost' ] = NULL;
73
+
74
+ //check if port or socket in hostname and set port and socket
75
+ $args[ 'dbport' ] = NULL;
76
+ $args[ 'dbsocket' ] = NULL;
77
+ if ( strstr( $args[ 'dbhost' ], ':' ) ) {
78
+ $hostparts = explode( ':', $args[ 'dbhost' ], 2 );
79
+ $hostparts[ 0 ] = trim( $hostparts[ 0 ] );
80
+ $hostparts[ 1 ] = trim( $hostparts[ 1 ] );
81
+ if ( empty( $hostparts[ 0 ] ) )
82
+ $args[ 'dbhost' ] = NULL;
83
+ else
84
+ $args[ 'dbhost' ] = $hostparts[ 0 ];
85
+ if ( is_numeric( $hostparts[ 1 ] ) )
86
+ $args[ 'dbport' ] = (int) $hostparts[ 1 ];
87
+ else
88
+ $args[ 'dbsocket' ] = $hostparts[ 1 ];
89
+ }
90
+
91
+ $this->mysqli = mysqli_init();
92
+ if ( ! $this->mysqli )
93
+ throw new BackWPup_MySQLDump_Exception( __( 'Cannot init MySQLi database connection', 'backwpup' ) );
94
+
95
+ if ( ! empty( $args[ 'dbcharset' ] ) ) {
96
+ if ( ! $this->mysqli->options( MYSQLI_INIT_COMMAND, 'SET NAMES ' . $args[ 'dbcharset' ] . ';' ) )
97
+ throw new BackWPup_MySQLDump_Exception( sprintf( __( 'Setting of MySQLi init command "%s" failed', 'backwpup' ), 'SET NAMES ' . $args[ 'dbcharset' ] . ';' ) );
98
+ }
99
+
100
+ if ( ! $this->mysqli->options( MYSQLI_OPT_CONNECT_TIMEOUT, 5 ) )
101
+ throw new BackWPup_MySQLDump_Exception( __( 'Setting of MySQLi connection timeout failed', 'backwpup' ) );
102
+
103
+ //connect to Database
104
+ if ( ! $this->mysqli->real_connect( $args[ 'dbhost' ], $args[ 'dbuser' ], $args[ 'dbpassword' ], $args[ 'dbname' ], $args[ 'dbport' ], $args[ 'dbsocket' ] ) )
105
+ throw new BackWPup_MySQLDump_Exception( sprintf( __( 'Cannot connect to MySQL database %1$d: %2$s', 'backwpup' ), mysqli_connect_errno(), mysqli_connect_error() ) );
106
+
107
+ //set charset
108
+ if ( ! empty( $args[ 'dbcharset' ] ) && method_exists( $this->mysqli, 'set_charset' ) ) {
109
+ $res = $this->mysqli->set_charset( $args[ 'dbcharset' ] );
110
+ if ( ! $res )
111
+ throw new BackWPup_MySQLDump_Exception( sprintf( _x( 'Cannot set DB charset to %s','Database Charset', 'backwpup' ), $args[ 'dbcharset' ] ) );
112
+ }
113
+
114
+ //set db name
115
+ $this->dbname = $args[ 'dbname' ];
116
+
117
+ //set compression
118
+ if ( ! empty( $args[ 'compression' ] ) && in_array( $args[ 'compression' ], array( 'gz' ) ) )
119
+ $this->compression = $args[ 'compression' ];
120
+
121
+ //open file if set
122
+ if ( $args[ 'dumpfile' ] ) {
123
+ if ( substr( strtolower( $args[ 'dumpfile' ] ), -3 ) == '.gz' ) {
124
+ if ( ! function_exists( 'gzencode' ) )
125
+ throw new BackWPup_MySQLDump_Exception( __( 'Functions for gz compression not available', 'backwpup' ) );
126
+ $this->compression = 'gz';
127
+ $this->handle = fopen( 'compress.zlib://' . $args[ 'dumpfile' ], 'ab' );
128
+ } else {
129
+ $this->compression = '';
130
+ $this->handle = fopen( $args[ 'dumpfile' ], 'ab' );
131
+ }
132
+ } else {
133
+ $this->handle = $args[ 'dumpfilehandle' ];
134
+ }
135
+
136
+ //check file handle
137
+ if ( ! is_resource( $this->handle ) )
138
+ throw new BackWPup_MySQLDump_Exception( __( 'Cannot open SQL backup file', 'backwpup' ) );
139
+
140
+ //get table names and types from Database
141
+ $res = $this->mysqli->query( 'SHOW FULL TABLES FROM `' . $this->dbname . '`' );
142
+ $GLOBALS[ 'wpdb' ]->num_queries ++;
143
+ if ( $this->mysqli->error )
144
+ throw new BackWPup_MySQLDump_Exception( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, 'SHOW FULL TABLES FROM `' . $this->dbname . '`' ) );
145
+ while ( $table = $res->fetch_array( MYSQLI_NUM ) ) {
146
+ $this->tables_to_dump[] = $table[ 0 ];
147
+ $this->table_types[ $table[ 0 ] ] = $table[ 1 ];
148
+ }
149
+ $res->close();
150
+
151
+ //get table info
152
+ $res = $this->mysqli->query( "SHOW TABLE STATUS FROM `" . $this->dbname . "`" );
153
+ $GLOBALS[ 'wpdb' ]->num_queries ++;
154
+ if ( $this->mysqli->error )
155
+ throw new BackWPup_MySQLDump_Exception( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, "SHOW TABLE STATUS FROM `" .$this->dbname . "`" ) );
156
+ while ( $tablestatus = $res->fetch_assoc() ) {
157
+ $this->table_status[ $tablestatus[ 'Name' ] ] = $tablestatus;
158
+ }
159
+ $res->close();
160
+ }
161
+
162
+ /**
163
+ * Start the dump
164
+ */
165
+ public function execute() {
166
+
167
+ //increase time limit
168
+ @set_time_limit( 300 );
169
+ //write dump head
170
+ $this->dump_head();
171
+ //write tables
172
+ foreach( $this->tables_to_dump as $table ) {
173
+ $this->dump_table_head( $table );
174
+ $this->dump_table( $table );
175
+ $this->dump_table_footer( $table );
176
+ }
177
+ //write footer
178
+ $this->dump_footer();
179
+
180
+ }
181
+
182
+ /**
183
+ * Write Dump Header
184
+ *
185
+ * @param bool $wp_info Dump WordPress info in dump head
186
+ */
187
+ public function dump_head( $wp_info = FALSE ) {
188
+
189
+ // get sql timezone
190
+ $res = $this->mysqli->query( "SELECT @@time_zone" );
191
+ $GLOBALS[ 'wpdb' ]->num_queries ++;
192
+ $mysqltimezone = $res->fetch_row();
193
+ $mysqltimezone = $mysqltimezone[0];
194
+ $res->close();
195
+
196
+
197
+ //For SQL always use \n as MySQL wants this on all platforms.
198
+ $dbdumpheader = "-- ---------------------------------------------------------\n";
199
+ $dbdumpheader .= "-- Backup with BackWPup ver.: " . BackWPup::get_plugin_data( 'Version' ) . "\n";
200
+ $dbdumpheader .= "-- https://marketpress.de/product/backwpup-pro/\n";
201
+ if ( $wp_info ) {
202
+ $dbdumpheader .= "-- Blog Name: " . get_bloginfo( 'name' ) . "\n";
203
+ $dbdumpheader .= "-- Blog URL: " . trailingslashit( get_bloginfo( 'url' ) ) . "\n";
204
+ $dbdumpheader .= "-- Blog ABSPATH: " . trailingslashit( str_replace( '\\', '/', ABSPATH ) ) . "\n";
205
+ $dbdumpheader .= "-- Blog Charset: " . get_bloginfo( 'charset' ) . "\n";
206
+ $dbdumpheader .= "-- Table Prefix: " . $GLOBALS[ 'wpdb' ]->prefix . "\n";
207
+ }
208
+ $dbdumpheader .= "-- Database Name: " . $this->dbname . "\n";
209
+ $dbdumpheader .= "-- Backup on: " . date_i18n( 'Y-m-d H:i.s' ) . "\n";
210
+ $dbdumpheader .= "-- ---------------------------------------------------------\n\n";
211
+ //for better import with mysql client
212
+ $dbdumpheader .= "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n";
213
+ $dbdumpheader .= "/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\n";
214
+ $dbdumpheader .= "/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\n";
215
+ $dbdumpheader .= "/*!40101 SET NAMES " . $this->mysqli->character_set_name() . " */;\n";
216
+ $dbdumpheader .= "/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;\n";
217
+ $dbdumpheader .= "/*!40103 SET TIME_ZONE='" . $mysqltimezone . "' */;\n";
218
+ $dbdumpheader .= "/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;\n";
219
+ $dbdumpheader .= "/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;\n";
220
+ $dbdumpheader .= "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;\n";
221
+ $dbdumpheader .= "/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;\n\n";
222
+ $this->write( $dbdumpheader );
223
+ }
224
+
225
+ /**
226
+ * Write Dump Footer with dump of functions and procedures
227
+ */
228
+ public function dump_footer() {
229
+
230
+ //dump procedures and functions
231
+ $this->write( "\n--\n-- Backup routines for database '" . $this->dbname . "'\n--\n" );
232
+
233
+ //dump Functions
234
+ $res = $this->mysqli->query( "SHOW FUNCTION STATUS" );
235
+ $GLOBALS[ 'wpdb' ]->num_queries ++;
236
+ if ( $this->mysqli->error ) {
237
+ trigger_error( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, "SHOW FUNCTION STATUS" ), E_USER_WARNING );
238
+ } else {
239
+ while ( $function_status = $res->fetch_assoc() ) {
240
+ if ( $this->dbname != $function_status[ 'Db' ] )
241
+ continue;
242
+ $create = "\n--\n-- Function structure for " . $function_status[ 'Name' ] . "\n--\n\n";
243
+ $create .= "DROP FUNCTION IF EXISTS `" . $function_status[ 'Name' ] . "`;\n";
244
+ $create .= "/*!40101 SET @saved_cs_client = @@character_set_client */;\n";
245
+ $create .= "/*!40101 SET character_set_client = '" . $this->mysqli->character_set_name() . "' */;\n";
246
+ //Dump the view structure
247
+ $res2 = $this->mysqli->query( "SHOW CREATE FUNCTION `" . $function_status[ 'Db' ] . "`.`" . $function_status[ 'Name' ] . "`" );
248
+ $GLOBALS[ 'wpdb' ]->num_queries ++;
249
+ if ( $this->mysqli->error )
250
+ trigger_error( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, "SHOW CREATE FUNCTION `" . $function_status[ 'Db' ] . "`.`" . $function_status[ 'Name' ] . "`" ), E_USER_WARNING );
251
+ $create_function = $res2->fetch_assoc();
252
+ $res2->close();
253
+ $create .= $create_function[ 'Create Function' ] . ";\n";
254
+ $create .= "/*!40101 SET character_set_client = @saved_cs_client */;\n";
255
+ $this->write( $create );
256
+ }
257
+ $res->close();
258
+ }
259
+
260
+ //dump Procedures
261
+ $res = $this->mysqli->query( "SHOW PROCEDURE STATUS" );
262
+ $GLOBALS[ 'wpdb' ]->num_queries ++;
263
+ if ( $this->mysqli->error ) {
264
+ trigger_error( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, "SHOW PROCEDURE STATUS" ), E_USER_WARNING );
265
+ } else {
266
+ while ( $procedure_status = $res->fetch_assoc() ) {
267
+ if ( $this->dbname != $procedure_status[ 'Db' ] )
268
+ continue;
269
+ $create = "\n--\n-- Procedure structure for " . $procedure_status[ 'Name' ] . "\n--\n\n";
270
+ $create .= "DROP PROCEDURE IF EXISTS `" . $procedure_status[ 'Name' ] . "`;\n";
271
+ $create .= "/*!40101 SET @saved_cs_client = @@character_set_client */;\n";
272
+ $create .= "/*!40101 SET character_set_client = '" . $this->mysqli->character_set_name() . "' */;\n";
273
+ //Dump the view structure
274
+ $res2 = $this->mysqli->query( "SHOW CREATE PROCEDURE `" . $procedure_status[ 'Db' ] . "`.`" . $procedure_status[ 'Name' ] . "`" );
275
+ $GLOBALS[ 'wpdb' ]->num_queries ++;
276
+ if ( $this->mysqli->error )
277
+ trigger_error( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, "SHOW CREATE PROCEDURE `" . $procedure_status[ 'Db' ] . "`.`" . $procedure_status[ 'Name' ] . "`" ), E_USER_WARNING );
278
+ $create_procedure = $res2->fetch_assoc();
279
+ $res2->close();
280
+ $create .= $create_procedure[ 'Create Procedure' ] . ";\n";
281
+ $create .= "/*!40101 SET character_set_client = @saved_cs_client */;\n";
282
+ $this->write( $create );
283
+ }
284
+ $res->close();
285
+ }
286
+
287
+ //for better import with mysql client
288
+ $dbdumpfooter = "\n/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;\n";
289
+ $dbdumpfooter .= "/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;\n";
290
+ $dbdumpfooter .= "/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;\n";
291
+ $dbdumpfooter .= "/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;\n";
292
+ $dbdumpfooter .= "/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n";
293
+ $dbdumpfooter .= "/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\n";
294
+ $dbdumpfooter .= "/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;\n";
295
+ $dbdumpfooter .= "/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;\n";
296
+ $dbdumpfooter .= "\n-- Backup completed on " . date_i18n( 'Y-m-d H:i:s' ). "\n";
297
+ $this->write( $dbdumpfooter );
298
+ }
299
+
300
+
301
+ /**
302
+ * Dump table structure
303
+ *
304
+ * @param string $table name of Table to dump
305
+ * @throws BackWPup_MySQLDump_Exception
306
+ * @return int Size of table
307
+ */
308
+ public function dump_table_head( $table ) {
309
+
310
+ //dump View
311
+ if ( $this->table_types[ $table ] == 'VIEW' ) {
312
+ $tablecreate = "\n--\n-- View structure for `" . $table . "`\n--\n\n";
313
+ $tablecreate .= "DROP VIEW IF EXISTS `" . $table . "`;\n";
314
+ $tablecreate .= "/*!40101 SET @saved_cs_client = @@character_set_client */;\n";
315
+ $tablecreate .= "/*!40101 SET character_set_client = '" . $this->mysqli->character_set_name() . "' */;\n";
316
+ //Dump the view structure
317
+ $res = $this->mysqli->query( "SHOW CREATE VIEW `" . $table . "`" );
318
+ $GLOBALS[ 'wpdb' ]->num_queries ++;
319
+ if ( $this->mysqli->error )
320
+ trigger_error( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, "SHOW CREATE VIEW `" . $table . "`" ), E_USER_WARNING );
321
+ $createview = $res->fetch_assoc();
322
+ $res->close();
323
+ $tablecreate .= $createview[ 'Create View' ] . ";\n";
324
+ $tablecreate .= "/*!40101 SET character_set_client = @saved_cs_client */;\n";
325
+ $this->write( $tablecreate );
326
+
327
+ return 0;
328
+ }
329
+
330
+ if ( $this->table_types[ $table ] != 'BASE TABLE' )
331
+ return 0;
332
+
333
+ //dump normal Table
334
+ $tablecreate = "\n--\n-- Table structure for `" . $table . "`\n--\n\n";
335
+ $tablecreate .= "DROP TABLE IF EXISTS `" . $table . "`;\n";
336
+ $tablecreate .= "/*!40101 SET @saved_cs_client = @@character_set_client */;\n";
337
+ $tablecreate .= "/*!40101 SET character_set_client = '" . $this->mysqli->character_set_name() . "' */;\n";
338
+ //Dump the table structure
339
+ $res = $this->mysqli->query( "SHOW CREATE TABLE `" . $table . "`" );
340
+ $GLOBALS[ 'wpdb' ]->num_queries ++;
341
+ if ( $this->mysqli->error )
342
+ trigger_error( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, "SHOW CREATE TABLE `" . $table . "`" ), E_USER_WARNING );
343
+ $createtable = $res->fetch_assoc();
344
+ $res->close();
345
+ $tablecreate .= $createtable[ 'Create Table' ] . ";\n";
346
+ $tablecreate .= "/*!40101 SET character_set_client = @saved_cs_client */;\n";
347
+ $this->write( $tablecreate );
348
+
349
+ if ( $this->table_status[ $table ][ 'Engine' ] !== 'MyISAM' ) {
350
+ $this->table_status[ $table ][ 'Rows' ] = '~' . $this->table_status[ $table ][ 'Rows' ];
351
+ }
352
+
353
+ if ( $this->table_status[ $table ][ 'Rows' ] !== 0 ) {
354
+ //Dump Table data
355
+ $this->write( "\n--\n-- Backup data for table `" . $table . "`\n--\n\nLOCK TABLES `" . $table . "` WRITE;\n/*!40000 ALTER TABLE `" . $table . "` DISABLE KEYS */;\n" );
356
+ }
357
+
358
+ return $this->table_status[ $table ][ 'Rows' ];
359
+
360
+ }
361
+
362
+ /**
363
+ * Dump table footer
364
+ *
365
+ * @param string $table name of Table to dump
366
+ * @return int Size of table
367
+ */
368
+ public function dump_table_footer( $table ) {
369
+
370
+ if ( $this->table_status[ $table ][ 'Rows' ] !== 0 ) {
371
+ $this->write( "/*!40000 ALTER TABLE `" . $table . "` ENABLE KEYS */;\nUNLOCK TABLES;\n" );
372
+ }
373
+ }
374
+
375
+
376
+ /**
377
+ * Dump table Data
378
+ *
379
+ * @param string $table name of Table to dump
380
+ * @param int $start Start of lengh paramter
381
+ * @param int $length how many
382
+ * @return int done records in this backup
383
+ * @throws BackWPup_MySQLDump_Exception
384
+ */
385
+ public function dump_table( $table, $start = 0, $length = 0 ) {
386
+
387
+ if ( ! is_numeric( $start ) ) {
388
+ throw new BackWPup_MySQLDump_Exception( sprintf( __( 'Start for table backup is not correctly set: %1$s ', 'backwpup' ), $start ) );
389
+ }
390
+
391
+ if ( ! is_numeric( $length ) ) {
392
+ throw new BackWPup_MySQLDump_Exception( sprintf( __( 'Length for table backup is not correctly set: %1$s ', 'backwpup' ), $length ) );
393
+ }
394
+
395
+ $done_records = 0;
396
+ //get data from table
397
+ if ( $length == 0 && $start == 0 ) {
398
+ $res = $this->mysqli->query( "SELECT * FROM `" . $table . "` ", MYSQLI_USE_RESULT );
399
+ } else {
400
+ $res = $this->mysqli->query( "SELECT * FROM `" . $table . "` LIMIT " . $start . ", " . $length, MYSQLI_USE_RESULT );
401
+ }
402
+ $GLOBALS[ 'wpdb' ]->num_queries ++;
403
+ if ( $this->mysqli->error )
404
+ trigger_error( sprintf( __( 'Database error %1$s for query %2$s', 'backwpup' ), $this->mysqli->error, "SELECT * FROM `" . $table . "`" ), E_USER_WARNING );
405
+
406
+ $fieldsarray = array();
407
+ $fieldinfo = array();
408
+ $fields = $res->fetch_fields();
409
+ $i = 0;
410
+ foreach ( $fields as $filed ) {
411
+ $fieldsarray[ $i ] = $filed->orgname;
412
+ $fieldinfo[ $fieldsarray[ $i ] ] = $filed;
413
+ $i ++;
414
+ }
415
+
416
+ $dump = '';
417
+ while ( $data = $res->fetch_assoc() ) {
418
+ $values = array();
419
+ foreach ( $data as $key => $value ) {
420
+ if ( is_null( $value ) || ! isset( $value ) ) // Make Value NULL to string NULL
421
+ $value = "NULL";
422
+ elseif ( in_array($fieldinfo[ $key ]->type, array( MYSQLI_TYPE_DECIMAL, MYSQLI_TYPE_TINY, MYSQLI_TYPE_SHORT, MYSQLI_TYPE_LONG, MYSQLI_TYPE_FLOAT, MYSQLI_TYPE_DOUBLE, MYSQLI_TYPE_LONGLONG, MYSQLI_TYPE_INT24 ) ) ) //is value numeric no esc
423
+ $value = empty( $value ) ? 0 : $value;
424
+ else
425
+ $value = "'" . $this->mysqli->real_escape_string( $value ) . "'";
426
+ $values[ ] = $value;
427
+ }
428
+ //new query in dump on more than 50000 chars.
429
+ if ( empty( $dump ) )
430
+ $dump = "INSERT INTO `" . $table . "` (`" . implode( "`, `", $fieldsarray ) . "`) VALUES \n";
431
+ if ( strlen( $dump ) <= 50000 ) {
432
+ $dump .= "(" . implode( ", ", $values ) . "),\n";
433
+ } else {
434
+ $dump .= "(" . implode( ", ", $values ) . ");\n";
435
+ $this->write( $dump );
436
+ $dump = '';
437
+ }
438
+ $done_records ++;
439
+ }
440
+ if ( ! empty( $dump ) ) {
441
+ $dump = substr( $dump, 0, -2 ) . ";\n" ;
442
+ $this->write( $dump );
443
+ }
444
+ $res->close();
445
+
446
+ return $done_records;
447
+ }
448
+
449
+ /**
450
+ * Writes data to handle and compress
451
+ *
452
+ * @param $data string to write
453
+ * @throws BackWPup_MySQLDump_Exception
454
+ */
455
+ private function write( $data ) {
456
+
457
+ $written = fwrite( $this->handle, $data );
458
+
459
+ if ( ! $written )
460
+ throw new BackWPup_MySQLDump_Exception( __( 'Error while writing file!', 'backwpup' ) );
461
+ }
462
+
463
+ /**
464
+ * Closes all confections on shutdown.
465
+ */
466
+ public function __destruct() {
467
+
468
+ //close MySQL connection
469
+ $this->mysqli->close();
470
+ //close file handle
471
+ if ( is_resource( $this->handle ) )
472
+ fclose( $this->handle );
473
+ }
474
+
475
+ }
476
+
477
+ /**
478
+ * Exception Handler
479
+ */
480
+ class BackWPup_MySQLDump_Exception extends Exception { }
inc/class-option.php CHANGED
@@ -1,282 +1,285 @@
1
- <?php
2
- /**
3
- * Class for options
4
- */
5
- final class BackWPup_Option {
6
-
7
- /**
8
- *
9
- * add filter for Site option defaults
10
- *
11
- */
12
- public static function default_site_options() {
13
-
14
- //global
15
- add_site_option( 'backwpup_version', '0.0.0' );
16
- //job default
17
- add_site_option( 'backwpup_jobs', array() );
18
- //general
19
- add_site_option( 'backwpup_cfg_showadminbar', 1 );
20
- add_site_option( 'backwpup_cfg_showfoldersize', 0 );
21
- add_site_option( 'backwpup_cfg_protectfolders', 1 );
22
- //job
23
- add_site_option( 'backwpup_cfg_jobmaxexecutiontime', 0 );
24
- add_site_option( 'backwpup_cfg_jobziparchivemethod','' );
25
- add_site_option( 'backwpup_cfg_jobstepretry', 3 );
26
- add_site_option( 'backwpup_cfg_jobsteprestart', 0 );
27
- add_site_option( 'backwpup_cfg_jobrunauthkey', substr( md5( BackWPup::get_plugin_data( 'hash' ) ), 11, 8 ) );
28
- add_site_option( 'backwpup_cfg_jobnotranslate', 0 );
29
- add_site_option( 'backwpup_cfg_jobwaittimems', 0 );
30
- //Logs
31
- add_site_option( 'backwpup_cfg_maxlogs', 30 );
32
- add_site_option( 'backwpup_cfg_gzlogs', 0 );
33
- $upload_dir = wp_upload_dir();
34
- $logs_dir = trailingslashit( str_replace( '\\', '/',$upload_dir[ 'basedir' ] ) ) . 'backwpup-' . BackWPup::get_plugin_data( 'hash' ) . '-logs/';
35
- add_site_option( 'backwpup_cfg_logfolder', $logs_dir );
36
- //Network Auth
37
- add_site_option( 'backwpup_cfg_httpauthuser','' );
38
- add_site_option( 'backwpup_cfg_httpauthpassword', '' );
39
-
40
- }
41
-
42
-
43
- /**
44
- *
45
- * Load BackWPup Options
46
- *
47
- * @param bool $use_cache
48
- * @return array of options
49
- */
50
- private static function jobs_options( $use_cache = TRUE ) {
51
-
52
- if ( $use_cache )
53
- return get_site_option( 'backwpup_jobs' );
54
-
55
- if ( is_multisite() )
56
- return get_site_option( 'backwpup_jobs', array(), FALSE );
57
-
58
- //remove from options cache
59
- wp_cache_delete( 'backwpup_jobs', 'options' );
60
- //remove from all options
61
- $alloptions = wp_cache_get( 'alloptions', 'options' );
62
- if ( isset( $alloptions[ 'backwpup_jobs' ] ) ) {
63
- unset( $alloptions[ 'backwpup_jobs' ] );
64
- wp_cache_set( 'alloptions', $alloptions, 'options' );
65
- }
66
-
67
- return get_option( 'backwpup_jobs', array() );
68
- }
69
-
70
- /**
71
- *
72
- * Update BackWPup Options
73
- *
74
- * @param array $options The options array to save
75
- * @return bool updated or not
76
- */
77
- private static function update_jobs_options( $options ) {
78
-
79
- return update_site_option( 'backwpup_jobs', $options );
80
- }
81
-
82
-
83
- /**
84
- *
85
- * Get default option for BackWPup option
86
- *
87
- * @param string $key Option key
88
- * @internal param int $id The job id
89
- *
90
- * @return bool|mixed
91
- */
92
- public static function defaults_job( $key = '' ) {
93
-
94
- $key = sanitize_key( trim( $key ) );
95
-
96
- //set defaults
97
- $default[ 'type' ] = array( 'DBDUMP', 'FILE', 'WPPLUGIN' );
98
- $default[ 'destinations' ] = array();
99
- $default[ 'name' ] = __( 'New Job', 'backwpup' );
100
- $default[ 'activetype' ] = '';
101
- $default[ 'logfile' ] = '';
102
- $default[ 'lastbackupdownloadurl' ] = '';
103
- $default[ 'cronselect' ] = 'basic';
104
- $default[ 'cron' ] = '0 3 * * *';
105
- $default[ 'mailaddresslog' ] = sanitize_email( get_bloginfo( 'admin_email' ) );
106
- $default[ 'mailaddresssenderlog' ] = 'BackWPup ' . get_bloginfo( 'name' ) . ' <' . sanitize_email( get_bloginfo( 'admin_email' ) ).'>';
107
- $default[ 'mailerroronly' ] = TRUE;
108
- $default[ 'backuptype' ] = 'archive';
109
- $default[ 'archiveformat' ] = '.tar.gz';
110
- $default[ 'archivename' ] = 'backwpup_' . BackWPup::get_plugin_data( 'hash' ) . '_%Y-%m-%d_%H-%i-%s';
111
- //defaults vor destinations
112
- foreach ( BackWPup::get_registered_destinations() as $dest_key => $dest ) {
113
- if ( ! empty( $dest[ 'class' ] ) ) {
114
- $dest_object = BackWPup::get_destination( $dest_key );
115
- $default = array_merge( $default, $dest_object->option_defaults() );
116
- }
117
- }
118
- //defaults vor job types
119
- foreach ( BackWPup::get_job_types() as $job_type ) {
120
- $default = array_merge( $default, $job_type->option_defaults() );
121
- }
122
-
123
- //return all
124
- if ( empty( $key ) )
125
- return $default;
126
- //return one default setting
127
- if ( isset( $default[ $key ] ) )
128
- return $default[ $key ];
129
- else
130
- return FALSE;
131
- }
132
-
133
- /**
134
- *
135
- * Update a BackWPup option
136
- *
137
- * @param int $jobid the job id
138
- * @param string $option Option key
139
- * @param mixed $value the value to store
140
- *
141
- * @return bool if option save or not
142
- */
143
- public static function update( $jobid, $option, $value ) {
144
-
145
- $jobid = (int) $jobid;
146
- $option = sanitize_key( trim( $option ) );
147
-
148
- if ( empty( $jobid ) || empty( $option ) )
149
- return FALSE;
150
-
151
- //Update option
152
- $jobs_options = self::jobs_options( FALSE );
153
- $jobs_options[ $jobid ][ $option ] = $value;
154
- return self::update_jobs_options( $jobs_options );
155
- }
156
-
157
-
158
- /**
159
- *
160
- * Get a BackWPup Option
161
- *
162
- * @param int $jobid Option the job id
163
- * @param string $option Option key
164
- * @param mixed $default returned if no value, if null the the default BackWPup option will get
165
- * @param bool $use_cache USe the cache
166
- * @return bool|mixed false if nothing can get else the option value
167
- */
168
- public static function get( $jobid, $option, $default = NULL, $use_cache = TRUE ) {
169
-
170
- $jobid = (int) $jobid;
171
- $option = sanitize_key( trim( $option ) );
172
-
173
- if ( empty( $jobid ) || empty( $option ) )
174
- return FALSE;
175
-
176
- $jobs_options = self::jobs_options( $use_cache );
177
- if ( ! isset( $jobs_options[ $jobid ][ $option ] ) && isset( $default ) )
178
- return $default;
179
- elseif ( ! isset( $jobs_options[ $jobid ][ $option ] ) )
180
- return self::defaults_job( $option );
181
- else
182
- return $jobs_options[ $jobid ][ $option ];
183
- }
184
-
185
- /**
186
- *
187
- * BackWPup Job Options
188
- *
189
- * @param int $id The job id
190
- * @param bool $use_cache
191
- *
192
- * @return array of all job options
193
- */
194
- public static function get_job( $id, $use_cache = TRUE ) {
195
-
196
- if ( ! is_numeric( $id ) )
197
- return FALSE;
198
-
199
- $id = intval( $id );
200
- $jobs_options = self::jobs_options( $use_cache );
201
-
202
- return wp_parse_args( $jobs_options[ $id ], self::defaults_job( ) );
203
- }
204
-
205
-
206
- /**
207
- *
208
- * Delete a BackWPup Option
209
- *
210
- * @param int $jobid the job id
211
- * @param string $option Option key
212
- *
213
- * @return bool deleted or not
214
- */
215
- public static function delete( $jobid, $option ) {
216
-
217
- $jobid = (int) $jobid;
218
- $option = sanitize_key( trim( $option ) );
219
-
220
- if ( empty( $jobid ) || empty( $option ) )
221
- return FALSE;
222
-
223
- //delete option
224
- $jobs_options = self::jobs_options( FALSE );
225
- unset( $jobs_options[ $jobid ][ $option ] );
226
- return self::update_jobs_options( $jobs_options );
227
-
228
-
229
- }
230
-
231
- /**
232
- *
233
- * Delete a BackWPup Job
234
- *
235
- * @param int $id The job id
236
- *
237
- * @return bool deleted or not
238
- */
239
- public static function delete_job( $id ) {
240
-
241
- if ( ! is_numeric( $id ) )
242
- return FALSE;
243
-
244
- $id = intval( $id );
245
- $jobs_options = self::jobs_options( FALSE );
246
- unset( $jobs_options[ $id ] );
247
-
248
- return self::update_jobs_options( $jobs_options );
249
- }
250
-
251
- /**
252
- *
253
- * get the id's of jobs
254
- *
255
- * @param string|null $key Option key or null for getting all id's
256
- * @param bool $value Value that the option must have to get the id
257
- *
258
- * @return array job id's
259
- */
260
- public static function get_job_ids( $key = NULL, $value = FALSE ) {
261
-
262
- $key = sanitize_key( trim( $key ) );
263
- $jobs_options = self::jobs_options( FALSE );
264
-
265
- if ( empty( $jobs_options ) )
266
- return array();
267
-
268
- //get option job ids
269
- if ( empty( $key ) )
270
- return array_keys( $jobs_options );
271
-
272
- //get option ids for option with the defined value
273
- $new_option_job_ids = array();
274
- foreach ( $jobs_options as $id => $option ) {
275
- if ( isset( $option[ $key ] ) && $value == $option[ $key ] )
276
- $new_option_job_ids[ ] = $id;
277
- }
278
- sort( $new_option_job_ids );
279
-
280
- return $new_option_job_ids;
281
- }
282
- }
 
 
 
1
+ <?php
2
+ /**
3
+ * Class for options
4
+ */
5
+ final class BackWPup_Option {
6
+
7
+ /**
8
+ *
9
+ * add filter for Site option defaults
10
+ *
11
+ */
12
+ public static function default_site_options() {
13
+
14
+ //global
15
+ add_site_option( 'backwpup_version', '0.0.0' );
16
+ //job default
17
+ add_site_option( 'backwpup_jobs', array() );
18
+ //general
19
+ add_site_option( 'backwpup_cfg_showadminbar', 1 );
20
+ add_site_option( 'backwpup_cfg_showfoldersize', 0 );
21
+ add_site_option( 'backwpup_cfg_protectfolders', 1 );
22
+ //job
23
+ $max_execution_time = 0;
24
+ if ( strstr( PHP_SAPI, 'cgi' ) ) {
25
+ $max_execution_time = (int) ini_get( 'max_execution_time' );
26
+ }
27
+ add_site_option( 'backwpup_cfg_jobmaxexecutiontime', $max_execution_time );
28
+ add_site_option( 'backwpup_cfg_jobziparchivemethod','' );
29
+ add_site_option( 'backwpup_cfg_jobstepretry', 3 );
30
+ add_site_option( 'backwpup_cfg_jobrunauthkey', substr( md5( BackWPup::get_plugin_data( 'hash' ) ), 11, 8 ) );
31
+ add_site_option( 'backwpup_cfg_jobnotranslate', 0 );
32
+ add_site_option( 'backwpup_cfg_jobwaittimems', 0 );
33
+ //Logs
34
+ add_site_option( 'backwpup_cfg_maxlogs', 30 );
35
+ add_site_option( 'backwpup_cfg_gzlogs', 0 );
36
+ $upload_dir = wp_upload_dir();
37
+ $logs_dir = trailingslashit( str_replace( '\\', '/',$upload_dir[ 'basedir' ] ) ) . 'backwpup-' . BackWPup::get_plugin_data( 'hash' ) . '-logs/';
38
+ add_site_option( 'backwpup_cfg_logfolder', $logs_dir );
39
+ //Network Auth
40
+ add_site_option( 'backwpup_cfg_httpauthuser','' );
41
+ add_site_option( 'backwpup_cfg_httpauthpassword', '' );
42
+
43
+ }
44
+
45
+
46
+ /**
47
+ *
48
+ * Load BackWPup Options
49
+ *
50
+ * @param bool $use_cache
51
+ * @return array of options
52
+ */
53
+ private static function jobs_options( $use_cache = TRUE ) {
54
+
55
+ if ( $use_cache )
56
+ return get_site_option( 'backwpup_jobs' );
57
+
58
+ if ( is_multisite() )
59
+ return get_site_option( 'backwpup_jobs', array(), FALSE );
60
+
61
+ //remove from options cache
62
+ wp_cache_delete( 'backwpup_jobs', 'options' );
63
+ //remove from all options
64
+ $alloptions = wp_cache_get( 'alloptions', 'options' );
65
+ if ( isset( $alloptions[ 'backwpup_jobs' ] ) ) {
66
+ unset( $alloptions[ 'backwpup_jobs' ] );
67
+ wp_cache_set( 'alloptions', $alloptions, 'options' );
68
+ }
69
+
70
+ return get_option( 'backwpup_jobs', array() );
71
+ }
72
+
73
+ /**
74
+ *
75
+ * Update BackWPup Options
76
+ *
77
+ * @param array $options The options array to save
78
+ * @return bool updated or not
79
+ */
80
+ private static function update_jobs_options( $options ) {
81
+
82
+ return update_site_option( 'backwpup_jobs', $options );
83
+ }
84
+
85
+
86
+ /**
87
+ *
88
+ * Get default option for BackWPup option
89
+ *
90
+ * @param string $key Option key
91
+ * @internal param int $id The job id
92
+ *
93
+ * @return bool|mixed
94
+ */
95
+ public static function defaults_job( $key = '' ) {
96
+
97
+ $key = sanitize_key( trim( $key ) );
98
+
99
+ //set defaults
100
+ $default[ 'type' ] = array( 'DBDUMP', 'FILE', 'WPPLUGIN' );
101
+ $default[ 'destinations' ] = array();
102
+ $default[ 'name' ] = __( 'New Job', 'backwpup' );
103
+ $default[ 'activetype' ] = '';
104
+ $default[ 'logfile' ] = '';
105
+ $default[ 'lastbackupdownloadurl' ] = '';
106
+ $default[ 'cronselect' ] = 'basic';
107
+ $default[ 'cron' ] = '0 3 * * *';
108
+ $default[ 'mailaddresslog' ] = sanitize_email( get_bloginfo( 'admin_email' ) );
109
+ $default[ 'mailaddresssenderlog' ] = 'BackWPup ' . get_bloginfo( 'name' ) . ' <' . sanitize_email( get_bloginfo( 'admin_email' ) ).'>';
110
+ $default[ 'mailerroronly' ] = TRUE;
111
+ $default[ 'backuptype' ] = 'archive';
112
+ $default[ 'archiveformat' ] = '.tar.gz';
113
+ $default[ 'archivename' ] = 'backwpup_' . BackWPup::get_plugin_data( 'hash' ) . '_%Y-%m-%d_%H-%i-%s';
114
+ //defaults vor destinations
115
+ foreach ( BackWPup::get_registered_destinations() as $dest_key => $dest ) {
116
+ if ( ! empty( $dest[ 'class' ] ) ) {
117
+ $dest_object = BackWPup::get_destination( $dest_key );
118
+ $default = array_merge( $default, $dest_object->option_defaults() );
119
+ }
120
+ }
121
+ //defaults vor job types
122
+ foreach ( BackWPup::get_job_types() as $job_type ) {
123
+ $default = array_merge( $default, $job_type->option_defaults() );
124
+ }
125
+
126
+ //return all
127
+ if ( empty( $key ) )
128
+ return $default;
129
+ //return one default setting
130
+ if ( isset( $default[ $key ] ) )
131
+ return $default[ $key ];
132
+ else
133
+ return FALSE;
134
+ }
135
+
136
+ /**
137
+ *
138
+ * Update a BackWPup option
139
+ *
140
+ * @param int $jobid the job id
141
+ * @param string $option Option key
142
+ * @param mixed $value the value to store
143
+ *
144
+ * @return bool if option save or not
145
+ */
146
+ public static function update( $jobid, $option, $value ) {
147
+
148
+ $jobid = (int) $jobid;
149
+ $option = sanitize_key( trim( $option ) );
150
+
151
+ if ( empty( $jobid ) || empty( $option ) )
152
+ return FALSE;
153
+
154
+ //Update option
155
+ $jobs_options = self::jobs_options( FALSE );
156
+ $jobs_options[ $jobid ][ $option ] = $value;
157
+ return self::update_jobs_options( $jobs_options );
158
+ }
159
+
160
+
161
+ /**
162
+ *
163
+ * Get a BackWPup Option
164
+ *
165
+ * @param int $jobid Option the job id
166
+ * @param string $option Option key
167
+ * @param mixed $default returned if no value, if null the the default BackWPup option will get
168
+ * @param bool $use_cache USe the cache
169
+ * @return bool|mixed false if nothing can get else the option value
170
+ */
171
+ public static function get( $jobid, $option, $default = NULL, $use_cache = TRUE ) {
172
+
173
+ $jobid = (int) $jobid;
174
+ $option = sanitize_key( trim( $option ) );
175
+
176
+ if ( empty( $jobid ) || empty( $option ) )
177
+ return FALSE;
178
+
179
+ $jobs_options = self::jobs_options( $use_cache );
180
+ if ( ! isset( $jobs_options[ $jobid ][ $option ] ) && isset( $default ) )
181
+ return $default;
182
+ elseif ( ! isset( $jobs_options[ $jobid ][ $option ] ) )
183
+ return self::defaults_job( $option );
184
+ else
185
+ return $jobs_options[ $jobid ][ $option ];
186
+ }
187
+
188
+ /**
189
+ *
190
+ * BackWPup Job Options
191
+ *
192
+ * @param int $id The job id
193
+ * @param bool $use_cache
194
+ *
195
+ * @return array of all job options
196
+ */
197
+ public static function get_job( $id, $use_cache = TRUE ) {
198
+
199
+ if ( ! is_numeric( $id ) )
200
+ return FALSE;
201
+
202
+ $id = intval( $id );
203
+ $jobs_options = self::jobs_options( $use_cache );
204
+
205
+ return wp_parse_args( $jobs_options[ $id ], self::defaults_job( ) );
206
+ }
207
+
208
+
209
+ /**
210
+ *
211
+ * Delete a BackWPup Option
212
+ *
213
+ * @param int $jobid the job id
214
+ * @param string $option Option key
215
+ *
216
+ * @return bool deleted or not
217
+ */
218
+ public static function delete( $jobid, $option ) {
219
+
220
+ $jobid = (int) $jobid;
221
+ $option = sanitize_key( trim( $option ) );
222
+
223
+ if ( empty( $jobid ) || empty( $option ) )
224
+ return FALSE;
225
+
226
+ //delete option
227
+ $jobs_options = self::jobs_options( FALSE );
228
+ unset( $jobs_options[ $jobid ][ $option ] );
229
+ return self::update_jobs_options( $jobs_options );
230
+
231
+
232
+ }
233
+
234
+ /**
235
+ *
236
+ * Delete a BackWPup Job
237
+ *
238
+ * @param int $id The job id
239
+ *
240
+ * @return bool deleted or not
241
+ */
242
+ public static function delete_job( $id ) {
243
+
244
+ if ( ! is_numeric( $id ) )
245
+ return FALSE;
246
+
247
+ $id = intval( $id );
248
+ $jobs_options = self::jobs_options( FALSE );
249
+ unset( $jobs_options[ $id ] );
250
+
251
+ return self::update_jobs_options( $jobs_options );
252
+ }
253
+
254
+ /**
255
+ *
256
+ * get the id's of jobs
257
+ *
258
+ * @param string|null $key Option key or null for getting all id's
259
+ * @param bool $value Value that the option must have to get the id
260
+ *
261
+ * @return array job id's
262
+ */
263
+ public static function get_job_ids( $key = NULL, $value = FALSE ) {
264
+
265
+ $key = sanitize_key( trim( $key ) );
266
+ $jobs_options = self::jobs_options( FALSE );
267
+
268
+ if ( empty( $jobs_options ) )
269
+ return array();
270
+
271
+ //get option job ids
272
+ if ( empty( $key ) )
273
+ return array_keys( $jobs_options );
274
+
275
+ //get option ids for option with the defined value
276
+ $new_option_job_ids = array();
277
+ foreach ( $jobs_options as $id => $option ) {
278
+ if ( isset( $option[ $key ] ) && $value == $option[ $key ] )
279
+ $new_option_job_ids[ ] = $id;
280
+ }
281
+ sort( $new_option_job_ids );
282
+
283
+ return $new_option_job_ids;
284
+ }
285
+ }
inc/class-page-about.php CHANGED
@@ -431,8 +431,8 @@ _e( 'Use your backup archives to save your entire WordPress installation includi
431
  </div>
432
  <?php } ?>
433
  <?php
434
- if ( class_exists( 'marketpress_autoupdate' ) && class_exists( 'BackWPup_Pro', FALSE ) ) :
435
- $autoupdate = $autoupdate = marketpress_autoupdate::get_instance( BackWPup::get_plugin_data( 'Slug' ) , BackWPup::get_plugin_data( 'MainFile' ) );
436
  if ( $autoupdate->license_check() == 'false' ) :
437
  $plugins = get_plugins();
438
  $localplugin = FALSE;
431
  </div>
432
  <?php } ?>
433
  <?php
434
+ if ( class_exists( 'BackWPup_Pro', FALSE ) ) :
435
+ $autoupdate = BackWPup_Pro_MarketPress_Autoupdate::get_instance( BackWPup::get_plugin_data( 'Slug' ) , BackWPup::get_plugin_data( 'MainFile' ) );
436
  if ( $autoupdate->license_check() == 'false' ) :
437
  $plugins = get_plugins();
438
  $localplugin = FALSE;
inc/class-page-backups.php CHANGED
@@ -1,472 +1,472 @@
1
- <?php
2
- /**
3
- *
4
- */
5
- class BackWPup_Page_Backups extends WP_List_Table {
6
-
7
- private static $listtable = NULL;
8
- private $destinations = array();
9
-
10
- /**
11
- * @var int
12
- */
13
- private $jobid = 1;
14
- /**
15
- * @var string
16
- */
17
- private $dest = 'FOLDER';
18
-
19
- /**
20
- *
21
- */
22
- function __construct() {
23
-
24
- parent::__construct( array(
25
- 'plural' => 'backups',
26
- 'singular' => 'backup',
27
- 'ajax' => TRUE
28
- ) );
29
-
30
- $this->destinations = BackWPup::get_registered_destinations();
31
-
32
- }
33
-
34
- /**
35
- * @return bool
36
- */
37
- function ajax_user_can() {
38
-
39
- return current_user_can( 'backwpup_backups' );
40
- }
41
-
42
- /**
43
- *
44
- */
45
- function prepare_items() {
46
-
47
- $per_page = $this->get_items_per_page( 'backwpupbackups_per_page' );
48
- if ( empty( $per_page ) || $per_page < 1 )
49
- $per_page = 20;
50
-
51
- $jobdest = '';
52
- if ( ! empty( $_GET[ 'jobdets-button-top' ] ) )
53
- $jobdest = $_GET[ 'jobdest-top' ];
54
- if( ! empty( $_GET[ 'jobdets-button-bottom' ] ) )
55
- $jobdest = $_GET[ 'jobdest-bottom' ];
56
-
57
- if ( empty( $jobdest ) ) {
58
- $jobdests = $this->get_destinations_list();
59
- if ( empty( $jobdests ) )
60
- $jobdests = array( '_' );
61
- $jobdest = $jobdests[ 0 ];
62
- $_GET[ 'jobdest-top' ] = $jobdests[ 0 ];
63
- $_GET[ 'jobdets-button-top' ] = 'empty';
64
- }
65
-
66
- list( $this->jobid, $this->dest ) = explode( '_', $jobdest );
67
-
68
- if ( ! empty( $this->destinations[ $this->dest ][ 'class' ] ) ) {
69
- $dest_object = BackWPup::get_destination( $this->dest );
70
- $this->items = $dest_object->file_get_list( $jobdest );
71
- }
72
-
73
- //if no items brake
74
- if ( ! $this->items ) {
75
- $this->items = '';
76
-
77
- return;
78
- }
79
-
80
- //Sorting
81
- $order = isset( $_GET[ 'order' ] ) ? $_GET[ 'order' ] : 'desc';
82
- $orderby = isset( $_GET[ 'orderby' ] ) ? $_GET[ 'orderby' ] : 'time';
83
- $tmp = Array();
84
- if ( $orderby == 'time' ) {
85
- if ( $order == 'asc' ) {
86
- foreach ( $this->items as &$ma ) {
87
- $tmp[ ] = & $ma[ "time" ];
88
- }
89
- array_multisort( $tmp, SORT_ASC, $this->items );
90
- }
91
- else {
92
- foreach ( $this->items as &$ma ) {
93
- $tmp[ ] = & $ma[ "time" ];
94
- }
95
- array_multisort( $tmp, SORT_DESC, $this->items );
96
- }
97
- }
98
- elseif ( $orderby == 'file' ) {
99
- if ( $order == 'asc' ) {
100
- foreach ( $this->items as &$ma ) {
101
- $tmp[ ] = & $ma[ "filename" ];
102
- }
103
- array_multisort( $tmp, SORT_ASC, $this->items );
104
- }
105
- else {
106
- foreach ( $this->items as &$ma ) {
107
- $tmp[ ] = & $ma[ "filename" ];
108
- }
109
- array_multisort( $tmp, SORT_DESC, $this->items );
110
- }
111
- }
112
- elseif ( $orderby == 'folder' ) {
113
- if ( $order == 'asc' ) {
114
- foreach ( $this->items as &$ma ) {
115
- $tmp[ ] = & $ma[ "folder" ];
116
- }
117
- array_multisort( $tmp, SORT_ASC, $this->items );
118
- }
119
- else {
120
- foreach ( $this->items as &$ma ) {
121
- $tmp[ ] = & $ma[ "folder" ];
122
- }
123
- array_multisort( $tmp, SORT_DESC, $this->items );
124
- }
125
- }
126
- elseif ( $orderby == 'size' ) {
127
- if ( $order == 'asc' ) {
128
- foreach ( $this->items as &$ma ) {
129
- $tmp[ ] = & $ma[ "filesize" ];
130
- }
131
- array_multisort( $tmp, SORT_ASC, $this->items );
132
- }
133
- else {
134
- foreach ( $this->items as &$ma ) {
135
- $tmp[ ] = & $ma[ "filesize" ];
136
- }
137
- array_multisort( $tmp, SORT_DESC, $this->items );
138
- }
139
- }
140
-
141
- $this->set_pagination_args( array(
142
- 'total_items' => count( $this->items ),
143
- 'per_page' => $per_page,
144
- 'jobdest' => $jobdest,
145
- 'orderby' => $orderby,
146
- 'order' => $order
147
- ) );
148
-
149
- //only display items on page
150
- $start = intval( ( $this->get_pagenum() - 1 ) * $per_page );
151
- $end = $start + $per_page;
152
- if ( $end > count( $this->items ) )
153
- $end = count( $this->items );
154
-
155
- $i = -1;
156
- foreach ( $this->items as $item ) {
157
- $i++;
158
- if ( $i < $start )
159
- continue;
160
- if ( $i >= $end )
161
- break;
162
- $paged_items[] = $item;
163
- }
164
-
165
- $this->items = $paged_items;
166
-
167
- }
168
-
169
- /**
170
- *
171
- */
172
- function no_items() {
173
- _e( 'No files could be found. (List will be generated during next backup.)', 'backwpup' );
174
- }
175
-
176
- /**
177
- * @return array
178
- */
179
- function get_bulk_actions() {
180
-
181
- if ( ! $this->has_items() )
182
- return array ();
183
-
184
- $actions = array();
185
- $actions[ 'delete' ] = __( 'Delete', 'backwpup' );
186
-
187
- return $actions;
188
- }
189
-
190
- /**
191
- * @param $which
192
- *
193
- * @return mixed
194
- */
195
- function extra_tablenav( $which ) {
196
-
197
- $destinations_list = $this->get_destinations_list();
198
-
199
- if ( count( $destinations_list ) < 1)
200
- return;
201
-
202
- if ( count( $destinations_list ) == 1 ) {
203
- echo '<input type="hidden" name="jobdest-' . $which . '" value="' . $destinations_list[0] . '">';
204
- return;
205
- }
206
-
207
- ?>
208
- <div class="alignleft actions">
209
- <label for="jobdest-<?php echo $which;?>">
210
- <select name="jobdest-<?php echo $which;?>" class="postform" id="jobdest-<?php echo $which;?>">
211
- <?php
212
- foreach ( $destinations_list as $jobdest ) {
213
- list( $jobid, $dest ) = explode( '_', $jobdest );
214
- echo "\t<option value=\"" . $jobdest . "\" " . selected( $this->jobid . '_' . $this->dest, $jobdest, false ) . ">" . $dest . ": " . esc_html( BackWPup_Option::get( $jobid, 'name' ) ) . "</option>" . PHP_EOL;
215
- }
216
- ?>
217
- </select>
218
- </label>
219
- <?php submit_button( __( 'Change destination', 'backwpup' ), 'secondary', 'jobdets-button-' . $which, FALSE, array( 'id' => 'query-submit-'.$which ) ); ?>
220
- </div>
221
- <?php
222
- }
223
-
224
- /**
225
- * @return array
226
- */
227
- function get_destinations_list() {
228
-
229
- $jobdest = array();
230
- $jobids = BackWPup_Option::get_job_ids();
231
-
232
- if ( ! empty( $jobids ) ) {
233
- foreach ( $jobids as $jobid ) {
234
- if ( BackWPup_Option::get( $jobid, 'backuptype' ) == 'sync' ) // jump over sync
235
- continue;
236
- $dests = BackWPup_Option::get( $jobid, 'destinations' );
237
- foreach ( $dests as $dest ) {
238
- if ( empty( $this->destinations[ $dest ][ 'class' ] ) )
239
- continue;
240
- $dest_class = BackWPup::get_destination( $dest );
241
- $can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest );
242
- if ( ! empty( $can_do_dest ) )
243
- $jobdest[ ] = $jobid . '_' . $dest;
244
- }
245
- }
246
- }
247
-
248
- return $jobdest;
249
- }
250
-
251
- /**
252
- * @return array
253
- */
254
- function get_columns() {
255
-
256
- $posts_columns = array();
257
- $posts_columns[ 'cb' ] = '<input type="checkbox" />';
258
- $posts_columns[ 'time' ] = __( 'Time', 'backwpup' );
259
- $posts_columns[ 'file' ] = __( 'File', 'backwpup' );
260
- $posts_columns[ 'folder' ] = __( 'Folder', 'backwpup' );
261
- $posts_columns[ 'size' ] = __( 'Size', 'backwpup' );
262
-
263
- return $posts_columns;
264
- }
265
-
266
- /**
267
- * @return array
268
- */
269
- function get_sortable_columns() {
270
-
271
- return array(
272
- 'file' => array( 'file', FALSE ),
273
- 'folder' => 'folder',
274
- 'size' => 'size',
275
- 'time' => array( 'time', FALSE )
276
- );
277
- }
278
-
279
- /**
280
- * The cb Column
281
- *
282
- * @param $item
283
- * @return string
284
- */
285
- function column_cb( $item ) {
286
-
287
- return '<input type="checkbox" name="backupfiles[]" value="' . esc_attr( $item[ 'file' ] ) . '" />';
288
- }
289
-
290
-
291
- /**
292
- * The file Column
293
- *
294
- * @param $item
295
- * @return string
296
- */
297
- function column_file( $item ) {
298
-
299
- $r = '<strong>' . esc_attr( $item[ 'filename' ] ) . '</strong><br />';
300
- if ( ! empty( $item[ 'info' ] ) )
301
- $r .= esc_attr( $item[ 'info' ] ) . '<br />';
302
- $actions = array();
303
- if ( current_user_can( 'backwpup_backups_delete' ) )
304
- $actions[ 'delete' ] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupbackups&action=delete&jobdest-top=' . $this->jobid . '_' . $this->dest . '&paged=' . $this->get_pagenum() . '&backupfiles[]=' . esc_attr( $item[ 'file' ] ), 'bulk-backups' ) . "\" onclick=\"if ( confirm('" . esc_js( __( "You are about to delete this backup archive. \n 'Cancel' to stop, 'OK' to delete.", "backwpup" ) ) . "') ) { return true;}return false;\">" . __( 'Delete', 'backwpup' ) . "</a>";
305
- if ( current_user_can( 'backwpup_backups_download' ) && ! empty( $item[ 'downloadurl' ] ) )
306
- $actions[ 'download' ] = "<a href=\"" . wp_nonce_url( $item[ 'downloadurl' ], 'download-backup' ) . "\">" . __( 'Download', 'backwpup' ) . "</a>";
307
- $r .= $this->row_actions( $actions );
308
-
309
- return $r;
310
- }
311
-
312
- /**
313
- * The folder Column
314
- *
315
- * @param $item
316
- * @return string
317
- */
318
- function column_folder( $item ) {
319
-
320
- return esc_attr( $item[ 'folder' ] );
321
- }
322
-
323
- /**
324
- * The size Column
325
- *
326
- * @param $item
327
- * @return string
328
- */
329
- function column_size( $item ) {
330
-
331
- if ( ! empty( $item[ 'filesize' ] ) && $item[ 'filesize' ] != - 1 ) {
332
- return size_format( $item[ 'filesize' ], 2 );
333
- }
334
- else {
335
- return __( '?', 'backwpup' );
336
- }
337
- }
338
-
339
- /**
340
- * The time Column
341
- *
342
- * @param $item
343
- * @return string
344
- */
345
- function column_time( $item ) {
346
-
347
- $item[ 'time' ] = $item[ 'time' ] + get_option( 'gmt_offset' ) * 3600;
348
- return sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ), $item[ 'time' ], TRUE ), date_i18n( get_option( 'time_format' ), $item[ 'time' ], TRUE ) );
349
-
350
- }
351
-
352
-
353
- /**
354
- *
355
- */
356
- public static function load() {
357
-
358
- //Create Table
359
- self::$listtable = new BackWPup_Page_Backups;
360
-
361
- switch ( self::$listtable->current_action() ) {
362
- case 'delete': //Delete Backup archives
363
- check_admin_referer( 'bulk-backups' );
364
- if ( ! current_user_can( 'backwpup_backups_delete' ) )
365
- wp_die( __( 'Sorry, you don\'t have permissions to do that.', 'backwpup') );
366
-
367
- $jobdest = '_';
368
- if ( ! empty( $_GET[ 'jobdest' ] ) )
369
- $jobdest = $_GET[ 'jobdest' ];
370
- if ( ! empty( $_GET[ 'jobdest-top' ] ) )
371
- $jobdest = $_GET[ 'jobdest-top' ];
372
-
373
- $_GET[ 'jobdest' ] = $jobdest;
374
-
375
- if ( $jobdest == '_' )
376
- return;
377
-
378
- list( $jobid, $dest ) = explode( '_', $jobdest );
379
- $dest_class = BackWPup::get_destination( $dest );
380
- $files = $dest_class->file_get_list( $jobdest );
381
- foreach ( $_GET[ 'backupfiles' ] as $backupfile ) {
382
- foreach ( $files as $file ) {
383
- if ( is_array( $file ) && $file[ 'file' ] == $backupfile )
384
- $dest_class->file_delete( $jobdest, $backupfile );
385
- }
386
- }
387
- break;
388
- default:
389
- $dest = strtoupper( str_replace( 'download', '', self::$listtable->current_action() ) );
390
- if ( !empty( $dest ) && strstr( self::$listtable->current_action(), 'download') ) {
391
- if ( ! current_user_can( 'backwpup_backups_download' ) )
392
- wp_die( __( 'Sorry, you don\'t have permissions to do that.', 'backwpup') );
393
- check_admin_referer( 'download-backup' );
394
- $dest_class = BackWPup::get_destination( $dest );
395
- $dest_class->file_download( (int)$_GET[ 'jobid' ], $_GET[ 'file' ] );
396
- die();
397
- }
398
- break;
399
- }
400
-
401
- //Save per page
402
- if ( isset( $_POST[ 'screen-options-apply' ] ) && isset( $_POST[ 'wp_screen_options' ][ 'option' ] ) && isset( $_POST[ 'wp_screen_options' ][ 'value' ] ) && $_POST[ 'wp_screen_options' ][ 'option' ] == 'backwpupbackups_per_page' ) {
403
- check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
404
- global $current_user;
405
- if ( $_POST[ 'wp_screen_options' ][ 'value' ] > 0 && $_POST[ 'wp_screen_options' ][ 'value' ] < 1000 ) {
406
- update_user_option( $current_user->ID, 'backwpupbackups_per_page', (int)$_POST[ 'wp_screen_options' ][ 'value' ] );
407
- wp_redirect( remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() ) );
408
- exit;
409
- }
410
- }
411
-
412
- add_screen_option( 'per_page', array(
413
- 'label' => __( 'Backup Files', 'backwpup' ),
414
- 'default' => 20,
415
- 'option' => 'backwpupbackups_per_page'
416
- ) );
417
-
418
- self::$listtable->prepare_items();
419
- }
420
-
421
- /**
422
- * Output css
423
- */
424
- public static function admin_print_styles() {
425
-
426
- ?>
427
- <style type="text/css" media="screen">
428
- .column-size, .column-time {
429
- width: 10%;
430
- }
431
- @media screen and (max-width: 782px) {
432
- .column-size, .column-runtime, .column-size, .column-folder {
433
- display: none;
434
- }
435
- .column-time {
436
- width: 18%;
437
- }
438
- }
439
- </style>
440
- <?php
441
- }
442
-
443
- /**
444
- *
445
- * Output js
446
- *
447
- * @return void
448
- */
449
- public static function admin_print_scripts() {
450
-
451
- wp_enqueue_script( 'backwpupgeneral' );
452
- }
453
-
454
- /**
455
- * Display the page content
456
- */
457
- public static function page() {
458
-
459
- ?>
460
- <div class="wrap" id="backwpup-page">
461
- <h2><span id="backwpup-page-icon">&nbsp;</span><?php echo esc_html( sprintf( __( '%s Manage Backup Archives', 'backwpup' ), BackWPup::get_plugin_data( 'name' ) ) ); ?></h2>
462
- <?php BackWPup_Admin::display_messages(); ?>
463
- <form id="posts-filter" action="" method="get">
464
- <input type="hidden" name="page" value="backwpupbackups" />
465
- <?php self::$listtable->display(); ?>
466
- <div id="ajax-response"></div>
467
- </form>
468
- </div>
469
- <?php
470
- }
471
- }
472
-
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ class BackWPup_Page_Backups extends WP_List_Table {
6
+
7
+ private static $listtable = NULL;
8
+ private $destinations = array();
9
+
10
+ /**
11
+ * @var int
12
+ */
13
+ private $jobid = 1;
14
+ /**
15
+ * @var string
16
+ */
17
+ private $dest = 'FOLDER';
18
+
19
+ /**
20
+ *
21
+ */
22
+ function __construct() {
23
+
24
+ parent::__construct( array(
25
+ 'plural' => 'backups',
26
+ 'singular' => 'backup',
27
+ 'ajax' => TRUE
28
+ ) );
29
+
30
+ $this->destinations = BackWPup::get_registered_destinations();
31
+
32
+ }
33
+
34
+ /**
35
+ * @return bool
36
+ */
37
+ function ajax_user_can() {
38
+
39
+ return current_user_can( 'backwpup_backups' );
40
+ }
41
+
42
+ /**
43
+ *
44
+ */
45
+ function prepare_items() {
46
+
47
+ $per_page = $this->get_items_per_page( 'backwpupbackups_per_page' );
48
+ if ( empty( $per_page ) || $per_page < 1 )
49
+ $per_page = 20;
50
+
51
+ $jobdest = '';
52
+ if ( ! empty( $_GET[ 'jobdets-button-top' ] ) )
53
+ $jobdest = $_GET[ 'jobdest-top' ];
54
+ if( ! empty( $_GET[ 'jobdets-button-bottom' ] ) )
55
+ $jobdest = $_GET[ 'jobdest-bottom' ];
56
+
57
+ if ( empty( $jobdest ) ) {
58
+ $jobdests = $this->get_destinations_list();
59
+ if ( empty( $jobdests ) )
60
+ $jobdests = array( '_' );
61
+ $jobdest = $jobdests[ 0 ];
62
+ $_GET[ 'jobdest-top' ] = $jobdests[ 0 ];
63
+ $_GET[ 'jobdets-button-top' ] = 'empty';
64
+ }
65
+
66
+ list( $this->jobid, $this->dest ) = explode( '_', $jobdest );
67
+
68
+ if ( ! empty( $this->destinations[ $this->dest ][ 'class' ] ) ) {
69
+ $dest_object = BackWPup::get_destination( $this->dest );
70
+ $this->items = $dest_object->file_get_list( $jobdest );
71
+ }
72
+
73
+ //if no items brake
74
+ if ( ! $this->items ) {
75
+ $this->items = '';
76
+
77
+ return;
78
+ }
79
+
80
+ //Sorting
81
+ $order = isset( $_GET[ 'order' ] ) ? $_GET[ 'order' ] : 'desc';
82
+ $orderby = isset( $_GET[ 'orderby' ] ) ? $_GET[ 'orderby' ] : 'time';
83
+ $tmp = Array();
84
+ if ( $orderby == 'time' ) {
85
+ if ( $order == 'asc' ) {
86
+ foreach ( $this->items as &$ma ) {
87
+ $tmp[ ] = & $ma[ "time" ];
88
+ }
89
+ array_multisort( $tmp, SORT_ASC, $this->items );
90
+ }
91
+ else {
92
+ foreach ( $this->items as &$ma ) {
93
+ $tmp[ ] = & $ma[ "time" ];
94
+ }
95
+ array_multisort( $tmp, SORT_DESC, $this->items );
96
+ }
97
+ }
98
+ elseif ( $orderby == 'file' ) {
99
+ if ( $order == 'asc' ) {
100
+ foreach ( $this->items as &$ma ) {
101
+ $tmp[ ] = & $ma[ "filename" ];
102
+ }
103
+ array_multisort( $tmp, SORT_ASC, $this->items );
104
+ }
105
+ else {
106
+ foreach ( $this->items as &$ma ) {
107
+ $tmp[ ] = & $ma[ "filename" ];
108
+ }
109
+ array_multisort( $tmp, SORT_DESC, $this->items );
110
+ }
111
+ }
112
+ elseif ( $orderby == 'folder' ) {
113
+ if ( $order == 'asc' ) {
114
+ foreach ( $this->items as &$ma ) {
115
+ $tmp[ ] = & $ma[ "folder" ];
116
+ }
117
+ array_multisort( $tmp, SORT_ASC, $this->items );
118
+ }
119
+ else {
120
+ foreach ( $this->items as &$ma ) {
121
+ $tmp[ ] = & $ma[ "folder" ];
122
+ }
123
+ array_multisort( $tmp, SORT_DESC, $this->items );
124
+ }
125
+ }
126
+ elseif ( $orderby == 'size' ) {
127
+ if ( $order == 'asc' ) {
128
+ foreach ( $this->items as &$ma ) {
129
+ $tmp[ ] = & $ma[ "filesize" ];
130
+ }
131
+ array_multisort( $tmp, SORT_ASC, $this->items );
132
+ }
133
+ else {
134
+ foreach ( $this->items as &$ma ) {
135
+ $tmp[ ] = & $ma[ "filesize" ];
136
+ }
137
+ array_multisort( $tmp, SORT_DESC, $this->items );
138
+ }
139
+ }
140
+
141
+ $this->set_pagination_args( array(
142
+ 'total_items' => count( $this->items ),
143
+ 'per_page' => $per_page,
144
+ 'jobdest' => $jobdest,
145
+ 'orderby' => $orderby,
146
+ 'order' => $order
147
+ ) );
148
+
149
+ //only display items on page
150
+ $start = intval( ( $this->get_pagenum() - 1 ) * $per_page );
151
+ $end = $start + $per_page;
152
+ if ( $end > count( $this->items ) )
153
+ $end = count( $this->items );
154
+
155
+ $i = -1;
156
+ foreach ( $this->items as $item ) {
157
+ $i++;
158
+ if ( $i < $start )
159
+ continue;
160
+ if ( $i >= $end )
161
+ break;
162
+ $paged_items[] = $item;
163
+ }
164
+
165
+ $this->items = $paged_items;
166
+
167
+ }
168
+
169
+ /**
170
+ *
171
+ */
172
+ function no_items() {
173
+ _e( 'No files could be found. (List will be generated during next backup.)', 'backwpup' );
174
+ }
175
+
176
+ /**
177
+ * @return array
178
+ */
179
+ function get_bulk_actions() {
180
+
181
+ if ( ! $this->has_items() )
182
+ return array ();
183
+
184
+ $actions = array();
185
+ $actions[ 'delete' ] = __( 'Delete', 'backwpup' );
186
+
187
+ return $actions;
188
+ }
189
+
190
+ /**
191
+ * @param $which
192
+ *
193
+ * @return mixed
194
+ */
195
+ function extra_tablenav( $which ) {
196
+
197
+ $destinations_list = $this->get_destinations_list();
198
+
199
+ if ( count( $destinations_list ) < 1)
200
+ return;
201
+
202
+ if ( count( $destinations_list ) == 1 ) {
203
+ echo '<input type="hidden" name="jobdest-' . $which . '" value="' . $destinations_list[0] . '">';
204
+ return;
205
+ }
206
+
207
+ ?>
208
+ <div class="alignleft actions">
209
+ <label for="jobdest-<?php echo $which;?>">
210
+ <select name="jobdest-<?php echo $which;?>" class="postform" id="jobdest-<?php echo $which;?>">
211
+ <?php
212
+ foreach ( $destinations_list as $jobdest ) {
213
+ list( $jobid, $dest ) = explode( '_', $jobdest );
214
+ echo "\t<option value=\"" . $jobdest . "\" " . selected( $this->jobid . '_' . $this->dest, $jobdest, false ) . ">" . $dest . ": " . esc_html( BackWPup_Option::get( $jobid, 'name' ) ) . "</option>" . PHP_EOL;
215
+ }
216
+ ?>
217
+ </select>
218
+ </label>
219
+ <?php submit_button( __( 'Change destination', 'backwpup' ), 'secondary', 'jobdets-button-' . $which, FALSE, array( 'id' => 'query-submit-'.$which ) ); ?>
220
+ </div>
221
+ <?php
222
+ }
223
+
224
+ /**
225
+ * @return array
226
+ */
227
+ function get_destinations_list() {
228
+
229
+ $jobdest = array();
230
+ $jobids = BackWPup_Option::get_job_ids();
231
+
232
+ if ( ! empty( $jobids ) ) {
233
+ foreach ( $jobids as $jobid ) {
234
+ if ( BackWPup_Option::get( $jobid, 'backuptype' ) == 'sync' ) // jump over sync
235
+ continue;
236
+ $dests = BackWPup_Option::get( $jobid, 'destinations' );
237
+ foreach ( $dests as $dest ) {
238
+ if ( empty( $this->destinations[ $dest ][ 'class' ] ) )
239
+ continue;
240
+ $dest_class = BackWPup::get_destination( $dest );
241
+ $can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest );
242
+ if ( ! empty( $can_do_dest ) )
243
+ $jobdest[ ] = $jobid . '_' . $dest;
244
+ }
245
+ }
246
+ }
247
+
248
+ return $jobdest;
249
+ }
250
+
251
+ /**
252
+ * @return array
253
+ */
254
+ function get_columns() {
255
+
256
+ $posts_columns = array();
257
+ $posts_columns[ 'cb' ] = '<input type="checkbox" />';
258
+ $posts_columns[ 'time' ] = __( 'Time', 'backwpup' );
259
+ $posts_columns[ 'file' ] = __( 'File', 'backwpup' );
260
+ $posts_columns[ 'folder' ] = __( 'Folder', 'backwpup' );
261
+ $posts_columns[ 'size' ] = __( 'Size', 'backwpup' );
262
+
263
+ return $posts_columns;
264
+ }
265
+
266
+ /**
267
+ * @return array
268
+ */
269
+ function get_sortable_columns() {
270
+
271
+ return array(
272
+ 'file' => array( 'file', FALSE ),
273
+ 'folder' => 'folder',
274
+ 'size' => 'size',
275
+ 'time' => array( 'time', FALSE )
276
+ );
277
+ }
278
+
279
+ /**
280
+ * The cb Column
281
+ *
282
+ * @param $item
283
+ * @return string
284
+ */
285
+ function column_cb( $item ) {
286
+
287
+ return '<input type="checkbox" name="backupfiles[]" value="' . esc_attr( $item[ 'file' ] ) . '" />';
288
+ }
289
+
290
+
291
+ /**
292
+ * The file Column
293
+ *
294
+ * @param $item
295
+ * @return string
296
+ */
297
+ function column_file( $item ) {
298
+
299
+ $r = '<strong>' . esc_attr( $item[ 'filename' ] ) . '</strong><br />';
300
+ if ( ! empty( $item[ 'info' ] ) )
301
+ $r .= esc_attr( $item[ 'info' ] ) . '<br />';
302
+ $actions = array();
303
+ if ( current_user_can( 'backwpup_backups_delete' ) )
304
+ $actions[ 'delete' ] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupbackups&action=delete&jobdest-top=' . $this->jobid . '_' . $this->dest . '&paged=' . $this->get_pagenum() . '&backupfiles[]=' . esc_attr( $item[ 'file' ] ), 'bulk-backups' ) . "\" onclick=\"if ( confirm('" . esc_js( __( "You are about to delete this backup archive. \n 'Cancel' to stop, 'OK' to delete.", "backwpup" ) ) . "') ) { return true;}return false;\">" . __( 'Delete', 'backwpup' ) . "</a>";
305
+ if ( current_user_can( 'backwpup_backups_download' ) && ! empty( $item[ 'downloadurl' ] ) )
306
+ $actions[ 'download' ] = "<a href=\"" . wp_nonce_url( $item[ 'downloadurl' ], 'download-backup' ) . "\">" . __( 'Download', 'backwpup' ) . "</a>";
307
+ $r .= $this->row_actions( $actions );
308
+
309
+ return $r;
310
+ }
311
+
312
+ /**
313
+ * The folder Column
314
+ *
315
+ * @param $item
316
+ * @return string
317
+ */
318
+ function column_folder( $item ) {
319
+
320
+ return esc_attr( $item[ 'folder' ] );
321
+ }
322
+
323
+ /**
324
+ * The size Column
325
+ *
326
+ * @param $item
327
+ * @return string
328
+ */
329
+ function column_size( $item ) {
330
+
331
+ if ( ! empty( $item[ 'filesize' ] ) && $item[ 'filesize' ] != - 1 ) {
332
+ return size_format( $item[ 'filesize' ], 2 );
333
+ }
334
+ else {
335
+ return __( '?', 'backwpup' );
336
+ }
337
+ }
338
+
339
+ /**
340
+ * The time Column
341
+ *
342
+ * @param $item
343
+ * @return string
344
+ */
345
+ function column_time( $item ) {
346
+
347
+ $item[ 'time' ] = $item[ 'time' ] + get_option( 'gmt_offset' ) * 3600;
348
+ return sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ), $item[ 'time' ], TRUE ), date_i18n( get_option( 'time_format' ), $item[ 'time' ], TRUE ) );
349
+
350
+ }
351
+
352
+
353
+ /**
354
+ *
355
+ */
356
+ public static function load() {
357
+
358
+ //Create Table
359
+ self::$listtable = new BackWPup_Page_Backups;
360
+
361
+ switch ( self::$listtable->current_action() ) {
362
+ case 'delete': //Delete Backup archives
363
+ check_admin_referer( 'bulk-backups' );
364
+ if ( ! current_user_can( 'backwpup_backups_delete' ) )
365
+ wp_die( __( 'Sorry, you don\'t have permissions to do that.', 'backwpup') );
366
+
367
+ $jobdest = '_';
368
+ if ( ! empty( $_GET[ 'jobdest' ] ) )
369
+ $jobdest = $_GET[ 'jobdest' ];
370
+ if ( ! empty( $_GET[ 'jobdest-top' ] ) )
371
+ $jobdest = $_GET[ 'jobdest-top' ];
372
+
373
+ $_GET[ 'jobdest' ] = $jobdest;
374
+
375
+ if ( $jobdest == '_' )
376
+ return;
377
+
378
+ list( $jobid, $dest ) = explode( '_', $jobdest );
379
+ $dest_class = BackWPup::get_destination( $dest );
380
+ $files = $dest_class->file_get_list( $jobdest );
381
+ foreach ( $_GET[ 'backupfiles' ] as $backupfile ) {
382
+ foreach ( $files as $file ) {
383
+ if ( is_array( $file ) && $file[ 'file' ] == $backupfile )
384
+ $dest_class->file_delete( $jobdest, $backupfile );
385
+ }
386
+ }
387
+ break;
388
+ default:
389
+ $dest = strtoupper( str_replace( 'download', '', self::$listtable->current_action() ) );
390
+ if ( !empty( $dest ) && strstr( self::$listtable->current_action(), 'download') ) {
391
+ if ( ! current_user_can( 'backwpup_backups_download' ) )
392
+ wp_die( __( 'Sorry, you don\'t have permissions to do that.', 'backwpup') );
393
+ check_admin_referer( 'download-backup' );
394
+ $dest_class = BackWPup::get_destination( $dest );
395
+ $dest_class->file_download( (int)$_GET[ 'jobid' ], $_GET[ 'file' ] );
396
+ die();
397
+ }
398
+ break;
399
+ }
400
+
401
+ //Save per page
402
+ if ( isset( $_POST[ 'screen-options-apply' ] ) && isset( $_POST[ 'wp_screen_options' ][ 'option' ] ) && isset( $_POST[ 'wp_screen_options' ][ 'value' ] ) && $_POST[ 'wp_screen_options' ][ 'option' ] == 'backwpupbackups_per_page' ) {
403
+ check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
404
+ global $current_user;
405
+ if ( $_POST[ 'wp_screen_options' ][ 'value' ] > 0 && $_POST[ 'wp_screen_options' ][ 'value' ] < 1000 ) {
406
+ update_user_option( $current_user->ID, 'backwpupbackups_per_page', (int)$_POST[ 'wp_screen_options' ][ 'value' ] );
407
+ wp_redirect( remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() ) );
408
+ exit;
409
+ }
410
+ }
411
+
412
+ add_screen_option( 'per_page', array(
413
+ 'label' => __( 'Backup Files', 'backwpup' ),
414
+ 'default' => 20,
415
+ 'option' => 'backwpupbackups_per_page'
416
+ ) );
417
+
418
+ self::$listtable->prepare_items();
419
+ }
420
+
421
+ /**
422
+ * Output css
423
+ */
424
+ public static function admin_print_styles() {
425
+
426
+ ?>
427
+ <style type="text/css" media="screen">
428
+ .column-size, .column-time {
429
+ width: 10%;
430
+ }
431
+ @media screen and (max-width: 782px) {
432
+ .column-size, .column-runtime, .column-size, .column-folder {
433
+ display: none;
434
+ }
435
+ .column-time {
436
+ width: 18%;
437
+ }
438
+ }
439
+ </style>
440
+ <?php
441
+ }
442
+
443
+ /**
444
+ *
445
+ * Output js
446
+ *
447
+ * @return void
448
+ */
449
+ public static function admin_print_scripts() {
450
+
451
+ wp_enqueue_script( 'backwpupgeneral' );
452
+ }
453
+
454
+ /**
455
+ * Display the page content
456
+ */
457
+ public static function page() {
458
+
459
+ ?>
460
+ <div class="wrap" id="backwpup-page">
461
+ <h2><span id="backwpup-page-icon">&nbsp;</span><?php echo esc_html( sprintf( __( '%s Manage Backup Archives', 'backwpup' ), BackWPup::get_plugin_data( 'name' ) ) ); ?></h2>
462
+ <?php BackWPup_Admin::display_messages(); ?>
463
+ <form id="posts-filter" action="" method="get">
464
+ <input type="hidden" name="page" value="backwpupbackups" />
465
+ <?php self::$listtable->display(); ?>
466
+ <div id="ajax-response"></div>
467
+ </form>
468
+ </div>
469
+ <?php
470
+ }
471
+ }
472
+
inc/class-page-backwpup.php CHANGED
@@ -1,387 +1,387 @@
1
- <?php
2
- /**
3
- * Render plugin dashboard.
4
- *
5
- */
6
- class BackWPup_Page_BackWPup {
7
-
8
-
9
- /**
10
- * Called on load action.
11
- *
12
- * @return void
13
- */
14
- public static function load() {
15
- global $wpdb;
16
-
17
- if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'dbdumpdl' ) {
18
-
19
- //check permissions
20
- check_admin_referer( 'backwpupdbdumpdl' );
21
-
22
- if ( ! current_user_can( 'backwpup_jobs_edit' ) )
23
- die();
24
-
25
- //doing dump
26
- header( "Pragma: public" );
27
- header( "Expires: 0" );
28
- header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
29
- header( "Content-Type: application/octet-stream; charset=". get_bloginfo( 'charset' ) );
30
- header( "Content-Disposition: attachment; filename=" . DB_NAME . ".sql;" );
31
- try {
32
- $sql_dump = new BackWPup_MySQLDump();
33
- foreach ( $sql_dump->tables_to_dump as $key => $table ) {
34
- if ( $wpdb->prefix != substr( $table,0 , strlen( $wpdb->prefix ) ) )
35
- unset( $sql_dump->tables_to_dump[ $key ] );
36
- }
37
- $sql_dump->execute();
38
- unset( $sql_dump );
39
- } catch ( Exception $e ) {
40
- die( $e->getMessage() );
41
- }
42
- die();
43
- }
44
- }
45
-
46
- /**
47
- * Enqueue script.
48
- *
49
- * @return void
50
- */
51
- public static function admin_print_scripts() {
52
-
53
- wp_enqueue_script( 'backwpupgeneral' );
54
-
55
- }
56
-
57
- /**
58
- * Print the markup.
59
- *
60
- * @return void
61
- */
62
- public static function page() {
63
- // get wizards
64
- $wizards = BackWPup::get_wizards();
65
- ?>
66
- <div class="wrap" id="backwpup-page">
67
- <h2><span id="backwpup-page-icon">&nbsp;</span><?php echo sprintf( __( '%s Dashboard', 'backwpup' ), BackWPup::get_plugin_data( 'name') ); ?></h2>
68
- <?php
69
-
70
- BackWPup_Admin::display_messages();
71
-
72
- if ( class_exists( 'BackWPup_Pro', FALSE ) ) { ?>
73
- <div class="backwpup-welcome backwpup-max-width">
74
- <h3><?php _ex( 'Planning backups', 'Dashboard heading', 'backwpup' ); ?></h3>
75
- <p><?php _e('BackWPup’s job wizards make planning and scheduling your backup jobs a breeze.','backwpup' ); echo ' '; _e('Use your backup archives to save your entire WordPress installation including <code>/wp-content/</code>. Push them to an external storage service if you don’t want to save the backups on the same server.','backwpup'); ?></p>
76
- <h3><?php _ex( 'Restoring backups', 'Dashboard heading', 'backwpup' ); ?></h3>
77
- <p><?php _e( 'With a single backup archive you are able to restore an installation. Use a tool like phpMyAdmin or a plugin like <a href="http://wordpress.org/plugins/adminer/" target="_blank">Adminer</a> to restore your database backup files.', 'backwpup' ) ?></p>
78
- <h3><?php _ex( 'Ready to set up a backup job?', 'Dashboard heading','backwpup' ); ?></h3>
79
- <p><?php printf( __('Use one of the wizards to plan a backup, or use <a href="%s">expert mode</a> for full control over all options.','backwpup'), network_admin_url( 'admin.php') . '?page=backwpupeditjob' ); echo ' '; _e( '<strong>Please note: You are solely responsible for the security of your data; the authors of this plugin are not.</strong>', 'backwpup' ); ?></p>
80
- </div>
81
- <?php } else {?>
82
- <div class="backwpup-welcome backwpup-max-width">
83
- <h3><?php _ex( 'Planning backups', 'Dashboard heading', 'backwpup' ); ?></h3>
84
- <p><?php _e('Use the short links in the <strong>First steps</strong> box to plan and schedule backup jobs.','backwpup' ); echo ' '; _e('Use your backup archives to save your entire WordPress installation including <code>/wp-content/</code>. Push them to an external storage service if you don’t want to save the backups on the same server.','backwpup'); ?></p>
85
- <h3><?php _ex( 'Restoring backups', 'Dashboard heading', 'backwpup' ); ?></h3>
86
- <p><?php _e( 'With a single backup archive you are able to restore an installation. Use a tool like phpMyAdmin or a plugin like <a href="http://wordpress.org/plugins/adminer/" target="_blank">Adminer</a> to restore your database backup files.', 'backwpup' ) ?></p>
87
- <h3><?php _ex( 'Ready to set up a backup job?', 'Dashboard heading','backwpup' ); ?></h3>
88
- <p><?php printf( __('<a href="%s">Add a new backup job</a> and plan what you want to save.','backwpup'), network_admin_url( 'admin.php') . '?page=backwpupeditjob' ); ?>
89
- <br /><?php _e( '<strong>Please note: You are solely responsible for the security of your data; the authors of this plugin are not.</strong>', 'backwpup' ); ?></p>
90
- </div>
91
- <?php }
92
-
93
- if ( current_user_can( 'backwpup_jobs_edit' ) && current_user_can( 'backwpup_logs' ) && current_user_can( 'backwpup_jobs_start' ) ) {
94
- ?>
95
- <div id="backwpup-first-steps" class="metabox-holder postbox backwpup-floated-postbox">
96
- <h3 class="hndle"><span><?php _e( 'First Steps', 'backwpup' ); ?></span></h3>
97
- <div class="inside">
98
- <ul>
99
- <?php if ( class_exists( 'BackWPup_Pro', FALSE ) ) { ?>
100
- <li type="1"><a href="<?php echo wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupwizard&wizard_start=SYSTEMTEST', 'wizard' ); ?>"><?php _e( 'Test the installation', 'backwpup' ); ?></a></li>
101
- <li type="1"><a href="<?php echo wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupwizard&wizard_start=JOB', 'wizard' ); ?>"><?php _e( 'Create a Job', 'backwpup' ); ?></a></li>
102
- <?php } else { ?>
103
- <li type="1"><a href="<?php echo network_admin_url( 'admin.php' ) . '?page=backwpupsettings#backwpup-tab-information'; ?>"><?php _e( 'Check the installation', 'backwpup' ); ?></a></li>
104
- <li type="1"><a href="<?php echo network_admin_url( 'admin.php' ) . '?page=backwpupeditjob'; ?>"><?php _e( 'Create a Job', 'backwpup' ); ?></a></li>
105
- <?php } ?>
106
- <li type="1"><a href="<?php echo network_admin_url( 'admin.php' ) . '?page=backwpupjobs'; ?>"><?php _e( 'Run the created job', 'backwpup' ); ?></a></li>
107
- <li type="1"><a href="<?php echo network_admin_url( 'admin.php' ) . '?page=backwpuplogs'; ?>"><?php _e( 'Check the job log', 'backwpup' ); ?></a></li>
108
- </ul>
109
- </div>
110
- </div>
111
- <?php }
112
-
113
- if ( current_user_can( 'backwpup_jobs_start' ) ) {?>
114
- <div id="backwpup-one-click-backup" class="metabox-holder postbox backwpup-floated-postbox">
115
- <h3 class="hndle"><span><?php _e( 'One click backup', 'backwpup' ); ?></span></h3>
116
- <div class="inside">
117
- <a href="<?php echo wp_nonce_url( network_admin_url( 'admin.php' ). '?page=backwpup&action=dbdumpdl', 'backwpupdbdumpdl' ); ?>" class="button button-primary button-primary-bwp" title="<?php _e( 'Generate a database backup of WordPress tables and download it right away!', 'backwpup' ); ?>"><?php _e( 'Download database backup', 'backwpup' ); ?></a><br />
118
- </div>
119
- </div>
120
- <?php } ?>
121
-
122
- <div id="backwpup-rss-feed" class="metabox-holder postbox backwpup-cleared-postbox backwpup-max-width">
123
- <h3 class="hndle"><span><?php _e( 'BackWPup News', 'backwpup' ); ?></span></h3>
124
- <div class="inside">
125
- <?php
126
- add_action( 'wp_feed_options', array( __CLASS__, 'wp_feed_options' ) );
127
-
128
- $rss = fetch_feed( _x( 'http://marketpress.com/news/plugins/backwpup/feed/', 'BackWPup News RSS Feed URL', 'backwpup' ) );
129
-
130
- remove_action( 'wp_feed_options', array( __CLASS__, 'wp_feed_options' ) );
131
-
132
- if ( is_wp_error($rss) ) {
133
- echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s', 'backwpup' ), $rss->get_error_message() ) . '</p>';
134
- return;
135
- }
136
-
137
- if ( !$rss->get_item_quantity() ) {
138
- echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.', 'backwpup' ) . '</li></ul>';
139
- $rss->__destruct();
140
- unset($rss);
141
- return;
142
- }
143
-
144
- echo '<ul>';
145
- $first = TRUE;
146
- foreach ( $rss->get_items( 0, 4 ) as $item ) {
147
- $link = $item->get_link();
148
- while ( stristr($link, 'http') != $link )
149
- $link = substr($link, 1);
150
- $link = esc_url(strip_tags($link));
151
- $title = esc_attr(strip_tags($item->get_title()));
152
- if ( empty($title) )
153
- $title = __( 'Untitled', 'backwpup' );
154
-
155
- $desc = str_replace( array("\n", "\r"), ' ', esc_attr( strip_tags( @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) ) );
156
- $excerpt = wp_html_excerpt( $desc, 360 );
157
-
158
- // Append ellipsis. Change existing [...] to [&hellip;].
159
- if ( '[...]' == substr( $excerpt, -5 ) )
160
- $excerpt = substr( $excerpt, 0, -5 ) . '[&hellip;]';
161
- elseif ( '[&hellip;]' != substr( $excerpt, -10 ) && $desc != $excerpt )
162
- $excerpt .= ' [&hellip;]';
163
-
164
- $excerpt = esc_html( $excerpt );
165
-
166
- if ( $first ) {
167
- $summary = "<div class='rssSummary'>$excerpt</div>";
168
- } else {
169
- $summary = '';
170
- }
171
-
172
- $date = '';
173
- if ( $first ) {
174
- $date = $item->get_date( 'U' );
175
-
176
- if ( $date ) {
177
- $date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date ) . '</span>';
178
- }
179
- }
180
-
181
- echo "<li><a href=\"$link\" title=\"$desc\">$title</a>{$date}{$summary}</li>";
182
- $first = FALSE;
183
- }
184
- echo '</ul>';
185
- $rss->__destruct();
186
- unset($rss);
187
- ?>
188
- </div>
189
- </div>
190
-
191
- <?php
192
- if ( class_exists( 'BackWPup_Pro', FALSE ) ) {
193
- /* @var BackWPup_Pro_Wizards $wizard_class */
194
-
195
- foreach ( $wizards as $wizard_class ) {
196
- //check permissions
197
- if ( ! current_user_can( $wizard_class->info[ 'cap' ] ) )
198
- continue;
199
- //get info of wizard
200
- echo '<div id="wizard-' . strtolower( $wizard_class->info[ 'ID' ] ) . '" class="wizardbox post-box backwpup-floated-postbox"><form method="get" action="' . network_admin_url( 'admin.php' ) . '">';
201
- echo '<h3 class="wizardbox_name">' . $wizard_class->info[ 'name' ] . '</h3>';
202
- echo '<p class="wizardbox_description">' . $wizard_class->info[ 'description' ] . '</p>';
203
- $conf_names = $wizard_class->get_pre_configurations();
204
- if ( ! empty ( $conf_names ) ) {
205
- echo '<select id="wizardbox_pre_conf" name="pre_conf" size="1">';
206
- foreach( $conf_names as $conf_key => $conf_name) {
207
- echo '<option value="' . esc_attr( $conf_key ) . '">' . esc_attr( $conf_name ) . '</option>';
208
- }
209
- echo '</select>';
210
- } else {
211
- echo '<input type="hidden" name="pre_conf" value="" />';
212
- }
213
- wp_nonce_field( 'wizard' );
214
- echo '<input type="hidden" name="page" value="backwpupwizard" />';
215
- echo '<input type="hidden" name="wizard_start" value="' . esc_attr( $wizard_class->info[ 'ID' ] ) . '" />';
216
- echo '<div class="wizardbox_start"><input type="submit" name="submit" class="button button-primary button-primary-bwp" value="' . esc_attr( __( 'Start wizard', 'backwpup' ) ) . '" /></div>';
217
- echo '</form></div>';
218
- }
219
- } ?>
220
-
221
- <div id="backwpup-stats" class="metabox-holder postbox backwpup-cleared-postbox backwpup-max-width">
222
- <div class="backwpup-table-wrap">
223
- <?php
224
- self::mb_next_jobs();
225
- self::mb_last_logs();
226
- ?>
227
- </div>
228
- </div>
229
-
230
- <?php if ( ! class_exists( 'BackWPup_Pro', FALSE ) ) { ?>
231
- <div id="backwpup-thank-you" class="metabox-holder postbox backwpup-cleared-postbox backwpup-max-width">
232
- <h3 class="hndle"><span><?php _ex( 'Thank you for using BackWPup!', 'Pro teaser box', 'backwpup' ); ?></span></h3>
233
- <div class="inside">
234
- <p><img class="backwpup-banner-img" src="<?php echo BackWPup::get_plugin_data( 'URL' ) . '/assets/images/backwpupbanner-pro.png'; ?>" alt="BackWPup Banner" /></p>
235
- <h3 class="backwpup-text-center"><?php _ex( 'Get access to:', 'Pro teaser box', 'backwpup' ); ?></h3>
236
- <ul class="backwpup-text-center">
237
- <li><?php _ex( 'First-class <strong>dedicated support</strong> at MarketPress Helpdesk.', 'Pro teaser box', 'backwpup' ); ?></li>
238
- <li><?php _ex( 'Differential backups to Google Drive and other cloud storage service.', 'Pro teaser box', 'backwpup' ); ?></li>
239
- <li><?php _ex( 'Easy-peasy wizards to create and schedule backup jobs.', 'Pro teaser box', 'backwpup' ); ?></li>
240
- <li><?php printf( '<a href="http://marketpress.com/product/backwpup-pro/">%s</a>', _x( 'And more…', 'Pro teaser box, link text', 'backwpup' ) ); ?></li>
241
- </ul>
242
- <p class="backwpup-text-center"><a href="http://marketpress.com/product/backwpup-pro/" class="button button-primary button-primary-bwp" title="<?php _ex( 'Get BackWPup Pro now', 'Pro teaser box, link title', 'backwpup' ); ?>"><?php _ex( 'Get BackWPup Pro now', 'Pro teaser box, link text', 'backwpup' ); ?></a></p>
243
- </div>
244
- </div>
245
- <?php } ?>
246
-
247
- </div>
248
- <?php
249
- }
250
-
251
- /**
252
- * Displaying last logs
253
- */
254
- private static function mb_last_logs() {
255
-
256
- if ( ! current_user_can( 'backwpup_logs' ) )
257
- return;
258
- ?>
259
- <table class="wp-list-table widefat" cellspacing="0">
260
- <caption><?php _e( 'Last logs', 'backwpup' ); ?></caption>
261
- <thead>
262
- <tr><th style="width:30%"><?php _e( 'Time', 'backwpup' ); ?></th><th style="width:55%"><?php _e( 'Job', 'backwpup' ); ?></th><th style="width:20%"><?php _e( 'Result', 'backwpup' ); ?></th></tr>
263
- </thead>
264
- <?php
265
- //get log files
266
- $logfiles = array();
267
- if ( is_writeable( get_site_option( 'backwpup_cfg_logfolder' ) ) && $dir = @opendir( get_site_option( 'backwpup_cfg_logfolder' ) ) ) {
268
- while ( ( $file = readdir( $dir ) ) !== FALSE ) {
269
- if ( is_readable( get_site_option( 'backwpup_cfg_logfolder' ) . $file ) && is_file( get_site_option( 'backwpup_cfg_logfolder' ) . $file ) && FALSE !== strpos( $file, 'backwpup_log_' ) && FALSE !== strpos( $file, '.html' ) )
270
- $logfiles[ filemtime( get_site_option( 'backwpup_cfg_logfolder' ) . '/' . $file ) ] = $file;
271
- }
272
- closedir( $dir );
273
- krsort( $logfiles, SORT_NUMERIC );
274
- }
275
-
276
- if ( count( $logfiles ) > 0 ) {
277
- $count = 0;
278
- $alternate = TRUE;
279
- foreach ( $logfiles as $logfile ) {
280
- $logdata = BackWPup_Job::read_logheader( get_site_option( 'backwpup_cfg_logfolder' ) . $logfile );
281
- if ( ! $alternate ) {
282
- echo '<tr>';
283
- $alternate = TRUE;
284
- } else {
285
- echo '<tr class="alternate">';
286
- $alternate = FALSE;
287
- }
288
- echo '<td>' . sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ) , $logdata[ 'logtime' ] ), date_i18n( get_option( 'time_format' ), $logdata[ 'logtime' ] ) ) . '</td>';
289
- echo '<td><a class="thickbox" href="' . admin_url( 'admin-ajax.php' ) . '?&action=backwpup_view_log&logfile=' . basename( $logfile ) .'&_ajax_nonce=' . wp_create_nonce( 'view-logs' ) . '&amp;TB_iframe=true&amp;width=640&amp;height=440" title="' . esc_attr( basename( $logfile ) ) . '">' . $logdata[ 'name' ] . '</i></a></td>';
290
- echo '<td>';
291
- if ( $logdata[ 'errors' ] > 0 )
292
- printf( '<span style="color:red;font-weight:bold;">' . _n( "%d ERROR", "%d ERRORS", $logdata[ 'errors' ], 'backwpup' ) . '</span><br />', $logdata[ 'errors' ] );
293
- if ( $logdata[ 'warnings' ] > 0 )
294
- printf( '<span style="color:#e66f00;font-weight:bold;">' . _n( "%d WARNING", "%d WARNINGS", $logdata[ 'warnings' ], 'backwpup' ) . '</span><br />', $logdata[ 'warnings' ] );
295
- if ( $logdata[ 'errors' ] == 0 && $logdata[ 'warnings' ] == 0 )
296
- echo '<span style="color:green;font-weight:bold;">' . __( 'OK', 'backwpup' ) . '</span>';
297
- echo '</td></tr>';
298
- $count ++;
299
- if ( $count >= 5 )
300
- break;
301
- }
302
- }
303
- else {
304
- echo '<tr><td colspan="3">' . __( 'none', 'backwpup' ) . '</td></tr>';
305
- }
306
- ?>
307
- </table>
308
- <?php
309
- }
310
-
311
- /**
312
- * Displaying next jobs
313
- */
314
- private static function mb_next_jobs() {
315
-
316
- if ( ! current_user_can( 'backwpup_jobs' ) )
317
- return;
318
- ?>
319
- <table class="wp-list-table widefat" cellspacing="0">
320
- <caption><?php _e( 'Next scheduled jobs', 'backwpup' ); ?></caption>
321
- <thead>
322
- <tr>
323
- <th style="width: 30%"><?php _e( 'Time', 'backwpup' ); ?></th>
324
- <th style="width: 70%"><?php _e( 'Job', 'backwpup' ); ?></th>
325
- </tr>
326
- </thead>
327
- <?php
328
- //get next jobs
329
- $mainsactive = BackWPup_Option::get_job_ids( 'activetype', 'wpcron' );
330
- sort( $mainsactive );
331
- $alternate = TRUE;
332
- // add working job if it not in active jobs
333
- $job_object = BackWPup_Job::get_working_data();
334
- if ( ! empty( $job_object ) && ! empty( $job_object->job[ 'jobid' ] ) && ! in_array($job_object->job[ 'jobid' ], $mainsactive ) )
335
- $mainsactive[ ] = $job_object->job[ 'jobid' ];
336
- foreach ( $mainsactive as $jobid ) {
337
- $name = BackWPup_Option::get( $jobid, 'name' );
338
- if ( ! empty( $job_object ) && $job_object->job[ 'jobid' ] == $jobid ) {
339
- $runtime = current_time( 'timestamp' ) - $job_object->job[ 'lastrun' ];
340
- if ( ! $alternate ) {
341
- echo '<tr>';
342
- $alternate = TRUE;
343
- } else {
344
- echo '<tr class="alternate">';
345
- $alternate = FALSE;
346
- }
347
- echo '<td>' . sprintf( '<span style="color:#e66f00;">' . __( 'working since %d seconds', 'backwpup' ) . '</span>', $runtime ) . '</td>';
348
- echo '<td><span style="font-weight:bold;">' . esc_html ( $job_object->job[ 'name' ] ) . '</span><br />';
349
- echo "<a style=\"color:red;\" href=\"" . wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupjobs&action=abort', 'abort-job' ) . "\">" . __( 'Abort', 'backwpup' ) . "</a>";
350
- echo "</td></tr>";
351
- }
352
- else {
353
- if ( ! $alternate ) {
354
- echo '<tr>';
355
- $alternate = TRUE;
356
- } else {
357
- echo '<tr class="alternate">';
358
- $alternate = FALSE;
359
- }
360
- if ( $nextrun = wp_next_scheduled( 'backwpup_cron', array( 'id' => $jobid ) ) + ( get_option( 'gmt_offset' ) * 3600 ) )
361
- echo '<td>' . sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ), $nextrun, TRUE ), date_i18n( get_option( 'time_format' ), $nextrun, TRUE ) ) . '</td>';
362
- else
363
- echo '<td><em>' . __( 'Not scheduled!', 'backwpup' ) . '</em></td>';
364
-
365
- echo '<td><a href="' . wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupeditjob&jobid=' . $jobid, 'edit-job' ) . '" title="' . esc_attr( __( 'Edit Job', 'backwpup' ) ) . '">' . $name . '</a></td></tr>';
366
- }
367
- }
368
- if ( empty( $mainsactive ) and ! empty( $job_object ) ) {
369
- echo '<tr><td colspan="2"><i>' . __( 'none', 'backwpup' ) . '</i></td></tr>';
370
- }
371
- ?>
372
- </table>
373
- <?php
374
- }
375
-
376
- /**
377
- * Set Feed Options
378
- *
379
- * @param $feed
380
- */
381
- public static function wp_feed_options( $feed ) {
382
-
383
- if ( is_object( $feed ) )
384
- $feed->set_useragent( BackWPup::get_plugin_data( 'user-agent' ) );
385
- }
386
-
387
- }
1
+ <?php
2
+ /**
3
+ * Render plugin dashboard.
4
+ *
5
+ */
6
+ class BackWPup_Page_BackWPup {
7
+
8
+
9
+ /**
10
+ * Called on load action.
11
+ *
12
+ * @return void
13
+ */
14
+ public static function load() {
15
+ global $wpdb;
16
+
17
+ if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'dbdumpdl' ) {
18
+
19
+ //check permissions
20
+ check_admin_referer( 'backwpupdbdumpdl' );
21
+
22
+ if ( ! current_user_can( 'backwpup_jobs_edit' ) )
23
+ die();
24
+
25
+ //doing dump
26
+ header( "Pragma: public" );
27
+ header( "Expires: 0" );
28
+ header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
29
+ header( "Content-Type: application/octet-stream; charset=". get_bloginfo( 'charset' ) );
30
+ header( "Content-Disposition: attachment; filename=" . DB_NAME . ".sql;" );
31
+ try {
32
+ $sql_dump = new BackWPup_MySQLDump();
33
+ foreach ( $sql_dump->tables_to_dump as $key => $table ) {
34
+ if ( $wpdb->prefix != substr( $table,0 , strlen( $wpdb->prefix ) ) )
35
+ unset( $sql_dump->tables_to_dump[ $key ] );
36
+ }
37
+ $sql_dump->execute();
38
+ unset( $sql_dump );
39
+ } catch ( Exception $e ) {
40
+ die( $e->getMessage() );
41
+ }
42
+ die();
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Enqueue script.
48
+ *
49
+ * @return void
50
+ */
51
+ public static function admin_print_scripts() {
52
+
53
+ wp_enqueue_script( 'backwpupgeneral' );
54
+
55
+ }
56
+
57
+ /**
58
+ * Print the markup.
59
+ *
60
+ * @return void
61
+ */
62
+ public static function page() {
63
+ // get wizards
64
+ $wizards = BackWPup::get_wizards();
65
+ ?>
66
+ <div class="wrap" id="backwpup-page">
67
+ <h2><span id="backwpup-page-icon">&nbsp;</span><?php echo sprintf( __( '%s Dashboard', 'backwpup' ), BackWPup::get_plugin_data( 'name') ); ?></h2>
68
+ <?php
69
+
70
+ BackWPup_Admin::display_messages();
71
+
72
+ if ( class_exists( 'BackWPup_Pro', FALSE ) ) { ?>
73
+ <div class="backwpup-welcome backwpup-max-width">
74
+ <h3><?php _ex( 'Planning backups', 'Dashboard heading', 'backwpup' ); ?></h3>
75
+ <p><?php _e('BackWPup’s job wizards make planning and scheduling your backup jobs a breeze.','backwpup' ); echo ' '; _e('Use your backup archives to save your entire WordPress installation including <code>/wp-content/</code>. Push them to an external storage service if you don’t want to save the backups on the same server.','backwpup'); ?></p>
76
+ <h3><?php _ex( 'Restoring backups', 'Dashboard heading', 'backwpup' ); ?></h3>
77
+ <p><?php _e( 'With a single backup archive you are able to restore an installation. Use a tool like phpMyAdmin or a plugin like <a href="http://wordpress.org/plugins/adminer/" target="_blank">Adminer</a> to restore your database backup files.', 'backwpup' ) ?></p>
78
+ <h3><?php _ex( 'Ready to set up a backup job?', 'Dashboard heading','backwpup' ); ?></h3>
79
+ <p><?php printf( __('Use one of the wizards to plan a backup, or use <a href="%s">expert mode</a> for full control over all options.','backwpup'), network_admin_url( 'admin.php') . '?page=backwpupeditjob' ); echo ' '; _e( '<strong>Please note: You are solely responsible for the security of your data; the authors of this plugin are not.</strong>', 'backwpup' ); ?></p>
80
+ </div>
81
+ <?php } else {?>
82
+ <div class="backwpup-welcome backwpup-max-width">
83
+ <h3><?php _ex( 'Planning backups', 'Dashboard heading', 'backwpup' ); ?></h3>
84
+ <p><?php _e('Use the short links in the <strong>First steps</strong> box to plan and schedule backup jobs.','backwpup' ); echo ' '; _e('Use your backup archives to save your entire WordPress installation including <code>/wp-content/</code>. Push them to an external storage service if you don’t want to save the backups on the same server.','backwpup'); ?></p>
85
+ <h3><?php _ex( 'Restoring backups', 'Dashboard heading', 'backwpup' ); ?></h3>
86
+ <p><?php _e( 'With a single backup archive you are able to restore an installation. Use a tool like phpMyAdmin or a plugin like <a href="http://wordpress.org/plugins/adminer/" target="_blank">Adminer</a> to restore your database backup files.', 'backwpup' ) ?></p>
87
+ <h3><?php _ex( 'Ready to set up a backup job?', 'Dashboard heading','backwpup' ); ?></h3>
88
+ <p><?php printf( __('<a href="%s">Add a new backup job</a> and plan what you want to save.','backwpup'), network_admin_url( 'admin.php') . '?page=backwpupeditjob' ); ?>
89
+ <br /><?php _e( '<strong>Please note: You are solely responsible for the security of your data; the authors of this plugin are not.</strong>', 'backwpup' ); ?></p>
90
+ </div>
91
+ <?php }
92
+
93
+ if ( current_user_can( 'backwpup_jobs_edit' ) && current_user_can( 'backwpup_logs' ) && current_user_can( 'backwpup_jobs_start' ) ) {
94
+ ?>
95
+ <div id="backwpup-first-steps" class="metabox-holder postbox backwpup-floated-postbox">
96
+ <h3 class="hndle"><span><?php _e( 'First Steps', 'backwpup' ); ?></span></h3>
97
+ <div class="inside">
98
+ <ul>
99
+ <?php if ( class_exists( 'BackWPup_Pro', FALSE ) ) { ?>
100
+ <li type="1"><a href="<?php echo wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupwizard&wizard_start=SYSTEMTEST', 'wizard' ); ?>"><?php _e( 'Test the installation', 'backwpup' ); ?></a></li>
101
+ <li type="1"><a href="<?php echo wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupwizard&wizard_start=JOB', 'wizard' ); ?>"><?php _e( 'Create a Job', 'backwpup' ); ?></a></li>
102
+ <?php } else { ?>
103
+ <li type="1"><a href="<?php echo network_admin_url( 'admin.php' ) . '?page=backwpupsettings#backwpup-tab-information'; ?>"><?php _e( 'Check the installation', 'backwpup' ); ?></a></li>
104
+ <li type="1"><a href="<?php echo network_admin_url( 'admin.php' ) . '?page=backwpupeditjob'; ?>"><?php _e( 'Create a Job', 'backwpup' ); ?></a></li>
105
+ <?php } ?>
106
+ <li type="1"><a href="<?php echo network_admin_url( 'admin.php' ) . '?page=backwpupjobs'; ?>"><?php _e( 'Run the created job', 'backwpup' ); ?></a></li>
107
+ <li type="1"><a href="<?php echo network_admin_url( 'admin.php' ) . '?page=backwpuplogs'; ?>"><?php _e( 'Check the job log', 'backwpup' ); ?></a></li>
108
+ </ul>
109
+ </div>
110
+ </div>
111
+ <?php }
112
+
113
+ if ( current_user_can( 'backwpup_jobs_start' ) ) {?>
114
+ <div id="backwpup-one-click-backup" class="metabox-holder postbox backwpup-floated-postbox">
115
+ <h3 class="hndle"><span><?php _e( 'One click backup', 'backwpup' ); ?></span></h3>
116
+ <div class="inside">
117
+ <a href="<?php echo wp_nonce_url( network_admin_url( 'admin.php' ). '?page=backwpup&action=dbdumpdl', 'backwpupdbdumpdl' ); ?>" class="button button-primary button-primary-bwp" title="<?php _e( 'Generate a database backup of WordPress tables and download it right away!', 'backwpup' ); ?>"><?php _e( 'Download database backup', 'backwpup' ); ?></a><br />
118
+ </div>
119
+ </div>
120
+ <?php } ?>
121
+
122
+ <div id="backwpup-rss-feed" class="metabox-holder postbox backwpup-cleared-postbox backwpup-max-width">
123
+ <h3 class="hndle"><span><?php _e( 'BackWPup News', 'backwpup' ); ?></span></h3>
124
+ <div class="inside">
125
+ <?php
126
+ add_action( 'wp_feed_options', array( __CLASS__, 'wp_feed_options' ) );
127
+
128
+ $rss = fetch_feed( _x( 'http://marketpress.com/news/plugins/backwpup/feed/', 'BackWPup News RSS Feed URL', 'backwpup' ) );
129
+
130
+ remove_action( 'wp_feed_options', array( __CLASS__, 'wp_feed_options' ) );
131
+
132
+ if ( is_wp_error($rss) ) {
133
+ echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s', 'backwpup' ), $rss->get_error_message() ) . '</p>';
134
+ return;
135
+ }
136
+
137
+ if ( !$rss->get_item_quantity() ) {
138
+ echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.', 'backwpup' ) . '</li></ul>';
139
+ $rss->__destruct();
140
+ unset($rss);
141
+ return;
142
+ }
143
+
144
+ echo '<ul>';
145
+ $first = TRUE;
146
+ foreach ( $rss->get_items( 0, 4 ) as $item ) {
147
+ $link = $item->get_link();
148
+ while ( stristr($link, 'http') != $link )
149
+ $link = substr($link, 1);
150
+ $link = esc_url(strip_tags($link));
151
+ $title = esc_attr(strip_tags($item->get_title()));
152
+ if ( empty($title) )
153
+ $title = __( 'Untitled', 'backwpup' );
154
+
155
+ $desc = str_replace( array("\n", "\r"), ' ', esc_attr( strip_tags( @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) ) );
156
+ $excerpt = wp_html_excerpt( $desc, 360 );
157
+
158
+ // Append ellipsis. Change existing [...] to [&hellip;].
159
+ if ( '[...]' == substr( $excerpt, -5 ) )
160
+ $excerpt = substr( $excerpt, 0, -5 ) . '[&hellip;]';
161
+ elseif ( '[&hellip;]' != substr( $excerpt, -10 ) && $desc != $excerpt )
162
+ $excerpt .= ' [&hellip;]';
163
+
164
+ $excerpt = esc_html( $excerpt );
165
+
166
+ if ( $first ) {
167
+ $summary = "<div class='rssSummary'>$excerpt</div>";
168
+ } else {
169
+ $summary = '';
170
+ }
171
+
172
+ $date = '';
173
+ if ( $first ) {
174
+ $date = $item->get_date( 'U' );
175
+
176
+ if ( $date ) {
177
+ $date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date ) . '</span>';
178
+ }
179
+ }
180
+
181
+ echo "<li><a href=\"$link\" title=\"$desc\">$title</a>{$date}{$summary}</li>";
182
+ $first = FALSE;
183
+ }
184
+ echo '</ul>';
185
+ $rss->__destruct();
186
+ unset($rss);
187
+ ?>
188
+ </div>
189
+ </div>
190
+
191
+ <?php
192
+ if ( class_exists( 'BackWPup_Pro', FALSE ) ) {
193
+ /* @var BackWPup_Pro_Wizards $wizard_class */
194
+
195
+ foreach ( $wizards as $wizard_class ) {
196
+ //check permissions
197
+ if ( ! current_user_can( $wizard_class->info[ 'cap' ] ) )
198
+ continue;
199
+ //get info of wizard
200
+ echo '<div id="wizard-' . strtolower( $wizard_class->info[ 'ID' ] ) . '" class="wizardbox post-box backwpup-floated-postbox"><form method="get" action="' . network_admin_url( 'admin.php' ) . '">';
201
+ echo '<h3 class="wizardbox_name">' . $wizard_class->info[ 'name' ] . '</h3>';
202
+ echo '<p class="wizardbox_description">' . $wizard_class->info[ 'description' ] . '</p>';
203
+ $conf_names = $wizard_class->get_pre_configurations();
204
+ if ( ! empty ( $conf_names ) ) {
205
+ echo '<select id="wizardbox_pre_conf" name="pre_conf" size="1">';
206
+ foreach( $conf_names as $conf_key => $conf_name) {
207
+ echo '<option value="' . esc_attr( $conf_key ) . '">' . esc_attr( $conf_name ) . '</option>';
208
+ }
209
+ echo '</select>';
210
+ } else {
211
+ echo '<input type="hidden" name="pre_conf" value="" />';
212
+ }
213
+ wp_nonce_field( 'wizard' );
214
+ echo '<input type="hidden" name="page" value="backwpupwizard" />';
215
+ echo '<input type="hidden" name="wizard_start" value="' . esc_attr( $wizard_class->info[ 'ID' ] ) . '" />';
216
+ echo '<div class="wizardbox_start"><input type="submit" name="submit" class="button button-primary button-primary-bwp" value="' . esc_attr( __( 'Start wizard', 'backwpup' ) ) . '" /></div>';
217
+ echo '</form></div>';
218
+ }
219
+ } ?>
220
+
221
+ <div id="backwpup-stats" class="metabox-holder postbox backwpup-cleared-postbox backwpup-max-width">
222
+ <div class="backwpup-table-wrap">
223
+ <?php
224
+ self::mb_next_jobs();
225
+ self::mb_last_logs();
226
+ ?>
227
+ </div>
228
+ </div>
229
+
230
+ <?php if ( ! class_exists( 'BackWPup_Pro', FALSE ) ) { ?>
231
+ <div id="backwpup-thank-you" class="metabox-holder postbox backwpup-cleared-postbox backwpup-max-width">
232
+ <h3 class="hndle"><span><?php _ex( 'Thank you for using BackWPup!', 'Pro teaser box', 'backwpup' ); ?></span></h3>
233
+ <div class="inside">
234
+ <p><img class="backwpup-banner-img" src="<?php echo BackWPup::get_plugin_data( 'URL' ) . '/assets/images/backwpupbanner-pro.png'; ?>" alt="BackWPup Banner" /></p>
235
+ <h3 class="backwpup-text-center"><?php _ex( 'Get access to:', 'Pro teaser box', 'backwpup' ); ?></h3>
236
+ <ul class="backwpup-text-center">
237
+ <li><?php _ex( 'First-class <strong>dedicated support</strong> at MarketPress Helpdesk.', 'Pro teaser box', 'backwpup' ); ?></li>
238
+ <li><?php _ex( 'Differential backups to Google Drive and other cloud storage service.', 'Pro teaser box', 'backwpup' ); ?></li>
239
+ <li><?php _ex( 'Easy-peasy wizards to create and schedule backup jobs.', 'Pro teaser box', 'backwpup' ); ?></li>
240
+ <li><?php printf( '<a href="http://marketpress.com/product/backwpup-pro/">%s</a>', _x( 'And more…', 'Pro teaser box, link text', 'backwpup' ) ); ?></li>
241
+ </ul>
242
+ <p class="backwpup-text-center"><a href="http://marketpress.com/product/backwpup-pro/" class="button button-primary button-primary-bwp" title="<?php _ex( 'Get BackWPup Pro now', 'Pro teaser box, link title', 'backwpup' ); ?>"><?php _ex( 'Get BackWPup Pro now', 'Pro teaser box, link text', 'backwpup' ); ?></a></p>
243
+ </div>
244
+ </div>
245
+ <?php } ?>
246
+
247
+ </div>
248
+ <?php
249
+ }
250
+
251
+ /**
252
+ * Displaying last logs
253
+ */
254
+ private static function mb_last_logs() {
255
+
256
+ if ( ! current_user_can( 'backwpup_logs' ) )
257
+ return;
258
+ ?>
259
+ <table class="wp-list-table widefat" cellspacing="0">
260
+ <caption><?php _e( 'Last logs', 'backwpup' ); ?></caption>
261
+ <thead>
262
+ <tr><th style="width:30%"><?php _e( 'Time', 'backwpup' ); ?></th><th style="width:55%"><?php _e( 'Job', 'backwpup' ); ?></th><th style="width:20%"><?php _e( 'Result', 'backwpup' ); ?></th></tr>
263
+ </thead>
264
+ <?php
265
+ //get log files
266
+ $logfiles = array();
267
+ if ( is_writeable( get_site_option( 'backwpup_cfg_logfolder' ) ) && $dir = @opendir( get_site_option( 'backwpup_cfg_logfolder' ) ) ) {
268
+ while ( ( $file = readdir( $dir ) ) !== FALSE ) {
269
+ if ( is_readable( get_site_option( 'backwpup_cfg_logfolder' ) . $file ) && is_file( get_site_option( 'backwpup_cfg_logfolder' ) . $file ) && FALSE !== strpos( $file, 'backwpup_log_' ) && FALSE !== strpos( $file, '.html' ) )
270
+ $logfiles[ filemtime( get_site_option( 'backwpup_cfg_logfolder' ) . '/' . $file ) ] = $file;
271
+ }
272
+ closedir( $dir );
273
+ krsort( $logfiles, SORT_NUMERIC );
274
+ }
275
+
276
+ if ( count( $logfiles ) > 0 ) {
277
+ $count = 0;
278
+ $alternate = TRUE;
279
+ foreach ( $logfiles as $logfile ) {
280
+ $logdata = BackWPup_Job::read_logheader( get_site_option( 'backwpup_cfg_logfolder' ) . $logfile );
281
+ if ( ! $alternate ) {
282
+ echo '<tr>';
283
+ $alternate = TRUE;
284
+ } else {
285
+ echo '<tr class="alternate">';
286
+ $alternate = FALSE;
287
+ }
288
+ echo '<td>' . sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ) , $logdata[ 'logtime' ] ), date_i18n( get_option( 'time_format' ), $logdata[ 'logtime' ] ) ) . '</td>';
289
+ echo '<td><a class="thickbox" href="' . admin_url( 'admin-ajax.php' ) . '?&action=backwpup_view_log&logfile=' . basename( $logfile ) .'&_ajax_nonce=' . wp_create_nonce( 'view-logs' ) . '&amp;TB_iframe=true&amp;width=640&amp;height=440" title="' . esc_attr( basename( $logfile ) ) . '">' . $logdata[ 'name' ] . '</i></a></td>';
290
+ echo '<td>';
291
+ if ( $logdata[ 'errors' ] > 0 )
292
+ printf( '<span style="color:red;font-weight:bold;">' . _n( "%d ERROR", "%d ERRORS", $logdata[ 'errors' ], 'backwpup' ) . '</span><br />', $logdata[ 'errors' ] );
293
+ if ( $logdata[ 'warnings' ] > 0 )
294
+ printf( '<span style="color:#e66f00;font-weight:bold;">' . _n( "%d WARNING", "%d WARNINGS", $logdata[ 'warnings' ], 'backwpup' ) . '</span><br />', $logdata[ 'warnings' ] );
295
+ if ( $logdata[ 'errors' ] == 0 && $logdata[ 'warnings' ] == 0 )
296
+ echo '<span style="color:green;font-weight:bold;">' . __( 'OK', 'backwpup' ) . '</span>';
297
+ echo '</td></tr>';
298
+ $count ++;
299
+ if ( $count >= 5 )
300
+ break;
301
+ }
302
+ }
303
+ else {
304
+ echo '<tr><td colspan="3">' . __( 'none', 'backwpup' ) . '</td></tr>';
305
+ }
306
+ ?>
307
+ </table>
308
+ <?php
309
+ }
310
+
311
+ /**
312
+ * Displaying next jobs
313
+ */
314
+ private static function mb_next_jobs() {
315
+
316
+ if ( ! current_user_can( 'backwpup_jobs' ) )
317
+ return;
318
+ ?>
319
+ <table class="wp-list-table widefat" cellspacing="0">
320
+ <caption><?php _e( 'Next scheduled jobs', 'backwpup' ); ?></caption>
321
+ <thead>
322
+ <tr>
323
+ <th style="width: 30%"><?php _e( 'Time', 'backwpup' ); ?></th>
324
+ <th style="width: 70%"><?php _e( 'Job', 'backwpup' ); ?></th>
325
+ </tr>
326
+ </thead>
327
+ <?php
328
+ //get next jobs
329
+ $mainsactive = BackWPup_Option::get_job_ids( 'activetype', 'wpcron' );
330
+ sort( $mainsactive );
331
+ $alternate = TRUE;
332
+ // add working job if it not in active jobs
333
+ $job_object = BackWPup_Job::get_working_data();
334
+ if ( ! empty( $job_object ) && ! empty( $job_object->job[ 'jobid' ] ) && ! in_array($job_object->job[ 'jobid' ], $mainsactive ) )
335
+ $mainsactive[ ] = $job_object->job[ 'jobid' ];
336
+ foreach ( $mainsactive as $jobid ) {
337
+ $name = BackWPup_Option::get( $jobid, 'name' );
338
+ if ( ! empty( $job_object ) && $job_object->job[ 'jobid' ] == $jobid ) {
339
+ $runtime = current_time( 'timestamp' ) - $job_object->job[ 'lastrun' ];
340
+ if ( ! $alternate ) {
341
+ echo '<tr>';
342
+ $alternate = TRUE;
343
+ } else {
344
+ echo '<tr class="alternate">';
345
+ $alternate = FALSE;
346
+ }
347
+ echo '<td>' . sprintf( '<span style="color:#e66f00;">' . __( 'working since %d seconds', 'backwpup' ) . '</span>', $runtime ) . '</td>';
348
+ echo '<td><span style="font-weight:bold;">' . esc_html ( $job_object->job[ 'name' ] ) . '</span><br />';
349
+ echo "<a style=\"color:red;\" href=\"" . wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupjobs&action=abort', 'abort-job' ) . "\">" . __( 'Abort', 'backwpup' ) . "</a>";
350
+ echo "</td></tr>";
351
+ }
352
+ else {
353
+ if ( ! $alternate ) {
354
+ echo '<tr>';
355
+ $alternate = TRUE;
356
+ } else {
357
+ echo '<tr class="alternate">';
358
+ $alternate = FALSE;
359
+ }
360
+ if ( $nextrun = wp_next_scheduled( 'backwpup_cron', array( 'id' => $jobid ) ) + ( get_option( 'gmt_offset' ) * 3600 ) )
361
+ echo '<td>' . sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ), $nextrun, TRUE ), date_i18n( get_option( 'time_format' ), $nextrun, TRUE ) ) . '</td>';
362
+ else
363
+ echo '<td><em>' . __( 'Not scheduled!', 'backwpup' ) . '</em></td>';
364
+
365
+ echo '<td><a href="' . wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupeditjob&jobid=' . $jobid, 'edit-job' ) . '" title="' . esc_attr( __( 'Edit Job', 'backwpup' ) ) . '">' . $name . '</a></td></tr>';
366
+ }
367
+ }
368
+ if ( empty( $mainsactive ) and ! empty( $job_object ) ) {
369
+ echo '<tr><td colspan="2"><i>' . __( 'none', 'backwpup' ) . '</i></td></tr>';
370
+ }
371
+ ?>
372
+ </table>
373
+ <?php
374
+ }
375
+
376
+ /**
377
+ * Set Feed Options
378
+ *
379
+ * @param $feed
380
+ */
381
+ public static function wp_feed_options( $feed ) {
382
+
383
+ if ( is_object( $feed ) )
384
+ $feed->set_useragent( BackWPup::get_plugin_data( 'user-agent' ) );
385
+ }
386
+
387
+ }
inc/class-page-editjob.php CHANGED
@@ -1,897 +1,897 @@
1
- <?php
2
- /**
3
- *
4
- */
5
- class BackWPup_Page_Editjob {
6
-
7
- /**
8
- *
9
- */
10
- public static function auth() {
11
-
12
- //check $_GET[ 'tab' ]
13
- if ( isset($_GET[ 'tab' ] ) ) {
14
- $_GET[ 'tab' ] = sanitize_title_with_dashes( $_GET[ 'tab' ] );
15
- if ( substr( $_GET[ 'tab' ], 0, 5 ) != 'dest-' && substr( $_GET[ 'tab' ], 0, 8 ) != 'jobtype-' && ! in_array( $_GET[ 'tab' ], array( 'job','cron' ) ) )
16
- $_GET[ 'tab' ] = 'job';
17
- } else {
18
- $_GET[ 'tab' ] = 'job';
19
- }
20
-
21
- if ( substr( $_GET[ 'tab' ], 0, 5 ) == 'dest-' ) {
22
- $jobid = (int)$_GET[ 'jobid' ];
23
- $id = strtoupper( str_replace( 'dest-', '', $_GET[ 'tab' ] ) );
24
- $dest_class = BackWPup::get_destination( $id );
25
- $dest_class->edit_auth( $jobid );
26
- }
27
- }
28
-
29
- /**
30
- *
31
- */
32
- public static function load() {
33
-
34
- //add Help tab
35
- BackWPup_Help::add_tab( array(
36
- 'id' => 'overview',
37
- 'title' => __( 'Overview','backwpup' ),
38
- 'content' =>
39
- '<p>' . '</p>'
40
- ) );
41
-
42
- }
43
-
44
- /**
45
- * Save Form data
46
- */
47
- public static function save_post_form($tab, $jobid) {
48
-
49
- if ( ! current_user_can( 'backwpup_jobs_edit' ) )
50
- return __( 'Sorry, you don\'t have permissions to do that.', 'backwpup');
51
-
52
- $destinations = BackWPup::get_registered_destinations();
53
- $job_types = BackWPup::get_job_types();
54
-
55
- switch ( $tab ) {
56
- case 'job':
57
- BackWPup_Option::update( $jobid, 'jobid', $jobid );
58
-
59
- if ( isset( $_POST[ 'type' ] ) && is_array( $_POST[ 'type' ] ) ) {
60
- foreach ( (array)$_POST[ 'type' ] as $typeid ) {
61
- if ( empty( $job_types[ $typeid ] ) )
62
- unset( $_POST[ 'type' ][ $typeid ] );
63
- }
64
- if ( is_array( $_POST[ 'type' ] ) )
65
- sort( $_POST[ 'type' ] );
66
- } else {
67
- $_POST[ 'type' ]= array();
68
- }
69
- //test if job type makes backup
70
- /* @var BackWPup_JobTypes $job_type */
71
- $makes_file = FALSE;
72
- foreach ( $job_types as $type_id => $job_type) {
73
- if ( in_array( $type_id, $_POST[ 'type' ] ) ) {
74
- if ( $job_type->creates_file() ) {
75
- $makes_file = TRUE;
76
- break;
77
- }
78
- }
79
- }
80
- if ( ! $makes_file )
81
- $_POST[ 'destinations' ] = array();
82
- BackWPup_Option::update( $jobid, 'type', $_POST[ 'type' ] );
83
-
84
- if ( isset( $_POST[ 'destinations' ] ) && is_array( $_POST[ 'destinations' ] ) ) {
85
- foreach ( (array)$_POST[ 'destinations' ] as $key => $destid ) {
86
- if ( empty( $destinations[ $destid ] ) ) //remove all destinations that not exists
87
- unset( $_POST[ 'destinations' ][ $key ] );
88
- if ( class_exists( 'BackWPup_Pro', FALSE ) && $_POST[ 'backuptype' ] == 'sync' ) { //if sync remove all not sync destinations
89
- if ( ! $destinations[ $destid ][ 'can_sync' ] )
90
- unset( $_POST[ 'destinations' ][ $key ] );
91
- }
92
- }
93
- if ( is_array( $_POST[ 'destinations' ] ) )
94
- sort( $_POST[ 'destinations' ] );
95
- } else {
96
- $_POST[ 'destinations' ] = array();
97
- }
98
- BackWPup_Option::update( $jobid, 'destinations', $_POST[ 'destinations' ] );
99
-
100
- $name = esc_html( trim( $_POST[ 'name' ] ) );
101
- if ( empty( $name ) || $_POST[ 'name' ] == __( 'New Job', 'backwpup' ) )
102
- $name = sprintf( __( 'Job with ID %d', 'backwpup' ), $jobid );
103
- BackWPup_Option::update( $jobid, 'name', $name );
104
- BackWPup_Option::update( $jobid, 'mailaddresslog', sanitize_email( $_POST[ 'mailaddresslog' ] ) );
105
-
106
- $_POST[ 'mailaddresssenderlog' ] = trim( $_POST[ 'mailaddresssenderlog' ] );
107
- if ( empty($_POST[ 'mailaddresssenderlog' ] ) )
108
- BackWPup_Option::delete( $jobid, 'mailaddresssenderlog');
109
- else
110
- BackWPup_Option::update( $jobid, 'mailaddresssenderlog', $_POST[ 'mailaddresssenderlog' ] );
111
-
112
- BackWPup_Option::update( $jobid, 'mailerroronly', ( isset( $_POST[ 'mailerroronly' ] ) && $_POST[ 'mailerroronly' ] == 1 ) ? TRUE : FALSE );
113
- if ( class_exists( 'BackWPup_Pro', FALSE ) )
114
- BackWPup_Option::update( $jobid, 'backuptype', $_POST[ 'backuptype' ] );
115
- else
116
- BackWPup_Option::update( $jobid, 'backuptype', 'archive' );
117
- BackWPup_Option::update( $jobid, 'archiveformat', $_POST[ 'archiveformat' ] );
118
- BackWPup_Option::update( $jobid, 'archivename', esc_html( $_POST[ 'archivename' ] ) );
119
- break;
120
- case 'cron':
121
- if ( $_POST[ 'activetype' ] == '' || $_POST[ 'activetype' ] == 'wpcron' || $_POST[ 'activetype' ] == 'link' )
122
- BackWPup_Option::update( $jobid, 'activetype', $_POST[ 'activetype' ] );
123
-
124
- BackWPup_Option::update( $jobid, 'cronselect', $_POST[ 'cronselect' ] == 'advanced' ? 'advanced' : 'basic' );
125
-
126
- if ( isset($_POST[ 'cronselect' ]) && $_POST[ 'cronselect' ] == 'advanced' ) { //save advanced
127
- if ( empty( $_POST[ 'cronminutes' ] ) || $_POST[ 'cronminutes' ][ 0 ] == '*' ) {
128
- if ( ! empty( $_POST[ 'cronminutes' ][ 1 ] ) )
129
- $_POST[ 'cronminutes' ] = array( '*/' . $_POST[ 'cronminutes' ][ 1 ] );
130
- else
131
- $_POST[ 'cronminutes' ] = array( '*' );
132
- }
133
- if ( empty( $_POST[ 'cronhours' ] ) || $_POST[ 'cronhours' ][ 0 ] == '*' ) {
134
- if ( ! empty( $_POST[ 'cronhours' ][ 1 ] ) )
135
- $_POST[ 'cronhours' ] = array( '*/' . $_POST[ 'cronhours' ][ 1 ] );
136
- else
137
- $_POST[ 'cronhours' ] = array( '*' );
138
- }
139
- if ( empty( $_POST[ 'cronmday' ] ) || $_POST[ 'cronmday' ][ 0 ] == '*' ) {
140
- if ( ! empty( $_POST[ 'cronmday' ][ 1 ] ) )
141
- $_POST[ 'cronmday' ] = array( '*/' . $_POST[ 'cronmday' ][ 1 ] );
142
- else
143
- $_POST[ 'cronmday' ] = array( '*' );
144
- }
145
- if ( empty( $_POST[ 'cronmon' ] ) || $_POST[ 'cronmon' ][ 0 ] == '*' ) {
146
- if ( ! empty( $_POST[ 'cronmon' ][ 1 ] ) )
147
- $_POST[ 'cronmon' ] = array( '*/' . $_POST[ 'cronmon' ][ 1 ] );
148
- else
149
- $_POST[ 'cronmon' ] = array( '*' );
150
- }
151
- if ( empty( $_POST[ 'cronwday' ] ) || $_POST[ 'cronwday' ][ 0 ] == '*' ) {
152
- if ( ! empty( $_POST[ 'cronwday' ][ 1 ] ) )
153
- $_POST[ 'cronwday' ] = array( '*/' . $_POST[ 'cronwday' ][ 1 ] );
154
- else
155
- $_POST[ 'cronwday' ] = array( '*' );
156
- }
157
- $cron = implode( ",", $_POST[ 'cronminutes' ] ) . ' ' . implode( ",", $_POST[ 'cronhours' ] ) . ' ' . implode( ",", $_POST[ 'cronmday' ] ) . ' ' . implode( ",", $_POST[ 'cronmon' ] ) . ' ' . implode( ",", $_POST[ 'cronwday' ] );
158
- BackWPup_Option::update( $jobid, 'cron', $cron );
159
- } else { //Save basic
160
- if ( $_POST[ 'cronbtype' ] == 'mon' )
161
- BackWPup_Option::update( $jobid, 'cron', $_POST[ 'moncronminutes' ] . ' ' . $_POST[ 'moncronhours' ] . ' ' . $_POST[ 'moncronmday' ] . ' * *' );
162
- if ( $_POST[ 'cronbtype' ] == 'week' )
163
- BackWPup_Option::update( $jobid, 'cron', $_POST[ 'weekcronminutes' ] . ' ' . $_POST[ 'weekcronhours' ] . ' * * ' . $_POST[ 'weekcronwday' ] );
164
- if ( $_POST[ 'cronbtype' ] == 'day' )
165
- BackWPup_Option::update( $jobid, 'cron', $_POST[ 'daycronminutes' ] . ' ' . $_POST[ 'daycronhours' ] . ' * * *' );
166
- if ( $_POST[ 'cronbtype' ] == 'hour' )
167
- BackWPup_Option::update( $jobid, 'cron', $_POST[ 'hourcronminutes' ] . ' * * * *' );
168
- }
169
- //reschedule
170
- wp_clear_scheduled_hook( 'backwpup_cron', array( 'id' => $jobid ) );
171
- if ( BackWPup_Option::get( $jobid, 'activetype' ) == 'wpcron' ) {
172
- $cron_next = BackWPup_Cron::cron_next( BackWPup_Option::get( $jobid, 'cron' ) );
173
- wp_schedule_single_event( $cron_next, 'backwpup_cron', array( 'id' => $jobid ) );
174
- }
175
- break;
176
- default:
177
- if ( strstr( $tab, 'dest-' ) ) {
178
- $dest_class = BackWPup::get_destination( str_replace( 'dest-', '', $tab ) );
179
- $dest_class->edit_form_post_save( $jobid );
180
- }
181
- if ( strstr( $tab, 'jobtype-' ) ) {
182
- $id = strtoupper( str_replace( 'jobtype-', '', $tab ) );
183
- $job_types[ $id ]->edit_form_post_save( $jobid );
184
- }
185
- }
186
-
187
- //saved message
188
- $messages = BackWPup_Admin::get_messages();
189
- if ( empty( $messages[ 'error' ] ) ) {
190
- $url = BackWPup_Job::get_jobrun_url( 'runnowlink', $jobid );
191
- BackWPup_Admin::message( sprintf( __( 'Changes for job <i>%s</i> saved.', 'backwpup' ), BackWPup_Option::get( $jobid, 'name' ) ) .
192
- ' <a href="' . network_admin_url( 'admin.php' ) . '?page=backwpupjobs">' . __( 'Jobs overview', 'backwpup' ) . '</a> | <a href="' . $url[ 'url' ] . '">' . __( 'Run now', 'backwpup' ) . '</a>' );
193
- }
194
- }
195
-
196
- /**
197
- *
198
- * Output css
199
- *
200
- * @return void
201
- */
202
- public static function admin_print_styles() {
203
-
204
- ?>
205
- <style type="text/css" media="screen">
206
- #cron-min, #cron-hour, #cron-day, #cron-month, #cron-weekday {
207
- overflow: auto;
208
- white-space: nowrap;
209
- height: 7em;
210
- }
211
- #cron-min-box, #cron-hour-box, #cron-day-box, #cron-month-box, #cron-weekday-box {
212
- border-color: gray;
213
- border-style: solid;
214
- border-width: 1px;
215
- margin: 10px 0px 10px 10px;
216
- padding: 2px 2px;
217
- width: 100px;
218
- float: left;
219
- }
220
- #wpcronbasic {
221
- border-collapse: collapse;
222
- }
223
- #wpcronbasic th, #wpcronbasic td {
224
- width:80px;
225
- border-bottom: 1px solid gray;
226
- }
227
- </style>
228
- <?php
229
- //add css for all other tabs
230
- if ( substr( $_GET[ 'tab' ], 0, 5 ) == 'dest-' ) {
231
- $dest_object = BackWPup::get_destination( str_replace( 'dest-', '', $_GET[ 'tab' ] ) );
232
- $dest_object->admin_print_styles();
233
- }
234
- elseif ( substr( $_GET[ 'tab' ], 0, 8 ) == 'jobtype-' ) {
235
- $job_type = BackWPup::get_job_types();
236
- $id = strtoupper( str_replace( 'jobtype-', '', $_GET[ 'tab' ] ) );
237
- $job_type[ $id ]->admin_print_styles( );
238
- }
239
- }
240
-
241
- /**
242
- *
243
- * Output js
244
- *
245
- * @return void
246
- */
247
- public static function admin_print_scripts() {
248
-
249
- wp_enqueue_script( 'backwpupgeneral' );
250
-
251
- //add js for the first tabs
252
- if ( $_GET[ 'tab' ] == 'job' ) {
253
- if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
254
- wp_enqueue_script( 'backwpuptabjob', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_edit_tab_job.js', array('jquery'), time(), TRUE );
255
- } else {
256
- wp_enqueue_script( 'backwpuptabjob', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_edit_tab_job.min.js', array('jquery'), BackWPup::get_plugin_data( 'Version' ), TRUE );
257
- }
258
- }
259
- elseif ( $_GET[ 'tab' ] == 'cron' ) {
260
- if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
261
- wp_enqueue_script( 'backwpuptabcron', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_edit_tab_cron.js', array('jquery'), time(), TRUE );
262
- } else {
263
- wp_enqueue_script( 'backwpuptabcron', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_edit_tab_cron.min.js', array('jquery'), BackWPup::get_plugin_data( 'Version' ), TRUE );
264
- }
265
- }
266
- //add js for all other tabs
267
- elseif ( strstr( $_GET[ 'tab' ], 'dest-' ) ) {
268
- $dest_object = BackWPup::get_destination( str_replace( 'dest-', '', $_GET[ 'tab' ] ) );
269
- $dest_object->admin_print_scripts();
270
- }
271
- elseif ( strstr( $_GET[ 'tab' ], 'jobtype-' ) ) {
272
- $job_type = BackWPup::get_job_types();
273
- $id = strtoupper( str_replace( 'jobtype-', '', $_GET[ 'tab' ] ) );
274
- $job_type[ $id ]->admin_print_scripts( );
275
- }
276
- }
277
-
278
- /**
279
- * @static
280
- *
281
- * @param string $args
282
- *
283
- * @return mixed
284
- */
285
- public static function ajax_cron_text( $args = '' ) {
286
-
287
- if ( is_array( $args ) ) {
288
- extract( $args );
289
- $ajax = FALSE;
290
- } else {
291
- if ( ! current_user_can( 'backwpup_jobs_edit' ) )
292
- wp_die( -1 );
293
- check_ajax_referer( 'backwpup_ajax_nonce' );
294
- if ( empty( $_POST[ 'cronminutes' ] ) || $_POST[ 'cronminutes' ][ 0 ] == '*' ) {
295
- if ( ! empty( $_POST[ 'cronminutes' ][ 1 ] ) )
296
- $_POST[ 'cronminutes' ] = array( '*/' . $_POST[ 'cronminutes' ][ 1 ] );
297
- else
298
- $_POST[ 'cronminutes' ] = array( '*' );
299
- }
300
- if ( empty( $_POST[ 'cronhours' ] ) || $_POST[ 'cronhours' ][ 0 ] == '*' ) {
301
- if ( ! empty( $_POST[ 'cronhours' ][ 1 ] ) )
302
- $_POST[ 'cronhours' ] = array( '*/' . $_POST[ 'cronhours' ][ 1 ] );
303
- else
304
- $_POST[ 'cronhours' ] = array( '*' );
305
- }
306
- if ( empty( $_POST[ 'cronmday' ] ) || $_POST[ 'cronmday' ][ 0 ] == '*' ) {
307
- if ( ! empty( $_POST[ 'cronmday' ][ 1 ] ) )
308
- $_POST[ 'cronmday' ] = array( '*/' . $_POST[ 'cronmday' ][ 1 ] );
309
- else
310
- $_POST[ 'cronmday' ] = array( '*' );
311
- }
312
- if ( empty( $_POST[ 'cronmon' ] ) || $_POST[ 'cronmon' ][ 0 ] == '*' ) {
313
- if ( ! empty( $_POST[ 'cronmon' ][ 1 ] ) )
314
- $_POST[ 'cronmon' ] = array( '*/' . $_POST[ 'cronmon' ][ 1 ] );
315
- else
316
- $_POST[ 'cronmon' ] = array( '*' );
317
- }
318
- if ( empty( $_POST[ 'cronwday' ] ) || $_POST[ 'cronwday' ][ 0 ] == '*' ) {
319
- if ( ! empty( $_POST[ 'cronwday' ][ 1 ] ) )
320
- $_POST[ 'cronwday' ] = array( '*/' . $_POST[ 'cronwday' ][ 1 ] );
321
- else
322
- $_POST[ 'cronwday' ] = array( '*' );
323
- }
324
- $crontype = $_POST[ 'crontype' ];
325
- $cronstamp = implode( ",", $_POST[ 'cronminutes' ] ) . ' ' . implode( ",", $_POST[ 'cronhours' ] ) . ' ' . implode( ",", $_POST[ 'cronmday' ] ) . ' ' . implode( ",", $_POST[ 'cronmon' ] ) . ' ' . implode( ",", $_POST[ 'cronwday' ] );
326
- $ajax = TRUE;
327
- }
328
- echo '<p class="wpcron" id="schedulecron">';
329
-
330
- if ( $crontype == 'advanced' ) {
331
- echo str_replace( '\"','"', __( 'Working as <a href="http://wikipedia.org/wiki/Cron">Cron</a> schedule:', 'backwpup' ) );
332
- echo ' <i><b>' . esc_attr( $cronstamp ). '</b></i><br />';
333
- }
334
-
335
- list( $cronstr[ 'minutes' ], $cronstr[ 'hours' ], $cronstr[ 'mday' ], $cronstr[ 'mon' ], $cronstr[ 'wday' ] ) = explode( ' ', $cronstamp, 5 );
336
- if ( FALSE !== strpos( $cronstr[ 'minutes' ], '*/' ) || $cronstr[ 'minutes' ] == '*' ) {
337
- $repeatmins = str_replace( '*/', '', $cronstr[ 'minutes' ] );
338
- if ( $repeatmins == '*' || empty( $repeatmins ) )
339
- $repeatmins = 5;
340
- echo '<span style="color:red;">' . sprintf( __( 'ATTENTION: Job runs every %d minutes!', 'backwpup' ), $repeatmins ) . '</span><br />';
341
- }
342
- if ( FALSE !== strpos( $cronstr[ 'hours' ], '*/' ) || $cronstr[ 'hours' ] == '*' ) {
343
- $repeathouer = str_replace( '*/', '', $cronstr[ 'hours' ] );
344
- if ( $repeathouer == '*' || empty( $repeathouer ) )
345
- $repeathouer = 1;
346
- echo '<span style="color:red;">' . sprintf( __( 'ATTENTION: Job runs every %d hours!', 'backwpup' ), $repeathouer ) . '</span><br />';
347
- }
348
- $cron_next = BackWPup_Cron::cron_next( $cronstamp ) + ( get_option( 'gmt_offset' ) * 3600 );
349
- if ( 2147483647 == $cron_next ) {
350
- echo '<span style="color:red;">' . __( 'ATTENTION: Can\'t calculate cron!', 'backwpup' ) . '</span><br />';
351
- }
352
- else {
353
- _e( 'Next runtime:', 'backwpup' );
354
- echo ' <b>' . date_i18n( 'D, j M Y, H:i', $cron_next, TRUE ) . '</b>';
355
- }
356
- echo "</p>";
357
-
358
- if ( $ajax )
359
- die();
360
- else
361
- return;
362
- }
363
-
364
- /**
365
- *
366
- */
367
- public static function page() {
368
-
369
- if ( ! empty( $_GET[ 'jobid' ] ) ) {
370
- $jobid = (int)$_GET[ 'jobid' ];
371
- }
372
- else {
373
- //generate jobid if not exists
374
- $newjobid = BackWPup_Option::get_job_ids();
375
- sort( $newjobid );
376
- $jobid = end( $newjobid ) + 1;
377
- }
378
-
379
- $destinations = BackWPup::get_registered_destinations();
380
- $job_types = BackWPup::get_job_types();
381
-
382
- ?>
383
- <div class="wrap" id="backwpup-page">
384
- <?php
385
- //default tabs
386
- $tabs = array( 'job' => array( 'name' => __( 'General', 'backwpup' ), 'display' => TRUE ), 'cron' => array( 'name' => __( 'Schedule', 'backwpup' ), 'display' => TRUE ) );
387
- //add jobtypes to tabs
388
- $job_job_types = BackWPup_Option::get( $jobid, 'type' );
389
- foreach ( $job_types as $typeid => $typeclass ) {
390
- $tabid = 'jobtype-' . strtolower( $typeid );
391
- $tabs[ $tabid ][ 'name' ] = $typeclass->info[ 'name' ];
392
- $tabs[ $tabid ][ 'display' ] = TRUE;
393
- if ( ! in_array( $typeid, $job_job_types ) )
394
- $tabs[ $tabid ][ 'display' ] = FALSE;
395
-
396
- }
397
- //add destinations to tabs
398
- $jobdests = BackWPup_Option::get( $jobid, 'destinations' );
399
- foreach ( $destinations as $destid => $dest ) {
400
- $tabid = 'dest-' . strtolower( $destid );
401
- $tabs[ $tabid ][ 'name' ] = sprintf( __( 'To: %s', 'backwpup' ), $dest[ 'info' ][ 'name' ] );
402
- $tabs[ $tabid ][ 'display' ] = TRUE;
403
- if ( ! in_array( $destid, $jobdests ) )
404
- $tabs[ $tabid ][ 'display' ] = FALSE;
405
- }
406
- //display tabs
407
- echo '<h2 class="nav-tab-wrapper"><span id="backwpup-page-icon">&nbsp;</span>' . sprintf( __( '%s Job:', 'backwpup' ), BackWPup::get_plugin_data( 'name' ) ). '&nbsp;';
408
- echo '<span id="h2jobtitle">' . esc_html( BackWPup_Option::get( $jobid, 'name' ) ) . '</span><br /><br />';
409
- foreach ( $tabs as $id => $tab ) {
410
- $addclass = '';
411
- if ( $id == $_GET[ 'tab' ] )
412
- $addclass = ' nav-tab-active';
413
- $display = '';
414
- if ( ! $tab[ 'display' ] )
415
- $display = ' style="display:none;"';
416
- echo '<a href="' . wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupeditjob&tab=' . $id . '&jobid=' . $jobid, 'edit-job' ) . '" class="nav-tab' . $addclass . '" id="tab-' . $id . '" data-nexttab="' . $id . '" ' . $display . '>' . $tab[ 'name' ] . '</a>';
417
- }
418
- echo '</h2>';
419
- //display messages
420
- BackWPup_Admin::display_messages();
421
- echo '<form name="editjob" id="editjob" method="post" action="' . admin_url( 'admin-post.php?action=backwpup' ) . '">';
422
- echo '<input type="hidden" id="jobid" name="jobid" value="' . $jobid . '" />';
423
- echo '<input type="hidden" name="tab" value="' . $_GET[ 'tab' ] . '" />';
424
- echo '<input type="hidden" name="nexttab" value="' . $_GET[ 'tab' ] . '" />';
425
- echo '<input type="hidden" name="page" value="backwpupeditjob" />';
426
- echo '<input type="hidden" name="anchor" value="" />';
427
- wp_nonce_field( 'backwpupeditjob_page' );
428
- wp_nonce_field( 'backwpup_ajax_nonce', 'backwpupajaxnonce', FALSE );
429
-
430
- switch ( $_GET[ 'tab' ] ) {
431
- case 'job':
432
- echo '<div class="table" id="info-tab-job">';
433
- ?>
434
- <h3 class="title"><?php _e( 'Job Name', 'backwpup' ) ?></h3>
435
- <p></p>
436
- <table class="form-table">
437
- <tr>
438
- <th scope="row"><label for="name"><?php _e( 'Please name this job.', 'backwpup' ) ?></label></th>
439
- <td>
440
- <input name="name" type="text" id="name" data-empty="<?php _e( 'New Job', 'backwpup' ); ?>"
441
- value="<?php echo BackWPup_Option::get( $jobid, 'name' ); ?>" class="regular-text" />
442
- </td>
443
- </tr>
444
- </table>
445
-
446
- <h3 class="title"><?php _e( 'Job Tasks', 'backwpup' ) ?></h3>
447
- <p></p>
448
- <table class="form-table">
449
- <tr>
450
- <th scope="row"><?php _e( 'This job is a&#160;&hellip;', 'backwpup' ) ?></th>
451
- <td>
452
- <fieldset>
453
- <legend class="screen-reader-text"><span><?php _e( 'Job tasks', 'backwpup' ) ?></span>
454
- </legend><?php
455
- foreach ( $job_types as $id => $typeclass ) {
456
- $addclass = '';
457
- if ( $typeclass->creates_file() )
458
- $addclass .= ' filetype';
459
- $title = '';
460
- if ( ! empty( $typeclass->info[ 'help' ] ) ) {
461
- $title = ' title="' . esc_attr( $typeclass->info[ 'help' ] ) . '"';
462
- $addclass .= ' help-tip';
463
- }
464
- echo '<label for="jobtype-select-' . strtolower( $id ) . '"><input class="jobtype-select checkbox' . $addclass . '"' . $title . ' id="jobtype-select-' . strtolower( $id ) . '" type="checkbox" ' . checked( TRUE, in_array( $id, BackWPup_Option::get( $jobid, 'type' ) ), FALSE ) . ' name="type[]" value="' . $id . '" /> ' . $typeclass->info[ 'description' ] . '</label><br />';
465
- }
466
- ?></fieldset>
467
- </td>
468
- </tr>
469
- </table>
470
-
471
- <h3 class="title hasdests"><?php _e( 'Backup File Creation', 'backwpup' ) ?></h3>
472
- <p class="hasdests"></p>
473
- <table class="form-table hasdests">
474
- <?php if ( class_exists( 'BackWPup_Pro', FALSE ) ) { ?>
475
- <tr>
476
- <th scope="row"><?php _e( 'Backup type', 'backwpup' ); ?></th>
477
- <td>
478
- <fieldset>
479
- <legend class="screen-reader-text"> <span><?php _e( 'Backup type', 'backwpup' ) ?></span></legend>
480
- <label for="idbackuptype-sync"><input class="radio"
481
- type="radio"<?php checked( 'sync', BackWPup_Option::get( $jobid, 'backuptype' ), TRUE ); ?>
482
- name="backuptype" id="idbackuptype-sync"
483
- value="sync"/> <?php _e( 'Synchronize file by file to destination', 'backwpup' ); ?></label><br/>
484
- <label for="idbackuptype-archive"><input class="radio"
485
- type="radio"<?php checked( 'archive', BackWPup_Option::get( $jobid, 'backuptype' ), TRUE ); ?>
486
- name="backuptype" id="idbackuptype-archive"
487
- value="archive"/> <?php _e( 'Create a backup archive', 'backwpup' ); ?></label><br/>
488
- </fieldset>
489
- </td>
490
- </tr>
491
- <?php } ?>
492
- <tr class="nosync">
493
- <th scope="row"><label for="archivename"><?php _e( 'Archive name', 'backwpup' ) ?></label></th>
494
- <td>
495
- <input name="archivename" type="text" id="archivename"
496
- value="<?php echo BackWPup_Option::get( $jobid, 'archivename' );?>"
497
- class="regular-text code help-tip" title="<?php
498
- echo "<strong>" . esc_attr__( 'Replacement patterns:', 'backwpup' ) . "</strong><br />";
499
- echo esc_attr__( '%d = Two digit day of the month, with leading zeros', 'backwpup' ) . '<br />';
500
- echo esc_attr__( '%j = Day of the month, without leading zeros', 'backwpup' ) . '<br />';
501
- echo esc_attr__( '%m = Day of the month, with leading zeros', 'backwpup' ) . '<br />';
502
- echo esc_attr__( '%n = Representation of the month (without leading zeros)', 'backwpup' ) . '<br />';
503
- echo esc_attr__( '%Y = Four digit representation for the year', 'backwpup' ) . '<br />';
504
- echo esc_attr__( '%y = Two digit representation of the year', 'backwpup' ) . '<br />';
505
- echo esc_attr__( '%a = Lowercase ante meridiem (am) and post meridiem (pm)', 'backwpup' ) . '<br />';
506
- echo esc_attr__( '%A = Uppercase ante meridiem (AM) and post meridiem (PM)', 'backwpup' ) . '<br />';
507
- echo esc_attr__( '%B = Swatch Internet Time', 'backwpup' ) . '<br />';
508
- echo esc_attr__( '%g = Hour in 12-hour format, without leading zeros', 'backwpup' ) . '<br />';
509
- echo esc_attr__( '%G = Hour in 24-hour format, without leading zeros', 'backwpup' ) . '<br />';
510
- echo esc_attr__( '%h = Hour in 12-hour format, with leading zeros', 'backwpup' ) . '<br />';
511
- echo esc_attr__( '%H = Hour in 24-hour format, with leading zeros', 'backwpup' ) . '<br />';
512
- echo esc_attr__( '%i = Two digit representation of the minute', 'backwpup' ) . '<br />';
513
- echo esc_attr__( '%s = Two digit representation of the second', 'backwpup' ) . '<br />';
514
- ?>" />
515
- <?php
516
- $datevars = array( '%d', '%j', '%m', '%n', '%Y', '%y', '%a', '%A', '%B', '%g', '%G', '%h', '%H', '%i', '%s' );
517
- $datevalues = array( date_i18n( 'd' ), date_i18n( 'j' ), date_i18n( 'm' ), date_i18n( 'n' ), date_i18n( 'Y' ), date_i18n( 'y' ), date_i18n( 'a' ), date_i18n( 'A' ), date_i18n( 'B' ), date_i18n( 'g' ), date_i18n( 'G' ), date_i18n( 'h' ), date_i18n( 'H' ), date_i18n( 'i' ), date_i18n( 's' ) );
518
- $archivename = str_replace( $datevars, $datevalues, BackWPup_Option::get( $jobid, 'archivename' ) );
519
- $archivename = sanitize_file_name( $archivename );
520
- echo '<p>Preview: <code><span id="archivefilename">' . $archivename . '</span><span id="archiveformat">' . BackWPup_Option::get( $jobid, 'archiveformat' ) . '</span></code></p>';
521
- ?>
522
- </td>
523
- </tr>
524
- <tr class="nosync">
525
- <th scope="row"><?php _e( 'Archive Format', 'backwpup' ); ?></th>
526
- <td>
527
- <fieldset>
528
- <legend class="screen-reader-text"><span><?php _e( 'Archive Format', 'backwpup' ) ?></span></legend>
529
- <?php
530
- if ( function_exists( 'gzopen' ) || class_exists( 'ZipArchive' ) )
531
- echo '<label for="idarchiveformat-zip"><input class="radio help-tip" title="'. __( 'PHP Zip functions will be used if available (needs less memory). Otherwise the PCLZip class will be used.', 'backwpup' ) .'" type="radio"' . checked( '.zip', BackWPup_Option::get( $jobid, 'archiveformat' ), FALSE ) . ' name="archiveformat" id="idarchiveformat-zip" value=".zip" /> ' . __( 'Zip', 'backwpup' ) . '</label><br />';
532
- else
533
- echo '<label for="idarchiveformat-zip"><input class="radio help-tip" title="' . __( 'Disabled due to missing PHP function.', 'backwpup' ) . '" type="radio"' . checked( '.zip', BackWPup_Option::get( $jobid, 'archiveformat' ), FALSE ) . ' name="archiveformat" id="idarchiveformat-zip" value=".zip" disabled="disabled" /> ' . __( 'Zip', 'backwpup' ) . '</label><br />';
534
- echo '<label for="idarchiveformat-tar"><input class="radio help-tip" title="' . __( 'A tarballed, not compressed archive (fast and less memory)', 'backwpup' ) . '" type="radio"' . checked( '.tar', BackWPup_Option::get( $jobid, 'archiveformat' ), FALSE ) . ' name="archiveformat" id="idarchiveformat-tar" value=".tar" /> ' . __( 'Tar', 'backwpup' ) . '</label><br />';
535
- if ( function_exists( 'gzopen' ) )
536
- echo '<label for="idarchiveformat-targz"><input class="radio help-tip" title="' . __( 'A tarballed, GZipped archive (fast and less memory)', 'backwpup' ) . '" type="radio"' . checked( '.tar.gz', BackWPup_Option::get( $jobid, 'archiveformat' ), FALSE ) . ' name="archiveformat" id="idarchiveformat-targz" value=".tar.gz" /> ' . __( 'Tar GZip', 'backwpup' ) . '</label><br />';
537
- else
538
- echo '<label for="idarchiveformat-targz"><input class="radio help-tip" title="' . __( 'Disabled due to missing PHP function.', 'backwpup' ) . '" type="radio"' . checked( '.tar.gz', BackWPup_Option::get( $jobid, 'archiveformat' ), FALSE ) . ' name="archiveformat" id="idarchiveformat-targz" value=".tar.gz" disabled="disabled" /> ' . __( 'Tar GZip', 'backwpup' ) . '</label><br />';
539
- if ( function_exists( 'bzopen' ) )
540
- echo '<label for="idarchiveformat-tarbz2"><input class="radio help-tip" title="' . __( 'A tarballed, BZipped archive (fast and less memory)', 'backwpup' ) . '" type="radio"' . checked( '.tar.bz2', BackWPup_Option::get( $jobid, 'archiveformat' ), FALSE ) . ' name="archiveformat" id="idarchiveformat-tarbz2" value=".tar.bz2" /> ' . __( 'Tar BZip2', 'backwpup' ) . '</label><br />';
541
- else
542
- echo '<label for="idarchiveformat-tarbz2"><input class="radio help-tip" title="' . __( 'Disabled due to missing PHP function.', 'backwpup' ) . '" type="radio"' . checked( '.tar.bz2', BackWPup_Option::get( $jobid, 'archiveformat' ), FALSE ) . ' name="archiveformat" id="idarchiveformat-tarbz2" value=".tar.bz2" disabled="disabled" /> ' . __( 'Tar BZip2', 'backwpup' ) . '</label><br />';
543
- ?></fieldset>
544
- </td>
545
- </tr>
546
- </table>
547
-
548
- <h3 class="title hasdests"><?php _e( 'Job Destination', 'backwpup' ) ?></h3>
549
- <p class="hasdests"></p>
550
- <table class="form-table hasdests">
551
- <tr>
552
- <th scope="row"><?php _e( 'Where should your backup file be stored?', 'backwpup' ) ?></th>
553
- <td>
554
- <fieldset>
555
- <legend class="screen-reader-text"><span><?php _e( 'Where should your backup file be stored?', 'backwpup' ) ?></span>
556
- </legend><?php
557
- foreach ( $destinations as $id => $dest ) {
558
- $syncclass = '';
559
- if ( ! $dest[ 'can_sync' ] )
560
- $syncclass = 'nosync';
561
- $title = ''; $helpclass = '';
562
- if ( ! empty( $dest[ 'info' ][ 'help' ] ) ) {
563
- $title = ' title="'. esc_attr( $dest[ 'info' ][ 'help' ] ) . '"';
564
- $helpclass = ' help-tip';
565
- }
566
- echo '<span class="' . $syncclass . '"><label for="dest-select-' . strtolower( $id ) . '"><input class="checkbox' . $helpclass . '"' . $title . ' id="dest-select-' . strtolower( $id ) . '" type="checkbox" ' . checked( TRUE, in_array( $id, BackWPup_Option::get( $jobid, 'destinations' ) ), FALSE ) . ' name="destinations[]" value="' . $id . '" ' . disabled( ! empty( $dest[ 'error' ] ), TRUE, FALSE ) . ' /> ' . $dest[ 'info' ][ 'description' ];
567
- if ( ! empty( $dest[ 'error' ] ) )
568
- echo '<br /><span class="description">' . $dest[ 'error' ] . '</span>';
569
- echo '</label><br /></span>';
570
- }
571
- ?></fieldset>
572
- </td>
573
- </tr>
574
- </table>
575
-
576
- <h3 class="title"><?php _e( 'Log Files', 'backwpup' ) ?></h3>
577
- <p></p>
578
- <table class="form-table">
579
- <tr>
580
- <th scope="row"><label for="mailaddresslog"><?php _e( 'Send log to email address', 'backwpup' ) ?></label></th>
581
- <td>
582
- <input name="mailaddresslog" type="text" id="mailaddresslog"
583
- value="<?php echo BackWPup_Option::get( $jobid, 'mailaddresslog' );?>"
584
- class="regular-text help-tip" title="<?php esc_attr_e( 'Leave empty to not have log sent.', 'backwpup' ); ?>" />
585
- </td>
586
- </tr>
587
- <tr>
588
- <th scope="row"><label for="mailaddresssenderlog"><?php _e( 'Email FROM field', 'backwpup' ) ?></label></th>
589
- <td>
590
- <input name="mailaddresssenderlog" type="text" id="mailaddresssenderlog"
591
- value="<?php echo BackWPup_Option::get( $jobid, 'mailaddresssenderlog' );?>"
592
- class="regular-text help-tip" title="<?php esc_attr_e( 'Email "From" field (Name &lt;&#160;you@your-email-address.tld&#160;&gt;)', 'backwpup' ); ?>" />
593
- </td>
594
- </tr>
595
- <tr>
596
- <th scope="row"><?php _e( 'Errors only', 'backwpup' ); ?></th>
597
- <td>
598
- <label for="idmailerroronly">
599
- <input class="checkbox" value="1" id="idmailerroronly"
600
- type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'mailerroronly' ), TRUE ); ?>
601
- name="mailerroronly" /> <?php _e( 'Send email with log only when errors occur during job execution.', 'backwpup' ); ?>
602
- </label>
603
- </td>
604
- </tr>
605
- </table>
606
- <?php
607
- echo '</div>';
608
- break;
609
- case 'cron':
610
- echo '<div class="table" id="info-tab-cron">';
611
- ?>
612
- <h3 class="title"><?php _e( 'Job Schedule', 'backwpup' ) ?></h3>
613
- <p></p>
614
- <table class="form-table">
615
- <tr>
616
- <th scope="row"><?php _e( 'Start job', 'backwpup' ); ?></th>
617
- <td>
618
- <fieldset>
619
- <legend class="screen-reader-text"><span><?php _e( 'Start job', 'backwpup' ) ?></span></legend>
620
- <label for="idactivetype"><input class="radio"
621
- type="radio"<?php checked( '', BackWPup_Option::get( $jobid, 'activetype' ), TRUE ); ?>
622
- name="activetype" id="idactivetype"
623
- value="" /> <?php _e( 'manually only', 'backwpup' ); ?></label><br/>
624
- <label for="idactivetype-wpcron"><input class="radio"
625
- type="radio"<?php checked( 'wpcron', BackWPup_Option::get( $jobid, 'activetype' ), TRUE ); ?>
626
- name="activetype" id="idactivetype-wpcron"
627
- value="wpcron" /> <?php _e( 'with WordPress cron', 'backwpup' ); ?></label><br/>
628
- <?php
629
- $url = BackWPup_Job::get_jobrun_url( 'runext', BackWPup_Option::get( $jobid, 'jobid' ) );
630
- ?>
631
- <label for="idactivetype-link"><input class="radio help-tip"
632
- type="radio"<?php checked( 'link', BackWPup_Option::get( $jobid, 'activetype' ), TRUE ); ?>
633
- name="activetype" id="idactivetype-link"
634
- value="link" title="<?php esc_attr_e( 'Copy the link for an external start. This option has to be activated to make the link work.', 'backwpup' )?>" /> <?php _e( 'with a link', 'backwpup' ); ?> <code><a href="<?php echo $url[ 'url' ];?>" target="_blank"><?php echo $url[ 'url' ];?></a></code></label>
635
- <br />
636
- </fieldset>
637
- </td>
638
- </tr>
639
- <tr>
640
- <th scope="row"><?php _e( 'Start job with CLI', 'backwpup' ); ?></th>
641
- <td class="help-tip" title="<?php esc_attr_e( 'Generate a server script file to let the job start with the server’s cron on command line interface. Alternatively use WP-CLI commands.', 'backwpup' ); ?>">
642
- <?php
643
- echo str_replace( '\"','"', sprintf ( __( 'Use <a href="http://wp-cli.org/">WP-CLI</a> to run jobs from commandline or <a href="%s">get the start script</a>.', 'backwpup' ), wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupjobs&action=start_cli&jobid=' . $jobid, 'start_cli' ) ) );
644
- ?>
645
- </td>
646
- </tr>
647
- </table>
648
- <h3 class="title wpcron"><?php _e( 'Schedule execution time', 'backwpup' ) ?></h3>
649
- <?php BackWPup_Page_Editjob::ajax_cron_text( array( 'cronstamp' => BackWPup_Option::get( $jobid, 'cron' ), 'crontype' => BackWPup_Option::get( $jobid, 'cronselect' ) ) ); ?>
650
- <table class="form-table wpcron">
651
- <tr>
652
- <th scope="row"><?php _e( 'Scheduler type', 'backwpup' ); ?></th>
653
- <td>
654
- <fieldset>
655
- <legend class="screen-reader-text"><span><?php _e( 'Scheduler type', 'backwpup' ) ?></span></legend>
656
- <label for="idcronselect-basic"><input class="radio"
657
- type="radio"<?php checked( 'basic', BackWPup_Option::get( $jobid, 'cronselect' ), TRUE ); ?>
658
- name="cronselect" id="idcronselect-basic"
659
- value="basic" /> <?php _e( 'basic', 'backwpup' ); ?></label><br/>
660
- <label for="idcronselect-advanced"><input class="radio"
661
- type="radio"<?php checked( 'advanced', BackWPup_Option::get( $jobid, 'cronselect' ), TRUE ); ?>
662
- name="cronselect" id="idcronselect-advanced"
663
- value="advanced" /> <?php _e( 'advanced', 'backwpup' ); ?></label><br/>
664
- </fieldset>
665
- </td>
666
- </tr>
667
- <?php
668
-
669
- list( $cronstr[ 'minutes' ], $cronstr[ 'hours' ], $cronstr[ 'mday' ], $cronstr[ 'mon' ], $cronstr[ 'wday' ] ) = explode( ' ', BackWPup_Option::get( $jobid, 'cron' ), 5 );
670
- if ( strstr( $cronstr[ 'minutes' ], '*/' ) )
671
- $minutes = explode( '/', $cronstr[ 'minutes' ] );
672
- else
673
- $minutes = explode( ',', $cronstr[ 'minutes' ] );
674
- if ( strstr( $cronstr[ 'hours' ], '*/' ) )
675
- $hours = explode( '/', $cronstr[ 'hours' ] );
676
- else
677
- $hours = explode( ',', $cronstr[ 'hours' ] );
678
- if ( strstr( $cronstr[ 'mday' ], '*/' ) )
679
- $mday = explode( '/', $cronstr[ 'mday' ] );
680
- else
681
- $mday = explode( ',', $cronstr[ 'mday' ] );
682
- if ( strstr( $cronstr[ 'mon' ], '*/' ) )
683
- $mon = explode( '/', $cronstr[ 'mon' ] );
684
- else
685
- $mon = explode( ',', $cronstr[ 'mon' ] );
686
- if ( strstr( $cronstr[ 'wday' ], '*/' ) )
687
- $wday = explode( '/', $cronstr[ 'wday' ] );
688
- else
689
- $wday = explode( ',', $cronstr[ 'wday' ] );
690
- ?>
691
- <tr class="wpcronbasic"<?php if ( BackWPup_Option::get( $jobid, 'cronselect' ) != 'basic' ) echo ' style="display:none;"';?>>
692
- <th scope="row"><?php _e( 'Scheduler', 'backwpup' ); ?></th>
693
- <td>
694
- <table id="wpcronbasic">
695
- <tr>
696
- <th>
697
- <?php _e( 'Type', 'backwpup' ); ?>
698
- </th>
699
- <th>
700
- </th>
701
- <th>
702
- <?php _e( 'Hour', 'backwpup' ); ?>
703
- </th>
704
- <th>
705
- <?php _e( 'Minute', 'backwpup' ); ?>
706
- </th>
707
- </tr>
708
- <tr>
709
- <td><label for="idcronbtype-mon"><?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $mday[ 0 ] ), FALSE ) . ' name="cronbtype" id="idcronbtype-mon" value="mon" /> ' . __( 'monthly', 'backwpup' ); ?></label></td>
710
- <td><select name="moncronmday"><?php for ( $i = 1; $i <= 31; $i ++ ) {
711
- echo '<option ' . selected( in_array( "$i", $mday, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . __( 'on', 'backwpup' ) . ' ' . $i . '.</option>';
712
- } ?></select></td>
713
- <td><select name="moncronhours"><?php for ( $i = 0; $i < 24; $i ++ ) {
714
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
715
- } ?></select></td>
716
- <td><select name="moncronminutes"><?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
717
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
718
- } ?></select></td>
719
- </tr>
720
- <tr>
721
- <td><label for="idcronbtype-week"><?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $wday[ 0 ] ), FALSE ) . ' name="cronbtype" id="idcronbtype-week" value="week" /> ' . __( 'weekly', 'backwpup' ); ?></label></td>
722
- <td><select name="weekcronwday">
723
- <?php echo '<option ' . selected( in_array( "0", $wday, TRUE ), TRUE, FALSE ) . ' value="0" />' . __( 'Sunday', 'backwpup' ) . '</option>';
724
- echo '<option ' . selected( in_array( "1", $wday, TRUE ), TRUE, FALSE ) . ' value="1" />' . __( 'Monday', 'backwpup' ) . '</option>';
725
- echo '<option ' . selected( in_array( "2", $wday, TRUE ), TRUE, FALSE ) . ' value="2" />' . __( 'Tuesday', 'backwpup' ) . '</option>';
726
- echo '<option ' . selected( in_array( "3", $wday, TRUE ), TRUE, FALSE ) . ' value="3" />' . __( 'Wednesday', 'backwpup' ) . '</option>';
727
- echo '<option ' . selected( in_array( "4", $wday, TRUE ), TRUE, FALSE ) . ' value="4" />' . __( 'Thursday', 'backwpup' ) . '</option>';
728
- echo '<option ' . selected( in_array( "5", $wday, TRUE ), TRUE, FALSE ) . ' value="5" />' . __( 'Friday', 'backwpup' ) . '</option>';
729
- echo '<option ' . selected( in_array( "6", $wday, TRUE ), TRUE, FALSE ) . ' value="6" />' . __( 'Saturday', 'backwpup' ) . '</option>'; ?>
730
- </select></td>
731
- <td><select name="weekcronhours"><?php for ( $i = 0; $i < 24; $i ++ ) {
732
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
733
- } ?></select></td>
734
- <td><select name="weekcronminutes"><?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
735
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
736
- } ?></select></td>
737
- </tr>
738
- <tr>
739
- <td><label for="idcronbtype-day"><?php echo '<input class="radio" type="radio"' . checked( "**", $mday[ 0 ] . $wday[ 0 ], FALSE ) . ' name="cronbtype" id="idcronbtype-day" value="day" /> ' . __( 'daily', 'backwpup' ); ?></label></td>
740
- <td></td>
741
- <td><select name="daycronhours"><?php for ( $i = 0; $i < 24; $i ++ ) {
742
- echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
743
- } ?></select></td>
744
- <td><select name="daycronminutes"><?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
745
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
746
- } ?></select></td>
747
- </tr>
748
- <tr>
749
- <td><label for="idcronbtype-hour"><?php echo '<input class="radio" type="radio"' . checked( "*", $hours[ 0 ], FALSE, FALSE ) . ' name="cronbtype" id="idcronbtype-hour" value="hour" /> ' . __( 'hourly', 'backwpup' ); ?></label></td>
750
- <td></td>
751
- <td></td>
752
- <td><select name="hourcronminutes"><?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
753
- echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
754
- } ?></select></td>
755
- </tr>
756
- </table>
757
- </td>
758
- </tr>
759
- <tr class="wpcronadvanced"<?php if ( BackWPup_Option::get( $jobid, 'cronselect' ) != 'advanced' ) echo ' style="display:none;"';?>>
760
- <th scope="row"><?php _e( 'Scheduler', 'backwpup' ); ?></th>
761
- <td>
762
- <div id="cron-min-box">
763
- <b><?php _e( 'Minutes:', 'backwpup' ); ?></b><br/>
764
- <?php
765
- echo '<label for="idcronminutes"><input class="checkbox" type="checkbox"' . checked( in_array( "*", $minutes, TRUE ), TRUE, FALSE ) . ' name="cronminutes[]" id="idcronminutes" value="*" /> ' . __( 'Any (*)', 'backwpup' ) . '</label><br />';
766
- ?>
767
- <div id="cron-min"><?php
768
- for ( $i = 0; $i < 60; $i = $i + 5 ) {
769
- echo '<label for="idcronminutes-' . $i . '"><input class="checkbox" type="checkbox"' . checked( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' name="cronminutes[]" id="idcronminutes-' . $i . '" value="' . $i . '" /> ' . $i . '</label><br />';
770
- }
771
- ?>
772
- </div>
773
- </div>
774
- <div id="cron-hour-box">
775
- <b><?php _e( 'Hours:', 'backwpup' ); ?></b><br/>
776
- <?php
777
-
778
- echo '<label for="idcronhours"><input class="checkbox" type="checkbox"' . checked( in_array( "*", $hours, TRUE ), TRUE, FALSE ) . ' name="cronhours[]" for="idcronhours" value="*" /> ' . __( 'Any (*)', 'backwpup' ) . '</label><br />';
779
- ?>
780
- <div id="cron-hour"><?php
781
- for ( $i = 0; $i < 24; $i ++ ) {
782
- echo '<label for="idcronhours-' . $i . '"><input class="checkbox" type="checkbox"' . checked( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' name="cronhours[]" id="idcronhours-' . $i . '" value="' . $i . '" /> ' . $i . '</label><br />';
783
- }
784
- ?>
785
- </div>
786
- </div>
787
- <div id="cron-day-box">
788
- <b><?php _e( 'Day of Month:', 'backwpup' ); ?></b><br/>
789
- <label for="idcronmday"><input class="checkbox" type="checkbox"<?php checked( in_array( "*", $mday, TRUE ), TRUE, TRUE ); ?>
790
- name="cronmday[]" id="idcronmday" value="*"/> <?php _e( 'Any (*)', 'backwpup' ); ?></label>
791
- <br/>
792
-
793
- <div id="cron-day">
794
- <?php
795
- for ( $i = 1; $i <= 31; $i ++ ) {
796
- echo '<label for="idcronmday-' . $i . '"><input class="checkbox" type="checkbox"' . checked( in_array( "$i", $mday, TRUE ), TRUE, FALSE ) . ' name="cronmday[]" id="idcronmday-' . $i . '" value="' . $i . '" /> ' . $i . '</label><br />';
797
- }
798
- ?>
799
- </div>
800
- </div>
801
- <div id="cron-month-box">
802
- <b><?php _e( 'Month:', 'backwpup' ); ?></b><br/>
803
- <?php
804
- echo '<label for="idcronmon"><input class="checkbox" type="checkbox"' . checked( in_array( "*", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon" value="*" /> ' . __( 'Any (*)', 'backwpup' ) . '</label><br />';
805
- ?>
806
- <div id="cron-month">
807
- <?php
808
- echo '<label for="idcronmon-1"><input class="checkbox" type="checkbox"' . checked( in_array( "1", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-1" value="1" /> ' . __( 'January', 'backwpup' ) . '</label><br />';
809
- echo '<label for="idcronmon-2"><input class="checkbox" type="checkbox"' . checked( in_array( "2", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-2" value="2" /> ' . __( 'February', 'backwpup' ) . '</label><br />';
810
- echo '<label for="idcronmon-3"><input class="checkbox" type="checkbox"' . checked( in_array( "3", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-3" value="3" /> ' . __( 'March', 'backwpup' ) . '</label><br />';
811
- echo '<label for="idcronmon-4"><input class="checkbox" type="checkbox"' . checked( in_array( "4", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-4" value="4" /> ' . __( 'April', 'backwpup' ) . '</label><br />';
812
- echo '<label for="idcronmon-5"><input class="checkbox" type="checkbox"' . checked( in_array( "5", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-5" value="5" /> ' . __( 'May', 'backwpup' ) . '</label><br />';
813
- echo '<label for="idcronmon-6"><input class="checkbox" type="checkbox"' . checked( in_array( "6", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-6" value="6" /> ' . __( 'June', 'backwpup' ) . '</label><br />';
814
- echo '<label for="idcronmon-7"><input class="checkbox" type="checkbox"' . checked( in_array( "7", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-7" value="7" /> ' . __( 'July', 'backwpup' ) . '</label><br />';
815
- echo '<label for="idcronmon-8"><input class="checkbox" type="checkbox"' . checked( in_array( "8", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-8" value="8" /> ' . __( 'August', 'backwpup' ) . '</label><br />';
816
- echo '<label for="idcronmon-9"><input class="checkbox" type="checkbox"' . checked( in_array( "9", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-9" value="9" /> ' . __( 'September', 'backwpup' ) . '</label><br />';
817
- echo '<label for="idcronmon-10"><input class="checkbox" type="checkbox"' . checked( in_array( "10", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-10" value="10" /> ' . __( 'October', 'backwpup' ) . '</label><br />';
818
- echo '<label for="idcronmon-11"><input class="checkbox" type="checkbox"' . checked( in_array( "11", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-11" value="11" /> ' . __( 'November', 'backwpup' ) . '</label><br />';
819
- echo '<label for="idcronmon-12"><input class="checkbox" type="checkbox"' . checked( in_array( "12", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-12" value="12" /> ' . __( 'December', 'backwpup' ) . '</label><br />';
820
- ?>
821
- </div>
822
- </div>
823
- <div id="cron-weekday-box">
824
- <b><?php _e( 'Day of Week:', 'backwpup' ); ?></b><br/>
825
- <?php
826
- echo '<label for="idcronwday"><input class="checkbox" type="checkbox"' . checked( in_array( "*", $wday, TRUE ), TRUE, FALSE ) . ' name="cronwday[]" id="idcronwday" value="*" /> ' . __( 'Any (*)', 'backwpup' ) . '</label><br />';
827
- ?>
828
- <div id="cron-weekday">
829
- <?php
830
- echo '<label for="idcronwday-0"><input class="checkbox" type="checkbox"' . checked( in_array( "0", $wday, TRUE ), TRUE, FALSE ) . ' name="cronwday[]" id="idcronwday-0" value="0" /> ' . __( 'Sunday', 'backwpup' ) . '</label><br />';
831
- echo '<label for="idcronwday-1"><input class="checkbox" type="checkbox"' . checked( in_array( "1", $wday, TRUE ), TRUE, FALSE ) . ' name="cronwday[]" id="idcronwday-1" value="1" /> ' . __( 'Monday', 'backwpup' ) . '</label><br />';
832
- echo '<label for="idcronwday-2"><input class="checkbox" type="checkbox"' . checked( in_array( "2", $wday, TRUE ), TRUE, FALSE ) . ' name="cronwday[]" id="idcronwday-2" value="2" /> ' . __( 'Tuesday', 'backwpup' ) . '</label><br />';
833
- echo '<label for="idcronwday-3"><input class="checkbox" type="checkbox"' . checked( in_array( "3", $wday, TRUE ), TRUE, FALSE ) . ' name="cronwday[]" id="idcronwday-3" value="3" /> ' . __( 'Wednesday', 'backwpup' ) . '</label><br />';
834
- echo '<label for="idcronwday-4"><input class="checkbox" type="checkbox"' . checked( in_array( "4", $wday, TRUE ), TRUE, FALSE ) . ' name="cronwday[]" id="idcronwday-4" value="4" /> ' . __( 'Thursday', 'backwpup' ) . '</label><br />';
835
- echo '<label for="idcronwday-5"><input class="checkbox" type="checkbox"' . checked( in_array( "5", $wday, TRUE ), TRUE, FALSE ) . ' name="cronwday[]" id="idcronwday-5" value="5" /> ' . __( 'Friday', 'backwpup' ) . '</label><br />';
836
- echo '<label for="idcronwday-6"><input class="checkbox" type="checkbox"' . checked( in_array( "6", $wday, TRUE ), TRUE, FALSE ) . ' name="cronwday[]" id="idcronwday-6" value="6" /> ' . __( 'Saturday', 'backwpup' ) . '</label><br />';
837
- ?>
838
- </div>
839
- </div>
840
- <br class="clear"/>
841
- </td>
842
- </tr>
843
- </table>
844
- <?php
845
- echo '</div>';
846
- break;
847
- default:
848
- echo '<div class="table" id="info-tab-' . $_GET[ 'tab' ] . '">';
849
- if ( strstr( $_GET[ 'tab' ], 'dest-' ) ) {
850
- $dest_object = BackWPup::get_destination( str_replace( 'dest-', '', $_GET[ 'tab' ] ) );
851
- $dest_object->edit_tab( $jobid );
852
- }
853
- if ( strstr( $_GET[ 'tab' ], 'jobtype-' ) ) {
854
- $id = strtoupper( str_replace( 'jobtype-', '', $_GET[ 'tab' ] ) );
855
- $job_types[ $id ]->edit_tab( $jobid );
856
- }
857
- echo '</div>';
858
- }
859
- echo '<br />';
860
- submit_button( __( 'Save changes', 'backwpup' ), 'primary', 'save', FALSE, array( 'tabindex' => '2', 'accesskey' => 'p' ) );
861
- echo '</form>';
862
- ?>
863
- </div>
864
-
865
- <script type="text/javascript">
866
- //<![CDATA[
867
- jQuery(document).ready(function ($) {
868
- // auto post if things changed
869
- var changed = false;
870
- $( '#editjob' ).change( function () {
871
- changed = true;
872
- });
873
- $( '.nav-tab' ).click( function () {
874
- if ( changed ) {
875
- $( 'input[name="nexttab"]' ).val( $(this).data( "nexttab" ) );
876
- $( '#editjob' ).submit();
877
- return false;
878
- }
879
- });
880
- <?php
881
- //add inline js
882
- if ( strstr( $_GET[ 'tab' ], 'dest-' ) ) {
883
- $dest_object = BackWPup::get_destination( str_replace( 'dest-', '', $_GET[ 'tab' ] ) );
884
- $dest_object->edit_inline_js();
885
- }
886
- if ( strstr( $_GET[ 'tab' ], 'jobtype-' ) ) {
887
- $id = strtoupper( str_replace( 'jobtype-', '', $_GET[ 'tab' ] ) );
888
- $job_types[ $id ]->edit_inline_js();
889
- }
890
- ?>
891
- });
892
- //]]>
893
- </script>
894
- <?php
895
- }
896
- }
897
-
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+ class BackWPup_Page_Editjob {
6
+
7
+ /**
8
+ *
9
+ */
10
+ public static function auth() {
11
+
12
+ //check $_GET[ 'tab' ]
13
+ if ( isset($_GET[ 'tab' ] ) ) {
14
+ $_GET[ 'tab' ] = sanitize_title_with_dashes( $_GET[ 'tab' ] );
15
+ if ( substr( $_GET[ 'tab' ], 0, 5 ) != 'dest-' && substr( $_GET[ 'tab' ], 0, 8 ) != 'jobtype-' && ! in_array( $_GET[ 'tab' ], array( 'job','cron' ) ) )
16
+ $_GET[ 'tab' ] = 'job';
17
+ } else {
18
+ $_GET[ 'tab' ] = 'job';
19
+ }
20
+
21
+ if ( substr( $_GET[ 'tab' ], 0, 5 ) == 'dest-' ) {
22
+ $jobid = (int)$_GET[ 'jobid' ];
23
+ $id = strtoupper( str_replace( 'dest-', '', $_GET[ 'tab' ] ) );
24
+ $dest_class = BackWPup::get_destination( $id );
25
+ $dest_class->edit_auth( $jobid );
26
+ }
27
+ }
28
+
29
+ /**
30
+ *
31
+ */
32
+ public static function load() {
33
+
34
+ //add Help tab
35
+ BackWPup_Help::add_tab( array(
36
+ 'id' => 'overview',
37
+ 'title' => __( 'Overview','backwpup' ),
38
+ 'content' =>
39
+ '<p>' . '</p>'
40
+ ) );
41
+
42
+ }
43
+
44
+ /**
45
+ * Save Form data
46
+ */
47
+ public static function save_post_form($tab, $jobid) {
48
+
49
+ if ( ! current_user_can( 'backwpup_jobs_edit' ) )
50
+ return __( 'Sorry, you don\'t have permissions to do that.', 'backwpup');
51
+
52
+ $destinations = BackWPup::get_registered_destinations();
53
+ $job_types = BackWPup::get_job_types();
54
+
55
+ switch ( $tab ) {
56
+ case 'job':
57
+ BackWPup_Option::update( $jobid, 'jobid', $jobid );
58
+
59
+ if ( isset( $_POST[ 'type' ] ) && is_array( $_POST[ 'type' ] ) ) {
60
+ foreach ( (array)$_POST[ 'type' ] as $typeid ) {
61
+ if ( empty( $job_types[ $typeid ] ) )
62
+ unset( $_POST[ 'type' ][ $typeid ] );
63
+ }
64
+ if ( is_array( $_POST[ 'type' ] ) )
65
+ sort( $_POST[ 'type' ] );
66
+ } else {
67
+ $_POST[ 'type' ]= array();
68
+ }
69
+ //test if job type makes backup
70
+ /* @var BackWPup_JobTypes $job_type */
71
+ $makes_file = FALSE;
72
+ foreach ( $job_types as $type_id => $job_type) {
73
+ if ( in_array( $type_id, $_POST[ 'type' ] ) ) {
74
+ if ( $job_type->creates_file() ) {
75
+ $makes_file = TRUE;
76
+ break;
77
+ }
78
+ }
79
+ }
80
+ if ( ! $makes_file )
81
+ $_POST[ 'destinations' ] = array();
82
+ BackWPup_Option::update( $jobid, 'type', $_POST[ 'type' ] );
83
+
84
+ if ( isset( $_POST[ 'destinations' ] ) && is_array( $_POST[ 'destinations' ] ) ) {
85
+ foreach ( (array)$_POST[ 'destinations' ] as $key => $destid ) {
86
+ if ( empty( $destinations[ $destid ] ) ) //remove all destinations that not exists
87
+ unset( $_POST[ 'destinations' ][ $key ] );
88
+ if ( class_exists( 'BackWPup_Pro', FALSE ) && $_POST[ 'backuptype' ] == 'sync' ) { //if sync remove all not sync destinations
89
+ if ( ! $destinations[ $destid ][ 'can_sync' ] )
90
+ unset( $_POST[ 'destinations' ][ $key ] );
91
+ }
92
+ }
93
+ if ( is_array( $_POST[ 'destinations' ] ) )
94
+ sort( $_POST[ 'destinations' ] );
95
+ } else {
96
+ $_POST[ 'destinations' ] = array();
97
+ }
98
+ BackWPup_Option::update( $jobid, 'destinations', $_POST[ 'destinations' ] );
99
+
100
+ $name = esc_html( trim( $_POST[ 'name' ] ) );
101
+ if ( empty( $name ) || $_POST[ 'name' ] == __( 'New Job', 'backwpup' ) )
102
+ $name = sprintf( __( 'Job with ID %d', 'backwpup' ), $jobid );
103
+ BackWPup_Option::update( $jobid, 'name', $name );
104
+ BackWPup_Option::update( $jobid, 'mailaddresslog', sanitize_email( $_POST[ 'mailaddresslog' ] ) );
105
+
106
+ $_POST[ 'mailaddresssenderlog' ] = trim( $_POST[ 'mailaddresssenderlog' ] );
107
+ if ( empty($_POST[ 'mailaddresssenderlog' ] ) )
108
+ BackWPup_Option::delete( $jobid, 'mailaddresssenderlog');
109
+ else
110
+ BackWPup_Option::update( $jobid, 'mailaddresssenderlog', $_POST[ 'mailaddresssenderlog' ] );
111
+
112
+ BackWPup_Option::update( $jobid, 'mailerroronly', ( isset( $_POST[ 'mailerroronly' ] ) && $_POST[ 'mailerroronly' ] == 1 ) ? TRUE : FALSE );
113
+ if ( class_exists( 'BackWPup_Pro', FALSE ) )
114
+ BackWPup_Option::update( $jobid, 'backuptype', $_POST[ 'backuptype' ] );
115
+ else
116
+ BackWPup_Option::update( $jobid, 'backuptype', 'archive' );
117
+ BackWPup_Option::update( $jobid, 'archiveformat', $_POST[ 'archiveformat' ] );
118
+ BackWPup_Option::update( $jobid, 'archivename', sanitize_file_name( esc_html( $_POST[ 'archivename' ] ) ) );
119
+ break;
120
+ case 'cron':
121
+ if ( $_POST[ 'activetype' ] == '' || $_POST[ 'activetype' ] == 'wpcron' || $_POST[ 'activetype' ] == 'link' )
122
+ BackWPup_Option::update( $jobid, 'activetype', $_POST[ 'activetype' ] );
123
+
124
+ BackWPup_Option::update( $jobid, 'cronselect', $_POST[ 'cronselect' ] == 'advanced' ? 'advanced' : 'basic' );
125
+
126
+ if ( isset($_POST[ 'cronselect' ]) && $_POST[ 'cronselect' ] == 'advanced' ) { //save advanced
127
+ if ( empty( $_POST[ 'cronminutes' ] ) || $_POST[ 'cronminutes' ][ 0 ] == '*' ) {
128
+ if ( ! empty( $_POST[ 'cronminutes' ][ 1 ] ) )
129
+ $_POST[ 'cronminutes' ] = array( '*/' . $_POST[ 'cronminutes' ][ 1 ] );
130
+ else
131
+ $_POST[ 'cronminutes' ] = array( '*' );
132
+ }
133
+ if ( empty( $_POST[ 'cronhours' ] ) || $_POST[ 'cronhours' ][ 0 ] == '*' ) {
134
+ if ( ! empty( $_POST[ 'cronhours' ][ 1 ] ) )
135
+ $_POST[ 'cronhours' ] = array( '*/' . $_POST[ 'cronhours' ][ 1 ] );
136
+ else
137
+ $_POST[ 'cronhours' ] = array( '*' );
138
+ }
139
+ if ( empty( $_POST[ 'cronmday' ] ) || $_POST[ 'cronmday' ][ 0 ] == '*' ) {
140
+ if ( ! empty( $_POST[ 'cronmday' ][ 1 ] ) )
141
+ $_POST[ 'cronmday' ] = array( '*/' . $_POST[ 'cronmday' ][ 1 ] );
142
+ else
143
+ $_POST[ 'cronmday' ] = array( '*' );
144
+ }
145
+ if ( empty( $_POST[ 'cronmon' ] ) || $_POST[ 'cronmon' ][ 0 ] == '*' ) {
146
+ if ( ! empty( $_POST[ 'cronmon' ][ 1 ] ) )
147
+ $_POST[ 'cronmon' ] = array( '*/' . $_POST[ 'cronmon' ][ 1 ] );
148
+ else
149
+ $_POST[ 'cronmon' ] = array( '*' );
150
+ }
151
+ if ( empty( $_POST[ 'cronwday' ] ) || $_POST[ 'cronwday' ][ 0 ] == '*' ) {
152
+ if ( ! empty( $_POST[ 'cronwday' ][ 1 ] ) )
153
+ $_POST[ 'cronwday' ] = array( '*/' . $_POST[ 'cronwday' ][ 1 ] );
154
+ else
155
+ $_POST[ 'cronwday' ] = array( '*' );
156
+ }
157
+ $cron = implode( ",", $_POST[ 'cronminutes' ] ) . ' ' . implode( ",", $_POST[ 'cronhours' ] ) . ' ' . implode( ",", $_POST[ 'cronmday' ] ) . ' ' . implode( ",", $_POST[ 'cronmon' ] ) . ' ' . implode( ",", $_POST[ 'cronwday' ] );
158
+ BackWPup_Option::update( $jobid, 'cron', $cron );
159
+ } else { //Save basic
160
+ if ( $_POST[ 'cronbtype' ] == 'mon' )
161
+ BackWPup_Option::update( $jobid, 'cron', $_POST[ 'moncronminutes' ] . ' ' . $_POST[ 'moncronhours' ] . ' ' . $_POST[ 'moncronmday' ] . ' * *' );
162
+ if ( $_POST[ 'cronbtype' ] == 'week' )
163
+ BackWPup_Option::update( $jobid, 'cron', $_POST[ 'weekcronminutes' ] . ' ' . $_POST[ 'weekcronhours' ] . ' * * ' . $_POST[ 'weekcronwday' ] );
164
+ if ( $_POST[ 'cronbtype' ] == 'day' )
165
+ BackWPup_Option::update( $jobid, 'cron', $_POST[ 'daycronminutes' ] . ' ' . $_POST[ 'daycronhours' ] . ' * * *' );
166
+ if ( $_POST[ 'cronbtype' ] == 'hour' )
167
+ BackWPup_Option::update( $jobid, 'cron', $_POST[ 'hourcronminutes' ] . ' * * * *' );
168
+ }
169
+ //reschedule
170
+ wp_clear_scheduled_hook( 'backwpup_cron', array( 'id' => $jobid ) );
171
+ if ( BackWPup_Option::get( $jobid, 'activetype' ) == 'wpcron' ) {
172
+ $cron_next = BackWPup_Cron::cron_next( BackWPup_Option::get( $jobid, 'cron' ) );
173
+ wp_schedule_single_event( $cron_next, 'backwpup_cron', array( 'id' => $jobid ) );
174
+ }
175
+ break;
176
+ default:
177
+ if ( strstr( $tab, 'dest-' ) ) {
178
+ $dest_class = BackWPup::get_destination( str_replace( 'dest-', '', $tab ) );
179
+ $dest_class->edit_form_post_save( $jobid );
180
+ }
181
+ if ( strstr( $tab, 'jobtype-' ) ) {
182
+ $id = strtoupper( str_replace( 'jobtype-', '', $tab ) );
183
+ $job_types[ $id ]->edit_form_post_save( $jobid );
184
+ }
185
+ }
186
+
187
+ //saved message
188
+ $messages = BackWPup_Admin::get_messages();
189
+ if ( empty( $messages[ 'error' ] ) ) {
190
+ $url = BackWPup_Job::get_jobrun_url( 'runnowlink', $jobid );
191
+ BackWPup_Admin::message( sprintf( __( 'Changes for job <i>%s</i> saved.', 'backwpup' ), BackWPup_Option::get( $jobid, 'name' ) ) .
192
+ ' <a href="' . network_admin_url( 'admin.php' ) . '?page=backwpupjobs">' . __( 'Jobs overview', 'backwpup' ) . '</a> | <a href="' . $url[ 'url' ] . '">' . __( 'Run now', 'backwpup' ) . '</a>' );
193
+ }
194
+ }
195
+
196
+ /**
197
+ *
198
+ * Output css
199
+ *
200
+ * @return void
201
+ */
202
+ public static function admin_print_styles() {
203
+
204
+ ?>
205
+ <style type="text/css" media="screen">
206
+ #cron-min, #cron-hour, #cron-day, #cron-month, #cron-weekday {
207
+ overflow: auto;
208
+ white-space: nowrap;
209
+ height: 7em;
210
+ }
211
+ #cron-min-box, #cron-hour-box, #cron-day-box, #cron-month-box, #cron-weekday-box {
212
+ border-color: gray;
213
+ border-style: solid;
214
+ border-width: 1px;
215
+ margin: 10px 0px 10px 10px;
216
+ padding: 2px 2px;
217
+ width: 100px;
218
+ float: left;
219
+ }
220
+ #wpcronbasic {
221
+ border-collapse: collapse;
222
+ }
223
+ #wpcronbasic th, #wpcronbasic td {
224
+ width:80px;
225
+ border-bottom: 1px solid gray;
226
+ }
227
+ </style>
228
+ <?php
229
+ //add css for all other tabs
230
+ if ( substr( $_GET[ 'tab' ], 0, 5 ) == 'dest-' ) {
231
+ $dest_object = BackWPup::get_destination( str_replace( 'dest-', '', $_GET[ 'tab' ] ) );
232
+ $dest_object->admin_print_styles();
233
+ }
234
+ elseif ( substr( $_GET[ 'tab' ], 0, 8 ) == 'jobtype-' ) {
235
+ $job_type = BackWPup::get_job_types();
236
+ $id = strtoupper( str_replace( 'jobtype-', '', $_GET[ 'tab' ] ) );
237
+ $job_type[ $id ]->admin_print_styles( );
238
+ }
239
+ }
240
+
241
+ /**
242
+ *
243
+ * Output js
244
+ *
245
+ * @return void
246
+ */
247
+ public static function admin_print_scripts() {
248
+
249
+ wp_enqueue_script( 'backwpupgeneral' );
250
+
251
+ //add js for the first tabs
252
+ if ( $_GET[ 'tab' ] == 'job' ) {
253
+ if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
254
+ wp_enqueue_script( 'backwpuptabjob', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_edit_tab_job.js', array('jquery'), time(), TRUE );
255
+ } else {
256
+ wp_enqueue_script( 'backwpuptabjob', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_edit_tab_job.min.js', array('jquery'), BackWPup::get_plugin_data( 'Version' ), TRUE );
257
+ }
258
+ }
259
+ elseif ( $_GET[ 'tab' ] == 'cron' ) {
260
+ if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
261
+ wp_enqueue_script( 'backwpuptabcron', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_edit_tab_cron.js', array('jquery'), time(), TRUE );
262
+ } else {
263
+ wp_enqueue_script( 'backwpuptabcron', BackWPup::get_plugin_data( 'URL' ) . '/assets/js/page_edit_tab_cron.min.js', array('jquery'), BackWPup::get_plugin_data( 'Version' ), TRUE );
264
+ }
265
+ }
266
+ //add js for all other tabs
267
+ elseif ( strstr( $_GET[ 'tab' ], 'dest-' ) ) {
268
+ $dest_object = BackWPup::get_destination( str_replace( 'dest-', '', $_GET[ 'tab' ] ) );
269
+ $dest_object->admin_print_scripts();
270
+ }
271
+ elseif ( strstr( $_GET[ 'tab' ], 'jobtype-' ) ) {
272
+ $job_type = BackWPup::get_job_types();
273
+ $id = strtoupper( str_replace( 'jobtype-', '', $_GET[ 'tab' ] ) );
274
+ $job_type[ $id ]->admin_print_scripts( );
275
+ }
276
+ }
277
+
278
+ /**
279
+ * @static
280
+ *
281
+ * @param string $args
282
+ *
283
+ * @return mixed
284
+ */
285
+ public static function ajax_cron_text( $args = '' ) {
286
+
287
+ if ( is_array( $args ) ) {
288
+ extract( $args );
289
+ $ajax = FALSE;
290
+ } else {
291
+ if ( ! current_user_can( 'backwpup_jobs_edit' ) )
292
+ wp_die( -1 );
293
+ check_ajax_referer( 'backwpup_ajax_nonce' );
294
+ if ( empty( $_POST[ 'cronminutes' ] ) || $_POST[ 'cronminutes' ][ 0 ] == '*' ) {
295
+ if ( ! empty( $_POST[ 'cronminutes' ][ 1 ] ) )
296
+ $_POST[ 'cronminutes' ] = array( '*/' . $_POST[ 'cronminutes' ][ 1 ] );
297
+ else
298
+ $_POST[ 'cronminutes' ] = array( '*' );
299
+ }
300
+ if ( empty( $_POST[ 'cronhours' ] ) || $_POST[ 'cronhours' ][ 0 ] == '*' ) {
301
+ if ( ! empty( $_POST[ 'cronhours' ][ 1 ] ) )
302
+ $_POST[ 'cronhours' ] = array( '*/' . $_POST[ 'cronhours' ][ 1 ] );
303
+ else
304
+ $_POST[ 'cronhours' ] = array( '*' );
305
+ }
306
+ if ( empty( $_POST[ 'cronmday' ] ) || $_POST[ 'cronmday' ][ 0 ] == '*' ) {
307
+ if ( ! empty( $_POST[ 'cronmday' ][ 1 ] ) )
308
+ $_POST[ 'cronmday' ] = array( '*/' . $_POST[ 'cronmday' ][ 1 ] );
309
+ else
310
+ $_POST[ 'cronmday' ] = array( '*' );
311
+ }
312
+ if ( empty( $_POST[ 'cronmon' ] ) || $_POST[ 'cronmon' ][ 0 ] == '*' ) {
313
+ if ( ! empty( $_POST[ 'cronmon' ][ 1 ] ) )
314
+ $_POST[ 'cronmon' ] = array( '*/' . $_POST[ 'cronmon' ][ 1 ] );
315
+ else
316
+ $_POST[ 'cronmon' ] = array( '*' );
317
+ }
318
+ if ( empty( $_POST[ 'cronwday' ] ) || $_POST[ 'cronwday' ][ 0 ] == '*' ) {
319
+ if ( ! empty( $_POST[ 'cronwday' ][ 1 ] ) )
320
+ $_POST[ 'cronwday' ] = array( '*/' . $_POST[ 'cronwday' ][ 1 ] );
321
+ else
322
+ $_POST[ 'cronwday' ] = array( '*' );
323
+ }
324
+ $crontype = $_POST[ 'crontype' ];
325
+ $cronstamp = implode( ",", $_POST[ 'cronminutes' ] ) . ' ' . implode( ",", $_POST[ 'cronhours' ] ) . ' ' . implode( ",", $_POST[ 'cronmday' ] ) . ' ' . implode( ",", $_POST[ 'cronmon' ] ) . ' ' . implode( ",", $_POST[ 'cronwday' ] );
326
+ $ajax = TRUE;
327
+ }
328
+ echo '<p class="wpcron" id="schedulecron">';
329
+
330
+ if ( $crontype == 'advanced' ) {
331
+ echo str_replace( '\"','"', __( 'Working as <a href="http://wikipedia.org/wiki/Cron">Cron</a> schedule:', 'backwpup' ) );
332
+ echo ' <i><b>' . esc_attr( $cronstamp ). '</b></i><br />';
333
+ }
334
+
335
+ list( $cronstr[ 'minutes' ], $cronstr[ 'hours' ], $cronstr[ 'mday' ], $cronstr[ 'mon' ], $cronstr[ 'wday' ] ) = explode( ' ', $cronstamp, 5 );
336
+ if ( FALSE !== strpos( $cronstr[ 'minutes' ], '*/' ) || $cronstr[ 'minutes' ] == '*' ) {
337
+ $repeatmins = str_replace( '*/', '', $cronstr[ 'minutes' ] );
338
+ if ( $repeatmins == '*' || empty( $repeatmins ) )
339
+ $repeatmins = 5;
340
+ echo '<span style="color:red;">' . sprintf( __( 'ATTENTION: Job runs every %d minutes!', 'backwpup' ), $repeatmins ) . '</span><br />';
341
+ }
342
+ if ( FALSE !== strpos( $cronstr[ 'hours' ], '*/' ) || $cronstr[ 'hours' ] == '*' ) {
343
+ $repeathouer = str_replace( '*/', '', $cronstr[ 'hours' ] );
344
+ if ( $repeathouer == '*' || empty( $repeathouer ) )
345
+ $repeathouer = 1;
346
+ echo '<span style="color:red;">' . sprintf( __( 'ATTENTION: Job runs every %d hours!', 'backwpup' ), $repeathouer ) . '</span><br />';
347
+ }
348
+ $cron_next = BackWPup_Cron::cron_next( $cronstamp ) + ( get_option( 'gmt_offset' ) * 3600 );
349
+ if ( 2147483647 == $cron_next ) {
350
+ echo '<span style="color:red;">' . __( 'ATTENTION: Can\'t calculate cron!', 'backwpup' ) . '</span><br />';
351
+ }
352
+ else {
353
+ _e( 'Next runtime:', 'backwpup' );
354
+ echo ' <b>' . date_i18n( 'D, j M Y, H:i', $cron_next, TRUE ) . '</b>';
355
+ }
356
+ echo "</p>";
357
+
358
+ if ( $ajax )
359
+ die();
360
+ else
361
+ return;
362
+ }
363
+
364
+ /**
365
+ *
366
+ */
367
+ public static function page() {
368
+
369
+ if ( ! empty( $_GET[ 'jobid' ] ) ) {
370
+ $jobid = (int)$_GET[ 'jobid' ];
371
+ }
372
+ else {
373
+ //generate jobid if not exists
374
+ $newjobid = BackWPup_Option::get_job_ids();
375
+ sort( $newjobid );
376
+ $jobid = end( $newjobid ) + 1;
377
+ }
378
+
379
+ $destinations = BackWPup::get_registered_destinations();
380
+ $job_types = BackWPup::get_job_types();
381
+
382
+ ?>
383
+ <div class="wrap" id="backwpup-page">
384
+ <?php
385
+ //default tabs
386
+ $tabs = array( 'job' => array( 'name' => __( 'General', 'backwpup' ), 'display' => TRUE ), 'cron' => array( 'name' => __( 'Schedule', 'backwpup' ), 'display' => TRUE ) );
387
+ //add jobtypes to tabs
388
+ $job_job_types = BackWPup_Option::get( $jobid, 'type' );
389
+ foreach ( $job_types as $typeid => $typeclass ) {
390
+ $tabid = 'jobtype-' . strtolower( $typeid );
391
+ $tabs[ $tabid ][ 'name' ] = $typeclass->info[ 'name' ];
392
+ $tabs[ $tabid ][ 'display' ] = TRUE;
393
+ if ( ! in_array( $typeid, $job_job_types ) )
394
+ $tabs[ $tabid ][ 'display' ] = FALSE;
395
+
396
+ }
397
+ //add destinations to tabs
398
+ $jobdests = BackWPup_Option::get( $jobid, 'destinations' );
399
+ foreach ( $destinations as $destid => $dest ) {
400
+ $tabid = 'dest-' . strtolower( $destid );
401
+ $tabs[ $tabid ][ 'name' ] = sprintf( __( 'To: %s', 'backwpup' ), $dest[ 'info' ][ 'name' ] );
402
+ $tabs[ $tabid ][ 'display' ] = TRUE;
403
+ if ( ! in_array( $destid, $jobdests ) )
404
+ $tabs[ $tabid ][ 'display' ] = FALSE;
405
+ }
406
+ //display tabs
407
+ echo '<h2 class="nav-tab-wrapper"><span id="backwpup-page-icon">&nbsp;</span>' . sprintf( __( '%s Job:', 'backwpup' ), BackWPup::get_plugin_data( 'name' ) ). '&nbsp;';
408
+ echo '<span id="h2jobtitle">' . esc_html( BackWPup_Option::get( $jobid, 'name' ) ) . '</span><br /><br />';
409
+ foreach ( $tabs as $id => $tab ) {
410
+ $addclass = '';
411
+ if ( $id == $_GET[ 'tab' ] )
412
+ $addclass = ' nav-tab-active';
413
+ $display = '';
414
+ if ( ! $tab[ 'display' ] )
415
+ $display = ' style="display:none;"';
416
+ echo '<a href="' . wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupeditjob&tab=' . $id . '&jobid=' . $jobid, 'edit-job' ) . '" class="nav-tab' . $addclass . '" id="tab-' . $id . '" data-nexttab="' . $id . '" ' . $display . '>' . $tab[ 'name' ] . '</a>';
417
+ }
418
+ echo '</h2>';
419
+ //display messages
420
+ BackWPup_Admin::display_messages();
421
+ echo '<form name="editjob" id="editjob" method="post" action="' . admin_url( 'admin-post.php?action=backwpup' ) . '">';
422
+ echo '<input type="hidden" id="jobid" name="jobid" value="' . $jobid . '" />';
423
+ echo '<input type="hidden" name="tab" value="' . $_GET[ 'tab' ] . '" />';
424
+ echo '<input type="hidden" name="nexttab" value="' . $_GET[ 'tab' ] . '" />';
425
+ echo '<input type="hidden" name="page" value="backwpupeditjob" />';
426
+ echo '<input type="hidden" name="anchor" value="" />';
427
+ wp_nonce_field( 'backwpupeditjob_page' );
428
+ wp_nonce_field( 'backwpup_ajax_nonce', 'backwpupajaxnonce', FALSE );
429
+
430
+ switch ( $_GET[ 'tab' ] ) {
431
+ case 'job':
432
+ echo '<div class="table" id="info-tab-job">';
433
+ ?>
434
+ <h3 class="title"><?php _e( 'Job Name', 'backwpup' ) ?></h3>
435
+ <p></p>
436
+ <table class="form-table">
437
+ <tr>
438
+ <th scope="row"><label for="name"><?php _e( 'Please name this job.', 'backwpup' ) ?></label></th>
439
+ <td>
440
+ <input name="name" type="text" id="name" data-empty="<?php _e( 'New Job', 'backwpup' ); ?>"
441
+ value="<?php echo BackWPup_Option::get( $jobid, 'name' ); ?>" class="regular-text" />
442
+ </td>
443
+ </tr>
444
+ </table>
445
+
446
+ <h3 class="title"><?php _e( 'Job Tasks', 'backwpup' ) ?></h3>
447
+ <p></p>
448
+ <table class="form-table">
449
+ <tr>
450
+ <th scope="row"><?php _e( 'This job is a&#160;&hellip;', 'backwpup' ) ?></th>
451
+ <td>
452
+ <fieldset>
453
+ <legend class="screen-reader-text"><span><?php _e( 'Job tasks', 'backwpup' ) ?></span>
454
+ </legend><?php
455
+ foreach ( $job_types as $id => $typeclass ) {
456
+ $addclass = '';
457
+ if ( $typeclass->creates_file() )
458
+ $addclass .= ' filetype';
459
+ $title = '';
460
+ if ( ! empty( $typeclass->info[ 'help' ] ) ) {
461
+ $title = ' title="' . esc_attr( $typeclass->info[ 'help' ] ) . '"';
462
+ $addclass .= ' help-tip';
463
+ }
464
+ echo '<label for="jobtype-select-' . strtolower( $id ) . '"><input class="jobtype-select checkbox' . $addclass . '"' . $title . ' id="jobtype-select-' . strtolower( $id ) . '" type="checkbox" ' . checked( TRUE, in_array( $id, BackWPup_Option::get( $jobid, 'type' ) ), FALSE ) . ' name="type[]" value="' . $id . '" /> ' . $typeclass->info[ 'description' ] . '</label><br />';
465
+ }
466
+ ?></fieldset>
467
+ </td>
468
+ </tr>
469
+ </table>
470
+
471
+ <h3 class="title hasdests"><?php _e( 'Backup File Creation', 'backwpup' ) ?></h3>
472
+ <p class="hasdests"></p>
473
+ <table class="form-table hasdests">
474
+ <?php if ( class_exists( 'BackWPup_Pro', FALSE ) ) { ?>
475
+ <tr>
476
+ <th scope="row"><?php _e( 'Backup type', 'backwpup' ); ?></th>
477
+ <td>
478
+ <fieldset>
479
+ <legend class="screen-reader-text"> <span><?php _e( 'Backup type', 'backwpup' ) ?></span></legend>
480
+ <label for="idbackuptype-sync"><input class="radio"
481
+ type="radio"<?php checked( 'sync', BackWPup_Option::get( $jobid, 'backuptype' ), TRUE ); ?>
482
+ name="backuptype" id="idbackuptype-sync"
483
+ value="sync"/> <?php _e( 'Synchronize file by file to destination', 'backwpup' ); ?></label><br/>
484
+ <label for="idbackuptype-archive"><input class="radio"
485
+ type="radio"<?php checked( 'archive', BackWPup_Option::get( $jobid, 'backuptype' ), TRUE ); ?>
486
+ name="backuptype" id="idbackuptype-archive"
487
+ value="archive"/> <?php _e( 'Create a backup archive', 'backwpup' ); ?></label><br/>
488
+ </fieldset>
489
+ </td>
490
+ </tr>
491
+ <?php } ?>
492
+ <tr class="nosync">
493
+ <th scope="row"><label for="archivename"><?php _e( 'Archive name', 'backwpup' ) ?></label></th>
494
+ <td>
495
+ <input name="archivename" type="text" id="archivename"
496
+ value="<?php echo BackWPup_Option::get( $jobid, 'archivename' );?>"
497
+ class="regular-text code help-tip" title="<?php
498
+ echo "<strong>" . esc_attr__( 'Replacement patterns:', 'backwpup' ) . "</strong><br />";
499
+ echo esc_attr__( '%d = Two digit day of the month, with leading zeros', 'backwpup' ) . '<br />';
500
+ echo esc_attr__( '%j = Day of the month, without leading zeros', 'backwpup' ) . '<br />';
501
+ echo esc_attr__( '%m = Day of the month, with leading zeros', 'backwpup' ) . '<br />';
502
+ echo esc_attr__( '%n = Representation of the month (without leading zeros)', 'backwpup' ) . '<br />';
503
+ echo esc_attr__( '%Y = Four digit representation for the year', 'backwpup' ) . '<br />';
504
+ echo esc_attr__( '%y = Two digit representation of the year', 'backwpup' ) . '<br />';
505
+ echo esc_attr__( '%a = Lowercase ante meridiem (am) and post meridiem (pm)', 'backwpup' ) . '<br />';
506
+ echo esc_attr__( '%A = Uppercase ante meridiem (AM) and post meridiem (PM)', 'backwpup' ) . '<br />';
507
+ echo esc_attr__( '%B = Swatch Internet Time', 'backwpup' ) . '<br />';
508
+ echo esc_attr__( '%g = Hour in 12-hour format, without leading zeros', 'backwpup' ) . '<br />';
509
+ echo esc_attr__( '%G = Hour in 24-hour format, without leading zeros', 'backwpup' ) . '<br />';
510
+ echo esc_attr__( '%h = Hour in 12-hour format, with leading zeros', 'backwpup' ) . '<br />';
511
+ echo esc_attr__( '%H = Hour in 24-hour format, with leading zeros', 'backwpup' ) . '<br />';
512
+ echo esc_attr__( '%i = Two digit representation of the minute', 'backwpup' ) . '<br />';
513
+ echo esc_attr__( '%s = Two digit representation of the second', 'backwpup' ) . '<br />';
514
+ ?>" />
515
+ <?php
516
+ $datevars = array( '%d', '%j', '%m', '%n', '%Y', '%y', '%a', '%A', '%B', '%g', '%G', '%h', '%H', '%i', '%s' );
517
+ $datevalues = array( date_i18n( 'd' ), date_i18n( 'j' ), date_i18n( 'm' ), date_i18n( 'n' ), date_i18n( 'Y' ), date_i18n( 'y' ), date_i18n( 'a' ), date_i18n( 'A' ), date_i18n( 'B' ), date_i18n( 'g' ), date_i18n( 'G' ), date_i18n( 'h' ), date_i18n( 'H' ), date_i18n( 'i' ), date_i18n( 's' ) );
518
+ $archivename = str_replace( $datevars, $datevalues, BackWPup_Option::get( $jobid, 'archivename' ) );
519
+ $archivename = sanitize_file_name( $archivename );
520
+ echo '<p>Preview: <code><span id="archivefilename">' . $archivename . '</span><span id="archiveformat">' . BackWPup_Option::get( $jobid, 'archiveformat' ) . '</span></code></p>';
521
+ ?>
522
+ </td>
523
+ </tr>
524
+ <tr class="nosync">
525
+ <th scope="row"><?php _e( 'Archive Format', 'backwpup' ); ?></th>
526
+ <td>
527
+ <fieldset>
528
+ <legend class="screen-reader-text"><span><?php _e( 'Archive Format', 'backwpup' ) ?></span></legend>
529
+ <?php
530
+ if ( function_exists( 'gzopen' ) || class_exists( 'ZipArchive' ) )
531
+ echo '<label for="idarchiveformat-zip"><input class="radio help-tip" title="'. __( 'PHP Zip functions will be used if available (needs less memory). Otherwise the PCLZip class will be used.', 'backwpup' ) .'" type="radio"' . checked( '.zip', BackWPup_Option::get( $jobid, 'archiveformat' ), FALSE ) . ' name="archiveformat" id="idarchiveformat-zip" value=".zip" /> ' . __( 'Zip', 'backwpup' ) . '</label><br />';
532
+ else
533
+ echo '<label for="idarchiveformat-zip"><input class="radio help-tip" title="' . __( 'Disabled due to missing PHP function.', 'backwpup' ) . '" type="radio"' . checked( '.zip', BackWPup_Option::get( $jobid, 'archiveformat' ), FALSE ) . ' name="archiveformat" id="idarchiveformat-zip" value=".zip" disabled="disabled" /> ' . __( 'Zip', 'backwpup' ) . '</label><br />';
534
+ echo '<label for="idarchiveformat-tar"><input class="radio help-tip" title="' . __( 'A tarballed, not compressed archive (fast and less memory)', 'backwpup' ) . '" type="radio"' . checked( '.tar', BackWPup_Option::get( $jobid, 'archiveformat' ), FALSE ) . ' name="archiveformat" id="idarchiveformat-tar" value=".tar" /> ' . __( 'Tar', 'backwpup' ) . '</label><br />';
535
+ if ( function_exists( 'gzopen' ) )
536
+ echo '<label for="idarchiveformat-targz"><input class="radio help-tip" title="' . __( 'A tarballed, GZipped archive (fast and less memory)', 'backwpup' ) . '" type="radio"' . checked( '.tar.gz', BackWPup_Option::get( $jobid, 'archiveformat' ), FALSE ) . ' name="archiveformat" id="idarchiveformat-targz" value=".tar.gz" /> ' . __( 'Tar GZip', 'backwpup' ) . '</label><br />';
537
+ else
538
+ echo '<label for="idarchiveformat-targz"><input class="radio help-tip" title="' . __( 'Disabled due to missing PHP function.', 'backwpup' ) . '" type="radio"' . checked( '.tar.gz', BackWPup_Option::get( $jobid, 'archiveformat' ), FALSE ) . ' name="archiveformat" id="idarchiveformat-targz" value=".tar.gz" disabled="disabled" /> ' . __( 'Tar GZip', 'backwpup' ) . '</label><br />';
539
+ if ( function_exists( 'bzopen' ) )
540
+ echo '<label for="idarchiveformat-tarbz2"><input class="radio help-tip" title="' . __( 'A tarballed, BZipped archive (fast and less memory)', 'backwpup' ) . '" type="radio"' . checked( '.tar.bz2', BackWPup_Option::get( $jobid, 'archiveformat' ), FALSE ) . ' name="archiveformat" id="idarchiveformat-tarbz2" value=".tar.bz2" /> ' . __( 'Tar BZip2', 'backwpup' ) . '</label><br />';
541
+ else
542
+ echo '<label for="idarchiveformat-tarbz2"><input class="radio help-tip" title="' . __( 'Disabled due to missing PHP function.', 'backwpup' ) . '" type="radio"' . checked( '.tar.bz2', BackWPup_Option::get( $jobid, 'archiveformat' ), FALSE ) . ' name="archiveformat" id="idarchiveformat-tarbz2" value=".tar.bz2" disabled="disabled" /> ' . __( 'Tar BZip2', 'backwpup' ) . '</label><br />';
543
+ ?></fieldset>
544
+ </td>
545
+ </tr>
546
+ </table>
547
+
548
+ <h3 class="title hasdests"><?php _e( 'Job Destination', 'backwpup' ) ?></h3>
549
+ <p class="hasdests"></p>
550
+ <table class="form-table hasdests">
551
+ <tr>
552
+ <th scope="row"><?php _e( 'Where should your backup file be stored?', 'backwpup' ) ?></th>
553
+ <td>
554
+ <fieldset>
555
+ <legend class="screen-reader-text"><span><?php _e( 'Where should your backup file be stored?', 'backwpup' ) ?></span>
556
+ </legend><?php
557
+ foreach ( $destinations as $id => $dest ) {
558
+ $syncclass = '';
559
+ if ( ! $dest[ 'can_sync' ] )
560
+ $syncclass = 'nosync';
561
+ $title = ''; $helpclass = '';
562
+ if ( ! empty( $dest[ 'info' ][ 'help' ] ) ) {
563
+ $title = ' title="'. esc_attr( $dest[ 'info' ][ 'help' ] ) . '"';
564
+ $helpclass = ' help-tip';
565
+ }
566
+ echo '<span class="' . $syncclass . '"><label for="dest-select-' . strtolower( $id ) . '"><input class="checkbox' . $helpclass . '"' . $title . ' id="dest-select-' . strtolower( $id ) . '" type="checkbox" ' . checked( TRUE, in_array( $id, BackWPup_Option::get( $jobid, 'destinations' ) ), FALSE ) . ' name="destinations[]" value="' . $id . '" ' . disabled( ! empty( $dest[ 'error' ] ), TRUE, FALSE ) . ' /> ' . $dest[ 'info' ][ 'description' ];
567
+ if ( ! empty( $dest[ 'error' ] ) )
568
+ echo '<br /><span class="description">' . $dest[ 'error' ] . '</span>';
569
+ echo '</label><br /></span>';
570
+ }
571
+ ?></fieldset>
572
+ </td>
573
+ </tr>
574
+ </table>
575
+
576
+ <h3 class="title"><?php _e( 'Log Files', 'backwpup' ) ?></h3>
577
+ <p></p>
578
+ <table class="form-table">
579
+ <tr>
580
+ <th scope="row"><label for="mailaddresslog"><?php _e( 'Send log to email address', 'backwpup' ) ?></label></th>
581
+ <td>
582
+ <input name="mailaddresslog" type="text" id="mailaddresslog"
583
+ value="<?php echo BackWPup_Option::get( $jobid, 'mailaddresslog' );?>"
584
+ class="regular-text help-tip" title="<?php esc_attr_e( 'Leave empty to not have log sent.', 'backwpup' ); ?>" />
585
+ </td>
586
+ </tr>
587
+ <tr>
588
+ <th scope="row"><label for="mailaddresssenderlog"><?php _e( 'Email FROM field', 'backwpup' ) ?></label></th>
589
+ <td>
590
+ <input name="mailaddresssenderlog" type="text" id="mailaddresssenderlog"
591
+ value="<?php echo BackWPup_Option::get( $jobid, 'mailaddresssenderlog' );?>"
592
+ class="regular-text help-tip" title="<?php esc_attr_e( 'Email "From" field (Name &lt;&#160;you@your-email-address.tld&#160;&gt;)', 'backwpup' ); ?>" />
593
+ </td>
594
+ </tr>
595
+ <tr>
596
+ <th scope="row"><?php _e( 'Errors only', 'backwpup' ); ?></th>
597
+ <td>
598
+ <label for="idmailerroronly">
599
+ <input class="checkbox" value="1" id="idmailerroronly"
600
+ type="checkbox" <?php checked( BackWPup_Option::get( $jobid, 'mailerroronly' ), TRUE ); ?>
601
+ name="mailerroronly" /> <?php _e( 'Send email with log only when errors occur during job execution.', 'backwpup' ); ?>
602
+ </label>
603
+ </td>
604
+ </tr>
605
+ </table>
606
+ <?php
607
+ echo '</div>';
608
+ break;
609
+ case 'cron':
610
+ echo '<div class="table" id="info-tab-cron">';
611
+ ?>
612
+ <h3 class="title"><?php _e( 'Job Schedule', 'backwpup' ) ?></h3>
613
+ <p></p>
614
+ <table class="form-table">
615
+ <tr>
616
+ <th scope="row"><?php _e( 'Start job', 'backwpup' ); ?></th>
617
+ <td>
618
+ <fieldset>
619
+ <legend class="screen-reader-text"><span><?php _e( 'Start job', 'backwpup' ) ?></span></legend>
620
+ <label for="idactivetype"><input class="radio"
621
+ type="radio"<?php checked( '', BackWPup_Option::get( $jobid, 'activetype' ), TRUE ); ?>
622
+ name="activetype" id="idactivetype"
623
+ value="" /> <?php _e( 'manually only', 'backwpup' ); ?></label><br/>
624
+ <label for="idactivetype-wpcron"><input class="radio"
625
+ type="radio"<?php checked( 'wpcron', BackWPup_Option::get( $jobid, 'activetype' ), TRUE ); ?>
626
+ name="activetype" id="idactivetype-wpcron"
627
+ value="wpcron" /> <?php _e( 'with WordPress cron', 'backwpup' ); ?></label><br/>
628
+ <?php
629
+ $url = BackWPup_Job::get_jobrun_url( 'runext', BackWPup_Option::get( $jobid, 'jobid' ) );
630
+ ?>
631
+ <label for="idactivetype-link"><input class="radio help-tip"
632
+ type="radio"<?php checked( 'link', BackWPup_Option::get( $jobid, 'activetype' ), TRUE ); ?>
633
+ name="activetype" id="idactivetype-link"
634
+ value="link" title="<?php esc_attr_e( 'Copy the link for an external start. This option has to be activated to make the link work.', 'backwpup' )?>" /> <?php _e( 'with a link', 'backwpup' ); ?> <code><a href="<?php echo $url[ 'url' ];?>" target="_blank"><?php echo $url[ 'url' ];?></a></code></label>
635
+ <br />
636
+ </fieldset>
637
+ </td>
638
+ </tr>
639
+ <tr>
640
+ <th scope="row"><?php _e( 'Start job with CLI', 'backwpup' ); ?></th>
641
+ <td class="help-tip" title="<?php esc_attr_e( 'Generate a server script file to let the job start with the server’s cron on command line interface. Alternatively use WP-CLI commands.', 'backwpup' ); ?>">
642
+ <?php
643
+ echo str_replace( '\"','"', sprintf ( __( 'Use <a href="http://wp-cli.org/">WP-CLI</a> to run jobs from commandline or <a href="%s">get the start script</a>.', 'backwpup' ), wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupjobs&action=start_cli&jobid=' . $jobid, 'start_cli' ) ) );
644
+ ?>
645
+ </td>
646
+ </tr>
647
+ </table>
648
+ <h3 class="title wpcron"><?php _e( 'Schedule execution time', 'backwpup' ) ?></h3>
649
+ <?php BackWPup_Page_Editjob::ajax_cron_text( array( 'cronstamp' => BackWPup_Option::get( $jobid, 'cron' ), 'crontype' => BackWPup_Option::get( $jobid, 'cronselect' ) ) ); ?>
650
+ <table class="form-table wpcron">
651
+ <tr>
652
+ <th scope="row"><?php _e( 'Scheduler type', 'backwpup' ); ?></th>
653
+ <td>
654
+ <fieldset>
655
+ <legend class="screen-reader-text"><span><?php _e( 'Scheduler type', 'backwpup' ) ?></span></legend>
656
+ <label for="idcronselect-basic"><input class="radio"
657
+ type="radio"<?php checked( 'basic', BackWPup_Option::get( $jobid, 'cronselect' ), TRUE ); ?>
658
+ name="cronselect" id="idcronselect-basic"
659
+ value="basic" /> <?php _e( 'basic', 'backwpup' ); ?></label><br/>
660
+ <label for="idcronselect-advanced"><input class="radio"
661
+ type="radio"<?php checked( 'advanced', BackWPup_Option::get( $jobid, 'cronselect' ), TRUE ); ?>
662
+ name="cronselect" id="idcronselect-advanced"
663
+ value="advanced" /> <?php _e( 'advanced', 'backwpup' ); ?></label><br/>
664
+ </fieldset>
665
+ </td>
666
+ </tr>
667
+ <?php
668
+
669
+ list( $cronstr[ 'minutes' ], $cronstr[ 'hours' ], $cronstr[ 'mday' ], $cronstr[ 'mon' ], $cronstr[ 'wday' ] ) = explode( ' ', BackWPup_Option::get( $jobid, 'cron' ), 5 );
670
+ if ( strstr( $cronstr[ 'minutes' ], '*/' ) )
671
+ $minutes = explode( '/', $cronstr[ 'minutes' ] );
672
+ else
673
+ $minutes = explode( ',', $cronstr[ 'minutes' ] );
674
+ if ( strstr( $cronstr[ 'hours' ], '*/' ) )
675
+ $hours = explode( '/', $cronstr[ 'hours' ] );
676
+ else
677
+ $hours = explode( ',', $cronstr[ 'hours' ] );
678
+ if ( strstr( $cronstr[ 'mday' ], '*/' ) )
679
+ $mday = explode( '/', $cronstr[ 'mday' ] );
680
+ else
681
+ $mday = explode( ',', $cronstr[ 'mday' ] );
682
+ if ( strstr( $cronstr[ 'mon' ], '*/' ) )
683
+ $mon = explode( '/', $cronstr[ 'mon' ] );
684
+ else
685
+ $mon = explode( ',', $cronstr[ 'mon' ] );
686
+ if ( strstr( $cronstr[ 'wday' ], '*/' ) )
687
+ $wday = explode( '/', $cronstr[ 'wday' ] );
688
+ else
689
+ $wday = explode( ',', $cronstr[ 'wday' ] );
690
+ ?>
691
+ <tr class="wpcronbasic"<?php if ( BackWPup_Option::get( $jobid, 'cronselect' ) != 'basic' ) echo ' style="display:none;"';?>>
692
+ <th scope="row"><?php _e( 'Scheduler', 'backwpup' ); ?></th>
693
+ <td>
694
+ <table id="wpcronbasic">
695
+ <tr>
696
+ <th>
697
+ <?php _e( 'Type', 'backwpup' ); ?>
698
+ </th>
699
+ <th>
700
+ </th>
701
+ <th>
702
+ <?php _e( 'Hour', 'backwpup' ); ?>
703
+ </th>
704
+ <th>
705
+ <?php _e( 'Minute', 'backwpup' ); ?>
706
+ </th>
707
+ </tr>
708
+ <tr>
709
+ <td><label for="idcronbtype-mon"><?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $mday[ 0 ] ), FALSE ) . ' name="cronbtype" id="idcronbtype-mon" value="mon" /> ' . __( 'monthly', 'backwpup' ); ?></label></td>
710
+ <td><select name="moncronmday"><?php for ( $i = 1; $i <= 31; $i ++ ) {
711
+ echo '<option ' . selected( in_array( "$i", $mday, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . __( 'on', 'backwpup' ) . ' ' . $i . '.</option>';
712
+ } ?></select></td>
713
+ <td><select name="moncronhours"><?php for ( $i = 0; $i < 24; $i ++ ) {
714
+ echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
715
+ } ?></select></td>
716
+ <td><select name="moncronminutes"><?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
717
+ echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
718
+ } ?></select></td>
719
+ </tr>
720
+ <tr>
721
+ <td><label for="idcronbtype-week"><?php echo '<input class="radio" type="radio"' . checked( TRUE, is_numeric( $wday[ 0 ] ), FALSE ) . ' name="cronbtype" id="idcronbtype-week" value="week" /> ' . __( 'weekly', 'backwpup' ); ?></label></td>
722
+ <td><select name="weekcronwday">
723
+ <?php echo '<option ' . selected( in_array( "0", $wday, TRUE ), TRUE, FALSE ) . ' value="0" />' . __( 'Sunday', 'backwpup' ) . '</option>';
724
+ echo '<option ' . selected( in_array( "1", $wday, TRUE ), TRUE, FALSE ) . ' value="1" />' . __( 'Monday', 'backwpup' ) . '</option>';
725
+ echo '<option ' . selected( in_array( "2", $wday, TRUE ), TRUE, FALSE ) . ' value="2" />' . __( 'Tuesday', 'backwpup' ) . '</option>';
726
+ echo '<option ' . selected( in_array( "3", $wday, TRUE ), TRUE, FALSE ) . ' value="3" />' . __( 'Wednesday', 'backwpup' ) . '</option>';
727
+ echo '<option ' . selected( in_array( "4", $wday, TRUE ), TRUE, FALSE ) . ' value="4" />' . __( 'Thursday', 'backwpup' ) . '</option>';
728
+ echo '<option ' . selected( in_array( "5", $wday, TRUE ), TRUE, FALSE ) . ' value="5" />' . __( 'Friday', 'backwpup' ) . '</option>';
729
+ echo '<option ' . selected( in_array( "6", $wday, TRUE ), TRUE, FALSE ) . ' value="6" />' . __( 'Saturday', 'backwpup' ) . '</option>'; ?>
730
+ </select></td>
731
+ <td><select name="weekcronhours"><?php for ( $i = 0; $i < 24; $i ++ ) {
732
+ echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
733
+ } ?></select></td>
734
+ <td><select name="weekcronminutes"><?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
735
+ echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
736
+ } ?></select></td>
737
+ </tr>
738
+ <tr>
739
+ <td><label for="idcronbtype-day"><?php echo '<input class="radio" type="radio"' . checked( "**", $mday[ 0 ] . $wday[ 0 ], FALSE ) . ' name="cronbtype" id="idcronbtype-day" value="day" /> ' . __( 'daily', 'backwpup' ); ?></label></td>
740
+ <td></td>
741
+ <td><select name="daycronhours"><?php for ( $i = 0; $i < 24; $i ++ ) {
742
+ echo '<option ' . selected( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
743
+ } ?></select></td>
744
+ <td><select name="daycronminutes"><?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
745
+ echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
746
+ } ?></select></td>
747
+ </tr>
748
+ <tr>
749
+ <td><label for="idcronbtype-hour"><?php echo '<input class="radio" type="radio"' . checked( "*", $hours[ 0 ], FALSE, FALSE ) . ' name="cronbtype" id="idcronbtype-hour" value="hour" /> ' . __( 'hourly', 'backwpup' ); ?></label></td>
750
+ <td></td>
751
+ <td></td>
752
+ <td><select name="hourcronminutes"><?php for ( $i = 0; $i < 60; $i = $i + 5 ) {
753
+ echo '<option ' . selected( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' value="' . $i . '" />' . $i . '</option>';
754
+ } ?></select></td>
755
+ </tr>
756
+ </table>
757
+ </td>
758
+ </tr>
759
+ <tr class="wpcronadvanced"<?php if ( BackWPup_Option::get( $jobid, 'cronselect' ) != 'advanced' ) echo ' style="display:none;"';?>>
760
+ <th scope="row"><?php _e( 'Scheduler', 'backwpup' ); ?></th>
761
+ <td>
762
+ <div id="cron-min-box">
763
+ <b><?php _e( 'Minutes:', 'backwpup' ); ?></b><br/>
764
+ <?php
765
+ echo '<label for="idcronminutes"><input class="checkbox" type="checkbox"' . checked( in_array( "*", $minutes, TRUE ), TRUE, FALSE ) . ' name="cronminutes[]" id="idcronminutes" value="*" /> ' . __( 'Any (*)', 'backwpup' ) . '</label><br />';
766
+ ?>
767
+ <div id="cron-min"><?php
768
+ for ( $i = 0; $i < 60; $i = $i + 5 ) {
769
+ echo '<label for="idcronminutes-' . $i . '"><input class="checkbox" type="checkbox"' . checked( in_array( "$i", $minutes, TRUE ), TRUE, FALSE ) . ' name="cronminutes[]" id="idcronminutes-' . $i . '" value="' . $i . '" /> ' . $i . '</label><br />';
770
+ }
771
+ ?>
772
+ </div>
773
+ </div>
774
+ <div id="cron-hour-box">
775
+ <b><?php _e( 'Hours:', 'backwpup' ); ?></b><br/>
776
+ <?php
777
+
778
+ echo '<label for="idcronhours"><input class="checkbox" type="checkbox"' . checked( in_array( "*", $hours, TRUE ), TRUE, FALSE ) . ' name="cronhours[]" for="idcronhours" value="*" /> ' . __( 'Any (*)', 'backwpup' ) . '</label><br />';
779
+ ?>
780
+ <div id="cron-hour"><?php
781
+ for ( $i = 0; $i < 24; $i ++ ) {
782
+ echo '<label for="idcronhours-' . $i . '"><input class="checkbox" type="checkbox"' . checked( in_array( "$i", $hours, TRUE ), TRUE, FALSE ) . ' name="cronhours[]" id="idcronhours-' . $i . '" value="' . $i . '" /> ' . $i . '</label><br />';
783
+ }
784
+ ?>
785
+ </div>
786
+ </div>
787
+ <div id="cron-day-box">
788
+ <b><?php _e( 'Day of Month:', 'backwpup' ); ?></b><br/>
789
+ <label for="idcronmday"><input class="checkbox" type="checkbox"<?php checked( in_array( "*", $mday, TRUE ), TRUE, TRUE ); ?>
790
+ name="cronmday[]" id="idcronmday" value="*"/> <?php _e( 'Any (*)', 'backwpup' ); ?></label>
791
+ <br/>
792
+
793
+ <div id="cron-day">
794
+ <?php
795
+ for ( $i = 1; $i <= 31; $i ++ ) {
796
+ echo '<label for="idcronmday-' . $i . '"><input class="checkbox" type="checkbox"' . checked( in_array( "$i", $mday, TRUE ), TRUE, FALSE ) . ' name="cronmday[]" id="idcronmday-' . $i . '" value="' . $i . '" /> ' . $i . '</label><br />';
797
+ }
798
+ ?>
799
+ </div>
800
+ </div>
801
+ <div id="cron-month-box">
802
+ <b><?php _e( 'Month:', 'backwpup' ); ?></b><br/>
803
+ <?php
804
+ echo '<label for="idcronmon"><input class="checkbox" type="checkbox"' . checked( in_array( "*", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon" value="*" /> ' . __( 'Any (*)', 'backwpup' ) . '</label><br />';
805
+ ?>
806
+ <div id="cron-month">
807
+ <?php
808
+ echo '<label for="idcronmon-1"><input class="checkbox" type="checkbox"' . checked( in_array( "1", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-1" value="1" /> ' . __( 'January', 'backwpup' ) . '</label><br />';
809
+ echo '<label for="idcronmon-2"><input class="checkbox" type="checkbox"' . checked( in_array( "2", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-2" value="2" /> ' . __( 'February', 'backwpup' ) . '</label><br />';
810
+ echo '<label for="idcronmon-3"><input class="checkbox" type="checkbox"' . checked( in_array( "3", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-3" value="3" /> ' . __( 'March', 'backwpup' ) . '</label><br />';
811
+ echo '<label for="idcronmon-4"><input class="checkbox" type="checkbox"' . checked( in_array( "4", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-4" value="4" /> ' . __( 'April', 'backwpup' ) . '</label><br />';
812
+ echo '<label for="idcronmon-5"><input class="checkbox" type="checkbox"' . checked( in_array( "5", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-5" value="5" /> ' . __( 'May', 'backwpup' ) . '</label><br />';
813
+ echo '<label for="idcronmon-6"><input class="checkbox" type="checkbox"' . checked( in_array( "6", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-6" value="6" /> ' . __( 'June', 'backwpup' ) . '</label><br />';
814
+ echo '<label for="idcronmon-7"><input class="checkbox" type="checkbox"' . checked( in_array( "7", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-7" value="7" /> ' . __( 'July', 'backwpup' ) . '</label><br />';
815
+ echo '<label for="idcronmon-8"><input class="checkbox" type="checkbox"' . checked( in_array( "8", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-8" value="8" /> ' . __( 'August', 'backwpup' ) . '</label><br />';
816
+ echo '<label for="idcronmon-9"><input class="checkbox" type="checkbox"' . checked( in_array( "9", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-9" value="9" /> ' . __( 'September', 'backwpup' ) . '</label><br />';
817
+ echo '<label for="idcronmon-10"><input class="checkbox" type="checkbox"' . checked( in_array( "10", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-10" value="10" /> ' . __( 'October', 'backwpup' ) . '</label><br />';
818
+ echo '<label for="idcronmon-11"><input class="checkbox" type="checkbox"' . checked( in_array( "11", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-11" value="11" /> ' . __( 'November', 'backwpup' ) . '</label><br />';
819
+ echo '<label for="idcronmon-12"><input class="checkbox" type="checkbox"' . checked( in_array( "12", $mon, TRUE ), TRUE, FALSE ) . ' name="cronmon[]" id="idcronmon-12" value="12" /> ' . __( 'December', 'backwpup' ) . '</label><br />';
820
+ ?>
821
+ </div>
822
+ </div>
823
+ <div id="cron-weekday-box">
824
+ <b><?php _e( 'Day of Week:', 'backwpup' ); ?></b><br/>
825
+ <?php
826
+ echo '<label for="idcronwday"><input class="checkbox" type="checkbox"' . checked( in_array( "*", $wday, TRUE ), TRUE, FALSE ) . ' name="cronwday[]" id="idcronwday" value="*" /> ' . __( 'Any (*)', 'backwpup' ) . '</label><br />';
827
+ ?>
828
+ <div id="cron-weekday">
829
+ <?php
830
+ echo '<label for="idcronwday-0"><input class="checkbox" type="checkbox"' . checked( in_array( "0", $wday, TRUE ), TRUE, FALSE ) . ' name="cronwday[]" id="idcronwday-0" value="0" /> ' . __( 'Sunday', 'backwpup' ) . '</label><br />';
831
+ echo '<label for="idcronwday-1"><input class="checkbox" type="checkbox"' . checked( in_array( "1", $wday, TRUE ), TRUE, FALSE ) . ' name="cronwday[]" id="idcronwday-1" value="1" /> ' . __( 'Monday', 'backwpup' ) . '</label><br />';
832
+ echo '<label for="idcronwday-2"><input class="checkbox" type="checkbox"' . checked( in_array( "2", $wday, TRUE ), TRUE, FALSE ) . ' name="cronwday[]" id="idcronwday-2" value="2" /> ' . __( 'Tuesday', 'backwpup' ) . '</label><br />';
833
+ echo '<label for="idcronwday-3"><input class="checkbox" type="checkbox"' . checked( in_array( "3", $wday, TRUE ), TRUE, FALSE ) . ' name="cronwday[]" id="idcronwday-3" value="3" /> ' . __( 'Wednesday', 'backwpup' ) . '</label><br />';
834
+ echo '<label for="idcronwday-4"><input class="checkbox" type="checkbox"' . checked( in_array( "4", $wday, TRUE ), TRUE, FALSE ) . ' name="cronwday[]" id="idcronwday-4" value="4" /> ' . __( 'Thursday', 'backwpup' ) . '</label><br />';
835
+ echo '<label for="idcronwday-5"><input class="checkbox" type="checkbox"' . checked( in_array( "5", $wday, TRUE ), TRUE, FALSE ) . ' name="cronwday[]" id="idcronwday-5" value="5" /> ' . __( 'Friday', 'backwpup' ) . '</label><br />';
836
+ echo '<label for="idcronwday-6"><input class="checkbox" type="checkbox"' . checked( in_array( "6", $wday, TRUE ), TRUE, FALSE ) . ' name="cronwday[]" id="idcronwday-6" value="6" /> ' . __( 'Saturday', 'backwpup' ) . '</label><br />';
837
+ ?>
838
+ </div>
839
+ </div>
840
+ <br class="clear"/>
841
+ </td>
842
+ </tr>
843
+ </table>
844
+ <?php
845
+ echo '</div>';
846
+ break;
847
+ default:
848
+ echo '<div class="table" id="info-tab-' . $_GET[ 'tab' ] . '">';
849
+ if ( strstr( $_GET[ 'tab' ], 'dest-' ) ) {
850
+ $dest_object = BackWPup::get_destination( str_replace( 'dest-', '', $_GET[ 'tab' ] ) );
851
+ $dest_object->edit_tab( $jobid );
852
+ }
853
+ if ( strstr( $_GET[ 'tab' ], 'jobtype-' ) ) {
854
+ $id = strtoupper( str_replace( 'jobtype-', '', $_GET[ 'tab' ] ) );
855
+ $job_types[ $id ]->edit_tab( $jobid );
856
+ }
857
+ echo '</div>';
858
+ }
859
+ echo '<br />';
860
+ submit_button( __( 'Save changes', 'backwpup' ), 'primary', 'save', FALSE, array( 'tabindex' => '2', 'accesskey' => 'p' ) );
861
+ echo '</form>';
862
+ ?>
863
+ </div>
864
+
865
+ <script type="text/javascript">
866
+ //<![CDATA[
867
+ jQuery(document).ready(function ($) {
868
+ // auto post if things changed
869
+ var changed = false;
870
+ $( '#editjob' ).change( function () {
871
+ changed = true;
872
+ });
873
+ $( '.nav-tab' ).click( function () {
874
+ if ( changed ) {
875
+ $( 'input[name="nexttab"]' ).val( $(this).data( "nexttab" ) );
876
+ $( '#editjob' ).submit();
877
+ return false;
878
+ }
879
+ });
880
+ <?php
881
+ //add inline js
882
+ if ( strstr( $_GET[ 'tab' ], 'dest-' ) ) {
883
+ $dest_object = BackWPup::get_destination( str_replace( 'dest-', '', $_GET[ 'tab' ] ) );
884
+ $dest_object->edit_inline_js();
885
+ }
886
+ if ( strstr( $_GET[ 'tab' ], 'jobtype-' ) ) {
887
+ $id = strtoupper( str_replace( 'jobtype-', '', $_GET[ 'tab' ] ) );
888
+ $job_types[ $id ]->edit_inline_js();
889
+ }
890
+ ?>
891
+ });
892
+ //]]>
893
+ </script>
894
+ <?php
895
+ }
896
+ }
897
+
inc/class-page-jobs.php CHANGED
@@ -353,21 +353,23 @@ class BackWPup_Page_Jobs extends WP_List_Table {
353
  //only start job if messages empty
354
  $log_messages = BackWPup_Admin::get_messages();
355
  if ( empty ( $log_messages ) ) {
356
- BackWPup_Admin::message( sprintf( __( 'Job "%s" started.', 'backwpup' ), esc_attr( BackWPup_Option::get( $_GET[ 'jobid' ], 'name' ) ) ) );
357
  BackWPup_Job::get_jobrun_url( 'runnow', $_GET[ 'jobid' ] );
358
  usleep( 250000 ); //wait a quarter second
 
359
  //sleep as long as job not started
360
  $i=0;
361
- $job_object = BackWPup_Job::get_working_data();
362
- while ( ! is_object( $job_object ) && empty( $job_object->logfile ) ) {
363
  usleep( 250000 ); //wait a quarter second for next try
364
- clearstatcache();
365
- $job_object = BackWPup_Job::get_working_data();
366
  //wait maximal 10 sec.
367
- if ( $i >= 40 )
368
- break;
 
 
369
  $i++;
370
  }
 
371
  }
372
  }
373
  break;
@@ -407,9 +409,12 @@ class BackWPup_Page_Jobs extends WP_List_Table {
407
  }
408
 
409
  #showworking {
410
- white-space: pre;
411
  display: block;
412
  width: 100%;
 
 
 
413
  }
414
  #runningjob {
415
  padding:10px;
@@ -430,32 +435,7 @@ class BackWPup_Page_Jobs extends WP_List_Table {
430
  right: 10px;
431
  bottom: 0;
432
  }
433
- /*
434
- a#showworkingbutton {
435
- float: left;
436
- padding: 10px;
437
- font-size: 12px;
438
- font-family: sans-serif,"Arial";
439
- text-decoration :none;
440
- background-color: #93b509;
441
- color: #fff;
442
- border: none;
443
- }
444
- a#abortbutton, a#showworkingclose {
445
- float: left;
446
- margin-left: 10px;
447
- padding: 10px;
448
- font-size: 12px;
449
- font-family: sans-serif,"Arial";
450
- text-decoration: none;
451
- background-color: #cd1212;
452
- color: #fff;
453
- border: none;
454
- }
455
- */
456
- #backwpup-page samp {
457
- font-family: Consolas, Monaco, monospace;
458
- }
459
  .progressbar {
460
  margin-top: 20px;
461
  height: auto;
@@ -466,9 +446,9 @@ class BackWPup_Page_Jobs extends WP_List_Table {
466
  text-align: center;
467
  margin-bottom: 20px;
468
  }
469
- #backwpup-page #lastmsg samp,
470
- #backwpup-page #onstep samp,
471
- #backwpup-page #lasterrormsg samp {
472
  font-family: "Open Sans", sans-serif;
473
  }
474
  .bwpu-progress {
@@ -544,7 +524,7 @@ class BackWPup_Page_Jobs extends WP_List_Table {
544
  <input type="hidden" name="logpos" id="logpos" value="<?php echo strlen( $logfiledata ); ?>">
545
  <div id="lasterrormsg"></div>
546
  <div class="progressbar"><div id="progressstep" class="bwpu-progress" style="width:<?php echo $job_object->step_percent; ?>%;"><?php echo $job_object->step_percent; ?>%</div></div>
547
- <div id="onstep"><samp><?php echo $job_object->steps_data[ $job_object->step_working ][ 'NAME' ]; ?></samp></div>
548
  <div class="progressbar"><div id="progresssteps" class="bwpu-progress" style="width:<?php echo $job_object->substep_percent; ?>%;"><?php echo $job_object->substep_percent; ?>%</div></div>
549
  <div id="lastmsg"><?php echo $job_object->lastmsg; ?></div>
550
  <div id="tb-showworking" style="display:none;">
@@ -616,7 +596,7 @@ class BackWPup_Page_Jobs extends WP_List_Table {
616
  $('#runtime').replaceWith('<span id="runtime">' + rundata.running_time + '</span>');
617
  }
618
  if ( '' != rundata.onstep ) {
619
- $('#onstep').replaceWith('<div id="onstep"><samp>' + rundata.on_step + '</samp></div>');
620
  }
621
  if ( '' != rundata.last_msg ) {
622
  $('#lastmsg').replaceWith('<div id="lastmsg">' + rundata.last_msg + '</div>');
@@ -717,8 +697,7 @@ class BackWPup_Page_Jobs extends WP_List_Table {
717
 
718
  $length = strlen( $logfiledata ) - ( strlen( $logfiledata ) - $endpos ) - $startpos;
719
 
720
- @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), TRUE );
721
- $json = json_encode( array(
722
  'log_pos' => strlen( $logfiledata ) + $logpos,
723
  'log_text' => substr( $logfiledata, $startpos, $length ),
724
  'warning_count' => $warnings,
@@ -731,7 +710,6 @@ class BackWPup_Page_Jobs extends WP_List_Table {
731
  'sub_step_percent'=> $substep_percent,
732
  'job_done' => $done
733
  ) );
734
- die( $json );
735
  }
736
 
737
  }
353
  //only start job if messages empty
354
  $log_messages = BackWPup_Admin::get_messages();
355
  if ( empty ( $log_messages ) ) {
356
+ $old_log_file = BackWPup_Option::get( $_GET[ 'jobid' ], 'logfile' );
357
  BackWPup_Job::get_jobrun_url( 'runnow', $_GET[ 'jobid' ] );
358
  usleep( 250000 ); //wait a quarter second
359
+ $new_log_file = BackWPup_Option::get( $_GET[ 'jobid' ], 'logfile', NULL, FALSE );
360
  //sleep as long as job not started
361
  $i=0;
362
+ while ( $old_log_file == $new_log_file ) {
 
363
  usleep( 250000 ); //wait a quarter second for next try
364
+ $new_log_file = BackWPup_Option::get( $_GET[ 'jobid' ], 'logfile', NULL, FALSE );
 
365
  //wait maximal 10 sec.
366
+ if ( $i >= 40 ) {
367
+ BackWPup_Admin::message( sprintf( __( 'Job “%s” has started, but not responded for 10 seconds.', 'backwpup' ), esc_attr( BackWPup_Option::get( $_GET[ 'jobid' ], 'name' ) ) ), TRUE );
368
+ break 2;
369
+ }
370
  $i++;
371
  }
372
+ BackWPup_Admin::message( sprintf( __( 'Job "%s" started.', 'backwpup' ), esc_attr( BackWPup_Option::get( $_GET[ 'jobid' ], 'name' ) ) ) );
373
  }
374
  }
375
  break;
409
  }
410
 
411
  #showworking {
412
+ white-space:nowrap;
413
  display: block;
414
  width: 100%;
415
+ font-family:monospace;
416
+ font-size:12px;
417
+ line-height:15px;
418
  }
419
  #runningjob {
420
  padding:10px;
435
  right: 10px;
436
  bottom: 0;
437
  }
438
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
439
  .progressbar {
440
  margin-top: 20px;
441
  height: auto;
446
  text-align: center;
447
  margin-bottom: 20px;
448
  }
449
+ #backwpup-page #lastmsg,
450
+ #backwpup-page #onstep,
451
+ #backwpup-page #lasterrormsg {
452
  font-family: "Open Sans", sans-serif;
453
  }
454
  .bwpu-progress {
524
  <input type="hidden" name="logpos" id="logpos" value="<?php echo strlen( $logfiledata ); ?>">
525
  <div id="lasterrormsg"></div>
526
  <div class="progressbar"><div id="progressstep" class="bwpu-progress" style="width:<?php echo $job_object->step_percent; ?>%;"><?php echo $job_object->step_percent; ?>%</div></div>
527
+ <div id="onstep"><?php echo $job_object->steps_data[ $job_object->step_working ][ 'NAME' ]; ?></div>
528
  <div class="progressbar"><div id="progresssteps" class="bwpu-progress" style="width:<?php echo $job_object->substep_percent; ?>%;"><?php echo $job_object->substep_percent; ?>%</div></div>
529
  <div id="lastmsg"><?php echo $job_object->lastmsg; ?></div>
530
  <div id="tb-showworking" style="display:none;">
596
  $('#runtime').replaceWith('<span id="runtime">' + rundata.running_time + '</span>');
597
  }
598
  if ( '' != rundata.onstep ) {
599
+ $('#onstep').replaceWith('<div id="onstep">' + rundata.on_step + '</div>');
600
  }
601
  if ( '' != rundata.last_msg ) {
602
  $('#lastmsg').replaceWith('<div id="lastmsg">' + rundata.last_msg + '</div>');
697
 
698
  $length = strlen( $logfiledata ) - ( strlen( $logfiledata ) - $endpos ) - $startpos;
699
 
700
+ wp_send_json( array(
 
701
  'log_pos' => strlen( $logfiledata ) + $logpos,
702
  'log_text' => substr( $logfiledata, $startpos, $length ),
703
  'warning_count' => $warnings,
710
  'sub_step_percent'=> $substep_percent,
711
  'job_done' => $done
712
  ) );
 
713
  }
714
 
715
  }
inc/class-page-logs.php CHANGED
@@ -1,400 +1,400 @@
1
- <?php
2
- /**
3
- * Class for BackWPup logs display page
4
- */
5
- class BackWPup_Page_Logs extends WP_List_Table {
6
-
7
- private static $listtable = NULL;
8
- private $job_types = NULL;
9
-
10
- /**
11
- *
12
- */
13
- function __construct() {
14
-
15
- parent::__construct( array(
16
- 'plural' => 'logs',
17
- 'singular' => 'log',
18
- 'ajax' => TRUE
19
- ) );
20
- }
21
-
22
- /**
23
- * @return bool
24
- */
25
- function ajax_user_can() {
26
-
27
- return current_user_can( 'backwpup_logs' );
28
- }
29
-
30
- /**
31
- *
32
- */
33
- function prepare_items() {
34
-
35
- $this->job_types = BackWPup::get_job_types();
36
-
37
- $per_page = $this->get_items_per_page( 'backwpuplogs_per_page' );
38
- if ( empty( $per_page ) || $per_page < 1 )
39
- $per_page = 20;
40
-
41
- //load logs
42
- $logfiles = array();
43
- if ( $dir = @opendir( get_site_option( 'backwpup_cfg_logfolder' ) ) ) {
44
- while ( ( $file = readdir( $dir ) ) !== FALSE ) {
45
- if ( is_readable( get_site_option( 'backwpup_cfg_logfolder' ) . '/' . $file ) && is_file( get_site_option( 'backwpup_cfg_logfolder' ) . '/' . $file ) && FALSE !== strpos( $file, 'backwpup_log_' ) && FALSE !== strpos( $file, '.html' ) )
46
- $logfiles[ filemtime( get_site_option( 'backwpup_cfg_logfolder' ) . '/' . $file ) ] = $file;
47
- }
48
- closedir( $dir );
49
- }
50
- //ordering
51
- $order = isset( $_GET[ 'order' ] ) ? $_GET[ 'order' ] : 'desc';
52
- $orderby = isset( $_GET[ 'orderby' ] ) ? $_GET[ 'orderby' ] : 'time';
53
- if ( $orderby == 'time' ) {
54
- if ( $order == 'asc' )
55
- ksort( $logfiles, SORT_NUMERIC );
56
- else
57
- krsort ( $logfiles, SORT_NUMERIC );
58
- }
59
- //by page
60
- $start = intval( ( $this->get_pagenum() - 1 ) * $per_page );
61
- $end = $start + $per_page;
62
- if ( $end > count( $logfiles ) )
63
- $end = count( $logfiles );
64
-
65
- $this->items = array();
66
- $i = -1;
67
- foreach ( $logfiles as $mtime => $logfile ) {
68
- $i++;
69
- if ( $i < $start )
70
- continue;
71
- if ( $i >= $end )
72
- break;
73
- $this->items[$mtime] = BackWPup_Job::read_logheader( get_site_option( 'backwpup_cfg_logfolder' ) . '/' . $logfile );
74
- $this->items[$mtime]['file'] = $logfile;
75
-
76
- }
77
-
78
- $this->set_pagination_args( array(
79
- 'total_items' => count( $logfiles ),
80
- 'per_page' => $per_page,
81
- 'orderby' => $orderby,
82
- 'order' => $order
83
- ) );
84
-
85
- }
86
-
87
- /**
88
- * @return array
89
- */
90
- function get_sortable_columns() {
91
-
92
- return array(
93
- 'time' => array( 'time', FALSE ),
94
- );
95
- }
96
-
97
- /**
98
- *
99
- */
100
- function no_items() {
101
-
102
- _e( 'No Logs.', 'backwpup' );
103
- }
104
-
105
- /**
106
- * @return array
107
- */
108
- function get_bulk_actions() {
109
-
110
- if ( ! $this->has_items() )
111
- return array ();
112
-
113
- $actions = array();
114
- $actions[ 'delete' ] = __( 'Delete', 'backwpup' );
115
-
116
- return $actions;
117
- }
118
-
119
- /**
120
- * @return array
121
- */
122
- function get_columns() {
123
- $posts_columns = array();
124
- $posts_columns[ 'cb' ] = '<input type="checkbox" />';
125
- $posts_columns[ 'time' ] = __( 'Time', 'backwpup' );
126
- $posts_columns[ 'job' ] = __( 'Job', 'backwpup' );
127
- $posts_columns[ 'status' ] = __( 'Status', 'backwpup' );
128
- $posts_columns[ 'type' ] = __( 'Type', 'backwpup' );
129
- $posts_columns[ 'size' ] = __( 'Size', 'backwpup' );
130
- $posts_columns[ 'runtime' ] = __( 'Runtime', 'backwpup' );
131
-
132
- return $posts_columns;
133
- }
134
-
135
- /**
136
- * The cb Column
137
- *
138
- * @param $item
139
- * @return string
140
- */
141
- function column_cb( $item ) {
142
-
143
- return '<input type="checkbox" name="logfiles[]" value="' .esc_attr( $item['file'] ) . '" />';
144
- }
145
-
146
- /**
147
- * The job id Column
148
- *
149
- * @param $item
150
- * @return string
151
- */
152
- function column_time( $item ) {
153
- $r = sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ) , $item[ 'logtime' ], TRUE ), date_i18n( get_option( 'time_format' ), $item[ 'logtime' ], TRUE ) );
154
- return $r;
155
- }
156
-
157
- /**
158
- * The type Column
159
- *
160
- * @param $item
161
- * @return string
162
- */
163
- function column_type( $item ) {
164
-
165
- $r = '';
166
- if ( $types = explode( '+', $item[ 'type' ] ) ) {
167
- foreach ( $types as $type ) {
168
- if ( isset( $this->job_types[ $type ] ) ) {
169
- $r .= $this->job_types[ $type ]->info[ 'name' ] . '<br />';
170
- }
171
- else {
172
- $r .= $type . '<br />';
173
- }
174
- }
175
- }
176
-
177
- return $r;
178
- }
179
-
180
- /**
181
- * The log Column
182
- *
183
- * @param $item
184
- * @return string
185
- */
186
- function column_job( $item ) {
187
-
188
- $r = "<strong><a class=\"thickbox\" href=\"" . admin_url( 'admin-ajax.php' ) . '?&action=backwpup_view_log&logfile=' . $item['file'] .'&_ajax_nonce=' . wp_create_nonce( 'view-logs' ) . "&amp;TB_iframe=true&amp;width=640&amp;height=440\" title=\"" . esc_attr( $item['file'] ) . "\n" . sprintf( __( 'Job ID: %d', 'backwpup' ), $item[ 'jobid' ] ) . "\">" . esc_attr( ! empty( $item[ 'name' ] ) ? $item[ 'name' ] : $item['file'] ) . "</a></strong>";
189
- $actions = array();
190
- $actions[ 'view' ] = '<a class="thickbox" href="' . admin_url( 'admin-ajax.php' ) . '?&action=backwpup_view_log&logfile=' . $item['file'] .'&_ajax_nonce=' . wp_create_nonce( 'view-logs' ) . '&amp;TB_iframe=true&amp;width=640&amp;height=440" title="' . $item['file'] . '">' . __( 'View', 'backwpup' ) . '</a>';
191
- if ( current_user_can( 'backwpup_logs_delete' ) )
192
- $actions[ 'delete' ] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpuplogs&action=delete&paged=' . $this->get_pagenum() . '&logfiles[]=' . $item['file'], 'bulk-logs' ) . "\" onclick=\"return showNotice.warn();\">" . __( 'Delete', 'backwpup' ) . "</a>";
193
- $actions[ 'download' ] = "<a href=\"" . wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpuplogs&action=download&file=' . $item['file'], 'download-backup_' . $item['file'] ) . "\">" . __( 'Download', 'backwpup' ) . "</a>";
194
- $r .= $this->row_actions( $actions );
195
-
196
- return $r;
197
- }
198
-
199
- /**
200
- * The status Column
201
- *
202
- * @param $item
203
- * @return string
204
- */
205
- function column_status( $item ) {
206
-
207
- $r = '';
208
- if ( $item[ 'errors' ] > 0 )
209
- $r .= str_replace( '%d', $item[ 'errors' ], '<span style="color:red;font-weight:bold;">' . _n( "1 ERROR", "%d ERRORS", $item[ 'errors' ], 'backwpup' ) . '</span><br />' );
210
- if ( $item[ 'warnings' ] > 0 )
211
- $r .= str_replace( '%d', $item[ 'warnings' ], '<span style="color:#e66f00;font-weight:bold;">' . _n( "1 WARNING", "%d WARNINGS", $item[ 'warnings' ], 'backwpup' ) . '</span><br />' );
212
- if ( $item[ 'errors' ] == 0 && $item[ 'warnings' ] == 0 )
213
- $r .= '<span style="color:green;font-weight:bold;">' . __( 'O.K.', 'backwpup' ) . '</span>';
214
-
215
- return $r;
216
- }
217
-
218
-
219
- /**
220
- * The size Column
221
- *
222
- * @param $item
223
- * @return string
224
- */
225
- function column_size( $item ) {
226
-
227
- if ( ! empty( $item[ 'backupfilesize' ] ) )
228
- return size_format( $item[ 'backupfilesize' ], 2 );
229
- else
230
- return __( 'Log only', 'backwpup' );
231
- }
232
-
233
- /**
234
- * The runtime Column
235
- *
236
- * @param $item
237
- * @return string
238
- */
239
- function column_runtime( $item ) {
240
-
241
- return $item[ 'runtime' ] . ' ' . __( 'seconds', 'backwpup' );
242
- }
243
-
244
- /**
245
- *
246
- */
247
- public static function load() {
248
-
249
- //Create Table
250
- self::$listtable = new BackWPup_Page_Logs;
251
-
252
- switch ( self::$listtable->current_action() ) {
253
- case 'delete':
254
- if ( ! current_user_can( 'backwpup_logs_delete' ) )
255
- break;
256
- if ( is_array( $_GET[ 'logfiles' ] ) ) {
257
- check_admin_referer( 'bulk-logs' );
258
- $num = 0;
259
- foreach ( $_GET[ 'logfiles' ] as $logfile ) {
260
- if ( is_writeable( get_site_option( 'backwpup_cfg_logfolder' ) . $logfile ) && ! is_dir( get_site_option( 'backwpup_cfg_logfolder' ) . $logfile ) && ! is_link( get_site_option( 'backwpup_cfg_logfolder' ) . $logfile ) )
261
- unlink( get_site_option( 'backwpup_cfg_logfolder' ) . $logfile );
262
- $num ++;
263
- }
264
- }
265
- break;
266
- case 'download': //Download Log
267
- if ( ! current_user_can( 'backwpup_logs' ) )
268
- break;
269
- check_admin_referer( 'download-backup_' . $_GET[ 'file' ] );
270
- if ( is_readable( get_site_option( 'backwpup_cfg_logfolder' ) . $_GET[ 'file' ] ) && ! is_dir( get_site_option( 'backwpup_cfg_logfolder' ) . $_GET[ 'file' ] ) && !is_link( get_site_option( 'backwpup_cfg_logfolder' ) . $_GET[ 'file' ] ) ) {
271
- header( "Pragma: public" );
272
- header( "Expires: 0" );
273
- header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
274
- header( "Content-Type: application/force-download" );
275
- header( "Content-Disposition: attachment; filename=" . get_site_option( 'backwpup_cfg_logfolder' ) . $_GET[ 'file' ] . ";" );
276
- header( "Content-Transfer-Encoding: binary" );
277
- header( "Content-Length: " . filesize( get_site_option( 'backwpup_cfg_logfolder' ) . $_GET[ 'file' ] ) );
278
- @readfile( get_site_option( 'backwpup_cfg_logfolder' ) . $_GET[ 'file' ] );
279
- die();
280
- }
281
- else {
282
- header( 'HTTP/1.0 404 Not Found' );
283
- die();
284
- }
285
- break;
286
- }
287
-
288
-
289
- //Save per page
290
- if ( isset( $_POST[ 'screen-options-apply' ] ) && isset( $_POST[ 'wp_screen_options' ][ 'option' ] ) && isset( $_POST[ 'wp_screen_options' ][ 'value' ] ) && $_POST[ 'wp_screen_options' ][ 'option' ] == 'backwpuplogs_per_page' ) {
291
- check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
292
- global $current_user;
293
- if ( $_POST[ 'wp_screen_options' ][ 'value' ] > 0 && $_POST[ 'wp_screen_options' ][ 'value' ] < 1000 ) {
294
- update_user_option( $current_user->ID, 'backwpuplogs_per_page', (int)$_POST[ 'wp_screen_options' ][ 'value' ] );
295
- wp_redirect( remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() ) );
296
- exit;
297
- }
298
- }
299
-
300
- add_screen_option( 'per_page', array(
301
- 'label' => __( 'Logs', 'backwpup' ),
302
- 'default' => 20,
303
- 'option' => 'backwpuplogs_per_page'
304
- ) );
305
-
306
- self::$listtable->prepare_items();
307
- }
308
-
309
- /**
310
- *
311
- * Output css
312
- *
313
- * @return void
314
- */
315
- public static function admin_print_styles() {
316
-
317
- ?>
318
- <style type="text/css" media="screen">
319
- .column-time {
320
- text-align: center;
321
- }
322
-
323
- .column-runtime, .column-time, .column-size {
324
- width: 8%;
325
- }
326
-
327
- .column-status {
328
- width: 10%;
329
- }
330
-
331
- .column-type {
332
- width: 15%;
333
- }
334
- @media screen and (max-width: 782px) {
335
- .column-type, .column-runtime, .column-size {
336
- display: none;
337
- }
338
- .column-time, .column-status {
339
- width: 18%;
340
- }
341
- }
342
- </style>
343
- <?php
344
- }
345
-
346
- /**
347
- *
348
- * Output js
349
- *
350
- * @return void
351
- */
352
- public static function admin_print_scripts() {
353
-
354
- wp_enqueue_script( 'backwpupgeneral' );
355
- }
356
-
357
- /**
358
- * Display the page content
359
- */
360
- public static function page() {
361
-
362
- ?>
363
- <div class="wrap" id="backwpup-page">
364
- <h2><span id="backwpup-page-icon">&nbsp;</span><?php echo esc_html( sprintf( __( '%s Logs', 'backwpup' ), BackWPup::get_plugin_data( 'name' ) ) ); ?></h2>
365
- <?php BackWPup_Admin::display_messages(); ?>
366
- <form id="posts-filter" action="" method="get">
367
- <input type="hidden" name="page" value="backwpuplogs" />
368
- <?php self::$listtable->display(); ?>
369
- <div id="ajax-response"></div>
370
- </form>
371
- </div>
372
- <?php
373
- }
374
-
375
- /**
376
- * For displaying log files with ajax
377
- */
378
- public static function ajax_view_log() {
379
-
380
- if ( ! current_user_can( 'backwpup_logs' ) )
381
- die( -1 );
382
- check_ajax_referer( 'view-logs' );
383
- $log_file = get_site_option( 'backwpup_cfg_logfolder' ) . $_GET[ 'logfile' ];
384
- if ( ! is_readable( $log_file ) && ! is_readable( $log_file . '.gz' ) && ! is_readable( $log_file . '.bz2' ) )
385
- die( -1 );
386
- //change file end if not html helps if log file compression is on
387
- if ( ! file_exists( $log_file ) && file_exists( $log_file . '.gz' ) )
388
- $log_file = $log_file . '.gz';
389
- if ( ! file_exists( $log_file ) && file_exists( $log_file . '.bz2' ) )
390
- $log_file = $log_file . '.bz2';
391
- //output file
392
- if ( '.gz' == substr( $log_file, -3 ) )
393
- echo file_get_contents( 'compress.zlib://' .$log_file, FALSE );
394
- else
395
- echo file_get_contents( $log_file, FALSE );
396
- die();
397
- }
398
-
399
- }
400
-
1
+ <?php
2
+ /**
3
+ * Class for BackWPup logs display page
4
+ */
5
+ class BackWPup_Page_Logs extends WP_List_Table {
6
+
7
+ private static $listtable = NULL;
8
+ private $job_types = NULL;
9
+
10
+ /**
11
+ *
12
+ */
13
+ function __construct() {
14
+
15
+ parent::__construct( array(
16
+ 'plural' => 'logs',
17
+ 'singular' => 'log',
18
+ 'ajax' => TRUE
19
+ ) );
20
+ }
21
+
22
+ /**
23
+ * @return bool
24
+ */
25
+ function ajax_user_can() {
26
+
27
+ return current_user_can( 'backwpup_logs' );
28
+ }
29
+
30
+ /**
31
+ *
32
+ */
33
+ function prepare_items() {
34
+
35
+ $this->job_types = BackWPup::get_job_types();
36
+
37
+ $per_page = $this->get_items_per_page( 'backwpuplogs_per_page' );
38
+ if ( empty( $per_page ) || $per_page < 1 )
39
+ $per_page = 20;
40
+
41
+ //load logs
42
+ $logfiles = array();
43
+ if ( $dir = @opendir( get_site_option( 'backwpup_cfg_logfolder' ) ) ) {
44
+ while ( ( $file = readdir( $dir ) ) !== FALSE ) {
45
+ if ( is_readable( get_site_option( 'backwpup_cfg_logfolder' ) . '/' . $file ) && is_file( get_site_option( 'backwpup_cfg_logfolder' ) . '/' . $file ) && FALSE !== strpos( $file, 'backwpup_log_' ) && FALSE !== strpos( $file, '.html' ) )
46
+ $logfiles[ filemtime( get_site_option( 'backwpup_cfg_logfolder' ) . '/' . $file ) ] = $file;
47
+ }
48
+ closedir( $dir );
49
+ }
50
+ //ordering
51
+ $order = isset( $_GET[ 'order' ] ) ? $_GET[ 'order' ] : 'desc';
52
+ $orderby = isset( $_GET[ 'orderby' ] ) ? $_GET[ 'orderby' ] : 'time';
53
+ if ( $orderby == 'time' ) {
54
+ if ( $order == 'asc' )
55
+ ksort( $logfiles, SORT_NUMERIC );
56
+ else
57
+ krsort ( $logfiles, SORT_NUMERIC );
58
+ }
59
+ //by page
60
+ $start = intval( ( $this->get_pagenum() - 1 ) * $per_page );
61
+ $end = $start + $per_page;
62
+ if ( $end > count( $logfiles ) )
63
+ $end = count( $logfiles );
64
+
65
+ $this->items = array();
66
+ $i = -1;
67
+ foreach ( $logfiles as $mtime => $logfile ) {
68
+ $i++;
69
+ if ( $i < $start )
70
+ continue;
71
+ if ( $i >= $end )
72
+ break;
73
+ $this->items[$mtime] = BackWPup_Job::read_logheader( get_site_option( 'backwpup_cfg_logfolder' ) . '/' . $logfile );
74
+ $this->items[$mtime]['file'] = $logfile;
75
+
76
+ }
77
+
78
+ $this->set_pagination_args( array(
79
+ 'total_items' => count( $logfiles ),
80
+ 'per_page' => $per_page,
81
+ 'orderby' => $orderby,
82
+ 'order' => $order
83
+ ) );
84
+
85
+ }
86
+
87
+ /**
88
+ * @return array
89
+ */
90
+ function get_sortable_columns() {
91
+
92
+ return array(
93
+ 'time' => array( 'time', FALSE ),
94
+ );
95
+ }
96
+
97
+ /**
98
+ *
99
+ */
100
+ function no_items() {
101
+
102
+ _e( 'No Logs.', 'backwpup' );
103
+ }
104
+
105
+ /**
106
+ * @return array
107
+ */
108
+ function get_bulk_actions() {
109
+
110
+ if ( ! $this->has_items() )
111
+ return array ();
112
+
113
+ $actions = array();
114
+ $actions[ 'delete' ] = __( 'Delete', 'backwpup' );
115
+
116
+ return $actions;
117
+ }
118
+
119
+ /**
120
+ * @return array
121
+ */
122
+ function get_columns() {
123
+ $posts_columns = array();
124
+ $posts_columns[ 'cb' ] = '<input type="checkbox" />';
125
+ $posts_columns[ 'time' ] = __( 'Time', 'backwpup' );
126
+ $posts_columns[ 'job' ] = __( 'Job', 'backwpup' );
127
+ $posts_columns[ 'status' ] = __( 'Status', 'backwpup' );
128
+ $posts_columns[ 'type' ] = __( 'Type', 'backwpup' );
129
+ $posts_columns[ 'size' ] = __( 'Size', 'backwpup' );
130
+ $posts_columns[ 'runtime' ] = __( 'Runtime', 'backwpup' );
131
+
132
+ return $posts_columns;
133
+ }
134
+
135
+ /**
136
+ * The cb Column
137
+ *
138
+ * @param $item
139
+ * @return string
140
+ */
141
+ function column_cb( $item ) {
142
+
143
+ return '<input type="checkbox" name="logfiles[]" value="' .esc_attr( $item['file'] ) . '" />';
144
+ }
145
+
146
+ /**
147
+ * The job id Column
148
+ *
149
+ * @param $item
150
+ * @return string
151
+ */
152
+ function column_time( $item ) {
153
+ $r = sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ) , $item[ 'logtime' ], TRUE ), date_i18n( get_option( 'time_format' ), $item[ 'logtime' ], TRUE ) );
154
+ return $r;
155
+ }
156
+
157
+ /**
158
+ * The type Column
159
+ *
160
+ * @param $item
161
+ * @return string
162
+ */
163
+ function column_type( $item ) {
164
+
165
+ $r = '';
166
+ if ( $types = explode( '+', $item[ 'type' ] ) ) {
167
+ foreach ( $types as $type ) {
168
+ if ( isset( $this->job_types[ $type ] ) ) {
169
+ $r .= $this->job_types[ $type ]->info[ 'name' ] . '<br />';
170
+ }
171
+ else {
172
+ $r .= $type . '<br />';
173
+ }
174
+ }
175
+ }
176
+
177
+ return $r;
178
+ }
179
+
180
+ /**
181
+ * The log Column
182
+ *
183
+ * @param $item
184
+ * @return string
185
+ */
186
+ function column_job( $item ) {
187
+
188
+ $r = "<strong><a class=\"thickbox\" href=\"" . admin_url( 'admin-ajax.php' ) . '?&action=backwpup_view_log&logfile=' . $item['file'] .'&_ajax_nonce=' . wp_create_nonce( 'view-logs' ) . "&amp;TB_iframe=true&amp;width=640&amp;height=440\" title=\"" . esc_attr( $item['file'] ) . "\n" . sprintf( __( 'Job ID: %d', 'backwpup' ), $item[ 'jobid' ] ) . "\">" . esc_attr( ! empty( $item[ 'name' ] ) ? $item[ 'name' ] : $item['file'] ) . "</a></strong>";
189
+ $actions = array();
190
+ $actions[ 'view' ] = '<a class="thickbox" href="' . admin_url( 'admin-ajax.php' ) . '?&action=backwpup_view_log&logfile=' . $item['file'] .'&_ajax_nonce=' . wp_create_nonce( 'view-logs' ) . '&amp;TB_iframe=true&amp;width=640&amp;height=440" title="' . $item['file'] . '">' . __( 'View', 'backwpup' ) . '</a>';
191
+ if ( current_user_can( 'backwpup_logs_delete' ) )
192
+ $actions[ 'delete' ] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpuplogs&action=delete&paged=' . $this->get_pagenum() . '&logfiles[]=' . $item['file'], 'bulk-logs' ) . "\" onclick=\"return showNotice.warn();\">" . __( 'Delete', 'backwpup' ) . "</a>";
193
+ $actions[ 'download' ] = "<a href=\"" . wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpuplogs&action=download&file=' . $item['file'], 'download-backup_' . $item['file'] ) . "\">" . __( 'Download', 'backwpup' ) . "</a>";
194
+ $r .= $this->row_actions( $actions );
195
+
196
+ return $r;
197
+ }
198
+
199
+ /**
200
+ * The status Column
201
+ *
202
+ * @param $item
203
+ * @return string
204
+ */
205
+ function column_status( $item ) {
206
+
207
+ $r = '';
208
+ if ( $item[ 'errors' ] > 0 )
209
+ $r .= str_replace( '%d', $item[ 'errors' ], '<span style="color:red;font-weight:bold;">' . _n( "1 ERROR", "%d ERRORS", $item[ 'errors' ], 'backwpup' ) . '</span><br />' );
210
+ if ( $item[ 'warnings' ] > 0 )
211
+ $r .= str_replace( '%d', $item[ 'warnings' ], '<span style="color:#e66f00;font-weight:bold;">' . _n( "1 WARNING", "%d WARNINGS", $item[ 'warnings' ], 'backwpup' ) . '</span><br />' );
212
+ if ( $item[ 'errors' ] == 0 && $item[ 'warnings' ] == 0 )
213
+ $r .= '<span style="color:green;font-weight:bold;">' . __( 'O.K.', 'backwpup' ) . '</span>';
214
+
215
+ return $r;
216
+ }
217
+
218
+
219
+ /**
220
+ * The size Column
221
+ *
222
+ * @param $item
223
+ * @return string
224
+ */
225
+ function column_size( $item ) {
226
+
227
+ if ( ! empty( $item[ 'backupfilesize' ] ) )
228
+ return size_format( $item[ 'backupfilesize' ], 2 );
229
+ else
230
+ return __( 'Log only', 'backwpup' );
231
+ }
232
+
233
+ /**
234
+ * The runtime Column
235
+ *
236
+ * @param $item
237
+ * @return string
238
+ */
239
+ function column_runtime( $item ) {
240
+
241
+ return $item[ 'runtime' ] . ' ' . __( 'seconds', 'backwpup' );
242
+ }
243
+
244
+ /**
245
+ *
246
+ */
247
+ public static function load() {
248
+
249
+ //Create Table
250
+ self::$listtable = new BackWPup_Page_Logs;
251
+
252
+ switch ( self::$listtable->current_action() ) {
253
+ case 'delete':
254
+ if ( ! current_user_can( 'backwpup_logs_delete' ) )
255
+ break;
256
+ if ( is_array( $_GET[ 'logfiles' ] ) ) {
257
+ check_admin_referer( 'bulk-logs' );
258
+ $num = 0;
259
+ foreach ( $_GET[ 'logfiles' ] as $logfile ) {
260
+ if ( is_writeable( get_site_option( 'backwpup_cfg_logfolder' ) . $logfile ) && ! is_dir( get_site_option( 'backwpup_cfg_logfolder' ) . $logfile ) && ! is_link( get_site_option( 'backwpup_cfg_logfolder' ) . $logfile ) )
261
+ unlink( get_site_option( 'backwpup_cfg_logfolder' ) . $logfile );
262
+ $num ++;
263
+ }
264
+ }
265
+ break;
266
+ case 'download': //Download Log
267
+ if ( ! current_user_can( 'backwpup_logs' ) )
268
+ break;
269
+ check_admin_referer( 'download-backup_' . $_GET[ 'file' ] );
270
+ if ( is_readable( get_site_option( 'backwpup_cfg_logfolder' ) . $_GET[ 'file' ] ) && ! is_dir( get_site_option( 'backwpup_cfg_logfolder' ) . $_GET[ 'file' ] ) && !is_link( get_site_option( 'backwpup_cfg_logfolder' ) . $_GET[ 'file' ] ) ) {
271
+ header( "Pragma: public" );
272
+ header( "Expires: 0" );
273
+ header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
274
+ header( "Content-Type: application/force-download" );
275
+ header( "Content-Disposition: attachment; filename=" . get_site_option( 'backwpup_cfg_logfolder' ) . $_GET[ 'file' ] . ";" );
276
+ header( "Content-Transfer-Encoding: binary" );
277
+ header( "Content-Length: " . filesize( get_site_option( 'backwpup_cfg_logfolder' ) . $_GET[ 'file' ] ) );
278
+ @readfile( get_site_option( 'backwpup_cfg_logfolder' ) . $_GET[ 'file' ] );
279
+ die();
280
+ }
281
+ else {
282
+ header( 'HTTP/1.0 404 Not Found' );
283
+ die();
284
+ }
285
+ break;
286
+ }
287
+
288
+
289
+ //Save per page
290
+ if ( isset( $_POST[ 'screen-options-apply' ] ) && isset( $_POST[ 'wp_screen_options' ][ 'option' ] ) && isset( $_POST[ 'wp_screen_options' ][ 'value' ] ) && $_POST[ 'wp_screen_options' ][ 'option' ] == 'backwpuplogs_per_page' ) {
291
+ check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
292
+ global $current_user;
293
+ if ( $_POST[ 'wp_screen_options' ][ 'value' ] > 0 && $_POST[ 'wp_screen_options' ][ 'value' ] < 1000 ) {
294
+ update_user_option( $current_user->ID, 'backwpuplogs_per_page', (int)$_POST[ 'wp_screen_options' ][ 'value' ] );
295
+ wp_redirect( remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() ) );
296
+ exit;
297
+ }
298
+ }
299
+
300
+ add_screen_option( 'per_page', array(
301
+ 'label' => __( 'Logs', 'backwpup' ),
302
+ 'default' => 20,
303
+ 'option' => 'backwpuplogs_per_page'
304
+ ) );
305
+
306
+ self::$listtable->prepare_items();
307
+ }
308
+
309
+ /**
310
+ *
311
+ * Output css
312
+ *
313
+ * @return void
314
+ */
315
+ public static function admin_print_styles() {
316
+
317
+ ?>
318
+ <style type="text/css" media="screen">
319
+ .column-time {
320
+ text-align: center;
321
+ }
322
+
323
+ .column-runtime, .column-time, .column-size {
324
+ width: 8%;
325
+ }
326
+
327
+ .column-status {
328
+ width: 10%;
329
+ }
330
+
331
+ .column-type {
332
+ width: 15%;
333
+ }
334
+ @media screen and (max-width: 782px) {
335
+ .column-type, .column-runtime, .column-size {
336
+ display: none;
337
+ }
338
+ .column-time, .column-status {
339
+ width: 18%;
340
+ }
341
+ }
342
+ </style>
343
+ <?php
344
+ }
345
+
346
+ /**
347
+ *
348
+ * Output js
349
+ *
350
+ * @return void
351
+ */
352
+ public static function admin_print_scripts() {
353
+
354
+ wp_enqueue_script( 'backwpupgeneral' );
355
+ }
356
+
357
+ /**
358
+ * Display the page content
359
+ */
360
+ public static function page() {
361
+
362
+ ?>
363
+ <div class="wrap" id="backwpup-page">
364
+ <h2><span id="backwpup-page-icon">&nbsp;</span><?php echo esc_html( sprintf( __( '%s Logs', 'backwpup' ), BackWPup::get_plugin_data( 'name' ) ) ); ?></h2>
365
+ <?php BackWPup_Admin::display_messages(); ?>
366
+ <form id="posts-filter" action="" method="get">
367
+ <input type="hidden" name="page" value="backwpuplogs" />
368
+ <?php self::$listtable->display(); ?>
369
+ <div id="ajax-response"></div>
370
+ </form>
371
+ </div>
372
+ <?php
373
+ }
374
+
375
+ /**
376
+ * For displaying log files with ajax
377
+ */
378
+ public static function ajax_view_log() {
379
+
380
+ if ( ! current_user_can( 'backwpup_logs' ) )
381
+ die( -1 );
382
+ check_ajax_referer( 'view-logs' );
383
+ $log_file = get_site_option( 'backwpup_cfg_logfolder' ) . $_GET[ 'logfile' ];
384
+ if ( ! is_readable( $log_file ) && ! is_readable( $log_file . '.gz' ) && ! is_readable( $log_file . '.bz2' ) )
385
+ die( -1 );
386
+ //change file end if not html helps if log file compression is on
387
+ if ( ! file_exists( $log_file ) && file_exists( $log_file . '.gz' ) )
388
+ $log_file = $log_file . '.gz';
389
+ if ( ! file_exists( $log_file ) && file_exists( $log_file . '.bz2' ) )
390
+ $log_file = $log_file . '.bz2';
391
+ //output file
392
+ if ( '.gz' == substr( $log_file, -3 ) )
393
+ echo file_get_contents( 'compress.zlib://' .$log_file, FALSE );
394
+ else
395
+ echo file_get_contents( $log_file, FALSE );
396
+ die();
397
+ }
398
+
399
+ }
400
+
inc/class-page-settings.php CHANGED
@@ -35,7 +35,6 @@ class BackWPup_Page_Settings {
35
 
36
  delete_site_option( 'backwpup_cfg_showadminbar' );
37
  delete_site_option( 'backwpup_cfg_showfoldersize' );
38
- delete_site_option( 'backwpup_cfg_jobsteprestart' );
39
  delete_site_option( 'backwpup_cfg_jobstepretry' );
40
  delete_site_option( 'backwpup_cfg_jobmaxexecutiontime' );
41
  delete_site_option( 'backwpup_cfg_jobziparchivemethod' );
@@ -64,13 +63,18 @@ class BackWPup_Page_Settings {
64
 
65
  update_site_option( 'backwpup_cfg_showadminbar', isset( $_POST[ 'showadminbar' ] ) ? 1 : 0 );
66
  update_site_option( 'backwpup_cfg_showfoldersize', isset( $_POST[ 'showfoldersize' ] ) ? 1 : 0 );
67
- update_site_option( 'backwpup_cfg_jobsteprestart', isset( $_POST[ 'jobsteprestart' ] ) ? 1 : 0 );
68
  if ( 100 > $_POST[ 'jobstepretry' ] && 0 < $_POST[ 'jobstepretry' ] )
69
  $_POST[ 'jobstepretry' ] = abs( (int)$_POST[ 'jobstepretry' ] );
70
  if ( empty( $_POST[ 'jobstepretry' ] ) or ! is_int( $_POST[ 'jobstepretry' ] ) )
71
  $_POST[ 'jobstepretry' ] = 3;
72
  update_site_option( 'backwpup_cfg_jobstepretry', $_POST[ 'jobstepretry' ] );
73
- update_site_option( 'backwpup_cfg_jobmaxexecutiontime', abs( (int)$_POST[ 'jobmaxexecutiontime' ] ) );
 
 
 
 
 
 
74
  update_site_option( 'backwpup_cfg_jobziparchivemethod', ( $_POST[ 'jobziparchivemethod' ] == '' || $_POST[ 'jobziparchivemethod' ] == 'PclZip' || $_POST[ 'jobziparchivemethod' ] == 'ZipArchive' ) ? $_POST[ 'jobziparchivemethod' ] : '' );
75
  update_site_option( 'backwpup_cfg_jobnotranslate', isset( $_POST[ 'jobnotranslate' ] ) ? 1 : 0 );
76
  update_site_option( 'backwpup_cfg_jobwaittimems', $_POST[ 'jobwaittimems' ] );
@@ -85,10 +89,12 @@ class BackWPup_Page_Settings {
85
  if ( $_POST[ 'logfolder' ][ 0 ] == '.' || ( $_POST[ 'logfolder' ][ 0 ] != '/' && ! preg_match( '#^[a-zA-Z]:/#', $_POST[ 'logfolder' ] ) ) )
86
  $_POST[ 'logfolder' ] = trailingslashit( str_replace( '\\', '/', ABSPATH ) ) . $_POST[ 'logfolder' ];
87
  //set def. folders
88
- if ( empty( $_POST[ 'logfolder' ] ) || $_POST[ 'logfolder' ] == '/' )
89
  delete_site_option( 'backwpup_cfg_logfolder' );
90
- else
 
91
  update_site_option( 'backwpup_cfg_logfolder', $_POST[ 'logfolder' ] );
 
92
 
93
  do_action( 'backwpup_page_settings_save' );
94
 
@@ -223,20 +229,6 @@ class BackWPup_Page_Settings {
223
  value="<?php echo get_site_option( 'backwpup_cfg_jobstepretry' );?>"
224
  class="small-text code" />
225
  </td>
226
- </tr>
227
- <tr>
228
- <th scope="row"><?php _e( 'Restart on every main step', 'backwpup' ); ?></th>
229
- <td>
230
- <fieldset>
231
- <legend class="screen-reader-text"><span><?php _e( 'Restart on every main step', 'backwpup' ); ?></span>
232
- </legend>
233
- <label for="jobsteprestart">
234
- <input name="jobsteprestart" type="checkbox" id="jobsteprestart" title="<?php esc_attr_e( 'Job will restart on every main step if the last restart has been longer than 3 seconds ago. This is to prevent running in an execution timeout. It will not work with CLI. If <code>ALTERNATE_WP_CRON</code> has been defined, WordPress Cron will be used.', 'backwpup' ); ?>"
235
- value="1" class="help-tip" <?php checked( get_site_option( 'backwpup_cfg_jobsteprestart' ), TRUE ); ?> />
236
- <?php _e( 'Restart the job on every main step on a running job', 'backwpup' ); ?>
237
- </label>
238
- </fieldset>
239
- </td>
240
  </tr>
241
  <tr>
242
  <th scope="row"><?php _e( 'Maximum script execution time', 'backwpup' ); ?></th>
35
 
36
  delete_site_option( 'backwpup_cfg_showadminbar' );
37
  delete_site_option( 'backwpup_cfg_showfoldersize' );
 
38
  delete_site_option( 'backwpup_cfg_jobstepretry' );
39
  delete_site_option( 'backwpup_cfg_jobmaxexecutiontime' );
40
  delete_site_option( 'backwpup_cfg_jobziparchivemethod' );
63
 
64
  update_site_option( 'backwpup_cfg_showadminbar', isset( $_POST[ 'showadminbar' ] ) ? 1 : 0 );
65
  update_site_option( 'backwpup_cfg_showfoldersize', isset( $_POST[ 'showfoldersize' ] ) ? 1 : 0 );
 
66
  if ( 100 > $_POST[ 'jobstepretry' ] && 0 < $_POST[ 'jobstepretry' ] )
67
  $_POST[ 'jobstepretry' ] = abs( (int)$_POST[ 'jobstepretry' ] );
68
  if ( empty( $_POST[ 'jobstepretry' ] ) or ! is_int( $_POST[ 'jobstepretry' ] ) )
69
  $_POST[ 'jobstepretry' ] = 3;
70
  update_site_option( 'backwpup_cfg_jobstepretry', $_POST[ 'jobstepretry' ] );
71
+ $max_exe_time = abs( (int)$_POST[ 'jobmaxexecutiontime' ] );
72
+ if ( ! is_int( $max_exe_time ) || $max_exe_time < 0 ) {
73
+ $max_exe_time = 0;
74
+ } elseif ( $max_exe_time > 300 ) {
75
+ $max_exe_time = 300;
76
+ }
77
+ update_site_option( 'backwpup_cfg_jobmaxexecutiontime', $max_exe_time );
78
  update_site_option( 'backwpup_cfg_jobziparchivemethod', ( $_POST[ 'jobziparchivemethod' ] == '' || $_POST[ 'jobziparchivemethod' ] == 'PclZip' || $_POST[ 'jobziparchivemethod' ] == 'ZipArchive' ) ? $_POST[ 'jobziparchivemethod' ] : '' );
79
  update_site_option( 'backwpup_cfg_jobnotranslate', isset( $_POST[ 'jobnotranslate' ] ) ? 1 : 0 );
80
  update_site_option( 'backwpup_cfg_jobwaittimems', $_POST[ 'jobwaittimems' ] );
89
  if ( $_POST[ 'logfolder' ][ 0 ] == '.' || ( $_POST[ 'logfolder' ][ 0 ] != '/' && ! preg_match( '#^[a-zA-Z]:/#', $_POST[ 'logfolder' ] ) ) )
90
  $_POST[ 'logfolder' ] = trailingslashit( str_replace( '\\', '/', ABSPATH ) ) . $_POST[ 'logfolder' ];
91
  //set def. folders
92
+ if ( empty( $_POST[ 'logfolder' ] ) || $_POST[ 'logfolder' ] == '/' ) {
93
  delete_site_option( 'backwpup_cfg_logfolder' );
94
+ BackWPup_Option::default_site_options();
95
+ } else {
96
  update_site_option( 'backwpup_cfg_logfolder', $_POST[ 'logfolder' ] );
97
+ }
98
 
99
  do_action( 'backwpup_page_settings_save' );
100
 
229
  value="<?php echo get_site_option( 'backwpup_cfg_jobstepretry' );?>"
230
  class="small-text code" />
231
  </td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  </tr>
233
  <tr>
234
  <th scope="row"><?php _e( 'Maximum script execution time', 'backwpup' ); ?></th>
inc/class-wp-cli.php CHANGED
@@ -1,84 +1,84 @@
1
- <?php
2
- /**
3
- * Class for WP-CLI commands
4
- */
5
- class BackWPup_WP_CLI extends WP_CLI_Command {
6
-
7
- /**
8
- * Start a BackWPup job
9
- *
10
- * @param $args
11
- * @param $assoc_args
12
- * @synopsis start --jobid=<ID>
13
- */
14
- public function start( $args, $assoc_args ) {
15
-
16
- if ( file_exists( BackWPup::get_plugin_data( 'running_file' ) ) )
17
- WP_CLI::error( __( 'A job is already running.', 'backwpup' ) );
18
-
19
- if ( empty( $assoc_args['jobid'] ) )
20
- WP_CLI::error( __( 'No job ID specified!', 'backwpup' ) );
21
-
22
- $jobids = BackWPup_Option::get_job_ids();
23
- if ( ! in_array( $assoc_args['jobid'], $jobids ) )
24
- WP_CLI::error( __( 'Job ID does not exist!', 'backwpup' ) );
25
-
26
- BackWPup_Job::start_cli( $assoc_args['jobid'] );
27
-
28
- }
29
-
30
- /**
31
- * Abort a working BackWPup Job
32
- *
33
- * @synopsis abort
34
- */
35
- public function abort( $args, $assoc_args ) {
36
-
37
- if ( file_exists( BackWPup::get_plugin_data( 'running_file' ) ) )
38
- WP_CLI::error( __( 'Nothing to abort!', 'backwpup' ) );
39
-
40
- //abort
41
- BackWPup_Job::user_abort();
42
- WP_CLI::success( __( 'Job will be terminated.', 'backwpup' ) ) ;
43
- }
44
-
45
- /**
46
- * Display a List of Jobs
47
- *
48
- * @synopsis jobs
49
- */
50
- public function jobs( $args, $assoc_args ) {
51
-
52
- $jobids = BackWPup_Option::get_job_ids();
53
-
54
- WP_CLI::line( __('List of jobs', 'backwpup' ) );
55
- WP_CLI::line( '----------------------------------------------------------------------' );
56
- foreach ($jobids as $jobid ) {
57
- WP_CLI::line( sprintf( __('ID: %1$d Name: %2$s', 'backwpup' ),$jobid, BackWPup_Option::get( $jobid, 'name' ) ) );
58
- }
59
-
60
- }
61
-
62
- /**
63
- * See Status of a working job
64
- *
65
- * @param $args
66
- * @param $assoc_args
67
- * @synopsis working
68
- */
69
- public function working( $args, $assoc_args ) {
70
-
71
- $job_object = BackWPup_Job::get_working_data();
72
- if ( is_object( $job_object ) )
73
- WP_CLI::error( __( 'No job running', 'backwpup' ) );
74
- WP_CLI::line( __('Running job', 'backwpup' ) );
75
- WP_CLI::line( '----------------------------------------------------------------------' );
76
- WP_CLI::line( sprintf( __( 'ID: %1$d Name: %2$s', 'backwpup' ), $job_object->job[ 'jobid' ], $job_object->job[ 'name' ] ) );
77
- WP_CLI::line( sprintf( __( 'Warnings: %1$d Errors: %2$d', 'backwpup' ), $job_object->warnings , $job_object->errors ) );
78
- WP_CLI::line( sprintf( __( 'Steps in percent: %1$d percent of step: %2$d', 'backwpup' ), $job_object->step_percent, $job_object->substep_percent ) );
79
- WP_CLI::line( sprintf( __( 'On step: %s', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'NAME' ] ) );
80
- WP_CLI::line( sprintf( __( 'Last message: %s', 'backwpup' ), str_replace( '&hellip;', '...', strip_tags( $job_object->lastmsg ) ) ) );
81
-
82
- }
83
-
84
- }
1
+ <?php
2
+ /**
3
+ * Class for WP-CLI commands
4
+ */
5
+ class BackWPup_WP_CLI extends WP_CLI_Command {
6
+
7
+ /**
8
+ * Start a BackWPup job
9
+ *
10
+ * @param $args
11
+ * @param $assoc_args
12
+ * @synopsis start --jobid=<ID>
13
+ */
14
+ public function start( $args, $assoc_args ) {
15
+
16
+ if ( file_exists( BackWPup::get_plugin_data( 'running_file' ) ) )
17
+ WP_CLI::error( __( 'A job is already running.', 'backwpup' ) );
18
+
19
+ if ( empty( $assoc_args['jobid'] ) )
20
+ WP_CLI::error( __( 'No job ID specified!', 'backwpup' ) );
21
+
22
+ $jobids = BackWPup_Option::get_job_ids();
23
+ if ( ! in_array( $assoc_args['jobid'], $jobids ) )
24
+ WP_CLI::error( __( 'Job ID does not exist!', 'backwpup' ) );
25
+
26
+ BackWPup_Job::start_cli( $assoc_args['jobid'] );
27
+
28
+ }
29
+
30
+ /**
31
+ * Abort a working BackWPup Job
32
+ *
33
+ * @synopsis abort
34
+ */
35
+ public function abort( $args, $assoc_args ) {
36
+
37
+ if ( file_exists( BackWPup::get_plugin_data( 'running_file' ) ) )
38
+ WP_CLI::error( __( 'Nothing to abort!', 'backwpup' ) );
39
+
40
+ //abort
41
+ BackWPup_Job::user_abort();
42
+ WP_CLI::success( __( 'Job will be terminated.', 'backwpup' ) ) ;
43
+ }
44
+
45
+ /**
46
+ * Display a List of Jobs
47
+ *
48
+ * @synopsis jobs
49
+ */
50
+ public function jobs( $args, $assoc_args ) {
51
+
52
+ $jobids = BackWPup_Option::get_job_ids();
53
+
54
+ WP_CLI::line( __('List of jobs', 'backwpup' ) );
55
+ WP_CLI::line( '----------------------------------------------------------------------' );
56
+ foreach ($jobids as $jobid ) {
57
+ WP_CLI::line( sprintf( __('ID: %1$d Name: %2$s', 'backwpup' ),$jobid, BackWPup_Option::get( $jobid, 'name' ) ) );
58
+ }
59
+
60
+ }
61
+
62
+ /**
63
+ * See Status of a working job
64
+ *
65
+ * @param $args
66
+ * @param $assoc_args
67
+ * @synopsis working
68
+ */
69
+ public function working( $args, $assoc_args ) {
70
+
71
+ $job_object = BackWPup_Job::get_working_data();
72
+ if ( is_object( $job_object ) )
73
+ WP_CLI::error( __( 'No job running', 'backwpup' ) );
74
+ WP_CLI::line( __('Running job', 'backwpup' ) );
75
+ WP_CLI::line( '----------------------------------------------------------------------' );
76
+ WP_CLI::line( sprintf( __( 'ID: %1$d Name: %2$s', 'backwpup' ), $job_object->job[ 'jobid' ], $job_object->job[ 'name' ] ) );
77
+ WP_CLI::line( sprintf( __( 'Warnings: %1$d Errors: %2$d', 'backwpup' ), $job_object->warnings , $job_object->errors ) );
78
+ WP_CLI::line( sprintf( __( 'Steps in percent: %1$d percent of step: %2$d', 'backwpup' ), $job_object->step_percent, $job_object->substep_percent ) );
79
+ WP_CLI::line( sprintf( __( 'On step: %s', 'backwpup' ), $job_object->steps_data[ $job_object->step_working ][ 'NAME' ] ) );
80
+ WP_CLI::line( sprintf( __( 'Last message: %s', 'backwpup' ), str_replace( '&hellip;', '...', strip_tags( $job_object->lastmsg ) ) ) );
81
+
82
+ }
83
+
84
+ }
languages/backwpup-de_DE.mo CHANGED
Binary file
languages/backwpup-de_DE.po CHANGED
@@ -1,6649 +1,6109 @@
1
  msgid ""
2
  msgstr ""
3
- "Project-Id-Version: BackWPup Pro v3.1.2\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: \n"
6
- "PO-Revision-Date: 2014-02-27 08:04:06+0000\n"
7
- "Last-Translator: Daniel Hüsken <mail@danielhuesken.de>\n"
8
  "Language-Team: \n"
 
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
- "X-Generator: Poedit 1.6.3\n"
14
- "X-Poedit-Language: \n"
15
- "X-Poedit-Country: \n"
16
  "X-Poedit-SourceCharset: utf-8\n"
17
- "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
18
- "X-Poedit-Basepath: \n"
19
- "X-Poedit-Bookmarks: \n"
20
  "X-Poedit-SearchPath-0: .\n"
21
- "X-Textdomain-Support: yes"
22
 
23
- #: inc/class-jobtype-dbdump.php:204
24
- #: inc/pro/class-jobtype-dbdump.php:511
25
- #, php-format
26
- #@ backwpup
27
- msgid "Backup database table \"%s\" with \"%d\" records"
28
- msgstr "Sichere Datenbank-Tabelle \"%s\" mit \"%d\" Einträgen"
29
 
30
- #: inc/pro/class-jobtype-dbdump.php:89
31
- #@ backwpup
32
- msgid "Backup only WordPress Database tables"
33
- msgstr "Nur die WordPress Datenbank Tabellen sichern"
34
 
35
- #: inc/class-jobtype-dbdump.php:15
36
- #@ backwpup
37
- msgid "Creates an .sql database backup file"
38
- msgstr "Erstellt ein Datenbank-Backup (.sql, .xml)"
39
 
40
- #: inc/pro/class-jobtype-dbdump.php:910
41
- #@ backwpup
42
- msgid "Database XML backup done!"
43
- msgstr "Datenbank XML Backup erstellt!"
44
 
45
- #: inc/class-job.php:308
46
- #, php-format
47
- #@ backwpup
48
- msgctxt "Plugin name; Plugin Version"
49
- msgid "[INFO] %1$s version %2$s; A project of Inpsyde GmbH"
50
- msgstr "[INFO] %1$s Version %2$s; Ein Projekt der Inpsyde GmbH"
51
 
52
- #: inc/class-job.php:309
53
- #, php-format
54
- #@ backwpup
55
- msgctxt "WordPress Version"
56
- msgid "[INFO] WordPress version %s"
57
- msgstr "[INFO] WordPress Version %s"
58
 
59
- #: inc/class-page-about.php:418
60
- #: inc/class-page-about.php:428
61
- #@ backwpup
62
- msgid "Use your backup archives to save your entire WordPress installation including <code>/wp-content/</code>. Push them to an external storage service if you don’t want to save the backups on the same server. With a single backup archive you are able to restore an installation. Use a tool like phpMyAdmin or a plugin like <a href=\"http://wordpress.org/plugins/adminer/\" target=\"_blank\">Adminer</a> to restore your database backup files."
63
- msgstr "Benutze deine Backup-Archive, um deine gesamte WordPress-Installation zu sichern, einschließlich <code>/wp-content/</code>. Lade sie zu einem externen Dienst hoch, wenn du deine Backups nicht auf demselben Server speichern möchtest. Mit einem einzigen Backup-Archiv kannst du deine Installation wiederherstellen. Benutze ein serverseitiges Tool wie phpMyAdmin, oder ein Plugin wie <a href=\"http://wordpress.org/plugins/adminer/\" target=\"_blank\">Adminer</a>, um deine Datenbanksicherung wiederherzustellen."
64
 
65
- #: inc/class-mysqldump.php:386
66
- #, php-format
67
- #@ backwpup
68
- msgid "Length for table backup is not correctly set: %1$s "
69
- msgstr "Länge des Tabellen Backups ist nicht richtig gesetzt: %1$s "
70
 
71
- #: inc/class-jobtype-dbdump.php:257
72
- #: inc/pro/class-jobtype-dbdump.php:564
73
- #: inc/pro/class-jobtype-dbdump.php:676
74
- #@ backwpup
75
- msgid "Database backup done!"
76
- msgstr "Datenbank-Backup fertig!"
77
 
78
- #: inc/pro/class-jobtype-dbdump.php:744
79
- #@ backwpup
80
- msgid "No tables for XML backup"
81
- msgstr "Es gibt keine Tabellen für einen XML Backup"
 
82
 
83
- #: inc/class-jobtype-dbdump.php:182
84
- #: inc/pro/class-jobtype-dbdump.php:486
85
- #@ backwpup
86
- msgid "No tables to backup."
87
- msgstr "Es gibt keine Tabellen zu sichern"
88
 
89
- #: inc/class-mysqldump.php:383
90
- #, php-format
91
- #@ backwpup
92
- msgid "Start for table backup is not correctly set: %1$s "
93
- msgstr "Start für den Tabellen Backup ist nicht richtig gesetzt: %1$s "
94
 
95
- #: inc/pro/class-jobtype-dbdump.php:558
96
- #, php-format
97
- #@ backwpup
98
- msgid "Added database backup \"%1$s\" with %2$s to backup file list"
99
- msgstr "Datenbank-Backup \"%1$s\" mit %2$s zur Backup-Datei-Liste hinzugefügt"
100
 
101
- #: inc/class-page-backwpup.php:77
102
- #: inc/class-page-backwpup.php:86
103
- #@ backwpup
104
- msgid "With a single backup archive you are able to restore an installation. Use a tool like phpMyAdmin or a plugin like <a href=\"http://wordpress.org/plugins/adminer/\" target=\"_blank\">Adminer</a> to restore your database backup files."
105
- msgstr "Mit einem einzigen Backup-Archiv kannst du deine Installation wiederherstellen. Benutze ein serverseitiges Tool wie phpMyAdmin, oder ein Plugin wie <a href=\"http://wordpress.org/plugins/adminer/\" target=\"_blank\">Adminer</a>, um deine Datenbanksicherung wiederherzustellen."
106
 
107
- #: inc/class-page-settings.php:389
108
- #, php-format
109
- #@ backwpup
110
- msgid "Temporary folder %s is not writable."
111
- msgstr "Temporärer Ordner %s ist nicht beschreibbar."
112
 
113
- #: inc/pro/class-jobtype-dbdump.php:691
114
- #, php-format
115
- #@ backwpup
116
- msgid "%d. Try to backup database as XML&#160;&hellip;"
117
- msgstr "%d. Versuche, Datenbank als XML zu sichern&#160;&hellip;"
118
 
119
- #: inc/class-page-settings.php:150
120
- #@ backwpup
121
- msgid "Display folder sizes in the files tab when editing a job. (Might increase loading time of files tab.)"
122
- msgstr "Ordnergrößen im Tab Dateien anzeigen, wenn ein Auftrag bearbeitet wird. (Kann die Ladezeit des Tab erhöhen.)"
123
 
124
- #: inc/class-jobtype-wpexp.php:137
125
- #@ backwpup
126
- msgid "Could not generate a WordPress export file."
127
- msgstr "Konnte keine WordPress-Exportdatei erstellen."
128
 
129
- #: inc/class-job.php:1767
 
130
  #, php-format
131
- #@ backwpup
132
- msgctxt "Archive compression method"
133
- msgid "Compressing files as %s. Please be patient, this may take a moment."
134
- msgstr "Komprimiere Dateien als %s. Bitte habe einen Moment Geduld."
135
 
136
- #: inc/class-admin.php:401
 
137
  #, php-format
138
- #@ backwpup
139
- msgid "<a class=\"backwpup-get-pro\" href=\"%s\">Get BackWPup Pro now.</a>"
140
- msgstr "<a class=\"backwpup-get-pro\" href=\"%s\">Wechsle jetzt zu BackWPup Pro.</a>"
141
 
142
- #: inc/class-job.php:341
 
143
  #, php-format
144
- #@ backwpup
145
- msgid "[INFO] Maximum PHP script execution time is %1$d seconds"
146
- msgstr "[INFO] Maximum PHP script execution time ist %1$d Sekunden"
147
 
148
- #: inc/class-page-about.php:417
149
- #: inc/class-page-backwpup.php:75
150
- #@ backwpup
151
- msgid "BackWPup’s job wizards make planning and scheduling your backup jobs a breeze."
152
- msgstr "Die Assistenten in BackWPup machen das Planen und terminieren deiner Sicherungen zu einem Spaziergang."
153
 
154
- #: inc/class-page-about.php:419
155
- #, php-format
156
- #@ backwpup
157
- msgid "Ready to <a href=\"%1$s\">set up a backup job</a>? You can <a href=\"%2$s\">use the wizards</a> or plan your backup in expert mode."
158
- msgstr "<a href=\"%1$s\">Bereit, einen Backup-Auftrag anzulegen</a>? Benutze die <a href=\"%2$s\">Assistenten</a>, oder plane dein Backup im Expertenmodus."
159
 
160
- #: inc/class-page-about.php:429
161
- #@ backwpup
162
- msgid "Ready to set up a backup job? Use one of the wizards to plan what you want to save."
163
- msgstr "Bereit, einen Backup-Auftrag anzulegen? Benutze einen der Assistenten, um deine Sicherung zu planen."
 
164
 
165
- #: inc/class-page-backups.php:395
166
- #@ backwpup
167
- msgid "Backup Files"
168
- msgstr "Backup-Dateien"
 
169
 
170
- #: inc/class-page-backwpup.php:75
171
- #: inc/class-page-backwpup.php:84
172
- #@ backwpup
173
- msgid "Use your backup archives to save your entire WordPress installation including <code>/wp-content/</code>. Push them to an external storage service if you don’t want to save the backups on the same server."
174
- msgstr "Benutze deine Backup-Archive, um deine gesamte WordPress-Installation zu sichern, einschließlich <code>/wp-content/</code>. Lade sie zu einem externen Dienst hoch, wenn du deine Backups nicht auf demselben Server speichern möchtest."
 
175
 
176
- #: inc/class-page-backwpup.php:79
 
177
  #, php-format
178
- #@ backwpup
179
- msgid "Use one of the wizards to plan a backup, or use <a href=\"%s\">expert mode</a> for full control over all options."
180
- msgstr "Verwende einen der Assistenten, um dein Backup zu planen, oder den <a href=\"%s\">Expertenmodus</a> für die volle Übersicht über alle Optionen."
181
-
182
- #: inc/class-page-backwpup.php:79
183
- #: inc/class-page-backwpup.php:89
184
- #@ backwpup
185
- msgid "<strong>Please note: You are solely responsible for the security of your data; the authors of this plugin are not.</strong>"
186
- msgstr "<strong>Bitte beachte: Für die Sicherheit deiner Daten bist du allein verantwortlich; die Autoren dieses Plugins sind es nicht.</strong>"
187
 
188
- #: inc/class-page-backwpup.php:84
189
- #@ backwpup
190
- msgid "Use the short links in the <strong>First steps</strong> box to plan and schedule backup jobs."
191
- msgstr "Benutze die Schnellverweise in <strong>Erste Schritte</strong>, um einen Backup-Auftrag zu planen und zu terminieren."
192
 
193
- #: inc/class-page-backwpup.php:88
194
- #, php-format
195
- #@ backwpup
196
- msgid "<a href=\"%s\">Add a new backup job</a> and plan what you want to save."
197
- msgstr "<a href=\"%s\">Erstelle einen Backup-Auftrag</a> und plane deine Sicherung."
198
 
199
- #: inc/class-page-backwpup.php:232
200
- #@ backwpup
201
- msgctxt "Pro teaser box"
202
- msgid "Thank you for using BackWPup!"
203
- msgstr "Danke, dass du BackWPup benutzt!"
204
 
205
- #: inc/class-page-backwpup.php:235
206
- #@ backwpup
207
- msgctxt "Pro teaser box"
208
- msgid "Get access to:"
209
- msgstr "Erhalte Zugang zu:"
210
 
211
- #: inc/class-page-backwpup.php:237
212
- #@ backwpup
213
- msgctxt "Pro teaser box"
214
- msgid "First-class <strong>dedicated support</strong> at MarketPress Helpdesk."
215
- msgstr "Erstklassigem <strong>persönlichen Support</strong> im Helpdesk bei MarketPress."
216
 
217
- #: inc/class-page-backwpup.php:238
218
- #@ backwpup
219
- msgctxt "Pro teaser box"
220
- msgid "Differential backups to Google Drive and other cloud storage service."
221
- msgstr "Differenzielle Backups zu Google Drive anderen Cloud-Storage-Diensten."
222
 
223
- #: inc/class-page-backwpup.php:239
224
- #@ backwpup
225
- msgctxt "Pro teaser box"
226
- msgid "Easy-peasy wizards to create and schedule backup jobs."
227
- msgstr "Kinderleichte Assistenten zum Erstellen und Planen von Backup-Aufträgen."
228
 
229
- #: inc/class-page-backwpup.php:240
230
- #@ backwpup
231
- msgctxt "Pro teaser box, link text"
232
- msgid "And more…"
233
- msgstr "Und mehr…"
234
 
235
- #: inc/class-page-backwpup.php:242
236
- #@ backwpup
237
- msgctxt "Pro teaser box, link title"
238
- msgid "Get BackWPup Pro now"
239
- msgstr "Wechsle jetzt zu BackWPup Pro"
240
 
241
- #: inc/class-page-backwpup.php:242
242
- #@ backwpup
243
- msgctxt "Pro teaser box, link text"
244
- msgid "Get BackWPup Pro now"
245
- msgstr "Wechsle jetzt zu BackWPup Pro"
246
 
247
- #: inc/class-page-jobs.php:108
248
- #: inc/class-page-logs.php:188
249
- #, php-format
250
- #@ backwpup
251
- msgid "Job ID: %d"
252
- msgstr "Auftrags-ID: %d"
253
 
254
- #: inc/class-page-jobs.php:692
255
- #@ backwpup
256
- msgid "Job completed"
257
- msgstr "Auftrag vollständig"
258
 
259
- #: inc/pro/class-destination-gdrive.php:33
260
- #: inc/pro/class-destination-gdrive.php:205
261
- #, php-format
262
- #@ backwpup
263
- msgid "Looks like you haven’t set up any API keys yet. Head over to <a href=\"%s\">Settings | API-Keys</a> and get Google Drive all set up, then come back here."
264
- msgstr "Sieht so aus, als hättest du bis jetzt noch keine API-Schlüssel erstellt. Gehe zu <a href=\"%s\">Einstellungen | API-Schlüssel</a> und setze die Verbindung zu Google Drive auf, kann komm’ hierhin zurück."
265
 
266
- #: inc/pro/class-destination-gdrive.php:79
267
- #@ backwpup
268
- msgid "Folder in Google Drive"
269
- msgstr "Ordner in Google Drive"
270
 
271
- #: inc/pro/class-page-wizard.php:169
272
- #: inc/pro/class-page-wizard.php:437
273
- #: inc/pro/class-page-wizard.php:470
274
- #@ backwpup
275
- msgid "Next ›"
276
- msgstr "Weiter ›"
277
 
278
- #: inc/pro/class-page-wizard.php:186
279
- #: inc/pro/class-page-wizard.php:433
280
- #@ backwpup
281
- msgid " Previous"
282
- msgstr "‹ Zurück"
283
 
284
- #: inc/class-destination-dropbox.php:266
285
- #: inc/pro/class-destination-gdrive.php:522
286
- #: inc/pro/class-destination-glacier.php:364
287
- #, php-format
288
- #@ backwpup
289
- msgid "Error transfering backup to %s."
290
- msgstr "Fehler beim Übertragen des Backups zu %s."
291
 
292
- #: inc/pro/class-destination-gdrive.php:504
293
- #, php-format
294
- #@ backwpup
295
- msgid "Error transfering file chunks to %s."
296
- msgstr "Fehler beim Übertragen von Datei-Teilen zu %s."
297
 
298
- #: inc/pro/class-destination-gdrive.php:504
299
- #: inc/pro/class-destination-gdrive.php:522
300
- #@ backwpup
301
- msgid "Google Drive"
302
- msgstr "Google Drive"
303
 
304
- #: inc/pro/class-destination-glacier.php:96
305
- #: inc/pro/class-destination-glacier.php:179
306
- #@ backwpup
307
- msgid "Number of files to keep in folder. (Archives deleted before 3 months after they have been stored may cause extra costs when deleted.)"
308
- msgstr "Anzahl der im Ordner verbleibenden Dateien. (Archive, die vor Ablauf von 3 Monaten gelöscht werden, können zusätzliche Kosten verursachen.)"
309
 
310
- #: inc/class-jobtype-dbdump.php:155
311
- #: inc/pro/class-jobtype-dbdump.php:454
312
- #, php-format
313
- #@ backwpup
314
- msgid "%d. Try to backup database&#160;&hellip;"
315
- msgstr "%d. Versuche, die Datenbank zu sichern&#160;&hellip;"
316
 
317
- #: inc/class-page-backwpup.php:74
318
- #: inc/class-page-backwpup.php:83
319
- #@ backwpup
320
- msgctxt "Dashboard heading"
321
- msgid "Planning backups"
322
- msgstr "Backups planen"
323
 
324
- #: inc/class-page-backwpup.php:76
325
- #: inc/class-page-backwpup.php:85
326
- #@ backwpup
327
- msgctxt "Dashboard heading"
328
- msgid "Restoring backups"
329
- msgstr "Backups wiederherstellen"
330
 
331
- #: inc/class-page-backwpup.php:78
332
- #: inc/class-page-backwpup.php:87
333
- #@ backwpup
334
- msgctxt "Dashboard heading"
335
- msgid "Ready to set up a backup job?"
336
- msgstr "Bereit, einen Backup-Auftrag zu erstellen?"
337
 
338
- #: inc/class-page-settings.php:234
339
- #@ backwpup
340
- msgid "Job will restart on every main step if the last restart has been longer than 3 seconds ago. This is to prevent running in an execution timeout. It will not work with CLI. If <code>ALTERNATE_WP_CRON</code> has been defined, WordPress Cron will be used."
341
- msgstr "Der Auftrag wird bei jedem Hauptschritt neu gestartet, sofern der letzte Neustart länger als 3 Sekunden zurück liegt. Dies soll das das Auftreten von Zeitüberschreitungen verhindern. Es funktioniert nicht in Verbindung mit CLI. Wenn <code>ALTERNATE_WP_CRON</code> definiert wurde, wird der WordPress-Cron verwendet."
342
 
343
- #: inc/class-page-settings.php:248
344
- #@ backwpup
345
- msgid "Job will restart before hitting maximum execution time. It will not work with CLI and not on every step during execution. If <code>ALTERNATE_WP_CRON</code> has been defined, WordPress Cron will be used."
346
- msgstr "Auftrag wird neu gestartet, bevor die Maximal Execution Time erreicht wird. Es funktioniert nicht in Verbindung mit CLI. Wenn <code>ALTERNATE_WP_CRON</code> definiert wurde, wird der WordPress-Cron verwendet."
347
 
348
- #: inc/pro/class-jobtype-dbdump.php:578
349
- #, php-format
350
- #@ backwpup
351
- msgid "%d. Try to backup MySQL system&#160;&hellip;"
352
- msgstr "%d. Versuche, das MySQL-System zu sichern&#160;&hellip;"
353
 
354
- #: inc/pro/class-wizard-systemtest.php:105
355
- #@ backwpup
356
- msgid "PHP cURL extension must be installed to use the full plugin functionality."
357
- msgstr "Die cURL-Erweiterung für PHP muss installiert sein, um das Plugin im Vollem Umfang zu nutzen."
358
 
359
- #: inc/pro/class-wizard-systemtest.php:175
360
- #, php-format
361
- #@ backwpup
362
- msgid "The HTTP response test result is a wrong HTTP status: %s. It should be status 200."
363
- msgstr "Der HTTP-Response-Test hat einen falschen HTTP-Status ergeben: %s. Es sollte Status 200 sein."
364
 
365
- #: inc/class-destination-email.php:79
366
- #@ backwpup
367
- msgid "- Use site settings: retrieve the email settings of your site.<br />-PHP mail(): needs more PHP memory"
368
- msgstr "- Verwende Seiteneinstellungen: Rufe die E-Mail-Einstellungen von deiner Seite ab.<br />-PHP mail():benötigt mehr PHP-Speicher"
369
 
370
- #: inc/class-page-jobs.php:540
371
- #@ backwpup
372
- msgid "Log of running job"
373
- msgstr "Protokoll des laufenden Auftrags"
374
 
375
- #: inc/class-page-settings.php:318
376
- #@ backwpup
377
- msgid "Is your blog protected with HTTP basic authentication (.htaccess)? If yes, please set the username and password for authentication here."
378
- msgstr "Ist deine Wesbite mit einer HTTP-Authentifizierung geschützt (.htaccess)? Wenn ja, trage hier bitte die Zugangsdaten ein."
379
 
380
- #: inc/class-page-settings.php:377
381
- #: inc/pro/class-wizard-systemtest.php:180
382
- #, php-format
383
- #@ backwpup
384
- msgid "The BackWPup HTTP response header returns a false value: \"%s\""
385
- msgstr "Der HTTP Response Header in BackWPup gibt einen fehlerhaften Wert zurück: \"%s\""
386
-
387
- #: inc/class-page-settings.php:394
388
- #@ backwpup
389
- msgid "Log folder:"
390
- msgstr "Protokoll-Ordner:"
391
 
392
- #: inc/class-page-settings.php:398
 
393
  #, php-format
394
- #@ backwpup
395
- msgid "Log folder %s is not writable."
396
- msgstr "Protokoll-Ordner %s ist nicht beschreibbar."
397
 
398
- #: inc/pro/class-destination-gdrive.php:718
 
399
  #, php-format
400
- #@ backwpup
401
- msgid "File %s moved to trash in Google Drive"
402
- msgstr "Datei %s in den Papierkorb bei Google Drive verschoben"
403
 
404
- #: inc/pro/class-destination-gdrive.php:732
 
405
  #, php-format
406
- #@ backwpup
407
- msgid "Folder %s moved to trash in Google Drive"
408
- msgstr "Ordner %s in den Papierkorb bei Google Drive verschoben"
409
-
410
- #: inc/pro/class-destination-glacier.php:30
411
- #@ backwpup
412
- msgid "Select a region:"
413
- msgstr "Wähle eine Region:"
414
 
415
- #: inc/pro/class-destination-glacier.php:293
 
 
 
 
 
416
  #, php-format
417
- #@ backwpup
418
- msgid "Connected to Glacier vault \"%1$s\" with %2$d archives and size of %3$d"
419
- msgstr "Verbunden mit Glacier-Vault \"%1$s\" mit %2$d archives einer Größe von %3$d"
420
 
421
- #: inc/pro/class-wizard-job.php:614
 
422
  #, php-format
423
- #@ backwpup
424
- msgid "New job %s generated."
425
- msgstr "Neuer Auftrag %s erstellt."
426
-
427
- #. translators: plugin header field 'PluginURI'
428
- #: backwpup.php:0
429
- #@ backwpup
430
- msgid "https://marketpress.com/product/backwpup-pro/"
431
- msgstr "https://marketpress.de/product/backwpup-pro/"
432
-
433
- #. translators: plugin header field 'Description'
434
- #: backwpup.php:0
435
- #@ backwpup
436
- msgid "WordPress Backup Plugin"
437
- msgstr "WordPress Backup Plugin"
438
-
439
- #. translators: plugin header field 'Author'
440
- #: backwpup.php:0
441
- #@ backwpup
442
- msgid "Inpsyde GmbH"
443
- msgstr "Inpsyde GmbH"
444
-
445
- #. translators: plugin header field 'AuthorURI'
446
- #: backwpup.php:0
447
- #@ backwpup
448
- msgid "http://inpsyde.com"
449
- msgstr "http://inpsyde.com"
450
-
451
- #: inc/class-page-about.php:602
452
- #: inc/pro/class-pro.php:123
453
- #@ backwpup
454
- msgid "Backup to Google Drive"
455
- msgstr "Backup zu Google Drive"
456
-
457
- #: inc/class-page-about.php:607
458
- #: inc/pro/class-pro.php:104
459
- #@ backwpup
460
- msgid "Backup to Amazon Glacier"
461
- msgstr "Backup zu Amazon Glacier"
462
 
463
- #: inc/class-page-jobs.php:123
464
- #@ backwpup
465
- msgid "Last log"
466
- msgstr "Letztes Log"
 
467
 
468
- #: inc/pro/class-destination-gdrive.php:55
469
- #: inc/pro/class-destination-gdrive.php:143
470
- #: inc/pro/class-destination-gdrive.php:171
471
- #: inc/pro/class-destination-gdrive.php:226
472
  #, php-format
473
- #@ backwpup
474
- msgid "GDrive API: %s"
475
- msgstr "GDrive API: %s"
476
 
477
- #: inc/pro/class-destination-gdrive.php:138
478
- #: inc/pro/class-destination-gdrive.php:167
479
- #@ backwpup
480
- msgid "GDrive: Authenticated."
481
- msgstr "GDrive: Authentifiziert."
482
 
483
- #: inc/pro/class-destination-gdrive.php:344
 
484
  #, php-format
485
- #@ backwpup
486
- msgid "%d. Try to send backup file to Google Drive&#160;&hellip;"
487
- msgstr "%d. Versuche das Backup zu Google Drive zu senden&#160;&hellip;"
488
-
489
- #: inc/pro/class-destination-gdrive.php:369
490
- #@ backwpup
491
- msgid "Uploading to Google Drive&#160;&hellip;"
492
- msgstr "Upload zu Google Drive&#160;&hellip;"
493
 
494
- #: inc/pro/class-destination-gdrive.php:413
495
- #@ backwpup
496
- msgid "Google Drive API: could not create resumable file"
497
- msgstr "Google Drive API: kann keine fortsetzbare Datei generieren"
498
 
499
- #: inc/pro/class-destination-gdrive.php:447
500
- #@ backwpup
501
- msgid "Can not resume transfer backup to Google Drive!"
502
- msgstr "Kann den Backup-Transfer zu Google Drive nicht fortsetzen!"
 
503
 
504
- #: inc/pro/class-destination-gdrive.php:562
 
505
  #, php-format
506
- #@ backwpup
507
- msgid "Error while deleting file from Google Drive: %s"
508
- msgstr "Fehler beim Löschen der Datei von Google Drive: %s"
509
 
510
- #: inc/pro/class-destination-gdrive.php:565
 
511
  #, php-format
512
- #@ backwpup
513
- msgid "One file deleted from Google Drive"
514
- msgid_plural "%d files deleted on Google Drive"
515
- msgstr[0] "Eine Datei von Google Drive gelöscht"
516
- msgstr[1] "%d Dateien von Google Drive gelöscht"
517
 
518
- #: inc/pro/class-destination-gdrive.php:571
519
- #: inc/pro/class-destination-gdrive.php:785
520
  #, php-format
521
- #@ backwpup
522
- msgid "Google Drive API: %s"
523
- msgstr "Google Drive API: %s"
524
 
525
- #: inc/pro/class-destination-gdrive.php:604
 
526
  #, php-format
527
- #@ backwpup
528
- msgid "%d. Try to sync files to Google Drive&#160;&hellip;"
529
- msgstr "%d. Versuche Dateien mit Google Drive zu synchronisieren&#160;&hellip;"
 
530
 
531
- #: inc/pro/class-destination-gdrive.php:625
532
- #@ backwpup
533
- msgid "Retrieving folder list from Google Drive"
534
- msgstr "Abrufen der Ordnerliste von Google Drive"
535
 
536
- #: inc/pro/class-destination-gdrive.php:642
537
- #@ backwpup
538
- msgid "Syncing changed files to Google Drive"
539
- msgstr "Synchronisiere geänderte Dateien mit Google Drive"
540
 
541
- #: inc/pro/class-destination-gdrive.php:679
542
- #, php-format
543
- #@ backwpup
544
- msgid "File %s updated on Google Drive"
545
- msgstr "Datei %s auf Google Drive aktualisiert"
546
 
547
- #: inc/pro/class-destination-gdrive.php:698
 
548
  #, php-format
549
- #@ backwpup
550
- msgid "File %s uploaded to Google Drive"
551
- msgstr "Datei %s zu Google Drive hochgeladen"
552
 
553
- #: inc/pro/class-destination-gdrive.php:757
554
- #, php-format
555
- #@ backwpup
556
- msgid "Extra file %s updated on Google Drive"
557
- msgstr "Extra Datei %s auf Google Drive aktualisiert"
558
 
559
- #: inc/pro/class-destination-gdrive.php:775
 
560
  #, php-format
561
- #@ backwpup
562
- msgid "Extra file %s uploaded to Google Drive"
563
- msgstr "Extra Datei %s auf Google Drive hochgeladen"
564
 
565
- #: inc/pro/class-destination-glacier.php:26
566
- #@ backwpup
567
- msgid "Amazon Glacier"
568
- msgstr "Amazon Glacier"
569
 
570
- #: inc/pro/class-destination-glacier.php:32
571
- #: inc/pro/class-destination-glacier.php:153
572
- #@ backwpup
573
- msgid "Amazon Glacier Region"
574
- msgstr "Amazon Glacier Region"
575
 
576
- #: inc/pro/class-destination-glacier.php:33
577
- #: inc/pro/class-destination-glacier.php:154
578
- #@ backwpup
579
- msgid "US Standard"
580
- msgstr "US Standard"
581
 
582
- #: inc/pro/class-destination-glacier.php:34
583
- #: inc/pro/class-destination-glacier.php:155
584
- #@ backwpup
585
- msgid "US West (Northern California)"
586
- msgstr "US West (Northern California)"
587
 
588
- #: inc/pro/class-destination-glacier.php:35
589
- #: inc/pro/class-destination-glacier.php:156
590
- #@ backwpup
591
- msgid "US West (Oregon)"
592
- msgstr "US West (Oregon)"
593
 
594
- #: inc/pro/class-destination-glacier.php:36
595
- #: inc/pro/class-destination-glacier.php:157
596
- #@ backwpup
597
- msgid "EU (Ireland)"
598
- msgstr "EU (Ireland)"
599
 
600
- #: inc/pro/class-destination-glacier.php:37
601
- #: inc/pro/class-destination-glacier.php:158
602
- #@ backwpup
603
- msgid "Asia Pacific (Tokyo)"
604
- msgstr "Asia Pacific (Tokyo)"
605
 
606
- #: inc/pro/class-destination-glacier.php:38
607
- #: inc/pro/class-destination-glacier.php:159
608
- #@ backwpup
609
- msgid "Asia Pacific (Singapore)"
610
- msgstr "Asia Pacific (Singapore)"
611
 
612
- #: inc/pro/class-destination-glacier.php:39
613
- #: inc/pro/class-destination-glacier.php:160
614
- #@ backwpup
615
- msgid "Asia Pacific (Sydney)"
616
- msgstr "Asia Pacific (Sydney)"
617
 
618
- #: inc/pro/class-destination-glacier.php:40
619
- #: inc/pro/class-destination-glacier.php:161
620
- #@ backwpup
621
- msgid "South America (Sao Paulo)"
622
- msgstr "South America (Sao Paulo)"
623
 
624
- #: inc/pro/class-destination-glacier.php:47
625
- #@ backwpup
626
- msgid "Amazon Access Keys"
627
- msgstr "Amazon Zugriffsschlüssel"
628
 
629
- #: inc/pro/class-destination-glacier.php:66
630
- #@ backwpup
631
- msgid "Vault"
632
- msgstr "Tresor"
633
 
634
- #: inc/pro/class-destination-glacier.php:70
635
- #@ backwpup
636
- msgid "Vault selection"
637
- msgstr "Tresorauswahl"
638
 
639
- #: inc/pro/class-destination-glacier.php:82
640
- #@ backwpup
641
- msgid "Create a new vault"
642
- msgstr "Neuen Tresor erstellen"
643
 
644
- #: inc/pro/class-destination-glacier.php:89
645
- #@ backwpup
646
- msgid "Glacier Backup settings"
647
- msgstr "Glacier Backup Einstellungen"
648
 
649
- #: inc/pro/class-destination-glacier.php:129
650
- #: inc/pro/class-destination-glacier.php:213
651
  #, php-format
652
- #@ backwpup
653
- msgid "Vault %1$s created."
654
- msgstr "Tresor %1$s erstellt."
655
 
656
- #: inc/pro/class-destination-glacier.php:131
657
- #: inc/pro/class-destination-glacier.php:215
658
- #, php-format
659
- #@ backwpup
660
- msgid "Vault %s could not be created."
661
- msgstr "Tresor %s konnte nicht erstellt werden."
662
 
663
- #: inc/pro/class-destination-glacier.php:152
664
- #@ backwpup
665
- msgid "Select an Amazon Glacier region:"
666
- msgstr "Wähle Amazon Glacier Region:"
667
 
668
- #: inc/pro/class-destination-glacier.php:167
669
- #@ backwpup
670
- msgid "Vault:"
671
- msgstr "Tresor:"
672
 
673
- #: inc/pro/class-destination-glacier.php:176
674
- #@ backwpup
675
- msgid "New Vault:"
676
- msgstr "Neuer Tresor:"
677
 
678
- #: inc/pro/class-destination-glacier.php:256
679
- #: inc/pro/class-destination-glacier.php:372
680
- #: inc/pro/class-destination-glacier.php:388
681
- #: inc/pro/class-destination-glacier.php:428
682
  #, php-format
683
- #@ backwpup
684
- msgid "AWS API: %s"
685
- msgstr "AWS API: %s"
686
 
687
- #: inc/pro/class-destination-glacier.php:280
688
- #, php-format
689
- #@ backwpup
690
- msgid "%d. Trying to send backup file to Amazon Glacier&#160;&hellip;"
691
- msgstr "%d. Versuche Backup-Datei zu Amazon Glacier zu senden&#160;&hellip;"
692
 
693
- #: inc/pro/class-destination-glacier.php:295
694
- #, php-format
695
- #@ backwpup
696
- msgid "Glacier vault \"%s\" does not exist!"
697
- msgstr "Glacier Tresor \"%s\" existiert nicht!"
698
 
699
- #: inc/pro/class-destination-glacier.php:301
700
- #@ backwpup
701
- msgid "Starting upload to Amazon Glacier&#160;&hellip;"
702
- msgstr "Upload zu Amazon Glacier wird gestartet&#160;&hellip;"
 
703
 
704
- #: inc/pro/class-destination-glacier.php:354
705
- #, php-format
706
- #@ backwpup
707
- msgid "Archive ID: %s"
708
- msgstr "Archiv ID: %s"
709
 
710
- #: inc/pro/class-destination-glacier.php:418
711
- #, php-format
712
- #@ backwpup
713
- msgid "Cannot delete archive from %s."
714
- msgstr "Kann das Archiv aus %s nicht löschen."
715
 
716
- #: inc/pro/class-destination-glacier.php:422
717
- #, php-format
718
- #@ backwpup
719
- msgid "One file deleted on vault."
720
- msgid_plural "%d files deleted on vault"
721
- msgstr[0] "Eine Datei aus Tresor entfernt."
722
- msgstr[1] "%d Dateien aus Tresor entfernt"
723
 
724
- #: inc/pro/class-destination-glacier.php:536
725
- #@ backwpup
726
- msgid "No vault found!"
727
- msgstr "Kein Tresor gefunden!"
728
 
729
- #: inc/pro/class-destination-glacier.php:365
730
- #: inc/pro/class-pro.php:103
731
- #@ backwpup
732
- msgid "Glacier"
733
- msgstr "Glacier"
734
 
735
- #: inc/pro/class-pro.php:122
736
- #@ backwpup
737
- msgid "GDrive"
738
- msgstr "GDrive"
739
 
740
- #: inc/pro/class-wizard-job.php:394
741
- #@ backwpup
742
- msgid "Tar (fast and memory less) uncompressed"
743
- msgstr "Tar (schnell und speicherschonend) unkomprimiert"
744
 
745
- #: inc/class-page-jobs.php:213
746
- #, php-format
747
- #@ backwpup
748
- msgid "Cron: %s"
749
- msgstr "Cron: %s"
750
 
751
- #: inc/pro/class-jobtype-dbdump.php:166
752
- #@ backwpup
753
- msgid "Database Backup type"
754
- msgstr "Datenbank Backup Typ"
755
 
756
- #: inc/class-page-settings.php:137
757
- #@ backwpup
758
- msgid "Show BackWPup links in admin bar."
759
- msgstr "BackWPup-Links in der Adminbar anzeigen."
760
 
761
- #: inc/class-page-settings.php:385
762
- #@ backwpup
763
- msgid "Temp folder:"
764
- msgstr "Temp Verzeichnis:"
765
 
766
- #: inc/pro/class-settings-apikeys.php:42
767
- #@ backwpup
768
- msgid "Hash key"
769
- msgstr "Hash key"
770
 
771
- #: inc/pro/class-destination-folder.php:18
772
- #@ backwpup
773
- msgid "Absolute path to folder for backup files:"
774
- msgstr "Absoluter Ordner-Pfad für Backup-Dateien:"
775
 
776
- #: inc/pro/class-jobtype-dbdump.php:171
777
- #@ backwpup
778
- msgid "XML File (phpMyAdmin schema)"
779
- msgstr "XML Datei (phpMyAdmin Schema)"
780
 
781
- #: inc/pro/class-jobtype-dbdump.php:177
782
- #@ backwpup
783
- msgid "Path to <em>mysqldump</em> file"
784
- msgstr "Pfad zur <em>mysqldump</em> Datei"
785
 
786
- #: inc/pro/class-jobtype-dbdump.php:179
787
- #@ backwpup
788
- msgid "Path to mysqldump file, so a backup can be made with it. If it is correct and <em>shell_exec</em> is active, the backup will be generated with a system command. If <em>shell_exec</em> ist not active, this is disabled"
789
- msgstr "Pfad zur MySQL-Dump Datei zum erstellen eines Backups. Wenn diese in Ordnung ist und <em>shell_exec</em> aktiviert wurde, wird ein Backup per Systembefehl generiert. Wenn <em>shell_exec</em> nicht aktiviert wurde, ist dieser Befehl deaktiviert."
790
 
791
- #: inc/pro/class-jobtype-dbdump.php:170
792
- #@ backwpup
793
- msgid "SQL File"
794
- msgstr "SQL Datei"
795
 
796
- #: inc/class-page-jobs.php:207
797
- #, php-format
798
- #@ backwpup
799
- msgid "Running for: %s seconds"
800
- msgstr "Läuft seit %s Sekunden"
801
 
802
- #: inc/class-page-editjob.php:815
803
- #@ backwpup
804
- msgid "August"
805
- msgstr "August"
806
 
807
- #: inc/class-page-editjob.php:860
808
- #@ backwpup
809
- msgid "Save changes"
810
- msgstr "Änderungen speichern"
811
 
812
- #: inc/class-page-jobs.php:213
813
- #, php-format
814
- #@ backwpup
815
- msgid "%1$s at %2$s by WP-Cron"
816
- msgstr "%1$s um %2$s mit WP-Cron"
817
 
818
- #: inc/class-page-jobs.php:240
819
- #, php-format
820
- #@ backwpup
821
- msgid "Runtime: %d seconds"
822
- msgstr "Ausführungszeit: %d Sekunden"
823
 
824
- #: inc/class-page-jobs.php:243
825
- #@ backwpup
826
- msgid "not yet"
827
- msgstr "noch nicht"
828
 
829
- #: inc/class-page-jobs.php:247
830
- #@ backwpup
831
- msgid "Download last backup"
832
- msgstr "Letztes Backup herunterladen"
833
 
834
- #: inc/class-page-jobs.php:347
835
- #: inc/class-page-settings.php:372
836
- #, php-format
837
- #@ backwpup
838
- msgid "The HTTP response test get an error \"%s\""
839
- msgstr "Der HTTP Antwort Test bekommt diesen Fehler \"%s\""
840
 
841
- #: inc/class-page-jobs.php:349
842
- #: inc/class-page-settings.php:374
843
- #, php-format
844
- #@ backwpup
845
- msgid "The HTTP response test get a false http status (%s)"
846
- msgstr "Der HTTP Antwort Test bekommt den falschen http Status (%s)"
847
 
848
- #: inc/class-page-jobs.php:356
849
- #, php-format
850
- #@ backwpup
851
- msgid "Job \"%s\" started."
852
- msgstr "Auftrag \"%s\" wurde gestartet."
853
 
854
- #: inc/class-page-jobs.php:517
855
- #, php-format
856
- #@ backwpup
857
- msgid "%s Jobs"
858
- msgstr "%s Auftr�
1
  msgid ""
2
  msgstr ""
3
+ "Project-Id-Version: BackWPup Pro v3.1.3\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2014-11-12 13:25+0100\n"
6
+ "PO-Revision-Date: 2014-11-12 13:26+0100\n"
7
+ "Last-Translator: Robert Windisch <r.windisch@inpsyde.com>\n"
8
  "Language-Team: \n"
9
+ "Language: \n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
14
+ "X-Generator: GlotPress/0.1\n"
 
 
15
  "X-Poedit-SourceCharset: utf-8\n"
16
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
17
+ "X-Poedit-Basepath: .\n"
18
+ "X-Textdomain-Support: yes\n"
19
  "X-Poedit-SearchPath-0: .\n"
20
+ "X-Poedit-SearchPath-1: ..\n"
21
 
22
+ # @ backwpup
23
+ #: ../backwpup.php:42
24
+ msgid "BackWPup requires PHP version 5.2.7 with spl extension or greater and WordPress 3.4 or greater."
25
+ msgstr "BackWPup benötigt PHP Version 5.2.7 oder höher mit der SPL-Erweiterung und WordPress 3.4 oder höher."
 
 
26
 
27
+ # @ backwpup
28
+ #: ../backwpup.php:289
29
+ msgid "Folder"
30
+ msgstr "Ordner"
31
 
32
+ # @ backwpup
33
+ #: ../backwpup.php:290
34
+ msgid "Backup to Folder"
35
+ msgstr "Backup in Ordner"
36
 
37
+ # @ backwpup
38
+ #: ../backwpup.php:305
39
+ msgid "Email"
40
+ msgstr "E-Mail"
41
 
42
+ # @ backwpup
43
+ #: ../backwpup.php:306
44
+ msgid "Backup sent via email"
45
+ msgstr "Backup als E-Mail versendet"
 
 
46
 
47
+ # @ backwpup
48
+ #: ../backwpup.php:321
49
+ msgid "FTP"
50
+ msgstr "FTP"
 
 
51
 
52
+ # @ backwpup
53
+ #: ../backwpup.php:322
54
+ msgid "Backup to FTP"
55
+ msgstr "Backup zu FTP"
 
56
 
57
+ # @ backwpup
58
+ #: ../backwpup.php:337
59
+ msgid "Dropbox"
60
+ msgstr "Dropbox"
 
61
 
62
+ # @ backwpup
63
+ #: ../backwpup.php:338
64
+ msgid "Backup to Dropbox"
65
+ msgstr "Backup in die Dropbox"
 
 
66
 
67
+ # @ backwpup
68
+ #: ../backwpup.php:354
69
+ #: ../backwpup.php:373
70
+ msgid "S3 Service"
71
+ msgstr "S3 Service"
72
 
73
+ # @ backwpup
74
+ #: ../backwpup.php:355
75
+ msgid "Backup to an S3 Service"
76
+ msgstr "Backup zu einem S3 Service"
 
77
 
78
+ # @ backwpup
79
+ #: ../backwpup.php:374
80
+ msgid "Backup to an S3 Service v1"
81
+ msgstr "Backup auf S3 Service v1"
 
82
 
83
+ # @ backwpup
84
+ #: ../backwpup.php:390
85
+ msgid "MS Azure"
86
+ msgstr "MS Azure"
 
87
 
88
+ # @ backwpup
89
+ #: ../backwpup.php:391
90
+ msgid "Backup to Microsoft Azure (Blob)"
91
+ msgstr "Backup zu Microsoft Azure (Blob)"
 
92
 
93
+ # @ backwpup
94
+ #: ../backwpup.php:406
95
+ msgid "RSC"
96
+ msgstr "RSC"
 
97
 
98
+ # @ backwpup
99
+ #: ../backwpup.php:407
100
+ msgid "Backup to Rackspace Cloud Files"
101
+ msgstr "Backup in die Rackspace Cloud"
 
102
 
103
+ # @ backwpup
104
+ #: ../backwpup.php:423
105
+ msgid "SugarSync"
106
+ msgstr "SugarSync"
107
 
108
+ # @ backwpup
109
+ #: ../backwpup.php:424
110
+ msgid "Backup to SugarSync"
111
+ msgstr "Backup zu SugarSync"
112
 
113
+ # @ backwpup
114
+ #: ../backwpup.php:443
115
  #, php-format
116
+ msgid "PHP Version %1$s is to low, you need Version %2$s or above."
117
+ msgstr "Du nutzt die veraltete PHP Version %1$s. Es wird aber mindestens die Version %2$s benötigt."
 
 
118
 
119
+ # @ backwpup
120
+ #: ../backwpup.php:450
121
  #, php-format
122
+ msgid "Missing function \"%s\"."
123
+ msgstr "Fehlende Funktion \"%s\"."
 
124
 
125
+ # @ backwpup
126
+ #: ../backwpup.php:459
127
  #, php-format
128
+ msgid "Missing class \"%s\"."
129
+ msgstr "Fehlende Klasse \"%s\"."
 
130
 
131
+ # @ backwpup
132
+ #: ../inc/class-destination-folder.php:26
133
+ #: ../inc/class-destination-ftp.php:52
134
+ msgid "Backup settings"
135
+ msgstr "Backup-Einstellungen"
136
 
137
+ # @ backwpup
138
+ #: ../inc/class-destination-folder.php:30
139
+ msgid "Folder to store backups in"
140
+ msgstr "Order für Dateien"
 
141
 
142
+ # @ backwpup
143
+ #: ../inc/class-destination-folder.php:36
144
+ #: ../inc/class-destination-ftp.php:62
145
+ msgid "File Deletion"
146
+ msgstr "Dateilöschung"
147
 
148
+ # @ backwpup
149
+ #: ../inc/class-destination-folder.php:42
150
+ #: ../inc/class-destination-s3.php:160
151
+ msgid "Number of files to keep in folder."
152
+ msgstr "Anzahl der Dateien, die im Ordner behalten werden"
153
 
154
+ # @ backwpup
155
+ #: ../inc/class-destination-folder.php:46
156
+ #: ../inc/class-destination-s3.php:164
157
+ #: ../inc/class-destination-ftp.php:72
158
+ msgid "Do not delete files while syncing to destination!"
159
+ msgstr "Keine Dateien im Sync-Zielverzeichnis löschen!"
160
 
161
+ # @ backwpup
162
+ #: ../inc/class-destination-folder.php:194
163
  #, php-format
164
+ msgid "One backup file deleted"
165
+ msgid_plural "%d backup files deleted"
166
+ msgstr[0] "Eine Sicherungsdatei gelöscht"
167
+ msgstr[1] "%d Sicherungsdateien gelöscht"
 
 
 
 
 
168
 
169
+ # @ backwpup
170
+ #: ../inc/class-destination-s3.php:74
171
+ msgid "Select a S3 service"
172
+ msgstr "Wähle einen S3 Service"
173
 
174
+ # @ backwpup
175
+ #: ../inc/class-destination-s3.php:76
176
+ msgid "Amazon S3 Region"
177
+ msgstr "Amazon S3 Region"
 
178
 
179
+ # @ backwpup
180
+ #: ../inc/class-destination-s3.php:77
181
+ msgid "Amazon S3: US Standard"
182
+ msgstr "Amazon S3: US Standard"
 
183
 
184
+ # @ backwpup
185
+ #: ../inc/class-destination-s3.php:78
186
+ msgid "Amazon S3: US West (Northern California)"
187
+ msgstr "Amazon S3: US West (Northern California)"
 
188
 
189
+ # @ backwpup
190
+ #: ../inc/class-destination-s3.php:79
191
+ msgid "Amazon S3: US West (Oregon)"
192
+ msgstr "Amazon S3: US West (Oregon)"
 
193
 
194
+ # @ backwpup
195
+ #: ../inc/class-destination-s3.php:80
196
+ msgid "Amazon S3: EU (Ireland)"
197
+ msgstr "Amazon S3: EU (Ireland)"
 
198
 
199
+ # @ backwpup
200
+ #: ../inc/class-destination-s3.php:81
201
+ msgid "Amazon S3: EU (Germany)"
202
+ msgstr "Amazon S3: EU (Germany)"
 
203
 
204
+ # @ backwpup
205
+ #: ../inc/class-destination-s3.php:82
206
+ msgid "Amazon S3: Asia Pacific (Tokyo)"
207
+ msgstr "Amazon S3: Asia Pacific (Tokyo)"
 
208
 
209
+ # @ backwpup
210
+ #: ../inc/class-destination-s3.php:83
211
+ msgid "Amazon S3: Asia Pacific (Singapore)"
212
+ msgstr "Amazon S3: Asia Pacific (Singapore)"
 
213
 
214
+ # @ backwpup
215
+ #: ../inc/class-destination-s3.php:84
216
+ msgid "Amazon S3: Asia Pacific (Sydney)"
217
+ msgstr "Amazon S3: Asia Pacific (Sydney)"
 
218
 
219
+ # @ backwpup
220
+ #: ../inc/class-destination-s3.php:85
221
+ msgid "Amazon S3: South America (Sao Paulo)"
222
+ msgstr "Amazon S3: South America (Sao Paulo)"
 
 
223
 
224
+ # @ backwpup
225
+ #: ../inc/class-destination-s3.php:86
226
+ msgid "Amazon S3: China (Beijing)"
227
+ msgstr "Amazon S3: China (Beijing)"
228
 
229
+ # @ backwpup
230
+ #: ../inc/class-destination-s3.php:87
231
+ msgid "Google Storage (Interoperable Access)"
232
+ msgstr "Google Storage (Interoperable Access)"
 
 
233
 
234
+ # @ backwpup
235
+ #: ../inc/class-destination-s3.php:88
236
+ msgid "Dream Host Cloud Storage"
237
+ msgstr "Dream Host Cloud Storage"
238
 
239
+ # @ backwpup
240
+ #: ../inc/class-destination-s3.php:89
241
+ msgid "GreenQloud Storage Qloud"
242
+ msgstr "GreenQloud Storage Qloud"
 
 
243
 
244
+ # @ backwpup
245
+ #: ../inc/class-destination-s3.php:94
246
+ msgid "Or a S3 Server URL"
247
+ msgstr "oder eine S3 Server URL"
 
248
 
249
+ # @ backwpup
250
+ #: ../inc/class-destination-s3.php:101
251
+ msgid "S3 Access Keys"
252
+ msgstr "S3 Access Keys"
 
 
 
253
 
254
+ # @ backwpup
255
+ #: ../inc/class-destination-s3.php:105
256
+ msgid "Access Key"
257
+ msgstr "Access Key"
 
258
 
259
+ # @ backwpup
260
+ #: ../inc/class-destination-s3.php:112
261
+ msgid "Secret Key"
262
+ msgstr "Secret Key"
 
263
 
264
+ # @ backwpup
265
+ #: ../inc/class-destination-s3.php:120
266
+ msgid "S3 Bucket"
267
+ msgstr "S3 Bucket"
 
268
 
269
+ # @ backwpup
270
+ #: ../inc/class-destination-s3.php:124
271
+ msgid "Bucket selection"
272
+ msgstr "Bucket Auswahl"
 
 
273
 
274
+ # @ backwpup
275
+ #: ../inc/class-destination-s3.php:137
276
+ msgid "Create a new bucket"
277
+ msgstr "Neues Bucket erstellen"
 
 
278
 
279
+ # @ backwpup
280
+ #: ../inc/class-destination-s3.php:144
281
+ msgid "S3 Backup settings"
282
+ msgstr "S3 Backup Einstellungen"
 
 
283
 
284
+ # @ backwpup
285
+ #: ../inc/class-destination-s3.php:148
286
+ msgid "Folder in bucket"
287
+ msgstr "Ordner im Bucket"
 
 
288
 
289
+ # @ backwpup
290
+ #: ../inc/class-destination-s3.php:154
291
+ msgid "File deletion"
292
+ msgstr "Datei Löschung"
293
 
294
+ # @ backwpup
295
+ #: ../inc/class-destination-s3.php:170
296
+ msgid "Multipart Upload"
297
+ msgstr "Multipart Upload"
298
 
299
+ # @ backwpup
300
+ #: ../inc/class-destination-s3.php:174
301
+ msgid "Use multipart upload for uploading a file"
302
+ msgstr "Benutze Multipart Upload zu hochladen der Datei"
 
303
 
304
+ # @ backwpup
305
+ #: ../inc/class-destination-s3.php:180
306
+ msgid "Amazon specific settings"
307
+ msgstr "Amazon spezifische Einstellungen"
308
 
309
+ # @ backwpup
310
+ #: ../inc/class-destination-s3.php:184
311
+ #: ../inc/class-destination-s3.php:186
312
+ msgid "Amazon: Storage Class"
313
+ msgstr "Amazon: Storage Class"
314
 
315
+ # @ backwpup
316
+ #: ../inc/class-destination-s3.php:187
317
+ msgid "none"
318
+ msgstr "keine"
319
 
320
+ # @ backwpup
321
+ #: ../inc/class-destination-s3.php:188
322
+ msgid "Reduced Redundancy"
323
+ msgstr "Reduzierte Redundanz"
324
 
325
+ # @ backwpup
326
+ #: ../inc/class-destination-s3.php:193
327
+ msgid "Server side encryption"
328
+ msgstr "Serverseitige Enkryption"
329
 
330
+ # @ backwpup
331
+ #: ../inc/class-destination-s3.php:197
332
+ msgid "Save files encrypted (AES256) on server."
333
+ msgstr "Speicher Dateien Server Side Encrypted (AES256)"
 
 
 
 
 
 
 
334
 
335
+ # @ backwpup
336
+ #: ../inc/class-destination-s3.php:253
337
  #, php-format
338
+ msgid "Bucket %1$s created in %2$s."
339
+ msgstr "Bucket %1$s in %2$s erstellt."
 
340
 
341
+ # @ backwpup
342
+ #: ../inc/class-destination-s3.php:255
343
  #, php-format
344
+ msgid "Bucket %s could not be created."
345
+ msgstr "Bucket %s konnte nicht erstellt werden."
 
346
 
347
+ # @ backwpup
348
+ #: ../inc/class-destination-s3.php:257
349
  #, php-format
350
+ msgid " %s is not a valid bucket name."
351
+ msgstr "%s ist kein gültiger Bucket Name"
 
 
 
 
 
 
352
 
353
+ # @ backwpup
354
+ #: ../inc/class-destination-s3.php:297
355
+ #: ../inc/class-destination-s3.php:418
356
+ #: ../inc/class-destination-s3.php:471
357
+ #: ../inc/class-destination-s3.php:501
358
+ #: ../inc/class-destination-s3.php:561
359
  #, php-format
360
+ msgid "S3 Service API: %s"
361
+ msgstr "S3 Service API: %s"
 
362
 
363
+ # @ backwpup
364
+ #: ../inc/class-destination-s3.php:361
365
  #, php-format
366
+ msgid "%d. Trying to send backup file to S3 Service&#160;&hellip;"
367
+ msgstr "%d. Versuche, ein Backup zum S3-Service zu senden&#160;&hellip;"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
368
 
369
+ # @ backwpup
370
+ #: ../inc/class-destination-s3.php:374
371
+ #, php-format
372
+ msgid "Connected to S3 Bucket \"%1$s\" in %2$s"
373
+ msgstr "Verbunden zum S3 Bucket \"%1$s\" in %2$s"
374
 
375
+ # @ backwpup
376
+ #: ../inc/class-destination-s3.php:377
 
 
377
  #, php-format
378
+ msgid "S3 Bucket \"%s\" does not exist!"
379
+ msgstr "Amazon S3 Bucket \"%s\" existiert nicht!"
 
380
 
381
+ # @ backwpup
382
+ #: ../inc/class-destination-s3.php:384
383
+ msgid "Checking for not aborted multipart Uploads&#160;&hellip;"
384
+ msgstr "Prüfe auf nicht abgebrochene, mehrteilige Uploads&#160;&hellip;"
 
385
 
386
+ # @ backwpup
387
+ #: ../inc/class-destination-s3.php:390
388
  #, php-format
389
+ msgid "Upload for %s aborted."
390
+ msgstr "Upload für %s abgebrochen."
 
 
 
 
 
 
391
 
392
+ # @ backwpup
393
+ #: ../inc/class-destination-s3.php:396
394
+ msgid "Starting upload to S3 Service&#160;&hellip;"
395
+ msgstr "Upload zum S3 Service begonnen&#160;&hellip;"
396
 
397
+ # @ backwpup
398
+ #: ../inc/class-destination-s3.php:492
399
+ #, php-format
400
+ msgid "Backup transferred to %s."
401
+ msgstr "Backup übertragen zu %s"
402
 
403
+ # @ backwpup
404
+ #: ../inc/class-destination-s3.php:497
405
  #, php-format
406
+ msgid "Cannot transfer backup to S3! (%1$d) %2$s"
407
+ msgstr "Backup kann nicht zu Amazon S3 übertragen werden! (%1$d) %2$s"
 
408
 
409
+ # @ backwpup
410
+ #: ../inc/class-destination-s3.php:525
411
  #, php-format
412
+ msgid "Storage Class: %s"
413
+ msgstr "Speicher-Klasse: %s"
 
 
 
414
 
415
+ # @ backwpup
416
+ #: ../inc/class-destination-s3.php:551
417
  #, php-format
418
+ msgid "Cannot delete backup from %s."
419
+ msgstr "Kann das Backup auf %s nicht löschen"
 
420
 
421
+ # @ backwpup
422
+ #: ../inc/class-destination-s3.php:555
423
  #, php-format
424
+ msgid "One file deleted on S3 Bucket."
425
+ msgid_plural "%d files deleted on S3 Bucket"
426
+ msgstr[0] "Eine Datei im S3-Bucket gelöscht"
427
+ msgstr[1] "%d Dateien im S3-Bucket gelöscht"
428
 
429
+ # @ backwpup
430
+ #: ../inc/class-destination-s3.php:658
431
+ msgid "Missing access key!"
432
+ msgstr "Der Zugangsschlüssel (Access Key) fehlt!"
433
 
434
+ # @ backwpup
435
+ #: ../inc/class-destination-s3.php:660
436
+ msgid "Missing secret access key!"
437
+ msgstr "Der geheime Zugangsschlüssel (Secret Access Key) fehlt!"
438
 
439
+ # @ backwpup
440
+ #: ../inc/class-destination-s3.php:666
441
+ msgid "No bucket found!"
442
+ msgstr "Kein Bucket gefunden!"
 
443
 
444
+ # @ backwpup
445
+ #: ../inc/class-page-about.php:394
446
  #, php-format
447
+ msgid "%s Welcome"
448
+ msgstr "%s Willkommen"
 
449
 
450
+ # @ backwpup
451
+ #: ../inc/class-page-about.php:401
452
+ msgid "Heads up! You have updated from version 2.x"
453
+ msgstr "Achtung! Sie haben von Version 2.x aktualisiert"
 
454
 
455
+ # @ backwpup
456
+ #: ../inc/class-page-about.php:402
457
  #, php-format
458
+ msgid "Please <a href=\"%s\">check your settings</a> after updating from version 2.x:"
459
+ msgstr "Bitte <a href=\"%s\">prüfen Sie Ihre Einstellungen</a> nach dem Update von Version 2.x."
 
460
 
461
+ # @ backwpup
462
+ #: ../inc/class-page-about.php:403
463
+ msgid "Dropbox authentication must be re-entered"
464
+ msgstr "Die Drohbox-Authentifizierung muss wiederholt werden."
465
 
466
+ # @ backwpup
467
+ #: ../inc/class-page-about.php:404
468
+ msgid "SugarSync authentication must be re-entered"
469
+ msgstr "Die SugarSync-Authentifizierung muss wiederholt werden"
 
470
 
471
+ # @ backwpup
472
+ #: ../inc/class-page-about.php:405
473
+ msgid "S3 Settings"
474
+ msgstr "S3-Einstellungen"
 
475
 
476
+ # @ backwpup
477
+ #: ../inc/class-page-about.php:406
478
+ msgid "Google Storage is now a part of S3 service settings"
479
+ msgstr "Google Storage ist jetzt Teil der S3-Einstellungen"
 
480
 
481
+ # @ backwpup
482
+ #: ../inc/class-page-about.php:407
483
+ msgid "All your passwords"
484
+ msgstr "All Ihre Passwörter"
 
485
 
486
+ # @ backwpup
487
+ #: ../inc/class-page-about.php:416
488
+ msgid "Welcome to BackWPup Pro"
489
+ msgstr "Willkommen zu BackWPup Pro"
 
490
 
491
+ # @ backwpup
492
+ #: ../inc/class-page-about.php:417
493
+ msgid "BackWPup’s job wizards make planning and scheduling your backup jobs a breeze."
494
+ msgstr "Die Assistenten in BackWPup machen das Planen und terminieren deiner Sicherungen zu einem Spaziergang."
 
495
 
496
+ # @ backwpup
497
+ #: ../inc/class-page-about.php:418
498
+ #: ../inc/class-page-about.php:428
499
+ msgid "Use your backup archives to save your entire WordPress installation including <code>/wp-content/</code>. Push them to an external storage service if you don’t want to save the backups on the same server. With a single backup archive you are able to restore an installation. Use a tool like phpMyAdmin or a plugin like <a href=\"http://wordpress.org/plugins/adminer/\" target=\"_blank\">Adminer</a> to restore your database backup files."
500
+ msgstr "Benutze deine Backup-Archive, um deine gesamte WordPress-Installation zu sichern, einschließlich <code>/wp-content/</code>. Lade sie zu einem externen Dienst hoch, wenn du deine Backups nicht auf demselben Server speichern möchtest. Mit einem einzigen Backup-Archiv kannst du deine Installation wiederherstellen. Benutze ein serverseitiges Tool wie phpMyAdmin, oder ein Plugin wie <a href=\"http://wordpress.org/plugins/adminer/\" target=\"_blank\">Adminer</a>, um deine Datenbanksicherung wiederherzustellen."
501
 
502
+ # @ backwpup
503
+ #: ../inc/class-page-about.php:419
504
+ #, php-format
505
+ msgid "Ready to <a href=\"%1$s\">set up a backup job</a>? You can <a href=\"%2$s\">use the wizards</a> or plan your backup in expert mode."
506
+ msgstr "<a href=\"%1$s\">Bereit, einen Backup-Auftrag anzulegen</a>? Benutze die <a href=\"%2$s\">Assistenten</a>, oder plane dein Backup im Expertenmodus."
507
 
508
+ # @ backwpup
509
+ #: ../inc/class-page-about.php:426
510
+ msgid "Welcome to BackWPup"
511
+ msgstr "Willkommen bei BackWPup"
 
512
 
513
+ # @ backwpup
514
+ #: ../inc/class-page-about.php:429
515
+ msgid "Ready to set up a backup job? Use one of the wizards to plan what you want to save."
516
+ msgstr "Bereit, einen Backup-Auftrag anzulegen? Benutze einen der Assistenten, um deine Sicherung zu planen."
517
 
518
+ # @ backwpup
519
+ #: ../inc/class-page-about.php:446
520
+ msgid "Please activate your license"
521
+ msgstr "Bitte aktivieren Sie Ihre Lizenz."
522
 
523
+ # @ backwpup
524
+ #: ../inc/class-page-about.php:447
525
+ msgid "Please go to your plugin page and active the license to have the autoupdates enabled."
526
+ msgstr "Bitte gehen Sie auf die Plugin-Seite, und aktivieren Sie die Lizenz, um automatische Aktualisierungen zu aktivieren."
527
 
528
+ # @ backwpup
529
+ #: ../inc/class-page-about.php:456
530
+ msgid "Save your database"
531
+ msgstr "Sichern Sie Ihre Datenbank"
532
 
533
+ # @ backwpup
534
+ #: ../inc/class-page-about.php:459
535
+ msgid "Save your database regularly"
536
+ msgstr "Sichern Sie Ihre Datenbank regelmäßig"
537
 
538
+ # @ backwpup
539
+ #: ../inc/class-page-about.php:460
540
  #, php-format
541
+ msgid "With BackWPup you can schedule the database backup to run automatically. With a single backup file you can restore your database. You should <a href=\"%s\">set up a backup job</a>, so you will never forget it. There is also an option to repair and optimize the database after each backup."
542
+ msgstr "Mit BackWPup können Sie automatische Datenbank-Backups planen. Mit einer einzigen Backup-Datei können Sie Ihre Datenbank wiederherstellen. Sie sollten einen <a href=\\\"%s\\\">Backup-Auftrag einrichten</a>, damit Sie es nie mehr vergessen. Es gibt auch eine Option, um die Datenbank anschließend zu reparieren und zu optimieren."
 
543
 
544
+ # @ backwpup
545
+ #: ../inc/class-page-about.php:465
546
+ #: ../inc/class-page-about.php:469
547
+ msgid "WordPress XML Export"
548
+ msgstr "WordPress-XML-Export"
 
549
 
550
+ # @ backwpup
551
+ #: ../inc/class-page-about.php:466
552
+ msgid "You can choose the built-in WordPress export format in addition or exclusive to save your data. This works in automated backups too of course. The advantage is: you can import these files into a blog with the regular WordPress importer."
553
+ msgstr "Sie können das interne WordPress-Export-Format zusätzlich oder ausschließlich wählen, um Ihre Daten zu sichern. Das funktioniert natürlich auch in automatischen Backups. Der Vorteil: Sie können dieses Format mit dem normalen WordPress-Importer-Plugin importieren."
554
 
555
+ # @ backwpup
556
+ #: ../inc/class-page-about.php:474
557
+ msgid "Save all data from the webserver"
558
+ msgstr "Sichern Sie alle Daten vom Webserver"
559
 
560
+ # @ backwpup
561
+ #: ../inc/class-page-about.php:477
562
+ msgid "Save all files"
563
+ msgstr "Sichern Sie alle Dateien"
564
 
565
+ # @ backwpup
566
+ #: ../inc/class-page-about.php:478
 
 
567
  #, php-format
568
+ msgid "You can backup all your attachments, also all system files, plugins and themes in a single file. You can <a href=\"%s\">create a job</a> to update a backup copy of your file system only when files are changed."
569
+ msgstr "Sie können all Ihre Anhänge sichern, ebenso alle Systemdateien, Plugins und Themes – in einer einzigen Datei. Sie können einen <a href=\\\"%s\\\">Auftrag erstellen</a>, um die Sicherungskopie nur dann zu aktualisieren, wenn sich tatsächlich eine Datei geändert hat."
 
570
 
571
+ # @ backwpup
572
+ #: ../inc/class-page-about.php:483
573
+ #: ../inc/class-page-about.php:487
574
+ msgid "Security!"
575
+ msgstr "Sicherheit!"
576
 
577
+ # @ backwpup
578
+ #: ../inc/class-page-about.php:484
579
+ msgid "By default everything is encrypted: connections to external services, local files and access to directories."
580
+ msgstr "In der Grundeinstellung ist alles verschlüsselt: Verbindungen zu externen Diensten, lokale Dateien und der Zugriff auf die Verzeichnisse."
 
581
 
582
+ # @ backwpup
583
+ #: ../inc/class-page-about.php:492
584
+ #: ../inc/class-page-about.php:495
585
+ msgid "Cloud Support"
586
+ msgstr "Cloud-Support"
587
 
588
+ # @ backwpup
589
+ #: ../inc/class-page-about.php:496
590
+ msgid "BackWPup supports multiple cloud services in parallel. This ensures backups are redundant."
591
+ msgstr "BackWPup unterstützt mehrere Cloud-Dienste parallel. Damit wird sichergestellt, dass Sie redundante Backups anlegen können."
 
592
 
593
+ # @ backwpup
594
+ #: ../inc/class-page-about.php:504
595
+ msgid "Features / differences between Free and Pro"
596
+ msgstr "Features / Unterschiede zwischen Free und Pro"
 
597
 
598
+ # @ backwpup
599
+ #: ../inc/class-page-about.php:507
600
+ msgid "Features"
601
+ msgstr "Features"
 
 
 
602
 
603
+ # @ backwpup
604
+ #: ../inc/class-page-about.php:508
605
+ msgid "FREE"
606
+ msgstr "FREE"
607
 
608
+ # @ backwpup
609
+ #: ../inc/class-page-about.php:509
610
+ msgid "PRO"
611
+ msgstr "PRO"
 
612
 
613
+ # @ backwpup
614
+ #: ../inc/class-page-about.php:512
615
+ msgid "Complete database backup"
616
+ msgstr "Vollständige Datenbanksicherung"
617
 
618
+ # @ backwpup
619
+ #: ../inc/class-page-about.php:517
620
+ msgid "Complete file backup"
621
+ msgstr "Vollständige Dateisicherung"
622
 
623
+ # @ backwpup
624
+ #: ../inc/class-page-about.php:522
625
+ msgid "Database check"
626
+ msgstr "Datenbanküberprüfung"
 
627
 
628
+ # @ backwpup
629
+ #: ../inc/class-page-about.php:527
630
+ msgid "Data compression"
631
+ msgstr "Datenbankoptimierung"
632
 
633
+ # @ backwpup
634
+ #: ../inc/class-page-about.php:532
635
+ msgid "WordPress XML export"
636
+ msgstr "WordPress XML Export"
637
 
638
+ # @ backwpup
639
+ #: ../inc/class-page-about.php:537
640
+ msgid "List of installed plugins"
641
+ msgstr "Liste installierter Plugins"
642
 
643
+ # @ backwpup
644
+ #: ../inc/class-page-about.php:542
645
+ msgid "Backup archives management"
646
+ msgstr "Verwaltung der Backup-Archive"
647
 
648
+ # @ backwpup
649
+ #: ../inc/class-page-about.php:547
650
+ msgid "Log file management"
651
+ msgstr "Verwaltung der Log-Dateien"
652
 
653
+ # @ backwpup
654
+ #: ../inc/class-page-about.php:552
655
+ msgid "Start jobs per WP-Cron, URL, system, backend or WP-CLI"
656
+ msgstr "Start der Aufträge über WP-Cron, URL, System, Backend, WP-CLI"
657
 
658
+ # @ backwpup
659
+ #: ../inc/class-page-about.php:557
660
+ msgid "Log report via email"
661
+ msgstr "Log-Report via E-Mail"
662
 
663
+ # @ backwpup
664
+ #: ../inc/class-page-about.php:562
665
+ msgid "Backup to Microsoft Azure"
666
+ msgstr "Backup zu Microsoft Azure"
667
 
668
+ # @ backwpup
669
+ #: ../inc/class-page-about.php:567
670
+ msgid "Backup as email"
671
+ msgstr "Backup per E-Mail"
672
 
673
+ # @ backwpup
674
+ #: ../inc/class-page-about.php:572
675
+ msgid "Backup to S3 services <small>(Amazon, Google Storage, Hosteurope and more)</small>"
676
+ msgstr "Backup zu S3-Dienstleistern <small>(Amazon, Google Storage, Hosteurope, usw)</small>"
 
677
 
678
+ # @ backwpup
679
+ #: ../inc/class-page-about.php:587
680
+ msgid "Backup to FTP server"
681
+ msgstr "Backup auf FTP-Server"
682
 
683
+ # @ backwpup
684
+ #: ../inc/class-page-about.php:592
685
+ msgid "Backup to your web space"
686
+ msgstr "Backup auf eigenem Webspace"
687
 
688
+ # @ backwpup
689
+ #: ../inc/class-page-about.php:602
690
+ msgid "Backup to Google Drive"
691
+ msgstr "Backup zu Google Drive"
 
692
 
693
+ # @ backwpup
694
+ #: ../inc/class-page-about.php:607
695
+ msgid "Backup to Amazon Glacier"
696
+ msgstr "Backup zu Amazon Glacier"
 
697
 
698
+ # @ backwpup
699
+ #: ../inc/class-page-about.php:612
700
+ msgid "Custom API keys for DropBox and SugarSync"
701
+ msgstr "Eigene API-Keys für DropBox und SugarSync hinterlegen"
702
 
703
+ # @ backwpup
704
+ #: ../inc/class-page-about.php:617
705
+ msgid "XML database backup as PHPMyAdmin schema"
706
+ msgstr "XML-Datenbanksicherung der Datenbank nach PHPMyAdmin-Schema"
707
 
708
+ # @ backwpup
709
+ #: ../inc/class-page-about.php:622
710
+ msgid "Database backup as mysqldump per command line"
711
+ msgstr "Datenbanksicherung mit System-Kommando mysqldump"
 
 
712
 
713
+ # @ backwpup
714
+ #: ../inc/class-page-about.php:627
715
+ msgid "Database backup for additional MySQL databases"
716
+ msgstr "Datenbanksicherung weiterer MySQL-Datenbanken"
 
 
717
 
718
+ # @ backwpup
719
+ #: ../inc/class-page-about.php:632
720
+ msgid "Import and export job settings as XML"
721
+ msgstr "Auftragseinstellungen als XML ex- und importieren"
 
722