Version Description
- always check existing .htaccess in log/temp/backup folder
- set tmp folder to plugindir/tmp
- removed input_filter function
- fixed problem with mb_string funktion on job start
- reduced needed memory for FTP upload.
- Updated Google Storage Url's
- Updated AWS lib to 1.5.8.1
Download this release
Release Info
Developer | danielhuesken |
Plugin | BackWPup – WordPress Backup Plugin |
Version | 2.1.12 |
Comparing to | |
See all releases |
Code changes from version 2.1.11 to 2.1.12
- backwpup-functions.php +1139 -1146
- backwpup.php +106 -107
- css/backwpup.css +12 -12
- css/backwpupbackups.css +6 -6
- css/backwpupeditjob.css +48 -48
- css/backwpuplogs.css +11 -11
- css/backwpupsettings.css +3 -3
- css/backwpuptools.css +3 -3
- css/backwpupworking.css +71 -71
- job/backup_create.php +209 -216
- job/db_check.php +64 -65
- job/db_dump.php +150 -151
- job/db_optimize.php +47 -49
- job/dest_dropbox.php +71 -72
- job/dest_folder.php +30 -32
- job/dest_ftp.php +142 -129
- job/dest_gstorage.php +71 -72
- job/dest_mail.php +62 -63
- job/dest_msazure.php +59 -60
- job/dest_rsc.php +96 -97
- job/dest_s3.php +74 -75
- job/dest_sugarsync.php +70 -71
- job/file_list.php +133 -135
- job/job_functions.php +576 -577
- job/job_run.php +170 -169
- job/job_start.php +248 -269
- job/show_working.php +89 -90
- job/wp_export.php +87 -88
- job/wp_export_generate.php +20 -21
- js/31backwpupeditjob.js +270 -270
- js/backwpup.js +17 -17
- js/backwpupeditjob.js +270 -270
- js/backwpupsettings.js +15 -15
- js/backwpupworking.js +59 -61
- libs/aws/README.md +4 -0
- libs/aws/authentication/signature_v3json.class.php +2 -21
- libs/aws/authentication/signature_v4json.class.php +4 -7
- libs/aws/authentication/signature_v4query.class.php +1 -1
- libs/aws/lib/dom/ArrayToDOMDocument.php +8 -0
- libs/aws/sdk.class.php +152 -30
- libs/aws/services/as.class.php +4 -3
- libs/aws/services/cloudsearch.class.php +20 -20
- libs/aws/services/cloudwatch.class.php +2 -2
- libs/aws/services/dynamodb.class.php +57 -32
- libs/aws/services/ec2.class.php +116 -12
- libs/aws/services/elasticache.class.php +67 -2
- libs/aws/services/elb.class.php +3 -2
- libs/aws/services/iam.class.php +353 -1
- libs/aws/services/s3.class.php +131 -40
- libs/aws/services/ses.class.php +72 -2
- libs/aws/services/storagegateway.class.php +1 -31
- libs/aws/services/sts.class.php +1 -3
- libs/aws/services/swf.class.php +8 -39
- libs/aws/utilities/credentials.class.php +9 -10
- libs/aws/utilities/simplexml.class.php +24 -2
- libs/dropbox.php +761 -763
- libs/sugarsync.php +371 -371
- pages/func_backwpup.php +256 -257
- pages/func_backwpupbackups.php +495 -498
- pages/func_backwpupeditjob.php +811 -812
- pages/func_backwpuplogs.php +161 -162
- pages/func_backwpupworking.php +24 -26
- pages/header_backwpup.php +138 -139
- pages/header_backwpupbackups.php +329 -330
- pages/header_backwpupeditjob.php +295 -296
- pages/header_backwpuplogs.php +63 -64
- pages/header_backwpupsettings.php +51 -52
- pages/header_backwpuptools.php +6 -7
- pages/header_backwpupworking.php +32 -33
- pages/page_backwpup.php +17 -18
- pages/page_backwpupbackups.php +16 -17
- pages/page_backwpupeditjob.php +209 -209
- pages/page_backwpuplogs.php +16 -17
- pages/page_backwpupsettings.php +170 -170
- pages/page_backwpuptools.php +121 -121
- pages/page_backwpupworking.php +49 -50
- pages/tools/db_restore.php +92 -97
- readme.txt +485 -476
- uninstall.php +12 -13
backwpup-functions.php
CHANGED
@@ -1,1146 +1,1139 @@
|
|
1 |
-
<?PHP
|
2 |
-
//Thems Option menu entry
|
3 |
-
function backwpup_admin_menu() {
|
4 |
-
add_menu_page( __('BackWPup','backwpup'), __('BackWPup','backwpup'), BACKWPUP_USER_CAPABILITY, 'backwpup', 'backwpup_menu_page', BACKWPUP_PLUGIN_BASEURL.'/css/BackWPup16.png');
|
5 |
-
$hook = add_submenu_page( 'backwpup', __('Jobs','backwpup'), __('Jobs','backwpup'), BACKWPUP_USER_CAPABILITY, 'backwpup', 'backwpup_menu_page' );
|
6 |
-
add_action('load-'.$hook, 'backwpup_menu_page_header');
|
7 |
-
$hook = add_submenu_page( 'backwpup', __('Add New','backwpup'), __('Add New','backwpup'), BACKWPUP_USER_CAPABILITY, 'backwpupeditjob', 'backwpup_menu_page' );
|
8 |
-
add_action('load-'.$hook, 'backwpup_menu_page_header');
|
9 |
-
$hook = add_submenu_page( 'backwpup', __('Working','backwpup'), __('Working','backwpup'), BACKWPUP_USER_CAPABILITY, 'backwpupworking', 'backwpup_menu_page' );
|
10 |
-
add_action('load-'.$hook, 'backwpup_menu_page_header',1);
|
11 |
-
$hook = add_submenu_page( 'backwpup', __('Logs','backwpup'), __('Logs','backwpup'), BACKWPUP_USER_CAPABILITY, 'backwpuplogs', 'backwpup_menu_page' );
|
12 |
-
add_action('load-'.$hook, 'backwpup_menu_page_header');
|
13 |
-
$hook = add_submenu_page( 'backwpup', __('Backups','backwpup'), __('Backups','backwpup'), BACKWPUP_USER_CAPABILITY, 'backwpupbackups', 'backwpup_menu_page' );
|
14 |
-
add_action('load-'.$hook, 'backwpup_menu_page_header');
|
15 |
-
$hook = add_submenu_page( 'backwpup', __('Tools','backwpup'), __('Tools','backwpup'), BACKWPUP_USER_CAPABILITY, 'backwpuptools', 'backwpup_menu_page' );
|
16 |
-
add_action('load-'.$hook, 'backwpup_menu_page_header');
|
17 |
-
$hook = add_submenu_page( 'backwpup', __('Settings','backwpup'), __('Settings','backwpup'), BACKWPUP_USER_CAPABILITY, 'backwpupsettings', 'backwpup_menu_page' );
|
18 |
-
add_action('load-'.$hook, 'backwpup_menu_page_header');
|
19 |
-
}
|
20 |
-
|
21 |
-
function backwpup_menu_page() {
|
22 |
-
global $backwpup_message,$backwpup_listtable,$current_screen;
|
23 |
-
//check user premessions
|
24 |
-
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
25 |
-
return;
|
26 |
-
//Set pages that exists
|
27 |
-
$menupages=array('backwpup','backwpupeditjob','backwpupworking','backwpuplogs','backwpupbackups','backwpuptools','backwpupsettings');
|
28 |
-
//check called page exists
|
29 |
-
if (!empty($_REQUEST['page']) and in_array($_REQUEST['page'],$menupages))
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
if (
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
$current_screen->add_help_tab( array(
|
96 |
-
'id' => 'plugininfo',
|
97 |
-
'title' => __( 'Plugin Info', 'backwpup' ),
|
98 |
-
'content' =>
|
99 |
-
'<p><a href="http://backwpup.
|
100 |
-
) );
|
101 |
-
}
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
'<p><a href="http://backwpup.
|
121 |
-
'<p><a href="
|
122 |
-
'<p><a href="
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
'
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
'
|
145 |
-
' <a href="
|
146 |
-
'</
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
'
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
//
|
167 |
-
$
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
if (
|
190 |
-
if (
|
191 |
-
if (
|
192 |
-
if (
|
193 |
-
if (isset($cfg['
|
194 |
-
|
195 |
-
if (!isset($cfg['
|
196 |
-
if (!isset($cfg['
|
197 |
-
if (!isset($cfg['
|
198 |
-
if (!isset($cfg['
|
199 |
-
if (!isset($cfg['
|
200 |
-
if (!isset($cfg['
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
if (!
|
205 |
-
if (!
|
206 |
-
if (!isset($cfg['
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
$
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
//
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
$
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
if (!
|
273 |
-
$
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
if ($
|
301 |
-
$
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
$
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
$
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
if (
|
400 |
-
$
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
$
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
}
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
}
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
if (
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
echo '
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
if (
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
if (
|
559 |
-
$
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
$
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
$
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
if ($
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
if ($
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
if ($
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
if (strtolower($value)=='
|
664 |
-
$value=
|
665 |
-
if (strtolower($value)=='
|
666 |
-
$value=6;
|
667 |
-
if (strtolower($value)=='
|
668 |
-
$value=
|
669 |
-
if (strtolower($value)=='
|
670 |
-
$value=
|
671 |
-
if (strtolower($value)=='
|
672 |
-
$value=
|
673 |
-
if (strtolower($value)=='
|
674 |
-
$value=
|
675 |
-
if (strtolower($value)=='
|
676 |
-
$value=
|
677 |
-
if (
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
$
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
if (
|
737 |
-
|
738 |
-
|
739 |
-
}
|
740 |
-
|
741 |
-
|
742 |
-
}
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
if (
|
750 |
-
$
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
}
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
function
|
787 |
-
global $
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
$
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
if (
|
822 |
-
$jobsettings['type']='DB+FILE';
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
$jobsettings['
|
834 |
-
|
835 |
-
if (
|
836 |
-
$jobsettings['
|
837 |
-
|
838 |
-
if (!isset($jobsettings['
|
839 |
-
$jobsettings['
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
if (
|
853 |
-
$
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
$
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
$
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
$
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
$jobsettings['
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
$jobsettings['
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
$jobsettings['
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
if (
|
971 |
-
$jobsettings['
|
972 |
-
|
973 |
-
if (
|
974 |
-
$jobsettings['
|
975 |
-
|
976 |
-
if (!isset($jobsettings['
|
977 |
-
$jobsettings['
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
if (!
|
988 |
-
|
989 |
-
|
990 |
-
if (!isset($jobsettings['
|
991 |
-
$jobsettings['
|
992 |
-
|
993 |
-
if (!isset($jobsettings['
|
994 |
-
$jobsettings['
|
995 |
-
|
996 |
-
if (!isset($jobsettings['
|
997 |
-
$jobsettings['
|
998 |
-
|
999 |
-
if (
|
1000 |
-
$jobsettings['
|
1001 |
-
|
1002 |
-
if (!isset($jobsettings['
|
1003 |
-
$jobsettings['
|
1004 |
-
|
1005 |
-
if (
|
1006 |
-
$jobsettings['
|
1007 |
-
|
1008 |
-
if (!isset($jobsettings['
|
1009 |
-
$jobsettings['
|
1010 |
-
|
1011 |
-
if (!isset($jobsettings['
|
1012 |
-
$jobsettings['
|
1013 |
-
|
1014 |
-
if (!isset($jobsettings['
|
1015 |
-
$jobsettings['
|
1016 |
-
|
1017 |
-
if (!isset($jobsettings['
|
1018 |
-
$jobsettings['
|
1019 |
-
|
1020 |
-
if (!isset($jobsettings['
|
1021 |
-
$jobsettings['
|
1022 |
-
|
1023 |
-
if (!isset($jobsettings['
|
1024 |
-
$jobsettings['
|
1025 |
-
|
1026 |
-
if (
|
1027 |
-
$jobsettings['
|
1028 |
-
|
1029 |
-
if (!isset($jobsettings['
|
1030 |
-
$jobsettings['
|
1031 |
-
|
1032 |
-
if (
|
1033 |
-
$jobsettings['
|
1034 |
-
|
1035 |
-
if (!isset($jobsettings['
|
1036 |
-
$jobsettings['
|
1037 |
-
|
1038 |
-
if (!isset($jobsettings['
|
1039 |
-
$jobsettings['
|
1040 |
-
|
1041 |
-
if (!isset($jobsettings['
|
1042 |
-
$jobsettings['
|
1043 |
-
|
1044 |
-
if (
|
1045 |
-
$jobsettings['
|
1046 |
-
|
1047 |
-
if (!isset($jobsettings['
|
1048 |
-
$jobsettings['
|
1049 |
-
|
1050 |
-
if (
|
1051 |
-
$jobsettings['
|
1052 |
-
|
1053 |
-
if (!isset($jobsettings['
|
1054 |
-
$jobsettings['
|
1055 |
-
|
1056 |
-
if (!isset($jobsettings['
|
1057 |
-
$jobsettings['
|
1058 |
-
|
1059 |
-
if (!isset($jobsettings['
|
1060 |
-
$jobsettings['
|
1061 |
-
|
1062 |
-
if (!isset($jobsettings['
|
1063 |
-
$jobsettings['
|
1064 |
-
|
1065 |
-
if (
|
1066 |
-
$jobsettings['
|
1067 |
-
|
1068 |
-
if (!isset($jobsettings['
|
1069 |
-
$jobsettings['
|
1070 |
-
|
1071 |
-
if (
|
1072 |
-
$jobsettings['
|
1073 |
-
|
1074 |
-
if (!isset($jobsettings['
|
1075 |
-
$jobsettings['
|
1076 |
-
|
1077 |
-
if (!isset($jobsettings['
|
1078 |
-
$jobsettings['
|
1079 |
-
|
1080 |
-
if (!isset($jobsettings['
|
1081 |
-
$jobsettings['
|
1082 |
-
|
1083 |
-
if (
|
1084 |
-
$jobsettings['
|
1085 |
-
|
1086 |
-
if (!isset($jobsettings['
|
1087 |
-
$jobsettings['
|
1088 |
-
|
1089 |
-
if (
|
1090 |
-
$jobsettings['
|
1091 |
-
|
1092 |
-
if (!isset($jobsettings['
|
1093 |
-
$jobsettings['
|
1094 |
-
|
1095 |
-
if (!isset($jobsettings['
|
1096 |
-
$jobsettings['
|
1097 |
-
|
1098 |
-
if (
|
1099 |
-
$jobsettings['
|
1100 |
-
|
1101 |
-
if (!isset($jobsettings['
|
1102 |
-
$jobsettings['
|
1103 |
-
|
1104 |
-
if (
|
1105 |
-
$jobsettings['
|
1106 |
-
|
1107 |
-
if (!isset($jobsettings['
|
1108 |
-
$jobsettings['
|
1109 |
-
|
1110 |
-
if (!isset($jobsettings['
|
1111 |
-
$jobsettings['
|
1112 |
-
|
1113 |
-
if (!isset($jobsettings['
|
1114 |
-
$jobsettings['
|
1115 |
-
|
1116 |
-
if (!isset($jobsettings['
|
1117 |
-
$jobsettings['
|
1118 |
-
|
1119 |
-
if (
|
1120 |
-
$jobsettings['
|
1121 |
-
|
1122 |
-
if (!isset($jobsettings['
|
1123 |
-
$jobsettings['
|
1124 |
-
|
1125 |
-
if (
|
1126 |
-
$jobsettings['
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
unset($jobsettings['
|
1136 |
-
unset($jobsettings['
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
unset($jobsettings['dropepass']);
|
1141 |
-
unset($jobsettings['dbtables']);
|
1142 |
-
unset($jobsettings['dropesignmethod']);
|
1143 |
-
|
1144 |
-
return $jobsettings;
|
1145 |
-
}
|
1146 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
//Thems Option menu entry
|
3 |
+
function backwpup_admin_menu() {
|
4 |
+
add_menu_page( __('BackWPup','backwpup'), __('BackWPup','backwpup'), BACKWPUP_USER_CAPABILITY, 'backwpup', 'backwpup_menu_page', BACKWPUP_PLUGIN_BASEURL.'/css/BackWPup16.png');
|
5 |
+
$hook = add_submenu_page( 'backwpup', __('Jobs','backwpup'), __('Jobs','backwpup'), BACKWPUP_USER_CAPABILITY, 'backwpup', 'backwpup_menu_page' );
|
6 |
+
add_action('load-'.$hook, 'backwpup_menu_page_header');
|
7 |
+
$hook = add_submenu_page( 'backwpup', __('Add New','backwpup'), __('Add New','backwpup'), BACKWPUP_USER_CAPABILITY, 'backwpupeditjob', 'backwpup_menu_page' );
|
8 |
+
add_action('load-'.$hook, 'backwpup_menu_page_header');
|
9 |
+
$hook = add_submenu_page( 'backwpup', __('Working','backwpup'), __('Working','backwpup'), BACKWPUP_USER_CAPABILITY, 'backwpupworking', 'backwpup_menu_page' );
|
10 |
+
add_action('load-'.$hook, 'backwpup_menu_page_header',1);
|
11 |
+
$hook = add_submenu_page( 'backwpup', __('Logs','backwpup'), __('Logs','backwpup'), BACKWPUP_USER_CAPABILITY, 'backwpuplogs', 'backwpup_menu_page' );
|
12 |
+
add_action('load-'.$hook, 'backwpup_menu_page_header');
|
13 |
+
$hook = add_submenu_page( 'backwpup', __('Backups','backwpup'), __('Backups','backwpup'), BACKWPUP_USER_CAPABILITY, 'backwpupbackups', 'backwpup_menu_page' );
|
14 |
+
add_action('load-'.$hook, 'backwpup_menu_page_header');
|
15 |
+
$hook = add_submenu_page( 'backwpup', __('Tools','backwpup'), __('Tools','backwpup'), BACKWPUP_USER_CAPABILITY, 'backwpuptools', 'backwpup_menu_page' );
|
16 |
+
add_action('load-'.$hook, 'backwpup_menu_page_header');
|
17 |
+
$hook = add_submenu_page( 'backwpup', __('Settings','backwpup'), __('Settings','backwpup'), BACKWPUP_USER_CAPABILITY, 'backwpupsettings', 'backwpup_menu_page' );
|
18 |
+
add_action('load-'.$hook, 'backwpup_menu_page_header');
|
19 |
+
}
|
20 |
+
|
21 |
+
function backwpup_menu_page() {
|
22 |
+
global $backwpup_message,$backwpup_listtable,$current_screen;
|
23 |
+
//check user premessions
|
24 |
+
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
25 |
+
return;
|
26 |
+
//Set pages that exists
|
27 |
+
$menupages=array('backwpup','backwpupeditjob','backwpupworking','backwpuplogs','backwpupbackups','backwpuptools','backwpupsettings');
|
28 |
+
//check called page exists
|
29 |
+
if (!empty($_REQUEST['page']) and in_array($_REQUEST['page'],$menupages))
|
30 |
+
require_once(dirname(__FILE__).'/pages/page_'.$_REQUEST['page'].'.php');
|
31 |
+
}
|
32 |
+
|
33 |
+
function backwpup_menu_page_header() {
|
34 |
+
global $wp_version,$backwpup_message,$backwpup_listtable,$current_screen;
|
35 |
+
//check user premessions
|
36 |
+
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
37 |
+
return;
|
38 |
+
//Set pages that exists
|
39 |
+
$menupages=array('backwpup','backwpupeditjob','backwpupworking','backwpuplogs','backwpupbackups','backwpuptools','backwpupsettings');
|
40 |
+
//check called page exists
|
41 |
+
$page=$_REQUEST['page'];
|
42 |
+
if (!empty($page) and in_array($page,$menupages)) {
|
43 |
+
//Css for Admin Section
|
44 |
+
if (is_file(dirname(__FILE__).'/css/'.$page.'.css')) {
|
45 |
+
if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG)
|
46 |
+
wp_enqueue_style($page,BACKWPUP_PLUGIN_BASEURL.'/css/'.$page.'.css','',time(),'screen');
|
47 |
+
else
|
48 |
+
wp_enqueue_style($page,BACKWPUP_PLUGIN_BASEURL.'/css/'.$page.'.css','',BACKWPUP_VERSION,'screen');
|
49 |
+
}
|
50 |
+
//add java
|
51 |
+
if (is_file(dirname(__FILE__).'/js/31'.$page.'.js') and version_compare($wp_version, '3.2', '<')) {
|
52 |
+
if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG)
|
53 |
+
wp_enqueue_script($page,BACKWPUP_PLUGIN_BASEURL.'/js/31'.$page.'.js','',time(),true);
|
54 |
+
else
|
55 |
+
wp_enqueue_script($page,BACKWPUP_PLUGIN_BASEURL.'/js/31'.$page.'.js','',BACKWPUP_VERSION,true);
|
56 |
+
} elseif (is_file(dirname(__FILE__).'/js/'.$page.'.js')) {
|
57 |
+
if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG)
|
58 |
+
wp_enqueue_script($page,BACKWPUP_PLUGIN_BASEURL.'/js/'.$page.'.js','',time(),true);
|
59 |
+
else
|
60 |
+
wp_enqueue_script($page,BACKWPUP_PLUGIN_BASEURL.'/js/'.$page.'.js','',BACKWPUP_VERSION,true);
|
61 |
+
}
|
62 |
+
//incude functions
|
63 |
+
if (is_file(dirname(__FILE__).'/pages/func_'.$page.'.php'))
|
64 |
+
require_once(dirname(__FILE__).'/pages/func_'.$page.'.php');
|
65 |
+
//include code
|
66 |
+
if (is_file(dirname(__FILE__).'/pages/header_'.$page.'.php'))
|
67 |
+
require_once(dirname(__FILE__).'/pages/header_'.$page.'.php');
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
function backwpup_load_ajax() {
|
72 |
+
//Set pages that exists
|
73 |
+
$menupages=array('backwpup','backwpupeditjob','backwpupworking','backwpuplogs','backwpupbackups','backwpuptools','backwpupsettings');
|
74 |
+
if (!empty($_POST['backwpupajaxpage']) and in_array($_POST['backwpupajaxpage'],$menupages)) {
|
75 |
+
$page=$_POST['backwpupajaxpage'];
|
76 |
+
//incude functions
|
77 |
+
if (is_file(dirname(__FILE__).'/pages/func_'.$page.'.php'))
|
78 |
+
require_once(dirname(__FILE__).'/pages/func_'.$page.'.php');
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
function backwpup_contextual_help($help='') {
|
83 |
+
global $current_screen;
|
84 |
+
$help='<p>'.$help.'</p>';
|
85 |
+
|
86 |
+
if ( method_exists( $current_screen, 'add_help_tab' ) ) {
|
87 |
+
if ( 'http://backwpup.de'==__('http://backwpup.com','backwpup')) {
|
88 |
+
$current_screen->add_help_tab( array(
|
89 |
+
'id' => 'plugininfo',
|
90 |
+
'title' => __( 'Plugin Info', 'backwpup' ),
|
91 |
+
'content' =>
|
92 |
+
'<p><a href="http://backwpup.de" target="_blank">BackWPup</a> v. ' . BACKWPUP_VERSION . ', <a href="http://www.gnu.org/licenses/gpl-2.0" target="_blank">GPLv2</a> © 2009-' . date( 'Y' ) . ' <a href="http://danielhuesken.de" target="_blank">Daniel Hüsken</a></p><p>' . __( 'BackWPup comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.', 'backwpup' ) . '</p>'
|
93 |
+
) );
|
94 |
+
} else {
|
95 |
+
$current_screen->add_help_tab( array(
|
96 |
+
'id' => 'plugininfo',
|
97 |
+
'title' => __( 'Plugin Info', 'backwpup' ),
|
98 |
+
'content' =>
|
99 |
+
'<p><a href="http://backwpup.com" target="_blank">BackWPup</a> v. ' . BACKWPUP_VERSION . ', <a href="http://www.gnu.org/licenses/gpl-2.0" target="_blank">GPLv2</a> © 2009-' . date( 'Y' ) . ' <a href="http://danielhuesken.de" target="_blank">Daniel Hüsken</a></p><p>' . __( 'BackWPup comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.', 'backwpup' ) . '</p>'
|
100 |
+
) );
|
101 |
+
}
|
102 |
+
$current_screen->add_help_tab( array(
|
103 |
+
'id' => 'overview',
|
104 |
+
'title' => __( 'Overview', 'backwpup' ),
|
105 |
+
'content' => $help
|
106 |
+
) );
|
107 |
+
if ( 'http://backwpup.de'==__('http://backwpup.com','backwpup')) {
|
108 |
+
$current_screen->set_help_sidebar(
|
109 |
+
'<p><strong>' . __( 'For more information:', 'backwpup' ) . '</strong></p>' .
|
110 |
+
'<p><a href="http://backwpup.de" target="_blank">BackWPup</a></p>' .
|
111 |
+
'<p><a href="http://backwpup.de/handbuch/" target="_blank">'.__('Documentation','backwpup').'</a></p>' .
|
112 |
+
'<p><a href="http://backwpup.de/faq/" target="_blank">'.__('FAQ','backwpup').'</a></p>' .
|
113 |
+
'<p><a href="http://backwpup.de/forums/" target="_blank"'.__('Support Forums','backwpup').'</a></p>' .
|
114 |
+
'<p><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Y6UHQE4NKFFKY" target="_blank">'.__('Donate','backwpup').'</a></p>' .
|
115 |
+
'<p><a href="https://plus.google.com/112659782148359984250/" target="_blank">'.__('Google+','backwpup').'</a></p>'
|
116 |
+
);
|
117 |
+
} else {
|
118 |
+
$current_screen->set_help_sidebar(
|
119 |
+
'<p><strong>' . __( 'For more information:', 'backwpup' ) . '</strong></p>' .
|
120 |
+
'<p><a href="http://backwpup.com" target="_blank">BackWPup</a></p>' .
|
121 |
+
'<p><a href="http://backwpup.com/manual/" target="_blank">'.__('Documentation','backwpup').'</a></p>' .
|
122 |
+
'<p><a href="http://backwpup.com/faq/" target="_blank">'.__('FAQ','backwpup').'</a></p>' .
|
123 |
+
'<p><a href="http://backwpup.com/forums/" target="_blank"'.__('Support Forums','backwpup').'</a></p>' .
|
124 |
+
'<p><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q3QSVRSFXBLSE" target="_blank">'.__('Donate','backwpup').'</a></p>' .
|
125 |
+
'<p><a href="https://plus.google.com/112659782148359984250/" target="_blank">'.__('Google+','backwpup').'</a></p>'
|
126 |
+
);
|
127 |
+
}
|
128 |
+
} elseif ( function_exists( 'add_contextual_help' ) ) { //for WP < 3.3 help
|
129 |
+
if ( 'http://backwpup.de'==__('http://backwpup.com','backwpup')) {
|
130 |
+
add_contextual_help( $current_screen,$help.
|
131 |
+
'<p><a href="http://backwpup.de" target="_blank">BackWPup</a> v. ' . BACKWPUP_VERSION . ', <a href="http://www.gnu.org/licenses/gpl-2.0" target="_blank">GPLv2</a> © 2009-' . date( 'Y' ) . ' <a href="http://danielhuesken.de" target="_blank">Daniel Hüsken</a></p><p>' . __( 'BackWPup comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.', 'backwpup' ) . '</p>' .
|
132 |
+
'<p><strong>' . __( 'For more information:', 'backwpup' ) . '</strong></p><p>' .
|
133 |
+
' <a href="http://backwpup.de" target="_blank">BackWPup</a> |' .
|
134 |
+
' <a href="http://backwpup.de/handbuch/" target="_blank">'.__('Documentation', 'backwpup').'</a> |' .
|
135 |
+
' <a href="http://backwpup.de/faq/" target="_blank">'.__('FAQ', 'backwpup').'</a> |' .
|
136 |
+
' <a href="http://backwpup.de/forums/" target="_blank">'.__('Support Forums', 'backwpup').'</a> |' .
|
137 |
+
' <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Y6UHQE4NKFFKY" target="_blank">'.__('Donate', 'backwpup').'</a> |' .
|
138 |
+
' <a href="https://plus.google.com/112659782148359984250/" target="_blank">'.__('Google+', 'backwpup').'</a> ' .
|
139 |
+
'</p>'
|
140 |
+
);
|
141 |
+
} else {
|
142 |
+
add_contextual_help( $current_screen,$help.
|
143 |
+
'<p><a href="http://backwpup.com" target="_blank">BackWPup</a> v. ' . BACKWPUP_VERSION . ', <a href="http://www.gnu.org/licenses/gpl-2.0" target="_blank">GPLv2</a> © 2009-' . date( 'Y' ) . ' <a href="http://danielhuesken.de" target="_blank">Daniel Hüsken</a></p><p>' . __( 'BackWPup comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.', 'backwpup' ) . '</p>' .
|
144 |
+
'<p><strong>' . __( 'For more information:', 'backwpup' ) . '</strong></p><p>' .
|
145 |
+
' <a href="http://backwpup.com" target="_blank">BackWPup</a> |' .
|
146 |
+
' <a href="http://backwpup.com/manual/" target="_blank">'.__('Documentation', 'backwpup').'</a> |' .
|
147 |
+
' <a href="http://backwpup.com/faq/" target="_blank">'.__('FAQ', 'backwpup').'</a> |' .
|
148 |
+
' <a href="http://backwpup.com/forums/" target="_blank">'.__('Support Forums', 'backwpup').'</a> |' .
|
149 |
+
' <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q3QSVRSFXBLSE" target="_blank">'.__('Donate', 'backwpup').'</a> |' .
|
150 |
+
' <a href="https://plus.google.com/112659782148359984250/" target="_blank">'.__('Google+', 'backwpup').'</a> ' .
|
151 |
+
'</p>'
|
152 |
+
);
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
//On activate function
|
158 |
+
function backwpup_plugin_activate() {
|
159 |
+
//Load Settings
|
160 |
+
$cfg=get_option('backwpup');
|
161 |
+
//Check only run once on update
|
162 |
+
if ($cfg['last_activate']==BACKWPUP_VERSION or !is_main_site())
|
163 |
+
return;
|
164 |
+
else
|
165 |
+
$cfg['last_activate']=BACKWPUP_VERSION;
|
166 |
+
//check jobs
|
167 |
+
$jobs=get_option('backwpup_jobs');
|
168 |
+
if (isset($jobs[0]))
|
169 |
+
unset($jobs[0]); //Delete old false job
|
170 |
+
if (!empty($jobs)) {
|
171 |
+
foreach ($jobs as $jobid => $jobvalue) {
|
172 |
+
$checktjobs[$jobid]=backwpup_get_job_vars($jobid); //check jobvaules
|
173 |
+
}
|
174 |
+
//save job values
|
175 |
+
update_option('backwpup_jobs',$checktjobs);
|
176 |
+
}
|
177 |
+
//remove old cron jobs
|
178 |
+
wp_clear_scheduled_hook('backwpup_cron');
|
179 |
+
//make new schedule round
|
180 |
+
wp_schedule_event(time(), 'backwpup_int', 'backwpup_cron');
|
181 |
+
//Set settings defaults
|
182 |
+
if (empty($cfg['mailsndemail'])) $cfg['mailsndemail']=sanitize_email(get_bloginfo( 'admin_email' ));
|
183 |
+
if (empty($cfg['mailsndname'])) $cfg['mailsndname']='BackWPup '.get_bloginfo( 'name' );
|
184 |
+
if (empty($cfg['mailmethod'])) $cfg['mailmethod']='mail';
|
185 |
+
if (empty($cfg['mailsendmail'])) $cfg['mailsendmail']=substr(ini_get('sendmail_path'),0,strpos(ini_get('sendmail_path'),' -'));
|
186 |
+
if (isset($cfg['mailhost']) && false !== strpos($cfg['mailhost'],':'))
|
187 |
+
list($cfg['mailhost'],$cfg['mailhostport'])=explode(':',$cfg['mailhost'],2);
|
188 |
+
if (!isset($cfg['mailhost'])) $cfg['mailhost']='';
|
189 |
+
if (!isset($cfg['mailhostport'])) $cfg['mailhostport']=25;
|
190 |
+
if (!isset($cfg['mailsecure'])) $cfg['mailsecure']='';
|
191 |
+
if (!isset($cfg['mailuser'])) $cfg['mailuser']='';
|
192 |
+
if (!isset($cfg['mailpass'])) $cfg['mailpass']='';
|
193 |
+
if (!isset($cfg['showadminbar'])) $cfg['showadminbar']=true;
|
194 |
+
if (!isset($cfg['jobstepretry']) or !is_int($cfg['jobstepretry']) or 100<$cfg['jobstepretry'] or empty($cfg['jobstepretry'])) $cfg['jobstepretry']=3;
|
195 |
+
if (!isset($cfg['jobscriptretry']) or !is_int($cfg['jobscriptretry']) or 100<$cfg['jobscriptretry'] or empty($cfg['jobscriptretry'])) $cfg['jobscriptretry']=5;
|
196 |
+
if (!isset($cfg['maxlogs']) or !is_int($cfg['maxlogs'])) $cfg['maxlogs']=50;
|
197 |
+
if (!function_exists('gzopen') or !isset($cfg['gzlogs'])) $cfg['gzlogs']=false;
|
198 |
+
if (!class_exists('ZipArchive') or !isset($cfg['phpzip'])) $cfg['phpzip']=false;
|
199 |
+
if (!isset($cfg['apicronservice']) or !is_bool($cfg['apicronservice'])) $cfg['apicronservice']=false;
|
200 |
+
if (!isset($cfg['dirlogs']) or empty($cfg['dirlogs']) or !is_dir($cfg['dirlogs'])) {
|
201 |
+
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
202 |
+
$cfg['dirlogs']=str_replace('\\','/',trailingslashit(WP_CONTENT_DIR)).'backwpup-'.$rand.'-logs/';
|
203 |
+
}
|
204 |
+
if (!isset($cfg['disablewpcron']) or !is_bool($cfg['disablewpcron'])) $cfg['disablewpcron']=false;
|
205 |
+
if (!isset($cfg['httpauthuser'])) $cfg['httpauthuser']='';
|
206 |
+
if (!isset($cfg['httpauthpassword'])) $cfg['httpauthpassword']='';
|
207 |
+
//remove old option
|
208 |
+
unset($cfg['dirtemp']);
|
209 |
+
unset($cfg['logfilelist']);
|
210 |
+
unset($cfg['jobscriptruntime']);
|
211 |
+
unset($cfg['jobscriptruntimelong']);
|
212 |
+
update_option('backwpup',$cfg);
|
213 |
+
//delete not longer used options
|
214 |
+
delete_option('backwpup_backups_chache');
|
215 |
+
delete_option('backwpup_last_activate');
|
216 |
+
backwpup_api(true);
|
217 |
+
}
|
218 |
+
|
219 |
+
//on Plugin deaktivate
|
220 |
+
function backwpup_plugin_deactivate() {
|
221 |
+
wp_clear_scheduled_hook('backwpup_cron'); //delete cron
|
222 |
+
$cfg=get_option('backwpup');
|
223 |
+
$cfg['last_activate']=''; //set to not activated
|
224 |
+
update_option('backwpup',$cfg);
|
225 |
+
backwpup_api(false);
|
226 |
+
}
|
227 |
+
|
228 |
+
//get temp dir
|
229 |
+
function backwpup_get_temp() {
|
230 |
+
$backwpuptmpfolder=str_replace('\\','/',dirname(__FILE__).'/tmp/');
|
231 |
+
return trailingslashit($backwpuptmpfolder);
|
232 |
+
}
|
233 |
+
//checks the dir is in openbasedir
|
234 |
+
function backwpup_check_open_basedir($dir) {
|
235 |
+
if (!ini_get('open_basedir'))
|
236 |
+
return true;
|
237 |
+
$openbasedirarray=explode(PATH_SEPARATOR,ini_get('open_basedir'));
|
238 |
+
$dir=rtrim(str_replace('\\','/',$dir),'/').'/';
|
239 |
+
if (!empty($openbasedirarray)) {
|
240 |
+
foreach ($openbasedirarray as $basedir) {
|
241 |
+
if (stripos($dir,rtrim(str_replace('\\','/',$basedir),'/').'/')==0)
|
242 |
+
return true;
|
243 |
+
}
|
244 |
+
}
|
245 |
+
return false;
|
246 |
+
}
|
247 |
+
|
248 |
+
//Backwpup API
|
249 |
+
function backwpup_api($active=false) {
|
250 |
+
include(ABSPATH . WPINC . '/version.php'); // include an unmodified $wp_version
|
251 |
+
$cfg=get_option('backwpup');
|
252 |
+
$post['URL']=site_url();
|
253 |
+
$post['WP_VER']=$wp_version;
|
254 |
+
$post['BACKWPUP_VER']=BACKWPUP_VERSION;
|
255 |
+
if (!empty($cfg['apicronservice'])) {
|
256 |
+
$post['OFFSET']=get_option('gmt_offset');
|
257 |
+
if (!empty($cfg['httpauthuser']) and !empty($cfg['httpauthpassword']))
|
258 |
+
$post['httpauth']=base64_encode($cfg['httpauthuser'].':'.base64_decode($cfg['httpauthpassword']));
|
259 |
+
$jobs=get_option('backwpup_jobs');
|
260 |
+
if (!empty($jobs)) {
|
261 |
+
foreach ($jobs as $jobid => $jobvalue) {
|
262 |
+
if ($jobvalue['activated'] and !empty($jobvalue['cron']))
|
263 |
+
$post["JOBCRON[".$jobid."]"]=$jobvalue['cron'];
|
264 |
+
}
|
265 |
+
}
|
266 |
+
}
|
267 |
+
wp_remote_post( BACKWPUP_API_URL, array('timeout' => 15, 'blocking' => false, 'sslverify' => false, 'body'=>$post, 'user-agent'=>'BackWPup '.BACKWPUP_VERSION) );
|
268 |
+
}
|
269 |
+
|
270 |
+
//add edit setting to plugins page
|
271 |
+
function backwpup_plugin_options_link($links) {
|
272 |
+
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
273 |
+
return $links;
|
274 |
+
$settings_link='<a href="'.backwpup_admin_url('admin.php').'?page=backwpup" title="' . __('Go to Settings Page','backwpup') . '" class="edit">' . __('Settings','backwpup') . '</a>';
|
275 |
+
array_unshift( $links, $settings_link );
|
276 |
+
return $links;
|
277 |
+
}
|
278 |
+
|
279 |
+
//add links on plugins page
|
280 |
+
function backwpup_plugin_links($links, $file) {
|
281 |
+
if (!current_user_can('install_plugins'))
|
282 |
+
return $links;
|
283 |
+
if ($file == BACKWPUP_PLUGIN_BASEDIR.'/backwpup.php') {
|
284 |
+
$links[] = '<a href="http://backwpup.com/faq/" target="_blank">' . __('FAQ','backwpup') . '</a>';
|
285 |
+
$links[] = '<a href="http://backwpup.com/forums/" target="_blank">' . __('Support','backwpup') . '</a>';
|
286 |
+
$links[] = '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q3QSVRSFXBLSE" target="_blank">' . __('Donate','backwpup') . '</a>';
|
287 |
+
}
|
288 |
+
return $links;
|
289 |
+
}
|
290 |
+
|
291 |
+
//Add cron interval
|
292 |
+
function backwpup_intervals($schedules) {
|
293 |
+
$intervals['backwpup_int']=array('interval' => '60', 'display' => __('BackWPup', 'backwpup'));
|
294 |
+
$schedules=array_merge($intervals,$schedules);
|
295 |
+
return $schedules;
|
296 |
+
}
|
297 |
+
|
298 |
+
//
|
299 |
+
function backwpup_date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) {
|
300 |
+
if ($unixtimestamp)
|
301 |
+
$unixtimestamp=$unixtimestamp+get_option('gmt_offset')*3600;
|
302 |
+
return date_i18n( $dateformatstring, $unixtimestamp, $gmt);
|
303 |
+
}
|
304 |
+
|
305 |
+
//cron work
|
306 |
+
function backwpup_cron() {
|
307 |
+
if (is_file(backwpup_get_temp().'.running')) {
|
308 |
+
$cfg=get_option('backwpup');
|
309 |
+
$revtime=time()-600; //10 min no progress.
|
310 |
+
$infile=backwpup_get_working_file();
|
311 |
+
$httpauthheader='';
|
312 |
+
if (!empty($cfg['httpauthuser']) and !empty($cfg['httpauthpassword']))
|
313 |
+
$httpauthheader=array( 'Authorization' => 'Basic '.base64_encode($cfg['httpauthuser'].':'.base64_decode($cfg['httpauthpassword'])));
|
314 |
+
if (!empty($infile['timestamp']) and $infile['timestamp']<$revtime) {
|
315 |
+
wp_remote_post(BACKWPUP_PLUGIN_BASEURL.'/job/job_run.php', array('timeout' => 3, 'blocking' => false, 'sslverify' => false,'headers'=>$httpauthheader, 'body'=>array('nonce'=> $infile['WORKING']['NONCE'],'type'=>'restarttime'), 'user-agent'=>'BackWPup') );
|
316 |
+
}
|
317 |
+
} else {
|
318 |
+
$jobs=get_option('backwpup_jobs');
|
319 |
+
if (!empty($jobs)) {
|
320 |
+
foreach ($jobs as $jobid => $jobvalue) {
|
321 |
+
if (!isset($jobvalue['activated']) or !$jobvalue['activated'])
|
322 |
+
continue;
|
323 |
+
if ($jobvalue['cronnextrun']<=current_time('timestamp')) {
|
324 |
+
require_once(dirname(__FILE__).'/job/job_start.php');
|
325 |
+
backwpup_jobstart($jobid,true);
|
326 |
+
}
|
327 |
+
}
|
328 |
+
}
|
329 |
+
}
|
330 |
+
}
|
331 |
+
|
332 |
+
//file size
|
333 |
+
function backwpup_formatBytes($bytes, $precision = 2) {
|
334 |
+
$units = array('B', 'KB', 'MB', 'GB', 'TB');
|
335 |
+
$bytes = max($bytes, 0);
|
336 |
+
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
337 |
+
$pow = min($pow, count($units) - 1);
|
338 |
+
$bytes /= pow(1024, $pow);
|
339 |
+
return round($bytes, $precision) . ' ' . $units[$pow];
|
340 |
+
}
|
341 |
+
|
342 |
+
//echo long backup type name
|
343 |
+
function backwpup_backup_types($type='',$echo=false) {
|
344 |
+
$typename='';
|
345 |
+
if (!empty($type)) {
|
346 |
+
$todo=explode('+',$type);
|
347 |
+
foreach($todo as $key => $value) {
|
348 |
+
switch($value) {
|
349 |
+
case 'WPEXP':
|
350 |
+
$typename.=__('WP XML Export','backwpup')."<br />";
|
351 |
+
break;
|
352 |
+
case 'FILE':
|
353 |
+
$typename.=__('File Backup','backwpup')."<br />";
|
354 |
+
break;
|
355 |
+
case 'DB':
|
356 |
+
$typename.=__('Database Backup','backwpup')."<br />";
|
357 |
+
break;
|
358 |
+
case 'OPTIMIZE':
|
359 |
+
$typename.=__('Optimize Database Tables','backwpup')."<br />";
|
360 |
+
break;
|
361 |
+
case 'CHECK':
|
362 |
+
$typename.=__('Check Database Tables','backwpup')."<br />";
|
363 |
+
break;
|
364 |
+
}
|
365 |
+
}
|
366 |
+
} else {
|
367 |
+
$typename=array('WPEXP','DB','FILE','OPTIMIZE','CHECK');
|
368 |
+
}
|
369 |
+
|
370 |
+
if ($echo)
|
371 |
+
echo $typename;
|
372 |
+
else
|
373 |
+
return $typename;
|
374 |
+
}
|
375 |
+
|
376 |
+
//read log file header
|
377 |
+
function backwpup_read_logheader($logfile) {
|
378 |
+
$headers=array("backwpup_version" => "version","backwpup_logtime" => "logtime","backwpup_errors" => "errors","backwpup_warnings" => "warnings","backwpup_jobid" => "jobid","backwpup_jobname" => "name","backwpup_jobtype" => "type","backwpup_jobruntime" => "runtime","backwpup_backupfilesize" => "backupfilesize");
|
379 |
+
if (!is_readable($logfile))
|
380 |
+
return false;
|
381 |
+
//Read file
|
382 |
+
if (strtolower(substr($logfile,-3))==".gz") {
|
383 |
+
$fp = gzopen( $logfile, 'r' );
|
384 |
+
$file_data = gzread( $fp, 1536 ); // Pull only the first 1,5kiB of the file in.
|
385 |
+
gzclose( $fp );
|
386 |
+
} else {
|
387 |
+
$fp = fopen( $logfile, 'r' );
|
388 |
+
$file_data = fread( $fp, 1536 ); // Pull only the first 1,5kiB of the file in.
|
389 |
+
fclose( $fp );
|
390 |
+
}
|
391 |
+
//get data form file
|
392 |
+
foreach ($headers as $keyword => $field) {
|
393 |
+
preg_match('/(<meta name="'.$keyword.'" content="(.*)" \/>)/i',$file_data,$content);
|
394 |
+
if (!empty($content))
|
395 |
+
$joddata[$field]=$content[2];
|
396 |
+
else
|
397 |
+
$joddata[$field]='';
|
398 |
+
}
|
399 |
+
if (empty($joddata['logtime']))
|
400 |
+
$joddata['logtime']=filectime($logfile);
|
401 |
+
return $joddata;
|
402 |
+
}
|
403 |
+
|
404 |
+
//Dashboard widget for Logs
|
405 |
+
function backwpup_dashboard_logs() {
|
406 |
+
$cfg=get_option('backwpup');
|
407 |
+
$widgets = get_option( 'dashboard_widget_options' );
|
408 |
+
if (!isset($widgets['backwpup_dashboard_logs']) or $widgets['backwpup_dashboard_logs']<1 or $widgets['backwpup_dashboard_logs']>20)
|
409 |
+
$widgets['backwpup_dashboard_logs'] =5;
|
410 |
+
//get log files
|
411 |
+
$logfiles=array();
|
412 |
+
if ( $dir = @opendir( $cfg['dirlogs'] ) ) {
|
413 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
414 |
+
if (is_file($cfg['dirlogs'].'/'.$file) and 'backwpup_log_' == substr($file,0,strlen('backwpup_log_')) and ('.html' == substr($file,-5) or '.html.gz' == substr($file,-8)))
|
415 |
+
$logfiles[]=$file;
|
416 |
+
}
|
417 |
+
closedir( $dir );
|
418 |
+
rsort($logfiles);
|
419 |
+
}
|
420 |
+
echo '<ul>';
|
421 |
+
if (count($logfiles)>0) {
|
422 |
+
$count=0;
|
423 |
+
foreach ($logfiles as $logfile) {
|
424 |
+
$logdata=backwpup_read_logheader($cfg['dirlogs'].'/'.$logfile);
|
425 |
+
echo '<li>';
|
426 |
+
echo '<span>'.backwpup_date_i18n(get_option('date_format').' @ '.get_option('time_format'),$logdata['logtime']).'</span> ';
|
427 |
+
echo '<a href="'.wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupworking&logfile='.$cfg['dirlogs'].'/'.$logfile, 'view-log_'.$logfile).'" title="'.__('View Log:','backwpup').' '.basename($logfile).'">'.$logdata['name'].'</i></a>';
|
428 |
+
if ($logdata['errors']>0)
|
429 |
+
printf(' <span style="color:red;font-weight:bold;">'._n("%d ERROR", "%d ERRORS", $logdata['errors'],'backwpup').'</span>', $logdata['errors']);
|
430 |
+
if ($logdata['warnings']>0)
|
431 |
+
printf(' <span style="color:#e66f00;font-weight:bold;">'._n("%d WARNING", "%d WARNINGS", $logdata['warnings'],'backwpup').'</span>', $logdata['warnings']);
|
432 |
+
if($logdata['errors']==0 and $logdata['warnings']==0)
|
433 |
+
echo ' <span style="color:green;font-weight:bold;">'.__('O.K.','backwpup').'</span>';
|
434 |
+
echo '</li>';
|
435 |
+
$count++;
|
436 |
+
if ($count>=$widgets['backwpup_dashboard_logs'])
|
437 |
+
break;
|
438 |
+
}
|
439 |
+
echo '</ul>';
|
440 |
+
} else {
|
441 |
+
echo '<i>'.__('none','backwpup').'</i>';
|
442 |
+
}
|
443 |
+
}
|
444 |
+
|
445 |
+
//Dashboard widget for Logs config
|
446 |
+
function backwpup_dashboard_logs_config() {
|
447 |
+
if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
|
448 |
+
$widget_options = array();
|
449 |
+
|
450 |
+
if ( !isset($widget_options['backwpup_dashboard_logs']) )
|
451 |
+
$widget_options['backwpup_dashboard_logs'] = 5;
|
452 |
+
|
453 |
+
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['backwpup_dashboard_logs']) ) {
|
454 |
+
$number = absint( $_POST['backwpup_dashboard_logs'] );
|
455 |
+
$widget_options['backwpup_dashboard_logs'] = $number;
|
456 |
+
update_option( 'dashboard_widget_options', $widget_options );
|
457 |
+
}
|
458 |
+
|
459 |
+
echo '<p><label for="backwpup-logs">'.__('How many of the lastes logs would you like to display?','backwpup').'</label>';
|
460 |
+
echo '<select id="backwpup-logs" name="backwpup_dashboard_logs">';
|
461 |
+
for ($i=0;$i<=20;$i++)
|
462 |
+
echo '<option value="'.$i.'" '.selected($i,$widget_options['backwpup_dashboard_logs']).'>'.$i.'</option>';
|
463 |
+
echo '</select>';
|
464 |
+
|
465 |
+
}
|
466 |
+
|
467 |
+
//Dashboard widget for Jobs
|
468 |
+
function backwpup_dashboard_activejobs() {
|
469 |
+
$jobs=get_option('backwpup_jobs');
|
470 |
+
if (empty($jobs)) {
|
471 |
+
echo '<ul><li><i>'.__('none','backwpup').'</i></li></ul>';
|
472 |
+
return;
|
473 |
+
}
|
474 |
+
$runningfile=backwpup_get_working_file();
|
475 |
+
$tmp = Array();
|
476 |
+
foreach($jobs as &$ma)
|
477 |
+
$tmp[] = &$ma["cronnextrun"];
|
478 |
+
array_multisort($tmp, SORT_DESC, $jobs);
|
479 |
+
$count=0;
|
480 |
+
echo '<ul>';
|
481 |
+
foreach ($jobs as $jobid => $jobvalue) {
|
482 |
+
if (!empty($runningfile['JOBID']) and $runningfile['JOBID']==$jobvalue['jobid']) {
|
483 |
+
$runtime=time()-$jobvalue['starttime'];
|
484 |
+
echo '<li><span style="font-weight:bold;">'.$jobvalue['jobid'].'. '.$jobvalue['name'].': </span>';
|
485 |
+
printf('<span style="color:#e66f00;">'.__('working since %d sec.','backwpup').'</span>',$runtime);
|
486 |
+
echo " <a style=\"color:green;\" href=\"" . backwpup_admin_url('admin.php').'?page=backwpupworking' . "\">" . __('View!','backwpup') . "</a>";
|
487 |
+
echo " <a style=\"color:red;\" href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpup&action=abort', 'abort-job') . "\">" . __('Abort!','backwpup') . "</a>";
|
488 |
+
echo "</li>";
|
489 |
+
$count++;
|
490 |
+
} elseif ($jobvalue['activated']) {
|
491 |
+
echo '<li><span>'.date_i18n(get_option('date_format'),$jobvalue['cronnextrun']).' @ '.date_i18n(get_option('time_format'),$jobvalue['cronnextrun']).'</span>';
|
492 |
+
echo ' <a href="'.wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupeditjob&jobid='.$jobvalue['jobid'], 'edit-job').'" title="'.__('Edit Job','backwpup').'">'.$jobvalue['name'].'</a><br />';
|
493 |
+
echo "</li>";
|
494 |
+
$count++;
|
495 |
+
}
|
496 |
+
}
|
497 |
+
|
498 |
+
if ($count==0)
|
499 |
+
echo '<li><i>'.__('none','backwpup').'</i></li>';
|
500 |
+
echo '</ul>';
|
501 |
+
}
|
502 |
+
|
503 |
+
//add dashboard widget
|
504 |
+
function backwpup_add_dashboard() {
|
505 |
+
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
506 |
+
return;
|
507 |
+
wp_add_dashboard_widget( 'backwpup_dashboard_widget_logs', __('BackWPup Logs','backwpup'), 'backwpup_dashboard_logs' , 'backwpup_dashboard_logs_config');
|
508 |
+
wp_add_dashboard_widget( 'backwpup_dashboard_widget_activejobs', __('BackWPup Aktive Jobs','backwpup'), 'backwpup_dashboard_activejobs' );
|
509 |
+
}
|
510 |
+
|
511 |
+
//add admin bar menu
|
512 |
+
function backwpup_add_adminbar() {
|
513 |
+
global $wp_admin_bar;
|
514 |
+
$cfg=get_option('backwpup'); //Load Settings
|
515 |
+
if (!$cfg['showadminbar'] || !current_user_can(BACKWPUP_USER_CAPABILITY) || !is_super_admin() || !is_admin_bar_showing())
|
516 |
+
return;
|
517 |
+
/* Add the main siteadmin menu item */
|
518 |
+
$wp_admin_bar->add_menu(array( 'id' => 'backwpup', 'title' => __( 'BackWPup', 'textdomain' ), 'href' => backwpup_admin_url('admin.php').'?page=backwpup'));
|
519 |
+
if (backwpup_get_working_file())
|
520 |
+
$wp_admin_bar->add_menu(array( 'id' => 'backwpup_working','parent' => 'backwpup', 'title' => __('See Working!','backwpup'), 'href' => backwpup_admin_url('admin.php').'?page=backwpupworking'));
|
521 |
+
$wp_admin_bar->add_menu(array( 'id' => 'backwpup_jobs', 'parent' => 'backwpup', 'title' => __('Jobs','backwpup'), 'href' => backwpup_admin_url('admin.php').'?page=backwpup'));
|
522 |
+
$wp_admin_bar->add_menu(array( 'id' => 'backwpup_logs', 'parent' => 'backwpup', 'title' => __('Logs','backwpup'), 'href' => backwpup_admin_url('admin.php').'?page=backwpuplogs'));
|
523 |
+
$wp_admin_bar->add_menu(array( 'id' => 'backwpup_backups', 'parent' => 'backwpup', 'title' => __('Backups','backwpup'), 'href' => backwpup_admin_url('admin.php').'?page=backwpupbackups'));
|
524 |
+
$wp_admin_bar->add_menu(array( 'id' => 'backwpup_newjob', 'parent' => 'new-content', 'title' => __('BackWPup Job','backwpup'), 'href' => backwpup_admin_url('admin.php').'?page=backwpupeditjob'));
|
525 |
+
}
|
526 |
+
|
527 |
+
function backwpup_get_upload_dir() {
|
528 |
+
$upload_path = get_option('upload_path');
|
529 |
+
$upload_path = trim($upload_path);
|
530 |
+
if ( empty($upload_path) ) {
|
531 |
+
$dir = WP_CONTENT_DIR . '/uploads';
|
532 |
+
} else {
|
533 |
+
$dir = $upload_path;
|
534 |
+
if ( 'wp-content/uploads' == $upload_path ) {
|
535 |
+
$dir = WP_CONTENT_DIR . '/uploads';
|
536 |
+
} elseif ( 0 !== strpos($dir, ABSPATH) ) {
|
537 |
+
// $dir is absolute, $upload_path is (maybe) relative to ABSPATH
|
538 |
+
$dir = path_join( ABSPATH, $dir );
|
539 |
+
}
|
540 |
+
}
|
541 |
+
if (defined('UPLOADS') && !is_multisite()) {
|
542 |
+
$dir = ABSPATH . UPLOADS;
|
543 |
+
}
|
544 |
+
if (is_multisite()) {
|
545 |
+
$dir = untrailingslashit(WP_CONTENT_DIR).'/blogs.dir';
|
546 |
+
}
|
547 |
+
return str_replace('\\','/',trailingslashit($dir));
|
548 |
+
}
|
549 |
+
|
550 |
+
function backwpup_get_exclude_wp_dirs($folder) {
|
551 |
+
$cfg=get_option('backwpup'); //Load Settings
|
552 |
+
$folder=trailingslashit(str_replace('\\','/',$folder));
|
553 |
+
$excludedir=array();
|
554 |
+
$excludedir[]=backwpup_get_temp(); //exclude temp
|
555 |
+
$excludedir[]=rtrim(str_replace('\\','/',$cfg['dirlogs']),'/').'/'; //exclude logfiles
|
556 |
+
if (false !== strpos(trailingslashit(str_replace('\\','/',ABSPATH)),$folder) and trailingslashit(str_replace('\\','/',ABSPATH))!=$folder)
|
557 |
+
$excludedir[]=trailingslashit(str_replace('\\','/',ABSPATH));
|
558 |
+
if (false !== strpos(trailingslashit(str_replace('\\','/',WP_CONTENT_DIR)),$folder) and trailingslashit(str_replace('\\','/',WP_CONTENT_DIR))!=$folder)
|
559 |
+
$excludedir[]=trailingslashit(str_replace('\\','/',WP_CONTENT_DIR));
|
560 |
+
if (false !== strpos(trailingslashit(str_replace('\\','/',WP_PLUGIN_DIR)),$folder) and trailingslashit(str_replace('\\','/',WP_PLUGIN_DIR))!=$folder)
|
561 |
+
$excludedir[]=trailingslashit(str_replace('\\','/',WP_PLUGIN_DIR));
|
562 |
+
if (false !== strpos(str_replace('\\','/',trailingslashit(WP_CONTENT_DIR).'themes/'),$folder) and str_replace('\\','/',trailingslashit(WP_CONTENT_DIR).'themes/')!=$folder)
|
563 |
+
$excludedir[]=str_replace('\\','/',trailingslashit(WP_CONTENT_DIR).'themes/');
|
564 |
+
if (false !== strpos(backwpup_get_upload_dir(),$folder) and backwpup_get_upload_dir()!=$folder)
|
565 |
+
$excludedir[]=backwpup_get_upload_dir();
|
566 |
+
//Exclude Backup dirs
|
567 |
+
$jobs=get_option('backwpup_jobs');
|
568 |
+
if (!empty($jobs)) {
|
569 |
+
foreach($jobs as $jobsvale) {
|
570 |
+
if (!empty($jobsvale['backupdir']) and $jobsvale['backupdir']!='/')
|
571 |
+
$excludedir[]=$jobsvale['backupdir'];
|
572 |
+
}
|
573 |
+
}
|
574 |
+
return $excludedir;
|
575 |
+
}
|
576 |
+
|
577 |
+
//Calcs next run for a cron string as timestamp
|
578 |
+
function backwpup_cron_next($cronstring) {
|
579 |
+
//Cronstring zerlegen
|
580 |
+
list($cronstr['minutes'],$cronstr['hours'],$cronstr['mday'],$cronstr['mon'],$cronstr['wday'])=explode(' ',$cronstring,5);
|
581 |
+
|
582 |
+
//make arrys form string
|
583 |
+
foreach ($cronstr as $key => $value) {
|
584 |
+
if (strstr($value,','))
|
585 |
+
$cronarray[$key]=explode(',',$value);
|
586 |
+
else
|
587 |
+
$cronarray[$key]=array(0=>$value);
|
588 |
+
}
|
589 |
+
//make arrys complete with ranges and steps
|
590 |
+
foreach ($cronarray as $cronarraykey => $cronarrayvalue) {
|
591 |
+
$cron[$cronarraykey]=array();
|
592 |
+
foreach ($cronarrayvalue as $key => $value) {
|
593 |
+
//steps
|
594 |
+
$step=1;
|
595 |
+
if (strstr($value,'/'))
|
596 |
+
list($value,$step)=explode('/',$value,2);
|
597 |
+
//replase weekday 7 with 0 for sundays
|
598 |
+
if ($cronarraykey=='wday')
|
599 |
+
$value=str_replace('7','0',$value);
|
600 |
+
//ranges
|
601 |
+
if (strstr($value,'-')) {
|
602 |
+
list($first,$last)=explode('-',$value,2);
|
603 |
+
if (!is_numeric($first) or !is_numeric($last) or $last>60 or $first>60) //check
|
604 |
+
return 2147483647;
|
605 |
+
if ($cronarraykey=='minutes' and $step<5) //set step ninimum to 5 min.
|
606 |
+
$step=5;
|
607 |
+
$range=array();
|
608 |
+
for ($i=$first;$i<=$last;$i=$i+$step)
|
609 |
+
$range[]=$i;
|
610 |
+
$cron[$cronarraykey]=array_merge($cron[$cronarraykey],$range);
|
611 |
+
} elseif ($value=='*') {
|
612 |
+
$range=array();
|
613 |
+
if ($cronarraykey=='minutes') {
|
614 |
+
if ($step<5) //set step ninimum to 5 min.
|
615 |
+
$step=5;
|
616 |
+
for ($i=0;$i<=59;$i=$i+$step)
|
617 |
+
$range[]=$i;
|
618 |
+
}
|
619 |
+
if ($cronarraykey=='hours') {
|
620 |
+
for ($i=0;$i<=23;$i=$i+$step)
|
621 |
+
$range[]=$i;
|
622 |
+
}
|
623 |
+
if ($cronarraykey=='mday') {
|
624 |
+
for ($i=$step;$i<=31;$i=$i+$step)
|
625 |
+
$range[]=$i;
|
626 |
+
}
|
627 |
+
if ($cronarraykey=='mon') {
|
628 |
+
for ($i=$step;$i<=12;$i=$i+$step)
|
629 |
+
$range[]=$i;
|
630 |
+
}
|
631 |
+
if ($cronarraykey=='wday') {
|
632 |
+
for ($i=0;$i<=6;$i=$i+$step)
|
633 |
+
$range[]=$i;
|
634 |
+
}
|
635 |
+
$cron[$cronarraykey]=array_merge($cron[$cronarraykey],$range);
|
636 |
+
} else {
|
637 |
+
//Month names
|
638 |
+
if (strtolower($value)=='jan')
|
639 |
+
$value=1;
|
640 |
+
if (strtolower($value)=='feb')
|
641 |
+
$value=2;
|
642 |
+
if (strtolower($value)=='mar')
|
643 |
+
$value=3;
|
644 |
+
if (strtolower($value)=='apr')
|
645 |
+
$value=4;
|
646 |
+
if (strtolower($value)=='may')
|
647 |
+
$value=5;
|
648 |
+
if (strtolower($value)=='jun')
|
649 |
+
$value=6;
|
650 |
+
if (strtolower($value)=='jul')
|
651 |
+
$value=7;
|
652 |
+
if (strtolower($value)=='aug')
|
653 |
+
$value=8;
|
654 |
+
if (strtolower($value)=='sep')
|
655 |
+
$value=9;
|
656 |
+
if (strtolower($value)=='oct')
|
657 |
+
$value=10;
|
658 |
+
if (strtolower($value)=='nov')
|
659 |
+
$value=11;
|
660 |
+
if (strtolower($value)=='dec')
|
661 |
+
$value=12;
|
662 |
+
//Week Day names
|
663 |
+
if (strtolower($value)=='sun')
|
664 |
+
$value=0;
|
665 |
+
if (strtolower($value)=='sat')
|
666 |
+
$value=6;
|
667 |
+
if (strtolower($value)=='mon')
|
668 |
+
$value=1;
|
669 |
+
if (strtolower($value)=='tue')
|
670 |
+
$value=2;
|
671 |
+
if (strtolower($value)=='wed')
|
672 |
+
$value=3;
|
673 |
+
if (strtolower($value)=='thu')
|
674 |
+
$value=4;
|
675 |
+
if (strtolower($value)=='fri')
|
676 |
+
$value=5;
|
677 |
+
if (!is_numeric($value) or $value>60) //check
|
678 |
+
return 2147483647;
|
679 |
+
$cron[$cronarraykey]=array_merge($cron[$cronarraykey],array(0=>$value));
|
680 |
+
}
|
681 |
+
}
|
682 |
+
}
|
683 |
+
//generate next 10 years
|
684 |
+
for ($i=date('Y');$i<2038;$i++)
|
685 |
+
$cron['year'][]=$i;
|
686 |
+
|
687 |
+
//calc next timestamp
|
688 |
+
$currenttime=current_time('timestamp');
|
689 |
+
foreach ($cron['year'] as $year) {
|
690 |
+
foreach ($cron['mon'] as $mon) {
|
691 |
+
foreach ($cron['mday'] as $mday) {
|
692 |
+
foreach ($cron['hours'] as $hours) {
|
693 |
+
foreach ($cron['minutes'] as $minutes) {
|
694 |
+
$timestamp=mktime($hours,$minutes,0,$mon,$mday,$year);
|
695 |
+
if ($timestamp and in_array(date('j',$timestamp),$cron['mday']) and in_array(date('w',$timestamp),$cron['wday']) and $timestamp>$currenttime) {
|
696 |
+
return $timestamp;
|
697 |
+
}
|
698 |
+
}
|
699 |
+
}
|
700 |
+
}
|
701 |
+
}
|
702 |
+
}
|
703 |
+
return 2147483647;
|
704 |
+
}
|
705 |
+
|
706 |
+
function backwpup_get_working_file() {
|
707 |
+
$tempdir=backwpup_get_temp();
|
708 |
+
if (is_file($tempdir.'.running')) {
|
709 |
+
if ($runningfile=file_get_contents($tempdir.'.running'))
|
710 |
+
return unserialize(trim($runningfile));
|
711 |
+
else
|
712 |
+
return false;
|
713 |
+
} else {
|
714 |
+
return false;
|
715 |
+
}
|
716 |
+
}
|
717 |
+
|
718 |
+
function backwpup_admin_url($url) {
|
719 |
+
if (is_multisite()) {
|
720 |
+
if (is_super_admin())
|
721 |
+
return network_admin_url($url);
|
722 |
+
} else {
|
723 |
+
return admin_url($url);
|
724 |
+
}
|
725 |
+
}
|
726 |
+
|
727 |
+
function backwpup_env_checks() {
|
728 |
+
global $wp_version,$backwpup_admin_message;
|
729 |
+
$message='';
|
730 |
+
$checks=true;
|
731 |
+
$cfg=get_option('backwpup');
|
732 |
+
if (version_compare($wp_version, BACKWPUP_MIN_WORDPRESS_VERSION, '<')) { // check WP Version
|
733 |
+
$message.=str_replace('%d',BACKWPUP_MIN_WORDPRESS_VERSION,__('- WordPress %d or higher is needed!','backwpup')) . '<br />';
|
734 |
+
$checks=false;
|
735 |
+
}
|
736 |
+
if (version_compare(phpversion(), '5.2.4', '<')) { // check PHP Version
|
737 |
+
$message.=__('- PHP 5.2.4 or higher is needed!','backwpup') . '<br />';
|
738 |
+
$checks=false;
|
739 |
+
}
|
740 |
+
if (!is_dir(backwpup_get_temp())) { // create logs folder if it not exists
|
741 |
+
@mkdir(untrailingslashit(backwpup_get_temp()),0777,true);
|
742 |
+
}
|
743 |
+
if (!is_dir(backwpup_get_temp())) { // check logs folder
|
744 |
+
$message.=sprintf(__("- Temp folder '%s' does not exists!",'backwpup'),backwpup_get_temp()).'<br />';
|
745 |
+
}
|
746 |
+
if (!is_writable(backwpup_get_temp())) { // check logs folder
|
747 |
+
$message.=sprintf(__("- Temp folder '%s' is not writeable!",'backwpup'),backwpup_get_temp()).'<br />';
|
748 |
+
}
|
749 |
+
if (!empty($cfg['dirlogs']) and !is_dir($cfg['dirlogs'])) { // create logs folder if it not exists
|
750 |
+
@mkdir(untrailingslashit($cfg['dirlogs']),0777,true);
|
751 |
+
}
|
752 |
+
if (!is_dir($cfg['dirlogs'])) { // check logs folder
|
753 |
+
$message.=sprintf(__("- Log folder '%s' does not exists!",'backwpup'),$cfg['dirlogs']).'<br />';
|
754 |
+
}
|
755 |
+
if (!is_writable($cfg['dirlogs'])) { // check logs folder
|
756 |
+
$message.=sprintf(__("- Log folder '%s' is not writeable!",'backwpup'),$cfg['dirlogs']).'<br />';
|
757 |
+
}
|
758 |
+
if (!backwpup_check_open_basedir($cfg['dirlogs'])) { // check logs folder
|
759 |
+
$message.=sprintf(__("- Log folder '%s' is not in open_basedir path!",'backwpup'),$cfg['dirlogs']).'<br />';
|
760 |
+
}
|
761 |
+
if (strtolower(substr(WP_CONTENT_URL,0,7))!='http://' and strtolower(substr(WP_CONTENT_URL,0,8))!='https://') { // check logs folder
|
762 |
+
$message.=sprintf(__("- WP_CONTENT_URL '%s' must set as a full URL!",'backwpup'),WP_CONTENT_URL).'<br />';
|
763 |
+
}
|
764 |
+
if (strtolower(substr(WP_PLUGIN_URL,0,7))!='http://' and strtolower(substr(WP_PLUGIN_URL,0,8))!='https://') { // check logs folder
|
765 |
+
$message.=sprintf(__("- WP_PLUGIN_URL '%s' must set as a full URL!",'backwpup'),WP_PLUGIN_URL).'<br />';
|
766 |
+
}
|
767 |
+
if (false !== $nextrun=wp_next_scheduled('backwpup_cron')) {
|
768 |
+
if (empty($nextrun) or $nextrun<(time()-(3600*24))) { //check cron jobs work
|
769 |
+
$message.=__("- WP-Cron isn't working, please check it!","backwpup") .'<br />';
|
770 |
+
}
|
771 |
+
}
|
772 |
+
//put massage if one
|
773 |
+
if (!empty($message))
|
774 |
+
$backwpup_admin_message = '<div id="message" class="error fade"><strong>BackWPup:</strong><br />'.$message.'</div>';
|
775 |
+
return $checks;
|
776 |
+
}
|
777 |
+
|
778 |
+
function backwpup_admin_notice() {
|
779 |
+
global $backwpup_admin_message;
|
780 |
+
if (current_user_can(BACKWPUP_USER_CAPABILITY))
|
781 |
+
echo $backwpup_admin_message;
|
782 |
+
return;
|
783 |
+
}
|
784 |
+
|
785 |
+
//Checking,upgrade and default job setting
|
786 |
+
function backwpup_get_job_vars($jobid='',$jobnewsettings='') {
|
787 |
+
global $wpdb;
|
788 |
+
//get job data
|
789 |
+
$jobs=get_option('backwpup_jobs'); //load jobs
|
790 |
+
if (!empty($jobid)) {
|
791 |
+
if (isset($jobs[$jobid]))
|
792 |
+
$jobsettings=$jobs[$jobid];
|
793 |
+
$jobsettings['jobid']=$jobid;
|
794 |
+
} else {
|
795 |
+
if (empty($jobsettings['jobid'])) { //generate jobid if not exists
|
796 |
+
$heighestid=0;
|
797 |
+
if (is_array($jobs)) {
|
798 |
+
foreach ($jobs as $jobkey => $jobvalue) {
|
799 |
+
if ($jobkey>$heighestid)
|
800 |
+
$heighestid=$jobkey;
|
801 |
+
}
|
802 |
+
}
|
803 |
+
$jobsettings['jobid']=$heighestid+1;
|
804 |
+
}
|
805 |
+
}
|
806 |
+
unset($jobs);
|
807 |
+
unset($jobid);
|
808 |
+
if (!empty($jobnewsettings) && is_array($jobnewsettings)) { //overwrite with new settings
|
809 |
+
$jobsettings=array_merge($jobsettings,$jobnewsettings);
|
810 |
+
}
|
811 |
+
|
812 |
+
//check job type
|
813 |
+
if (!isset($jobsettings['type']) or !is_string($jobsettings['type']))
|
814 |
+
$jobsettings['type']='DB+FILE';
|
815 |
+
$todo=explode('+',strtoupper($jobsettings['type']));
|
816 |
+
foreach($todo as $key => $value) {
|
817 |
+
if (!in_array($value,backwpup_backup_types()))
|
818 |
+
unset($todo[$key]);
|
819 |
+
}
|
820 |
+
$jobsettings['type']=implode('+',$todo);
|
821 |
+
if (empty($jobsettings['type']))
|
822 |
+
$jobsettings['type']='DB+FILE';
|
823 |
+
|
824 |
+
if (empty($jobsettings['name']) or !is_string($jobsettings['name']))
|
825 |
+
$jobsettings['name']= __('New', 'backwpup');
|
826 |
+
|
827 |
+
if (!isset($jobsettings['activated']) or !is_bool($jobsettings['activated']))
|
828 |
+
$jobsettings['activated']=false;
|
829 |
+
|
830 |
+
if (!isset($jobsettings['cronselect']) and !isset($jobsettings['cron']))
|
831 |
+
$jobsettings['cronselect']='basic';
|
832 |
+
elseif (!isset($jobsettings['cronselect']) and isset($jobsettings['cron']))
|
833 |
+
$jobsettings['cronselect']='advanced';
|
834 |
+
|
835 |
+
if ($jobsettings['cronselect']!='advanced' and $jobsettings['cronselect']!='basic')
|
836 |
+
$jobsettings['cronselect']='advanced';
|
837 |
+
|
838 |
+
if (!isset($jobsettings['cron']) or !is_string($jobsettings['cron']))
|
839 |
+
$jobsettings['cron']='0 3 * * *';
|
840 |
+
|
841 |
+
if (!isset($jobsettings['cronnextrun']) or !is_numeric($jobsettings['cronnextrun']))
|
842 |
+
$jobsettings['cronnextrun']=backwpup_cron_next($jobsettings['cron']);
|
843 |
+
|
844 |
+
if (!isset($jobsettings['mailaddresslog']) or !is_string($jobsettings['mailaddresslog']))
|
845 |
+
$jobsettings['mailaddresslog']=get_option('admin_email');
|
846 |
+
|
847 |
+
if (!isset($jobsettings['mailerroronly']) or !is_bool($jobsettings['mailerroronly']))
|
848 |
+
$jobsettings['mailerroronly']=true;
|
849 |
+
|
850 |
+
|
851 |
+
//Tables to backup (old)
|
852 |
+
if (isset($jobsettings['dbtables']) and is_array($jobsettings['dbtables'])) {
|
853 |
+
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
854 |
+
foreach ($tables as $table) {
|
855 |
+
if (!in_array($table,$jobsettings['dbtables']))
|
856 |
+
$jobsettings['dbexclude'][]=$table;
|
857 |
+
}
|
858 |
+
}
|
859 |
+
|
860 |
+
//don not backup tables
|
861 |
+
if (!isset($jobsettings['dbexclude']) or !is_array($jobsettings['dbexclude'])) {
|
862 |
+
$jobsettings['dbexclude']=array();
|
863 |
+
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
864 |
+
foreach ($tables as $table) {
|
865 |
+
if (substr($table,0,strlen($wpdb->prefix))!=$wpdb->prefix)
|
866 |
+
$jobsettings['dbexclude'][]=$table;
|
867 |
+
}
|
868 |
+
}
|
869 |
+
|
870 |
+
if (!isset($jobsettings['dbshortinsert']) or !is_bool($jobsettings['dbshortinsert']))
|
871 |
+
$jobsettings['dbshortinsert']=false;
|
872 |
+
|
873 |
+
if (!isset($jobsettings['maintenance']) or !is_bool($jobsettings['maintenance']))
|
874 |
+
$jobsettings['maintenance']=false;
|
875 |
+
|
876 |
+
if (!isset($jobsettings['fileexclude']) or !is_string($jobsettings['fileexclude']))
|
877 |
+
$jobsettings['fileexclude']='';
|
878 |
+
$fileexclude=explode(',',$jobsettings['fileexclude']);
|
879 |
+
foreach($fileexclude as $key => $value) {
|
880 |
+
$fileexclude[$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
881 |
+
if (empty($fileexclude[$key]))
|
882 |
+
unset($fileexclude[$key]);
|
883 |
+
}
|
884 |
+
sort($fileexclude);
|
885 |
+
$jobsettings['fileexclude']=implode(',',$fileexclude);
|
886 |
+
|
887 |
+
if (!isset($jobsettings['dirinclude']) or !is_string($jobsettings['dirinclude']))
|
888 |
+
$jobsettings['dirinclude']='';
|
889 |
+
$dirinclude=explode(',',$jobsettings['dirinclude']);
|
890 |
+
foreach($dirinclude as $key => $value) {
|
891 |
+
$dirinclude[$key]=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($value))));
|
892 |
+
if ($dirinclude[$key]=='/' or empty($dirinclude[$key]) or !is_dir($dirinclude[$key]))
|
893 |
+
unset($dirinclude[$key]);
|
894 |
+
}
|
895 |
+
sort($dirinclude);
|
896 |
+
$jobsettings['dirinclude']=implode(',',$dirinclude);
|
897 |
+
|
898 |
+
if (!isset($jobsettings['backuproot']) or !is_bool($jobsettings['backuproot']))
|
899 |
+
$jobsettings['backuproot']=true;
|
900 |
+
|
901 |
+
if (!isset($jobsettings['backupcontent']) or !is_bool($jobsettings['backupcontent']))
|
902 |
+
$jobsettings['backupcontent']=true;
|
903 |
+
|
904 |
+
if (!isset($jobsettings['backupplugins']) or !is_bool($jobsettings['backupplugins']))
|
905 |
+
$jobsettings['backupplugins']=true;
|
906 |
+
|
907 |
+
if (!isset($jobsettings['backupthemes']) or !is_bool($jobsettings['backupthemes']))
|
908 |
+
$jobsettings['backupthemes']=true;
|
909 |
+
|
910 |
+
if (!isset($jobsettings['backupuploads']) or !is_bool($jobsettings['backupuploads']))
|
911 |
+
$jobsettings['backupuploads']=true;
|
912 |
+
|
913 |
+
if (!isset($jobsettings['backuprootexcludedirs']) or !is_array($jobsettings['backuprootexcludedirs']))
|
914 |
+
$jobsettings['backuprootexcludedirs']=array();
|
915 |
+
foreach($jobsettings['backuprootexcludedirs'] as $key => $value) {
|
916 |
+
$jobsettings['backuprootexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
917 |
+
if (empty($jobsettings['backuprootexcludedirs'][$key]) or $jobsettings['backuprootexcludedirs'][$key]=='/' or !is_dir($jobsettings['backuprootexcludedirs'][$key]))
|
918 |
+
unset($jobsettings['backuprootexcludedirs'][$key]);
|
919 |
+
}
|
920 |
+
sort($jobsettings['backuprootexcludedirs']);
|
921 |
+
|
922 |
+
if (!isset($jobsettings['backupcontentexcludedirs']) or !is_array($jobsettings['backupcontentexcludedirs']))
|
923 |
+
$jobsettings['backupcontentexcludedirs']=array();
|
924 |
+
foreach($jobsettings['backupcontentexcludedirs'] as $key => $value) {
|
925 |
+
$jobsettings['backupcontentexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
926 |
+
if (empty($jobsettings['backupcontentexcludedirs'][$key]) or $jobsettings['backupcontentexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupcontentexcludedirs'][$key]))
|
927 |
+
unset($jobsettings['backupcontentexcludedirs'][$key]);
|
928 |
+
}
|
929 |
+
sort($jobsettings['backupcontentexcludedirs']);
|
930 |
+
|
931 |
+
if (!isset($jobsettings['backuppluginsexcludedirs']) or !is_array($jobsettings['backuppluginsexcludedirs']))
|
932 |
+
$jobsettings['backuppluginsexcludedirs']=array();
|
933 |
+
foreach($jobsettings['backuppluginsexcludedirs'] as $key => $value) {
|
934 |
+
$jobsettings['backuppluginsexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
935 |
+
if (empty($jobsettings['backuppluginsexcludedirs'][$key]) or $jobsettings['backuppluginsexcludedirs'][$key]=='/' or !is_dir($jobsettings['backuppluginsexcludedirs'][$key]))
|
936 |
+
unset($jobsettings['backuppluginsexcludedirs'][$key]);
|
937 |
+
}
|
938 |
+
sort($jobsettings['backuppluginsexcludedirs']);
|
939 |
+
|
940 |
+
if (!isset($jobsettings['backupthemesexcludedirs']) or !is_array($jobsettings['backupthemesexcludedirs']))
|
941 |
+
$jobsettings['backupthemesexcludedirs']=array();
|
942 |
+
foreach($jobsettings['backupthemesexcludedirs'] as $key => $value) {
|
943 |
+
$jobsettings['backupthemesexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
944 |
+
if (empty($jobsettings['backupthemesexcludedirs'][$key]) or $jobsettings['backupthemesexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupthemesexcludedirs'][$key]))
|
945 |
+
unset($jobsettings['backupthemesexcludedirs'][$key]);
|
946 |
+
}
|
947 |
+
sort($jobsettings['backupthemesexcludedirs']);
|
948 |
+
|
949 |
+
if (!isset($jobsettings['backupuploadsexcludedirs']) or !is_array($jobsettings['backupuploadsexcludedirs']))
|
950 |
+
$jobsettings['backupuploadsexcludedirs']=array();
|
951 |
+
foreach($jobsettings['backupuploadsexcludedirs'] as $key => $value) {
|
952 |
+
$jobsettings['backupuploadsexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
953 |
+
if (empty($jobsettings['backupuploadsexcludedirs'][$key]) or $jobsettings['backupuploadsexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupuploadsexcludedirs'][$key]))
|
954 |
+
unset($jobsettings['backupuploadsexcludedirs'][$key]);
|
955 |
+
}
|
956 |
+
sort($jobsettings['backupuploadsexcludedirs']);
|
957 |
+
|
958 |
+
$fileformarts=array('.zip','.tar.gz','.tar.bz2','.tar');
|
959 |
+
if (!isset($jobsettings['fileformart']) or !in_array($jobsettings['fileformart'],$fileformarts))
|
960 |
+
$jobsettings['fileformart']='.zip';
|
961 |
+
|
962 |
+
if (!isset($jobsettings['fileprefix']) or !is_string($jobsettings['fileprefix']))
|
963 |
+
$jobsettings['fileprefix']='backwpup_'.$jobsettings['jobid'].'_';
|
964 |
+
|
965 |
+
if (!isset($jobsettings['mailefilesize']) or !is_float($jobsettings['mailefilesize']))
|
966 |
+
$jobsettings['mailefilesize']=0;
|
967 |
+
|
968 |
+
if (!isset($jobsettings['backupdir']))
|
969 |
+
$jobsettings['backupdir']='';
|
970 |
+
if (substr($jobsettings['backupdir'],0,1)!='/' and substr($jobsettings['backupdir'],1,1)!=':' and !empty($jobsettings['backupdir'])) //add abspath if not absolute
|
971 |
+
$jobsettings['backupdir']=rtrim(str_replace('\\','/',ABSPATH),'/').'/'.$jobsettings['backupdir'];
|
972 |
+
$jobsettings['backupdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['backupdir']))));
|
973 |
+
if ($jobsettings['backupdir']=='/')
|
974 |
+
$jobsettings['backupdir']='';
|
975 |
+
|
976 |
+
if (!isset($jobsettings['maxbackups']) or !is_int($jobsettings['maxbackups']))
|
977 |
+
$jobsettings['maxbackups']=0;
|
978 |
+
|
979 |
+
if (!empty($jobsettings['ftphost']) and false !== strpos($jobsettings['ftphost'],':'))
|
980 |
+
list($jobsettings['ftphost'],$jobsettings['ftphostport'])=explode(':',$jobsettings['ftphost'],2);
|
981 |
+
|
982 |
+
if (!isset($jobsettings['ftphost']) or !is_string($jobsettings['ftphost']))
|
983 |
+
$jobsettings['ftphost']='';
|
984 |
+
|
985 |
+
$jobsettings['ftphost']=str_replace(array('http://','ftp://'),'',$jobsettings['ftphost']);
|
986 |
+
|
987 |
+
if (!isset($jobsettings['ftphostport']) or !is_int($jobsettings['ftphostport']))
|
988 |
+
$jobsettings['ftphostport']=21;
|
989 |
+
|
990 |
+
if (!isset($jobsettings['ftpuser']) or !is_string($jobsettings['ftpuser']))
|
991 |
+
$jobsettings['ftpuser']='';
|
992 |
+
|
993 |
+
if (!isset($jobsettings['ftppass']) or !is_string($jobsettings['ftppass']))
|
994 |
+
$jobsettings['ftppass']='';
|
995 |
+
|
996 |
+
if (!isset($jobsettings['ftpdir']) or !is_string($jobsettings['ftpdir']) or $jobsettings['ftpdir']=='/')
|
997 |
+
$jobsettings['ftpdir']='';
|
998 |
+
$jobsettings['ftpdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['ftpdir']))));
|
999 |
+
if (substr($jobsettings['ftpdir'],0,1)!='/')
|
1000 |
+
$jobsettings['ftpdir']='/'.$jobsettings['ftpdir'];
|
1001 |
+
|
1002 |
+
if (!isset($jobsettings['ftpmaxbackups']) or !is_int($jobsettings['ftpmaxbackups']))
|
1003 |
+
$jobsettings['ftpmaxbackups']=0;
|
1004 |
+
|
1005 |
+
if (!isset($jobsettings['ftppasv']) or !is_bool($jobsettings['ftppasv']))
|
1006 |
+
$jobsettings['ftppasv']=true;
|
1007 |
+
|
1008 |
+
if (!isset($jobsettings['ftpssl']) or !is_bool($jobsettings['ftpssl']))
|
1009 |
+
$jobsettings['ftpssl']=false;
|
1010 |
+
|
1011 |
+
if (!isset($jobsettings['awsAccessKey']) or !is_string($jobsettings['awsAccessKey']))
|
1012 |
+
$jobsettings['awsAccessKey']='';
|
1013 |
+
|
1014 |
+
if (!isset($jobsettings['awsSecretKey']) or !is_string($jobsettings['awsSecretKey']))
|
1015 |
+
$jobsettings['awsSecretKey']='';
|
1016 |
+
|
1017 |
+
if (!isset($jobsettings['awsrrs']) or !is_bool($jobsettings['awsrrs']))
|
1018 |
+
$jobsettings['awsrrs']=false;
|
1019 |
+
|
1020 |
+
if (!isset($jobsettings['awsBucket']) or !is_string($jobsettings['awsBucket']))
|
1021 |
+
$jobsettings['awsBucket']='';
|
1022 |
+
|
1023 |
+
if (!isset($jobsettings['awsdir']) or !is_string($jobsettings['awsdir']) or $jobsettings['awsdir']=='/')
|
1024 |
+
$jobsettings['awsdir']='';
|
1025 |
+
$jobsettings['awsdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['awsdir']))));
|
1026 |
+
if (substr($jobsettings['awsdir'],0,1)=='/')
|
1027 |
+
$jobsettings['awsdir']=substr($jobsettings['awsdir'],1);
|
1028 |
+
|
1029 |
+
if (!isset($jobsettings['awsmaxbackups']) or !is_int($jobsettings['awsmaxbackups']))
|
1030 |
+
$jobsettings['awsmaxbackups']=0;
|
1031 |
+
|
1032 |
+
if (!isset($jobsettings['GStorageAccessKey']) or !is_string($jobsettings['GStorageAccessKey']))
|
1033 |
+
$jobsettings['GStorageAccessKey']='';
|
1034 |
+
|
1035 |
+
if (!isset($jobsettings['GStorageSecret']) or !is_string($jobsettings['GStorageSecret']))
|
1036 |
+
$jobsettings['GStorageSecret']='';
|
1037 |
+
|
1038 |
+
if (!isset($jobsettings['GStorageBucket']) or !is_string($jobsettings['GStorageBucket']))
|
1039 |
+
$jobsettings['GStorageBucket']='';
|
1040 |
+
|
1041 |
+
if (!isset($jobsettings['GStoragedir']) or !is_string($jobsettings['GStoragedir']) or $jobsettings['GStoragedir']=='/')
|
1042 |
+
$jobsettings['GStoragedir']='';
|
1043 |
+
$jobsettings['GStoragedir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['GStoragedir']))));
|
1044 |
+
if (substr($jobsettings['GStoragedir'],0,1)=='/')
|
1045 |
+
$jobsettings['GStoragedir']=substr($jobsettings['GStoragedir'],1);
|
1046 |
+
|
1047 |
+
if (!isset($jobsettings['GStoragemaxbackups']) or !is_int($jobsettings['GStoragemaxbackups']))
|
1048 |
+
$jobsettings['GStoragemaxbackups']=0;
|
1049 |
+
|
1050 |
+
if (!isset($jobsettings['msazureHost']) or !is_string($jobsettings['msazureHost']))
|
1051 |
+
$jobsettings['msazureHost']='blob.core.windows.net';
|
1052 |
+
|
1053 |
+
if (!isset($jobsettings['msazureAccName']) or !is_string($jobsettings['msazureAccName']))
|
1054 |
+
$jobsettings['msazureAccName']='';
|
1055 |
+
|
1056 |
+
if (!isset($jobsettings['msazureKey']) or !is_string($jobsettings['msazureKey']))
|
1057 |
+
$jobsettings['msazureKey']='';
|
1058 |
+
|
1059 |
+
if (!isset($jobsettings['msazureContainer']) or !is_string($jobsettings['msazureContainer']))
|
1060 |
+
$jobsettings['msazureContainer']='';
|
1061 |
+
|
1062 |
+
if (!isset($jobsettings['msazuredir']) or !is_string($jobsettings['msazuredir']) or $jobsettings['msazuredir']=='/')
|
1063 |
+
$jobsettings['msazuredir']='';
|
1064 |
+
$jobsettings['msazuredir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['msazuredir']))));
|
1065 |
+
if (substr($jobsettings['msazuredir'],0,1)=='/')
|
1066 |
+
$jobsettings['msazuredir']=substr($jobsettings['msazuredir'],1);
|
1067 |
+
|
1068 |
+
if (!isset($jobsettings['msazuremaxbackups']) or !is_int($jobsettings['msazuremaxbackups']))
|
1069 |
+
$jobsettings['msazuremaxbackups']=0;
|
1070 |
+
|
1071 |
+
if (!isset($jobsettings['rscUsername']) or !is_string($jobsettings['rscUsername']))
|
1072 |
+
$jobsettings['rscUsername']='';
|
1073 |
+
|
1074 |
+
if (!isset($jobsettings['rscAPIKey']) or !is_string($jobsettings['rscAPIKey']))
|
1075 |
+
$jobsettings['rscAPIKey']='';
|
1076 |
+
|
1077 |
+
if (!isset($jobsettings['rscContainer']) or !is_string($jobsettings['rscContainer']))
|
1078 |
+
$jobsettings['rscContainer']='';
|
1079 |
+
|
1080 |
+
if (!isset($jobsettings['rscdir']) or !is_string($jobsettings['rscdir']) or $jobsettings['rscdir']=='/')
|
1081 |
+
$jobsettings['rscdir']='';
|
1082 |
+
$jobsettings['rscdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['rscdir']))));
|
1083 |
+
if (substr($jobsettings['rscdir'],0,1)=='/')
|
1084 |
+
$jobsettings['rscdir']=substr($jobsettings['rscdir'],1);
|
1085 |
+
|
1086 |
+
if (!isset($jobsettings['rscmaxbackups']) or !is_int($jobsettings['rscmaxbackups']))
|
1087 |
+
$jobsettings['rscmaxbackups']=0;
|
1088 |
+
|
1089 |
+
if (!isset($jobsettings['dropetoken']) or !is_string($jobsettings['dropetoken']))
|
1090 |
+
$jobsettings['dropetoken']='';
|
1091 |
+
|
1092 |
+
if (!isset($jobsettings['dropesecret']) or !is_string($jobsettings['dropesecret']))
|
1093 |
+
$jobsettings['dropesecret']='';
|
1094 |
+
|
1095 |
+
if (!isset($jobsettings['dropedir']) or !is_string($jobsettings['dropedir']) or $jobsettings['dropedir']=='/')
|
1096 |
+
$jobsettings['dropedir']='';
|
1097 |
+
$jobsettings['dropedir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['dropedir']))));
|
1098 |
+
if (substr($jobsettings['dropedir'],0,1)=='/')
|
1099 |
+
$jobsettings['dropedir']=substr($jobsettings['dropedir'],1);
|
1100 |
+
|
1101 |
+
if (!isset($jobsettings['droperoot']) or ($jobsettings['droperoot']!='dropbox' and $jobsettings['droperoot']!='sandbox'))
|
1102 |
+
$jobsettings['droperoot']='dropbox';
|
1103 |
+
|
1104 |
+
if (!isset($jobsettings['dropemaxbackups']) or !is_int($jobsettings['dropemaxbackups']))
|
1105 |
+
$jobsettings['dropemaxbackups']=0;
|
1106 |
+
|
1107 |
+
if (!isset($jobsettings['sugaruser']) or !is_string($jobsettings['sugaruser']))
|
1108 |
+
$jobsettings['sugaruser']='';
|
1109 |
+
|
1110 |
+
if (!isset($jobsettings['sugarpass']) or !is_string($jobsettings['sugarpass']))
|
1111 |
+
$jobsettings['sugarpass']='';
|
1112 |
+
|
1113 |
+
if (!isset($jobsettings['sugarroot']) or !is_string($jobsettings['sugarroot']))
|
1114 |
+
$jobsettings['sugarroot']='';
|
1115 |
+
|
1116 |
+
if (!isset($jobsettings['sugardir']) or !is_string($jobsettings['sugardir']) or $jobsettings['sugardir']=='/')
|
1117 |
+
$jobsettings['sugardir']='';
|
1118 |
+
$jobsettings['sugardir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['sugardir']))));
|
1119 |
+
if (substr($jobsettings['sugardir'],0,1)=='/')
|
1120 |
+
$jobsettings['sugardir']=substr($jobsettings['sugardir'],1);
|
1121 |
+
|
1122 |
+
if (!isset($jobsettings['sugarmaxbackups']) or !is_int($jobsettings['sugarmaxbackups']))
|
1123 |
+
$jobsettings['sugarmaxbackups']=0;
|
1124 |
+
|
1125 |
+
if (!isset($jobsettings['mailaddress']) or !is_string($jobsettings['mailaddress']))
|
1126 |
+
$jobsettings['mailaddress']='';
|
1127 |
+
|
1128 |
+
//unset old not nedded vars
|
1129 |
+
unset($jobsettings['scheduletime']);
|
1130 |
+
unset($jobsettings['scheduleintervaltype']);
|
1131 |
+
unset($jobsettings['scheduleintervalteimes']);
|
1132 |
+
unset($jobsettings['scheduleinterval']);
|
1133 |
+
unset($jobsettings['dropemail']);
|
1134 |
+
unset($jobsettings['dropepass']);
|
1135 |
+
unset($jobsettings['dbtables']);
|
1136 |
+
unset($jobsettings['dropesignmethod']);
|
1137 |
+
|
1138 |
+
return $jobsettings;
|
1139 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backwpup.php
CHANGED
@@ -1,107 +1,106 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: BackWPup
|
4 |
-
Plugin URI: http://backwpup.com
|
5 |
-
Description: WordPress Backup and more...
|
6 |
-
Author: Daniel Hüsken
|
7 |
-
Version: 2.1.
|
8 |
-
Author URI: http://danielhuesken.de
|
9 |
-
Text Domain: backwpup
|
10 |
-
Domain Path: /lang/
|
11 |
-
*/
|
12 |
-
|
13 |
-
/*
|
14 |
-
Copyright (C) 2011 Daniel H�sken (email: mail@backwpup.com)
|
15 |
-
|
16 |
-
This program is free software; you can redistribute it and/or
|
17 |
-
modify it under the terms of the GNU General Public License
|
18 |
-
as published by the Free Software Foundation; either version 2
|
19 |
-
of the License, or (at your option) any later version.
|
20 |
-
|
21 |
-
This program is distributed in the hope that it will be useful,
|
22 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
-
GNU General Public License for more details.
|
25 |
-
|
26 |
-
You should have received a copy of the GNU General Public License
|
27 |
-
along with this program; if not, write to the Free Software
|
28 |
-
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
29 |
-
*/
|
30 |
-
|
31 |
-
//Set plugin dirname
|
32 |
-
define('BACKWPUP_PLUGIN_BASEDIR', dirname(plugin_basename(__FILE__)));
|
33 |
-
define('BACKWPUP_PLUGIN_BASEURL',plugins_url('',__FILE__));
|
34 |
-
//Set Plugin Version
|
35 |
-
define('BACKWPUP_VERSION', '2.1.
|
36 |
-
//Set Min Wordpress Version
|
37 |
-
define('BACKWPUP_MIN_WORDPRESS_VERSION', '3.1');
|
38 |
-
//Set User Capability
|
39 |
-
define('BACKWPUP_USER_CAPABILITY', 'export');
|
40 |
-
//Set useable destinations
|
41 |
-
if (!defined('BACKWPUP_DESTS')) {
|
42 |
-
if (!function_exists('curl_init'))
|
43 |
-
define('BACKWPUP_DESTS', 'FTP,MSAZURE');
|
44 |
-
else
|
45 |
-
define('BACKWPUP_DESTS', 'FTP,DROPBOX,SUGARSYNC,S3,GSTORAGE,RSC,MSAZURE');
|
46 |
-
}
|
47 |
-
//Set Dropbox Aplication Keys
|
48 |
-
define('BACKWPUP_DROPBOX_APP_KEY', 'q2jbt0unkkc54u2');
|
49 |
-
define('BACKWPUP_DROPBOX_APP_SECRET', 't5hlbxtz473hchy');
|
50 |
-
//Set SugarSync Aplication Keys
|
51 |
-
define('BACKWPUP_SUGARSYNC_ACCESSKEY', 'OTcwNjc5MTI5OTQxMzY1Njc5OA');
|
52 |
-
define('BACKWPUP_SUGARSYNC_PRIVATEACCESSKEY', 'NzNmNDMwMDBiNTkwNDY0YzhjY2JiN2E5YWVkMjFmYmI');
|
53 |
-
//BackWPup API url
|
54 |
-
define('BACKWPUP_API_URL', 'https://api.backwpup.com');
|
55 |
-
//load Text Domain
|
56 |
-
load_plugin_textdomain('backwpup', false, BACKWPUP_PLUGIN_BASEDIR.'/lang');
|
57 |
-
//Load functions file
|
58 |
-
require_once(dirname(__FILE__).'/backwpup-functions.php');
|
59 |
-
//Plugin deactivate
|
60 |
-
register_deactivation_hook(__FILE__, 'backwpup_plugin_deactivate');
|
61 |
-
//Admin message
|
62 |
-
if (is_multisite())
|
63 |
-
add_action('network_admin_notices', 'backwpup_admin_notice');
|
64 |
-
else
|
65 |
-
add_action('admin_notices', 'backwpup_admin_notice');
|
66 |
-
//add cron intervals
|
67 |
-
add_filter('cron_schedules', 'backwpup_intervals',20);
|
68 |
-
//call activation settings
|
69 |
-
backwpup_plugin_activate();
|
70 |
-
//Check if plugin can activated
|
71 |
-
if (backwpup_env_checks()) {
|
72 |
-
if (is_multisite()) { //For multisite
|
73 |
-
//add Menu
|
74 |
-
add_action('network_admin_menu','backwpup_admin_menu');
|
75 |
-
//add Dashboard widget
|
76 |
-
add_action('wp_network_dashboard_setup', 'backwpup_add_dashboard');
|
77 |
-
if (is_main_site())
|
78 |
-
add_action('plugins_loaded','backwpup_plugin_activate');
|
79 |
-
//Additional links on the plugin page
|
80 |
-
add_filter('plugin_row_meta', 'backwpup_plugin_links',10,2);
|
81 |
-
} else {
|
82 |
-
//add Menu
|
83 |
-
add_action('admin_menu', 'backwpup_admin_menu',97);
|
84 |
-
//add Dashboard widget
|
85 |
-
add_action('wp_dashboard_setup', 'backwpup_add_dashboard');
|
86 |
-
//Additional links on the plugin page
|
87 |
-
add_filter('plugin_action_links_'.BACKWPUP_PLUGIN_BASEDIR.'/backwpup.php', 'backwpup_plugin_options_link');
|
88 |
-
add_filter('plugin_row_meta', 'backwpup_plugin_links',10,2);
|
89 |
-
}
|
90 |
-
//Actions for Cron job
|
91 |
-
add_action('backwpup_cron', 'backwpup_cron',1);
|
92 |
-
//add Admin Bar menu
|
93 |
-
add_action('admin_bar_menu', 'backwpup_add_adminbar',100);
|
94 |
-
//load ajax functions
|
95 |
-
backwpup_load_ajax();
|
96 |
-
//Disabele WP_Corn
|
97 |
-
$cfg=get_option('backwpup');
|
98 |
-
if (!empty($cfg['disablewpcron']))
|
99 |
-
define('DISABLE_WP_CRON',true);
|
100 |
-
//bypass Google Analytics by Yoast oauth
|
101 |
-
if ( isset($_GET['oauth_token']) && isset($_GET['page']) && $_GET['page'] == 'backwpupeditjob' ) {
|
102 |
-
$_GET['oauth_token_backwpup'] = $_GET['oauth_token'];
|
103 |
-
unset($_GET['oauth_token']);
|
104 |
-
unset($_REQUEST['oauth_token']);
|
105 |
-
}
|
106 |
-
}
|
107 |
-
?>
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: BackWPup
|
4 |
+
Plugin URI: http://backwpup.com
|
5 |
+
Description: WordPress Backup and more...
|
6 |
+
Author: Daniel Hüsken
|
7 |
+
Version: 2.1.12
|
8 |
+
Author URI: http://danielhuesken.de
|
9 |
+
Text Domain: backwpup
|
10 |
+
Domain Path: /lang/
|
11 |
+
*/
|
12 |
+
|
13 |
+
/*
|
14 |
+
Copyright (C) 2011 Daniel H�sken (email: mail@backwpup.com)
|
15 |
+
|
16 |
+
This program is free software; you can redistribute it and/or
|
17 |
+
modify it under the terms of the GNU General Public License
|
18 |
+
as published by the Free Software Foundation; either version 2
|
19 |
+
of the License, or (at your option) any later version.
|
20 |
+
|
21 |
+
This program is distributed in the hope that it will be useful,
|
22 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
+
GNU General Public License for more details.
|
25 |
+
|
26 |
+
You should have received a copy of the GNU General Public License
|
27 |
+
along with this program; if not, write to the Free Software
|
28 |
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
29 |
+
*/
|
30 |
+
|
31 |
+
//Set plugin dirname
|
32 |
+
define('BACKWPUP_PLUGIN_BASEDIR', dirname(plugin_basename(__FILE__)));
|
33 |
+
define('BACKWPUP_PLUGIN_BASEURL',plugins_url('',__FILE__));
|
34 |
+
//Set Plugin Version
|
35 |
+
define('BACKWPUP_VERSION', '2.1.12');
|
36 |
+
//Set Min Wordpress Version
|
37 |
+
define('BACKWPUP_MIN_WORDPRESS_VERSION', '3.1');
|
38 |
+
//Set User Capability
|
39 |
+
define('BACKWPUP_USER_CAPABILITY', 'export');
|
40 |
+
//Set useable destinations
|
41 |
+
if (!defined('BACKWPUP_DESTS')) {
|
42 |
+
if (!function_exists('curl_init'))
|
43 |
+
define('BACKWPUP_DESTS', 'FTP,MSAZURE');
|
44 |
+
else
|
45 |
+
define('BACKWPUP_DESTS', 'FTP,DROPBOX,SUGARSYNC,S3,GSTORAGE,RSC,MSAZURE');
|
46 |
+
}
|
47 |
+
//Set Dropbox Aplication Keys
|
48 |
+
define('BACKWPUP_DROPBOX_APP_KEY', 'q2jbt0unkkc54u2');
|
49 |
+
define('BACKWPUP_DROPBOX_APP_SECRET', 't5hlbxtz473hchy');
|
50 |
+
//Set SugarSync Aplication Keys
|
51 |
+
define('BACKWPUP_SUGARSYNC_ACCESSKEY', 'OTcwNjc5MTI5OTQxMzY1Njc5OA');
|
52 |
+
define('BACKWPUP_SUGARSYNC_PRIVATEACCESSKEY', 'NzNmNDMwMDBiNTkwNDY0YzhjY2JiN2E5YWVkMjFmYmI');
|
53 |
+
//BackWPup API url
|
54 |
+
define('BACKWPUP_API_URL', 'https://api.backwpup.com');
|
55 |
+
//load Text Domain
|
56 |
+
load_plugin_textdomain('backwpup', false, BACKWPUP_PLUGIN_BASEDIR.'/lang');
|
57 |
+
//Load functions file
|
58 |
+
require_once(dirname(__FILE__).'/backwpup-functions.php');
|
59 |
+
//Plugin deactivate
|
60 |
+
register_deactivation_hook(__FILE__, 'backwpup_plugin_deactivate');
|
61 |
+
//Admin message
|
62 |
+
if (is_multisite())
|
63 |
+
add_action('network_admin_notices', 'backwpup_admin_notice');
|
64 |
+
else
|
65 |
+
add_action('admin_notices', 'backwpup_admin_notice');
|
66 |
+
//add cron intervals
|
67 |
+
add_filter('cron_schedules', 'backwpup_intervals',20);
|
68 |
+
//call activation settings
|
69 |
+
backwpup_plugin_activate();
|
70 |
+
//Check if plugin can activated
|
71 |
+
if (backwpup_env_checks()) {
|
72 |
+
if (is_multisite()) { //For multisite
|
73 |
+
//add Menu
|
74 |
+
add_action('network_admin_menu','backwpup_admin_menu');
|
75 |
+
//add Dashboard widget
|
76 |
+
add_action('wp_network_dashboard_setup', 'backwpup_add_dashboard');
|
77 |
+
if (is_main_site())
|
78 |
+
add_action('plugins_loaded','backwpup_plugin_activate');
|
79 |
+
//Additional links on the plugin page
|
80 |
+
add_filter('plugin_row_meta', 'backwpup_plugin_links',10,2);
|
81 |
+
} else {
|
82 |
+
//add Menu
|
83 |
+
add_action('admin_menu', 'backwpup_admin_menu',97);
|
84 |
+
//add Dashboard widget
|
85 |
+
add_action('wp_dashboard_setup', 'backwpup_add_dashboard');
|
86 |
+
//Additional links on the plugin page
|
87 |
+
add_filter('plugin_action_links_'.BACKWPUP_PLUGIN_BASEDIR.'/backwpup.php', 'backwpup_plugin_options_link');
|
88 |
+
add_filter('plugin_row_meta', 'backwpup_plugin_links',10,2);
|
89 |
+
}
|
90 |
+
//Actions for Cron job
|
91 |
+
add_action('backwpup_cron', 'backwpup_cron',1);
|
92 |
+
//add Admin Bar menu
|
93 |
+
add_action('admin_bar_menu', 'backwpup_add_adminbar',100);
|
94 |
+
//load ajax functions
|
95 |
+
backwpup_load_ajax();
|
96 |
+
//Disabele WP_Corn
|
97 |
+
$cfg=get_option('backwpup');
|
98 |
+
if (!empty($cfg['disablewpcron']))
|
99 |
+
define('DISABLE_WP_CRON',true);
|
100 |
+
//bypass Google Analytics by Yoast oauth
|
101 |
+
if ( isset($_GET['oauth_token']) && isset($_GET['page']) && $_GET['page'] == 'backwpupeditjob' ) {
|
102 |
+
$_GET['oauth_token_backwpup'] = $_GET['oauth_token'];
|
103 |
+
unset($_GET['oauth_token']);
|
104 |
+
unset($_REQUEST['oauth_token']);
|
105 |
+
}
|
106 |
+
}
|
|
css/backwpup.css
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
#icon-backwpup {
|
2 |
-
background: url('BackWPup32.png') no-repeat;
|
3 |
-
}
|
4 |
-
.column-id {
|
5 |
-
width:5%;text-align:center;
|
6 |
-
}
|
7 |
-
.column-last, .column-next , .column-type {
|
8 |
-
width:15%;
|
9 |
-
}
|
10 |
-
.column-info {
|
11 |
-
width:20%;
|
12 |
-
}
|
1 |
+
#icon-backwpup {
|
2 |
+
background: url('BackWPup32.png') no-repeat;
|
3 |
+
}
|
4 |
+
.column-id {
|
5 |
+
width:5%;text-align:center;
|
6 |
+
}
|
7 |
+
.column-last, .column-next , .column-type {
|
8 |
+
width:15%;
|
9 |
+
}
|
10 |
+
.column-info {
|
11 |
+
width:20%;
|
12 |
+
}
|
css/backwpupbackups.css
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
#icon-backwpup {
|
2 |
-
background: url('BackWPup32.png') no-repeat;
|
3 |
-
}
|
4 |
-
.column-size, .column-time {
|
5 |
-
width:10%;
|
6 |
-
}
|
1 |
+
#icon-backwpup {
|
2 |
+
background: url('BackWPup32.png') no-repeat;
|
3 |
+
}
|
4 |
+
.column-size, .column-time {
|
5 |
+
width:10%;
|
6 |
+
}
|
css/backwpupeditjob.css
CHANGED
@@ -1,48 +1,48 @@
|
|
1 |
-
#icon-backwpup {
|
2 |
-
background: url('BackWPup32.png') no-repeat;
|
3 |
-
}
|
4 |
-
|
5 |
-
#cron-min, #cron-hour, #cron-day, #cron-month, #cron-weekday {
|
6 |
-
overflow:auto;
|
7 |
-
white-space:nowrap;
|
8 |
-
height:7em;
|
9 |
-
}
|
10 |
-
#cron-min-box , #cron-hour-box, #cron-day-box, #cron-month-box, #cron-weekday-box {
|
11 |
-
border-color:#CEE1EF;
|
12 |
-
border-style:solid;
|
13 |
-
border-width:2px;
|
14 |
-
margin:5px 0px 5px 5px;
|
15 |
-
padding:2px 2px;
|
16 |
-
width:85px;
|
17 |
-
float:left;
|
18 |
-
}
|
19 |
-
#dbtables {
|
20 |
-
border-color:#CEE1EF;
|
21 |
-
border-style:solid;
|
22 |
-
border-width:2px;
|
23 |
-
height:10em;
|
24 |
-
margin:3px 15px 3px 15px;
|
25 |
-
overflow:auto;
|
26 |
-
padding:0.5em 0.5em;
|
27 |
-
white-space:nowrap;
|
28 |
-
}
|
29 |
-
.dests {
|
30 |
-
float:left;
|
31 |
-
width:80%;
|
32 |
-
}
|
33 |
-
.destlinks {
|
34 |
-
font-style:italic;
|
35 |
-
letter-spacing:1px;
|
36 |
-
font-weight:bold;
|
37 |
-
line-height:20px;
|
38 |
-
white-space:nowrap;
|
39 |
-
}
|
40 |
-
#cron-text {
|
41 |
-
line-height:20px;
|
42 |
-
color:#804000;
|
43 |
-
}
|
44 |
-
#schedbasic {
|
45 |
-
border-color:#CEE1EF;
|
46 |
-
border-style:solid;
|
47 |
-
border-width:2px;
|
48 |
-
}
|
1 |
+
#icon-backwpup {
|
2 |
+
background: url('BackWPup32.png') no-repeat;
|
3 |
+
}
|
4 |
+
|
5 |
+
#cron-min, #cron-hour, #cron-day, #cron-month, #cron-weekday {
|
6 |
+
overflow:auto;
|
7 |
+
white-space:nowrap;
|
8 |
+
height:7em;
|
9 |
+
}
|
10 |
+
#cron-min-box , #cron-hour-box, #cron-day-box, #cron-month-box, #cron-weekday-box {
|
11 |
+
border-color:#CEE1EF;
|
12 |
+
border-style:solid;
|
13 |
+
border-width:2px;
|
14 |
+
margin:5px 0px 5px 5px;
|
15 |
+
padding:2px 2px;
|
16 |
+
width:85px;
|
17 |
+
float:left;
|
18 |
+
}
|
19 |
+
#dbtables {
|
20 |
+
border-color:#CEE1EF;
|
21 |
+
border-style:solid;
|
22 |
+
border-width:2px;
|
23 |
+
height:10em;
|
24 |
+
margin:3px 15px 3px 15px;
|
25 |
+
overflow:auto;
|
26 |
+
padding:0.5em 0.5em;
|
27 |
+
white-space:nowrap;
|
28 |
+
}
|
29 |
+
.dests {
|
30 |
+
float:left;
|
31 |
+
width:80%;
|
32 |
+
}
|
33 |
+
.destlinks {
|
34 |
+
font-style:italic;
|
35 |
+
letter-spacing:1px;
|
36 |
+
font-weight:bold;
|
37 |
+
line-height:20px;
|
38 |
+
white-space:nowrap;
|
39 |
+
}
|
40 |
+
#cron-text {
|
41 |
+
line-height:20px;
|
42 |
+
color:#804000;
|
43 |
+
}
|
44 |
+
#schedbasic {
|
45 |
+
border-color:#CEE1EF;
|
46 |
+
border-style:solid;
|
47 |
+
border-width:2px;
|
48 |
+
}
|
css/backwpuplogs.css
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
#icon-backwpup {
|
2 |
-
background: url('BackWPup32.png') no-repeat;
|
3 |
-
}
|
4 |
-
.column-id {
|
5 |
-
width:5%;text-align:center;
|
6 |
-
}
|
7 |
-
.column-runtime, .column-status , .column-size {
|
8 |
-
width:8%;
|
9 |
-
}
|
10 |
-
.column-type {
|
11 |
-
width:15%;
|
12 |
}
|
1 |
+
#icon-backwpup {
|
2 |
+
background: url('BackWPup32.png') no-repeat;
|
3 |
+
}
|
4 |
+
.column-id {
|
5 |
+
width:5%;text-align:center;
|
6 |
+
}
|
7 |
+
.column-runtime, .column-status , .column-size {
|
8 |
+
width:8%;
|
9 |
+
}
|
10 |
+
.column-type {
|
11 |
+
width:15%;
|
12 |
}
|
css/backwpupsettings.css
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
#icon-backwpup {
|
2 |
-
background: url('BackWPup32.png') no-repeat;
|
3 |
-
}
|
1 |
+
#icon-backwpup {
|
2 |
+
background: url('BackWPup32.png') no-repeat;
|
3 |
+
}
|
css/backwpuptools.css
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
#icon-backwpup {
|
2 |
-
background: url('BackWPup32.png') no-repeat;
|
3 |
-
}
|
1 |
+
#icon-backwpup {
|
2 |
+
background: url('BackWPup32.png') no-repeat;
|
3 |
+
}
|
css/backwpupworking.css
CHANGED
@@ -1,72 +1,72 @@
|
|
1 |
-
#icon-backwpup {
|
2 |
-
background: url('BackWPup32.png') no-repeat;
|
3 |
-
}
|
4 |
-
#showworking, #showlogfile{
|
5 |
-
background-color:black;
|
6 |
-
color:white;
|
7 |
-
font-family:fixedsys, monospace, Courier, monospace;
|
8 |
-
line-height: 15px;
|
9 |
-
font-size:12px;
|
10 |
-
border-color:#CEE1EF;
|
11 |
-
border-style:solid;
|
12 |
-
border-width:5px;
|
13 |
-
height:480px;
|
14 |
-
width:800px;
|
15 |
-
padding:2px 2px 2px 2px;
|
16 |
-
overflow:auto;
|
17 |
-
white-space:nowrap;
|
18 |
-
float:left;
|
19 |
-
}
|
20 |
-
.timestamp {
|
21 |
-
background-color:darkgrey;
|
22 |
-
}
|
23 |
-
.warning {
|
24 |
-
background-color:tan;
|
25 |
-
}
|
26 |
-
.error {
|
27 |
-
background-color:red;
|
28 |
-
}
|
29 |
-
#warningsid {
|
30 |
-
margin-left:10px;
|
31 |
-
margin-bottom:5px;
|
32 |
-
color:yellow;
|
33 |
-
font-size:20px;
|
34 |
-
}
|
35 |
-
#errorid {
|
36 |
-
margin-left:10px;
|
37 |
-
margin-bottom:5px;
|
38 |
-
color:red;
|
39 |
-
font-size:20px;
|
40 |
-
}
|
41 |
-
.progressbar {
|
42 |
-
margin-top:10px;
|
43 |
-
border-color:#CEE1EF;
|
44 |
-
border-style:solid;
|
45 |
-
border-width:2px;
|
46 |
-
height:20px;
|
47 |
-
width:800px;
|
48 |
-
-moz-border-radius: 3px;
|
49 |
-
-webkit-border-radius: 3px;
|
50 |
-
-khtml-border-radius: 3px;
|
51 |
-
border-radius: 3px;
|
52 |
-
}
|
53 |
-
#progressstep {
|
54 |
-
height:20px;
|
55 |
-
background-color:gray;
|
56 |
-
color:black;
|
57 |
-
text-align:center;
|
58 |
-
-moz-border-radius: 3px;
|
59 |
-
-webkit-border-radius: 3px;
|
60 |
-
-khtml-border-radius: 3px;
|
61 |
-
border-radius: 3px;
|
62 |
-
}
|
63 |
-
#progresssteps {
|
64 |
-
height:20px;
|
65 |
-
background-color:yellow;
|
66 |
-
color:black;
|
67 |
-
text-align:center;
|
68 |
-
-moz-border-radius: 3px;
|
69 |
-
-webkit-border-radius: 3px;
|
70 |
-
-khtml-border-radius: 3px;
|
71 |
-
border-radius: 3px;
|
72 |
}
|
1 |
+
#icon-backwpup {
|
2 |
+
background: url('BackWPup32.png') no-repeat;
|
3 |
+
}
|
4 |
+
#showworking, #showlogfile{
|
5 |
+
background-color:black;
|
6 |
+
color:white;
|
7 |
+
font-family:fixedsys, monospace, Courier, monospace;
|
8 |
+
line-height: 15px;
|
9 |
+
font-size:12px;
|
10 |
+
border-color:#CEE1EF;
|
11 |
+
border-style:solid;
|
12 |
+
border-width:5px;
|
13 |
+
height:480px;
|
14 |
+
width:800px;
|
15 |
+
padding:2px 2px 2px 2px;
|
16 |
+
overflow:auto;
|
17 |
+
white-space:nowrap;
|
18 |
+
float:left;
|
19 |
+
}
|
20 |
+
.timestamp {
|
21 |
+
background-color:darkgrey;
|
22 |
+
}
|
23 |
+
.warning {
|
24 |
+
background-color:tan;
|
25 |
+
}
|
26 |
+
.error {
|
27 |
+
background-color:red;
|
28 |
+
}
|
29 |
+
#warningsid {
|
30 |
+
margin-left:10px;
|
31 |
+
margin-bottom:5px;
|
32 |
+
color:yellow;
|
33 |
+
font-size:20px;
|
34 |
+
}
|
35 |
+
#errorid {
|
36 |
+
margin-left:10px;
|
37 |
+
margin-bottom:5px;
|
38 |
+
color:red;
|
39 |
+
font-size:20px;
|
40 |
+
}
|
41 |
+
.progressbar {
|
42 |
+
margin-top:10px;
|
43 |
+
border-color:#CEE1EF;
|
44 |
+
border-style:solid;
|
45 |
+
border-width:2px;
|
46 |
+
height:20px;
|
47 |
+
width:800px;
|
48 |
+
-moz-border-radius: 3px;
|
49 |
+
-webkit-border-radius: 3px;
|
50 |
+
-khtml-border-radius: 3px;
|
51 |
+
border-radius: 3px;
|
52 |
+
}
|
53 |
+
#progressstep {
|
54 |
+
height:20px;
|
55 |
+
background-color:gray;
|
56 |
+
color:black;
|
57 |
+
text-align:center;
|
58 |
+
-moz-border-radius: 3px;
|
59 |
+
-webkit-border-radius: 3px;
|
60 |
+
-khtml-border-radius: 3px;
|
61 |
+
border-radius: 3px;
|
62 |
+
}
|
63 |
+
#progresssteps {
|
64 |
+
height:20px;
|
65 |
+
background-color:yellow;
|
66 |
+
color:black;
|
67 |
+
text-align:center;
|
68 |
+
-moz-border-radius: 3px;
|
69 |
+
-webkit-border-radius: 3px;
|
70 |
+
-khtml-border-radius: 3px;
|
71 |
+
border-radius: 3px;
|
72 |
}
|
job/backup_create.php
CHANGED
@@ -1,216 +1,209 @@
|
|
1 |
-
<?PHP
|
2 |
-
function backup_create() {
|
3 |
-
global $WORKING,$STATIC;
|
4 |
-
if ($WORKING['ALLFILESIZE']==0)
|
5 |
-
return;
|
6 |
-
$filelist=get_filelist(); //get file list
|
7 |
-
$WORKING['STEPTODO']=count($filelist);
|
8 |
-
if (empty($WORKING['STEPDONE']))
|
9 |
-
$WORKING['STEPDONE']=0;
|
10 |
-
|
11 |
-
if (strtolower($STATIC['JOB']['fileformart'])==".zip") { //Zip files
|
12 |
-
if ($STATIC['CFG']['phpzip']) { //use php zip lib
|
13 |
-
trigger_error(sprintf(__('%d. try to create backup zip archive...','backwpup'),$WORKING['BACKUP_CREATE']['STEP_TRY']),E_USER_NOTICE);
|
14 |
-
$zip = new ZipArchive();
|
15 |
-
if ($res=$zip->open($STATIC['JOB']['backupdir'].$STATIC['backupfile'],ZIPARCHIVE::CREATE) === TRUE) {
|
16 |
-
for ($i=$WORKING['STEPDONE'];$i<$WORKING['STEPTODO'];$i++) {
|
17 |
-
if (!$zip->addFile($filelist[$i]['FILE'], $filelist[$i]['OUTFILE']))
|
18 |
-
trigger_error(sprintf(__('Can not add "%s" to zip archive!','backwpup'),$filelist[$i]['OUTFILE']),E_USER_ERROR);
|
19 |
-
$WORKING['STEPDONE']++;
|
20 |
-
update_working_file();
|
21 |
-
}
|
22 |
-
if ($zip->status>0) {
|
23 |
-
$ziperror=$zip->status;
|
24 |
-
if ($zip->status==4)
|
25 |
-
$ziperror=__('(4) ER_SEEK','backwpup');
|
26 |
-
if ($zip->status==5)
|
27 |
-
$ziperror=__('(5) ER_READ','backwpup');
|
28 |
-
if ($zip->status==9)
|
29 |
-
$ziperror=__('(9) ER_NOENT','backwpup');
|
30 |
-
if ($zip->status==10)
|
31 |
-
$ziperror=__('(10) ER_EXISTS','backwpup');
|
32 |
-
if ($zip->status==11)
|
33 |
-
$ziperror=__('(11) ER_OPEN','backwpup');
|
34 |
-
if ($zip->status==14)
|
35 |
-
$ziperror=__('(14) ER_MEMORY','backwpup');
|
36 |
-
if ($zip->status==18)
|
37 |
-
$ziperror=__('(18) ER_INVAL','backwpup');
|
38 |
-
if ($zip->status==19)
|
39 |
-
$ziperror=__('(19) ER_NOZIP','backwpup');
|
40 |
-
if ($zip->status==21)
|
41 |
-
$ziperror=__('(21) ER_INCONS','backwpup');
|
42 |
-
trigger_error(sprintf(__('Zip returns status: %s','backwpup'),$zip->status),E_USER_ERROR);
|
43 |
-
}
|
44 |
-
$res2=$zip->close();
|
45 |
-
trigger_error(__('Backup zip archive create done!','backwpup'),E_USER_NOTICE);
|
46 |
-
$WORKING['STEPSDONE'][]='BACKUP_CREATE'; //set done
|
47 |
-
} else {
|
48 |
-
trigger_error(sprintf(__('Can not create backup zip archive $s!','backwpup'),$res),E_USER_ERROR);
|
49 |
-
}
|
50 |
-
} else { //use PclZip
|
51 |
-
define('PCLZIP_TEMPORARY_DIR', $STATIC['TEMPDIR']);
|
52 |
-
require_once($STATIC['WP']['ABSPATH'].'wp-admin/includes/class-pclzip.php');
|
53 |
-
if ( ini_get( 'mbstring.func_overload' ) && function_exists( 'mb_internal_encoding' ) ) {
|
54 |
-
$previous_encoding = mb_internal_encoding();
|
55 |
-
mb_internal_encoding( 'ISO-8859-1' );
|
56 |
-
}
|
57 |
-
//Create Zip File
|
58 |
-
if (is_array($filelist[0])) {
|
59 |
-
trigger_error(sprintf(__('%d. try to create backup zip (PclZip) archive...','backwpup'),$WORKING['BACKUP_CREATE']['STEP_TRY']),E_USER_NOTICE);
|
60 |
-
for ($i=0;$i<$WORKING['STEPTODO'];$i++) { //must begin at 0 for PCLzip
|
61 |
-
$files[$i][79001]=$filelist[$i]['FILE'];
|
62 |
-
$files[$i][79003]=$filelist[$i]['OUTFILE'];
|
63 |
-
$files[$i][79004]=$filelist[$i]['MTIME'];
|
64 |
-
}
|
65 |
-
need_free_memory('20M'); //20MB free memory for zip
|
66 |
-
$zipbackupfile = new PclZip($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
67 |
-
if (0==$zipbackupfile->create($files,PCLZIP_CB_POST_ADD,'_pclzipPostAddCallBack',PCLZIP_OPT_TEMP_FILE_THRESHOLD, 5)) {
|
68 |
-
trigger_error(sprintf(__('Zip archive create error: %s','backwpup'),$zipbackupfile->errorInfo(true)),E_USER_ERROR);
|
69 |
-
} else {
|
70 |
-
$WORKING['STEPDONE']=count($filelist);
|
71 |
-
unset($files);
|
72 |
-
trigger_error(__('Backup zip archive create done','backwpup'),E_USER_NOTICE);
|
73 |
-
}
|
74 |
-
}
|
75 |
-
if ( isset($previous_encoding) )
|
76 |
-
mb_internal_encoding( $previous_encoding );
|
77 |
-
}
|
78 |
-
} elseif (strtolower($STATIC['JOB']['fileformart'])==".tar.gz" or strtolower($STATIC['JOB']['fileformart'])==".tar.bz2" or strtolower($STATIC['JOB']['fileformart'])==".tar") { //tar files
|
79 |
-
|
80 |
-
if (strtolower($STATIC['JOB']['fileformart'])=='.tar.gz') {
|
81 |
-
$tarbackup=gzopen($STATIC['JOB']['backupdir'].$STATIC['backupfile'],'w9');
|
82 |
-
} elseif (strtolower($STATIC['JOB']['fileformart'])=='.tar.bz2') {
|
83 |
-
$tarbackup=bzopen($STATIC['JOB']['backupdir'].$STATIC['backupfile'],'w');
|
84 |
-
} else {
|
85 |
-
$tarbackup=fopen($STATIC['JOB']['backupdir'].$STATIC['backupfile'],'w');
|
86 |
-
}
|
87 |
-
|
88 |
-
if (!$tarbackup) {
|
89 |
-
trigger_error(__('Can not create tar arcive file!','backwpup'),E_USER_ERROR);
|
90 |
-
return;
|
91 |
-
} else {
|
92 |
-
trigger_error(sprintf(__('%1$d. try to create %2$s archive file...','backwpup'),$WORKING['BACKUP_CREATE']['STEP_TRY'],substr($STATIC['JOB']['fileformart'],1)),E_USER_NOTICE);
|
93 |
-
}
|
94 |
-
|
95 |
-
for ($index=$WORKING['STEPDONE'];$index<$WORKING['STEPTODO'];$index++) {
|
96 |
-
need_free_memory(2097152); //2MB free memory for tar
|
97 |
-
$files=$filelist[$index];
|
98 |
-
//check file readable
|
99 |
-
if ( empty($files['FILE']) or !file_exists($files['FILE']) or !is_readable($files['FILE'])) {
|
100 |
-
trigger_error(sprintf(__('File "%s" not readable!','backwpup'),$files['FILE']),E_USER_WARNING);
|
101 |
-
$WORKING['STEPDONE']++;
|
102 |
-
continue;
|
103 |
-
}
|
104 |
-
|
105 |
-
//split filename larger than 100 chars
|
106 |
-
if (strlen($files['OUTFILE'])<=100) {
|
107 |
-
$filename=$files['OUTFILE'];
|
108 |
-
$filenameprefix="";
|
109 |
-
} else {
|
110 |
-
$filenameofset=strlen($files['OUTFILE'])-100;
|
111 |
-
$dividor=strpos($files['OUTFILE'],'/',$filenameofset);
|
112 |
-
$filename=substr($files['OUTFILE'],$dividor+1);
|
113 |
-
$filenameprefix=substr($files['OUTFILE'],0,$dividor);
|
114 |
-
if (strlen($filename)>100)
|
115 |
-
trigger_error(sprintf(__('File name "%1$s" to long to save corectly in %2$s archive!','backwpup'),$files['OUTFILE'],substr($STATIC['JOB']['fileformart'],1)),E_USER_WARNING);
|
116 |
-
if (strlen($filenameprefix)>155)
|
117 |
-
trigger_error(sprintf(__('File path "%1$s" to long to save corectly in %2$s archive!','backwpup'),$files['OUTFILE'],substr($STATIC['JOB']['fileformart'],1)),E_USER_WARNING);
|
118 |
-
}
|
119 |
-
//Set file user/group name if linux
|
120 |
-
$fileowner="Unknown";
|
121 |
-
$filegroup="Unknown";
|
122 |
-
if (function_exists('posix_getpwuid')) {
|
123 |
-
$info=posix_getpwuid($files['UID']);
|
124 |
-
$fileowner=$info['name'];
|
125 |
-
$info=posix_getgrgid($files['GID']);
|
126 |
-
$filegroup=$info['name'];
|
127 |
-
}
|
128 |
-
|
129 |
-
// Generate the TAR header for this file
|
130 |
-
$header = pack("a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155a12",
|
131 |
-
$filename, //name of file 100
|
132 |
-
sprintf("%07o", $files['MODE']), //file mode 8
|
133 |
-
sprintf("%07o", $files['UID']), //owner user ID 8
|
134 |
-
sprintf("%07o", $files['GID']), //owner group ID 8
|
135 |
-
sprintf("%011o", $files['SIZE']), //length of file in bytes 12
|
136 |
-
sprintf("%011o", $files['MTIME']), //modify time of file 12
|
137 |
-
" ", //checksum for header 8
|
138 |
-
0, //type of file 0 or null = File, 5=Dir
|
139 |
-
"", //name of linked file 100
|
140 |
-
"ustar", //USTAR indicator 6
|
141 |
-
"00", //USTAR version 2
|
142 |
-
$fileowner, //owner user name 32
|
143 |
-
$filegroup, //owner group name 32
|
144 |
-
"", //device major number 8
|
145 |
-
"", //device minor number 8
|
146 |
-
$filenameprefix, //prefix for file name 155
|
147 |
-
""); //fill block 512K
|
148 |
-
|
149 |
-
// Computes the unsigned Checksum of a file's header
|
150 |
-
$checksum = 0;
|
151 |
-
for ($i = 0; $i < 512; $i++)
|
152 |
-
$checksum += ord(substr($header, $i, 1));
|
153 |
-
$checksum = pack("a8", sprintf("%07o", $checksum));
|
154 |
-
|
155 |
-
$header = substr_replace($header, $checksum, 148, 8);
|
156 |
-
|
157 |
-
if (strtolower($STATIC['JOB']['fileformart'])=='.tar.gz') {
|
158 |
-
gzwrite($tarbackup, $header);
|
159 |
-
} elseif (strtolower($STATIC['JOB']['fileformart'])=='.tar.bz2') {
|
160 |
-
bzwrite($tarbackup, $header);
|
161 |
-
} else {
|
162 |
-
fwrite($tarbackup, $header);
|
163 |
-
}
|
164 |
-
|
165 |
-
// read/write files in 512K Blocks
|
166 |
-
if ($fd=fopen($files['FILE'],'rb')) {
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
$
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
}
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
global $WORKING,$STATIC;
|
211 |
-
if ($p_header['status'] != 'ok')
|
212 |
-
trigger_error(sprintf(__('PCL ZIP Error "%1$s" on file %2$s!','backwpup'),$p_header['status'],$p_header['filename']),E_USER_ERROR);
|
213 |
-
$WORKING['STEPDONE']++;
|
214 |
-
update_working_file();
|
215 |
-
}
|
216 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
function backup_create() {
|
3 |
+
global $WORKING,$STATIC;
|
4 |
+
if ($WORKING['ALLFILESIZE']==0)
|
5 |
+
return;
|
6 |
+
$filelist=get_filelist(); //get file list
|
7 |
+
$WORKING['STEPTODO']=count($filelist);
|
8 |
+
if (empty($WORKING['STEPDONE']))
|
9 |
+
$WORKING['STEPDONE']=0;
|
10 |
+
|
11 |
+
if (strtolower($STATIC['JOB']['fileformart'])==".zip") { //Zip files
|
12 |
+
if ($STATIC['CFG']['phpzip']) { //use php zip lib
|
13 |
+
trigger_error(sprintf(__('%d. try to create backup zip archive...','backwpup'),$WORKING['BACKUP_CREATE']['STEP_TRY']),E_USER_NOTICE);
|
14 |
+
$zip = new ZipArchive();
|
15 |
+
if ($res=$zip->open($STATIC['JOB']['backupdir'].$STATIC['backupfile'],ZIPARCHIVE::CREATE) === TRUE) {
|
16 |
+
for ($i=$WORKING['STEPDONE'];$i<$WORKING['STEPTODO'];$i++) {
|
17 |
+
if (!$zip->addFile($filelist[$i]['FILE'], $filelist[$i]['OUTFILE']))
|
18 |
+
trigger_error(sprintf(__('Can not add "%s" to zip archive!','backwpup'),$filelist[$i]['OUTFILE']),E_USER_ERROR);
|
19 |
+
$WORKING['STEPDONE']++;
|
20 |
+
update_working_file();
|
21 |
+
}
|
22 |
+
if ($zip->status>0) {
|
23 |
+
$ziperror=$zip->status;
|
24 |
+
if ($zip->status==4)
|
25 |
+
$ziperror=__('(4) ER_SEEK','backwpup');
|
26 |
+
if ($zip->status==5)
|
27 |
+
$ziperror=__('(5) ER_READ','backwpup');
|
28 |
+
if ($zip->status==9)
|
29 |
+
$ziperror=__('(9) ER_NOENT','backwpup');
|
30 |
+
if ($zip->status==10)
|
31 |
+
$ziperror=__('(10) ER_EXISTS','backwpup');
|
32 |
+
if ($zip->status==11)
|
33 |
+
$ziperror=__('(11) ER_OPEN','backwpup');
|
34 |
+
if ($zip->status==14)
|
35 |
+
$ziperror=__('(14) ER_MEMORY','backwpup');
|
36 |
+
if ($zip->status==18)
|
37 |
+
$ziperror=__('(18) ER_INVAL','backwpup');
|
38 |
+
if ($zip->status==19)
|
39 |
+
$ziperror=__('(19) ER_NOZIP','backwpup');
|
40 |
+
if ($zip->status==21)
|
41 |
+
$ziperror=__('(21) ER_INCONS','backwpup');
|
42 |
+
trigger_error(sprintf(__('Zip returns status: %s','backwpup'),$zip->status),E_USER_ERROR);
|
43 |
+
}
|
44 |
+
$res2=$zip->close();
|
45 |
+
trigger_error(__('Backup zip archive create done!','backwpup'),E_USER_NOTICE);
|
46 |
+
$WORKING['STEPSDONE'][]='BACKUP_CREATE'; //set done
|
47 |
+
} else {
|
48 |
+
trigger_error(sprintf(__('Can not create backup zip archive $s!','backwpup'),$res),E_USER_ERROR);
|
49 |
+
}
|
50 |
+
} else { //use PclZip
|
51 |
+
define('PCLZIP_TEMPORARY_DIR', $STATIC['TEMPDIR']);
|
52 |
+
require_once($STATIC['WP']['ABSPATH'].'wp-admin/includes/class-pclzip.php');
|
53 |
+
if ( ini_get( 'mbstring.func_overload' ) && function_exists( 'mb_internal_encoding' ) ) {
|
54 |
+
$previous_encoding = mb_internal_encoding();
|
55 |
+
mb_internal_encoding( 'ISO-8859-1' );
|
56 |
+
}
|
57 |
+
//Create Zip File
|
58 |
+
if (is_array($filelist[0])) {
|
59 |
+
trigger_error(sprintf(__('%d. try to create backup zip (PclZip) archive...','backwpup'),$WORKING['BACKUP_CREATE']['STEP_TRY']),E_USER_NOTICE);
|
60 |
+
for ($i=0;$i<$WORKING['STEPTODO'];$i++) { //must begin at 0 for PCLzip
|
61 |
+
$files[$i][79001]=$filelist[$i]['FILE'];
|
62 |
+
$files[$i][79003]=$filelist[$i]['OUTFILE'];
|
63 |
+
$files[$i][79004]=$filelist[$i]['MTIME'];
|
64 |
+
}
|
65 |
+
need_free_memory('20M'); //20MB free memory for zip
|
66 |
+
$zipbackupfile = new PclZip($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
67 |
+
if (0==$zipbackupfile->create($files,PCLZIP_CB_POST_ADD,'_pclzipPostAddCallBack',PCLZIP_OPT_TEMP_FILE_THRESHOLD, 5)) {
|
68 |
+
trigger_error(sprintf(__('Zip archive create error: %s','backwpup'),$zipbackupfile->errorInfo(true)),E_USER_ERROR);
|
69 |
+
} else {
|
70 |
+
$WORKING['STEPDONE']=count($filelist);
|
71 |
+
unset($files);
|
72 |
+
trigger_error(__('Backup zip archive create done','backwpup'),E_USER_NOTICE);
|
73 |
+
}
|
74 |
+
}
|
75 |
+
if ( isset($previous_encoding) )
|
76 |
+
mb_internal_encoding( $previous_encoding );
|
77 |
+
}
|
78 |
+
} elseif (strtolower($STATIC['JOB']['fileformart'])==".tar.gz" or strtolower($STATIC['JOB']['fileformart'])==".tar.bz2" or strtolower($STATIC['JOB']['fileformart'])==".tar") { //tar files
|
79 |
+
|
80 |
+
if (strtolower($STATIC['JOB']['fileformart'])=='.tar.gz') {
|
81 |
+
$tarbackup=gzopen($STATIC['JOB']['backupdir'].$STATIC['backupfile'],'w9');
|
82 |
+
} elseif (strtolower($STATIC['JOB']['fileformart'])=='.tar.bz2') {
|
83 |
+
$tarbackup=bzopen($STATIC['JOB']['backupdir'].$STATIC['backupfile'],'w');
|
84 |
+
} else {
|
85 |
+
$tarbackup=fopen($STATIC['JOB']['backupdir'].$STATIC['backupfile'],'w');
|
86 |
+
}
|
87 |
+
|
88 |
+
if (!$tarbackup) {
|
89 |
+
trigger_error(__('Can not create tar arcive file!','backwpup'),E_USER_ERROR);
|
90 |
+
return;
|
91 |
+
} else {
|
92 |
+
trigger_error(sprintf(__('%1$d. try to create %2$s archive file...','backwpup'),$WORKING['BACKUP_CREATE']['STEP_TRY'],substr($STATIC['JOB']['fileformart'],1)),E_USER_NOTICE);
|
93 |
+
}
|
94 |
+
|
95 |
+
for ($index=$WORKING['STEPDONE'];$index<$WORKING['STEPTODO'];$index++) {
|
96 |
+
need_free_memory(2097152); //2MB free memory for tar
|
97 |
+
$files=$filelist[$index];
|
98 |
+
//check file readable
|
99 |
+
if ( empty($files['FILE']) or !file_exists($files['FILE']) or !is_readable($files['FILE'])) {
|
100 |
+
trigger_error(sprintf(__('File "%s" not readable!','backwpup'),$files['FILE']),E_USER_WARNING);
|
101 |
+
$WORKING['STEPDONE']++;
|
102 |
+
continue;
|
103 |
+
}
|
104 |
+
|
105 |
+
//split filename larger than 100 chars
|
106 |
+
if (strlen($files['OUTFILE'])<=100) {
|
107 |
+
$filename=$files['OUTFILE'];
|
108 |
+
$filenameprefix="";
|
109 |
+
} else {
|
110 |
+
$filenameofset=strlen($files['OUTFILE'])-100;
|
111 |
+
$dividor=strpos($files['OUTFILE'],'/',$filenameofset);
|
112 |
+
$filename=substr($files['OUTFILE'],$dividor+1);
|
113 |
+
$filenameprefix=substr($files['OUTFILE'],0,$dividor);
|
114 |
+
if (strlen($filename)>100)
|
115 |
+
trigger_error(sprintf(__('File name "%1$s" to long to save corectly in %2$s archive!','backwpup'),$files['OUTFILE'],substr($STATIC['JOB']['fileformart'],1)),E_USER_WARNING);
|
116 |
+
if (strlen($filenameprefix)>155)
|
117 |
+
trigger_error(sprintf(__('File path "%1$s" to long to save corectly in %2$s archive!','backwpup'),$files['OUTFILE'],substr($STATIC['JOB']['fileformart'],1)),E_USER_WARNING);
|
118 |
+
}
|
119 |
+
//Set file user/group name if linux
|
120 |
+
$fileowner="Unknown";
|
121 |
+
$filegroup="Unknown";
|
122 |
+
if (function_exists('posix_getpwuid')) {
|
123 |
+
$info=posix_getpwuid($files['UID']);
|
124 |
+
$fileowner=$info['name'];
|
125 |
+
$info=posix_getgrgid($files['GID']);
|
126 |
+
$filegroup=$info['name'];
|
127 |
+
}
|
128 |
+
|
129 |
+
// Generate the TAR header for this file
|
130 |
+
$header = pack("a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155a12",
|
131 |
+
$filename, //name of file 100
|
132 |
+
sprintf("%07o", $files['MODE']), //file mode 8
|
133 |
+
sprintf("%07o", $files['UID']), //owner user ID 8
|
134 |
+
sprintf("%07o", $files['GID']), //owner group ID 8
|
135 |
+
sprintf("%011o", $files['SIZE']), //length of file in bytes 12
|
136 |
+
sprintf("%011o", $files['MTIME']), //modify time of file 12
|
137 |
+
" ", //checksum for header 8
|
138 |
+
0, //type of file 0 or null = File, 5=Dir
|
139 |
+
"", //name of linked file 100
|
140 |
+
"ustar", //USTAR indicator 6
|
141 |
+
"00", //USTAR version 2
|
142 |
+
$fileowner, //owner user name 32
|
143 |
+
$filegroup, //owner group name 32
|
144 |
+
"", //device major number 8
|
145 |
+
"", //device minor number 8
|
146 |
+
$filenameprefix, //prefix for file name 155
|
147 |
+
""); //fill block 512K
|
148 |
+
|
149 |
+
// Computes the unsigned Checksum of a file's header
|
150 |
+
$checksum = 0;
|
151 |
+
for ($i = 0; $i < 512; $i++)
|
152 |
+
$checksum += ord(substr($header, $i, 1));
|
153 |
+
$checksum = pack("a8", sprintf("%07o", $checksum));
|
154 |
+
|
155 |
+
$header = substr_replace($header, $checksum, 148, 8);
|
156 |
+
|
157 |
+
if (strtolower($STATIC['JOB']['fileformart'])=='.tar.gz') {
|
158 |
+
gzwrite($tarbackup, $header);
|
159 |
+
} elseif (strtolower($STATIC['JOB']['fileformart'])=='.tar.bz2') {
|
160 |
+
bzwrite($tarbackup, $header);
|
161 |
+
} else {
|
162 |
+
fwrite($tarbackup, $header);
|
163 |
+
}
|
164 |
+
|
165 |
+
// read/write files in 512K Blocks
|
166 |
+
if ($fd=fopen($files['FILE'],'rb')) {
|
167 |
+
while(!feof($fd)) {
|
168 |
+
$filedata=fread($fd,512);
|
169 |
+
if (strlen($filedata)>0) {
|
170 |
+
if (strtolower($STATIC['JOB']['fileformart'])=='.tar.gz') {
|
171 |
+
gzwrite($tarbackup,pack("a512", $filedata));
|
172 |
+
} elseif (strtolower($STATIC['JOB']['fileformart'])=='.tar.bz2') {
|
173 |
+
bzwrite($tarbackup,pack("a512", $filedata));
|
174 |
+
} else {
|
175 |
+
fwrite($tarbackup,pack("a512", $filedata));
|
176 |
+
}
|
177 |
+
}
|
178 |
+
}
|
179 |
+
fclose($fd);
|
180 |
+
}
|
181 |
+
$WORKING['STEPDONE']++;
|
182 |
+
update_working_file();
|
183 |
+
}
|
184 |
+
|
185 |
+
if (strtolower($STATIC['JOB']['fileformart'])=='.tar.gz') {
|
186 |
+
gzwrite($tarbackup, pack("a1024", "")); // Add 1024 bytes of NULLs to designate EOF
|
187 |
+
gzclose($tarbackup);
|
188 |
+
} elseif (strtolower($STATIC['JOB']['fileformart'])=='.tar.bz2') {
|
189 |
+
bzwrite($tarbackup, pack("a1024", "")); // Add 1024 bytes of NULLs to designate EOF
|
190 |
+
bzclose($tarbackup);
|
191 |
+
} else {
|
192 |
+
fwrite($tarbackup, pack("a1024", "")); // Add 1024 bytes of NULLs to designate EOF
|
193 |
+
fclose($tarbackup);
|
194 |
+
}
|
195 |
+
trigger_error(sprintf(__('%s archive creation done','backwpup'),substr($STATIC['JOB']['fileformart'],1)),E_USER_NOTICE);
|
196 |
+
}
|
197 |
+
$WORKING['STEPSDONE'][]='BACKUP_CREATE'; //set done
|
198 |
+
if ($filesize=filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']))
|
199 |
+
trigger_error(sprintf(__('Archive size is %s','backwpup'),formatBytes($filesize)),E_USER_NOTICE);
|
200 |
+
}
|
201 |
+
|
202 |
+
|
203 |
+
function _pclzipPostAddCallBack($p_event, &$p_header) {
|
204 |
+
global $WORKING,$STATIC;
|
205 |
+
if ($p_header['status'] != 'ok')
|
206 |
+
trigger_error(sprintf(__('PCL ZIP Error "%1$s" on file %2$s!','backwpup'),$p_header['status'],$p_header['filename']),E_USER_ERROR);
|
207 |
+
$WORKING['STEPDONE']++;
|
208 |
+
update_working_file();
|
209 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
job/db_check.php
CHANGED
@@ -1,65 +1,64 @@
|
|
1 |
-
<?PHP
|
2 |
-
function db_check() {
|
3 |
-
global $WORKING,$STATIC;
|
4 |
-
trigger_error(sprintf(__('%d. try for database check...','backwpup'),$WORKING['DB_CHECK']['STEP_TRY']),E_USER_NOTICE);
|
5 |
-
if (!isset($WORKING['DB_CHECK']['DONETABLE']) or !is_array($WORKING['DB_CHECK']['DONETABLE']))
|
6 |
-
$WORKING['DB_CHECK']['DONETABLE']=array();
|
7 |
-
|
8 |
-
mysql_update();
|
9 |
-
//to backup
|
10 |
-
$tabelstobackup=array();
|
11 |
-
$result=mysql_query("SHOW TABLES FROM `".$STATIC['WP']['DB_NAME']."`"); //get table status
|
12 |
-
if (!$result)
|
13 |
-
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "SHOW TABLE STATUS FROM `".$STATIC['WP']['DB_NAME']."`;"),E_USER_ERROR);
|
14 |
-
while ($data = mysql_fetch_row($result)) {
|
15 |
-
if (!in_array($data[0],$STATIC['JOB']['dbexclude']))
|
16 |
-
$tabelstobackup[]=$data[0];
|
17 |
-
}
|
18 |
-
//Set num of todos
|
19 |
-
$WORKING['STEPTODO']=sizeof($tabelstobackup);
|
20 |
-
|
21 |
-
//check tables
|
22 |
-
if (count($tabelstobackup)>0) {
|
23 |
-
maintenance_mode(true);
|
24 |
-
foreach ($tabelstobackup as $table) {
|
25 |
-
if (in_array($table, $WORKING['DB_CHECK']['DONETABLE']))
|
26 |
-
continue;
|
27 |
-
$result=mysql_query('CHECK TABLE `'.$table.'` MEDIUM');
|
28 |
-
if (!$result) {
|
29 |
-
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "CHECK TABLE `".$table."` MEDIUM"),E_USER_ERROR);
|
30 |
-
continue;
|
31 |
-
}
|
32 |
-
$check=mysql_fetch_assoc($result);
|
33 |
-
if ($check['Msg_type']=='error')
|
34 |
-
trigger_error(sprintf(__('Result of table check for %1$s is: %2$s','backwpup'), $table, $check['Msg_text']),E_USER_ERROR);
|
35 |
-
elseif ($check['Msg_type']=='warning')
|
36 |
-
trigger_error(sprintf(__('Result of table check for %1$s is: %2$s','backwpup'), $table, $check['Msg_text']),E_USER_WARNING);
|
37 |
-
else
|
38 |
-
trigger_error(sprintf(__('Result of table check for %1$s is: %2$s','backwpup'), $table, $check['Msg_text']),E_USER_NOTICE);
|
39 |
-
|
40 |
-
//Try to Repair tabele
|
41 |
-
if ($check['Msg_type']=='error' or $check['Msg_type']=='warning') {
|
42 |
-
$result=mysql_query('REPAIR TABLE `'.$table.'`');
|
43 |
-
if (!$result) {
|
44 |
-
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "REPAIR TABLE `'.$table.'`"),E_USER_ERROR);
|
45 |
-
continue;
|
46 |
-
}
|
47 |
-
$repair=mysql_fetch_assoc($result);
|
48 |
-
if ($repair['Msg_type']=='error')
|
49 |
-
trigger_error(sprintf(__('Result of table repair for %1$s is: %2$s','backwpup'), $table, $repair['Msg_text']),E_USER_ERROR);
|
50 |
-
elseif ($repair['Msg_type']=='warning')
|
51 |
-
trigger_error(sprintf(__('Result of table repair for %1$s is: %2$s','backwpup'), $table, $repair['Msg_text']),E_USER_WARNING);
|
52 |
-
else
|
53 |
-
trigger_error(sprintf(__('Result of table repair for %1$s is: %2$s','backwpup'), $table, $repair['Msg_text']),E_USER_NOTICE);
|
54 |
-
}
|
55 |
-
$WORKING['DB_CHECK']['DONETABLE'][]=$table;
|
56 |
-
$WORKING['STEPDONE']=sizeof($WORKING['DB_CHECK']['DONETABLE']);
|
57 |
-
}
|
58 |
-
maintenance_mode(false);
|
59 |
-
trigger_error(__('Database check done!','backwpup'),E_USER_NOTICE);
|
60 |
-
} else {
|
61 |
-
trigger_error(__('No tables to check','backwpup'),E_USER_WARNING);
|
62 |
-
}
|
63 |
-
$WORKING['STEPSDONE'][]='DB_CHECK'; //set done
|
64 |
-
}
|
65 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
function db_check() {
|
3 |
+
global $WORKING,$STATIC;
|
4 |
+
trigger_error(sprintf(__('%d. try for database check...','backwpup'),$WORKING['DB_CHECK']['STEP_TRY']),E_USER_NOTICE);
|
5 |
+
if (!isset($WORKING['DB_CHECK']['DONETABLE']) or !is_array($WORKING['DB_CHECK']['DONETABLE']))
|
6 |
+
$WORKING['DB_CHECK']['DONETABLE']=array();
|
7 |
+
|
8 |
+
mysql_update();
|
9 |
+
//to backup
|
10 |
+
$tabelstobackup=array();
|
11 |
+
$result=mysql_query("SHOW TABLES FROM `".$STATIC['WP']['DB_NAME']."`"); //get table status
|
12 |
+
if (!$result)
|
13 |
+
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "SHOW TABLE STATUS FROM `".$STATIC['WP']['DB_NAME']."`;"),E_USER_ERROR);
|
14 |
+
while ($data = mysql_fetch_row($result)) {
|
15 |
+
if (!in_array($data[0],$STATIC['JOB']['dbexclude']))
|
16 |
+
$tabelstobackup[]=$data[0];
|
17 |
+
}
|
18 |
+
//Set num of todos
|
19 |
+
$WORKING['STEPTODO']=sizeof($tabelstobackup);
|
20 |
+
|
21 |
+
//check tables
|
22 |
+
if (count($tabelstobackup)>0) {
|
23 |
+
maintenance_mode(true);
|
24 |
+
foreach ($tabelstobackup as $table) {
|
25 |
+
if (in_array($table, $WORKING['DB_CHECK']['DONETABLE']))
|
26 |
+
continue;
|
27 |
+
$result=mysql_query('CHECK TABLE `'.$table.'` MEDIUM');
|
28 |
+
if (!$result) {
|
29 |
+
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "CHECK TABLE `".$table."` MEDIUM"),E_USER_ERROR);
|
30 |
+
continue;
|
31 |
+
}
|
32 |
+
$check=mysql_fetch_assoc($result);
|
33 |
+
if ($check['Msg_type']=='error')
|
34 |
+
trigger_error(sprintf(__('Result of table check for %1$s is: %2$s','backwpup'), $table, $check['Msg_text']),E_USER_ERROR);
|
35 |
+
elseif ($check['Msg_type']=='warning')
|
36 |
+
trigger_error(sprintf(__('Result of table check for %1$s is: %2$s','backwpup'), $table, $check['Msg_text']),E_USER_WARNING);
|
37 |
+
else
|
38 |
+
trigger_error(sprintf(__('Result of table check for %1$s is: %2$s','backwpup'), $table, $check['Msg_text']),E_USER_NOTICE);
|
39 |
+
|
40 |
+
//Try to Repair tabele
|
41 |
+
if ($check['Msg_type']=='error' or $check['Msg_type']=='warning') {
|
42 |
+
$result=mysql_query('REPAIR TABLE `'.$table.'`');
|
43 |
+
if (!$result) {
|
44 |
+
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "REPAIR TABLE `'.$table.'`"),E_USER_ERROR);
|
45 |
+
continue;
|
46 |
+
}
|
47 |
+
$repair=mysql_fetch_assoc($result);
|
48 |
+
if ($repair['Msg_type']=='error')
|
49 |
+
trigger_error(sprintf(__('Result of table repair for %1$s is: %2$s','backwpup'), $table, $repair['Msg_text']),E_USER_ERROR);
|
50 |
+
elseif ($repair['Msg_type']=='warning')
|
51 |
+
trigger_error(sprintf(__('Result of table repair for %1$s is: %2$s','backwpup'), $table, $repair['Msg_text']),E_USER_WARNING);
|
52 |
+
else
|
53 |
+
trigger_error(sprintf(__('Result of table repair for %1$s is: %2$s','backwpup'), $table, $repair['Msg_text']),E_USER_NOTICE);
|
54 |
+
}
|
55 |
+
$WORKING['DB_CHECK']['DONETABLE'][]=$table;
|
56 |
+
$WORKING['STEPDONE']=sizeof($WORKING['DB_CHECK']['DONETABLE']);
|
57 |
+
}
|
58 |
+
maintenance_mode(false);
|
59 |
+
trigger_error(__('Database check done!','backwpup'),E_USER_NOTICE);
|
60 |
+
} else {
|
61 |
+
trigger_error(__('No tables to check','backwpup'),E_USER_WARNING);
|
62 |
+
}
|
63 |
+
$WORKING['STEPSDONE'][]='DB_CHECK'; //set done
|
64 |
+
}
|
|
job/db_dump.php
CHANGED
@@ -1,151 +1,150 @@
|
|
1 |
-
<?PHP
|
2 |
-
function db_dump() {
|
3 |
-
global $WORKING,$STATIC;
|
4 |
-
trigger_error(sprintf(__('%d. try for database dump...','backwpup'),$WORKING['DB_DUMP']['STEP_TRY']),E_USER_NOTICE);
|
5 |
-
if (!isset($WORKING['DB_DUMP']['DONETABLE']) or !is_array($WORKING['DB_DUMP']['DONETABLE']))
|
6 |
-
$WORKING['DB_DUMP']['DONETABLE']=array();
|
7 |
-
|
8 |
-
mysql_update();
|
9 |
-
//to backup
|
10 |
-
$tabelstobackup=array();
|
11 |
-
$result=mysql_query("SHOW TABLES FROM `".$STATIC['WP']['DB_NAME']."`"); //get table status
|
12 |
-
if (!$result)
|
13 |
-
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "SHOW TABLE STATUS FROM `".$STATIC['WP']['DB_NAME']."`;"),E_USER_ERROR);
|
14 |
-
while ($data = mysql_fetch_row($result)) {
|
15 |
-
if (!in_array($data[0],$STATIC['JOB']['dbexclude']))
|
16 |
-
$tabelstobackup[]=$data[0];
|
17 |
-
}
|
18 |
-
$WORKING['STEPTODO']=count($tabelstobackup);
|
19 |
-
//Set maintenance
|
20 |
-
maintenance_mode(true);
|
21 |
-
|
22 |
-
if (count($tabelstobackup)>0) {
|
23 |
-
$result=mysql_query("SHOW TABLE STATUS FROM `".$STATIC['WP']['DB_NAME']."`"); //get table status
|
24 |
-
if (!$result)
|
25 |
-
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "SHOW TABLE STATUS FROM `".$STATIC['WP']['DB_NAME']."`;"),E_USER_ERROR);
|
26 |
-
while ($data = mysql_fetch_assoc($result)) {
|
27 |
-
$status[$data['Name']]=$data;
|
28 |
-
}
|
29 |
-
|
30 |
-
if ($file = fopen($STATIC['TEMPDIR'].$STATIC['WP']['DB_NAME'].'.sql', 'wb')) {
|
31 |
-
fwrite($file, "-- ---------------------------------------------------------\n");
|
32 |
-
fwrite($file, "-- Dump with BackWPup ver.: ".$STATIC['BACKWPUP']['VERSION']."\n");
|
33 |
-
fwrite($file, "-- Plugin for WordPress ".$STATIC['WP']['VERSION']." by Daniel Huesken\n");
|
34 |
-
fwrite($file, "-- http://danielhuesken.de/portfolio/backwpup/\n");
|
35 |
-
fwrite($file, "-- Blog Name: ".$STATIC['WP']['BLOGNAME']."\n");
|
36 |
-
fwrite($file, "-- Blog URL: ".$STATIC['WP']['SITEURL']."\n");
|
37 |
-
fwrite($file, "-- Blog ABSPATH: ".$STATIC['WP']['ABSPATH']."\n");
|
38 |
-
fwrite($file, "-- Table Prefix: ".$STATIC['WP']['TABLE_PREFIX']."\n");
|
39 |
-
fwrite($file, "-- Database Name: ".$STATIC['WP']['DB_NAME']."\n");
|
40 |
-
fwrite($file, "-- Dump on: ".date('Y-m-d H:i.s',time()+$STATIC['WP']['TIMEDIFF'])."\n");
|
41 |
-
fwrite($file, "-- ---------------------------------------------------------\n\n");
|
42 |
-
//for better import with mysql client
|
43 |
-
fwrite($file, "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n");
|
44 |
-
fwrite($file, "/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\n");
|
45 |
-
fwrite($file, "/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\n");
|
46 |
-
fwrite($file, "/*!40101 SET NAMES '".mysql_client_encoding()."' */;\n");
|
47 |
-
fwrite($file, "/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;\n");
|
48 |
-
fwrite($file, "/*!40103 SET TIME_ZONE='".mysql_result(mysql_query("SELECT @@time_zone"),0)."' */;\n");
|
49 |
-
fwrite($file, "/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;\n");
|
50 |
-
fwrite($file, "/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;\n");
|
51 |
-
fwrite($file, "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;\n");
|
52 |
-
fwrite($file, "/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;\n\n");
|
53 |
-
//make table dumps
|
54 |
-
foreach($tabelstobackup as $table) {
|
55 |
-
if (in_array($table, $WORKING['DB_DUMP']['DONETABLE']))
|
56 |
-
continue;
|
57 |
-
trigger_error(sprintf(__('Dump database table "%s"','backwpup'),$table),E_USER_NOTICE);
|
58 |
-
need_free_memory(($status[$table]['Data_length']+$status[$table]['Index_length'])*
|
59 |
-
_db_dump_table($table,$status[$table],$file);
|
60 |
-
$WORKING['DB_DUMP']['DONETABLE'][]=$table;
|
61 |
-
$WORKING['STEPDONE']=count($WORKING['DB_DUMP']['DONETABLE']);
|
62 |
-
}
|
63 |
-
//for better import with mysql client
|
64 |
-
fwrite($file, "\n");
|
65 |
-
fwrite($file, "/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;\n");
|
66 |
-
fwrite($file, "/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;\n");
|
67 |
-
fwrite($file, "/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;\n");
|
68 |
-
fwrite($file, "/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;\n");
|
69 |
-
fwrite($file, "/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n");
|
70 |
-
fwrite($file, "/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\n");
|
71 |
-
fwrite($file, "/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;\n");
|
72 |
-
fwrite($file, "/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;\n");
|
73 |
-
fclose($file);
|
74 |
-
trigger_error(__('Database dump done!','backwpup'),E_USER_NOTICE);
|
75 |
-
} else {
|
76 |
-
trigger_error(__('Can not create database dump!','backwpup'),E_USER_ERROR);
|
77 |
-
}
|
78 |
-
} else {
|
79 |
-
trigger_error(__('No tables to dump','backwpup'),E_USER_WARNING);
|
80 |
-
}
|
81 |
-
|
82 |
-
//add database file to backupfiles
|
83 |
-
if (is_readable($STATIC['TEMPDIR'].$STATIC['WP']['DB_NAME'].'.sql')) {
|
84 |
-
$filestat=stat($STATIC['TEMPDIR'].$STATIC['WP']['DB_NAME'].'.sql');
|
85 |
-
trigger_error(sprintf(__('Add database dump "%1$s" with %2$s to backup file list','backwpup'),$STATIC['WP']['DB_NAME'].'.sql',formatbytes($filestat['size'])),E_USER_NOTICE);
|
86 |
-
$WORKING['ALLFILESIZE']+=$filestat['size'];
|
87 |
-
add_file(array(array('FILE'=>$STATIC['TEMPDIR'].$STATIC['WP']['DB_NAME'].'.sql','OUTFILE'=>$STATIC['WP']['DB_NAME'].'.sql','SIZE'=>$filestat['size'],'ATIME'=>$filestat['atime'],'MTIME'=>$filestat['mtime'],'CTIME'=>$filestat['ctime'],'UID'=>$filestat['uid'],'GID'=>$filestat['gid'],'MODE'=>$filestat['mode'])));
|
88 |
-
}
|
89 |
-
//Back from maintenance
|
90 |
-
maintenance_mode(false);
|
91 |
-
$WORKING['STEPSDONE'][]='DB_DUMP'; //set done
|
92 |
-
}
|
93 |
-
|
94 |
-
|
95 |
-
function _db_dump_table($table,$status,$file) {
|
96 |
-
global $WORKING,$STATIC;
|
97 |
-
// create dump
|
98 |
-
fwrite($file, "\n");
|
99 |
-
fwrite($file, "--\n");
|
100 |
-
fwrite($file, "-- Table structure for table $table\n");
|
101 |
-
fwrite($file, "--\n\n");
|
102 |
-
fwrite($file, "DROP TABLE IF EXISTS `" . $table . "`;\n");
|
103 |
-
fwrite($file, "/*!40101 SET @saved_cs_client = @@character_set_client */;\n");
|
104 |
-
fwrite($file, "/*!40101 SET character_set_client = '".mysql_client_encoding()."' */;\n");
|
105 |
-
//Dump the table structure
|
106 |
-
$result=mysql_query("SHOW CREATE TABLE `".$table."`");
|
107 |
-
if (!$result) {
|
108 |
-
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "SHOW CREATE TABLE `".$table."`"),E_USER_ERROR);
|
109 |
-
return false;
|
110 |
-
}
|
111 |
-
$tablestruc=mysql_fetch_assoc($result);
|
112 |
-
fwrite($file, $tablestruc['Create Table'].";\n");
|
113 |
-
fwrite($file, "/*!40101 SET character_set_client = @saved_cs_client */;\n");
|
114 |
-
|
115 |
-
//take data of table
|
116 |
-
$result=mysql_query("SELECT * FROM `".$table."`");
|
117 |
-
if (!$result) {
|
118 |
-
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "SELECT * FROM `".$table."`"),E_USER_ERROR);
|
119 |
-
return false;
|
120 |
-
}
|
121 |
-
|
122 |
-
fwrite($file, "--\n");
|
123 |
-
fwrite($file, "-- Dumping data for table $table\n");
|
124 |
-
fwrite($file, "--\n\n");
|
125 |
-
if ($status['Engine']=='MyISAM')
|
126 |
-
fwrite($file, "/*!40000 ALTER TABLE `".$table."` DISABLE KEYS */;\n");
|
127 |
-
|
128 |
-
while ($data = mysql_fetch_assoc($result)) {
|
129 |
-
$keys = array();
|
130 |
-
$values = array();
|
131 |
-
foreach($data as $key => $value) {
|
132 |
-
if (!$STATIC['JOB']['dbshortinsert'])
|
133 |
-
$keys[] = "`".str_replace("�", "��", $key)."`"; // Add key to key list
|
134 |
-
if($value === NULL) // Make Value NULL to string NULL
|
135 |
-
$value = "NULL";
|
136 |
-
elseif($value === "" or $value === false) // if empty or false Value make "" as Value
|
137 |
-
$value = "''";
|
138 |
-
elseif(!is_numeric($value)) //is value not numeric esc
|
139 |
-
$value = "'".mysql_real_escape_string($value)."'";
|
140 |
-
$values[] = $value;
|
141 |
-
}
|
142 |
-
// make data dump
|
143 |
-
if ($STATIC['JOB']['dbshortinsert'])
|
144 |
-
fwrite($file, "INSERT INTO `".$table."` VALUES ( ".implode(", ",$values)." );\n");
|
145 |
-
else
|
146 |
-
fwrite($file, "INSERT INTO `".$table."` ( ".implode(", ",$keys)." )\n\tVALUES ( ".implode(", ",$values)." );\n");
|
147 |
-
}
|
148 |
-
if ($status['Engine']=='MyISAM')
|
149 |
-
fwrite($file, "/*!40000 ALTER TABLE ".$table." ENABLE KEYS */;\n");
|
150 |
-
}
|
151 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
function db_dump() {
|
3 |
+
global $WORKING,$STATIC;
|
4 |
+
trigger_error(sprintf(__('%d. try for database dump...','backwpup'),$WORKING['DB_DUMP']['STEP_TRY']),E_USER_NOTICE);
|
5 |
+
if (!isset($WORKING['DB_DUMP']['DONETABLE']) or !is_array($WORKING['DB_DUMP']['DONETABLE']))
|
6 |
+
$WORKING['DB_DUMP']['DONETABLE']=array();
|
7 |
+
|
8 |
+
mysql_update();
|
9 |
+
//to backup
|
10 |
+
$tabelstobackup=array();
|
11 |
+
$result=mysql_query("SHOW TABLES FROM `".$STATIC['WP']['DB_NAME']."`"); //get table status
|
12 |
+
if (!$result)
|
13 |
+
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "SHOW TABLE STATUS FROM `".$STATIC['WP']['DB_NAME']."`;"),E_USER_ERROR);
|
14 |
+
while ($data = mysql_fetch_row($result)) {
|
15 |
+
if (!in_array($data[0],$STATIC['JOB']['dbexclude']))
|
16 |
+
$tabelstobackup[]=$data[0];
|
17 |
+
}
|
18 |
+
$WORKING['STEPTODO']=count($tabelstobackup);
|
19 |
+
//Set maintenance
|
20 |
+
maintenance_mode(true);
|
21 |
+
|
22 |
+
if (count($tabelstobackup)>0) {
|
23 |
+
$result=mysql_query("SHOW TABLE STATUS FROM `".$STATIC['WP']['DB_NAME']."`"); //get table status
|
24 |
+
if (!$result)
|
25 |
+
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "SHOW TABLE STATUS FROM `".$STATIC['WP']['DB_NAME']."`;"),E_USER_ERROR);
|
26 |
+
while ($data = mysql_fetch_assoc($result)) {
|
27 |
+
$status[$data['Name']]=$data;
|
28 |
+
}
|
29 |
+
|
30 |
+
if ($file = fopen($STATIC['TEMPDIR'].$STATIC['WP']['DB_NAME'].'.sql', 'wb')) {
|
31 |
+
fwrite($file, "-- ---------------------------------------------------------\n");
|
32 |
+
fwrite($file, "-- Dump with BackWPup ver.: ".$STATIC['BACKWPUP']['VERSION']."\n");
|
33 |
+
fwrite($file, "-- Plugin for WordPress ".$STATIC['WP']['VERSION']." by Daniel Huesken\n");
|
34 |
+
fwrite($file, "-- http://danielhuesken.de/portfolio/backwpup/\n");
|
35 |
+
fwrite($file, "-- Blog Name: ".$STATIC['WP']['BLOGNAME']."\n");
|
36 |
+
fwrite($file, "-- Blog URL: ".$STATIC['WP']['SITEURL']."\n");
|
37 |
+
fwrite($file, "-- Blog ABSPATH: ".$STATIC['WP']['ABSPATH']."\n");
|
38 |
+
fwrite($file, "-- Table Prefix: ".$STATIC['WP']['TABLE_PREFIX']."\n");
|
39 |
+
fwrite($file, "-- Database Name: ".$STATIC['WP']['DB_NAME']."\n");
|
40 |
+
fwrite($file, "-- Dump on: ".date('Y-m-d H:i.s',time()+$STATIC['WP']['TIMEDIFF'])."\n");
|
41 |
+
fwrite($file, "-- ---------------------------------------------------------\n\n");
|
42 |
+
//for better import with mysql client
|
43 |
+
fwrite($file, "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n");
|
44 |
+
fwrite($file, "/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\n");
|
45 |
+
fwrite($file, "/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\n");
|
46 |
+
fwrite($file, "/*!40101 SET NAMES '".mysql_client_encoding()."' */;\n");
|
47 |
+
fwrite($file, "/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;\n");
|
48 |
+
fwrite($file, "/*!40103 SET TIME_ZONE='".mysql_result(mysql_query("SELECT @@time_zone"),0)."' */;\n");
|
49 |
+
fwrite($file, "/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;\n");
|
50 |
+
fwrite($file, "/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;\n");
|
51 |
+
fwrite($file, "/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;\n");
|
52 |
+
fwrite($file, "/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;\n\n");
|
53 |
+
//make table dumps
|
54 |
+
foreach($tabelstobackup as $table) {
|
55 |
+
if (in_array($table, $WORKING['DB_DUMP']['DONETABLE']))
|
56 |
+
continue;
|
57 |
+
trigger_error(sprintf(__('Dump database table "%s"','backwpup'),$table),E_USER_NOTICE);
|
58 |
+
need_free_memory(($status[$table]['Data_length']+$status[$table]['Index_length'])*4); //get more memory if needed
|
59 |
+
_db_dump_table($table,$status[$table],$file);
|
60 |
+
$WORKING['DB_DUMP']['DONETABLE'][]=$table;
|
61 |
+
$WORKING['STEPDONE']=count($WORKING['DB_DUMP']['DONETABLE']);
|
62 |
+
}
|
63 |
+
//for better import with mysql client
|
64 |
+
fwrite($file, "\n");
|
65 |
+
fwrite($file, "/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;\n");
|
66 |
+
fwrite($file, "/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;\n");
|
67 |
+
fwrite($file, "/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;\n");
|
68 |
+
fwrite($file, "/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;\n");
|
69 |
+
fwrite($file, "/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n");
|
70 |
+
fwrite($file, "/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\n");
|
71 |
+
fwrite($file, "/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;\n");
|
72 |
+
fwrite($file, "/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;\n");
|
73 |
+
fclose($file);
|
74 |
+
trigger_error(__('Database dump done!','backwpup'),E_USER_NOTICE);
|
75 |
+
} else {
|
76 |
+
trigger_error(__('Can not create database dump!','backwpup'),E_USER_ERROR);
|
77 |
+
}
|
78 |
+
} else {
|
79 |
+
trigger_error(__('No tables to dump','backwpup'),E_USER_WARNING);
|
80 |
+
}
|
81 |
+
|
82 |
+
//add database file to backupfiles
|
83 |
+
if (is_readable($STATIC['TEMPDIR'].$STATIC['WP']['DB_NAME'].'.sql')) {
|
84 |
+
$filestat=stat($STATIC['TEMPDIR'].$STATIC['WP']['DB_NAME'].'.sql');
|
85 |
+
trigger_error(sprintf(__('Add database dump "%1$s" with %2$s to backup file list','backwpup'),$STATIC['WP']['DB_NAME'].'.sql',formatbytes($filestat['size'])),E_USER_NOTICE);
|
86 |
+
$WORKING['ALLFILESIZE']+=$filestat['size'];
|
87 |
+
add_file(array(array('FILE'=>$STATIC['TEMPDIR'].$STATIC['WP']['DB_NAME'].'.sql','OUTFILE'=>$STATIC['WP']['DB_NAME'].'.sql','SIZE'=>$filestat['size'],'ATIME'=>$filestat['atime'],'MTIME'=>$filestat['mtime'],'CTIME'=>$filestat['ctime'],'UID'=>$filestat['uid'],'GID'=>$filestat['gid'],'MODE'=>$filestat['mode'])));
|
88 |
+
}
|
89 |
+
//Back from maintenance
|
90 |
+
maintenance_mode(false);
|
91 |
+
$WORKING['STEPSDONE'][]='DB_DUMP'; //set done
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
function _db_dump_table($table,$status,$file) {
|
96 |
+
global $WORKING,$STATIC;
|
97 |
+
// create dump
|
98 |
+
fwrite($file, "\n");
|
99 |
+
fwrite($file, "--\n");
|
100 |
+
fwrite($file, "-- Table structure for table $table\n");
|
101 |
+
fwrite($file, "--\n\n");
|
102 |
+
fwrite($file, "DROP TABLE IF EXISTS `" . $table . "`;\n");
|
103 |
+
fwrite($file, "/*!40101 SET @saved_cs_client = @@character_set_client */;\n");
|
104 |
+
fwrite($file, "/*!40101 SET character_set_client = '".mysql_client_encoding()."' */;\n");
|
105 |
+
//Dump the table structure
|
106 |
+
$result=mysql_query("SHOW CREATE TABLE `".$table."`");
|
107 |
+
if (!$result) {
|
108 |
+
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "SHOW CREATE TABLE `".$table."`"),E_USER_ERROR);
|
109 |
+
return false;
|
110 |
+
}
|
111 |
+
$tablestruc=mysql_fetch_assoc($result);
|
112 |
+
fwrite($file, $tablestruc['Create Table'].";\n");
|
113 |
+
fwrite($file, "/*!40101 SET character_set_client = @saved_cs_client */;\n");
|
114 |
+
|
115 |
+
//take data of table
|
116 |
+
$result=mysql_query("SELECT * FROM `".$table."`");
|
117 |
+
if (!$result) {
|
118 |
+
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "SELECT * FROM `".$table."`"),E_USER_ERROR);
|
119 |
+
return false;
|
120 |
+
}
|
121 |
+
|
122 |
+
fwrite($file, "--\n");
|
123 |
+
fwrite($file, "-- Dumping data for table $table\n");
|
124 |
+
fwrite($file, "--\n\n");
|
125 |
+
if ($status['Engine']=='MyISAM')
|
126 |
+
fwrite($file, "/*!40000 ALTER TABLE `".$table."` DISABLE KEYS */;\n");
|
127 |
+
|
128 |
+
while ($data = mysql_fetch_assoc($result)) {
|
129 |
+
$keys = array();
|
130 |
+
$values = array();
|
131 |
+
foreach($data as $key => $value) {
|
132 |
+
if (!$STATIC['JOB']['dbshortinsert'])
|
133 |
+
$keys[] = "`".str_replace("�", "��", $key)."`"; // Add key to key list
|
134 |
+
if($value === NULL) // Make Value NULL to string NULL
|
135 |
+
$value = "NULL";
|
136 |
+
elseif($value === "" or $value === false) // if empty or false Value make "" as Value
|
137 |
+
$value = "''";
|
138 |
+
elseif(!is_numeric($value)) //is value not numeric esc
|
139 |
+
$value = "'".mysql_real_escape_string($value)."'";
|
140 |
+
$values[] = $value;
|
141 |
+
}
|
142 |
+
// make data dump
|
143 |
+
if ($STATIC['JOB']['dbshortinsert'])
|
144 |
+
fwrite($file, "INSERT INTO `".$table."` VALUES ( ".implode(", ",$values)." );\n");
|
145 |
+
else
|
146 |
+
fwrite($file, "INSERT INTO `".$table."` ( ".implode(", ",$keys)." )\n\tVALUES ( ".implode(", ",$values)." );\n");
|
147 |
+
}
|
148 |
+
if ($status['Engine']=='MyISAM')
|
149 |
+
fwrite($file, "/*!40000 ALTER TABLE ".$table." ENABLE KEYS */;\n");
|
150 |
+
}
|
|
job/db_optimize.php
CHANGED
@@ -1,49 +1,47 @@
|
|
1 |
-
<?PHP
|
2 |
-
function db_optimize() {
|
3 |
-
global $WORKING,$STATIC;
|
4 |
-
trigger_error(sprintf(__('%d. try for database optimize...','backwpup'),$WORKING['DB_OPTIMIZE']['STEP_TRY']),E_USER_NOTICE);
|
5 |
-
if (!isset($WORKING['DB_OPTIMIZE']['DONETABLE']) or !is_array($WORKING['DB_OPTIMIZE']['DONETABLE']))
|
6 |
-
$WORKING['DB_OPTIMIZE']['DONETABLE']=array();
|
7 |
-
|
8 |
-
mysql_update();
|
9 |
-
//to backup
|
10 |
-
$tabelstobackup=array();
|
11 |
-
$result=mysql_query("SHOW TABLES FROM `".$STATIC['WP']['DB_NAME']."`"); //get table status
|
12 |
-
if (!$result)
|
13 |
-
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "SHOW TABLE STATUS FROM `".$STATIC['WP']['DB_NAME']."`;"),E_USER_ERROR);
|
14 |
-
while ($data = mysql_fetch_row($result)) {
|
15 |
-
if (!in_array($data[0],$STATIC['JOB']['dbexclude']))
|
16 |
-
$tabelstobackup[]=$data[0];
|
17 |
-
}
|
18 |
-
//Set num of todos
|
19 |
-
$WORKING['STEPTODO']=count($tabelstobackup);
|
20 |
-
|
21 |
-
if (count($tabelstobackup)>0) {
|
22 |
-
maintenance_mode(true);
|
23 |
-
foreach ($tabelstobackup as $table) {
|
24 |
-
if (in_array($table, $WORKING['DB_OPTIMIZE']['DONETABLE']))
|
25 |
-
continue;
|
26 |
-
$result=mysql_query('OPTIMIZE TABLE `'.$table.'`');
|
27 |
-
if (!$result) {
|
28 |
-
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "OPTIMIZE TABLE `".$table."`"),E_USER_ERROR);
|
29 |
-
continue;
|
30 |
-
}
|
31 |
-
$optimize=mysql_fetch_assoc($result);
|
32 |
-
$WORKING['DB_OPTIMIZE']['DONETABLE'][]=$table;
|
33 |
-
$WORKING['STEPDONE']=count($WORKING['DB_OPTIMIZE']['DONETABLE']);
|
34 |
-
if ($optimize['Msg_type']=='error')
|
35 |
-
trigger_error(sprintf(__('Result of table optimize for %1$s is: %2$s','backwpup'), $table, $optimize['Msg_text']),E_USER_ERROR);
|
36 |
-
elseif ($optimize['Msg_type']=='warning')
|
37 |
-
trigger_error(sprintf(__('Result of table optimize for %1$s is: %2$s','backwpup'), $table, $optimize['Msg_text']),E_USER_WARNING);
|
38 |
-
else
|
39 |
-
trigger_error(sprintf(__('Result of table optimize for %1$s is: %2$s','backwpup'), $table, $optimize['Msg_text']),E_USER_NOTICE);
|
40 |
-
}
|
41 |
-
trigger_error(__('Database optimize done!','backwpup'),E_USER_NOTICE);
|
42 |
-
maintenance_mode(false);
|
43 |
-
} else {
|
44 |
-
trigger_error(__('No tables to optimize','backwpup'),E_USER_WARNING);
|
45 |
-
}
|
46 |
-
$WORKING['STEPSDONE'][]='DB_OPTIMIZE'; //set done
|
47 |
-
}
|
48 |
-
|
49 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
function db_optimize() {
|
3 |
+
global $WORKING,$STATIC;
|
4 |
+
trigger_error(sprintf(__('%d. try for database optimize...','backwpup'),$WORKING['DB_OPTIMIZE']['STEP_TRY']),E_USER_NOTICE);
|
5 |
+
if (!isset($WORKING['DB_OPTIMIZE']['DONETABLE']) or !is_array($WORKING['DB_OPTIMIZE']['DONETABLE']))
|
6 |
+
$WORKING['DB_OPTIMIZE']['DONETABLE']=array();
|
7 |
+
|
8 |
+
mysql_update();
|
9 |
+
//to backup
|
10 |
+
$tabelstobackup=array();
|
11 |
+
$result=mysql_query("SHOW TABLES FROM `".$STATIC['WP']['DB_NAME']."`"); //get table status
|
12 |
+
if (!$result)
|
13 |
+
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "SHOW TABLE STATUS FROM `".$STATIC['WP']['DB_NAME']."`;"),E_USER_ERROR);
|
14 |
+
while ($data = mysql_fetch_row($result)) {
|
15 |
+
if (!in_array($data[0],$STATIC['JOB']['dbexclude']))
|
16 |
+
$tabelstobackup[]=$data[0];
|
17 |
+
}
|
18 |
+
//Set num of todos
|
19 |
+
$WORKING['STEPTODO']=count($tabelstobackup);
|
20 |
+
|
21 |
+
if (count($tabelstobackup)>0) {
|
22 |
+
maintenance_mode(true);
|
23 |
+
foreach ($tabelstobackup as $table) {
|
24 |
+
if (in_array($table, $WORKING['DB_OPTIMIZE']['DONETABLE']))
|
25 |
+
continue;
|
26 |
+
$result=mysql_query('OPTIMIZE TABLE `'.$table.'`');
|
27 |
+
if (!$result) {
|
28 |
+
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), "OPTIMIZE TABLE `".$table."`"),E_USER_ERROR);
|
29 |
+
continue;
|
30 |
+
}
|
31 |
+
$optimize=mysql_fetch_assoc($result);
|
32 |
+
$WORKING['DB_OPTIMIZE']['DONETABLE'][]=$table;
|
33 |
+
$WORKING['STEPDONE']=count($WORKING['DB_OPTIMIZE']['DONETABLE']);
|
34 |
+
if ($optimize['Msg_type']=='error')
|
35 |
+
trigger_error(sprintf(__('Result of table optimize for %1$s is: %2$s','backwpup'), $table, $optimize['Msg_text']),E_USER_ERROR);
|
36 |
+
elseif ($optimize['Msg_type']=='warning')
|
37 |
+
trigger_error(sprintf(__('Result of table optimize for %1$s is: %2$s','backwpup'), $table, $optimize['Msg_text']),E_USER_WARNING);
|
38 |
+
else
|
39 |
+
trigger_error(sprintf(__('Result of table optimize for %1$s is: %2$s','backwpup'), $table, $optimize['Msg_text']),E_USER_NOTICE);
|
40 |
+
}
|
41 |
+
trigger_error(__('Database optimize done!','backwpup'),E_USER_NOTICE);
|
42 |
+
maintenance_mode(false);
|
43 |
+
} else {
|
44 |
+
trigger_error(__('No tables to optimize','backwpup'),E_USER_WARNING);
|
45 |
+
}
|
46 |
+
$WORKING['STEPSDONE'][]='DB_OPTIMIZE'; //set done
|
47 |
+
}
|
|
|
|
job/dest_dropbox.php
CHANGED
@@ -1,72 +1,71 @@
|
|
1 |
-
<?PHP
|
2 |
-
function dest_dropbox() {
|
3 |
-
global $WORKING,$STATIC;
|
4 |
-
$WORKING['STEPTODO']=2+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
5 |
-
$WORKING['STEPDONE']=0;
|
6 |
-
trigger_error(sprintf(__('%d. Try to sending backup file to DropBox...','backwpup'),$WORKING['DEST_DROPBOX']['STEP_TRY']),E_USER_NOTICE);
|
7 |
-
|
8 |
-
require_once(realpath(dirname(__FILE__).'/../libs/dropbox.php'));
|
9 |
-
try {
|
10 |
-
//set boxtype and authkeys
|
11 |
-
$dropbox = new backwpup_Dropbox($STATIC['BACKWPUP']['DROPBOX_APP_KEY'], $STATIC['BACKWPUP']['DROPBOX_APP_SECRET'],'dropbox');
|
12 |
-
|
13 |
-
// set the tokens
|
14 |
-
$dropbox->setOAuthTokens($STATIC['JOB']['dropetoken'],$STATIC['JOB']['dropesecret']);
|
15 |
-
$info=$dropbox->accountInfo();
|
16 |
-
if (!empty($info['uid'])) {
|
17 |
-
trigger_error(sprintf(__('Authed with DropBox from %s','backwpup'),$info['display_name']),E_USER_NOTICE);
|
18 |
-
}
|
19 |
-
//Check Quota
|
20 |
-
$dropboxfreespase=$info['quota_info']['quota']-$info['quota_info']['shared']-$info['quota_info']['normal'];
|
21 |
-
if (filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile'])>$dropboxfreespase) {
|
22 |
-
trigger_error(__('No free space left on DropBox!!!','backwpup'),E_USER_ERROR);
|
23 |
-
$WORKING['STEPSDONE'][]='DEST_DROPBOX'; //set done
|
24 |
-
return;
|
25 |
-
} else {
|
26 |
-
trigger_error(sprintf(__('%s free on DropBox','backwpup'),formatBytes($dropboxfreespase)),E_USER_NOTICE);
|
27 |
-
}
|
28 |
-
//set calback function
|
29 |
-
$dropbox->setProgressFunction='curl_progresscallback';
|
30 |
-
// put the file
|
31 |
-
trigger_error(__('Upload to DropBox now started... ','backwpup'),E_USER_NOTICE);
|
32 |
-
$response = $dropbox->upload($STATIC['JOB']['backupdir'].$STATIC['backupfile'],$STATIC['JOB']['dropedir'].$STATIC['backupfile']);
|
33 |
-
if ($response['bytes']==filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile'])) {
|
34 |
-
$STATIC['JOB']['lastbackupdownloadurl']=$STATIC['WP']['ADMINURL'].'?page=backwpupbackups&action=downloaddropbox&file='.$STATIC['JOB']['dropedir'].$STATIC['backupfile'].'&jobid='.$STATIC['JOB']['jobid'];
|
35 |
-
$WORKING['STEPDONE']++;
|
36 |
-
$WORKING['STEPSDONE'][]='DEST_DROPBOX'; //set done
|
37 |
-
trigger_error(sprintf(__('Backup transferred to %s','backwpup'),'https://api-content.dropbox.com/1/files/'.$STATIC['JOB']['droperoot'].'/'.$STATIC['JOB']['dropedir'].$STATIC['backupfile']),E_USER_NOTICE);
|
38 |
-
}
|
39 |
-
//unset calback function
|
40 |
-
$dropbox->setProgressFunction='';
|
41 |
-
} catch (Exception $e) {
|
42 |
-
trigger_error(sprintf(__('DropBox API: %s','backwpup'),$e->getMessage()),E_USER_ERROR);
|
43 |
-
}
|
44 |
-
try {
|
45 |
-
if ($STATIC['JOB']['dropemaxbackups']>0 and is_object($dropbox)) { //Delete old backups
|
46 |
-
$backupfilelist=array();
|
47 |
-
$metadata = $dropbox->metadata($STATIC['JOB']['dropedir']);
|
48 |
-
if (is_array($metadata)) {
|
49 |
-
foreach ($metadata['contents'] as $data) {
|
50 |
-
$file=basename($data['path']);
|
51 |
-
if ($data['is_dir']!=true and $STATIC['JOB']['fileprefix'] == substr($file,0,strlen($STATIC['JOB']['fileprefix'])) and $STATIC['JOB']['fileformart'] == substr($file,-strlen($STATIC['JOB']['fileformart'])))
|
52 |
-
$backupfilelist[]=$file;
|
53 |
-
}
|
54 |
-
}
|
55 |
-
if (sizeof($backupfilelist)>0) {
|
56 |
-
rsort($backupfilelist);
|
57 |
-
$numdeltefiles=0;
|
58 |
-
for ($i=$STATIC['JOB']['dropemaxbackups'];$i<count($backupfilelist);$i++) {
|
59 |
-
$dropbox->fileopsDelete($STATIC['JOB']['dropedir'].$backupfilelist[$i]); //delete files on Cloud
|
60 |
-
$numdeltefiles++;
|
61 |
-
}
|
62 |
-
if ($numdeltefiles>0)
|
63 |
-
trigger_error(sprintf(_n('One file deleted on DropBox','%d files deleted on DropBox',$numdeltefiles,'backwpup'),$numdeltefiles),E_USER_NOTICE);
|
64 |
-
}
|
65 |
-
}
|
66 |
-
} catch (Exception $e) {
|
67 |
-
trigger_error(sprintf(__('DropBox API: %s','backwpup'),$e->getMessage()),E_USER_ERROR);
|
68 |
-
}
|
69 |
-
|
70 |
-
$WORKING['STEPDONE']++;
|
71 |
-
}
|
72 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
function dest_dropbox() {
|
3 |
+
global $WORKING,$STATIC;
|
4 |
+
$WORKING['STEPTODO']=2+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
5 |
+
$WORKING['STEPDONE']=0;
|
6 |
+
trigger_error(sprintf(__('%d. Try to sending backup file to DropBox...','backwpup'),$WORKING['DEST_DROPBOX']['STEP_TRY']),E_USER_NOTICE);
|
7 |
+
|
8 |
+
require_once(realpath(dirname(__FILE__).'/../libs/dropbox.php'));
|
9 |
+
try {
|
10 |
+
//set boxtype and authkeys
|
11 |
+
$dropbox = new backwpup_Dropbox($STATIC['BACKWPUP']['DROPBOX_APP_KEY'], $STATIC['BACKWPUP']['DROPBOX_APP_SECRET'],'dropbox');
|
12 |
+
|
13 |
+
// set the tokens
|
14 |
+
$dropbox->setOAuthTokens($STATIC['JOB']['dropetoken'],$STATIC['JOB']['dropesecret']);
|
15 |
+
$info=$dropbox->accountInfo();
|
16 |
+
if (!empty($info['uid'])) {
|
17 |
+
trigger_error(sprintf(__('Authed with DropBox from %s','backwpup'),$info['display_name']),E_USER_NOTICE);
|
18 |
+
}
|
19 |
+
//Check Quota
|
20 |
+
$dropboxfreespase=$info['quota_info']['quota']-$info['quota_info']['shared']-$info['quota_info']['normal'];
|
21 |
+
if (filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile'])>$dropboxfreespase) {
|
22 |
+
trigger_error(__('No free space left on DropBox!!!','backwpup'),E_USER_ERROR);
|
23 |
+
$WORKING['STEPSDONE'][]='DEST_DROPBOX'; //set done
|
24 |
+
return;
|
25 |
+
} else {
|
26 |
+
trigger_error(sprintf(__('%s free on DropBox','backwpup'),formatBytes($dropboxfreespase)),E_USER_NOTICE);
|
27 |
+
}
|
28 |
+
//set calback function
|
29 |
+
$dropbox->setProgressFunction='curl_progresscallback';
|
30 |
+
// put the file
|
31 |
+
trigger_error(__('Upload to DropBox now started... ','backwpup'),E_USER_NOTICE);
|
32 |
+
$response = $dropbox->upload($STATIC['JOB']['backupdir'].$STATIC['backupfile'],$STATIC['JOB']['dropedir'].$STATIC['backupfile']);
|
33 |
+
if ($response['bytes']==filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile'])) {
|
34 |
+
$STATIC['JOB']['lastbackupdownloadurl']=$STATIC['WP']['ADMINURL'].'?page=backwpupbackups&action=downloaddropbox&file='.$STATIC['JOB']['dropedir'].$STATIC['backupfile'].'&jobid='.$STATIC['JOB']['jobid'];
|
35 |
+
$WORKING['STEPDONE']++;
|
36 |
+
$WORKING['STEPSDONE'][]='DEST_DROPBOX'; //set done
|
37 |
+
trigger_error(sprintf(__('Backup transferred to %s','backwpup'),'https://api-content.dropbox.com/1/files/'.$STATIC['JOB']['droperoot'].'/'.$STATIC['JOB']['dropedir'].$STATIC['backupfile']),E_USER_NOTICE);
|
38 |
+
}
|
39 |
+
//unset calback function
|
40 |
+
$dropbox->setProgressFunction='';
|
41 |
+
} catch (Exception $e) {
|
42 |
+
trigger_error(sprintf(__('DropBox API: %s','backwpup'),$e->getMessage()),E_USER_ERROR);
|
43 |
+
}
|
44 |
+
try {
|
45 |
+
if ($STATIC['JOB']['dropemaxbackups']>0 and is_object($dropbox)) { //Delete old backups
|
46 |
+
$backupfilelist=array();
|
47 |
+
$metadata = $dropbox->metadata($STATIC['JOB']['dropedir']);
|
48 |
+
if (is_array($metadata)) {
|
49 |
+
foreach ($metadata['contents'] as $data) {
|
50 |
+
$file=basename($data['path']);
|
51 |
+
if ($data['is_dir']!=true and $STATIC['JOB']['fileprefix'] == substr($file,0,strlen($STATIC['JOB']['fileprefix'])) and $STATIC['JOB']['fileformart'] == substr($file,-strlen($STATIC['JOB']['fileformart'])))
|
52 |
+
$backupfilelist[]=$file;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
if (sizeof($backupfilelist)>0) {
|
56 |
+
rsort($backupfilelist);
|
57 |
+
$numdeltefiles=0;
|
58 |
+
for ($i=$STATIC['JOB']['dropemaxbackups'];$i<count($backupfilelist);$i++) {
|
59 |
+
$dropbox->fileopsDelete($STATIC['JOB']['dropedir'].$backupfilelist[$i]); //delete files on Cloud
|
60 |
+
$numdeltefiles++;
|
61 |
+
}
|
62 |
+
if ($numdeltefiles>0)
|
63 |
+
trigger_error(sprintf(_n('One file deleted on DropBox','%d files deleted on DropBox',$numdeltefiles,'backwpup'),$numdeltefiles),E_USER_NOTICE);
|
64 |
+
}
|
65 |
+
}
|
66 |
+
} catch (Exception $e) {
|
67 |
+
trigger_error(sprintf(__('DropBox API: %s','backwpup'),$e->getMessage()),E_USER_ERROR);
|
68 |
+
}
|
69 |
+
|
70 |
+
$WORKING['STEPDONE']++;
|
71 |
+
}
|
|
job/dest_folder.php
CHANGED
@@ -1,32 +1,30 @@
|
|
1 |
-
<?PHP
|
2 |
-
function dest_folder() {
|
3 |
-
global $WORKING,$STATIC;
|
4 |
-
$WORKING['STEPTODO']=1;
|
5 |
-
$WORKING['STEPDONE']=0;
|
6 |
-
$STATIC['JOB']['lastbackupdownloadurl']=$STATIC['WP']['ADMINURL'].'?page=backwpupbackups&action=download&file='.$STATIC['JOB']['backupdir'].$STATIC['backupfile'];
|
7 |
-
//Delete old Backupfiles
|
8 |
-
$backupfilelist=array();
|
9 |
-
if ($STATIC['JOB']['maxbackups']>0) {
|
10 |
-
if ( $dir = @opendir($STATIC['JOB']['backupdir']) ) { //make file list
|
11 |
-
while (($file = readdir($dir)) !== false ) {
|
12 |
-
if ($STATIC['JOB']['fileprefix'] == substr($file,0,strlen($STATIC['JOB']['fileprefix'])) and $STATIC['JOB']['fileformart'] == substr($file,-strlen($STATIC['JOB']['fileformart'])))
|
13 |
-
$backupfilelist[]=$file;
|
14 |
-
}
|
15 |
-
@closedir($dir);
|
16 |
-
}
|
17 |
-
if (sizeof($backupfilelist)>0) {
|
18 |
-
rsort($backupfilelist);
|
19 |
-
$numdeltefiles=0;
|
20 |
-
for ($i=$STATIC['JOB']['maxbackups'];$i<sizeof($backupfilelist);$i++) {
|
21 |
-
unlink($STATIC['JOB']['backupdir'].$backupfilelist[$i]);
|
22 |
-
$numdeltefiles++;
|
23 |
-
}
|
24 |
-
if ($numdeltefiles>0)
|
25 |
-
trigger_error(sprintf(_n('One backup file deleted','%d backup files deleted',$numdeltefiles,'backwpup'),$numdeltefiles),E_USER_NOTICE);
|
26 |
-
}
|
27 |
-
}
|
28 |
-
$WORKING['STEPDONE']++;
|
29 |
-
$WORKING['STEPSDONE'][]='DEST_FOLDER'; //set done
|
30 |
-
}
|
31 |
-
|
32 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
function dest_folder() {
|
3 |
+
global $WORKING,$STATIC;
|
4 |
+
$WORKING['STEPTODO']=1;
|
5 |
+
$WORKING['STEPDONE']=0;
|
6 |
+
$STATIC['JOB']['lastbackupdownloadurl']=$STATIC['WP']['ADMINURL'].'?page=backwpupbackups&action=download&file='.$STATIC['JOB']['backupdir'].$STATIC['backupfile'];
|
7 |
+
//Delete old Backupfiles
|
8 |
+
$backupfilelist=array();
|
9 |
+
if ($STATIC['JOB']['maxbackups']>0) {
|
10 |
+
if ( $dir = @opendir($STATIC['JOB']['backupdir']) ) { //make file list
|
11 |
+
while (($file = readdir($dir)) !== false ) {
|
12 |
+
if ($STATIC['JOB']['fileprefix'] == substr($file,0,strlen($STATIC['JOB']['fileprefix'])) and $STATIC['JOB']['fileformart'] == substr($file,-strlen($STATIC['JOB']['fileformart'])))
|
13 |
+
$backupfilelist[]=$file;
|
14 |
+
}
|
15 |
+
@closedir($dir);
|
16 |
+
}
|
17 |
+
if (sizeof($backupfilelist)>0) {
|
18 |
+
rsort($backupfilelist);
|
19 |
+
$numdeltefiles=0;
|
20 |
+
for ($i=$STATIC['JOB']['maxbackups'];$i<sizeof($backupfilelist);$i++) {
|
21 |
+
unlink($STATIC['JOB']['backupdir'].$backupfilelist[$i]);
|
22 |
+
$numdeltefiles++;
|
23 |
+
}
|
24 |
+
if ($numdeltefiles>0)
|
25 |
+
trigger_error(sprintf(_n('One backup file deleted','%d backup files deleted',$numdeltefiles,'backwpup'),$numdeltefiles),E_USER_NOTICE);
|
26 |
+
}
|
27 |
+
}
|
28 |
+
$WORKING['STEPDONE']++;
|
29 |
+
$WORKING['STEPSDONE'][]='DEST_FOLDER'; //set done
|
30 |
+
}
|
|
|
|
job/dest_ftp.php
CHANGED
@@ -1,129 +1,142 @@
|
|
1 |
-
<?PHP
|
2 |
-
function dest_ftp() {
|
3 |
-
global $WORKING,$STATIC;
|
4 |
-
if (empty($STATIC['JOB']['ftphost']) or empty($STATIC['JOB']['ftpuser']) or empty($STATIC['JOB']['ftppass'])) {
|
5 |
-
$WORKING['STEPSDONE'][]='DEST_FTP'; //set done
|
6 |
-
return;
|
7 |
-
}
|
8 |
-
$WORKING['STEPTODO']=
|
9 |
-
trigger_error(sprintf(__('%d. try to sending backup file to a FTP Server...','backwpup'),$WORKING['DEST_FTP']['STEP_TRY']),E_USER_NOTICE);
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
trigger_error(sprintf(__('
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
trigger_error(sprintf(__('
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
$loginok=
|
38 |
-
|
39 |
-
if
|
40 |
-
|
41 |
-
|
42 |
-
$return
|
43 |
-
|
44 |
-
|
45 |
-
trigger_error(sprintf(__('FTP
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
if ($
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?PHP
|
2 |
+
function dest_ftp() {
|
3 |
+
global $WORKING,$STATIC;
|
4 |
+
if (empty($STATIC['JOB']['ftphost']) or empty($STATIC['JOB']['ftpuser']) or empty($STATIC['JOB']['ftppass'])) {
|
5 |
+
$WORKING['STEPSDONE'][]='DEST_FTP'; //set done
|
6 |
+
return;
|
7 |
+
}
|
8 |
+
$WORKING['STEPTODO']=filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
9 |
+
trigger_error(sprintf(__('%d. try to sending backup file to a FTP Server...','backwpup'),$WORKING['DEST_FTP']['STEP_TRY']),E_USER_NOTICE);
|
10 |
+
|
11 |
+
if ($STATIC['JOB']['ftpssl']) { //make SSL FTP connection
|
12 |
+
if (function_exists('ftp_ssl_connect')) {
|
13 |
+
$ftp_conn_id = ftp_ssl_connect($STATIC['JOB']['ftphost'],$STATIC['JOB']['ftphostport'],10);
|
14 |
+
if ($ftp_conn_id)
|
15 |
+
trigger_error(sprintf(__('Connected by SSL-FTP to Server: %s','backwpup'),$STATIC['JOB']['ftphost'].':'.$STATIC['JOB']['ftphostport']),E_USER_NOTICE);
|
16 |
+
else {
|
17 |
+
trigger_error(sprintf(__('Can not connect by SSL-FTP to Server: %s','backwpup'),$STATIC['JOB']['ftphost'].':'.$STATIC['JOB']['ftphostport']),E_USER_ERROR);
|
18 |
+
return false;
|
19 |
+
}
|
20 |
+
} else {
|
21 |
+
trigger_error(__('PHP function to connect with SSL-FTP to server not exists!','backwpup'),E_USER_ERROR);
|
22 |
+
return false;
|
23 |
+
}
|
24 |
+
} else { //make normal FTP conection if SSL not work
|
25 |
+
$ftp_conn_id = ftp_connect($STATIC['JOB']['ftphost'],$STATIC['JOB']['ftphostport'],10);
|
26 |
+
if ($ftp_conn_id)
|
27 |
+
trigger_error(sprintf(__('Connected to FTP server: %s','backwpup'),$STATIC['JOB']['ftphost'].':'.$STATIC['JOB']['ftphostport']),E_USER_NOTICE);
|
28 |
+
else {
|
29 |
+
trigger_error(sprintf(__('Can not connect to FTP server: %s','backwpup'),$STATIC['JOB']['ftphost'].':'.$STATIC['JOB']['ftphostport']),E_USER_ERROR);
|
30 |
+
return false;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
//FTP Login
|
35 |
+
$loginok=false;
|
36 |
+
trigger_error(sprintf(__('FTP Client command: %s','backwpup'),' USER '.$STATIC['JOB']['ftpuser']),E_USER_NOTICE);
|
37 |
+
if ($loginok=ftp_login($ftp_conn_id, $STATIC['JOB']['ftpuser'], base64_decode($STATIC['JOB']['ftppass']))) {
|
38 |
+
trigger_error(sprintf(__('FTP Server reply: %s','backwpup'),' User '.$STATIC['JOB']['ftpuser'].' logged in.'),E_USER_NOTICE);
|
39 |
+
} else { //if PHP ftp login don't work use raw login
|
40 |
+
$return=ftp_raw($ftp_conn_id,'USER '.$STATIC['JOB']['ftpuser']);
|
41 |
+
trigger_error(sprintf(__('FTP Server reply: %s','backwpup'),$return[0]),E_USER_NOTICE);
|
42 |
+
if (substr(trim($return[0]),0,3)<=400) {
|
43 |
+
trigger_error(sprintf(__('FTP Client command: %s','backwpup'),' PASS *******'),E_USER_NOTICE);
|
44 |
+
$return=ftp_raw($ftp_conn_id,'PASS '.base64_decode($STATIC['JOB']['ftppass']));
|
45 |
+
trigger_error(sprintf(__('FTP Server reply: %s','backwpup'),$return[0]),E_USER_NOTICE);
|
46 |
+
if (substr(trim($return[0]),0,3)<=400)
|
47 |
+
$loginok=true;
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
if (!$loginok)
|
52 |
+
return false;
|
53 |
+
|
54 |
+
//SYSTYPE
|
55 |
+
trigger_error(sprintf(__('FTP Client command: %s','backwpup'),' SYST'),E_USER_NOTICE);
|
56 |
+
$systype=ftp_systype($ftp_conn_id);
|
57 |
+
if ($systype)
|
58 |
+
trigger_error(sprintf(__('FTP Server reply: %s','backwpup'),$systype),E_USER_NOTICE);
|
59 |
+
else
|
60 |
+
trigger_error(sprintf(__('FTP Server reply: %s','backwpup'),__('Error getting SYSTYPE','backwpup')),E_USER_ERROR);
|
61 |
+
|
62 |
+
//test ftp dir and create it f not exists
|
63 |
+
$ftpdirs=explode("/", rtrim($STATIC['JOB']['ftpdir'],'/'));
|
64 |
+
foreach ($ftpdirs as $ftpdir) {
|
65 |
+
if (empty($ftpdir))
|
66 |
+
continue;
|
67 |
+
if (!@ftp_chdir($ftp_conn_id, $ftpdir)) {
|
68 |
+
if (@ftp_mkdir($ftp_conn_id, $ftpdir)) {
|
69 |
+
trigger_error(sprintf(__('FTP Folder "%s" created!','backwpup'),$ftpdir),E_USER_NOTICE);
|
70 |
+
ftp_chdir($ftp_conn_id, $ftpdir);
|
71 |
+
} else {
|
72 |
+
trigger_error(sprintf(__('FTP Folder "%s" can not created!','backwpup'),$ftpdir),E_USER_ERROR);
|
73 |
+
return false;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
//delete file on ftp if new try
|
79 |
+
if ($WORKING['STEPDONE']==0)
|
80 |
+
@ftp_delete($ftp_conn_id, $STATIC['JOB']['ftpdir'].$STATIC['backupfile']);
|
81 |
+
|
82 |
+
//PASV
|
83 |
+
trigger_error(sprintf(__('FTP Client command: %s','backwpup'),' PASV'),E_USER_NOTICE);
|
84 |
+
if ($STATIC['JOB']['ftppasv']) {
|
85 |
+
if (ftp_pasv($ftp_conn_id, true))
|
86 |
+
trigger_error(sprintf(__('FTP Server reply: %s','backwpup'),__('Entering Passive Mode','backwpup')),E_USER_NOTICE);
|
87 |
+
else
|
88 |
+
trigger_error(sprintf(__('FTP Server reply: %s','backwpup'),__('Can not Entering Passive Mode','backwpup')),E_USER_WARNING);
|
89 |
+
} else {
|
90 |
+
if (ftp_pasv($ftp_conn_id, false))
|
91 |
+
trigger_error(sprintf(__('FTP Server reply: %s','backwpup'),__('Entering Normal Mode','backwpup')),E_USER_NOTICE);
|
92 |
+
else
|
93 |
+
trigger_error(sprintf(__('FTP Server reply: %s','backwpup'),__('Can not Entering Normal Mode','backwpup')),E_USER_WARNING);
|
94 |
+
}
|
95 |
+
|
96 |
+
if ($WORKING['STEPDONE']<$WORKING['STEPTODO']) {
|
97 |
+
trigger_error(__('Upload to FTP now started ... ','backwpup'),E_USER_NOTICE);
|
98 |
+
$fp = fopen($STATIC['JOB']['backupdir'].$STATIC['backupfile'], 'r');
|
99 |
+
$ret = ftp_nb_fput($ftp_conn_id, $STATIC['JOB']['ftpdir'].$STATIC['backupfile'], $fp, FTP_BINARY,$WORKING['STEPDONE']);
|
100 |
+
while ($ret == FTP_MOREDATA) {
|
101 |
+
$WORKING['STEPDONE']=ftell($fp);
|
102 |
+
update_working_file();
|
103 |
+
$ret = ftp_nb_continue($ftp_conn_id);
|
104 |
+
}
|
105 |
+
if ($ret != FTP_FINISHED) {
|
106 |
+
trigger_error(__('Can not transfer backup to FTP server!','backwpup'),E_USER_ERROR);
|
107 |
+
return false;
|
108 |
+
} else {
|
109 |
+
$WORKING['STEPDONE']=filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
110 |
+
trigger_error(sprintf(__('Backup transferred to FTP server: %s','backwpup'),$STATIC['JOB']['ftpdir'].$STATIC['backupfile']),E_USER_NOTICE);
|
111 |
+
$STATIC['JOB']['lastbackupdownloadurl']="ftp://".$STATIC['JOB']['ftpuser'].":".base64_decode($STATIC['JOB']['ftppass'])."@".$STATIC['JOB']['ftphost'].':'.$STATIC['JOB']['ftphostport'].$STATIC['JOB']['ftpdir'].$STATIC['backupfile'];
|
112 |
+
$WORKING['STEPSDONE'][]='DEST_FTP'; //set done
|
113 |
+
}
|
114 |
+
fclose($fp);
|
115 |
+
}
|
116 |
+
|
117 |
+
if ($STATIC['JOB']['ftpmaxbackups']>0) { //Delete old backups
|
118 |
+
$backupfilelist=array();
|
119 |
+
if ($filelist=ftp_nlist($ftp_conn_id, $STATIC['JOB']['ftpdir'])) {
|
120 |
+
foreach($filelist as $files) {
|
121 |
+
if ($STATIC['JOB']['fileprefix'] == substr(basename($files),0,strlen($STATIC['JOB']['fileprefix'])) and $STATIC['JOB']['fileformart'] == substr(basename($files),-strlen($STATIC['JOB']['fileformart'])))
|
122 |
+
$backupfilelist[]=basename($files);
|
123 |
+
}
|
124 |
+
if (sizeof($backupfilelist)>0) {
|
125 |
+
rsort($backupfilelist);
|
126 |
+
$numdeltefiles=0;
|
127 |
+
for ($i=$STATIC['JOB']['ftpmaxbackups'];$i<sizeof($backupfilelist);$i++) {
|
128 |
+
if (ftp_delete($ftp_conn_id, $STATIC['JOB']['ftpdir'].$backupfilelist[$i])) //delte files on ftp
|
129 |
+
$numdeltefiles++;
|
130 |
+
else
|
131 |
+
trigger_error(sprintf(__('Can not delete "%s" on FTP server!','backwpup'),$STATIC['JOB']['ftpdir'].$backupfilelist[$i]),E_USER_ERROR);
|
132 |
+
}
|
133 |
+
if ($numdeltefiles>0)
|
134 |
+
trigger_error(sprintf(_n('One file deleted on FTP Server','%d files deleted on FTP Server',$numdeltefiles,'backwpup'),$numdeltefiles),E_USER_NOTICE);
|
135 |
+
}
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
ftp_close($ftp_conn_id);
|
140 |
+
$WORKING['STEPDONE']++;
|
141 |
+
|
142 |
+
}
|
job/dest_gstorage.php
CHANGED
@@ -1,72 +1,71 @@
|
|
1 |
-
<?PHP
|
2 |
-
function dest_gstorage() {
|
3 |
-
global $WORKING,$STATIC;
|
4 |
-
trigger_error(sprintf(__('%d. try sending backup to Google Storage...','backwpup'),$WORKING['DEST_GSTORAGE']['STEP_TRY']),E_USER_NOTICE);
|
5 |
-
$WORKING['STEPTODO']=2+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
6 |
-
$WORKING['STEPDONE']=0;
|
7 |
-
|
8 |
-
require_once(dirname(__FILE__).'/../libs/aws/sdk.class.php');
|
9 |
-
need_free_memory(26214400*1.1);
|
10 |
-
try {
|
11 |
-
$gstorage = new AmazonS3(array('key'=>$STATIC['JOB']['GStorageAccessKey'],'secret'=>$STATIC['JOB']['GStorageSecret'],'certificate_authority'=>true));
|
12 |
-
//set up s3 for google
|
13 |
-
$gstorage->set_hostname('commondatastorage.googleapis.com');
|
14 |
-
$gstorage->allow_hostname_override(false);
|
15 |
-
if ($gstorage->if_bucket_exists($STATIC['JOB']['GStorageBucket'])) {
|
16 |
-
trigger_error(sprintf(__('Connected to GStorage Bucket: %s','backwpup'),$STATIC['JOB']['GStorageBucket']),E_USER_NOTICE);
|
17 |
-
//set surl Prozess bar
|
18 |
-
$curlops=array();
|
19 |
-
if (defined('CURLOPT_PROGRESSFUNCTION'))
|
20 |
-
$curlops=array(CURLOPT_NOPROGRESS=>false,CURLOPT_PROGRESSFUNCTION=>'curl_progresscallback',CURLOPT_BUFFERSIZE=>256);
|
21 |
-
trigger_error(__('Upload to GStorage now started... ','backwpup'),E_USER_NOTICE);
|
22 |
-
//transfere file to GStorage
|
23 |
-
$result=$gstorage->create_mpu_object($STATIC['JOB']['GStorageBucket'], $STATIC['JOB']['GStoragedir'].$STATIC['backupfile'], array('fileUpload' => $STATIC['JOB']['backupdir'].$STATIC['backupfile'],'acl' => 'private','partSize'=>26214400,'curlopts'=>$curlops));
|
24 |
-
$result=(array)$result;
|
25 |
-
if ($result["status"]=200 and $result["status"]<300) {
|
26 |
-
$WORKING['STEPTODO']=1+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
27 |
-
trigger_error(sprintf(__('Backup transferred to %s','backwpup'),"https://
|
28 |
-
$STATIC['JOB']['lastbackupdownloadurl']="https://
|
29 |
-
$WORKING['STEPSDONE'][]='DEST_GSTORAGE'; //set done
|
30 |
-
} else {
|
31 |
-
trigger_error(sprintf(__('Can not transfer backup to GStorage! (%1$d) %2$s','backwpup'),$result["status"],$result["Message"]),E_USER_ERROR);
|
32 |
-
}
|
33 |
-
} else {
|
34 |
-
trigger_error(sprintf(__('GStorage Bucket "%s" not exists!','backwpup'),$STATIC['JOB']['GStorageBucket']),E_USER_ERROR);
|
35 |
-
}
|
36 |
-
} catch (Exception $e) {
|
37 |
-
trigger_error(sprintf(__('GStorage API: %s','backwpup'),$e->getMessage()),E_USER_ERROR);
|
38 |
-
return;
|
39 |
-
}
|
40 |
-
try {
|
41 |
-
if ($gstorage->if_bucket_exists($STATIC['JOB']['GStorageBucket'])) {
|
42 |
-
if ($STATIC['JOB']['GStoragemaxbackups']>0) { //Delete old backups
|
43 |
-
$backupfilelist=array();
|
44 |
-
if (($contents = $gstorage->list_objects($STATIC['JOB']['GStorageBucket'],array('prefix'=>$STATIC['JOB']['GStoragedir']))) !== false) {
|
45 |
-
foreach ($contents->body->Contents as $object) {
|
46 |
-
$file=basename($object->Key);
|
47 |
-
if ($STATIC['JOB']['fileprefix'] == substr($file,0,strlen($STATIC['JOB']['fileprefix'])) and $STATIC['JOB']['fileformart'] == substr($file,-strlen($STATIC['JOB']['fileformart'])))
|
48 |
-
$backupfilelist[]=$file;
|
49 |
-
}
|
50 |
-
}
|
51 |
-
if (sizeof($backupfilelist)>0) {
|
52 |
-
rsort($backupfilelist);
|
53 |
-
$numdeltefiles=0;
|
54 |
-
for ($i=$STATIC['JOB']['GStoragemaxbackups'];$i<sizeof($backupfilelist);$i++) {
|
55 |
-
if ($gstorage->delete_object($STATIC['JOB']['GStorageBucket'], $STATIC['JOB']['GStoragedir'].$backupfilelist[$i])) //delte files on S3
|
56 |
-
$numdeltefiles++;
|
57 |
-
else
|
58 |
-
trigger_error(sprintf(__('Can not delete backup on GStorage://%s','backwpup'),$STATIC['JOB']['awsBucket'].'/'.$STATIC['JOB']['GStoragedir'].$backupfilelist[$i]),E_USER_ERROR);
|
59 |
-
}
|
60 |
-
if ($numdeltefiles>0)
|
61 |
-
trigger_error(sprintf(_n('One file deleted on GStorage Bucket','%d files deleted on GStorage Bucket',$numdeltefiles,'backwpup'),$numdeltefiles),E_USER_NOTICE);
|
62 |
-
}
|
63 |
-
}
|
64 |
-
}
|
65 |
-
} catch (Exception $e) {
|
66 |
-
trigger_error(sprintf(__('GStorage API: %s','backwpup'),$e->getMessage()),E_USER_ERROR);
|
67 |
-
return;
|
68 |
-
}
|
69 |
-
|
70 |
-
$WORKING['STEPDONE']++;
|
71 |
-
}
|
72 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
function dest_gstorage() {
|
3 |
+
global $WORKING,$STATIC;
|
4 |
+
trigger_error(sprintf(__('%d. try sending backup to Google Storage...','backwpup'),$WORKING['DEST_GSTORAGE']['STEP_TRY']),E_USER_NOTICE);
|
5 |
+
$WORKING['STEPTODO']=2+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
6 |
+
$WORKING['STEPDONE']=0;
|
7 |
+
|
8 |
+
require_once(dirname(__FILE__).'/../libs/aws/sdk.class.php');
|
9 |
+
need_free_memory(26214400*1.1);
|
10 |
+
try {
|
11 |
+
$gstorage = new AmazonS3(array('key'=>$STATIC['JOB']['GStorageAccessKey'],'secret'=>$STATIC['JOB']['GStorageSecret'],'certificate_authority'=>true));
|
12 |
+
//set up s3 for google
|
13 |
+
$gstorage->set_hostname('commondatastorage.googleapis.com');
|
14 |
+
$gstorage->allow_hostname_override(false);
|
15 |
+
if ($gstorage->if_bucket_exists($STATIC['JOB']['GStorageBucket'])) {
|
16 |
+
trigger_error(sprintf(__('Connected to GStorage Bucket: %s','backwpup'),$STATIC['JOB']['GStorageBucket']),E_USER_NOTICE);
|
17 |
+
//set surl Prozess bar
|
18 |
+
$curlops=array();
|
19 |
+
if (defined('CURLOPT_PROGRESSFUNCTION'))
|
20 |
+
$curlops=array(CURLOPT_NOPROGRESS=>false,CURLOPT_PROGRESSFUNCTION=>'curl_progresscallback',CURLOPT_BUFFERSIZE=>256);
|
21 |
+
trigger_error(__('Upload to GStorage now started... ','backwpup'),E_USER_NOTICE);
|
22 |
+
//transfere file to GStorage
|
23 |
+
$result=$gstorage->create_mpu_object($STATIC['JOB']['GStorageBucket'], $STATIC['JOB']['GStoragedir'].$STATIC['backupfile'], array('fileUpload' => $STATIC['JOB']['backupdir'].$STATIC['backupfile'],'acl' => 'private','partSize'=>26214400,'curlopts'=>$curlops));
|
24 |
+
$result=(array)$result;
|
25 |
+
if ($result["status"]=200 and $result["status"]<300) {
|
26 |
+
$WORKING['STEPTODO']=1+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
27 |
+
trigger_error(sprintf(__('Backup transferred to %s','backwpup'),"https://storage.cloud.google.com/".$STATIC['JOB']['GStorageBucket']."/".$STATIC['JOB']['GStoragedir'].$STATIC['backupfile']),E_USER_NOTICE);
|
28 |
+
$STATIC['JOB']['lastbackupdownloadurl']="https://storage.cloud.google.com/" . $STATIC['JOB']['GStorageBucket'] . "/" . $STATIC['JOB']['GStoragedir'] . $STATIC['backupfile'];
|
29 |
+
$WORKING['STEPSDONE'][]='DEST_GSTORAGE'; //set done
|
30 |
+
} else {
|
31 |
+
trigger_error(sprintf(__('Can not transfer backup to GStorage! (%1$d) %2$s','backwpup'),$result["status"],$result["Message"]),E_USER_ERROR);
|
32 |
+
}
|
33 |
+
} else {
|
34 |
+
trigger_error(sprintf(__('GStorage Bucket "%s" not exists!','backwpup'),$STATIC['JOB']['GStorageBucket']),E_USER_ERROR);
|
35 |
+
}
|
36 |
+
} catch (Exception $e) {
|
37 |
+
trigger_error(sprintf(__('GStorage API: %s','backwpup'),$e->getMessage()),E_USER_ERROR);
|
38 |
+
return;
|
39 |
+
}
|
40 |
+
try {
|
41 |
+
if ($gstorage->if_bucket_exists($STATIC['JOB']['GStorageBucket'])) {
|
42 |
+
if ($STATIC['JOB']['GStoragemaxbackups']>0) { //Delete old backups
|
43 |
+
$backupfilelist=array();
|
44 |
+
if (($contents = $gstorage->list_objects($STATIC['JOB']['GStorageBucket'],array('prefix'=>$STATIC['JOB']['GStoragedir']))) !== false) {
|
45 |
+
foreach ($contents->body->Contents as $object) {
|
46 |
+
$file=basename($object->Key);
|
47 |
+
if ($STATIC['JOB']['fileprefix'] == substr($file,0,strlen($STATIC['JOB']['fileprefix'])) and $STATIC['JOB']['fileformart'] == substr($file,-strlen($STATIC['JOB']['fileformart'])))
|
48 |
+
$backupfilelist[]=$file;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
if (sizeof($backupfilelist)>0) {
|
52 |
+
rsort($backupfilelist);
|
53 |
+
$numdeltefiles=0;
|
54 |
+
for ($i=$STATIC['JOB']['GStoragemaxbackups'];$i<sizeof($backupfilelist);$i++) {
|
55 |
+
if ($gstorage->delete_object($STATIC['JOB']['GStorageBucket'], $STATIC['JOB']['GStoragedir'].$backupfilelist[$i])) //delte files on S3
|
56 |
+
$numdeltefiles++;
|
57 |
+
else
|
58 |
+
trigger_error(sprintf(__('Can not delete backup on GStorage://%s','backwpup'),$STATIC['JOB']['awsBucket'].'/'.$STATIC['JOB']['GStoragedir'].$backupfilelist[$i]),E_USER_ERROR);
|
59 |
+
}
|
60 |
+
if ($numdeltefiles>0)
|
61 |
+
trigger_error(sprintf(_n('One file deleted on GStorage Bucket','%d files deleted on GStorage Bucket',$numdeltefiles,'backwpup'),$numdeltefiles),E_USER_NOTICE);
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
65 |
+
} catch (Exception $e) {
|
66 |
+
trigger_error(sprintf(__('GStorage API: %s','backwpup'),$e->getMessage()),E_USER_ERROR);
|
67 |
+
return;
|
68 |
+
}
|
69 |
+
|
70 |
+
$WORKING['STEPDONE']++;
|
71 |
+
}
|
|
job/dest_mail.php
CHANGED
@@ -1,63 +1,62 @@
|
|
1 |
-
<?PHP
|
2 |
-
function dest_mail() {
|
3 |
-
global $WORKING,$STATIC;
|
4 |
-
$WORKING['STEPTODO']=filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
5 |
-
$WORKING['STEPDONE']=0;
|
6 |
-
trigger_error(sprintf(__('%d. try to sending backup with mail...','backwpup'),$WORKING['DEST_MAIL']['STEP_TRY']),E_USER_NOTICE);
|
7 |
-
|
8 |
-
//Create PHP Mailer
|
9 |
-
require_once(realpath($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC']).'/class-phpmailer.php');
|
10 |
-
$phpmailer = new PHPMailer();
|
11 |
-
//Setting den methode
|
12 |
-
if ($STATIC['CFG']['mailmethod']=="SMTP") {
|
13 |
-
require_once(realpath($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC']).'/class-smtp.php');
|
14 |
-
$phpmailer->Host=$STATIC['CFG']['mailhost'];
|
15 |
-
$phpmailer->Port=$STATIC['CFG']['mailhostport'];
|
16 |
-
$phpmailer->SMTPSecure=$STATIC['CFG']['mailsecure'];
|
17 |
-
$phpmailer->Username=$STATIC['CFG']['mailuser'];
|
18 |
-
$phpmailer->Password=base64_decode($STATIC['CFG']['mailpass']);
|
19 |
-
if (!empty($STATIC['CFG']['mailuser']) and !empty($STATIC['CFG']['mailpass']))
|
20 |
-
$phpmailer->SMTPAuth=true;
|
21 |
-
$phpmailer->IsSMTP();
|
22 |
-
trigger_error(__('Send mail with SMTP','backwpup'),E_USER_NOTICE);
|
23 |
-
} elseif ($STATIC['CFG']['mailmethod']=="Sendmail") {
|
24 |
-
$phpmailer->Sendmail=$STATIC['CFG']['mailsendmail'];
|
25 |
-
$phpmailer->IsSendmail();
|
26 |
-
trigger_error(__('Send mail with Sendmail','backwpup'),E_USER_NOTICE);
|
27 |
-
} else {
|
28 |
-
$phpmailer->IsMail();
|
29 |
-
trigger_error(__('Send mail with PHP mail','backwpup'),E_USER_NOTICE);
|
30 |
-
}
|
31 |
-
|
32 |
-
trigger_error(__('Creating mail','backwpup'),E_USER_NOTICE);
|
33 |
-
$phpmailer->From = $STATIC['CFG']['mailsndemail'];
|
34 |
-
$phpmailer->FromName = $STATIC['CFG']['mailsndname'];
|
35 |
-
$phpmailer->AddAddress($STATIC['JOB']['mailaddress']);
|
36 |
-
$phpmailer->Subject = sprintf(__('BackWPup archive from %1$s: %2$s','backwpup'),date('Y/m/d @ H:i',$STATIC['JOB']['starttime']+$STATIC['WP']['TIMEDIFF']),$STATIC['JOB']['name']);
|
37 |
-
$phpmailer->IsHTML(false);
|
38 |
-
$phpmailer->Body = sprintf(__('Backup archive: %s','backwpup'),$STATIC['backupfile']);
|
39 |
-
|
40 |
-
//check file Size
|
41 |
-
if (!empty($STATIC['JOB']['mailefilesize'])) {
|
42 |
-
if (filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile'])>abs($STATIC['JOB']['mailefilesize']*1024*1024)) {
|
43 |
-
trigger_error(__('Backup archive too big for sending by mail!','backwpup'),E_USER_ERROR);
|
44 |
-
$WORKING['STEPDONE']=1;
|
45 |
-
$WORKING['STEPSDONE'][]='DEST_MAIL'; //set done
|
46 |
-
return;
|
47 |
-
}
|
48 |
-
}
|
49 |
-
|
50 |
-
trigger_error(__('Adding backup archive to mail','backwpup'),E_USER_NOTICE);
|
51 |
-
need_free_memory(filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile'])*5);
|
52 |
-
$phpmailer->AddAttachment($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
53 |
-
|
54 |
-
trigger_error(__('Send mail....','backwpup'),E_USER_NOTICE);
|
55 |
-
if (false == $phpmailer->Send()) {
|
56 |
-
trigger_error(sprintf(__('Error "%s" on sending mail!','backwpup'),$phpmailer->ErrorInfo),E_USER_ERROR);
|
57 |
-
} else {
|
58 |
-
$WORKING['STEPTODO']=filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
59 |
-
trigger_error(__('Mail send!!!','backwpup'),E_USER_NOTICE);
|
60 |
-
}
|
61 |
-
$WORKING['STEPSDONE'][]='DEST_MAIL'; //set done
|
62 |
-
}
|
63 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
function dest_mail() {
|
3 |
+
global $WORKING,$STATIC;
|
4 |
+
$WORKING['STEPTODO']=filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
5 |
+
$WORKING['STEPDONE']=0;
|
6 |
+
trigger_error(sprintf(__('%d. try to sending backup with mail...','backwpup'),$WORKING['DEST_MAIL']['STEP_TRY']),E_USER_NOTICE);
|
7 |
+
|
8 |
+
//Create PHP Mailer
|
9 |
+
require_once(realpath($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC']).'/class-phpmailer.php');
|
10 |
+
$phpmailer = new PHPMailer();
|
11 |
+
//Setting den methode
|
12 |
+
if ($STATIC['CFG']['mailmethod']=="SMTP") {
|
13 |
+
require_once(realpath($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC']).'/class-smtp.php');
|
14 |
+
$phpmailer->Host=$STATIC['CFG']['mailhost'];
|
15 |
+
$phpmailer->Port=$STATIC['CFG']['mailhostport'];
|
16 |
+
$phpmailer->SMTPSecure=$STATIC['CFG']['mailsecure'];
|
17 |
+
$phpmailer->Username=$STATIC['CFG']['mailuser'];
|
18 |
+
$phpmailer->Password=base64_decode($STATIC['CFG']['mailpass']);
|
19 |
+
if (!empty($STATIC['CFG']['mailuser']) and !empty($STATIC['CFG']['mailpass']))
|
20 |
+
$phpmailer->SMTPAuth=true;
|
21 |
+
$phpmailer->IsSMTP();
|
22 |
+
trigger_error(__('Send mail with SMTP','backwpup'),E_USER_NOTICE);
|
23 |
+
} elseif ($STATIC['CFG']['mailmethod']=="Sendmail") {
|
24 |
+
$phpmailer->Sendmail=$STATIC['CFG']['mailsendmail'];
|
25 |
+
$phpmailer->IsSendmail();
|
26 |
+
trigger_error(__('Send mail with Sendmail','backwpup'),E_USER_NOTICE);
|
27 |
+
} else {
|
28 |
+
$phpmailer->IsMail();
|
29 |
+
trigger_error(__('Send mail with PHP mail','backwpup'),E_USER_NOTICE);
|
30 |
+
}
|
31 |
+
|
32 |
+
trigger_error(__('Creating mail','backwpup'),E_USER_NOTICE);
|
33 |
+
$phpmailer->From = $STATIC['CFG']['mailsndemail'];
|
34 |
+
$phpmailer->FromName = $STATIC['CFG']['mailsndname'];
|
35 |
+
$phpmailer->AddAddress($STATIC['JOB']['mailaddress']);
|
36 |
+
$phpmailer->Subject = sprintf(__('BackWPup archive from %1$s: %2$s','backwpup'),date('Y/m/d @ H:i',$STATIC['JOB']['starttime']+$STATIC['WP']['TIMEDIFF']),$STATIC['JOB']['name']);
|
37 |
+
$phpmailer->IsHTML(false);
|
38 |
+
$phpmailer->Body = sprintf(__('Backup archive: %s','backwpup'),$STATIC['backupfile']);
|
39 |
+
|
40 |
+
//check file Size
|
41 |
+
if (!empty($STATIC['JOB']['mailefilesize'])) {
|
42 |
+
if (filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile'])>abs($STATIC['JOB']['mailefilesize']*1024*1024)) {
|
43 |
+
trigger_error(__('Backup archive too big for sending by mail!','backwpup'),E_USER_ERROR);
|
44 |
+
$WORKING['STEPDONE']=1;
|
45 |
+
$WORKING['STEPSDONE'][]='DEST_MAIL'; //set done
|
46 |
+
return;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
trigger_error(__('Adding backup archive to mail','backwpup'),E_USER_NOTICE);
|
51 |
+
need_free_memory(filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile'])*5);
|
52 |
+
$phpmailer->AddAttachment($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
53 |
+
|
54 |
+
trigger_error(__('Send mail....','backwpup'),E_USER_NOTICE);
|
55 |
+
if (false == $phpmailer->Send()) {
|
56 |
+
trigger_error(sprintf(__('Error "%s" on sending mail!','backwpup'),$phpmailer->ErrorInfo),E_USER_ERROR);
|
57 |
+
} else {
|
58 |
+
$WORKING['STEPTODO']=filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
59 |
+
trigger_error(__('Mail send!!!','backwpup'),E_USER_NOTICE);
|
60 |
+
}
|
61 |
+
$WORKING['STEPSDONE'][]='DEST_MAIL'; //set done
|
62 |
+
}
|
|
job/dest_msazure.php
CHANGED
@@ -1,60 +1,59 @@
|
|
1 |
-
<?PHP
|
2 |
-
function dest_msazure() {
|
3 |
-
global $WORKING,$STATIC;
|
4 |
-
$WORKING['STEPTODO']=2+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
5 |
-
trigger_error(sprintf(__('%d. try sending backup to a Microsoft Azure (Blob)...','backwpup'),$WORKING['DEST_MSAZURE']['STEP_TRY']),E_USER_NOTICE);
|
6 |
-
|
7 |
-
require_once(dirname(__FILE__).'/../libs/Microsoft/WindowsAzure/Storage/Blob.php');
|
8 |
-
need_free_memory(4194304*1.5);
|
9 |
-
|
10 |
-
try {
|
11 |
-
$storageClient = new Microsoft_WindowsAzure_Storage_Blob($STATIC['JOB']['msazureHost'],$STATIC['JOB']['msazureAccName'],$STATIC['JOB']['msazureKey']);
|
12 |
-
|
13 |
-
if(!$storageClient->containerExists($STATIC['JOB']['msazureContainer'])) {
|
14 |
-
trigger_error(sprintf(__('Microsoft Azure container "%s" not exists!','backwpup'),$STATIC['JOB']['msazureContainer']),E_USER_ERROR);
|
15 |
-
return;
|
16 |
-
} else {
|
17 |
-
trigger_error(sprintf(__('Connected to Microsoft Azure container "%s"','backwpup'),$STATIC['JOB']['msazureContainer']),E_USER_NOTICE);
|
18 |
-
}
|
19 |
-
|
20 |
-
trigger_error(__('Upload to MS Azure now started... ','backwpup'),E_USER_NOTICE);
|
21 |
-
$result = $storageClient->putBlob($STATIC['JOB']['msazureContainer'], $STATIC['JOB']['msazuredir'].$STATIC['backupfile'], $STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
22 |
-
|
23 |
-
if ($result->Name==$STATIC['JOB']['msazuredir'].$STATIC['backupfile']) {
|
24 |
-
$WORKING['STEPTODO']=1+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
25 |
-
trigger_error(sprintf(__('Backup transferred to %s','backwpup'),'https://'.$STATIC['JOB']['msazureAccName'].'.'.$STATIC['JOB']['msazureHost'].'/'.$STATIC['JOB']['msazuredir'].$STATIC['backupfile']),E_USER_NOTICE);
|
26 |
-
$STATIC['JOB']['lastbackupdownloadurl']=$STATIC['WP']['ADMINURL'].'?page=backwpupbackups&action=downloadmsazure&file='.$STATIC['JOB']['msazuredir'].$STATIC['backupfile'].'&jobid='.$STATIC['JOB']['jobid'];
|
27 |
-
$WORKING['STEPSDONE'][]='DEST_MSAZURE'; //set done
|
28 |
-
} else {
|
29 |
-
trigger_error(__('Can not transfer backup to Microsoft Azure!','backwpup'),E_USER_ERROR);
|
30 |
-
}
|
31 |
-
|
32 |
-
if ($STATIC['JOB']['msazuremaxbackups']>0) { //Delete old backups
|
33 |
-
$backupfilelist=array();
|
34 |
-
$blobs = $storageClient->listBlobs($STATIC['JOB']['msazureContainer'],$STATIC['JOB']['msazuredir']);
|
35 |
-
if (is_array($blobs)) {
|
36 |
-
foreach ($blobs as $blob) {
|
37 |
-
$file=basename($blob->Name);
|
38 |
-
if ($STATIC['JOB']['fileprefix'] == substr($file,0,strlen($STATIC['JOB']['fileprefix'])) and $STATIC['JOB']['fileformart'] == substr($file,-strlen($STATIC['JOB']['fileformart'])))
|
39 |
-
$backupfilelist[]=$file;
|
40 |
-
}
|
41 |
-
}
|
42 |
-
if (sizeof($backupfilelist)>0) {
|
43 |
-
rsort($backupfilelist);
|
44 |
-
$numdeltefiles=0;
|
45 |
-
for ($i=$STATIC['JOB']['msazuremaxbackups'];$i<sizeof($backupfilelist);$i++) {
|
46 |
-
$storageClient->deleteBlob($STATIC['JOB']['msazureContainer'],$STATIC['JOB']['msazuredir'].$backupfilelist[$i]); //delte files on Cloud
|
47 |
-
$numdeltefiles++;
|
48 |
-
}
|
49 |
-
if ($numdeltefiles>0)
|
50 |
-
trigger_error(sprintf(_n('One file deleted on Microsoft Azure container','%d files deleted on Microsoft Azure container',$numdeltefiles,'backwpup'),$numdeltefiles),E_USER_NOTICE);
|
51 |
-
}
|
52 |
-
}
|
53 |
-
|
54 |
-
} catch (Exception $e) {
|
55 |
-
trigger_error(sprintf(__('Microsoft Azure API: %s','backwpup'),$e->getMessage()),E_USER_ERROR);
|
56 |
-
}
|
57 |
-
|
58 |
-
$WORKING['STEPDONE']++;
|
59 |
-
}
|
60 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
function dest_msazure() {
|
3 |
+
global $WORKING,$STATIC;
|
4 |
+
$WORKING['STEPTODO']=2+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
5 |
+
trigger_error(sprintf(__('%d. try sending backup to a Microsoft Azure (Blob)...','backwpup'),$WORKING['DEST_MSAZURE']['STEP_TRY']),E_USER_NOTICE);
|
6 |
+
|
7 |
+
require_once(dirname(__FILE__).'/../libs/Microsoft/WindowsAzure/Storage/Blob.php');
|
8 |
+
need_free_memory(4194304*1.5);
|
9 |
+
|
10 |
+
try {
|
11 |
+
$storageClient = new Microsoft_WindowsAzure_Storage_Blob($STATIC['JOB']['msazureHost'],$STATIC['JOB']['msazureAccName'],$STATIC['JOB']['msazureKey']);
|
12 |
+
|
13 |
+
if(!$storageClient->containerExists($STATIC['JOB']['msazureContainer'])) {
|
14 |
+
trigger_error(sprintf(__('Microsoft Azure container "%s" not exists!','backwpup'),$STATIC['JOB']['msazureContainer']),E_USER_ERROR);
|
15 |
+
return;
|
16 |
+
} else {
|
17 |
+
trigger_error(sprintf(__('Connected to Microsoft Azure container "%s"','backwpup'),$STATIC['JOB']['msazureContainer']),E_USER_NOTICE);
|
18 |
+
}
|
19 |
+
|
20 |
+
trigger_error(__('Upload to MS Azure now started... ','backwpup'),E_USER_NOTICE);
|
21 |
+
$result = $storageClient->putBlob($STATIC['JOB']['msazureContainer'], $STATIC['JOB']['msazuredir'].$STATIC['backupfile'], $STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
22 |
+
|
23 |
+
if ($result->Name==$STATIC['JOB']['msazuredir'].$STATIC['backupfile']) {
|
24 |
+
$WORKING['STEPTODO']=1+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
25 |
+
trigger_error(sprintf(__('Backup transferred to %s','backwpup'),'https://'.$STATIC['JOB']['msazureAccName'].'.'.$STATIC['JOB']['msazureHost'].'/'.$STATIC['JOB']['msazuredir'].$STATIC['backupfile']),E_USER_NOTICE);
|
26 |
+
$STATIC['JOB']['lastbackupdownloadurl']=$STATIC['WP']['ADMINURL'].'?page=backwpupbackups&action=downloadmsazure&file='.$STATIC['JOB']['msazuredir'].$STATIC['backupfile'].'&jobid='.$STATIC['JOB']['jobid'];
|
27 |
+
$WORKING['STEPSDONE'][]='DEST_MSAZURE'; //set done
|
28 |
+
} else {
|
29 |
+
trigger_error(__('Can not transfer backup to Microsoft Azure!','backwpup'),E_USER_ERROR);
|
30 |
+
}
|
31 |
+
|
32 |
+
if ($STATIC['JOB']['msazuremaxbackups']>0) { //Delete old backups
|
33 |
+
$backupfilelist=array();
|
34 |
+
$blobs = $storageClient->listBlobs($STATIC['JOB']['msazureContainer'],$STATIC['JOB']['msazuredir']);
|
35 |
+
if (is_array($blobs)) {
|
36 |
+
foreach ($blobs as $blob) {
|
37 |
+
$file=basename($blob->Name);
|
38 |
+
if ($STATIC['JOB']['fileprefix'] == substr($file,0,strlen($STATIC['JOB']['fileprefix'])) and $STATIC['JOB']['fileformart'] == substr($file,-strlen($STATIC['JOB']['fileformart'])))
|
39 |
+
$backupfilelist[]=$file;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
if (sizeof($backupfilelist)>0) {
|
43 |
+
rsort($backupfilelist);
|
44 |
+
$numdeltefiles=0;
|
45 |
+
for ($i=$STATIC['JOB']['msazuremaxbackups'];$i<sizeof($backupfilelist);$i++) {
|
46 |
+
$storageClient->deleteBlob($STATIC['JOB']['msazureContainer'],$STATIC['JOB']['msazuredir'].$backupfilelist[$i]); //delte files on Cloud
|
47 |
+
$numdeltefiles++;
|
48 |
+
}
|
49 |
+
if ($numdeltefiles>0)
|
50 |
+
trigger_error(sprintf(_n('One file deleted on Microsoft Azure container','%d files deleted on Microsoft Azure container',$numdeltefiles,'backwpup'),$numdeltefiles),E_USER_NOTICE);
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
} catch (Exception $e) {
|
55 |
+
trigger_error(sprintf(__('Microsoft Azure API: %s','backwpup'),$e->getMessage()),E_USER_ERROR);
|
56 |
+
}
|
57 |
+
|
58 |
+
$WORKING['STEPDONE']++;
|
59 |
+
}
|
|
job/dest_rsc.php
CHANGED
@@ -1,97 +1,96 @@
|
|
1 |
-
<?PHP
|
2 |
-
function dest_rsc() {
|
3 |
-
global $WORKING,$STATIC;
|
4 |
-
trigger_error($WORKING['DEST_RSC']['STEP_TRY'].'. '.__('Try to sending backup file to Rackspace Cloud...','backwpup'),E_USER_NOTICE);
|
5 |
-
$WORKING['STEPTODO']=2+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
6 |
-
$WORKING['STEPDONE']=0;
|
7 |
-
require_once(dirname(__FILE__).'/../libs/rackspace/cloudfiles.php');
|
8 |
-
|
9 |
-
$auth = new CF_Authentication($STATIC['JOB']['rscUsername'], $STATIC['JOB']['rscAPIKey']);
|
10 |
-
$auth->ssl_use_cabundle();
|
11 |
-
try {
|
12 |
-
if ($auth->authenticate())
|
13 |
-
trigger_error(__('Connected to Rackspase ...','backwpup'),E_USER_NOTICE);
|
14 |
-
$conn = new CF_Connection($auth);
|
15 |
-
$conn->ssl_use_cabundle();
|
16 |
-
$is_container=false;
|
17 |
-
$containers=$conn->get_containers();
|
18 |
-
foreach ($containers as $container) {
|
19 |
-
if ($container->name == $STATIC['JOB']['rscContainer'] )
|
20 |
-
$is_container=true;
|
21 |
-
}
|
22 |
-
if (!$is_container) {
|
23 |
-
$public_container = $conn->create_container($STATIC['JOB']['rscContainer']);
|
24 |
-
$public_container->make_private();
|
25 |
-
if (empty($public_container))
|
26 |
-
$is_container=false;
|
27 |
-
}
|
28 |
-
} catch (Exception $e) {
|
29 |
-
trigger_error(__('Rackspase Cloud API:','backwpup').' '.$e->getMessage(),E_USER_ERROR);
|
30 |
-
return;
|
31 |
-
}
|
32 |
-
|
33 |
-
if (!$is_container) {
|
34 |
-
trigger_error(__('Rackspase Cloud Container not exists:','backwpup').' '.$STATIC['JOB']['rscContainer'],E_USER_ERROR);
|
35 |
-
return;
|
36 |
-
}
|
37 |
-
|
38 |
-
try {
|
39 |
-
//Transfer Backup to Rackspace Cloud
|
40 |
-
$backwpupcontainer = $conn->get_container($STATIC['JOB']['rscContainer']);
|
41 |
-
//if (!empty($STATIC['JOB']['rscdir'])) //make the foldder
|
42 |
-
// $backwpupcontainer->create_paths($STATIC['JOB']['rscdir']);
|
43 |
-
$backwpupbackup = $backwpupcontainer->create_object($STATIC['JOB']['rscdir'].$STATIC['backupfile']);
|
44 |
-
//set content Type
|
45 |
-
if ($STATIC['JOB']['fileformart']=='.zip')
|
46 |
-
$backwpupbackup->content_type='application/zip';
|
47 |
-
if ($STATIC['JOB']['fileformart']=='.tar')
|
48 |
-
$backwpupbackup->content_type='application/x-ustar';
|
49 |
-
if ($STATIC['JOB']['fileformart']=='.tar.gz')
|
50 |
-
$backwpupbackup->content_type='application/x-compressed';
|
51 |
-
if ($STATIC['JOB']['fileformart']=='.tar.bz2')
|
52 |
-
$backwpupbackup->content_type='application/x-compressed';
|
53 |
-
trigger_error(__('Upload to RSC now started ... ','backwpup'),E_USER_NOTICE);
|
54 |
-
if ($backwpupbackup->load_from_filename($STATIC['JOB']['backupdir'].$STATIC['backupfile'])) {
|
55 |
-
$WORKING['STEPTODO']=1+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
56 |
-
trigger_error(__('Backup File transferred to RSC://','backwpup').$STATIC['JOB']['rscContainer'].'/'.$STATIC['JOB']['rscdir'].$STATIC['backupfile'],E_USER_NOTICE);
|
57 |
-
$STATIC['JOB']['lastbackupdownloadurl']=$STATIC['WP']['ADMINURL'].'?page=backwpupbackups&action=downloadrsc&file='.$STATIC['JOB']['rscdir'].$STATIC['backupfile'].'&jobid='.$STATIC['JOB']['jobid'];
|
58 |
-
$WORKING['STEPSDONE'][]='DEST_RSC'; //set done
|
59 |
-
} else {
|
60 |
-
trigger_error(__('Can not transfer backup to RSC.','backwpup'),E_USER_ERROR);
|
61 |
-
}
|
62 |
-
} catch (Exception $e) {
|
63 |
-
trigger_error(__('Rackspase Cloud API:','backwpup').' '.$e->getMessage(),E_USER_ERROR);
|
64 |
-
}
|
65 |
-
try {
|
66 |
-
if ($STATIC['JOB']['rscmaxbackups']>0) { //Delete old backups
|
67 |
-
$backupfilelist=array();
|
68 |
-
$contents = $backwpupcontainer->list_objects(0,NULL,NULL,$STATIC['JOB']['rscdir']);
|
69 |
-
if (is_array($contents)) {
|
70 |
-
foreach ($contents as $object) {
|
71 |
-
$file=basename($object);
|
72 |
-
if ($STATIC['JOB']['rscdir'].$file == $object) {//only in the folder and not in complete bucket
|
73 |
-
if ($STATIC['JOB']['fileprefix'] == substr($file,0,strlen($STATIC['JOB']['fileprefix'])) and $STATIC['JOB']['fileformart'] == substr($file,-strlen($STATIC['JOB']['fileformart'])))
|
74 |
-
$backupfilelist[]=$file;
|
75 |
-
}
|
76 |
-
}
|
77 |
-
}
|
78 |
-
if (sizeof($backupfilelist)>0) {
|
79 |
-
rsort($backupfilelist);
|
80 |
-
$numdeltefiles=0;
|
81 |
-
for ($i=$STATIC['JOB']['rscmaxbackups'];$i<sizeof($backupfilelist);$i++) {
|
82 |
-
if ($backwpupcontainer->delete_object($STATIC['JOB']['rscdir'].$backupfilelist[$i])) //delte files on Cloud
|
83 |
-
$numdeltefiles++;
|
84 |
-
else
|
85 |
-
trigger_error(__('Can not delete file on RSC://','backwpup').$STATIC['JOB']['rscContainer'].$STATIC['JOB']['rscdir'].$backupfilelist[$i],E_USER_ERROR);
|
86 |
-
}
|
87 |
-
if ($numdeltefiles>0)
|
88 |
-
trigger_error(sprintf(_n('One file deleted on RSC container','%d files deleted on RSC container',$numdeltefiles,'backwpup'),$numdeltefiles),E_USER_NOTICE);
|
89 |
-
}
|
90 |
-
}
|
91 |
-
} catch (Exception $e) {
|
92 |
-
trigger_error(__('Rackspase Cloud API:','backwpup').' '.$e->getMessage(),E_USER_ERROR);
|
93 |
-
}
|
94 |
-
|
95 |
-
$WORKING['STEPDONE']++;
|
96 |
-
}
|
97 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
function dest_rsc() {
|
3 |
+
global $WORKING,$STATIC;
|
4 |
+
trigger_error($WORKING['DEST_RSC']['STEP_TRY'].'. '.__('Try to sending backup file to Rackspace Cloud...','backwpup'),E_USER_NOTICE);
|
5 |
+
$WORKING['STEPTODO']=2+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
6 |
+
$WORKING['STEPDONE']=0;
|
7 |
+
require_once(dirname(__FILE__).'/../libs/rackspace/cloudfiles.php');
|
8 |
+
|
9 |
+
$auth = new CF_Authentication($STATIC['JOB']['rscUsername'], $STATIC['JOB']['rscAPIKey']);
|
10 |
+
$auth->ssl_use_cabundle();
|
11 |
+
try {
|
12 |
+
if ($auth->authenticate())
|
13 |
+
trigger_error(__('Connected to Rackspase ...','backwpup'),E_USER_NOTICE);
|
14 |
+
$conn = new CF_Connection($auth);
|
15 |
+
$conn->ssl_use_cabundle();
|
16 |
+
$is_container=false;
|
17 |
+
$containers=$conn->get_containers();
|
18 |
+
foreach ($containers as $container) {
|
19 |
+
if ($container->name == $STATIC['JOB']['rscContainer'] )
|
20 |
+
$is_container=true;
|
21 |
+
}
|
22 |
+
if (!$is_container) {
|
23 |
+
$public_container = $conn->create_container($STATIC['JOB']['rscContainer']);
|
24 |
+
$public_container->make_private();
|
25 |
+
if (empty($public_container))
|
26 |
+
$is_container=false;
|
27 |
+
}
|
28 |
+
} catch (Exception $e) {
|
29 |
+
trigger_error(__('Rackspase Cloud API:','backwpup').' '.$e->getMessage(),E_USER_ERROR);
|
30 |
+
return;
|
31 |
+
}
|
32 |
+
|
33 |
+
if (!$is_container) {
|
34 |
+
trigger_error(__('Rackspase Cloud Container not exists:','backwpup').' '.$STATIC['JOB']['rscContainer'],E_USER_ERROR);
|
35 |
+
return;
|
36 |
+
}
|
37 |
+
|
38 |
+
try {
|
39 |
+
//Transfer Backup to Rackspace Cloud
|
40 |
+
$backwpupcontainer = $conn->get_container($STATIC['JOB']['rscContainer']);
|
41 |
+
//if (!empty($STATIC['JOB']['rscdir'])) //make the foldder
|
42 |
+
// $backwpupcontainer->create_paths($STATIC['JOB']['rscdir']);
|
43 |
+
$backwpupbackup = $backwpupcontainer->create_object($STATIC['JOB']['rscdir'].$STATIC['backupfile']);
|
44 |
+
//set content Type
|
45 |
+
if ($STATIC['JOB']['fileformart']=='.zip')
|
46 |
+
$backwpupbackup->content_type='application/zip';
|
47 |
+
if ($STATIC['JOB']['fileformart']=='.tar')
|
48 |
+
$backwpupbackup->content_type='application/x-ustar';
|
49 |
+
if ($STATIC['JOB']['fileformart']=='.tar.gz')
|
50 |
+
$backwpupbackup->content_type='application/x-compressed';
|
51 |
+
if ($STATIC['JOB']['fileformart']=='.tar.bz2')
|
52 |
+
$backwpupbackup->content_type='application/x-compressed';
|
53 |
+
trigger_error(__('Upload to RSC now started ... ','backwpup'),E_USER_NOTICE);
|
54 |
+
if ($backwpupbackup->load_from_filename($STATIC['JOB']['backupdir'].$STATIC['backupfile'])) {
|
55 |
+
$WORKING['STEPTODO']=1+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
56 |
+
trigger_error(__('Backup File transferred to RSC://','backwpup').$STATIC['JOB']['rscContainer'].'/'.$STATIC['JOB']['rscdir'].$STATIC['backupfile'],E_USER_NOTICE);
|
57 |
+
$STATIC['JOB']['lastbackupdownloadurl']=$STATIC['WP']['ADMINURL'].'?page=backwpupbackups&action=downloadrsc&file='.$STATIC['JOB']['rscdir'].$STATIC['backupfile'].'&jobid='.$STATIC['JOB']['jobid'];
|
58 |
+
$WORKING['STEPSDONE'][]='DEST_RSC'; //set done
|
59 |
+
} else {
|
60 |
+
trigger_error(__('Can not transfer backup to RSC.','backwpup'),E_USER_ERROR);
|
61 |
+
}
|
62 |
+
} catch (Exception $e) {
|
63 |
+
trigger_error(__('Rackspase Cloud API:','backwpup').' '.$e->getMessage(),E_USER_ERROR);
|
64 |
+
}
|
65 |
+
try {
|
66 |
+
if ($STATIC['JOB']['rscmaxbackups']>0) { //Delete old backups
|
67 |
+
$backupfilelist=array();
|
68 |
+
$contents = $backwpupcontainer->list_objects(0,NULL,NULL,$STATIC['JOB']['rscdir']);
|
69 |
+
if (is_array($contents)) {
|
70 |
+
foreach ($contents as $object) {
|
71 |
+
$file=basename($object);
|
72 |
+
if ($STATIC['JOB']['rscdir'].$file == $object) {//only in the folder and not in complete bucket
|
73 |
+
if ($STATIC['JOB']['fileprefix'] == substr($file,0,strlen($STATIC['JOB']['fileprefix'])) and $STATIC['JOB']['fileformart'] == substr($file,-strlen($STATIC['JOB']['fileformart'])))
|
74 |
+
$backupfilelist[]=$file;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
if (sizeof($backupfilelist)>0) {
|
79 |
+
rsort($backupfilelist);
|
80 |
+
$numdeltefiles=0;
|
81 |
+
for ($i=$STATIC['JOB']['rscmaxbackups'];$i<sizeof($backupfilelist);$i++) {
|
82 |
+
if ($backwpupcontainer->delete_object($STATIC['JOB']['rscdir'].$backupfilelist[$i])) //delte files on Cloud
|
83 |
+
$numdeltefiles++;
|
84 |
+
else
|
85 |
+
trigger_error(__('Can not delete file on RSC://','backwpup').$STATIC['JOB']['rscContainer'].$STATIC['JOB']['rscdir'].$backupfilelist[$i],E_USER_ERROR);
|
86 |
+
}
|
87 |
+
if ($numdeltefiles>0)
|
88 |
+
trigger_error(sprintf(_n('One file deleted on RSC container','%d files deleted on RSC container',$numdeltefiles,'backwpup'),$numdeltefiles),E_USER_NOTICE);
|
89 |
+
}
|
90 |
+
}
|
91 |
+
} catch (Exception $e) {
|
92 |
+
trigger_error(__('Rackspase Cloud API:','backwpup').' '.$e->getMessage(),E_USER_ERROR);
|
93 |
+
}
|
94 |
+
|
95 |
+
$WORKING['STEPDONE']++;
|
96 |
+
}
|
|
job/dest_s3.php
CHANGED
@@ -1,75 +1,74 @@
|
|
1 |
-
<?PHP
|
2 |
-
function dest_s3() {
|
3 |
-
global $WORKING,$STATIC;
|
4 |
-
trigger_error(sprintf(__('%d. try sending backup file to Amazon S3...','backwpup'),$WORKING['DEST_S3']['STEP_TRY']),E_USER_NOTICE);
|
5 |
-
$WORKING['STEPTODO']=2+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
6 |
-
$WORKING['STEPDONE']=0;
|
7 |
-
|
8 |
-
require_once(dirname(__FILE__).'/../libs/aws/sdk.class.php');
|
9 |
-
need_free_memory(26214400*1.1);
|
10 |
-
|
11 |
-
try {
|
12 |
-
$s3 = new AmazonS3(array('key'=>$STATIC['JOB']['awsAccessKey'],'secret'=>$STATIC['JOB']['awsSecretKey'],'certificate_authority'=>true));
|
13 |
-
if ($s3->if_bucket_exists($STATIC['JOB']['awsBucket'])) {
|
14 |
-
trigger_error(sprintf(__('Connected to S3 Bucket: %s','backwpup'),$STATIC['JOB']['awsBucket']),E_USER_NOTICE);
|
15 |
-
//Transfer Backup to S3
|
16 |
-
if ($STATIC['JOB']['awsrrs']) //set reduced redundancy or not
|
17 |
-
$storage=AmazonS3::STORAGE_REDUCED;
|
18 |
-
else
|
19 |
-
$storage=AmazonS3::STORAGE_STANDARD;
|
20 |
-
//set surl Prozess bar
|
21 |
-
$curlops=array();
|
22 |
-
if (defined('CURLOPT_PROGRESSFUNCTION'))
|
23 |
-
$curlops=array(CURLOPT_NOPROGRESS=>false,CURLOPT_PROGRESSFUNCTION=>'curl_progresscallback',CURLOPT_BUFFERSIZE=>256);
|
24 |
-
trigger_error(__('Upload to Amazon S3 now started... ','backwpup'),E_USER_NOTICE);
|
25 |
-
//transfere file to S3
|
26 |
-
$result=$s3->create_mpu_object($STATIC['JOB']['awsBucket'], $STATIC['JOB']['awsdir'].$STATIC['backupfile'], array('fileUpload' => $STATIC['JOB']['backupdir'].$STATIC['backupfile'],'acl' => AmazonS3::ACL_PRIVATE,'storage' => $storage,'partSize'=>26214400,'curlopts'=>$curlops));
|
27 |
-
$result=(array)$result;
|
28 |
-
if ($result["status"]=200 and $result["status"]<300) {
|
29 |
-
$WORKING['STEPTODO']=1+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
30 |
-
trigger_error(sprintf(__('Backup transferred to %s','backwpup'),$result["header"]["_info"]["url"]),E_USER_NOTICE);
|
31 |
-
$STATIC['JOB']['lastbackupdownloadurl']=$STATIC['WP']['ADMINURL'].'?page=backwpupbackups&action=downloads3&file='.$STATIC['JOB']['awsdir'].$STATIC['backupfile'].'&jobid='.$STATIC['JOB']['jobid'];
|
32 |
-
$WORKING['STEPSDONE'][]='DEST_S3'; //set done
|
33 |
-
} else {
|
34 |
-
trigger_error(sprintf(__('Can not transfer backup to S3! (%1$d) %2$s','backwpup'),$result["status"],$result["Message"]),E_USER_ERROR);
|
35 |
-
}
|
36 |
-
} else {
|
37 |
-
trigger_error(sprintf(__('S3 Bucket "%s" not exists!','backwpup'),$STATIC['JOB']['awsBucket']),E_USER_ERROR);
|
38 |
-
}
|
39 |
-
} catch (Exception $e) {
|
40 |
-
trigger_error(sprintf(__('Amazon API: %s','backwpup'),$e->getMessage()),E_USER_ERROR);
|
41 |
-
return;
|
42 |
-
}
|
43 |
-
try {
|
44 |
-
if ($s3->if_bucket_exists($STATIC['JOB']['awsBucket'])) {
|
45 |
-
if ($STATIC['JOB']['awsmaxbackups']>0) { //Delete old backups
|
46 |
-
$backupfilelist=array();
|
47 |
-
if (($contents = $s3->list_objects($STATIC['JOB']['awsBucket'],array('prefix'=>$STATIC['JOB']['awsdir']))) !== false) {
|
48 |
-
foreach ($contents->body->Contents as $object) {
|
49 |
-
$file=basename($object->Key);
|
50 |
-
if ($STATIC['JOB']['fileprefix'] == substr($file,0,strlen($STATIC['JOB']['fileprefix'])) and $STATIC['JOB']['fileformart'] == substr($file,-strlen($STATIC['JOB']['fileformart'])))
|
51 |
-
$backupfilelist[]=$file;
|
52 |
-
}
|
53 |
-
}
|
54 |
-
if (sizeof($backupfilelist)>0) {
|
55 |
-
rsort($backupfilelist);
|
56 |
-
$numdeltefiles=0;
|
57 |
-
for ($i=$STATIC['JOB']['awsmaxbackups'];$i<sizeof($backupfilelist);$i++) {
|
58 |
-
if ($s3->delete_object($STATIC['JOB']['awsBucket'], $STATIC['JOB']['awsdir'].$backupfilelist[$i])) //delte files on S3
|
59 |
-
$numdeltefiles++;
|
60 |
-
else
|
61 |
-
trigger_error(sprintf(__('Can not delete backup on S3://%s','backwpup'),$STATIC['JOB']['awsBucket'].'/'.$STATIC['JOB']['awsdir'].$backupfilelist[$i]),E_USER_ERROR);
|
62 |
-
}
|
63 |
-
if ($numdeltefiles>0)
|
64 |
-
trigger_error(sprintf(_n('One file deleted on S3 Bucket','%d files deleted on S3 Bucket',$numdeltefiles,'backwpup'),$numdeltefiles),E_USER_NOTICE);
|
65 |
-
}
|
66 |
-
}
|
67 |
-
}
|
68 |
-
} catch (Exception $e) {
|
69 |
-
trigger_error(sprintf(__('Amazon API: %s','backwpup'),$e->getMessage()),E_USER_ERROR);
|
70 |
-
return;
|
71 |
-
}
|
72 |
-
|
73 |
-
$WORKING['STEPDONE']++;
|
74 |
-
}
|
75 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
function dest_s3() {
|
3 |
+
global $WORKING,$STATIC;
|
4 |
+
trigger_error(sprintf(__('%d. try sending backup file to Amazon S3...','backwpup'),$WORKING['DEST_S3']['STEP_TRY']),E_USER_NOTICE);
|
5 |
+
$WORKING['STEPTODO']=2+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
6 |
+
$WORKING['STEPDONE']=0;
|
7 |
+
|
8 |
+
require_once(dirname(__FILE__).'/../libs/aws/sdk.class.php');
|
9 |
+
need_free_memory(26214400*1.1);
|
10 |
+
|
11 |
+
try {
|
12 |
+
$s3 = new AmazonS3(array('key'=>$STATIC['JOB']['awsAccessKey'],'secret'=>$STATIC['JOB']['awsSecretKey'],'certificate_authority'=>true));
|
13 |
+
if ($s3->if_bucket_exists($STATIC['JOB']['awsBucket'])) {
|
14 |
+
trigger_error(sprintf(__('Connected to S3 Bucket: %s','backwpup'),$STATIC['JOB']['awsBucket']),E_USER_NOTICE);
|
15 |
+
//Transfer Backup to S3
|
16 |
+
if ($STATIC['JOB']['awsrrs']) //set reduced redundancy or not
|
17 |
+
$storage=AmazonS3::STORAGE_REDUCED;
|
18 |
+
else
|
19 |
+
$storage=AmazonS3::STORAGE_STANDARD;
|
20 |
+
//set surl Prozess bar
|
21 |
+
$curlops=array();
|
22 |
+
if (defined('CURLOPT_PROGRESSFUNCTION'))
|
23 |
+
$curlops=array(CURLOPT_NOPROGRESS=>false,CURLOPT_PROGRESSFUNCTION=>'curl_progresscallback',CURLOPT_BUFFERSIZE=>256);
|
24 |
+
trigger_error(__('Upload to Amazon S3 now started... ','backwpup'),E_USER_NOTICE);
|
25 |
+
//transfere file to S3
|
26 |
+
$result=$s3->create_mpu_object($STATIC['JOB']['awsBucket'], $STATIC['JOB']['awsdir'].$STATIC['backupfile'], array('fileUpload' => $STATIC['JOB']['backupdir'].$STATIC['backupfile'],'acl' => AmazonS3::ACL_PRIVATE,'storage' => $storage,'partSize'=>26214400,'curlopts'=>$curlops));
|
27 |
+
$result=(array)$result;
|
28 |
+
if ($result["status"]=200 and $result["status"]<300) {
|
29 |
+
$WORKING['STEPTODO']=1+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
30 |
+
trigger_error(sprintf(__('Backup transferred to %s','backwpup'),$result["header"]["_info"]["url"]),E_USER_NOTICE);
|
31 |
+
$STATIC['JOB']['lastbackupdownloadurl']=$STATIC['WP']['ADMINURL'].'?page=backwpupbackups&action=downloads3&file='.$STATIC['JOB']['awsdir'].$STATIC['backupfile'].'&jobid='.$STATIC['JOB']['jobid'];
|
32 |
+
$WORKING['STEPSDONE'][]='DEST_S3'; //set done
|
33 |
+
} else {
|
34 |
+
trigger_error(sprintf(__('Can not transfer backup to S3! (%1$d) %2$s','backwpup'),$result["status"],$result["Message"]),E_USER_ERROR);
|
35 |
+
}
|
36 |
+
} else {
|
37 |
+
trigger_error(sprintf(__('S3 Bucket "%s" not exists!','backwpup'),$STATIC['JOB']['awsBucket']),E_USER_ERROR);
|
38 |
+
}
|
39 |
+
} catch (Exception $e) {
|
40 |
+
trigger_error(sprintf(__('Amazon API: %s','backwpup'),$e->getMessage()),E_USER_ERROR);
|
41 |
+
return;
|
42 |
+
}
|
43 |
+
try {
|
44 |
+
if ($s3->if_bucket_exists($STATIC['JOB']['awsBucket'])) {
|
45 |
+
if ($STATIC['JOB']['awsmaxbackups']>0) { //Delete old backups
|
46 |
+
$backupfilelist=array();
|
47 |
+
if (($contents = $s3->list_objects($STATIC['JOB']['awsBucket'],array('prefix'=>$STATIC['JOB']['awsdir']))) !== false) {
|
48 |
+
foreach ($contents->body->Contents as $object) {
|
49 |
+
$file=basename($object->Key);
|
50 |
+
if ($STATIC['JOB']['fileprefix'] == substr($file,0,strlen($STATIC['JOB']['fileprefix'])) and $STATIC['JOB']['fileformart'] == substr($file,-strlen($STATIC['JOB']['fileformart'])))
|
51 |
+
$backupfilelist[]=$file;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
if (sizeof($backupfilelist)>0) {
|
55 |
+
rsort($backupfilelist);
|
56 |
+
$numdeltefiles=0;
|
57 |
+
for ($i=$STATIC['JOB']['awsmaxbackups'];$i<sizeof($backupfilelist);$i++) {
|
58 |
+
if ($s3->delete_object($STATIC['JOB']['awsBucket'], $STATIC['JOB']['awsdir'].$backupfilelist[$i])) //delte files on S3
|
59 |
+
$numdeltefiles++;
|
60 |
+
else
|
61 |
+
trigger_error(sprintf(__('Can not delete backup on S3://%s','backwpup'),$STATIC['JOB']['awsBucket'].'/'.$STATIC['JOB']['awsdir'].$backupfilelist[$i]),E_USER_ERROR);
|
62 |
+
}
|
63 |
+
if ($numdeltefiles>0)
|
64 |
+
trigger_error(sprintf(_n('One file deleted on S3 Bucket','%d files deleted on S3 Bucket',$numdeltefiles,'backwpup'),$numdeltefiles),E_USER_NOTICE);
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
68 |
+
} catch (Exception $e) {
|
69 |
+
trigger_error(sprintf(__('Amazon API: %s','backwpup'),$e->getMessage()),E_USER_ERROR);
|
70 |
+
return;
|
71 |
+
}
|
72 |
+
|
73 |
+
$WORKING['STEPDONE']++;
|
74 |
+
}
|
|
job/dest_sugarsync.php
CHANGED
@@ -1,71 +1,70 @@
|
|
1 |
-
<?PHP
|
2 |
-
function dest_sugarsync() {
|
3 |
-
global $WORKING,$STATIC;
|
4 |
-
$WORKING['STEPTODO']=2+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
5 |
-
$WORKING['STEPDONE']=0;
|
6 |
-
trigger_error(sprintf(__('%d. try sending backup to SugarSync...','backwpup'),$WORKING['DEST_SUGARSYNC']['STEP_TRY']),E_USER_NOTICE);
|
7 |
-
|
8 |
-
require_once(realpath(dirname(__FILE__).'/../libs/sugarsync.php'));
|
9 |
-
|
10 |
-
try {
|
11 |
-
$sugarsync = new SugarSync($STATIC['JOB']['sugaruser'],base64_decode($STATIC['JOB']['sugarpass']),$STATIC['BACKWPUP']['SUGARSYNC_ACCESSKEY'], $STATIC['BACKWPUP']['SUGARSYNC_PRIVATEACCESSKEY']);
|
12 |
-
//Check Quota
|
13 |
-
$user=$sugarsync->user();
|
14 |
-
if (!empty($user->nickname)) {
|
15 |
-
trigger_error(sprintf(__('Authed to SugarSync with Nick %s','backwpup'),$user->nickname),E_USER_NOTICE);
|
16 |
-
}
|
17 |
-
$sugarsyncfreespase=(float)$user->quota->limit-(float)$user->quota->usage; //float fixes bug for display of no free space
|
18 |
-
if (filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile'])>$sugarsyncfreespase) {
|
19 |
-
trigger_error(__('No free space left on SugarSync!!!','backwpup'),E_USER_ERROR);
|
20 |
-
$WORKING['STEPTODO']=1+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
21 |
-
$WORKING['STEPSDONE'][]='DEST_SUGARSYNC'; //set done
|
22 |
-
return;
|
23 |
-
} else {
|
24 |
-
trigger_error(sprintf(__('%s free on SugarSync','backwpup'),formatBytes($sugarsyncfreespase)),E_USER_NOTICE);
|
25 |
-
}
|
26 |
-
//Create and change folder
|
27 |
-
$sugarsync->mkdir($STATIC['JOB']['sugardir'],$STATIC['JOB']['sugarroot']);
|
28 |
-
$dirid=$sugarsync->chdir($STATIC['JOB']['sugardir'],$STATIC['JOB']['sugarroot']);
|
29 |
-
//Upload to Sugarsync
|
30 |
-
$sugarsync->setProgressFunction('curl_progresscallback');
|
31 |
-
trigger_error(__('Upload to SugarSync now started... ','backwpup'),E_USER_NOTICE);
|
32 |
-
$reponse=$sugarsync->upload($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
33 |
-
if (is_object($reponse)) {
|
34 |
-
$STATIC['JOB']['lastbackupdownloadurl']=$STATIC['WP']['ADMINURL'].'?page=backwpupbackups&action=downloadsugarsync&file='.(string)$reponse.'&jobid='.$STATIC['JOB']['jobid'];
|
35 |
-
$WORKING['STEPDONE']++;
|
36 |
-
$WORKING['STEPSDONE'][]='DEST_SUGARSYNC'; //set done
|
37 |
-
trigger_error(sprintf(__('Backup transferred to %s','backwpup'),'https://'.$user->nickname.'.sugarsync.com/'.$sugarsync->showdir($dirid).$STATIC['backupfile']),E_USER_NOTICE);
|
38 |
-
} else {
|
39 |
-
trigger_error(__('Can not transfer backup to SugarSync!','backwpup'),E_USER_ERROR);
|
40 |
-
return;
|
41 |
-
}
|
42 |
-
$sugarsync->setProgressFunction('');
|
43 |
-
|
44 |
-
if ($STATIC['JOB']['sugarmaxbackups']>0) { //Delete old backups
|
45 |
-
$backupfilelist=array();
|
46 |
-
$getfiles=$sugarsync->getcontents('file');
|
47 |
-
if (is_object($getfiles)) {
|
48 |
-
foreach ($getfiles->file as $getfile) {
|
49 |
-
if ($STATIC['JOB']['fileprefix'] == substr($getfile->displayName,0,strlen($STATIC['JOB']['fileprefix'])) and $STATIC['JOB']['fileformart'] == substr($getfile->displayName,-strlen($STATIC['JOB']['fileformart'])))
|
50 |
-
$backupfilelist[]=$getfile->displayName;
|
51 |
-
$backupfileref[utf8_encode($getfile->displayName)]=$getfile->ref;
|
52 |
-
}
|
53 |
-
}
|
54 |
-
if (sizeof($backupfilelist)>0) {
|
55 |
-
rsort($backupfilelist);
|
56 |
-
$numdeltefiles=0;
|
57 |
-
for ($i=$STATIC['JOB']['sugarmaxbackups'];$i<count($backupfilelist);$i++) {
|
58 |
-
$sugarsync->delete($backupfileref[utf8_encode($backupfilelist[$i])]); //delete files on Cloud
|
59 |
-
$numdeltefiles++;
|
60 |
-
}
|
61 |
-
if ($numdeltefiles>0)
|
62 |
-
trigger_error(sprintf(_n('One file deleted on SugarSync folder','%d files deleted on SugarSync folder',$numdeltefiles,'backwpup'),$numdeltefiles),E_USER_NOTICE);
|
63 |
-
}
|
64 |
-
}
|
65 |
-
} catch (Exception $e) {
|
66 |
-
trigger_error(sprintf(__('SugarSync API: %s','backwpup'),$e->getMessage()),E_USER_ERROR);
|
67 |
-
}
|
68 |
-
|
69 |
-
$WORKING['STEPDONE']++;
|
70 |
-
}
|
71 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
function dest_sugarsync() {
|
3 |
+
global $WORKING,$STATIC;
|
4 |
+
$WORKING['STEPTODO']=2+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
5 |
+
$WORKING['STEPDONE']=0;
|
6 |
+
trigger_error(sprintf(__('%d. try sending backup to SugarSync...','backwpup'),$WORKING['DEST_SUGARSYNC']['STEP_TRY']),E_USER_NOTICE);
|
7 |
+
|
8 |
+
require_once(realpath(dirname(__FILE__).'/../libs/sugarsync.php'));
|
9 |
+
|
10 |
+
try {
|
11 |
+
$sugarsync = new SugarSync($STATIC['JOB']['sugaruser'],base64_decode($STATIC['JOB']['sugarpass']),$STATIC['BACKWPUP']['SUGARSYNC_ACCESSKEY'], $STATIC['BACKWPUP']['SUGARSYNC_PRIVATEACCESSKEY']);
|
12 |
+
//Check Quota
|
13 |
+
$user=$sugarsync->user();
|
14 |
+
if (!empty($user->nickname)) {
|
15 |
+
trigger_error(sprintf(__('Authed to SugarSync with Nick %s','backwpup'),$user->nickname),E_USER_NOTICE);
|
16 |
+
}
|
17 |
+
$sugarsyncfreespase=(float)$user->quota->limit-(float)$user->quota->usage; //float fixes bug for display of no free space
|
18 |
+
if (filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile'])>$sugarsyncfreespase) {
|
19 |
+
trigger_error(__('No free space left on SugarSync!!!','backwpup'),E_USER_ERROR);
|
20 |
+
$WORKING['STEPTODO']=1+filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
21 |
+
$WORKING['STEPSDONE'][]='DEST_SUGARSYNC'; //set done
|
22 |
+
return;
|
23 |
+
} else {
|
24 |
+
trigger_error(sprintf(__('%s free on SugarSync','backwpup'),formatBytes($sugarsyncfreespase)),E_USER_NOTICE);
|
25 |
+
}
|
26 |
+
//Create and change folder
|
27 |
+
$sugarsync->mkdir($STATIC['JOB']['sugardir'],$STATIC['JOB']['sugarroot']);
|
28 |
+
$dirid=$sugarsync->chdir($STATIC['JOB']['sugardir'],$STATIC['JOB']['sugarroot']);
|
29 |
+
//Upload to Sugarsync
|
30 |
+
$sugarsync->setProgressFunction('curl_progresscallback');
|
31 |
+
trigger_error(__('Upload to SugarSync now started... ','backwpup'),E_USER_NOTICE);
|
32 |
+
$reponse=$sugarsync->upload($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
|
33 |
+
if (is_object($reponse)) {
|
34 |
+
$STATIC['JOB']['lastbackupdownloadurl']=$STATIC['WP']['ADMINURL'].'?page=backwpupbackups&action=downloadsugarsync&file='.(string)$reponse.'&jobid='.$STATIC['JOB']['jobid'];
|
35 |
+
$WORKING['STEPDONE']++;
|
36 |
+
$WORKING['STEPSDONE'][]='DEST_SUGARSYNC'; //set done
|
37 |
+
trigger_error(sprintf(__('Backup transferred to %s','backwpup'),'https://'.$user->nickname.'.sugarsync.com/'.$sugarsync->showdir($dirid).$STATIC['backupfile']),E_USER_NOTICE);
|
38 |
+
} else {
|
39 |
+
trigger_error(__('Can not transfer backup to SugarSync!','backwpup'),E_USER_ERROR);
|
40 |
+
return;
|
41 |
+
}
|
42 |
+
$sugarsync->setProgressFunction('');
|
43 |
+
|
44 |
+
if ($STATIC['JOB']['sugarmaxbackups']>0) { //Delete old backups
|
45 |
+
$backupfilelist=array();
|
46 |
+
$getfiles=$sugarsync->getcontents('file');
|
47 |
+
if (is_object($getfiles)) {
|
48 |
+
foreach ($getfiles->file as $getfile) {
|
49 |
+
if ($STATIC['JOB']['fileprefix'] == substr($getfile->displayName,0,strlen($STATIC['JOB']['fileprefix'])) and $STATIC['JOB']['fileformart'] == substr($getfile->displayName,-strlen($STATIC['JOB']['fileformart'])))
|
50 |
+
$backupfilelist[]=$getfile->displayName;
|
51 |
+
$backupfileref[utf8_encode($getfile->displayName)]=$getfile->ref;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
if (sizeof($backupfilelist)>0) {
|
55 |
+
rsort($backupfilelist);
|
56 |
+
$numdeltefiles=0;
|
57 |
+
for ($i=$STATIC['JOB']['sugarmaxbackups'];$i<count($backupfilelist);$i++) {
|
58 |
+
$sugarsync->delete($backupfileref[utf8_encode($backupfilelist[$i])]); //delete files on Cloud
|
59 |
+
$numdeltefiles++;
|
60 |
+
}
|
61 |
+
if ($numdeltefiles>0)
|
62 |
+
trigger_error(sprintf(_n('One file deleted on SugarSync folder','%d files deleted on SugarSync folder',$numdeltefiles,'backwpup'),$numdeltefiles),E_USER_NOTICE);
|
63 |
+
}
|
64 |
+
}
|
65 |
+
} catch (Exception $e) {
|
66 |
+
trigger_error(sprintf(__('SugarSync API: %s','backwpup'),$e->getMessage()),E_USER_ERROR);
|
67 |
+
}
|
68 |
+
|
69 |
+
$WORKING['STEPDONE']++;
|
70 |
+
}
|
|
job/file_list.php
CHANGED
@@ -1,135 +1,133 @@
|
|
1 |
-
<?PHP
|
2 |
-
function file_list() {
|
3 |
-
global $WORKING,$STATIC,$tempfilelist;
|
4 |
-
//Make filelist
|
5 |
-
trigger_error(sprintf(__('%d. try for make list of files to backup....','backwpup'),$WORKING['FILE_LIST']['STEP_TRY']),E_USER_NOTICE);
|
6 |
-
$WORKING['STEPTODO']=2;
|
7 |
-
|
8 |
-
//Check free memory for file list
|
9 |
-
need_free_memory('10MB'); //10MB free memory for filelist
|
10 |
-
//empty filelist
|
11 |
-
$tempfilelist=array();
|
12 |
-
//exlude of job
|
13 |
-
$WORKING['FILEEXCLUDES']=explode(',',trim($STATIC['JOB']['fileexclude']));
|
14 |
-
$WORKING['FILEEXCLUDES'][]='.tmp'; //do not backup .tmp files
|
15 |
-
$WORKING['FILEEXCLUDES']=array_unique($WORKING['FILEEXCLUDES']);
|
16 |
-
|
17 |
-
//File list for blog folders
|
18 |
-
if ($STATIC['JOB']['backuproot'])
|
19 |
-
_file_list($STATIC['WP']['ABSPATH'],100,array_merge($STATIC['JOB']['backuprootexcludedirs'],_get_exclude_dirs($STATIC['WP']['ABSPATH'])));
|
20 |
-
if ($STATIC['JOB']['backupcontent'])
|
21 |
-
_file_list($STATIC['WP']['WP_CONTENT_DIR'],100,array_merge($STATIC['JOB']['backupcontentexcludedirs'],_get_exclude_dirs($STATIC['WP']['WP_CONTENT_DIR'])));
|
22 |
-
if ($STATIC['JOB']['backupplugins'])
|
23 |
-
_file_list($STATIC['WP']['WP_PLUGIN_DIR'],100,array_merge($STATIC['JOB']['backuppluginsexcludedirs'],_get_exclude_dirs($STATIC['WP']['WP_PLUGIN_DIR'])));
|
24 |
-
if ($STATIC['JOB']['backupthemes'])
|
25 |
-
_file_list($STATIC['WP']['WP_THEMES_DIR'],100,array_merge($STATIC['JOB']['backupthemesexcludedirs'],_get_exclude_dirs($STATIC['WP']['WP_THEMES_DIR'])));
|
26 |
-
if ($STATIC['JOB']['backupuploads'])
|
27 |
-
_file_list($STATIC['WP']['WP_UPLOAD_DIR'],100,array_merge($STATIC['JOB']['backupuploadsexcludedirs'],_get_exclude_dirs($STATIC['WP']['WP_UPLOAD_DIR'])));
|
28 |
-
|
29 |
-
//include dirs
|
30 |
-
if (!empty($STATIC['JOB']['dirinclude'])) {
|
31 |
-
$dirinclude=explode(',',$STATIC['JOB']['dirinclude']);
|
32 |
-
$dirinclude=array_unique($dirinclude);
|
33 |
-
//Crate file list for includes
|
34 |
-
foreach($dirinclude as $dirincludevalue) {
|
35 |
-
if (is_dir($dirincludevalue))
|
36 |
-
_file_list($dirincludevalue,100);
|
37 |
-
}
|
38 |
-
}
|
39 |
-
$tempfilelist=array_unique($tempfilelist); //all files only one time in list
|
40 |
-
sort($tempfilelist);
|
41 |
-
$WORKING['STEPDONE']=1; //Step done
|
42 |
-
update_working_file();
|
43 |
-
|
44 |
-
//Check abs path
|
45 |
-
if ($STATIC['WP']['ABSPATH']=='/' or $STATIC['WP']['ABSPATH']=='')
|
46 |
-
$removepath='';
|
47 |
-
else
|
48 |
-
$removepath=$STATIC['WP']['ABSPATH'];
|
49 |
-
//make file list
|
50 |
-
$filelist=array();
|
51 |
-
for ($i=0; $i<count($tempfilelist); $i++) {
|
52 |
-
$filestat=stat($tempfilelist[$i]);
|
53 |
-
$WORKING['ALLFILESIZE']+=$filestat['size'];
|
54 |
-
$outfile=str_replace($removepath,'',$tempfilelist[$i]);
|
55 |
-
if (substr($outfile,0,1)=='/') //remove first /
|
56 |
-
$outfile=substr($outfile,1);
|
57 |
-
$filelist[]=array('FILE'=>$tempfilelist[$i],'OUTFILE'=>$outfile,'SIZE'=>$filestat['size'],'ATIME'=>$filestat['atime'],'MTIME'=>$filestat['mtime'],'CTIME'=>$filestat['ctime'],'UID'=>$filestat['uid'],'GID'=>$filestat['gid'],'MODE'=>$filestat['mode']);
|
58 |
-
}
|
59 |
-
add_file($filelist); //add files to list
|
60 |
-
$WORKING['STEPDONE']=2;
|
61 |
-
$WORKING['STEPSDONE'][]='FILE_LIST'; //set done
|
62 |
-
unset($tempfilelist);
|
63 |
-
|
64 |
-
$filelist=get_filelist(); //get files from list
|
65 |
-
if (!is_array($filelist[0])) {
|
66 |
-
trigger_error(__('No files to backup','backwpup'),E_USER_ERROR);
|
67 |
-
} else {
|
68 |
-
trigger_error(sprintf(__('%1$d files with %2$s to backup','backwpup'),count($filelist),formatBytes($WORKING['ALLFILESIZE'])),E_USER_NOTICE);
|
69 |
-
}
|
70 |
-
}
|
71 |
-
|
72 |
-
function _file_list( $folder = '', $levels = 100, $excludedirs=array()) {
|
73 |
-
global $WORKING,$tempfilelist;
|
74 |
-
if( empty($folder) )
|
75 |
-
return false;
|
76 |
-
if( ! $levels )
|
77 |
-
return false;
|
78 |
-
if ($levels == 100 or $levels == 95)
|
79 |
-
update_working_file();
|
80 |
-
$folder=rtrim($folder,'/').'/';
|
81 |
-
if ( $dir = @opendir( $folder ) ) {
|
82 |
-
while (($file = readdir( $dir ) ) !== false ) {
|
83 |
-
if ( in_array($file, array('.', '..','.svn') ) )
|
84 |
-
continue;
|
85 |
-
foreach ($WORKING['FILEEXCLUDES'] as $exclusion) { //exclude dirs and files
|
86 |
-
$exclusion=trim($exclusion);
|
87 |
-
if (false !== stripos($folder.$file,$exclusion) and !empty($exclusion) and $exclusion!='/')
|
88 |
-
continue 2;
|
89 |
-
}
|
90 |
-
if (in_array(rtrim($folder.$file,'/').'/',$excludedirs) and is_dir( $folder.$file ))
|
91 |
-
continue;
|
92 |
-
if ( !is_readable($folder.$file)) {
|
93 |
-
trigger_error(sprintf(__('File or folder "%s" is not readable!','backwpup'),$folder.$file),E_USER_WARNING);
|
94 |
-
} elseif ( is_link($folder.$file) ) {
|
95 |
-
trigger_error(sprintf(__('Link "%s" not followed','backwpup'),$folder.$file),E_USER_WARNING);
|
96 |
-
} elseif ( is_dir( $folder.$file )) {
|
97 |
-
_file_list( rtrim($folder.$file,'/'), $levels - 1,$excludedirs);
|
98 |
-
} elseif ( is_file( $folder.$file ) or is_executable($folder.$file)) { //add file to filelist
|
99 |
-
$tempfilelist[]=$folder.$file;
|
100 |
-
} else {
|
101 |
-
trigger_error(sprintf(__('"%s" is not a file or directory','backwpup'),$folder.$file),E_USER_WARNING);
|
102 |
-
}
|
103 |
-
|
104 |
-
}
|
105 |
-
@closedir( $dir );
|
106 |
-
}
|
107 |
-
}
|
108 |
-
|
109 |
-
function _get_exclude_dirs($folder) {
|
110 |
-
global $WORKING,$STATIC;
|
111 |
-
$excludedir=array();
|
112 |
-
$excludedir[]=$STATIC['TEMPDIR']; //exclude temp dir
|
113 |
-
$excludedir[]=$STATIC['CFG']['dirlogs'];
|
114 |
-
if (false !== strpos($STATIC['WP']['ABSPATH'],$folder) and $STATIC['WP']['ABSPATH']!=$folder)
|
115 |
-
$excludedir[]=$STATIC['WP']['ABSPATH'];
|
116 |
-
if (false !== strpos($STATIC['WP']['WP_CONTENT_DIR'],$folder) and $STATIC['WP']['WP_CONTENT_DIR']!=$folder)
|
117 |
-
$excludedir[]=$STATIC['WP']['WP_CONTENT_DIR'];
|
118 |
-
if (false !== strpos($STATIC['WP']['WP_PLUGIN_DIR'],$folder) and $STATIC['WP']['WP_PLUGIN_DIR']!=$folder)
|
119 |
-
$excludedir[]=$STATIC['WP']['WP_PLUGIN_DIR'];
|
120 |
-
if (false !== strpos($STATIC['WP']['WP_THEMES_DIR'],$folder) and $STATIC['WP']['WP_THEMES_DIR']!=$folder)
|
121 |
-
$excludedir[]=$STATIC['WP']['WP_THEMES_DIR'];
|
122 |
-
if (false !== strpos($STATIC['WP']['WP_UPLOAD_DIR'],$folder) and $STATIC['WP']['WP_UPLOAD_DIR']!=$folder)
|
123 |
-
$excludedir[]=$STATIC['WP']['WP_UPLOAD_DIR'];
|
124 |
-
//Exclude Backup dirs
|
125 |
-
$jobs=get_option('backwpup_jobs');
|
126 |
-
if (!empty($jobs)) {
|
127 |
-
foreach($jobs as $jobsvalue) {
|
128 |
-
if (!empty($jobsvalue['backupdir']) and $jobsvalue['backupdir']!='/')
|
129 |
-
$excludedir[]=$jobsvalue['backupdir'];
|
130 |
-
}
|
131 |
-
}
|
132 |
-
return $excludedir;
|
133 |
-
}
|
134 |
-
|
135 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
function file_list() {
|
3 |
+
global $WORKING,$STATIC,$tempfilelist;
|
4 |
+
//Make filelist
|
5 |
+
trigger_error(sprintf(__('%d. try for make list of files to backup....','backwpup'),$WORKING['FILE_LIST']['STEP_TRY']),E_USER_NOTICE);
|
6 |
+
$WORKING['STEPTODO']=2;
|
7 |
+
|
8 |
+
//Check free memory for file list
|
9 |
+
need_free_memory('10MB'); //10MB free memory for filelist
|
10 |
+
//empty filelist
|
11 |
+
$tempfilelist=array();
|
12 |
+
//exlude of job
|
13 |
+
$WORKING['FILEEXCLUDES']=explode(',',trim($STATIC['JOB']['fileexclude']));
|
14 |
+
$WORKING['FILEEXCLUDES'][]='.tmp'; //do not backup .tmp files
|
15 |
+
$WORKING['FILEEXCLUDES']=array_unique($WORKING['FILEEXCLUDES']);
|
16 |
+
|
17 |
+
//File list for blog folders
|
18 |
+
if ($STATIC['JOB']['backuproot'])
|
19 |
+
_file_list($STATIC['WP']['ABSPATH'],100,array_merge($STATIC['JOB']['backuprootexcludedirs'],_get_exclude_dirs($STATIC['WP']['ABSPATH'])));
|
20 |
+
if ($STATIC['JOB']['backupcontent'])
|
21 |
+
_file_list($STATIC['WP']['WP_CONTENT_DIR'],100,array_merge($STATIC['JOB']['backupcontentexcludedirs'],_get_exclude_dirs($STATIC['WP']['WP_CONTENT_DIR'])));
|
22 |
+
if ($STATIC['JOB']['backupplugins'])
|
23 |
+
_file_list($STATIC['WP']['WP_PLUGIN_DIR'],100,array_merge($STATIC['JOB']['backuppluginsexcludedirs'],_get_exclude_dirs($STATIC['WP']['WP_PLUGIN_DIR'])));
|
24 |
+
if ($STATIC['JOB']['backupthemes'])
|
25 |
+
_file_list($STATIC['WP']['WP_THEMES_DIR'],100,array_merge($STATIC['JOB']['backupthemesexcludedirs'],_get_exclude_dirs($STATIC['WP']['WP_THEMES_DIR'])));
|
26 |
+
if ($STATIC['JOB']['backupuploads'])
|
27 |
+
_file_list($STATIC['WP']['WP_UPLOAD_DIR'],100,array_merge($STATIC['JOB']['backupuploadsexcludedirs'],_get_exclude_dirs($STATIC['WP']['WP_UPLOAD_DIR'])));
|
28 |
+
|
29 |
+
//include dirs
|
30 |
+
if (!empty($STATIC['JOB']['dirinclude'])) {
|
31 |
+
$dirinclude=explode(',',$STATIC['JOB']['dirinclude']);
|
32 |
+
$dirinclude=array_unique($dirinclude);
|
33 |
+
//Crate file list for includes
|
34 |
+
foreach($dirinclude as $dirincludevalue) {
|
35 |
+
if (is_dir($dirincludevalue))
|
36 |
+
_file_list($dirincludevalue,100);
|
37 |
+
}
|
38 |
+
}
|
39 |
+
$tempfilelist=array_unique($tempfilelist); //all files only one time in list
|
40 |
+
sort($tempfilelist);
|
41 |
+
$WORKING['STEPDONE']=1; //Step done
|
42 |
+
update_working_file();
|
43 |
+
|
44 |
+
//Check abs path
|
45 |
+
if ($STATIC['WP']['ABSPATH']=='/' or $STATIC['WP']['ABSPATH']=='')
|
46 |
+
$removepath='';
|
47 |
+
else
|
48 |
+
$removepath=$STATIC['WP']['ABSPATH'];
|
49 |
+
//make file list
|
50 |
+
$filelist=array();
|
51 |
+
for ($i=0; $i<count($tempfilelist); $i++) {
|
52 |
+
$filestat=stat($tempfilelist[$i]);
|
53 |
+
$WORKING['ALLFILESIZE']+=$filestat['size'];
|
54 |
+
$outfile=str_replace($removepath,'',$tempfilelist[$i]);
|
55 |
+
if (substr($outfile,0,1)=='/') //remove first /
|
56 |
+
$outfile=substr($outfile,1);
|
57 |
+
$filelist[]=array('FILE'=>$tempfilelist[$i],'OUTFILE'=>$outfile,'SIZE'=>$filestat['size'],'ATIME'=>$filestat['atime'],'MTIME'=>$filestat['mtime'],'CTIME'=>$filestat['ctime'],'UID'=>$filestat['uid'],'GID'=>$filestat['gid'],'MODE'=>$filestat['mode']);
|
58 |
+
}
|
59 |
+
add_file($filelist); //add files to list
|
60 |
+
$WORKING['STEPDONE']=2;
|
61 |
+
$WORKING['STEPSDONE'][]='FILE_LIST'; //set done
|
62 |
+
unset($tempfilelist);
|
63 |
+
|
64 |
+
$filelist=get_filelist(); //get files from list
|
65 |
+
if (!is_array($filelist[0])) {
|
66 |
+
trigger_error(__('No files to backup','backwpup'),E_USER_ERROR);
|
67 |
+
} else {
|
68 |
+
trigger_error(sprintf(__('%1$d files with %2$s to backup','backwpup'),count($filelist),formatBytes($WORKING['ALLFILESIZE'])),E_USER_NOTICE);
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
function _file_list( $folder = '', $levels = 100, $excludedirs=array()) {
|
73 |
+
global $WORKING,$tempfilelist;
|
74 |
+
if( empty($folder) )
|
75 |
+
return false;
|
76 |
+
if( ! $levels )
|
77 |
+
return false;
|
78 |
+
if ($levels == 100 or $levels == 95)
|
79 |
+
update_working_file();
|
80 |
+
$folder=rtrim($folder,'/').'/';
|
81 |
+
if ( $dir = @opendir( $folder ) ) {
|
82 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
83 |
+
if ( in_array($file, array('.', '..','.svn') ) )
|
84 |
+
continue;
|
85 |
+
foreach ($WORKING['FILEEXCLUDES'] as $exclusion) { //exclude dirs and files
|
86 |
+
$exclusion=trim($exclusion);
|
87 |
+
if (false !== stripos($folder.$file,$exclusion) and !empty($exclusion) and $exclusion!='/')
|
88 |
+
continue 2;
|
89 |
+
}
|
90 |
+
if (in_array(rtrim($folder.$file,'/').'/',$excludedirs) and is_dir( $folder.$file ))
|
91 |
+
continue;
|
92 |
+
if ( !is_readable($folder.$file)) {
|
93 |
+
trigger_error(sprintf(__('File or folder "%s" is not readable!','backwpup'),$folder.$file),E_USER_WARNING);
|
94 |
+
} elseif ( is_link($folder.$file) ) {
|
95 |
+
trigger_error(sprintf(__('Link "%s" not followed','backwpup'),$folder.$file),E_USER_WARNING);
|
96 |
+
} elseif ( is_dir( $folder.$file )) {
|
97 |
+
_file_list( rtrim($folder.$file,'/'), $levels - 1,$excludedirs);
|
98 |
+
} elseif ( is_file( $folder.$file ) or is_executable($folder.$file)) { //add file to filelist
|
99 |
+
$tempfilelist[]=$folder.$file;
|
100 |
+
} else {
|
101 |
+
trigger_error(sprintf(__('"%s" is not a file or directory','backwpup'),$folder.$file),E_USER_WARNING);
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
105 |
+
@closedir( $dir );
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
function _get_exclude_dirs($folder) {
|
110 |
+
global $WORKING,$STATIC;
|
111 |
+
$excludedir=array();
|
112 |
+
$excludedir[]=$STATIC['TEMPDIR']; //exclude temp dir
|
113 |
+
$excludedir[]=$STATIC['CFG']['dirlogs'];
|
114 |
+
if (false !== strpos($STATIC['WP']['ABSPATH'],$folder) and $STATIC['WP']['ABSPATH']!=$folder)
|
115 |
+
$excludedir[]=$STATIC['WP']['ABSPATH'];
|
116 |
+
if (false !== strpos($STATIC['WP']['WP_CONTENT_DIR'],$folder) and $STATIC['WP']['WP_CONTENT_DIR']!=$folder)
|
117 |
+
$excludedir[]=$STATIC['WP']['WP_CONTENT_DIR'];
|
118 |
+
if (false !== strpos($STATIC['WP']['WP_PLUGIN_DIR'],$folder) and $STATIC['WP']['WP_PLUGIN_DIR']!=$folder)
|
119 |
+
$excludedir[]=$STATIC['WP']['WP_PLUGIN_DIR'];
|
120 |
+
if (false !== strpos($STATIC['WP']['WP_THEMES_DIR'],$folder) and $STATIC['WP']['WP_THEMES_DIR']!=$folder)
|
121 |
+
$excludedir[]=$STATIC['WP']['WP_THEMES_DIR'];
|
122 |
+
if (false !== strpos($STATIC['WP']['WP_UPLOAD_DIR'],$folder) and $STATIC['WP']['WP_UPLOAD_DIR']!=$folder)
|
123 |
+
$excludedir[]=$STATIC['WP']['WP_UPLOAD_DIR'];
|
124 |
+
//Exclude Backup dirs
|
125 |
+
$jobs=get_option('backwpup_jobs');
|
126 |
+
if (!empty($jobs)) {
|
127 |
+
foreach($jobs as $jobsvalue) {
|
128 |
+
if (!empty($jobsvalue['backupdir']) and $jobsvalue['backupdir']!='/')
|
129 |
+
$excludedir[]=$jobsvalue['backupdir'];
|
130 |
+
}
|
131 |
+
}
|
132 |
+
return $excludedir;
|
133 |
+
}
|
|
|
|
job/job_functions.php
CHANGED
@@ -1,577 +1,576 @@
|
|
1 |
-
<?PHP
|
2 |
-
function __($message,$domain='backwpup') {
|
3 |
-
global $TRANSLATE;
|
4 |
-
return $TRANSLATE->translate($message);
|
5 |
-
}
|
6 |
-
|
7 |
-
function _e($message,$domain='backwpup') {
|
8 |
-
global $TRANSLATE;
|
9 |
-
echo $TRANSLATE->translate($message);
|
10 |
-
}
|
11 |
-
|
12 |
-
function _n($single, $plural, $number,$domain='backwpup') {
|
13 |
-
global $TRANSLATE;
|
14 |
-
return $TRANSLATE->translate_plural($single,$plural,$number);
|
15 |
-
}
|
16 |
-
|
17 |
-
function exists_option($option='backwpup_jobs') {
|
18 |
-
global $WORKING,$STATIC;
|
19 |
-
mysql_update();
|
20 |
-
$query="SELECT option_value as value FROM ".$STATIC['WP']['OPTIONS_TABLE']." WHERE option_name='".trim($option)."' LIMIT 1";
|
21 |
-
$res=mysql_query($query);
|
22 |
-
if (!$res or mysql_num_rows($res)<1) {
|
23 |
-
return false;
|
24 |
-
}
|
25 |
-
return true;
|
26 |
-
}
|
27 |
-
|
28 |
-
function get_option($option='backwpup_jobs') {
|
29 |
-
global $WORKING,$STATIC;
|
30 |
-
mysql_update();
|
31 |
-
$query="SELECT option_value FROM ".$STATIC['WP']['OPTIONS_TABLE']." WHERE option_name='".trim($option)."' LIMIT 1";
|
32 |
-
$res=mysql_query($query);
|
33 |
-
if (!$res) {
|
34 |
-
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), $query),E_USER_ERROR);
|
35 |
-
return false;
|
36 |
-
}
|
37 |
-
return unserialize(mysql_result($res,0));
|
38 |
-
}
|
39 |
-
|
40 |
-
function update_option($option='backwpup_jobs',$data) {
|
41 |
-
global $WORKING,$STATIC;
|
42 |
-
mysql_update();
|
43 |
-
$serdata=mysql_real_escape_string(serialize($data));
|
44 |
-
$query="UPDATE ".$STATIC['WP']['OPTIONS_TABLE']." SET option_value= '".$serdata."' WHERE option_name='".trim($option)."' LIMIT 1";
|
45 |
-
$res=mysql_query($query);
|
46 |
-
if (!$res) {
|
47 |
-
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), $query),E_USER_ERROR);
|
48 |
-
return false;
|
49 |
-
}
|
50 |
-
return true;
|
51 |
-
}
|
52 |
-
|
53 |
-
// add to file list
|
54 |
-
function add_file($files) {
|
55 |
-
global $STATIC;
|
56 |
-
if (empty($files))
|
57 |
-
return;
|
58 |
-
$filelist=get_filelist();
|
59 |
-
foreach($files as $file)
|
60 |
-
$filelist[]=$file;
|
61 |
-
file_put_contents($STATIC['TEMPDIR'].'.filelist',serialize($filelist));
|
62 |
-
}
|
63 |
-
|
64 |
-
// get file list
|
65 |
-
function get_filelist() {
|
66 |
-
global $STATIC;
|
67 |
-
if (is_file($STATIC['TEMPDIR'].'.filelist') and $filelistfile=file_get_contents($STATIC['TEMPDIR'].'.filelist'))
|
68 |
-
return unserialize(trim($filelistfile));
|
69 |
-
else
|
70 |
-
return array();
|
71 |
-
}
|
72 |
-
|
73 |
-
//file size
|
74 |
-
function formatbytes($bytes, $precision = 2) {
|
75 |
-
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
|
76 |
-
$bytes = max($bytes, 0);
|
77 |
-
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
78 |
-
$pow = min($pow, count($units) - 1);
|
79 |
-
$bytes /= pow(1024, $pow);
|
80 |
-
return round($bytes, $precision) . ' ' . $units[$pow];
|
81 |
-
}
|
82 |
-
|
83 |
-
|
84 |
-
function inbytes($value) {
|
85 |
-
$multi=strtoupper(substr(trim($value),-1));
|
86 |
-
$bytes=abs(intval(trim($value)));
|
87 |
-
if ($multi=='G')
|
88 |
-
$bytes=$bytes*1024*1024*1024;
|
89 |
-
if ($multi=='M')
|
90 |
-
$bytes=$bytes*1024*1024;
|
91 |
-
if ($multi=='K')
|
92 |
-
$bytes=$bytes*1024;
|
93 |
-
return $bytes;
|
94 |
-
}
|
95 |
-
|
96 |
-
function need_free_memory($memneed) {
|
97 |
-
if (!function_exists('memory_get_usage'))
|
98 |
-
return;
|
99 |
-
//need memory
|
100 |
-
$needmemory=@memory_get_usage(true)+inbytes($memneed);
|
101 |
-
// increase Memory
|
102 |
-
if ($needmemory>inbytes(ini_get('memory_limit'))) {
|
103 |
-
$newmemory=round($needmemory/1024/1024)+1 .'M';
|
104 |
-
if ($needmemory>=1073741824)
|
105 |
-
$newmemory=round($needmemory/1024/1024/1024) .'G';
|
106 |
-
if ($oldmem=@ini_set('memory_limit', $newmemory))
|
107 |
-
trigger_error(sprintf(__('Memory increased from %1$s to %2$s','backwpup'),$oldmem,@ini_get('memory_limit')),E_USER_NOTICE);
|
108 |
-
else
|
109 |
-
trigger_error(sprintf(__('Can not increase memory limit is %1$s','backwpup'),@ini_get('memory_limit')),E_USER_WARNING);
|
110 |
-
}
|
111 |
-
}
|
112 |
-
|
113 |
-
function maintenance_mode($enable = false) {
|
114 |
-
global $WORKING,$STATIC;
|
115 |
-
if (!$STATIC['JOB']['maintenance'])
|
116 |
-
return;
|
117 |
-
if ( $enable ) {
|
118 |
-
trigger_error(__('Set Blog to maintenance mode','backwpup'),E_USER_NOTICE);
|
119 |
-
if ( exists_option('wp-maintenance-mode-msqld') ) { //Support for WP Maintenance Mode Plugin
|
120 |
-
update_option('wp-maintenance-mode-msqld','1');
|
121 |
-
} elseif ( exists_option('plugin_maintenance-mode') ) { //Support for Maintenance Mode Plugin
|
122 |
-
$mamo=get_option('plugin_maintenance-mode');
|
123 |
-
$mamo['mamo_activate']='on_'.time();
|
124 |
-
$mamo['mamo_backtime_days']='0';
|
125 |
-
$mamo['mamo_backtime_hours']='0';
|
126 |
-
$mamo['mamo_backtime_mins']='5';
|
127 |
-
update_option('plugin_maintenance-mode',$mamo);
|
128 |
-
} else { //WP Support
|
129 |
-
if (is_writable(rtrim($STATIC['WP']['ABSPATH'],'/')))
|
130 |
-
file_put_contents(rtrim($STATIC['WP']['ABSPATH'],'/').'/.maintenance','<?php $upgrading = '.time().'; ?>');
|
131 |
-
else
|
132 |
-
trigger_error(__('Cannot set Blog to maintenance mode! Root folder is not writeable!','backwpup'),E_USER_NOTICE);
|
133 |
-
}
|
134 |
-
} else {
|
135 |
-
trigger_error(__('Set Blog to normal mode','backwpup'),E_USER_NOTICE);
|
136 |
-
if ( exists_option('wp-maintenance-mode-msqld') ) { //Support for WP Maintenance Mode Plugin
|
137 |
-
update_option('wp-maintenance-mode-msqld','0');
|
138 |
-
} elseif ( exists_option('plugin_maintenance-mode') ) { //Support for Maintenance Mode Plugin
|
139 |
-
$mamo=get_option('plugin_maintenance-mode');
|
140 |
-
$mamo['mamo_activate']='off';
|
141 |
-
update_option('plugin_maintenance-mode',$mamo);
|
142 |
-
} else { //WP Support
|
143 |
-
@unlink(rtrim($STATIC['WP']['ABSPATH'],'/').'/.maintenance');
|
144 |
-
}
|
145 |
-
}
|
146 |
-
}
|
147 |
-
|
148 |
-
function curl_progresscallback($download_size, $downloaded, $upload_size, $uploaded) {
|
149 |
-
global $WORKING,$STATIC;
|
150 |
-
if ($WORKING['STEPTODO']>10)
|
151 |
-
$WORKING['STEPDONE']=$uploaded;
|
152 |
-
update_working_file();
|
153 |
-
return(0);
|
154 |
-
}
|
155 |
-
|
156 |
-
function get_working_file() {
|
157 |
-
global $STATIC;
|
158 |
-
if (is_writable($STATIC['TEMPDIR'].'.running')) {
|
159 |
-
if ($runningfile=file_get_contents($STATIC['TEMPDIR'].'.running'))
|
160 |
-
return unserialize(trim($runningfile));
|
161 |
-
else
|
162 |
-
return false;
|
163 |
-
} else {
|
164 |
-
return false;
|
165 |
-
}
|
166 |
-
}
|
167 |
-
|
168 |
-
function delete_working_file() {
|
169 |
-
global $STATIC;
|
170 |
-
if (is_writable($STATIC['TEMPDIR'].'.running')) {
|
171 |
-
unlink($STATIC['TEMPDIR'].'.running');
|
172 |
-
unlink($STATIC['TEMPDIR'].'.static');
|
173 |
-
return true;
|
174 |
-
} else {
|
175 |
-
return false;
|
176 |
-
}
|
177 |
-
}
|
178 |
-
|
179 |
-
function update_working_file($mustwrite=false) {
|
180 |
-
global $WORKING,$STATIC,$runmicrotime;
|
181 |
-
if (!is_file($STATIC['TEMPDIR'].'.running')) {
|
182 |
-
job_end();
|
183 |
-
return false;
|
184 |
-
}
|
185 |
-
if ($mustwrite or empty($runmicrotime) or $runmicrotime<(microtime()-1000)) { //only update all 1 sec.
|
186 |
-
if ($WORKING['STEPTODO']>0 and $WORKING['STEPDONE']>0)
|
187 |
-
$steppersent=round($WORKING['STEPDONE']/$WORKING['STEPTODO']*100);
|
188 |
-
else
|
189 |
-
$steppersent=1;
|
190 |
-
if (count($WORKING['STEPSDONE'])>0)
|
191 |
-
$stepspersent=round(count($WORKING['STEPSDONE'])/count($WORKING['STEPS'])*100);
|
192 |
-
else
|
193 |
-
$stepspersent=1;
|
194 |
-
@set_time_limit(0);
|
195 |
-
$runningfile=file_get_contents($STATIC['TEMPDIR'].'.running');
|
196 |
-
$infile=unserialize(trim($runningfile));
|
197 |
-
if (is_writable($STATIC['TEMPDIR'].'.running')) {
|
198 |
-
file_put_contents($STATIC['TEMPDIR'].'.running',serialize(array('timestamp'=>time(),'JOBID'=>$STATIC['JOB']['jobid'],'LOGFILE'=>$STATIC['LOGFILE'],'STEPSPERSENT'=>$stepspersent,'STEPPERSENT'=>$steppersent,'ABSPATH'=>$STATIC['WP']['ABSPATH'],'WORKING'=>$WORKING)));
|
199 |
-
$runmicrotime=microtime();
|
200 |
-
}
|
201 |
-
}
|
202 |
-
return true;
|
203 |
-
}
|
204 |
-
|
205 |
-
function mysql_update() {
|
206 |
-
global $WORKING,$STATIC,$mysqlconlink;
|
207 |
-
if (!$mysqlconlink or !@mysql_ping($mysqlconlink)) {
|
208 |
-
// make a mysql connection
|
209 |
-
$mysqlconlink=mysql_connect($STATIC['WP']['DB_HOST'], $STATIC['WP']['DB_USER'], $STATIC['WP']['DB_PASSWORD'], true);
|
210 |
-
if (!$mysqlconlink)
|
211 |
-
trigger_error(sprintf(__('No MySQL connection: %s','backwpup'),mysql_error()),E_USER_ERROR);
|
212 |
-
//set connecten charset
|
213 |
-
if (!empty($STATIC['WP']['DB_CHARSET'])) {
|
214 |
-
if ( function_exists( 'mysql_set_charset' )) {
|
215 |
-
mysql_set_charset( $STATIC['WP']['DB_CHARSET'], $mysqlconlink );
|
216 |
-
} else {
|
217 |
-
$query = "SET NAMES '".$STATIC['WP']['DB_CHARSET']."'";
|
218 |
-
if (!empty($collate))
|
219 |
-
$query .= " COLLATE '".$STATIC['WP']['DB_COLLATE']."'";
|
220 |
-
mysql_query($query,$mysqlconlink);
|
221 |
-
}
|
222 |
-
}
|
223 |
-
//connect to database
|
224 |
-
$mysqldblink = mysql_select_db($STATIC['WP']['DB_NAME'], $mysqlconlink);
|
225 |
-
if (!$mysqldblink)
|
226 |
-
trigger_error(sprintf(__('No MySQL connection to database: %s','backwpup'),mysql_error()),E_USER_ERROR);
|
227 |
-
}
|
228 |
-
}
|
229 |
-
|
230 |
-
//function for PHP error handling
|
231 |
-
function joberrorhandler() {
|
232 |
-
global $WORKING,$STATIC;
|
233 |
-
$args = func_get_args(); // 0:errno, 1:errstr, 2:errfile, 3:errline
|
234 |
-
|
235 |
-
// if error has been supressed with an @
|
236 |
-
if (error_reporting()==0)
|
237 |
-
return;
|
238 |
-
|
239 |
-
$adderrorwarning=false;
|
240 |
-
|
241 |
-
switch ($args[0]) {
|
242 |
-
case E_NOTICE:
|
243 |
-
case E_USER_NOTICE:
|
244 |
-
$message="<span>".$args[1]."</span>";
|
245 |
-
break;
|
246 |
-
case E_WARNING:
|
247 |
-
case E_USER_WARNING:
|
248 |
-
$WORKING['WARNING']++;
|
249 |
-
$adderrorwarning=true;
|
250 |
-
$message="<span class=\"warning\">".__('[WARNING]','backwpup')." ".$args[1]."</span>";
|
251 |
-
break;
|
252 |
-
case E_ERROR:
|
253 |
-
case E_USER_ERROR:
|
254 |
-
$WORKING['ERROR']++;
|
255 |
-
$adderrorwarning=true;
|
256 |
-
$message="<span class=\"error\">".__('[ERROR]','backwpup')." ".$args[1]."</span>";
|
257 |
-
break;
|
258 |
-
case E_DEPRECATED:
|
259 |
-
case E_USER_DEPRECATED:
|
260 |
-
$message="<span>".__('[DEPRECATED]','backwpup')." ".$args[1]."</span>";
|
261 |
-
break;
|
262 |
-
case E_STRICT:
|
263 |
-
$message="<span>".__('[STRICT NOTICE]','backwpup')." ".$args[1]."</span>";
|
264 |
-
break;
|
265 |
-
case E_RECOVERABLE_ERROR:
|
266 |
-
$message="<span>".__('[RECOVERABLE ERROR]','backwpup')." ".$args[1]."</span>";
|
267 |
-
break;
|
268 |
-
default:
|
269 |
-
$message="<span>[".$args[0]."] ".$args[1]."</span>";
|
270 |
-
break;
|
271 |
-
}
|
272 |
-
|
273 |
-
//log line
|
274 |
-
$timestamp="<span class=\"timestamp\" title=\"[Line: ".$args[3]."|File: ".basename($args[2])."|Mem: ".formatbytes(@memory_get_usage(true))."|Mem Max: ".formatbytes(@memory_get_peak_usage(true))."|Mem Limit: ".ini_get('memory_limit')."|PID: ".getmypid()."]\">".date('Y/m/d H:i.s',time()+$STATIC['WP']['TIMEDIFF']).":</span> ";
|
275 |
-
//wirte log file
|
276 |
-
if (is_writable($STATIC['LOGFILE'])) {
|
277 |
-
file_put_contents($STATIC['LOGFILE'], $timestamp.$message."<br />\n", FILE_APPEND);
|
278 |
-
|
279 |
-
//write new log header
|
280 |
-
if ($adderrorwarning) {
|
281 |
-
$found=0;
|
282 |
-
$fd=fopen($STATIC['LOGFILE'],'r+');
|
283 |
-
while (!feof($fd)) {
|
284 |
-
$line=fgets($fd);
|
285 |
-
if (stripos($line,"<meta name=\"backwpup_errors\"") !== false) {
|
286 |
-
fseek($fd,$filepos);
|
287 |
-
fwrite($fd,str_pad("<meta name=\"backwpup_errors\" content=\"".$WORKING['ERROR']."\" />",100)."\n");
|
288 |
-
$found++;
|
289 |
-
}
|
290 |
-
if (stripos($line,"<meta name=\"backwpup_warnings\"") !== false) {
|
291 |
-
fseek($fd,$filepos);
|
292 |
-
fwrite($fd,str_pad("<meta name=\"backwpup_warnings\" content=\"".$WORKING['WARNING']."\" />",100)."\n");
|
293 |
-
$found++;
|
294 |
-
}
|
295 |
-
if ($found>=2)
|
296 |
-
break;
|
297 |
-
$filepos=ftell($fd);
|
298 |
-
}
|
299 |
-
fclose($fd);
|
300 |
-
}
|
301 |
-
}
|
302 |
-
//write working file
|
303 |
-
if (is_file($STATIC['TEMPDIR'].'.running'))
|
304 |
-
update_working_file();
|
305 |
-
|
306 |
-
if ($args[0]==E_ERROR or $args[0]==E_CORE_ERROR or $args[0]==E_COMPILE_ERROR) {//Die on fatal php errors.
|
307 |
-
die();
|
308 |
-
}
|
309 |
-
|
310 |
-
//true for no more php error hadling.
|
311 |
-
return true;
|
312 |
-
}
|
313 |
-
|
314 |
-
//job end function
|
315 |
-
function job_end() {
|
316 |
-
global $WORKING,$STATIC,$mysqlconlink;
|
317 |
-
//check if job_end allredy runs
|
318 |
-
if (empty($WORKING['JOBENDINPROGRESS']) or !$WORKING['JOBENDINPROGRESS'])
|
319 |
-
$WORKING['JOBENDINPROGRESS']=true;
|
320 |
-
else
|
321 |
-
return;
|
322 |
-
|
323 |
-
$WORKING['STEPTODO']=1;
|
324 |
-
$WORKING['STEPDONE']=0;
|
325 |
-
//delete old logs
|
326 |
-
if (!empty($STATIC['CFG']['maxlogs'])) {
|
327 |
-
if ( $dir = opendir($STATIC['CFG']['dirlogs']) ) { //make file list
|
328 |
-
while (($file = readdir($dir)) !== false ) {
|
329 |
-
if ('backwpup_log_' == substr($file,0,strlen('backwpup_log_')) and (".html" == substr($file,-5) or ".html.gz" == substr($file,-8)))
|
330 |
-
$logfilelist[]=$file;
|
331 |
-
}
|
332 |
-
closedir( $dir );
|
333 |
-
}
|
334 |
-
if (sizeof($logfilelist)>0) {
|
335 |
-
rsort($logfilelist);
|
336 |
-
$numdeltefiles=0;
|
337 |
-
for ($i=$STATIC['CFG']['maxlogs'];$i<sizeof($logfilelist);$i++) {
|
338 |
-
unlink($STATIC['CFG']['dirlogs'].$logfilelist[$i]);
|
339 |
-
$numdeltefiles++;
|
340 |
-
}
|
341 |
-
if ($numdeltefiles>0)
|
342 |
-
trigger_error(sprintf(_n('One old log deleted','%d old logs deleted',$numdeltefiles,'backwpup'),$numdeltefiles),E_USER_NOTICE);
|
343 |
-
}
|
344 |
-
}
|
345 |
-
//Display job working time
|
346 |
-
trigger_error(sprintf(__('Job done in %s sec.','backwpup'),time()-$STATIC['JOB']['starttime']),E_USER_NOTICE);
|
347 |
-
|
348 |
-
if (empty($STATIC['backupfile']) or !is_file($STATIC['JOB']['backupdir'].$STATIC['backupfile']) or !($filesize=filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']))) //Set the filezie corectly
|
349 |
-
$filesize=0;
|
350 |
-
|
351 |
-
//clean up temp
|
352 |
-
if ($dir = opendir($STATIC['TEMPDIR'])) {
|
353 |
-
while (($file = readdir($dir)) !== false) {
|
354 |
-
if (is_readable($STATIC['TEMPDIR'].$file) and is_file($STATIC['TEMPDIR'].$file)) {
|
355 |
-
if ($file!='.' and $file!='..' and $file!='.running') {
|
356 |
-
unlink($STATIC['TEMPDIR'].$file);
|
357 |
-
}
|
358 |
-
}
|
359 |
-
}
|
360 |
-
closedir($dir);
|
361 |
-
}
|
362 |
-
|
363 |
-
$jobs=get_option('backwpup_jobs');
|
364 |
-
$jobs[$STATIC['JOB']['jobid']]['lastrun']=$jobs[$STATIC['JOB']['jobid']]['starttime'];
|
365 |
-
$STATIC['JOB']['lastrun']=$jobs[$STATIC['JOB']['jobid']]['lastrun'];
|
366 |
-
$jobs[$STATIC['JOB']['jobid']]['lastruntime']=time()-$STATIC['JOB']['starttime'];
|
367 |
-
$STATIC['JOB']['lastruntime']=$jobs[$STATIC['JOB']['jobid']]['lastruntime'];
|
368 |
-
$jobs[$STATIC['JOB']['jobid']]['starttime']='';
|
369 |
-
if (!empty($STATIC['JOB']['lastbackupdownloadurl']))
|
370 |
-
$jobs[$STATIC['JOB']['jobid']]['lastbackupdownloadurl']=$STATIC['JOB']['lastbackupdownloadurl'];
|
371 |
-
else
|
372 |
-
$jobs[$STATIC['JOB']['jobid']]['lastbackupdownloadurl']='';
|
373 |
-
update_option('backwpup_jobs',$jobs); //Save Settings
|
374 |
-
|
375 |
-
//write header info
|
376 |
-
if (is_writable($STATIC['LOGFILE'])) {
|
377 |
-
$fd=fopen($STATIC['LOGFILE'],'r+');
|
378 |
-
$found=0;
|
379 |
-
while (!feof($fd)) {
|
380 |
-
$line=fgets($fd);
|
381 |
-
if (stripos($line,"<meta name=\"backwpup_jobruntime\"") !== false) {
|
382 |
-
fseek($fd,$filepos);
|
383 |
-
fwrite($fd,str_pad("<meta name=\"backwpup_jobruntime\" content=\"".$STATIC['JOB']['lastruntime']."\" />",100)."\n");
|
384 |
-
$found++;
|
385 |
-
}
|
386 |
-
if (stripos($line,"<meta name=\"backwpup_backupfilesize\"") !== false) {
|
387 |
-
fseek($fd,$filepos);
|
388 |
-
fwrite($fd,str_pad("<meta name=\"backwpup_backupfilesize\" content=\"".$filesize."\" />",100)."\n");
|
389 |
-
$found++;
|
390 |
-
}
|
391 |
-
if ($found>=2)
|
392 |
-
break;
|
393 |
-
$filepos=ftell($fd);
|
394 |
-
}
|
395 |
-
fclose($fd);
|
396 |
-
}
|
397 |
-
//Restore error handler
|
398 |
-
restore_error_handler();
|
399 |
-
//logfile end
|
400 |
-
file_put_contents($STATIC['LOGFILE'], "</body>\n</html>\n", FILE_APPEND);
|
401 |
-
//gzip logfile
|
402 |
-
if ($STATIC['CFG']['gzlogs'] and is_writable($STATIC['LOGFILE'])) {
|
403 |
-
$fd=fopen($STATIC['LOGFILE'],'r');
|
404 |
-
$zd=gzopen($STATIC['LOGFILE'].'.gz','w9');
|
405 |
-
while (!feof($fd)) {
|
406 |
-
gzwrite($zd,fread($fd,4096));
|
407 |
-
}
|
408 |
-
gzclose($zd);
|
409 |
-
fclose($fd);
|
410 |
-
unlink($STATIC['LOGFILE']);
|
411 |
-
$STATIC['LOGFILE']=$STATIC['LOGFILE'].'.gz';
|
412 |
-
|
413 |
-
$jobs=get_option('backwpup_jobs');
|
414 |
-
$jobs[$STATIC['JOB']['jobid']]['logfile']=$STATIC['LOGFILE'];
|
415 |
-
update_option('backwpup_jobs',$jobs); //Save Settings
|
416 |
-
}
|
417 |
-
|
418 |
-
//Send mail with log
|
419 |
-
$sendmail=false;
|
420 |
-
if ($WORKING['ERROR']>0 and $STATIC['JOB']['mailerroronly'] and !empty($STATIC['JOB']['mailaddresslog']))
|
421 |
-
$sendmail=true;
|
422 |
-
if (!$STATIC['JOB']['mailerroronly'] and !empty($STATIC['JOB']['mailaddresslog']))
|
423 |
-
$sendmail=true;
|
424 |
-
if ($sendmail) {
|
425 |
-
//Create PHP Mailer
|
426 |
-
require_once($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC'].'/class-phpmailer.php');
|
427 |
-
$phpmailer = new PHPMailer();
|
428 |
-
//Setting den methode
|
429 |
-
if ($STATIC['CFG']['mailmethod']=="SMTP") {
|
430 |
-
require_once($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC'].'/class-smtp.php');
|
431 |
-
$phpmailer->Host=$STATIC['CFG']['mailhost'];
|
432 |
-
$phpmailer->Port=$STATIC['CFG']['mailhostport'];
|
433 |
-
$phpmailer->SMTPSecure=$STATIC['CFG']['mailsecure'];
|
434 |
-
$phpmailer->Username=$STATIC['CFG']['mailuser'];
|
435 |
-
$phpmailer->Password=base64_decode($STATIC['CFG']['mailpass']);
|
436 |
-
if (!empty($STATIC['CFG']['mailuser']) and !empty($STATIC['CFG']['mailpass']))
|
437 |
-
$phpmailer->SMTPAuth=true;
|
438 |
-
$phpmailer->IsSMTP();
|
439 |
-
} elseif ($STATIC['CFG']['mailmethod']=="Sendmail") {
|
440 |
-
$phpmailer->Sendmail=$STATIC['CFG']['mailsendmail'];
|
441 |
-
$phpmailer->IsSendmail();
|
442 |
-
} else {
|
443 |
-
$phpmailer->IsMail();
|
444 |
-
}
|
445 |
-
//read log file
|
446 |
-
$mailbody='';
|
447 |
-
if (substr($STATIC['LOGFILE'],-3)=='.gz') {
|
448 |
-
$lines=gzfile($STATIC['LOGFILE']);
|
449 |
-
foreach ($lines as $line) {
|
450 |
-
$mailbody.=$line;
|
451 |
-
}
|
452 |
-
} else {
|
453 |
-
$mailbody=file_get_contents($STATIC['LOGFILE']);
|
454 |
-
}
|
455 |
-
|
456 |
-
$phpmailer->From = $STATIC['CFG']['mailsndemail'];
|
457 |
-
$phpmailer->FromName = $STATIC['CFG']['mailsndname'];
|
458 |
-
$phpmailer->AddAddress($STATIC['JOB']['mailaddresslog']);
|
459 |
-
$phpmailer->Subject = sprintf(__('BackWPup log from %1$s: %2$s','backwpup'),date('Y/m/d @ H:i',$STATIC['JOB']['starttime']+$STATIC['WP']['TIMEDIFF']),$STATIC['JOB']['name']);
|
460 |
-
$phpmailer->IsHTML(true);
|
461 |
-
$phpmailer->Body=$mailbody;
|
462 |
-
$phpmailer->AltBody=strip_tags($mailbody);
|
463 |
-
$phpmailer->Send();
|
464 |
-
}
|
465 |
-
|
466 |
-
$WORKING['STEPDONE']=1;
|
467 |
-
$WORKING['STEPSDONE'][]='JOB_END'; //set done
|
468 |
-
if (is_file($STATIC['TEMPDIR'].'.running')) {
|
469 |
-
update_working_file(true);
|
470 |
-
unlink($STATIC['TEMPDIR'].'.running');
|
471 |
-
rmdir($STATIC['TEMPDIR']);
|
472 |
-
clearstatcache();
|
473 |
-
}
|
474 |
-
mysql_close($mysqlconlink);
|
475 |
-
die();
|
476 |
-
}
|
477 |
-
|
478 |
-
// execute on script job shutdown
|
479 |
-
function job_shutdown($signal='') {
|
480 |
-
global $WORKING,$STATIC;
|
481 |
-
if (empty($STATIC['LOGFILE'])) //nothing on empty
|
482 |
-
return;
|
483 |
-
//Put last error to log if one
|
484 |
-
$lasterror=error_get_last();
|
485 |
-
if (($lasterror['type']==E_ERROR or $lasterror['type']==E_PARSE or $lasterror['type']==E_CORE_ERROR or $lasterror['type']==E_COMPILE_ERROR or !empty($signal)) and is_writable($STATIC['LOGFILE'])) {
|
486 |
-
if (!empty($signal))
|
487 |
-
file_put_contents($STATIC['LOGFILE'], "<span class=\"timestamp\" title=\"[Line: ".__LINE__."|File: ".basename(__FILE__)."|Mem: ".formatbytes(@memory_get_usage(true))."|Mem Max: ".formatbytes(@memory_get_peak_usage(true))."|Mem Limit: ".ini_get('memory_limit')."|PID: ".getmypid()."]\">".date('Y/m/d H:i.s',time()+$STATIC['WP']['TIMEDIFF']).":</span> <span class=\"error\">[ERROR]".sprintf(__('Signal %d send to script!','backwpup'),$signal)."</span><br />\n", FILE_APPEND);
|
488 |
-
file_put_contents($STATIC['LOGFILE'], "<span class=\"timestamp\" title=\"[Line: ".$lasterror['line']."|File: ".basename($lasterror['file'])."|Mem: ".formatbytes(@memory_get_usage(true))."|Mem Max: ".formatbytes(@memory_get_peak_usage(true))."|Mem Limit: ".ini_get('memory_limit')."|PID: ".getmypid()."]\">".date('Y/m/d H:i.s',time()+$STATIC['WP']['TIMEDIFF']).":</span> <span class=\"error\">[ERROR]".$lasterror['message']."</span><br />\n", FILE_APPEND);
|
489 |
-
//write new log header
|
490 |
-
$WORKING['ERROR']++;
|
491 |
-
$fd=fopen($STATIC['LOGFILE'],'r+');
|
492 |
-
while (!feof($fd)) {
|
493 |
-
$line=fgets($fd);
|
494 |
-
if (stripos($line,"<meta name=\"backwpup_errors\"") !== false) {
|
495 |
-
fseek($fd,$filepos);
|
496 |
-
fwrite($fd,str_pad("<meta name=\"backwpup_errors\" content=\"".$WORKING['ERROR']."\" />",100)."\n");
|
497 |
-
break;
|
498 |
-
}
|
499 |
-
$filepos=ftell($fd);
|
500 |
-
}
|
501 |
-
fclose($fd);
|
502 |
-
}
|
503 |
-
//no more restarts
|
504 |
-
$WORKING['RESTART']++;
|
505 |
-
if ((!empty($STATIC['WP']['ALTERNATE_CRON']) or $WORKING['RESTART']>=$STATIC['CFG']['jobscriptretry']) and is_file($STATIC['TEMPDIR'].'.running') and is_writable($STATIC['LOGFILE'])) { //only x restarts allowed
|
506 |
-
if (!empty($STATIC['WP']['ALTERNATE_CRON']))
|
507 |
-
file_put_contents($STATIC['LOGFILE'], "<span class=\"timestamp\" title=\"[Line: ".__LINE__."|File: ".basename(__FILE__)."\"|Mem: ".formatbytes(@memory_get_usage(true))."|Mem Max: ".formatbytes(@memory_get_peak_usage(true))."|Mem Limit: ".ini_get('memory_limit')."|PID: ".getmypid()."]>".date('Y/m/d H:i.s',time()+$STATIC['WP']['TIMEDIFF']).":</span> <span class=\"error\">[ERROR]".__('Can not restart on alternate cron....','backwpup')."</span><br />\n", FILE_APPEND);
|
508 |
-
else
|
509 |
-
file_put_contents($STATIC['LOGFILE'], "<span class=\"timestamp\" title=\"[Line: ".__LINE__."|File: ".basename(__FILE__)."\"|Mem: ".formatbytes(@memory_get_usage(true))."|Mem Max: ".formatbytes(@memory_get_peak_usage(true))."|Mem Limit: ".ini_get('memory_limit')."|PID: ".getmypid()."]>".date('Y/m/d H:i.s',time()+$STATIC['WP']['TIMEDIFF']).":</span> <span class=\"error\">[ERROR]".__('To many restarts....','backwpup')."</span><br />\n", FILE_APPEND);
|
510 |
-
$WORKING['ERROR']++;
|
511 |
-
$fd=fopen($STATIC['LOGFILE'],'r+');
|
512 |
-
while (!feof($fd)) {
|
513 |
-
$line=fgets($fd);
|
514 |
-
if (stripos($line,"<meta name=\"backwpup_errors\"") !== false) {
|
515 |
-
fseek($fd,$filepos);
|
516 |
-
fwrite($fd,str_pad("<meta name=\"backwpup_errors\" content=\"".$WORKING['ERROR']."\" />",100)."\n");
|
517 |
-
break;
|
518 |
-
}
|
519 |
-
$filepos=ftell($fd);
|
520 |
-
}
|
521 |
-
fclose($fd);
|
522 |
-
job_end();
|
523 |
-
}
|
524 |
-
//set PID to 0
|
525 |
-
$WORKING['PID']=0;
|
526 |
-
//Excute jobrun again
|
527 |
-
if (!is_file($STATIC['TEMPDIR'].'.running'))
|
528 |
-
exit;
|
529 |
-
if (is_writable($STATIC['LOGFILE']))
|
530 |
-
file_put_contents($STATIC['LOGFILE'], "<span class=\"timestamp\" title=\"[Line: ".__LINE__."|File: ".basename(__FILE__)."|Mem: ".formatbytes(@memory_get_usage(true))."|Mem Max: ".formatbytes(@memory_get_peak_usage(true))."|Mem Limit: ".ini_get('memory_limit')."|PID: ".getmypid()."]\">".date('Y/m/d H:i.s',time()+$STATIC['WP']['TIMEDIFF']).":</span> <span>".$WORKING['RESTART'].'. '.__('Script stop! Will started again now!','backwpup')."</span><br />\n", FILE_APPEND);
|
531 |
-
update_working_file(true);
|
532 |
-
if (!empty($STATIC['JOBRUNURL'])) {
|
533 |
-
if (function_exists('curl_exec')) {
|
534 |
-
$ch = curl_init();
|
535 |
-
curl_setopt($ch, CURLOPT_URL, $STATIC['JOBRUNURL']);
|
536 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
|
537 |
-
curl_setopt($ch, CURLOPT_POST, true);
|
538 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, array('BackWPupJobTemp'=>$STATIC['TEMPDIR'],'nonce'=>$WORKING['NONCE'],'type'=>'restart'));
|
539 |
-
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
|
540 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
541 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
542 |
-
curl_setopt($ch, CURLOPT_USERAGENT, 'BackWPup');
|
543 |
-
if (!empty($STATIC['CFG']['httpauthuser']) and !empty($STATIC['CFG']['httpauthpassword'])) {
|
544 |
-
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
|
545 |
-
curl_setopt($ch, CURLOPT_USERPWD, $STATIC['CFG']['httpauthuser'].':'.base64_decode($STATIC['CFG']['httpauthpassword']));
|
546 |
-
}
|
547 |
-
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
|
548 |
-
curl_exec($ch);
|
549 |
-
} else {
|
550 |
-
//use fopen if no curl
|
551 |
-
$urlParsed=parse_url($STATIC['JOBRUNURL']);
|
552 |
-
if ($urlParsed['scheme'] == 'https') {
|
553 |
-
$host = 'ssl://' . $urlParsed['host'];
|
554 |
-
$port = (!empty($urlParsed['port'])) ? $urlParsed['port'] : 443;
|
555 |
-
} else {
|
556 |
-
$host = $urlParsed['host'];
|
557 |
-
$port = (!empty($urlParsed['port'])) ? $urlParsed['port'] : 80;
|
558 |
-
}
|
559 |
-
$query=http_build_query(array('
|
560 |
-
$path=(isset($urlParsed['path']) ? $urlParsed['path'] : '/').(isset($urlParsed['query']) ? '?' . $urlParsed['query'] : '');
|
561 |
-
$header = "POST ".$path." HTTP/1.1\r\n";
|
562 |
-
$header.= "Host: ".$urlParsed['host']."\r\n";
|
563 |
-
$header.= "User-Agent: BackWPup\r\n";
|
564 |
-
$header.= "Content-Type: application/x-www-form-urlencoded\r\n";
|
565 |
-
$header.= "Content-Length: ".strlen($query)."\r\n";
|
566 |
-
if (!empty($STATIC['CFG']['httpauthuser']) and !empty($STATIC['CFG']['httpauthpassword']))
|
567 |
-
$header.= "Authorization: Basic ".base64_encode($STATIC['CFG']['httpauthuser'].':'.base64_decode($STATIC['CFG']['httpauthpassword']))."\r\n";
|
568 |
-
$header.= "Connection: Close\r\n\r\n";
|
569 |
-
$header.=$query;
|
570 |
-
$fp=fsockopen($host, $port, $errno, $errstr, 3);
|
571 |
-
fwrite($fp,$header);
|
572 |
-
fclose($fp);
|
573 |
-
}
|
574 |
-
}
|
575 |
-
exit;
|
576 |
-
}
|
577 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
function __($message,$domain='backwpup') {
|
3 |
+
global $TRANSLATE;
|
4 |
+
return $TRANSLATE->translate($message);
|
5 |
+
}
|
6 |
+
|
7 |
+
function _e($message,$domain='backwpup') {
|
8 |
+
global $TRANSLATE;
|
9 |
+
echo $TRANSLATE->translate($message);
|
10 |
+
}
|
11 |
+
|
12 |
+
function _n($single, $plural, $number,$domain='backwpup') {
|
13 |
+
global $TRANSLATE;
|
14 |
+
return $TRANSLATE->translate_plural($single,$plural,$number);
|
15 |
+
}
|
16 |
+
|
17 |
+
function exists_option($option='backwpup_jobs') {
|
18 |
+
global $WORKING,$STATIC;
|
19 |
+
mysql_update();
|
20 |
+
$query="SELECT option_value as value FROM ".$STATIC['WP']['OPTIONS_TABLE']." WHERE option_name='".trim($option)."' LIMIT 1";
|
21 |
+
$res=mysql_query($query);
|
22 |
+
if (!$res or mysql_num_rows($res)<1) {
|
23 |
+
return false;
|
24 |
+
}
|
25 |
+
return true;
|
26 |
+
}
|
27 |
+
|
28 |
+
function get_option($option='backwpup_jobs') {
|
29 |
+
global $WORKING,$STATIC;
|
30 |
+
mysql_update();
|
31 |
+
$query="SELECT option_value FROM ".$STATIC['WP']['OPTIONS_TABLE']." WHERE option_name='".trim($option)."' LIMIT 1";
|
32 |
+
$res=mysql_query($query);
|
33 |
+
if (!$res) {
|
34 |
+
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), $query),E_USER_ERROR);
|
35 |
+
return false;
|
36 |
+
}
|
37 |
+
return unserialize(mysql_result($res,0));
|
38 |
+
}
|
39 |
+
|
40 |
+
function update_option($option='backwpup_jobs',$data) {
|
41 |
+
global $WORKING,$STATIC;
|
42 |
+
mysql_update();
|
43 |
+
$serdata=mysql_real_escape_string(serialize($data));
|
44 |
+
$query="UPDATE ".$STATIC['WP']['OPTIONS_TABLE']." SET option_value= '".$serdata."' WHERE option_name='".trim($option)."' LIMIT 1";
|
45 |
+
$res=mysql_query($query);
|
46 |
+
if (!$res) {
|
47 |
+
trigger_error(sprintf(__('Database error %1$s for query %2$s','backwpup'), mysql_error(), $query),E_USER_ERROR);
|
48 |
+
return false;
|
49 |
+
}
|
50 |
+
return true;
|
51 |
+
}
|
52 |
+
|
53 |
+
// add to file list
|
54 |
+
function add_file($files) {
|
55 |
+
global $STATIC;
|
56 |
+
if (empty($files))
|
57 |
+
return;
|
58 |
+
$filelist=get_filelist();
|
59 |
+
foreach($files as $file)
|
60 |
+
$filelist[]=$file;
|
61 |
+
file_put_contents($STATIC['TEMPDIR'].'.filelist',serialize($filelist));
|
62 |
+
}
|
63 |
+
|
64 |
+
// get file list
|
65 |
+
function get_filelist() {
|
66 |
+
global $STATIC;
|
67 |
+
if (is_file($STATIC['TEMPDIR'].'.filelist') and $filelistfile=file_get_contents($STATIC['TEMPDIR'].'.filelist'))
|
68 |
+
return unserialize(trim($filelistfile));
|
69 |
+
else
|
70 |
+
return array();
|
71 |
+
}
|
72 |
+
|
73 |
+
//file size
|
74 |
+
function formatbytes($bytes, $precision = 2) {
|
75 |
+
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
|
76 |
+
$bytes = max($bytes, 0);
|
77 |
+
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
78 |
+
$pow = min($pow, count($units) - 1);
|
79 |
+
$bytes /= pow(1024, $pow);
|
80 |
+
return round($bytes, $precision) . ' ' . $units[$pow];
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
function inbytes($value) {
|
85 |
+
$multi=strtoupper(substr(trim($value),-1));
|
86 |
+
$bytes=abs(intval(trim($value)));
|
87 |
+
if ($multi=='G')
|
88 |
+
$bytes=$bytes*1024*1024*1024;
|
89 |
+
if ($multi=='M')
|
90 |
+
$bytes=$bytes*1024*1024;
|
91 |
+
if ($multi=='K')
|
92 |
+
$bytes=$bytes*1024;
|
93 |
+
return $bytes;
|
94 |
+
}
|
95 |
+
|
96 |
+
function need_free_memory($memneed) {
|
97 |
+
if (!function_exists('memory_get_usage'))
|
98 |
+
return;
|
99 |
+
//need memory
|
100 |
+
$needmemory=@memory_get_usage(true)+inbytes($memneed);
|
101 |
+
// increase Memory
|
102 |
+
if ($needmemory>inbytes(ini_get('memory_limit'))) {
|
103 |
+
$newmemory=round($needmemory/1024/1024)+1 .'M';
|
104 |
+
if ($needmemory>=1073741824)
|
105 |
+
$newmemory=round($needmemory/1024/1024/1024) .'G';
|
106 |
+
if ($oldmem=@ini_set('memory_limit', $newmemory))
|
107 |
+
trigger_error(sprintf(__('Memory increased from %1$s to %2$s','backwpup'),$oldmem,@ini_get('memory_limit')),E_USER_NOTICE);
|
108 |
+
else
|
109 |
+
trigger_error(sprintf(__('Can not increase memory limit is %1$s','backwpup'),@ini_get('memory_limit')),E_USER_WARNING);
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
function maintenance_mode($enable = false) {
|
114 |
+
global $WORKING,$STATIC;
|
115 |
+
if (!$STATIC['JOB']['maintenance'])
|
116 |
+
return;
|
117 |
+
if ( $enable ) {
|
118 |
+
trigger_error(__('Set Blog to maintenance mode','backwpup'),E_USER_NOTICE);
|
119 |
+
if ( exists_option('wp-maintenance-mode-msqld') ) { //Support for WP Maintenance Mode Plugin
|
120 |
+
update_option('wp-maintenance-mode-msqld','1');
|
121 |
+
} elseif ( exists_option('plugin_maintenance-mode') ) { //Support for Maintenance Mode Plugin
|
122 |
+
$mamo=get_option('plugin_maintenance-mode');
|
123 |
+
$mamo['mamo_activate']='on_'.time();
|
124 |
+
$mamo['mamo_backtime_days']='0';
|
125 |
+
$mamo['mamo_backtime_hours']='0';
|
126 |
+
$mamo['mamo_backtime_mins']='5';
|
127 |
+
update_option('plugin_maintenance-mode',$mamo);
|
128 |
+
} else { //WP Support
|
129 |
+
if (is_writable(rtrim($STATIC['WP']['ABSPATH'],'/')))
|
130 |
+
file_put_contents(rtrim($STATIC['WP']['ABSPATH'],'/').'/.maintenance','<?php $upgrading = '.time().'; ?>');
|
131 |
+
else
|
132 |
+
trigger_error(__('Cannot set Blog to maintenance mode! Root folder is not writeable!','backwpup'),E_USER_NOTICE);
|
133 |
+
}
|
134 |
+
} else {
|
135 |
+
trigger_error(__('Set Blog to normal mode','backwpup'),E_USER_NOTICE);
|
136 |
+
if ( exists_option('wp-maintenance-mode-msqld') ) { //Support for WP Maintenance Mode Plugin
|
137 |
+
update_option('wp-maintenance-mode-msqld','0');
|
138 |
+
} elseif ( exists_option('plugin_maintenance-mode') ) { //Support for Maintenance Mode Plugin
|
139 |
+
$mamo=get_option('plugin_maintenance-mode');
|
140 |
+
$mamo['mamo_activate']='off';
|
141 |
+
update_option('plugin_maintenance-mode',$mamo);
|
142 |
+
} else { //WP Support
|
143 |
+
@unlink(rtrim($STATIC['WP']['ABSPATH'],'/').'/.maintenance');
|
144 |
+
}
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
function curl_progresscallback($download_size, $downloaded, $upload_size, $uploaded) {
|
149 |
+
global $WORKING,$STATIC;
|
150 |
+
if ($WORKING['STEPTODO']>10)
|
151 |
+
$WORKING['STEPDONE']=$uploaded;
|
152 |
+
update_working_file();
|
153 |
+
return(0);
|
154 |
+
}
|
155 |
+
|
156 |
+
function get_working_file() {
|
157 |
+
global $STATIC;
|
158 |
+
if (is_writable($STATIC['TEMPDIR'].'.running')) {
|
159 |
+
if ($runningfile=file_get_contents($STATIC['TEMPDIR'].'.running'))
|
160 |
+
return unserialize(trim($runningfile));
|
161 |
+
else
|
162 |
+
return false;
|
163 |
+
} else {
|
164 |
+
return false;
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
function delete_working_file() {
|
169 |
+
global $STATIC;
|
170 |
+
if (is_writable($STATIC['TEMPDIR'].'.running')) {
|
171 |
+
unlink($STATIC['TEMPDIR'].'.running');
|
172 |
+
unlink($STATIC['TEMPDIR'].'.static');
|
173 |
+
return true;
|
174 |
+
} else {
|
175 |
+
return false;
|
176 |
+
}
|
177 |
+
}
|
178 |
+
|
179 |
+
function update_working_file($mustwrite=false) {
|
180 |
+
global $WORKING,$STATIC,$runmicrotime;
|
181 |
+
if (!is_file($STATIC['TEMPDIR'].'.running')) {
|
182 |
+
job_end();
|
183 |
+
return false;
|
184 |
+
}
|
185 |
+
if ($mustwrite or empty($runmicrotime) or $runmicrotime<(microtime()-1000)) { //only update all 1 sec.
|
186 |
+
if ($WORKING['STEPTODO']>0 and $WORKING['STEPDONE']>0)
|
187 |
+
$steppersent=round($WORKING['STEPDONE']/$WORKING['STEPTODO']*100);
|
188 |
+
else
|
189 |
+
$steppersent=1;
|
190 |
+
if (count($WORKING['STEPSDONE'])>0)
|
191 |
+
$stepspersent=round(count($WORKING['STEPSDONE'])/count($WORKING['STEPS'])*100);
|
192 |
+
else
|
193 |
+
$stepspersent=1;
|
194 |
+
@set_time_limit(0);
|
195 |
+
$runningfile=file_get_contents($STATIC['TEMPDIR'].'.running');
|
196 |
+
$infile=unserialize(trim($runningfile));
|
197 |
+
if (is_writable($STATIC['TEMPDIR'].'.running')) {
|
198 |
+
file_put_contents($STATIC['TEMPDIR'].'.running',serialize(array('timestamp'=>time(),'JOBID'=>$STATIC['JOB']['jobid'],'LOGFILE'=>$STATIC['LOGFILE'],'STEPSPERSENT'=>$stepspersent,'STEPPERSENT'=>$steppersent,'ABSPATH'=>$STATIC['WP']['ABSPATH'],'WORKING'=>$WORKING)));
|
199 |
+
$runmicrotime=microtime();
|
200 |
+
}
|
201 |
+
}
|
202 |
+
return true;
|
203 |
+
}
|
204 |
+
|
205 |
+
function mysql_update() {
|
206 |
+
global $WORKING,$STATIC,$mysqlconlink;
|
207 |
+
if (!$mysqlconlink or !@mysql_ping($mysqlconlink)) {
|
208 |
+
// make a mysql connection
|
209 |
+
$mysqlconlink=mysql_connect($STATIC['WP']['DB_HOST'], $STATIC['WP']['DB_USER'], $STATIC['WP']['DB_PASSWORD'], true);
|
210 |
+
if (!$mysqlconlink)
|
211 |
+
trigger_error(sprintf(__('No MySQL connection: %s','backwpup'),mysql_error()),E_USER_ERROR);
|
212 |
+
//set connecten charset
|
213 |
+
if (!empty($STATIC['WP']['DB_CHARSET'])) {
|
214 |
+
if ( function_exists( 'mysql_set_charset' )) {
|
215 |
+
mysql_set_charset( $STATIC['WP']['DB_CHARSET'], $mysqlconlink );
|
216 |
+
} else {
|
217 |
+
$query = "SET NAMES '".$STATIC['WP']['DB_CHARSET']."'";
|
218 |
+
if (!empty($collate))
|
219 |
+
$query .= " COLLATE '".$STATIC['WP']['DB_COLLATE']."'";
|
220 |
+
mysql_query($query,$mysqlconlink);
|
221 |
+
}
|
222 |
+
}
|
223 |
+
//connect to database
|
224 |
+
$mysqldblink = mysql_select_db($STATIC['WP']['DB_NAME'], $mysqlconlink);
|
225 |
+
if (!$mysqldblink)
|
226 |
+
trigger_error(sprintf(__('No MySQL connection to database: %s','backwpup'),mysql_error()),E_USER_ERROR);
|
227 |
+
}
|
228 |
+
}
|
229 |
+
|
230 |
+
//function for PHP error handling
|
231 |
+
function joberrorhandler() {
|
232 |
+
global $WORKING,$STATIC;
|
233 |
+
$args = func_get_args(); // 0:errno, 1:errstr, 2:errfile, 3:errline
|
234 |
+
|
235 |
+
// if error has been supressed with an @
|
236 |
+
if (error_reporting()==0)
|
237 |
+
return;
|
238 |
+
|
239 |
+
$adderrorwarning=false;
|
240 |
+
|
241 |
+
switch ($args[0]) {
|
242 |
+
case E_NOTICE:
|
243 |
+
case E_USER_NOTICE:
|
244 |
+
$message="<span>".$args[1]."</span>";
|
245 |
+
break;
|
246 |
+
case E_WARNING:
|
247 |
+
case E_USER_WARNING:
|
248 |
+
$WORKING['WARNING']++;
|
249 |
+
$adderrorwarning=true;
|
250 |
+
$message="<span class=\"warning\">".__('[WARNING]','backwpup')." ".$args[1]."</span>";
|
251 |
+
break;
|
252 |
+
case E_ERROR:
|
253 |
+
case E_USER_ERROR:
|
254 |
+
$WORKING['ERROR']++;
|
255 |
+
$adderrorwarning=true;
|
256 |
+
$message="<span class=\"error\">".__('[ERROR]','backwpup')." ".$args[1]."</span>";
|
257 |
+
break;
|
258 |
+
case E_DEPRECATED:
|
259 |
+
case E_USER_DEPRECATED:
|
260 |
+
$message="<span>".__('[DEPRECATED]','backwpup')." ".$args[1]."</span>";
|
261 |
+
break;
|
262 |
+
case E_STRICT:
|
263 |
+
$message="<span>".__('[STRICT NOTICE]','backwpup')." ".$args[1]."</span>";
|
264 |
+
break;
|
265 |
+
case E_RECOVERABLE_ERROR:
|
266 |
+
$message="<span>".__('[RECOVERABLE ERROR]','backwpup')." ".$args[1]."</span>";
|
267 |
+
break;
|
268 |
+
default:
|
269 |
+
$message="<span>[".$args[0]."] ".$args[1]."</span>";
|
270 |
+
break;
|
271 |
+
}
|
272 |
+
|
273 |
+
//log line
|
274 |
+
$timestamp="<span class=\"timestamp\" title=\"[Line: ".$args[3]."|File: ".basename($args[2])."|Mem: ".formatbytes(@memory_get_usage(true))."|Mem Max: ".formatbytes(@memory_get_peak_usage(true))."|Mem Limit: ".ini_get('memory_limit')."|PID: ".getmypid()."]\">".date('Y/m/d H:i.s',time()+$STATIC['WP']['TIMEDIFF']).":</span> ";
|
275 |
+
//wirte log file
|
276 |
+
if (is_writable($STATIC['LOGFILE'])) {
|
277 |
+
file_put_contents($STATIC['LOGFILE'], $timestamp.$message."<br />\n", FILE_APPEND);
|
278 |
+
|
279 |
+
//write new log header
|
280 |
+
if ($adderrorwarning) {
|
281 |
+
$found=0;
|
282 |
+
$fd=fopen($STATIC['LOGFILE'],'r+');
|
283 |
+
while (!feof($fd)) {
|
284 |
+
$line=fgets($fd);
|
285 |
+
if (stripos($line,"<meta name=\"backwpup_errors\"") !== false) {
|
286 |
+
fseek($fd,$filepos);
|
287 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_errors\" content=\"".$WORKING['ERROR']."\" />",100)."\n");
|
288 |
+
$found++;
|
289 |
+
}
|
290 |
+
if (stripos($line,"<meta name=\"backwpup_warnings\"") !== false) {
|
291 |
+
fseek($fd,$filepos);
|
292 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_warnings\" content=\"".$WORKING['WARNING']."\" />",100)."\n");
|
293 |
+
$found++;
|
294 |
+
}
|
295 |
+
if ($found>=2)
|
296 |
+
break;
|
297 |
+
$filepos=ftell($fd);
|
298 |
+
}
|
299 |
+
fclose($fd);
|
300 |
+
}
|
301 |
+
}
|
302 |
+
//write working file
|
303 |
+
if (is_file($STATIC['TEMPDIR'].'.running'))
|
304 |
+
update_working_file();
|
305 |
+
|
306 |
+
if ($args[0]==E_ERROR or $args[0]==E_CORE_ERROR or $args[0]==E_COMPILE_ERROR) {//Die on fatal php errors.
|
307 |
+
die();
|
308 |
+
}
|
309 |
+
|
310 |
+
//true for no more php error hadling.
|
311 |
+
return true;
|
312 |
+
}
|
313 |
+
|
314 |
+
//job end function
|
315 |
+
function job_end() {
|
316 |
+
global $WORKING,$STATIC,$mysqlconlink;
|
317 |
+
//check if job_end allredy runs
|
318 |
+
if (empty($WORKING['JOBENDINPROGRESS']) or !$WORKING['JOBENDINPROGRESS'])
|
319 |
+
$WORKING['JOBENDINPROGRESS']=true;
|
320 |
+
else
|
321 |
+
return;
|
322 |
+
|
323 |
+
$WORKING['STEPTODO']=1;
|
324 |
+
$WORKING['STEPDONE']=0;
|
325 |
+
//delete old logs
|
326 |
+
if (!empty($STATIC['CFG']['maxlogs'])) {
|
327 |
+
if ( $dir = opendir($STATIC['CFG']['dirlogs']) ) { //make file list
|
328 |
+
while (($file = readdir($dir)) !== false ) {
|
329 |
+
if ('backwpup_log_' == substr($file,0,strlen('backwpup_log_')) and (".html" == substr($file,-5) or ".html.gz" == substr($file,-8)))
|
330 |
+
$logfilelist[]=$file;
|
331 |
+
}
|
332 |
+
closedir( $dir );
|
333 |
+
}
|
334 |
+
if (sizeof($logfilelist)>0) {
|
335 |
+
rsort($logfilelist);
|
336 |
+
$numdeltefiles=0;
|
337 |
+
for ($i=$STATIC['CFG']['maxlogs'];$i<sizeof($logfilelist);$i++) {
|
338 |
+
unlink($STATIC['CFG']['dirlogs'].$logfilelist[$i]);
|
339 |
+
$numdeltefiles++;
|
340 |
+
}
|
341 |
+
if ($numdeltefiles>0)
|
342 |
+
trigger_error(sprintf(_n('One old log deleted','%d old logs deleted',$numdeltefiles,'backwpup'),$numdeltefiles),E_USER_NOTICE);
|
343 |
+
}
|
344 |
+
}
|
345 |
+
//Display job working time
|
346 |
+
trigger_error(sprintf(__('Job done in %s sec.','backwpup'),time()-$STATIC['JOB']['starttime']),E_USER_NOTICE);
|
347 |
+
|
348 |
+
if (empty($STATIC['backupfile']) or !is_file($STATIC['JOB']['backupdir'].$STATIC['backupfile']) or !($filesize=filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile']))) //Set the filezie corectly
|
349 |
+
$filesize=0;
|
350 |
+
|
351 |
+
//clean up temp
|
352 |
+
if ($dir = opendir($STATIC['TEMPDIR'])) {
|
353 |
+
while (($file = readdir($dir)) !== false) {
|
354 |
+
if (is_readable($STATIC['TEMPDIR'].$file) and is_file($STATIC['TEMPDIR'].$file)) {
|
355 |
+
if ($file!='.' and $file!='..' and $file!='.running') {
|
356 |
+
unlink($STATIC['TEMPDIR'].$file);
|
357 |
+
}
|
358 |
+
}
|
359 |
+
}
|
360 |
+
closedir($dir);
|
361 |
+
}
|
362 |
+
|
363 |
+
$jobs=get_option('backwpup_jobs');
|
364 |
+
$jobs[$STATIC['JOB']['jobid']]['lastrun']=$jobs[$STATIC['JOB']['jobid']]['starttime'];
|
365 |
+
$STATIC['JOB']['lastrun']=$jobs[$STATIC['JOB']['jobid']]['lastrun'];
|
366 |
+
$jobs[$STATIC['JOB']['jobid']]['lastruntime']=time()-$STATIC['JOB']['starttime'];
|
367 |
+
$STATIC['JOB']['lastruntime']=$jobs[$STATIC['JOB']['jobid']]['lastruntime'];
|
368 |
+
$jobs[$STATIC['JOB']['jobid']]['starttime']='';
|
369 |
+
if (!empty($STATIC['JOB']['lastbackupdownloadurl']))
|
370 |
+
$jobs[$STATIC['JOB']['jobid']]['lastbackupdownloadurl']=$STATIC['JOB']['lastbackupdownloadurl'];
|
371 |
+
else
|
372 |
+
$jobs[$STATIC['JOB']['jobid']]['lastbackupdownloadurl']='';
|
373 |
+
update_option('backwpup_jobs',$jobs); //Save Settings
|
374 |
+
|
375 |
+
//write header info
|
376 |
+
if (is_writable($STATIC['LOGFILE'])) {
|
377 |
+
$fd=fopen($STATIC['LOGFILE'],'r+');
|
378 |
+
$found=0;
|
379 |
+
while (!feof($fd)) {
|
380 |
+
$line=fgets($fd);
|
381 |
+
if (stripos($line,"<meta name=\"backwpup_jobruntime\"") !== false) {
|
382 |
+
fseek($fd,$filepos);
|
383 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_jobruntime\" content=\"".$STATIC['JOB']['lastruntime']."\" />",100)."\n");
|
384 |
+
$found++;
|
385 |
+
}
|
386 |
+
if (stripos($line,"<meta name=\"backwpup_backupfilesize\"") !== false) {
|
387 |
+
fseek($fd,$filepos);
|
388 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_backupfilesize\" content=\"".$filesize."\" />",100)."\n");
|
389 |
+
$found++;
|
390 |
+
}
|
391 |
+
if ($found>=2)
|
392 |
+
break;
|
393 |
+
$filepos=ftell($fd);
|
394 |
+
}
|
395 |
+
fclose($fd);
|
396 |
+
}
|
397 |
+
//Restore error handler
|
398 |
+
restore_error_handler();
|
399 |
+
//logfile end
|
400 |
+
file_put_contents($STATIC['LOGFILE'], "</body>\n</html>\n", FILE_APPEND);
|
401 |
+
//gzip logfile
|
402 |
+
if ($STATIC['CFG']['gzlogs'] and is_writable($STATIC['LOGFILE'])) {
|
403 |
+
$fd=fopen($STATIC['LOGFILE'],'r');
|
404 |
+
$zd=gzopen($STATIC['LOGFILE'].'.gz','w9');
|
405 |
+
while (!feof($fd)) {
|
406 |
+
gzwrite($zd,fread($fd,4096));
|
407 |
+
}
|
408 |
+
gzclose($zd);
|
409 |
+
fclose($fd);
|
410 |
+
unlink($STATIC['LOGFILE']);
|
411 |
+
$STATIC['LOGFILE']=$STATIC['LOGFILE'].'.gz';
|
412 |
+
|
413 |
+
$jobs=get_option('backwpup_jobs');
|
414 |
+
$jobs[$STATIC['JOB']['jobid']]['logfile']=$STATIC['LOGFILE'];
|
415 |
+
update_option('backwpup_jobs',$jobs); //Save Settings
|
416 |
+
}
|
417 |
+
|
418 |
+
//Send mail with log
|
419 |
+
$sendmail=false;
|
420 |
+
if ($WORKING['ERROR']>0 and $STATIC['JOB']['mailerroronly'] and !empty($STATIC['JOB']['mailaddresslog']))
|
421 |
+
$sendmail=true;
|
422 |
+
if (!$STATIC['JOB']['mailerroronly'] and !empty($STATIC['JOB']['mailaddresslog']))
|
423 |
+
$sendmail=true;
|
424 |
+
if ($sendmail) {
|
425 |
+
//Create PHP Mailer
|
426 |
+
require_once($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC'].'/class-phpmailer.php');
|
427 |
+
$phpmailer = new PHPMailer();
|
428 |
+
//Setting den methode
|
429 |
+
if ($STATIC['CFG']['mailmethod']=="SMTP") {
|
430 |
+
require_once($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC'].'/class-smtp.php');
|
431 |
+
$phpmailer->Host=$STATIC['CFG']['mailhost'];
|
432 |
+
$phpmailer->Port=$STATIC['CFG']['mailhostport'];
|
433 |
+
$phpmailer->SMTPSecure=$STATIC['CFG']['mailsecure'];
|
434 |
+
$phpmailer->Username=$STATIC['CFG']['mailuser'];
|
435 |
+
$phpmailer->Password=base64_decode($STATIC['CFG']['mailpass']);
|
436 |
+
if (!empty($STATIC['CFG']['mailuser']) and !empty($STATIC['CFG']['mailpass']))
|
437 |
+
$phpmailer->SMTPAuth=true;
|
438 |
+
$phpmailer->IsSMTP();
|
439 |
+
} elseif ($STATIC['CFG']['mailmethod']=="Sendmail") {
|
440 |
+
$phpmailer->Sendmail=$STATIC['CFG']['mailsendmail'];
|
441 |
+
$phpmailer->IsSendmail();
|
442 |
+
} else {
|
443 |
+
$phpmailer->IsMail();
|
444 |
+
}
|
445 |
+
//read log file
|
446 |
+
$mailbody='';
|
447 |
+
if (substr($STATIC['LOGFILE'],-3)=='.gz') {
|
448 |
+
$lines=gzfile($STATIC['LOGFILE']);
|
449 |
+
foreach ($lines as $line) {
|
450 |
+
$mailbody.=$line;
|
451 |
+
}
|
452 |
+
} else {
|
453 |
+
$mailbody=file_get_contents($STATIC['LOGFILE']);
|
454 |
+
}
|
455 |
+
|
456 |
+
$phpmailer->From = $STATIC['CFG']['mailsndemail'];
|
457 |
+
$phpmailer->FromName = $STATIC['CFG']['mailsndname'];
|
458 |
+
$phpmailer->AddAddress($STATIC['JOB']['mailaddresslog']);
|
459 |
+
$phpmailer->Subject = sprintf(__('BackWPup log from %1$s: %2$s','backwpup'),date('Y/m/d @ H:i',$STATIC['JOB']['starttime']+$STATIC['WP']['TIMEDIFF']),$STATIC['JOB']['name']);
|
460 |
+
$phpmailer->IsHTML(true);
|
461 |
+
$phpmailer->Body=$mailbody;
|
462 |
+
$phpmailer->AltBody=strip_tags($mailbody);
|
463 |
+
$phpmailer->Send();
|
464 |
+
}
|
465 |
+
|
466 |
+
$WORKING['STEPDONE']=1;
|
467 |
+
$WORKING['STEPSDONE'][]='JOB_END'; //set done
|
468 |
+
if (is_file($STATIC['TEMPDIR'].'.running')) {
|
469 |
+
update_working_file(true);
|
470 |
+
unlink($STATIC['TEMPDIR'].'.running');
|
471 |
+
rmdir($STATIC['TEMPDIR']);
|
472 |
+
clearstatcache();
|
473 |
+
}
|
474 |
+
mysql_close($mysqlconlink);
|
475 |
+
die();
|
476 |
+
}
|
477 |
+
|
478 |
+
// execute on script job shutdown
|
479 |
+
function job_shutdown($signal='') {
|
480 |
+
global $WORKING,$STATIC;
|
481 |
+
if (empty($STATIC['LOGFILE'])) //nothing on empty
|
482 |
+
return;
|
483 |
+
//Put last error to log if one
|
484 |
+
$lasterror=error_get_last();
|
485 |
+
if (($lasterror['type']==E_ERROR or $lasterror['type']==E_PARSE or $lasterror['type']==E_CORE_ERROR or $lasterror['type']==E_COMPILE_ERROR or !empty($signal)) and is_writable($STATIC['LOGFILE'])) {
|
486 |
+
if (!empty($signal))
|
487 |
+
file_put_contents($STATIC['LOGFILE'], "<span class=\"timestamp\" title=\"[Line: ".__LINE__."|File: ".basename(__FILE__)."|Mem: ".formatbytes(@memory_get_usage(true))."|Mem Max: ".formatbytes(@memory_get_peak_usage(true))."|Mem Limit: ".ini_get('memory_limit')."|PID: ".getmypid()."]\">".date('Y/m/d H:i.s',time()+$STATIC['WP']['TIMEDIFF']).":</span> <span class=\"error\">[ERROR]".sprintf(__('Signal %d send to script!','backwpup'),$signal)."</span><br />\n", FILE_APPEND);
|
488 |
+
file_put_contents($STATIC['LOGFILE'], "<span class=\"timestamp\" title=\"[Line: ".$lasterror['line']."|File: ".basename($lasterror['file'])."|Mem: ".formatbytes(@memory_get_usage(true))."|Mem Max: ".formatbytes(@memory_get_peak_usage(true))."|Mem Limit: ".ini_get('memory_limit')."|PID: ".getmypid()."]\">".date('Y/m/d H:i.s',time()+$STATIC['WP']['TIMEDIFF']).":</span> <span class=\"error\">[ERROR]".$lasterror['message']."</span><br />\n", FILE_APPEND);
|
489 |
+
//write new log header
|
490 |
+
$WORKING['ERROR']++;
|
491 |
+
$fd=fopen($STATIC['LOGFILE'],'r+');
|
492 |
+
while (!feof($fd)) {
|
493 |
+
$line=fgets($fd);
|
494 |
+
if (stripos($line,"<meta name=\"backwpup_errors\"") !== false) {
|
495 |
+
fseek($fd,$filepos);
|
496 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_errors\" content=\"".$WORKING['ERROR']."\" />",100)."\n");
|
497 |
+
break;
|
498 |
+
}
|
499 |
+
$filepos=ftell($fd);
|
500 |
+
}
|
501 |
+
fclose($fd);
|
502 |
+
}
|
503 |
+
//no more restarts
|
504 |
+
$WORKING['RESTART']++;
|
505 |
+
if ((!empty($STATIC['WP']['ALTERNATE_CRON']) or $WORKING['RESTART']>=$STATIC['CFG']['jobscriptretry']) and is_file($STATIC['TEMPDIR'].'.running') and is_writable($STATIC['LOGFILE'])) { //only x restarts allowed
|
506 |
+
if (!empty($STATIC['WP']['ALTERNATE_CRON']))
|
507 |
+
file_put_contents($STATIC['LOGFILE'], "<span class=\"timestamp\" title=\"[Line: ".__LINE__."|File: ".basename(__FILE__)."\"|Mem: ".formatbytes(@memory_get_usage(true))."|Mem Max: ".formatbytes(@memory_get_peak_usage(true))."|Mem Limit: ".ini_get('memory_limit')."|PID: ".getmypid()."]>".date('Y/m/d H:i.s',time()+$STATIC['WP']['TIMEDIFF']).":</span> <span class=\"error\">[ERROR]".__('Can not restart on alternate cron....','backwpup')."</span><br />\n", FILE_APPEND);
|
508 |
+
else
|
509 |
+
file_put_contents($STATIC['LOGFILE'], "<span class=\"timestamp\" title=\"[Line: ".__LINE__."|File: ".basename(__FILE__)."\"|Mem: ".formatbytes(@memory_get_usage(true))."|Mem Max: ".formatbytes(@memory_get_peak_usage(true))."|Mem Limit: ".ini_get('memory_limit')."|PID: ".getmypid()."]>".date('Y/m/d H:i.s',time()+$STATIC['WP']['TIMEDIFF']).":</span> <span class=\"error\">[ERROR]".__('To many restarts....','backwpup')."</span><br />\n", FILE_APPEND);
|
510 |
+
$WORKING['ERROR']++;
|
511 |
+
$fd=fopen($STATIC['LOGFILE'],'r+');
|
512 |
+
while (!feof($fd)) {
|
513 |
+
$line=fgets($fd);
|
514 |
+
if (stripos($line,"<meta name=\"backwpup_errors\"") !== false) {
|
515 |
+
fseek($fd,$filepos);
|
516 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_errors\" content=\"".$WORKING['ERROR']."\" />",100)."\n");
|
517 |
+
break;
|
518 |
+
}
|
519 |
+
$filepos=ftell($fd);
|
520 |
+
}
|
521 |
+
fclose($fd);
|
522 |
+
job_end();
|
523 |
+
}
|
524 |
+
//set PID to 0
|
525 |
+
$WORKING['PID']=0;
|
526 |
+
//Excute jobrun again
|
527 |
+
if (!is_file($STATIC['TEMPDIR'].'.running'))
|
528 |
+
exit;
|
529 |
+
if (is_writable($STATIC['LOGFILE']))
|
530 |
+
file_put_contents($STATIC['LOGFILE'], "<span class=\"timestamp\" title=\"[Line: ".__LINE__."|File: ".basename(__FILE__)."|Mem: ".formatbytes(@memory_get_usage(true))."|Mem Max: ".formatbytes(@memory_get_peak_usage(true))."|Mem Limit: ".ini_get('memory_limit')."|PID: ".getmypid()."]\">".date('Y/m/d H:i.s',time()+$STATIC['WP']['TIMEDIFF']).":</span> <span>".$WORKING['RESTART'].'. '.__('Script stop! Will started again now!','backwpup')."</span><br />\n", FILE_APPEND);
|
531 |
+
update_working_file(true);
|
532 |
+
if (!empty($STATIC['JOBRUNURL'])) {
|
533 |
+
if (function_exists('curl_exec')) {
|
534 |
+
$ch = curl_init();
|
535 |
+
curl_setopt($ch, CURLOPT_URL, $STATIC['JOBRUNURL']);
|
536 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
|
537 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
538 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, array('BackWPupJobTemp'=>$STATIC['TEMPDIR'],'nonce'=>$WORKING['NONCE'],'type'=>'restart'));
|
539 |
+
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
|
540 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
541 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
542 |
+
curl_setopt($ch, CURLOPT_USERAGENT, 'BackWPup');
|
543 |
+
if (!empty($STATIC['CFG']['httpauthuser']) and !empty($STATIC['CFG']['httpauthpassword'])) {
|
544 |
+
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
|
545 |
+
curl_setopt($ch, CURLOPT_USERPWD, $STATIC['CFG']['httpauthuser'].':'.base64_decode($STATIC['CFG']['httpauthpassword']));
|
546 |
+
}
|
547 |
+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
|
548 |
+
curl_exec($ch);
|
549 |
+
} else {
|
550 |
+
//use fopen if no curl
|
551 |
+
$urlParsed=parse_url($STATIC['JOBRUNURL']);
|
552 |
+
if ($urlParsed['scheme'] == 'https') {
|
553 |
+
$host = 'ssl://' . $urlParsed['host'];
|
554 |
+
$port = (!empty($urlParsed['port'])) ? $urlParsed['port'] : 443;
|
555 |
+
} else {
|
556 |
+
$host = $urlParsed['host'];
|
557 |
+
$port = (!empty($urlParsed['port'])) ? $urlParsed['port'] : 80;
|
558 |
+
}
|
559 |
+
$query=http_build_query(array('nonce'=>$WORKING['NONCE'],'type'=>'restart'));
|
560 |
+
$path=(isset($urlParsed['path']) ? $urlParsed['path'] : '/').(isset($urlParsed['query']) ? '?' . $urlParsed['query'] : '');
|
561 |
+
$header = "POST ".$path." HTTP/1.1\r\n";
|
562 |
+
$header.= "Host: ".$urlParsed['host']."\r\n";
|
563 |
+
$header.= "User-Agent: BackWPup\r\n";
|
564 |
+
$header.= "Content-Type: application/x-www-form-urlencoded\r\n";
|
565 |
+
$header.= "Content-Length: ".strlen($query)."\r\n";
|
566 |
+
if (!empty($STATIC['CFG']['httpauthuser']) and !empty($STATIC['CFG']['httpauthpassword']))
|
567 |
+
$header.= "Authorization: Basic ".base64_encode($STATIC['CFG']['httpauthuser'].':'.base64_decode($STATIC['CFG']['httpauthpassword']))."\r\n";
|
568 |
+
$header.= "Connection: Close\r\n\r\n";
|
569 |
+
$header.=$query;
|
570 |
+
$fp=fsockopen($host, $port, $errno, $errstr, 3);
|
571 |
+
fwrite($fp,$header);
|
572 |
+
fclose($fp);
|
573 |
+
}
|
574 |
+
}
|
575 |
+
exit;
|
576 |
+
}
|
|
job/job_run.php
CHANGED
@@ -1,169 +1,170 @@
|
|
1 |
-
<?PHP
|
2 |
-
//Set a constance for not direkt loding in other files
|
3 |
-
define('BACKWPUP_JOBRUN_FOLDER', dirname(__FILE__).'/');
|
4 |
-
//
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
$STATIC['TEMPDIR']
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
die('
|
30 |
-
}
|
31 |
-
ob_end_clean();
|
32 |
-
header("Connection: close");
|
33 |
-
ob_start();
|
34 |
-
header("Content-Length: 0");
|
35 |
-
ob_end_flush();
|
36 |
-
flush();
|
37 |
-
// set memory limit to the same as WP.
|
38 |
-
if (function_exists('memory_get_usage') && (inbytes(@ini_get('memory_limit')) < inbytes($STATIC['WP']['MEMORY_LIMIT'])))
|
39 |
-
@ini_set('memory_limit',$STATIC['WP']['MEMORY_LIMIT']);
|
40 |
-
//check existing Logfile
|
41 |
-
if (empty($STATIC) or !is_file($STATIC['LOGFILE'])) {
|
42 |
-
delete_working_file();
|
43 |
-
die('No logfile found!');
|
44 |
-
}
|
45 |
-
//load translation
|
46 |
-
if (is_file(dirname(__FILE__).'/../lang/backwpup-'.$STATIC['WP']['WPLANG'].'.mo')) {
|
47 |
-
require($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC'].'/pomo/mo.php');
|
48 |
-
$TRANSLATE = new MO();
|
49 |
-
$TRANSLATE->import_from_file(dirname(__FILE__).'/../lang/backwpup-'.$STATIC['WP']['WPLANG'].'.mo');
|
50 |
-
} else {
|
51 |
-
require($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC'].'/pomo/translations.php');
|
52 |
-
$TRANSLATE = new NOOP_Translations;
|
53 |
-
}
|
54 |
-
//set ticks
|
55 |
-
declare(ticks=1);
|
56 |
-
//set timezone
|
57 |
-
date_default_timezone_set('UTC');
|
58 |
-
// set charakter encoding
|
59 |
-
if (
|
60 |
-
mb_internal_encoding('
|
61 |
-
|
62 |
-
|
63 |
-
//
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
} elseif
|
72 |
-
trigger_error(
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
$
|
78 |
-
//
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
//
|
86 |
-
@ini_set('
|
87 |
-
//
|
88 |
-
ignore_user_abort
|
89 |
-
//
|
90 |
-
|
91 |
-
//
|
92 |
-
|
93 |
-
//
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
}
|
102 |
-
|
103 |
-
}
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
trigger_error(__('[INFO]: BackWPup
|
111 |
-
|
112 |
-
|
113 |
-
if ($STATIC['
|
114 |
-
trigger_error(__('[INFO]: BackWPup
|
115 |
-
|
116 |
-
trigger_error(__('[INFO]: BackWPup job started
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
$WORKING['
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
//
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
$WORKING[
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
}
|
167 |
-
|
168 |
-
|
169 |
-
|
|
1 |
+
<?PHP
|
2 |
+
//Set a constance for not direkt loding in other files
|
3 |
+
define('BACKWPUP_JOBRUN_FOLDER', str_replace('\\','/',dirname(__FILE__).'/'));
|
4 |
+
//set temp dir
|
5 |
+
$STATIC['TEMPDIR']=BACKWPUP_JOBRUN_FOLDER.'../tmp/';
|
6 |
+
$STATIC['TEMPDIR']=realpath($STATIC['TEMPDIR']).'/';
|
7 |
+
//check temp dir
|
8 |
+
if (empty($STATIC['TEMPDIR']) || !is_dir($STATIC['TEMPDIR']) || !is_writable($STATIC['TEMPDIR']))
|
9 |
+
die($STATIC['TEMPDIR'].'Temp dir not writable!!! Job aborted!');
|
10 |
+
//write PHP log
|
11 |
+
@ini_set( 'error_log', $STATIC['TEMPDIR'].'php_error.log' );
|
12 |
+
@ini_set( 'display_errors', 'Off' );
|
13 |
+
@ini_set( 'log_errors', 'On' );
|
14 |
+
// get needed functions for the jobrun
|
15 |
+
require_once(BACKWPUP_JOBRUN_FOLDER.'job_functions.php');
|
16 |
+
//read runningfile and config
|
17 |
+
$runningfile=get_working_file();
|
18 |
+
if ($runningfile['JOBID']>0 and $runningfile['WORKING']['NONCE']==$_POST['nonce']) {
|
19 |
+
if ($staticfile=file_get_contents($STATIC['TEMPDIR'].'.static')) {
|
20 |
+
$STATIC=unserialize(trim($staticfile));
|
21 |
+
} else {
|
22 |
+
delete_working_file();
|
23 |
+
die('No config file found');
|
24 |
+
}
|
25 |
+
$WORKING=$runningfile['WORKING'];
|
26 |
+
unset($runningfile);
|
27 |
+
unset($staticfile);
|
28 |
+
} else {
|
29 |
+
die('Hack ?');
|
30 |
+
}
|
31 |
+
ob_end_clean();
|
32 |
+
header("Connection: close");
|
33 |
+
ob_start();
|
34 |
+
header("Content-Length: 0");
|
35 |
+
ob_end_flush();
|
36 |
+
flush();
|
37 |
+
// set memory limit to the same as WP.
|
38 |
+
if (function_exists('memory_get_usage') && (inbytes(@ini_get('memory_limit')) < inbytes($STATIC['WP']['MEMORY_LIMIT'])))
|
39 |
+
@ini_set('memory_limit',$STATIC['WP']['MEMORY_LIMIT']);
|
40 |
+
//check existing Logfile
|
41 |
+
if (empty($STATIC) or !is_file($STATIC['LOGFILE'])) {
|
42 |
+
delete_working_file();
|
43 |
+
die('No logfile found!');
|
44 |
+
}
|
45 |
+
//load translation
|
46 |
+
if (is_file(dirname(__FILE__).'/../lang/backwpup-'.$STATIC['WP']['WPLANG'].'.mo')) {
|
47 |
+
require($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC'].'/pomo/mo.php');
|
48 |
+
$TRANSLATE = new MO();
|
49 |
+
$TRANSLATE->import_from_file(dirname(__FILE__).'/../lang/backwpup-'.$STATIC['WP']['WPLANG'].'.mo');
|
50 |
+
} else {
|
51 |
+
require($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC'].'/pomo/translations.php');
|
52 |
+
$TRANSLATE = new NOOP_Translations;
|
53 |
+
}
|
54 |
+
//set ticks
|
55 |
+
declare(ticks=1);
|
56 |
+
//set timezone
|
57 |
+
date_default_timezone_set('UTC');
|
58 |
+
// set charakter encoding
|
59 |
+
if ( function_exists( 'mb_internal_encoding' ) ) {
|
60 |
+
if (!@mb_internal_encoding($STATIC['WP']['CHARSET']))
|
61 |
+
mb_internal_encoding('UTF-8');
|
62 |
+
}
|
63 |
+
//set function for PHP user defineid error handling
|
64 |
+
set_error_handler('joberrorhandler',E_ALL | E_STRICT);
|
65 |
+
//Get type and check job runs
|
66 |
+
$runningfile=get_working_file();
|
67 |
+
$revtime=time()-$STATIC['CFG']['jobscriptruntimelong']-10;
|
68 |
+
if ($WORKING['PID']!=getmypid() and $runningfile['timestamp']>$revtime and $_POST['type']=='restarttime') {
|
69 |
+
trigger_error(__('Job restart terminated, bcause old job runs again!','backwpup'),E_USER_ERROR);
|
70 |
+
die();
|
71 |
+
} elseif($_POST['type']=='restarttime') {
|
72 |
+
trigger_error(__('Job restarted, bcause inactivity!','backwpup'),E_USER_ERROR);
|
73 |
+
} elseif ($WORKING['PID']!=getmypid() and $WORKING['PID']!=0 and $runningfile['timestamp']>$revtime) {
|
74 |
+
trigger_error(sprintf(__('Second Prozess is running, bcause old job runs! Start type is %s','backwpup'),$_POST['type']),E_USER_ERROR);
|
75 |
+
die();
|
76 |
+
}
|
77 |
+
unset($runningfile);
|
78 |
+
//set Pid
|
79 |
+
$WORKING['PID']=getmypid();
|
80 |
+
// execute function on job shutdown
|
81 |
+
register_shutdown_function('job_shutdown');
|
82 |
+
if (function_exists('pcntl_signal')) {
|
83 |
+
pcntl_signal(SIGTERM, 'job_shutdown');
|
84 |
+
}
|
85 |
+
//try to disable safe mode
|
86 |
+
@ini_set('safe_mode','0');
|
87 |
+
// Now user abrot allowed
|
88 |
+
@ini_set('ignore_user_abort','0');
|
89 |
+
//disable user abort
|
90 |
+
ignore_user_abort(true);
|
91 |
+
//update running file
|
92 |
+
update_working_file(true);
|
93 |
+
//mysql connect
|
94 |
+
mysql_update();
|
95 |
+
//Load needed files
|
96 |
+
foreach($WORKING['STEPS'] as $step) {
|
97 |
+
$stepfile=strtolower($step).'.php';
|
98 |
+
if ($step!='JOB_END') {
|
99 |
+
if (is_file(BACKWPUP_JOBRUN_FOLDER.$stepfile)) {
|
100 |
+
require_once(BACKWPUP_JOBRUN_FOLDER.$stepfile);
|
101 |
+
} else {
|
102 |
+
trigger_error(sprintf(__('Can not find job step file: %s','backwpup'),$stepfile),E_USER_ERROR);
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
106 |
+
// Working step by step
|
107 |
+
foreach($WORKING['STEPS'] as $step) {
|
108 |
+
//display some info massages bevor fist step
|
109 |
+
if (count($WORKING['STEPSDONE'])==0) {
|
110 |
+
trigger_error(sprintf(__('[INFO]: BackWPup version %1$s, WordPress version %4$s Copyright © %2$s %3$s'),$STATIC['BACKWPUP']['VERSION'],date('Y',time()+$STATIC['WP']['TIMEDIFF']),'<a href="http://danielhuesken.de" target="_blank">Daniel Hüsken</a>',$STATIC['WP']['VERSION']),E_USER_NOTICE);
|
111 |
+
trigger_error(__('[INFO]: BackWPup comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.','backwpup'),E_USER_NOTICE);
|
112 |
+
trigger_error(__('[INFO]: BackWPup job:','backwpup').' '.$STATIC['JOB']['jobid'].'. '.$STATIC['JOB']['name'].'; '.$STATIC['JOB']['type'],E_USER_NOTICE);
|
113 |
+
if ($STATIC['JOB']['activated'])
|
114 |
+
trigger_error(__('[INFO]: BackWPup cron:','backwpup').' '.$STATIC['JOB']['cron'].'; '.date('D, j M Y @ H:i',$STATIC['JOB']['cronnextrun']),E_USER_NOTICE);
|
115 |
+
if ($STATIC['CRONSTART'])
|
116 |
+
trigger_error(__('[INFO]: BackWPup job started by cron','backwpup'),E_USER_NOTICE);
|
117 |
+
else
|
118 |
+
trigger_error(__('[INFO]: BackWPup job started manualy','backwpup'),E_USER_NOTICE);
|
119 |
+
trigger_error(__('[INFO]: PHP ver.:','backwpup').' '.phpversion().'; '.php_sapi_name().'; '.PHP_OS,E_USER_NOTICE);
|
120 |
+
if ((bool)ini_get('safe_mode'))
|
121 |
+
trigger_error(sprintf(__('[INFO]: PHP Safe mode is ON! Maximum script execution time is %1$d sec.','backwpup'),ini_get('max_execution_time')),E_USER_NOTICE);
|
122 |
+
trigger_error(__('[INFO]: MySQL ver.:','backwpup').' '.mysql_result(mysql_query("SELECT VERSION() AS version"),0),E_USER_NOTICE);
|
123 |
+
if (function_exists('curl_init')) {
|
124 |
+
$curlversion=curl_version();
|
125 |
+
trigger_error(__('[INFO]: curl ver.:','backwpup').' '.$curlversion['version'].'; '.$curlversion['ssl_version'],E_USER_NOTICE);
|
126 |
+
}
|
127 |
+
trigger_error(__('[INFO]: Temp folder is:','backwpup').' '.$STATIC['TEMPDIR'],E_USER_NOTICE);
|
128 |
+
if(!empty($STATIC['backupfile']))
|
129 |
+
trigger_error(__('[INFO]: Backup file is:','backwpup').' '.$STATIC['JOB']['backupdir'].$STATIC['backupfile'],E_USER_NOTICE);
|
130 |
+
//test for destinations
|
131 |
+
if (in_array('DB',$STATIC['TODO']) or in_array('WPEXP',$STATIC['TODO']) or in_array('FILE',$STATIC['TODO'])) {
|
132 |
+
$desttest=false;
|
133 |
+
foreach($WORKING['STEPS'] as $deststeptest) {
|
134 |
+
if (substr($deststeptest,0,5)=='DEST_') {
|
135 |
+
$desttest=true;
|
136 |
+
break;
|
137 |
+
}
|
138 |
+
}
|
139 |
+
if (!$desttest)
|
140 |
+
trigger_error(__('No destination defineid for backup!!! Please correct job settings','backwpup'),E_USER_ERROR);
|
141 |
+
}
|
142 |
+
}
|
143 |
+
//Set next step
|
144 |
+
if (!isset($WORKING[$step]['STEP_TRY']) or empty($WORKING[$step]['STEP_TRY'])) {
|
145 |
+
$WORKING[$step]['STEP_TRY']=0;
|
146 |
+
$WORKING['STEPDONE']=0;
|
147 |
+
$WORKING['STEPTODO']=0;
|
148 |
+
}
|
149 |
+
//update running file
|
150 |
+
update_working_file(true);
|
151 |
+
//Run next step
|
152 |
+
if (!in_array($step,$WORKING['STEPSDONE'])) {
|
153 |
+
if (function_exists(strtolower($step))) {
|
154 |
+
while ($WORKING[$step]['STEP_TRY']<$STATIC['CFG']['jobstepretry']) {
|
155 |
+
if (in_array($step,$WORKING['STEPSDONE']))
|
156 |
+
break;
|
157 |
+
$WORKING[$step]['STEP_TRY']++;
|
158 |
+
update_working_file(true);
|
159 |
+
call_user_func(strtolower($step));
|
160 |
+
}
|
161 |
+
if ($WORKING[$step]['STEP_TRY']>=$STATIC['CFG']['jobstepretry'])
|
162 |
+
trigger_error(__('Step arborted has too many trys!','backwpup'),E_USER_ERROR);
|
163 |
+
} else {
|
164 |
+
trigger_error(sprintf(__('Can not find job step function %s!','backwpup'),strtolower($step)),E_USER_ERROR);
|
165 |
+
$WORKING['STEPSDONE'][]=$step;
|
166 |
+
}
|
167 |
+
}
|
168 |
+
}
|
169 |
+
//close mysql
|
170 |
+
mysql_close($mysqlconlink);
|
job/job_start.php
CHANGED
@@ -1,269 +1,248 @@
|
|
1 |
-
<?PHP
|
2 |
-
function backwpup_jobstart($jobid='',$cronstart=false) {
|
3 |
-
global $wpdb,$wp_version;
|
4 |
-
$jobid=(int)trim($jobid);
|
5 |
-
if (empty($jobid) or !is_integer($jobid)) {
|
6 |
-
return false;
|
7 |
-
}
|
8 |
-
//check if a job running
|
9 |
-
if ($infile=backwpup_get_working_file()) {
|
10 |
-
trigger_error(__("A job already running!","backwpup"),E_USER_WARNING);
|
11 |
-
return false;
|
12 |
-
}
|
13 |
-
|
14 |
-
//clean var
|
15 |
-
$backwpup_static = array();
|
16 |
-
$backwpup_working = array();
|
17 |
-
//get
|
18 |
-
$backwpup_static['TEMPDIR']=backwpup_get_temp();
|
19 |
-
if (!
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
$backwpup_static['WP']['
|
57 |
-
$backwpup_static['WP']['
|
58 |
-
$backwpup_static['WP']['
|
59 |
-
$backwpup_static['WP']['
|
60 |
-
$backwpup_static['WP']['
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
$backwpup_static['WP']['
|
65 |
-
|
66 |
-
|
67 |
-
$backwpup_static['WP']['
|
68 |
-
$backwpup_static['WP']['
|
69 |
-
$backwpup_static['WP']['
|
70 |
-
$backwpup_static['WP']['
|
71 |
-
$backwpup_static['WP']['
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
$backwpup_static['
|
78 |
-
$backwpup_static['
|
79 |
-
$backwpup_static['
|
80 |
-
$backwpup_static['
|
81 |
-
$backwpup_static['
|
82 |
-
|
83 |
-
$backwpup_static['
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
$backwpup_static['
|
91 |
-
|
92 |
-
$backwpup_static['
|
93 |
-
|
94 |
-
$backwpup_static['CFG']
|
95 |
-
|
96 |
-
if(!
|
97 |
-
$backwpup_static['CFG']['
|
98 |
-
|
99 |
-
|
100 |
-
//
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
$
|
137 |
-
|
138 |
-
$fd
|
139 |
-
|
140 |
-
fwrite($fd,"
|
141 |
-
fwrite($fd,"
|
142 |
-
fwrite($fd,"<
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
}
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
$
|
222 |
-
|
223 |
-
$
|
224 |
-
|
225 |
-
$
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
$backwpup_working['STEPS'][]='DB_CHECK';
|
250 |
-
if (in_array('OPTIMIZE',$backwpup_static['TODO']))
|
251 |
-
$backwpup_working['STEPS'][]='DB_OPTIMIZE';
|
252 |
-
$backwpup_working['STEPS'][]='JOB_END';
|
253 |
-
//mark all as not done
|
254 |
-
foreach($backwpup_working['STEPS'] as $step)
|
255 |
-
$backwpup_working[$step]['DONE']=false;
|
256 |
-
//write working file
|
257 |
-
file_put_contents($backwpup_static['TEMPDIR'].'.running',serialize(array('timestamp'=>time(),'JOBID'=>$backwpup_static['JOB']['jobid'],'LOGFILE'=>$backwpup_static['LOGFILE'],'STEPSPERSENT'=>0,'STEPPERSENT'=>0,'WORKING'=>$backwpup_working)));
|
258 |
-
//write static file
|
259 |
-
file_put_contents($backwpup_static['TEMPDIR'].'.static',serialize($backwpup_static));
|
260 |
-
//Run job
|
261 |
-
$httpauthheader='';
|
262 |
-
if (!empty($backwpup_static['CFG']['httpauthuser']) and !empty($backwpup_static['CFG']['httpauthpassword']))
|
263 |
-
$httpauthheader=array( 'Authorization' => 'Basic '.base64_encode($backwpup_static['CFG']['httpauthuser'].':'.base64_decode($backwpup_static['CFG']['httpauthpassword'])));
|
264 |
-
if (!$backwpup_static['WP']['ALTERNATE_CRON'])
|
265 |
-
wp_remote_post($backwpup_static['JOBRUNURL'], array('timeout' => 3, 'blocking' => false, 'sslverify' => false, 'headers'=>$httpauthheader ,'body'=>array('BackWPupJobTemp'=>$backwpup_static['TEMPDIR'], 'nonce'=>$backwpup_working['NONCE'], 'type'=>'start'), 'user-agent'=>'BackWPup'));
|
266 |
-
|
267 |
-
return $backwpup_static['LOGFILE'];
|
268 |
-
}
|
269 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
function backwpup_jobstart($jobid='',$cronstart=false) {
|
3 |
+
global $wpdb,$wp_version;
|
4 |
+
$jobid=(int)trim($jobid);
|
5 |
+
if (empty($jobid) or !is_integer($jobid)) {
|
6 |
+
return false;
|
7 |
+
}
|
8 |
+
//check if a job running
|
9 |
+
if ($infile=backwpup_get_working_file()) {
|
10 |
+
trigger_error(__("A job already running!","backwpup"),E_USER_WARNING);
|
11 |
+
return false;
|
12 |
+
}
|
13 |
+
|
14 |
+
//clean var
|
15 |
+
$backwpup_static = array();
|
16 |
+
$backwpup_working = array();
|
17 |
+
//get temp dir
|
18 |
+
$backwpup_static['TEMPDIR']=backwpup_get_temp();
|
19 |
+
if (!is_writable($backwpup_static['TEMPDIR'])) {
|
20 |
+
trigger_error(__("Temp dir not writeable","backwpup"),E_USER_ERROR);
|
21 |
+
return false;
|
22 |
+
} else { //clean up old temp files
|
23 |
+
if ($dir = opendir($backwpup_static['TEMPDIR'])) {
|
24 |
+
while (($file = readdir($dir)) !== false) {
|
25 |
+
if (is_readable($backwpup_static['TEMPDIR'].$file) and is_file($backwpup_static['TEMPDIR'].$file)) {
|
26 |
+
if ($file!='.' and $file!='..') {
|
27 |
+
unlink($backwpup_static['TEMPDIR'].$file);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
closedir($dir);
|
32 |
+
}
|
33 |
+
//create .htaccess for apache and index.php for folder security
|
34 |
+
if (!is_file($backwpup_static['TEMPDIR'].'.htaccess'))
|
35 |
+
file_put_contents($backwpup_static['TEMPDIR'].'.htaccess',"<Files \"*\">\n<IfModule mod_access.c>\nDeny from all\n</IfModule>\n<IfModule !mod_access_compat>\n<IfModule mod_authz_host.c>\nDeny from all\n</IfModule>\n</IfModule>\n<IfModule mod_access_compat>\nDeny from all\n</IfModule>\n</Files>");
|
36 |
+
if (!is_file($backwpup_static['TEMPDIR'].'index.php'))
|
37 |
+
file_put_contents($backwpup_static['TEMPDIR'].'index.php',"\n");
|
38 |
+
}
|
39 |
+
//Write running file to prevent dobble runnging
|
40 |
+
file_put_contents($backwpup_static['TEMPDIR'].'.running',serialize(array('timestamp'=>time(),'JOBID'=>$jobid,'LOGFILE'=>'','STEPSPERSENT'=>0,'STEPPERSENT'=>0,'WORKING'=>array('PID'=>0))));
|
41 |
+
|
42 |
+
//Set needed WP vars
|
43 |
+
$backwpup_static['WP']['DB_NAME']=DB_NAME;
|
44 |
+
$backwpup_static['WP']['DB_USER']=DB_USER;
|
45 |
+
$backwpup_static['WP']['DB_PASSWORD']=DB_PASSWORD;
|
46 |
+
$backwpup_static['WP']['DB_HOST']=DB_HOST;
|
47 |
+
$backwpup_static['WP']['DB_CHARSET']=DB_CHARSET;
|
48 |
+
$backwpup_static['WP']['DB_COLLATE']=DB_COLLATE;
|
49 |
+
$backwpup_static['WP']['OPTIONS_TABLE']=$wpdb->options;
|
50 |
+
$backwpup_static['WP']['TABLE_PREFIX']=$wpdb->prefix;
|
51 |
+
$backwpup_static['WP']['BLOGNAME']=get_bloginfo('name');
|
52 |
+
if (defined('WP_SITEURL'))
|
53 |
+
$backwpup_static['WP']['SITEURL']=trailingslashit(WP_SITEURL);
|
54 |
+
else
|
55 |
+
$backwpup_static['WP']['SITEURL']=trailingslashit(get_option('siteurl'));
|
56 |
+
$backwpup_static['WP']['TIMEDIFF']=get_option('gmt_offset')*3600;
|
57 |
+
$backwpup_static['WP']['WPLANG']=WPLANG;
|
58 |
+
$backwpup_static['WP']['VERSION']=$wp_version;
|
59 |
+
$backwpup_static['WP']['CHARSET']=get_option('blog_charset');
|
60 |
+
$backwpup_static['WP']['MEMORY_LIMIT']=WP_MEMORY_LIMIT;
|
61 |
+
if (defined('ALTERNATE_WP_CRON'))
|
62 |
+
$backwpup_static['WP']['ALTERNATE_CRON']=ALTERNATE_WP_CRON;
|
63 |
+
else
|
64 |
+
$backwpup_static['WP']['ALTERNATE_CRON']=false;
|
65 |
+
//WP folder
|
66 |
+
$backwpup_static['WP']['ABSPATH']=rtrim(str_replace('\\','/',ABSPATH),'/').'/';
|
67 |
+
$backwpup_static['WP']['WP_CONTENT_DIR']=rtrim(str_replace('\\','/',WP_CONTENT_DIR),'/').'/';
|
68 |
+
$backwpup_static['WP']['WP_PLUGIN_DIR']=rtrim(str_replace('\\','/',WP_PLUGIN_DIR),'/').'/';
|
69 |
+
$backwpup_static['WP']['WP_THEMES_DIR']=rtrim(str_replace('\\','/',trailingslashit(WP_CONTENT_DIR).'themes/'),'/').'/';
|
70 |
+
$backwpup_static['WP']['WP_UPLOAD_DIR']=backwpup_get_upload_dir();
|
71 |
+
$backwpup_static['WP']['WPINC']=WPINC;
|
72 |
+
$backwpup_static['WP']['MULTISITE']=is_multisite();
|
73 |
+
$backwpup_static['WP']['ADMINURL']=backwpup_admin_url('admin.php');
|
74 |
+
//Set plugin data
|
75 |
+
$backwpup_static['BACKWPUP']['PLUGIN_BASEDIR']=BACKWPUP_PLUGIN_BASEDIR;
|
76 |
+
$backwpup_static['BACKWPUP']['VERSION']=BACKWPUP_VERSION;
|
77 |
+
$backwpup_static['BACKWPUP']['BACKWPUP_DESTS']=BACKWPUP_DESTS;
|
78 |
+
$backwpup_static['BACKWPUP']['DROPBOX_APP_KEY']=BACKWPUP_DROPBOX_APP_KEY;
|
79 |
+
$backwpup_static['BACKWPUP']['DROPBOX_APP_SECRET']=BACKWPUP_DROPBOX_APP_SECRET;
|
80 |
+
$backwpup_static['BACKWPUP']['SUGARSYNC_ACCESSKEY']=BACKWPUP_SUGARSYNC_ACCESSKEY;
|
81 |
+
$backwpup_static['BACKWPUP']['SUGARSYNC_PRIVATEACCESSKEY']=BACKWPUP_SUGARSYNC_PRIVATEACCESSKEY;
|
82 |
+
//Set config data
|
83 |
+
$backwpup_static['CFG']=get_option('backwpup');
|
84 |
+
//check exists gzip functions
|
85 |
+
if(!function_exists('gzopen'))
|
86 |
+
$backwpup_static['CFG']['gzlogs']=false;
|
87 |
+
if(!class_exists('ZipArchive'))
|
88 |
+
$backwpup_static['CFG']['phpzip']=false;
|
89 |
+
//Check working times
|
90 |
+
if (empty($backwpup_static['CFG']['jobstepretry']) or !is_int($backwpup_static['CFG']['jobstepretry']) or $backwpup_static['CFG']['jobstepretry']>100)
|
91 |
+
$backwpup_static['CFG']['jobstepretry']=3;
|
92 |
+
if (empty($backwpup_static['CFG']['jobscriptretry']) or !is_int($backwpup_static['CFG']['jobscriptretry']) or $backwpup_static['CFG']['jobscriptretry']>100)
|
93 |
+
$backwpup_static['CFG']['jobscriptretry']=5;
|
94 |
+
if (empty($backwpup_static['CFG']['jobscriptruntime']) or !is_int($backwpup_static['CFG']['jobscriptruntime']) or $backwpup_static['CFG']['jobscriptruntime']>100)
|
95 |
+
$backwpup_static['CFG']['jobscriptruntime']=ini_get('max_execution_time');
|
96 |
+
if (empty($backwpup_static['CFG']['jobscriptruntimelong']) or !is_int($backwpup_static['CFG']['jobscriptruntimelong']) or $backwpup_static['CFG']['jobscriptruntimelong']>1000)
|
97 |
+
$backwpup_static['CFG']['jobscriptruntimelong']=300;
|
98 |
+
//Set job data
|
99 |
+
$backwpup_static['JOB']=backwpup_get_job_vars($jobid);
|
100 |
+
//STATIC data
|
101 |
+
$backwpup_static['JOBRUNURL']=BACKWPUP_PLUGIN_BASEURL.'/job/job_run.php';
|
102 |
+
//Setup Logs dir
|
103 |
+
$backwpup_static['CFG']['dirlogs']=rtrim(str_replace('\\','/',$backwpup_static['CFG']['dirlogs']),'/').'/';
|
104 |
+
if (!is_dir($backwpup_static['CFG']['dirlogs'])) {
|
105 |
+
if (!mkdir(rtrim($backwpup_static['CFG']['dirlogs'],'/'),0777,true)) {
|
106 |
+
trigger_error(printf(__('Can not create folder for log files: %s','backwpup'),$backwpup_static['CFG']['dirlogs']),E_USER_ERROR);
|
107 |
+
return false;
|
108 |
+
}
|
109 |
+
}
|
110 |
+
//create .htaccess for apache and index.php for folder security
|
111 |
+
if (!is_file($backwpup_static['CFG']['dirlogs'].'.htaccess'))
|
112 |
+
file_put_contents($backwpup_static['CFG']['dirlogs'].'.htaccess',"<Files \"*\">\n<IfModule mod_access.c>\nDeny from all\n</IfModule>\n<IfModule !mod_access_compat>\n<IfModule mod_authz_host.c>\nDeny from all\n</IfModule>\n</IfModule>\n<IfModule mod_access_compat>\nDeny from all\n</IfModule>\n</Files>");
|
113 |
+
if (!is_file($backwpup_static['CFG']['dirlogs'].'index.php'))
|
114 |
+
file_put_contents($backwpup_static['CFG']['dirlogs'].'index.php',"\n");
|
115 |
+
|
116 |
+
if (!is_writable($backwpup_static['CFG']['dirlogs'])) {
|
117 |
+
trigger_error(__("Log folder not writeable!","backwpup"),E_USER_ERROR);
|
118 |
+
return false;
|
119 |
+
}
|
120 |
+
//set Logfile
|
121 |
+
$backwpup_static['LOGFILE']=$backwpup_static['CFG']['dirlogs'].'backwpup_log_'.backwpup_date_i18n('Y-m-d_H-i-s').'.html';
|
122 |
+
//create log file
|
123 |
+
$fd=fopen($backwpup_static['LOGFILE'],'w');
|
124 |
+
//Create log file header
|
125 |
+
fwrite($fd,"<html>\n<head>\n");
|
126 |
+
fwrite($fd,"<meta name=\"robots\" content=\"noindex, nofollow\" />\n");
|
127 |
+
fwrite($fd,"<meta name=\"backwpup_version\" content=\"".BACKWPUP_VERSION."\" />\n");
|
128 |
+
fwrite($fd,"<meta name=\"backwpup_logtime\" content=\"".time()."\" />\n");
|
129 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_errors\" content=\"0\" />",100)."\n");
|
130 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_warnings\" content=\"0\" />",100)."\n");
|
131 |
+
fwrite($fd,"<meta name=\"backwpup_jobid\" content=\"".$backwpup_static['JOB']['jobid']."\" />\n");
|
132 |
+
fwrite($fd,"<meta name=\"backwpup_jobname\" content=\"".$backwpup_static['JOB']['name']."\" />\n");
|
133 |
+
fwrite($fd,"<meta name=\"backwpup_jobtype\" content=\"".$backwpup_static['JOB']['type']."\" />\n");
|
134 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_backupfilesize\" content=\"0\" />",100)."\n");
|
135 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_jobruntime\" content=\"0\" />",100)."\n");
|
136 |
+
fwrite($fd,"<style type=\"text/css\">\n");
|
137 |
+
fwrite($fd,".timestamp {background-color:grey;}\n");
|
138 |
+
fwrite($fd,".warning {background-color:yellow;}\n");
|
139 |
+
fwrite($fd,".error {background-color:red;}\n");
|
140 |
+
fwrite($fd,"#body {font-family:monospace;font-size:12px;white-space:nowrap;}\n");
|
141 |
+
fwrite($fd,"</style>\n");
|
142 |
+
fwrite($fd,"<title>".sprintf(__('BackWPup log for %1$s from %2$s at %3$s','backwpup'),$backwpup_static['JOB']['name'],backwpup_date_i18n(get_option('date_format')),backwpup_date_i18n(get_option('time_format')))."</title>\n</head>\n<body id=\"body\">\n");
|
143 |
+
fclose($fd);
|
144 |
+
//Set job start settings
|
145 |
+
$jobs=get_option('backwpup_jobs');
|
146 |
+
$jobs[$backwpup_static['JOB']['jobid']]['starttime']=time(); //set start time for job
|
147 |
+
$backwpup_static['JOB']['starttime']=$jobs[$backwpup_static['JOB']['jobid']]['starttime'];
|
148 |
+
$jobs[$backwpup_static['JOB']['jobid']]['logfile']=$backwpup_static['LOGFILE']; //Set current logfile
|
149 |
+
$jobs[$backwpup_static['JOB']['jobid']]['cronnextrun']=backwpup_cron_next($jobs[$backwpup_static['JOB']['jobid']]['cron']); //set next run
|
150 |
+
$backwpup_static['JOB']['cronnextrun']=$jobs[$backwpup_static['JOB']['jobid']]['cronnextrun'];
|
151 |
+
$jobs[$backwpup_static['JOB']['jobid']]['lastbackupdownloadurl']='';
|
152 |
+
$backwpup_static['JOB']['lastbackupdownloadurl']='';
|
153 |
+
update_option('backwpup_jobs',$jobs); //Save job Settings
|
154 |
+
//Set todo
|
155 |
+
$backwpup_static['TODO']=explode('+',$backwpup_static['JOB']['type']);
|
156 |
+
//only for jos that makes backups
|
157 |
+
if (in_array('FILE',$backwpup_static['TODO']) or in_array('DB',$backwpup_static['TODO']) or in_array('WPEXP',$backwpup_static['TODO'])) {
|
158 |
+
//make emty file list
|
159 |
+
$backwpup_working['FILELIST']=array();
|
160 |
+
$backwpup_working['ALLFILESIZE']=0;
|
161 |
+
//set Backup Dir if not set
|
162 |
+
if (empty($backwpup_static['JOB']['backupdir'])) {
|
163 |
+
$backwpup_static['JOB']['backupdir']=$backwpup_static['TEMPDIR'];
|
164 |
+
} else {
|
165 |
+
//clear path
|
166 |
+
$backwpup_static['JOB']['backupdir']=rtrim(str_replace('\\','/',$backwpup_static['JOB']['backupdir']),'/').'/';
|
167 |
+
//create backup dir if it not exists
|
168 |
+
if (!is_dir($backwpup_static['JOB']['backupdir'])) {
|
169 |
+
if (!mkdir(rtrim($backwpup_static['JOB']['backupdir'],'/'),0777,true)) {
|
170 |
+
trigger_error(sprintf(__('Can not create folder for backups: %1$s','backwpup'),$backwpup_static['JOB']['backupdir']),E_USER_ERROR);
|
171 |
+
return false;
|
172 |
+
}
|
173 |
+
}
|
174 |
+
//create .htaccess and index.php for folder security
|
175 |
+
if (!is_file($backwpup_static['JOB']['backupdir'].'.htaccess'))
|
176 |
+
file_put_contents($backwpup_static['JOB']['backupdir'].'.htaccess',"<Files \"*\">\n<IfModule mod_access.c>\nDeny from all\n</IfModule>\n<IfModule !mod_access_compat>\n<IfModule mod_authz_host.c>\nDeny from all\n</IfModule>\n</IfModule>\n<IfModule mod_access_compat>\nDeny from all\n</IfModule>\n</Files>");
|
177 |
+
if (!is_file($backwpup_static['JOB']['backupdir'].'index.php'))
|
178 |
+
file_put_contents($backwpup_static['JOB']['backupdir'].'index.php',"\n");
|
179 |
+
}
|
180 |
+
//check backup dir
|
181 |
+
if (!is_writable($backwpup_static['JOB']['backupdir'])) {
|
182 |
+
trigger_error(__("Backup folder not writeable!","backwpup"),E_USER_ERROR);
|
183 |
+
return false;
|
184 |
+
}
|
185 |
+
//set Backup file Name
|
186 |
+
$backwpup_static['backupfile']=$backwpup_static['JOB']['fileprefix'].backwpup_date_i18n('Y-m-d_H-i-s').$backwpup_static['JOB']['fileformart'];
|
187 |
+
}
|
188 |
+
$backwpup_static['CRONSTART']=$cronstart;
|
189 |
+
$backwpup_working['NONCE']=wp_create_nonce('BackWPupJob');
|
190 |
+
$backwpup_working['PID']=0;
|
191 |
+
$backwpup_working['WARNING']=0;
|
192 |
+
$backwpup_working['ERROR']=0;
|
193 |
+
$backwpup_working['RESTART']=0;
|
194 |
+
$backwpup_working['STEPSDONE']=array();
|
195 |
+
$backwpup_working['STEPTODO']=0;
|
196 |
+
$backwpup_working['STEPDONE']=0;
|
197 |
+
//build working steps
|
198 |
+
$backwpup_working['STEPS']=array();
|
199 |
+
//setup job steps
|
200 |
+
if (in_array('DB',$backwpup_static['TODO']))
|
201 |
+
$backwpup_working['STEPS'][]='DB_DUMP';
|
202 |
+
if (in_array('WPEXP',$backwpup_static['TODO']))
|
203 |
+
$backwpup_working['STEPS'][]='WP_EXPORT';
|
204 |
+
if (in_array('FILE',$backwpup_static['TODO']))
|
205 |
+
$backwpup_working['STEPS'][]='FILE_LIST';
|
206 |
+
if (in_array('DB',$backwpup_static['TODO']) or in_array('WPEXP',$backwpup_static['TODO']) or in_array('FILE',$backwpup_static['TODO'])) {
|
207 |
+
$backwpup_working['STEPS'][]='BACKUP_CREATE';
|
208 |
+
//ADD Destinations
|
209 |
+
if (!empty($backwpup_static['JOB']['backupdir']) and $backwpup_static['JOB']['backupdir']!='/' and $backwpup_static['JOB']['backupdir']!=$backwpup_static['TEMPDIR'])
|
210 |
+
$backwpup_working['STEPS'][]='DEST_FOLDER';
|
211 |
+
if (!empty($backwpup_static['JOB']['mailaddress']))
|
212 |
+
$backwpup_working['STEPS'][]='DEST_MAIL';
|
213 |
+
if (!empty($backwpup_static['JOB']['ftphost']) and !empty($backwpup_static['JOB']['ftpuser']) and !empty($backwpup_static['JOB']['ftppass']) and in_array('FTP',explode(',',strtoupper(BACKWPUP_DESTS))))
|
214 |
+
$backwpup_working['STEPS'][]='DEST_FTP';
|
215 |
+
if (!empty($backwpup_static['JOB']['dropetoken']) and !empty($backwpup_static['JOB']['dropesecret']) and in_array('DROPBOX',explode(',',strtoupper(BACKWPUP_DESTS))))
|
216 |
+
$backwpup_working['STEPS'][]='DEST_DROPBOX';
|
217 |
+
if (!empty($backwpup_static['JOB']['sugaruser']) and !empty($backwpup_static['JOB']['sugarpass']) and !empty($backwpup_static['JOB']['sugarroot']) and in_array('SUGARSYNC',explode(',',strtoupper(BACKWPUP_DESTS))))
|
218 |
+
$backwpup_working['STEPS'][]='DEST_SUGARSYNC';
|
219 |
+
if (!empty($backwpup_static['JOB']['awsAccessKey']) and !empty($backwpup_static['JOB']['awsSecretKey']) and !empty($backwpup_static['JOB']['awsBucket']) and in_array('S3',explode(',',strtoupper(BACKWPUP_DESTS))))
|
220 |
+
$backwpup_working['STEPS'][]='DEST_S3';
|
221 |
+
if (!empty($backwpup_static['JOB']['GStorageAccessKey']) and !empty($backwpup_static['JOB']['GStorageSecret']) and !empty($backwpup_static['JOB']['GStorageBucket']) and in_array('GSTORAGE',explode(',',strtoupper(BACKWPUP_DESTS))))
|
222 |
+
$backwpup_working['STEPS'][]='DEST_GSTORAGE';
|
223 |
+
if (!empty($backwpup_static['JOB']['rscUsername']) and !empty($backwpup_static['JOB']['rscAPIKey']) and !empty($backwpup_static['JOB']['rscContainer']) and in_array('RSC',explode(',',strtoupper(BACKWPUP_DESTS))))
|
224 |
+
$backwpup_working['STEPS'][]='DEST_RSC';
|
225 |
+
if (!empty($backwpup_static['JOB']['msazureHost']) and !empty($backwpup_static['JOB']['msazureAccName']) and !empty($backwpup_static['JOB']['msazureKey']) and !empty($backwpup_static['JOB']['msazureContainer']) and in_array('MSAZURE',explode(',',strtoupper(BACKWPUP_DESTS))))
|
226 |
+
$backwpup_working['STEPS'][]='DEST_MSAZURE';
|
227 |
+
}
|
228 |
+
if (in_array('CHECK',$backwpup_static['TODO']))
|
229 |
+
$backwpup_working['STEPS'][]='DB_CHECK';
|
230 |
+
if (in_array('OPTIMIZE',$backwpup_static['TODO']))
|
231 |
+
$backwpup_working['STEPS'][]='DB_OPTIMIZE';
|
232 |
+
$backwpup_working['STEPS'][]='JOB_END';
|
233 |
+
//mark all as not done
|
234 |
+
foreach($backwpup_working['STEPS'] as $step)
|
235 |
+
$backwpup_working[$step]['DONE']=false;
|
236 |
+
//write working file
|
237 |
+
file_put_contents($backwpup_static['TEMPDIR'].'.running',serialize(array('timestamp'=>time(),'JOBID'=>$backwpup_static['JOB']['jobid'],'LOGFILE'=>$backwpup_static['LOGFILE'],'STEPSPERSENT'=>0,'STEPPERSENT'=>0,'WORKING'=>$backwpup_working)));
|
238 |
+
//write static file
|
239 |
+
file_put_contents($backwpup_static['TEMPDIR'].'.static',serialize($backwpup_static));
|
240 |
+
//Run job
|
241 |
+
$httpauthheader='';
|
242 |
+
if (!empty($backwpup_static['CFG']['httpauthuser']) and !empty($backwpup_static['CFG']['httpauthpassword']))
|
243 |
+
$httpauthheader=array( 'Authorization' => 'Basic '.base64_encode($backwpup_static['CFG']['httpauthuser'].':'.base64_decode($backwpup_static['CFG']['httpauthpassword'])));
|
244 |
+
if (!$backwpup_static['WP']['ALTERNATE_CRON'])
|
245 |
+
wp_remote_post($backwpup_static['JOBRUNURL'], array('timeout' => 3, 'blocking' => false, 'sslverify' => false, 'headers'=>$httpauthheader ,'body'=>array('nonce'=>$backwpup_working['NONCE'], 'type'=>'start'), 'user-agent'=>'BackWPup'));
|
246 |
+
|
247 |
+
return $backwpup_static['LOGFILE'];
|
248 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
job/show_working.php
CHANGED
@@ -1,90 +1,89 @@
|
|
1 |
-
<?PHP
|
2 |
-
function backwpup_read_logfile($logfile) {
|
3 |
-
if (is_file($logfile) and substr($logfile,-3)=='.gz')
|
4 |
-
$logfiledata=gzfile($logfile);
|
5 |
-
elseif (is_file($logfile.'.gz'))
|
6 |
-
$logfiledata=gzfile($logfile.'.gz');
|
7 |
-
elseif (is_file($logfile))
|
8 |
-
$logfiledata=file($logfile);
|
9 |
-
else
|
10 |
-
return array();
|
11 |
-
$lines=array();
|
12 |
-
$start=false;
|
13 |
-
foreach ($logfiledata as $line){
|
14 |
-
$line=trim($line);
|
15 |
-
if (strripos($line,'<body')!== false) { // jop over header
|
16 |
-
$start=true;
|
17 |
-
continue;
|
18 |
-
}
|
19 |
-
if ($line!='</body>' and $line!='</html>' and $start) //no Footer
|
20 |
-
$lines[]=$line;
|
21 |
-
}
|
22 |
-
return $lines;
|
23 |
-
}
|
24 |
-
|
25 |
-
//read log file header
|
26 |
-
function backwpup_read_logheader($logfile) {
|
27 |
-
$headers=array("backwpup_version" => "version","backwpup_logtime" => "logtime","backwpup_errors" => "errors","backwpup_warnings" => "warnings","backwpup_jobid" => "jobid","backwpup_jobname" => "name","backwpup_jobtype" => "type","backwpup_jobruntime" => "runtime","backwpup_backupfilesize" => "backupfilesize");
|
28 |
-
if (!is_readable($logfile))
|
29 |
-
return false;
|
30 |
-
//Read file
|
31 |
-
if (substr($logfile,-3)==".gz") {
|
32 |
-
$fp = gzopen( $logfile, 'r' );
|
33 |
-
$file_data = gzread( $fp, 1536 ); // Pull only the first 1,5kiB of the file in.
|
34 |
-
gzclose( $fp );
|
35 |
-
} else {
|
36 |
-
$fp = fopen( $logfile, 'r' );
|
37 |
-
$file_data = fread( $fp, 1536 ); // Pull only the first 1,5kiB of the file in.
|
38 |
-
fclose( $fp );
|
39 |
-
}
|
40 |
-
//get data form file
|
41 |
-
foreach ($headers as $keyword => $field) {
|
42 |
-
preg_match('/(<meta name="'.$keyword.'" content="(.*)" \/>)/i',$file_data,$content);
|
43 |
-
if (!empty($content))
|
44 |
-
$joddata[$field]=$content[2];
|
45 |
-
else
|
46 |
-
$joddata[$field]='';
|
47 |
-
}
|
48 |
-
if (empty($joddata['logtime']))
|
49 |
-
$joddata['logtime']=filectime($logfile);
|
50 |
-
return $joddata;
|
51 |
-
}
|
52 |
-
|
53 |
-
$logfile=
|
54 |
-
$logfile
|
55 |
-
|
56 |
-
|
57 |
-
if (is_file($logfile.'.gz'))
|
58 |
-
$logfile.='.gz';
|
59 |
-
|
60 |
-
$backwpupjobtemp=
|
61 |
-
$backwpupjobtemp=rtrim(realpath($backwpupjobtemp),'
|
62 |
-
|
63 |
-
$log='';
|
64 |
-
if (is_file($logfile)) {
|
65 |
-
$logpos=
|
66 |
-
$logfilarray=backwpup_read_logfile($logfile);
|
67 |
-
$newpos=count($logfilarray);
|
68 |
-
for ($i=$logpos;$i<count($logfilarray);$i++)
|
69 |
-
$log.=$logfilarray[$i];
|
70 |
-
if (!empty($newpos) && $newpos>0)
|
71 |
-
$logpos=$newpos;
|
72 |
-
|
73 |
-
if (is_file($backwpupjobtemp.'/.running') && $runningfile=file_get_contents($backwpupjobtemp.'/.running')) {
|
74 |
-
$infile=unserialize($runningfile);
|
75 |
-
$warnings=$infile['WORKING']['WARNING'];
|
76 |
-
$errors=$infile['WORKING']['ERROR'];
|
77 |
-
$stepspersent=$infile['STEPSPERSENT'];
|
78 |
-
$steppersent=$infile['STEPPERSENT'];
|
79 |
-
} else {
|
80 |
-
$logheader=backwpup_read_logheader($logfile);
|
81 |
-
$warnings=$logheader['warnings'];
|
82 |
-
$errors=$logheader['errors'];
|
83 |
-
$stepspersent=100;
|
84 |
-
$steppersent=100;
|
85 |
-
$log.='<span id="stopworking"></span>';
|
86 |
-
}
|
87 |
-
echo json_encode(array('logpos'=>$logpos,'LOG'=>$log,'WARNING'=>$warnings,'ERROR'=>$errors,'STEPSPERSENT'=>$stepspersent,'STEPPERSENT'=>$steppersent));
|
88 |
-
}
|
89 |
-
die();
|
90 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
function backwpup_read_logfile($logfile) {
|
3 |
+
if (is_file($logfile) and substr($logfile,-3)=='.gz')
|
4 |
+
$logfiledata=gzfile($logfile);
|
5 |
+
elseif (is_file($logfile.'.gz'))
|
6 |
+
$logfiledata=gzfile($logfile.'.gz');
|
7 |
+
elseif (is_file($logfile))
|
8 |
+
$logfiledata=file($logfile);
|
9 |
+
else
|
10 |
+
return array();
|
11 |
+
$lines=array();
|
12 |
+
$start=false;
|
13 |
+
foreach ($logfiledata as $line){
|
14 |
+
$line=trim($line);
|
15 |
+
if (strripos($line,'<body')!== false) { // jop over header
|
16 |
+
$start=true;
|
17 |
+
continue;
|
18 |
+
}
|
19 |
+
if ($line!='</body>' and $line!='</html>' and $start) //no Footer
|
20 |
+
$lines[]=$line;
|
21 |
+
}
|
22 |
+
return $lines;
|
23 |
+
}
|
24 |
+
|
25 |
+
//read log file header
|
26 |
+
function backwpup_read_logheader($logfile) {
|
27 |
+
$headers=array("backwpup_version" => "version","backwpup_logtime" => "logtime","backwpup_errors" => "errors","backwpup_warnings" => "warnings","backwpup_jobid" => "jobid","backwpup_jobname" => "name","backwpup_jobtype" => "type","backwpup_jobruntime" => "runtime","backwpup_backupfilesize" => "backupfilesize");
|
28 |
+
if (!is_readable($logfile))
|
29 |
+
return false;
|
30 |
+
//Read file
|
31 |
+
if (substr($logfile,-3)==".gz") {
|
32 |
+
$fp = gzopen( $logfile, 'r' );
|
33 |
+
$file_data = gzread( $fp, 1536 ); // Pull only the first 1,5kiB of the file in.
|
34 |
+
gzclose( $fp );
|
35 |
+
} else {
|
36 |
+
$fp = fopen( $logfile, 'r' );
|
37 |
+
$file_data = fread( $fp, 1536 ); // Pull only the first 1,5kiB of the file in.
|
38 |
+
fclose( $fp );
|
39 |
+
}
|
40 |
+
//get data form file
|
41 |
+
foreach ($headers as $keyword => $field) {
|
42 |
+
preg_match('/(<meta name="'.$keyword.'" content="(.*)" \/>)/i',$file_data,$content);
|
43 |
+
if (!empty($content))
|
44 |
+
$joddata[$field]=$content[2];
|
45 |
+
else
|
46 |
+
$joddata[$field]='';
|
47 |
+
}
|
48 |
+
if (empty($joddata['logtime']))
|
49 |
+
$joddata['logtime']=filectime($logfile);
|
50 |
+
return $joddata;
|
51 |
+
}
|
52 |
+
|
53 |
+
$logfile=realpath($_POST['logfile']);
|
54 |
+
if (substr($logfile,-5)!='.html' && substr(basename($logfile),0,13)!='backwpup_log_')
|
55 |
+
die();
|
56 |
+
|
57 |
+
if (is_file($logfile.'.gz'))
|
58 |
+
$logfile.='.gz';
|
59 |
+
|
60 |
+
$backwpupjobtemp=str_replace('\\','/',dirname(__FILE__).'/../tmp/');
|
61 |
+
$backwpupjobtemp=rtrim(realpath($backwpupjobtemp),'/');
|
62 |
+
|
63 |
+
$log='';
|
64 |
+
if (is_file($logfile)) {
|
65 |
+
$logpos=(int)$_POST['logpos'];
|
66 |
+
$logfilarray=backwpup_read_logfile($logfile);
|
67 |
+
$newpos=count($logfilarray);
|
68 |
+
for ($i=$logpos;$i<count($logfilarray);$i++)
|
69 |
+
$log.=$logfilarray[$i];
|
70 |
+
if (!empty($newpos) && $newpos>0)
|
71 |
+
$logpos=$newpos;
|
72 |
+
|
73 |
+
if (is_file($backwpupjobtemp.'/.running') && $runningfile=file_get_contents($backwpupjobtemp.'/.running')) {
|
74 |
+
$infile=unserialize($runningfile);
|
75 |
+
$warnings=$infile['WORKING']['WARNING'];
|
76 |
+
$errors=$infile['WORKING']['ERROR'];
|
77 |
+
$stepspersent=$infile['STEPSPERSENT'];
|
78 |
+
$steppersent=$infile['STEPPERSENT'];
|
79 |
+
} else {
|
80 |
+
$logheader=backwpup_read_logheader($logfile);
|
81 |
+
$warnings=$logheader['warnings'];
|
82 |
+
$errors=$logheader['errors'];
|
83 |
+
$stepspersent=100;
|
84 |
+
$steppersent=100;
|
85 |
+
$log.='<span id="stopworking"></span>';
|
86 |
+
}
|
87 |
+
echo json_encode(array('logpos'=>$logpos,'LOG'=>$log,'WARNING'=>$warnings,'ERROR'=>$errors,'STEPSPERSENT'=>$stepspersent,'STEPPERSENT'=>$steppersent));
|
88 |
+
}
|
89 |
+
die();
|
|
job/wp_export.php
CHANGED
@@ -1,88 +1,87 @@
|
|
1 |
-
<?PHP
|
2 |
-
if (!defined('BACKWPUP_JOBRUN_FOLDER')) {
|
3 |
-
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
4 |
-
header("Status: 404 Not Found");
|
5 |
-
die();
|
6 |
-
}
|
7 |
-
|
8 |
-
function wp_export() {
|
9 |
-
global $WORKING,$STATIC;
|
10 |
-
$WORKING['STEPTODO']=1;
|
11 |
-
trigger_error(sprintf(__('%d. try for wordpress export to XML file...','backwpup'),$WORKING['WP_EXPORT']['STEP_TRY']),E_USER_NOTICE);
|
12 |
-
need_free_memory(10485760); //10MB free memory
|
13 |
-
if (function_exists('curl_exec')) {
|
14 |
-
$ch = curl_init();
|
15 |
-
curl_setopt($ch, CURLOPT_URL, substr($STATIC['JOBRUNURL'],0,-11).'wp_export_generate.php');
|
16 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
17 |
-
curl_setopt($ch, CURLOPT_POST, true);
|
18 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, array('BackWPupJobTemp'=>$STATIC['TEMPDIR'],'nonce'=>$WORKING['NONCE'],'type'=>'getxmlexport'));
|
19 |
-
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
|
20 |
-
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
|
21 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
22 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
23 |
-
curl_setopt($ch, CURLOPT_USERAGENT, 'BackWPup');
|
24 |
-
if (defined('CURLOPT_PROGRESSFUNCTION')) {
|
25 |
-
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
|
26 |
-
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'curl_progresscallback');
|
27 |
-
curl_setopt($ch, CURLOPT_BUFFERSIZE, 512);
|
28 |
-
}
|
29 |
-
if (!empty($STATIC['CFG']['httpauthuser']) and !empty($STATIC['CFG']['httpauthpassword'])) {
|
30 |
-
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
|
31 |
-
curl_setopt($ch, CURLOPT_USERPWD, $STATIC['CFG']['httpauthuser'].':'.base64_decode($STATIC['CFG']['httpauthpassword']));
|
32 |
-
}
|
33 |
-
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
|
34 |
-
$return=curl_exec($ch);
|
35 |
-
$status=curl_getinfo($ch);
|
36 |
-
if ($status['http_code']>=300 or $status['http_code']<200 or curl_errno($ch)>0) {
|
37 |
-
if (0!=curl_errno($ch))
|
38 |
-
trigger_error(__('cURL:','backwpup').' ('.curl_errno($ch).') '.curl_error($ch),E_USER_ERROR);
|
39 |
-
else
|
40 |
-
trigger_error(__('cURL:','backwpup').' ('.$status['http_code'].') Invalid response.',E_USER_ERROR);
|
41 |
-
} else {
|
42 |
-
file_put_contents($STATIC['TEMPDIR'].preg_replace( '/[^a-z0-9_\-]/', '', strtolower($STATIC['WP']['BLOGNAME'])).'.wordpress.'.date( 'Y-m-d' ).'.xml', $return);
|
43 |
-
}
|
44 |
-
curl_close($ch);
|
45 |
-
} else {
|
46 |
-
//use fopen if no curl
|
47 |
-
$urlParsed=parse_url(substr($STATIC['JOBRUNURL'],0,-11).'wp_export_generate.php');
|
48 |
-
if ($urlParsed['scheme'] == 'https') {
|
49 |
-
$host = 'ssl://' . $urlParsed['host'];
|
50 |
-
$port = (!empty($urlParsed['port'])) ? $urlParsed['port'] : 443;
|
51 |
-
} else {
|
52 |
-
$host = $urlParsed['host'];
|
53 |
-
$port = (!empty($urlParsed['port'])) ? $urlParsed['port'] : 80;
|
54 |
-
}
|
55 |
-
$query=http_build_query(array('BackWPupJobTemp'=>$STATIC['TEMPDIR'],'nonce'=>$WORKING['NONCE'],'type'=>'getxmlexport'));
|
56 |
-
$path=(isset($urlParsed['path']) ? $urlParsed['path'] : '/').(isset($urlParsed['query']) ? '?' . $urlParsed['query'] : '');
|
57 |
-
$header = "POST ".$path." HTTP/1.1\r\n";
|
58 |
-
$header.= "Host: ".$urlParsed['host']."\r\n";
|
59 |
-
$header.= "User-Agent: BackWPup\r\n";
|
60 |
-
$header.= "Content-Type: application/x-www-form-urlencoded\r\n";
|
61 |
-
$header.= "Content-Length: ".strlen($query)."\r\n";
|
62 |
-
if (!empty($STATIC['CFG']['httpauthuser']) and !empty($STATIC['CFG']['httpauthpassword']))
|
63 |
-
$header.= "Authorization: Basic ".base64_encode($STATIC['CFG']['httpauthuser'].':'.base64_decode($STATIC['CFG']['httpauthpassword']))."\r\n";
|
64 |
-
$header.= "Connection: Close\r\n\r\n";
|
65 |
-
$header.=$query;
|
66 |
-
$fp=fsockopen($host, $port, $errno, $errstr, 300);
|
67 |
-
fwrite($fp,$header);
|
68 |
-
$responseHeader='';
|
69 |
-
do {
|
70 |
-
$responseHeader.= fread($fp, 1);
|
71 |
-
} while (!preg_match('/\\r\\n\\r\\n$/', $responseHeader));
|
72 |
-
while (!feof($fp)) {
|
73 |
-
update_working_file();
|
74 |
-
file_put_contents($STATIC['TEMPDIR'].preg_replace( '/[^a-z0-9_\-]/', '', strtolower($STATIC['WP']['BLOGNAME'])).'.wordpress.'.date( 'Y-m-d' ).'.xml', fgets($fp, 256), FILE_APPEND);
|
75 |
-
}
|
76 |
-
fclose($fp);
|
77 |
-
}
|
78 |
-
//add XML file to backupfiles
|
79 |
-
if (is_readable($STATIC['TEMPDIR'].preg_replace( '/[^a-z0-9_\-]/', '', strtolower($STATIC['WP']['BLOGNAME'])).'.wordpress.'.date( 'Y-m-d' ).'.xml')) {
|
80 |
-
$filestat=stat($STATIC['TEMPDIR'].preg_replace( '/[^a-z0-9_\-]/', '', strtolower($STATIC['WP']['BLOGNAME'])).'.wordpress.'.date( 'Y-m-d' ).'.xml');
|
81 |
-
trigger_error(sprintf(__('Add XML export "%1$s" to backup list with %2$s','backwpup'),preg_replace( '/[^a-z0-9_\-]/', '', strtolower($STATIC['WP']['BLOGNAME'])).'.wordpress.'.date( 'Y-m-d' ).'.xml',formatbytes($filestat['size'])),E_USER_NOTICE);
|
82 |
-
$WORKING['ALLFILESIZE']+=$filestat['size'];
|
83 |
-
add_file(array(array('FILE'=>$STATIC['TEMPDIR'].preg_replace( '/[^a-z0-9_\-]/', '', strtolower($STATIC['WP']['BLOGNAME'])).'.wordpress.'.date( 'Y-m-d' ).'.xml','OUTFILE'=>preg_replace( '/[^a-z0-9_\-]/', '', strtolower($STATIC['WP']['BLOGNAME'])).'.wordpress.'.date( 'Y-m-d' ).'.xml','SIZE'=>$filestat['size'],'ATIME'=>$filestat['atime'],'MTIME'=>$filestat['mtime'],'CTIME'=>$filestat['ctime'],'UID'=>$filestat['uid'],'GID'=>$filestat['gid'],'MODE'=>$filestat['mode'])));
|
84 |
-
}
|
85 |
-
$WORKING['STEPDONE']=1;
|
86 |
-
$WORKING['STEPSDONE'][]='WP_EXPORT'; //set done
|
87 |
-
}
|
88 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
if (!defined('BACKWPUP_JOBRUN_FOLDER')) {
|
3 |
+
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
4 |
+
header("Status: 404 Not Found");
|
5 |
+
die();
|
6 |
+
}
|
7 |
+
|
8 |
+
function wp_export() {
|
9 |
+
global $WORKING,$STATIC;
|
10 |
+
$WORKING['STEPTODO']=1;
|
11 |
+
trigger_error(sprintf(__('%d. try for wordpress export to XML file...','backwpup'),$WORKING['WP_EXPORT']['STEP_TRY']),E_USER_NOTICE);
|
12 |
+
need_free_memory(10485760); //10MB free memory
|
13 |
+
if (function_exists('curl_exec')) {
|
14 |
+
$ch = curl_init();
|
15 |
+
curl_setopt($ch, CURLOPT_URL, substr($STATIC['JOBRUNURL'],0,-11).'wp_export_generate.php');
|
16 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
17 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
18 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, array('BackWPupJobTemp'=>$STATIC['TEMPDIR'],'nonce'=>$WORKING['NONCE'],'type'=>'getxmlexport'));
|
19 |
+
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
|
20 |
+
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
|
21 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
22 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
23 |
+
curl_setopt($ch, CURLOPT_USERAGENT, 'BackWPup');
|
24 |
+
if (defined('CURLOPT_PROGRESSFUNCTION')) {
|
25 |
+
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
|
26 |
+
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'curl_progresscallback');
|
27 |
+
curl_setopt($ch, CURLOPT_BUFFERSIZE, 512);
|
28 |
+
}
|
29 |
+
if (!empty($STATIC['CFG']['httpauthuser']) and !empty($STATIC['CFG']['httpauthpassword'])) {
|
30 |
+
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
|
31 |
+
curl_setopt($ch, CURLOPT_USERPWD, $STATIC['CFG']['httpauthuser'].':'.base64_decode($STATIC['CFG']['httpauthpassword']));
|
32 |
+
}
|
33 |
+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
|
34 |
+
$return=curl_exec($ch);
|
35 |
+
$status=curl_getinfo($ch);
|
36 |
+
if ($status['http_code']>=300 or $status['http_code']<200 or curl_errno($ch)>0) {
|
37 |
+
if (0!=curl_errno($ch))
|
38 |
+
trigger_error(__('cURL:','backwpup').' ('.curl_errno($ch).') '.curl_error($ch),E_USER_ERROR);
|
39 |
+
else
|
40 |
+
trigger_error(__('cURL:','backwpup').' ('.$status['http_code'].') Invalid response.',E_USER_ERROR);
|
41 |
+
} else {
|
42 |
+
file_put_contents($STATIC['TEMPDIR'].preg_replace( '/[^a-z0-9_\-]/', '', strtolower($STATIC['WP']['BLOGNAME'])).'.wordpress.'.date( 'Y-m-d' ).'.xml', $return);
|
43 |
+
}
|
44 |
+
curl_close($ch);
|
45 |
+
} else {
|
46 |
+
//use fopen if no curl
|
47 |
+
$urlParsed=parse_url(substr($STATIC['JOBRUNURL'],0,-11).'wp_export_generate.php');
|
48 |
+
if ($urlParsed['scheme'] == 'https') {
|
49 |
+
$host = 'ssl://' . $urlParsed['host'];
|
50 |
+
$port = (!empty($urlParsed['port'])) ? $urlParsed['port'] : 443;
|
51 |
+
} else {
|
52 |
+
$host = $urlParsed['host'];
|
53 |
+
$port = (!empty($urlParsed['port'])) ? $urlParsed['port'] : 80;
|
54 |
+
}
|
55 |
+
$query=http_build_query(array('BackWPupJobTemp'=>$STATIC['TEMPDIR'],'nonce'=>$WORKING['NONCE'],'type'=>'getxmlexport'));
|
56 |
+
$path=(isset($urlParsed['path']) ? $urlParsed['path'] : '/').(isset($urlParsed['query']) ? '?' . $urlParsed['query'] : '');
|
57 |
+
$header = "POST ".$path." HTTP/1.1\r\n";
|
58 |
+
$header.= "Host: ".$urlParsed['host']."\r\n";
|
59 |
+
$header.= "User-Agent: BackWPup\r\n";
|
60 |
+
$header.= "Content-Type: application/x-www-form-urlencoded\r\n";
|
61 |
+
$header.= "Content-Length: ".strlen($query)."\r\n";
|
62 |
+
if (!empty($STATIC['CFG']['httpauthuser']) and !empty($STATIC['CFG']['httpauthpassword']))
|
63 |
+
$header.= "Authorization: Basic ".base64_encode($STATIC['CFG']['httpauthuser'].':'.base64_decode($STATIC['CFG']['httpauthpassword']))."\r\n";
|
64 |
+
$header.= "Connection: Close\r\n\r\n";
|
65 |
+
$header.=$query;
|
66 |
+
$fp=fsockopen($host, $port, $errno, $errstr, 300);
|
67 |
+
fwrite($fp,$header);
|
68 |
+
$responseHeader='';
|
69 |
+
do {
|
70 |
+
$responseHeader.= fread($fp, 1);
|
71 |
+
} while (!preg_match('/\\r\\n\\r\\n$/', $responseHeader));
|
72 |
+
while (!feof($fp)) {
|
73 |
+
update_working_file();
|
74 |
+
file_put_contents($STATIC['TEMPDIR'].preg_replace( '/[^a-z0-9_\-]/', '', strtolower($STATIC['WP']['BLOGNAME'])).'.wordpress.'.date( 'Y-m-d' ).'.xml', fgets($fp, 256), FILE_APPEND);
|
75 |
+
}
|
76 |
+
fclose($fp);
|
77 |
+
}
|
78 |
+
//add XML file to backupfiles
|
79 |
+
if (is_readable($STATIC['TEMPDIR'].preg_replace( '/[^a-z0-9_\-]/', '', strtolower($STATIC['WP']['BLOGNAME'])).'.wordpress.'.date( 'Y-m-d' ).'.xml')) {
|
80 |
+
$filestat=stat($STATIC['TEMPDIR'].preg_replace( '/[^a-z0-9_\-]/', '', strtolower($STATIC['WP']['BLOGNAME'])).'.wordpress.'.date( 'Y-m-d' ).'.xml');
|
81 |
+
trigger_error(sprintf(__('Add XML export "%1$s" to backup list with %2$s','backwpup'),preg_replace( '/[^a-z0-9_\-]/', '', strtolower($STATIC['WP']['BLOGNAME'])).'.wordpress.'.date( 'Y-m-d' ).'.xml',formatbytes($filestat['size'])),E_USER_NOTICE);
|
82 |
+
$WORKING['ALLFILESIZE']+=$filestat['size'];
|
83 |
+
add_file(array(array('FILE'=>$STATIC['TEMPDIR'].preg_replace( '/[^a-z0-9_\-]/', '', strtolower($STATIC['WP']['BLOGNAME'])).'.wordpress.'.date( 'Y-m-d' ).'.xml','OUTFILE'=>preg_replace( '/[^a-z0-9_\-]/', '', strtolower($STATIC['WP']['BLOGNAME'])).'.wordpress.'.date( 'Y-m-d' ).'.xml','SIZE'=>$filestat['size'],'ATIME'=>$filestat['atime'],'MTIME'=>$filestat['mtime'],'CTIME'=>$filestat['ctime'],'UID'=>$filestat['uid'],'GID'=>$filestat['gid'],'MODE'=>$filestat['mode'])));
|
84 |
+
}
|
85 |
+
$WORKING['STEPDONE']=1;
|
86 |
+
$WORKING['STEPSDONE'][]='WP_EXPORT'; //set done
|
87 |
+
}
|
|
job/wp_export_generate.php
CHANGED
@@ -1,21 +1,20 @@
|
|
1 |
-
<?PHP
|
2 |
-
define('DONOTCACHEPAGE', true);
|
3 |
-
define('DONOTCACHEDB', true);
|
4 |
-
define('DONOTMINIFY', true);
|
5 |
-
define('DONOTCDN', true);
|
6 |
-
define('DONOTCACHCEOBJECT', true);
|
7 |
-
define('W3TC_IN_MINIFY',false); //W3TC will not loaded
|
8 |
-
|
9 |
-
$backwpupjobtemp=
|
10 |
-
$backwpupjobtemp=rtrim(realpath($
|
11 |
-
if (!empty($backwpupjobtemp) && is_dir($backwpupjobtemp) && is_file($backwpupjobtemp).'/.running')
|
12 |
-
$runningfile=file_get_contents($backwpupjobtemp.'/.running');
|
13 |
-
$infile=array();
|
14 |
-
if (!empty($runningfile))
|
15 |
-
$infile=unserialize(trim($runningfile));
|
16 |
-
if (is_file(trim($infile['ABSPATH']).'wp-load.php') and $_POST['nonce']==$infile['WORKING']['NONCE'] and $_POST['type']=='getxmlexport') {
|
17 |
-
require_once(trim($infile['ABSPATH']).'wp-load.php'); /** Setup WordPress environment */
|
18 |
-
require_once(trim($infile['ABSPATH']).'wp-admin/includes/export.php');
|
19 |
-
export_wp();
|
20 |
-
}
|
21 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
define('DONOTCACHEPAGE', true);
|
3 |
+
define('DONOTCACHEDB', true);
|
4 |
+
define('DONOTMINIFY', true);
|
5 |
+
define('DONOTCDN', true);
|
6 |
+
define('DONOTCACHCEOBJECT', true);
|
7 |
+
define('W3TC_IN_MINIFY',false); //W3TC will not loaded
|
8 |
+
|
9 |
+
$backwpupjobtemp=str_replace('\\','/',dirname(__FILE__).'/../tmp/');
|
10 |
+
$backwpupjobtemp=rtrim(realpath($STATIC['TEMPDIR']),'/');
|
11 |
+
if (!empty($backwpupjobtemp) && is_dir($backwpupjobtemp) && is_file($backwpupjobtemp).'/.running')
|
12 |
+
$runningfile=file_get_contents($backwpupjobtemp.'/.running');
|
13 |
+
$infile=array();
|
14 |
+
if (!empty($runningfile))
|
15 |
+
$infile=unserialize(trim($runningfile));
|
16 |
+
if (is_file(trim($infile['ABSPATH']).'wp-load.php') and $_POST['nonce']==$infile['WORKING']['NONCE'] and $_POST['type']=='getxmlexport') {
|
17 |
+
require_once(trim($infile['ABSPATH']).'wp-load.php'); /** Setup WordPress environment */
|
18 |
+
require_once(trim($infile['ABSPATH']).'wp-admin/includes/export.php');
|
19 |
+
export_wp();
|
20 |
+
}
|
|
js/31backwpupeditjob.js
CHANGED
@@ -1,270 +1,270 @@
|
|
1 |
-
jQuery(document).ready( function($) {
|
2 |
-
|
3 |
-
$('.if-js-closed').removeClass('if-js-closed').addClass('closed');
|
4 |
-
|
5 |
-
$('.jobtype-select').change(function() {
|
6 |
-
if ( true == $('#jobtype-select-FILE').attr('checked') || true == $('#jobtype-select-DB').attr('checked') || true == $('#jobtype-select-WPEXP').attr('checked')) {
|
7 |
-
$('#backwpup_jobedit_destfolder').show();
|
8 |
-
$('#backwpup_jobedit_destftp').show();
|
9 |
-
$('#backwpup_jobedit_dests3').show();
|
10 |
-
$('#backwpup_jobedit_destgstorage').show();
|
11 |
-
$('#backwpup_jobedit_destazure').show();
|
12 |
-
$('#backwpup_jobedit_destrsc').show();
|
13 |
-
$('#backwpup_jobedit_destdropbox').show();
|
14 |
-
$('#backwpup_jobedit_destsugarsync').show();
|
15 |
-
$('#backwpup_jobedit_destfile').show();
|
16 |
-
$('#backwpup_jobedit_destmail').show();
|
17 |
-
} else {
|
18 |
-
$('#backwpup_jobedit_destfolder').hide();
|
19 |
-
$('#backwpup_jobedit_destftp').hide();
|
20 |
-
$('#backwpup_jobedit_dests3').hide();
|
21 |
-
$('#backwpup_jobedit_destgstorage').hide();
|
22 |
-
$('#backwpup_jobedit_destazure').hide();
|
23 |
-
$('#backwpup_jobedit_destrsc').hide();
|
24 |
-
$('#backwpup_jobedit_destdropbox').hide();
|
25 |
-
$('#backwpup_jobedit_destsugarsync').hide();
|
26 |
-
$('#backwpup_jobedit_destfile').hide();
|
27 |
-
$('#backwpup_jobedit_destmail').hide();
|
28 |
-
}
|
29 |
-
if ( true == $('#jobtype-select-DB').attr('checked') || true == $('#jobtype-select-CHECK').attr('checked') || true == $('#jobtype-select-OPTIMIZE').attr('checked')) {
|
30 |
-
$('#databasejobs').show();
|
31 |
-
} else {
|
32 |
-
$('#databasejobs').hide();
|
33 |
-
}
|
34 |
-
if ( true == $('#jobtype-select-DB').attr('checked')) {
|
35 |
-
$('#dbshortinsert').show();
|
36 |
-
} else {
|
37 |
-
$('#dbshortinsert').hide();
|
38 |
-
}
|
39 |
-
if ( true == $('#jobtype-select-FILE').attr('checked')) {
|
40 |
-
$('#filebackup').show();
|
41 |
-
} else {
|
42 |
-
$('#filebackup').hide();
|
43 |
-
}
|
44 |
-
});
|
45 |
-
|
46 |
-
$('input[name="cronselect"]').change(function() {
|
47 |
-
if ( 'basic' == $('input[name="cronselect"]:checked').val()) {
|
48 |
-
$('#schedadvanced').hide();
|
49 |
-
$('#schedbasic').show();
|
50 |
-
cronstampbasic();
|
51 |
-
} else {
|
52 |
-
$('#schedadvanced').show();
|
53 |
-
$('#schedbasic').hide();
|
54 |
-
cronstampadvanced();
|
55 |
-
}
|
56 |
-
});
|
57 |
-
|
58 |
-
$('input[name="fileprefix"]').keyup(function() {
|
59 |
-
$('#backupfileprefix').replaceWith('<span id="backupfileprefix">'+$(this).val()+'</span>');
|
60 |
-
});
|
61 |
-
|
62 |
-
$('input[name="fileformart"]').change(function() {
|
63 |
-
$('#backupfileformart').replaceWith('<span id="backupfileformart">'+$(this).val()+'</span>');
|
64 |
-
});
|
65 |
-
|
66 |
-
function cronstampadvanced() {
|
67 |
-
var cronminutes = [];
|
68 |
-
var cronhours = [];
|
69 |
-
var cronmday = [];
|
70 |
-
var cronmon = [];
|
71 |
-
var cronwday = [];
|
72 |
-
$('input[name="cronminutes[]"]:checked').each(function() {
|
73 |
-
cronminutes.push($(this).val());
|
74 |
-
});
|
75 |
-
$('input[name="cronhours[]"]:checked').each(function() {
|
76 |
-
cronhours.push($(this).val());
|
77 |
-
});
|
78 |
-
$('input[name="cronmday[]"]:checked').each(function() {
|
79 |
-
cronmday.push($(this).val());
|
80 |
-
});
|
81 |
-
$('input[name="cronmon[]"]:checked').each(function() {
|
82 |
-
cronmon.push($(this).val());
|
83 |
-
});
|
84 |
-
$('input[name="cronwday[]"]:checked').each(function() {
|
85 |
-
cronwday.push($(this).val());
|
86 |
-
});
|
87 |
-
var data = {
|
88 |
-
action: 'backwpup_get_cron_text',
|
89 |
-
backwpupajaxpage: 'backwpupeditjob',
|
90 |
-
cronminutes: cronminutes,
|
91 |
-
cronhours: cronhours,
|
92 |
-
cronmday: cronmday,
|
93 |
-
cronmon: cronmon,
|
94 |
-
cronwday: cronwday,
|
95 |
-
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
96 |
-
};
|
97 |
-
$.post(ajaxurl, data, function(response) {
|
98 |
-
$('#cron-text').replaceWith(response);
|
99 |
-
});
|
100 |
-
}
|
101 |
-
$('input[name="cronminutes[]"]').change(function() {cronstampadvanced();});
|
102 |
-
$('input[name="cronhours[]"]').change(function() {cronstampadvanced();});
|
103 |
-
$('input[name="cronmday[]"]').change(function() {cronstampadvanced();});
|
104 |
-
$('input[name="cronmon[]"]').change(function() {cronstampadvanced();});
|
105 |
-
$('input[name="cronwday[]"]').change(function() {cronstampadvanced();});
|
106 |
-
|
107 |
-
function cronstampbasic() {
|
108 |
-
var cronminutes = [];
|
109 |
-
var cronhours = [];
|
110 |
-
var cronmday = [];
|
111 |
-
var cronmon = [];
|
112 |
-
var cronwday = [];
|
113 |
-
if ( 'mon' == $('input[name="cronbtype"]:checked').val()) {
|
114 |
-
cronminutes.push($('select[name="moncronminutes"]').val());
|
115 |
-
cronhours.push($('select[name="moncronhours"]').val());
|
116 |
-
cronmday.push($('select[name="moncronmday"]').val());
|
117 |
-
cronmon.push('*');
|
118 |
-
cronwday.push('*');
|
119 |
-
}
|
120 |
-
if ( 'week' == $('input[name="cronbtype"]:checked').val()) {
|
121 |
-
cronminutes.push($('select[name="weekcronminutes"]').val());
|
122 |
-
cronhours.push($('select[name="weekcronhours"]').val());
|
123 |
-
cronmday.push('*');
|
124 |
-
cronmon.push('*');
|
125 |
-
cronwday.push($('select[name="weekcronwday"]').val());
|
126 |
-
}
|
127 |
-
if ( 'day' == $('input[name="cronbtype"]:checked').val()) {
|
128 |
-
cronminutes.push($('select[name="daycronminutes"]').val());
|
129 |
-
cronhours.push($('select[name="daycronhours"]').val());
|
130 |
-
cronmday.push('*');
|
131 |
-
cronmon.push('*');
|
132 |
-
cronwday.push('*');
|
133 |
-
}
|
134 |
-
if ( 'hour' == $('input[name="cronbtype"]:checked').val()) {
|
135 |
-
cronminutes.push($('select[name="hourcronminutes"]').val());
|
136 |
-
cronhours.push('*');
|
137 |
-
cronmday.push('*');
|
138 |
-
cronmon.push('*');
|
139 |
-
cronwday.push('*');
|
140 |
-
}
|
141 |
-
var data = {
|
142 |
-
action: 'backwpup_get_cron_text',
|
143 |
-
backwpupajaxpage: 'backwpupeditjob',
|
144 |
-
cronminutes: cronminutes,
|
145 |
-
cronhours: cronhours,
|
146 |
-
cronmday: cronmday,
|
147 |
-
cronmon: cronmon,
|
148 |
-
cronwday: cronwday,
|
149 |
-
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
150 |
-
};
|
151 |
-
$.post(ajaxurl, data, function(response) {
|
152 |
-
$('#cron-text').replaceWith(response);
|
153 |
-
});
|
154 |
-
}
|
155 |
-
$('input[name="cronbtype"]').change(function() {cronstampbasic();});
|
156 |
-
$('select[name="moncronmday"]').change(function() {cronstampbasic();});
|
157 |
-
$('select[name="moncronhours"]').change(function() {cronstampbasic();});
|
158 |
-
$('select[name="moncronminutes"]').change(function() {cronstampbasic();});
|
159 |
-
$('select[name="weekcronwday"]').change(function() {cronstampbasic();});
|
160 |
-
$('select[name="weekcronhours"]').change(function() {cronstampbasic();});
|
161 |
-
$('select[name="weekcronminutes"]').change(function() {cronstampbasic();});
|
162 |
-
$('select[name="daycronhours"]').change(function() {cronstampbasic();});
|
163 |
-
$('select[name="daycronminutes"]').change(function() {cronstampbasic();});
|
164 |
-
$('select[name="hourcronminutes"]').change(function() {cronstampbasic();});
|
165 |
-
|
166 |
-
|
167 |
-
function awsgetbucket() {
|
168 |
-
var data = {
|
169 |
-
action: 'backwpup_get_aws_buckets',
|
170 |
-
backwpupajaxpage: 'backwpupeditjob',
|
171 |
-
awsAccessKey: jQuery('#awsAccessKey').val(),
|
172 |
-
awsSecretKey: jQuery('#awsSecretKey').val(),
|
173 |
-
awsselected: jQuery('#awsBucketselected').val(),
|
174 |
-
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
175 |
-
};
|
176 |
-
$.post(ajaxurl, data, function(response) {
|
177 |
-
$('#awsBucket').remove();
|
178 |
-
$('#awsBucketselected').after(response);
|
179 |
-
});
|
180 |
-
}
|
181 |
-
$('#awsAccessKey').change(function() {awsgetbucket();});
|
182 |
-
$('#awsSecretKey').change(function() {awsgetbucket();});
|
183 |
-
|
184 |
-
function gstoragegetbucket() {
|
185 |
-
var data = {
|
186 |
-
action: 'backwpup_get_gstorage_buckets',
|
187 |
-
backwpupajaxpage: 'backwpupeditjob',
|
188 |
-
GStorageAccessKey: jQuery('#GStorageAccessKey').val(),
|
189 |
-
GStorageSecret: jQuery('#GStorageSecret').val(),
|
190 |
-
GStorageselected: jQuery('#GStorageselected').val(),
|
191 |
-
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
192 |
-
};
|
193 |
-
$.post(ajaxurl, data, function(response) {
|
194 |
-
$('#GStorageBucket').remove();
|
195 |
-
$('#GStorageselected').after(response);
|
196 |
-
});
|
197 |
-
}
|
198 |
-
$('#GStorageAccessKey').change(function() {gstoragegetbucket();});
|
199 |
-
$('#GStorageSecret').change(function() {gstoragegetbucket();});
|
200 |
-
|
201 |
-
function msazuregetcontainer() {
|
202 |
-
var data = {
|
203 |
-
action: 'backwpup_get_msazure_container',
|
204 |
-
backwpupajaxpage: 'backwpupeditjob',
|
205 |
-
msazureHost: jQuery('#msazureHost').val(),
|
206 |
-
msazureAccName: jQuery('#msazureAccName').val(),
|
207 |
-
msazureKey: jQuery('#msazureKey').val(),
|
208 |
-
msazureselected: jQuery('#msazureContainerselected').val(),
|
209 |
-
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
210 |
-
};
|
211 |
-
$.post(ajaxurl, data, function(response) {
|
212 |
-
$('#msazureContainer').remove();
|
213 |
-
$('#msazureContainerselected').after(response);
|
214 |
-
});
|
215 |
-
}
|
216 |
-
$('#msazureHost').change(function() {msazuregetcontainer();});
|
217 |
-
$('#msazureAccName').change(function() {msazuregetcontainer();});
|
218 |
-
$('#msazureKey').change(function() {msazuregetcontainer();});
|
219 |
-
|
220 |
-
function rscgetcontainer() {
|
221 |
-
var data = {
|
222 |
-
action: 'backwpup_get_rsc_container',
|
223 |
-
backwpupajaxpage: 'backwpupeditjob',
|
224 |
-
rscUsername: jQuery('#rscUsername').val(),
|
225 |
-
rscAPIKey: jQuery('#rscAPIKey').val(),
|
226 |
-
rscselected: jQuery('#rscContainerselected').val(),
|
227 |
-
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
228 |
-
};
|
229 |
-
$.post(ajaxurl, data, function(response) {
|
230 |
-
$('#rscContainer').remove();
|
231 |
-
$('#rscContainerselected').after(response);
|
232 |
-
});
|
233 |
-
}
|
234 |
-
$('#rscUsername').change(function() {rscgetcontainer();});
|
235 |
-
$('#rscAPIKey').change(function() {rscgetcontainer();});
|
236 |
-
|
237 |
-
function sugarsyncgetroot() {
|
238 |
-
var data = {
|
239 |
-
action: 'backwpup_get_sugarsync_root',
|
240 |
-
backwpupajaxpage: 'backwpupeditjob',
|
241 |
-
sugaruser: jQuery('#sugaruser').val(),
|
242 |
-
sugarpass: jQuery('#sugarpass').val(),
|
243 |
-
sugarrootselected: jQuery('#sugarrootselected').val(),
|
244 |
-
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
245 |
-
};
|
246 |
-
$.post(ajaxurl, data, function(response) {
|
247 |
-
$('#sugarroot').remove();
|
248 |
-
$('#sugarrootselected').after(response);
|
249 |
-
});
|
250 |
-
}
|
251 |
-
$('#sugaruser').change(function() {sugarsyncgetroot();});
|
252 |
-
$('#sugarpass').change(function() {sugarsyncgetroot();});
|
253 |
-
|
254 |
-
if ( $('#title').val() == '' )
|
255 |
-
$('#title').siblings('#title-prompt-text').css('visibility', '');
|
256 |
-
$('#title-prompt-text').click(function(){
|
257 |
-
$(this).css('visibility', 'hidden').siblings('#title').focus();
|
258 |
-
});
|
259 |
-
$('#title').blur(function(){
|
260 |
-
if (this.value == '')
|
261 |
-
$(this).siblings('#title-prompt-text').css('visibility', '');
|
262 |
-
}).focus(function(){
|
263 |
-
$(this).siblings('#title-prompt-text').css('visibility', 'hidden');
|
264 |
-
}).keydown(function(e){
|
265 |
-
$(this).siblings('#title-prompt-text').css('visibility', 'hidden');
|
266 |
-
$(this).unbind(e);
|
267 |
-
});
|
268 |
-
|
269 |
-
});
|
270 |
-
|
1 |
+
jQuery(document).ready( function($) {
|
2 |
+
|
3 |
+
$('.if-js-closed').removeClass('if-js-closed').addClass('closed');
|
4 |
+
|
5 |
+
$('.jobtype-select').change(function() {
|
6 |
+
if ( true == $('#jobtype-select-FILE').attr('checked') || true == $('#jobtype-select-DB').attr('checked') || true == $('#jobtype-select-WPEXP').attr('checked')) {
|
7 |
+
$('#backwpup_jobedit_destfolder').show();
|
8 |
+
$('#backwpup_jobedit_destftp').show();
|
9 |
+
$('#backwpup_jobedit_dests3').show();
|
10 |
+
$('#backwpup_jobedit_destgstorage').show();
|
11 |
+
$('#backwpup_jobedit_destazure').show();
|
12 |
+
$('#backwpup_jobedit_destrsc').show();
|
13 |
+
$('#backwpup_jobedit_destdropbox').show();
|
14 |
+
$('#backwpup_jobedit_destsugarsync').show();
|
15 |
+
$('#backwpup_jobedit_destfile').show();
|
16 |
+
$('#backwpup_jobedit_destmail').show();
|
17 |
+
} else {
|
18 |
+
$('#backwpup_jobedit_destfolder').hide();
|
19 |
+
$('#backwpup_jobedit_destftp').hide();
|
20 |
+
$('#backwpup_jobedit_dests3').hide();
|
21 |
+
$('#backwpup_jobedit_destgstorage').hide();
|
22 |
+
$('#backwpup_jobedit_destazure').hide();
|
23 |
+
$('#backwpup_jobedit_destrsc').hide();
|
24 |
+
$('#backwpup_jobedit_destdropbox').hide();
|
25 |
+
$('#backwpup_jobedit_destsugarsync').hide();
|
26 |
+
$('#backwpup_jobedit_destfile').hide();
|
27 |
+
$('#backwpup_jobedit_destmail').hide();
|
28 |
+
}
|
29 |
+
if ( true == $('#jobtype-select-DB').attr('checked') || true == $('#jobtype-select-CHECK').attr('checked') || true == $('#jobtype-select-OPTIMIZE').attr('checked')) {
|
30 |
+
$('#databasejobs').show();
|
31 |
+
} else {
|
32 |
+
$('#databasejobs').hide();
|
33 |
+
}
|
34 |
+
if ( true == $('#jobtype-select-DB').attr('checked')) {
|
35 |
+
$('#dbshortinsert').show();
|
36 |
+
} else {
|
37 |
+
$('#dbshortinsert').hide();
|
38 |
+
}
|
39 |
+
if ( true == $('#jobtype-select-FILE').attr('checked')) {
|
40 |
+
$('#filebackup').show();
|
41 |
+
} else {
|
42 |
+
$('#filebackup').hide();
|
43 |
+
}
|
44 |
+
});
|
45 |
+
|
46 |
+
$('input[name="cronselect"]').change(function() {
|
47 |
+
if ( 'basic' == $('input[name="cronselect"]:checked').val()) {
|
48 |
+
$('#schedadvanced').hide();
|
49 |
+
$('#schedbasic').show();
|
50 |
+
cronstampbasic();
|
51 |
+
} else {
|
52 |
+
$('#schedadvanced').show();
|
53 |
+
$('#schedbasic').hide();
|
54 |
+
cronstampadvanced();
|
55 |
+
}
|
56 |
+
});
|
57 |
+
|
58 |
+
$('input[name="fileprefix"]').keyup(function() {
|
59 |
+
$('#backupfileprefix').replaceWith('<span id="backupfileprefix">'+$(this).val()+'</span>');
|
60 |
+
});
|
61 |
+
|
62 |
+
$('input[name="fileformart"]').change(function() {
|
63 |
+
$('#backupfileformart').replaceWith('<span id="backupfileformart">'+$(this).val()+'</span>');
|
64 |
+
});
|
65 |
+
|
66 |
+
function cronstampadvanced() {
|
67 |
+
var cronminutes = [];
|
68 |
+
var cronhours = [];
|
69 |
+
var cronmday = [];
|
70 |
+
var cronmon = [];
|
71 |
+
var cronwday = [];
|
72 |
+
$('input[name="cronminutes[]"]:checked').each(function() {
|
73 |
+
cronminutes.push($(this).val());
|
74 |
+
});
|
75 |
+
$('input[name="cronhours[]"]:checked').each(function() {
|
76 |
+
cronhours.push($(this).val());
|
77 |
+
});
|
78 |
+
$('input[name="cronmday[]"]:checked').each(function() {
|
79 |
+
cronmday.push($(this).val());
|
80 |
+
});
|
81 |
+
$('input[name="cronmon[]"]:checked').each(function() {
|
82 |
+
cronmon.push($(this).val());
|
83 |
+
});
|
84 |
+
$('input[name="cronwday[]"]:checked').each(function() {
|
85 |
+
cronwday.push($(this).val());
|
86 |
+
});
|
87 |
+
var data = {
|
88 |
+
action: 'backwpup_get_cron_text',
|
89 |
+
backwpupajaxpage: 'backwpupeditjob',
|
90 |
+
cronminutes: cronminutes,
|
91 |
+
cronhours: cronhours,
|
92 |
+
cronmday: cronmday,
|
93 |
+
cronmon: cronmon,
|
94 |
+
cronwday: cronwday,
|
95 |
+
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
96 |
+
};
|
97 |
+
$.post(ajaxurl, data, function(response) {
|
98 |
+
$('#cron-text').replaceWith(response);
|
99 |
+
});
|
100 |
+
}
|
101 |
+
$('input[name="cronminutes[]"]').change(function() {cronstampadvanced();});
|
102 |
+
$('input[name="cronhours[]"]').change(function() {cronstampadvanced();});
|
103 |
+
$('input[name="cronmday[]"]').change(function() {cronstampadvanced();});
|
104 |
+
$('input[name="cronmon[]"]').change(function() {cronstampadvanced();});
|
105 |
+
$('input[name="cronwday[]"]').change(function() {cronstampadvanced();});
|
106 |
+
|
107 |
+
function cronstampbasic() {
|
108 |
+
var cronminutes = [];
|
109 |
+
var cronhours = [];
|
110 |
+
var cronmday = [];
|
111 |
+
var cronmon = [];
|
112 |
+
var cronwday = [];
|
113 |
+
if ( 'mon' == $('input[name="cronbtype"]:checked').val()) {
|
114 |
+
cronminutes.push($('select[name="moncronminutes"]').val());
|
115 |
+
cronhours.push($('select[name="moncronhours"]').val());
|
116 |
+
cronmday.push($('select[name="moncronmday"]').val());
|
117 |
+
cronmon.push('*');
|
118 |
+
cronwday.push('*');
|
119 |
+
}
|
120 |
+
if ( 'week' == $('input[name="cronbtype"]:checked').val()) {
|
121 |
+
cronminutes.push($('select[name="weekcronminutes"]').val());
|
122 |
+
cronhours.push($('select[name="weekcronhours"]').val());
|
123 |
+
cronmday.push('*');
|
124 |
+
cronmon.push('*');
|
125 |
+
cronwday.push($('select[name="weekcronwday"]').val());
|
126 |
+
}
|
127 |
+
if ( 'day' == $('input[name="cronbtype"]:checked').val()) {
|
128 |
+
cronminutes.push($('select[name="daycronminutes"]').val());
|
129 |
+
cronhours.push($('select[name="daycronhours"]').val());
|
130 |
+
cronmday.push('*');
|
131 |
+
cronmon.push('*');
|
132 |
+
cronwday.push('*');
|
133 |
+
}
|
134 |
+
if ( 'hour' == $('input[name="cronbtype"]:checked').val()) {
|
135 |
+
cronminutes.push($('select[name="hourcronminutes"]').val());
|
136 |
+
cronhours.push('*');
|
137 |
+
cronmday.push('*');
|
138 |
+
cronmon.push('*');
|
139 |
+
cronwday.push('*');
|
140 |
+
}
|
141 |
+
var data = {
|
142 |
+
action: 'backwpup_get_cron_text',
|
143 |
+
backwpupajaxpage: 'backwpupeditjob',
|
144 |
+
cronminutes: cronminutes,
|
145 |
+
cronhours: cronhours,
|
146 |
+
cronmday: cronmday,
|
147 |
+
cronmon: cronmon,
|
148 |
+
cronwday: cronwday,
|
149 |
+
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
150 |
+
};
|
151 |
+
$.post(ajaxurl, data, function(response) {
|
152 |
+
$('#cron-text').replaceWith(response);
|
153 |
+
});
|
154 |
+
}
|
155 |
+
$('input[name="cronbtype"]').change(function() {cronstampbasic();});
|
156 |
+
$('select[name="moncronmday"]').change(function() {cronstampbasic();});
|
157 |
+
$('select[name="moncronhours"]').change(function() {cronstampbasic();});
|
158 |
+
$('select[name="moncronminutes"]').change(function() {cronstampbasic();});
|
159 |
+
$('select[name="weekcronwday"]').change(function() {cronstampbasic();});
|
160 |
+
$('select[name="weekcronhours"]').change(function() {cronstampbasic();});
|
161 |
+
$('select[name="weekcronminutes"]').change(function() {cronstampbasic();});
|
162 |
+
$('select[name="daycronhours"]').change(function() {cronstampbasic();});
|
163 |
+
$('select[name="daycronminutes"]').change(function() {cronstampbasic();});
|
164 |
+
$('select[name="hourcronminutes"]').change(function() {cronstampbasic();});
|
165 |
+
|
166 |
+
|
167 |
+
function awsgetbucket() {
|
168 |
+
var data = {
|
169 |
+
action: 'backwpup_get_aws_buckets',
|
170 |
+
backwpupajaxpage: 'backwpupeditjob',
|
171 |
+
awsAccessKey: jQuery('#awsAccessKey').val(),
|
172 |
+
awsSecretKey: jQuery('#awsSecretKey').val(),
|
173 |
+
awsselected: jQuery('#awsBucketselected').val(),
|
174 |
+
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
175 |
+
};
|
176 |
+
$.post(ajaxurl, data, function(response) {
|
177 |
+
$('#awsBucket').remove();
|
178 |
+
$('#awsBucketselected').after(response);
|
179 |
+
});
|
180 |
+
}
|
181 |
+
$('#awsAccessKey').change(function() {awsgetbucket();});
|
182 |
+
$('#awsSecretKey').change(function() {awsgetbucket();});
|
183 |
+
|
184 |
+
function gstoragegetbucket() {
|
185 |
+
var data = {
|
186 |
+
action: 'backwpup_get_gstorage_buckets',
|
187 |
+
backwpupajaxpage: 'backwpupeditjob',
|
188 |
+
GStorageAccessKey: jQuery('#GStorageAccessKey').val(),
|
189 |
+
GStorageSecret: jQuery('#GStorageSecret').val(),
|
190 |
+
GStorageselected: jQuery('#GStorageselected').val(),
|
191 |
+
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
192 |
+
};
|
193 |
+
$.post(ajaxurl, data, function(response) {
|
194 |
+
$('#GStorageBucket').remove();
|
195 |
+
$('#GStorageselected').after(response);
|
196 |
+
});
|
197 |
+
}
|
198 |
+
$('#GStorageAccessKey').change(function() {gstoragegetbucket();});
|
199 |
+
$('#GStorageSecret').change(function() {gstoragegetbucket();});
|
200 |
+
|
201 |
+
function msazuregetcontainer() {
|
202 |
+
var data = {
|
203 |
+
action: 'backwpup_get_msazure_container',
|
204 |
+
backwpupajaxpage: 'backwpupeditjob',
|
205 |
+
msazureHost: jQuery('#msazureHost').val(),
|
206 |
+
msazureAccName: jQuery('#msazureAccName').val(),
|
207 |
+
msazureKey: jQuery('#msazureKey').val(),
|
208 |
+
msazureselected: jQuery('#msazureContainerselected').val(),
|
209 |
+
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
210 |
+
};
|
211 |
+
$.post(ajaxurl, data, function(response) {
|
212 |
+
$('#msazureContainer').remove();
|
213 |
+
$('#msazureContainerselected').after(response);
|
214 |
+
});
|
215 |
+
}
|
216 |
+
$('#msazureHost').change(function() {msazuregetcontainer();});
|
217 |
+
$('#msazureAccName').change(function() {msazuregetcontainer();});
|
218 |
+
$('#msazureKey').change(function() {msazuregetcontainer();});
|
219 |
+
|
220 |
+
function rscgetcontainer() {
|
221 |
+
var data = {
|
222 |
+
action: 'backwpup_get_rsc_container',
|
223 |
+
backwpupajaxpage: 'backwpupeditjob',
|
224 |
+
rscUsername: jQuery('#rscUsername').val(),
|
225 |
+
rscAPIKey: jQuery('#rscAPIKey').val(),
|
226 |
+
rscselected: jQuery('#rscContainerselected').val(),
|
227 |
+
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
228 |
+
};
|
229 |
+
$.post(ajaxurl, data, function(response) {
|
230 |
+
$('#rscContainer').remove();
|
231 |
+
$('#rscContainerselected').after(response);
|
232 |
+
});
|
233 |
+
}
|
234 |
+
$('#rscUsername').change(function() {rscgetcontainer();});
|
235 |
+
$('#rscAPIKey').change(function() {rscgetcontainer();});
|
236 |
+
|
237 |
+
function sugarsyncgetroot() {
|
238 |
+
var data = {
|
239 |
+
action: 'backwpup_get_sugarsync_root',
|
240 |
+
backwpupajaxpage: 'backwpupeditjob',
|
241 |
+
sugaruser: jQuery('#sugaruser').val(),
|
242 |
+
sugarpass: jQuery('#sugarpass').val(),
|
243 |
+
sugarrootselected: jQuery('#sugarrootselected').val(),
|
244 |
+
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
245 |
+
};
|
246 |
+
$.post(ajaxurl, data, function(response) {
|
247 |
+
$('#sugarroot').remove();
|
248 |
+
$('#sugarrootselected').after(response);
|
249 |
+
});
|
250 |
+
}
|
251 |
+
$('#sugaruser').change(function() {sugarsyncgetroot();});
|
252 |
+
$('#sugarpass').change(function() {sugarsyncgetroot();});
|
253 |
+
|
254 |
+
if ( $('#title').val() == '' )
|
255 |
+
$('#title').siblings('#title-prompt-text').css('visibility', '');
|
256 |
+
$('#title-prompt-text').click(function(){
|
257 |
+
$(this).css('visibility', 'hidden').siblings('#title').focus();
|
258 |
+
});
|
259 |
+
$('#title').blur(function(){
|
260 |
+
if (this.value == '')
|
261 |
+
$(this).siblings('#title-prompt-text').css('visibility', '');
|
262 |
+
}).focus(function(){
|
263 |
+
$(this).siblings('#title-prompt-text').css('visibility', 'hidden');
|
264 |
+
}).keydown(function(e){
|
265 |
+
$(this).siblings('#title-prompt-text').css('visibility', 'hidden');
|
266 |
+
$(this).unbind(e);
|
267 |
+
});
|
268 |
+
|
269 |
+
});
|
270 |
+
|
js/backwpup.js
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
jQuery(document).ready( function($) {
|
2 |
-
$('.waiting').each( function (index) {
|
3 |
-
var jobid = $(this).attr('id').replace('image-wait-',''),
|
4 |
-
data = {
|
5 |
-
action: 'backwpup_show_info_td',
|
6 |
-
backwpupajaxpage: 'backwpup',
|
7 |
-
jobid: jobid,
|
8 |
-
mode: jQuery('input[name="mode"]').val(),
|
9 |
-
_ajax_nonce: jQuery('#backwpupajaxnonce').val()
|
10 |
-
};
|
11 |
-
$.post(ajaxurl, data, function(response) {
|
12 |
-
$('#image-wait-' + jobid).css('display','none');
|
13 |
-
$('#image-wait-' + jobid).after(response);
|
14 |
-
});
|
15 |
-
});
|
16 |
-
});
|
17 |
-
|
1 |
+
jQuery(document).ready( function($) {
|
2 |
+
$('.waiting').each( function (index) {
|
3 |
+
var jobid = $(this).attr('id').replace('image-wait-',''),
|
4 |
+
data = {
|
5 |
+
action: 'backwpup_show_info_td',
|
6 |
+
backwpupajaxpage: 'backwpup',
|
7 |
+
jobid: jobid,
|
8 |
+
mode: jQuery('input[name="mode"]').val(),
|
9 |
+
_ajax_nonce: jQuery('#backwpupajaxnonce').val()
|
10 |
+
};
|
11 |
+
$.post(ajaxurl, data, function(response) {
|
12 |
+
$('#image-wait-' + jobid).css('display','none');
|
13 |
+
$('#image-wait-' + jobid).after(response);
|
14 |
+
});
|
15 |
+
});
|
16 |
+
});
|
17 |
+
|
js/backwpupeditjob.js
CHANGED
@@ -1,270 +1,270 @@
|
|
1 |
-
jQuery(document).ready( function($) {
|
2 |
-
|
3 |
-
$('.if-js-closed').removeClass('if-js-closed').addClass('closed');
|
4 |
-
|
5 |
-
$('.jobtype-select').change(function() {
|
6 |
-
if ( true == $('#jobtype-select-FILE').prop('checked') || true == $('#jobtype-select-DB').prop('checked') || true == $('#jobtype-select-WPEXP').prop('checked')) {
|
7 |
-
$('#backwpup_jobedit_destfolder').show();
|
8 |
-
$('#backwpup_jobedit_destftp').show();
|
9 |
-
$('#backwpup_jobedit_dests3').show();
|
10 |
-
$('#backwpup_jobedit_destgstorage').show();
|
11 |
-
$('#backwpup_jobedit_destazure').show();
|
12 |
-
$('#backwpup_jobedit_destrsc').show();
|
13 |
-
$('#backwpup_jobedit_destdropbox').show();
|
14 |
-
$('#backwpup_jobedit_destsugarsync').show();
|
15 |
-
$('#backwpup_jobedit_destfile').show();
|
16 |
-
$('#backwpup_jobedit_destmail').show();
|
17 |
-
} else {
|
18 |
-
$('#backwpup_jobedit_destfolder').hide();
|
19 |
-
$('#backwpup_jobedit_destftp').hide();
|
20 |
-
$('#backwpup_jobedit_dests3').hide();
|
21 |
-
$('#backwpup_jobedit_destgstorage').hide();
|
22 |
-
$('#backwpup_jobedit_destazure').hide();
|
23 |
-
$('#backwpup_jobedit_destrsc').hide();
|
24 |
-
$('#backwpup_jobedit_destdropbox').hide();
|
25 |
-
$('#backwpup_jobedit_destsugarsync').hide();
|
26 |
-
$('#backwpup_jobedit_destfile').hide();
|
27 |
-
$('#backwpup_jobedit_destmail').hide();
|
28 |
-
}
|
29 |
-
if ( true == $('#jobtype-select-DB').prop('checked') || true == $('#jobtype-select-CHECK').prop('checked') || true == $('#jobtype-select-OPTIMIZE').prop('checked')) {
|
30 |
-
$('#databasejobs').show();
|
31 |
-
} else {
|
32 |
-
$('#databasejobs').hide();
|
33 |
-
}
|
34 |
-
if ( true == $('#jobtype-select-DB').prop('checked')) {
|
35 |
-
$('#dbshortinsert').show();
|
36 |
-
} else {
|
37 |
-
$('#dbshortinsert').hide();
|
38 |
-
}
|
39 |
-
if ( true == $('#jobtype-select-FILE').prop('checked')) {
|
40 |
-
$('#filebackup').show();
|
41 |
-
} else {
|
42 |
-
$('#filebackup').hide();
|
43 |
-
}
|
44 |
-
});
|
45 |
-
|
46 |
-
$('input[name="cronselect"]').change(function() {
|
47 |
-
if ( 'basic' == $('input[name="cronselect"]:checked').val()) {
|
48 |
-
$('#schedadvanced').hide();
|
49 |
-
$('#schedbasic').show();
|
50 |
-
cronstampbasic();
|
51 |
-
} else {
|
52 |
-
$('#schedadvanced').show();
|
53 |
-
$('#schedbasic').hide();
|
54 |
-
cronstampadvanced();
|
55 |
-
}
|
56 |
-
});
|
57 |
-
|
58 |
-
$('input[name="fileprefix"]').keyup(function() {
|
59 |
-
$('#backupfileprefix').replaceWith('<span id="backupfileprefix">'+$(this).val()+'</span>');
|
60 |
-
});
|
61 |
-
|
62 |
-
$('input[name="fileformart"]').change(function() {
|
63 |
-
$('#backupfileformart').replaceWith('<span id="backupfileformart">'+$(this).val()+'</span>');
|
64 |
-
});
|
65 |
-
|
66 |
-
function cronstampadvanced() {
|
67 |
-
var cronminutes = [];
|
68 |
-
var cronhours = [];
|
69 |
-
var cronmday = [];
|
70 |
-
var cronmon = [];
|
71 |
-
var cronwday = [];
|
72 |
-
$('input[name="cronminutes[]"]:checked').each(function() {
|
73 |
-
cronminutes.push($(this).val());
|
74 |
-
});
|
75 |
-
$('input[name="cronhours[]"]:checked').each(function() {
|
76 |
-
cronhours.push($(this).val());
|
77 |
-
});
|
78 |
-
$('input[name="cronmday[]"]:checked').each(function() {
|
79 |
-
cronmday.push($(this).val());
|
80 |
-
});
|
81 |
-
$('input[name="cronmon[]"]:checked').each(function() {
|
82 |
-
cronmon.push($(this).val());
|
83 |
-
});
|
84 |
-
$('input[name="cronwday[]"]:checked').each(function() {
|
85 |
-
cronwday.push($(this).val());
|
86 |
-
});
|
87 |
-
var data = {
|
88 |
-
action: 'backwpup_get_cron_text',
|
89 |
-
backwpupajaxpage: 'backwpupeditjob',
|
90 |
-
cronminutes: cronminutes,
|
91 |
-
cronhours: cronhours,
|
92 |
-
cronmday: cronmday,
|
93 |
-
cronmon: cronmon,
|
94 |
-
cronwday: cronwday,
|
95 |
-
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
96 |
-
};
|
97 |
-
$.post(ajaxurl, data, function(response) {
|
98 |
-
$('#cron-text').replaceWith(response);
|
99 |
-
});
|
100 |
-
}
|
101 |
-
$('input[name="cronminutes[]"]').change(function() {cronstampadvanced();});
|
102 |
-
$('input[name="cronhours[]"]').change(function() {cronstampadvanced();});
|
103 |
-
$('input[name="cronmday[]"]').change(function() {cronstampadvanced();});
|
104 |
-
$('input[name="cronmon[]"]').change(function() {cronstampadvanced();});
|
105 |
-
$('input[name="cronwday[]"]').change(function() {cronstampadvanced();});
|
106 |
-
|
107 |
-
function cronstampbasic() {
|
108 |
-
var cronminutes = [];
|
109 |
-
var cronhours = [];
|
110 |
-
var cronmday = [];
|
111 |
-
var cronmon = [];
|
112 |
-
var cronwday = [];
|
113 |
-
if ( 'mon' == $('input[name="cronbtype"]:checked').val()) {
|
114 |
-
cronminutes.push($('select[name="moncronminutes"]').val());
|
115 |
-
cronhours.push($('select[name="moncronhours"]').val());
|
116 |
-
cronmday.push($('select[name="moncronmday"]').val());
|
117 |
-
cronmon.push('*');
|
118 |
-
cronwday.push('*');
|
119 |
-
}
|
120 |
-
if ( 'week' == $('input[name="cronbtype"]:checked').val()) {
|
121 |
-
cronminutes.push($('select[name="weekcronminutes"]').val());
|
122 |
-
cronhours.push($('select[name="weekcronhours"]').val());
|
123 |
-
cronmday.push('*');
|
124 |
-
cronmon.push('*');
|
125 |
-
cronwday.push($('select[name="weekcronwday"]').val());
|
126 |
-
}
|
127 |
-
if ( 'day' == $('input[name="cronbtype"]:checked').val()) {
|
128 |
-
cronminutes.push($('select[name="daycronminutes"]').val());
|
129 |
-
cronhours.push($('select[name="daycronhours"]').val());
|
130 |
-
cronmday.push('*');
|
131 |
-
cronmon.push('*');
|
132 |
-
cronwday.push('*');
|
133 |
-
}
|
134 |
-
if ( 'hour' == $('input[name="cronbtype"]:checked').val()) {
|
135 |
-
cronminutes.push($('select[name="hourcronminutes"]').val());
|
136 |
-
cronhours.push('*');
|
137 |
-
cronmday.push('*');
|
138 |
-
cronmon.push('*');
|
139 |
-
cronwday.push('*');
|
140 |
-
}
|
141 |
-
var data = {
|
142 |
-
action: 'backwpup_get_cron_text',
|
143 |
-
backwpupajaxpage: 'backwpupeditjob',
|
144 |
-
cronminutes: cronminutes,
|
145 |
-
cronhours: cronhours,
|
146 |
-
cronmday: cronmday,
|
147 |
-
cronmon: cronmon,
|
148 |
-
cronwday: cronwday,
|
149 |
-
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
150 |
-
};
|
151 |
-
$.post(ajaxurl, data, function(response) {
|
152 |
-
$('#cron-text').replaceWith(response);
|
153 |
-
});
|
154 |
-
}
|
155 |
-
$('input[name="cronbtype"]').change(function() {cronstampbasic();});
|
156 |
-
$('select[name="moncronmday"]').change(function() {cronstampbasic();});
|
157 |
-
$('select[name="moncronhours"]').change(function() {cronstampbasic();});
|
158 |
-
$('select[name="moncronminutes"]').change(function() {cronstampbasic();});
|
159 |
-
$('select[name="weekcronwday"]').change(function() {cronstampbasic();});
|
160 |
-
$('select[name="weekcronhours"]').change(function() {cronstampbasic();});
|
161 |
-
$('select[name="weekcronminutes"]').change(function() {cronstampbasic();});
|
162 |
-
$('select[name="daycronhours"]').change(function() {cronstampbasic();});
|
163 |
-
$('select[name="daycronminutes"]').change(function() {cronstampbasic();});
|
164 |
-
$('select[name="hourcronminutes"]').change(function() {cronstampbasic();});
|
165 |
-
|
166 |
-
|
167 |
-
function awsgetbucket() {
|
168 |
-
var data = {
|
169 |
-
action: 'backwpup_get_aws_buckets',
|
170 |
-
backwpupajaxpage: 'backwpupeditjob',
|
171 |
-
awsAccessKey: jQuery('#awsAccessKey').val(),
|
172 |
-
awsSecretKey: jQuery('#awsSecretKey').val(),
|
173 |
-
awsselected: jQuery('#awsBucketselected').val(),
|
174 |
-
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
175 |
-
};
|
176 |
-
$.post(ajaxurl, data, function(response) {
|
177 |
-
$('#awsBucket').remove();
|
178 |
-
$('#awsBucketselected').after(response);
|
179 |
-
});
|
180 |
-
}
|
181 |
-
$('#awsAccessKey').change(function() {awsgetbucket();});
|
182 |
-
$('#awsSecretKey').change(function() {awsgetbucket();});
|
183 |
-
|
184 |
-
function gstoragegetbucket() {
|
185 |
-
var data = {
|
186 |
-
action: 'backwpup_get_gstorage_buckets',
|
187 |
-
backwpupajaxpage: 'backwpupeditjob',
|
188 |
-
GStorageAccessKey: jQuery('#GStorageAccessKey').val(),
|
189 |
-
GStorageSecret: jQuery('#GStorageSecret').val(),
|
190 |
-
GStorageselected: jQuery('#GStorageselected').val(),
|
191 |
-
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
192 |
-
};
|
193 |
-
$.post(ajaxurl, data, function(response) {
|
194 |
-
$('#GStorageBucket').remove();
|
195 |
-
$('#GStorageselected').after(response);
|
196 |
-
});
|
197 |
-
}
|
198 |
-
$('#GStorageAccessKey').change(function() {gstoragegetbucket();});
|
199 |
-
$('#GStorageSecret').change(function() {gstoragegetbucket();});
|
200 |
-
|
201 |
-
function msazuregetcontainer() {
|
202 |
-
var data = {
|
203 |
-
action: 'backwpup_get_msazure_container',
|
204 |
-
backwpupajaxpage: 'backwpupeditjob',
|
205 |
-
msazureHost: jQuery('#msazureHost').val(),
|
206 |
-
msazureAccName: jQuery('#msazureAccName').val(),
|
207 |
-
msazureKey: jQuery('#msazureKey').val(),
|
208 |
-
msazureselected: jQuery('#msazureContainerselected').val(),
|
209 |
-
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
210 |
-
};
|
211 |
-
$.post(ajaxurl, data, function(response) {
|
212 |
-
$('#msazureContainer').remove();
|
213 |
-
$('#msazureContainerselected').after(response);
|
214 |
-
});
|
215 |
-
}
|
216 |
-
$('#msazureHost').change(function() {msazuregetcontainer();});
|
217 |
-
$('#msazureAccName').change(function() {msazuregetcontainer();});
|
218 |
-
$('#msazureKey').change(function() {msazuregetcontainer();});
|
219 |
-
|
220 |
-
function rscgetcontainer() {
|
221 |
-
var data = {
|
222 |
-
action: 'backwpup_get_rsc_container',
|
223 |
-
backwpupajaxpage: 'backwpupeditjob',
|
224 |
-
rscUsername: jQuery('#rscUsername').val(),
|
225 |
-
rscAPIKey: jQuery('#rscAPIKey').val(),
|
226 |
-
rscselected: jQuery('#rscContainerselected').val(),
|
227 |
-
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
228 |
-
};
|
229 |
-
$.post(ajaxurl, data, function(response) {
|
230 |
-
$('#rscContainer').remove();
|
231 |
-
$('#rscContainerselected').after(response);
|
232 |
-
});
|
233 |
-
}
|
234 |
-
$('#rscUsername').change(function() {rscgetcontainer();});
|
235 |
-
$('#rscAPIKey').change(function() {rscgetcontainer();});
|
236 |
-
|
237 |
-
function sugarsyncgetroot() {
|
238 |
-
var data = {
|
239 |
-
action: 'backwpup_get_sugarsync_root',
|
240 |
-
backwpupajaxpage: 'backwpupeditjob',
|
241 |
-
sugaruser: jQuery('#sugaruser').val(),
|
242 |
-
sugarpass: jQuery('#sugarpass').val(),
|
243 |
-
sugarrootselected: jQuery('#sugarrootselected').val(),
|
244 |
-
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
245 |
-
};
|
246 |
-
$.post(ajaxurl, data, function(response) {
|
247 |
-
$('#sugarroot').remove();
|
248 |
-
$('#sugarrootselected').after(response);
|
249 |
-
});
|
250 |
-
}
|
251 |
-
$('#sugaruser').change(function() {sugarsyncgetroot();});
|
252 |
-
$('#sugarpass').change(function() {sugarsyncgetroot();});
|
253 |
-
|
254 |
-
if ( $('#title').val() == '' )
|
255 |
-
$('#title').siblings('#title-prompt-text').css('visibility', '');
|
256 |
-
$('#title-prompt-text').click(function(){
|
257 |
-
$(this).css('visibility', 'hidden').siblings('#title').focus();
|
258 |
-
});
|
259 |
-
$('#title').blur(function(){
|
260 |
-
if (this.value == '')
|
261 |
-
$(this).siblings('#title-prompt-text').css('visibility', '');
|
262 |
-
}).focus(function(){
|
263 |
-
$(this).siblings('#title-prompt-text').css('visibility', 'hidden');
|
264 |
-
}).keydown(function(e){
|
265 |
-
$(this).siblings('#title-prompt-text').css('visibility', 'hidden');
|
266 |
-
$(this).unbind(e);
|
267 |
-
});
|
268 |
-
|
269 |
-
});
|
270 |
-
|
1 |
+
jQuery(document).ready( function($) {
|
2 |
+
|
3 |
+
$('.if-js-closed').removeClass('if-js-closed').addClass('closed');
|
4 |
+
|
5 |
+
$('.jobtype-select').change(function() {
|
6 |
+
if ( true == $('#jobtype-select-FILE').prop('checked') || true == $('#jobtype-select-DB').prop('checked') || true == $('#jobtype-select-WPEXP').prop('checked')) {
|
7 |
+
$('#backwpup_jobedit_destfolder').show();
|
8 |
+
$('#backwpup_jobedit_destftp').show();
|
9 |
+
$('#backwpup_jobedit_dests3').show();
|
10 |
+
$('#backwpup_jobedit_destgstorage').show();
|
11 |
+
$('#backwpup_jobedit_destazure').show();
|
12 |
+
$('#backwpup_jobedit_destrsc').show();
|
13 |
+
$('#backwpup_jobedit_destdropbox').show();
|
14 |
+
$('#backwpup_jobedit_destsugarsync').show();
|
15 |
+
$('#backwpup_jobedit_destfile').show();
|
16 |
+
$('#backwpup_jobedit_destmail').show();
|
17 |
+
} else {
|
18 |
+
$('#backwpup_jobedit_destfolder').hide();
|
19 |
+
$('#backwpup_jobedit_destftp').hide();
|
20 |
+
$('#backwpup_jobedit_dests3').hide();
|
21 |
+
$('#backwpup_jobedit_destgstorage').hide();
|
22 |
+
$('#backwpup_jobedit_destazure').hide();
|
23 |
+
$('#backwpup_jobedit_destrsc').hide();
|
24 |
+
$('#backwpup_jobedit_destdropbox').hide();
|
25 |
+
$('#backwpup_jobedit_destsugarsync').hide();
|
26 |
+
$('#backwpup_jobedit_destfile').hide();
|
27 |
+
$('#backwpup_jobedit_destmail').hide();
|
28 |
+
}
|
29 |
+
if ( true == $('#jobtype-select-DB').prop('checked') || true == $('#jobtype-select-CHECK').prop('checked') || true == $('#jobtype-select-OPTIMIZE').prop('checked')) {
|
30 |
+
$('#databasejobs').show();
|
31 |
+
} else {
|
32 |
+
$('#databasejobs').hide();
|
33 |
+
}
|
34 |
+
if ( true == $('#jobtype-select-DB').prop('checked')) {
|
35 |
+
$('#dbshortinsert').show();
|
36 |
+
} else {
|
37 |
+
$('#dbshortinsert').hide();
|
38 |
+
}
|
39 |
+
if ( true == $('#jobtype-select-FILE').prop('checked')) {
|
40 |
+
$('#filebackup').show();
|
41 |
+
} else {
|
42 |
+
$('#filebackup').hide();
|
43 |
+
}
|
44 |
+
});
|
45 |
+
|
46 |
+
$('input[name="cronselect"]').change(function() {
|
47 |
+
if ( 'basic' == $('input[name="cronselect"]:checked').val()) {
|
48 |
+
$('#schedadvanced').hide();
|
49 |
+
$('#schedbasic').show();
|
50 |
+
cronstampbasic();
|
51 |
+
} else {
|
52 |
+
$('#schedadvanced').show();
|
53 |
+
$('#schedbasic').hide();
|
54 |
+
cronstampadvanced();
|
55 |
+
}
|
56 |
+
});
|
57 |
+
|
58 |
+
$('input[name="fileprefix"]').keyup(function() {
|
59 |
+
$('#backupfileprefix').replaceWith('<span id="backupfileprefix">'+$(this).val()+'</span>');
|
60 |
+
});
|
61 |
+
|
62 |
+
$('input[name="fileformart"]').change(function() {
|
63 |
+
$('#backupfileformart').replaceWith('<span id="backupfileformart">'+$(this).val()+'</span>');
|
64 |
+
});
|
65 |
+
|
66 |
+
function cronstampadvanced() {
|
67 |
+
var cronminutes = [];
|
68 |
+
var cronhours = [];
|
69 |
+
var cronmday = [];
|
70 |
+
var cronmon = [];
|
71 |
+
var cronwday = [];
|
72 |
+
$('input[name="cronminutes[]"]:checked').each(function() {
|
73 |
+
cronminutes.push($(this).val());
|
74 |
+
});
|
75 |
+
$('input[name="cronhours[]"]:checked').each(function() {
|
76 |
+
cronhours.push($(this).val());
|
77 |
+
});
|
78 |
+
$('input[name="cronmday[]"]:checked').each(function() {
|
79 |
+
cronmday.push($(this).val());
|
80 |
+
});
|
81 |
+
$('input[name="cronmon[]"]:checked').each(function() {
|
82 |
+
cronmon.push($(this).val());
|
83 |
+
});
|
84 |
+
$('input[name="cronwday[]"]:checked').each(function() {
|
85 |
+
cronwday.push($(this).val());
|
86 |
+
});
|
87 |
+
var data = {
|
88 |
+
action: 'backwpup_get_cron_text',
|
89 |
+
backwpupajaxpage: 'backwpupeditjob',
|
90 |
+
cronminutes: cronminutes,
|
91 |
+
cronhours: cronhours,
|
92 |
+
cronmday: cronmday,
|
93 |
+
cronmon: cronmon,
|
94 |
+
cronwday: cronwday,
|
95 |
+
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
96 |
+
};
|
97 |
+
$.post(ajaxurl, data, function(response) {
|
98 |
+
$('#cron-text').replaceWith(response);
|
99 |
+
});
|
100 |
+
}
|
101 |
+
$('input[name="cronminutes[]"]').change(function() {cronstampadvanced();});
|
102 |
+
$('input[name="cronhours[]"]').change(function() {cronstampadvanced();});
|
103 |
+
$('input[name="cronmday[]"]').change(function() {cronstampadvanced();});
|
104 |
+
$('input[name="cronmon[]"]').change(function() {cronstampadvanced();});
|
105 |
+
$('input[name="cronwday[]"]').change(function() {cronstampadvanced();});
|
106 |
+
|
107 |
+
function cronstampbasic() {
|
108 |
+
var cronminutes = [];
|
109 |
+
var cronhours = [];
|
110 |
+
var cronmday = [];
|
111 |
+
var cronmon = [];
|
112 |
+
var cronwday = [];
|
113 |
+
if ( 'mon' == $('input[name="cronbtype"]:checked').val()) {
|
114 |
+
cronminutes.push($('select[name="moncronminutes"]').val());
|
115 |
+
cronhours.push($('select[name="moncronhours"]').val());
|
116 |
+
cronmday.push($('select[name="moncronmday"]').val());
|
117 |
+
cronmon.push('*');
|
118 |
+
cronwday.push('*');
|
119 |
+
}
|
120 |
+
if ( 'week' == $('input[name="cronbtype"]:checked').val()) {
|
121 |
+
cronminutes.push($('select[name="weekcronminutes"]').val());
|
122 |
+
cronhours.push($('select[name="weekcronhours"]').val());
|
123 |
+
cronmday.push('*');
|
124 |
+
cronmon.push('*');
|
125 |
+
cronwday.push($('select[name="weekcronwday"]').val());
|
126 |
+
}
|
127 |
+
if ( 'day' == $('input[name="cronbtype"]:checked').val()) {
|
128 |
+
cronminutes.push($('select[name="daycronminutes"]').val());
|
129 |
+
cronhours.push($('select[name="daycronhours"]').val());
|
130 |
+
cronmday.push('*');
|
131 |
+
cronmon.push('*');
|
132 |
+
cronwday.push('*');
|
133 |
+
}
|
134 |
+
if ( 'hour' == $('input[name="cronbtype"]:checked').val()) {
|
135 |
+
cronminutes.push($('select[name="hourcronminutes"]').val());
|
136 |
+
cronhours.push('*');
|
137 |
+
cronmday.push('*');
|
138 |
+
cronmon.push('*');
|
139 |
+
cronwday.push('*');
|
140 |
+
}
|
141 |
+
var data = {
|
142 |
+
action: 'backwpup_get_cron_text',
|
143 |
+
backwpupajaxpage: 'backwpupeditjob',
|
144 |
+
cronminutes: cronminutes,
|
145 |
+
cronhours: cronhours,
|
146 |
+
cronmday: cronmday,
|
147 |
+
cronmon: cronmon,
|
148 |
+
cronwday: cronwday,
|
149 |
+
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
150 |
+
};
|
151 |
+
$.post(ajaxurl, data, function(response) {
|
152 |
+
$('#cron-text').replaceWith(response);
|
153 |
+
});
|
154 |
+
}
|
155 |
+
$('input[name="cronbtype"]').change(function() {cronstampbasic();});
|
156 |
+
$('select[name="moncronmday"]').change(function() {cronstampbasic();});
|
157 |
+
$('select[name="moncronhours"]').change(function() {cronstampbasic();});
|
158 |
+
$('select[name="moncronminutes"]').change(function() {cronstampbasic();});
|
159 |
+
$('select[name="weekcronwday"]').change(function() {cronstampbasic();});
|
160 |
+
$('select[name="weekcronhours"]').change(function() {cronstampbasic();});
|
161 |
+
$('select[name="weekcronminutes"]').change(function() {cronstampbasic();});
|
162 |
+
$('select[name="daycronhours"]').change(function() {cronstampbasic();});
|
163 |
+
$('select[name="daycronminutes"]').change(function() {cronstampbasic();});
|
164 |
+
$('select[name="hourcronminutes"]').change(function() {cronstampbasic();});
|
165 |
+
|
166 |
+
|
167 |
+
function awsgetbucket() {
|
168 |
+
var data = {
|
169 |
+
action: 'backwpup_get_aws_buckets',
|
170 |
+
backwpupajaxpage: 'backwpupeditjob',
|
171 |
+
awsAccessKey: jQuery('#awsAccessKey').val(),
|
172 |
+
awsSecretKey: jQuery('#awsSecretKey').val(),
|
173 |
+
awsselected: jQuery('#awsBucketselected').val(),
|
174 |
+
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
175 |
+
};
|
176 |
+
$.post(ajaxurl, data, function(response) {
|
177 |
+
$('#awsBucket').remove();
|
178 |
+
$('#awsBucketselected').after(response);
|
179 |
+
});
|
180 |
+
}
|
181 |
+
$('#awsAccessKey').change(function() {awsgetbucket();});
|
182 |
+
$('#awsSecretKey').change(function() {awsgetbucket();});
|
183 |
+
|
184 |
+
function gstoragegetbucket() {
|
185 |
+
var data = {
|
186 |
+
action: 'backwpup_get_gstorage_buckets',
|
187 |
+
backwpupajaxpage: 'backwpupeditjob',
|
188 |
+
GStorageAccessKey: jQuery('#GStorageAccessKey').val(),
|
189 |
+
GStorageSecret: jQuery('#GStorageSecret').val(),
|
190 |
+
GStorageselected: jQuery('#GStorageselected').val(),
|
191 |
+
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
192 |
+
};
|
193 |
+
$.post(ajaxurl, data, function(response) {
|
194 |
+
$('#GStorageBucket').remove();
|
195 |
+
$('#GStorageselected').after(response);
|
196 |
+
});
|
197 |
+
}
|
198 |
+
$('#GStorageAccessKey').change(function() {gstoragegetbucket();});
|
199 |
+
$('#GStorageSecret').change(function() {gstoragegetbucket();});
|
200 |
+
|
201 |
+
function msazuregetcontainer() {
|
202 |
+
var data = {
|
203 |
+
action: 'backwpup_get_msazure_container',
|
204 |
+
backwpupajaxpage: 'backwpupeditjob',
|
205 |
+
msazureHost: jQuery('#msazureHost').val(),
|
206 |
+
msazureAccName: jQuery('#msazureAccName').val(),
|
207 |
+
msazureKey: jQuery('#msazureKey').val(),
|
208 |
+
msazureselected: jQuery('#msazureContainerselected').val(),
|
209 |
+
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
210 |
+
};
|
211 |
+
$.post(ajaxurl, data, function(response) {
|
212 |
+
$('#msazureContainer').remove();
|
213 |
+
$('#msazureContainerselected').after(response);
|
214 |
+
});
|
215 |
+
}
|
216 |
+
$('#msazureHost').change(function() {msazuregetcontainer();});
|
217 |
+
$('#msazureAccName').change(function() {msazuregetcontainer();});
|
218 |
+
$('#msazureKey').change(function() {msazuregetcontainer();});
|
219 |
+
|
220 |
+
function rscgetcontainer() {
|
221 |
+
var data = {
|
222 |
+
action: 'backwpup_get_rsc_container',
|
223 |
+
backwpupajaxpage: 'backwpupeditjob',
|
224 |
+
rscUsername: jQuery('#rscUsername').val(),
|
225 |
+
rscAPIKey: jQuery('#rscAPIKey').val(),
|
226 |
+
rscselected: jQuery('#rscContainerselected').val(),
|
227 |
+
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
228 |
+
};
|
229 |
+
$.post(ajaxurl, data, function(response) {
|
230 |
+
$('#rscContainer').remove();
|
231 |
+
$('#rscContainerselected').after(response);
|
232 |
+
});
|
233 |
+
}
|
234 |
+
$('#rscUsername').change(function() {rscgetcontainer();});
|
235 |
+
$('#rscAPIKey').change(function() {rscgetcontainer();});
|
236 |
+
|
237 |
+
function sugarsyncgetroot() {
|
238 |
+
var data = {
|
239 |
+
action: 'backwpup_get_sugarsync_root',
|
240 |
+
backwpupajaxpage: 'backwpupeditjob',
|
241 |
+
sugaruser: jQuery('#sugaruser').val(),
|
242 |
+
sugarpass: jQuery('#sugarpass').val(),
|
243 |
+
sugarrootselected: jQuery('#sugarrootselected').val(),
|
244 |
+
_ajax_nonce: jQuery('#backwpupeditjobajaxnonce').val()
|
245 |
+
};
|
246 |
+
$.post(ajaxurl, data, function(response) {
|
247 |
+
$('#sugarroot').remove();
|
248 |
+
$('#sugarrootselected').after(response);
|
249 |
+
});
|
250 |
+
}
|
251 |
+
$('#sugaruser').change(function() {sugarsyncgetroot();});
|
252 |
+
$('#sugarpass').change(function() {sugarsyncgetroot();});
|
253 |
+
|
254 |
+
if ( $('#title').val() == '' )
|
255 |
+
$('#title').siblings('#title-prompt-text').css('visibility', '');
|
256 |
+
$('#title-prompt-text').click(function(){
|
257 |
+
$(this).css('visibility', 'hidden').siblings('#title').focus();
|
258 |
+
});
|
259 |
+
$('#title').blur(function(){
|
260 |
+
if (this.value == '')
|
261 |
+
$(this).siblings('#title-prompt-text').css('visibility', '');
|
262 |
+
}).focus(function(){
|
263 |
+
$(this).siblings('#title-prompt-text').css('visibility', 'hidden');
|
264 |
+
}).keydown(function(e){
|
265 |
+
$(this).siblings('#title-prompt-text').css('visibility', 'hidden');
|
266 |
+
$(this).unbind(e);
|
267 |
+
});
|
268 |
+
|
269 |
+
});
|
270 |
+
|
js/backwpupsettings.js
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
jQuery(document).ready( function($) {
|
2 |
-
$('#mailmethod').change(function() {
|
3 |
-
if ( 'SMTP' == $('#mailmethod').val()) {
|
4 |
-
$('.mailsmtp').show();
|
5 |
-
$('#mailsendmail').hide();
|
6 |
-
} else if ( 'Sendmail' == $('#mailmethod').val()) {
|
7 |
-
$('.mailsmtp').hide();
|
8 |
-
$('#mailsendmail').show();
|
9 |
-
} else {
|
10 |
-
$('.mailsmtp').hide();
|
11 |
-
$('#mailsendmail').hide();
|
12 |
-
}
|
13 |
-
});
|
14 |
-
});
|
15 |
-
|
1 |
+
jQuery(document).ready( function($) {
|
2 |
+
$('#mailmethod').change(function() {
|
3 |
+
if ( 'SMTP' == $('#mailmethod').val()) {
|
4 |
+
$('.mailsmtp').show();
|
5 |
+
$('#mailsendmail').hide();
|
6 |
+
} else if ( 'Sendmail' == $('#mailmethod').val()) {
|
7 |
+
$('.mailsmtp').hide();
|
8 |
+
$('#mailsendmail').show();
|
9 |
+
} else {
|
10 |
+
$('.mailsmtp').hide();
|
11 |
+
$('#mailsendmail').hide();
|
12 |
+
}
|
13 |
+
});
|
14 |
+
});
|
15 |
+
|
js/backwpupworking.js
CHANGED
@@ -1,61 +1,59 @@
|
|
1 |
-
jQuery(document).ready( function($) {
|
2 |
-
if ($('#alternate_wp_cron').val()=='1') {
|
3 |
-
$.ajax({
|
4 |
-
type: 'POST',
|
5 |
-
url: $('#backwpuprunurl').val(),
|
6 |
-
cache: false,
|
7 |
-
timeout: 3000,
|
8 |
-
async: false,
|
9 |
-
data: {
|
10 |
-
nonce: $('#alternate_wp_cron_nonce').val(),
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
$('
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
$('
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
});
|
61 |
-
|
1 |
+
jQuery(document).ready( function($) {
|
2 |
+
if ($('#alternate_wp_cron').val()=='1') {
|
3 |
+
$.ajax({
|
4 |
+
type: 'POST',
|
5 |
+
url: $('#backwpuprunurl').val(),
|
6 |
+
cache: false,
|
7 |
+
timeout: 3000,
|
8 |
+
async: false,
|
9 |
+
data: {
|
10 |
+
nonce: $('#alternate_wp_cron_nonce').val(),
|
11 |
+
type: 'javastart'
|
12 |
+
}
|
13 |
+
});
|
14 |
+
};
|
15 |
+
if ($('#logfile').length>0) {
|
16 |
+
var refreshId = setInterval(function() {
|
17 |
+
$.ajax({
|
18 |
+
type: 'POST',
|
19 |
+
url: $('#backwpupworkingajaxurl').val(),
|
20 |
+
cache: false,
|
21 |
+
data: {
|
22 |
+
logfile: $('#logfile').val(),
|
23 |
+
logpos: $('#logpos').val()
|
24 |
+
},
|
25 |
+
dataType: 'json',
|
26 |
+
success: function(rundata) {
|
27 |
+
$('#logpos').val(rundata.logpos);
|
28 |
+
if ( '' != rundata.LOG ) {
|
29 |
+
$('#showworking').append(rundata.LOG);
|
30 |
+
$('#showworking').scrollTop(rundata.logpos*12);
|
31 |
+
}
|
32 |
+
if ( 0 < rundata.ERROR ) {
|
33 |
+
$('#errors').replaceWith('<span id="errors">'+rundata.ERROR+'</span>');
|
34 |
+
$('#errorid').show();
|
35 |
+
}
|
36 |
+
if ( 0 < rundata.WARNING ) {
|
37 |
+
$('#warnings').replaceWith('<span id="warnings">'+rundata.WARNING+'</span>');
|
38 |
+
$('#warningsid').show();
|
39 |
+
}
|
40 |
+
if ( 0 < rundata.STEPSPERSENT ) {
|
41 |
+
$('#progressstep').replaceWith('<div id="progressstep">'+rundata.STEPSPERSENT+'%</div>');
|
42 |
+
$('#progressstep').css('width', parseFloat(rundata.STEPSPERSENT)+'%');
|
43 |
+
$('.progressbar').show();
|
44 |
+
}
|
45 |
+
if ( 0 < rundata.STEPPERSENT ) {
|
46 |
+
$('#progresssteps').replaceWith('<div id="progresssteps">'+rundata.STEPPERSENT+'%</div>');
|
47 |
+
$('#progresssteps').css('width', parseFloat(rundata.STEPPERSENT)+'%');
|
48 |
+
$('.progressbar').show();
|
49 |
+
}
|
50 |
+
}
|
51 |
+
});
|
52 |
+
$("#stopworking").each(function(index) {
|
53 |
+
$("#message").remove();
|
54 |
+
clearInterval(refreshId);
|
55 |
+
});
|
56 |
+
}, 1000);
|
57 |
+
}
|
58 |
+
});
|
59 |
+
|
|
|
|
libs/aws/README.md
CHANGED
@@ -127,6 +127,10 @@ your project with:
|
|
127 |
3. Make sure that `getenv('HOME')` points to your user directory. If not you'll need to set
|
128 |
`putenv('HOME=<your-user-directory>')`.
|
129 |
|
|
|
|
|
|
|
|
|
130 |
|
131 |
## Additional Information
|
132 |
|
127 |
3. Make sure that `getenv('HOME')` points to your user directory. If not you'll need to set
|
128 |
`putenv('HOME=<your-user-directory>')`.
|
129 |
|
130 |
+
This is because PHP will attempt to load the file from your user directory (e.g., `~/.aws/sdk/config.inc.php`).
|
131 |
+
If PHP doesn't happen to know where your user directory is, you'll need to tell PHP where it is with the `putenv()`
|
132 |
+
function.
|
133 |
+
|
134 |
|
135 |
## Additional Information
|
136 |
|
libs/aws/authentication/signature_v3json.class.php
CHANGED
@@ -54,11 +54,9 @@ class AuthV3JSON extends Signer implements Signable
|
|
54 |
$date = gmdate(CFUtilities::DATE_FORMAT_RFC2616, $current_time);
|
55 |
$timestamp = gmdate(CFUtilities::DATE_FORMAT_ISO8601, $current_time);
|
56 |
$nonce = $this->util->generate_guid();
|
57 |
-
$curlopts = array();
|
58 |
$signed_headers = array();
|
59 |
-
$return_curl_handle = false;
|
60 |
$x_amz_target = null;
|
61 |
-
$query = array(
|
62 |
|
63 |
// Do we have an authentication token?
|
64 |
if ($this->auth_token)
|
@@ -83,28 +81,11 @@ class AuthV3JSON extends Signer implements Signable
|
|
83 |
$query['Version'] = $this->api_version;
|
84 |
}
|
85 |
|
86 |
-
$curlopts = array();
|
87 |
-
|
88 |
-
// Set custom CURLOPT settings
|
89 |
-
if (is_array($this->payload) && isset($this->payload['curlopts']))
|
90 |
-
{
|
91 |
-
$curlopts = $this->payload['curlopts'];
|
92 |
-
unset($this->payload['curlopts']);
|
93 |
-
}
|
94 |
-
|
95 |
-
// Merge in any options that were passed in
|
96 |
-
if (is_array($this->payload))
|
97 |
-
{
|
98 |
-
$query = array_merge($query, $this->payload);
|
99 |
-
}
|
100 |
-
|
101 |
-
$return_curl_handle = isset($query['returnCurlHandle']) ? $query['returnCurlHandle'] : false;
|
102 |
-
unset($query['returnCurlHandle']);
|
103 |
-
|
104 |
// Do a case-sensitive, natural order sort on the array keys.
|
105 |
uksort($query, 'strcmp');
|
106 |
|
107 |
// Normalize JSON input
|
|
|
108 |
if (isset($query['body']) && $query['body'] === '[]')
|
109 |
{
|
110 |
$query['body'] = '{}';
|
54 |
$date = gmdate(CFUtilities::DATE_FORMAT_RFC2616, $current_time);
|
55 |
$timestamp = gmdate(CFUtilities::DATE_FORMAT_ISO8601, $current_time);
|
56 |
$nonce = $this->util->generate_guid();
|
|
|
57 |
$signed_headers = array();
|
|
|
58 |
$x_amz_target = null;
|
59 |
+
$query = array();
|
60 |
|
61 |
// Do we have an authentication token?
|
62 |
if ($this->auth_token)
|
81 |
$query['Version'] = $this->api_version;
|
82 |
}
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
// Do a case-sensitive, natural order sort on the array keys.
|
85 |
uksort($query, 'strcmp');
|
86 |
|
87 |
// Normalize JSON input
|
88 |
+
$query['body'] = json_encode($this->payload);
|
89 |
if (isset($query['body']) && $query['body'] === '[]')
|
90 |
{
|
91 |
$query['body'] = '{}';
|
libs/aws/authentication/signature_v4json.class.php
CHANGED
@@ -62,11 +62,7 @@ class AuthV4JSON extends Signer implements Signable
|
|
62 |
$this->query = array();
|
63 |
|
64 |
// Prepare JSON structure
|
65 |
-
$
|
66 |
-
$data = (array) (is_array($decoded) ? $decoded : $this->payload);
|
67 |
-
unset($data['curlopts']);
|
68 |
-
unset($data['returnCurlHandle']);
|
69 |
-
$this->body = json_encode($data);
|
70 |
if ($this->body === '' || $this->body === '[]')
|
71 |
{
|
72 |
$this->body = '{}';
|
@@ -133,7 +129,8 @@ class AuthV4JSON extends Signer implements Signable
|
|
133 |
$request->set_method('POST');
|
134 |
$request->set_body($this->body);
|
135 |
$this->querystring = $this->body;
|
136 |
-
$this->
|
|
|
137 |
$this->headers['X-Amz-Target'] = $x_amz_target;
|
138 |
|
139 |
// Pass along registered stream callbacks
|
@@ -275,7 +272,7 @@ class AuthV4JSON extends Signer implements Signable
|
|
275 |
$pieces = explode('.', $this->endpoint);
|
276 |
|
277 |
// Handle cases with single/no region (i.e. service.region.amazonaws.com vs. service.amazonaws.com)
|
278 |
-
if (count($pieces < 4)
|
279 |
{
|
280 |
return 'us-east-1';
|
281 |
}
|
62 |
$this->query = array();
|
63 |
|
64 |
// Prepare JSON structure
|
65 |
+
$this->body = json_encode($this->payload);
|
|
|
|
|
|
|
|
|
66 |
if ($this->body === '' || $this->body === '[]')
|
67 |
{
|
68 |
$this->body = '{}';
|
129 |
$request->set_method('POST');
|
130 |
$request->set_body($this->body);
|
131 |
$this->querystring = $this->body;
|
132 |
+
$content_type = (stripos($this->operation, 'StorageGateway') !== false) ? 'application/x-amz-json-1.1' : 'application/x-amz-json-1.0';
|
133 |
+
$this->headers['Content-Type'] = $content_type;
|
134 |
$this->headers['X-Amz-Target'] = $x_amz_target;
|
135 |
|
136 |
// Pass along registered stream callbacks
|
272 |
$pieces = explode('.', $this->endpoint);
|
273 |
|
274 |
// Handle cases with single/no region (i.e. service.region.amazonaws.com vs. service.amazonaws.com)
|
275 |
+
if (count($pieces) < 4)
|
276 |
{
|
277 |
return 'us-east-1';
|
278 |
}
|
libs/aws/authentication/signature_v4query.class.php
CHANGED
@@ -267,7 +267,7 @@ class AuthV4Query extends Signer implements Signable
|
|
267 |
$pieces = explode('.', $this->endpoint);
|
268 |
|
269 |
// Handle cases with single/no region (i.e. service.region.amazonaws.com vs. service.amazonaws.com)
|
270 |
-
if (count($pieces < 4)
|
271 |
{
|
272 |
return 'us-east-1';
|
273 |
}
|
267 |
$pieces = explode('.', $this->endpoint);
|
268 |
|
269 |
// Handle cases with single/no region (i.e. service.region.amazonaws.com vs. service.amazonaws.com)
|
270 |
+
if (count($pieces) < 4)
|
271 |
{
|
272 |
return 'us-east-1';
|
273 |
}
|
libs/aws/lib/dom/ArrayToDOMDocument.php
CHANGED
@@ -67,6 +67,14 @@ class Array2DOM
|
|
67 |
if (!is_array($source))
|
68 |
{
|
69 |
$element = $document->createElement($tagName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
$element->appendChild($document->createCDATASection($source));
|
71 |
|
72 |
return $element;
|
67 |
if (!is_array($source))
|
68 |
{
|
69 |
$element = $document->createElement($tagName);
|
70 |
+
|
71 |
+
// Handle NULL bytes
|
72 |
+
if (strpos($source, "\0") !== false)
|
73 |
+
{
|
74 |
+
$source = 'json_encoded::' . json_encode($source);
|
75 |
+
$element->setAttribute('encoded', 'json');
|
76 |
+
}
|
77 |
+
|
78 |
$element->appendChild($document->createCDATASection($source));
|
79 |
|
80 |
return $element;
|
libs/aws/sdk.class.php
CHANGED
@@ -115,8 +115,8 @@ function __aws_sdk_ua_callback()
|
|
115 |
// INTERMEDIARY CONSTANTS
|
116 |
|
117 |
define('CFRUNTIME_NAME', 'aws-sdk-php');
|
118 |
-
define('CFRUNTIME_VERSION', '
|
119 |
-
define('CFRUNTIME_BUILD', '
|
120 |
define('CFRUNTIME_USERAGENT', CFRUNTIME_NAME . '/' . CFRUNTIME_VERSION . ' PHP/' . PHP_VERSION . ' ' . str_replace(' ', '_', php_uname('s')) . '/' . str_replace(' ', '_', php_uname('r')) . ' Arch/' . php_uname('m') . ' SAPI/' . php_sapi_name() . ' Integer/' . PHP_INT_MAX . ' Build/' . CFRUNTIME_BUILD . __aws_sdk_ua_callback());
|
121 |
|
122 |
|
@@ -127,7 +127,7 @@ define('CFRUNTIME_USERAGENT', CFRUNTIME_NAME . '/' . CFRUNTIME_VERSION . ' PHP/'
|
|
127 |
* Core functionality and default settings shared across all SDK classes. All methods and properties in this
|
128 |
* class are inherited by the service-specific classes.
|
129 |
*
|
130 |
-
* @version 2012.
|
131 |
* @license See the included NOTICE.md file for more information.
|
132 |
* @copyright See the included NOTICE.md file for more information.
|
133 |
* @link http://aws.amazon.com/php/ PHP Developer Center
|
@@ -374,8 +374,10 @@ class CFRuntime
|
|
374 |
* <li><code>credentials</code> - <code>string</code> - Optional - The name of the credential set to use for authentication.</li>
|
375 |
* <li><code>default_cache_config</code> - <code>string</code> - Optional - This option allows a preferred storage type to be configured for long-term caching. This can be changed later using the <set_cache_config()> method. Valid values are: <code>apc</code>, <code>xcache</code>, or a file system path such as <code>./cache</code> or <code>/tmp/cache/</code>.</li>
|
376 |
* <li><code>key</code> - <code>string</code> - Optional - Your AWS key, or a session key. If blank, the default credential set will be used.</li>
|
|
|
377 |
* <li><code>secret</code> - <code>string</code> - Optional - Your AWS secret key, or a session secret key. If blank, the default credential set will be used.</li>
|
378 |
-
* <li><code>token</code> - <code>string</code> - Optional - An AWS session token.</li
|
|
|
379 |
* @return void
|
380 |
*/
|
381 |
public function __construct(array $options = array())
|
@@ -387,45 +389,77 @@ class CFRuntime
|
|
387 |
$this->service = get_class($this);
|
388 |
|
389 |
// Create credentials based on the options
|
390 |
-
$
|
|
|
391 |
|
392 |
-
//
|
393 |
if (isset($options['credentials']))
|
394 |
{
|
395 |
-
// Use a specific credential set and merge with the
|
396 |
$this->credentials = CFCredentials::get($options['credentials'])
|
397 |
-
->merge($
|
398 |
}
|
399 |
else
|
400 |
{
|
401 |
try
|
402 |
{
|
403 |
-
// Use the default credential set and merge with the
|
404 |
$this->credentials = CFCredentials::get(CFCredentials::DEFAULT_KEY)
|
405 |
-
->merge($
|
406 |
}
|
407 |
catch (CFCredentials_Exception $e)
|
408 |
{
|
409 |
-
|
410 |
-
|
411 |
-
// Only the instance credentials were provided
|
412 |
-
$this->credentials = $instance_credentials;
|
413 |
-
}
|
414 |
-
else
|
415 |
-
{
|
416 |
-
// No credentials provided in the config file or constructor
|
417 |
-
throw new CFCredentials_Exception('No credentials were provided to ' . $this->service . '.');
|
418 |
-
}
|
419 |
}
|
420 |
}
|
421 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
422 |
// Set internal credentials after they are resolved
|
423 |
$this->key = $this->credentials->key;
|
424 |
$this->secret_key = $this->credentials->secret;
|
425 |
$this->auth_token = $this->credentials->token;
|
426 |
-
|
427 |
-
// Automatically enable whichever caching mechanism is set to default.
|
428 |
-
$this->set_cache_config($this->credentials->default_cache_config);
|
429 |
}
|
430 |
|
431 |
/**
|
@@ -607,6 +641,12 @@ class CFRuntime
|
|
607 |
*/
|
608 |
public function set_cache_config($location, $gzip = true)
|
609 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
610 |
// If we have an array, we're probably passing in Memcached servers and ports.
|
611 |
if (is_array($location))
|
612 |
{
|
@@ -712,15 +752,88 @@ class CFRuntime
|
|
712 |
$cache->expire_in($expiration_duration);
|
713 |
|
714 |
// Return the important data
|
|
|
|
|
715 |
return array(
|
716 |
-
'key' => (string) $
|
717 |
-
'secret' => (string) $
|
718 |
-
'token' => (string) $
|
719 |
-
'expires' => (string) $
|
720 |
);
|
721 |
}
|
722 |
|
723 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
724 |
}
|
725 |
|
726 |
|
@@ -1405,10 +1518,19 @@ else
|
|
1405 |
}
|
1406 |
elseif (!isset($_ENV['HOME']) && !isset($_SERVER['HOME']))
|
1407 |
{
|
1408 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1409 |
if (!$_ENV['HOME'])
|
1410 |
{
|
1411 |
-
switch (
|
1412 |
{
|
1413 |
case 'darwin':
|
1414 |
$_ENV['HOME'] = '/Users/' . get_current_user();
|
115 |
// INTERMEDIARY CONSTANTS
|
116 |
|
117 |
define('CFRUNTIME_NAME', 'aws-sdk-php');
|
118 |
+
define('CFRUNTIME_VERSION', '1.5.8.1');
|
119 |
+
define('CFRUNTIME_BUILD', '20120629120500');
|
120 |
define('CFRUNTIME_USERAGENT', CFRUNTIME_NAME . '/' . CFRUNTIME_VERSION . ' PHP/' . PHP_VERSION . ' ' . str_replace(' ', '_', php_uname('s')) . '/' . str_replace(' ', '_', php_uname('r')) . ' Arch/' . php_uname('m') . ' SAPI/' . php_sapi_name() . ' Integer/' . PHP_INT_MAX . ' Build/' . CFRUNTIME_BUILD . __aws_sdk_ua_callback());
|
121 |
|
122 |
|
127 |
* Core functionality and default settings shared across all SDK classes. All methods and properties in this
|
128 |
* class are inherited by the service-specific classes.
|
129 |
*
|
130 |
+
* @version 2012.05.25
|
131 |
* @license See the included NOTICE.md file for more information.
|
132 |
* @copyright See the included NOTICE.md file for more information.
|
133 |
* @link http://aws.amazon.com/php/ PHP Developer Center
|
374 |
* <li><code>credentials</code> - <code>string</code> - Optional - The name of the credential set to use for authentication.</li>
|
375 |
* <li><code>default_cache_config</code> - <code>string</code> - Optional - This option allows a preferred storage type to be configured for long-term caching. This can be changed later using the <set_cache_config()> method. Valid values are: <code>apc</code>, <code>xcache</code>, or a file system path such as <code>./cache</code> or <code>/tmp/cache/</code>.</li>
|
376 |
* <li><code>key</code> - <code>string</code> - Optional - Your AWS key, or a session key. If blank, the default credential set will be used.</li>
|
377 |
+
* <li><code>instance_profile_timeout</code> - <code>integer</code> - Optional - When retrieving IAM instance profile credentials, there is a hard connection timeout that defaults to 2 seconds to prevent unnecessary on non-EC2 systems. This setting allows you to change that timeout if needed.</li>
|
378 |
* <li><code>secret</code> - <code>string</code> - Optional - Your AWS secret key, or a session secret key. If blank, the default credential set will be used.</li>
|
379 |
+
* <li><code>token</code> - <code>string</code> - Optional - An AWS session token.</li>
|
380 |
+
* <li><code>use_instance_profile_credentials</code> - <code>boolean</code> - Optional - Forces the use of IAM Instance Profile credentials, even when regular credentials are provided.</li></ul>
|
381 |
* @return void
|
382 |
*/
|
383 |
public function __construct(array $options = array())
|
389 |
$this->service = get_class($this);
|
390 |
|
391 |
// Create credentials based on the options
|
392 |
+
$runtime_credentials = new CFCredential($options);
|
393 |
+
$credentials_provided = false;
|
394 |
|
395 |
+
// Retrieve a credential set from config.inc.php if it exists
|
396 |
if (isset($options['credentials']))
|
397 |
{
|
398 |
+
// Use a specific credential set and merge with the runtime credentials
|
399 |
$this->credentials = CFCredentials::get($options['credentials'])
|
400 |
+
->merge($runtime_credentials);
|
401 |
}
|
402 |
else
|
403 |
{
|
404 |
try
|
405 |
{
|
406 |
+
// Use the default credential set and merge with the runtime credentials
|
407 |
$this->credentials = CFCredentials::get(CFCredentials::DEFAULT_KEY)
|
408 |
+
->merge($runtime_credentials);
|
409 |
}
|
410 |
catch (CFCredentials_Exception $e)
|
411 |
{
|
412 |
+
// Only the runtime credentials were provided
|
413 |
+
$this->credentials = $runtime_credentials;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
}
|
415 |
}
|
416 |
|
417 |
+
// Check if keys were actually provided
|
418 |
+
if (isset($this->credentials['key']) && isset($this->credentials['secret']))
|
419 |
+
{
|
420 |
+
$credentials_provided = true;
|
421 |
+
}
|
422 |
+
|
423 |
+
// Check for an instance profile credentials override
|
424 |
+
if (isset($this->credentials['use_instance_profile_credentials']) && $this->credentials['use_instance_profile_credentials'])
|
425 |
+
{
|
426 |
+
$credentials_provided = false;
|
427 |
+
}
|
428 |
+
|
429 |
+
// Automatically enable whichever caching mechanism is set to default.
|
430 |
+
$this->set_cache_config($this->credentials->default_cache_config);
|
431 |
+
|
432 |
+
// If no credentials were provided, try to get them from the EC2 instance profile
|
433 |
+
if (!$credentials_provided)
|
434 |
+
{
|
435 |
+
// Default caching mechanism is required
|
436 |
+
if (!$this->credentials->default_cache_config)
|
437 |
+
{
|
438 |
+
// @codeCoverageIgnoreStart
|
439 |
+
throw new CFCredentials_Exception('No credentials were provided. The SDK attempts to retrieve Instance '
|
440 |
+
. 'Profile credentials from the EC2 Instance Metadata Service, but doing this requires the '
|
441 |
+
. '"default_cache_config" option to be set in the config.inc.php file or constructor. In order to '
|
442 |
+
. 'cache the retrieved credentials.');
|
443 |
+
// @codeCoverageIgnoreEnd
|
444 |
+
}
|
445 |
+
|
446 |
+
// Instantiate and invoke the cache for instance profile credentials
|
447 |
+
$cache = new $this->cache_class('instance_profile_credentials', $this->cache_location, 0, $this->cache_compress);
|
448 |
+
if ($data = $cache->read())
|
449 |
+
{
|
450 |
+
$cache->expire_in((strtotime($data['expires']) - time()) * 0.85);
|
451 |
+
}
|
452 |
+
$instance_profile_credentials = $cache->response_manager(array($this, 'cache_instance_profile_credentials'), array($cache, $options));
|
453 |
+
|
454 |
+
$this->credentials->key = $instance_profile_credentials['key'];
|
455 |
+
$this->credentials->secret = $instance_profile_credentials['secret'];
|
456 |
+
$this->credentials->token = $instance_profile_credentials['token'];
|
457 |
+
}
|
458 |
+
|
459 |
// Set internal credentials after they are resolved
|
460 |
$this->key = $this->credentials->key;
|
461 |
$this->secret_key = $this->credentials->secret;
|
462 |
$this->auth_token = $this->credentials->token;
|
|
|
|
|
|
|
463 |
}
|
464 |
|
465 |
/**
|
641 |
*/
|
642 |
public function set_cache_config($location, $gzip = true)
|
643 |
{
|
644 |
+
// If location is empty, don't do anything.
|
645 |
+
if (empty($location))
|
646 |
+
{
|
647 |
+
return $this;
|
648 |
+
}
|
649 |
+
|
650 |
// If we have an array, we're probably passing in Memcached servers and ports.
|
651 |
if (is_array($location))
|
652 |
{
|
752 |
$cache->expire_in($expiration_duration);
|
753 |
|
754 |
// Return the important data
|
755 |
+
$credentials = $response->body->GetSessionTokenResult->Credentials;
|
756 |
+
|
757 |
return array(
|
758 |
+
'key' => (string) $credentials->AccessKeyId,
|
759 |
+
'secret' => (string) $credentials->SecretAccessKey,
|
760 |
+
'token' => (string) $credentials->SessionToken,
|
761 |
+
'expires' => (string) $credentials->Expiration,
|
762 |
);
|
763 |
}
|
764 |
|
765 |
+
// @codeCoverageIgnoreStart
|
766 |
+
throw new STS_Exception('Temporary credentials from the AWS Security '
|
767 |
+
. 'Token Service could not be retrieved using the provided long '
|
768 |
+
. 'term credentials. It\'s possible that the provided long term '
|
769 |
+
. 'credentials were invalid.');
|
770 |
+
// @codeCoverageIgnoreEnd
|
771 |
+
}
|
772 |
+
|
773 |
+
/**
|
774 |
+
* Fetches and caches EC2 instance profile credentials. This is meant to be used by the constructor, and is not to
|
775 |
+
* be manually invoked.
|
776 |
+
*
|
777 |
+
* @param CacheCore $cache (Required) The a reference to the cache object that is being used to handle the caching.
|
778 |
+
* @param array $options (Required) The options that were passed into the constructor.
|
779 |
+
* @return mixed The data to be cached, or NULL.
|
780 |
+
*/
|
781 |
+
public function cache_instance_profile_credentials($cache, $options)
|
782 |
+
{
|
783 |
+
$instance_profile_url = 'http://169.254.169.254/latest/meta-data/iam/security-credentials/';
|
784 |
+
$connect_timeout = isset($options['instance_profile_timeout']) ? $options['instance_profile_timeout'] : 2;
|
785 |
+
|
786 |
+
try
|
787 |
+
{
|
788 |
+
// Make a call to the EC2 Metadata Service to find the available instance profile
|
789 |
+
$request = new RequestCore($instance_profile_url);
|
790 |
+
$request->set_curlopts(array(CURLOPT_CONNECTTIMEOUT => $connect_timeout));
|
791 |
+
$response = $request->send_request(true);
|
792 |
+
|
793 |
+
if ($response->isOK())
|
794 |
+
{
|
795 |
+
// Get the instance profile name
|
796 |
+
$profile = (string) $response->body;
|
797 |
+
|
798 |
+
// Make a call to the EC2 Metadata Service to get the instance profile credentials
|
799 |
+
$request = new RequestCore($instance_profile_url . $profile);
|
800 |
+
$request->set_curlopts(array(CURLOPT_CONNECTTIMEOUT => $connect_timeout));
|
801 |
+
$response = $request->send_request(true);
|
802 |
+
|
803 |
+
if ($response->isOK())
|
804 |
+
{
|
805 |
+
// Get the credentials
|
806 |
+
$credentials = json_decode($response->body, true);
|
807 |
+
|
808 |
+
if ($credentials['Code'] === 'Success')
|
809 |
+
{
|
810 |
+
// Determine the expiration time
|
811 |
+
$expiration_time = strtotime((string) $credentials['Expiration']);
|
812 |
+
$expiration_duration = round(($expiration_time - time()) * 0.85);
|
813 |
+
$cache->expire_in($expiration_duration);
|
814 |
+
|
815 |
+
// Return the credential information
|
816 |
+
return array(
|
817 |
+
'key' => $credentials['AccessKeyId'],
|
818 |
+
'secret' => $credentials['SecretAccessKey'],
|
819 |
+
'token' => $credentials['Token'],
|
820 |
+
'expires' => $credentials['Expiration'],
|
821 |
+
);
|
822 |
+
}
|
823 |
+
}
|
824 |
+
}
|
825 |
+
}
|
826 |
+
catch (cURL_Exception $e)
|
827 |
+
{
|
828 |
+
// The EC2 Metadata Service does not exist or had timed out.
|
829 |
+
// An exception will be thrown on the next line.
|
830 |
+
}
|
831 |
+
|
832 |
+
// @codeCoverageIgnoreStart
|
833 |
+
throw new CFCredentials_Exception('No credentials were provided. The SDK attempted to retrieve Instance '
|
834 |
+
. 'Profile credentials from the EC2 Instance Metadata Service, but failed to do so. Instance profile '
|
835 |
+
. 'credentials are only accessible on EC2 instances configured with a specific IAM role.');
|
836 |
+
// @codeCoverageIgnoreEnd
|
837 |
}
|
838 |
|
839 |
|
1518 |
}
|
1519 |
elseif (!isset($_ENV['HOME']) && !isset($_SERVER['HOME']))
|
1520 |
{
|
1521 |
+
$os = strtolower(PHP_OS);
|
1522 |
+
if (in_array($os, array('windows', 'winnt', 'win32')))
|
1523 |
+
{
|
1524 |
+
$_ENV['HOME'] = false;
|
1525 |
+
}
|
1526 |
+
else
|
1527 |
+
{
|
1528 |
+
$_ENV['HOME'] = `cd ~ && pwd`;
|
1529 |
+
}
|
1530 |
+
|
1531 |
if (!$_ENV['HOME'])
|
1532 |
{
|
1533 |
+
switch ($os)
|
1534 |
{
|
1535 |
case 'darwin':
|
1536 |
$_ENV['HOME'] = '/Users/' . get_current_user();
|
libs/aws/services/as.class.php
CHANGED
@@ -36,7 +36,7 @@
|
|
36 |
* "http://docs.amazonwebservices.com/general/latest/gr/index.html?rande.html">Regions and
|
37 |
* Endpoints</a> in the Amazon Web Services General Reference.
|
38 |
*
|
39 |
-
* @version 2012.
|
40 |
* @license See the included NOTICE.md file for complete information.
|
41 |
* @copyright See the included NOTICE.md file for complete information.
|
42 |
* @link http://aws.amazon.com/as/ Auto Scaling
|
@@ -142,7 +142,7 @@ class AmazonAS extends CFRuntime
|
|
142 |
{
|
143 |
$this->api_version = '2011-01-01';
|
144 |
$this->hostname = self::DEFAULT_URL;
|
145 |
-
$this->auth_class = '
|
146 |
|
147 |
return parent::__construct($options);
|
148 |
}
|
@@ -280,6 +280,7 @@ class AmazonAS extends CFRuntime
|
|
280 |
* </ul></li>
|
281 |
* </ul></li>
|
282 |
* <li><code>SpotPrice</code> - <code>string</code> - Optional - </li>
|
|
|
283 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
284 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
285 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
@@ -926,7 +927,7 @@ class AmazonAS extends CFRuntime
|
|
926 |
* @param string $adjustment_type (Required) Specifies whether the <code>ScalingAdjustment</code> is an absolute number or a percentage of the current capacity. Valid values are <code>ChangeInCapacity</code>, <code>ExactCapacity</code>, and <code>PercentChangeInCapacity</code>. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: <code>[\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*</code>]
|
927 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
928 |
* <li><code>Cooldown</code> - <code>integer</code> - Optional - The amount of time, in seconds, after a scaling activity completes before any further trigger-related scaling activities can start.</li>
|
929 |
-
* <li><code>
|
930 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
931 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
932 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
36 |
* "http://docs.amazonwebservices.com/general/latest/gr/index.html?rande.html">Regions and
|
37 |
* Endpoints</a> in the Amazon Web Services General Reference.
|
38 |
*
|
39 |
+
* @version 2012.06.21
|
40 |
* @license See the included NOTICE.md file for complete information.
|
41 |
* @copyright See the included NOTICE.md file for complete information.
|
42 |
* @link http://aws.amazon.com/as/ Auto Scaling
|
142 |
{
|
143 |
$this->api_version = '2011-01-01';
|
144 |
$this->hostname = self::DEFAULT_URL;
|
145 |
+
$this->auth_class = 'AuthV4Query';
|
146 |
|
147 |
return parent::__construct($options);
|
148 |
}
|
280 |
* </ul></li>
|
281 |
* </ul></li>
|
282 |
* <li><code>SpotPrice</code> - <code>string</code> - Optional - </li>
|
283 |
+
* <li><code>IamInstanceProfile</code> - <code>string</code> - Optional - [Constraints: The value must be between 1 and 1600 characters, and must match the following regular expression pattern: <code>[\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*</code>]</li>
|
284 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
285 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
286 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
927 |
* @param string $adjustment_type (Required) Specifies whether the <code>ScalingAdjustment</code> is an absolute number or a percentage of the current capacity. Valid values are <code>ChangeInCapacity</code>, <code>ExactCapacity</code>, and <code>PercentChangeInCapacity</code>. [Constraints: The value must be between 1 and 255 characters, and must match the following regular expression pattern: <code>[\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*</code>]
|
928 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
929 |
* <li><code>Cooldown</code> - <code>integer</code> - Optional - The amount of time, in seconds, after a scaling activity completes before any further trigger-related scaling activities can start.</li>
|
930 |
+
* <li><code>MinAdjustmentStep</code> - <code>integer</code> - Optional - </li>
|
931 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
932 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
933 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
libs/aws/services/cloudsearch.class.php
CHANGED
@@ -19,7 +19,7 @@
|
|
19 |
* CloudSearch configuration requests are submitted to
|
20 |
* <code>cloudsearch.us-east-1.amazonaws.com</code> using the AWS Query protocol.
|
21 |
*
|
22 |
-
* @version 2012.
|
23 |
* @license See the included NOTICE.md file for complete information.
|
24 |
* @copyright See the included NOTICE.md file for complete information.
|
25 |
* @link http://aws.amazon.com/cloudsearch/ Amazon CloudSearch
|
@@ -121,22 +121,22 @@ class AmazonCloudSearch extends CFRuntime
|
|
121 |
* <li><code>IndexFieldType</code> - <code>string</code> - Required - The type of field. Based on this type, exactly one of the <code>UIntOptions</code>, <code>LiteralOptions</code> or <code>TextOptions</code> must be present. [Allowed values: <code>uint</code>, <code>literal</code>, <code>text</code>]</li>
|
122 |
* <li><code>UIntOptions</code> - <code>array</code> - Optional - Options for an unsigned integer field. Present if <code>IndexFieldType</code> specifies the field is of type unsigned integer. <ul>
|
123 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
124 |
-
* <li><code>DefaultValue</code> - <code>integer</code> - Optional - The default value for an unsigned integer field.</li>
|
125 |
* </ul></li>
|
126 |
* </ul></li>
|
127 |
* <li><code>LiteralOptions</code> - <code>array</code> - Optional - Options for literal field. Present if <code>IndexFieldType</code> specifies the field is of type literal. <ul>
|
128 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
129 |
-
* <li><code>DefaultValue</code> - <code>string</code> - Optional - The default value for a literal field.</li>
|
130 |
-
* <li><code>SearchEnabled</code> - <code>boolean</code> - Optional - Specifies whether search is enabled for this field.</li>
|
131 |
-
* <li><code>FacetEnabled</code> - <code>boolean</code> - Optional - Specifies whether facets are enabled for this field.</li>
|
132 |
-
* <li><code>ResultEnabled</code> - <code>boolean</code> - Optional - Specifies whether values of this field can be returned in search results and used for ranking.</li>
|
133 |
* </ul></li>
|
134 |
* </ul></li>
|
135 |
* <li><code>TextOptions</code> - <code>array</code> - Optional - Options for text field. Present if <code>IndexFieldType</code> specifies the field is of type text. <ul>
|
136 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
137 |
-
* <li><code>DefaultValue</code> - <code>string</code> - Optional - The default value for a text field.</li>
|
138 |
-
* <li><code>FacetEnabled</code> - <code>boolean</code> - Optional - Specifies whether facets are enabled for this field.</li>
|
139 |
-
* <li><code>ResultEnabled</code> - <code>boolean</code> - Optional - Specifies whether values of this field can be returned in search results and used for ranking.</li>
|
140 |
* </ul></li>
|
141 |
* </ul></li>
|
142 |
* <li><code>SourceAttributes</code> - <code>array</code> - Optional - An optional list of source attributes that provide data for this index field. If not specified, the data is pulled from a source attribute with the same name as this <code>IndexField</code>. When one or more source attributes are specified, an optional data transformation can be applied to the source data when populating the index field. You can configure a maximum of 20 sources for an <code>IndexField</code>. <ul>
|
@@ -145,13 +145,13 @@ class AmazonCloudSearch extends CFRuntime
|
|
145 |
* <li><code>SourceDataCopy</code> - <code>array</code> - Optional - Copies data from a source document attribute to an <code>IndexField</code>. <ul>
|
146 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
147 |
* <li><code>SourceName</code> - <code>string</code> - Required - The name of the document source field to add to this <code>IndexField</code>. [Constraints: The value must be between 1 and 64 characters, and must match the following regular expression pattern: <code>[a-z][a-z0-9_]*</code>]</li>
|
148 |
-
* <li><code>DefaultValue</code> - <code>string</code> - Optional - The value
|
149 |
* </ul></li>
|
150 |
* </ul></li>
|
151 |
* <li><code>SourceDataTrimTitle</code> - <code>array</code> - Optional - Trims common title words from a source document attribute when populating an <code>IndexField</code>. This can be used to create an <code>IndexField</code> you can use for sorting. <ul>
|
152 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
153 |
* <li><code>SourceName</code> - <code>string</code> - Required - The name of the document source field to add to this <code>IndexField</code>. [Constraints: The value must be between 1 and 64 characters, and must match the following regular expression pattern: <code>[a-z][a-z0-9_]*</code>]</li>
|
154 |
-
* <li><code>DefaultValue</code> - <code>string</code> - Optional - The value
|
155 |
* <li><code>Separator</code> - <code>string</code> - Optional - The separator that follows the text to trim.</li>
|
156 |
* <li><code>Language</code> - <code>string</code> - Optional - An <a href="http://tools.ietf.org/html/rfc4646">IETF RFC 4646</a> language code. Only the primary language is considered. English (en) is currently the only supported language. [Constraints: The value must match the following regular expression pattern: <code>[a-zA-Z]{2,8}(?:-[a-zA-Z]{2,8})*</code>]</li>
|
157 |
* </ul></li>
|
@@ -159,7 +159,7 @@ class AmazonCloudSearch extends CFRuntime
|
|
159 |
* <li><code>SourceDataMap</code> - <code>array</code> - Optional - Maps source document attribute values to new values when populating the <code>IndexField</code>. <ul>
|
160 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
161 |
* <li><code>SourceName</code> - <code>string</code> - Required - The name of the document source field to add to this <code>IndexField</code>. [Constraints: The value must be between 1 and 64 characters, and must match the following regular expression pattern: <code>[a-z][a-z0-9_]*</code>]</li>
|
162 |
-
* <li><code>DefaultValue</code> - <code>string</code> - Optional - The value
|
163 |
* <li><code>Cases</code> - <code>array</code> - Optional - A map that translates source field values to custom values. <ul>
|
164 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
165 |
* <li><code>[custom-key]</code> - <code>string</code> - Optional - The value of a field or source document attribute.</li>
|
@@ -485,10 +485,10 @@ class AmazonCloudSearch extends CFRuntime
|
|
485 |
|
486 |
/**
|
487 |
* Configures the policies that control access to the domain's document and search services. The
|
488 |
-
* maximum size of an access policy document is
|
489 |
*
|
490 |
* @param string $domain_name (Required) A string that represents the name of a domain. Domain names must be unique across the domains owned by an account within an AWS region. Domain names must start with a letter or number and can contain the following characters: a-z (lowercase), 0-9, and - (hyphen). Uppercase letters and underscores are not allowed. [Constraints: The value must be between 3 and 28 characters, and must match the following regular expression pattern: <code>[a-z][a-z0-9\-]+</code>]
|
491 |
-
* @param string $access_policies (Required) An IAM access policy as described in <a href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?AccessPolicyLanguage.html" target="_blank">The Access Policy Language</a> in <em>Using AWS Identity and Access Management</em>. The maximum size of an access policy document is
|
492 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
493 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
494 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
@@ -506,10 +506,10 @@ class AmazonCloudSearch extends CFRuntime
|
|
506 |
/**
|
507 |
* Configures a stemming dictionary for the search domain. The stemming dictionary is used during
|
508 |
* indexing and when processing search requests. The maximum size of the stemming dictionary is
|
509 |
-
*
|
510 |
*
|
511 |
* @param string $domain_name (Required) A string that represents the name of a domain. Domain names must be unique across the domains owned by an account within an AWS region. Domain names must start with a letter or number and can contain the following characters: a-z (lowercase), 0-9, and - (hyphen). Uppercase letters and underscores are not allowed. [Constraints: The value must be between 3 and 28 characters, and must match the following regular expression pattern: <code>[a-z][a-z0-9\-]+</code>]
|
512 |
-
* @param string $stems (Required) Maps terms to their stems, serialized as a JSON document. The document has a single object with one property "stems" whose value is an object mapping terms to their stems. The maximum size of a stemming document is
|
513 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
514 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
515 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
@@ -526,10 +526,10 @@ class AmazonCloudSearch extends CFRuntime
|
|
526 |
|
527 |
/**
|
528 |
* Configures stopwords for the search domain. Stopwords are used during indexing and when
|
529 |
-
* processing search requests. The maximum size of the stopwords dictionary is
|
530 |
*
|
531 |
* @param string $domain_name (Required) A string that represents the name of a domain. Domain names must be unique across the domains owned by an account within an AWS region. Domain names must start with a letter or number and can contain the following characters: a-z (lowercase), 0-9, and - (hyphen). Uppercase letters and underscores are not allowed. [Constraints: The value must be between 3 and 28 characters, and must match the following regular expression pattern: <code>[a-z][a-z0-9\-]+</code>]
|
532 |
-
* @param string $stopwords (Required) Lists stopwords serialized as a JSON document. The document has a single object with one property "stopwords" whose value is an array of strings. The maximum size of a stopwords document is
|
533 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
534 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
535 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
@@ -547,10 +547,10 @@ class AmazonCloudSearch extends CFRuntime
|
|
547 |
/**
|
548 |
* Configures a synonym dictionary for the search domain. The synonym dictionary is used during
|
549 |
* indexing to configure mappings for terms that occur in text fields. The maximum size of the
|
550 |
-
* synonym dictionary is
|
551 |
*
|
552 |
* @param string $domain_name (Required) A string that represents the name of a domain. Domain names must be unique across the domains owned by an account within an AWS region. Domain names must start with a letter or number and can contain the following characters: a-z (lowercase), 0-9, and - (hyphen). Uppercase letters and underscores are not allowed. [Constraints: The value must be between 3 and 28 characters, and must match the following regular expression pattern: <code>[a-z][a-z0-9\-]+</code>]
|
553 |
-
* @param string $synonyms (Required) Maps terms to their synonyms, serialized as a JSON document. The document has a single object with one property "synonyms" whose value is an object mapping terms to their synonyms. Each synonym is a simple string or an array of strings. The maximum size of a stopwords document is
|
554 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
555 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
556 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
19 |
* CloudSearch configuration requests are submitted to
|
20 |
* <code>cloudsearch.us-east-1.amazonaws.com</code> using the AWS Query protocol.
|
21 |
*
|
22 |
+
* @version 2012.05.31
|
23 |
* @license See the included NOTICE.md file for complete information.
|
24 |
* @copyright See the included NOTICE.md file for complete information.
|
25 |
* @link http://aws.amazon.com/cloudsearch/ Amazon CloudSearch
|
121 |
* <li><code>IndexFieldType</code> - <code>string</code> - Required - The type of field. Based on this type, exactly one of the <code>UIntOptions</code>, <code>LiteralOptions</code> or <code>TextOptions</code> must be present. [Allowed values: <code>uint</code>, <code>literal</code>, <code>text</code>]</li>
|
122 |
* <li><code>UIntOptions</code> - <code>array</code> - Optional - Options for an unsigned integer field. Present if <code>IndexFieldType</code> specifies the field is of type unsigned integer. <ul>
|
123 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
124 |
+
* <li><code>DefaultValue</code> - <code>integer</code> - Optional - The default value for an unsigned integer field. Optional.</li>
|
125 |
* </ul></li>
|
126 |
* </ul></li>
|
127 |
* <li><code>LiteralOptions</code> - <code>array</code> - Optional - Options for literal field. Present if <code>IndexFieldType</code> specifies the field is of type literal. <ul>
|
128 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
129 |
+
* <li><code>DefaultValue</code> - <code>string</code> - Optional - The default value for a literal field. Optional.</li>
|
130 |
+
* <li><code>SearchEnabled</code> - <code>boolean</code> - Optional - Specifies whether search is enabled for this field. Default: False.</li>
|
131 |
+
* <li><code>FacetEnabled</code> - <code>boolean</code> - Optional - Specifies whether facets are enabled for this field. Default: False.</li>
|
132 |
+
* <li><code>ResultEnabled</code> - <code>boolean</code> - Optional - Specifies whether values of this field can be returned in search results and used for ranking. Default: False.</li>
|
133 |
* </ul></li>
|
134 |
* </ul></li>
|
135 |
* <li><code>TextOptions</code> - <code>array</code> - Optional - Options for text field. Present if <code>IndexFieldType</code> specifies the field is of type text. <ul>
|
136 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
137 |
+
* <li><code>DefaultValue</code> - <code>string</code> - Optional - The default value for a text field. Optional.</li>
|
138 |
+
* <li><code>FacetEnabled</code> - <code>boolean</code> - Optional - Specifies whether facets are enabled for this field. Default: False.</li>
|
139 |
+
* <li><code>ResultEnabled</code> - <code>boolean</code> - Optional - Specifies whether values of this field can be returned in search results and used for ranking. Default: False.</li>
|
140 |
* </ul></li>
|
141 |
* </ul></li>
|
142 |
* <li><code>SourceAttributes</code> - <code>array</code> - Optional - An optional list of source attributes that provide data for this index field. If not specified, the data is pulled from a source attribute with the same name as this <code>IndexField</code>. When one or more source attributes are specified, an optional data transformation can be applied to the source data when populating the index field. You can configure a maximum of 20 sources for an <code>IndexField</code>. <ul>
|
145 |
* <li><code>SourceDataCopy</code> - <code>array</code> - Optional - Copies data from a source document attribute to an <code>IndexField</code>. <ul>
|
146 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
147 |
* <li><code>SourceName</code> - <code>string</code> - Required - The name of the document source field to add to this <code>IndexField</code>. [Constraints: The value must be between 1 and 64 characters, and must match the following regular expression pattern: <code>[a-z][a-z0-9_]*</code>]</li>
|
148 |
+
* <li><code>DefaultValue</code> - <code>string</code> - Optional - The default value to use if the source attribute is not specified in a document. Optional.</li>
|
149 |
* </ul></li>
|
150 |
* </ul></li>
|
151 |
* <li><code>SourceDataTrimTitle</code> - <code>array</code> - Optional - Trims common title words from a source document attribute when populating an <code>IndexField</code>. This can be used to create an <code>IndexField</code> you can use for sorting. <ul>
|
152 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
153 |
* <li><code>SourceName</code> - <code>string</code> - Required - The name of the document source field to add to this <code>IndexField</code>. [Constraints: The value must be between 1 and 64 characters, and must match the following regular expression pattern: <code>[a-z][a-z0-9_]*</code>]</li>
|
154 |
+
* <li><code>DefaultValue</code> - <code>string</code> - Optional - The default value to use if the source attribute is not specified in a document. Optional.</li>
|
155 |
* <li><code>Separator</code> - <code>string</code> - Optional - The separator that follows the text to trim.</li>
|
156 |
* <li><code>Language</code> - <code>string</code> - Optional - An <a href="http://tools.ietf.org/html/rfc4646">IETF RFC 4646</a> language code. Only the primary language is considered. English (en) is currently the only supported language. [Constraints: The value must match the following regular expression pattern: <code>[a-zA-Z]{2,8}(?:-[a-zA-Z]{2,8})*</code>]</li>
|
157 |
* </ul></li>
|
159 |
* <li><code>SourceDataMap</code> - <code>array</code> - Optional - Maps source document attribute values to new values when populating the <code>IndexField</code>. <ul>
|
160 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
161 |
* <li><code>SourceName</code> - <code>string</code> - Required - The name of the document source field to add to this <code>IndexField</code>. [Constraints: The value must be between 1 and 64 characters, and must match the following regular expression pattern: <code>[a-z][a-z0-9_]*</code>]</li>
|
162 |
+
* <li><code>DefaultValue</code> - <code>string</code> - Optional - The default value to use if the source attribute is not specified in a document. Optional.</li>
|
163 |
* <li><code>Cases</code> - <code>array</code> - Optional - A map that translates source field values to custom values. <ul>
|
164 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
165 |
* <li><code>[custom-key]</code> - <code>string</code> - Optional - The value of a field or source document attribute.</li>
|
485 |
|
486 |
/**
|
487 |
* Configures the policies that control access to the domain's document and search services. The
|
488 |
+
* maximum size of an access policy document is 100 KB.
|
489 |
*
|
490 |
* @param string $domain_name (Required) A string that represents the name of a domain. Domain names must be unique across the domains owned by an account within an AWS region. Domain names must start with a letter or number and can contain the following characters: a-z (lowercase), 0-9, and - (hyphen). Uppercase letters and underscores are not allowed. [Constraints: The value must be between 3 and 28 characters, and must match the following regular expression pattern: <code>[a-z][a-z0-9\-]+</code>]
|
491 |
+
* @param string $access_policies (Required) An IAM access policy as described in <a href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?AccessPolicyLanguage.html" target="_blank">The Access Policy Language</a> in <em>Using AWS Identity and Access Management</em>. The maximum size of an access policy document is 100 KB. Example: <code>{"Statement": [{"Effect":"Allow", "Action": "*", "Resource": "arn:aws:cs:us-east-1:1234567890:search/movies", "Condition": { "IpAddress": { aws:SourceIp": ["203.0.113.1/32"] } }}, {"Effect":"Allow", "Action": "*", "Resource": "arn:aws:cs:us-east-1:1234567890:documents/movies", "Condition": { "IpAddress": { aws:SourceIp": ["203.0.113.1/32"] } }} ]}</code>
|
492 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
493 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
494 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
506 |
/**
|
507 |
* Configures a stemming dictionary for the search domain. The stemming dictionary is used during
|
508 |
* indexing and when processing search requests. The maximum size of the stemming dictionary is
|
509 |
+
* 500 KB.
|
510 |
*
|
511 |
* @param string $domain_name (Required) A string that represents the name of a domain. Domain names must be unique across the domains owned by an account within an AWS region. Domain names must start with a letter or number and can contain the following characters: a-z (lowercase), 0-9, and - (hyphen). Uppercase letters and underscores are not allowed. [Constraints: The value must be between 3 and 28 characters, and must match the following regular expression pattern: <code>[a-z][a-z0-9\-]+</code>]
|
512 |
+
* @param string $stems (Required) Maps terms to their stems, serialized as a JSON document. The document has a single object with one property "stems" whose value is an object mapping terms to their stems. The maximum size of a stemming document is 500 KB. Example: <code>{ "stems": {"people": "person", "walking": "walk"} }</code>
|
513 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
514 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
515 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
526 |
|
527 |
/**
|
528 |
* Configures stopwords for the search domain. Stopwords are used during indexing and when
|
529 |
+
* processing search requests. The maximum size of the stopwords dictionary is 10 KB.
|
530 |
*
|
531 |
* @param string $domain_name (Required) A string that represents the name of a domain. Domain names must be unique across the domains owned by an account within an AWS region. Domain names must start with a letter or number and can contain the following characters: a-z (lowercase), 0-9, and - (hyphen). Uppercase letters and underscores are not allowed. [Constraints: The value must be between 3 and 28 characters, and must match the following regular expression pattern: <code>[a-z][a-z0-9\-]+</code>]
|
532 |
+
* @param string $stopwords (Required) Lists stopwords serialized as a JSON document. The document has a single object with one property "stopwords" whose value is an array of strings. The maximum size of a stopwords document is 10 KB. Example: <code>{ "stopwords": ["a", "an", "the", "of"] }</code>
|
533 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
534 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
535 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
547 |
/**
|
548 |
* Configures a synonym dictionary for the search domain. The synonym dictionary is used during
|
549 |
* indexing to configure mappings for terms that occur in text fields. The maximum size of the
|
550 |
+
* synonym dictionary is 100 KB.
|
551 |
*
|
552 |
* @param string $domain_name (Required) A string that represents the name of a domain. Domain names must be unique across the domains owned by an account within an AWS region. Domain names must start with a letter or number and can contain the following characters: a-z (lowercase), 0-9, and - (hyphen). Uppercase letters and underscores are not allowed. [Constraints: The value must be between 3 and 28 characters, and must match the following regular expression pattern: <code>[a-z][a-z0-9\-]+</code>]
|
553 |
+
* @param string $synonyms (Required) Maps terms to their synonyms, serialized as a JSON document. The document has a single object with one property "synonyms" whose value is an object mapping terms to their synonyms. Each synonym is a simple string or an array of strings. The maximum size of a stopwords document is 100 KB. Example: <code>{ "synonyms": {"cat": ["feline", "kitten"], "puppy": "dog"} }</code>
|
554 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
555 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
556 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
libs/aws/services/cloudwatch.class.php
CHANGED
@@ -47,7 +47,7 @@
|
|
47 |
* http://monitoring.amazonaws.com/doc/2010-08-01/CloudWatch.wsdl</li>
|
48 |
* </ul>
|
49 |
*
|
50 |
-
* @version 2012.
|
51 |
* @license See the included NOTICE.md file for complete information.
|
52 |
* @copyright See the included NOTICE.md file for complete information.
|
53 |
* @link http://aws.amazon.com/cloudwatch/ Amazon CloudWatch
|
@@ -158,7 +158,7 @@ class AmazonCloudWatch extends CFRuntime
|
|
158 |
{
|
159 |
$this->api_version = '2010-08-01';
|
160 |
$this->hostname = self::DEFAULT_URL;
|
161 |
-
$this->auth_class = '
|
162 |
|
163 |
return parent::__construct($options);
|
164 |
}
|
47 |
* http://monitoring.amazonaws.com/doc/2010-08-01/CloudWatch.wsdl</li>
|
48 |
* </ul>
|
49 |
*
|
50 |
+
* @version 2012.06.21
|
51 |
* @license See the included NOTICE.md file for complete information.
|
52 |
* @copyright See the included NOTICE.md file for complete information.
|
53 |
* @link http://aws.amazon.com/cloudwatch/ Amazon CloudWatch
|
158 |
{
|
159 |
$this->api_version = '2010-08-01';
|
160 |
$this->hostname = self::DEFAULT_URL;
|
161 |
+
$this->auth_class = 'AuthV4Query';
|
162 |
|
163 |
return parent::__construct($options);
|
164 |
}
|
libs/aws/services/dynamodb.class.php
CHANGED
@@ -21,7 +21,7 @@
|
|
21 |
* Amazon DynamoDB removes traditional scalability limitations on data storage while maintaining
|
22 |
* low latency and predictable performance.
|
23 |
*
|
24 |
-
* @version 2012.
|
25 |
* @license See the included NOTICE.md file for complete information.
|
26 |
* @copyright See the included NOTICE.md file for complete information.
|
27 |
* @link http://aws.amazon.com/dynamodb/ Amazon DynamoDB
|
@@ -42,6 +42,26 @@ class AmazonDynamoDB extends CFRuntime
|
|
42 |
*/
|
43 |
const REGION_VIRGINIA = self::REGION_US_E1;
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
/**
|
46 |
* Specify the queue URL for the Europe West (Ireland) Region.
|
47 |
*/
|
@@ -52,6 +72,16 @@ class AmazonDynamoDB extends CFRuntime
|
|
52 |
*/
|
53 |
const REGION_IRELAND = self::REGION_EU_W1;
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
/**
|
56 |
* Specify the queue URL for the Asia Pacific Northeast (Tokyo) Region.
|
57 |
*/
|
@@ -233,26 +263,34 @@ class AmazonDynamoDB extends CFRuntime
|
|
233 |
|
234 |
parent::__construct($options);
|
235 |
|
236 |
-
//
|
237 |
-
|
|
|
238 |
{
|
239 |
-
//
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
|
|
247 |
|
248 |
-
|
249 |
-
|
250 |
-
|
|
|
|
|
|
|
|
|
|
|
251 |
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
|
|
256 |
}
|
257 |
|
258 |
|
@@ -262,7 +300,7 @@ class AmazonDynamoDB extends CFRuntime
|
|
262 |
/**
|
263 |
* This allows you to explicitly sets the region for the service to use.
|
264 |
*
|
265 |
-
* @param string $region (Required) The region to explicitly set. Available options are <REGION_US_E1>, <REGION_EU_W1>, <REGION_APAC_NE1>.
|
266 |
* @return $this A reference to the current instance.
|
267 |
*/
|
268 |
public function set_region($region)
|
@@ -481,7 +519,6 @@ class AmazonDynamoDB extends CFRuntime
|
|
481 |
{
|
482 |
if (!$opt) $opt = array();
|
483 |
|
484 |
-
$opt = json_encode($opt);
|
485 |
return $this->authenticate('BatchGetItem', $opt);
|
486 |
}
|
487 |
|
@@ -539,7 +576,6 @@ class AmazonDynamoDB extends CFRuntime
|
|
539 |
{
|
540 |
if (!$opt) $opt = array();
|
541 |
|
542 |
-
$opt = json_encode($opt);
|
543 |
return $this->authenticate('BatchWriteItem', $opt);
|
544 |
}
|
545 |
|
@@ -578,7 +614,6 @@ class AmazonDynamoDB extends CFRuntime
|
|
578 |
{
|
579 |
if (!$opt) $opt = array();
|
580 |
|
581 |
-
$opt = json_encode($opt);
|
582 |
return $this->authenticate('CreateTable', $opt);
|
583 |
}
|
584 |
|
@@ -624,7 +659,6 @@ class AmazonDynamoDB extends CFRuntime
|
|
624 |
{
|
625 |
if (!$opt) $opt = array();
|
626 |
|
627 |
-
$opt = json_encode($opt);
|
628 |
return $this->authenticate('DeleteItem', $opt);
|
629 |
}
|
630 |
|
@@ -646,7 +680,6 @@ class AmazonDynamoDB extends CFRuntime
|
|
646 |
{
|
647 |
if (!$opt) $opt = array();
|
648 |
|
649 |
-
$opt = json_encode($opt);
|
650 |
return $this->authenticate('DeleteTable', $opt);
|
651 |
}
|
652 |
|
@@ -666,7 +699,6 @@ class AmazonDynamoDB extends CFRuntime
|
|
666 |
{
|
667 |
if (!$opt) $opt = array();
|
668 |
|
669 |
-
$opt = json_encode($opt);
|
670 |
return $this->authenticate('DescribeTable', $opt);
|
671 |
}
|
672 |
|
@@ -710,7 +742,6 @@ class AmazonDynamoDB extends CFRuntime
|
|
710 |
$opt['AttributesToGet'] = (is_array($opt['AttributesToGet']) ? $opt['AttributesToGet'] : array($opt['AttributesToGet']));
|
711 |
}
|
712 |
|
713 |
-
$opt = json_encode($opt);
|
714 |
return $this->authenticate('GetItem', $opt);
|
715 |
}
|
716 |
|
@@ -729,7 +760,6 @@ class AmazonDynamoDB extends CFRuntime
|
|
729 |
{
|
730 |
if (!$opt) $opt = array();
|
731 |
|
732 |
-
$opt = json_encode($opt);
|
733 |
return $this->authenticate('ListTables', $opt);
|
734 |
}
|
735 |
|
@@ -771,7 +801,6 @@ class AmazonDynamoDB extends CFRuntime
|
|
771 |
{
|
772 |
if (!$opt) $opt = array();
|
773 |
|
774 |
-
$opt = json_encode($opt);
|
775 |
return $this->authenticate('PutItem', $opt);
|
776 |
}
|
777 |
|
@@ -835,7 +864,6 @@ class AmazonDynamoDB extends CFRuntime
|
|
835 |
$opt['AttributesToGet'] = (is_array($opt['AttributesToGet']) ? $opt['AttributesToGet'] : array($opt['AttributesToGet']));
|
836 |
}
|
837 |
|
838 |
-
$opt = json_encode($opt);
|
839 |
return $this->authenticate('Query', $opt);
|
840 |
}
|
841 |
|
@@ -890,7 +918,6 @@ class AmazonDynamoDB extends CFRuntime
|
|
890 |
$opt['AttributesToGet'] = (is_array($opt['AttributesToGet']) ? $opt['AttributesToGet'] : array($opt['AttributesToGet']));
|
891 |
}
|
892 |
|
893 |
-
$opt = json_encode($opt);
|
894 |
return $this->authenticate('Scan', $opt);
|
895 |
}
|
896 |
|
@@ -947,7 +974,6 @@ class AmazonDynamoDB extends CFRuntime
|
|
947 |
{
|
948 |
if (!$opt) $opt = array();
|
949 |
|
950 |
-
$opt = json_encode($opt);
|
951 |
return $this->authenticate('UpdateItem', $opt);
|
952 |
}
|
953 |
|
@@ -971,7 +997,6 @@ class AmazonDynamoDB extends CFRuntime
|
|
971 |
{
|
972 |
if (!$opt) $opt = array();
|
973 |
|
974 |
-
$opt = json_encode($opt);
|
975 |
return $this->authenticate('UpdateTable', $opt);
|
976 |
}
|
977 |
}
|
21 |
* Amazon DynamoDB removes traditional scalability limitations on data storage while maintaining
|
22 |
* low latency and predictable performance.
|
23 |
*
|
24 |
+
* @version 2012.05.31
|
25 |
* @license See the included NOTICE.md file for complete information.
|
26 |
* @copyright See the included NOTICE.md file for complete information.
|
27 |
* @link http://aws.amazon.com/dynamodb/ Amazon DynamoDB
|
42 |
*/
|
43 |
const REGION_VIRGINIA = self::REGION_US_E1;
|
44 |
|
45 |
+
/**
|
46 |
+
* Specify the queue URL for the United States West (Northern California) Region.
|
47 |
+
*/
|
48 |
+
const REGION_US_W1 = 'dynamodb.us-west-1.amazonaws.com';
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Specify the queue URL for the United States West (Northern California) Region.
|
52 |
+
*/
|
53 |
+
const REGION_CALIFORNIA = self::REGION_US_W1;
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Specify the queue URL for the United States West (Oregon) Region.
|
57 |
+
*/
|
58 |
+
const REGION_US_W2 = 'dynamodb.us-west-2.amazonaws.com';
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Specify the queue URL for the United States West (Oregon) Region.
|
62 |
+
*/
|
63 |
+
const REGION_OREGON = self::REGION_US_W2;
|
64 |
+
|
65 |
/**
|
66 |
* Specify the queue URL for the Europe West (Ireland) Region.
|
67 |
*/
|
72 |
*/
|
73 |
const REGION_IRELAND = self::REGION_EU_W1;
|
74 |
|
75 |
+
/**
|
76 |
+
* Specify the queue URL for the Asia Pacific Southeast (Singapore) Region.
|
77 |
+
*/
|
78 |
+
const REGION_APAC_SE1 = 'dynamodb.ap-southeast-1.amazonaws.com';
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Specify the queue URL for the Asia Pacific Southeast (Singapore) Region.
|
82 |
+
*/
|
83 |
+
const REGION_SINGAPORE = self::REGION_APAC_SE1;
|
84 |
+
|
85 |
/**
|
86 |
* Specify the queue URL for the Asia Pacific Northeast (Tokyo) Region.
|
87 |
*/
|
263 |
|
264 |
parent::__construct($options);
|
265 |
|
266 |
+
// Only attempt to get STS credentials if there is no token (i.e. they
|
267 |
+
// are not already using STS or instance profile credentials)
|
268 |
+
if (!$this->auth_token)
|
269 |
{
|
270 |
+
// Default caching mechanism is required
|
271 |
+
if (!$this->credentials->default_cache_config)
|
272 |
+
{
|
273 |
+
// @codeCoverageIgnoreStart
|
274 |
+
throw new DynamoDB_Exception('The DynamoDB class requires the '
|
275 |
+
. '"default_cache_config" option to be set in the '
|
276 |
+
. 'config.inc.php file or AmazonDynamoDB constructor.');
|
277 |
+
// @codeCoverageIgnoreEnd
|
278 |
+
}
|
279 |
|
280 |
+
// Instantiate and invoke the cache
|
281 |
+
$cache_id = $this->key . '_sts_credentials_' . sha1(serialize($options));
|
282 |
+
$cache = new $this->cache_class($cache_id, $this->cache_location, 0, $this->cache_compress);
|
283 |
+
if ($data = $cache->read())
|
284 |
+
{
|
285 |
+
$cache->expire_in((strtotime($data['expires']) - time()) * 0.85);
|
286 |
+
}
|
287 |
+
$sts_credentials = $cache->response_manager(array($this, 'cache_sts_credentials'), array($cache, $options));
|
288 |
|
289 |
+
// Store the credentials inside the class
|
290 |
+
$this->key = $sts_credentials['key'];
|
291 |
+
$this->secret_key = $sts_credentials['secret'];
|
292 |
+
$this->auth_token = $sts_credentials['token'];
|
293 |
+
}
|
294 |
}
|
295 |
|
296 |
|
300 |
/**
|
301 |
* This allows you to explicitly sets the region for the service to use.
|
302 |
*
|
303 |
+
* @param string $region (Required) The region to explicitly set. Available options are <REGION_US_E1>, <REGION_US_W1>, <REGION_US_W2>, <REGION_EU_W1>, <REGION_APAC_SE1>, <REGION_APAC_NE1>.
|
304 |
* @return $this A reference to the current instance.
|
305 |
*/
|
306 |
public function set_region($region)
|
519 |
{
|
520 |
if (!$opt) $opt = array();
|
521 |
|
|
|
522 |
return $this->authenticate('BatchGetItem', $opt);
|
523 |
}
|
524 |
|
576 |
{
|
577 |
if (!$opt) $opt = array();
|
578 |
|
|
|
579 |
return $this->authenticate('BatchWriteItem', $opt);
|
580 |
}
|
581 |
|
614 |
{
|
615 |
if (!$opt) $opt = array();
|
616 |
|
|
|
617 |
return $this->authenticate('CreateTable', $opt);
|
618 |
}
|
619 |
|
659 |
{
|
660 |
if (!$opt) $opt = array();
|
661 |
|
|
|
662 |
return $this->authenticate('DeleteItem', $opt);
|
663 |
}
|
664 |
|
680 |
{
|
681 |
if (!$opt) $opt = array();
|
682 |
|
|
|
683 |
return $this->authenticate('DeleteTable', $opt);
|
684 |
}
|
685 |
|
699 |
{
|
700 |
if (!$opt) $opt = array();
|
701 |
|
|
|
702 |
return $this->authenticate('DescribeTable', $opt);
|
703 |
}
|
704 |
|
742 |
$opt['AttributesToGet'] = (is_array($opt['AttributesToGet']) ? $opt['AttributesToGet'] : array($opt['AttributesToGet']));
|
743 |
}
|
744 |
|
|
|
745 |
return $this->authenticate('GetItem', $opt);
|
746 |
}
|
747 |
|
760 |
{
|
761 |
if (!$opt) $opt = array();
|
762 |
|
|
|
763 |
return $this->authenticate('ListTables', $opt);
|
764 |
}
|
765 |
|
801 |
{
|
802 |
if (!$opt) $opt = array();
|
803 |
|
|
|
804 |
return $this->authenticate('PutItem', $opt);
|
805 |
}
|
806 |
|
864 |
$opt['AttributesToGet'] = (is_array($opt['AttributesToGet']) ? $opt['AttributesToGet'] : array($opt['AttributesToGet']));
|
865 |
}
|
866 |
|
|
|
867 |
return $this->authenticate('Query', $opt);
|
868 |
}
|
869 |
|
918 |
$opt['AttributesToGet'] = (is_array($opt['AttributesToGet']) ? $opt['AttributesToGet'] : array($opt['AttributesToGet']));
|
919 |
}
|
920 |
|
|
|
921 |
return $this->authenticate('Scan', $opt);
|
922 |
}
|
923 |
|
974 |
{
|
975 |
if (!$opt) $opt = array();
|
976 |
|
|
|
977 |
return $this->authenticate('UpdateItem', $opt);
|
978 |
}
|
979 |
|
997 |
{
|
998 |
if (!$opt) $opt = array();
|
999 |
|
|
|
1000 |
return $this->authenticate('UpdateTable', $opt);
|
1001 |
}
|
1002 |
}
|
libs/aws/services/ec2.class.php
CHANGED
@@ -29,7 +29,7 @@
|
|
29 |
*
|
30 |
* Visit <a href="http://aws.amazon.com/ec2/">http://aws.amazon.com/ec2/</a> for more information.
|
31 |
*
|
32 |
-
* @version 2012.
|
33 |
* @license See the included NOTICE.md file for complete information.
|
34 |
* @copyright See the included NOTICE.md file for complete information.
|
35 |
* @link http://aws.amazon.com/ec2/ Amazon EC2
|
@@ -138,7 +138,7 @@ class AmazonEC2 extends CFRuntime
|
|
138 |
*/
|
139 |
public function __construct(array $options = array())
|
140 |
{
|
141 |
-
$this->api_version = '2012-
|
142 |
$this->hostname = self::DEFAULT_URL;
|
143 |
$this->auth_class = 'AuthV2Query';
|
144 |
|
@@ -573,6 +573,23 @@ class AmazonEC2 extends CFRuntime
|
|
573 |
return $this->authenticate('CancelConversionTask', $opt);
|
574 |
}
|
575 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
576 |
/**
|
577 |
* Cancels one or more Spot Instance requests.
|
578 |
*
|
@@ -713,10 +730,46 @@ class AmazonEC2 extends CFRuntime
|
|
713 |
if (!$opt) $opt = array();
|
714 |
$opt['InstanceId'] = $instance_id;
|
715 |
$opt['Name'] = $name;
|
716 |
-
|
717 |
return $this->authenticate('CreateImage', $opt);
|
718 |
}
|
719 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
720 |
/**
|
721 |
* Creates a new Internet gateway in your AWS account. After creating the Internet gateway, you
|
722 |
* then attach it to a VPC using <code>AttachInternetGateway</code>. For more information about
|
@@ -1896,6 +1949,35 @@ class AmazonEC2 extends CFRuntime
|
|
1896 |
return $this->authenticate('DescribeDhcpOptions', $opt);
|
1897 |
}
|
1898 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1899 |
/**
|
1900 |
* The DescribeImageAttribute operation returns information about an attribute of an AMI. Only one
|
1901 |
* attribute can be specified per call.
|
@@ -2017,7 +2099,7 @@ class AmazonEC2 extends CFRuntime
|
|
2017 |
* call.
|
2018 |
*
|
2019 |
* @param string $instance_id (Required) The ID of the instance whose instance attribute is being described.
|
2020 |
-
* @param string $attribute (Required) The name of the attribute to describe. Available attribute names: <code>instanceType</code>, <code>kernel</code>, <code>ramdisk</code>, <code>userData</code>, <code>disableApiTermination</code>, <code>instanceInitiatedShutdownBehavior</code>, <code>rootDeviceName</code>, <code>blockDeviceMapping</code>
|
2021 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2022 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
2023 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
@@ -2092,6 +2174,7 @@ class AmazonEC2 extends CFRuntime
|
|
2092 |
* </ul></li>
|
2093 |
* <li><code>NextToken</code> - <code>string</code> - Optional - A string specifying the next paginated set of results to return.</li>
|
2094 |
* <li><code>MaxResults</code> - <code>integer</code> - Optional - The maximum number of paginated instance items per response.</li>
|
|
|
2095 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
2096 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
2097 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
@@ -2704,7 +2787,7 @@ class AmazonEC2 extends CFRuntime
|
|
2704 |
* call.
|
2705 |
*
|
2706 |
* @param string $snapshot_id (Required) The ID of the EBS snapshot whose attribute is being described.
|
2707 |
-
* @param string $attribute (Required) The name of the EBS attribute to describe. Available attribute names: createVolumePermission
|
2708 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2709 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
2710 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
@@ -3028,7 +3111,7 @@ class AmazonEC2 extends CFRuntime
|
|
3028 |
*
|
3029 |
* @param string $volume_id (Required)
|
3030 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
3031 |
-
* <li><code>Attribute</code> - <code>string</code> - Optional - </li>
|
3032 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
3033 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
3034 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
@@ -3517,7 +3600,7 @@ class AmazonEC2 extends CFRuntime
|
|
3517 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
3518 |
* <li><code>AvailabilityZone</code> - <code>string</code> - Optional - The availability zone in which an Amazon EC2 instance runs.</li>
|
3519 |
* <li><code>GroupName</code> - <code>string</code> - Optional - The name of the <code>PlacementGroup</code> in which an Amazon EC2 instance runs. Placement groups are primarily used for launching High Performance Computing instances in the same group to ensure fast connection speeds.</li>
|
3520 |
-
* <li><code>Tenancy</code> - <code>string</code> - Optional - The allowed tenancy of instances launched into the VPC. A value of default means instances can be launched with any tenancy; a value of dedicated means instances
|
3521 |
* </ul></li>
|
3522 |
* </ul></li>
|
3523 |
* <li><code>BlockDeviceMapping</code> - <code>array</code> - Optional - The BlockDeviceMappingItemType data type. <ul>
|
@@ -3748,7 +3831,7 @@ class AmazonEC2 extends CFRuntime
|
|
3748 |
*
|
3749 |
* @param string $instance_id (Required) The ID of the instance whose attribute is being modified.
|
3750 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
3751 |
-
* <li><code>Attribute</code> - <code>string</code> - Optional - The name of the attribute being modified. Available attribute names: <code>instanceType</code>, <code>kernel</code>, <code>ramdisk</code>, <code>userData</code>, <code>disableApiTermination</code>, <code>instanceInitiatedShutdownBehavior</code>, <code>rootDevice</code>, <code>blockDeviceMapping</code
|
3752 |
* <li><code>Value</code> - <code>string</code> - Optional - The new value of the instance attribute being modified. Only valid when <code>kernel</code>, <code>ramdisk</code>, <code>userData</code>, <code>disableApiTermination</code> or <code>instanceInitiateShutdownBehavior</code> is specified as the attribute being modified.</li>
|
3753 |
* <li><code>BlockDeviceMapping</code> - <code>array</code> - Optional - The new block device mappings for the instance whose attributes are being modified. Only valid when blockDeviceMapping is specified as the attribute being modified. <ul>
|
3754 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
@@ -3850,7 +3933,7 @@ class AmazonEC2 extends CFRuntime
|
|
3850 |
*
|
3851 |
* @param string $snapshot_id (Required) The ID of the EBS snapshot whose attributes are being modified.
|
3852 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
3853 |
-
* <li><code>Attribute</code> - <code>string</code> - Optional - The name of the attribute being modified. Available attribute names: <code>createVolumePermission</code
|
3854 |
* <li><code>OperationType</code> - <code>string</code> - Optional - The operation to perform on the attribute. Available operation names: <code>add</code>, <code>remove</code></li>
|
3855 |
* <li><code>UserId</code> - <code>string|array</code> - Optional - The AWS user IDs to add to or remove from the list of users that have permission to create EBS volumes from the specified snapshot. Currently supports "all". <p class="note">Only valid when the <code>createVolumePermission</code> attribute is being modified.</p> Pass a string for a single value, or an indexed array for multiple values.</li>
|
3856 |
* <li><code>UserGroup</code> - <code>string|array</code> - Optional - The AWS group names to add to or remove from the list of groups that have permission to create EBS volumes from the specified snapshot. Currently supports "all". <p class="note">Only valid when the <code>createVolumePermission</code> attribute is being modified.</p> Pass a string for a single value, or an indexed array for multiple values.</li>
|
@@ -4329,6 +4412,12 @@ class AmazonEC2 extends CFRuntime
|
|
4329 |
* <li><code>DeleteOnTermination</code> - <code>boolean</code> - Optional - </li>
|
4330 |
* </ul></li>
|
4331 |
* </ul></li>
|
|
|
|
|
|
|
|
|
|
|
|
|
4332 |
* </ul></li>
|
4333 |
* </ul></li>
|
4334 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
@@ -4391,7 +4480,7 @@ class AmazonEC2 extends CFRuntime
|
|
4391 |
* Resets an attribute of an instance to its default value.
|
4392 |
*
|
4393 |
* @param string $instance_id (Required) The ID of the Amazon EC2 instance whose attribute is being reset.
|
4394 |
-
* @param string $attribute (Required) The name of the attribute being reset. Available attribute names: <code>kernel</code>, <code>ramdisk</code>
|
4395 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
4396 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
4397 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
@@ -4428,7 +4517,7 @@ class AmazonEC2 extends CFRuntime
|
|
4428 |
* Resets permission settings for the specified snapshot.
|
4429 |
*
|
4430 |
* @param string $snapshot_id (Required) The ID of the snapshot whose attribute is being reset.
|
4431 |
-
* @param string $attribute (Required) The name of the attribute being reset. Available attribute names: <code>createVolumePermission</code>
|
4432 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
4433 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
4434 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
@@ -4604,7 +4693,7 @@ class AmazonEC2 extends CFRuntime
|
|
4604 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
4605 |
* <li><code>AvailabilityZone</code> - <code>string</code> - Optional - The availability zone in which an Amazon EC2 instance runs.</li>
|
4606 |
* <li><code>GroupName</code> - <code>string</code> - Optional - The name of the <code>PlacementGroup</code> in which an Amazon EC2 instance runs. Placement groups are primarily used for launching High Performance Computing instances in the same group to ensure fast connection speeds.</li>
|
4607 |
-
* <li><code>Tenancy</code> - <code>string</code> - Optional - The allowed tenancy of instances launched into the VPC. A value of default means instances can be launched with any tenancy; a value of dedicated means instances
|
4608 |
* </ul></li>
|
4609 |
* </ul></li>
|
4610 |
* <li><code>KernelId</code> - <code>string</code> - Optional - The ID of the kernel with which to launch the instance.</li>
|
@@ -4645,6 +4734,12 @@ class AmazonEC2 extends CFRuntime
|
|
4645 |
* <li><code>DeleteOnTermination</code> - <code>boolean</code> - Optional - </li>
|
4646 |
* </ul></li>
|
4647 |
* </ul></li>
|
|
|
|
|
|
|
|
|
|
|
|
|
4648 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
4649 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
4650 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
@@ -4709,6 +4804,15 @@ class AmazonEC2 extends CFRuntime
|
|
4709 |
)));
|
4710 |
unset($opt['NetworkInterface']);
|
4711 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4712 |
|
4713 |
return $this->authenticate('RunInstances', $opt);
|
4714 |
}
|
29 |
*
|
30 |
* Visit <a href="http://aws.amazon.com/ec2/">http://aws.amazon.com/ec2/</a> for more information.
|
31 |
*
|
32 |
+
* @version 2012.06.08
|
33 |
* @license See the included NOTICE.md file for complete information.
|
34 |
* @copyright See the included NOTICE.md file for complete information.
|
35 |
* @link http://aws.amazon.com/ec2/ Amazon EC2
|
138 |
*/
|
139 |
public function __construct(array $options = array())
|
140 |
{
|
141 |
+
$this->api_version = '2012-06-01';
|
142 |
$this->hostname = self::DEFAULT_URL;
|
143 |
$this->auth_class = 'AuthV2Query';
|
144 |
|
573 |
return $this->authenticate('CancelConversionTask', $opt);
|
574 |
}
|
575 |
|
576 |
+
/**
|
577 |
+
*
|
578 |
+
*
|
579 |
+
* @param string $export_task_id (Required)
|
580 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
581 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
582 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
583 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
584 |
+
*/
|
585 |
+
public function cancel_export_task($export_task_id, $opt = null)
|
586 |
+
{
|
587 |
+
if (!$opt) $opt = array();
|
588 |
+
$opt['ExportTaskId'] = $export_task_id;
|
589 |
+
|
590 |
+
return $this->authenticate('CancelExportTask', $opt);
|
591 |
+
}
|
592 |
+
|
593 |
/**
|
594 |
* Cancels one or more Spot Instance requests.
|
595 |
*
|
730 |
if (!$opt) $opt = array();
|
731 |
$opt['InstanceId'] = $instance_id;
|
732 |
$opt['Name'] = $name;
|
733 |
+
|
734 |
return $this->authenticate('CreateImage', $opt);
|
735 |
}
|
736 |
|
737 |
+
/**
|
738 |
+
*
|
739 |
+
*
|
740 |
+
* @param string $instance_id (Required)
|
741 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
742 |
+
* <li><code>Description</code> - <code>string</code> - Optional - </li>
|
743 |
+
* <li><code>TargetEnvironment</code> - <code>string</code> - Optional - [Allowed values: <code>citrix</code>, <code>vmware</code>]</li>
|
744 |
+
* <li><code>ExportToS3</code> - <code>array</code> - Optional - <ul>
|
745 |
+
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
746 |
+
* <li><code>DiskImageFormat</code> - <code>string</code> - Optional - [Allowed values: <code>vmdk</code>, <code>vhd</code>]</li>
|
747 |
+
* <li><code>ContainerFormat</code> - <code>string</code> - Optional - [Allowed values: <code>ova</code>]</li>
|
748 |
+
* <li><code>S3Bucket</code> - <code>string</code> - Optional - </li>
|
749 |
+
* <li><code>S3Prefix</code> - <code>string</code> - Optional - </li>
|
750 |
+
* </ul></li>
|
751 |
+
* </ul></li>
|
752 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
753 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
754 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
755 |
+
*/
|
756 |
+
public function create_instance_export_task($instance_id, $opt = null)
|
757 |
+
{
|
758 |
+
if (!$opt) $opt = array();
|
759 |
+
$opt['InstanceId'] = $instance_id;
|
760 |
+
|
761 |
+
// Optional map (non-list)
|
762 |
+
if (isset($opt['ExportToS3']))
|
763 |
+
{
|
764 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
765 |
+
'ExportToS3' => $opt['ExportToS3']
|
766 |
+
)));
|
767 |
+
unset($opt['ExportToS3']);
|
768 |
+
}
|
769 |
+
|
770 |
+
return $this->authenticate('CreateInstanceExportTask', $opt);
|
771 |
+
}
|
772 |
+
|
773 |
/**
|
774 |
* Creates a new Internet gateway in your AWS account. After creating the Internet gateway, you
|
775 |
* then attach it to a VPC using <code>AttachInternetGateway</code>. For more information about
|
1949 |
return $this->authenticate('DescribeDhcpOptions', $opt);
|
1950 |
}
|
1951 |
|
1952 |
+
/**
|
1953 |
+
*
|
1954 |
+
*
|
1955 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1956 |
+
* <li><code>ExportTaskId</code> - <code>array</code> - Optional - <ul>
|
1957 |
+
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
1958 |
+
* <li><code>ExportTaskId</code> - <code>string</code> - Optional - </li>
|
1959 |
+
* </ul></li>
|
1960 |
+
* </ul></li>
|
1961 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
1962 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
1963 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1964 |
+
*/
|
1965 |
+
public function describe_export_tasks($opt = null)
|
1966 |
+
{
|
1967 |
+
if (!$opt) $opt = array();
|
1968 |
+
|
1969 |
+
// Optional list + map
|
1970 |
+
if (isset($opt['ExportTaskId']))
|
1971 |
+
{
|
1972 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
1973 |
+
'ExportTaskId' => $opt['ExportTaskId']
|
1974 |
+
)));
|
1975 |
+
unset($opt['ExportTaskId']);
|
1976 |
+
}
|
1977 |
+
|
1978 |
+
return $this->authenticate('DescribeExportTasks', $opt);
|
1979 |
+
}
|
1980 |
+
|
1981 |
/**
|
1982 |
* The DescribeImageAttribute operation returns information about an attribute of an AMI. Only one
|
1983 |
* attribute can be specified per call.
|
2099 |
* call.
|
2100 |
*
|
2101 |
* @param string $instance_id (Required) The ID of the instance whose instance attribute is being described.
|
2102 |
+
* @param string $attribute (Required) The name of the attribute to describe. Available attribute names: <code>instanceType</code>, <code>kernel</code>, <code>ramdisk</code>, <code>userData</code>, <code>disableApiTermination</code>, <code>instanceInitiatedShutdownBehavior</code>, <code>rootDeviceName</code>, <code>blockDeviceMapping</code> [Allowed values: <code>instanceType</code>, <code>kernel</code>, <code>ramdisk</code>, <code>userData</code>, <code>disableApiTermination</code>, <code>instanceInitiatedShutdownBehavior</code>, <code>rootDeviceName</code>, <code>blockDeviceMapping</code>, <code>productCodes</code>, <code>sourceDestCheck</code>, <code>groupSet</code>]
|
2103 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2104 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
2105 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
2174 |
* </ul></li>
|
2175 |
* <li><code>NextToken</code> - <code>string</code> - Optional - A string specifying the next paginated set of results to return.</li>
|
2176 |
* <li><code>MaxResults</code> - <code>integer</code> - Optional - The maximum number of paginated instance items per response.</li>
|
2177 |
+
* <li><code>IncludeAllInstances</code> - <code>boolean</code> - Optional - </li>
|
2178 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
2179 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
2180 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
2787 |
* call.
|
2788 |
*
|
2789 |
* @param string $snapshot_id (Required) The ID of the EBS snapshot whose attribute is being described.
|
2790 |
+
* @param string $attribute (Required) The name of the EBS attribute to describe. Available attribute names: createVolumePermission [Allowed values: <code>productCodes</code>, <code>createVolumePermission</code>]
|
2791 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2792 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
2793 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
3111 |
*
|
3112 |
* @param string $volume_id (Required)
|
3113 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
3114 |
+
* <li><code>Attribute</code> - <code>string</code> - Optional - [Allowed values: <code>autoEnableIO</code>, <code>productCodes</code>]</li>
|
3115 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
3116 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
3117 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
3600 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
3601 |
* <li><code>AvailabilityZone</code> - <code>string</code> - Optional - The availability zone in which an Amazon EC2 instance runs.</li>
|
3602 |
* <li><code>GroupName</code> - <code>string</code> - Optional - The name of the <code>PlacementGroup</code> in which an Amazon EC2 instance runs. Placement groups are primarily used for launching High Performance Computing instances in the same group to ensure fast connection speeds.</li>
|
3603 |
+
* <li><code>Tenancy</code> - <code>string</code> - Optional - The allowed tenancy of instances launched into the VPC. A value of default means instances can be launched with any tenancy; a value of dedicated means all instances launched into the VPC will be launched as dedicated tenancy regardless of the tenancy assigned to the instance at launch.</li>
|
3604 |
* </ul></li>
|
3605 |
* </ul></li>
|
3606 |
* <li><code>BlockDeviceMapping</code> - <code>array</code> - Optional - The BlockDeviceMappingItemType data type. <ul>
|
3831 |
*
|
3832 |
* @param string $instance_id (Required) The ID of the instance whose attribute is being modified.
|
3833 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
3834 |
+
* <li><code>Attribute</code> - <code>string</code> - Optional - The name of the attribute being modified. Available attribute names: <code>instanceType</code>, <code>kernel</code>, <code>ramdisk</code>, <code>userData</code>, <code>disableApiTermination</code>, <code>instanceInitiatedShutdownBehavior</code>, <code>rootDevice</code>, <code>blockDeviceMapping</code> [Allowed values: <code>instanceType</code>, <code>kernel</code>, <code>ramdisk</code>, <code>userData</code>, <code>disableApiTermination</code>, <code>instanceInitiatedShutdownBehavior</code>, <code>rootDeviceName</code>, <code>blockDeviceMapping</code>, <code>productCodes</code>, <code>sourceDestCheck</code>, <code>groupSet</code>]</li>
|
3835 |
* <li><code>Value</code> - <code>string</code> - Optional - The new value of the instance attribute being modified. Only valid when <code>kernel</code>, <code>ramdisk</code>, <code>userData</code>, <code>disableApiTermination</code> or <code>instanceInitiateShutdownBehavior</code> is specified as the attribute being modified.</li>
|
3836 |
* <li><code>BlockDeviceMapping</code> - <code>array</code> - Optional - The new block device mappings for the instance whose attributes are being modified. Only valid when blockDeviceMapping is specified as the attribute being modified. <ul>
|
3837 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
3933 |
*
|
3934 |
* @param string $snapshot_id (Required) The ID of the EBS snapshot whose attributes are being modified.
|
3935 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
3936 |
+
* <li><code>Attribute</code> - <code>string</code> - Optional - The name of the attribute being modified. Available attribute names: <code>createVolumePermission</code> [Allowed values: <code>productCodes</code>, <code>createVolumePermission</code>]</li>
|
3937 |
* <li><code>OperationType</code> - <code>string</code> - Optional - The operation to perform on the attribute. Available operation names: <code>add</code>, <code>remove</code></li>
|
3938 |
* <li><code>UserId</code> - <code>string|array</code> - Optional - The AWS user IDs to add to or remove from the list of users that have permission to create EBS volumes from the specified snapshot. Currently supports "all". <p class="note">Only valid when the <code>createVolumePermission</code> attribute is being modified.</p> Pass a string for a single value, or an indexed array for multiple values.</li>
|
3939 |
* <li><code>UserGroup</code> - <code>string|array</code> - Optional - The AWS group names to add to or remove from the list of groups that have permission to create EBS volumes from the specified snapshot. Currently supports "all". <p class="note">Only valid when the <code>createVolumePermission</code> attribute is being modified.</p> Pass a string for a single value, or an indexed array for multiple values.</li>
|
4412 |
* <li><code>DeleteOnTermination</code> - <code>boolean</code> - Optional - </li>
|
4413 |
* </ul></li>
|
4414 |
* </ul></li>
|
4415 |
+
* <li><code>IamInstanceProfile</code> - <code>array</code> - Optional - <ul>
|
4416 |
+
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
4417 |
+
* <li><code>Arn</code> - <code>string</code> - Optional - </li>
|
4418 |
+
* <li><code>Name</code> - <code>string</code> - Optional - </li>
|
4419 |
+
* </ul></li>
|
4420 |
+
* </ul></li>
|
4421 |
* </ul></li>
|
4422 |
* </ul></li>
|
4423 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
4480 |
* Resets an attribute of an instance to its default value.
|
4481 |
*
|
4482 |
* @param string $instance_id (Required) The ID of the Amazon EC2 instance whose attribute is being reset.
|
4483 |
+
* @param string $attribute (Required) The name of the attribute being reset. Available attribute names: <code>kernel</code>, <code>ramdisk</code> [Allowed values: <code>instanceType</code>, <code>kernel</code>, <code>ramdisk</code>, <code>userData</code>, <code>disableApiTermination</code>, <code>instanceInitiatedShutdownBehavior</code>, <code>rootDeviceName</code>, <code>blockDeviceMapping</code>, <code>productCodes</code>, <code>sourceDestCheck</code>, <code>groupSet</code>]
|
4484 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
4485 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
4486 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
4517 |
* Resets permission settings for the specified snapshot.
|
4518 |
*
|
4519 |
* @param string $snapshot_id (Required) The ID of the snapshot whose attribute is being reset.
|
4520 |
+
* @param string $attribute (Required) The name of the attribute being reset. Available attribute names: <code>createVolumePermission</code> [Allowed values: <code>productCodes</code>, <code>createVolumePermission</code>]
|
4521 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
4522 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
4523 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
4693 |
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
4694 |
* <li><code>AvailabilityZone</code> - <code>string</code> - Optional - The availability zone in which an Amazon EC2 instance runs.</li>
|
4695 |
* <li><code>GroupName</code> - <code>string</code> - Optional - The name of the <code>PlacementGroup</code> in which an Amazon EC2 instance runs. Placement groups are primarily used for launching High Performance Computing instances in the same group to ensure fast connection speeds.</li>
|
4696 |
+
* <li><code>Tenancy</code> - <code>string</code> - Optional - The allowed tenancy of instances launched into the VPC. A value of default means instances can be launched with any tenancy; a value of dedicated means all instances launched into the VPC will be launched as dedicated tenancy regardless of the tenancy assigned to the instance at launch.</li>
|
4697 |
* </ul></li>
|
4698 |
* </ul></li>
|
4699 |
* <li><code>KernelId</code> - <code>string</code> - Optional - The ID of the kernel with which to launch the instance.</li>
|
4734 |
* <li><code>DeleteOnTermination</code> - <code>boolean</code> - Optional - </li>
|
4735 |
* </ul></li>
|
4736 |
* </ul></li>
|
4737 |
+
* <li><code>IamInstanceProfile</code> - <code>array</code> - Optional - <ul>
|
4738 |
+
* <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
|
4739 |
+
* <li><code>Arn</code> - <code>string</code> - Optional - </li>
|
4740 |
+
* <li><code>Name</code> - <code>string</code> - Optional - </li>
|
4741 |
+
* </ul></li>
|
4742 |
+
* </ul></li>
|
4743 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
4744 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
4745 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
4804 |
)));
|
4805 |
unset($opt['NetworkInterface']);
|
4806 |
}
|
4807 |
+
|
4808 |
+
// Optional map (non-list)
|
4809 |
+
if (isset($opt['IamInstanceProfile']))
|
4810 |
+
{
|
4811 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
4812 |
+
'IamInstanceProfile' => $opt['IamInstanceProfile']
|
4813 |
+
)));
|
4814 |
+
unset($opt['IamInstanceProfile']);
|
4815 |
+
}
|
4816 |
|
4817 |
return $this->authenticate('RunInstances', $opt);
|
4818 |
}
|
libs/aws/services/elasticache.class.php
CHANGED
@@ -27,7 +27,7 @@
|
|
27 |
* the key performance statistics associated with their cache and can receive alarms if a part of
|
28 |
* their cache runs hot.
|
29 |
*
|
30 |
-
* @version 2012.
|
31 |
* @license See the included NOTICE.md file for complete information.
|
32 |
* @copyright See the included NOTICE.md file for complete information.
|
33 |
* @link http://aws.amazon.com/elasticache/ AWS ElastiCache
|
@@ -131,7 +131,7 @@ class AmazonElastiCache extends CFRuntime
|
|
131 |
*/
|
132 |
public function __construct(array $options = array())
|
133 |
{
|
134 |
-
$this->api_version = '
|
135 |
$this->hostname = self::DEFAULT_URL;
|
136 |
$this->auth_class = 'AuthV2Query';
|
137 |
|
@@ -477,6 +477,52 @@ class AmazonElastiCache extends CFRuntime
|
|
477 |
return $this->authenticate('DescribeEvents', $opt);
|
478 |
}
|
479 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
480 |
/**
|
481 |
* Modifies the Cache Cluster settings. You can change one or more Cache Cluster configuration
|
482 |
* parameters by specifying the parameters and the new values in the request.
|
@@ -553,6 +599,25 @@ class AmazonElastiCache extends CFRuntime
|
|
553 |
return $this->authenticate('ModifyCacheParameterGroup', $opt);
|
554 |
}
|
555 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
556 |
/**
|
557 |
* Reboots some (or all) of the cache cluster nodes within a previously provisioned ElastiCache
|
558 |
* cluster. This API results in the application of modified CacheParameterGroup parameters to the
|
27 |
* the key performance statistics associated with their cache and can receive alarms if a part of
|
28 |
* their cache runs hot.
|
29 |
*
|
30 |
+
* @version 2012.05.31
|
31 |
* @license See the included NOTICE.md file for complete information.
|
32 |
* @copyright See the included NOTICE.md file for complete information.
|
33 |
* @link http://aws.amazon.com/elasticache/ AWS ElastiCache
|
131 |
*/
|
132 |
public function __construct(array $options = array())
|
133 |
{
|
134 |
+
$this->api_version = '2012-03-09';
|
135 |
$this->hostname = self::DEFAULT_URL;
|
136 |
$this->auth_class = 'AuthV2Query';
|
137 |
|
477 |
return $this->authenticate('DescribeEvents', $opt);
|
478 |
}
|
479 |
|
480 |
+
/**
|
481 |
+
* Returns information about reserved Cache Nodes for this account, or about a specified reserved
|
482 |
+
* Cache Node.
|
483 |
+
*
|
484 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
485 |
+
* <li><code>ReservedCacheNodeId</code> - <code>string</code> - Optional - The reserved Cache Node identifier filter value. Specify this parameter to show only the reservation that matches the specified reservation ID.</li>
|
486 |
+
* <li><code>ReservedCacheNodesOfferingId</code> - <code>string</code> - Optional - The offering identifier filter value. Specify this parameter to show only purchased reservations matching the specified offering identifier.</li>
|
487 |
+
* <li><code>CacheNodeType</code> - <code>string</code> - Optional - The Cache Node type filter value. Specify this parameter to show only those reservations matching the specified Cache Nodes type.</li>
|
488 |
+
* <li><code>Duration</code> - <code>string</code> - Optional - The duration filter value, specified in years or seconds. Specify this parameter to show only reservations for this duration. Valid Values: <code>1 | 3 | 31536000 | 94608000</code></li>
|
489 |
+
* <li><code>ProductDescription</code> - <code>string</code> - Optional - The product description filter value. Specify this parameter to show only those reservations matching the specified product description.</li>
|
490 |
+
* <li><code>OfferingType</code> - <code>string</code> - Optional - The offering type filter value. Specify this parameter to show only the available offerings matching the specified offering type. Valid Values: <code>"Light Utilization" | "Medium Utilization" | "Heavy Utilization"</code></li>
|
491 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of records to include in the response. If more than the <code>MaxRecords</code> value is available, a marker is included in the response so that the following results can be retrieved. Default: 100 Constraints: minimum 20, maximum 100</li>
|
492 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - The marker provided in the previous request. If this parameter is specified, the response includes records beyond the marker only, up to <code>MaxRecords</code>.</li>
|
493 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
494 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
495 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
496 |
+
*/
|
497 |
+
public function describe_reserved_cache_nodes($opt = null)
|
498 |
+
{
|
499 |
+
if (!$opt) $opt = array();
|
500 |
+
|
501 |
+
return $this->authenticate('DescribeReservedCacheNodes', $opt);
|
502 |
+
}
|
503 |
+
|
504 |
+
/**
|
505 |
+
* Lists available reserved Cache Node offerings.
|
506 |
+
*
|
507 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
508 |
+
* <li><code>ReservedCacheNodesOfferingId</code> - <code>string</code> - Optional - The offering identifier filter value. Specify this parameter to show only the available offering that matches the specified reservation identifier. Example: <code>438012d3-4052-4cc7-b2e3-8d3372e0e706</code></li>
|
509 |
+
* <li><code>CacheNodeType</code> - <code>string</code> - Optional - The Cache Node type filter value. Specify this parameter to show only the available offerings matching the specified Cache Node type.</li>
|
510 |
+
* <li><code>Duration</code> - <code>string</code> - Optional - Duration filter value, specified in years or seconds. Specify this parameter to show only reservations for this duration. Valid Values: <code>1 | 3 | 31536000 | 94608000</code></li>
|
511 |
+
* <li><code>ProductDescription</code> - <code>string</code> - Optional - Product description filter value. Specify this parameter to show only the available offerings matching the specified product description.</li>
|
512 |
+
* <li><code>OfferingType</code> - <code>string</code> - Optional - The offering type filter value. Specify this parameter to show only the available offerings matching the specified offering type. Valid Values: <code>"Light Utilization" | "Medium Utilization" | "Heavy Utilization"</code></li>
|
513 |
+
* <li><code>MaxRecords</code> - <code>integer</code> - Optional - The maximum number of records to include in the response. If more than the <code>MaxRecords</code> value is available, a marker is included in the response so that the following results can be retrieved. Default: 100 Constraints: minimum 20, maximum 100</li>
|
514 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - The marker provided in the previous request. If this parameter is specified, the response includes records beyond the marker only, up to <code>MaxRecords</code>.</li>
|
515 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
516 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
517 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
518 |
+
*/
|
519 |
+
public function describe_reserved_cache_nodes_offerings($opt = null)
|
520 |
+
{
|
521 |
+
if (!$opt) $opt = array();
|
522 |
+
|
523 |
+
return $this->authenticate('DescribeReservedCacheNodesOfferings', $opt);
|
524 |
+
}
|
525 |
+
|
526 |
/**
|
527 |
* Modifies the Cache Cluster settings. You can change one or more Cache Cluster configuration
|
528 |
* parameters by specifying the parameters and the new values in the request.
|
599 |
return $this->authenticate('ModifyCacheParameterGroup', $opt);
|
600 |
}
|
601 |
|
602 |
+
/**
|
603 |
+
* Purchases a reserved Cache Node offering.
|
604 |
+
*
|
605 |
+
* @param string $reserved_cache_nodes_offering_id (Required) The ID of the Reserved Cache Node offering to purchase. Example: 438012d3-4052-4cc7-b2e3-8d3372e0e706
|
606 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
607 |
+
* <li><code>ReservedCacheNodeId</code> - <code>string</code> - Optional - Customer-specified identifier to track this reservation. Example: myreservationID</li>
|
608 |
+
* <li><code>CacheNodeCount</code> - <code>integer</code> - Optional - The number of instances to reserve. Default: <code>1</code></li>
|
609 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
610 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
611 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
612 |
+
*/
|
613 |
+
public function purchase_reserved_cache_nodes_offering($reserved_cache_nodes_offering_id, $opt = null)
|
614 |
+
{
|
615 |
+
if (!$opt) $opt = array();
|
616 |
+
$opt['ReservedCacheNodesOfferingId'] = $reserved_cache_nodes_offering_id;
|
617 |
+
|
618 |
+
return $this->authenticate('PurchaseReservedCacheNodesOffering', $opt);
|
619 |
+
}
|
620 |
+
|
621 |
/**
|
622 |
* Reboots some (or all) of the cache cluster nodes within a previously provisioned ElastiCache
|
623 |
* cluster. This API results in the application of modified CacheParameterGroup parameters to the
|
libs/aws/services/elb.class.php
CHANGED
@@ -20,7 +20,7 @@
|
|
20 |
* application loads between two or more EC2 instances. Elastic Load Balancing enables
|
21 |
* availability through redundancy and supports traffic growth of your application.
|
22 |
*
|
23 |
-
* @version 2012.
|
24 |
* @license See the included NOTICE.md file for complete information.
|
25 |
* @copyright See the included NOTICE.md file for complete information.
|
26 |
* @link http://aws.amazon.com/elasticloadbalancing/ Elastic Load Balancing
|
@@ -124,7 +124,7 @@ class AmazonELB extends CFRuntime
|
|
124 |
*/
|
125 |
public function __construct(array $options = array())
|
126 |
{
|
127 |
-
$this->api_version = '
|
128 |
$this->hostname = self::DEFAULT_URL;
|
129 |
$this->auth_class = 'AuthV2Query';
|
130 |
|
@@ -342,6 +342,7 @@ class AmazonELB extends CFRuntime
|
|
342 |
* <li><code>AvailabilityZones</code> - <code>string|array</code> - Optional - A list of Availability Zones. At least one Availability Zone must be specified. Specified Availability Zones must be in the same EC2 Region as the LoadBalancer. Traffic will be equally distributed across all zones. This list can be modified after the creation of the LoadBalancer. Pass a string for a single value, or an indexed array for multiple values.</li>
|
343 |
* <li><code>Subnets</code> - <code>string|array</code> - Optional - A list of subnet IDs in your VPC to attach to your LoadBalancer. Pass a string for a single value, or an indexed array for multiple values.</li>
|
344 |
* <li><code>SecurityGroups</code> - <code>string|array</code> - Optional - The security groups assigned to your LoadBalancer within your VPC. Pass a string for a single value, or an indexed array for multiple values.</li>
|
|
|
345 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
346 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
347 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
20 |
* application loads between two or more EC2 instances. Elastic Load Balancing enables
|
21 |
* availability through redundancy and supports traffic growth of your application.
|
22 |
*
|
23 |
+
* @version 2012.06.25
|
24 |
* @license See the included NOTICE.md file for complete information.
|
25 |
* @copyright See the included NOTICE.md file for complete information.
|
26 |
* @link http://aws.amazon.com/elasticloadbalancing/ Elastic Load Balancing
|
124 |
*/
|
125 |
public function __construct(array $options = array())
|
126 |
{
|
127 |
+
$this->api_version = '2012-06-01';
|
128 |
$this->hostname = self::DEFAULT_URL;
|
129 |
$this->auth_class = 'AuthV2Query';
|
130 |
|
342 |
* <li><code>AvailabilityZones</code> - <code>string|array</code> - Optional - A list of Availability Zones. At least one Availability Zone must be specified. Specified Availability Zones must be in the same EC2 Region as the LoadBalancer. Traffic will be equally distributed across all zones. This list can be modified after the creation of the LoadBalancer. Pass a string for a single value, or an indexed array for multiple values.</li>
|
343 |
* <li><code>Subnets</code> - <code>string|array</code> - Optional - A list of subnet IDs in your VPC to attach to your LoadBalancer. Pass a string for a single value, or an indexed array for multiple values.</li>
|
344 |
* <li><code>SecurityGroups</code> - <code>string|array</code> - Optional - The security groups assigned to your LoadBalancer within your VPC. Pass a string for a single value, or an indexed array for multiple values.</li>
|
345 |
+
* <li><code>Scheme</code> - <code>string</code> - Optional - Specifies the type of a load balancer, which can be internet-facing or internal. - internet-facing: (default) The load balancer will have a publicly resolvable DNS name that resolves to public IP addresses. - internal: The load balancer will have a publicly resolvable DNS name that resolves to private IP addresses This option is only available for load balancers attached to a VPC. [Allowed values: <code>internet-facing</code>, <code>internal</code>]</li>
|
346 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
347 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
348 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
libs/aws/services/iam.class.php
CHANGED
@@ -34,7 +34,7 @@
|
|
34 |
* "http://aws.amazon.com/documentation/" target=
|
35 |
* "_blank">http://aws.amazon.com/documentation/</a>.
|
36 |
*
|
37 |
-
* @version 2012.05.
|
38 |
* @license See the included NOTICE.md file for complete information.
|
39 |
* @copyright See the included NOTICE.md file for complete information.
|
40 |
* @link http://aws.amazon.com/iam/ AWS Identity and Access Management
|
@@ -91,6 +91,12 @@ class AmazonIAM extends CFRuntime
|
|
91 |
}
|
92 |
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
/*%******************************************************************************************%*/
|
95 |
// SETTERS
|
96 |
|
@@ -112,6 +118,25 @@ class AmazonIAM extends CFRuntime
|
|
112 |
/*%******************************************************************************************%*/
|
113 |
// SERVICE METHODS
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
/**
|
116 |
* Adds the specified user to the specified group.
|
117 |
*
|
@@ -230,6 +255,29 @@ class AmazonIAM extends CFRuntime
|
|
230 |
return $this->authenticate('CreateGroup', $opt);
|
231 |
}
|
232 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
/**
|
234 |
* Creates a password for the specified user, giving the user the ability to access AWS services
|
235 |
* through the AWS Management Console. For more information about managing passwords, see <a href=
|
@@ -252,6 +300,31 @@ class AmazonIAM extends CFRuntime
|
|
252 |
return $this->authenticate('CreateLoginProfile', $opt);
|
253 |
}
|
254 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
/**
|
256 |
* Creates a new user for your AWS account.
|
257 |
*
|
@@ -426,6 +499,23 @@ class AmazonIAM extends CFRuntime
|
|
426 |
return $this->authenticate('DeleteGroupPolicy', $opt);
|
427 |
}
|
428 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
429 |
/**
|
430 |
* Deletes the password for the specified user, which terminates the user's ability to access AWS
|
431 |
* services through the AWS Management Console.
|
@@ -451,6 +541,42 @@ class AmazonIAM extends CFRuntime
|
|
451 |
return $this->authenticate('DeleteLoginProfile', $opt);
|
452 |
}
|
453 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
/**
|
455 |
* Deletes the specified server certificate.
|
456 |
*
|
@@ -667,6 +793,24 @@ class AmazonIAM extends CFRuntime
|
|
667 |
return $this->authenticate('GetGroupPolicy', $opt);
|
668 |
}
|
669 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
670 |
/**
|
671 |
* Retrieves the user name and password create date for the specified user.
|
672 |
*
|
@@ -684,6 +828,45 @@ class AmazonIAM extends CFRuntime
|
|
684 |
return $this->authenticate('GetLoginProfile', $opt);
|
685 |
}
|
686 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
687 |
/**
|
688 |
* Retrieves information about the specified server certificate.
|
689 |
*
|
@@ -863,6 +1046,51 @@ class AmazonIAM extends CFRuntime
|
|
863 |
return $this->authenticate('ListGroupsForUser', $opt);
|
864 |
}
|
865 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
866 |
/**
|
867 |
* Lists the MFA devices. If the request includes the user name, then this action lists all the
|
868 |
* MFA devices associated with the specified user name. If you do not specify a user name, IAM
|
@@ -886,6 +1114,51 @@ class AmazonIAM extends CFRuntime
|
|
886 |
return $this->authenticate('ListMFADevices', $opt);
|
887 |
}
|
888 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
889 |
/**
|
890 |
* Lists the server certificates that have the specified path prefix. If none exist, the action
|
891 |
* returns an empty list.
|
@@ -1044,6 +1317,47 @@ class AmazonIAM extends CFRuntime
|
|
1044 |
return $this->authenticate('PutGroupPolicy', $opt);
|
1045 |
}
|
1046 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1047 |
/**
|
1048 |
* Adds (or updates) a policy document associated with the specified user. For information about
|
1049 |
* policies, refer to <a href=
|
@@ -1085,6 +1399,25 @@ class AmazonIAM extends CFRuntime
|
|
1085 |
return $this->authenticate('PutUserPolicy', $opt);
|
1086 |
}
|
1087 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1088 |
/**
|
1089 |
* Removes the specified user from the specified group.
|
1090 |
*
|
@@ -1182,6 +1515,25 @@ class AmazonIAM extends CFRuntime
|
|
1182 |
return $this->authenticate('UpdateAccountPasswordPolicy', $opt);
|
1183 |
}
|
1184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1185 |
/**
|
1186 |
* Updates the name and/or the path of the specified group.
|
1187 |
*
|
34 |
* "http://aws.amazon.com/documentation/" target=
|
35 |
* "_blank">http://aws.amazon.com/documentation/</a>.
|
36 |
*
|
37 |
+
* @version 2012.05.31
|
38 |
* @license See the included NOTICE.md file for complete information.
|
39 |
* @copyright See the included NOTICE.md file for complete information.
|
40 |
* @link http://aws.amazon.com/iam/ AWS Identity and Access Management
|
91 |
}
|
92 |
|
93 |
|
94 |
+
/*%******************************************************************************************%*/
|
95 |
+
// CONVENIENCE CONSTANTS
|
96 |
+
|
97 |
+
const STANDARD_EC2_ASSUME_ROLE_POLICY = '{"Statement":[{"Principal":{"Service":["ec2.amazonaws.com"]},"Effect":"Allow","Action":["sts:AssumeRole"]}]}';
|
98 |
+
|
99 |
+
|
100 |
/*%******************************************************************************************%*/
|
101 |
// SETTERS
|
102 |
|
118 |
/*%******************************************************************************************%*/
|
119 |
// SERVICE METHODS
|
120 |
|
121 |
+
/**
|
122 |
+
* Adds the specified role to the specified instance profile.
|
123 |
+
*
|
124 |
+
* @param string $instance_profile_name (Required) Name of the instance profile to update. [Constraints: The value must be between 1 and 128 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
125 |
+
* @param string $role_name (Required) Name of the role to add. [Constraints: The value must be between 1 and 64 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
126 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
127 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
128 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
129 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
130 |
+
*/
|
131 |
+
public function add_role_to_instance_profile($instance_profile_name, $role_name, $opt = null)
|
132 |
+
{
|
133 |
+
if (!$opt) $opt = array();
|
134 |
+
$opt['InstanceProfileName'] = $instance_profile_name;
|
135 |
+
$opt['RoleName'] = $role_name;
|
136 |
+
|
137 |
+
return $this->authenticate('AddRoleToInstanceProfile', $opt);
|
138 |
+
}
|
139 |
+
|
140 |
/**
|
141 |
* Adds the specified user to the specified group.
|
142 |
*
|
255 |
return $this->authenticate('CreateGroup', $opt);
|
256 |
}
|
257 |
|
258 |
+
/**
|
259 |
+
* Creates a new instance profile.
|
260 |
+
*
|
261 |
+
* For information about the number of instance profiles you can create, see <a href=
|
262 |
+
* "http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?LimitationsOnEntities.html"
|
263 |
+
* target="_blank">Limitations on IAM Entities</a> in <em>Using AWS Identity and Access
|
264 |
+
* Management</em>.
|
265 |
+
*
|
266 |
+
* @param string $instance_profile_name (Required) Name of the instance profile to create. [Constraints: The value must be between 1 and 128 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
267 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
268 |
+
* <li><code>Path</code> - <code>string</code> - Optional - The path to the instance profile. For more information about paths, see <a href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?Using_Identifiers.html" target="_blank">Identifiers for IAM Entities</a> in <em>Using AWS Identity and Access Management</em>. This parameter is optional. If it is not included, it defaults to a slash (/). [Constraints: The value must be between 1 and 512 characters, and must match the following regular expression pattern: <code>(\u002F)|(\u002F[\u0021-\u007F]+\u002F)</code>]</li>
|
269 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
270 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
271 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
272 |
+
*/
|
273 |
+
public function create_instance_profile($instance_profile_name, $opt = null)
|
274 |
+
{
|
275 |
+
if (!$opt) $opt = array();
|
276 |
+
$opt['InstanceProfileName'] = $instance_profile_name;
|
277 |
+
|
278 |
+
return $this->authenticate('CreateInstanceProfile', $opt);
|
279 |
+
}
|
280 |
+
|
281 |
/**
|
282 |
* Creates a password for the specified user, giving the user the ability to access AWS services
|
283 |
* through the AWS Management Console. For more information about managing passwords, see <a href=
|
300 |
return $this->authenticate('CreateLoginProfile', $opt);
|
301 |
}
|
302 |
|
303 |
+
/**
|
304 |
+
* Creates a new role for your AWS account.
|
305 |
+
*
|
306 |
+
* For information about limitations on the number of roles you can create, see <a href=
|
307 |
+
* "http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?LimitationsOnEntities.html"
|
308 |
+
* target="_blank">Limitations on IAM Entities</a> in <em>Using AWS Identity and Access
|
309 |
+
* Management</em>.
|
310 |
+
*
|
311 |
+
* @param string $role_name (Required) Name of the role to create. [Constraints: The value must be between 1 and 64 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
312 |
+
* @param string $assume_role_policy_document (Required) The policy govering by who and under what conditions the role can be assumed. [Constraints: The value must be between 1 and 131072 characters, and must match the following regular expression pattern: <code>[\u0009\u000A\u000D\u0020-\u00FF]+</code>]
|
313 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
314 |
+
* <li><code>Path</code> - <code>string</code> - Optional - The path to the role. For more information about paths, see <a href="http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?Using_Identifiers.html" target="_blank">Identifiers for IAM Entities</a> in <em>Using AWS Identity and Access Management</em>. This parameter is optional. If it is not included, it defaults to a slash (/). [Constraints: The value must be between 1 and 512 characters, and must match the following regular expression pattern: <code>(\u002F)|(\u002F[\u0021-\u007F]+\u002F)</code>]</li>
|
315 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
316 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
317 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
318 |
+
*/
|
319 |
+
public function create_role($role_name, $assume_role_policy_document, $opt = null)
|
320 |
+
{
|
321 |
+
if (!$opt) $opt = array();
|
322 |
+
$opt['RoleName'] = $role_name;
|
323 |
+
$opt['AssumeRolePolicyDocument'] = $assume_role_policy_document;
|
324 |
+
|
325 |
+
return $this->authenticate('CreateRole', $opt);
|
326 |
+
}
|
327 |
+
|
328 |
/**
|
329 |
* Creates a new user for your AWS account.
|
330 |
*
|
499 |
return $this->authenticate('DeleteGroupPolicy', $opt);
|
500 |
}
|
501 |
|
502 |
+
/**
|
503 |
+
* Deletes the specified instance profile. The instance profile must have an associated role.
|
504 |
+
*
|
505 |
+
* @param string $instance_profile_name (Required) Name of the instance profile to delete. [Constraints: The value must be between 1 and 128 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
506 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
507 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
508 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
509 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
510 |
+
*/
|
511 |
+
public function delete_instance_profile($instance_profile_name, $opt = null)
|
512 |
+
{
|
513 |
+
if (!$opt) $opt = array();
|
514 |
+
$opt['InstanceProfileName'] = $instance_profile_name;
|
515 |
+
|
516 |
+
return $this->authenticate('DeleteInstanceProfile', $opt);
|
517 |
+
}
|
518 |
+
|
519 |
/**
|
520 |
* Deletes the password for the specified user, which terminates the user's ability to access AWS
|
521 |
* services through the AWS Management Console.
|
541 |
return $this->authenticate('DeleteLoginProfile', $opt);
|
542 |
}
|
543 |
|
544 |
+
/**
|
545 |
+
* Deletes the specified role. The role must not have any attached policies.
|
546 |
+
*
|
547 |
+
* @param string $role_name (Required) Name of the role to delete. [Constraints: The value must be between 1 and 64 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
548 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
549 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
550 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
551 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
552 |
+
*/
|
553 |
+
public function delete_role($role_name, $opt = null)
|
554 |
+
{
|
555 |
+
if (!$opt) $opt = array();
|
556 |
+
$opt['RoleName'] = $role_name;
|
557 |
+
|
558 |
+
return $this->authenticate('DeleteRole', $opt);
|
559 |
+
}
|
560 |
+
|
561 |
+
/**
|
562 |
+
* Deletes the specified policy associated with the specified role.
|
563 |
+
*
|
564 |
+
* @param string $role_name (Required) Name of the role the policy is associated with. [Constraints: The value must be between 1 and 64 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
565 |
+
* @param string $policy_name (Required) Name of the policy document to delete. [Constraints: The value must be between 1 and 128 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
566 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
567 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
568 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
569 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
570 |
+
*/
|
571 |
+
public function delete_role_policy($role_name, $policy_name, $opt = null)
|
572 |
+
{
|
573 |
+
if (!$opt) $opt = array();
|
574 |
+
$opt['RoleName'] = $role_name;
|
575 |
+
$opt['PolicyName'] = $policy_name;
|
576 |
+
|
577 |
+
return $this->authenticate('DeleteRolePolicy', $opt);
|
578 |
+
}
|
579 |
+
|
580 |
/**
|
581 |
* Deletes the specified server certificate.
|
582 |
*
|
793 |
return $this->authenticate('GetGroupPolicy', $opt);
|
794 |
}
|
795 |
|
796 |
+
/**
|
797 |
+
* Retrieves information about the specified instance profile, including the instance profile's
|
798 |
+
* path, GUID, ARN, and role.
|
799 |
+
*
|
800 |
+
* @param string $instance_profile_name (Required) Name of the instance profile to get information about. [Constraints: The value must be between 1 and 128 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
801 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
802 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
803 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
804 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
805 |
+
*/
|
806 |
+
public function get_instance_profile($instance_profile_name, $opt = null)
|
807 |
+
{
|
808 |
+
if (!$opt) $opt = array();
|
809 |
+
$opt['InstanceProfileName'] = $instance_profile_name;
|
810 |
+
|
811 |
+
return $this->authenticate('GetInstanceProfile', $opt);
|
812 |
+
}
|
813 |
+
|
814 |
/**
|
815 |
* Retrieves the user name and password create date for the specified user.
|
816 |
*
|
828 |
return $this->authenticate('GetLoginProfile', $opt);
|
829 |
}
|
830 |
|
831 |
+
/**
|
832 |
+
* Retrieves information about the specified role, including the role's path, GUID, ARN, and the
|
833 |
+
* assume role policy.
|
834 |
+
*
|
835 |
+
* @param string $role_name (Required) Name of the role to get information about. [Constraints: The value must be between 1 and 64 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
836 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
837 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
838 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
839 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
840 |
+
*/
|
841 |
+
public function get_role($role_name, $opt = null)
|
842 |
+
{
|
843 |
+
if (!$opt) $opt = array();
|
844 |
+
$opt['RoleName'] = $role_name;
|
845 |
+
|
846 |
+
return $this->authenticate('GetRole', $opt);
|
847 |
+
}
|
848 |
+
|
849 |
+
/**
|
850 |
+
* Retrieves the specified policy document for the specified role. The returned policy is
|
851 |
+
* URL-encoded according to RFC 3986. For more information about RFC 3986, go to <a href=
|
852 |
+
* "http://www.faqs.org/rfcs/rfc3986.html">http://www.faqs.org/rfcs/rfc3986.html</a>.
|
853 |
+
*
|
854 |
+
* @param string $role_name (Required) Name of the role who the policy is associated with. [Constraints: The value must be between 1 and 64 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
855 |
+
* @param string $policy_name (Required) Name of the policy document to get. [Constraints: The value must be between 1 and 128 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
856 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
857 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
858 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
859 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
860 |
+
*/
|
861 |
+
public function get_role_policy($role_name, $policy_name, $opt = null)
|
862 |
+
{
|
863 |
+
if (!$opt) $opt = array();
|
864 |
+
$opt['RoleName'] = $role_name;
|
865 |
+
$opt['PolicyName'] = $policy_name;
|
866 |
+
|
867 |
+
return $this->authenticate('GetRolePolicy', $opt);
|
868 |
+
}
|
869 |
+
|
870 |
/**
|
871 |
* Retrieves information about the specified server certificate.
|
872 |
*
|
1046 |
return $this->authenticate('ListGroupsForUser', $opt);
|
1047 |
}
|
1048 |
|
1049 |
+
/**
|
1050 |
+
* Lists the instance profiles that have the specified path prefix. If there are none, the action
|
1051 |
+
* returns an empty list.
|
1052 |
+
*
|
1053 |
+
* You can paginate the results using the <code>MaxItems</code> and <code>Marker</code>
|
1054 |
+
* parameters.
|
1055 |
+
*
|
1056 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1057 |
+
* <li><code>PathPrefix</code> - <code>string</code> - Optional - The path prefix for filtering the results. For example: <code>/application_abc/component_xyz/</code>, which would get all instance profiles whose path starts with <code>/application_abc/component_xyz/</code>. This parameter is optional. If it is not included, it defaults to a slash (/), listing all instance profiles. [Constraints: The value must be between 1 and 512 characters, and must match the following regular expression pattern: <code>\u002F[\u0021-\u007F]*</code>]</li>
|
1058 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this parameter only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the <code>Marker</code> element in the response you just received. [Constraints: The value must be between 1 and 320 characters, and must match the following regular expression pattern: <code>[\u0020-\u00FF]*</code>]</li>
|
1059 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - Use this parameter only when paginating results to indicate the maximum number of user names you want in the response. If there are additional user names beyond the maximum you specify, the <code>IsTruncated</code> response element is <code>true</code>.</li>
|
1060 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
1061 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
1062 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1063 |
+
*/
|
1064 |
+
public function list_instance_profiles($opt = null)
|
1065 |
+
{
|
1066 |
+
if (!$opt) $opt = array();
|
1067 |
+
|
1068 |
+
return $this->authenticate('ListInstanceProfiles', $opt);
|
1069 |
+
}
|
1070 |
+
|
1071 |
+
/**
|
1072 |
+
* Lists the instance profiles that have the specified associated role. If there are none, the
|
1073 |
+
* action returns an empty list.
|
1074 |
+
*
|
1075 |
+
* You can paginate the results using the <code>MaxItems</code> and <code>Marker</code>
|
1076 |
+
* parameters.
|
1077 |
+
*
|
1078 |
+
* @param string $role_name (Required) The name of the role to list instance profiles for. [Constraints: The value must be between 1 and 64 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
1079 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1080 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this parameter only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the <code>Marker</code> element in the response you just received. [Constraints: The value must be between 1 and 320 characters, and must match the following regular expression pattern: <code>[\u0020-\u00FF]*</code>]</li>
|
1081 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - Use this parameter only when paginating results to indicate the maximum number of user names you want in the response. If there are additional user names beyond the maximum you specify, the <code>IsTruncated</code> response element is <code>true</code>.</li>
|
1082 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
1083 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
1084 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1085 |
+
*/
|
1086 |
+
public function list_instance_profiles_for_role($role_name, $opt = null)
|
1087 |
+
{
|
1088 |
+
if (!$opt) $opt = array();
|
1089 |
+
$opt['RoleName'] = $role_name;
|
1090 |
+
|
1091 |
+
return $this->authenticate('ListInstanceProfilesForRole', $opt);
|
1092 |
+
}
|
1093 |
+
|
1094 |
/**
|
1095 |
* Lists the MFA devices. If the request includes the user name, then this action lists all the
|
1096 |
* MFA devices associated with the specified user name. If you do not specify a user name, IAM
|
1114 |
return $this->authenticate('ListMFADevices', $opt);
|
1115 |
}
|
1116 |
|
1117 |
+
/**
|
1118 |
+
* Lists the names of the policies associated with the specified role. If there are none, the
|
1119 |
+
* action returns an empty list.
|
1120 |
+
*
|
1121 |
+
* You can paginate the results using the <code>MaxItems</code> and <code>Marker</code>
|
1122 |
+
* parameters.
|
1123 |
+
*
|
1124 |
+
* @param string $role_name (Required) The name of the role to list policies for. [Constraints: The value must be between 1 and 64 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
1125 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1126 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this parameter only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the <code>Marker</code> element in the response you just received. [Constraints: The value must be between 1 and 320 characters, and must match the following regular expression pattern: <code>[\u0020-\u00FF]*</code>]</li>
|
1127 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - Use this parameter only when paginating results to indicate the maximum number of user names you want in the response. If there are additional user names beyond the maximum you specify, the <code>IsTruncated</code> response element is <code>true</code>.</li>
|
1128 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
1129 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
1130 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1131 |
+
*/
|
1132 |
+
public function list_role_policies($role_name, $opt = null)
|
1133 |
+
{
|
1134 |
+
if (!$opt) $opt = array();
|
1135 |
+
$opt['RoleName'] = $role_name;
|
1136 |
+
|
1137 |
+
return $this->authenticate('ListRolePolicies', $opt);
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
/**
|
1141 |
+
* Lists the roles have the specified path prefix. If there are none, the action returns an empty
|
1142 |
+
* list.
|
1143 |
+
*
|
1144 |
+
* You can paginate the results using the <code>MaxItems</code> and <code>Marker</code>
|
1145 |
+
* parameters.
|
1146 |
+
*
|
1147 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1148 |
+
* <li><code>PathPrefix</code> - <code>string</code> - Optional - The path prefix for filtering the results. For example: <code>/application_abc/component_xyz/</code>, which would get all roles whose path starts with <code>/application_abc/component_xyz/</code>. This parameter is optional. If it is not included, it defaults to a slash (/), listing all roles. [Constraints: The value must be between 1 and 512 characters, and must match the following regular expression pattern: <code>\u002F[\u0021-\u007F]*</code>]</li>
|
1149 |
+
* <li><code>Marker</code> - <code>string</code> - Optional - Use this parameter only when paginating results, and only in a subsequent request after you've received a response where the results are truncated. Set it to the value of the <code>Marker</code> element in the response you just received. [Constraints: The value must be between 1 and 320 characters, and must match the following regular expression pattern: <code>[\u0020-\u00FF]*</code>]</li>
|
1150 |
+
* <li><code>MaxItems</code> - <code>integer</code> - Optional - Use this parameter only when paginating results to indicate the maximum number of user names you want in the response. If there are additional user names beyond the maximum you specify, the <code>IsTruncated</code> response element is <code>true</code>.</li>
|
1151 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
1152 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
1153 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1154 |
+
*/
|
1155 |
+
public function list_roles($opt = null)
|
1156 |
+
{
|
1157 |
+
if (!$opt) $opt = array();
|
1158 |
+
|
1159 |
+
return $this->authenticate('ListRoles', $opt);
|
1160 |
+
}
|
1161 |
+
|
1162 |
/**
|
1163 |
* Lists the server certificates that have the specified path prefix. If none exist, the action
|
1164 |
* returns an empty list.
|
1317 |
return $this->authenticate('PutGroupPolicy', $opt);
|
1318 |
}
|
1319 |
|
1320 |
+
/**
|
1321 |
+
* Adds (or updates) a policy document associated with the specified role. For information about
|
1322 |
+
* policies, refer to <a href=
|
1323 |
+
* "http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?PoliciesOverview.html"
|
1324 |
+
* target="_blank">Overview of Policies</a> in <em>Using AWS Identity and Access Management</em>.
|
1325 |
+
*
|
1326 |
+
* For information about limits on the number of policies you can associate with a role, see
|
1327 |
+
* <a href=
|
1328 |
+
* "http://docs.amazonwebservices.com/IAM/latest/UserGuide/index.html?LimitationsOnEntities.html"
|
1329 |
+
* target="_blank">Limitations on IAM Entities</a> in <em>Using AWS Identity and Access
|
1330 |
+
* Management</em>.
|
1331 |
+
*
|
1332 |
+
* <p class="note">
|
1333 |
+
* Because policy documents can be large, you should use POST rather than GET when calling
|
1334 |
+
* <code>PutRolePolicy</code>. For information about setting up signatures and authorization
|
1335 |
+
* through the API, go to <a href=
|
1336 |
+
* "http://docs.amazonwebservices.com/general/latest/gr/signing_aws_api_requests.html" target=
|
1337 |
+
* "_blank">Signing AWS API Requests</a> in the <em>AWS General Reference</em>. For general
|
1338 |
+
* information about using the Query API with IAM, go to <a href=
|
1339 |
+
* "http://docs.amazonwebservices.com/IAM/latest/UserGuide/IAM_UsingQueryAPI.html" target=
|
1340 |
+
* "_blank">Making Query Requests</a> in <em>Using IAM</em>.
|
1341 |
+
* </p>
|
1342 |
+
*
|
1343 |
+
* @param string $role_name (Required) Name of the role to associate the policy with. [Constraints: The value must be between 1 and 64 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
1344 |
+
* @param string $policy_name (Required) Name of the policy document. [Constraints: The value must be between 1 and 128 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
1345 |
+
* @param string $policy_document (Required) The policy document. [Constraints: The value must be between 1 and 131072 characters, and must match the following regular expression pattern: <code>[\u0009\u000A\u000D\u0020-\u00FF]+</code>]
|
1346 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1347 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
1348 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
1349 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1350 |
+
*/
|
1351 |
+
public function put_role_policy($role_name, $policy_name, $policy_document, $opt = null)
|
1352 |
+
{
|
1353 |
+
if (!$opt) $opt = array();
|
1354 |
+
$opt['RoleName'] = $role_name;
|
1355 |
+
$opt['PolicyName'] = $policy_name;
|
1356 |
+
$opt['PolicyDocument'] = $policy_document;
|
1357 |
+
|
1358 |
+
return $this->authenticate('PutRolePolicy', $opt);
|
1359 |
+
}
|
1360 |
+
|
1361 |
/**
|
1362 |
* Adds (or updates) a policy document associated with the specified user. For information about
|
1363 |
* policies, refer to <a href=
|
1399 |
return $this->authenticate('PutUserPolicy', $opt);
|
1400 |
}
|
1401 |
|
1402 |
+
/**
|
1403 |
+
* Removes the specified role from the specified instance profile.
|
1404 |
+
*
|
1405 |
+
* @param string $instance_profile_name (Required) Name of the instance profile to update. [Constraints: The value must be between 1 and 128 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
1406 |
+
* @param string $role_name (Required) Name of the role to remove. [Constraints: The value must be between 1 and 64 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
1407 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1408 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
1409 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
1410 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1411 |
+
*/
|
1412 |
+
public function remove_role_from_instance_profile($instance_profile_name, $role_name, $opt = null)
|
1413 |
+
{
|
1414 |
+
if (!$opt) $opt = array();
|
1415 |
+
$opt['InstanceProfileName'] = $instance_profile_name;
|
1416 |
+
$opt['RoleName'] = $role_name;
|
1417 |
+
|
1418 |
+
return $this->authenticate('RemoveRoleFromInstanceProfile', $opt);
|
1419 |
+
}
|
1420 |
+
|
1421 |
/**
|
1422 |
* Removes the specified user from the specified group.
|
1423 |
*
|
1515 |
return $this->authenticate('UpdateAccountPasswordPolicy', $opt);
|
1516 |
}
|
1517 |
|
1518 |
+
/**
|
1519 |
+
* Updates the policy governing how the given role can be assumed.
|
1520 |
+
*
|
1521 |
+
* @param string $role_name (Required) Name of the role to update. [Constraints: The value must be between 1 and 64 characters, and must match the following regular expression pattern: <code>[\w+=,.@-]*</code>]
|
1522 |
+
* @param string $policy_document (Required) The policy govering by who and under what conditions the role can be assumed. [Constraints: The value must be between 1 and 131072 characters, and must match the following regular expression pattern: <code>[\u0009\u000A\u000D\u0020-\u00FF]+</code>]
|
1523 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1524 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
1525 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
1526 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
1527 |
+
*/
|
1528 |
+
public function update_assume_role_policy($role_name, $policy_document, $opt = null)
|
1529 |
+
{
|
1530 |
+
if (!$opt) $opt = array();
|
1531 |
+
$opt['RoleName'] = $role_name;
|
1532 |
+
$opt['PolicyDocument'] = $policy_document;
|
1533 |
+
|
1534 |
+
return $this->authenticate('UpdateAssumeRolePolicy', $opt);
|
1535 |
+
}
|
1536 |
+
|
1537 |
/**
|
1538 |
* Updates the name and/or the path of the specified group.
|
1539 |
*
|
libs/aws/services/s3.class.php
CHANGED
@@ -49,7 +49,7 @@ class S3_Exception extends Exception {}
|
|
49 |
*
|
50 |
* Visit <http://aws.amazon.com/s3/> for more information.
|
51 |
*
|
52 |
-
* @version 2012.
|
53 |
* @license See the included NOTICE.md file for more information.
|
54 |
* @copyright See the included NOTICE.md file for more information.
|
55 |
* @link http://aws.amazon.com/s3/ Amazon Simple Storage Service
|
@@ -1070,7 +1070,7 @@ class AmazonS3 extends CFRuntime
|
|
1070 |
*
|
1071 |
* @param string $bucket (Required) The name of the bucket to create.
|
1072 |
* @param string $region (Required) The preferred geographical location for the bucket. [Allowed values: `AmazonS3::REGION_US_E1 `, `AmazonS3::REGION_US_W1`, `AmazonS3::REGION_EU_W1`, `AmazonS3::REGION_APAC_SE1`, `AmazonS3::REGION_APAC_NE1`]
|
1073 |
-
* @param string $acl (Optional) The ACL settings for the specified
|
1074 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1075 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
1076 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request.</li></ul>
|
@@ -1100,10 +1100,22 @@ class AmazonS3 extends CFRuntime
|
|
1100 |
if (!$opt) $opt = array();
|
1101 |
$opt['verb'] = 'PUT';
|
1102 |
$opt['headers'] = array(
|
1103 |
-
'Content-Type' => 'application/xml'
|
1104 |
-
'x-amz-acl' => $acl
|
1105 |
);
|
1106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1107 |
// Defaults
|
1108 |
$this->set_region($region); // Also sets path-style
|
1109 |
$xml = simplexml_load_string($this->base_location_constraint);
|
@@ -1287,7 +1299,7 @@ class AmazonS3 extends CFRuntime
|
|
1287 |
|
1288 |
if (is_array($acl))
|
1289 |
{
|
1290 |
-
$opt['
|
1291 |
}
|
1292 |
else
|
1293 |
{
|
@@ -1313,11 +1325,11 @@ class AmazonS3 extends CFRuntime
|
|
1313 |
* @param string $bucket (Required) The name of the bucket to use.
|
1314 |
* @param string $filename (Required) The file name for the object.
|
1315 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
1316 |
* <li><code>body</code> - <code>string</code> - Required; Conditional - The data to be stored in the object. Either this parameter or <code>fileUpload</code> must be specified.</li>
|
1317 |
-
* <li><code>fileUpload</code> - <code>string|resource</code> - Required; Conditional - The URL/path for the file to upload, or an open resource. Either this parameter or <code>body</code> is required.</li>
|
1318 |
-
* <li><code>acl</code> - <code>string</code> - Optional - The ACL settings for the specified object. [Allowed values: <code>AmazonS3::ACL_PRIVATE</code>, <code>AmazonS3::ACL_PUBLIC</code>, <code>AmazonS3::ACL_OPEN</code>, <code>AmazonS3::ACL_AUTH_READ</code>, <code>AmazonS3::ACL_OWNER_READ</code>, <code>AmazonS3::ACL_OWNER_FULL_CONTROL</code>]. The default value is <code>ACL_PRIVATE</code>.</li>
|
1319 |
* <li><code>contentType</code> - <code>string</code> - Optional - The type of content that is being sent in the body. If a file is being uploaded via <code>fileUpload</code> as a file system path, it will attempt to determine the correct mime-type based on the file extension. The default value is <code>application/octet-stream</code>.</li>
|
1320 |
* <li><code>encryption</code> - <code>string</code> - Optional - The algorithm to use for encrypting the object. [Allowed values: <code>AES256</code>]</li>
|
|
|
1321 |
* <li><code>headers</code> - <code>array</code> - Optional - Standard HTTP headers to send along in the request. Accepts an associative array of key-value pairs.</li>
|
1322 |
* <li><code>length</code> - <code>integer</code> - Optional - The size of the object in bytes. For more information, see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13">RFC 2616, section 14.13</a>. The value can also be passed to the <code>header</code> option as <code>Content-Length</code>.</li>
|
1323 |
* <li><code>meta</code> - <code>array</code> - Optional - An associative array of key-value pairs. Represented by <code>x-amz-meta-:</code>. Any header starting with this prefix is considered user metadata. It will be stored with the object and returned when you retrieve the object. The total size of the HTTP request, not including the body, must be less than 4 KB.</li>
|
@@ -1353,8 +1365,14 @@ class AmazonS3 extends CFRuntime
|
|
1353 |
// Handle Access Control Lists. Can also be passed as an HTTP header.
|
1354 |
if (isset($opt['acl']))
|
1355 |
{
|
1356 |
-
|
1357 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1358 |
}
|
1359 |
|
1360 |
// Handle storage settings. Can also be passed as an HTTP header.
|
@@ -1512,7 +1530,10 @@ class AmazonS3 extends CFRuntime
|
|
1512 |
}
|
1513 |
|
1514 |
/**
|
1515 |
-
* Deletes
|
|
|
|
|
|
|
1516 |
*
|
1517 |
* @param string $bucket (Required) The name of the bucket to use.
|
1518 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
@@ -1548,7 +1569,8 @@ class AmazonS3 extends CFRuntime
|
|
1548 |
foreach ($opt['objects'] as $object)
|
1549 |
{
|
1550 |
$xobject = $xml->addChild('Object');
|
1551 |
-
$xobject->addChild('Key'
|
|
|
1552 |
|
1553 |
if (isset($object['version_id']))
|
1554 |
{
|
@@ -1666,19 +1688,6 @@ class AmazonS3 extends CFRuntime
|
|
1666 |
$opt['headers']['x-amz-copy-source'] = '/' . $source['bucket'] . '/' . rawurlencode($source['filename'])
|
1667 |
. (isset($opt['versionId']) ? ('?' . 'versionId=' . rawurlencode($opt['versionId'])) : ''); // Append the versionId to copy, if available
|
1668 |
unset($opt['versionId']);
|
1669 |
-
|
1670 |
-
// Determine if we need to lookup the pre-existing content-type.
|
1671 |
-
if (
|
1672 |
-
(!$this->use_batch_flow && !isset($opt['returnCurlHandle'])) &&
|
1673 |
-
!in_array(strtolower('content-type'), array_map('strtolower', array_keys($opt['headers'])))
|
1674 |
-
)
|
1675 |
-
{
|
1676 |
-
$response = $this->get_object_headers($source['bucket'], $source['filename']);
|
1677 |
-
if ($response->isOK())
|
1678 |
-
{
|
1679 |
-
$opt['headers']['Content-Type'] = $response->header['content-type'];
|
1680 |
-
}
|
1681 |
-
}
|
1682 |
}
|
1683 |
|
1684 |
// Handle metadata directive
|
@@ -1758,7 +1767,7 @@ class AmazonS3 extends CFRuntime
|
|
1758 |
$response = $this->authenticate($dest['bucket'], $opt);
|
1759 |
|
1760 |
// Attempt to reset ACLs
|
1761 |
-
$http = new
|
1762 |
$http->send_multi_request($batch);
|
1763 |
|
1764 |
return $response;
|
@@ -1840,7 +1849,6 @@ class AmazonS3 extends CFRuntime
|
|
1840 |
$opt['verb'] = 'PUT';
|
1841 |
$opt['resource'] = $filename;
|
1842 |
$opt['sub_resource'] = 'acl';
|
1843 |
-
|
1844 |
// Retrieve the original metadata
|
1845 |
$metadata = $this->get_object_metadata($bucket, $filename);
|
1846 |
if ($metadata && $metadata['ContentType'])
|
@@ -1865,7 +1873,7 @@ class AmazonS3 extends CFRuntime
|
|
1865 |
|
1866 |
if (is_array($acl))
|
1867 |
{
|
1868 |
-
$opt['
|
1869 |
}
|
1870 |
else
|
1871 |
{
|
@@ -1884,7 +1892,7 @@ class AmazonS3 extends CFRuntime
|
|
1884 |
* @param string $canonical_name (Required) The canonical display name for the bucket owner. This is provided as the `display_name` value from <get_canonical_user_id()>.
|
1885 |
* @param array $users (Optional) An array of associative arrays. Each associative array contains an `id` value and a `permission` value.
|
1886 |
* @return string Access Control Policy XML.
|
1887 |
-
* @link http://docs.amazonwebservices.com/AmazonS3/latest/dev/
|
1888 |
*/
|
1889 |
public function generate_access_policy($canonical_id, $canonical_name, $users)
|
1890 |
{
|
@@ -1941,6 +1949,59 @@ class AmazonS3 extends CFRuntime
|
|
1941 |
return $xml->asXML();
|
1942 |
}
|
1943 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1944 |
|
1945 |
/*%******************************************************************************************%*/
|
1946 |
// LOGGING METHODS
|
@@ -2615,14 +2676,14 @@ class AmazonS3 extends CFRuntime
|
|
2615 |
}
|
2616 |
|
2617 |
$data = array(
|
2618 |
-
'ACL'
|
2619 |
-
'ContentType'
|
2620 |
-
'ETag'
|
2621 |
-
'Headers'
|
2622 |
-
'Key'
|
2623 |
'LastModified' => null,
|
2624 |
-
'Owner'
|
2625 |
-
'Size'
|
2626 |
'StorageClass' => null,
|
2627 |
);
|
2628 |
|
@@ -2673,7 +2734,7 @@ class AmazonS3 extends CFRuntime
|
|
2673 |
* @param string $filename (Required) The file name for the Amazon S3 object.
|
2674 |
* @param integer|string $preauth (Optional) Specifies that a presigned URL for this request should be returned. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.
|
2675 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2676 |
-
* <li><code>https</code> - <code>boolean</code> - Optional - Set to <code>true</code> if you would like the URL be in https mode. Otherwise, the default behavior is always to use http regardless of your SSL settings
|
2677 |
* <li><code>method</code> - <code>string</code> - Optional - The HTTP method to use for the request. Defaults to a value of <code>GET</code>.</li>
|
2678 |
* <li><code>response</code> - <code>array</code> - Optional - Allows adjustments to specific response headers. Pass an associative array where each key is one of the following: <code>cache-control</code>, <code>content-disposition</code>, <code>content-encoding</code>, <code>content-language</code>, <code>content-type</code>, <code>expires</code>. The <code>expires</code> value should use <php:gmdate()> and be formatted with the <code>DATE_RFC2822</code> constant.</li>
|
2679 |
* <li><code>torrent</code> - <code>boolean</code> - Optional - A value of <code>true</code> will return a URL to a torrent of the Amazon S3 object. A value of <code>false</code> will return a non-torrent URL. Defaults to <code>false</code>.</li>
|
@@ -3096,7 +3157,7 @@ class AmazonS3 extends CFRuntime
|
|
3096 |
* @param string $bucket (Required) The name of the bucket to use.
|
3097 |
* @param string $filename (Required) The file name for the object.
|
3098 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
3099 |
-
* <li><code>acl</code> - <code>string</code> - Optional - The ACL settings for the specified object. [Allowed values: <code>AmazonS3::ACL_PRIVATE</code>, <code>AmazonS3::ACL_PUBLIC</code>, <code>AmazonS3::ACL_OPEN</code>, <code>AmazonS3::ACL_AUTH_READ</code>, <code>AmazonS3::ACL_OWNER_READ</code>, <code>AmazonS3::ACL_OWNER_FULL_CONTROL</code>]. The default value is <code>ACL_PRIVATE</code>.</li>
|
3100 |
* <li><code>contentType</code> - <code>string</code> - Optional - The type of content that is being sent. The default value is <code>application/octet-stream</code>.</li>
|
3101 |
* <li><code>encryption</code> - <code>string</code> - Optional - The algorithm to use for encrypting the object. [Allowed values: <code>AES256</code>]</li>
|
3102 |
* <li><code>headers</code> - <code>array</code> - Optional - Standard HTTP headers to send along in the request. Accepts an associative array of key-value pairs.</li>
|
@@ -3133,8 +3194,14 @@ class AmazonS3 extends CFRuntime
|
|
3133 |
// Handle Access Control Lists. Can also be passed as an HTTP header.
|
3134 |
if (isset($opt['acl']))
|
3135 |
{
|
3136 |
-
|
3137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
3138 |
}
|
3139 |
|
3140 |
// Handle storage settings. Can also be passed as an HTTP header.
|
@@ -3822,11 +3889,13 @@ class AmazonS3 extends CFRuntime
|
|
3822 |
* measured as number of days from creation time. Amazon S3 guarantees that the object will be
|
3823 |
* deleted when the expiration time is passed.
|
3824 |
*
|
|
|
|
|
3825 |
* @param string $bucket (Required) The name of the bucket to use.
|
3826 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
3827 |
* <li><code>rules</code> - <code>string</code> - Required - The object expiration rule-sets to apply to the bucket. <ul>
|
3828 |
* <li><code>x</code> - <code>array</code> - Required - This represents a simple array index. <ul>
|
3829 |
-
* <li><code>id</code> - <code>string</code> - Optional - Unique identifier for the rule. The value cannot be longer than 255 characters
|
3830 |
* <li><code>prefix</code> - <code>string</code> - Required - The Amazon S3 object prefix which targets the file(s) for expiration.</li>
|
3831 |
* <li><code>expiration</code> - <code>array</code> - Required - The container for the unit of measurement by which the expiration time is calculated. <ul>
|
3832 |
* <li><code>days</code> - <code>integer</code> - Required - The number of days until the targetted objects expire from the bucket.</li>
|
@@ -3919,6 +3988,17 @@ class AmazonS3 extends CFRuntime
|
|
3919 |
return $this->authenticate($bucket, $opt);
|
3920 |
}
|
3921 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3922 |
public function get_object_expiration_config($bucket, $opt = null)
|
3923 |
{
|
3924 |
if (!$opt) $opt = array();
|
@@ -3929,6 +4009,17 @@ class AmazonS3 extends CFRuntime
|
|
3929 |
return $this->authenticate($bucket, $opt);
|
3930 |
}
|
3931 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3932 |
public function delete_object_expiration_config($bucket, $opt = null)
|
3933 |
{
|
3934 |
if (!$opt) $opt = array();
|
49 |
*
|
50 |
* Visit <http://aws.amazon.com/s3/> for more information.
|
51 |
*
|
52 |
+
* @version 2012.06.18
|
53 |
* @license See the included NOTICE.md file for more information.
|
54 |
* @copyright See the included NOTICE.md file for more information.
|
55 |
* @link http://aws.amazon.com/s3/ Amazon Simple Storage Service
|
1070 |
*
|
1071 |
* @param string $bucket (Required) The name of the bucket to create.
|
1072 |
* @param string $region (Required) The preferred geographical location for the bucket. [Allowed values: `AmazonS3::REGION_US_E1 `, `AmazonS3::REGION_US_W1`, `AmazonS3::REGION_EU_W1`, `AmazonS3::REGION_APAC_SE1`, `AmazonS3::REGION_APAC_NE1`]
|
1073 |
+
* @param string $acl (Optional) The ACL settings for the specified object. Accepts any of the following constants: [Allowed values: <code>AmazonS3::ACL_PRIVATE</code>, <code>AmazonS3::ACL_PUBLIC</code>, <code>AmazonS3::ACL_OPEN</code>, <code>AmazonS3::ACL_AUTH_READ</code>, <code>AmazonS3::ACL_OWNER_READ</code>, <code>AmazonS3::ACL_OWNER_FULL_CONTROL</code>]. Alternatively, an array of associative arrays. Each associative array contains an <code>id</code> and a <code>permission</code> key. The default value is <code>ACL_PRIVATE</code>.
|
1074 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1075 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
1076 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request.</li></ul>
|
1100 |
if (!$opt) $opt = array();
|
1101 |
$opt['verb'] = 'PUT';
|
1102 |
$opt['headers'] = array(
|
1103 |
+
'Content-Type' => 'application/xml'
|
|
|
1104 |
);
|
1105 |
|
1106 |
+
// Handle Access Control Lists. Can also be passed as an HTTP header.
|
1107 |
+
if (isset($acl))
|
1108 |
+
{
|
1109 |
+
if (is_array($acl))
|
1110 |
+
{
|
1111 |
+
$opt['headers'] = array_merge($opt['headers'], $this->generate_access_policy_headers($acl));
|
1112 |
+
}
|
1113 |
+
else
|
1114 |
+
{
|
1115 |
+
$opt['headers']['x-amz-acl'] = $acl;
|
1116 |
+
}
|
1117 |
+
}
|
1118 |
+
|
1119 |
// Defaults
|
1120 |
$this->set_region($region); // Also sets path-style
|
1121 |
$xml = simplexml_load_string($this->base_location_constraint);
|
1299 |
|
1300 |
if (is_array($acl))
|
1301 |
{
|
1302 |
+
$opt['headers'] = array_merge($opt['headers'], $this->generate_access_policy_headers($acl));
|
1303 |
}
|
1304 |
else
|
1305 |
{
|
1325 |
* @param string $bucket (Required) The name of the bucket to use.
|
1326 |
* @param string $filename (Required) The file name for the object.
|
1327 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1328 |
+
* <li><code>acl</code> - <code>string</code> - Optional - The ACL settings for the specified object. Accepts any of the following constants: [Allowed values: <code>AmazonS3::ACL_PRIVATE</code>, <code>AmazonS3::ACL_PUBLIC</code>, <code>AmazonS3::ACL_OPEN</code>, <code>AmazonS3::ACL_AUTH_READ</code>, <code>AmazonS3::ACL_OWNER_READ</code>, <code>AmazonS3::ACL_OWNER_FULL_CONTROL</code>]. Alternatively, an array of associative arrays. Each associative array contains an <code>id</code> and a <code>permission</code> key. The default value is <code>ACL_PRIVATE</code>.</li>
|
1329 |
* <li><code>body</code> - <code>string</code> - Required; Conditional - The data to be stored in the object. Either this parameter or <code>fileUpload</code> must be specified.</li>
|
|
|
|
|
1330 |
* <li><code>contentType</code> - <code>string</code> - Optional - The type of content that is being sent in the body. If a file is being uploaded via <code>fileUpload</code> as a file system path, it will attempt to determine the correct mime-type based on the file extension. The default value is <code>application/octet-stream</code>.</li>
|
1331 |
* <li><code>encryption</code> - <code>string</code> - Optional - The algorithm to use for encrypting the object. [Allowed values: <code>AES256</code>]</li>
|
1332 |
+
* <li><code>fileUpload</code> - <code>string|resource</code> - Required; Conditional - The URL/path for the file to upload, or an open resource. Either this parameter or <code>body</code> is required.</li>
|
1333 |
* <li><code>headers</code> - <code>array</code> - Optional - Standard HTTP headers to send along in the request. Accepts an associative array of key-value pairs.</li>
|
1334 |
* <li><code>length</code> - <code>integer</code> - Optional - The size of the object in bytes. For more information, see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13">RFC 2616, section 14.13</a>. The value can also be passed to the <code>header</code> option as <code>Content-Length</code>.</li>
|
1335 |
* <li><code>meta</code> - <code>array</code> - Optional - An associative array of key-value pairs. Represented by <code>x-amz-meta-:</code>. Any header starting with this prefix is considered user metadata. It will be stored with the object and returned when you retrieve the object. The total size of the HTTP request, not including the body, must be less than 4 KB.</li>
|
1365 |
// Handle Access Control Lists. Can also be passed as an HTTP header.
|
1366 |
if (isset($opt['acl']))
|
1367 |
{
|
1368 |
+
if (is_array($opt['acl']))
|
1369 |
+
{
|
1370 |
+
$opt['headers'] = array_merge($opt['headers'], $this->generate_access_policy_headers($opt['acl']));
|
1371 |
+
}
|
1372 |
+
else
|
1373 |
+
{
|
1374 |
+
$opt['headers']['x-amz-acl'] = $opt['acl'];
|
1375 |
+
}
|
1376 |
}
|
1377 |
|
1378 |
// Handle storage settings. Can also be passed as an HTTP header.
|
1530 |
}
|
1531 |
|
1532 |
/**
|
1533 |
+
* Deletes one or more specified Amazon S3 objects from the specified bucket.
|
1534 |
+
*
|
1535 |
+
* Since `delete_object()` is designed for deleting a single object, this method is intended to be used
|
1536 |
+
* when there are two or more objects to delete.
|
1537 |
*
|
1538 |
* @param string $bucket (Required) The name of the bucket to use.
|
1539 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
1569 |
foreach ($opt['objects'] as $object)
|
1570 |
{
|
1571 |
$xobject = $xml->addChild('Object');
|
1572 |
+
$node = $xobject->addChild('Key');
|
1573 |
+
$node[0] = $object['key'];
|
1574 |
|
1575 |
if (isset($object['version_id']))
|
1576 |
{
|
1688 |
$opt['headers']['x-amz-copy-source'] = '/' . $source['bucket'] . '/' . rawurlencode($source['filename'])
|
1689 |
. (isset($opt['versionId']) ? ('?' . 'versionId=' . rawurlencode($opt['versionId'])) : ''); // Append the versionId to copy, if available
|
1690 |
unset($opt['versionId']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1691 |
}
|
1692 |
|
1693 |
// Handle metadata directive
|
1767 |
$response = $this->authenticate($dest['bucket'], $opt);
|
1768 |
|
1769 |
// Attempt to reset ACLs
|
1770 |
+
$http = new CFRequest();
|
1771 |
$http->send_multi_request($batch);
|
1772 |
|
1773 |
return $response;
|
1849 |
$opt['verb'] = 'PUT';
|
1850 |
$opt['resource'] = $filename;
|
1851 |
$opt['sub_resource'] = 'acl';
|
|
|
1852 |
// Retrieve the original metadata
|
1853 |
$metadata = $this->get_object_metadata($bucket, $filename);
|
1854 |
if ($metadata && $metadata['ContentType'])
|
1873 |
|
1874 |
if (is_array($acl))
|
1875 |
{
|
1876 |
+
$opt['headers'] = array_merge($opt['headers'], $this->generate_access_policy_headers($acl));
|
1877 |
}
|
1878 |
else
|
1879 |
{
|
1892 |
* @param string $canonical_name (Required) The canonical display name for the bucket owner. This is provided as the `display_name` value from <get_canonical_user_id()>.
|
1893 |
* @param array $users (Optional) An array of associative arrays. Each associative array contains an `id` value and a `permission` value.
|
1894 |
* @return string Access Control Policy XML.
|
1895 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/dev/ACLOverview.html Access Control Lists
|
1896 |
*/
|
1897 |
public function generate_access_policy($canonical_id, $canonical_name, $users)
|
1898 |
{
|
1949 |
return $xml->asXML();
|
1950 |
}
|
1951 |
|
1952 |
+
/**
|
1953 |
+
* Generates the HTTP headers to be used for the Access Control Policy Grants.
|
1954 |
+
*
|
1955 |
+
* @param array $users (Optional) An array of associative arrays. Each associative array contains an `id` value and a `permission` value.
|
1956 |
+
* @return array HTTP headers to be applied to the request.
|
1957 |
+
* @link http://docs.amazonwebservices.com/AmazonS3/latest/dev/ACLOverview.html Access Control Lists
|
1958 |
+
*/
|
1959 |
+
public function generate_access_policy_headers($users)
|
1960 |
+
{
|
1961 |
+
$headers = array();
|
1962 |
+
|
1963 |
+
foreach ($users as $user)
|
1964 |
+
{
|
1965 |
+
// Determine permission. If doesn't exist, create it.
|
1966 |
+
$permission = 'x-amz-grant-' . str_replace('_', '-', strtolower($user['permission']));
|
1967 |
+
if (!isset($headers[$permission]))
|
1968 |
+
{
|
1969 |
+
$headers[$permission] = array();
|
1970 |
+
}
|
1971 |
+
|
1972 |
+
// Handle the IDs
|
1973 |
+
switch ($user['id'])
|
1974 |
+
{
|
1975 |
+
case self::USERS_AUTH: // Authorized Users
|
1976 |
+
case self::USERS_ALL: // All Users
|
1977 |
+
case self::USERS_LOGGING: // The Logging User
|
1978 |
+
$headers[$permission][] = 'uri="' . $user['id'] . '"';
|
1979 |
+
break;
|
1980 |
+
|
1981 |
+
// Email Address or Canonical Id
|
1982 |
+
default:
|
1983 |
+
if (strpos($user['id'], '@'))
|
1984 |
+
{
|
1985 |
+
// Treat as email address
|
1986 |
+
$headers[$permission][] = 'emailAddress="' . $user['id'] . '"';
|
1987 |
+
}
|
1988 |
+
else
|
1989 |
+
{
|
1990 |
+
// Assume Canonical Id
|
1991 |
+
$headers[$permission][] = 'id="' . $user['id'] . '"';
|
1992 |
+
}
|
1993 |
+
break;
|
1994 |
+
}
|
1995 |
+
}
|
1996 |
+
|
1997 |
+
foreach ($headers as &$permission)
|
1998 |
+
{
|
1999 |
+
$permission = implode(', ', $permission);
|
2000 |
+
}
|
2001 |
+
|
2002 |
+
return $headers;
|
2003 |
+
}
|
2004 |
+
|
2005 |
|
2006 |
/*%******************************************************************************************%*/
|
2007 |
// LOGGING METHODS
|
2676 |
}
|
2677 |
|
2678 |
$data = array(
|
2679 |
+
'ACL' => array(),
|
2680 |
+
'ContentType' => null,
|
2681 |
+
'ETag' => null,
|
2682 |
+
'Headers' => null,
|
2683 |
+
'Key' => null,
|
2684 |
'LastModified' => null,
|
2685 |
+
'Owner' => array(),
|
2686 |
+
'Size' => null,
|
2687 |
'StorageClass' => null,
|
2688 |
);
|
2689 |
|
2734 |
* @param string $filename (Required) The file name for the Amazon S3 object.
|
2735 |
* @param integer|string $preauth (Optional) Specifies that a presigned URL for this request should be returned. May be passed as a number of seconds since UNIX Epoch, or any string compatible with <php:strtotime()>.
|
2736 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
2737 |
+
* <li><code>https</code> - <code>boolean</code> - Optional - Set to <code>true</code> if you would like the URL be in https mode. Otherwise, the default behavior is always to use http regardless of your SSL settings.</li>
|
2738 |
* <li><code>method</code> - <code>string</code> - Optional - The HTTP method to use for the request. Defaults to a value of <code>GET</code>.</li>
|
2739 |
* <li><code>response</code> - <code>array</code> - Optional - Allows adjustments to specific response headers. Pass an associative array where each key is one of the following: <code>cache-control</code>, <code>content-disposition</code>, <code>content-encoding</code>, <code>content-language</code>, <code>content-type</code>, <code>expires</code>. The <code>expires</code> value should use <php:gmdate()> and be formatted with the <code>DATE_RFC2822</code> constant.</li>
|
2740 |
* <li><code>torrent</code> - <code>boolean</code> - Optional - A value of <code>true</code> will return a URL to a torrent of the Amazon S3 object. A value of <code>false</code> will return a non-torrent URL. Defaults to <code>false</code>.</li>
|
3157 |
* @param string $bucket (Required) The name of the bucket to use.
|
3158 |
* @param string $filename (Required) The file name for the object.
|
3159 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
3160 |
+
* <li><code>acl</code> - <code>string</code> - Optional - The ACL settings for the specified object. Accepts any of the following constants: [Allowed values: <code>AmazonS3::ACL_PRIVATE</code>, <code>AmazonS3::ACL_PUBLIC</code>, <code>AmazonS3::ACL_OPEN</code>, <code>AmazonS3::ACL_AUTH_READ</code>, <code>AmazonS3::ACL_OWNER_READ</code>, <code>AmazonS3::ACL_OWNER_FULL_CONTROL</code>]. Alternatively, an array of associative arrays. Each associative array contains an <code>id</code> and a <code>permission</code> key. The default value is <code>ACL_PRIVATE</code>.</li>
|
3161 |
* <li><code>contentType</code> - <code>string</code> - Optional - The type of content that is being sent. The default value is <code>application/octet-stream</code>.</li>
|
3162 |
* <li><code>encryption</code> - <code>string</code> - Optional - The algorithm to use for encrypting the object. [Allowed values: <code>AES256</code>]</li>
|
3163 |
* <li><code>headers</code> - <code>array</code> - Optional - Standard HTTP headers to send along in the request. Accepts an associative array of key-value pairs.</li>
|
3194 |
// Handle Access Control Lists. Can also be passed as an HTTP header.
|
3195 |
if (isset($opt['acl']))
|
3196 |
{
|
3197 |
+
if (is_array($opt['acl']))
|
3198 |
+
{
|
3199 |
+
$opt['headers'] = array_merge($opt['headers'], $this->generate_access_policy_headers($opt['acl']));
|
3200 |
+
}
|
3201 |
+
else
|
3202 |
+
{
|
3203 |
+
$opt['headers']['x-amz-acl'] = $opt['acl'];
|
3204 |
+
}
|
3205 |
}
|
3206 |
|
3207 |
// Handle storage settings. Can also be passed as an HTTP header.
|
3889 |
* measured as number of days from creation time. Amazon S3 guarantees that the object will be
|
3890 |
* deleted when the expiration time is passed.
|
3891 |
*
|
3892 |
+
* This feature is also known as "lifecycle" (e.g., in the AWS Console).
|
3893 |
+
*
|
3894 |
* @param string $bucket (Required) The name of the bucket to use.
|
3895 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
3896 |
* <li><code>rules</code> - <code>string</code> - Required - The object expiration rule-sets to apply to the bucket. <ul>
|
3897 |
* <li><code>x</code> - <code>array</code> - Required - This represents a simple array index. <ul>
|
3898 |
+
* <li><code>id</code> - <code>string</code> - Optional - Unique identifier for the rule. The value cannot be longer than 255 characters.</li>
|
3899 |
* <li><code>prefix</code> - <code>string</code> - Required - The Amazon S3 object prefix which targets the file(s) for expiration.</li>
|
3900 |
* <li><code>expiration</code> - <code>array</code> - Required - The container for the unit of measurement by which the expiration time is calculated. <ul>
|
3901 |
* <li><code>days</code> - <code>integer</code> - Required - The number of days until the targetted objects expire from the bucket.</li>
|
3988 |
return $this->authenticate($bucket, $opt);
|
3989 |
}
|
3990 |
|
3991 |
+
/**
|
3992 |
+
* Retrieves the expiry period (i.e., lifecycle) for objects.
|
3993 |
+
*
|
3994 |
+
* This feature is also known as "lifecycle" (e.g., in the AWS Console).
|
3995 |
+
*
|
3996 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
3997 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
3998 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
3999 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
4000 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
4001 |
+
*/
|
4002 |
public function get_object_expiration_config($bucket, $opt = null)
|
4003 |
{
|
4004 |
if (!$opt) $opt = array();
|
4009 |
return $this->authenticate($bucket, $opt);
|
4010 |
}
|
4011 |
|
4012 |
+
/**
|
4013 |
+
* Deletes the expiry period (i.e., lifecycle) for objects.
|
4014 |
+
*
|
4015 |
+
* This feature is also known as "lifecycle" (e.g., in the AWS Console).
|
4016 |
+
*
|
4017 |
+
* @param string $bucket (Required) The name of the bucket to use.
|
4018 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
4019 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
4020 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
4021 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
4022 |
+
*/
|
4023 |
public function delete_object_expiration_config($bucket, $opt = null)
|
4024 |
{
|
4025 |
if (!$opt) $opt = array();
|
libs/aws/services/ses.class.php
CHANGED
@@ -26,7 +26,7 @@
|
|
26 |
* The endpoint for Amazon SES is located at: <code>https://email.us-east-1.amazonaws.com</code>
|
27 |
* </p>
|
28 |
*
|
29 |
-
* @version 2012.
|
30 |
* @license See the included NOTICE.md file for complete information.
|
31 |
* @copyright See the included NOTICE.md file for complete information.
|
32 |
* @link http://aws.amazon.com/ses/ Amazon Simple Email Service
|
@@ -106,7 +106,7 @@ class AmazonSES extends CFRuntime
|
|
106 |
*/
|
107 |
public function disable_ssl()
|
108 |
{
|
109 |
-
throw new
|
110 |
}
|
111 |
|
112 |
|
@@ -152,6 +152,30 @@ class AmazonSES extends CFRuntime
|
|
152 |
return $this->authenticate('DeleteVerifiedEmailAddress', $opt);
|
153 |
}
|
154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
/**
|
156 |
* Given a list of identities (email addresses and/or domains), returns the verification status
|
157 |
* and (for domain identities) the verification token for each identity.
|
@@ -395,6 +419,52 @@ class AmazonSES extends CFRuntime
|
|
395 |
return $this->authenticate('SendRawEmail', $opt);
|
396 |
}
|
397 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
398 |
/**
|
399 |
* Verifies a domain.
|
400 |
*
|
26 |
* The endpoint for Amazon SES is located at: <code>https://email.us-east-1.amazonaws.com</code>
|
27 |
* </p>
|
28 |
*
|
29 |
+
* @version 2012.06.21
|
30 |
* @license See the included NOTICE.md file for complete information.
|
31 |
* @copyright See the included NOTICE.md file for complete information.
|
32 |
* @link http://aws.amazon.com/ses/ Amazon Simple Email Service
|
106 |
*/
|
107 |
public function disable_ssl()
|
108 |
{
|
109 |
+
throw new SES_Exception('SSL/HTTPS is REQUIRED for Amazon Email Service and cannot be disabled.');
|
110 |
}
|
111 |
|
112 |
|
152 |
return $this->authenticate('DeleteVerifiedEmailAddress', $opt);
|
153 |
}
|
154 |
|
155 |
+
/**
|
156 |
+
* Given a list of verified identities (email addresses and/or domains), returns a structure
|
157 |
+
* describing identity notification attributes. For more information about feedback notification,
|
158 |
+
* see the <a href="http://docs.amazonwebservices.com/ses/latest/DeveloperGuide">Amazon SES
|
159 |
+
* Developer Guide</a>.
|
160 |
+
*
|
161 |
+
* @param string|array $identities (Required) A list of one or more identities. Pass a string for a single value, or an indexed array for multiple values.
|
162 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
163 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
164 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
165 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
166 |
+
*/
|
167 |
+
public function get_identity_notification_attributes($identities, $opt = null)
|
168 |
+
{
|
169 |
+
if (!$opt) $opt = array();
|
170 |
+
|
171 |
+
// Required list (non-map)
|
172 |
+
$opt = array_merge($opt, CFComplexType::map(array(
|
173 |
+
'Identities' => (is_array($identities) ? $identities : array($identities))
|
174 |
+
), 'member'));
|
175 |
+
|
176 |
+
return $this->authenticate('GetIdentityNotificationAttributes', $opt);
|
177 |
+
}
|
178 |
+
|
179 |
/**
|
180 |
* Given a list of identities (email addresses and/or domains), returns the verification status
|
181 |
* and (for domain identities) the verification token for each identity.
|
419 |
return $this->authenticate('SendRawEmail', $opt);
|
420 |
}
|
421 |
|
422 |
+
/**
|
423 |
+
* Given an identity (email address or domain), enables or disables whether Amazon SES forwards
|
424 |
+
* feedback notifications as email. Feedback forwarding may only be disabled when both complaint
|
425 |
+
* and bounce topics are set. For more information about feedback notification, see the <a href=
|
426 |
+
* "http://docs.amazonwebservices.com/ses/latest/DeveloperGuide">Amazon SES Developer Guide</a>.
|
427 |
+
*
|
428 |
+
* @param string $identity (Required) The identity for which to set feedback notification forwarding. Examples: <code>user@example.com</code>, <code>example.com</code>.
|
429 |
+
* @param boolean $forwarding_enabled (Required) Sets whether Amazon SES will forward feedback notifications as email. <code>true</code> specifies that Amazon SES will forward feedback notifications as email, in addition to any Amazon SNS topic publishing otherwise specified. <code>false</code> specifies that Amazon SES will publish feedback notifications only through Amazon SNS. This value can only be set to <code>false</code> when topics are specified for both <code>Bounce</code> and <code>Complaint</code> topic types.
|
430 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
431 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
432 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
433 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
434 |
+
*/
|
435 |
+
public function set_identity_feedback_forwarding_enabled($identity, $forwarding_enabled, $opt = null)
|
436 |
+
{
|
437 |
+
if (!$opt) $opt = array();
|
438 |
+
$opt['Identity'] = $identity;
|
439 |
+
$opt['ForwardingEnabled'] = $forwarding_enabled;
|
440 |
+
|
441 |
+
return $this->authenticate('SetIdentityFeedbackForwardingEnabled', $opt);
|
442 |
+
}
|
443 |
+
|
444 |
+
/**
|
445 |
+
* Given an identity (email address or domain), sets the Amazon SNS topic to which Amazon SES will
|
446 |
+
* publish bounce and complaint notifications for emails sent with that identity as the
|
447 |
+
* <code>Source</code>. Publishing to topics may only be disabled when feedback forwarding is
|
448 |
+
* enabled. For more information about feedback notification, see the <a href=
|
449 |
+
* "http://docs.amazonwebservices.com/ses/latest/DeveloperGuide">Amazon SES Developer Guide</a>.
|
450 |
+
*
|
451 |
+
* @param string $identity (Required) The identity for which the topic will be set. Examples: <code>user@example.com</code>, <code>example.com</code>.
|
452 |
+
* @param string $notification_type (Required) The type of feedback notifications that will be published to the specified topic. [Allowed values: <code>Bounce</code>, <code>Complaint</code>]
|
453 |
+
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
454 |
+
* <li><code>SnsTopic</code> - <code>string</code> - Optional - The Amazon Resource Name (ARN) of the Amazon Simple Notification Service (Amazon SNS) topic. If the parameter is ommited from the request or a null value is passed, the topic is cleared and publishing is disabled.</li>
|
455 |
+
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
456 |
+
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
457 |
+
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
458 |
+
*/
|
459 |
+
public function set_identity_notification_topic($identity, $notification_type, $opt = null)
|
460 |
+
{
|
461 |
+
if (!$opt) $opt = array();
|
462 |
+
$opt['Identity'] = $identity;
|
463 |
+
$opt['NotificationType'] = $notification_type;
|
464 |
+
|
465 |
+
return $this->authenticate('SetIdentityNotificationTopic', $opt);
|
466 |
+
}
|
467 |
+
|
468 |
/**
|
469 |
* Verifies a domain.
|
470 |
*
|
libs/aws/services/storagegateway.class.php
CHANGED
@@ -35,13 +35,9 @@
|
|
35 |
* Errors</a>: Client and server errors that all actions can return.</li>
|
36 |
* <li><a href="http://docs.amazonwebservices.com/general/latest/gr/index.html?rande.html">Regions
|
37 |
* and Endpoints</a>: Itemized regions and endpoints for all AWS products.</li>
|
38 |
-
* <li><a href=
|
39 |
-
* "http://sns.us-east-1.amazonaws.com/doc/2010-03-31/SimpleNotificationService.wsdl">WSDL
|
40 |
-
* Location</a>:
|
41 |
-
* http://storagegateway.us-east-1.amazonaws.com/doc/2012-04-15/AWSStorageGatewayService.wsdl</li>
|
42 |
* </ul>
|
43 |
*
|
44 |
-
* @version 2012.05.
|
45 |
* @license See the included NOTICE.md file for complete information.
|
46 |
* @copyright See the included NOTICE.md file for complete information.
|
47 |
* @link http://aws.amazon.com/storagegateway/ AWS Storage Gateway
|
@@ -232,7 +228,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
232 |
{
|
233 |
if (!$opt) $opt = array();
|
234 |
|
235 |
-
$opt = json_encode($opt);
|
236 |
return $this->authenticate('ActivateGateway', $opt);
|
237 |
}
|
238 |
|
@@ -259,7 +254,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
259 |
$opt['DiskIds'] = (is_array($opt['DiskIds']) ? $opt['DiskIds'] : array($opt['DiskIds']));
|
260 |
}
|
261 |
|
262 |
-
$opt = json_encode($opt);
|
263 |
return $this->authenticate('AddWorkingStorage', $opt);
|
264 |
}
|
265 |
|
@@ -299,7 +293,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
299 |
{
|
300 |
if (!$opt) $opt = array();
|
301 |
|
302 |
-
$opt = json_encode($opt);
|
303 |
return $this->authenticate('CreateSnapshot', $opt);
|
304 |
}
|
305 |
|
@@ -329,7 +322,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
329 |
{
|
330 |
if (!$opt) $opt = array();
|
331 |
|
332 |
-
$opt = json_encode($opt);
|
333 |
return $this->authenticate('CreateStorediSCSIVolume', $opt);
|
334 |
}
|
335 |
|
@@ -350,7 +342,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
350 |
{
|
351 |
if (!$opt) $opt = array();
|
352 |
|
353 |
-
$opt = json_encode($opt);
|
354 |
return $this->authenticate('DeleteBandwidthRateLimit', $opt);
|
355 |
}
|
356 |
|
@@ -369,7 +360,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
369 |
{
|
370 |
if (!$opt) $opt = array();
|
371 |
|
372 |
-
$opt = json_encode($opt);
|
373 |
return $this->authenticate('DeleteChapCredentials', $opt);
|
374 |
}
|
375 |
|
@@ -392,7 +382,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
392 |
{
|
393 |
if (!$opt) $opt = array();
|
394 |
|
395 |
-
$opt = json_encode($opt);
|
396 |
return $this->authenticate('DeleteGateway', $opt);
|
397 |
}
|
398 |
|
@@ -421,7 +410,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
421 |
{
|
422 |
if (!$opt) $opt = array();
|
423 |
|
424 |
-
$opt = json_encode($opt);
|
425 |
return $this->authenticate('DeleteVolume', $opt);
|
426 |
}
|
427 |
|
@@ -444,7 +432,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
444 |
{
|
445 |
if (!$opt) $opt = array();
|
446 |
|
447 |
-
$opt = json_encode($opt);
|
448 |
return $this->authenticate('DescribeBandwidthRateLimit', $opt);
|
449 |
}
|
450 |
|
@@ -462,7 +449,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
462 |
{
|
463 |
if (!$opt) $opt = array();
|
464 |
|
465 |
-
$opt = json_encode($opt);
|
466 |
return $this->authenticate('DescribeChapCredentials', $opt);
|
467 |
}
|
468 |
|
@@ -481,7 +467,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
481 |
{
|
482 |
if (!$opt) $opt = array();
|
483 |
|
484 |
-
$opt = json_encode($opt);
|
485 |
return $this->authenticate('DescribeGatewayInformation', $opt);
|
486 |
}
|
487 |
|
@@ -499,7 +484,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
499 |
{
|
500 |
if (!$opt) $opt = array();
|
501 |
|
502 |
-
$opt = json_encode($opt);
|
503 |
return $this->authenticate('DescribeMaintenanceStartTime', $opt);
|
504 |
}
|
505 |
|
@@ -518,7 +502,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
518 |
{
|
519 |
if (!$opt) $opt = array();
|
520 |
|
521 |
-
$opt = json_encode($opt);
|
522 |
return $this->authenticate('DescribeSnapshotSchedule', $opt);
|
523 |
}
|
524 |
|
@@ -543,7 +526,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
543 |
$opt['VolumeARNs'] = (is_array($opt['VolumeARNs']) ? $opt['VolumeARNs'] : array($opt['VolumeARNs']));
|
544 |
}
|
545 |
|
546 |
-
$opt = json_encode($opt);
|
547 |
return $this->authenticate('DescribeStorediSCSIVolumes', $opt);
|
548 |
}
|
549 |
|
@@ -562,7 +544,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
562 |
{
|
563 |
if (!$opt) $opt = array();
|
564 |
|
565 |
-
$opt = json_encode($opt);
|
566 |
return $this->authenticate('DescribeWorkingStorage', $opt);
|
567 |
}
|
568 |
|
@@ -588,7 +569,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
588 |
{
|
589 |
if (!$opt) $opt = array();
|
590 |
|
591 |
-
$opt = json_encode($opt);
|
592 |
return $this->authenticate('ListGateways', $opt);
|
593 |
}
|
594 |
|
@@ -609,7 +589,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
609 |
{
|
610 |
if (!$opt) $opt = array();
|
611 |
|
612 |
-
$opt = json_encode($opt);
|
613 |
return $this->authenticate('ListLocalDisks', $opt);
|
614 |
}
|
615 |
|
@@ -636,7 +615,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
636 |
{
|
637 |
if (!$opt) $opt = array();
|
638 |
|
639 |
-
$opt = json_encode($opt);
|
640 |
return $this->authenticate('ListVolumes', $opt);
|
641 |
}
|
642 |
|
@@ -673,7 +651,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
673 |
{
|
674 |
if (!$opt) $opt = array();
|
675 |
|
676 |
-
$opt = json_encode($opt);
|
677 |
return $this->authenticate('ShutdownGateway', $opt);
|
678 |
}
|
679 |
|
@@ -702,7 +679,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
702 |
{
|
703 |
if (!$opt) $opt = array();
|
704 |
|
705 |
-
$opt = json_encode($opt);
|
706 |
return $this->authenticate('StartGateway', $opt);
|
707 |
}
|
708 |
|
@@ -730,7 +706,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
730 |
{
|
731 |
if (!$opt) $opt = array();
|
732 |
|
733 |
-
$opt = json_encode($opt);
|
734 |
return $this->authenticate('UpdateBandwidthRateLimit', $opt);
|
735 |
}
|
736 |
|
@@ -752,7 +727,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
752 |
{
|
753 |
if (!$opt) $opt = array();
|
754 |
|
755 |
-
$opt = json_encode($opt);
|
756 |
return $this->authenticate('UpdateChapCredentials', $opt);
|
757 |
}
|
758 |
|
@@ -773,7 +747,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
773 |
{
|
774 |
if (!$opt) $opt = array();
|
775 |
|
776 |
-
$opt = json_encode($opt);
|
777 |
return $this->authenticate('UpdateGatewayInformation', $opt);
|
778 |
}
|
779 |
|
@@ -803,7 +776,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
803 |
{
|
804 |
if (!$opt) $opt = array();
|
805 |
|
806 |
-
$opt = json_encode($opt);
|
807 |
return $this->authenticate('UpdateGatewaySoftwareNow', $opt);
|
808 |
}
|
809 |
|
@@ -824,7 +796,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
824 |
{
|
825 |
if (!$opt) $opt = array();
|
826 |
|
827 |
-
$opt = json_encode($opt);
|
828 |
return $this->authenticate('UpdateMaintenanceStartTime', $opt);
|
829 |
}
|
830 |
|
@@ -851,7 +822,6 @@ class AmazonStorageGateway extends CFRuntime
|
|
851 |
{
|
852 |
if (!$opt) $opt = array();
|
853 |
|
854 |
-
$opt = json_encode($opt);
|
855 |
return $this->authenticate('UpdateSnapshotSchedule', $opt);
|
856 |
}
|
857 |
}
|
35 |
* Errors</a>: Client and server errors that all actions can return.</li>
|
36 |
* <li><a href="http://docs.amazonwebservices.com/general/latest/gr/index.html?rande.html">Regions
|
37 |
* and Endpoints</a>: Itemized regions and endpoints for all AWS products.</li>
|
|
|
|
|
|
|
|
|
38 |
* </ul>
|
39 |
*
|
40 |
+
* @version 2012.05.14
|
41 |
* @license See the included NOTICE.md file for complete information.
|
42 |
* @copyright See the included NOTICE.md file for complete information.
|
43 |
* @link http://aws.amazon.com/storagegateway/ AWS Storage Gateway
|
228 |
{
|
229 |
if (!$opt) $opt = array();
|
230 |
|
|
|
231 |
return $this->authenticate('ActivateGateway', $opt);
|
232 |
}
|
233 |
|
254 |
$opt['DiskIds'] = (is_array($opt['DiskIds']) ? $opt['DiskIds'] : array($opt['DiskIds']));
|
255 |
}
|
256 |
|
|
|
257 |
return $this->authenticate('AddWorkingStorage', $opt);
|
258 |
}
|
259 |
|
293 |
{
|
294 |
if (!$opt) $opt = array();
|
295 |
|
|
|
296 |
return $this->authenticate('CreateSnapshot', $opt);
|
297 |
}
|
298 |
|
322 |
{
|
323 |
if (!$opt) $opt = array();
|
324 |
|
|
|
325 |
return $this->authenticate('CreateStorediSCSIVolume', $opt);
|
326 |
}
|
327 |
|
342 |
{
|
343 |
if (!$opt) $opt = array();
|
344 |
|
|
|
345 |
return $this->authenticate('DeleteBandwidthRateLimit', $opt);
|
346 |
}
|
347 |
|
360 |
{
|
361 |
if (!$opt) $opt = array();
|
362 |
|
|
|
363 |
return $this->authenticate('DeleteChapCredentials', $opt);
|
364 |
}
|
365 |
|
382 |
{
|
383 |
if (!$opt) $opt = array();
|
384 |
|
|
|
385 |
return $this->authenticate('DeleteGateway', $opt);
|
386 |
}
|
387 |
|
410 |
{
|
411 |
if (!$opt) $opt = array();
|
412 |
|
|
|
413 |
return $this->authenticate('DeleteVolume', $opt);
|
414 |
}
|
415 |
|
432 |
{
|
433 |
if (!$opt) $opt = array();
|
434 |
|
|
|
435 |
return $this->authenticate('DescribeBandwidthRateLimit', $opt);
|
436 |
}
|
437 |
|
449 |
{
|
450 |
if (!$opt) $opt = array();
|
451 |
|
|
|
452 |
return $this->authenticate('DescribeChapCredentials', $opt);
|
453 |
}
|
454 |
|
467 |
{
|
468 |
if (!$opt) $opt = array();
|
469 |
|
|
|
470 |
return $this->authenticate('DescribeGatewayInformation', $opt);
|
471 |
}
|
472 |
|
484 |
{
|
485 |
if (!$opt) $opt = array();
|
486 |
|
|
|
487 |
return $this->authenticate('DescribeMaintenanceStartTime', $opt);
|
488 |
}
|
489 |
|
502 |
{
|
503 |
if (!$opt) $opt = array();
|
504 |
|
|
|
505 |
return $this->authenticate('DescribeSnapshotSchedule', $opt);
|
506 |
}
|
507 |
|
526 |
$opt['VolumeARNs'] = (is_array($opt['VolumeARNs']) ? $opt['VolumeARNs'] : array($opt['VolumeARNs']));
|
527 |
}
|
528 |
|
|
|
529 |
return $this->authenticate('DescribeStorediSCSIVolumes', $opt);
|
530 |
}
|
531 |
|
544 |
{
|
545 |
if (!$opt) $opt = array();
|
546 |
|
|
|
547 |
return $this->authenticate('DescribeWorkingStorage', $opt);
|
548 |
}
|
549 |
|
569 |
{
|
570 |
if (!$opt) $opt = array();
|
571 |
|
|
|
572 |
return $this->authenticate('ListGateways', $opt);
|
573 |
}
|
574 |
|
589 |
{
|
590 |
if (!$opt) $opt = array();
|
591 |
|
|
|
592 |
return $this->authenticate('ListLocalDisks', $opt);
|
593 |
}
|
594 |
|
615 |
{
|
616 |
if (!$opt) $opt = array();
|
617 |
|
|
|
618 |
return $this->authenticate('ListVolumes', $opt);
|
619 |
}
|
620 |
|
651 |
{
|
652 |
if (!$opt) $opt = array();
|
653 |
|
|
|
654 |
return $this->authenticate('ShutdownGateway', $opt);
|
655 |
}
|
656 |
|
679 |
{
|
680 |
if (!$opt) $opt = array();
|
681 |
|
|
|
682 |
return $this->authenticate('StartGateway', $opt);
|
683 |
}
|
684 |
|
706 |
{
|
707 |
if (!$opt) $opt = array();
|
708 |
|
|
|
709 |
return $this->authenticate('UpdateBandwidthRateLimit', $opt);
|
710 |
}
|
711 |
|
727 |
{
|
728 |
if (!$opt) $opt = array();
|
729 |
|
|
|
730 |
return $this->authenticate('UpdateChapCredentials', $opt);
|
731 |
}
|
732 |
|
747 |
{
|
748 |
if (!$opt) $opt = array();
|
749 |
|
|
|
750 |
return $this->authenticate('UpdateGatewayInformation', $opt);
|
751 |
}
|
752 |
|
776 |
{
|
777 |
if (!$opt) $opt = array();
|
778 |
|
|
|
779 |
return $this->authenticate('UpdateGatewaySoftwareNow', $opt);
|
780 |
}
|
781 |
|
796 |
{
|
797 |
if (!$opt) $opt = array();
|
798 |
|
|
|
799 |
return $this->authenticate('UpdateMaintenanceStartTime', $opt);
|
800 |
}
|
801 |
|
822 |
{
|
823 |
if (!$opt) $opt = array();
|
824 |
|
|
|
825 |
return $this->authenticate('UpdateSnapshotSchedule', $opt);
|
826 |
}
|
827 |
}
|
libs/aws/services/sts.class.php
CHANGED
@@ -42,7 +42,7 @@
|
|
42 |
* We will refer to Amazon Identity and Access Management using the abbreviated form IAM. All
|
43 |
* copyrights and legal protections still apply.
|
44 |
*
|
45 |
-
* @version 2012.
|
46 |
* @license See the included NOTICE.md file for complete information.
|
47 |
* @copyright See the included NOTICE.md file for complete information.
|
48 |
* @link http://aws.amazon.com/sts/ Amazon Secure Token Service
|
@@ -165,8 +165,6 @@ class AmazonSTS extends CFRuntime
|
|
165 |
*
|
166 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
167 |
* <li><code>DurationSeconds</code> - <code>integer</code> - Optional - The duration, in seconds, that the credentials should remain valid. Acceptable durations for IAM user sessions range from 3600s (one hour) to 129600s (36 hours), with 43200s (12 hours) as the default. Sessions for AWS account owners are restricted to a maximum of 3600s (one hour).</li>
|
168 |
-
* <li><code>SerialNumber</code> - <code>string</code> - Optional - [Constraints: The value must be between 9 and 256 characters, and must match the following regular expression pattern: <code>[\w+=/:,.@-]*</code>]</li>
|
169 |
-
* <li><code>TokenCode</code> - <code>string</code> - Optional - [Constraints: The value must be between 6 and 6 characters, and must match the following regular expression pattern: <code>[\d]*</code>]</li>
|
170 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
171 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
172 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
42 |
* We will refer to Amazon Identity and Access Management using the abbreviated form IAM. All
|
43 |
* copyrights and legal protections still apply.
|
44 |
*
|
45 |
+
* @version 2012.05.31
|
46 |
* @license See the included NOTICE.md file for complete information.
|
47 |
* @copyright See the included NOTICE.md file for complete information.
|
48 |
* @link http://aws.amazon.com/sts/ Amazon Secure Token Service
|
165 |
*
|
166 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
167 |
* <li><code>DurationSeconds</code> - <code>integer</code> - Optional - The duration, in seconds, that the credentials should remain valid. Acceptable durations for IAM user sessions range from 3600s (one hour) to 129600s (36 hours), with 43200s (12 hours) as the default. Sessions for AWS account owners are restricted to a maximum of 3600s (one hour).</li>
|
|
|
|
|
168 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
169 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
170 |
* @return CFResponse A <CFResponse> object containing a parsed HTTP response.
|
libs/aws/services/swf.class.php
CHANGED
@@ -187,7 +187,7 @@
|
|
187 |
* "CountPendingDecisionTasks">CountPendingDecisionTasks</a></li>
|
188 |
* </ul>
|
189 |
*
|
190 |
-
* @version 2012.05.
|
191 |
* @license See the included NOTICE.md file for complete information.
|
192 |
* @copyright See the included NOTICE.md file for complete information.
|
193 |
* @link http://aws.amazon.com/simpleworkflow/ Amazon Simple Workflow
|
@@ -334,7 +334,6 @@ class AmazonSWF extends CFRuntime
|
|
334 |
{
|
335 |
if (!$opt) $opt = array();
|
336 |
|
337 |
-
$opt = json_encode($opt);
|
338 |
return $this->authenticate('CountClosedWorkflowExecutions', $opt);
|
339 |
}
|
340 |
|
@@ -371,7 +370,6 @@ class AmazonSWF extends CFRuntime
|
|
371 |
{
|
372 |
if (!$opt) $opt = array();
|
373 |
|
374 |
-
$opt = json_encode($opt);
|
375 |
return $this->authenticate('CountOpenWorkflowExecutions', $opt);
|
376 |
}
|
377 |
|
@@ -393,7 +391,6 @@ class AmazonSWF extends CFRuntime
|
|
393 |
{
|
394 |
if (!$opt) $opt = array();
|
395 |
|
396 |
-
$opt = json_encode($opt);
|
397 |
return $this->authenticate('CountPendingActivityTasks', $opt);
|
398 |
}
|
399 |
|
@@ -415,7 +412,6 @@ class AmazonSWF extends CFRuntime
|
|
415 |
{
|
416 |
if (!$opt) $opt = array();
|
417 |
|
418 |
-
$opt = json_encode($opt);
|
419 |
return $this->authenticate('CountPendingDecisionTasks', $opt);
|
420 |
}
|
421 |
|
@@ -443,7 +439,6 @@ class AmazonSWF extends CFRuntime
|
|
443 |
{
|
444 |
if (!$opt) $opt = array();
|
445 |
|
446 |
-
$opt = json_encode($opt);
|
447 |
return $this->authenticate('DeprecateActivityType', $opt);
|
448 |
}
|
449 |
|
@@ -468,7 +463,6 @@ class AmazonSWF extends CFRuntime
|
|
468 |
{
|
469 |
if (!$opt) $opt = array();
|
470 |
|
471 |
-
$opt = json_encode($opt);
|
472 |
return $this->authenticate('DeprecateDomain', $opt);
|
473 |
}
|
474 |
|
@@ -497,7 +491,6 @@ class AmazonSWF extends CFRuntime
|
|
497 |
{
|
498 |
if (!$opt) $opt = array();
|
499 |
|
500 |
-
$opt = json_encode($opt);
|
501 |
return $this->authenticate('DeprecateWorkflowType', $opt);
|
502 |
}
|
503 |
|
@@ -519,7 +512,6 @@ class AmazonSWF extends CFRuntime
|
|
519 |
{
|
520 |
if (!$opt) $opt = array();
|
521 |
|
522 |
-
$opt = json_encode($opt);
|
523 |
return $this->authenticate('DescribeActivityType', $opt);
|
524 |
}
|
525 |
|
@@ -536,7 +528,6 @@ class AmazonSWF extends CFRuntime
|
|
536 |
{
|
537 |
if (!$opt) $opt = array();
|
538 |
|
539 |
-
$opt = json_encode($opt);
|
540 |
return $this->authenticate('DescribeDomain', $opt);
|
541 |
}
|
542 |
|
@@ -563,7 +554,6 @@ class AmazonSWF extends CFRuntime
|
|
563 |
{
|
564 |
if (!$opt) $opt = array();
|
565 |
|
566 |
-
$opt = json_encode($opt);
|
567 |
return $this->authenticate('DescribeWorkflowExecution', $opt);
|
568 |
}
|
569 |
|
@@ -586,7 +576,6 @@ class AmazonSWF extends CFRuntime
|
|
586 |
{
|
587 |
if (!$opt) $opt = array();
|
588 |
|
589 |
-
$opt = json_encode($opt);
|
590 |
return $this->authenticate('DescribeWorkflowType', $opt);
|
591 |
}
|
592 |
|
@@ -607,7 +596,7 @@ class AmazonSWF extends CFRuntime
|
|
607 |
* <li><code>runId</code> - <code>string</code> - Required - A system generated unique identifier for the workflow execution.</li>
|
608 |
* </ul></li>
|
609 |
* <li><code>nextPageToken</code> - <code>string</code> - Optional - If a <code>NextPageToken</code> is returned, the result has more than one pages. To get the next page, repeat the call and specify the nextPageToken with all other arguments unchanged.</li>
|
610 |
-
* <li><code>maximumPageSize</code> - <code>integer</code> - Optional - Specifies the maximum number of history events returned in one page. The next page in the result is identified by the <code>NextPageToken</code> returned. By default 100 history events are returned in a page but the caller can override this value to a page size <em>smaller</em> than the default. You cannot specify a page size larger than 100.</li>
|
611 |
* <li><code>reverseOrder</code> - <code>boolean</code> - Optional - When set to <code>true</code>, returns the events in reverse order. By default the results are returned in ascending order of the <code>eventTimeStamp</code> of the events.</li>
|
612 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
613 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
@@ -617,7 +606,6 @@ class AmazonSWF extends CFRuntime
|
|
617 |
{
|
618 |
if (!$opt) $opt = array();
|
619 |
|
620 |
-
$opt = json_encode($opt);
|
621 |
return $this->authenticate('GetWorkflowExecutionHistory', $opt);
|
622 |
}
|
623 |
|
@@ -633,7 +621,7 @@ class AmazonSWF extends CFRuntime
|
|
633 |
* <li><code>name</code> - <code>string</code> - Optional - If specified, only lists the activity types that have this name.</li>
|
634 |
* <li><code>registrationStatus</code> - <code>string</code> - Required - Specifies the registration status of the activity types to list. [Allowed values: <code>REGISTERED</code>, <code>DEPRECATED</code>]</li>
|
635 |
* <li><code>nextPageToken</code> - <code>string</code> - Optional - If on a previous call to this method a <code>NextResultToken</code> was returned, the results have more than one page. To get the next page of results, repeat the call with the <code>nextPageToken</code> and keep all other arguments unchanged.</li>
|
636 |
-
* <li><code>maximumPageSize</code> - <code>integer</code> - Optional - The maximum number of results returned in each page. The default is 100, but the caller can override this value to a page size <em>smaller</em> than the default. You cannot specify a page size greater than 100.</li>
|
637 |
* <li><code>reverseOrder</code> - <code>boolean</code> - Optional - When set to <code>true</code>, returns the results in reverse order. By default the results are returned in ascending alphabetical order of the <code>name</code> of the activity types.</li>
|
638 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
639 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
@@ -643,7 +631,6 @@ class AmazonSWF extends CFRuntime
|
|
643 |
{
|
644 |
if (!$opt) $opt = array();
|
645 |
|
646 |
-
$opt = json_encode($opt);
|
647 |
return $this->authenticate('ListActivityTypes', $opt);
|
648 |
}
|
649 |
|
@@ -681,7 +668,7 @@ class AmazonSWF extends CFRuntime
|
|
681 |
* <li><code>tag</code> - <code>string</code> - Required - Specifies the tag that must be associated with the execution for it to meet the filter criteria. This field is required.</li>
|
682 |
* </ul></li>
|
683 |
* <li><code>nextPageToken</code> - <code>string</code> - Optional - If on a previous call to this method a <code>NextPageToken</code> was returned, the results are being paginated. To get the next page of results, repeat the call with the returned token and all other arguments unchanged.</li>
|
684 |
-
* <li><code>maximumPageSize</code> - <code>integer</code> - Optional - The maximum number of results returned in each page. The default is 100, but the caller can override this value to a page size <em>smaller</em> than the default. You cannot specify a page size greater than 100.</li>
|
685 |
* <li><code>reverseOrder</code> - <code>boolean</code> - Optional - When set to <code>true</code>, returns the results in reverse order. By default the results are returned in descending order of the start or the close time of the executions.</li>
|
686 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
687 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
@@ -691,7 +678,6 @@ class AmazonSWF extends CFRuntime
|
|
691 |
{
|
692 |
if (!$opt) $opt = array();
|
693 |
|
694 |
-
$opt = json_encode($opt);
|
695 |
return $this->authenticate('ListClosedWorkflowExecutions', $opt);
|
696 |
}
|
697 |
|
@@ -708,7 +694,7 @@ class AmazonSWF extends CFRuntime
|
|
708 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
709 |
* <li><code>nextPageToken</code> - <code>string</code> - Optional - If on a previous call to this method a <code>NextPageToken</code> was returned, the result has more than one page. To get the next page of results, repeat the call with the returned token and all other arguments unchanged.</li>
|
710 |
* <li><code>registrationStatus</code> - <code>string</code> - Required - Specifies the registration status of the domains to list. [Allowed values: <code>REGISTERED</code>, <code>DEPRECATED</code>]</li>
|
711 |
-
* <li><code>maximumPageSize</code> - <code>integer</code> - Optional - The maximum number of results returned in each page. The default is 100, but the caller can override this value to a page size <em>smaller</em> than the default. You cannot specify a page size greater than 100.</li>
|
712 |
* <li><code>reverseOrder</code> - <code>boolean</code> - Optional - When set to <code>true</code>, returns the results in reverse order. By default the results are returned in ascending alphabetical order of the <code>name</code> of the domains.</li>
|
713 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
714 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
@@ -718,7 +704,6 @@ class AmazonSWF extends CFRuntime
|
|
718 |
{
|
719 |
if (!$opt) $opt = array();
|
720 |
|
721 |
-
$opt = json_encode($opt);
|
722 |
return $this->authenticate('ListDomains', $opt);
|
723 |
}
|
724 |
|
@@ -746,7 +731,7 @@ class AmazonSWF extends CFRuntime
|
|
746 |
* <li><code>tag</code> - <code>string</code> - Required - Specifies the tag that must be associated with the execution for it to meet the filter criteria. This field is required.</li>
|
747 |
* </ul></li>
|
748 |
* <li><code>nextPageToken</code> - <code>string</code> - Optional - If on a previous call to this method a <code>NextPageToken</code> was returned, the results are being paginated. To get the next page of results, repeat the call with the returned token and all other arguments unchanged.</li>
|
749 |
-
* <li><code>maximumPageSize</code> - <code>integer</code> - Optional - The maximum number of results returned in each page. The default is 100, but the caller can override this value to a page size <em>smaller</em> than the default. You cannot specify a page size greater than 100.</li>
|
750 |
* <li><code>reverseOrder</code> - <code>boolean</code> - Optional - When set to <code>true</code>, returns the results in reverse order. By default the results are returned in descending order of the start time of the executions.</li>
|
751 |
* <li><code>executionFilter</code> - <code>array</code> - Optional - If specified, only workflow executions matching the workflow id specified in the filter are returned. <p class="note"> <code>executionFilter</code>, <code>typeFilter</code> and <code>tagFilter</code> are mutually exclusive. You can specify at most one of these in a request.</p> <ul>
|
752 |
* <li><code>workflowId</code> - <code>string</code> - Required - The workflowId to pass of match the criteria of this filter.</li>
|
@@ -759,7 +744,6 @@ class AmazonSWF extends CFRuntime
|
|
759 |
{
|
760 |
if (!$opt) $opt = array();
|
761 |
|
762 |
-
$opt = json_encode($opt);
|
763 |
return $this->authenticate('ListOpenWorkflowExecutions', $opt);
|
764 |
}
|
765 |
|
@@ -772,7 +756,7 @@ class AmazonSWF extends CFRuntime
|
|
772 |
* <li><code>name</code> - <code>string</code> - Optional - If specified, lists the workflow type with this name.</li>
|
773 |
* <li><code>registrationStatus</code> - <code>string</code> - Required - Specifies the registration status of the workflow types to list. [Allowed values: <code>REGISTERED</code>, <code>DEPRECATED</code>]</li>
|
774 |
* <li><code>nextPageToken</code> - <code>string</code> - Optional - If on a previous call to this method a <code>NextPageToken</code> was returned, the results are being paginated. To get the next page of results, repeat the call with the returned token and all other arguments unchanged.</li>
|
775 |
-
* <li><code>maximumPageSize</code> - <code>integer</code> - Optional - The maximum number of results returned in each page. The default is 100, but the caller can override this value to a page size <em>smaller</em> than the default. You cannot specify a page size greater than 100.</li>
|
776 |
* <li><code>reverseOrder</code> - <code>boolean</code> - Optional - When set to <code>true</code>, returns the results in reverse order. By default the results are returned in ascending alphabetical order of the <code>name</code> of the workflow types.</li>
|
777 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
778 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
@@ -782,7 +766,6 @@ class AmazonSWF extends CFRuntime
|
|
782 |
{
|
783 |
if (!$opt) $opt = array();
|
784 |
|
785 |
-
$opt = json_encode($opt);
|
786 |
return $this->authenticate('ListWorkflowTypes', $opt);
|
787 |
}
|
788 |
|
@@ -814,7 +797,6 @@ class AmazonSWF extends CFRuntime
|
|
814 |
{
|
815 |
if (!$opt) $opt = array();
|
816 |
|
817 |
-
$opt = json_encode($opt);
|
818 |
return $this->authenticate('PollForActivityTask', $opt);
|
819 |
}
|
820 |
|
@@ -851,7 +833,7 @@ class AmazonSWF extends CFRuntime
|
|
851 |
* </ul></li>
|
852 |
* <li><code>identity</code> - <code>string</code> - Optional - Identity of the decider making the request, which is recorded in the DecisionTaskStarted event in the workflow history. This enables diagnostic tracing when problems arise. The form of this identity is user defined.</li>
|
853 |
* <li><code>nextPageToken</code> - <code>string</code> - Optional - If on a previous call to this method a <code>NextPageToken</code> was returned, the results are being paginated. To get the next page of results, repeat the call with the returned token and all other arguments unchanged. <p class="note">The <code>nextPageToken</code> returned by this action cannot be used with <code>GetWorkflowExecutionHistory</code> to get the next page. You must call <code>PollForDecisionTask</code> again (with the <code>nextPageToken</code>) to retrieve the next page of history records. Calling <code>PollForDecisionTask</code> with a <code>nextPageToken</code> will not return a new decision task.</p> .</li>
|
854 |
-
* <li><code>maximumPageSize</code> - <code>integer</code> - Optional - The maximum number of history events returned in each page. The default is 100, but the caller can override this value to a page size <em>smaller</em> than the default. You cannot specify a page size greater than 100.</li>
|
855 |
* <li><code>reverseOrder</code> - <code>boolean</code> - Optional - When set to <code>true</code>, returns the events in reverse order. By default the results are returned in ascending order of the <code>eventTimestamp</code> of the events.</li>
|
856 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
857 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
@@ -861,7 +843,6 @@ class AmazonSWF extends CFRuntime
|
|
861 |
{
|
862 |
if (!$opt) $opt = array();
|
863 |
|
864 |
-
$opt = json_encode($opt);
|
865 |
return $this->authenticate('PollForDecisionTask', $opt);
|
866 |
}
|
867 |
|
@@ -909,7 +890,6 @@ class AmazonSWF extends CFRuntime
|
|
909 |
{
|
910 |
if (!$opt) $opt = array();
|
911 |
|
912 |
-
$opt = json_encode($opt);
|
913 |
return $this->authenticate('RecordActivityTaskHeartbeat', $opt);
|
914 |
}
|
915 |
|
@@ -943,7 +923,6 @@ class AmazonSWF extends CFRuntime
|
|
943 |
{
|
944 |
if (!$opt) $opt = array();
|
945 |
|
946 |
-
$opt = json_encode($opt);
|
947 |
return $this->authenticate('RegisterActivityType', $opt);
|
948 |
}
|
949 |
|
@@ -962,7 +941,6 @@ class AmazonSWF extends CFRuntime
|
|
962 |
{
|
963 |
if (!$opt) $opt = array();
|
964 |
|
965 |
-
$opt = json_encode($opt);
|
966 |
return $this->authenticate('RegisterDomain', $opt);
|
967 |
}
|
968 |
|
@@ -994,7 +972,6 @@ class AmazonSWF extends CFRuntime
|
|
994 |
{
|
995 |
if (!$opt) $opt = array();
|
996 |
|
997 |
-
$opt = json_encode($opt);
|
998 |
return $this->authenticate('RegisterWorkflowType', $opt);
|
999 |
}
|
1000 |
|
@@ -1026,7 +1003,6 @@ class AmazonSWF extends CFRuntime
|
|
1026 |
{
|
1027 |
if (!$opt) $opt = array();
|
1028 |
|
1029 |
-
$opt = json_encode($opt);
|
1030 |
return $this->authenticate('RequestCancelWorkflowExecution', $opt);
|
1031 |
}
|
1032 |
|
@@ -1055,7 +1031,6 @@ class AmazonSWF extends CFRuntime
|
|
1055 |
{
|
1056 |
if (!$opt) $opt = array();
|
1057 |
|
1058 |
-
$opt = json_encode($opt);
|
1059 |
return $this->authenticate('RespondActivityTaskCanceled', $opt);
|
1060 |
}
|
1061 |
|
@@ -1084,7 +1059,6 @@ class AmazonSWF extends CFRuntime
|
|
1084 |
{
|
1085 |
if (!$opt) $opt = array();
|
1086 |
|
1087 |
-
$opt = json_encode($opt);
|
1088 |
return $this->authenticate('RespondActivityTaskCompleted', $opt);
|
1089 |
}
|
1090 |
|
@@ -1107,7 +1081,6 @@ class AmazonSWF extends CFRuntime
|
|
1107 |
{
|
1108 |
if (!$opt) $opt = array();
|
1109 |
|
1110 |
-
$opt = json_encode($opt);
|
1111 |
return $this->authenticate('RespondActivityTaskFailed', $opt);
|
1112 |
}
|
1113 |
|
@@ -1222,7 +1195,6 @@ class AmazonSWF extends CFRuntime
|
|
1222 |
$opt['decisions'] = (is_array($opt['decisions']) ? $opt['decisions'] : array($opt['decisions']));
|
1223 |
}
|
1224 |
|
1225 |
-
$opt = json_encode($opt);
|
1226 |
return $this->authenticate('RespondDecisionTaskCompleted', $opt);
|
1227 |
}
|
1228 |
|
@@ -1255,7 +1227,6 @@ class AmazonSWF extends CFRuntime
|
|
1255 |
{
|
1256 |
if (!$opt) $opt = array();
|
1257 |
|
1258 |
-
$opt = json_encode($opt);
|
1259 |
return $this->authenticate('SignalWorkflowExecution', $opt);
|
1260 |
}
|
1261 |
|
@@ -1294,7 +1265,6 @@ class AmazonSWF extends CFRuntime
|
|
1294 |
$opt['tagList'] = (is_array($opt['tagList']) ? $opt['tagList'] : array($opt['tagList']));
|
1295 |
}
|
1296 |
|
1297 |
-
$opt = json_encode($opt);
|
1298 |
return $this->authenticate('StartWorkflowExecution', $opt);
|
1299 |
}
|
1300 |
|
@@ -1332,7 +1302,6 @@ class AmazonSWF extends CFRuntime
|
|
1332 |
{
|
1333 |
if (!$opt) $opt = array();
|
1334 |
|
1335 |
-
$opt = json_encode($opt);
|
1336 |
return $this->authenticate('TerminateWorkflowExecution', $opt);
|
1337 |
}
|
1338 |
}
|
187 |
* "CountPendingDecisionTasks">CountPendingDecisionTasks</a></li>
|
188 |
* </ul>
|
189 |
*
|
190 |
+
* @version 2012.05.31
|
191 |
* @license See the included NOTICE.md file for complete information.
|
192 |
* @copyright See the included NOTICE.md file for complete information.
|
193 |
* @link http://aws.amazon.com/simpleworkflow/ Amazon Simple Workflow
|
334 |
{
|
335 |
if (!$opt) $opt = array();
|
336 |
|
|
|
337 |
return $this->authenticate('CountClosedWorkflowExecutions', $opt);
|
338 |
}
|
339 |
|
370 |
{
|
371 |
if (!$opt) $opt = array();
|
372 |
|
|
|
373 |
return $this->authenticate('CountOpenWorkflowExecutions', $opt);
|
374 |
}
|
375 |
|
391 |
{
|
392 |
if (!$opt) $opt = array();
|
393 |
|
|
|
394 |
return $this->authenticate('CountPendingActivityTasks', $opt);
|
395 |
}
|
396 |
|
412 |
{
|
413 |
if (!$opt) $opt = array();
|
414 |
|
|
|
415 |
return $this->authenticate('CountPendingDecisionTasks', $opt);
|
416 |
}
|
417 |
|
439 |
{
|
440 |
if (!$opt) $opt = array();
|
441 |
|
|
|
442 |
return $this->authenticate('DeprecateActivityType', $opt);
|
443 |
}
|
444 |
|
463 |
{
|
464 |
if (!$opt) $opt = array();
|
465 |
|
|
|
466 |
return $this->authenticate('DeprecateDomain', $opt);
|
467 |
}
|
468 |
|
491 |
{
|
492 |
if (!$opt) $opt = array();
|
493 |
|
|
|
494 |
return $this->authenticate('DeprecateWorkflowType', $opt);
|
495 |
}
|
496 |
|
512 |
{
|
513 |
if (!$opt) $opt = array();
|
514 |
|
|
|
515 |
return $this->authenticate('DescribeActivityType', $opt);
|
516 |
}
|
517 |
|
528 |
{
|
529 |
if (!$opt) $opt = array();
|
530 |
|
|
|
531 |
return $this->authenticate('DescribeDomain', $opt);
|
532 |
}
|
533 |
|
554 |
{
|
555 |
if (!$opt) $opt = array();
|
556 |
|
|
|
557 |
return $this->authenticate('DescribeWorkflowExecution', $opt);
|
558 |
}
|
559 |
|
576 |
{
|
577 |
if (!$opt) $opt = array();
|
578 |
|
|
|
579 |
return $this->authenticate('DescribeWorkflowType', $opt);
|
580 |
}
|
581 |
|
596 |
* <li><code>runId</code> - <code>string</code> - Required - A system generated unique identifier for the workflow execution.</li>
|
597 |
* </ul></li>
|
598 |
* <li><code>nextPageToken</code> - <code>string</code> - Optional - If a <code>NextPageToken</code> is returned, the result has more than one pages. To get the next page, repeat the call and specify the nextPageToken with all other arguments unchanged.</li>
|
599 |
+
* <li><code>maximumPageSize</code> - <code>integer</code> - Optional - Specifies the maximum number of history events returned in one page. The next page in the result is identified by the <code>NextPageToken</code> returned. By default 100 history events are returned in a page but the caller can override this value to a page size <em>smaller</em> than the default. You cannot specify a page size larger than 100. Note that the number of events may be less than the maxiumum page size, in which case, a smaller page size is returned.</li>
|
600 |
* <li><code>reverseOrder</code> - <code>boolean</code> - Optional - When set to <code>true</code>, returns the events in reverse order. By default the results are returned in ascending order of the <code>eventTimeStamp</code> of the events.</li>
|
601 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
602 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
606 |
{
|
607 |
if (!$opt) $opt = array();
|
608 |
|
|
|
609 |
return $this->authenticate('GetWorkflowExecutionHistory', $opt);
|
610 |
}
|
611 |
|
621 |
* <li><code>name</code> - <code>string</code> - Optional - If specified, only lists the activity types that have this name.</li>
|
622 |
* <li><code>registrationStatus</code> - <code>string</code> - Required - Specifies the registration status of the activity types to list. [Allowed values: <code>REGISTERED</code>, <code>DEPRECATED</code>]</li>
|
623 |
* <li><code>nextPageToken</code> - <code>string</code> - Optional - If on a previous call to this method a <code>NextResultToken</code> was returned, the results have more than one page. To get the next page of results, repeat the call with the <code>nextPageToken</code> and keep all other arguments unchanged.</li>
|
624 |
+
* <li><code>maximumPageSize</code> - <code>integer</code> - Optional - The maximum number of results returned in each page. The default is 100, but the caller can override this value to a page size <em>smaller</em> than the default. You cannot specify a page size greater than 100. Note that the number of types may be less than the maxiumum page size, in which case, a smaller page size is returned.</li>
|
625 |
* <li><code>reverseOrder</code> - <code>boolean</code> - Optional - When set to <code>true</code>, returns the results in reverse order. By default the results are returned in ascending alphabetical order of the <code>name</code> of the activity types.</li>
|
626 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
627 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
631 |
{
|
632 |
if (!$opt) $opt = array();
|
633 |
|
|
|
634 |
return $this->authenticate('ListActivityTypes', $opt);
|
635 |
}
|
636 |
|
668 |
* <li><code>tag</code> - <code>string</code> - Required - Specifies the tag that must be associated with the execution for it to meet the filter criteria. This field is required.</li>
|
669 |
* </ul></li>
|
670 |
* <li><code>nextPageToken</code> - <code>string</code> - Optional - If on a previous call to this method a <code>NextPageToken</code> was returned, the results are being paginated. To get the next page of results, repeat the call with the returned token and all other arguments unchanged.</li>
|
671 |
+
* <li><code>maximumPageSize</code> - <code>integer</code> - Optional - The maximum number of results returned in each page. The default is 100, but the caller can override this value to a page size <em>smaller</em> than the default. You cannot specify a page size greater than 100. Note that the number of executions may be less than the maxiumum page size, in which case, a smaller page size is returned.</li>
|
672 |
* <li><code>reverseOrder</code> - <code>boolean</code> - Optional - When set to <code>true</code>, returns the results in reverse order. By default the results are returned in descending order of the start or the close time of the executions.</li>
|
673 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
674 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
678 |
{
|
679 |
if (!$opt) $opt = array();
|
680 |
|
|
|
681 |
return $this->authenticate('ListClosedWorkflowExecutions', $opt);
|
682 |
}
|
683 |
|
694 |
* @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
|
695 |
* <li><code>nextPageToken</code> - <code>string</code> - Optional - If on a previous call to this method a <code>NextPageToken</code> was returned, the result has more than one page. To get the next page of results, repeat the call with the returned token and all other arguments unchanged.</li>
|
696 |
* <li><code>registrationStatus</code> - <code>string</code> - Required - Specifies the registration status of the domains to list. [Allowed values: <code>REGISTERED</code>, <code>DEPRECATED</code>]</li>
|
697 |
+
* <li><code>maximumPageSize</code> - <code>integer</code> - Optional - The maximum number of results returned in each page. The default is 100, but the caller can override this value to a page size <em>smaller</em> than the default. You cannot specify a page size greater than 100. Note that the number of domains may be less than the maxiumum page size, in which case, a smaller page size is returned.</li>
|
698 |
* <li><code>reverseOrder</code> - <code>boolean</code> - Optional - When set to <code>true</code>, returns the results in reverse order. By default the results are returned in ascending alphabetical order of the <code>name</code> of the domains.</li>
|
699 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
700 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
704 |
{
|
705 |
if (!$opt) $opt = array();
|
706 |
|
|
|
707 |
return $this->authenticate('ListDomains', $opt);
|
708 |
}
|
709 |
|
731 |
* <li><code>tag</code> - <code>string</code> - Required - Specifies the tag that must be associated with the execution for it to meet the filter criteria. This field is required.</li>
|
732 |
* </ul></li>
|
733 |
* <li><code>nextPageToken</code> - <code>string</code> - Optional - If on a previous call to this method a <code>NextPageToken</code> was returned, the results are being paginated. To get the next page of results, repeat the call with the returned token and all other arguments unchanged.</li>
|
734 |
+
* <li><code>maximumPageSize</code> - <code>integer</code> - Optional - The maximum number of results returned in each page. The default is 100, but the caller can override this value to a page size <em>smaller</em> than the default. You cannot specify a page size greater than 100. Note that the number of executions may be less than the maxiumum page size, in which case, a smaller page size is returned.</li>
|
735 |
* <li><code>reverseOrder</code> - <code>boolean</code> - Optional - When set to <code>true</code>, returns the results in reverse order. By default the results are returned in descending order of the start time of the executions.</li>
|
736 |
* <li><code>executionFilter</code> - <code>array</code> - Optional - If specified, only workflow executions matching the workflow id specified in the filter are returned. <p class="note"> <code>executionFilter</code>, <code>typeFilter</code> and <code>tagFilter</code> are mutually exclusive. You can specify at most one of these in a request.</p> <ul>
|
737 |
* <li><code>workflowId</code> - <code>string</code> - Required - The workflowId to pass of match the criteria of this filter.</li>
|
744 |
{
|
745 |
if (!$opt) $opt = array();
|
746 |
|
|
|
747 |
return $this->authenticate('ListOpenWorkflowExecutions', $opt);
|
748 |
}
|
749 |
|
756 |
* <li><code>name</code> - <code>string</code> - Optional - If specified, lists the workflow type with this name.</li>
|
757 |
* <li><code>registrationStatus</code> - <code>string</code> - Required - Specifies the registration status of the workflow types to list. [Allowed values: <code>REGISTERED</code>, <code>DEPRECATED</code>]</li>
|
758 |
* <li><code>nextPageToken</code> - <code>string</code> - Optional - If on a previous call to this method a <code>NextPageToken</code> was returned, the results are being paginated. To get the next page of results, repeat the call with the returned token and all other arguments unchanged.</li>
|
759 |
+
* <li><code>maximumPageSize</code> - <code>integer</code> - Optional - The maximum number of results returned in each page. The default is 100, but the caller can override this value to a page size <em>smaller</em> than the default. You cannot specify a page size greater than 100. Note that the number of types may be less than the maxiumum page size, in which case, a smaller page size is returned.</li>
|
760 |
* <li><code>reverseOrder</code> - <code>boolean</code> - Optional - When set to <code>true</code>, returns the results in reverse order. By default the results are returned in ascending alphabetical order of the <code>name</code> of the workflow types.</li>
|
761 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
762 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
766 |
{
|
767 |
if (!$opt) $opt = array();
|
768 |
|
|
|
769 |
return $this->authenticate('ListWorkflowTypes', $opt);
|
770 |
}
|
771 |
|
797 |
{
|
798 |
if (!$opt) $opt = array();
|
799 |
|
|
|
800 |
return $this->authenticate('PollForActivityTask', $opt);
|
801 |
}
|
802 |
|
833 |
* </ul></li>
|
834 |
* <li><code>identity</code> - <code>string</code> - Optional - Identity of the decider making the request, which is recorded in the DecisionTaskStarted event in the workflow history. This enables diagnostic tracing when problems arise. The form of this identity is user defined.</li>
|
835 |
* <li><code>nextPageToken</code> - <code>string</code> - Optional - If on a previous call to this method a <code>NextPageToken</code> was returned, the results are being paginated. To get the next page of results, repeat the call with the returned token and all other arguments unchanged. <p class="note">The <code>nextPageToken</code> returned by this action cannot be used with <code>GetWorkflowExecutionHistory</code> to get the next page. You must call <code>PollForDecisionTask</code> again (with the <code>nextPageToken</code>) to retrieve the next page of history records. Calling <code>PollForDecisionTask</code> with a <code>nextPageToken</code> will not return a new decision task.</p> .</li>
|
836 |
+
* <li><code>maximumPageSize</code> - <code>integer</code> - Optional - The maximum number of history events returned in each page. The default is 100, but the caller can override this value to a page size <em>smaller</em> than the default. You cannot specify a page size greater than 100. Note that the number of events may be less than the maxiumum page size, in which case, a smaller page size is returned.</li>
|
837 |
* <li><code>reverseOrder</code> - <code>boolean</code> - Optional - When set to <code>true</code>, returns the events in reverse order. By default the results are returned in ascending order of the <code>eventTimestamp</code> of the events.</li>
|
838 |
* <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
|
839 |
* <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
|
843 |
{
|
844 |
if (!$opt) $opt = array();
|
845 |
|
|
|
846 |
return $this->authenticate('PollForDecisionTask', $opt);
|
847 |
}
|
848 |
|
890 |
{
|
891 |
if (!$opt) $opt = array();
|
892 |
|
|
|
893 |
return $this->authenticate('RecordActivityTaskHeartbeat', $opt);
|
894 |
}
|
895 |
|
923 |
{
|
924 |
if (!$opt) $opt = array();
|
925 |
|
|
|
926 |
return $this->authenticate('RegisterActivityType', $opt);
|
927 |
}
|
928 |
|
941 |
{
|
942 |
if (!$opt) $opt = array();
|
943 |
|
|
|
944 |
return $this->authenticate('RegisterDomain', $opt);
|
945 |
}
|
946 |
|
972 |
{
|
973 |
if (!$opt) $opt = array();
|
974 |
|
|
|
975 |
return $this->authenticate('RegisterWorkflowType', $opt);
|
976 |
}
|
977 |
|
1003 |
{
|
1004 |
if (!$opt) $opt = array();
|
1005 |
|
|
|
1006 |
return $this->authenticate('RequestCancelWorkflowExecution', $opt);
|
1007 |
}
|
1008 |
|
1031 |
{
|
1032 |
if (!$opt) $opt = array();
|
1033 |
|
|
|
1034 |
return $this->authenticate('RespondActivityTaskCanceled', $opt);
|
1035 |
}
|
1036 |
|
1059 |
{
|
1060 |
if (!$opt) $opt = array();
|
1061 |
|
|
|
1062 |
return $this->authenticate('RespondActivityTaskCompleted', $opt);
|
1063 |
}
|
1064 |
|
1081 |
{
|
1082 |
if (!$opt) $opt = array();
|
1083 |
|
|
|
1084 |
return $this->authenticate('RespondActivityTaskFailed', $opt);
|
1085 |
}
|
1086 |
|
1195 |
$opt['decisions'] = (is_array($opt['decisions']) ? $opt['decisions'] : array($opt['decisions']));
|
1196 |
}
|
1197 |
|
|
|
1198 |
return $this->authenticate('RespondDecisionTaskCompleted', $opt);
|
1199 |
}
|
1200 |
|
1227 |
{
|
1228 |
if (!$opt) $opt = array();
|
1229 |
|
|
|
1230 |
return $this->authenticate('SignalWorkflowExecution', $opt);
|
1231 |
}
|
1232 |
|
1265 |
$opt['tagList'] = (is_array($opt['tagList']) ? $opt['tagList'] : array($opt['tagList']));
|
1266 |
}
|
1267 |
|
|
|
1268 |
return $this->authenticate('StartWorkflowExecution', $opt);
|
1269 |
}
|
1270 |
|
1302 |
{
|
1303 |
if (!$opt) $opt = array();
|
1304 |
|
|
|
1305 |
return $this->authenticate('TerminateWorkflowExecution', $opt);
|
1306 |
}
|
1307 |
}
|
libs/aws/utilities/credentials.class.php
CHANGED
@@ -61,10 +61,6 @@ class CFCredentials
|
|
61 |
{
|
62 |
$credential_sets[self::DEFAULT_KEY] = reset($credential_sets);
|
63 |
}
|
64 |
-
elseif (!isset($credential_sets[self::DEFAULT_KEY]))
|
65 |
-
{
|
66 |
-
throw new CFCredentials_Exception('If more than one credential set is provided, a default credential set (identified by the key "' . self::DEFAULT_KEY . '") must be specified.');
|
67 |
-
}
|
68 |
|
69 |
// Resolve any @inherit tags
|
70 |
foreach ($credential_sets as $credential_name => &$credential_set)
|
@@ -88,15 +84,18 @@ class CFCredentials
|
|
88 |
}
|
89 |
|
90 |
// Normalize the value of the @default credential set
|
91 |
-
|
92 |
-
if (is_string($default))
|
93 |
{
|
94 |
-
|
|
|
95 |
{
|
96 |
-
|
97 |
-
|
|
|
|
|
98 |
|
99 |
-
|
|
|
100 |
}
|
101 |
|
102 |
// Store the credentials
|
61 |
{
|
62 |
$credential_sets[self::DEFAULT_KEY] = reset($credential_sets);
|
63 |
}
|
|
|
|
|
|
|
|
|
64 |
|
65 |
// Resolve any @inherit tags
|
66 |
foreach ($credential_sets as $credential_name => &$credential_set)
|
84 |
}
|
85 |
|
86 |
// Normalize the value of the @default credential set
|
87 |
+
if (isset($credential_sets[self::DEFAULT_KEY]))
|
|
|
88 |
{
|
89 |
+
$default = $credential_sets[self::DEFAULT_KEY];
|
90 |
+
if (is_string($default))
|
91 |
{
|
92 |
+
if (!isset($credential_sets[$default]))
|
93 |
+
{
|
94 |
+
throw new CFCredentials_Exception('The credential set, "' . $default . '", does not exist and cannot be used as the default credential set.');
|
95 |
+
}
|
96 |
|
97 |
+
$credential_sets[self::DEFAULT_KEY] = $credential_sets[$default];
|
98 |
+
}
|
99 |
}
|
100 |
|
101 |
// Store the credentials
|
libs/aws/utilities/simplexml.class.php
CHANGED
@@ -22,7 +22,7 @@
|
|
22 |
* Wraps the underlying `SimpleXMLIterator` class with enhancements for rapidly traversing the DOM tree,
|
23 |
* converting types, and comparisons.
|
24 |
*
|
25 |
-
* @version 2012.
|
26 |
* @license See the included NOTICE.md file for more information.
|
27 |
* @copyright See the included NOTICE.md file for more information.
|
28 |
* @link http://aws.amazon.com/php/ PHP Developer Center
|
@@ -40,6 +40,11 @@ class CFSimpleXML extends SimpleXMLIterator
|
|
40 |
*/
|
41 |
public $xml_ns_url;
|
42 |
|
|
|
|
|
|
|
|
|
|
|
43 |
/**
|
44 |
* Catches requests made to methods that don't exist. Specifically, looks for child nodes via XPath.
|
45 |
*
|
@@ -77,6 +82,16 @@ class CFSimpleXML extends SimpleXMLIterator
|
|
77 |
return $results;
|
78 |
}
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
/**
|
81 |
* Alternate approach to constructing a new instance. Supports chaining.
|
82 |
*
|
@@ -144,7 +159,14 @@ class CFSimpleXML extends SimpleXMLIterator
|
|
144 |
*/
|
145 |
public function to_string()
|
146 |
{
|
147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
}
|
149 |
|
150 |
/**
|
22 |
* Wraps the underlying `SimpleXMLIterator` class with enhancements for rapidly traversing the DOM tree,
|
23 |
* converting types, and comparisons.
|
24 |
*
|
25 |
+
* @version 2012.05.31
|
26 |
* @license See the included NOTICE.md file for more information.
|
27 |
* @copyright See the included NOTICE.md file for more information.
|
28 |
* @link http://aws.amazon.com/php/ PHP Developer Center
|
40 |
*/
|
41 |
public $xml_ns_url;
|
42 |
|
43 |
+
/**
|
44 |
+
* Stores whether or not the value is encoded.
|
45 |
+
*/
|
46 |
+
public $encoded = false;
|
47 |
+
|
48 |
/**
|
49 |
* Catches requests made to methods that don't exist. Specifically, looks for child nodes via XPath.
|
50 |
*
|
82 |
return $results;
|
83 |
}
|
84 |
|
85 |
+
/**
|
86 |
+
* Gets the current XML node as a true string.
|
87 |
+
*
|
88 |
+
* @return string The current XML node as a true string.
|
89 |
+
*/
|
90 |
+
public function __toString()
|
91 |
+
{
|
92 |
+
return $this->to_string();
|
93 |
+
}
|
94 |
+
|
95 |
/**
|
96 |
* Alternate approach to constructing a new instance. Supports chaining.
|
97 |
*
|
159 |
*/
|
160 |
public function to_string()
|
161 |
{
|
162 |
+
$s = (string) $this;
|
163 |
+
|
164 |
+
if ($this->attributes())
|
165 |
+
{
|
166 |
+
return json_decode(substr($s, 14));
|
167 |
+
}
|
168 |
+
|
169 |
+
return $s;
|
170 |
}
|
171 |
|
172 |
/**
|
libs/dropbox.php
CHANGED
@@ -1,763 +1,761 @@
|
|
1 |
-
<?PHP
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Dropbox class
|
5 |
-
*
|
6 |
-
* This source file can be used to communicate with DropBox (http://dropbox.com)
|
7 |
-
*
|
8 |
-
* The class is documented in the file itself. If you find any bugs help me out and report them.
|
9 |
-
* If you report a bug, make sure you give me enough information (include your code).
|
10 |
-
*
|
11 |
-
*
|
12 |
-
*
|
13 |
-
* License
|
14 |
-
* Copyright (c), Daniel Huesken. All rights reserved.
|
15 |
-
*
|
16 |
-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
17 |
-
*
|
18 |
-
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
19 |
-
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
20 |
-
* 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
|
21 |
-
*
|
22 |
-
* This software is provided by the author "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the author be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
|
23 |
-
*
|
24 |
-
* @author Daniel Huesken <daniel@huesken-net.de>
|
25 |
-
* @version 2.0.0
|
26 |
-
*
|
27 |
-
* @copyright Copyright (c), Daniel Huesken. All rights reserved.
|
28 |
-
* @license BSD License
|
29 |
-
*/
|
30 |
-
|
31 |
-
class backwpup_Dropbox {
|
32 |
-
const API_URL = 'https://api.dropbox.com/';
|
33 |
-
const API_CONTENT_URL = 'https://api-content.dropbox.com/';
|
34 |
-
const API_WWW_URL = 'https://www.dropbox.com/';
|
35 |
-
const API_VERSION_URL = '1/';
|
36 |
-
|
37 |
-
private $root = 'sandbox';
|
38 |
-
private $OAuthObject;
|
39 |
-
private $OAuthToken;
|
40 |
-
private $ProgressFunction = false;
|
41 |
-
|
42 |
-
public function __construct($applicationKey, $applicationSecret,$dropbox=false) {
|
43 |
-
$this->OAuthObject = new BackWPup_OAuthSimple($applicationKey, $applicationSecret);
|
44 |
-
if ($dropbox)
|
45 |
-
$this->root = 'dropbox';
|
46 |
-
else
|
47 |
-
$this->root = 'sandbox';
|
48 |
-
}
|
49 |
-
|
50 |
-
public function setOAuthTokens($token,$secret) {
|
51 |
-
$this->OAuthToken = array('oauth_token'=>$token,'oauth_secret'=> $secret);
|
52 |
-
}
|
53 |
-
|
54 |
-
public function setProgressFunction($function) {
|
55 |
-
if (function_exists($function))
|
56 |
-
$this->ProgressFunction = $function;
|
57 |
-
else
|
58 |
-
$this->ProgressFunction = false;
|
59 |
-
}
|
60 |
-
|
61 |
-
public function accountInfo(){
|
62 |
-
$url = self::API_URL.self::API_VERSION_URL.'account/info';
|
63 |
-
return $this->request($url);
|
64 |
-
}
|
65 |
-
|
66 |
-
public function upload($file, $path = '',$overwrite=true){
|
67 |
-
$file = str_replace("\\", "/",$file);
|
68 |
-
if (!is_readable($file) or !is_file($file))
|
69 |
-
throw new DropboxException("Error: File \"$file\" is not readable or doesn't exist.");
|
70 |
-
if (filesize($file)>157286400)
|
71 |
-
throw new DropboxException("Error: File \"$file\" is too big max. 150 MB.");
|
72 |
-
$url = self::API_CONTENT_URL.self::API_VERSION_URL.'files_put/'.$this->root.'/'.trim($path, '/');
|
73 |
-
return $this->request($url, array('overwrite' => ($overwrite)? 'true' : 'false'), 'PUT', $file);
|
74 |
-
}
|
75 |
-
|
76 |
-
public function download($path,$echo=false){
|
77 |
-
$url = self::API_CONTENT_URL.self::API_VERSION_URL.'files/'.$this->root.'/'.trim($path,'/');
|
78 |
-
if (!$echo)
|
79 |
-
return $this->request($url);
|
80 |
-
else
|
81 |
-
$this->request($url,'','GET','',true);
|
82 |
-
}
|
83 |
-
|
84 |
-
public function metadata($path = '', $listContents = true, $fileLimit = 10000){
|
85 |
-
$url = self::API_URL.self::API_VERSION_URL.'metadata/'.$this->root.'/'.trim($path,'/');
|
86 |
-
return $this->request($url, array('list' => ($listContents)? 'true' : 'false', 'file_limit' => $fileLimit));
|
87 |
-
}
|
88 |
-
|
89 |
-
public function search($path = '', $query , $fileLimit = 1000){
|
90 |
-
if (strlen($query)>=3)
|
91 |
-
throw new DropboxException("Error: Query \"$query\" must three characters long.");
|
92 |
-
$url = self::API_URL.self::API_VERSION_URL.'search/'.$this->root.'/'.trim($path,'/');
|
93 |
-
return $this->request($url, array('query' => $query, 'file_limit' => $fileLimit));
|
94 |
-
}
|
95 |
-
|
96 |
-
public function shares($path = ''){
|
97 |
-
$url = self::API_URL.self::API_VERSION_URL.'shares/'.$this->root.'/'.trim($path,'/');
|
98 |
-
return $this->request($url);
|
99 |
-
}
|
100 |
-
|
101 |
-
public function media($path = ''){
|
102 |
-
$url = self::API_URL.self::API_VERSION_URL.'media/'.$this->root.'/'.trim($path,'/');
|
103 |
-
return $this->request($url);
|
104 |
-
}
|
105 |
-
|
106 |
-
public function fileopsDelete($path){
|
107 |
-
$url = self::API_URL.self::API_VERSION_URL.'fileops/delete';
|
108 |
-
return $this->request($url, array('path' => '/'.trim($path,'/'), 'root' => $this->root));
|
109 |
-
}
|
110 |
-
|
111 |
-
public function fileopsCreate_folder($path){
|
112 |
-
$url = self::API_URL.self::API_VERSION_URL.'fileops/create_folder';
|
113 |
-
return $this->request($url, array('path' => '/'.trim($path,'/'), 'root' => $this->root));
|
114 |
-
}
|
115 |
-
|
116 |
-
public function oAuthAuthorize($callback_url) {
|
117 |
-
//request tokens
|
118 |
-
$OAuthSign = $this->OAuthObject->sign(array(
|
119 |
-
'path' =>self::API_URL.self::API_VERSION_URL.'oauth/request_token',
|
120 |
-
'method' =>'HMAC-SHA1',
|
121 |
-
'action' =>'GET',
|
122 |
-
'parameters'=>array('oauth_callback'=>$callback_url)));
|
123 |
-
$ch = curl_init();
|
124 |
-
curl_setopt($ch, CURLOPT_URL, $OAuthSign['signed_url']);
|
125 |
-
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
|
126 |
-
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
127 |
-
curl_setopt($ch, CURLOPT_SSLVERSION,3);
|
128 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
129 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
130 |
-
if (is_file(dirname(__FILE__).'/aws/lib/requestcore/cacert.pem'))
|
131 |
-
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__).'/aws/lib/requestcore/cacert.pem');
|
132 |
-
curl_setopt($ch, CURLOPT_AUTOREFERER , true);
|
133 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
134 |
-
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
|
135 |
-
$content = curl_exec($ch);
|
136 |
-
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
137 |
-
if ($status>=200 and $status<300 and 0==curl_errno($ch) ) {
|
138 |
-
parse_str($content, $oauth_token);
|
139 |
-
} else {
|
140 |
-
$output = json_decode($content, true);
|
141 |
-
if(isset($output['error']) && is_string($output['error'])) $message = $output['error'];
|
142 |
-
elseif(isset($output['error']['hash']) && $output['error']['hash'] != '') $message = (string) $output['error']['hash'];
|
143 |
-
elseif (0!=curl_errno($ch)) $message = '('.curl_errno($ch).') '.curl_error($ch);
|
144 |
-
else $message = '('.$status.') Invalid response.';
|
145 |
-
throw new DropboxException($message);
|
146 |
-
}
|
147 |
-
curl_close($ch);
|
148 |
-
$OAuthSign = $this->OAuthObject->sign(array(
|
149 |
-
'path' =>self::API_WWW_URL.self::API_VERSION_URL.'oauth/authorize',
|
150 |
-
'action' =>'GET',
|
151 |
-
'parameters'=>array(
|
152 |
-
'oauth_token' => $oauth_token['oauth_token'])));
|
153 |
-
return array('authurl'=>$OAuthSign['signed_url'],'oauth_token'=>$oauth_token['oauth_token'],'oauth_token_secret'=>$oauth_token['oauth_token_secret']);
|
154 |
-
}
|
155 |
-
|
156 |
-
public function oAuthAccessToken($oauth_token, $oauth_token_secret) {
|
157 |
-
$OAuthSign = $this->OAuthObject->sign(array(
|
158 |
-
'path' => self::API_URL.self::API_VERSION_URL.'oauth/access_token',
|
159 |
-
'action' =>'GET',
|
160 |
-
'method' =>'HMAC-SHA1',
|
161 |
-
'parameters'=>array('oauth_token' => $oauth_token),
|
162 |
-
'signatures'=>array('oauth_token'=>$oauth_token,'oauth_secret'=>$oauth_token_secret)));
|
163 |
-
$ch = curl_init();
|
164 |
-
curl_setopt($ch, CURLOPT_URL, $OAuthSign['signed_url']);
|
165 |
-
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
166 |
-
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
|
167 |
-
curl_setopt($ch, CURLOPT_SSLVERSION,3);
|
168 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
169 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
170 |
-
if (is_file(dirname(__FILE__).'/aws/lib/requestcore/cacert.pem'))
|
171 |
-
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__).'/aws/lib/requestcore/cacert.pem');
|
172 |
-
curl_setopt($ch, CURLOPT_AUTOREFERER , true);
|
173 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
174 |
-
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
|
175 |
-
$content = curl_exec($ch);
|
176 |
-
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
177 |
-
if ($status>=200 and $status<300 and 0==curl_errno($ch)) {
|
178 |
-
parse_str($content, $oauth_token);
|
179 |
-
$this->setOAuthTokens($oauth_token['oauth_token'],$oauth_token['oauth_token_secret']);
|
180 |
-
return $oauth_token;
|
181 |
-
} else {
|
182 |
-
$output = json_decode($content, true);
|
183 |
-
if(isset($output['error']) && is_string($output['error'])) $message = $output['error'];
|
184 |
-
elseif(isset($output['error']['hash']) && $output['error']['hash'] != '') $message = (string) $output['error']['hash'];
|
185 |
-
elseif (0!=curl_errno($ch)) $message = '('.curl_errno($ch).') '.curl_error($ch);
|
186 |
-
else $message = '('.$status.') Invalid response.';
|
187 |
-
throw new DropboxException($message);
|
188 |
-
}
|
189 |
-
}
|
190 |
-
|
191 |
-
private function request($url, $args = null, $method = 'GET', $file = null, $echo=false){
|
192 |
-
$args = (is_array($args)) ? $args : array();
|
193 |
-
$url = $this->url_encode($url);
|
194 |
-
/* Sign Request*/
|
195 |
-
$this->OAuthObject->reset();
|
196 |
-
$OAuthSign=$this->OAuthObject->sign(array(
|
197 |
-
'path' => $url,
|
198 |
-
'parameters'=> $args,
|
199 |
-
'action'=> $method,
|
200 |
-
'method' => 'HMAC-SHA1',
|
201 |
-
'signatures'=> $this->OAuthToken));
|
202 |
-
|
203 |
-
/* Header*/
|
204 |
-
$headers[]='Expect:';
|
205 |
-
|
206 |
-
/* Build cURL Request */
|
207 |
-
$ch = curl_init();
|
208 |
-
if ($method == 'POST') {
|
209 |
-
curl_setopt($ch, CURLOPT_POST, true);
|
210 |
-
$args = (is_array($args)) ? http_build_query($args) : $args;
|
211 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
|
212 |
-
$headers[]='Content-Length: '.strlen($args);
|
213 |
-
$headers[]='Authorization: '.$OAuthSign['header'];
|
214 |
-
curl_setopt($ch, CURLOPT_URL, $url);
|
215 |
-
} elseif ($method == 'PUT') {
|
216 |
-
$datafilefd=fopen($file,'r');
|
217 |
-
curl_setopt($ch,CURLOPT_PUT,true);
|
218 |
-
curl_setopt($ch,CURLOPT_INFILE,$datafilefd);
|
219 |
-
curl_setopt($ch,CURLOPT_INFILESIZE,filesize($file));
|
220 |
-
$args = (is_array($args)) ? '?'.http_build_query($args) : $args;
|
221 |
-
$headers[]='Authorization: '.$OAuthSign['header'];
|
222 |
-
curl_setopt($ch, CURLOPT_URL, $url.$args);
|
223 |
-
} else {
|
224 |
-
$headers[]='Authorization: '.$OAuthSign['header'];
|
225 |
-
$args = (is_array($args)) ? '?'.http_build_query($args) : $args;
|
226 |
-
curl_setopt($ch, CURLOPT_URL, $url.$args);
|
227 |
-
}
|
228 |
-
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
|
229 |
-
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
230 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
231 |
-
curl_setopt($ch, CURLOPT_SSLVERSION,3);
|
232 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
233 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
234 |
-
if (is_file(dirname(__FILE__).'/aws/lib/requestcore/cacert.pem'))
|
235 |
-
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__).'/aws/lib/requestcore/cacert.pem');
|
236 |
-
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
237 |
-
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
|
238 |
-
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
|
239 |
-
if (!empty($this->ProgressFunction) and function_exists($this->ProgressFunction) and defined('CURLOPT_PROGRESSFUNCTION') and $method == 'PUT') {
|
240 |
-
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
|
241 |
-
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, $this->ProgressFunction);
|
242 |
-
curl_setopt($ch, CURLOPT_BUFFERSIZE, 512);
|
243 |
-
}
|
244 |
-
if ($echo) {
|
245 |
-
echo curl_exec($ch);
|
246 |
-
$output='';
|
247 |
-
} else {
|
248 |
-
$content = curl_exec($ch);
|
249 |
-
$output = json_decode($content, true);
|
250 |
-
}
|
251 |
-
$status = curl_getinfo($ch);
|
252 |
-
if ($method == 'PUT')
|
253 |
-
fclose($datafilefd);
|
254 |
-
|
255 |
-
if (isset($output['error']) or $status['http_code']>=300 or $status['http_code']<200 or curl_errno($ch)>0) {
|
256 |
-
if(isset($output['error']) && is_string($output['error'])) $message = '('.$status['http_code'].') '.$output['error'];
|
257 |
-
elseif(isset($output['error']['hash']) && $output['error']['hash'] != '') $message = (string) '('.$status['http_code'].') '.$output['error']['hash'];
|
258 |
-
elseif (0!=curl_errno($ch)) $message = '('.curl_errno($ch).') '.curl_error($ch);
|
259 |
-
elseif ($status['http_code']==304) $message = '(304) The folder contents have not changed (relies on hash parameter).';
|
260 |
-
elseif ($status['http_code']==400) $message = '(400) Bad input parameter: '.strip_tags($content);
|
261 |
-
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.';
|
262 |
-
elseif ($status['http_code']==403) $message = '(403) Bad OAuth request (wrong consumer key, bad nonce, expired timestamp, ...). Unfortunately, reauthenticating the user won\'t help here.';
|
263 |
-
elseif ($status['http_code']==404) $message = '(404) The file was not found at the specified path, or was not found at the specified rev.';
|
264 |
-
elseif ($status['http_code']==405) $message = '(405) Request method not expected (generally should be GET,PUT or POST).';
|
265 |
-
elseif ($status['http_code']==406) $message = '(406) There are too many file entries to return.';
|
266 |
-
elseif ($status['http_code']==411) $message = '(411) Chunked encoding was attempted for this upload, but is not supported by Dropbox.';
|
267 |
-
elseif ($status['http_code']==415) $message = '(415) The image is invalid and cannot be thumbnailed.';
|
268 |
-
elseif ($status['http_code']==503) $message = '(503) Your app is making too many requests and is being rate limited. 503s can trigger on a per-app or per-user basis.';
|
269 |
-
elseif ($status['http_code']==507) $message = '(507) User is over Dropbox storage quota.';
|
270 |
-
else $message = '('.$status['http_code'].') Invalid response.';
|
271 |
-
throw new DropboxException($message);
|
272 |
-
} else {
|
273 |
-
curl_close($ch);
|
274 |
-
if (!is_array($output))
|
275 |
-
return $content;
|
276 |
-
else
|
277 |
-
return $output;
|
278 |
-
}
|
279 |
-
}
|
280 |
-
|
281 |
-
private function url_encode($string) {
|
282 |
-
$string = str_replace('?','%3F',$string);
|
283 |
-
$string = str_replace('=','%3D',$string);
|
284 |
-
$string = str_replace(' ','%20',$string);
|
285 |
-
$string = str_replace('(','%28',$string);
|
286 |
-
$string = str_replace(')','%29',$string);
|
287 |
-
$string = str_replace('&','%26',$string);
|
288 |
-
$string = str_replace('@','%40',$string);
|
289 |
-
return $string;
|
290 |
-
}
|
291 |
-
|
292 |
-
}
|
293 |
-
|
294 |
-
class DropboxException extends Exception {
|
295 |
-
}
|
296 |
-
|
297 |
-
|
298 |
-
/**
|
299 |
-
* OAuthSimple - A simpler version of OAuth
|
300 |
-
*
|
301 |
-
* https://github.com/jrconlin/oauthsimple
|
302 |
-
*
|
303 |
-
* @author jr conlin <src@jrconlin.com>
|
304 |
-
* @copyright unitedHeroes.net 2011
|
305 |
-
* @version 1.3
|
306 |
-
* @license See license.txt
|
307 |
-
*
|
308 |
-
*/
|
309 |
-
|
310 |
-
class BackWPup_OAuthSimple {
|
311 |
-
private $_secrets;
|
312 |
-
private $_default_signature_method;
|
313 |
-
private $_action;
|
314 |
-
private $_nonce_chars;
|
315 |
-
|
316 |
-
/**
|
317 |
-
* Constructor
|
318 |
-
*
|
319 |
-
* @access public
|
320 |
-
*
|
321 |
-
* @param api_key (String) The API Key (sometimes referred to as the consumer key) This value is usually supplied by the site you wish to use.
|
322 |
-
* @param shared_secret (String) The shared secret. This value is also usually provided by the site you wish to use.
|
323 |
-
*
|
324 |
-
* @return OAuthSimple (Object)
|
325 |
-
*/
|
326 |
-
function __construct( $APIKey = "", $sharedSecret = "" ) {
|
327 |
-
|
328 |
-
if ( ! empty($APIKey) ) {
|
329 |
-
$this->_secrets['consumer_key'] = $APIKey;
|
330 |
-
}
|
331 |
-
|
332 |
-
if ( ! empty($sharedSecret) ) {
|
333 |
-
$this->_secrets['shared_secret'] = $sharedSecret;
|
334 |
-
}
|
335 |
-
|
336 |
-
$this->_default_signature_method = "HMAC-SHA1";
|
337 |
-
$this->_action = "GET";
|
338 |
-
$this->_nonce_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
339 |
-
|
340 |
-
return $this;
|
341 |
-
}
|
342 |
-
|
343 |
-
/**
|
344 |
-
* Reset the parameters and URL
|
345 |
-
*
|
346 |
-
* @access public
|
347 |
-
* @return OAuthSimple (Object)
|
348 |
-
*/
|
349 |
-
public function reset() {
|
350 |
-
$this->_parameters = Array();
|
351 |
-
$this->path = NULL;
|
352 |
-
$this->sbs = NULL;
|
353 |
-
|
354 |
-
return $this;
|
355 |
-
}
|
356 |
-
|
357 |
-
/**
|
358 |
-
* Set the parameters either from a hash or a string
|
359 |
-
*
|
360 |
-
* @access public
|
361 |
-
*
|
362 |
-
* @param (string, object) List of parameters for the call, this can either be a URI string (e.g. "foo=bar&gorp=banana" or an object/hash)
|
363 |
-
*
|
364 |
-
* @return OAuthSimple (Object)
|
365 |
-
*/
|
366 |
-
public function setParameters( $parameters = Array() ) {
|
367 |
-
|
368 |
-
if ( is_string( $parameters ) ) {
|
369 |
-
$parameters = $this->_parseParameterString( $parameters );
|
370 |
-
}
|
371 |
-
if ( empty($this->_parameters) ) {
|
372 |
-
$this->_parameters = $parameters;
|
373 |
-
}
|
374 |
-
else if ( ! empty($parameters) ) {
|
375 |
-
$this->_parameters = array_merge( $this->_parameters, $parameters );
|
376 |
-
}
|
377 |
-
if ( empty($this->_parameters['oauth_nonce']) ) {
|
378 |
-
$this->_getNonce();
|
379 |
-
}
|
380 |
-
if ( empty($this->_parameters['oauth_timestamp']) ) {
|
381 |
-
$this->_getTimeStamp();
|
382 |
-
}
|
383 |
-
if ( empty($this->_parameters['oauth_consumer_key']) ) {
|
384 |
-
$this->_getApiKey();
|
385 |
-
}
|
386 |
-
if ( empty($this->_parameters['oauth_token']) ) {
|
387 |
-
$this->_getAccessToken();
|
388 |
-
}
|
389 |
-
if ( empty($this->_parameters['oauth_signature_method']) ) {
|
390 |
-
$this->setSignatureMethod();
|
391 |
-
}
|
392 |
-
if ( empty($this->_parameters['oauth_version']) ) {
|
393 |
-
$this->_parameters['oauth_version'] = "1.0";
|
394 |
-
}
|
395 |
-
|
396 |
-
return $this;
|
397 |
-
}
|
398 |
-
|
399 |
-
/**
|
400 |
-
* Convenience method for setParameters
|
401 |
-
*
|
402 |
-
* @access public
|
403 |
-
* @see setParameters
|
404 |
-
*/
|
405 |
-
public function setQueryString( $parameters ) {
|
406 |
-
return $this->setParameters( $parameters );
|
407 |
-
}
|
408 |
-
|
409 |
-
/**
|
410 |
-
* Set the target URL (does not include the parameters)
|
411 |
-
*
|
412 |
-
* @param path (String) the fully qualified URI (excluding query arguments) (e.g "http://example.org/foo")
|
413 |
-
*
|
414 |
-
* @return OAuthSimple (Object)
|
415 |
-
*/
|
416 |
-
public function setURL( $path ) {
|
417 |
-
if ( empty($path) ) {
|
418 |
-
throw new BackWPup_OAuthSimpleException('No path specified for OAuthSimple.setURL');
|
419 |
-
}
|
420 |
-
$this->_path = $path;
|
421 |
-
|
422 |
-
return $this;
|
423 |
-
}
|
424 |
-
|
425 |
-
/**
|
426 |
-
* Convenience method for setURL
|
427 |
-
*
|
428 |
-
* @param path (String)
|
429 |
-
*
|
430 |
-
* @see setURL
|
431 |
-
*/
|
432 |
-
public function setPath( $path ) {
|
433 |
-
return $this->_path = $path;
|
434 |
-
}
|
435 |
-
|
436 |
-
/**
|
437 |
-
* Set the "action" for the url, (e.g. GET,POST, DELETE, etc.)
|
438 |
-
*
|
439 |
-
* @param action (String) HTTP Action word.
|
440 |
-
*
|
441 |
-
* @return OAuthSimple (Object)
|
442 |
-
*/
|
443 |
-
public function setAction( $action ) {
|
444 |
-
if ( empty($action) ) {
|
445 |
-
$action = 'GET';
|
446 |
-
}
|
447 |
-
$action = strtoupper( $action );
|
448 |
-
if ( preg_match( '/[^A-Z]/', $action ) ) {
|
449 |
-
throw new BackWPup_OAuthSimpleException('Invalid action specified for OAuthSimple.setAction');
|
450 |
-
}
|
451 |
-
$this->_action = $action;
|
452 |
-
|
453 |
-
return $this;
|
454 |
-
}
|
455 |
-
|
456 |
-
/**
|
457 |
-
* Set the signatures (as well as validate the ones you have)
|
458 |
-
*
|
459 |
-
* @param signatures (object) object/hash of the token/signature pairs {api_key:, shared_secret:, oauth_token: oauth_secret:}
|
460 |
-
*
|
461 |
-
* @return OAuthSimple (Object)
|
462 |
-
*/
|
463 |
-
public function signatures( $signatures ) {
|
464 |
-
if ( ! empty($signatures) && ! is_array( $signatures ) ) {
|
465 |
-
throw new BackWPup_OAuthSimpleException('Must pass dictionary array to OAuthSimple.signatures');
|
466 |
-
}
|
467 |
-
if ( ! empty($signatures) ) {
|
468 |
-
if ( empty($this->_secrets) ) {
|
469 |
-
$this->_secrets = Array();
|
470 |
-
}
|
471 |
-
$this->_secrets = array_merge( $this->_secrets, $signatures );
|
472 |
-
}
|
473 |
-
if ( isset($this->_secrets['api_key']) ) {
|
474 |
-
$this->_secrets['consumer_key'] = $this->_secrets['api_key'];
|
475 |
-
}
|
476 |
-
if ( isset($this->_secrets['access_token']) ) {
|
477 |
-
$this->_secrets['oauth_token'] = $this->_secrets['access_token'];
|
478 |
-
}
|
479 |
-
if ( isset($this->_secrets['access_secret']) ) {
|
480 |
-
$this->_secrets['oauth_secret'] = $this->_secrets['access_secret'];
|
481 |
-
}
|
482 |
-
if ( isset($this->_secrets['access_token_secret']) ) {
|
483 |
-
$this->_secrets['oauth_secret'] = $this->_secrets['access_token_secret'];
|
484 |
-
}
|
485 |
-
if ( empty($this->_secrets['consumer_key']) ) {
|
486 |
-
throw new BackWPup_OAuthSimpleException('Missing required consumer_key in OAuthSimple.signatures');
|
487 |
-
}
|
488 |
-
if ( empty($this->_secrets['shared_secret']) ) {
|
489 |
-
throw new BackWPup_OAuthSimpleException('Missing requires shared_secret in OAuthSimple.signatures');
|
490 |
-
}
|
491 |
-
if ( ! empty($this->_secrets['oauth_token']) && empty($this->_secrets['oauth_secret']) ) {
|
492 |
-
throw new BackWPup_OAuthSimpleException('Missing oauth_secret for supplied oauth_token in OAuthSimple.signatures');
|
493 |
-
}
|
494 |
-
|
495 |
-
return $this;
|
496 |
-
}
|
497 |
-
|
498 |
-
public function setTokensAndSecrets( $signatures ) {
|
499 |
-
return $this->signatures( $signatures );
|
500 |
-
}
|
501 |
-
|
502 |
-
/**
|
503 |
-
* Set the signature method (currently only Plaintext or SHA-MAC1)
|
504 |
-
*
|
505 |
-
* @param method (String) Method of signing the transaction (only PLAINTEXT and SHA-MAC1 allowed for now)
|
506 |
-
*
|
507 |
-
* @return OAuthSimple (Object)
|
508 |
-
*/
|
509 |
-
public function setSignatureMethod( $method = "" ) {
|
510 |
-
if ( empty($method) ) {
|
511 |
-
$method = $this->_default_signature_method;
|
512 |
-
}
|
513 |
-
$method = strtoupper( $method );
|
514 |
-
switch ( $method )
|
515 |
-
{
|
516 |
-
case 'PLAINTEXT':
|
517 |
-
case 'HMAC-SHA1':
|
518 |
-
$this->_parameters['oauth_signature_method'] = $method;
|
519 |
-
break;
|
520 |
-
default:
|
521 |
-
throw new BackWPup_OAuthSimpleException ("Unknown signing method $method specified for OAuthSimple.setSignatureMethod");
|
522 |
-
break;
|
523 |
-
}
|
524 |
-
|
525 |
-
return $this;
|
526 |
-
}
|
527 |
-
|
528 |
-
/** sign the request
|
529 |
-
*
|
530 |
-
* note: all arguments are optional, provided you've set them using the
|
531 |
-
* other helper functions.
|
532 |
-
*
|
533 |
-
* @param args (Array) hash of arguments for the call {action, path, parameters (array), method, signatures (array)} all arguments are optional.
|
534 |
-
*
|
535 |
-
* @return (Array) signed values
|
536 |
-
*/
|
537 |
-
public function sign( $args = array() ) {
|
538 |
-
if ( ! empty($args['action']) ) {
|
539 |
-
$this->setAction( $args['action'] );
|
540 |
-
}
|
541 |
-
if ( ! empty($args['path']) ) {
|
542 |
-
$this->setPath( $args['path'] );
|
543 |
-
}
|
544 |
-
if ( ! empty($args['method']) ) {
|
545 |
-
$this->setSignatureMethod( $args['method'] );
|
546 |
-
}
|
547 |
-
if ( ! empty($args['signatures']) ) {
|
548 |
-
$this->signatures( $args['signatures'] );
|
549 |
-
}
|
550 |
-
if ( empty($args['parameters']) ) {
|
551 |
-
$args['parameters'] = array();
|
552 |
-
}
|
553 |
-
$this->setParameters( $args['parameters'] );
|
554 |
-
$normParams = $this->_normalizedParameters();
|
555 |
-
$this->_parameters['oauth_signature'] = $this->_generateSignature( $normParams );
|
556 |
-
|
557 |
-
return Array(
|
558 |
-
'parameters' => $this->_parameters,
|
559 |
-
'signature' => self::_oauthEscape( $this->_parameters['oauth_signature'] ),
|
560 |
-
'signed_url' => $this->_path . '?' . $this->_normalizedParameters(),
|
561 |
-
'header' => $this->getHeaderString(),
|
562 |
-
'sbs' => $this->sbs
|
563 |
-
);
|
564 |
-
}
|
565 |
-
|
566 |
-
/**
|
567 |
-
* Return a formatted "header" string
|
568 |
-
*
|
569 |
-
* NOTE: This doesn't set the "Authorization: " prefix, which is required.
|
570 |
-
* It's not set because various set header functions prefer different
|
571 |
-
* ways to do that.
|
572 |
-
*
|
573 |
-
* @param args (Array)
|
574 |
-
*
|
575 |
-
* @return $result (String)
|
576 |
-
*/
|
577 |
-
public function getHeaderString( $args = array() ) {
|
578 |
-
if ( empty($this->_parameters['oauth_signature']) ) {
|
579 |
-
$this->sign( $args );
|
580 |
-
}
|
581 |
-
$result = 'OAuth ';
|
582 |
-
|
583 |
-
foreach ( $this->_parameters as $pName => $pValue )
|
584 |
-
{
|
585 |
-
if ( strpos( $pName, 'oauth_' ) !== 0 ) {
|
586 |
-
continue;
|
587 |
-
}
|
588 |
-
if ( is_array( $pValue ) ) {
|
589 |
-
foreach ( $pValue as $val )
|
590 |
-
{
|
591 |
-
$result .= $pName . '="' . self::_oauthEscape( $val ) . '", ';
|
592 |
-
}
|
593 |
-
}
|
594 |
-
else
|
595 |
-
{
|
596 |
-
$result .= $pName . '="' . self::_oauthEscape( $pValue ) . '", ';
|
597 |
-
}
|
598 |
-
}
|
599 |
-
|
600 |
-
return preg_replace( '/, $/', '', $result );
|
601 |
-
}
|
602 |
-
|
603 |
-
private function _parseParameterString( $paramString ) {
|
604 |
-
$elements = explode( '&', $paramString );
|
605 |
-
$result = array();
|
606 |
-
foreach ( $elements as $element )
|
607 |
-
{
|
608 |
-
list ($key, $token) = explode( '=', $element );
|
609 |
-
if ( $token ) {
|
610 |
-
$token = urldecode( $token );
|
611 |
-
}
|
612 |
-
if ( ! empty($result[$key]) ) {
|
613 |
-
if ( ! is_array( $result[$key] ) ) {
|
614 |
-
$result[$key] = array( $result[$key], $token );
|
615 |
-
}
|
616 |
-
else
|
617 |
-
{
|
618 |
-
array_push( $result[$key], $token );
|
619 |
-
}
|
620 |
-
}
|
621 |
-
else
|
622 |
-
$result[$key] = $token;
|
623 |
-
}
|
624 |
-
return $result;
|
625 |
-
}
|
626 |
-
|
627 |
-
|
628 |
-
private static function _oauthEscape( $string ) {
|
629 |
-
if ( $string === 0 ) {
|
630 |
-
return 0;
|
631 |
-
}
|
632 |
-
if ( $string == '0' ) {
|
633 |
-
return '0';
|
634 |
-
}
|
635 |
-
if ( strlen( $string ) == 0 ) {
|
636 |
-
return '';
|
637 |
-
}
|
638 |
-
if ( is_array( $string ) ) {
|
639 |
-
throw new BackWPup_OAuthSimpleException('Array passed to _oauthEscape');
|
640 |
-
}
|
641 |
-
$string = rawurlencode( $string );
|
642 |
-
|
643 |
-
$string = str_replace( '+', '%20', $string );
|
644 |
-
$string = str_replace( '!', '%21', $string );
|
645 |
-
$string = str_replace( '*', '%2A', $string );
|
646 |
-
$string = str_replace( '\'', '%27', $string );
|
647 |
-
$string = str_replace( '(', '%28', $string );
|
648 |
-
$string = str_replace( ')', '%29', $string );
|
649 |
-
|
650 |
-
return $string;
|
651 |
-
}
|
652 |
-
|
653 |
-
private function _getNonce( $length = 5 ) {
|
654 |
-
$result = '';
|
655 |
-
$cLength = strlen( $this->_nonce_chars );
|
656 |
-
for ( $i = 0; $i < $length; $i ++ )
|
657 |
-
{
|
658 |
-
$rnum = rand( 0, $cLength );
|
659 |
-
$result .= substr( $this->_nonce_chars, $rnum, 1 );
|
660 |
-
}
|
661 |
-
$this->_parameters['oauth_nonce'] = $result;
|
662 |
-
|
663 |
-
return $result;
|
664 |
-
}
|
665 |
-
|
666 |
-
private function _getApiKey() {
|
667 |
-
if ( empty($this->_secrets['consumer_key']) ) {
|
668 |
-
throw new BackWPup_OAuthSimpleException('No consumer_key set for OAuthSimple');
|
669 |
-
}
|
670 |
-
$this->_parameters['oauth_consumer_key'] = $this->_secrets['consumer_key'];
|
671 |
-
|
672 |
-
return $this->_parameters['oauth_consumer_key'];
|
673 |
-
}
|
674 |
-
|
675 |
-
private function _getAccessToken() {
|
676 |
-
if ( ! isset($this->_secrets['oauth_secret']) ) {
|
677 |
-
return '';
|
678 |
-
}
|
679 |
-
if ( ! isset($this->_secrets['oauth_token']) ) {
|
680 |
-
throw new BackWPup_OAuthSimpleException('No access token (oauth_token) set for OAuthSimple.');
|
681 |
-
}
|
682 |
-
$this->_parameters['oauth_token'] = $this->_secrets['oauth_token'];
|
683 |
-
|
684 |
-
return $this->_parameters['oauth_token'];
|
685 |
-
}
|
686 |
-
|
687 |
-
private function _getTimeStamp() {
|
688 |
-
return $this->_parameters['oauth_timestamp'] = time();
|
689 |
-
}
|
690 |
-
|
691 |
-
private function _normalizedParameters() {
|
692 |
-
$normalized_keys = array();
|
693 |
-
$return_array = array();
|
694 |
-
|
695 |
-
foreach ( $this->_parameters as $paramName=> $paramValue ) {
|
696 |
-
if ( ! preg_match( '/\w+_secret/', $paramName ) || (strpos( $paramValue, '@' ) !== 0 && ! file_exists( substr( $paramValue, 1 ) )) ) {
|
697 |
-
if ( is_array( $paramValue ) ) {
|
698 |
-
$normalized_keys[self::_oauthEscape( $paramName )] = array();
|
699 |
-
foreach ( $paramValue as $item )
|
700 |
-
{
|
701 |
-
array_push( $normalized_keys[self::_oauthEscape( $paramName )], self::_oauthEscape( $item ) );
|
702 |
-
}
|
703 |
-
}
|
704 |
-
else
|
705 |
-
{
|
706 |
-
$normalized_keys[self::_oauthEscape( $paramName )] = self::_oauthEscape( $paramValue );
|
707 |
-
}
|
708 |
-
}
|
709 |
-
}
|
710 |
-
|
711 |
-
ksort( $normalized_keys );
|
712 |
-
|
713 |
-
foreach ( $normalized_keys as $key=> $val )
|
714 |
-
{
|
715 |
-
if ( is_array( $val ) ) {
|
716 |
-
sort( $val );
|
717 |
-
foreach ( $val as $element )
|
718 |
-
{
|
719 |
-
array_push( $return_array, $key . "=" . $element );
|
720 |
-
}
|
721 |
-
}
|
722 |
-
else
|
723 |
-
{
|
724 |
-
array_push( $return_array, $key . '=' . $val );
|
725 |
-
}
|
726 |
-
|
727 |
-
}
|
728 |
-
|
729 |
-
return join( "&", $return_array );
|
730 |
-
}
|
731 |
-
|
732 |
-
|
733 |
-
private function _generateSignature() {
|
734 |
-
$secretKey = '';
|
735 |
-
if ( isset($this->_secrets['shared_secret']) ) {
|
736 |
-
$secretKey = self::_oauthEscape( $this->_secrets['shared_secret'] );
|
737 |
-
}
|
738 |
-
|
739 |
-
$secretKey .= '&';
|
740 |
-
if ( isset($this->_secrets['oauth_secret']) ) {
|
741 |
-
$secretKey .= self::_oauthEscape( $this->_secrets['oauth_secret'] );
|
742 |
-
}
|
743 |
-
switch ( $this->_parameters['oauth_signature_method'] )
|
744 |
-
{
|
745 |
-
case 'PLAINTEXT':
|
746 |
-
return urlencode( $secretKey );
|
747 |
-
;
|
748 |
-
case 'HMAC-SHA1':
|
749 |
-
$this->sbs = self::_oauthEscape( $this->_action ) . '&' . self::_oauthEscape( $this->_path ) . '&' . self::_oauthEscape( $this->_normalizedParameters() );
|
750 |
-
|
751 |
-
return base64_encode( hash_hmac( 'sha1', $this->sbs, $secretKey, TRUE ) );
|
752 |
-
default:
|
753 |
-
throw new BackWPup_OAuthSimpleException('Unknown signature method for OAuthSimple');
|
754 |
-
break;
|
755 |
-
}
|
756 |
-
}
|
757 |
-
}
|
758 |
-
|
759 |
-
class BackWPup_OAuthSimpleException extends Exception {
|
760 |
-
|
761 |
-
}
|
762 |
-
|
763 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Dropbox class
|
5 |
+
*
|
6 |
+
* This source file can be used to communicate with DropBox (http://dropbox.com)
|
7 |
+
*
|
8 |
+
* The class is documented in the file itself. If you find any bugs help me out and report them.
|
9 |
+
* If you report a bug, make sure you give me enough information (include your code).
|
10 |
+
*
|
11 |
+
*
|
12 |
+
*
|
13 |
+
* License
|
14 |
+
* Copyright (c), Daniel Huesken. All rights reserved.
|
15 |
+
*
|
16 |
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
17 |
+
*
|
18 |
+
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
19 |
+
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
20 |
+
* 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
|
21 |
+
*
|
22 |
+
* This software is provided by the author "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the author be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
|
23 |
+
*
|
24 |
+
* @author Daniel Huesken <daniel@huesken-net.de>
|
25 |
+
* @version 2.0.0
|
26 |
+
*
|
27 |
+
* @copyright Copyright (c), Daniel Huesken. All rights reserved.
|
28 |
+
* @license BSD License
|
29 |
+
*/
|
30 |
+
|
31 |
+
class backwpup_Dropbox {
|
32 |
+
const API_URL = 'https://api.dropbox.com/';
|
33 |
+
const API_CONTENT_URL = 'https://api-content.dropbox.com/';
|
34 |
+
const API_WWW_URL = 'https://www.dropbox.com/';
|
35 |
+
const API_VERSION_URL = '1/';
|
36 |
+
|
37 |
+
private $root = 'sandbox';
|
38 |
+
private $OAuthObject;
|
39 |
+
private $OAuthToken;
|
40 |
+
private $ProgressFunction = false;
|
41 |
+
|
42 |
+
public function __construct($applicationKey, $applicationSecret,$dropbox=false) {
|
43 |
+
$this->OAuthObject = new BackWPup_OAuthSimple($applicationKey, $applicationSecret);
|
44 |
+
if ($dropbox)
|
45 |
+
$this->root = 'dropbox';
|
46 |
+
else
|
47 |
+
$this->root = 'sandbox';
|
48 |
+
}
|
49 |
+
|
50 |
+
public function setOAuthTokens($token,$secret) {
|
51 |
+
$this->OAuthToken = array('oauth_token'=>$token,'oauth_secret'=> $secret);
|
52 |
+
}
|
53 |
+
|
54 |
+
public function setProgressFunction($function) {
|
55 |
+
if (function_exists($function))
|
56 |
+
$this->ProgressFunction = $function;
|
57 |
+
else
|
58 |
+
$this->ProgressFunction = false;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function accountInfo(){
|
62 |
+
$url = self::API_URL.self::API_VERSION_URL.'account/info';
|
63 |
+
return $this->request($url);
|
64 |
+
}
|
65 |
+
|
66 |
+
public function upload($file, $path = '',$overwrite=true){
|
67 |
+
$file = str_replace("\\", "/",$file);
|
68 |
+
if (!is_readable($file) or !is_file($file))
|
69 |
+
throw new DropboxException("Error: File \"$file\" is not readable or doesn't exist.");
|
70 |
+
if (filesize($file)>157286400)
|
71 |
+
throw new DropboxException("Error: File \"$file\" is too big max. 150 MB.");
|
72 |
+
$url = self::API_CONTENT_URL.self::API_VERSION_URL.'files_put/'.$this->root.'/'.trim($path, '/');
|
73 |
+
return $this->request($url, array('overwrite' => ($overwrite)? 'true' : 'false'), 'PUT', $file);
|
74 |
+
}
|
75 |
+
|
76 |
+
public function download($path,$echo=false){
|
77 |
+
$url = self::API_CONTENT_URL.self::API_VERSION_URL.'files/'.$this->root.'/'.trim($path,'/');
|
78 |
+
if (!$echo)
|
79 |
+
return $this->request($url);
|
80 |
+
else
|
81 |
+
$this->request($url,'','GET','',true);
|
82 |
+
}
|
83 |
+
|
84 |
+
public function metadata($path = '', $listContents = true, $fileLimit = 10000){
|
85 |
+
$url = self::API_URL.self::API_VERSION_URL.'metadata/'.$this->root.'/'.trim($path,'/');
|
86 |
+
return $this->request($url, array('list' => ($listContents)? 'true' : 'false', 'file_limit' => $fileLimit));
|
87 |
+
}
|
88 |
+
|
89 |
+
public function search($path = '', $query , $fileLimit = 1000){
|
90 |
+
if (strlen($query)>=3)
|
91 |
+
throw new DropboxException("Error: Query \"$query\" must three characters long.");
|
92 |
+
$url = self::API_URL.self::API_VERSION_URL.'search/'.$this->root.'/'.trim($path,'/');
|
93 |
+
return $this->request($url, array('query' => $query, 'file_limit' => $fileLimit));
|
94 |
+
}
|
95 |
+
|
96 |
+
public function shares($path = ''){
|
97 |
+
$url = self::API_URL.self::API_VERSION_URL.'shares/'.$this->root.'/'.trim($path,'/');
|
98 |
+
return $this->request($url);
|
99 |
+
}
|
100 |
+
|
101 |
+
public function media($path = ''){
|
102 |
+
$url = self::API_URL.self::API_VERSION_URL.'media/'.$this->root.'/'.trim($path,'/');
|
103 |
+
return $this->request($url);
|
104 |
+
}
|
105 |
+
|
106 |
+
public function fileopsDelete($path){
|
107 |
+
$url = self::API_URL.self::API_VERSION_URL.'fileops/delete';
|
108 |
+
return $this->request($url, array('path' => '/'.trim($path,'/'), 'root' => $this->root));
|
109 |
+
}
|
110 |
+
|
111 |
+
public function fileopsCreate_folder($path){
|
112 |
+
$url = self::API_URL.self::API_VERSION_URL.'fileops/create_folder';
|
113 |
+
return $this->request($url, array('path' => '/'.trim($path,'/'), 'root' => $this->root));
|
114 |
+
}
|
115 |
+
|
116 |
+
public function oAuthAuthorize($callback_url) {
|
117 |
+
//request tokens
|
118 |
+
$OAuthSign = $this->OAuthObject->sign(array(
|
119 |
+
'path' =>self::API_URL.self::API_VERSION_URL.'oauth/request_token',
|
120 |
+
'method' =>'HMAC-SHA1',
|
121 |
+
'action' =>'GET',
|
122 |
+
'parameters'=>array('oauth_callback'=>$callback_url)));
|
123 |
+
$ch = curl_init();
|
124 |
+
curl_setopt($ch, CURLOPT_URL, $OAuthSign['signed_url']);
|
125 |
+
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
|
126 |
+
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
127 |
+
curl_setopt($ch, CURLOPT_SSLVERSION,3);
|
128 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
129 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
130 |
+
if (is_file(dirname(__FILE__).'/aws/lib/requestcore/cacert.pem'))
|
131 |
+
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__).'/aws/lib/requestcore/cacert.pem');
|
132 |
+
curl_setopt($ch, CURLOPT_AUTOREFERER , true);
|
133 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
134 |
+
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
|
135 |
+
$content = curl_exec($ch);
|
136 |
+
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
137 |
+
if ($status>=200 and $status<300 and 0==curl_errno($ch) ) {
|
138 |
+
parse_str($content, $oauth_token);
|
139 |
+
} else {
|
140 |
+
$output = json_decode($content, true);
|
141 |
+
if(isset($output['error']) && is_string($output['error'])) $message = $output['error'];
|
142 |
+
elseif(isset($output['error']['hash']) && $output['error']['hash'] != '') $message = (string) $output['error']['hash'];
|
143 |
+
elseif (0!=curl_errno($ch)) $message = '('.curl_errno($ch).') '.curl_error($ch);
|
144 |
+
else $message = '('.$status.') Invalid response.';
|
145 |
+
throw new DropboxException($message);
|
146 |
+
}
|
147 |
+
curl_close($ch);
|
148 |
+
$OAuthSign = $this->OAuthObject->sign(array(
|
149 |
+
'path' =>self::API_WWW_URL.self::API_VERSION_URL.'oauth/authorize',
|
150 |
+
'action' =>'GET',
|
151 |
+
'parameters'=>array(
|
152 |
+
'oauth_token' => $oauth_token['oauth_token'])));
|
153 |
+
return array('authurl'=>$OAuthSign['signed_url'],'oauth_token'=>$oauth_token['oauth_token'],'oauth_token_secret'=>$oauth_token['oauth_token_secret']);
|
154 |
+
}
|
155 |
+
|
156 |
+
public function oAuthAccessToken($oauth_token, $oauth_token_secret) {
|
157 |
+
$OAuthSign = $this->OAuthObject->sign(array(
|
158 |
+
'path' => self::API_URL.self::API_VERSION_URL.'oauth/access_token',
|
159 |
+
'action' =>'GET',
|
160 |
+
'method' =>'HMAC-SHA1',
|
161 |
+
'parameters'=>array('oauth_token' => $oauth_token),
|
162 |
+
'signatures'=>array('oauth_token'=>$oauth_token,'oauth_secret'=>$oauth_token_secret)));
|
163 |
+
$ch = curl_init();
|
164 |
+
curl_setopt($ch, CURLOPT_URL, $OAuthSign['signed_url']);
|
165 |
+
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
166 |
+
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
|
167 |
+
curl_setopt($ch, CURLOPT_SSLVERSION,3);
|
168 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
169 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
170 |
+
if (is_file(dirname(__FILE__).'/aws/lib/requestcore/cacert.pem'))
|
171 |
+
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__).'/aws/lib/requestcore/cacert.pem');
|
172 |
+
curl_setopt($ch, CURLOPT_AUTOREFERER , true);
|
173 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
174 |
+
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
|
175 |
+
$content = curl_exec($ch);
|
176 |
+
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
177 |
+
if ($status>=200 and $status<300 and 0==curl_errno($ch)) {
|
178 |
+
parse_str($content, $oauth_token);
|
179 |
+
$this->setOAuthTokens($oauth_token['oauth_token'],$oauth_token['oauth_token_secret']);
|
180 |
+
return $oauth_token;
|
181 |
+
} else {
|
182 |
+
$output = json_decode($content, true);
|
183 |
+
if(isset($output['error']) && is_string($output['error'])) $message = $output['error'];
|
184 |
+
elseif(isset($output['error']['hash']) && $output['error']['hash'] != '') $message = (string) $output['error']['hash'];
|
185 |
+
elseif (0!=curl_errno($ch)) $message = '('.curl_errno($ch).') '.curl_error($ch);
|
186 |
+
else $message = '('.$status.') Invalid response.';
|
187 |
+
throw new DropboxException($message);
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
private function request($url, $args = null, $method = 'GET', $file = null, $echo=false){
|
192 |
+
$args = (is_array($args)) ? $args : array();
|
193 |
+
$url = $this->url_encode($url);
|
194 |
+
/* Sign Request*/
|
195 |
+
$this->OAuthObject->reset();
|
196 |
+
$OAuthSign=$this->OAuthObject->sign(array(
|
197 |
+
'path' => $url,
|
198 |
+
'parameters'=> $args,
|
199 |
+
'action'=> $method,
|
200 |
+
'method' => 'HMAC-SHA1',
|
201 |
+
'signatures'=> $this->OAuthToken));
|
202 |
+
|
203 |
+
/* Header*/
|
204 |
+
$headers[]='Expect:';
|
205 |
+
|
206 |
+
/* Build cURL Request */
|
207 |
+
$ch = curl_init();
|
208 |
+
if ($method == 'POST') {
|
209 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
210 |
+
$args = (is_array($args)) ? http_build_query($args) : $args;
|
211 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
|
212 |
+
$headers[]='Content-Length: '.strlen($args);
|
213 |
+
$headers[]='Authorization: '.$OAuthSign['header'];
|
214 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
215 |
+
} elseif ($method == 'PUT') {
|
216 |
+
$datafilefd=fopen($file,'r');
|
217 |
+
curl_setopt($ch,CURLOPT_PUT,true);
|
218 |
+
curl_setopt($ch,CURLOPT_INFILE,$datafilefd);
|
219 |
+
curl_setopt($ch,CURLOPT_INFILESIZE,filesize($file));
|
220 |
+
$args = (is_array($args)) ? '?'.http_build_query($args) : $args;
|
221 |
+
$headers[]='Authorization: '.$OAuthSign['header'];
|
222 |
+
curl_setopt($ch, CURLOPT_URL, $url.$args);
|
223 |
+
} else {
|
224 |
+
$headers[]='Authorization: '.$OAuthSign['header'];
|
225 |
+
$args = (is_array($args)) ? '?'.http_build_query($args) : $args;
|
226 |
+
curl_setopt($ch, CURLOPT_URL, $url.$args);
|
227 |
+
}
|
228 |
+
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
|
229 |
+
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
230 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
231 |
+
curl_setopt($ch, CURLOPT_SSLVERSION,3);
|
232 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
233 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
234 |
+
if (is_file(dirname(__FILE__).'/aws/lib/requestcore/cacert.pem'))
|
235 |
+
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__).'/aws/lib/requestcore/cacert.pem');
|
236 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
237 |
+
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
|
238 |
+
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
|
239 |
+
if (!empty($this->ProgressFunction) and function_exists($this->ProgressFunction) and defined('CURLOPT_PROGRESSFUNCTION') and $method == 'PUT') {
|
240 |
+
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
|
241 |
+
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, $this->ProgressFunction);
|
242 |
+
curl_setopt($ch, CURLOPT_BUFFERSIZE, 512);
|
243 |
+
}
|
244 |
+
if ($echo) {
|
245 |
+
echo curl_exec($ch);
|
246 |
+
$output='';
|
247 |
+
} else {
|
248 |
+
$content = curl_exec($ch);
|
249 |
+
$output = json_decode($content, true);
|
250 |
+
}
|
251 |
+
$status = curl_getinfo($ch);
|
252 |
+
if ($method == 'PUT')
|
253 |
+
fclose($datafilefd);
|
254 |
+
|
255 |
+
if (isset($output['error']) or $status['http_code']>=300 or $status['http_code']<200 or curl_errno($ch)>0) {
|
256 |
+
if(isset($output['error']) && is_string($output['error'])) $message = '('.$status['http_code'].') '.$output['error'];
|
257 |
+
elseif(isset($output['error']['hash']) && $output['error']['hash'] != '') $message = (string) '('.$status['http_code'].') '.$output['error']['hash'];
|
258 |
+
elseif (0!=curl_errno($ch)) $message = '('.curl_errno($ch).') '.curl_error($ch);
|
259 |
+
elseif ($status['http_code']==304) $message = '(304) The folder contents have not changed (relies on hash parameter).';
|
260 |
+
elseif ($status['http_code']==400) $message = '(400) Bad input parameter: '.strip_tags($content);
|
261 |
+
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.';
|
262 |
+
elseif ($status['http_code']==403) $message = '(403) Bad OAuth request (wrong consumer key, bad nonce, expired timestamp, ...). Unfortunately, reauthenticating the user won\'t help here.';
|
263 |
+
elseif ($status['http_code']==404) $message = '(404) The file was not found at the specified path, or was not found at the specified rev.';
|
264 |
+
elseif ($status['http_code']==405) $message = '(405) Request method not expected (generally should be GET,PUT or POST).';
|
265 |
+
elseif ($status['http_code']==406) $message = '(406) There are too many file entries to return.';
|
266 |
+
elseif ($status['http_code']==411) $message = '(411) Chunked encoding was attempted for this upload, but is not supported by Dropbox.';
|
267 |
+
elseif ($status['http_code']==415) $message = '(415) The image is invalid and cannot be thumbnailed.';
|
268 |
+
elseif ($status['http_code']==503) $message = '(503) Your app is making too many requests and is being rate limited. 503s can trigger on a per-app or per-user basis.';
|
269 |
+
elseif ($status['http_code']==507) $message = '(507) User is over Dropbox storage quota.';
|
270 |
+
else $message = '('.$status['http_code'].') Invalid response.';
|
271 |
+
throw new DropboxException($message);
|
272 |
+
} else {
|
273 |
+
curl_close($ch);
|
274 |
+
if (!is_array($output))
|
275 |
+
return $content;
|
276 |
+
else
|
277 |
+
return $output;
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
private function url_encode($string) {
|
282 |
+
$string = str_replace('?','%3F',$string);
|
283 |
+
$string = str_replace('=','%3D',$string);
|
284 |
+
$string = str_replace(' ','%20',$string);
|
285 |
+
$string = str_replace('(','%28',$string);
|
286 |
+
$string = str_replace(')','%29',$string);
|
287 |
+
$string = str_replace('&','%26',$string);
|
288 |
+
$string = str_replace('@','%40',$string);
|
289 |
+
return $string;
|
290 |
+
}
|
291 |
+
|
292 |
+
}
|
293 |
+
|
294 |
+
class DropboxException extends Exception {
|
295 |
+
}
|
296 |
+
|
297 |
+
|
298 |
+
/**
|
299 |
+
* OAuthSimple - A simpler version of OAuth
|
300 |
+
*
|
301 |
+
* https://github.com/jrconlin/oauthsimple
|
302 |
+
*
|
303 |
+
* @author jr conlin <src@jrconlin.com>
|
304 |
+
* @copyright unitedHeroes.net 2011
|
305 |
+
* @version 1.3
|
306 |
+
* @license See license.txt
|
307 |
+
*
|
308 |
+
*/
|
309 |
+
|
310 |
+
class BackWPup_OAuthSimple {
|
311 |
+
private $_secrets;
|
312 |
+
private $_default_signature_method;
|
313 |
+
private $_action;
|
314 |
+
private $_nonce_chars;
|
315 |
+
|
316 |
+
/**
|
317 |
+
* Constructor
|
318 |
+
*
|
319 |
+
* @access public
|
320 |
+
*
|
321 |
+
* @param api_key (String) The API Key (sometimes referred to as the consumer key) This value is usually supplied by the site you wish to use.
|
322 |
+
* @param shared_secret (String) The shared secret. This value is also usually provided by the site you wish to use.
|
323 |
+
*
|
324 |
+
* @return OAuthSimple (Object)
|
325 |
+
*/
|
326 |
+
function __construct( $APIKey = "", $sharedSecret = "" ) {
|
327 |
+
|
328 |
+
if ( ! empty($APIKey) ) {
|
329 |
+
$this->_secrets['consumer_key'] = $APIKey;
|
330 |
+
}
|
331 |
+
|
332 |
+
if ( ! empty($sharedSecret) ) {
|
333 |
+
$this->_secrets['shared_secret'] = $sharedSecret;
|
334 |
+
}
|
335 |
+
|
336 |
+
$this->_default_signature_method = "HMAC-SHA1";
|
337 |
+
$this->_action = "GET";
|
338 |
+
$this->_nonce_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
339 |
+
|
340 |
+
return $this;
|
341 |
+
}
|
342 |
+
|
343 |
+
/**
|
344 |
+
* Reset the parameters and URL
|
345 |
+
*
|
346 |
+
* @access public
|
347 |
+
* @return OAuthSimple (Object)
|
348 |
+
*/
|
349 |
+
public function reset() {
|
350 |
+
$this->_parameters = Array();
|
351 |
+
$this->path = NULL;
|
352 |
+
$this->sbs = NULL;
|
353 |
+
|
354 |
+
return $this;
|
355 |
+
}
|
356 |
+
|
357 |
+
/**
|
358 |
+
* Set the parameters either from a hash or a string
|
359 |
+
*
|
360 |
+
* @access public
|
361 |
+
*
|
362 |
+
* @param (string, object) List of parameters for the call, this can either be a URI string (e.g. "foo=bar&gorp=banana" or an object/hash)
|
363 |
+
*
|
364 |
+
* @return OAuthSimple (Object)
|
365 |
+
*/
|
366 |
+
public function setParameters( $parameters = Array() ) {
|
367 |
+
|
368 |
+
if ( is_string( $parameters ) ) {
|
369 |
+
$parameters = $this->_parseParameterString( $parameters );
|
370 |
+
}
|
371 |
+
if ( empty($this->_parameters) ) {
|
372 |
+
$this->_parameters = $parameters;
|
373 |
+
}
|
374 |
+
else if ( ! empty($parameters) ) {
|
375 |
+
$this->_parameters = array_merge( $this->_parameters, $parameters );
|
376 |
+
}
|
377 |
+
if ( empty($this->_parameters['oauth_nonce']) ) {
|
378 |
+
$this->_getNonce();
|
379 |
+
}
|
380 |
+
if ( empty($this->_parameters['oauth_timestamp']) ) {
|
381 |
+
$this->_getTimeStamp();
|
382 |
+
}
|
383 |
+
if ( empty($this->_parameters['oauth_consumer_key']) ) {
|
384 |
+
$this->_getApiKey();
|
385 |
+
}
|
386 |
+
if ( empty($this->_parameters['oauth_token']) ) {
|
387 |
+
$this->_getAccessToken();
|
388 |
+
}
|
389 |
+
if ( empty($this->_parameters['oauth_signature_method']) ) {
|
390 |
+
$this->setSignatureMethod();
|
391 |
+
}
|
392 |
+
if ( empty($this->_parameters['oauth_version']) ) {
|
393 |
+
$this->_parameters['oauth_version'] = "1.0";
|
394 |
+
}
|
395 |
+
|
396 |
+
return $this;
|
397 |
+
}
|
398 |
+
|
399 |
+
/**
|
400 |
+
* Convenience method for setParameters
|
401 |
+
*
|
402 |
+
* @access public
|
403 |
+
* @see setParameters
|
404 |
+
*/
|
405 |
+
public function setQueryString( $parameters ) {
|
406 |
+
return $this->setParameters( $parameters );
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Set the target URL (does not include the parameters)
|
411 |
+
*
|
412 |
+
* @param path (String) the fully qualified URI (excluding query arguments) (e.g "http://example.org/foo")
|
413 |
+
*
|
414 |
+
* @return OAuthSimple (Object)
|
415 |
+
*/
|
416 |
+
public function setURL( $path ) {
|
417 |
+
if ( empty($path) ) {
|
418 |
+
throw new BackWPup_OAuthSimpleException('No path specified for OAuthSimple.setURL');
|
419 |
+
}
|
420 |
+
$this->_path = $path;
|
421 |
+
|
422 |
+
return $this;
|
423 |
+
}
|
424 |
+
|
425 |
+
/**
|
426 |
+
* Convenience method for setURL
|
427 |
+
*
|
428 |
+
* @param path (String)
|
429 |
+
*
|
430 |
+
* @see setURL
|
431 |
+
*/
|
432 |
+
public function setPath( $path ) {
|
433 |
+
return $this->_path = $path;
|
434 |
+
}
|
435 |
+
|
436 |
+
/**
|
437 |
+
* Set the "action" for the url, (e.g. GET,POST, DELETE, etc.)
|
438 |
+
*
|
439 |
+
* @param action (String) HTTP Action word.
|
440 |
+
*
|
441 |
+
* @return OAuthSimple (Object)
|
442 |
+
*/
|
443 |
+
public function setAction( $action ) {
|
444 |
+
if ( empty($action) ) {
|
445 |
+
$action = 'GET';
|
446 |
+
}
|
447 |
+
$action = strtoupper( $action );
|
448 |
+
if ( preg_match( '/[^A-Z]/', $action ) ) {
|
449 |
+
throw new BackWPup_OAuthSimpleException('Invalid action specified for OAuthSimple.setAction');
|
450 |
+
}
|
451 |
+
$this->_action = $action;
|
452 |
+
|
453 |
+
return $this;
|
454 |
+
}
|
455 |
+
|
456 |
+
/**
|
457 |
+
* Set the signatures (as well as validate the ones you have)
|
458 |
+
*
|
459 |
+
* @param signatures (object) object/hash of the token/signature pairs {api_key:, shared_secret:, oauth_token: oauth_secret:}
|
460 |
+
*
|
461 |
+
* @return OAuthSimple (Object)
|
462 |
+
*/
|
463 |
+
public function signatures( $signatures ) {
|
464 |
+
if ( ! empty($signatures) && ! is_array( $signatures ) ) {
|
465 |
+
throw new BackWPup_OAuthSimpleException('Must pass dictionary array to OAuthSimple.signatures');
|
466 |
+
}
|
467 |
+
if ( ! empty($signatures) ) {
|
468 |
+
if ( empty($this->_secrets) ) {
|
469 |
+
$this->_secrets = Array();
|
470 |
+
}
|
471 |
+
$this->_secrets = array_merge( $this->_secrets, $signatures );
|
472 |
+
}
|
473 |
+
if ( isset($this->_secrets['api_key']) ) {
|
474 |
+
$this->_secrets['consumer_key'] = $this->_secrets['api_key'];
|
475 |
+
}
|
476 |
+
if ( isset($this->_secrets['access_token']) ) {
|
477 |
+
$this->_secrets['oauth_token'] = $this->_secrets['access_token'];
|
478 |
+
}
|
479 |
+
if ( isset($this->_secrets['access_secret']) ) {
|
480 |
+
$this->_secrets['oauth_secret'] = $this->_secrets['access_secret'];
|
481 |
+
}
|
482 |
+
if ( isset($this->_secrets['access_token_secret']) ) {
|
483 |
+
$this->_secrets['oauth_secret'] = $this->_secrets['access_token_secret'];
|
484 |
+
}
|
485 |
+
if ( empty($this->_secrets['consumer_key']) ) {
|
486 |
+
throw new BackWPup_OAuthSimpleException('Missing required consumer_key in OAuthSimple.signatures');
|
487 |
+
}
|
488 |
+
if ( empty($this->_secrets['shared_secret']) ) {
|
489 |
+
throw new BackWPup_OAuthSimpleException('Missing requires shared_secret in OAuthSimple.signatures');
|
490 |
+
}
|
491 |
+
if ( ! empty($this->_secrets['oauth_token']) && empty($this->_secrets['oauth_secret']) ) {
|
492 |
+
throw new BackWPup_OAuthSimpleException('Missing oauth_secret for supplied oauth_token in OAuthSimple.signatures');
|
493 |
+
}
|
494 |
+
|
495 |
+
return $this;
|
496 |
+
}
|
497 |
+
|
498 |
+
public function setTokensAndSecrets( $signatures ) {
|
499 |
+
return $this->signatures( $signatures );
|
500 |
+
}
|
501 |
+
|
502 |
+
/**
|
503 |
+
* Set the signature method (currently only Plaintext or SHA-MAC1)
|
504 |
+
*
|
505 |
+
* @param method (String) Method of signing the transaction (only PLAINTEXT and SHA-MAC1 allowed for now)
|
506 |
+
*
|
507 |
+
* @return OAuthSimple (Object)
|
508 |
+
*/
|
509 |
+
public function setSignatureMethod( $method = "" ) {
|
510 |
+
if ( empty($method) ) {
|
511 |
+
$method = $this->_default_signature_method;
|
512 |
+
}
|
513 |
+
$method = strtoupper( $method );
|
514 |
+
switch ( $method )
|
515 |
+
{
|
516 |
+
case 'PLAINTEXT':
|
517 |
+
case 'HMAC-SHA1':
|
518 |
+
$this->_parameters['oauth_signature_method'] = $method;
|
519 |
+
break;
|
520 |
+
default:
|
521 |
+
throw new BackWPup_OAuthSimpleException ("Unknown signing method $method specified for OAuthSimple.setSignatureMethod");
|
522 |
+
break;
|
523 |
+
}
|
524 |
+
|
525 |
+
return $this;
|
526 |
+
}
|
527 |
+
|
528 |
+
/** sign the request
|
529 |
+
*
|
530 |
+
* note: all arguments are optional, provided you've set them using the
|
531 |
+
* other helper functions.
|
532 |
+
*
|
533 |
+
* @param args (Array) hash of arguments for the call {action, path, parameters (array), method, signatures (array)} all arguments are optional.
|
534 |
+
*
|
535 |
+
* @return (Array) signed values
|
536 |
+
*/
|
537 |
+
public function sign( $args = array() ) {
|
538 |
+
if ( ! empty($args['action']) ) {
|
539 |
+
$this->setAction( $args['action'] );
|
540 |
+
}
|
541 |
+
if ( ! empty($args['path']) ) {
|
542 |
+
$this->setPath( $args['path'] );
|
543 |
+
}
|
544 |
+
if ( ! empty($args['method']) ) {
|
545 |
+
$this->setSignatureMethod( $args['method'] );
|
546 |
+
}
|
547 |
+
if ( ! empty($args['signatures']) ) {
|
548 |
+
$this->signatures( $args['signatures'] );
|
549 |
+
}
|
550 |
+
if ( empty($args['parameters']) ) {
|
551 |
+
$args['parameters'] = array();
|
552 |
+
}
|
553 |
+
$this->setParameters( $args['parameters'] );
|
554 |
+
$normParams = $this->_normalizedParameters();
|
555 |
+
$this->_parameters['oauth_signature'] = $this->_generateSignature( $normParams );
|
556 |
+
|
557 |
+
return Array(
|
558 |
+
'parameters' => $this->_parameters,
|
559 |
+
'signature' => self::_oauthEscape( $this->_parameters['oauth_signature'] ),
|
560 |
+
'signed_url' => $this->_path . '?' . $this->_normalizedParameters(),
|
561 |
+
'header' => $this->getHeaderString(),
|
562 |
+
'sbs' => $this->sbs
|
563 |
+
);
|
564 |
+
}
|
565 |
+
|
566 |
+
/**
|
567 |
+
* Return a formatted "header" string
|
568 |
+
*
|
569 |
+
* NOTE: This doesn't set the "Authorization: " prefix, which is required.
|
570 |
+
* It's not set because various set header functions prefer different
|
571 |
+
* ways to do that.
|
572 |
+
*
|
573 |
+
* @param args (Array)
|
574 |
+
*
|
575 |
+
* @return $result (String)
|
576 |
+
*/
|
577 |
+
public function getHeaderString( $args = array() ) {
|
578 |
+
if ( empty($this->_parameters['oauth_signature']) ) {
|
579 |
+
$this->sign( $args );
|
580 |
+
}
|
581 |
+
$result = 'OAuth ';
|
582 |
+
|
583 |
+
foreach ( $this->_parameters as $pName => $pValue )
|
584 |
+
{
|
585 |
+
if ( strpos( $pName, 'oauth_' ) !== 0 ) {
|
586 |
+
continue;
|
587 |
+
}
|
588 |
+
if ( is_array( $pValue ) ) {
|
589 |
+
foreach ( $pValue as $val )
|
590 |
+
{
|
591 |
+
$result .= $pName . '="' . self::_oauthEscape( $val ) . '", ';
|
592 |
+
}
|
593 |
+
}
|
594 |
+
else
|
595 |
+
{
|
596 |
+
$result .= $pName . '="' . self::_oauthEscape( $pValue ) . '", ';
|
597 |
+
}
|
598 |
+
}
|
599 |
+
|
600 |
+
return preg_replace( '/, $/', '', $result );
|
601 |
+
}
|
602 |
+
|
603 |
+
private function _parseParameterString( $paramString ) {
|
604 |
+
$elements = explode( '&', $paramString );
|
605 |
+
$result = array();
|
606 |
+
foreach ( $elements as $element )
|
607 |
+
{
|
608 |
+
list ($key, $token) = explode( '=', $element );
|
609 |
+
if ( $token ) {
|
610 |
+
$token = urldecode( $token );
|
611 |
+
}
|
612 |
+
if ( ! empty($result[$key]) ) {
|
613 |
+
if ( ! is_array( $result[$key] ) ) {
|
614 |
+
$result[$key] = array( $result[$key], $token );
|
615 |
+
}
|
616 |
+
else
|
617 |
+
{
|
618 |
+
array_push( $result[$key], $token );
|
619 |
+
}
|
620 |
+
}
|
621 |
+
else
|
622 |
+
$result[$key] = $token;
|
623 |
+
}
|
624 |
+
return $result;
|
625 |
+
}
|
626 |
+
|
627 |
+
|
628 |
+
private static function _oauthEscape( $string ) {
|
629 |
+
if ( $string === 0 ) {
|
630 |
+
return 0;
|
631 |
+
}
|
632 |
+
if ( $string == '0' ) {
|
633 |
+
return '0';
|
634 |
+
}
|
635 |
+
if ( strlen( $string ) == 0 ) {
|
636 |
+
return '';
|
637 |
+
}
|
638 |
+
if ( is_array( $string ) ) {
|
639 |
+
throw new BackWPup_OAuthSimpleException('Array passed to _oauthEscape');
|
640 |
+
}
|
641 |
+
$string = rawurlencode( $string );
|
642 |
+
|
643 |
+
$string = str_replace( '+', '%20', $string );
|
644 |
+
$string = str_replace( '!', '%21', $string );
|
645 |
+
$string = str_replace( '*', '%2A', $string );
|
646 |
+
$string = str_replace( '\'', '%27', $string );
|
647 |
+
$string = str_replace( '(', '%28', $string );
|
648 |
+
$string = str_replace( ')', '%29', $string );
|
649 |
+
|
650 |
+
return $string;
|
651 |
+
}
|
652 |
+
|
653 |
+
private function _getNonce( $length = 5 ) {
|
654 |
+
$result = '';
|
655 |
+
$cLength = strlen( $this->_nonce_chars );
|
656 |
+
for ( $i = 0; $i < $length; $i ++ )
|
657 |
+
{
|
658 |
+
$rnum = rand( 0, $cLength );
|
659 |
+
$result .= substr( $this->_nonce_chars, $rnum, 1 );
|
660 |
+
}
|
661 |
+
$this->_parameters['oauth_nonce'] = $result;
|
662 |
+
|
663 |
+
return $result;
|
664 |
+
}
|
665 |
+
|
666 |
+
private function _getApiKey() {
|
667 |
+
if ( empty($this->_secrets['consumer_key']) ) {
|
668 |
+
throw new BackWPup_OAuthSimpleException('No consumer_key set for OAuthSimple');
|
669 |
+
}
|
670 |
+
$this->_parameters['oauth_consumer_key'] = $this->_secrets['consumer_key'];
|
671 |
+
|
672 |
+
return $this->_parameters['oauth_consumer_key'];
|
673 |
+
}
|
674 |
+
|
675 |
+
private function _getAccessToken() {
|
676 |
+
if ( ! isset($this->_secrets['oauth_secret']) ) {
|
677 |
+
return '';
|
678 |
+
}
|
679 |
+
if ( ! isset($this->_secrets['oauth_token']) ) {
|
680 |
+
throw new BackWPup_OAuthSimpleException('No access token (oauth_token) set for OAuthSimple.');
|
681 |
+
}
|
682 |
+
$this->_parameters['oauth_token'] = $this->_secrets['oauth_token'];
|
683 |
+
|
684 |
+
return $this->_parameters['oauth_token'];
|
685 |
+
}
|
686 |
+
|
687 |
+
private function _getTimeStamp() {
|
688 |
+
return $this->_parameters['oauth_timestamp'] = time();
|
689 |
+
}
|
690 |
+
|
691 |
+
private function _normalizedParameters() {
|
692 |
+
$normalized_keys = array();
|
693 |
+
$return_array = array();
|
694 |
+
|
695 |
+
foreach ( $this->_parameters as $paramName=> $paramValue ) {
|
696 |
+
if ( ! preg_match( '/\w+_secret/', $paramName ) || (strpos( $paramValue, '@' ) !== 0 && ! file_exists( substr( $paramValue, 1 ) )) ) {
|
697 |
+
if ( is_array( $paramValue ) ) {
|
698 |
+
$normalized_keys[self::_oauthEscape( $paramName )] = array();
|
699 |
+
foreach ( $paramValue as $item )
|
700 |
+
{
|
701 |
+
array_push( $normalized_keys[self::_oauthEscape( $paramName )], self::_oauthEscape( $item ) );
|
702 |
+
}
|
703 |
+
}
|
704 |
+
else
|
705 |
+
{
|
706 |
+
$normalized_keys[self::_oauthEscape( $paramName )] = self::_oauthEscape( $paramValue );
|
707 |
+
}
|
708 |
+
}
|
709 |
+
}
|
710 |
+
|
711 |
+
ksort( $normalized_keys );
|
712 |
+
|
713 |
+
foreach ( $normalized_keys as $key=> $val )
|
714 |
+
{
|
715 |
+
if ( is_array( $val ) ) {
|
716 |
+
sort( $val );
|
717 |
+
foreach ( $val as $element )
|
718 |
+
{
|
719 |
+
array_push( $return_array, $key . "=" . $element );
|
720 |
+
}
|
721 |
+
}
|
722 |
+
else
|
723 |
+
{
|
724 |
+
array_push( $return_array, $key . '=' . $val );
|
725 |
+
}
|
726 |
+
|
727 |
+
}
|
728 |
+
|
729 |
+
return join( "&", $return_array );
|
730 |
+
}
|
731 |
+
|
732 |
+
|
733 |
+
private function _generateSignature() {
|
734 |
+
$secretKey = '';
|
735 |
+
if ( isset($this->_secrets['shared_secret']) ) {
|
736 |
+
$secretKey = self::_oauthEscape( $this->_secrets['shared_secret'] );
|
737 |
+
}
|
738 |
+
|
739 |
+
$secretKey .= '&';
|
740 |
+
if ( isset($this->_secrets['oauth_secret']) ) {
|
741 |
+
$secretKey .= self::_oauthEscape( $this->_secrets['oauth_secret'] );
|
742 |
+
}
|
743 |
+
switch ( $this->_parameters['oauth_signature_method'] )
|
744 |
+
{
|
745 |
+
case 'PLAINTEXT':
|
746 |
+
return urlencode( $secretKey );
|
747 |
+
;
|
748 |
+
case 'HMAC-SHA1':
|
749 |
+
$this->sbs = self::_oauthEscape( $this->_action ) . '&' . self::_oauthEscape( $this->_path ) . '&' . self::_oauthEscape( $this->_normalizedParameters() );
|
750 |
+
|
751 |
+
return base64_encode( hash_hmac( 'sha1', $this->sbs, $secretKey, TRUE ) );
|
752 |
+
default:
|
753 |
+
throw new BackWPup_OAuthSimpleException('Unknown signature method for OAuthSimple');
|
754 |
+
break;
|
755 |
+
}
|
756 |
+
}
|
757 |
+
}
|
758 |
+
|
759 |
+
class BackWPup_OAuthSimpleException extends Exception {
|
760 |
+
|
761 |
+
}
|
|
|
|
libs/sugarsync.php
CHANGED
@@ -1,372 +1,372 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* SugarSync class
|
5 |
-
*
|
6 |
-
* This source file can be used to communicate with SugarSync (http://sugarsync.com)
|
7 |
-
*
|
8 |
-
* The class is documented in the file itself. If you find any bugs help me out and report them.
|
9 |
-
* If you report a bug, make sure you give me enough information (include your code).
|
10 |
-
*
|
11 |
-
*
|
12 |
-
* License
|
13 |
-
* Copyright (c), Daniel Huesken. All rights reserved.
|
14 |
-
*
|
15 |
-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
16 |
-
*
|
17 |
-
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
18 |
-
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
19 |
-
* 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
|
20 |
-
*
|
21 |
-
* This software is provided by the author "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the author be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
|
22 |
-
*
|
23 |
-
* @author Daniel Huesken <daniel@huesken-net.de>
|
24 |
-
* @version 1.0.0
|
25 |
-
*
|
26 |
-
* @copyright Copyright (c), Daniel Huesken. All rights reserved.
|
27 |
-
* @license BSD License
|
28 |
-
*/
|
29 |
-
|
30 |
-
class SugarSync {
|
31 |
-
|
32 |
-
// url for the sugarsync-api
|
33 |
-
const API_URL = 'https://api.sugarsync.com';
|
34 |
-
|
35 |
-
// current version
|
36 |
-
const VERSION = '1.0.0';
|
37 |
-
|
38 |
-
|
39 |
-
/**
|
40 |
-
* The Auth-token
|
41 |
-
*
|
42 |
-
* @var string
|
43 |
-
*/
|
44 |
-
protected $AuthToken = '';
|
45 |
-
|
46 |
-
protected $folder = '';
|
47 |
-
|
48 |
-
protected $ProgressFunction = false;
|
49 |
-
|
50 |
-
// class methods
|
51 |
-
/**
|
52 |
-
* Default constructor/Auth
|
53 |
-
*
|
54 |
-
* @return void
|
55 |
-
* @param string $email The consumer E-Mail.
|
56 |
-
* @param string $password The consumer password.
|
57 |
-
* @param string $accessKeyId The developer access key.
|
58 |
-
* @param string $privateAccessKey The developer access scret.
|
59 |
-
*/
|
60 |
-
public function __construct($email, $password, $accessKeyId, $privateAccessKey)
|
61 |
-
{
|
62 |
-
if(!is_string($email) or empty($email))
|
63 |
-
throw new SugarSyncException('You must set Account E-Mail!');
|
64 |
-
if(!is_string($password) or empty($password))
|
65 |
-
throw new SugarSyncException('You must set Account Password!');
|
66 |
-
if(!is_string($accessKeyId) or empty($accessKeyId))
|
67 |
-
throw new SugarSyncException('You must Developer access Key!');
|
68 |
-
if(!is_string($privateAccessKey) or empty($privateAccessKey))
|
69 |
-
throw new SugarSyncException('You must Developer access Secret!');
|
70 |
-
|
71 |
-
//auth xml
|
72 |
-
$auth ='<?xml version="1.0" encoding="UTF-8" ?>';
|
73 |
-
$auth.='<authRequest>';
|
74 |
-
$auth.='<username>'.utf8_encode($email).'</username>';
|
75 |
-
$auth.='<password>'.utf8_encode($password).'</password>';
|
76 |
-
$auth.='<accessKeyId>'.utf8_encode($accessKeyId).'</accessKeyId>';
|
77 |
-
$auth.='<privateAccessKey>'.utf8_encode($privateAccessKey).'</privateAccessKey>';
|
78 |
-
$auth.='</authRequest>';
|
79 |
-
// init
|
80 |
-
$curl = curl_init();
|
81 |
-
//set otions
|
82 |
-
curl_setopt($curl,CURLOPT_URL,self::API_URL .'/authorization');
|
83 |
-
curl_setopt($curl,CURLOPT_USERAGENT,'PHP SugarSync/'. self::VERSION);
|
84 |
-
if(ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) curl_setopt($curl,CURLOPT_FOLLOWLOCATION,true);
|
85 |
-
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
|
86 |
-
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false);
|
87 |
-
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,false);
|
88 |
-
curl_setopt($curl,CURLOPT_HEADER,true);
|
89 |
-
curl_setopt($curl,CURLOPT_HTTPHEADER,array('Content-Type: application/xml; charset=UTF-8'));
|
90 |
-
curl_setopt($curl,CURLOPT_POSTFIELDS,$auth);
|
91 |
-
curl_setopt($curl,CURLOPT_POST,true);
|
92 |
-
// execute
|
93 |
-
$response = curl_exec($curl);
|
94 |
-
$curlgetinfo = curl_getinfo($curl);
|
95 |
-
// fetch curl errors
|
96 |
-
if (curl_errno($curl) != 0)
|
97 |
-
throw new SugarSyncException('cUrl Error: '. curl_error($curl));
|
98 |
-
|
99 |
-
curl_close($curl);
|
100 |
-
|
101 |
-
if ($curlgetinfo['http_code']>=200 and $curlgetinfo['http_code']<=204) {
|
102 |
-
if (preg_match('/Location:(.*?)\r/i', $response, $matches))
|
103 |
-
$this->AuthToken=$matches[1];
|
104 |
-
} else {
|
105 |
-
if ($curlgetinfo['http_code']==401)
|
106 |
-
throw new SugarSyncException('Http Error: '. $curlgetinfo['http_code'].' Authorization required.');
|
107 |
-
elseif ($curlgetinfo['http_code']==403)
|
108 |
-
throw new SugarSyncException('Http Error: '. $curlgetinfo['http_code'].' (Forbidden) Authentication failed.');
|
109 |
-
elseif ($curlgetinfo['http_code']==404)
|
110 |
-
throw new SugarSyncException('Http Error: '. $curlgetinfo['http_code'].' Not found');
|
111 |
-
else
|
112 |
-
throw new SugarSyncException('Http Error: '. $curlgetinfo['http_code']);
|
113 |
-
}
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* Make the call
|
118 |
-
*
|
119 |
-
* @return string
|
120 |
-
* @param string $url The url to call.
|
121 |
-
* @param string[optiona] $data File on put, xml on post.
|
122 |
-
* @param string[optional] $method The method to use. Possible values are GET, POST, PUT, DELETE.
|
123 |
-
*/
|
124 |
-
private function doCall($url, $data = '', $method = 'GET') {
|
125 |
-
// allowed methods
|
126 |
-
$allowedMethods = array('GET','POST','PUT','DELETE');
|
127 |
-
|
128 |
-
// redefine
|
129 |
-
$url = (string) $url;
|
130 |
-
$method = (string) $method;
|
131 |
-
|
132 |
-
// validate method
|
133 |
-
if(!in_array($method, $allowedMethods))
|
134 |
-
throw new SugarSyncException('Unknown method ('. $method .'). Allowed methods are: '. implode(', ', $allowedMethods));
|
135 |
-
|
136 |
-
// check auth token
|
137 |
-
if(!is_string($this->AuthToken) or empty($this->AuthToken) or !strripos($this->AuthToken,self::API_URL))
|
138 |
-
throw new SugarSyncException('Auth Token not set correctly!!');
|
139 |
-
else
|
140 |
-
$headers[] = 'Authorization: '.$this->AuthToken;
|
141 |
-
$headers[] = 'Expect:';
|
142 |
-
|
143 |
-
// init
|
144 |
-
$curl = curl_init();
|
145 |
-
//set otions
|
146 |
-
curl_setopt($curl,CURLOPT_URL, $url);
|
147 |
-
curl_setopt($curl,CURLOPT_USERAGENT,'PHP SugarSync/'. self::VERSION);
|
148 |
-
if(ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) curl_setopt($curl,CURLOPT_FOLLOWLOCATION,true);
|
149 |
-
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
|
150 |
-
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false);
|
151 |
-
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,false);
|
152 |
-
|
153 |
-
if ($method == 'POST') {
|
154 |
-
$headers[]='Content-Type: application/xml; charset=UTF-8';
|
155 |
-
curl_setopt($curl,CURLOPT_POSTFIELDS,$data);
|
156 |
-
curl_setopt($curl,CURLOPT_POST,true);
|
157 |
-
$headers[]='Content-Length: '.strlen($data);
|
158 |
-
} elseif ($method == 'PUT') {
|
159 |
-
if (is_file($data) and is_readable($data)) {
|
160 |
-
$headers[]='Content-Length: '.filesize($data);
|
161 |
-
$datafilefd=fopen($data,'r');
|
162 |
-
curl_setopt($curl,CURLOPT_PUT,true);
|
163 |
-
curl_setopt($curl,CURLOPT_INFILE,$datafilefd);
|
164 |
-
curl_setopt($curl,CURLOPT_INFILESIZE,filesize($data));
|
165 |
-
} else {
|
166 |
-
throw new SugarSyncException('Is not a readable file:'. $data);
|
167 |
-
}
|
168 |
-
} elseif ($method == 'DELETE') {
|
169 |
-
curl_setopt($curl,CURLOPT_CUSTOMREQUEST,'DELETE');
|
170 |
-
} else {
|
171 |
-
curl_setopt($curl,CURLOPT_POST,false);
|
172 |
-
}
|
173 |
-
|
174 |
-
// set headers
|
175 |
-
curl_setopt($curl,CURLOPT_HTTPHEADER,$headers);
|
176 |
-
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
|
177 |
-
if (function_exists($this->ProgressFunction) and defined('CURLOPT_PROGRESSFUNCTION')) {
|
178 |
-
curl_setopt($curl, CURLOPT_NOPROGRESS, false);
|
179 |
-
curl_setopt($curl, CURLOPT_PROGRESSFUNCTION, $this->ProgressFunction);
|
180 |
-
curl_setopt($curl, CURLOPT_BUFFERSIZE, 512);
|
181 |
-
}
|
182 |
-
// execute
|
183 |
-
$response = curl_exec($curl);
|
184 |
-
$curlgetinfo = curl_getinfo($curl);
|
185 |
-
|
186 |
-
// fetch curl errors
|
187 |
-
if (curl_errno($curl) != 0)
|
188 |
-
throw new SugarSyncException('cUrl Error: '. curl_error($curl));
|
189 |
-
curl_close($curl);
|
190 |
-
if (!empty($datafilefd) and is_resource($datafilefd))
|
191 |
-
fclose($datafilefd);
|
192 |
-
|
193 |
-
if ($curlgetinfo['http_code']>=200 and $curlgetinfo['http_code']<300) {
|
194 |
-
if (false !== stripos($curlgetinfo['content_type'],'xml') and !empty($response))
|
195 |
-
return simplexml_load_string($response);
|
196 |
-
else
|
197 |
-
return $response;
|
198 |
-
} else {
|
199 |
-
if ($curlgetinfo['http_code']==401)
|
200 |
-
throw new SugarSyncException('Http Error: '. $curlgetinfo['http_code'].' Authorization required.');
|
201 |
-
elseif ($curlgetinfo['http_code']==403)
|
202 |
-
throw new SugarSyncException('Http Error: '. $curlgetinfo['http_code'].' (Forbidden) Authentication failed.');
|
203 |
-
elseif ($curlgetinfo['http_code']==404)
|
204 |
-
throw new SugarSyncException('Http Error: '. $curlgetinfo['http_code'].' Not found');
|
205 |
-
else
|
206 |
-
throw new SugarSyncException('Http Error: '. $curlgetinfo['http_code']);
|
207 |
-
}
|
208 |
-
}
|
209 |
-
|
210 |
-
public function chdir($folder,$root='') {
|
211 |
-
$folder=rtrim($folder,'/');
|
212 |
-
if (substr($folder,0,1)=='/' or empty($this->folder)) {
|
213 |
-
if (!empty($root))
|
214 |
-
$this->folder=$root;
|
215 |
-
else
|
216 |
-
throw new SugarSyncException('chdir: root folder must set!');
|
217 |
-
}
|
218 |
-
$folders=explode('/',$folder);
|
219 |
-
foreach ($folders as $dir) {
|
220 |
-
if ($dir=='..') {
|
221 |
-
$contents=$this->doCall($this->folder);
|
222 |
-
if (!empty($contents->parent))
|
223 |
-
$this->folder=$contents->parent;
|
224 |
-
} elseif (!empty($dir) and $dir!='.') {
|
225 |
-
$isdir=false;
|
226 |
-
$contents=$this->getcontents('folder');
|
227 |
-
foreach ($contents->collection as $collection) {
|
228 |
-
if (strtolower($collection->displayName)==strtolower($dir)) {
|
229 |
-
$isdir=true;
|
230 |
-
$this->folder=$collection->ref;
|
231 |
-
break;
|
232 |
-
}
|
233 |
-
}
|
234 |
-
if (!$isdir)
|
235 |
-
throw new SugarSyncException('chdir: Folder '. $folder.' not exitst');
|
236 |
-
}
|
237 |
-
}
|
238 |
-
return $this->folder;
|
239 |
-
}
|
240 |
-
|
241 |
-
public function showdir($folderid) {
|
242 |
-
$showfolder='';
|
243 |
-
while ($folderid) {
|
244 |
-
$contents=$this->doCall($folderid);
|
245 |
-
$showfolder=$contents->displayName.'/'.$showfolder;
|
246 |
-
if (isset($contents->parent))
|
247 |
-
$folderid=$contents->parent;
|
248 |
-
else
|
249 |
-
break;
|
250 |
-
}
|
251 |
-
return $showfolder;
|
252 |
-
}
|
253 |
-
|
254 |
-
public function mkdir($folder,$root='') {
|
255 |
-
$savefolder=$this->folder;
|
256 |
-
$folder=rtrim($folder,'/');
|
257 |
-
if (substr($folder,0,1)=='/' or empty($this->folder)) {
|
258 |
-
if (!empty($root))
|
259 |
-
$this->folder=$root;
|
260 |
-
else
|
261 |
-
throw new SugarSyncException('mkdir: root folder must set!');
|
262 |
-
}
|
263 |
-
$folders=explode('/',$folder);
|
264 |
-
foreach ($folders as $dir) {
|
265 |
-
if ($dir=='..') {
|
266 |
-
$contents=$this->doCall($this->folder);
|
267 |
-
if (!empty($contents->parent))
|
268 |
-
$this->folder=$contents->parent;
|
269 |
-
} elseif (!empty($dir) and $dir!='.') {
|
270 |
-
$isdir=false;
|
271 |
-
$contents=$this->getcontents('folder');
|
272 |
-
foreach ($contents->collection as $collection) {
|
273 |
-
if (strtolower($collection->displayName)==strtolower($dir)) {
|
274 |
-
$isdir=true;
|
275 |
-
$this->folder=$collection->ref;
|
276 |
-
break;
|
277 |
-
}
|
278 |
-
}
|
279 |
-
if (!$isdir) {
|
280 |
-
$request=$this->doCall($this->folder,'<?xml version="1.0" encoding="UTF-8"?><folder><displayName>'.utf8_encode($dir).'</displayName></folder>','POST');
|
281 |
-
$contents=$this->getcontents('folder');
|
282 |
-
foreach ($contents->collection as $collection) {
|
283 |
-
if (strtolower($collection->displayName)==strtolower($dir)) {
|
284 |
-
$isdir=true;
|
285 |
-
$this->folder=$collection->ref;
|
286 |
-
break;
|
287 |
-
}
|
288 |
-
}
|
289 |
-
}
|
290 |
-
}
|
291 |
-
}
|
292 |
-
$this->folder=$savefolder;
|
293 |
-
return true;
|
294 |
-
}
|
295 |
-
|
296 |
-
|
297 |
-
public function user() {
|
298 |
-
return $this->doCall(self::API_URL .'/user');
|
299 |
-
}
|
300 |
-
|
301 |
-
|
302 |
-
public function get($url) {
|
303 |
-
return $this->doCall($url,'','GET');
|
304 |
-
}
|
305 |
-
|
306 |
-
public function download($url) {
|
307 |
-
return $this->doCall($url.'/data');
|
308 |
-
}
|
309 |
-
|
310 |
-
public function delete($url) {
|
311 |
-
return $this->doCall($url,'','DELETE');
|
312 |
-
}
|
313 |
-
|
314 |
-
|
315 |
-
public function getcontents($type='',$start=0,$max=500) {
|
316 |
-
$parameters='';
|
317 |
-
if (strtolower($type)=='folder' or strtolower($type)=='file')
|
318 |
-
$parameters.='type='.strtolower($type);
|
319 |
-
if (!empty($start) and is_integer($start)) {
|
320 |
-
if (!empty($parameters))
|
321 |
-
$parameters.='&';
|
322 |
-
$parameters.='start='.$start;
|
323 |
-
|
324 |
-
}
|
325 |
-
if (!empty($max) and is_integer($max)) {
|
326 |
-
if (!empty($parameters))
|
327 |
-
$parameters.='&';
|
328 |
-
$parameters.='max='.$max;
|
329 |
-
}
|
330 |
-
|
331 |
-
$request=$this->doCall($this->folder.'/contents?'.$parameters);
|
332 |
-
return $request;
|
333 |
-
}
|
334 |
-
|
335 |
-
public function upload($file,$name='') {
|
336 |
-
if (empty($name))
|
337 |
-
$name=basename($file);
|
338 |
-
$xmlrequest ='<?xml version="1.0" encoding="UTF-8"?>';
|
339 |
-
$xmlrequest.='<file>';
|
340 |
-
$xmlrequest.='<displayName>'.utf8_encode($name).'</displayName>';
|
341 |
-
if (!is_file($file)) {
|
342 |
-
$finfo = fopen($file,'r');
|
343 |
-
$xmlrequest.='<mediaType>'.mime_content_type($finfo).'</mediaType>';
|
344 |
-
fclose($finfo);
|
345 |
-
}
|
346 |
-
$xmlrequest.='</file>';
|
347 |
-
$request=$this->doCall($this->folder,$xmlrequest,'POST');
|
348 |
-
$getfiles=$this->getcontents('file');
|
349 |
-
foreach ($getfiles->file as $getfile) {
|
350 |
-
if ($getfile->displayName==$name) {
|
351 |
-
$this->doCall($getfile->ref.'/data',$file,'PUT');
|
352 |
-
return $getfile->ref;
|
353 |
-
}
|
354 |
-
}
|
355 |
-
}
|
356 |
-
|
357 |
-
public function setProgressFunction($function) {
|
358 |
-
if (function_exists($function))
|
359 |
-
$this->ProgressFunction = $function;
|
360 |
-
else
|
361 |
-
$this->ProgressFunction = false;
|
362 |
-
}
|
363 |
-
}
|
364 |
-
|
365 |
-
|
366 |
-
/**
|
367 |
-
* SugarSync Exception class
|
368 |
-
*
|
369 |
-
* @author Daniel Huesken <daniel@huersken-net.de>
|
370 |
-
*/
|
371 |
-
class SugarSyncException extends Exception {
|
372 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* SugarSync class
|
5 |
+
*
|
6 |
+
* This source file can be used to communicate with SugarSync (http://sugarsync.com)
|
7 |
+
*
|
8 |
+
* The class is documented in the file itself. If you find any bugs help me out and report them.
|
9 |
+
* If you report a bug, make sure you give me enough information (include your code).
|
10 |
+
*
|
11 |
+
*
|
12 |
+
* License
|
13 |
+
* Copyright (c), Daniel Huesken. All rights reserved.
|
14 |
+
*
|
15 |
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
16 |
+
*
|
17 |
+
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
18 |
+
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
19 |
+
* 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
|
20 |
+
*
|
21 |
+
* This software is provided by the author "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the author be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
|
22 |
+
*
|
23 |
+
* @author Daniel Huesken <daniel@huesken-net.de>
|
24 |
+
* @version 1.0.0
|
25 |
+
*
|
26 |
+
* @copyright Copyright (c), Daniel Huesken. All rights reserved.
|
27 |
+
* @license BSD License
|
28 |
+
*/
|
29 |
+
|
30 |
+
class SugarSync {
|
31 |
+
|
32 |
+
// url for the sugarsync-api
|
33 |
+
const API_URL = 'https://api.sugarsync.com';
|
34 |
+
|
35 |
+
// current version
|
36 |
+
const VERSION = '1.0.0';
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
* The Auth-token
|
41 |
+
*
|
42 |
+
* @var string
|
43 |
+
*/
|
44 |
+
protected $AuthToken = '';
|
45 |
+
|
46 |
+
protected $folder = '';
|
47 |
+
|
48 |
+
protected $ProgressFunction = false;
|
49 |
+
|
50 |
+
// class methods
|
51 |
+
/**
|
52 |
+
* Default constructor/Auth
|
53 |
+
*
|
54 |
+
* @return void
|
55 |
+
* @param string $email The consumer E-Mail.
|
56 |
+
* @param string $password The consumer password.
|
57 |
+
* @param string $accessKeyId The developer access key.
|
58 |
+
* @param string $privateAccessKey The developer access scret.
|
59 |
+
*/
|
60 |
+
public function __construct($email, $password, $accessKeyId, $privateAccessKey)
|
61 |
+
{
|
62 |
+
if(!is_string($email) or empty($email))
|
63 |
+
throw new SugarSyncException('You must set Account E-Mail!');
|
64 |
+
if(!is_string($password) or empty($password))
|
65 |
+
throw new SugarSyncException('You must set Account Password!');
|
66 |
+
if(!is_string($accessKeyId) or empty($accessKeyId))
|
67 |
+
throw new SugarSyncException('You must Developer access Key!');
|
68 |
+
if(!is_string($privateAccessKey) or empty($privateAccessKey))
|
69 |
+
throw new SugarSyncException('You must Developer access Secret!');
|
70 |
+
|
71 |
+
//auth xml
|
72 |
+
$auth ='<?xml version="1.0" encoding="UTF-8" ?>';
|
73 |
+
$auth.='<authRequest>';
|
74 |
+
$auth.='<username>'.utf8_encode($email).'</username>';
|
75 |
+
$auth.='<password>'.utf8_encode($password).'</password>';
|
76 |
+
$auth.='<accessKeyId>'.utf8_encode($accessKeyId).'</accessKeyId>';
|
77 |
+
$auth.='<privateAccessKey>'.utf8_encode($privateAccessKey).'</privateAccessKey>';
|
78 |
+
$auth.='</authRequest>';
|
79 |
+
// init
|
80 |
+
$curl = curl_init();
|
81 |
+
//set otions
|
82 |
+
curl_setopt($curl,CURLOPT_URL,self::API_URL .'/authorization');
|
83 |
+
curl_setopt($curl,CURLOPT_USERAGENT,'PHP SugarSync/'. self::VERSION);
|
84 |
+
if(ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) curl_setopt($curl,CURLOPT_FOLLOWLOCATION,true);
|
85 |
+
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
|
86 |
+
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false);
|
87 |
+
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,false);
|
88 |
+
curl_setopt($curl,CURLOPT_HEADER,true);
|
89 |
+
curl_setopt($curl,CURLOPT_HTTPHEADER,array('Content-Type: application/xml; charset=UTF-8'));
|
90 |
+
curl_setopt($curl,CURLOPT_POSTFIELDS,$auth);
|
91 |
+
curl_setopt($curl,CURLOPT_POST,true);
|
92 |
+
// execute
|
93 |
+
$response = curl_exec($curl);
|
94 |
+
$curlgetinfo = curl_getinfo($curl);
|
95 |
+
// fetch curl errors
|
96 |
+
if (curl_errno($curl) != 0)
|
97 |
+
throw new SugarSyncException('cUrl Error: '. curl_error($curl));
|
98 |
+
|
99 |
+
curl_close($curl);
|
100 |
+
|
101 |
+
if ($curlgetinfo['http_code']>=200 and $curlgetinfo['http_code']<=204) {
|
102 |
+
if (preg_match('/Location:(.*?)\r/i', $response, $matches))
|
103 |
+
$this->AuthToken=$matches[1];
|
104 |
+
} else {
|
105 |
+
if ($curlgetinfo['http_code']==401)
|
106 |
+
throw new SugarSyncException('Http Error: '. $curlgetinfo['http_code'].' Authorization required.');
|
107 |
+
elseif ($curlgetinfo['http_code']==403)
|
108 |
+
throw new SugarSyncException('Http Error: '. $curlgetinfo['http_code'].' (Forbidden) Authentication failed.');
|
109 |
+
elseif ($curlgetinfo['http_code']==404)
|
110 |
+
throw new SugarSyncException('Http Error: '. $curlgetinfo['http_code'].' Not found');
|
111 |
+
else
|
112 |
+
throw new SugarSyncException('Http Error: '. $curlgetinfo['http_code']);
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Make the call
|
118 |
+
*
|
119 |
+
* @return string
|
120 |
+
* @param string $url The url to call.
|
121 |
+
* @param string[optiona] $data File on put, xml on post.
|
122 |
+
* @param string[optional] $method The method to use. Possible values are GET, POST, PUT, DELETE.
|
123 |
+
*/
|
124 |
+
private function doCall($url, $data = '', $method = 'GET') {
|
125 |
+
// allowed methods
|
126 |
+
$allowedMethods = array('GET','POST','PUT','DELETE');
|
127 |
+
|
128 |
+
// redefine
|
129 |
+
$url = (string) $url;
|
130 |
+
$method = (string) $method;
|
131 |
+
|
132 |
+
// validate method
|
133 |
+
if(!in_array($method, $allowedMethods))
|
134 |
+
throw new SugarSyncException('Unknown method ('. $method .'). Allowed methods are: '. implode(', ', $allowedMethods));
|
135 |
+
|
136 |
+
// check auth token
|
137 |
+
if(!is_string($this->AuthToken) or empty($this->AuthToken) or !strripos($this->AuthToken,self::API_URL))
|
138 |
+
throw new SugarSyncException('Auth Token not set correctly!!');
|
139 |
+
else
|
140 |
+
$headers[] = 'Authorization: '.$this->AuthToken;
|
141 |
+
$headers[] = 'Expect:';
|
142 |
+
|
143 |
+
// init
|
144 |
+
$curl = curl_init();
|
145 |
+
//set otions
|
146 |
+
curl_setopt($curl,CURLOPT_URL, $url);
|
147 |
+
curl_setopt($curl,CURLOPT_USERAGENT,'PHP SugarSync/'. self::VERSION);
|
148 |
+
if(ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) curl_setopt($curl,CURLOPT_FOLLOWLOCATION,true);
|
149 |
+
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
|
150 |
+
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false);
|
151 |
+
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,false);
|
152 |
+
|
153 |
+
if ($method == 'POST') {
|
154 |
+
$headers[]='Content-Type: application/xml; charset=UTF-8';
|
155 |
+
curl_setopt($curl,CURLOPT_POSTFIELDS,$data);
|
156 |
+
curl_setopt($curl,CURLOPT_POST,true);
|
157 |
+
$headers[]='Content-Length: '.strlen($data);
|
158 |
+
} elseif ($method == 'PUT') {
|
159 |
+
if (is_file($data) and is_readable($data)) {
|
160 |
+
$headers[]='Content-Length: '.filesize($data);
|
161 |
+
$datafilefd=fopen($data,'r');
|
162 |
+
curl_setopt($curl,CURLOPT_PUT,true);
|
163 |
+
curl_setopt($curl,CURLOPT_INFILE,$datafilefd);
|
164 |
+
curl_setopt($curl,CURLOPT_INFILESIZE,filesize($data));
|
165 |
+
} else {
|
166 |
+
throw new SugarSyncException('Is not a readable file:'. $data);
|
167 |
+
}
|
168 |
+
} elseif ($method == 'DELETE') {
|
169 |
+
curl_setopt($curl,CURLOPT_CUSTOMREQUEST,'DELETE');
|
170 |
+
} else {
|
171 |
+
curl_setopt($curl,CURLOPT_POST,false);
|
172 |
+
}
|
173 |
+
|
174 |
+
// set headers
|
175 |
+
curl_setopt($curl,CURLOPT_HTTPHEADER,$headers);
|
176 |
+
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
|
177 |
+
if (function_exists($this->ProgressFunction) and defined('CURLOPT_PROGRESSFUNCTION')) {
|
178 |
+
curl_setopt($curl, CURLOPT_NOPROGRESS, false);
|
179 |
+
curl_setopt($curl, CURLOPT_PROGRESSFUNCTION, $this->ProgressFunction);
|
180 |
+
curl_setopt($curl, CURLOPT_BUFFERSIZE, 512);
|
181 |
+
}
|
182 |
+
// execute
|
183 |
+
$response = curl_exec($curl);
|
184 |
+
$curlgetinfo = curl_getinfo($curl);
|
185 |
+
|
186 |
+
// fetch curl errors
|
187 |
+
if (curl_errno($curl) != 0)
|
188 |
+
throw new SugarSyncException('cUrl Error: '. curl_error($curl));
|
189 |
+
curl_close($curl);
|
190 |
+
if (!empty($datafilefd) and is_resource($datafilefd))
|
191 |
+
fclose($datafilefd);
|
192 |
+
|
193 |
+
if ($curlgetinfo['http_code']>=200 and $curlgetinfo['http_code']<300) {
|
194 |
+
if (false !== stripos($curlgetinfo['content_type'],'xml') and !empty($response))
|
195 |
+
return simplexml_load_string($response);
|
196 |
+
else
|
197 |
+
return $response;
|
198 |
+
} else {
|
199 |
+
if ($curlgetinfo['http_code']==401)
|
200 |
+
throw new SugarSyncException('Http Error: '. $curlgetinfo['http_code'].' Authorization required.');
|
201 |
+
elseif ($curlgetinfo['http_code']==403)
|
202 |
+
throw new SugarSyncException('Http Error: '. $curlgetinfo['http_code'].' (Forbidden) Authentication failed.');
|
203 |
+
elseif ($curlgetinfo['http_code']==404)
|
204 |
+
throw new SugarSyncException('Http Error: '. $curlgetinfo['http_code'].' Not found');
|
205 |
+
else
|
206 |
+
throw new SugarSyncException('Http Error: '. $curlgetinfo['http_code']);
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
public function chdir($folder,$root='') {
|
211 |
+
$folder=rtrim($folder,'/');
|
212 |
+
if (substr($folder,0,1)=='/' or empty($this->folder)) {
|
213 |
+
if (!empty($root))
|
214 |
+
$this->folder=$root;
|
215 |
+
else
|
216 |
+
throw new SugarSyncException('chdir: root folder must set!');
|
217 |
+
}
|
218 |
+
$folders=explode('/',$folder);
|
219 |
+
foreach ($folders as $dir) {
|
220 |
+
if ($dir=='..') {
|
221 |
+
$contents=$this->doCall($this->folder);
|
222 |
+
if (!empty($contents->parent))
|
223 |
+
$this->folder=$contents->parent;
|
224 |
+
} elseif (!empty($dir) and $dir!='.') {
|
225 |
+
$isdir=false;
|
226 |
+
$contents=$this->getcontents('folder');
|
227 |
+
foreach ($contents->collection as $collection) {
|
228 |
+
if (strtolower($collection->displayName)==strtolower($dir)) {
|
229 |
+
$isdir=true;
|
230 |
+
$this->folder=$collection->ref;
|
231 |
+
break;
|
232 |
+
}
|
233 |
+
}
|
234 |
+
if (!$isdir)
|
235 |
+
throw new SugarSyncException('chdir: Folder '. $folder.' not exitst');
|
236 |
+
}
|
237 |
+
}
|
238 |
+
return $this->folder;
|
239 |
+
}
|
240 |
+
|
241 |
+
public function showdir($folderid) {
|
242 |
+
$showfolder='';
|
243 |
+
while ($folderid) {
|
244 |
+
$contents=$this->doCall($folderid);
|
245 |
+
$showfolder=$contents->displayName.'/'.$showfolder;
|
246 |
+
if (isset($contents->parent))
|
247 |
+
$folderid=$contents->parent;
|
248 |
+
else
|
249 |
+
break;
|
250 |
+
}
|
251 |
+
return $showfolder;
|
252 |
+
}
|
253 |
+
|
254 |
+
public function mkdir($folder,$root='') {
|
255 |
+
$savefolder=$this->folder;
|
256 |
+
$folder=rtrim($folder,'/');
|
257 |
+
if (substr($folder,0,1)=='/' or empty($this->folder)) {
|
258 |
+
if (!empty($root))
|
259 |
+
$this->folder=$root;
|
260 |
+
else
|
261 |
+
throw new SugarSyncException('mkdir: root folder must set!');
|
262 |
+
}
|
263 |
+
$folders=explode('/',$folder);
|
264 |
+
foreach ($folders as $dir) {
|
265 |
+
if ($dir=='..') {
|
266 |
+
$contents=$this->doCall($this->folder);
|
267 |
+
if (!empty($contents->parent))
|
268 |
+
$this->folder=$contents->parent;
|
269 |
+
} elseif (!empty($dir) and $dir!='.') {
|
270 |
+
$isdir=false;
|
271 |
+
$contents=$this->getcontents('folder');
|
272 |
+
foreach ($contents->collection as $collection) {
|
273 |
+
if (strtolower($collection->displayName)==strtolower($dir)) {
|
274 |
+
$isdir=true;
|
275 |
+
$this->folder=$collection->ref;
|
276 |
+
break;
|
277 |
+
}
|
278 |
+
}
|
279 |
+
if (!$isdir) {
|
280 |
+
$request=$this->doCall($this->folder,'<?xml version="1.0" encoding="UTF-8"?><folder><displayName>'.utf8_encode($dir).'</displayName></folder>','POST');
|
281 |
+
$contents=$this->getcontents('folder');
|
282 |
+
foreach ($contents->collection as $collection) {
|
283 |
+
if (strtolower($collection->displayName)==strtolower($dir)) {
|
284 |
+
$isdir=true;
|
285 |
+
$this->folder=$collection->ref;
|
286 |
+
break;
|
287 |
+
}
|
288 |
+
}
|
289 |
+
}
|
290 |
+
}
|
291 |
+
}
|
292 |
+
$this->folder=$savefolder;
|
293 |
+
return true;
|
294 |
+
}
|
295 |
+
|
296 |
+
|
297 |
+
public function user() {
|
298 |
+
return $this->doCall(self::API_URL .'/user');
|
299 |
+
}
|
300 |
+
|
301 |
+
|
302 |
+
public function get($url) {
|
303 |
+
return $this->doCall($url,'','GET');
|
304 |
+
}
|
305 |
+
|
306 |
+
public function download($url) {
|
307 |
+
return $this->doCall($url.'/data');
|
308 |
+
}
|
309 |
+
|
310 |
+
public function delete($url) {
|
311 |
+
return $this->doCall($url,'','DELETE');
|
312 |
+
}
|
313 |
+
|
314 |
+
|
315 |
+
public function getcontents($type='',$start=0,$max=500) {
|
316 |
+
$parameters='';
|
317 |
+
if (strtolower($type)=='folder' or strtolower($type)=='file')
|
318 |
+
$parameters.='type='.strtolower($type);
|
319 |
+
if (!empty($start) and is_integer($start)) {
|
320 |
+
if (!empty($parameters))
|
321 |
+
$parameters.='&';
|
322 |
+
$parameters.='start='.$start;
|
323 |
+
|
324 |
+
}
|
325 |
+
if (!empty($max) and is_integer($max)) {
|
326 |
+
if (!empty($parameters))
|
327 |
+
$parameters.='&';
|
328 |
+
$parameters.='max='.$max;
|
329 |
+
}
|
330 |
+
|
331 |
+
$request=$this->doCall($this->folder.'/contents?'.$parameters);
|
332 |
+
return $request;
|
333 |
+
}
|
334 |
+
|
335 |
+
public function upload($file,$name='') {
|
336 |
+
if (empty($name))
|
337 |
+
$name=basename($file);
|
338 |
+
$xmlrequest ='<?xml version="1.0" encoding="UTF-8"?>';
|
339 |
+
$xmlrequest.='<file>';
|
340 |
+
$xmlrequest.='<displayName>'.utf8_encode($name).'</displayName>';
|
341 |
+
if (!is_file($file)) {
|
342 |
+
$finfo = fopen($file,'r');
|
343 |
+
$xmlrequest.='<mediaType>'.mime_content_type($finfo).'</mediaType>';
|
344 |
+
fclose($finfo);
|
345 |
+
}
|
346 |
+
$xmlrequest.='</file>';
|
347 |
+
$request=$this->doCall($this->folder,$xmlrequest,'POST');
|
348 |
+
$getfiles=$this->getcontents('file');
|
349 |
+
foreach ($getfiles->file as $getfile) {
|
350 |
+
if ($getfile->displayName==$name) {
|
351 |
+
$this->doCall($getfile->ref.'/data',$file,'PUT');
|
352 |
+
return $getfile->ref;
|
353 |
+
}
|
354 |
+
}
|
355 |
+
}
|
356 |
+
|
357 |
+
public function setProgressFunction($function) {
|
358 |
+
if (function_exists($function))
|
359 |
+
$this->ProgressFunction = $function;
|
360 |
+
else
|
361 |
+
$this->ProgressFunction = false;
|
362 |
+
}
|
363 |
+
}
|
364 |
+
|
365 |
+
|
366 |
+
/**
|
367 |
+
* SugarSync Exception class
|
368 |
+
*
|
369 |
+
* @author Daniel Huesken <daniel@huersken-net.de>
|
370 |
+
*/
|
371 |
+
class SugarSyncException extends Exception {
|
372 |
}
|
pages/func_backwpup.php
CHANGED
@@ -1,257 +1,256 @@
|
|
1 |
-
<?PHP
|
2 |
-
include_once( trailingslashit(ABSPATH).'wp-admin/includes/class-wp-list-table.php');
|
3 |
-
|
4 |
-
class BackWPup_Jobs_Table extends WP_List_Table {
|
5 |
-
|
6 |
-
function __construct() {
|
7 |
-
parent::__construct( array(
|
8 |
-
'plural' => 'jobs',
|
9 |
-
'singular' => 'job',
|
10 |
-
'ajax' => true
|
11 |
-
) );
|
12 |
-
}
|
13 |
-
|
14 |
-
function ajax_user_can() {
|
15 |
-
return current_user_can(BACKWPUP_USER_CAPABILITY);
|
16 |
-
}
|
17 |
-
|
18 |
-
function prepare_items() {
|
19 |
-
global $mode;
|
20 |
-
$jobs=get_option('backwpup_jobs');
|
21 |
-
if (!empty($jobs) and is_array($jobs)) {
|
22 |
-
foreach ($jobs as $key => $value) {
|
23 |
-
$this->items[]=backwpup_get_job_vars($key);
|
24 |
-
}
|
25 |
-
} else {
|
26 |
-
$this->items='';
|
27 |
-
}
|
28 |
-
$mode = empty( $_GET['mode'] ) ? 'list' : $_GET['mode'];
|
29 |
-
}
|
30 |
-
|
31 |
-
function pagination( $which ) {
|
32 |
-
global $mode;
|
33 |
-
|
34 |
-
parent::pagination( $which );
|
35 |
-
|
36 |
-
if ( 'top' == $which )
|
37 |
-
$this->view_switcher( $mode );
|
38 |
-
}
|
39 |
-
|
40 |
-
function no_items() {
|
41 |
-
_e( 'No Jobs.','backwpup');
|
42 |
-
}
|
43 |
-
|
44 |
-
function get_bulk_actions() {
|
45 |
-
$actions = array();
|
46 |
-
$actions['export'] = __( 'Export' );
|
47 |
-
$actions['delete'] = __( 'Delete' );
|
48 |
-
|
49 |
-
return $actions;
|
50 |
-
}
|
51 |
-
|
52 |
-
function get_columns() {
|
53 |
-
$jobs_columns = array();
|
54 |
-
$jobs_columns['cb'] = '<input type="checkbox" />';
|
55 |
-
$jobs_columns['id'] = __('ID','backwpup');
|
56 |
-
$jobs_columns['jobname'] = __('Job Name','backwpup');
|
57 |
-
$jobs_columns['type'] = __('Type','backwpup');
|
58 |
-
$jobs_columns['info'] = __('Information','backwpup');
|
59 |
-
$jobs_columns['next'] = __('Next Run','backwpup');
|
60 |
-
$jobs_columns['last'] = __('Last Run','backwpup');
|
61 |
-
return $jobs_columns;
|
62 |
-
}
|
63 |
-
|
64 |
-
function display_rows() {
|
65 |
-
//check for running job
|
66 |
-
$runningfile['JOBID']='';
|
67 |
-
$runningfile=backwpup_get_working_file();
|
68 |
-
$style = '';
|
69 |
-
foreach ( $this->items as $jobvalue ) {
|
70 |
-
$style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
|
71 |
-
echo "\n\t", $this->single_row( $jobvalue, $runningfile, $style );
|
72 |
-
}
|
73 |
-
}
|
74 |
-
|
75 |
-
function single_row($jobvalue, $runningfile, $style = '' ) {
|
76 |
-
global $mode;
|
77 |
-
|
78 |
-
list( $columns, $hidden, $sortable ) = $this->get_column_info();
|
79 |
-
$r = "<tr id=\"jodid-".$jobvalue["jobid"]."\"".$style.">";
|
80 |
-
foreach ( $columns as $column_name => $column_display_name ) {
|
81 |
-
$class = "class=\"$column_name column-$column_name\"";
|
82 |
-
|
83 |
-
$style = '';
|
84 |
-
if ( in_array( $column_name, $hidden ) )
|
85 |
-
$style = ' style="display:none;"';
|
86 |
-
|
87 |
-
$attributes = "$class$style";
|
88 |
-
|
89 |
-
switch( $column_name ) {
|
90 |
-
case 'cb':
|
91 |
-
$r .= '<th scope="row" class="check-column"><input type="checkbox" name="jobs[]" value="'. esc_attr($jobvalue["jobid"]) .'" /></th>';
|
92 |
-
break;
|
93 |
-
case 'id':
|
94 |
-
$r .= "<td $attributes>".$jobvalue["jobid"]."</td>";
|
95 |
-
break;
|
96 |
-
case 'jobname':
|
97 |
-
$r .= "<td $attributes><strong><a href=\"".wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupeditjob&jobid='.$jobvalue["jobid"], 'edit-job')."\" title=\"".__('Edit:','backwpup').esc_html($jobvalue['name'])."\">".esc_html($jobvalue['name'])."</a></strong>";
|
98 |
-
$actions = array();
|
99 |
-
if ($runningfile==false) {
|
100 |
-
$actions['edit'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupeditjob&jobid='.$jobvalue["jobid"], 'edit-job') . "\">" . __('Edit') . "</a>";
|
101 |
-
$actions['copy'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpup&action=copy&jobid='.$jobvalue["jobid"], 'copy-job_'.$jobvalue["jobid"]) . "\">" . __('Copy','backwpup') . "</a>";
|
102 |
-
$actions['export'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpup&action=export&jobs[]='.$jobvalue["jobid"], 'bulk-jobs') . "\">" . __('Export','backwpup') . "</a>";
|
103 |
-
$actions['delete'] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpup&action=delete&jobs[]='.$jobvalue["jobid"], 'bulk-jobs') . "\" onclick=\"return showNotice.warn();\">" . __('Delete') . "</a>";
|
104 |
-
$actions['runnow'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupworking&action=runnow&jobid='.$jobvalue["jobid"], 'runnow-job_'.$jobvalue["jobid"]) . "\">" . __('Run Now','backwpup') . "</a>";
|
105 |
-
} else {
|
106 |
-
if ($runningfile['JOBID']==$jobvalue["jobid"]) {
|
107 |
-
$actions['working'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupworking', '') . "\">" . __('View!','backwpup') . "</a>";
|
108 |
-
$actions['abort'] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpup&action=abort', 'abort-job') . "\">" . __('Abort!','backwpup') . "</a>";
|
109 |
-
}
|
110 |
-
}
|
111 |
-
$r .= $this->row_actions($actions);
|
112 |
-
$r .= '</td>';
|
113 |
-
break;
|
114 |
-
case 'type':
|
115 |
-
$r .= "<td $attributes>";
|
116 |
-
$r .= backwpup_backup_types($jobvalue['type'],false);
|
117 |
-
$r .= "</td>";
|
118 |
-
break;
|
119 |
-
case 'info':
|
120 |
-
$r .= "<td $attributes>";
|
121 |
-
$r .= "<img class=\"waiting\" src=\"".esc_url( backwpup_admin_url( 'images/wpspin_light.gif' ) )."\" id=\"image-wait-".$jobvalue["jobid"]."\" />";
|
122 |
-
$r .= "</td>";
|
123 |
-
break;
|
124 |
-
case 'next':
|
125 |
-
$r .= "<td $attributes>";
|
126 |
-
if ($runningfile['JOBID']==$jobvalue["jobid"] and $runningfile!=false) {
|
127 |
-
$runtime=time()-$jobvalue['starttime'];
|
128 |
-
$r .= __('Running since:','backwpup').' '.$runtime.' '.__('sec.','backwpup');
|
129 |
-
} elseif ($jobvalue['activated']) {
|
130 |
-
$r .= date_i18n(get_option('date_format').' @ '.get_option('time_format'),$jobvalue['cronnextrun']);
|
131 |
-
} else {
|
132 |
-
$r .= __('Inactive','backwpup');
|
133 |
-
}
|
134 |
-
if ( 'excerpt' == $mode ) {
|
135 |
-
$r .= '<br />'.__('<a href="http://wikipedia.org/wiki/Cron" target="_blank">Cron</a>:','backwpup').' '.$jobvalue['cron'];
|
136 |
-
}
|
137 |
-
$r .= "</td>";
|
138 |
-
break;
|
139 |
-
case 'last':
|
140 |
-
$r .= "<td $attributes>";
|
141 |
-
if (isset($jobvalue['lastrun']) && $jobvalue['lastrun']) {
|
142 |
-
$r .= backwpup_date_i18n(get_option('date_format').' @ '.get_option('time_format'),$jobvalue['lastrun']);
|
143 |
-
if (isset($jobvalue['lastruntime']))
|
144 |
-
$r .= '<br />'.__('Runtime:','backwpup').' '.$jobvalue['lastruntime'].' '.__('sec.','backwpup').'<br />';
|
145 |
-
} else {
|
146 |
-
$r .= __('None','backwpup');
|
147 |
-
}
|
148 |
-
if (!empty($jobvalue['lastbackupdownloadurl']))
|
149 |
-
$r .="<a href=\"" . wp_nonce_url($jobvalue['lastbackupdownloadurl'], 'download-backup') . "\" title=\"".__('Download last Backup','backwpup')."\">" . __('Download','backwpup') . "</a> | ";
|
150 |
-
if (!empty($jobvalue['logfile']))
|
151 |
-
$r .="<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupworking&logfile='.$jobvalue['logfile'], 'view-log_'.basename($jobvalue['logfile'])) . "\" title=\"".__('View last Log','backwpup')."\">" . __('Log','backwpup') . "</a><br />";
|
152 |
-
|
153 |
-
$r .= "</td>";
|
154 |
-
break;
|
155 |
-
}
|
156 |
-
}
|
157 |
-
$r .= '</tr>';
|
158 |
-
return $r;
|
159 |
-
}
|
160 |
-
}
|
161 |
-
|
162 |
-
|
163 |
-
//helper functions for detecting file size
|
164 |
-
function _backwpup_calc_file_size_file_list_folder( $folder = '', $levels = 100, $excludes=array(),$excludedirs=array()) {
|
165 |
-
global $backwpup_temp_files;
|
166 |
-
if ( !empty($folder) and $levels and $dir = @opendir( $folder )) {
|
167 |
-
while (($file = readdir( $dir ) ) !== false ) {
|
168 |
-
if ( in_array($file, array('.', '..','.svn') ) )
|
169 |
-
continue;
|
170 |
-
foreach ($excludes as $exclusion) { //exclude dirs and files
|
171 |
-
if (false !== stripos($folder.$file,$exclusion) and !empty($exclusion) and $exclusion!='/')
|
172 |
-
continue 2;
|
173 |
-
}
|
174 |
-
if ( @is_dir( $folder.$file )) {
|
175 |
-
if (!in_array(trailingslashit($folder.$file),$excludedirs))
|
176 |
-
_backwpup_calc_file_size_file_list_folder( trailingslashit($folder.$file), $levels - 1, $excludes);
|
177 |
-
} elseif ((@is_file( $folder.$file ) or @is_executable($folder.$file)) and @is_readable($folder.$file)) {
|
178 |
-
$backwpup_temp_files['num']++;
|
179 |
-
$backwpup_temp_files['size']=$backwpup_temp_files['size']+filesize($folder.$file);
|
180 |
-
}
|
181 |
-
}
|
182 |
-
@closedir( $dir );
|
183 |
-
}
|
184 |
-
}
|
185 |
-
|
186 |
-
//helper functions for detecting file size
|
187 |
-
function backwpup_calc_file_size($jobvalues) {
|
188 |
-
global $backwpup_temp_files;
|
189 |
-
$backwpup_temp_files=array('size'=>0,'num'=>0);
|
190 |
-
//Exclude Files
|
191 |
-
$backwpup_exclude=explode(',',trim($jobvalues['fileexclude']));
|
192 |
-
$backwpup_exclude[]='.tmp'; //do not backup .tmp files
|
193 |
-
$backwpup_exclude=array_unique($backwpup_exclude);
|
194 |
-
|
195 |
-
//File list for blog folders
|
196 |
-
if ($jobvalues['backuproot'])
|
197 |
-
_backwpup_calc_file_size_file_list_folder(trailingslashit(str_replace('\\','/',ABSPATH)),100,$backwpup_exclude,array_merge($jobvalues['backuprootexcludedirs'],backwpup_get_exclude_wp_dirs(ABSPATH)));
|
198 |
-
if ($jobvalues['backupcontent'])
|
199 |
-
_backwpup_calc_file_size_file_list_folder(trailingslashit(str_replace('\\','/',WP_CONTENT_DIR)),100,$backwpup_exclude,array_merge($jobvalues['backupcontentexcludedirs'],backwpup_get_exclude_wp_dirs(WP_CONTENT_DIR)));
|
200 |
-
if ($jobvalues['backupplugins'])
|
201 |
-
_backwpup_calc_file_size_file_list_folder(trailingslashit(str_replace('\\','/',WP_PLUGIN_DIR)),100,$backwpup_exclude,array_merge($jobvalues['backuppluginsexcludedirs'],backwpup_get_exclude_wp_dirs(WP_PLUGIN_DIR)));
|
202 |
-
if ($jobvalues['backupthemes'])
|
203 |
-
_backwpup_calc_file_size_file_list_folder(trailingslashit(trailingslashit(str_replace('\\','/',WP_CONTENT_DIR)).'themes'),100,$backwpup_exclude,array_merge($jobvalues['backupthemesexcludedirs'],backwpup_get_exclude_wp_dirs(trailingslashit(WP_CONTENT_DIR).'themes')));
|
204 |
-
if ($jobvalues['backupuploads'])
|
205 |
-
_backwpup_calc_file_size_file_list_folder(trailingslashit(str_replace('\\','/',backwpup_get_upload_dir())),100,$backwpup_exclude,array_merge($jobvalues['backupuploadsexcludedirs'],backwpup_get_exclude_wp_dirs(backwpup_get_upload_dir())));
|
206 |
-
|
207 |
-
//include dirs
|
208 |
-
if (!empty($jobvalues['dirinclude'])) {
|
209 |
-
$dirinclude=explode(',',$jobvalues['dirinclude']);
|
210 |
-
$dirinclude=array_unique($dirinclude);
|
211 |
-
//Crate file list for includes
|
212 |
-
foreach($dirinclude as $dirincludevalue) {
|
213 |
-
if (is_dir($dirincludevalue))
|
214 |
-
_backwpup_calc_file_size_file_list_folder(trailingslashit($dirincludevalue),100,$backwpup_exclude);
|
215 |
-
}
|
216 |
-
}
|
217 |
-
|
218 |
-
return $backwpup_temp_files;
|
219 |
-
|
220 |
-
}
|
221 |
-
|
222 |
-
//ajax show info div for jobs
|
223 |
-
function backwpup_show_info_td() {
|
224 |
-
check_ajax_referer('backwpup_ajax_nonce');
|
225 |
-
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
226 |
-
die('-1');
|
227 |
-
global $wpdb;
|
228 |
-
$mode=$_POST['mode'];
|
229 |
-
$jobvalue=backwpup_get_job_vars($_POST['jobid']);
|
230 |
-
if (in_array('DB',explode('+',$jobvalue['type'])) or in_array('OPTIMIZE',explode('+',$jobvalue['type'])) or in_array('CHECK',explode('+',$jobvalue['type']))) {
|
231 |
-
$dbsize=array('size'=>0,'num'=>0,'rows'=>0);
|
232 |
-
$status=$wpdb->get_results("SHOW TABLE STATUS FROM `".DB_NAME."`;", ARRAY_A);
|
233 |
-
foreach($status as $tablekey => $tablevalue) {
|
234 |
-
if (!in_array($tablevalue['Name'],$jobvalue['dbexclude'])) {
|
235 |
-
$dbsize['size']=$dbsize['size']+$tablevalue["Data_length"]+$tablevalue["Index_length"];
|
236 |
-
$dbsize['num']++;
|
237 |
-
$dbsize['rows']=$dbsize['rows']+$tablevalue["Rows"];
|
238 |
-
}
|
239 |
-
}
|
240 |
-
echo __("DB Size:","backwpup")." ".backwpup_formatBytes($dbsize['size'])."<br />";
|
241 |
-
if ( 'excerpt' == $mode ) {
|
242 |
-
echo __("DB Tables:","backwpup")." ".$dbsize['num']."<br />";
|
243 |
-
echo __("DB Rows:","backwpup")." ".$dbsize['rows']."<br />";
|
244 |
-
}
|
245 |
-
}
|
246 |
-
if (in_array('FILE',explode('+',$jobvalue['type']))) {
|
247 |
-
$files=backwpup_calc_file_size($jobvalue);
|
248 |
-
echo __("Files Size:","backwpup")." ".backwpup_formatBytes($files['size'])."<br />";
|
249 |
-
if ( 'excerpt' == $mode ) {
|
250 |
-
echo __("Files count:","backwpup")." ".$files['num']."<br />";
|
251 |
-
}
|
252 |
-
}
|
253 |
-
die();
|
254 |
-
}
|
255 |
-
//add ajax function
|
256 |
-
add_action('wp_ajax_backwpup_show_info_td', 'backwpup_show_info_td');
|
257 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
include_once( trailingslashit(ABSPATH).'wp-admin/includes/class-wp-list-table.php');
|
3 |
+
|
4 |
+
class BackWPup_Jobs_Table extends WP_List_Table {
|
5 |
+
|
6 |
+
function __construct() {
|
7 |
+
parent::__construct( array(
|
8 |
+
'plural' => 'jobs',
|
9 |
+
'singular' => 'job',
|
10 |
+
'ajax' => true
|
11 |
+
) );
|
12 |
+
}
|
13 |
+
|
14 |
+
function ajax_user_can() {
|
15 |
+
return current_user_can(BACKWPUP_USER_CAPABILITY);
|
16 |
+
}
|
17 |
+
|
18 |
+
function prepare_items() {
|
19 |
+
global $mode;
|
20 |
+
$jobs=get_option('backwpup_jobs');
|
21 |
+
if (!empty($jobs) and is_array($jobs)) {
|
22 |
+
foreach ($jobs as $key => $value) {
|
23 |
+
$this->items[]=backwpup_get_job_vars($key);
|
24 |
+
}
|
25 |
+
} else {
|
26 |
+
$this->items='';
|
27 |
+
}
|
28 |
+
$mode = empty( $_GET['mode'] ) ? 'list' : $_GET['mode'];
|
29 |
+
}
|
30 |
+
|
31 |
+
function pagination( $which ) {
|
32 |
+
global $mode;
|
33 |
+
|
34 |
+
parent::pagination( $which );
|
35 |
+
|
36 |
+
if ( 'top' == $which )
|
37 |
+
$this->view_switcher( $mode );
|
38 |
+
}
|
39 |
+
|
40 |
+
function no_items() {
|
41 |
+
_e( 'No Jobs.','backwpup');
|
42 |
+
}
|
43 |
+
|
44 |
+
function get_bulk_actions() {
|
45 |
+
$actions = array();
|
46 |
+
$actions['export'] = __( 'Export' );
|
47 |
+
$actions['delete'] = __( 'Delete' );
|
48 |
+
|
49 |
+
return $actions;
|
50 |
+
}
|
51 |
+
|
52 |
+
function get_columns() {
|
53 |
+
$jobs_columns = array();
|
54 |
+
$jobs_columns['cb'] = '<input type="checkbox" />';
|
55 |
+
$jobs_columns['id'] = __('ID','backwpup');
|
56 |
+
$jobs_columns['jobname'] = __('Job Name','backwpup');
|
57 |
+
$jobs_columns['type'] = __('Type','backwpup');
|
58 |
+
$jobs_columns['info'] = __('Information','backwpup');
|
59 |
+
$jobs_columns['next'] = __('Next Run','backwpup');
|
60 |
+
$jobs_columns['last'] = __('Last Run','backwpup');
|
61 |
+
return $jobs_columns;
|
62 |
+
}
|
63 |
+
|
64 |
+
function display_rows() {
|
65 |
+
//check for running job
|
66 |
+
$runningfile['JOBID']='';
|
67 |
+
$runningfile=backwpup_get_working_file();
|
68 |
+
$style = '';
|
69 |
+
foreach ( $this->items as $jobvalue ) {
|
70 |
+
$style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
|
71 |
+
echo "\n\t", $this->single_row( $jobvalue, $runningfile, $style );
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
function single_row($jobvalue, $runningfile, $style = '' ) {
|
76 |
+
global $mode;
|
77 |
+
|
78 |
+
list( $columns, $hidden, $sortable ) = $this->get_column_info();
|
79 |
+
$r = "<tr id=\"jodid-".$jobvalue["jobid"]."\"".$style.">";
|
80 |
+
foreach ( $columns as $column_name => $column_display_name ) {
|
81 |
+
$class = "class=\"$column_name column-$column_name\"";
|
82 |
+
|
83 |
+
$style = '';
|
84 |
+
if ( in_array( $column_name, $hidden ) )
|
85 |
+
$style = ' style="display:none;"';
|
86 |
+
|
87 |
+
$attributes = "$class$style";
|
88 |
+
|
89 |
+
switch( $column_name ) {
|
90 |
+
case 'cb':
|
91 |
+
$r .= '<th scope="row" class="check-column"><input type="checkbox" name="jobs[]" value="'. esc_attr($jobvalue["jobid"]) .'" /></th>';
|
92 |
+
break;
|
93 |
+
case 'id':
|
94 |
+
$r .= "<td $attributes>".$jobvalue["jobid"]."</td>";
|
95 |
+
break;
|
96 |
+
case 'jobname':
|
97 |
+
$r .= "<td $attributes><strong><a href=\"".wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupeditjob&jobid='.$jobvalue["jobid"], 'edit-job')."\" title=\"".__('Edit:','backwpup').esc_html($jobvalue['name'])."\">".esc_html($jobvalue['name'])."</a></strong>";
|
98 |
+
$actions = array();
|
99 |
+
if ($runningfile==false) {
|
100 |
+
$actions['edit'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupeditjob&jobid='.$jobvalue["jobid"], 'edit-job') . "\">" . __('Edit') . "</a>";
|
101 |
+
$actions['copy'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpup&action=copy&jobid='.$jobvalue["jobid"], 'copy-job_'.$jobvalue["jobid"]) . "\">" . __('Copy','backwpup') . "</a>";
|
102 |
+
$actions['export'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpup&action=export&jobs[]='.$jobvalue["jobid"], 'bulk-jobs') . "\">" . __('Export','backwpup') . "</a>";
|
103 |
+
$actions['delete'] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpup&action=delete&jobs[]='.$jobvalue["jobid"], 'bulk-jobs') . "\" onclick=\"return showNotice.warn();\">" . __('Delete') . "</a>";
|
104 |
+
$actions['runnow'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupworking&action=runnow&jobid='.$jobvalue["jobid"], 'runnow-job_'.$jobvalue["jobid"]) . "\">" . __('Run Now','backwpup') . "</a>";
|
105 |
+
} else {
|
106 |
+
if ($runningfile['JOBID']==$jobvalue["jobid"]) {
|
107 |
+
$actions['working'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupworking', '') . "\">" . __('View!','backwpup') . "</a>";
|
108 |
+
$actions['abort'] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpup&action=abort', 'abort-job') . "\">" . __('Abort!','backwpup') . "</a>";
|
109 |
+
}
|
110 |
+
}
|
111 |
+
$r .= $this->row_actions($actions);
|
112 |
+
$r .= '</td>';
|
113 |
+
break;
|
114 |
+
case 'type':
|
115 |
+
$r .= "<td $attributes>";
|
116 |
+
$r .= backwpup_backup_types($jobvalue['type'],false);
|
117 |
+
$r .= "</td>";
|
118 |
+
break;
|
119 |
+
case 'info':
|
120 |
+
$r .= "<td $attributes>";
|
121 |
+
$r .= "<img class=\"waiting\" src=\"".esc_url( backwpup_admin_url( 'images/wpspin_light.gif' ) )."\" id=\"image-wait-".$jobvalue["jobid"]."\" />";
|
122 |
+
$r .= "</td>";
|
123 |
+
break;
|
124 |
+
case 'next':
|
125 |
+
$r .= "<td $attributes>";
|
126 |
+
if ($runningfile['JOBID']==$jobvalue["jobid"] and $runningfile!=false) {
|
127 |
+
$runtime=time()-$jobvalue['starttime'];
|
128 |
+
$r .= __('Running since:','backwpup').' '.$runtime.' '.__('sec.','backwpup');
|
129 |
+
} elseif ($jobvalue['activated']) {
|
130 |
+
$r .= date_i18n(get_option('date_format').' @ '.get_option('time_format'),$jobvalue['cronnextrun']);
|
131 |
+
} else {
|
132 |
+
$r .= __('Inactive','backwpup');
|
133 |
+
}
|
134 |
+
if ( 'excerpt' == $mode ) {
|
135 |
+
$r .= '<br />'.__('<a href="http://wikipedia.org/wiki/Cron" target="_blank">Cron</a>:','backwpup').' '.$jobvalue['cron'];
|
136 |
+
}
|
137 |
+
$r .= "</td>";
|
138 |
+
break;
|
139 |
+
case 'last':
|
140 |
+
$r .= "<td $attributes>";
|
141 |
+
if (isset($jobvalue['lastrun']) && $jobvalue['lastrun']) {
|
142 |
+
$r .= backwpup_date_i18n(get_option('date_format').' @ '.get_option('time_format'),$jobvalue['lastrun']);
|
143 |
+
if (isset($jobvalue['lastruntime']))
|
144 |
+
$r .= '<br />'.__('Runtime:','backwpup').' '.$jobvalue['lastruntime'].' '.__('sec.','backwpup').'<br />';
|
145 |
+
} else {
|
146 |
+
$r .= __('None','backwpup');
|
147 |
+
}
|
148 |
+
if (!empty($jobvalue['lastbackupdownloadurl']))
|
149 |
+
$r .="<a href=\"" . wp_nonce_url($jobvalue['lastbackupdownloadurl'], 'download-backup') . "\" title=\"".__('Download last Backup','backwpup')."\">" . __('Download','backwpup') . "</a> | ";
|
150 |
+
if (!empty($jobvalue['logfile']))
|
151 |
+
$r .="<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupworking&logfile='.$jobvalue['logfile'], 'view-log_'.basename($jobvalue['logfile'])) . "\" title=\"".__('View last Log','backwpup')."\">" . __('Log','backwpup') . "</a><br />";
|
152 |
+
|
153 |
+
$r .= "</td>";
|
154 |
+
break;
|
155 |
+
}
|
156 |
+
}
|
157 |
+
$r .= '</tr>';
|
158 |
+
return $r;
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
|
163 |
+
//helper functions for detecting file size
|
164 |
+
function _backwpup_calc_file_size_file_list_folder( $folder = '', $levels = 100, $excludes=array(),$excludedirs=array()) {
|
165 |
+
global $backwpup_temp_files;
|
166 |
+
if ( !empty($folder) and $levels and $dir = @opendir( $folder )) {
|
167 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
168 |
+
if ( in_array($file, array('.', '..','.svn') ) )
|
169 |
+
continue;
|
170 |
+
foreach ($excludes as $exclusion) { //exclude dirs and files
|
171 |
+
if (false !== stripos($folder.$file,$exclusion) and !empty($exclusion) and $exclusion!='/')
|
172 |
+
continue 2;
|
173 |
+
}
|
174 |
+
if ( @is_dir( $folder.$file )) {
|
175 |
+
if (!in_array(trailingslashit($folder.$file),$excludedirs))
|
176 |
+
_backwpup_calc_file_size_file_list_folder( trailingslashit($folder.$file), $levels - 1, $excludes);
|
177 |
+
} elseif ((@is_file( $folder.$file ) or @is_executable($folder.$file)) and @is_readable($folder.$file)) {
|
178 |
+
$backwpup_temp_files['num']++;
|
179 |
+
$backwpup_temp_files['size']=$backwpup_temp_files['size']+filesize($folder.$file);
|
180 |
+
}
|
181 |
+
}
|
182 |
+
@closedir( $dir );
|
183 |
+
}
|
184 |
+
}
|
185 |
+
|
186 |
+
//helper functions for detecting file size
|
187 |
+
function backwpup_calc_file_size($jobvalues) {
|
188 |
+
global $backwpup_temp_files;
|
189 |
+
$backwpup_temp_files=array('size'=>0,'num'=>0);
|
190 |
+
//Exclude Files
|
191 |
+
$backwpup_exclude=explode(',',trim($jobvalues['fileexclude']));
|
192 |
+
$backwpup_exclude[]='.tmp'; //do not backup .tmp files
|
193 |
+
$backwpup_exclude=array_unique($backwpup_exclude);
|
194 |
+
|
195 |
+
//File list for blog folders
|
196 |
+
if ($jobvalues['backuproot'])
|
197 |
+
_backwpup_calc_file_size_file_list_folder(trailingslashit(str_replace('\\','/',ABSPATH)),100,$backwpup_exclude,array_merge($jobvalues['backuprootexcludedirs'],backwpup_get_exclude_wp_dirs(ABSPATH)));
|
198 |
+
if ($jobvalues['backupcontent'])
|
199 |
+
_backwpup_calc_file_size_file_list_folder(trailingslashit(str_replace('\\','/',WP_CONTENT_DIR)),100,$backwpup_exclude,array_merge($jobvalues['backupcontentexcludedirs'],backwpup_get_exclude_wp_dirs(WP_CONTENT_DIR)));
|
200 |
+
if ($jobvalues['backupplugins'])
|
201 |
+
_backwpup_calc_file_size_file_list_folder(trailingslashit(str_replace('\\','/',WP_PLUGIN_DIR)),100,$backwpup_exclude,array_merge($jobvalues['backuppluginsexcludedirs'],backwpup_get_exclude_wp_dirs(WP_PLUGIN_DIR)));
|
202 |
+
if ($jobvalues['backupthemes'])
|
203 |
+
_backwpup_calc_file_size_file_list_folder(trailingslashit(trailingslashit(str_replace('\\','/',WP_CONTENT_DIR)).'themes'),100,$backwpup_exclude,array_merge($jobvalues['backupthemesexcludedirs'],backwpup_get_exclude_wp_dirs(trailingslashit(WP_CONTENT_DIR).'themes')));
|
204 |
+
if ($jobvalues['backupuploads'])
|
205 |
+
_backwpup_calc_file_size_file_list_folder(trailingslashit(str_replace('\\','/',backwpup_get_upload_dir())),100,$backwpup_exclude,array_merge($jobvalues['backupuploadsexcludedirs'],backwpup_get_exclude_wp_dirs(backwpup_get_upload_dir())));
|
206 |
+
|
207 |
+
//include dirs
|
208 |
+
if (!empty($jobvalues['dirinclude'])) {
|
209 |
+
$dirinclude=explode(',',$jobvalues['dirinclude']);
|
210 |
+
$dirinclude=array_unique($dirinclude);
|
211 |
+
//Crate file list for includes
|
212 |
+
foreach($dirinclude as $dirincludevalue) {
|
213 |
+
if (is_dir($dirincludevalue))
|
214 |
+
_backwpup_calc_file_size_file_list_folder(trailingslashit($dirincludevalue),100,$backwpup_exclude);
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
return $backwpup_temp_files;
|
219 |
+
|
220 |
+
}
|
221 |
+
|
222 |
+
//ajax show info div for jobs
|
223 |
+
function backwpup_show_info_td() {
|
224 |
+
check_ajax_referer('backwpup_ajax_nonce');
|
225 |
+
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
226 |
+
die('-1');
|
227 |
+
global $wpdb;
|
228 |
+
$mode=$_POST['mode'];
|
229 |
+
$jobvalue=backwpup_get_job_vars($_POST['jobid']);
|
230 |
+
if (in_array('DB',explode('+',$jobvalue['type'])) or in_array('OPTIMIZE',explode('+',$jobvalue['type'])) or in_array('CHECK',explode('+',$jobvalue['type']))) {
|
231 |
+
$dbsize=array('size'=>0,'num'=>0,'rows'=>0);
|
232 |
+
$status=$wpdb->get_results("SHOW TABLE STATUS FROM `".DB_NAME."`;", ARRAY_A);
|
233 |
+
foreach($status as $tablekey => $tablevalue) {
|
234 |
+
if (!in_array($tablevalue['Name'],$jobvalue['dbexclude'])) {
|
235 |
+
$dbsize['size']=$dbsize['size']+$tablevalue["Data_length"]+$tablevalue["Index_length"];
|
236 |
+
$dbsize['num']++;
|
237 |
+
$dbsize['rows']=$dbsize['rows']+$tablevalue["Rows"];
|
238 |
+
}
|
239 |
+
}
|
240 |
+
echo __("DB Size:","backwpup")." ".backwpup_formatBytes($dbsize['size'])."<br />";
|
241 |
+
if ( 'excerpt' == $mode ) {
|
242 |
+
echo __("DB Tables:","backwpup")." ".$dbsize['num']."<br />";
|
243 |
+
echo __("DB Rows:","backwpup")." ".$dbsize['rows']."<br />";
|
244 |
+
}
|
245 |
+
}
|
246 |
+
if (in_array('FILE',explode('+',$jobvalue['type']))) {
|
247 |
+
$files=backwpup_calc_file_size($jobvalue);
|
248 |
+
echo __("Files Size:","backwpup")." ".backwpup_formatBytes($files['size'])."<br />";
|
249 |
+
if ( 'excerpt' == $mode ) {
|
250 |
+
echo __("Files count:","backwpup")." ".$files['num']."<br />";
|
251 |
+
}
|
252 |
+
}
|
253 |
+
die();
|
254 |
+
}
|
255 |
+
//add ajax function
|
256 |
+
add_action('wp_ajax_backwpup_show_info_td', 'backwpup_show_info_td');
|
|
pages/func_backwpupbackups.php
CHANGED
@@ -1,498 +1,495 @@
|
|
1 |
-
<?PHP
|
2 |
-
include_once( trailingslashit(ABSPATH).'wp-admin/includes/class-wp-list-table.php');
|
3 |
-
|
4 |
-
class BackWPup_Backups_Table extends WP_List_Table {
|
5 |
-
|
6 |
-
private $jobid=1;
|
7 |
-
private $dest='FOLDER';
|
8 |
-
|
9 |
-
function __construct() {
|
10 |
-
parent::__construct( array(
|
11 |
-
'plural' => 'backups',
|
12 |
-
'singular' => 'backup',
|
13 |
-
'ajax' => true
|
14 |
-
) );
|
15 |
-
}
|
16 |
-
|
17 |
-
function ajax_user_can() {
|
18 |
-
return current_user_can(BACKWPUP_USER_CAPABILITY);
|
19 |
-
}
|
20 |
-
|
21 |
-
function prepare_items() {
|
22 |
-
|
23 |
-
$per_page = $this->get_items_per_page('backwpupbackups_per_page');
|
24 |
-
if ( empty( $per_page ) || $per_page < 1 )
|
25 |
-
$per_page = 20;
|
26 |
-
|
27 |
-
if (isset($_GET['jobdest'])) {
|
28 |
-
$jobdest=$_GET['jobdest'];
|
29 |
-
} else {
|
30 |
-
$jobdests=$this->get_dest_list();
|
31 |
-
if (empty($jobdests))
|
32 |
-
$jobdests=array(',');
|
33 |
-
$jobdest=$jobdests[0];
|
34 |
-
$_GET['jobdest']=$jobdests[0];
|
35 |
-
}
|
36 |
-
|
37 |
-
list($this->jobid,$this->dest)=explode(',',$jobdest);
|
38 |
-
|
39 |
-
if (false === ($backups=get_transient('backwpup_backups_chache'))) { //create new list
|
40 |
-
$backups=backwpup_get_backup_files($this->jobid,$this->dest);
|
41 |
-
set_transient('backwpup_backups_chache',$backups,300);
|
42 |
-
}
|
43 |
-
|
44 |
-
if (!$backups or $this->dest!=$backups[0]['DEST'] or $this->jobid!=$backups[0]['JOBID']) {
|
45 |
-
$backups=backwpup_get_backup_files($this->jobid,$this->dest);
|
46 |
-
set_transient('backwpup_backups_chache',$backups,300);
|
47 |
-
}
|
48 |
-
|
49 |
-
//if no itmes brake
|
50 |
-
if (empty($backups)) {
|
51 |
-
$this->items='';
|
52 |
-
return;
|
53 |
-
}
|
54 |
-
|
55 |
-
//Sorting
|
56 |
-
$order=isset($_GET['order']) ? $_GET['order'] : 'desc';
|
57 |
-
$orderby=isset($_GET['orderby']) ? $_GET['orderby'] : 'time';
|
58 |
-
$tmp = Array();
|
59 |
-
if ($orderby=='time') {
|
60 |
-
if ($order=='asc') {
|
61 |
-
foreach($backups as &$ma)
|
62 |
-
$tmp[] = &$ma["time"];
|
63 |
-
array_multisort($tmp, SORT_ASC, $backups);
|
64 |
-
} else {
|
65 |
-
foreach($backups as &$ma)
|
66 |
-
$tmp[] = &$ma["time"];
|
67 |
-
array_multisort($tmp, SORT_DESC, $backups);
|
68 |
-
}
|
69 |
-
}
|
70 |
-
elseif ($orderby=='file') {
|
71 |
-
if ($order=='asc') {
|
72 |
-
foreach($backups as &$ma)
|
73 |
-
$tmp[] = &$ma["filename"];
|
74 |
-
array_multisort($tmp, SORT_ASC, $backups);
|
75 |
-
} else {
|
76 |
-
foreach($backups as &$ma)
|
77 |
-
$tmp[] = &$ma["filename"];
|
78 |
-
array_multisort($tmp, SORT_DESC, $backups);
|
79 |
-
}
|
80 |
-
}
|
81 |
-
elseif ($orderby=='folder') {
|
82 |
-
if ($order=='asc') {
|
83 |
-
foreach($backups as &$ma)
|
84 |
-
$tmp[] = &$ma["folder"];
|
85 |
-
array_multisort($tmp, SORT_ASC, $backups);
|
86 |
-
} else {
|
87 |
-
foreach($backups as &$ma)
|
88 |
-
$tmp[] = &$ma["folder"];
|
89 |
-
array_multisort($tmp, SORT_DESC, $backups);
|
90 |
-
}
|
91 |
-
}
|
92 |
-
elseif ($orderby=='size') {
|
93 |
-
if ($order=='asc') {
|
94 |
-
foreach($backups as &$ma)
|
95 |
-
$tmp[] = &$ma["filesize"];
|
96 |
-
array_multisort($tmp, SORT_ASC, $backups);
|
97 |
-
} else {
|
98 |
-
foreach($backups as &$ma)
|
99 |
-
$tmp[] = &$ma["filesize"];
|
100 |
-
array_multisort($tmp, SORT_DESC, $backups);
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
//by page
|
105 |
-
$start=intval( ( $this->get_pagenum() - 1 ) * $per_page );
|
106 |
-
$end=$start+$per_page;
|
107 |
-
if ($end>count($backups))
|
108 |
-
$end=count($backups);
|
109 |
-
|
110 |
-
$this->items=array();
|
111 |
-
for ($i=$start;$i<$end;$i++)
|
112 |
-
$this->items[]=$backups[$i];
|
113 |
-
|
114 |
-
$this->set_pagination_args( array(
|
115 |
-
'total_items' => count($backups),
|
116 |
-
'per_page' => $per_page,
|
117 |
-
'jobdest' => $jobdest,
|
118 |
-
'orderby' => $orderby,
|
119 |
-
'order' => $order
|
120 |
-
) );
|
121 |
-
|
122 |
-
}
|
123 |
-
|
124 |
-
function no_items() {
|
125 |
-
_e( 'No Files found.','backwpup');
|
126 |
-
}
|
127 |
-
|
128 |
-
function get_bulk_actions() {
|
129 |
-
$actions = array();
|
130 |
-
$actions['delete'] = __( 'Delete' );
|
131 |
-
return $actions;
|
132 |
-
}
|
133 |
-
|
134 |
-
function extra_tablenav( $which ) {
|
135 |
-
if ( 'top' != $which )
|
136 |
-
return;
|
137 |
-
$jobs=get_option('backwpup_jobs');
|
138 |
-
echo '<div class="alignleft actions">';
|
139 |
-
echo "<select name=\"jobdest\" id=\"jobdest\" class=\"postform\">\n";
|
140 |
-
foreach ($this->get_dest_list() as $jobdest) {
|
141 |
-
list($jobid,$dest)=explode(',',$jobdest);
|
142 |
-
echo "\t<option value=\"".$jobdest."\" ".selected($this->jobid.','.$this->dest,$jobdest).">".$dest.": ".esc_html($jobs[$jobid]['name'])."</option>\n";
|
143 |
-
}
|
144 |
-
echo "</select>\n";
|
145 |
-
submit_button( __('Change Destination','backwpup'), 'secondary', '', false, array( 'id' => 'post-query-submit' ) );
|
146 |
-
echo '</div>';
|
147 |
-
}
|
148 |
-
|
149 |
-
function get_dest_list() {
|
150 |
-
$jobdest=array();
|
151 |
-
$jobs=get_option('backwpup_jobs');
|
152 |
-
if (!empty($jobs) and is_array($jobs)) {
|
153 |
-
foreach ($jobs as $jobid => $jobvalue) {
|
154 |
-
if (!empty($jobvalue['backupdir']) and is_dir($jobvalue['backupdir']))
|
155 |
-
$jobdest[]=$jobid.',FOLDER';
|
156 |
-
foreach (explode(',',strtoupper(BACKWPUP_DESTS)) as $dest) {
|
157 |
-
$dest=strtoupper($dest);
|
158 |
-
if ($dest=='S3' and !empty($jobvalue['awsAccessKey']) and !empty($jobvalue['awsSecretKey']) and !empty($jobvalue['awsBucket']))
|
159 |
-
$jobdest[]=$jobid.','.$dest;
|
160 |
-
if ($dest=='GSTORAGE' and !empty($jobvalue['GStorageAccessKey']) and !empty($jobvalue['GStorageSecret']) and !empty($jobvalue['GStorageBucket']))
|
161 |
-
$jobdest[]=$jobid.','.$dest;
|
162 |
-
if ($dest=='DROPBOX' and !empty($jobvalue['dropetoken']) and !empty($jobvalue['dropesecret']))
|
163 |
-
$jobdest[]=$jobid.','.$dest;
|
164 |
-
if ($dest=='RSC' and !empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey']) and !empty($jobvalue['rscContainer']))
|
165 |
-
$jobdest[]=$jobid.','.$dest;
|
166 |
-
if ($dest=='FTP' and !empty($jobvalue['ftphost']) and function_exists('ftp_connect') and !empty($jobvalue['ftpuser']) and !empty($jobvalue['ftppass']))
|
167 |
-
$jobdest[]=$jobid.','.$dest;
|
168 |
-
if ($dest=='MSAZURE' and !empty($jobvalue['msazureHost']) and !empty($jobvalue['msazureAccName']) and !empty($jobvalue['msazureKey']) and !empty($jobvalue['msazureContainer']))
|
169 |
-
$jobdest[]=$jobid.','.$dest;
|
170 |
-
if ($dest=='SUGARSYNC' and !empty($jobvalue['sugarpass']) and !empty($jobvalue['sugarpass']))
|
171 |
-
$jobdest[]=$jobid.','.$dest;
|
172 |
-
}
|
173 |
-
|
174 |
-
}
|
175 |
-
}
|
176 |
-
return $jobdest;
|
177 |
-
}
|
178 |
-
|
179 |
-
function get_columns() {
|
180 |
-
$posts_columns = array();
|
181 |
-
$posts_columns['cb'] = '<input type="checkbox" />';
|
182 |
-
$posts_columns['file'] = __('File','backwpup');
|
183 |
-
$posts_columns['folder'] = __('Folder','backwpup');
|
184 |
-
$posts_columns['size'] = __('Size','backwpup');
|
185 |
-
$posts_columns['folder'] = __('Folder','backwpup');
|
186 |
-
$posts_columns['time'] = __('Time','backwpup');
|
187 |
-
return $posts_columns;
|
188 |
-
}
|
189 |
-
|
190 |
-
function get_sortable_columns() {
|
191 |
-
return array(
|
192 |
-
'file' => array('file',false),
|
193 |
-
'folder' => 'folder',
|
194 |
-
'size' => 'size',
|
195 |
-
'time' => array('time',false)
|
196 |
-
);
|
197 |
-
}
|
198 |
-
|
199 |
-
function display_rows() {
|
200 |
-
$style = '';
|
201 |
-
$jobs=get_option('backwpup_jobs'); //Load jobs
|
202 |
-
foreach ( $this->items as $backup ) {
|
203 |
-
$style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
|
204 |
-
echo "\n\t", $this->single_row( $backup, $jobs[$this->jobid], $style );
|
205 |
-
}
|
206 |
-
}
|
207 |
-
|
208 |
-
function single_row( $backup, $jobvalue, $style = '' ) {
|
209 |
-
list( $columns, $hidden, $sortable ) = $this->get_column_info();
|
210 |
-
$r = "<tr $style>";
|
211 |
-
foreach ( $columns as $column_name => $column_display_name ) {
|
212 |
-
$class = "class=\"$column_name column-$column_name\"";
|
213 |
-
|
214 |
-
$style = '';
|
215 |
-
if ( in_array( $column_name, $hidden ) )
|
216 |
-
$style = ' style="display:none;"';
|
217 |
-
|
218 |
-
$attributes = "$class$style";
|
219 |
-
|
220 |
-
switch($column_name) {
|
221 |
-
case 'cb':
|
222 |
-
$r .= '<th scope="row" class="check-column"><input type="checkbox" name="backupfiles[]" value="'. esc_attr($backup['file']) .'" /></th>';
|
223 |
-
break;
|
224 |
-
case 'file':
|
225 |
-
$r .= "<td $attributes><strong>".$backup['filename']."</strong>";
|
226 |
-
$actions = array();
|
227 |
-
$actions['delete'] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupbackups&action=delete&jobdest='.$this->jobid.','.$this->dest.'&paged='.$this->get_pagenum().'&backupfiles[]='.esc_attr($backup['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') . "</a>";
|
228 |
-
$actions['download'] = "<a href=\"" . wp_nonce_url($backup['downloadurl'], 'download-backup') . "\">" . __('Download','backwpup') . "</a>";
|
229 |
-
$r .= $this->row_actions($actions);
|
230 |
-
$r .= "</td>";
|
231 |
-
break;
|
232 |
-
case 'folder':
|
233 |
-
$r .= "<td $attributes>";
|
234 |
-
$r .= $backup['folder'];
|
235 |
-
$r .= "</td>";
|
236 |
-
break;
|
237 |
-
case 'size':
|
238 |
-
$r .= "<td $attributes>";
|
239 |
-
if (!empty($backup['filesize']) and $backup['filesize']!=-1) {
|
240 |
-
$r .= backwpup_formatBytes($backup['filesize']);
|
241 |
-
} else {
|
242 |
-
$r .= __('?','backwpup');
|
243 |
-
}
|
244 |
-
$r .= "</td>";
|
245 |
-
break;
|
246 |
-
case 'time':
|
247 |
-
$r .= "<td $attributes>";
|
248 |
-
$r .= backwpup_date_i18n(get_option('date_format'),$backup['time']).'<br />'. backwpup_date_i18n(get_option('time_format'),$backup['time']);
|
249 |
-
$r .= "</td>";
|
250 |
-
break;
|
251 |
-
}
|
252 |
-
}
|
253 |
-
$r .= '</tr>';
|
254 |
-
return $r;
|
255 |
-
}
|
256 |
-
}
|
257 |
-
|
258 |
-
|
259 |
-
//get backup files and infos
|
260 |
-
function backwpup_get_backup_files($jobid,$dest) {
|
261 |
-
global $backwpup_message;
|
262 |
-
if (empty($jobid) or (!in_array(strtoupper($dest),explode(',',strtoupper(BACKWPUP_DESTS))) and $dest!='FOLDER'))
|
263 |
-
return false;
|
264 |
-
$jobs=get_option('backwpup_jobs'); //Load jobs
|
265 |
-
$jobvalue=$jobs[$jobid];
|
266 |
-
$filecounter=0;
|
267 |
-
$files=array();
|
268 |
-
//Get files/filinfo in backup folder
|
269 |
-
if ($dest=='FOLDER' and !empty($jobvalue['backupdir']) and is_dir($jobvalue['backupdir'])) {
|
270 |
-
if ( $dir = opendir( $jobvalue['backupdir'] ) ) {
|
271 |
-
while (($file = readdir( $dir ) ) !== false ) {
|
272 |
-
if (substr($file,0,1)=='.')
|
273 |
-
continue;
|
274 |
-
if (is_file($jobvalue['backupdir'].$file)) {
|
275 |
-
$files[$filecounter]['JOBID']=$jobid;
|
276 |
-
$files[$filecounter]['DEST']=$dest;
|
277 |
-
$files[$filecounter]['folder']=$jobvalue['backupdir'];
|
278 |
-
$files[$filecounter]['file']=$jobvalue['backupdir'].$file;
|
279 |
-
$files[$filecounter]['filename']=$file;
|
280 |
-
$files[$filecounter]['downloadurl']=backwpup_admin_url('admin.php').'?page=backwpupbackups&action=download&file='.$jobvalue['backupdir'].$file;
|
281 |
-
$files[$filecounter]['filesize']=filesize($jobvalue['backupdir'].$file);
|
282 |
-
$files[$filecounter]['time']=filemtime($jobvalue['backupdir'].$file);
|
283 |
-
$filecounter++;
|
284 |
-
}
|
285 |
-
}
|
286 |
-
closedir( $dir );
|
287 |
-
}
|
288 |
-
}
|
289 |
-
//Get files/filinfo from Dropbox
|
290 |
-
if ($dest=='DROPBOX' and !empty($jobvalue['dropetoken']) and !empty($jobvalue['dropesecret'])) {
|
291 |
-
require_once(realpath(dirname(__FILE__).'/../libs/dropbox.php'));
|
292 |
-
try {
|
293 |
-
$dropbox = new backwpup_Dropbox(BACKWPUP_DROPBOX_APP_KEY, BACKWPUP_DROPBOX_APP_SECRET,'dropbox');
|
294 |
-
$dropbox->setOAuthTokens($jobvalue['dropetoken'],$jobvalue['dropesecret']);
|
295 |
-
$contents = $dropbox->metadata($jobvalue['dropedir']);
|
296 |
-
if (is_array($contents)) {
|
297 |
-
foreach ($contents['contents'] as $object) {
|
298 |
-
if ($object['is_dir']!=true) {
|
299 |
-
$files[$filecounter]['JOBID']=$jobid;
|
300 |
-
$files[$filecounter]['DEST']=$dest;
|
301 |
-
$files[$filecounter]['folder']="https://api-content.dropbox.com/1/files/".$jobvalue['droperoot']."/".dirname($object['path'])."/";
|
302 |
-
$files[$filecounter]['file']=$object['path'];
|
303 |
-
$files[$filecounter]['filename']=basename($object['path']);
|
304 |
-
$files[$filecounter]['downloadurl']=backwpup_admin_url('admin.php').'?page=backwpupbackups&action=downloaddropbox&file='.$object['path'].'&jobid='.$jobid;
|
305 |
-
$files[$filecounter]['filesize']=$object['bytes'];
|
306 |
-
$files[$filecounter]['time']=strtotime($object['modified']);
|
307 |
-
$filecounter++;
|
308 |
-
}
|
309 |
-
}
|
310 |
-
}
|
311 |
-
} catch (Exception $e) {
|
312 |
-
$backwpup_message.='DROPBOX: '.$e->getMessage().'<br />';
|
313 |
-
}
|
314 |
-
}
|
315 |
-
//Get files/filinfo from Sugarsync
|
316 |
-
if ($dest=='SUGARSYNC' and !empty($jobvalue['sugarpass']) and !empty($jobvalue['sugarpass'])) {
|
317 |
-
if (!class_exists('SugarSync'))
|
318 |
-
require_once (dirname(__FILE__).'/../libs/sugarsync.php');
|
319 |
-
if (class_exists('SugarSync')) {
|
320 |
-
try {
|
321 |
-
$sugarsync = new SugarSync($jobvalue['sugaruser'],base64_decode($jobvalue['sugarpass']),BACKWPUP_SUGARSYNC_ACCESSKEY, BACKWPUP_SUGARSYNC_PRIVATEACCESSKEY);
|
322 |
-
$dirid=$sugarsync->chdir($jobvalue['sugardir'],$jobvalue['sugarroot']);
|
323 |
-
$user=$sugarsync->user();
|
324 |
-
$dir=$sugarsync->showdir($dirid);
|
325 |
-
$getfiles=$sugarsync->getcontents('file');
|
326 |
-
if (is_object($getfiles)) {
|
327 |
-
foreach ($getfiles->file as $getfile) {
|
328 |
-
$files[$filecounter]['JOBID']=$jobid;
|
329 |
-
$files[$filecounter]['DEST']=$dest;
|
330 |
-
$files[$filecounter]['folder']='https://'.$user->nickname.'.sugarsync.com/'.$dir;
|
331 |
-
$files[$filecounter]['file']=(string)$getfile->ref;
|
332 |
-
$files[$filecounter]['filename']=utf8_decode((string) $getfile->displayName);
|
333 |
-
$files[$filecounter]['downloadurl']=backwpup_admin_url('admin.php').'?page=backwpupbackups&action=downloadsugarsync&file='.(string) $getfile->ref.'&jobid='.$jobid;
|
334 |
-
$files[$filecounter]['filesize']=(int) $getfile->size;
|
335 |
-
$files[$filecounter]['time']=strtotime((string) $getfile->lastModified);
|
336 |
-
$filecounter++;
|
337 |
-
}
|
338 |
-
}
|
339 |
-
} catch (Exception $e) {
|
340 |
-
$backwpup_message.='SUGARSYNC: '.$e->getMessage().'<br />';
|
341 |
-
}
|
342 |
-
}
|
343 |
-
}
|
344 |
-
//Get files/filinfo from S3
|
345 |
-
if ($dest=='S3' and !empty($jobvalue['awsAccessKey']) and !empty($jobvalue['awsSecretKey']) and !empty($jobvalue['awsBucket'])) {
|
346 |
-
if (!class_exists('AmazonS3'))
|
347 |
-
require_once(dirname(__FILE__).'/../libs/aws/sdk.class.php');
|
348 |
-
if (class_exists('AmazonS3')) {
|
349 |
-
try {
|
350 |
-
$s3 = new AmazonS3(array('key'=>$jobvalue['awsAccessKey'],'secret'=>$jobvalue['awsSecretKey'],'certificate_authority'=> true ));
|
351 |
-
if (($contents = $s3->list_objects($jobvalue['awsBucket'],array('prefix'=>$jobvalue['awsdir']))) !== false) {
|
352 |
-
foreach ($contents->body->Contents as $object) {
|
353 |
-
$files[$filecounter]['JOBID']=$jobid;
|
354 |
-
$files[$filecounter]['DEST']=$dest;
|
355 |
-
$files[$filecounter]['folder']="https://".$jobvalue['awsBucket'].".s3.amazonaws.com/".dirname((string)$object->Key).'/';
|
356 |
-
$files[$filecounter]['file']=(string)$object->Key;
|
357 |
-
$files[$filecounter]['filename']=basename($object->Key);
|
358 |
-
$files[$filecounter]['downloadurl']=backwpup_admin_url('admin.php').'?page=backwpupbackups&action=downloads3&file='.$object->Key.'&jobid='.$jobid;
|
359 |
-
$files[$filecounter]['filesize']=(string)$object->Size;
|
360 |
-
$files[$filecounter]['time']=strtotime($object->LastModified);
|
361 |
-
$filecounter++;
|
362 |
-
}
|
363 |
-
}
|
364 |
-
} catch (Exception $e) {
|
365 |
-
$backwpup_message.='Amazon S3: '.$e->getMessage().'<br />';
|
366 |
-
}
|
367 |
-
}
|
368 |
-
}
|
369 |
-
//Get files/filinfo from Google Storage
|
370 |
-
if ($dest=='GSTORAGE' and !empty($jobvalue['GStorageAccessKey']) and !empty($jobvalue['GStorageSecret']) and !empty($jobvalue['GStorageBucket'])) {
|
371 |
-
if (!class_exists('AmazonS3'))
|
372 |
-
require_once(dirname(__FILE__).'/../libs/aws/sdk.class.php');
|
373 |
-
if (class_exists('AmazonS3')) {
|
374 |
-
try {
|
375 |
-
$gstorage = new AmazonS3(array('key'=>$jobvalue['GStorageAccessKey'],'secret'=>$jobvalue['GStorageSecret'],'certificate_authority'=> true ));
|
376 |
-
$gstorage->set_hostname('commondatastorage.googleapis.com');
|
377 |
-
$gstorage->allow_hostname_override(false);
|
378 |
-
if (($contents = $gstorage->list_objects($jobvalue['GStorageBucket'],array('prefix'=>$jobvalue['GStoragedir']))) !== false) {
|
379 |
-
foreach ($contents->body->Contents as $object) {
|
380 |
-
$files[$filecounter]['JOBID']=$jobid;
|
381 |
-
$files[$filecounter]['DEST']=$dest;
|
382 |
-
$files[$filecounter]['folder']="https://
|
383 |
-
$files[$filecounter]['file']=(string)$object->Key;
|
384 |
-
$files[$filecounter]['filename']=basename($object->Key);
|
385 |
-
$files[$filecounter]['downloadurl']="https://
|
386 |
-
$files[$filecounter]['filesize']=(string)$object->Size;
|
387 |
-
$files[$filecounter]['time']=strtotime($object->LastModified);
|
388 |
-
$filecounter++;
|
389 |
-
}
|
390 |
-
}
|
391 |
-
} catch (Exception $e) {
|
392 |
-
$backwpup_message.=sprintf(__('GStorage API: %s','backwpup'),$e->getMessage()).'<br />';
|
393 |
-
}
|
394 |
-
}
|
395 |
-
}
|
396 |
-
//Get files/filinfo from Microsoft Azure
|
397 |
-
if ($dest=='MSAZURE' and !empty($jobvalue['msazureHost']) and !empty($jobvalue['msazureAccName']) and !empty($jobvalue['msazureKey']) and !empty($jobvalue['msazureContainer'])) {
|
398 |
-
if (!class_exists('Microsoft_WindowsAzure_Storage_Blob'))
|
399 |
-
require_once(dirname(__FILE__).'/../libs/Microsoft/WindowsAzure/Storage/Blob.php');
|
400 |
-
if (class_exists('Microsoft_WindowsAzure_Storage_Blob')) {
|
401 |
-
try {
|
402 |
-
$storageClient = new Microsoft_WindowsAzure_Storage_Blob($jobvalue['msazureHost'],$jobvalue['msazureAccName'],$jobvalue['msazureKey']);
|
403 |
-
$blobs = $storageClient->listBlobs($jobvalue['msazureContainer'],$jobvalue['msazuredir']);
|
404 |
-
if (is_array($blobs)) {
|
405 |
-
foreach ($blobs as $blob) {
|
406 |
-
$files[$filecounter]['JOBID']=$jobid;
|
407 |
-
$files[$filecounter]['DEST']=$dest;
|
408 |
-
$files[$filecounter]['folder']="https://".$jobvalue['msazureAccName'].'.'.$jobvalue['msazureHost']."/".$jobvalue['msazureContainer']."/".dirname($blob->Name)."/";
|
409 |
-
$files[$filecounter]['file']=$blob->Name;
|
410 |
-
$files[$filecounter]['filename']=basename($blob->Name);
|
411 |
-
$files[$filecounter]['downloadurl']=backwpup_admin_url('admin.php').'?page=backwpupbackups&action=downloadmsazure&file='.$blob->Name.'&jobid='.$jobid;
|
412 |
-
$files[$filecounter]['filesize']=$blob->size;
|
413 |
-
$files[$filecounter]['time']=strtotime($blob->lastmodified);
|
414 |
-
$filecounter++;
|
415 |
-
}
|
416 |
-
}
|
417 |
-
} catch (Exception $e) {
|
418 |
-
$backwpup_message.='MSAZURE: '.$e->getMessage().'<br />';
|
419 |
-
}
|
420 |
-
}
|
421 |
-
}
|
422 |
-
//Get files/filinfo from RSC
|
423 |
-
if ($dest=='RSC' and !empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey']) and !empty($jobvalue['rscContainer'])) {
|
424 |
-
if (!class_exists('CF_Authentication'))
|
425 |
-
require_once(dirname(__FILE__).'/../libs/rackspace/cloudfiles.php');
|
426 |
-
if (class_exists('CF_Authentication') ) {
|
427 |
-
try {
|
428 |
-
$auth = new CF_Authentication($jobvalue['rscUsername'], $jobvalue['rscAPIKey']);
|
429 |
-
$auth->ssl_use_cabundle();
|
430 |
-
if ($auth->authenticate()) {
|
431 |
-
$conn = new CF_Connection($auth);
|
432 |
-
$conn->ssl_use_cabundle();
|
433 |
-
$backwpupcontainer = $conn->get_container($jobvalue['rscContainer']);
|
434 |
-
$contents = $backwpupcontainer->get_objects(0,NULL,NULL,$jobvalue['rscdir']);
|
435 |
-
foreach ($contents as $object) {
|
436 |
-
$files[$filecounter]['JOBID']=$jobid;
|
437 |
-
$files[$filecounter]['DEST']=$dest;
|
438 |
-
$files[$filecounter]['folder']="RSC://".$jobvalue['rscContainer']."/".dirname($object->name)."/";
|
439 |
-
$files[$filecounter]['file']=$object->name;
|
440 |
-
$files[$filecounter]['filename']=basename($object->name);
|
441 |
-
$files[$filecounter]['downloadurl']=backwpup_admin_url('admin.php').'?page=backwpupbackups&action=downloadrsc&file='.$object->name.'&jobid='.$jobid;
|
442 |
-
$files[$filecounter]['filesize']=$object->content_length;
|
443 |
-
$files[$filecounter]['time']=strtotime($object->last_modified);
|
444 |
-
$filecounter++;
|
445 |
-
}
|
446 |
-
}
|
447 |
-
} catch (Exception $e) {
|
448 |
-
$backwpup_message.='RSC: '.$e->getMessage().'<br />';
|
449 |
-
}
|
450 |
-
}
|
451 |
-
}
|
452 |
-
//Get files/filinfo from FTP
|
453 |
-
if ($dest=='FTP' and !empty($jobvalue['ftphost']) and function_exists('ftp_connect') and !empty($jobvalue['ftpuser']) and !empty($jobvalue['ftppass'])) {
|
454 |
-
|
455 |
-
if (function_exists('ftp_ssl_connect') and $jobvalue['ftpssl']) { //make SSL FTP connection
|
456 |
-
$ftp_conn_id = ftp_ssl_connect($jobvalue['ftphost'],$jobvalue['ftphostport'],10);
|
457 |
-
} elseif (!$jobvalue['ftpssl']) { //make normal FTP conection if SSL not work
|
458 |
-
$ftp_conn_id = ftp_connect($jobvalue['ftphost'],$jobvalue['ftphostport'],10);
|
459 |
-
}
|
460 |
-
$loginok=false;
|
461 |
-
if ($ftp_conn_id) {
|
462 |
-
//FTP Login
|
463 |
-
if (@ftp_login($ftp_conn_id, $jobvalue['ftpuser'], base64_decode($jobvalue['ftppass']))) {
|
464 |
-
$loginok=true;
|
465 |
-
} else { //if PHP ftp login don't work use raw login
|
466 |
-
ftp_raw($ftp_conn_id,'USER '.$jobvalue['ftpuser']);
|
467 |
-
$return=ftp_raw($ftp_conn_id,'PASS '.base64_decode($jobvalue['ftppass']));
|
468 |
-
if (substr(trim($return[0]),0,3)<=400)
|
469 |
-
$loginok=true;
|
470 |
-
}
|
471 |
-
}
|
472 |
-
if ($loginok) {
|
473 |
-
ftp_pasv($ftp_conn_id, $jobvalue['ftppasv']);
|
474 |
-
if ($ftpfilelist=ftp_nlist($ftp_conn_id, $jobvalue['ftpdir'])) {
|
475 |
-
foreach($ftpfilelist as $ftpfiles) {
|
476 |
-
if (substr(basename($ftpfiles),0,1)=='.')
|
477 |
-
continue;
|
478 |
-
$files[$filecounter]['JOBID']=$jobid;
|
479 |
-
$files[$filecounter]['DEST']=$dest;
|
480 |
-
|
481 |
-
$files[$filecounter]['file']=$ftpfiles;
|
482 |
-
$files[$filecounter]['filename']=basename($ftpfiles);
|
483 |
-
|
484 |
-
$files[$filecounter]['filesize']=ftp_size($ftp_conn_id,$ftpfiles);
|
485 |
-
$files[$filecounter]['time']=ftp_mdtm($ftp_conn_id,$ftpfiles);
|
486 |
-
$filecounter++;
|
487 |
-
}
|
488 |
-
}
|
489 |
-
} else {
|
490 |
-
$backwpup_message.='FTP: '.__('Login failure!','backwpup').'<br />';
|
491 |
-
}
|
492 |
-
$donefolders[]=$jobvalue['ftphost'].'|'.$jobvalue['ftpuser'].'|'.$jobvalue['ftpdir'];
|
493 |
-
}
|
494 |
-
return $files;
|
495 |
-
}
|
496 |
-
|
497 |
-
|
498 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
include_once( trailingslashit(ABSPATH).'wp-admin/includes/class-wp-list-table.php');
|
3 |
+
|
4 |
+
class BackWPup_Backups_Table extends WP_List_Table {
|
5 |
+
|
6 |
+
private $jobid=1;
|
7 |
+
private $dest='FOLDER';
|
8 |
+
|
9 |
+
function __construct() {
|
10 |
+
parent::__construct( array(
|
11 |
+
'plural' => 'backups',
|
12 |
+
'singular' => 'backup',
|
13 |
+
'ajax' => true
|
14 |
+
) );
|
15 |
+
}
|
16 |
+
|
17 |
+
function ajax_user_can() {
|
18 |
+
return current_user_can(BACKWPUP_USER_CAPABILITY);
|
19 |
+
}
|
20 |
+
|
21 |
+
function prepare_items() {
|
22 |
+
|
23 |
+
$per_page = $this->get_items_per_page('backwpupbackups_per_page');
|
24 |
+
if ( empty( $per_page ) || $per_page < 1 )
|
25 |
+
$per_page = 20;
|
26 |
+
|
27 |
+
if (isset($_GET['jobdest'])) {
|
28 |
+
$jobdest=$_GET['jobdest'];
|
29 |
+
} else {
|
30 |
+
$jobdests=$this->get_dest_list();
|
31 |
+
if (empty($jobdests))
|
32 |
+
$jobdests=array(',');
|
33 |
+
$jobdest=$jobdests[0];
|
34 |
+
$_GET['jobdest']=$jobdests[0];
|
35 |
+
}
|
36 |
+
|
37 |
+
list($this->jobid,$this->dest)=explode(',',$jobdest);
|
38 |
+
|
39 |
+
if (false === ($backups=get_transient('backwpup_backups_chache'))) { //create new list
|
40 |
+
$backups=backwpup_get_backup_files($this->jobid,$this->dest);
|
41 |
+
set_transient('backwpup_backups_chache',$backups,300);
|
42 |
+
}
|
43 |
+
|
44 |
+
if (!$backups or $this->dest!=$backups[0]['DEST'] or $this->jobid!=$backups[0]['JOBID']) {
|
45 |
+
$backups=backwpup_get_backup_files($this->jobid,$this->dest);
|
46 |
+
set_transient('backwpup_backups_chache',$backups,300);
|
47 |
+
}
|
48 |
+
|
49 |
+
//if no itmes brake
|
50 |
+
if (empty($backups)) {
|
51 |
+
$this->items='';
|
52 |
+
return;
|
53 |
+
}
|
54 |
+
|
55 |
+
//Sorting
|
56 |
+
$order=isset($_GET['order']) ? $_GET['order'] : 'desc';
|
57 |
+
$orderby=isset($_GET['orderby']) ? $_GET['orderby'] : 'time';
|
58 |
+
$tmp = Array();
|
59 |
+
if ($orderby=='time') {
|
60 |
+
if ($order=='asc') {
|
61 |
+
foreach($backups as &$ma)
|
62 |
+
$tmp[] = &$ma["time"];
|
63 |
+
array_multisort($tmp, SORT_ASC, $backups);
|
64 |
+
} else {
|
65 |
+
foreach($backups as &$ma)
|
66 |
+
$tmp[] = &$ma["time"];
|
67 |
+
array_multisort($tmp, SORT_DESC, $backups);
|
68 |
+
}
|
69 |
+
}
|
70 |
+
elseif ($orderby=='file') {
|
71 |
+
if ($order=='asc') {
|
72 |
+
foreach($backups as &$ma)
|
73 |
+
$tmp[] = &$ma["filename"];
|
74 |
+
array_multisort($tmp, SORT_ASC, $backups);
|
75 |
+
} else {
|
76 |
+
foreach($backups as &$ma)
|
77 |
+
$tmp[] = &$ma["filename"];
|
78 |
+
array_multisort($tmp, SORT_DESC, $backups);
|
79 |
+
}
|
80 |
+
}
|
81 |
+
elseif ($orderby=='folder') {
|
82 |
+
if ($order=='asc') {
|
83 |
+
foreach($backups as &$ma)
|
84 |
+
$tmp[] = &$ma["folder"];
|
85 |
+
array_multisort($tmp, SORT_ASC, $backups);
|
86 |
+
} else {
|
87 |
+
foreach($backups as &$ma)
|
88 |
+
$tmp[] = &$ma["folder"];
|
89 |
+
array_multisort($tmp, SORT_DESC, $backups);
|
90 |
+
}
|
91 |
+
}
|
92 |
+
elseif ($orderby=='size') {
|
93 |
+
if ($order=='asc') {
|
94 |
+
foreach($backups as &$ma)
|
95 |
+
$tmp[] = &$ma["filesize"];
|
96 |
+
array_multisort($tmp, SORT_ASC, $backups);
|
97 |
+
} else {
|
98 |
+
foreach($backups as &$ma)
|
99 |
+
$tmp[] = &$ma["filesize"];
|
100 |
+
array_multisort($tmp, SORT_DESC, $backups);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
//by page
|
105 |
+
$start=intval( ( $this->get_pagenum() - 1 ) * $per_page );
|
106 |
+
$end=$start+$per_page;
|
107 |
+
if ($end>count($backups))
|
108 |
+
$end=count($backups);
|
109 |
+
|
110 |
+
$this->items=array();
|
111 |
+
for ($i=$start;$i<$end;$i++)
|
112 |
+
$this->items[]=$backups[$i];
|
113 |
+
|
114 |
+
$this->set_pagination_args( array(
|
115 |
+
'total_items' => count($backups),
|
116 |
+
'per_page' => $per_page,
|
117 |
+
'jobdest' => $jobdest,
|
118 |
+
'orderby' => $orderby,
|
119 |
+
'order' => $order
|
120 |
+
) );
|
121 |
+
|
122 |
+
}
|
123 |
+
|
124 |
+
function no_items() {
|
125 |
+
_e( 'No Files found.','backwpup');
|
126 |
+
}
|
127 |
+
|
128 |
+
function get_bulk_actions() {
|
129 |
+
$actions = array();
|
130 |
+
$actions['delete'] = __( 'Delete' );
|
131 |
+
return $actions;
|
132 |
+
}
|
133 |
+
|
134 |
+
function extra_tablenav( $which ) {
|
135 |
+
if ( 'top' != $which )
|
136 |
+
return;
|
137 |
+
$jobs=get_option('backwpup_jobs');
|
138 |
+
echo '<div class="alignleft actions">';
|
139 |
+
echo "<select name=\"jobdest\" id=\"jobdest\" class=\"postform\">\n";
|
140 |
+
foreach ($this->get_dest_list() as $jobdest) {
|
141 |
+
list($jobid,$dest)=explode(',',$jobdest);
|
142 |
+
echo "\t<option value=\"".$jobdest."\" ".selected($this->jobid.','.$this->dest,$jobdest).">".$dest.": ".esc_html($jobs[$jobid]['name'])."</option>\n";
|
143 |
+
}
|
144 |
+
echo "</select>\n";
|
145 |
+
submit_button( __('Change Destination','backwpup'), 'secondary', '', false, array( 'id' => 'post-query-submit' ) );
|
146 |
+
echo '</div>';
|
147 |
+
}
|
148 |
+
|
149 |
+
function get_dest_list() {
|
150 |
+
$jobdest=array();
|
151 |
+
$jobs=get_option('backwpup_jobs');
|
152 |
+
if (!empty($jobs) and is_array($jobs)) {
|
153 |
+
foreach ($jobs as $jobid => $jobvalue) {
|
154 |
+
if (!empty($jobvalue['backupdir']) and is_dir($jobvalue['backupdir']))
|
155 |
+
$jobdest[]=$jobid.',FOLDER';
|
156 |
+
foreach (explode(',',strtoupper(BACKWPUP_DESTS)) as $dest) {
|
157 |
+
$dest=strtoupper($dest);
|
158 |
+
if ($dest=='S3' and !empty($jobvalue['awsAccessKey']) and !empty($jobvalue['awsSecretKey']) and !empty($jobvalue['awsBucket']))
|
159 |
+
$jobdest[]=$jobid.','.$dest;
|
160 |
+
if ($dest=='GSTORAGE' and !empty($jobvalue['GStorageAccessKey']) and !empty($jobvalue['GStorageSecret']) and !empty($jobvalue['GStorageBucket']))
|
161 |
+
$jobdest[]=$jobid.','.$dest;
|
162 |
+
if ($dest=='DROPBOX' and !empty($jobvalue['dropetoken']) and !empty($jobvalue['dropesecret']))
|
163 |
+
$jobdest[]=$jobid.','.$dest;
|
164 |
+
if ($dest=='RSC' and !empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey']) and !empty($jobvalue['rscContainer']))
|
165 |
+
$jobdest[]=$jobid.','.$dest;
|
166 |
+
if ($dest=='FTP' and !empty($jobvalue['ftphost']) and function_exists('ftp_connect') and !empty($jobvalue['ftpuser']) and !empty($jobvalue['ftppass']))
|
167 |
+
$jobdest[]=$jobid.','.$dest;
|
168 |
+
if ($dest=='MSAZURE' and !empty($jobvalue['msazureHost']) and !empty($jobvalue['msazureAccName']) and !empty($jobvalue['msazureKey']) and !empty($jobvalue['msazureContainer']))
|
169 |
+
$jobdest[]=$jobid.','.$dest;
|
170 |
+
if ($dest=='SUGARSYNC' and !empty($jobvalue['sugarpass']) and !empty($jobvalue['sugarpass']))
|
171 |
+
$jobdest[]=$jobid.','.$dest;
|
172 |
+
}
|
173 |
+
|
174 |
+
}
|
175 |
+
}
|
176 |
+
return $jobdest;
|
177 |
+
}
|
178 |
+
|
179 |
+
function get_columns() {
|
180 |
+
$posts_columns = array();
|
181 |
+
$posts_columns['cb'] = '<input type="checkbox" />';
|
182 |
+
$posts_columns['file'] = __('File','backwpup');
|
183 |
+
$posts_columns['folder'] = __('Folder','backwpup');
|
184 |
+
$posts_columns['size'] = __('Size','backwpup');
|
185 |
+
$posts_columns['folder'] = __('Folder','backwpup');
|
186 |
+
$posts_columns['time'] = __('Time','backwpup');
|
187 |
+
return $posts_columns;
|
188 |
+
}
|
189 |
+
|
190 |
+
function get_sortable_columns() {
|
191 |
+
return array(
|
192 |
+
'file' => array('file',false),
|
193 |
+
'folder' => 'folder',
|
194 |
+
'size' => 'size',
|
195 |
+
'time' => array('time',false)
|
196 |
+
);
|
197 |
+
}
|
198 |
+
|
199 |
+
function display_rows() {
|
200 |
+
$style = '';
|
201 |
+
$jobs=get_option('backwpup_jobs'); //Load jobs
|
202 |
+
foreach ( $this->items as $backup ) {
|
203 |
+
$style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
|
204 |
+
echo "\n\t", $this->single_row( $backup, $jobs[$this->jobid], $style );
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
function single_row( $backup, $jobvalue, $style = '' ) {
|
209 |
+
list( $columns, $hidden, $sortable ) = $this->get_column_info();
|
210 |
+
$r = "<tr $style>";
|
211 |
+
foreach ( $columns as $column_name => $column_display_name ) {
|
212 |
+
$class = "class=\"$column_name column-$column_name\"";
|
213 |
+
|
214 |
+
$style = '';
|
215 |
+
if ( in_array( $column_name, $hidden ) )
|
216 |
+
$style = ' style="display:none;"';
|
217 |
+
|
218 |
+
$attributes = "$class$style";
|
219 |
+
|
220 |
+
switch($column_name) {
|
221 |
+
case 'cb':
|
222 |
+
$r .= '<th scope="row" class="check-column"><input type="checkbox" name="backupfiles[]" value="'. esc_attr($backup['file']) .'" /></th>';
|
223 |
+
break;
|
224 |
+
case 'file':
|
225 |
+
$r .= "<td $attributes><strong>".$backup['filename']."</strong>";
|
226 |
+
$actions = array();
|
227 |
+
$actions['delete'] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupbackups&action=delete&jobdest='.$this->jobid.','.$this->dest.'&paged='.$this->get_pagenum().'&backupfiles[]='.esc_attr($backup['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') . "</a>";
|
228 |
+
$actions['download'] = "<a href=\"" . wp_nonce_url($backup['downloadurl'], 'download-backup') . "\">" . __('Download','backwpup') . "</a>";
|
229 |
+
$r .= $this->row_actions($actions);
|
230 |
+
$r .= "</td>";
|
231 |
+
break;
|
232 |
+
case 'folder':
|
233 |
+
$r .= "<td $attributes>";
|
234 |
+
$r .= $backup['folder'];
|
235 |
+
$r .= "</td>";
|
236 |
+
break;
|
237 |
+
case 'size':
|
238 |
+
$r .= "<td $attributes>";
|
239 |
+
if (!empty($backup['filesize']) and $backup['filesize']!=-1) {
|
240 |
+
$r .= backwpup_formatBytes($backup['filesize']);
|
241 |
+
} else {
|
242 |
+
$r .= __('?','backwpup');
|
243 |
+
}
|
244 |
+
$r .= "</td>";
|
245 |
+
break;
|
246 |
+
case 'time':
|
247 |
+
$r .= "<td $attributes>";
|
248 |
+
$r .= backwpup_date_i18n(get_option('date_format'),$backup['time']).'<br />'. backwpup_date_i18n(get_option('time_format'),$backup['time']);
|
249 |
+
$r .= "</td>";
|
250 |
+
break;
|
251 |
+
}
|
252 |
+
}
|
253 |
+
$r .= '</tr>';
|
254 |
+
return $r;
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
|
259 |
+
//get backup files and infos
|
260 |
+
function backwpup_get_backup_files($jobid,$dest) {
|
261 |
+
global $backwpup_message;
|
262 |
+
if (empty($jobid) or (!in_array(strtoupper($dest),explode(',',strtoupper(BACKWPUP_DESTS))) and $dest!='FOLDER'))
|
263 |
+
return false;
|
264 |
+
$jobs=get_option('backwpup_jobs'); //Load jobs
|
265 |
+
$jobvalue=$jobs[$jobid];
|
266 |
+
$filecounter=0;
|
267 |
+
$files=array();
|
268 |
+
//Get files/filinfo in backup folder
|
269 |
+
if ($dest=='FOLDER' and !empty($jobvalue['backupdir']) and is_dir($jobvalue['backupdir'])) {
|
270 |
+
if ( $dir = opendir( $jobvalue['backupdir'] ) ) {
|
271 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
272 |
+
if (substr($file,0,1)=='.')
|
273 |
+
continue;
|
274 |
+
if (is_file($jobvalue['backupdir'].$file)) {
|
275 |
+
$files[$filecounter]['JOBID']=$jobid;
|
276 |
+
$files[$filecounter]['DEST']=$dest;
|
277 |
+
$files[$filecounter]['folder']=$jobvalue['backupdir'];
|
278 |
+
$files[$filecounter]['file']=$jobvalue['backupdir'].$file;
|
279 |
+
$files[$filecounter]['filename']=$file;
|
280 |
+
$files[$filecounter]['downloadurl']=backwpup_admin_url('admin.php').'?page=backwpupbackups&action=download&file='.$jobvalue['backupdir'].$file;
|
281 |
+
$files[$filecounter]['filesize']=filesize($jobvalue['backupdir'].$file);
|
282 |
+
$files[$filecounter]['time']=filemtime($jobvalue['backupdir'].$file);
|
283 |
+
$filecounter++;
|
284 |
+
}
|
285 |
+
}
|
286 |
+
closedir( $dir );
|
287 |
+
}
|
288 |
+
}
|
289 |
+
//Get files/filinfo from Dropbox
|
290 |
+
if ($dest=='DROPBOX' and !empty($jobvalue['dropetoken']) and !empty($jobvalue['dropesecret'])) {
|
291 |
+
require_once(realpath(dirname(__FILE__).'/../libs/dropbox.php'));
|
292 |
+
try {
|
293 |
+
$dropbox = new backwpup_Dropbox(BACKWPUP_DROPBOX_APP_KEY, BACKWPUP_DROPBOX_APP_SECRET,'dropbox');
|
294 |
+
$dropbox->setOAuthTokens($jobvalue['dropetoken'],$jobvalue['dropesecret']);
|
295 |
+
$contents = $dropbox->metadata($jobvalue['dropedir']);
|
296 |
+
if (is_array($contents)) {
|
297 |
+
foreach ($contents['contents'] as $object) {
|
298 |
+
if ($object['is_dir']!=true) {
|
299 |
+
$files[$filecounter]['JOBID']=$jobid;
|
300 |
+
$files[$filecounter]['DEST']=$dest;
|
301 |
+
$files[$filecounter]['folder']="https://api-content.dropbox.com/1/files/".$jobvalue['droperoot']."/".dirname($object['path'])."/";
|
302 |
+
$files[$filecounter]['file']=$object['path'];
|
303 |
+
$files[$filecounter]['filename']=basename($object['path']);
|
304 |
+
$files[$filecounter]['downloadurl']=backwpup_admin_url('admin.php').'?page=backwpupbackups&action=downloaddropbox&file='.$object['path'].'&jobid='.$jobid;
|
305 |
+
$files[$filecounter]['filesize']=$object['bytes'];
|
306 |
+
$files[$filecounter]['time']=strtotime($object['modified']);
|
307 |
+
$filecounter++;
|
308 |
+
}
|
309 |
+
}
|
310 |
+
}
|
311 |
+
} catch (Exception $e) {
|
312 |
+
$backwpup_message.='DROPBOX: '.$e->getMessage().'<br />';
|
313 |
+
}
|
314 |
+
}
|
315 |
+
//Get files/filinfo from Sugarsync
|
316 |
+
if ($dest=='SUGARSYNC' and !empty($jobvalue['sugarpass']) and !empty($jobvalue['sugarpass'])) {
|
317 |
+
if (!class_exists('SugarSync'))
|
318 |
+
require_once (dirname(__FILE__).'/../libs/sugarsync.php');
|
319 |
+
if (class_exists('SugarSync')) {
|
320 |
+
try {
|
321 |
+
$sugarsync = new SugarSync($jobvalue['sugaruser'],base64_decode($jobvalue['sugarpass']),BACKWPUP_SUGARSYNC_ACCESSKEY, BACKWPUP_SUGARSYNC_PRIVATEACCESSKEY);
|
322 |
+
$dirid=$sugarsync->chdir($jobvalue['sugardir'],$jobvalue['sugarroot']);
|
323 |
+
$user=$sugarsync->user();
|
324 |
+
$dir=$sugarsync->showdir($dirid);
|
325 |
+
$getfiles=$sugarsync->getcontents('file');
|
326 |
+
if (is_object($getfiles)) {
|
327 |
+
foreach ($getfiles->file as $getfile) {
|
328 |
+
$files[$filecounter]['JOBID']=$jobid;
|
329 |
+
$files[$filecounter]['DEST']=$dest;
|
330 |
+
$files[$filecounter]['folder']='https://'.$user->nickname.'.sugarsync.com/'.$dir;
|
331 |
+
$files[$filecounter]['file']=(string)$getfile->ref;
|
332 |
+
$files[$filecounter]['filename']=utf8_decode((string) $getfile->displayName);
|
333 |
+
$files[$filecounter]['downloadurl']=backwpup_admin_url('admin.php').'?page=backwpupbackups&action=downloadsugarsync&file='.(string) $getfile->ref.'&jobid='.$jobid;
|
334 |
+
$files[$filecounter]['filesize']=(int) $getfile->size;
|
335 |
+
$files[$filecounter]['time']=strtotime((string) $getfile->lastModified);
|
336 |
+
$filecounter++;
|
337 |
+
}
|
338 |
+
}
|
339 |
+
} catch (Exception $e) {
|
340 |
+
$backwpup_message.='SUGARSYNC: '.$e->getMessage().'<br />';
|
341 |
+
}
|
342 |
+
}
|
343 |
+
}
|
344 |
+
//Get files/filinfo from S3
|
345 |
+
if ($dest=='S3' and !empty($jobvalue['awsAccessKey']) and !empty($jobvalue['awsSecretKey']) and !empty($jobvalue['awsBucket'])) {
|
346 |
+
if (!class_exists('AmazonS3'))
|
347 |
+
require_once(dirname(__FILE__).'/../libs/aws/sdk.class.php');
|
348 |
+
if (class_exists('AmazonS3')) {
|
349 |
+
try {
|
350 |
+
$s3 = new AmazonS3(array('key'=>$jobvalue['awsAccessKey'],'secret'=>$jobvalue['awsSecretKey'],'certificate_authority'=> true ));
|
351 |
+
if (($contents = $s3->list_objects($jobvalue['awsBucket'],array('prefix'=>$jobvalue['awsdir']))) !== false) {
|
352 |
+
foreach ($contents->body->Contents as $object) {
|
353 |
+
$files[$filecounter]['JOBID']=$jobid;
|
354 |
+
$files[$filecounter]['DEST']=$dest;
|
355 |
+
$files[$filecounter]['folder']="https://".$jobvalue['awsBucket'].".s3.amazonaws.com/".dirname((string)$object->Key).'/';
|
356 |
+
$files[$filecounter]['file']=(string)$object->Key;
|
357 |
+
$files[$filecounter]['filename']=basename($object->Key);
|
358 |
+
$files[$filecounter]['downloadurl']=backwpup_admin_url('admin.php').'?page=backwpupbackups&action=downloads3&file='.$object->Key.'&jobid='.$jobid;
|
359 |
+
$files[$filecounter]['filesize']=(string)$object->Size;
|
360 |
+
$files[$filecounter]['time']=strtotime($object->LastModified);
|
361 |
+
$filecounter++;
|
362 |
+
}
|
363 |
+
}
|
364 |
+
} catch (Exception $e) {
|
365 |
+
$backwpup_message.='Amazon S3: '.$e->getMessage().'<br />';
|
366 |
+
}
|
367 |
+
}
|
368 |
+
}
|
369 |
+
//Get files/filinfo from Google Storage
|
370 |
+
if ($dest=='GSTORAGE' and !empty($jobvalue['GStorageAccessKey']) and !empty($jobvalue['GStorageSecret']) and !empty($jobvalue['GStorageBucket'])) {
|
371 |
+
if (!class_exists('AmazonS3'))
|
372 |
+
require_once(dirname(__FILE__).'/../libs/aws/sdk.class.php');
|
373 |
+
if (class_exists('AmazonS3')) {
|
374 |
+
try {
|
375 |
+
$gstorage = new AmazonS3(array('key'=>$jobvalue['GStorageAccessKey'],'secret'=>$jobvalue['GStorageSecret'],'certificate_authority'=> true ));
|
376 |
+
$gstorage->set_hostname('commondatastorage.googleapis.com');
|
377 |
+
$gstorage->allow_hostname_override(false);
|
378 |
+
if (($contents = $gstorage->list_objects($jobvalue['GStorageBucket'],array('prefix'=>$jobvalue['GStoragedir']))) !== false) {
|
379 |
+
foreach ($contents->body->Contents as $object) {
|
380 |
+
$files[$filecounter]['JOBID']=$jobid;
|
381 |
+
$files[$filecounter]['DEST']=$dest;
|
382 |
+
$files[$filecounter]['folder']="https://storage.cloud.google.com/".$jobvalue['GStorageBucket']."/".dirname((string)$object->Key).'/';
|
383 |
+
$files[$filecounter]['file']=(string)$object->Key;
|
384 |
+
$files[$filecounter]['filename']=basename($object->Key);
|
385 |
+
$files[$filecounter]['downloadurl']="https://storage.cloud.google.com/".$jobvalue['GStorageBucket']."/".(string)$object->Key;
|
386 |
+
$files[$filecounter]['filesize']=(string)$object->Size;
|
387 |
+
$files[$filecounter]['time']=strtotime($object->LastModified);
|
388 |
+
$filecounter++;
|
389 |
+
}
|
390 |
+
}
|
391 |
+
} catch (Exception $e) {
|
392 |
+
$backwpup_message.=sprintf(__('GStorage API: %s','backwpup'),$e->getMessage()).'<br />';
|
393 |
+
}
|
394 |
+
}
|
395 |
+
}
|
396 |
+
//Get files/filinfo from Microsoft Azure
|
397 |
+
if ($dest=='MSAZURE' and !empty($jobvalue['msazureHost']) and !empty($jobvalue['msazureAccName']) and !empty($jobvalue['msazureKey']) and !empty($jobvalue['msazureContainer'])) {
|
398 |
+
if (!class_exists('Microsoft_WindowsAzure_Storage_Blob'))
|
399 |
+
require_once(dirname(__FILE__).'/../libs/Microsoft/WindowsAzure/Storage/Blob.php');
|
400 |
+
if (class_exists('Microsoft_WindowsAzure_Storage_Blob')) {
|
401 |
+
try {
|
402 |
+
$storageClient = new Microsoft_WindowsAzure_Storage_Blob($jobvalue['msazureHost'],$jobvalue['msazureAccName'],$jobvalue['msazureKey']);
|
403 |
+
$blobs = $storageClient->listBlobs($jobvalue['msazureContainer'],$jobvalue['msazuredir']);
|
404 |
+
if (is_array($blobs)) {
|
405 |
+
foreach ($blobs as $blob) {
|
406 |
+
$files[$filecounter]['JOBID']=$jobid;
|
407 |
+
$files[$filecounter]['DEST']=$dest;
|
408 |
+
$files[$filecounter]['folder']="https://".$jobvalue['msazureAccName'].'.'.$jobvalue['msazureHost']."/".$jobvalue['msazureContainer']."/".dirname($blob->Name)."/";
|
409 |
+
$files[$filecounter]['file']=$blob->Name;
|
410 |
+
$files[$filecounter]['filename']=basename($blob->Name);
|
411 |
+
$files[$filecounter]['downloadurl']=backwpup_admin_url('admin.php').'?page=backwpupbackups&action=downloadmsazure&file='.$blob->Name.'&jobid='.$jobid;
|
412 |
+
$files[$filecounter]['filesize']=$blob->size;
|
413 |
+
$files[$filecounter]['time']=strtotime($blob->lastmodified);
|
414 |
+
$filecounter++;
|
415 |
+
}
|
416 |
+
}
|
417 |
+
} catch (Exception $e) {
|
418 |
+
$backwpup_message.='MSAZURE: '.$e->getMessage().'<br />';
|
419 |
+
}
|
420 |
+
}
|
421 |
+
}
|
422 |
+
//Get files/filinfo from RSC
|
423 |
+
if ($dest=='RSC' and !empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey']) and !empty($jobvalue['rscContainer'])) {
|
424 |
+
if (!class_exists('CF_Authentication'))
|
425 |
+
require_once(dirname(__FILE__).'/../libs/rackspace/cloudfiles.php');
|
426 |
+
if (class_exists('CF_Authentication') ) {
|
427 |
+
try {
|
428 |
+
$auth = new CF_Authentication($jobvalue['rscUsername'], $jobvalue['rscAPIKey']);
|
429 |
+
$auth->ssl_use_cabundle();
|
430 |
+
if ($auth->authenticate()) {
|
431 |
+
$conn = new CF_Connection($auth);
|
432 |
+
$conn->ssl_use_cabundle();
|
433 |
+
$backwpupcontainer = $conn->get_container($jobvalue['rscContainer']);
|
434 |
+
$contents = $backwpupcontainer->get_objects(0,NULL,NULL,$jobvalue['rscdir']);
|
435 |
+
foreach ($contents as $object) {
|
436 |
+
$files[$filecounter]['JOBID']=$jobid;
|
437 |
+
$files[$filecounter]['DEST']=$dest;
|
438 |
+
$files[$filecounter]['folder']="RSC://".$jobvalue['rscContainer']."/".dirname($object->name)."/";
|
439 |
+
$files[$filecounter]['file']=$object->name;
|
440 |
+
$files[$filecounter]['filename']=basename($object->name);
|
441 |
+
$files[$filecounter]['downloadurl']=backwpup_admin_url('admin.php').'?page=backwpupbackups&action=downloadrsc&file='.$object->name.'&jobid='.$jobid;
|
442 |
+
$files[$filecounter]['filesize']=$object->content_length;
|
443 |
+
$files[$filecounter]['time']=strtotime($object->last_modified);
|
444 |
+
$filecounter++;
|
445 |
+
}
|
446 |
+
}
|
447 |
+
} catch (Exception $e) {
|
448 |
+
$backwpup_message.='RSC: '.$e->getMessage().'<br />';
|
449 |
+
}
|
450 |
+
}
|
451 |
+
}
|
452 |
+
//Get files/filinfo from FTP
|
453 |
+
if ($dest=='FTP' and !empty($jobvalue['ftphost']) and function_exists('ftp_connect') and !empty($jobvalue['ftpuser']) and !empty($jobvalue['ftppass'])) {
|
454 |
+
|
455 |
+
if (function_exists('ftp_ssl_connect') and $jobvalue['ftpssl']) { //make SSL FTP connection
|
456 |
+
$ftp_conn_id = ftp_ssl_connect($jobvalue['ftphost'],$jobvalue['ftphostport'],10);
|
457 |
+
} elseif (!$jobvalue['ftpssl']) { //make normal FTP conection if SSL not work
|
458 |
+
$ftp_conn_id = ftp_connect($jobvalue['ftphost'],$jobvalue['ftphostport'],10);
|
459 |
+
}
|
460 |
+
$loginok=false;
|
461 |
+
if ($ftp_conn_id) {
|
462 |
+
//FTP Login
|
463 |
+
if (@ftp_login($ftp_conn_id, $jobvalue['ftpuser'], base64_decode($jobvalue['ftppass']))) {
|
464 |
+
$loginok=true;
|
465 |
+
} else { //if PHP ftp login don't work use raw login
|
466 |
+
ftp_raw($ftp_conn_id,'USER '.$jobvalue['ftpuser']);
|
467 |
+
$return=ftp_raw($ftp_conn_id,'PASS '.base64_decode($jobvalue['ftppass']));
|
468 |
+
if (substr(trim($return[0]),0,3)<=400)
|
469 |
+
$loginok=true;
|
470 |
+
}
|
471 |
+
}
|
472 |
+
if ($loginok) {
|
473 |
+
ftp_pasv($ftp_conn_id, $jobvalue['ftppasv']);
|
474 |
+
if ($ftpfilelist=ftp_nlist($ftp_conn_id, $jobvalue['ftpdir'])) {
|
475 |
+
foreach($ftpfilelist as $ftpfiles) {
|
476 |
+
if (substr(basename($ftpfiles),0,1)=='.')
|
477 |
+
continue;
|
478 |
+
$files[$filecounter]['JOBID']=$jobid;
|
479 |
+
$files[$filecounter]['DEST']=$dest;
|
480 |
+
$files[$filecounter]['folder']="ftp://".$jobvalue['ftphost'].':'.$jobvalue['ftphostport'].dirname($ftpfiles)."/";
|
481 |
+
$files[$filecounter]['file']=$ftpfiles;
|
482 |
+
$files[$filecounter]['filename']=basename($ftpfiles);
|
483 |
+
$files[$filecounter]['downloadurl']="ftp://".rawurlencode($jobvalue['ftpuser']).":".rawurlencode(base64_decode($jobvalue['ftppass']))."@".$jobvalue['ftphost'].':'.$jobvalue['ftphostport'].$ftpfiles;
|
484 |
+
$files[$filecounter]['filesize']=ftp_size($ftp_conn_id,$ftpfiles);
|
485 |
+
$files[$filecounter]['time']=ftp_mdtm($ftp_conn_id,$ftpfiles);
|
486 |
+
$filecounter++;
|
487 |
+
}
|
488 |
+
}
|
489 |
+
} else {
|
490 |
+
$backwpup_message.='FTP: '.__('Login failure!','backwpup').'<br />';
|
491 |
+
}
|
492 |
+
$donefolders[]=$jobvalue['ftphost'].'|'.$jobvalue['ftpuser'].'|'.$jobvalue['ftpdir'];
|
493 |
+
}
|
494 |
+
return $files;
|
495 |
+
}
|
|
|
|
|
|
pages/func_backwpupeditjob.php
CHANGED
@@ -1,812 +1,811 @@
|
|
1 |
-
<?PHP
|
2 |
-
function backwpup_jobedit_metabox_save($jobvalue) {
|
3 |
-
?>
|
4 |
-
<div class="submitbox" id="submitjobedit">
|
5 |
-
<div id="minor-publishing">
|
6 |
-
<div id="minor-publishing-actions">
|
7 |
-
<div id="preview-action">
|
8 |
-
</div>
|
9 |
-
<div class="clear"></div>
|
10 |
-
</div>
|
11 |
-
<div id="misc-publishing-actions">
|
12 |
-
<div class="misc-pub-section misc-pub-section-last">
|
13 |
-
<?php
|
14 |
-
foreach (backwpup_backup_types() as $type) {
|
15 |
-
echo "<input class=\"jobtype-select checkbox\" id=\"jobtype-select-".$type."\" type=\"checkbox\"".checked(true,in_array($type,explode('+',$jobvalue['type'])),false)." name=\"type[]\" value=\"".$type."\"/> ".backwpup_backup_types($type);
|
16 |
-
}
|
17 |
-
if (!function_exists('curl_init'))
|
18 |
-
echo '<br /><strong style="color:red;">'.__( 'PHP curl functions not available! Most backup destinations deaktivated!', 'backwpup' ).'</strong>';
|
19 |
-
?>
|
20 |
-
</div>
|
21 |
-
</div>
|
22 |
-
</div>
|
23 |
-
<div id="major-publishing-actions">
|
24 |
-
<div id="delete-action">
|
25 |
-
<a class="submitdelete deletion" href="<?PHP echo wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpup&action=delete&jobs[]='.$jobvalue['jobid'], 'bulk-jobs'); ?>" onclick="if ( confirm('<?PHP echo esc_js(__("You are about to delete this Job. \n 'Cancel' to stop, 'OK' to delete.","backwpup")); ?>') ) { return true;}return false;"><?php _e('Delete', 'backwpup'); ?></a>
|
26 |
-
</div>
|
27 |
-
<div id="publishing-action">
|
28 |
-
<?php submit_button( __('Save Changes', 'backwpup'), 'primary', 'save', false, array( 'tabindex' => '2', 'accesskey' => 'p' ) ); ?>
|
29 |
-
</div>
|
30 |
-
<div class="clear"></div>
|
31 |
-
</div>
|
32 |
-
</div>
|
33 |
-
<?PHP
|
34 |
-
}
|
35 |
-
|
36 |
-
function backwpup_jobedit_metabox_backupfile($jobvalue) {
|
37 |
-
?>
|
38 |
-
<b><?PHP _e('File Prefix:','backwpup'); ?></b><br />
|
39 |
-
<input name="fileprefix" type="text" value="<?PHP echo $jobvalue['fileprefix'];?>" class="large-text" /><br />
|
40 |
-
<b><?PHP _e('File Formart:','backwpup'); ?></b><br />
|
41 |
-
<?PHP
|
42 |
-
if (function_exists('gzopen') or class_exists('ZipArchive'))
|
43 |
-
echo '<input class="radio" type="radio"'.checked('.zip',$jobvalue['fileformart'],false).' name="fileformart" value=".zip" />'.__('Zip','backwpup').'<br />';
|
44 |
-
else
|
45 |
-
echo '<input class="radio" type="radio"'.checked('.zip',$jobvalue['fileformart'],false).' name="fileformart" value=".zip" disabled="disabled" />'.__('Zip','backwpup').'<br />';
|
46 |
-
echo '<input class="radio" type="radio"'.checked('.tar',$jobvalue['fileformart'],false).' name="fileformart" value=".tar" />'.__('Tar','backwpup').'<br />';
|
47 |
-
if (function_exists('gzopen'))
|
48 |
-
echo '<input class="radio" type="radio"'.checked('.tar.gz',$jobvalue['fileformart'],false).' name="fileformart" value=".tar.gz" />'.__('Tar GZip','backwpup').'<br />';
|
49 |
-
else
|
50 |
-
echo '<input class="radio" type="radio"'.checked('.tar.gz',$jobvalue['fileformart'],false).' name="fileformart" value=".tar.gz" disabled="disabled" />'.__('Tar GZip','backwpup').'<br />';
|
51 |
-
if (function_exists('bzopen'))
|
52 |
-
echo '<input class="radio" type="radio"'.checked('.tar.bz2',$jobvalue['fileformart'],false).' name="fileformart" value=".tar.bz2" />'.__('Tar BZip2','backwpup').'<br />';
|
53 |
-
else
|
54 |
-
echo '<input class="radio" type="radio"'.checked('.tar.bz2',$jobvalue['fileformart'],false).' name="fileformart" value=".tar.bz2" disabled="disabled" />'.__('Tar BZip2','backwpup').'<br />';
|
55 |
-
_e('Preview:','backwpup');
|
56 |
-
echo '<br /><i><span id="backupfileprefix">'.$jobvalue['fileprefix'].'</span>'.backwpup_date_i18n('Y-m-d_H-i-s').'<span id="backupfileformart">'.$jobvalue['fileformart'].'</span></i>';
|
57 |
-
}
|
58 |
-
|
59 |
-
function backwpup_jobedit_metabox_sendlog($jobvalue) {
|
60 |
-
_e('E-Mail-Adress:','backwpup'); ?>
|
61 |
-
<input name="mailaddresslog" id="mailaddresslog" type="text" value="<?PHP echo $jobvalue['mailaddresslog'];?>" class="large-text" /><br />
|
62 |
-
<input class="checkbox" value="1" type="checkbox" <?php checked($jobvalue['mailerroronly'],true); ?> name="mailerroronly" /> <?PHP _e('Only send an e-mail if there are errors.','backwpup'); ?>
|
63 |
-
<?PHP
|
64 |
-
}
|
65 |
-
|
66 |
-
function backwpup_jobedit_metabox_schedule($jobvalue) {
|
67 |
-
list($cronstr['minutes'],$cronstr['hours'],$cronstr['mday'],$cronstr['mon'],$cronstr['wday'])=explode(' ',$jobvalue['cron'],5);
|
68 |
-
if (strstr($cronstr['minutes'],'*/'))
|
69 |
-
$minutes=explode('/',$cronstr['minutes']);
|
70 |
-
else
|
71 |
-
$minutes=explode(',',$cronstr['minutes']);
|
72 |
-
if (strstr($cronstr['hours'],'*/'))
|
73 |
-
$hours=explode('/',$cronstr['hours']);
|
74 |
-
else
|
75 |
-
$hours=explode(',',$cronstr['hours']);
|
76 |
-
if (strstr($cronstr['mday'],'*/'))
|
77 |
-
$mday=explode('/',$cronstr['mday']);
|
78 |
-
else
|
79 |
-
$mday=explode(',',$cronstr['mday']);
|
80 |
-
if (strstr($cronstr['mon'],'*/'))
|
81 |
-
$mon=explode('/',$cronstr['mon']);
|
82 |
-
else
|
83 |
-
$mon=explode(',',$cronstr['mon']);
|
84 |
-
if (strstr($cronstr['wday'],'*/'))
|
85 |
-
$wday=explode('/',$cronstr['wday']);
|
86 |
-
else
|
87 |
-
$wday=explode(',',$cronstr['wday']);
|
88 |
-
backwpup_get_cron_text(array('cronstamp'=>$jobvalue['cron']));
|
89 |
-
?>
|
90 |
-
<br />
|
91 |
-
<b><input class="checkbox" value="1" type="checkbox" <?php checked($jobvalue['activated'],true); ?> name="activated" /> <?PHP _e('Activate scheduling', 'backwpup'); ?></b><br /><br />
|
92 |
-
<?PHP echo '<input class="radio" type="radio"'.checked("advanced",$jobvalue['cronselect'],false).' name="cronselect" value="advanced" />'.__('advanced','backwpup').' ';
|
93 |
-
echo '<input class="radio" type="radio"'.checked("basic",$jobvalue['cronselect'],false).' name="cronselect" value="basic" />'.__('basic','backwpup');?>
|
94 |
-
<br /><br />
|
95 |
-
<div id="schedadvanced" <?PHP if ($jobvalue['cronselect']!='advanced') echo 'style="display:none;"';?>>
|
96 |
-
<div id="cron-min-box">
|
97 |
-
<b><?PHP _e('Minutes: ','backwpup'); ?></b><br />
|
98 |
-
<?PHP
|
99 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("*",$minutes,true),true,false).' name="cronminutes[]" value="*" /> '.__('Any (*)','backwpup').'<br />';
|
100 |
-
echo '<div id="cron-min">';
|
101 |
-
for ($i=0;$i<60;$i=$i+5) {
|
102 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("$i",$minutes,true),true,false).' name="cronminutes[]" value="'.$i.'" /> '.$i.'<br />';
|
103 |
-
}
|
104 |
-
?>
|
105 |
-
</div>
|
106 |
-
</div>
|
107 |
-
<div id="cron-hour-box">
|
108 |
-
<b><?PHP _e('Hours:','backwpup'); ?></b><br />
|
109 |
-
<?PHP
|
110 |
-
|
111 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("*",$hours,true),true,false).' name="cronhours[]" value="*" /> '.__('Any (*)','backwpup').'<br />';
|
112 |
-
echo '<div id="cron-hour">';
|
113 |
-
for ($i=0;$i<24;$i++) {
|
114 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("$i",$hours,true),true,false).' name="cronhours[]" value="'.$i.'" /> '.$i.'<br />';
|
115 |
-
}
|
116 |
-
?>
|
117 |
-
</div>
|
118 |
-
</div>
|
119 |
-
<div id="cron-day-box">
|
120 |
-
<b><?PHP _e('Day of Month:','backwpup'); ?></b><br />
|
121 |
-
<?PHP
|
122 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("*",$mday,true),true,false).' name="cronmday[]" value="*" /> '.__('Any (*)','backwpup').'<br />';
|
123 |
-
echo '<div id="cron-day">';
|
124 |
-
for ($i=1;$i<=31;$i++) {
|
125 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("$i",$mday,true),true,false).' name="cronmday[]" value="'.$i.'" /> '.$i.'<br />';
|
126 |
-
}
|
127 |
-
?>
|
128 |
-
</div>
|
129 |
-
</div>
|
130 |
-
<div id="cron-month-box">
|
131 |
-
<b><?PHP _e('Month:','backwpup'); ?></b><br />
|
132 |
-
<?PHP
|
133 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("*",$mday,true),true,false).' name="cronmon[]" value="*" /> '.__('Any (*)','backwpup').'<br />';
|
134 |
-
echo '<div id="cron-month">';
|
135 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("1",$mday,true),true,false).' name="cronmon[]" value="1" /> '.__('January','backwpup').'<br />';
|
136 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("2",$mday,true),true,false).' name="cronmon[]" value="2" /> '.__('February','backwpup').'<br />';
|
137 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("3",$mday,true),true,false).' name="cronmon[]" value="3" /> '.__('March','backwpup').'<br />';
|
138 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("4",$mday,true),true,false).' name="cronmon[]" value="4" /> '.__('April','backwpup').'<br />';
|
139 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("5",$mday,true),true,false).' name="cronmon[]" value="5" /> '.__('May','backwpup').'<br />';
|
140 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("6",$mday,true),true,false).' name="cronmon[]" value="6" /> '.__('June','backwpup').'<br />';
|
141 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("7",$mday,true),true,false).' name="cronmon[]" value="7" /> '.__('July','backwpup').'<br />';
|
142 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("8",$mday,true),true,false).' name="cronmon[]" value="8" /> '.__('Augest','backwpup').'<br />';
|
143 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("9",$mday,true),true,false).' name="cronmon[]" value="9" /> '.__('September','backwpup').'<br />';
|
144 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("10",$mday,true),true,false).' name="cronmon[]" value="10" /> '.__('October','backwpup').'<br />';
|
145 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("11",$mday,true),true,false).' name="cronmon[]" value="11" /> '.__('November','backwpup').'<br />';
|
146 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("12",$mday,true),true,false).' name="cronmon[]" value="12" /> '.__('December','backwpup').'<br />';
|
147 |
-
?>
|
148 |
-
</div>
|
149 |
-
</div>
|
150 |
-
<div id="cron-weekday-box">
|
151 |
-
<b><?PHP _e('Day of Week:','backwpup'); ?></b><br />
|
152 |
-
<?PHP
|
153 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("*",$wday,true),true,false).' name="cronwday[]" value="*" /> '.__('Any (*)','backwpup').'<br />';
|
154 |
-
echo '<div id="cron-weekday">';
|
155 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("0",$wday,true),true,false).' name="cronwday[]" value="0" /> '.__('Sunday','backwpup').'<br />';
|
156 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("1",$wday,true),true,false).' name="cronwday[]" value="1" /> '.__('Monday','backwpup').'<br />';
|
157 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("2",$wday,true),true,false).' name="cronwday[]" value="2" /> '.__('Tuesday','backwpup').'<br />';
|
158 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("3",$wday,true),true,false).' name="cronwday[]" value="3" /> '.__('Wednesday','backwpup').'<br />';
|
159 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("4",$wday,true),true,false).' name="cronwday[]" value="4" /> '.__('Thursday','backwpup').'<br />';
|
160 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("5",$wday,true),true,false).' name="cronwday[]" value="5" /> '.__('Friday','backwpup').'<br />';
|
161 |
-
echo '<input class="checkbox" type="checkbox"'.checked(in_array("6",$wday,true),true,false).' name="cronwday[]" value="6" /> '.__('Saturday','backwpup').'<br />';
|
162 |
-
?>
|
163 |
-
</div>
|
164 |
-
</div>
|
165 |
-
<br class="clear" />
|
166 |
-
</div>
|
167 |
-
<div id="schedbasic" <?PHP if ($jobvalue['cronselect']!='basic') echo 'style="display:none;"';?>>
|
168 |
-
<table>
|
169 |
-
<tr>
|
170 |
-
<th>
|
171 |
-
<?PHP _e('Type','backwpup') ?>
|
172 |
-
</th>
|
173 |
-
<th>
|
174 |
-
</th>
|
175 |
-
<th>
|
176 |
-
<?PHP _e('Hour','backwpup') ?>
|
177 |
-
</th>
|
178 |
-
<th>
|
179 |
-
<?PHP _e('Minute','backwpup') ?>
|
180 |
-
</th>
|
181 |
-
</tr>
|
182 |
-
<tr>
|
183 |
-
<td><?PHP echo '<input class="radio" type="radio"'.checked(true,is_numeric($mday[0]),false).' name="cronbtype" value="mon" />'.__('monthly','backwpup'); ?></td>
|
184 |
-
<td><select name="moncronmday"><?PHP for ($i=1;$i<=31;$i++) {echo '<option '.selected(in_array("$i",$mday,true),true,false).' value="'.$i.'" />'.__('on','backwpup').' '.$i.'.</option>';} ?></select></td>
|
185 |
-
<td><select name="moncronhours"><?PHP for ($i=0;$i<24;$i++) {echo '<option '.selected(in_array("$i",$hours,true),true,false).' value="'.$i.'" />'.$i.'</option>';} ?></select></td>
|
186 |
-
<td><select name="moncronminutes"><?PHP for ($i=0;$i<60;$i=$i+5) {echo '<option '.selected(in_array("$i",$minutes,true),true,false).' value="'.$i.'" />'.$i.'</option>';} ?></select></td>
|
187 |
-
</tr>
|
188 |
-
<tr>
|
189 |
-
<td><?PHP echo '<input class="radio" type="radio"'.checked(true,is_numeric($wday[0]),false).' name="cronbtype" value="week" />'.__('weekly','backwpup'); ?></td>
|
190 |
-
<td><select name="weekcronwday">
|
191 |
-
<?PHP echo '<option '.selected(in_array("0",$wday,true),true,false).' value="0" />'.__('Sunday','backwpup').'</option>';
|
192 |
-
echo '<option '.selected(in_array("1",$wday,true),true,false).' value="1" />'.__('Monday','backwpup').'</option>';
|
193 |
-
echo '<option '.selected(in_array("2",$wday,true),true,false).' value="2" />'.__('Tuesday','backwpup').'</option>';
|
194 |
-
echo '<option '.selected(in_array("3",$wday,true),true,false).' value="3" />'.__('Wednesday','backwpup').'</option>';
|
195 |
-
echo '<option '.selected(in_array("4",$wday,true),true,false).' value="4" />'.__('Thursday','backwpup').'</option>';
|
196 |
-
echo '<option '.selected(in_array("5",$wday,true),true,false).' value="5" />'.__('Friday','backwpup').'</option>';
|
197 |
-
echo '<option '.selected(in_array("6",$wday,true),true,false).' value="6" />'.__('Saturday','backwpup').'</option>'; ?>
|
198 |
-
</select></td>
|
199 |
-
<td><select name="weekcronhours"><?PHP for ($i=0;$i<24;$i++) {echo '<option '.selected(in_array("$i",$hours,true),true,false).' value="'.$i.'" />'.$i.'</option>';} ?></select></td>
|
200 |
-
<td><select name="weekcronminutes"><?PHP for ($i=0;$i<60;$i=$i+5) {echo '<option '.selected(in_array("$i",$minutes,true),true,false).' value="'.$i.'" />'.$i.'</option>';} ?></select></td>
|
201 |
-
</tr>
|
202 |
-
<tr>
|
203 |
-
<td><?PHP echo '<input class="radio" type="radio"'.checked("**",$mday[0].$wday[0],false).' name="cronbtype" value="day" />'.__('daily','backwpup'); ?></td>
|
204 |
-
<td></td>
|
205 |
-
<td><select name="daycronhours"><?PHP for ($i=0;$i<24;$i++) {echo '<option '.selected(in_array("$i",$hours,true),true,false).' value="'.$i.'" />'.$i.'</option>';} ?></select></td>
|
206 |
-
<td><select name="daycronminutes"><?PHP for ($i=0;$i<60;$i=$i+5) {echo '<option '.selected(in_array("$i",$minutes,true),true,false).' value="'.$i.'" />'.$i.'</option>';} ?></select></td>
|
207 |
-
</tr>
|
208 |
-
<tr>
|
209 |
-
<td><?PHP echo '<input class="radio" type="radio"'.checked("*",$hours[0],false,false).' name="cronbtype" value="hour" />'.__('hourly','backwpup'); ?></td>
|
210 |
-
<td></td>
|
211 |
-
<td></td>
|
212 |
-
<td><select name="hourcronminutes"><?PHP for ($i=0;$i<60;$i=$i+5) {echo '<option '.selected(in_array("$i",$minutes,true),true,false).' value="'.$i.'" />'.$i.'</option>';} ?></select></td>
|
213 |
-
</tr>
|
214 |
-
</table>
|
215 |
-
</div>
|
216 |
-
<?PHP
|
217 |
-
}
|
218 |
-
|
219 |
-
function backwpup_jobedit_metabox_destfolder($jobvalue) {
|
220 |
-
?>
|
221 |
-
<b><?PHP _e('Full Path to folder for Backup Files:','backwpup'); ?></b><br />
|
222 |
-
<input name="backupdir" id="backupdir" type="text" value="<?PHP echo $jobvalue['backupdir'];?>" class="large-text" /><br />
|
223 |
-
<span class="description"><?PHP _e('Your WordPress dir is:','backwpup'); echo ' '.trailingslashit(str_replace('\\','/',ABSPATH));?></span><br /> <br />
|
224 |
-
<?PHP _e('Max. backup files in folder:','backwpup'); ?> <input name="maxbackups" id="maxbackups" type="text" size="3" value="<?PHP echo $jobvalue['maxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will deleted first.)','backwpup');?></span>
|
225 |
-
<?PHP
|
226 |
-
}
|
227 |
-
|
228 |
-
function backwpup_jobedit_metabox_destftp($jobvalue) {
|
229 |
-
?>
|
230 |
-
<b><?PHP _e('Hostname:','backwpup'); ?></b><br />
|
231 |
-
<input name="ftphost" type="text" value="<?PHP echo $jobvalue['ftphost'];?>" class="large-text" /><br />
|
232 |
-
<b><?PHP _e('Port:','backwpup'); ?></b><br />
|
233 |
-
<input name="ftphostport" type="text" value="<?PHP echo $jobvalue['ftphostport'];?>" class="small-text" /><br />
|
234 |
-
<b><?PHP _e('Username:','backwpup'); ?></b><br />
|
235 |
-
<input name="ftpuser" type="text" value="<?PHP echo $jobvalue['ftpuser'];?>" class="user large-text" /><br />
|
236 |
-
<b><?PHP _e('Password:','backwpup'); ?></b><br />
|
237 |
-
<input name="ftppass" type="password" value="<?PHP echo base64_decode($jobvalue['ftppass']);?>" class="password large-text" /><br />
|
238 |
-
<b><?PHP _e('Folder on Server:','backwpup'); ?></b><br />
|
239 |
-
<input name="ftpdir" type="text" value="<?PHP echo $jobvalue['ftpdir'];?>" class="large-text" /><br />
|
240 |
-
<?PHP if (!is_numeric($jobvalue['ftpmaxbackups'])) $jobvalue['ftpmaxbackups']=0; ?>
|
241 |
-
<?PHP _e('Max. backup files in FTP folder:','backwpup'); ?> <input name="ftpmaxbackups" type="text" size="3" value="<?PHP echo $jobvalue['ftpmaxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will be deleted first.)','backwpup');?></span><br />
|
242 |
-
<input class="checkbox" value="1" type="checkbox" <?php checked($jobvalue['ftpssl'],true); ?> name="ftpssl" /> <?PHP _e('Use SSL-FTP Connection.','backwpup'); ?><br />
|
243 |
-
<input class="checkbox" value="1" type="checkbox" <?php checked($jobvalue['ftppasv'],true); ?> name="ftppasv" /> <?PHP _e('Use FTP Passiv mode.','backwpup'); ?><br />
|
244 |
-
<?PHP
|
245 |
-
}
|
246 |
-
|
247 |
-
function backwpup_jobedit_metabox_dests3($jobvalue) {
|
248 |
-
?>
|
249 |
-
<div class="dests">
|
250 |
-
<b><?PHP _e('Access Key ID:','backwpup'); ?></b>
|
251 |
-
<input id="awsAccessKey" name="awsAccessKey" type="text" value="<?PHP echo $jobvalue['awsAccessKey'];?>" class="large-text" /><br />
|
252 |
-
<b><?PHP _e('Secret Access Key:','backwpup'); ?></b><br />
|
253 |
-
<input id="awsSecretKey" name="awsSecretKey" type="password" value="<?PHP echo $jobvalue['awsSecretKey'];?>" class="large-text" /><br />
|
254 |
-
<b><?PHP _e('Bucket:','backwpup'); ?></b><br />
|
255 |
-
<input id="awsBucketselected" name="awsBucketselected" type="hidden" value="<?PHP echo $jobvalue['awsBucket'];?>" />
|
256 |
-
<?PHP if (!empty($jobvalue['awsAccessKey']) and !empty($jobvalue['awsSecretKey'])) backwpup_get_aws_buckets(array('awsAccessKey'=>$jobvalue['awsAccessKey'],'awsSecretKey'=>$jobvalue['awsSecretKey'],'awsselected'=>$jobvalue['awsBucket'])); ?>
|
257 |
-
<?PHP _e('Create bucket:','backwpup'); ?><input name="newawsBucket" type="text" value="" class="text" /> <select name="awsRegion" title="<?php _e('Bucket Region', 'backwpup'); ?>"><option value="s3.amazonaws.com"><?php _e('US-Standard (Northern Virginia & Washington State)', 'backwpup'); ?></option><option value="s3-us-west-1.amazonaws.com"><?php _e('US-West 1 (Northern California)', 'backwpup'); ?></option><option value="s3-us-west-2.amazonaws.com"><?php _e('US-West 2 (Oregon)', 'backwpup'); ?></option><option value="s3-eu-west-1.amazonaws.com"><?php _e('EU (Ireland)', 'backwpup'); ?></option><option value="s3-ap-southeast-1.amazonaws.com"><?php _e('Asia Pacific (Singapore)', 'backwpup'); ?></option><option value="s3-ap-northeast-1.amazonaws.com"><?php _e('Asia Pacific (Japan)', 'backwpup'); ?></option><option value="s3-sa-east-1.amazonaws.com"><?php _e('South America (Sao Paulo)', 'backwpup'); ?></option><option value="s3-us-gov-west-1.amazonaws.com"><?php _e('United States GovCloud', 'backwpup'); ?></option><option value="s3-fips-us-gov-west-1.amazonaws.com"><?php _e('United States GovCloud FIPS 140-2', 'backwpup'); ?></option></select><br />
|
258 |
-
<b><?PHP _e('Folder in bucket:','backwpup'); ?></b><br />
|
259 |
-
<input name="awsdir" type="text" value="<?PHP echo $jobvalue['awsdir'];?>" class="large-text" /><br />
|
260 |
-
<?PHP _e('Max. backup files in bucket folder:','backwpup'); ?><input name="awsmaxbackups" type="text" size="3" value="<?PHP echo $jobvalue['awsmaxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will be deleted first.)','backwpup');?></span><br />
|
261 |
-
<input class="checkbox" value="1" type="checkbox" <?php checked($jobvalue['awsrrs'],true); ?> name="awsrrs" /> <?PHP _e('Save Backups with reduced redundancy!','backwpup'); ?><br />
|
262 |
-
</div>
|
263 |
-
<div class="destlinks">
|
264 |
-
<a href="http://www.amazon.de/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2Fgp%2Faws%2Fregistration%2Fregistration-form.html&site-redirect=de&tag=hueskennet-21&linkCode=ur2&camp=1638&creative=6742" target="_blank"><?PHP _e('Create Account','backwpup'); ?></a><br />
|
265 |
-
<a href="http://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key" target="_blank"><?PHP _e('Find Keys','backwpup'); ?></a><br />
|
266 |
-
<a href="https://console.aws.amazon.com/s3/home" target="_blank"><?PHP _e('Webinterface','backwpup'); ?></a><br />
|
267 |
-
</div>
|
268 |
-
<br class="clear" />
|
269 |
-
<?PHP
|
270 |
-
}
|
271 |
-
|
272 |
-
function backwpup_jobedit_metabox_destgstorage($jobvalue) {
|
273 |
-
?>
|
274 |
-
<div class="dests">
|
275 |
-
<b><?PHP _e('Access Key:','backwpup'); ?></b><br />
|
276 |
-
<input id="GStorageAccessKey" name="GStorageAccessKey" type="text" value="<?PHP echo $jobvalue['GStorageAccessKey'];?>" class="large-text" /><br />
|
277 |
-
<b><?PHP _e('Secret:','backwpup'); ?></b><br />
|
278 |
-
<input id="GStorageSecret" name="GStorageSecret" type="password" value="<?PHP echo $jobvalue['GStorageSecret'];?>" class="large-text" /><br />
|
279 |
-
<b><?PHP _e('Bucket:','backwpup'); ?></b><br />
|
280 |
-
<input id="GStorageselected" name="GStorageselected" type="hidden" value="<?PHP echo $jobvalue['GStorageBucket'];?>" />
|
281 |
-
<?PHP if (!empty($jobvalue['GStorageAccessKey']) and !empty($jobvalue['GStorageSecret'])) backwpup_get_gstorage_buckets(array('GStorageAccessKey'=>$jobvalue['GStorageAccessKey'],'GStorageSecret'=>$jobvalue['GStorageSecret'],'GStorageselected'=>$jobvalue['GStorageBucket'])); ?>
|
282 |
-
<?PHP _e('Create bucket:','backwpup'); ?><input name="newGStorageBucket" type="text" value="" class="text" /><br />
|
283 |
-
<b><?PHP _e('Folder in bucket:','backwpup'); ?></b><br />
|
284 |
-
<input name="GStoragedir" type="text" value="<?PHP echo $jobvalue['GStoragedir'];?>" class="large-text" /><br />
|
285 |
-
<?PHP _e('Max. backup files in bucket folder:','backwpup'); ?><input name="GStoragemaxbackups" type="text" size="3" value="<?PHP echo $jobvalue['GStoragemaxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will be deleted first.)','backwpup');?></span><br />
|
286 |
-
</div>
|
287 |
-
<div class="destlinks">
|
288 |
-
<a href="http://code.google.com/apis/storage/docs/signup.html" target="_blank"><?PHP _e('Create Account','backwpup'); ?></a><br />
|
289 |
-
<a href="https://code.google.com/apis/console/" target="_blank"><?PHP _e('Find Keys','backwpup'); ?></a><br />
|
290 |
-
<a href="https://
|
291 |
-
</div>
|
292 |
-
<br class="clear" />
|
293 |
-
<?PHP
|
294 |
-
}
|
295 |
-
|
296 |
-
function backwpup_jobedit_metabox_destazure($jobvalue) {
|
297 |
-
?>
|
298 |
-
<div class="dests">
|
299 |
-
|
300 |
-
<b><?PHP _e('Host:','backwpup'); ?></b><br />
|
301 |
-
<input id="msazureHost" name="msazureHost" type="text" value="<?PHP echo $jobvalue['msazureHost'];?>" class="large-text" /><span class="description"><?PHP _e('Normely: blob.core.windows.net','backwpup');?></span><br />
|
302 |
-
<b><?PHP _e('Account Name:','backwpup'); ?></b><br />
|
303 |
-
<input id="msazureAccName" name="msazureAccName" type="text" value="<?PHP echo $jobvalue['msazureAccName'];?>" class="large-text" /><br />
|
304 |
-
<b><?PHP _e('Access Key:','backwpup'); ?></b><br />
|
305 |
-
<input id="msazureKey" name="msazureKey" type="password" value="<?PHP echo $jobvalue['msazureKey'];?>" class="large-text" /><br />
|
306 |
-
<b><?PHP _e('Container:','backwpup'); ?></b><br />
|
307 |
-
<input id="msazureContainerselected" name="msazureContainerselected" type="hidden" value="<?PHP echo $jobvalue['msazureContainer'];?>" />
|
308 |
-
<?PHP if (!empty($jobvalue['msazureAccName']) and !empty($jobvalue['msazureKey'])) backwpup_get_msazure_container(array('msazureHost'=>$jobvalue['msazureHost'],'msazureAccName'=>$jobvalue['msazureAccName'],'msazureKey'=>$jobvalue['msazureKey'],'msazureselected'=>$jobvalue['msazureContainer'])); ?>
|
309 |
-
<?PHP _e('Create Container:','backwpup'); ?><input name="newmsazureContainer" type="text" value="" class="text" /> <br />
|
310 |
-
<b><?PHP _e('Folder in Container:','backwpup'); ?></b><br />
|
311 |
-
<input name="msazuredir" type="text" value="<?PHP echo $jobvalue['msazuredir'];?>" class="large-text" /><br />
|
312 |
-
<?PHP _e('Max. backup files in container folder:','backwpup'); ?><input name="msazuremaxbackups" type="text" size="3" value="<?PHP echo $jobvalue['msazuremaxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will be deleted first.)','backwpup');?></span><br />
|
313 |
-
</div>
|
314 |
-
<div class="destlinks">
|
315 |
-
<a href="http://www.microsoft.com/windowsazure/offers/" target="_blank"><?PHP _e('Create Account','backwpup'); ?></a><br />
|
316 |
-
<a href="http://windows.azure.com/" target="_blank"><?PHP _e('Find Key','backwpup'); ?></a><br />
|
317 |
-
</div>
|
318 |
-
<br class="clear" />
|
319 |
-
<?PHP
|
320 |
-
}
|
321 |
-
|
322 |
-
function backwpup_jobedit_metabox_destrsc($jobvalue) {
|
323 |
-
?>
|
324 |
-
<div class="dests">
|
325 |
-
<b><?PHP _e('Username:','backwpup'); ?></b><br />
|
326 |
-
<input id="rscUsername" name="rscUsername" type="text" value="<?PHP echo $jobvalue['rscUsername'];?>" class="large-text" /><br />
|
327 |
-
<b><?PHP _e('API Key:','backwpup'); ?></b><br />
|
328 |
-
<input id="rscAPIKey" name="rscAPIKey" type="text" value="<?PHP echo $jobvalue['rscAPIKey'];?>" class="large-text" /><br />
|
329 |
-
<b><?PHP _e('Container:','backwpup'); ?></b><br />
|
330 |
-
<input id="rscContainerselected" name="rscContainerselected" type="hidden" value="<?PHP echo $jobvalue['rscContainer'];?>" />
|
331 |
-
<?PHP if (!empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey'])) backwpup_get_rsc_container(array('rscUsername'=>$jobvalue['rscUsername'],'rscAPIKey'=>$jobvalue['rscAPIKey'],'rscselected'=>$jobvalue['rscContainer'])); ?>
|
332 |
-
<?PHP _e('Create Container:','backwpup'); ?><input name="newrscContainer" type="text" value="" class="text" /> <br />
|
333 |
-
<b><?PHP _e('Folder in container:','backwpup'); ?></b><br />
|
334 |
-
<input name="rscdir" type="text" value="<?PHP echo $jobvalue['rscdir'];?>" class="large-text" /><br />
|
335 |
-
<?PHP _e('Max. backup files in container folder:','backwpup'); ?><input name="rscmaxbackups" type="text" size="3" value="<?PHP echo $jobvalue['rscmaxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will be deleted first.)','backwpup');?></span><br />
|
336 |
-
</div>
|
337 |
-
<div class="destlinks">
|
338 |
-
<a href="http://www.rackspacecloud.com/2073.html" target="_blank"><?PHP _e('Create Account','backwpup'); ?></a><br />
|
339 |
-
<a href="https://manage.rackspacecloud.com/APIAccess.do" target="_blank"><?PHP _e('Find Key','backwpup'); ?></a><br />
|
340 |
-
<a href="https://manage.rackspacecloud.com/CloudFiles.do" target="_blank"><?PHP _e('Webinterface','backwpup'); ?></a><br />
|
341 |
-
</div>
|
342 |
-
<br class="clear" />
|
343 |
-
<?PHP
|
344 |
-
}
|
345 |
-
|
346 |
-
function backwpup_jobedit_metabox_destdropbox($jobvalue) {
|
347 |
-
?>
|
348 |
-
<div class="dests">
|
349 |
-
<b><?PHP _e('Login:','backwpup'); ?></b>
|
350 |
-
<?PHP if (empty($jobvalue['dropetoken']) and empty($jobvalue['dropesecret'])) { ?>
|
351 |
-
<span style="color:red;"><?php _e('Not authenticated!', 'backwpup'); ?></span> <input type="submit" name="dropboxauth" class="button-primary" accesskey="d" value="<?php _e('Authenticate!', 'backwpup'); ?>" /><br />
|
352 |
-
<?PHP } else { ?>
|
353 |
-
<span style="color:green;"><?php _e('Authenticated!', 'backwpup'); ?></span> <input type="submit" name="dropboxauthdel" class="button-primary" accesskey="d" value="<?php _e('Delete!', 'backwpup'); ?>" /><br />
|
354 |
-
<?PHP } ?><br />
|
355 |
-
<b><?PHP _e('Root:','backwpup'); ?></b><br />
|
356 |
-
<select name="droperoot" id="droperoot">
|
357 |
-
<option <?PHP selected($jobvalue['droperoot'],'dropbox',true); ?> value="dropbox"><?php _e('dropbox', 'backwpup'); ?></option>
|
358 |
-
<option <?PHP selected($jobvalue['droperoot'],'sandbox',true); ?> value="sandbox" disabled="disabled"><?php _e('sandbox (disabled by DropBox)', 'backwpup'); ?></option>
|
359 |
-
</select><br />
|
360 |
-
<b><?PHP _e('Folder:','backwpup'); ?></b><br />
|
361 |
-
<input name="dropedir" type="text" value="<?PHP echo $jobvalue['dropedir'];?>" class="user large-text" /><br />
|
362 |
-
<?PHP _e('Max. backup files in Dropbox folder:','backwpup'); ?><input name="dropemaxbackups" type="text" size="3" value="<?PHP echo $jobvalue['dropemaxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will be deleted first.)','backwpup');?></span><br />
|
363 |
-
</div>
|
364 |
-
<div class="destlinks">
|
365 |
-
<a name="dropbox" href="http://db.tt/8irM1vQ0" target="_blank"><?PHP _e('Create Account','backwpup'); ?></a><br />
|
366 |
-
<a href="https://www.dropbox.com/" target="_blank"><?PHP _e('Webinterface','backwpup'); ?></a><br />
|
367 |
-
</div>
|
368 |
-
<br class="clear" />
|
369 |
-
<?PHP
|
370 |
-
}
|
371 |
-
|
372 |
-
function backwpup_jobedit_metabox_destsugarsync($jobvalue) {
|
373 |
-
?>
|
374 |
-
<div class="dests">
|
375 |
-
<b><?PHP _e('E-mail address:','backwpup'); ?></b><br />
|
376 |
-
<input id="sugaruser" name="sugaruser" type="text" value="<?PHP echo $jobvalue['sugaruser'];?>" class="large-text" /><br />
|
377 |
-
<b><?PHP _e('Password:','backwpup'); ?></b><br />
|
378 |
-
<input id="sugarpass" name="sugarpass" type="password" value="<?PHP echo base64_decode($jobvalue['sugarpass']);?>" class="large-text" /><br />
|
379 |
-
<b><?PHP _e('Root:','backwpup'); ?></b><br />
|
380 |
-
<input id="sugarrootselected" name="sugarrootselected" type="hidden" value="<?PHP echo $jobvalue['sugarroot'];?>" />
|
381 |
-
<?PHP if (!empty($jobvalue['sugaruser']) and !empty($jobvalue['sugarpass'])) backwpup_get_sugarsync_root(array('sugaruser'=>$jobvalue['sugaruser'],'sugarpass'=>base64_decode($jobvalue['sugarpass']),'sugarrootselected'=>$jobvalue['sugarroot'])); ?><br />
|
382 |
-
<b><?PHP _e('Folder:','backwpup'); ?></b><br />
|
383 |
-
<input name="sugardir" type="text" value="<?PHP echo $jobvalue['sugardir'];?>" class="large-text" /><br />
|
384 |
-
<?PHP _e('Max. backup files in folder:','backwpup'); ?><input name="sugarmaxbackups" type="text" size="3" value="<?PHP echo $jobvalue['sugarmaxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will be deleted first.)','backwpup');?></span><br />
|
385 |
-
</div>
|
386 |
-
<div class="destlinks">
|
387 |
-
<a href="http://www.anrdoezrs.net/click-5425765-10671858" target="_blank"><?PHP _e('Create Account','backwpup'); ?></a><br />
|
388 |
-
<a href="https://sugarsync.com" target="_blank"><?PHP _e('Webinterface','backwpup'); ?></a><br />
|
389 |
-
</div>
|
390 |
-
<br class="clear" />
|
391 |
-
<?PHP
|
392 |
-
}
|
393 |
-
function backwpup_jobedit_metabox_destmail($jobvalue) {
|
394 |
-
?>
|
395 |
-
<b><?PHP _e('E-mail address:','backwpup'); ?></b><br />
|
396 |
-
<input name="mailaddress" id="mailaddress" type="text" value="<?PHP echo $jobvalue['mailaddress'];?>" class="large-text" /><br />
|
397 |
-
<?PHP if (!is_numeric($jobvalue['mailefilesize'])) $jobvalue['mailefilesize']=0; ?>
|
398 |
-
<?PHP echo __('Max. File Size for sending Backups with mail:','backwpup').'<input name="mailefilesize" type="text" value="'.$jobvalue['mailefilesize'].'" class="small-text" />MB<br />';?>
|
399 |
-
<?PHP
|
400 |
-
}
|
401 |
-
|
402 |
-
//ever display needed boxes
|
403 |
-
function backwpup_jobedit_metabox_displayneeded($hidden) {
|
404 |
-
$newhidden=array();
|
405 |
-
foreach($hidden as $hiddenid) {
|
406 |
-
if ($hiddenid!='backwpup_jobedit_save' and $hiddenid!='backwpup_jobedit_schedule')
|
407 |
-
$newhidden[]=$hiddenid;
|
408 |
-
}
|
409 |
-
return $newhidden;
|
410 |
-
}
|
411 |
-
add_filter( 'hidden_meta_boxes', 'backwpup_jobedit_metabox_displayneeded' );
|
412 |
-
|
413 |
-
//ajax/normal get cron text
|
414 |
-
function backwpup_get_cron_text($args='') {
|
415 |
-
if (is_array($args)) {
|
416 |
-
extract($args);
|
417 |
-
$ajax=false;
|
418 |
-
} else {
|
419 |
-
check_ajax_referer('backwpupeditjob_ajax_nonce');
|
420 |
-
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
421 |
-
die('-1');
|
422 |
-
if (empty($_POST['cronminutes']) or $_POST['cronminutes'][0]=='*') {
|
423 |
-
if (!empty($_POST['cronminutes'][1]))
|
424 |
-
$_POST['cronminutes']=array('*/'.$_POST['cronminutes'][1]);
|
425 |
-
else
|
426 |
-
$_POST['cronminutes']=array('*');
|
427 |
-
}
|
428 |
-
if (empty($_POST['cronhours']) or $_POST['cronhours'][0]=='*') {
|
429 |
-
if (!empty($_POST['cronhours'][1]))
|
430 |
-
$_POST['cronhours']=array('*/'.$_POST['cronhours'][1]);
|
431 |
-
else
|
432 |
-
$_POST['cronhours']=array('*');
|
433 |
-
}
|
434 |
-
if (empty($_POST['cronmday']) or $_POST['cronmday'][0]=='*') {
|
435 |
-
if (!empty($_POST['cronmday'][1]))
|
436 |
-
$_POST['cronmday']=array('*/'.$_POST['cronmday'][1]);
|
437 |
-
else
|
438 |
-
$_POST['cronmday']=array('*');
|
439 |
-
}
|
440 |
-
if (empty($_POST['cronmon']) or $_POST['cronmon'][0]=='*') {
|
441 |
-
if (!empty($_POST['cronmon'][1]))
|
442 |
-
$_POST['cronmon']=array('*/'.$_POST['cronmon'][1]);
|
443 |
-
else
|
444 |
-
$_POST['cronmon']=array('*');
|
445 |
-
}
|
446 |
-
if (empty($_POST['cronwday']) or $_POST['cronwday'][0]=='*') {
|
447 |
-
if (!empty($_POST['cronwday'][1]))
|
448 |
-
$_POST['cronwday']=array('*/'.$_POST['cronwday'][1]);
|
449 |
-
else
|
450 |
-
$_POST['cronwday']=array('*');
|
451 |
-
}
|
452 |
-
$cronstamp=implode(",",$_POST['cronminutes']).' '.implode(",",$_POST['cronhours']).' '.implode(",",$_POST['cronmday']).' '.implode(",",$_POST['cronmon']).' '.implode(",",$_POST['cronwday']);
|
453 |
-
$ajax=true;
|
454 |
-
}
|
455 |
-
echo '<div id="cron-text">';
|
456 |
-
_e('Working as <a href="http://wikipedia.org/wiki/Cron" target="_blank">Cron</a> job schedule:','backwpup'); echo ' <i><b><nobr>'.$cronstamp.'</nobr></b></i><br />';
|
457 |
-
list($cronstr['minutes'],$cronstr['hours'],$cronstr['mday'],$cronstr['mon'],$cronstr['wday'])=explode(' ',$cronstamp,5);
|
458 |
-
if (false !== strpos($cronstr['minutes'],'*/') or ($cronstr['minutes']=='*')) {
|
459 |
-
$repeatmins=str_replace('*/','',$cronstr['minutes']);
|
460 |
-
if ($repeatmins=='*' or empty($repeatmins))
|
461 |
-
$repeatmins=5;
|
462 |
-
echo '<span style="color:red;">'.str_replace('%d',$repeatmins,__('ATTENTION: Job runs every %d mins.!!!','backwpup')).'</span><br />';
|
463 |
-
}
|
464 |
-
if (false !== strpos($cronstr['hours'],'*/') or ($cronstr['hours']=='*')) {
|
465 |
-
$repeathouer=str_replace('*/','',$cronstr['hours']);
|
466 |
-
if ($repeathouer=='*' or empty($repeathouer))
|
467 |
-
$repeathouer=1;
|
468 |
-
echo '<span style="color:red;">'.str_replace('%d',$repeathouer,__('ATTENTION: Job runs every %d houers.!!!','backwpup')).'</span><br />';
|
469 |
-
}
|
470 |
-
$nextrun=backwpup_cron_next($cronstamp);
|
471 |
-
if (2147483647==$nextrun) {
|
472 |
-
echo '<span style="color:red;">'.__('ATTENTION: Can\'t calculate cron!!!','backwpup').'</span><br />';
|
473 |
-
} else {
|
474 |
-
_e('Next runtime:','backwpup'); echo ' <b>'.date_i18n('D, j M Y, H:i',backwpup_cron_next($cronstamp)).'</b>';
|
475 |
-
}
|
476 |
-
echo "</div>";
|
477 |
-
if ($ajax)
|
478 |
-
die();
|
479 |
-
else
|
480 |
-
return;
|
481 |
-
}
|
482 |
-
|
483 |
-
//ajax/normal get buckests select box
|
484 |
-
function backwpup_get_aws_buckets($args='') {
|
485 |
-
if (is_array($args)) {
|
486 |
-
extract($args);
|
487 |
-
$ajax=false;
|
488 |
-
} else {
|
489 |
-
check_ajax_referer('backwpupeditjob_ajax_nonce');
|
490 |
-
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
491 |
-
die('-1');
|
492 |
-
$awsAccessKey=$_POST['awsAccessKey'];
|
493 |
-
$awsSecretKey=$_POST['awsSecretKey'];
|
494 |
-
$awsselected=$_POST['awsselected'];
|
495 |
-
$ajax=true;
|
496 |
-
}
|
497 |
-
if (!class_exists('CFRuntime'))
|
498 |
-
require_once(dirname(__FILE__).'/../libs/aws/sdk.class.php');
|
499 |
-
if (empty($awsAccessKey)) {
|
500 |
-
echo '<span id="awsBucket" style="color:red;">'.__('Missing access key!','backwpup').'</span>';
|
501 |
-
if ($ajax)
|
502 |
-
die();
|
503 |
-
else
|
504 |
-
return;
|
505 |
-
}
|
506 |
-
if (empty($awsSecretKey)) {
|
507 |
-
echo '<span id="awsBucket" style="color:red;">'.__('Missing secret access key!','backwpup').'</span>';
|
508 |
-
if ($ajax)
|
509 |
-
die();
|
510 |
-
else
|
511 |
-
return;
|
512 |
-
}
|
513 |
-
try {
|
514 |
-
$s3 = new AmazonS3(array('key'=>$awsAccessKey,'secret'=>$awsSecretKey,'certificate_authority'=>true));
|
515 |
-
$buckets=$s3->list_buckets();
|
516 |
-
} catch (Exception $e) {
|
517 |
-
echo '<span id="awsBucket" style="color:red;">'.$e->getMessage().'</span>';
|
518 |
-
if ($ajax)
|
519 |
-
die();
|
520 |
-
else
|
521 |
-
return;
|
522 |
-
}
|
523 |
-
if ($buckets->status<200 or $buckets->status>=300) {
|
524 |
-
echo '<span id="awsBucket" style="color:red;">'.$buckets->status.': '.$buckets->body->Message.'</span>';
|
525 |
-
if ($ajax)
|
526 |
-
die();
|
527 |
-
else
|
528 |
-
return;
|
529 |
-
}
|
530 |
-
if (count($buckets->body->Buckets->Bucket)<1) {
|
531 |
-
echo '<span id="awsBucket" style="color:red;">'.__('No bucket fount!','backwpup').'</span>';
|
532 |
-
if ($ajax)
|
533 |
-
die();
|
534 |
-
else
|
535 |
-
return;
|
536 |
-
}
|
537 |
-
echo '<select name="awsBucket" id="awsBucket">';
|
538 |
-
foreach ($buckets->body->Buckets->Bucket as $bucket) {
|
539 |
-
echo "<option ".selected(strtolower($awsselected),strtolower($bucket->Name),false).">".$bucket->Name."</option>";
|
540 |
-
}
|
541 |
-
echo '</select>';
|
542 |
-
if ($ajax)
|
543 |
-
die();
|
544 |
-
else
|
545 |
-
return;
|
546 |
-
}
|
547 |
-
|
548 |
-
//ajax/normal get buckests select box
|
549 |
-
function backwpup_get_gstorage_buckets($args='') {
|
550 |
-
if (is_array($args)) {
|
551 |
-
extract($args);
|
552 |
-
$ajax=false;
|
553 |
-
} else {
|
554 |
-
check_ajax_referer('backwpupeditjob_ajax_nonce');
|
555 |
-
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
556 |
-
die('-1');
|
557 |
-
$GStorageAccessKey=$_POST['GStorageAccessKey'];
|
558 |
-
$GStorageSecret=$_POST['GStorageSecret'];
|
559 |
-
$GStorageselected=$_POST['GStorageselected'];
|
560 |
-
$ajax=true;
|
561 |
-
}
|
562 |
-
if (!class_exists('CFRuntime'))
|
563 |
-
require_once(dirname(__FILE__).'/../libs/aws/sdk.class.php');
|
564 |
-
if (empty($GStorageAccessKey)) {
|
565 |
-
echo '<span id="GStorageBucket" style="color:red;">'.__('Missing access key!','backwpup').'</span>';
|
566 |
-
if ($ajax)
|
567 |
-
die();
|
568 |
-
else
|
569 |
-
return;
|
570 |
-
}
|
571 |
-
if (empty($GStorageSecret)) {
|
572 |
-
echo '<span id="GStorageBucket" style="color:red;">'.__('Missing secret access key!','backwpup').'</span>';
|
573 |
-
if ($ajax)
|
574 |
-
die();
|
575 |
-
else
|
576 |
-
return;
|
577 |
-
}
|
578 |
-
try {
|
579 |
-
$gstorage = new AmazonS3(array('key'=>$GStorageAccessKey,'secret'=>$GStorageSecret,'certificate_authority'=>true));
|
580 |
-
$gstorage->set_hostname('commondatastorage.googleapis.com');
|
581 |
-
$gstorage->allow_hostname_override(false);
|
582 |
-
$buckets=$gstorage->list_buckets();
|
583 |
-
} catch (Exception $e) {
|
584 |
-
echo '<span id="GStorageBucket" style="color:red;">'.$e->getMessage().'</span>';
|
585 |
-
if ($ajax)
|
586 |
-
die();
|
587 |
-
else
|
588 |
-
return;
|
589 |
-
}
|
590 |
-
if ($buckets->status<200 or $buckets->status>=300) {
|
591 |
-
echo '<span id="GStorageBucket" style="color:red;">'.$buckets->status.': '.$buckets->body->Message.'</span>';
|
592 |
-
if ($ajax)
|
593 |
-
die();
|
594 |
-
else
|
595 |
-
return;
|
596 |
-
}
|
597 |
-
if (count($buckets->body->Buckets->Bucket)<1) {
|
598 |
-
echo '<span id="GStorageBucket" style="color:red;">'.__('No bucket fount!','backwpup').'</span>';
|
599 |
-
if ($ajax)
|
600 |
-
die();
|
601 |
-
else
|
602 |
-
return;
|
603 |
-
}
|
604 |
-
echo '<select name="GStorageBucket" id="GStorageBucket">';
|
605 |
-
foreach ($buckets->body->Buckets->Bucket as $bucket) {
|
606 |
-
echo "<option ".selected(strtolower($GStorageselected),strtolower($bucket->Name),false).">".$bucket->Name."</option>";
|
607 |
-
}
|
608 |
-
echo '</select>';
|
609 |
-
if ($ajax)
|
610 |
-
die();
|
611 |
-
else
|
612 |
-
return;
|
613 |
-
}
|
614 |
-
|
615 |
-
//ajax/normal get Container for RSC select box
|
616 |
-
function backwpup_get_rsc_container($args='') {
|
617 |
-
if (is_array($args)) {
|
618 |
-
extract($args);
|
619 |
-
$ajax=false;
|
620 |
-
} else {
|
621 |
-
check_ajax_referer('backwpupeditjob_ajax_nonce');
|
622 |
-
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
623 |
-
die('-1');
|
624 |
-
$rscUsername=$_POST['rscUsername'];
|
625 |
-
$rscAPIKey=$_POST['rscAPIKey'];
|
626 |
-
$rscselected=$_POST['rscselected'];
|
627 |
-
$ajax=true;
|
628 |
-
}
|
629 |
-
if (!class_exists('CF_Authentication'))
|
630 |
-
require_once(dirname(__FILE__).'/../libs/rackspace/cloudfiles.php');
|
631 |
-
|
632 |
-
if (empty($rscUsername)) {
|
633 |
-
echo '<span id="rscContainer" style="color:red;">'.__('Missing Username!','backwpup').'</span>';
|
634 |
-
if ($ajax)
|
635 |
-
die();
|
636 |
-
else
|
637 |
-
return;
|
638 |
-
}
|
639 |
-
if (empty($rscAPIKey)) {
|
640 |
-
echo '<span id="rscContainer" style="color:red;">'.__('Missing API Key!','backwpup').'</span>';
|
641 |
-
if ($ajax)
|
642 |
-
die();
|
643 |
-
else
|
644 |
-
return;
|
645 |
-
}
|
646 |
-
|
647 |
-
try {
|
648 |
-
$auth = new CF_Authentication($rscUsername, $rscAPIKey);
|
649 |
-
$auth->authenticate();
|
650 |
-
$conn = new CF_Connection($auth);
|
651 |
-
$containers=$conn->get_containers();
|
652 |
-
} catch (Exception $e) {
|
653 |
-
echo '<span id="rscContainer" style="color:red;">'.$e->getMessage().'</span>';
|
654 |
-
if ($ajax)
|
655 |
-
die();
|
656 |
-
else
|
657 |
-
return;
|
658 |
-
}
|
659 |
-
|
660 |
-
if (!is_array($containers)) {
|
661 |
-
echo '<span id="rscContainer" style="color:red;">'.__('No Containerss found!','backwpup').'</span>';
|
662 |
-
if ($ajax)
|
663 |
-
die();
|
664 |
-
else
|
665 |
-
return;
|
666 |
-
}
|
667 |
-
echo '<select name="rscContainer" id="rscContainer">';
|
668 |
-
foreach ($containers as $container) {
|
669 |
-
echo "<option ".selected(strtolower($rscselected),strtolower($container->name),false).">".$container->name."</option>";
|
670 |
-
}
|
671 |
-
echo '</select>';
|
672 |
-
if ($ajax)
|
673 |
-
die();
|
674 |
-
else
|
675 |
-
return;
|
676 |
-
}
|
677 |
-
|
678 |
-
//ajax/normal get buckests select box
|
679 |
-
function backwpup_get_msazure_container($args='') {
|
680 |
-
if (is_array($args)) {
|
681 |
-
extract($args);
|
682 |
-
$ajax=false;
|
683 |
-
} else {
|
684 |
-
check_ajax_referer('backwpupeditjob_ajax_nonce');
|
685 |
-
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
686 |
-
die('-1');
|
687 |
-
$msazureHost=$_POST['msazureHost'];
|
688 |
-
$msazureAccName=$_POST['msazureAccName'];
|
689 |
-
$msazureKey=$_POST['msazureKey'];
|
690 |
-
$msazureselected=$_POST['msazureselected'];
|
691 |
-
$ajax=true;
|
692 |
-
}
|
693 |
-
if (!class_exists('Microsoft_WindowsAzure_Storage_Blob'))
|
694 |
-
require_once(dirname(__FILE__).'/../libs/Microsoft/WindowsAzure/Storage/Blob.php');
|
695 |
-
if (empty($msazureHost)) {
|
696 |
-
echo '<span id="msazureContainer" style="color:red;">'.__('Missing Hostname!','backwpup').'</span>';
|
697 |
-
if ($ajax)
|
698 |
-
die();
|
699 |
-
else
|
700 |
-
return;
|
701 |
-
}
|
702 |
-
if (empty($msazureAccName)) {
|
703 |
-
echo '<span id="msazureContainer" style="color:red;">'.__('Missing Account Name!','backwpup').'</span>';
|
704 |
-
if ($ajax)
|
705 |
-
die();
|
706 |
-
else
|
707 |
-
return;
|
708 |
-
}
|
709 |
-
if (empty($msazureKey)) {
|
710 |
-
echo '<span id="msazureContainer" style="color:red;">'.__('Missing Access Key!','backwpup').'</span>';
|
711 |
-
if ($ajax)
|
712 |
-
die();
|
713 |
-
else
|
714 |
-
return;
|
715 |
-
}
|
716 |
-
try {
|
717 |
-
$storageClient = new Microsoft_WindowsAzure_Storage_Blob($msazureHost,$msazureAccName,$msazureKey);
|
718 |
-
$Containers=$storageClient->listContainers();
|
719 |
-
} catch (Exception $e) {
|
720 |
-
echo '<span id="msazureContainer" style="color:red;">'.$e->getMessage().'</span>';
|
721 |
-
if ($ajax)
|
722 |
-
die();
|
723 |
-
else
|
724 |
-
return;
|
725 |
-
}
|
726 |
-
if (empty($Containers)) {
|
727 |
-
echo '<span id="msazureContainer" style="color:red;">'.__('No Container found!','backwpup').'</span>';
|
728 |
-
if ($ajax)
|
729 |
-
die();
|
730 |
-
else
|
731 |
-
return;
|
732 |
-
}
|
733 |
-
echo '<select name="msazureContainer" id="msazureContainer">';
|
734 |
-
foreach ($Containers as $Container) {
|
735 |
-
echo "<option ".selected(strtolower($msazureselected),strtolower($Container->Name),false).">".$Container->Name."</option>";
|
736 |
-
}
|
737 |
-
echo '</select>';
|
738 |
-
if ($ajax)
|
739 |
-
die();
|
740 |
-
else
|
741 |
-
return;
|
742 |
-
}
|
743 |
-
|
744 |
-
//ajax/normal get SugarSync roots select box
|
745 |
-
function backwpup_get_sugarsync_root($args='') {
|
746 |
-
if (is_array($args)) {
|
747 |
-
extract($args);
|
748 |
-
$ajax=false;
|
749 |
-
} else {
|
750 |
-
check_ajax_referer('backwpupeditjob_ajax_nonce');
|
751 |
-
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
752 |
-
die('-1');
|
753 |
-
$sugaruser=$_POST['sugaruser'];
|
754 |
-
$sugarpass=$_POST['sugarpass'];
|
755 |
-
$sugarrootselected=$_POST['sugarrootselected'];
|
756 |
-
$ajax=true;
|
757 |
-
}
|
758 |
-
if (!class_exists('SugarSync'))
|
759 |
-
require_once(dirname(__FILE__).'/../libs/sugarsync.php');
|
760 |
-
|
761 |
-
if (empty($sugaruser)) {
|
762 |
-
echo '<span id="sugarroot" style="color:red;">'.__('Missing Username!','backwpup').'</span>';
|
763 |
-
if ($ajax)
|
764 |
-
die();
|
765 |
-
else
|
766 |
-
return;
|
767 |
-
}
|
768 |
-
if (empty($sugarpass)) {
|
769 |
-
echo '<span id="sugarroot" style="color:red;">'.__('Missing Password!','backwpup').'</span>';
|
770 |
-
if ($ajax)
|
771 |
-
die();
|
772 |
-
else
|
773 |
-
return;
|
774 |
-
}
|
775 |
-
|
776 |
-
try {
|
777 |
-
$sugarsync = new SugarSync($sugaruser,$sugarpass,BACKWPUP_SUGARSYNC_ACCESSKEY, BACKWPUP_SUGARSYNC_PRIVATEACCESSKEY);
|
778 |
-
$user=$sugarsync->user();
|
779 |
-
$syncfolders=$sugarsync->get($user->syncfolders);
|
780 |
-
} catch (Exception $e) {
|
781 |
-
echo '<span id="sugarroot" style="color:red;">'.$e->getMessage().'</span>';
|
782 |
-
if ($ajax)
|
783 |
-
die();
|
784 |
-
else
|
785 |
-
return;
|
786 |
-
}
|
787 |
-
|
788 |
-
if (!is_object($syncfolders)) {
|
789 |
-
echo '<span id="sugarroot" style="color:red;">'.__('No Syncfolders found!','backwpup').'</span>';
|
790 |
-
if ($ajax)
|
791 |
-
die();
|
792 |
-
else
|
793 |
-
return;
|
794 |
-
}
|
795 |
-
echo '<select name="sugarroot" id="sugarroot">';
|
796 |
-
foreach ($syncfolders->collection as $roots) {
|
797 |
-
echo "<option ".selected(strtolower($sugarrootselected),strtolower($roots->ref),false)." value=\"".$roots->ref."\">".$roots->displayName."</option>";
|
798 |
-
}
|
799 |
-
echo '</select>';
|
800 |
-
if ($ajax)
|
801 |
-
die();
|
802 |
-
else
|
803 |
-
return;
|
804 |
-
}
|
805 |
-
//add ajax function
|
806 |
-
add_action('wp_ajax_backwpup_get_cron_text', 'backwpup_get_cron_text');
|
807 |
-
add_action('wp_ajax_backwpup_get_aws_buckets', 'backwpup_get_aws_buckets');
|
808 |
-
add_action('wp_ajax_backwpup_get_gstorage_buckets', 'backwpup_get_gstorage_buckets');
|
809 |
-
add_action('wp_ajax_backwpup_get_rsc_container', 'backwpup_get_rsc_container');
|
810 |
-
add_action('wp_ajax_backwpup_get_msazure_container', 'backwpup_get_msazure_container');
|
811 |
-
add_action('wp_ajax_backwpup_get_sugarsync_root', 'backwpup_get_sugarsync_root');
|
812 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
function backwpup_jobedit_metabox_save($jobvalue) {
|
3 |
+
?>
|
4 |
+
<div class="submitbox" id="submitjobedit">
|
5 |
+
<div id="minor-publishing">
|
6 |
+
<div id="minor-publishing-actions">
|
7 |
+
<div id="preview-action">
|
8 |
+
</div>
|
9 |
+
<div class="clear"></div>
|
10 |
+
</div>
|
11 |
+
<div id="misc-publishing-actions">
|
12 |
+
<div class="misc-pub-section misc-pub-section-last">
|
13 |
+
<?php
|
14 |
+
foreach (backwpup_backup_types() as $type) {
|
15 |
+
echo "<input class=\"jobtype-select checkbox\" id=\"jobtype-select-".$type."\" type=\"checkbox\"".checked(true,in_array($type,explode('+',$jobvalue['type'])),false)." name=\"type[]\" value=\"".$type."\"/> ".backwpup_backup_types($type);
|
16 |
+
}
|
17 |
+
if (!function_exists('curl_init'))
|
18 |
+
echo '<br /><strong style="color:red;">'.__( 'PHP curl functions not available! Most backup destinations deaktivated!', 'backwpup' ).'</strong>';
|
19 |
+
?>
|
20 |
+
</div>
|
21 |
+
</div>
|
22 |
+
</div>
|
23 |
+
<div id="major-publishing-actions">
|
24 |
+
<div id="delete-action">
|
25 |
+
<a class="submitdelete deletion" href="<?PHP echo wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpup&action=delete&jobs[]='.$jobvalue['jobid'], 'bulk-jobs'); ?>" onclick="if ( confirm('<?PHP echo esc_js(__("You are about to delete this Job. \n 'Cancel' to stop, 'OK' to delete.","backwpup")); ?>') ) { return true;}return false;"><?php _e('Delete', 'backwpup'); ?></a>
|
26 |
+
</div>
|
27 |
+
<div id="publishing-action">
|
28 |
+
<?php submit_button( __('Save Changes', 'backwpup'), 'primary', 'save', false, array( 'tabindex' => '2', 'accesskey' => 'p' ) ); ?>
|
29 |
+
</div>
|
30 |
+
<div class="clear"></div>
|
31 |
+
</div>
|
32 |
+
</div>
|
33 |
+
<?PHP
|
34 |
+
}
|
35 |
+
|
36 |
+
function backwpup_jobedit_metabox_backupfile($jobvalue) {
|
37 |
+
?>
|
38 |
+
<b><?PHP _e('File Prefix:','backwpup'); ?></b><br />
|
39 |
+
<input name="fileprefix" type="text" value="<?PHP echo $jobvalue['fileprefix'];?>" class="large-text" /><br />
|
40 |
+
<b><?PHP _e('File Formart:','backwpup'); ?></b><br />
|
41 |
+
<?PHP
|
42 |
+
if (function_exists('gzopen') or class_exists('ZipArchive'))
|
43 |
+
echo '<input class="radio" type="radio"'.checked('.zip',$jobvalue['fileformart'],false).' name="fileformart" value=".zip" />'.__('Zip','backwpup').'<br />';
|
44 |
+
else
|
45 |
+
echo '<input class="radio" type="radio"'.checked('.zip',$jobvalue['fileformart'],false).' name="fileformart" value=".zip" disabled="disabled" />'.__('Zip','backwpup').'<br />';
|
46 |
+
echo '<input class="radio" type="radio"'.checked('.tar',$jobvalue['fileformart'],false).' name="fileformart" value=".tar" />'.__('Tar','backwpup').'<br />';
|
47 |
+
if (function_exists('gzopen'))
|
48 |
+
echo '<input class="radio" type="radio"'.checked('.tar.gz',$jobvalue['fileformart'],false).' name="fileformart" value=".tar.gz" />'.__('Tar GZip','backwpup').'<br />';
|
49 |
+
else
|
50 |
+
echo '<input class="radio" type="radio"'.checked('.tar.gz',$jobvalue['fileformart'],false).' name="fileformart" value=".tar.gz" disabled="disabled" />'.__('Tar GZip','backwpup').'<br />';
|
51 |
+
if (function_exists('bzopen'))
|
52 |
+
echo '<input class="radio" type="radio"'.checked('.tar.bz2',$jobvalue['fileformart'],false).' name="fileformart" value=".tar.bz2" />'.__('Tar BZip2','backwpup').'<br />';
|
53 |
+
else
|
54 |
+
echo '<input class="radio" type="radio"'.checked('.tar.bz2',$jobvalue['fileformart'],false).' name="fileformart" value=".tar.bz2" disabled="disabled" />'.__('Tar BZip2','backwpup').'<br />';
|
55 |
+
_e('Preview:','backwpup');
|
56 |
+
echo '<br /><i><span id="backupfileprefix">'.$jobvalue['fileprefix'].'</span>'.backwpup_date_i18n('Y-m-d_H-i-s').'<span id="backupfileformart">'.$jobvalue['fileformart'].'</span></i>';
|
57 |
+
}
|
58 |
+
|
59 |
+
function backwpup_jobedit_metabox_sendlog($jobvalue) {
|
60 |
+
_e('E-Mail-Adress:','backwpup'); ?>
|
61 |
+
<input name="mailaddresslog" id="mailaddresslog" type="text" value="<?PHP echo $jobvalue['mailaddresslog'];?>" class="large-text" /><br />
|
62 |
+
<input class="checkbox" value="1" type="checkbox" <?php checked($jobvalue['mailerroronly'],true); ?> name="mailerroronly" /> <?PHP _e('Only send an e-mail if there are errors.','backwpup'); ?>
|
63 |
+
<?PHP
|
64 |
+
}
|
65 |
+
|
66 |
+
function backwpup_jobedit_metabox_schedule($jobvalue) {
|
67 |
+
list($cronstr['minutes'],$cronstr['hours'],$cronstr['mday'],$cronstr['mon'],$cronstr['wday'])=explode(' ',$jobvalue['cron'],5);
|
68 |
+
if (strstr($cronstr['minutes'],'*/'))
|
69 |
+
$minutes=explode('/',$cronstr['minutes']);
|
70 |
+
else
|
71 |
+
$minutes=explode(',',$cronstr['minutes']);
|
72 |
+
if (strstr($cronstr['hours'],'*/'))
|
73 |
+
$hours=explode('/',$cronstr['hours']);
|
74 |
+
else
|
75 |
+
$hours=explode(',',$cronstr['hours']);
|
76 |
+
if (strstr($cronstr['mday'],'*/'))
|
77 |
+
$mday=explode('/',$cronstr['mday']);
|
78 |
+
else
|
79 |
+
$mday=explode(',',$cronstr['mday']);
|
80 |
+
if (strstr($cronstr['mon'],'*/'))
|
81 |
+
$mon=explode('/',$cronstr['mon']);
|
82 |
+
else
|
83 |
+
$mon=explode(',',$cronstr['mon']);
|
84 |
+
if (strstr($cronstr['wday'],'*/'))
|
85 |
+
$wday=explode('/',$cronstr['wday']);
|
86 |
+
else
|
87 |
+
$wday=explode(',',$cronstr['wday']);
|
88 |
+
backwpup_get_cron_text(array('cronstamp'=>$jobvalue['cron']));
|
89 |
+
?>
|
90 |
+
<br />
|
91 |
+
<b><input class="checkbox" value="1" type="checkbox" <?php checked($jobvalue['activated'],true); ?> name="activated" /> <?PHP _e('Activate scheduling', 'backwpup'); ?></b><br /><br />
|
92 |
+
<?PHP echo '<input class="radio" type="radio"'.checked("advanced",$jobvalue['cronselect'],false).' name="cronselect" value="advanced" />'.__('advanced','backwpup').' ';
|
93 |
+
echo '<input class="radio" type="radio"'.checked("basic",$jobvalue['cronselect'],false).' name="cronselect" value="basic" />'.__('basic','backwpup');?>
|
94 |
+
<br /><br />
|
95 |
+
<div id="schedadvanced" <?PHP if ($jobvalue['cronselect']!='advanced') echo 'style="display:none;"';?>>
|
96 |
+
<div id="cron-min-box">
|
97 |
+
<b><?PHP _e('Minutes: ','backwpup'); ?></b><br />
|
98 |
+
<?PHP
|
99 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("*",$minutes,true),true,false).' name="cronminutes[]" value="*" /> '.__('Any (*)','backwpup').'<br />';
|
100 |
+
echo '<div id="cron-min">';
|
101 |
+
for ($i=0;$i<60;$i=$i+5) {
|
102 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("$i",$minutes,true),true,false).' name="cronminutes[]" value="'.$i.'" /> '.$i.'<br />';
|
103 |
+
}
|
104 |
+
?>
|
105 |
+
</div>
|
106 |
+
</div>
|
107 |
+
<div id="cron-hour-box">
|
108 |
+
<b><?PHP _e('Hours:','backwpup'); ?></b><br />
|
109 |
+
<?PHP
|
110 |
+
|
111 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("*",$hours,true),true,false).' name="cronhours[]" value="*" /> '.__('Any (*)','backwpup').'<br />';
|
112 |
+
echo '<div id="cron-hour">';
|
113 |
+
for ($i=0;$i<24;$i++) {
|
114 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("$i",$hours,true),true,false).' name="cronhours[]" value="'.$i.'" /> '.$i.'<br />';
|
115 |
+
}
|
116 |
+
?>
|
117 |
+
</div>
|
118 |
+
</div>
|
119 |
+
<div id="cron-day-box">
|
120 |
+
<b><?PHP _e('Day of Month:','backwpup'); ?></b><br />
|
121 |
+
<?PHP
|
122 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("*",$mday,true),true,false).' name="cronmday[]" value="*" /> '.__('Any (*)','backwpup').'<br />';
|
123 |
+
echo '<div id="cron-day">';
|
124 |
+
for ($i=1;$i<=31;$i++) {
|
125 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("$i",$mday,true),true,false).' name="cronmday[]" value="'.$i.'" /> '.$i.'<br />';
|
126 |
+
}
|
127 |
+
?>
|
128 |
+
</div>
|
129 |
+
</div>
|
130 |
+
<div id="cron-month-box">
|
131 |
+
<b><?PHP _e('Month:','backwpup'); ?></b><br />
|
132 |
+
<?PHP
|
133 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("*",$mday,true),true,false).' name="cronmon[]" value="*" /> '.__('Any (*)','backwpup').'<br />';
|
134 |
+
echo '<div id="cron-month">';
|
135 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("1",$mday,true),true,false).' name="cronmon[]" value="1" /> '.__('January','backwpup').'<br />';
|
136 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("2",$mday,true),true,false).' name="cronmon[]" value="2" /> '.__('February','backwpup').'<br />';
|
137 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("3",$mday,true),true,false).' name="cronmon[]" value="3" /> '.__('March','backwpup').'<br />';
|
138 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("4",$mday,true),true,false).' name="cronmon[]" value="4" /> '.__('April','backwpup').'<br />';
|
139 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("5",$mday,true),true,false).' name="cronmon[]" value="5" /> '.__('May','backwpup').'<br />';
|
140 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("6",$mday,true),true,false).' name="cronmon[]" value="6" /> '.__('June','backwpup').'<br />';
|
141 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("7",$mday,true),true,false).' name="cronmon[]" value="7" /> '.__('July','backwpup').'<br />';
|
142 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("8",$mday,true),true,false).' name="cronmon[]" value="8" /> '.__('Augest','backwpup').'<br />';
|
143 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("9",$mday,true),true,false).' name="cronmon[]" value="9" /> '.__('September','backwpup').'<br />';
|
144 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("10",$mday,true),true,false).' name="cronmon[]" value="10" /> '.__('October','backwpup').'<br />';
|
145 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("11",$mday,true),true,false).' name="cronmon[]" value="11" /> '.__('November','backwpup').'<br />';
|
146 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("12",$mday,true),true,false).' name="cronmon[]" value="12" /> '.__('December','backwpup').'<br />';
|
147 |
+
?>
|
148 |
+
</div>
|
149 |
+
</div>
|
150 |
+
<div id="cron-weekday-box">
|
151 |
+
<b><?PHP _e('Day of Week:','backwpup'); ?></b><br />
|
152 |
+
<?PHP
|
153 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("*",$wday,true),true,false).' name="cronwday[]" value="*" /> '.__('Any (*)','backwpup').'<br />';
|
154 |
+
echo '<div id="cron-weekday">';
|
155 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("0",$wday,true),true,false).' name="cronwday[]" value="0" /> '.__('Sunday','backwpup').'<br />';
|
156 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("1",$wday,true),true,false).' name="cronwday[]" value="1" /> '.__('Monday','backwpup').'<br />';
|
157 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("2",$wday,true),true,false).' name="cronwday[]" value="2" /> '.__('Tuesday','backwpup').'<br />';
|
158 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("3",$wday,true),true,false).' name="cronwday[]" value="3" /> '.__('Wednesday','backwpup').'<br />';
|
159 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("4",$wday,true),true,false).' name="cronwday[]" value="4" /> '.__('Thursday','backwpup').'<br />';
|
160 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("5",$wday,true),true,false).' name="cronwday[]" value="5" /> '.__('Friday','backwpup').'<br />';
|
161 |
+
echo '<input class="checkbox" type="checkbox"'.checked(in_array("6",$wday,true),true,false).' name="cronwday[]" value="6" /> '.__('Saturday','backwpup').'<br />';
|
162 |
+
?>
|
163 |
+
</div>
|
164 |
+
</div>
|
165 |
+
<br class="clear" />
|
166 |
+
</div>
|
167 |
+
<div id="schedbasic" <?PHP if ($jobvalue['cronselect']!='basic') echo 'style="display:none;"';?>>
|
168 |
+
<table>
|
169 |
+
<tr>
|
170 |
+
<th>
|
171 |
+
<?PHP _e('Type','backwpup') ?>
|
172 |
+
</th>
|
173 |
+
<th>
|
174 |
+
</th>
|
175 |
+
<th>
|
176 |
+
<?PHP _e('Hour','backwpup') ?>
|
177 |
+
</th>
|
178 |
+
<th>
|
179 |
+
<?PHP _e('Minute','backwpup') ?>
|
180 |
+
</th>
|
181 |
+
</tr>
|
182 |
+
<tr>
|
183 |
+
<td><?PHP echo '<input class="radio" type="radio"'.checked(true,is_numeric($mday[0]),false).' name="cronbtype" value="mon" />'.__('monthly','backwpup'); ?></td>
|
184 |
+
<td><select name="moncronmday"><?PHP for ($i=1;$i<=31;$i++) {echo '<option '.selected(in_array("$i",$mday,true),true,false).' value="'.$i.'" />'.__('on','backwpup').' '.$i.'.</option>';} ?></select></td>
|
185 |
+
<td><select name="moncronhours"><?PHP for ($i=0;$i<24;$i++) {echo '<option '.selected(in_array("$i",$hours,true),true,false).' value="'.$i.'" />'.$i.'</option>';} ?></select></td>
|
186 |
+
<td><select name="moncronminutes"><?PHP for ($i=0;$i<60;$i=$i+5) {echo '<option '.selected(in_array("$i",$minutes,true),true,false).' value="'.$i.'" />'.$i.'</option>';} ?></select></td>
|
187 |
+
</tr>
|
188 |
+
<tr>
|
189 |
+
<td><?PHP echo '<input class="radio" type="radio"'.checked(true,is_numeric($wday[0]),false).' name="cronbtype" value="week" />'.__('weekly','backwpup'); ?></td>
|
190 |
+
<td><select name="weekcronwday">
|
191 |
+
<?PHP echo '<option '.selected(in_array("0",$wday,true),true,false).' value="0" />'.__('Sunday','backwpup').'</option>';
|
192 |
+
echo '<option '.selected(in_array("1",$wday,true),true,false).' value="1" />'.__('Monday','backwpup').'</option>';
|
193 |
+
echo '<option '.selected(in_array("2",$wday,true),true,false).' value="2" />'.__('Tuesday','backwpup').'</option>';
|
194 |
+
echo '<option '.selected(in_array("3",$wday,true),true,false).' value="3" />'.__('Wednesday','backwpup').'</option>';
|
195 |
+
echo '<option '.selected(in_array("4",$wday,true),true,false).' value="4" />'.__('Thursday','backwpup').'</option>';
|
196 |
+
echo '<option '.selected(in_array("5",$wday,true),true,false).' value="5" />'.__('Friday','backwpup').'</option>';
|
197 |
+
echo '<option '.selected(in_array("6",$wday,true),true,false).' value="6" />'.__('Saturday','backwpup').'</option>'; ?>
|
198 |
+
</select></td>
|
199 |
+
<td><select name="weekcronhours"><?PHP for ($i=0;$i<24;$i++) {echo '<option '.selected(in_array("$i",$hours,true),true,false).' value="'.$i.'" />'.$i.'</option>';} ?></select></td>
|
200 |
+
<td><select name="weekcronminutes"><?PHP for ($i=0;$i<60;$i=$i+5) {echo '<option '.selected(in_array("$i",$minutes,true),true,false).' value="'.$i.'" />'.$i.'</option>';} ?></select></td>
|
201 |
+
</tr>
|
202 |
+
<tr>
|
203 |
+
<td><?PHP echo '<input class="radio" type="radio"'.checked("**",$mday[0].$wday[0],false).' name="cronbtype" value="day" />'.__('daily','backwpup'); ?></td>
|
204 |
+
<td></td>
|
205 |
+
<td><select name="daycronhours"><?PHP for ($i=0;$i<24;$i++) {echo '<option '.selected(in_array("$i",$hours,true),true,false).' value="'.$i.'" />'.$i.'</option>';} ?></select></td>
|
206 |
+
<td><select name="daycronminutes"><?PHP for ($i=0;$i<60;$i=$i+5) {echo '<option '.selected(in_array("$i",$minutes,true),true,false).' value="'.$i.'" />'.$i.'</option>';} ?></select></td>
|
207 |
+
</tr>
|
208 |
+
<tr>
|
209 |
+
<td><?PHP echo '<input class="radio" type="radio"'.checked("*",$hours[0],false,false).' name="cronbtype" value="hour" />'.__('hourly','backwpup'); ?></td>
|
210 |
+
<td></td>
|
211 |
+
<td></td>
|
212 |
+
<td><select name="hourcronminutes"><?PHP for ($i=0;$i<60;$i=$i+5) {echo '<option '.selected(in_array("$i",$minutes,true),true,false).' value="'.$i.'" />'.$i.'</option>';} ?></select></td>
|
213 |
+
</tr>
|
214 |
+
</table>
|
215 |
+
</div>
|
216 |
+
<?PHP
|
217 |
+
}
|
218 |
+
|
219 |
+
function backwpup_jobedit_metabox_destfolder($jobvalue) {
|
220 |
+
?>
|
221 |
+
<b><?PHP _e('Full Path to folder for Backup Files:','backwpup'); ?></b><br />
|
222 |
+
<input name="backupdir" id="backupdir" type="text" value="<?PHP echo $jobvalue['backupdir'];?>" class="large-text" /><br />
|
223 |
+
<span class="description"><?PHP _e('Your WordPress dir is:','backwpup'); echo ' '.trailingslashit(str_replace('\\','/',ABSPATH));?></span><br /> <br />
|
224 |
+
<?PHP _e('Max. backup files in folder:','backwpup'); ?> <input name="maxbackups" id="maxbackups" type="text" size="3" value="<?PHP echo $jobvalue['maxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will deleted first.)','backwpup');?></span>
|
225 |
+
<?PHP
|
226 |
+
}
|
227 |
+
|
228 |
+
function backwpup_jobedit_metabox_destftp($jobvalue) {
|
229 |
+
?>
|
230 |
+
<b><?PHP _e('Hostname:','backwpup'); ?></b><br />
|
231 |
+
<input name="ftphost" type="text" value="<?PHP echo $jobvalue['ftphost'];?>" class="large-text" /><br />
|
232 |
+
<b><?PHP _e('Port:','backwpup'); ?></b><br />
|
233 |
+
<input name="ftphostport" type="text" value="<?PHP echo $jobvalue['ftphostport'];?>" class="small-text" /><br />
|
234 |
+
<b><?PHP _e('Username:','backwpup'); ?></b><br />
|
235 |
+
<input name="ftpuser" type="text" value="<?PHP echo $jobvalue['ftpuser'];?>" class="user large-text" /><br />
|
236 |
+
<b><?PHP _e('Password:','backwpup'); ?></b><br />
|
237 |
+
<input name="ftppass" type="password" value="<?PHP echo base64_decode($jobvalue['ftppass']);?>" class="password large-text" /><br />
|
238 |
+
<b><?PHP _e('Folder on Server:','backwpup'); ?></b><br />
|
239 |
+
<input name="ftpdir" type="text" value="<?PHP echo $jobvalue['ftpdir'];?>" class="large-text" /><br />
|
240 |
+
<?PHP if (!is_numeric($jobvalue['ftpmaxbackups'])) $jobvalue['ftpmaxbackups']=0; ?>
|
241 |
+
<?PHP _e('Max. backup files in FTP folder:','backwpup'); ?> <input name="ftpmaxbackups" type="text" size="3" value="<?PHP echo $jobvalue['ftpmaxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will be deleted first.)','backwpup');?></span><br />
|
242 |
+
<input class="checkbox" value="1" type="checkbox" <?php checked($jobvalue['ftpssl'],true); ?> name="ftpssl" /> <?PHP _e('Use SSL-FTP Connection.','backwpup'); ?><br />
|
243 |
+
<input class="checkbox" value="1" type="checkbox" <?php checked($jobvalue['ftppasv'],true); ?> name="ftppasv" /> <?PHP _e('Use FTP Passiv mode.','backwpup'); ?><br />
|
244 |
+
<?PHP
|
245 |
+
}
|
246 |
+
|
247 |
+
function backwpup_jobedit_metabox_dests3($jobvalue) {
|
248 |
+
?>
|
249 |
+
<div class="dests">
|
250 |
+
<b><?PHP _e('Access Key ID:','backwpup'); ?></b>
|
251 |
+
<input id="awsAccessKey" name="awsAccessKey" type="text" value="<?PHP echo $jobvalue['awsAccessKey'];?>" class="large-text" /><br />
|
252 |
+
<b><?PHP _e('Secret Access Key:','backwpup'); ?></b><br />
|
253 |
+
<input id="awsSecretKey" name="awsSecretKey" type="password" value="<?PHP echo $jobvalue['awsSecretKey'];?>" class="large-text" /><br />
|
254 |
+
<b><?PHP _e('Bucket:','backwpup'); ?></b><br />
|
255 |
+
<input id="awsBucketselected" name="awsBucketselected" type="hidden" value="<?PHP echo $jobvalue['awsBucket'];?>" />
|
256 |
+
<?PHP if (!empty($jobvalue['awsAccessKey']) and !empty($jobvalue['awsSecretKey'])) backwpup_get_aws_buckets(array('awsAccessKey'=>$jobvalue['awsAccessKey'],'awsSecretKey'=>$jobvalue['awsSecretKey'],'awsselected'=>$jobvalue['awsBucket'])); ?>
|
257 |
+
<?PHP _e('Create bucket:','backwpup'); ?><input name="newawsBucket" type="text" value="" class="text" /> <select name="awsRegion" title="<?php _e('Bucket Region', 'backwpup'); ?>"><option value="s3.amazonaws.com"><?php _e('US-Standard (Northern Virginia & Washington State)', 'backwpup'); ?></option><option value="s3-us-west-1.amazonaws.com"><?php _e('US-West 1 (Northern California)', 'backwpup'); ?></option><option value="s3-us-west-2.amazonaws.com"><?php _e('US-West 2 (Oregon)', 'backwpup'); ?></option><option value="s3-eu-west-1.amazonaws.com"><?php _e('EU (Ireland)', 'backwpup'); ?></option><option value="s3-ap-southeast-1.amazonaws.com"><?php _e('Asia Pacific (Singapore)', 'backwpup'); ?></option><option value="s3-ap-northeast-1.amazonaws.com"><?php _e('Asia Pacific (Japan)', 'backwpup'); ?></option><option value="s3-sa-east-1.amazonaws.com"><?php _e('South America (Sao Paulo)', 'backwpup'); ?></option><option value="s3-us-gov-west-1.amazonaws.com"><?php _e('United States GovCloud', 'backwpup'); ?></option><option value="s3-fips-us-gov-west-1.amazonaws.com"><?php _e('United States GovCloud FIPS 140-2', 'backwpup'); ?></option></select><br />
|
258 |
+
<b><?PHP _e('Folder in bucket:','backwpup'); ?></b><br />
|
259 |
+
<input name="awsdir" type="text" value="<?PHP echo $jobvalue['awsdir'];?>" class="large-text" /><br />
|
260 |
+
<?PHP _e('Max. backup files in bucket folder:','backwpup'); ?><input name="awsmaxbackups" type="text" size="3" value="<?PHP echo $jobvalue['awsmaxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will be deleted first.)','backwpup');?></span><br />
|
261 |
+
<input class="checkbox" value="1" type="checkbox" <?php checked($jobvalue['awsrrs'],true); ?> name="awsrrs" /> <?PHP _e('Save Backups with reduced redundancy!','backwpup'); ?><br />
|
262 |
+
</div>
|
263 |
+
<div class="destlinks">
|
264 |
+
<a href="http://www.amazon.de/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2Fgp%2Faws%2Fregistration%2Fregistration-form.html&site-redirect=de&tag=hueskennet-21&linkCode=ur2&camp=1638&creative=6742" target="_blank"><?PHP _e('Create Account','backwpup'); ?></a><br />
|
265 |
+
<a href="http://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key" target="_blank"><?PHP _e('Find Keys','backwpup'); ?></a><br />
|
266 |
+
<a href="https://console.aws.amazon.com/s3/home" target="_blank"><?PHP _e('Webinterface','backwpup'); ?></a><br />
|
267 |
+
</div>
|
268 |
+
<br class="clear" />
|
269 |
+
<?PHP
|
270 |
+
}
|
271 |
+
|
272 |
+
function backwpup_jobedit_metabox_destgstorage($jobvalue) {
|
273 |
+
?>
|
274 |
+
<div class="dests">
|
275 |
+
<b><?PHP _e('Access Key:','backwpup'); ?></b><br />
|
276 |
+
<input id="GStorageAccessKey" name="GStorageAccessKey" type="text" value="<?PHP echo $jobvalue['GStorageAccessKey'];?>" class="large-text" /><br />
|
277 |
+
<b><?PHP _e('Secret:','backwpup'); ?></b><br />
|
278 |
+
<input id="GStorageSecret" name="GStorageSecret" type="password" value="<?PHP echo $jobvalue['GStorageSecret'];?>" class="large-text" /><br />
|
279 |
+
<b><?PHP _e('Bucket:','backwpup'); ?></b><br />
|
280 |
+
<input id="GStorageselected" name="GStorageselected" type="hidden" value="<?PHP echo $jobvalue['GStorageBucket'];?>" />
|
281 |
+
<?PHP if (!empty($jobvalue['GStorageAccessKey']) and !empty($jobvalue['GStorageSecret'])) backwpup_get_gstorage_buckets(array('GStorageAccessKey'=>$jobvalue['GStorageAccessKey'],'GStorageSecret'=>$jobvalue['GStorageSecret'],'GStorageselected'=>$jobvalue['GStorageBucket'])); ?>
|
282 |
+
<?PHP _e('Create bucket:','backwpup'); ?><input name="newGStorageBucket" type="text" value="" class="text" /><br />
|
283 |
+
<b><?PHP _e('Folder in bucket:','backwpup'); ?></b><br />
|
284 |
+
<input name="GStoragedir" type="text" value="<?PHP echo $jobvalue['GStoragedir'];?>" class="large-text" /><br />
|
285 |
+
<?PHP _e('Max. backup files in bucket folder:','backwpup'); ?><input name="GStoragemaxbackups" type="text" size="3" value="<?PHP echo $jobvalue['GStoragemaxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will be deleted first.)','backwpup');?></span><br />
|
286 |
+
</div>
|
287 |
+
<div class="destlinks">
|
288 |
+
<a href="http://code.google.com/apis/storage/docs/signup.html" target="_blank"><?PHP _e('Create Account','backwpup'); ?></a><br />
|
289 |
+
<a href="https://code.google.com/apis/console/" target="_blank"><?PHP _e('Find Keys','backwpup'); ?></a><br />
|
290 |
+
<a href="https://storage.cloud.google.com/" target="_blank"><?PHP _e('Webinterface','backwpup'); ?></a><br />
|
291 |
+
</div>
|
292 |
+
<br class="clear" />
|
293 |
+
<?PHP
|
294 |
+
}
|
295 |
+
|
296 |
+
function backwpup_jobedit_metabox_destazure($jobvalue) {
|
297 |
+
?>
|
298 |
+
<div class="dests">
|
299 |
+
|
300 |
+
<b><?PHP _e('Host:','backwpup'); ?></b><br />
|
301 |
+
<input id="msazureHost" name="msazureHost" type="text" value="<?PHP echo $jobvalue['msazureHost'];?>" class="large-text" /><span class="description"><?PHP _e('Normely: blob.core.windows.net','backwpup');?></span><br />
|
302 |
+
<b><?PHP _e('Account Name:','backwpup'); ?></b><br />
|
303 |
+
<input id="msazureAccName" name="msazureAccName" type="text" value="<?PHP echo $jobvalue['msazureAccName'];?>" class="large-text" /><br />
|
304 |
+
<b><?PHP _e('Access Key:','backwpup'); ?></b><br />
|
305 |
+
<input id="msazureKey" name="msazureKey" type="password" value="<?PHP echo $jobvalue['msazureKey'];?>" class="large-text" /><br />
|
306 |
+
<b><?PHP _e('Container:','backwpup'); ?></b><br />
|
307 |
+
<input id="msazureContainerselected" name="msazureContainerselected" type="hidden" value="<?PHP echo $jobvalue['msazureContainer'];?>" />
|
308 |
+
<?PHP if (!empty($jobvalue['msazureAccName']) and !empty($jobvalue['msazureKey'])) backwpup_get_msazure_container(array('msazureHost'=>$jobvalue['msazureHost'],'msazureAccName'=>$jobvalue['msazureAccName'],'msazureKey'=>$jobvalue['msazureKey'],'msazureselected'=>$jobvalue['msazureContainer'])); ?>
|
309 |
+
<?PHP _e('Create Container:','backwpup'); ?><input name="newmsazureContainer" type="text" value="" class="text" /> <br />
|
310 |
+
<b><?PHP _e('Folder in Container:','backwpup'); ?></b><br />
|
311 |
+
<input name="msazuredir" type="text" value="<?PHP echo $jobvalue['msazuredir'];?>" class="large-text" /><br />
|
312 |
+
<?PHP _e('Max. backup files in container folder:','backwpup'); ?><input name="msazuremaxbackups" type="text" size="3" value="<?PHP echo $jobvalue['msazuremaxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will be deleted first.)','backwpup');?></span><br />
|
313 |
+
</div>
|
314 |
+
<div class="destlinks">
|
315 |
+
<a href="http://www.microsoft.com/windowsazure/offers/" target="_blank"><?PHP _e('Create Account','backwpup'); ?></a><br />
|
316 |
+
<a href="http://windows.azure.com/" target="_blank"><?PHP _e('Find Key','backwpup'); ?></a><br />
|
317 |
+
</div>
|
318 |
+
<br class="clear" />
|
319 |
+
<?PHP
|
320 |
+
}
|
321 |
+
|
322 |
+
function backwpup_jobedit_metabox_destrsc($jobvalue) {
|
323 |
+
?>
|
324 |
+
<div class="dests">
|
325 |
+
<b><?PHP _e('Username:','backwpup'); ?></b><br />
|
326 |
+
<input id="rscUsername" name="rscUsername" type="text" value="<?PHP echo $jobvalue['rscUsername'];?>" class="large-text" /><br />
|
327 |
+
<b><?PHP _e('API Key:','backwpup'); ?></b><br />
|
328 |
+
<input id="rscAPIKey" name="rscAPIKey" type="text" value="<?PHP echo $jobvalue['rscAPIKey'];?>" class="large-text" /><br />
|
329 |
+
<b><?PHP _e('Container:','backwpup'); ?></b><br />
|
330 |
+
<input id="rscContainerselected" name="rscContainerselected" type="hidden" value="<?PHP echo $jobvalue['rscContainer'];?>" />
|
331 |
+
<?PHP if (!empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey'])) backwpup_get_rsc_container(array('rscUsername'=>$jobvalue['rscUsername'],'rscAPIKey'=>$jobvalue['rscAPIKey'],'rscselected'=>$jobvalue['rscContainer'])); ?>
|
332 |
+
<?PHP _e('Create Container:','backwpup'); ?><input name="newrscContainer" type="text" value="" class="text" /> <br />
|
333 |
+
<b><?PHP _e('Folder in container:','backwpup'); ?></b><br />
|
334 |
+
<input name="rscdir" type="text" value="<?PHP echo $jobvalue['rscdir'];?>" class="large-text" /><br />
|
335 |
+
<?PHP _e('Max. backup files in container folder:','backwpup'); ?><input name="rscmaxbackups" type="text" size="3" value="<?PHP echo $jobvalue['rscmaxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will be deleted first.)','backwpup');?></span><br />
|
336 |
+
</div>
|
337 |
+
<div class="destlinks">
|
338 |
+
<a href="http://www.rackspacecloud.com/2073.html" target="_blank"><?PHP _e('Create Account','backwpup'); ?></a><br />
|
339 |
+
<a href="https://manage.rackspacecloud.com/APIAccess.do" target="_blank"><?PHP _e('Find Key','backwpup'); ?></a><br />
|
340 |
+
<a href="https://manage.rackspacecloud.com/CloudFiles.do" target="_blank"><?PHP _e('Webinterface','backwpup'); ?></a><br />
|
341 |
+
</div>
|
342 |
+
<br class="clear" />
|
343 |
+
<?PHP
|
344 |
+
}
|
345 |
+
|
346 |
+
function backwpup_jobedit_metabox_destdropbox($jobvalue) {
|
347 |
+
?>
|
348 |
+
<div class="dests">
|
349 |
+
<b><?PHP _e('Login:','backwpup'); ?></b>
|
350 |
+
<?PHP if (empty($jobvalue['dropetoken']) and empty($jobvalue['dropesecret'])) { ?>
|
351 |
+
<span style="color:red;"><?php _e('Not authenticated!', 'backwpup'); ?></span> <input type="submit" name="dropboxauth" class="button-primary" accesskey="d" value="<?php _e('Authenticate!', 'backwpup'); ?>" /><br />
|
352 |
+
<?PHP } else { ?>
|
353 |
+
<span style="color:green;"><?php _e('Authenticated!', 'backwpup'); ?></span> <input type="submit" name="dropboxauthdel" class="button-primary" accesskey="d" value="<?php _e('Delete!', 'backwpup'); ?>" /><br />
|
354 |
+
<?PHP } ?><br />
|
355 |
+
<b><?PHP _e('Root:','backwpup'); ?></b><br />
|
356 |
+
<select name="droperoot" id="droperoot">
|
357 |
+
<option <?PHP selected($jobvalue['droperoot'],'dropbox',true); ?> value="dropbox"><?php _e('dropbox', 'backwpup'); ?></option>
|
358 |
+
<option <?PHP selected($jobvalue['droperoot'],'sandbox',true); ?> value="sandbox" disabled="disabled"><?php _e('sandbox (disabled by DropBox)', 'backwpup'); ?></option>
|
359 |
+
</select><br />
|
360 |
+
<b><?PHP _e('Folder:','backwpup'); ?></b><br />
|
361 |
+
<input name="dropedir" type="text" value="<?PHP echo $jobvalue['dropedir'];?>" class="user large-text" /><br />
|
362 |
+
<?PHP _e('Max. backup files in Dropbox folder:','backwpup'); ?><input name="dropemaxbackups" type="text" size="3" value="<?PHP echo $jobvalue['dropemaxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will be deleted first.)','backwpup');?></span><br />
|
363 |
+
</div>
|
364 |
+
<div class="destlinks">
|
365 |
+
<a name="dropbox" href="http://db.tt/8irM1vQ0" target="_blank"><?PHP _e('Create Account','backwpup'); ?></a><br />
|
366 |
+
<a href="https://www.dropbox.com/" target="_blank"><?PHP _e('Webinterface','backwpup'); ?></a><br />
|
367 |
+
</div>
|
368 |
+
<br class="clear" />
|
369 |
+
<?PHP
|
370 |
+
}
|
371 |
+
|
372 |
+
function backwpup_jobedit_metabox_destsugarsync($jobvalue) {
|
373 |
+
?>
|
374 |
+
<div class="dests">
|
375 |
+
<b><?PHP _e('E-mail address:','backwpup'); ?></b><br />
|
376 |
+
<input id="sugaruser" name="sugaruser" type="text" value="<?PHP echo $jobvalue['sugaruser'];?>" class="large-text" /><br />
|
377 |
+
<b><?PHP _e('Password:','backwpup'); ?></b><br />
|
378 |
+
<input id="sugarpass" name="sugarpass" type="password" value="<?PHP echo base64_decode($jobvalue['sugarpass']);?>" class="large-text" /><br />
|
379 |
+
<b><?PHP _e('Root:','backwpup'); ?></b><br />
|
380 |
+
<input id="sugarrootselected" name="sugarrootselected" type="hidden" value="<?PHP echo $jobvalue['sugarroot'];?>" />
|
381 |
+
<?PHP if (!empty($jobvalue['sugaruser']) and !empty($jobvalue['sugarpass'])) backwpup_get_sugarsync_root(array('sugaruser'=>$jobvalue['sugaruser'],'sugarpass'=>base64_decode($jobvalue['sugarpass']),'sugarrootselected'=>$jobvalue['sugarroot'])); ?><br />
|
382 |
+
<b><?PHP _e('Folder:','backwpup'); ?></b><br />
|
383 |
+
<input name="sugardir" type="text" value="<?PHP echo $jobvalue['sugardir'];?>" class="large-text" /><br />
|
384 |
+
<?PHP _e('Max. backup files in folder:','backwpup'); ?><input name="sugarmaxbackups" type="text" size="3" value="<?PHP echo $jobvalue['sugarmaxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will be deleted first.)','backwpup');?></span><br />
|
385 |
+
</div>
|
386 |
+
<div class="destlinks">
|
387 |
+
<a href="http://www.anrdoezrs.net/click-5425765-10671858" target="_blank"><?PHP _e('Create Account','backwpup'); ?></a><br />
|
388 |
+
<a href="https://sugarsync.com" target="_blank"><?PHP _e('Webinterface','backwpup'); ?></a><br />
|
389 |
+
</div>
|
390 |
+
<br class="clear" />
|
391 |
+
<?PHP
|
392 |
+
}
|
393 |
+
function backwpup_jobedit_metabox_destmail($jobvalue) {
|
394 |
+
?>
|
395 |
+
<b><?PHP _e('E-mail address:','backwpup'); ?></b><br />
|
396 |
+
<input name="mailaddress" id="mailaddress" type="text" value="<?PHP echo $jobvalue['mailaddress'];?>" class="large-text" /><br />
|
397 |
+
<?PHP if (!is_numeric($jobvalue['mailefilesize'])) $jobvalue['mailefilesize']=0; ?>
|
398 |
+
<?PHP echo __('Max. File Size for sending Backups with mail:','backwpup').'<input name="mailefilesize" type="text" value="'.$jobvalue['mailefilesize'].'" class="small-text" />MB<br />';?>
|
399 |
+
<?PHP
|
400 |
+
}
|
401 |
+
|
402 |
+
//ever display needed boxes
|
403 |
+
function backwpup_jobedit_metabox_displayneeded($hidden) {
|
404 |
+
$newhidden=array();
|
405 |
+
foreach($hidden as $hiddenid) {
|
406 |
+
if ($hiddenid!='backwpup_jobedit_save' and $hiddenid!='backwpup_jobedit_schedule')
|
407 |
+
$newhidden[]=$hiddenid;
|
408 |
+
}
|
409 |
+
return $newhidden;
|
410 |
+
}
|
411 |
+
add_filter( 'hidden_meta_boxes', 'backwpup_jobedit_metabox_displayneeded' );
|
412 |
+
|
413 |
+
//ajax/normal get cron text
|
414 |
+
function backwpup_get_cron_text($args='') {
|
415 |
+
if (is_array($args)) {
|
416 |
+
extract($args);
|
417 |
+
$ajax=false;
|
418 |
+
} else {
|
419 |
+
check_ajax_referer('backwpupeditjob_ajax_nonce');
|
420 |
+
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
421 |
+
die('-1');
|
422 |
+
if (empty($_POST['cronminutes']) or $_POST['cronminutes'][0]=='*') {
|
423 |
+
if (!empty($_POST['cronminutes'][1]))
|
424 |
+
$_POST['cronminutes']=array('*/'.$_POST['cronminutes'][1]);
|
425 |
+
else
|
426 |
+
$_POST['cronminutes']=array('*');
|
427 |
+
}
|
428 |
+
if (empty($_POST['cronhours']) or $_POST['cronhours'][0]=='*') {
|
429 |
+
if (!empty($_POST['cronhours'][1]))
|
430 |
+
$_POST['cronhours']=array('*/'.$_POST['cronhours'][1]);
|
431 |
+
else
|
432 |
+
$_POST['cronhours']=array('*');
|
433 |
+
}
|
434 |
+
if (empty($_POST['cronmday']) or $_POST['cronmday'][0]=='*') {
|
435 |
+
if (!empty($_POST['cronmday'][1]))
|
436 |
+
$_POST['cronmday']=array('*/'.$_POST['cronmday'][1]);
|
437 |
+
else
|
438 |
+
$_POST['cronmday']=array('*');
|
439 |
+
}
|
440 |
+
if (empty($_POST['cronmon']) or $_POST['cronmon'][0]=='*') {
|
441 |
+
if (!empty($_POST['cronmon'][1]))
|
442 |
+
$_POST['cronmon']=array('*/'.$_POST['cronmon'][1]);
|
443 |
+
else
|
444 |
+
$_POST['cronmon']=array('*');
|
445 |
+
}
|
446 |
+
if (empty($_POST['cronwday']) or $_POST['cronwday'][0]=='*') {
|
447 |
+
if (!empty($_POST['cronwday'][1]))
|
448 |
+
$_POST['cronwday']=array('*/'.$_POST['cronwday'][1]);
|
449 |
+
else
|
450 |
+
$_POST['cronwday']=array('*');
|
451 |
+
}
|
452 |
+
$cronstamp=implode(",",$_POST['cronminutes']).' '.implode(",",$_POST['cronhours']).' '.implode(",",$_POST['cronmday']).' '.implode(",",$_POST['cronmon']).' '.implode(",",$_POST['cronwday']);
|
453 |
+
$ajax=true;
|
454 |
+
}
|
455 |
+
echo '<div id="cron-text">';
|
456 |
+
_e('Working as <a href="http://wikipedia.org/wiki/Cron" target="_blank">Cron</a> job schedule:','backwpup'); echo ' <i><b><nobr>'.$cronstamp.'</nobr></b></i><br />';
|
457 |
+
list($cronstr['minutes'],$cronstr['hours'],$cronstr['mday'],$cronstr['mon'],$cronstr['wday'])=explode(' ',$cronstamp,5);
|
458 |
+
if (false !== strpos($cronstr['minutes'],'*/') or ($cronstr['minutes']=='*')) {
|
459 |
+
$repeatmins=str_replace('*/','',$cronstr['minutes']);
|
460 |
+
if ($repeatmins=='*' or empty($repeatmins))
|
461 |
+
$repeatmins=5;
|
462 |
+
echo '<span style="color:red;">'.str_replace('%d',$repeatmins,__('ATTENTION: Job runs every %d mins.!!!','backwpup')).'</span><br />';
|
463 |
+
}
|
464 |
+
if (false !== strpos($cronstr['hours'],'*/') or ($cronstr['hours']=='*')) {
|
465 |
+
$repeathouer=str_replace('*/','',$cronstr['hours']);
|
466 |
+
if ($repeathouer=='*' or empty($repeathouer))
|
467 |
+
$repeathouer=1;
|
468 |
+
echo '<span style="color:red;">'.str_replace('%d',$repeathouer,__('ATTENTION: Job runs every %d houers.!!!','backwpup')).'</span><br />';
|
469 |
+
}
|
470 |
+
$nextrun=backwpup_cron_next($cronstamp);
|
471 |
+
if (2147483647==$nextrun) {
|
472 |
+
echo '<span style="color:red;">'.__('ATTENTION: Can\'t calculate cron!!!','backwpup').'</span><br />';
|
473 |
+
} else {
|
474 |
+
_e('Next runtime:','backwpup'); echo ' <b>'.date_i18n('D, j M Y, H:i',backwpup_cron_next($cronstamp)).'</b>';
|
475 |
+
}
|
476 |
+
echo "</div>";
|
477 |
+
if ($ajax)
|
478 |
+
die();
|
479 |
+
else
|
480 |
+
return;
|
481 |
+
}
|
482 |
+
|
483 |
+
//ajax/normal get buckests select box
|
484 |
+
function backwpup_get_aws_buckets($args='') {
|
485 |
+
if (is_array($args)) {
|
486 |
+
extract($args);
|
487 |
+
$ajax=false;
|
488 |
+
} else {
|
489 |
+
check_ajax_referer('backwpupeditjob_ajax_nonce');
|
490 |
+
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
491 |
+
die('-1');
|
492 |
+
$awsAccessKey=$_POST['awsAccessKey'];
|
493 |
+
$awsSecretKey=$_POST['awsSecretKey'];
|
494 |
+
$awsselected=$_POST['awsselected'];
|
495 |
+
$ajax=true;
|
496 |
+
}
|
497 |
+
if (!class_exists('CFRuntime'))
|
498 |
+
require_once(dirname(__FILE__).'/../libs/aws/sdk.class.php');
|
499 |
+
if (empty($awsAccessKey)) {
|
500 |
+
echo '<span id="awsBucket" style="color:red;">'.__('Missing access key!','backwpup').'</span>';
|
501 |
+
if ($ajax)
|
502 |
+
die();
|
503 |
+
else
|
504 |
+
return;
|
505 |
+
}
|
506 |
+
if (empty($awsSecretKey)) {
|
507 |
+
echo '<span id="awsBucket" style="color:red;">'.__('Missing secret access key!','backwpup').'</span>';
|
508 |
+
if ($ajax)
|
509 |
+
die();
|
510 |
+
else
|
511 |
+
return;
|
512 |
+
}
|
513 |
+
try {
|
514 |
+
$s3 = new AmazonS3(array('key'=>$awsAccessKey,'secret'=>$awsSecretKey,'certificate_authority'=>true));
|
515 |
+
$buckets=$s3->list_buckets();
|
516 |
+
} catch (Exception $e) {
|
517 |
+
echo '<span id="awsBucket" style="color:red;">'.$e->getMessage().'</span>';
|
518 |
+
if ($ajax)
|
519 |
+
die();
|
520 |
+
else
|
521 |
+
return;
|
522 |
+
}
|
523 |
+
if ($buckets->status<200 or $buckets->status>=300) {
|
524 |
+
echo '<span id="awsBucket" style="color:red;">'.$buckets->status.': '.$buckets->body->Message.'</span>';
|
525 |
+
if ($ajax)
|
526 |
+
die();
|
527 |
+
else
|
528 |
+
return;
|
529 |
+
}
|
530 |
+
if (count($buckets->body->Buckets->Bucket)<1) {
|
531 |
+
echo '<span id="awsBucket" style="color:red;">'.__('No bucket fount!','backwpup').'</span>';
|
532 |
+
if ($ajax)
|
533 |
+
die();
|
534 |
+
else
|
535 |
+
return;
|
536 |
+
}
|
537 |
+
echo '<select name="awsBucket" id="awsBucket">';
|
538 |
+
foreach ($buckets->body->Buckets->Bucket as $bucket) {
|
539 |
+
echo "<option ".selected(strtolower($awsselected),strtolower($bucket->Name),false).">".$bucket->Name."</option>";
|
540 |
+
}
|
541 |
+
echo '</select>';
|
542 |
+
if ($ajax)
|
543 |
+
die();
|
544 |
+
else
|
545 |
+
return;
|
546 |
+
}
|
547 |
+
|
548 |
+
//ajax/normal get buckests select box
|
549 |
+
function backwpup_get_gstorage_buckets($args='') {
|
550 |
+
if (is_array($args)) {
|
551 |
+
extract($args);
|
552 |
+
$ajax=false;
|
553 |
+
} else {
|
554 |
+
check_ajax_referer('backwpupeditjob_ajax_nonce');
|
555 |
+
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
556 |
+
die('-1');
|
557 |
+
$GStorageAccessKey=$_POST['GStorageAccessKey'];
|
558 |
+
$GStorageSecret=$_POST['GStorageSecret'];
|
559 |
+
$GStorageselected=$_POST['GStorageselected'];
|
560 |
+
$ajax=true;
|
561 |
+
}
|
562 |
+
if (!class_exists('CFRuntime'))
|
563 |
+
require_once(dirname(__FILE__).'/../libs/aws/sdk.class.php');
|
564 |
+
if (empty($GStorageAccessKey)) {
|
565 |
+
echo '<span id="GStorageBucket" style="color:red;">'.__('Missing access key!','backwpup').'</span>';
|
566 |
+
if ($ajax)
|
567 |
+
die();
|
568 |
+
else
|
569 |
+
return;
|
570 |
+
}
|
571 |
+
if (empty($GStorageSecret)) {
|
572 |
+
echo '<span id="GStorageBucket" style="color:red;">'.__('Missing secret access key!','backwpup').'</span>';
|
573 |
+
if ($ajax)
|
574 |
+
die();
|
575 |
+
else
|
576 |
+
return;
|
577 |
+
}
|
578 |
+
try {
|
579 |
+
$gstorage = new AmazonS3(array('key'=>$GStorageAccessKey,'secret'=>$GStorageSecret,'certificate_authority'=>true));
|
580 |
+
$gstorage->set_hostname('commondatastorage.googleapis.com');
|
581 |
+
$gstorage->allow_hostname_override(false);
|
582 |
+
$buckets=$gstorage->list_buckets();
|
583 |
+
} catch (Exception $e) {
|
584 |
+
echo '<span id="GStorageBucket" style="color:red;">'.$e->getMessage().'</span>';
|
585 |
+
if ($ajax)
|
586 |
+
die();
|
587 |
+
else
|
588 |
+
return;
|
589 |
+
}
|
590 |
+
if ($buckets->status<200 or $buckets->status>=300) {
|
591 |
+
echo '<span id="GStorageBucket" style="color:red;">'.$buckets->status.': '.$buckets->body->Message.'</span>';
|
592 |
+
if ($ajax)
|
593 |
+
die();
|
594 |
+
else
|
595 |
+
return;
|
596 |
+
}
|
597 |
+
if (count($buckets->body->Buckets->Bucket)<1) {
|
598 |
+
echo '<span id="GStorageBucket" style="color:red;">'.__('No bucket fount!','backwpup').'</span>';
|
599 |
+
if ($ajax)
|
600 |
+
die();
|
601 |
+
else
|
602 |
+
return;
|
603 |
+
}
|
604 |
+
echo '<select name="GStorageBucket" id="GStorageBucket">';
|
605 |
+
foreach ($buckets->body->Buckets->Bucket as $bucket) {
|
606 |
+
echo "<option ".selected(strtolower($GStorageselected),strtolower($bucket->Name),false).">".$bucket->Name."</option>";
|
607 |
+
}
|
608 |
+
echo '</select>';
|
609 |
+
if ($ajax)
|
610 |
+
die();
|
611 |
+
else
|
612 |
+
return;
|
613 |
+
}
|
614 |
+
|
615 |
+
//ajax/normal get Container for RSC select box
|
616 |
+
function backwpup_get_rsc_container($args='') {
|
617 |
+
if (is_array($args)) {
|
618 |
+
extract($args);
|
619 |
+
$ajax=false;
|
620 |
+
} else {
|
621 |
+
check_ajax_referer('backwpupeditjob_ajax_nonce');
|
622 |
+
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
623 |
+
die('-1');
|
624 |
+
$rscUsername=$_POST['rscUsername'];
|
625 |
+
$rscAPIKey=$_POST['rscAPIKey'];
|
626 |
+
$rscselected=$_POST['rscselected'];
|
627 |
+
$ajax=true;
|
628 |
+
}
|
629 |
+
if (!class_exists('CF_Authentication'))
|
630 |
+
require_once(dirname(__FILE__).'/../libs/rackspace/cloudfiles.php');
|
631 |
+
|
632 |
+
if (empty($rscUsername)) {
|
633 |
+
echo '<span id="rscContainer" style="color:red;">'.__('Missing Username!','backwpup').'</span>';
|
634 |
+
if ($ajax)
|
635 |
+
die();
|
636 |
+
else
|
637 |
+
return;
|
638 |
+
}
|
639 |
+
if (empty($rscAPIKey)) {
|
640 |
+
echo '<span id="rscContainer" style="color:red;">'.__('Missing API Key!','backwpup').'</span>';
|
641 |
+
if ($ajax)
|
642 |
+
die();
|
643 |
+
else
|
644 |
+
return;
|
645 |
+
}
|
646 |
+
|
647 |
+
try {
|
648 |
+
$auth = new CF_Authentication($rscUsername, $rscAPIKey);
|
649 |
+
$auth->authenticate();
|
650 |
+
$conn = new CF_Connection($auth);
|
651 |
+
$containers=$conn->get_containers();
|
652 |
+
} catch (Exception $e) {
|
653 |
+
echo '<span id="rscContainer" style="color:red;">'.$e->getMessage().'</span>';
|
654 |
+
if ($ajax)
|
655 |
+
die();
|
656 |
+
else
|
657 |
+
return;
|
658 |
+
}
|
659 |
+
|
660 |
+
if (!is_array($containers)) {
|
661 |
+
echo '<span id="rscContainer" style="color:red;">'.__('No Containerss found!','backwpup').'</span>';
|
662 |
+
if ($ajax)
|
663 |
+
die();
|
664 |
+
else
|
665 |
+
return;
|
666 |
+
}
|
667 |
+
echo '<select name="rscContainer" id="rscContainer">';
|
668 |
+
foreach ($containers as $container) {
|
669 |
+
echo "<option ".selected(strtolower($rscselected),strtolower($container->name),false).">".$container->name."</option>";
|
670 |
+
}
|
671 |
+
echo '</select>';
|
672 |
+
if ($ajax)
|
673 |
+
die();
|
674 |
+
else
|
675 |
+
return;
|
676 |
+
}
|
677 |
+
|
678 |
+
//ajax/normal get buckests select box
|
679 |
+
function backwpup_get_msazure_container($args='') {
|
680 |
+
if (is_array($args)) {
|
681 |
+
extract($args);
|
682 |
+
$ajax=false;
|
683 |
+
} else {
|
684 |
+
check_ajax_referer('backwpupeditjob_ajax_nonce');
|
685 |
+
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
686 |
+
die('-1');
|
687 |
+
$msazureHost=$_POST['msazureHost'];
|
688 |
+
$msazureAccName=$_POST['msazureAccName'];
|
689 |
+
$msazureKey=$_POST['msazureKey'];
|
690 |
+
$msazureselected=$_POST['msazureselected'];
|
691 |
+
$ajax=true;
|
692 |
+
}
|
693 |
+
if (!class_exists('Microsoft_WindowsAzure_Storage_Blob'))
|
694 |
+
require_once(dirname(__FILE__).'/../libs/Microsoft/WindowsAzure/Storage/Blob.php');
|
695 |
+
if (empty($msazureHost)) {
|
696 |
+
echo '<span id="msazureContainer" style="color:red;">'.__('Missing Hostname!','backwpup').'</span>';
|
697 |
+
if ($ajax)
|
698 |
+
die();
|
699 |
+
else
|
700 |
+
return;
|
701 |
+
}
|
702 |
+
if (empty($msazureAccName)) {
|
703 |
+
echo '<span id="msazureContainer" style="color:red;">'.__('Missing Account Name!','backwpup').'</span>';
|
704 |
+
if ($ajax)
|
705 |
+
die();
|
706 |
+
else
|
707 |
+
return;
|
708 |
+
}
|
709 |
+
if (empty($msazureKey)) {
|
710 |
+
echo '<span id="msazureContainer" style="color:red;">'.__('Missing Access Key!','backwpup').'</span>';
|
711 |
+
if ($ajax)
|
712 |
+
die();
|
713 |
+
else
|
714 |
+
return;
|
715 |
+
}
|
716 |
+
try {
|
717 |
+
$storageClient = new Microsoft_WindowsAzure_Storage_Blob($msazureHost,$msazureAccName,$msazureKey);
|
718 |
+
$Containers=$storageClient->listContainers();
|
719 |
+
} catch (Exception $e) {
|
720 |
+
echo '<span id="msazureContainer" style="color:red;">'.$e->getMessage().'</span>';
|
721 |
+
if ($ajax)
|
722 |
+
die();
|
723 |
+
else
|
724 |
+
return;
|
725 |
+
}
|
726 |
+
if (empty($Containers)) {
|
727 |
+
echo '<span id="msazureContainer" style="color:red;">'.__('No Container found!','backwpup').'</span>';
|
728 |
+
if ($ajax)
|
729 |
+
die();
|
730 |
+
else
|
731 |
+
return;
|
732 |
+
}
|
733 |
+
echo '<select name="msazureContainer" id="msazureContainer">';
|
734 |
+
foreach ($Containers as $Container) {
|
735 |
+
echo "<option ".selected(strtolower($msazureselected),strtolower($Container->Name),false).">".$Container->Name."</option>";
|
736 |
+
}
|
737 |
+
echo '</select>';
|
738 |
+
if ($ajax)
|
739 |
+
die();
|
740 |
+
else
|
741 |
+
return;
|
742 |
+
}
|
743 |
+
|
744 |
+
//ajax/normal get SugarSync roots select box
|
745 |
+
function backwpup_get_sugarsync_root($args='') {
|
746 |
+
if (is_array($args)) {
|
747 |
+
extract($args);
|
748 |
+
$ajax=false;
|
749 |
+
} else {
|
750 |
+
check_ajax_referer('backwpupeditjob_ajax_nonce');
|
751 |
+
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
752 |
+
die('-1');
|
753 |
+
$sugaruser=$_POST['sugaruser'];
|
754 |
+
$sugarpass=$_POST['sugarpass'];
|
755 |
+
$sugarrootselected=$_POST['sugarrootselected'];
|
756 |
+
$ajax=true;
|
757 |
+
}
|
758 |
+
if (!class_exists('SugarSync'))
|
759 |
+
require_once(dirname(__FILE__).'/../libs/sugarsync.php');
|
760 |
+
|
761 |
+
if (empty($sugaruser)) {
|
762 |
+
echo '<span id="sugarroot" style="color:red;">'.__('Missing Username!','backwpup').'</span>';
|
763 |
+
if ($ajax)
|
764 |
+
die();
|
765 |
+
else
|
766 |
+
return;
|
767 |
+
}
|
768 |
+
if (empty($sugarpass)) {
|
769 |
+
echo '<span id="sugarroot" style="color:red;">'.__('Missing Password!','backwpup').'</span>';
|
770 |
+
if ($ajax)
|
771 |
+
die();
|
772 |
+
else
|
773 |
+
return;
|
774 |
+
}
|
775 |
+
|
776 |
+
try {
|
777 |
+
$sugarsync = new SugarSync($sugaruser,$sugarpass,BACKWPUP_SUGARSYNC_ACCESSKEY, BACKWPUP_SUGARSYNC_PRIVATEACCESSKEY);
|
778 |
+
$user=$sugarsync->user();
|
779 |
+
$syncfolders=$sugarsync->get($user->syncfolders);
|
780 |
+
} catch (Exception $e) {
|
781 |
+
echo '<span id="sugarroot" style="color:red;">'.$e->getMessage().'</span>';
|
782 |
+
if ($ajax)
|
783 |
+
die();
|
784 |
+
else
|
785 |
+
return;
|
786 |
+
}
|
787 |
+
|
788 |
+
if (!is_object($syncfolders)) {
|
789 |
+
echo '<span id="sugarroot" style="color:red;">'.__('No Syncfolders found!','backwpup').'</span>';
|
790 |
+
if ($ajax)
|
791 |
+
die();
|
792 |
+
else
|
793 |
+
return;
|
794 |
+
}
|
795 |
+
echo '<select name="sugarroot" id="sugarroot">';
|
796 |
+
foreach ($syncfolders->collection as $roots) {
|
797 |
+
echo "<option ".selected(strtolower($sugarrootselected),strtolower($roots->ref),false)." value=\"".$roots->ref."\">".$roots->displayName."</option>";
|
798 |
+
}
|
799 |
+
echo '</select>';
|
800 |
+
if ($ajax)
|
801 |
+
die();
|
802 |
+
else
|
803 |
+
return;
|
804 |
+
}
|
805 |
+
//add ajax function
|
806 |
+
add_action('wp_ajax_backwpup_get_cron_text', 'backwpup_get_cron_text');
|
807 |
+
add_action('wp_ajax_backwpup_get_aws_buckets', 'backwpup_get_aws_buckets');
|
808 |
+
add_action('wp_ajax_backwpup_get_gstorage_buckets', 'backwpup_get_gstorage_buckets');
|
809 |
+
add_action('wp_ajax_backwpup_get_rsc_container', 'backwpup_get_rsc_container');
|
810 |
+
add_action('wp_ajax_backwpup_get_msazure_container', 'backwpup_get_msazure_container');
|
811 |
+
add_action('wp_ajax_backwpup_get_sugarsync_root', 'backwpup_get_sugarsync_root');
|
|
pages/func_backwpuplogs.php
CHANGED
@@ -1,162 +1,161 @@
|
|
1 |
-
<?PHP
|
2 |
-
include_once(trailingslashit(ABSPATH).'wp-admin/includes/class-wp-list-table.php');
|
3 |
-
|
4 |
-
class BackWPup_Logs_Table extends WP_List_Table {
|
5 |
-
function __construct() {
|
6 |
-
parent::__construct( array(
|
7 |
-
'plural' => 'logs',
|
8 |
-
'singular' => 'log',
|
9 |
-
'ajax' => true
|
10 |
-
) );
|
11 |
-
}
|
12 |
-
|
13 |
-
function ajax_user_can() {
|
14 |
-
return current_user_can(BACKWPUP_USER_CAPABILITY);
|
15 |
-
}
|
16 |
-
|
17 |
-
function prepare_items() {
|
18 |
-
|
19 |
-
$per_page = $this->get_items_per_page('backwpuplogs_per_page');
|
20 |
-
if ( empty( $per_page ) || $per_page < 1 )
|
21 |
-
$per_page = 20;
|
22 |
-
|
23 |
-
//load logs
|
24 |
-
$cfg=get_option('backwpup');
|
25 |
-
$logfiles=array();
|
26 |
-
if ( $dir = @opendir( $cfg['dirlogs'] ) ) {
|
27 |
-
while (($file = readdir( $dir ) ) !== false ) {
|
28 |
-
if (is_file($cfg['dirlogs'].'/'.$file) and 'backwpup_log_' == substr($file,0,strlen('backwpup_log_')) and ('.html' == substr($file,-5) or '.html.gz' == substr($file,-8)))
|
29 |
-
$logfiles[]=$file;
|
30 |
-
}
|
31 |
-
closedir( $dir );
|
32 |
-
}
|
33 |
-
//ordering
|
34 |
-
$order=isset($_GET['order']) ? $_GET['order'] : 'desc';
|
35 |
-
$orderby=isset($_GET['orderby']) ? $_GET['orderby'] : 'log';
|
36 |
-
if ($orderby=='log') {
|
37 |
-
if ($order=='asc')
|
38 |
-
sort($logfiles);
|
39 |
-
else
|
40 |
-
rsort($logfiles);
|
41 |
-
}
|
42 |
-
//by page
|
43 |
-
$start=intval( ( $this->get_pagenum() - 1 ) * $per_page );
|
44 |
-
$end=$start+$per_page;
|
45 |
-
if ($end>count($logfiles))
|
46 |
-
$end=count($logfiles);
|
47 |
-
|
48 |
-
$this->items=array();
|
49 |
-
for ($i=$start;$i<$end;$i++)
|
50 |
-
$this->items[]=$logfiles[$i];
|
51 |
-
|
52 |
-
$this->set_pagination_args( array(
|
53 |
-
'total_items' => count($logfiles),
|
54 |
-
'per_page' => $per_page,
|
55 |
-
'orderby' => $orderby,
|
56 |
-
'order' => $order
|
57 |
-
) );
|
58 |
-
|
59 |
-
}
|
60 |
-
|
61 |
-
function get_sortable_columns() {
|
62 |
-
return array(
|
63 |
-
'log' => array('log',false),
|
64 |
-
);
|
65 |
-
}
|
66 |
-
|
67 |
-
function no_items() {
|
68 |
-
_e( 'No Logs.','backwpup');
|
69 |
-
}
|
70 |
-
|
71 |
-
function get_bulk_actions() {
|
72 |
-
$actions = array();
|
73 |
-
$actions['delete'] = __( 'Delete' );
|
74 |
-
return $actions;
|
75 |
-
}
|
76 |
-
|
77 |
-
function get_columns() {
|
78 |
-
$posts_columns = array();
|
79 |
-
$posts_columns['cb'] = '<input type="checkbox" />';
|
80 |
-
$posts_columns['id'] = __('Job','backwpup');
|
81 |
-
$posts_columns['type'] = __('Type','backwpup');
|
82 |
-
$posts_columns['log'] = __('Backup/Log Date/Time','backwpup');
|
83 |
-
$posts_columns['status'] = __('Status','backwpup');
|
84 |
-
$posts_columns['size'] = __('Size','backwpup');
|
85 |
-
$posts_columns['runtime'] = __('Runtime','backwpup');
|
86 |
-
return $posts_columns;
|
87 |
-
}
|
88 |
-
|
89 |
-
function display_rows() {
|
90 |
-
$style = '';
|
91 |
-
$cfg=get_option('backwpup');
|
92 |
-
foreach ( $this->items as $logfile ) {
|
93 |
-
$style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
|
94 |
-
$logdata=backwpup_read_logheader($cfg['dirlogs'].$logfile);
|
95 |
-
echo "\n\t", $this->single_row( $cfg['dirlogs'].$logfile, $logdata, $style );
|
96 |
-
}
|
97 |
-
}
|
98 |
-
|
99 |
-
function single_row( $logfile, $logdata, $style = '' ) {
|
100 |
-
list( $columns, $hidden, $sortable ) = $this->get_column_info();
|
101 |
-
$r = "<tr id='".basename($logfile)."'$style>";
|
102 |
-
foreach ( $columns as $column_name => $column_display_name ) {
|
103 |
-
$class = "class=\"$column_name column-$column_name\"";
|
104 |
-
|
105 |
-
$style = '';
|
106 |
-
if ( in_array( $column_name, $hidden ) )
|
107 |
-
$style = ' style="display:none;"';
|
108 |
-
|
109 |
-
$attributes = "$class$style";
|
110 |
-
|
111 |
-
switch($column_name) {
|
112 |
-
case 'cb':
|
113 |
-
$r .= '<th scope="row" class="check-column"><input type="checkbox" name="logfiles[]" value="'. esc_attr(basename($logfile)) .'" /></th>';
|
114 |
-
break;
|
115 |
-
case 'id':
|
116 |
-
$r .= "<td $attributes>".$logdata['jobid']."</td>";
|
117 |
-
break;
|
118 |
-
case 'type':
|
119 |
-
$r .= "<td $attributes>";
|
120 |
-
$r .= backwpup_backup_types($logdata['type'],false);
|
121 |
-
$r .= "</td>";
|
122 |
-
break;
|
123 |
-
case 'log':
|
124 |
-
$r .= "<td $attributes><strong><a href=\"".wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupworking&logfile='.$logfile, 'view-log_'.basename($logfile))."\" title=\"".__('View log','backwpup')."\">".backwpup_date_i18n(get_option('date_format')." @ ".get_option('time_format'),$logdata['logtime']).": <i>".$logdata['name']."</i></a></strong>";
|
125 |
-
$actions = array();
|
126 |
-
$actions['view'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupworking&logfile='.$logfile, 'view-log_'.basename($logfile)) . "\">" . __('View','backwpup') . "</a>";
|
127 |
-
$actions['delete'] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpuplogs&action=delete&paged='.$this->get_pagenum().'&logfiles[]='.basename($logfile), 'bulk-logs') . "\" onclick=\"return showNotice.warn();\">" . __('Delete') . "</a>";
|
128 |
-
$actions['download'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpuplogs&action=download&file='.$logfile, 'download-backup_'.basename($logfile)) . "\">" . __('Download','backwpup') . "</a>";
|
129 |
-
$r .= $this->row_actions($actions);
|
130 |
-
$r .= "</td>";
|
131 |
-
break;
|
132 |
-
case 'status':
|
133 |
-
$r .= "<td $attributes>";
|
134 |
-
if ($logdata['errors']>0)
|
135 |
-
$r .= str_replace('%d',$logdata['errors'],'<span style="color:red;font-weight:bold;">'._n("%d ERROR", "%d ERRORS", $logdata['errors'],'backwpup').'</span><br />');
|
136 |
-
if ($logdata['warnings']>0)
|
137 |
-
$r .= str_replace('%d',$logdata['warnings'],'<span style="color:#e66f00;font-weight:bold;">'._n("%d WARNING", "%d WARNINGS", $logdata['warnings'],'backwpup').'</span><br />');
|
138 |
-
if($logdata['errors']==0 and $logdata['warnings']==0)
|
139 |
-
$r .= '<span style="color:green;font-weight:bold;">'.__('O.K.','backwpup').'</span>';
|
140 |
-
$r .= "</td>";
|
141 |
-
break;
|
142 |
-
case 'size':
|
143 |
-
$r .= "<td $attributes>";
|
144 |
-
if (!empty($logdata['backupfilesize'])) {
|
145 |
-
$r .= backwpup_formatBytes($logdata['backupfilesize']);
|
146 |
-
} else {
|
147 |
-
$r .= __('only Log','backwpup');
|
148 |
-
}
|
149 |
-
$r .= "</td>";
|
150 |
-
break;
|
151 |
-
case 'runtime':
|
152 |
-
$r .= "<td $attributes>";
|
153 |
-
$r .= $logdata['runtime'].' '.__('sec.','backwpup');
|
154 |
-
$r .= "</td>";
|
155 |
-
break;
|
156 |
-
}
|
157 |
-
}
|
158 |
-
$r .= '</tr>';
|
159 |
-
return $r;
|
160 |
-
}
|
161 |
-
}
|
162 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
include_once(trailingslashit(ABSPATH).'wp-admin/includes/class-wp-list-table.php');
|
3 |
+
|
4 |
+
class BackWPup_Logs_Table extends WP_List_Table {
|
5 |
+
function __construct() {
|
6 |
+
parent::__construct( array(
|
7 |
+
'plural' => 'logs',
|
8 |
+
'singular' => 'log',
|
9 |
+
'ajax' => true
|
10 |
+
) );
|
11 |
+
}
|
12 |
+
|
13 |
+
function ajax_user_can() {
|
14 |
+
return current_user_can(BACKWPUP_USER_CAPABILITY);
|
15 |
+
}
|
16 |
+
|
17 |
+
function prepare_items() {
|
18 |
+
|
19 |
+
$per_page = $this->get_items_per_page('backwpuplogs_per_page');
|
20 |
+
if ( empty( $per_page ) || $per_page < 1 )
|
21 |
+
$per_page = 20;
|
22 |
+
|
23 |
+
//load logs
|
24 |
+
$cfg=get_option('backwpup');
|
25 |
+
$logfiles=array();
|
26 |
+
if ( $dir = @opendir( $cfg['dirlogs'] ) ) {
|
27 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
28 |
+
if (is_file($cfg['dirlogs'].'/'.$file) and 'backwpup_log_' == substr($file,0,strlen('backwpup_log_')) and ('.html' == substr($file,-5) or '.html.gz' == substr($file,-8)))
|
29 |
+
$logfiles[]=$file;
|
30 |
+
}
|
31 |
+
closedir( $dir );
|
32 |
+
}
|
33 |
+
//ordering
|
34 |
+
$order=isset($_GET['order']) ? $_GET['order'] : 'desc';
|
35 |
+
$orderby=isset($_GET['orderby']) ? $_GET['orderby'] : 'log';
|
36 |
+
if ($orderby=='log') {
|
37 |
+
if ($order=='asc')
|
38 |
+
sort($logfiles);
|
39 |
+
else
|
40 |
+
rsort($logfiles);
|
41 |
+
}
|
42 |
+
//by page
|
43 |
+
$start=intval( ( $this->get_pagenum() - 1 ) * $per_page );
|
44 |
+
$end=$start+$per_page;
|
45 |
+
if ($end>count($logfiles))
|
46 |
+
$end=count($logfiles);
|
47 |
+
|
48 |
+
$this->items=array();
|
49 |
+
for ($i=$start;$i<$end;$i++)
|
50 |
+
$this->items[]=$logfiles[$i];
|
51 |
+
|
52 |
+
$this->set_pagination_args( array(
|
53 |
+
'total_items' => count($logfiles),
|
54 |
+
'per_page' => $per_page,
|
55 |
+
'orderby' => $orderby,
|
56 |
+
'order' => $order
|
57 |
+
) );
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
function get_sortable_columns() {
|
62 |
+
return array(
|
63 |
+
'log' => array('log',false),
|
64 |
+
);
|
65 |
+
}
|
66 |
+
|
67 |
+
function no_items() {
|
68 |
+
_e( 'No Logs.','backwpup');
|
69 |
+
}
|
70 |
+
|
71 |
+
function get_bulk_actions() {
|
72 |
+
$actions = array();
|
73 |
+
$actions['delete'] = __( 'Delete' );
|
74 |
+
return $actions;
|
75 |
+
}
|
76 |
+
|
77 |
+
function get_columns() {
|
78 |
+
$posts_columns = array();
|
79 |
+
$posts_columns['cb'] = '<input type="checkbox" />';
|
80 |
+
$posts_columns['id'] = __('Job','backwpup');
|
81 |
+
$posts_columns['type'] = __('Type','backwpup');
|
82 |
+
$posts_columns['log'] = __('Backup/Log Date/Time','backwpup');
|
83 |
+
$posts_columns['status'] = __('Status','backwpup');
|
84 |
+
$posts_columns['size'] = __('Size','backwpup');
|
85 |
+
$posts_columns['runtime'] = __('Runtime','backwpup');
|
86 |
+
return $posts_columns;
|
87 |
+
}
|
88 |
+
|
89 |
+
function display_rows() {
|
90 |
+
$style = '';
|
91 |
+
$cfg=get_option('backwpup');
|
92 |
+
foreach ( $this->items as $logfile ) {
|
93 |
+
$style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
|
94 |
+
$logdata=backwpup_read_logheader($cfg['dirlogs'].$logfile);
|
95 |
+
echo "\n\t", $this->single_row( $cfg['dirlogs'].$logfile, $logdata, $style );
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
function single_row( $logfile, $logdata, $style = '' ) {
|
100 |
+
list( $columns, $hidden, $sortable ) = $this->get_column_info();
|
101 |
+
$r = "<tr id='".basename($logfile)."'$style>";
|
102 |
+
foreach ( $columns as $column_name => $column_display_name ) {
|
103 |
+
$class = "class=\"$column_name column-$column_name\"";
|
104 |
+
|
105 |
+
$style = '';
|
106 |
+
if ( in_array( $column_name, $hidden ) )
|
107 |
+
$style = ' style="display:none;"';
|
108 |
+
|
109 |
+
$attributes = "$class$style";
|
110 |
+
|
111 |
+
switch($column_name) {
|
112 |
+
case 'cb':
|
113 |
+
$r .= '<th scope="row" class="check-column"><input type="checkbox" name="logfiles[]" value="'. esc_attr(basename($logfile)) .'" /></th>';
|
114 |
+
break;
|
115 |
+
case 'id':
|
116 |
+
$r .= "<td $attributes>".$logdata['jobid']."</td>";
|
117 |
+
break;
|
118 |
+
case 'type':
|
119 |
+
$r .= "<td $attributes>";
|
120 |
+
$r .= backwpup_backup_types($logdata['type'],false);
|
121 |
+
$r .= "</td>";
|
122 |
+
break;
|
123 |
+
case 'log':
|
124 |
+
$r .= "<td $attributes><strong><a href=\"".wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupworking&logfile='.$logfile, 'view-log_'.basename($logfile))."\" title=\"".__('View log','backwpup')."\">".backwpup_date_i18n(get_option('date_format')." @ ".get_option('time_format'),$logdata['logtime']).": <i>".$logdata['name']."</i></a></strong>";
|
125 |
+
$actions = array();
|
126 |
+
$actions['view'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupworking&logfile='.$logfile, 'view-log_'.basename($logfile)) . "\">" . __('View','backwpup') . "</a>";
|
127 |
+
$actions['delete'] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpuplogs&action=delete&paged='.$this->get_pagenum().'&logfiles[]='.basename($logfile), 'bulk-logs') . "\" onclick=\"return showNotice.warn();\">" . __('Delete') . "</a>";
|
128 |
+
$actions['download'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpuplogs&action=download&file='.$logfile, 'download-backup_'.basename($logfile)) . "\">" . __('Download','backwpup') . "</a>";
|
129 |
+
$r .= $this->row_actions($actions);
|
130 |
+
$r .= "</td>";
|
131 |
+
break;
|
132 |
+
case 'status':
|
133 |
+
$r .= "<td $attributes>";
|
134 |
+
if ($logdata['errors']>0)
|
135 |
+
$r .= str_replace('%d',$logdata['errors'],'<span style="color:red;font-weight:bold;">'._n("%d ERROR", "%d ERRORS", $logdata['errors'],'backwpup').'</span><br />');
|
136 |
+
if ($logdata['warnings']>0)
|
137 |
+
$r .= str_replace('%d',$logdata['warnings'],'<span style="color:#e66f00;font-weight:bold;">'._n("%d WARNING", "%d WARNINGS", $logdata['warnings'],'backwpup').'</span><br />');
|
138 |
+
if($logdata['errors']==0 and $logdata['warnings']==0)
|
139 |
+
$r .= '<span style="color:green;font-weight:bold;">'.__('O.K.','backwpup').'</span>';
|
140 |
+
$r .= "</td>";
|
141 |
+
break;
|
142 |
+
case 'size':
|
143 |
+
$r .= "<td $attributes>";
|
144 |
+
if (!empty($logdata['backupfilesize'])) {
|
145 |
+
$r .= backwpup_formatBytes($logdata['backupfilesize']);
|
146 |
+
} else {
|
147 |
+
$r .= __('only Log','backwpup');
|
148 |
+
}
|
149 |
+
$r .= "</td>";
|
150 |
+
break;
|
151 |
+
case 'runtime':
|
152 |
+
$r .= "<td $attributes>";
|
153 |
+
$r .= $logdata['runtime'].' '.__('sec.','backwpup');
|
154 |
+
$r .= "</td>";
|
155 |
+
break;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
$r .= '</tr>';
|
159 |
+
return $r;
|
160 |
+
}
|
161 |
+
}
|
|
pages/func_backwpupworking.php
CHANGED
@@ -1,26 +1,24 @@
|
|
1 |
-
<?PHP
|
2 |
-
// Remove header and footer form logfile
|
3 |
-
function backwpup_read_logfile($logfile) {
|
4 |
-
if (is_file($logfile) and strtolower(substr($logfile,-3))=='.gz')
|
5 |
-
$logfiledata=gzfile($logfile);
|
6 |
-
elseif (is_file($logfile.'.gz'))
|
7 |
-
$logfiledata=gzfile($logfile.'.gz');
|
8 |
-
elseif (is_file($logfile))
|
9 |
-
$logfiledata=file($logfile);
|
10 |
-
else
|
11 |
-
return false;
|
12 |
-
$lines=array();
|
13 |
-
$start=false;
|
14 |
-
foreach ($logfiledata as $line){
|
15 |
-
$line=trim($line);
|
16 |
-
if (strripos($line,'<body')!== false) { // jop over header
|
17 |
-
$start=true;
|
18 |
-
continue;
|
19 |
-
}
|
20 |
-
if ($line!='</body>' and $line!='</html>' and $start) //no Footer
|
21 |
-
$lines[]=$line;
|
22 |
-
}
|
23 |
-
return $lines;
|
24 |
-
}
|
25 |
-
|
26 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
// Remove header and footer form logfile
|
3 |
+
function backwpup_read_logfile($logfile) {
|
4 |
+
if (is_file($logfile) and strtolower(substr($logfile,-3))=='.gz')
|
5 |
+
$logfiledata=gzfile($logfile);
|
6 |
+
elseif (is_file($logfile.'.gz'))
|
7 |
+
$logfiledata=gzfile($logfile.'.gz');
|
8 |
+
elseif (is_file($logfile))
|
9 |
+
$logfiledata=file($logfile);
|
10 |
+
else
|
11 |
+
return false;
|
12 |
+
$lines=array();
|
13 |
+
$start=false;
|
14 |
+
foreach ($logfiledata as $line){
|
15 |
+
$line=trim($line);
|
16 |
+
if (strripos($line,'<body')!== false) { // jop over header
|
17 |
+
$start=true;
|
18 |
+
continue;
|
19 |
+
}
|
20 |
+
if ($line!='</body>' and $line!='</html>' and $start) //no Footer
|
21 |
+
$lines[]=$line;
|
22 |
+
}
|
23 |
+
return $lines;
|
24 |
+
}
|
|
|
|
pages/header_backwpup.php
CHANGED
@@ -1,139 +1,138 @@
|
|
1 |
-
<?PHP
|
2 |
-
if (!defined('ABSPATH'))
|
3 |
-
die();
|
4 |
-
|
5 |
-
|
6 |
-
//Create Table
|
7 |
-
$backwpup_listtable = new BackWPup_Jobs_Table;
|
8 |
-
|
9 |
-
//get cuurent action
|
10 |
-
$doaction = $backwpup_listtable->current_action();
|
11 |
-
|
12 |
-
if (!empty($doaction)) {
|
13 |
-
switch($doaction) {
|
14 |
-
case 'delete': //Delete Job
|
15 |
-
$jobs=get_option('backwpup_jobs');
|
16 |
-
if (is_array($_GET['jobs'])) {
|
17 |
-
check_admin_referer('bulk-jobs');
|
18 |
-
foreach ($_GET['jobs'] as $jobid) {
|
19 |
-
unset($jobs[$jobid]);
|
20 |
-
}
|
21 |
-
}
|
22 |
-
//activate/deactivate seduling if not needed
|
23 |
-
$activejobs=false;
|
24 |
-
foreach ($jobs as $jobid => $jobvalue) {
|
25 |
-
if (!empty($jobvalue['activated']))
|
26 |
-
$activejobs=true;
|
27 |
-
}
|
28 |
-
if (!$activejobs and false !== wp_next_scheduled('backwpup_cron')) {
|
29 |
-
wp_clear_scheduled_hook('backwpup_cron');
|
30 |
-
}
|
31 |
-
update_option('backwpup_jobs',$jobs);
|
32 |
-
break;
|
33 |
-
case 'copy': //Copy Job
|
34 |
-
$jobid = (int) $_GET['jobid'];
|
35 |
-
check_admin_referer('copy-job_'.$jobid);
|
36 |
-
$jobs=get_option('backwpup_jobs');
|
37 |
-
//generate new ID
|
38 |
-
$heighestid=0;
|
39 |
-
foreach ($jobs as $jobkey => $jobvalue) {
|
40 |
-
if ($jobkey>$heighestid) $heighestid=$jobkey;
|
41 |
-
}
|
42 |
-
$newjobid=$heighestid+1;
|
43 |
-
$jobs[$newjobid]=$jobs[$jobid];
|
44 |
-
$jobs[$newjobid]['name']=__('Copy of','backwpup').' '.$jobs[$newjobid]['name'];
|
45 |
-
$jobs[$newjobid]['activated']=false;
|
46 |
-
$jobs[$newjobid]['fileprefix']=str_replace($jobid,$newjobid,$jobs[$jobid]['fileprefix']);
|
47 |
-
unset($jobs[$newjobid]['logfile']);
|
48 |
-
unset($jobs[$newjobid]['starttime']);
|
49 |
-
unset($jobs[$newjobid]['lastbackupdownloadurl']);
|
50 |
-
unset($jobs[$newjobid]['lastruntime']);
|
51 |
-
unset($jobs[$newjobid]['lastrun']);
|
52 |
-
update_option('backwpup_jobs',$jobs);
|
53 |
-
break;
|
54 |
-
case 'export': //Copy Job
|
55 |
-
if (is_array($_GET['jobs'])) {
|
56 |
-
check_admin_referer('bulk-jobs');
|
57 |
-
foreach ($_GET['jobs'] as $jobid) {
|
58 |
-
$jobsexport[$jobid]=backwpup_get_job_vars($jobid);
|
59 |
-
$jobsexport[$jobid]['activated']=false;
|
60 |
-
unset($jobsexport[$jobid]['logfile']);
|
61 |
-
unset($jobsexport[$jobid]['starttime']);
|
62 |
-
unset($jobsexport[$jobid]['lastbackupdownloadurl']);
|
63 |
-
unset($jobsexport[$jobid]['lastruntime']);
|
64 |
-
unset($jobsexport[$jobid]['lastrun']);
|
65 |
-
}
|
66 |
-
}
|
67 |
-
$export=serialize($jobsexport);
|
68 |
-
header("Pragma: public");
|
69 |
-
header("Expires: 0");
|
70 |
-
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
71 |
-
header("Content-Type: text/plain");
|
72 |
-
header("Content-Type: application/force-download");
|
73 |
-
header("Content-Type: application/octet-stream");
|
74 |
-
header("Content-Type: application/download");
|
75 |
-
header("Content-Disposition: attachment; filename=".sanitize_key(get_bloginfo('name'))."_BackWPupExport.txt;");
|
76 |
-
header("Content-Transfer-Encoding: 8bit");
|
77 |
-
header("Content-Length: ".strlen($export));
|
78 |
-
echo $export;
|
79 |
-
die();
|
80 |
-
break;
|
81 |
-
case 'abort': //Abort Job
|
82 |
-
check_admin_referer('abort-job');
|
83 |
-
$runningfile=backwpup_get_working_file();
|
84 |
-
$tempdir=backwpup_get_temp();
|
85 |
-
//clean up temp
|
86 |
-
if (is_dir($tempdir)) {
|
87 |
-
if ($dir = opendir($tempdir)) {
|
88 |
-
while (($file = readdir($dir)) !== false) {
|
89 |
-
if (is_readable($tempdir.$file) and is_file($tempdir.$file)) {
|
90 |
-
if ($file!='.' and $file!='..') {
|
91 |
-
unlink($tempdir.$file);
|
92 |
-
}
|
93 |
-
}
|
94 |
-
}
|
95 |
-
closedir($dir);
|
96 |
-
}
|
97 |
-
}
|
98 |
-
clearstatcache();
|
99 |
-
if (!empty($runningfile['LOGFILE'])) {
|
100 |
-
file_put_contents($runningfile['LOGFILE'], "<span class=\"timestamp\">".backwpup_date_i18n('Y/m/d H:i.s').":</span> <span class=\"error\">[ERROR]".__('Aborted by user!!!','backwpup')."</span><br />\n", FILE_APPEND);
|
101 |
-
//write new log header
|
102 |
-
$runningfile['WORKING']['ERROR']++;
|
103 |
-
$fd=fopen($runningfile['LOGFILE'],'r+');
|
104 |
-
while (!feof($fd)) {
|
105 |
-
$line=fgets($fd);
|
106 |
-
if (stripos($line,"<meta name=\"backwpup_errors\"") !== false) {
|
107 |
-
fseek($fd,$filepos);
|
108 |
-
fwrite($fd,str_pad("<meta name=\"backwpup_errors\" content=\"".$runningfile['WORKING']['ERROR']."\" />",100)."\n");
|
109 |
-
break;
|
110 |
-
}
|
111 |
-
$filepos=ftell($fd);
|
112 |
-
}
|
113 |
-
fclose($fd);
|
114 |
-
}
|
115 |
-
$backwpup_message=__('Job will be terminated.','backwpup').'<br />';
|
116 |
-
if (!empty($runningfile['WORKING']['PID']) and function_exists('posix_kill')) {
|
117 |
-
if (posix_kill($runningfile['WORKING']['PID'],9))
|
118 |
-
$backwpup_message.=__('Process killed with PID:','backwpup').' '.$runningfile['WORKING']['PID'];
|
119 |
-
else
|
120 |
-
$backwpup_message.=__('Can\'t kill process with PID:','backwpup').' '.$runningfile['WORKING']['PID'];
|
121 |
-
}
|
122 |
-
//update job settings
|
123 |
-
if (!empty($runningfile['JOBID'])) {
|
124 |
-
$jobs=get_option('backwpup_jobs');
|
125 |
-
if (isset($newlogfile) and !empty($newlogfile))
|
126 |
-
$jobs[$runningfile['JOBID']]['logfile']=$newlogfile;
|
127 |
-
$jobs[$runningfile['JOBID']]['lastrun']=$jobs[$runningfile['JOBID']]['starttime'];
|
128 |
-
$jobs[$runningfile['JOBID']]['lastruntime']=$runningfile['timestamp']-$jobs[$runningfile['JOBID']]['starttime'];
|
129 |
-
update_option('backwpup_jobs',$jobs); //Save Settings
|
130 |
-
}
|
131 |
-
break;
|
132 |
-
}
|
133 |
-
}
|
134 |
-
|
135 |
-
//add Help
|
136 |
-
backwpup_contextual_help(__('Here is the job overview with some information. You can see some further information of the jobs, how many can be switched with the view button. Also you can manage the jobs or abbort working jobs. Some links are added to have direct access to the last log or download.','backwpup'));
|
137 |
-
|
138 |
-
$backwpup_listtable->prepare_items();
|
139 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
if (!defined('ABSPATH'))
|
3 |
+
die();
|
4 |
+
|
5 |
+
|
6 |
+
//Create Table
|
7 |
+
$backwpup_listtable = new BackWPup_Jobs_Table;
|
8 |
+
|
9 |
+
//get cuurent action
|
10 |
+
$doaction = $backwpup_listtable->current_action();
|
11 |
+
|
12 |
+
if (!empty($doaction)) {
|
13 |
+
switch($doaction) {
|
14 |
+
case 'delete': //Delete Job
|
15 |
+
$jobs=get_option('backwpup_jobs');
|
16 |
+
if (is_array($_GET['jobs'])) {
|
17 |
+
check_admin_referer('bulk-jobs');
|
18 |
+
foreach ($_GET['jobs'] as $jobid) {
|
19 |
+
unset($jobs[$jobid]);
|
20 |
+
}
|
21 |
+
}
|
22 |
+
//activate/deactivate seduling if not needed
|
23 |
+
$activejobs=false;
|
24 |
+
foreach ($jobs as $jobid => $jobvalue) {
|
25 |
+
if (!empty($jobvalue['activated']))
|
26 |
+
$activejobs=true;
|
27 |
+
}
|
28 |
+
if (!$activejobs and false !== wp_next_scheduled('backwpup_cron')) {
|
29 |
+
wp_clear_scheduled_hook('backwpup_cron');
|
30 |
+
}
|
31 |
+
update_option('backwpup_jobs',$jobs);
|
32 |
+
break;
|
33 |
+
case 'copy': //Copy Job
|
34 |
+
$jobid = (int) $_GET['jobid'];
|
35 |
+
check_admin_referer('copy-job_'.$jobid);
|
36 |
+
$jobs=get_option('backwpup_jobs');
|
37 |
+
//generate new ID
|
38 |
+
$heighestid=0;
|
39 |
+
foreach ($jobs as $jobkey => $jobvalue) {
|
40 |
+
if ($jobkey>$heighestid) $heighestid=$jobkey;
|
41 |
+
}
|
42 |
+
$newjobid=$heighestid+1;
|
43 |
+
$jobs[$newjobid]=$jobs[$jobid];
|
44 |
+
$jobs[$newjobid]['name']=__('Copy of','backwpup').' '.$jobs[$newjobid]['name'];
|
45 |
+
$jobs[$newjobid]['activated']=false;
|
46 |
+
$jobs[$newjobid]['fileprefix']=str_replace($jobid,$newjobid,$jobs[$jobid]['fileprefix']);
|
47 |
+
unset($jobs[$newjobid]['logfile']);
|
48 |
+
unset($jobs[$newjobid]['starttime']);
|
49 |
+
unset($jobs[$newjobid]['lastbackupdownloadurl']);
|
50 |
+
unset($jobs[$newjobid]['lastruntime']);
|
51 |
+
unset($jobs[$newjobid]['lastrun']);
|
52 |
+
update_option('backwpup_jobs',$jobs);
|
53 |
+
break;
|
54 |
+
case 'export': //Copy Job
|
55 |
+
if (is_array($_GET['jobs'])) {
|
56 |
+
check_admin_referer('bulk-jobs');
|
57 |
+
foreach ($_GET['jobs'] as $jobid) {
|
58 |
+
$jobsexport[$jobid]=backwpup_get_job_vars($jobid);
|
59 |
+
$jobsexport[$jobid]['activated']=false;
|
60 |
+
unset($jobsexport[$jobid]['logfile']);
|
61 |
+
unset($jobsexport[$jobid]['starttime']);
|
62 |
+
unset($jobsexport[$jobid]['lastbackupdownloadurl']);
|
63 |
+
unset($jobsexport[$jobid]['lastruntime']);
|
64 |
+
unset($jobsexport[$jobid]['lastrun']);
|
65 |
+
}
|
66 |
+
}
|
67 |
+
$export=serialize($jobsexport);
|
68 |
+
header("Pragma: public");
|
69 |
+
header("Expires: 0");
|
70 |
+
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
71 |
+
header("Content-Type: text/plain");
|
72 |
+
header("Content-Type: application/force-download");
|
73 |
+
header("Content-Type: application/octet-stream");
|
74 |
+
header("Content-Type: application/download");
|
75 |
+
header("Content-Disposition: attachment; filename=".sanitize_key(get_bloginfo('name'))."_BackWPupExport.txt;");
|
76 |
+
header("Content-Transfer-Encoding: 8bit");
|
77 |
+
header("Content-Length: ".strlen($export));
|
78 |
+
echo $export;
|
79 |
+
die();
|
80 |
+
break;
|
81 |
+
case 'abort': //Abort Job
|
82 |
+
check_admin_referer('abort-job');
|
83 |
+
$runningfile=backwpup_get_working_file();
|
84 |
+
$tempdir=backwpup_get_temp();
|
85 |
+
//clean up temp
|
86 |
+
if (is_dir($tempdir)) {
|
87 |
+
if ($dir = opendir($tempdir)) {
|
88 |
+
while (($file = readdir($dir)) !== false) {
|
89 |
+
if (is_readable($tempdir.$file) and is_file($tempdir.$file)) {
|
90 |
+
if ($file!='.' and $file!='..') {
|
91 |
+
unlink($tempdir.$file);
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
closedir($dir);
|
96 |
+
}
|
97 |
+
}
|
98 |
+
clearstatcache();
|
99 |
+
if (!empty($runningfile['LOGFILE'])) {
|
100 |
+
file_put_contents($runningfile['LOGFILE'], "<span class=\"timestamp\">".backwpup_date_i18n('Y/m/d H:i.s').":</span> <span class=\"error\">[ERROR]".__('Aborted by user!!!','backwpup')."</span><br />\n", FILE_APPEND);
|
101 |
+
//write new log header
|
102 |
+
$runningfile['WORKING']['ERROR']++;
|
103 |
+
$fd=fopen($runningfile['LOGFILE'],'r+');
|
104 |
+
while (!feof($fd)) {
|
105 |
+
$line=fgets($fd);
|
106 |
+
if (stripos($line,"<meta name=\"backwpup_errors\"") !== false) {
|
107 |
+
fseek($fd,$filepos);
|
108 |
+
fwrite($fd,str_pad("<meta name=\"backwpup_errors\" content=\"".$runningfile['WORKING']['ERROR']."\" />",100)."\n");
|
109 |
+
break;
|
110 |
+
}
|
111 |
+
$filepos=ftell($fd);
|
112 |
+
}
|
113 |
+
fclose($fd);
|
114 |
+
}
|
115 |
+
$backwpup_message=__('Job will be terminated.','backwpup').'<br />';
|
116 |
+
if (!empty($runningfile['WORKING']['PID']) and function_exists('posix_kill')) {
|
117 |
+
if (posix_kill($runningfile['WORKING']['PID'],9))
|
118 |
+
$backwpup_message.=__('Process killed with PID:','backwpup').' '.$runningfile['WORKING']['PID'];
|
119 |
+
else
|
120 |
+
$backwpup_message.=__('Can\'t kill process with PID:','backwpup').' '.$runningfile['WORKING']['PID'];
|
121 |
+
}
|
122 |
+
//update job settings
|
123 |
+
if (!empty($runningfile['JOBID'])) {
|
124 |
+
$jobs=get_option('backwpup_jobs');
|
125 |
+
if (isset($newlogfile) and !empty($newlogfile))
|
126 |
+
$jobs[$runningfile['JOBID']]['logfile']=$newlogfile;
|
127 |
+
$jobs[$runningfile['JOBID']]['lastrun']=$jobs[$runningfile['JOBID']]['starttime'];
|
128 |
+
$jobs[$runningfile['JOBID']]['lastruntime']=$runningfile['timestamp']-$jobs[$runningfile['JOBID']]['starttime'];
|
129 |
+
update_option('backwpup_jobs',$jobs); //Save Settings
|
130 |
+
}
|
131 |
+
break;
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
//add Help
|
136 |
+
backwpup_contextual_help(__('Here is the job overview with some information. You can see some further information of the jobs, how many can be switched with the view button. Also you can manage the jobs or abbort working jobs. Some links are added to have direct access to the last log or download.','backwpup'));
|
137 |
+
|
138 |
+
$backwpup_listtable->prepare_items();
|
|
pages/header_backwpupbackups.php
CHANGED
@@ -1,330 +1,329 @@
|
|
1 |
-
<?PHP
|
2 |
-
if (!defined('ABSPATH'))
|
3 |
-
die();
|
4 |
-
|
5 |
-
//Create Table
|
6 |
-
$backwpup_listtable = new BackWPup_Backups_Table;
|
7 |
-
|
8 |
-
//get cuurent action
|
9 |
-
$doaction = $backwpup_listtable->current_action();
|
10 |
-
|
11 |
-
if (!empty($doaction)) {
|
12 |
-
switch($doaction) {
|
13 |
-
case 'delete': //Delete Backup archives
|
14 |
-
check_admin_referer('bulk-backups');
|
15 |
-
$jobs=get_option('backwpup_jobs'); //Load jobs
|
16 |
-
list($jobid,$dest)=explode(',',$_GET['jobdest']);
|
17 |
-
$jobvalue=$jobs[$jobid];
|
18 |
-
foreach ($_GET['backupfiles'] as $backupfile) {
|
19 |
-
if ($dest=='FOLDER') {
|
20 |
-
if (is_file($backupfile))
|
21 |
-
unlink($backupfile);
|
22 |
-
} elseif ($dest=='S3') {
|
23 |
-
if (!class_exists('AmazonS3'))
|
24 |
-
require_once(realpath(dirname(__FILE__).'/../libs/aws/sdk.class.php'));
|
25 |
-
if (class_exists('AmazonS3')) {
|
26 |
-
if (!empty($jobvalue['awsAccessKey']) and !empty($jobvalue['awsSecretKey']) and !empty($jobvalue['awsBucket'])) {
|
27 |
-
try {
|
28 |
-
$s3 = new AmazonS3(array('key'=>$jobvalue['awsAccessKey'],'secret'=>$jobvalue['awsSecretKey'],'certificate_authority'=>true));
|
29 |
-
$s3->ssl_verification=false;
|
30 |
-
$s3->delete_object($jobvalue['awsBucket'],$backupfile);
|
31 |
-
unset($s3);
|
32 |
-
} catch (Exception $e) {
|
33 |
-
$backwpup_message.='Amazon S3: '.$e->getMessage().'<br />';
|
34 |
-
}
|
35 |
-
}
|
36 |
-
}
|
37 |
-
} elseif ($dest=='GSTORAGE') {
|
38 |
-
if (!class_exists('AmazonS3'))
|
39 |
-
require_once(realpath(dirname(__FILE__).'/../libs/aws/sdk.class.php'));
|
40 |
-
if (class_exists('AmazonS3')) {
|
41 |
-
if (!empty($jobvalue['GStorageAccessKey']) and !empty($jobvalue['GStorageSecret']) and !empty($jobvalue['GStorageBucket'])) {
|
42 |
-
try {
|
43 |
-
$gstorage = new AmazonS3(array('key'=>$jobvalue['GStorageAccessKey'],'secret'=>$jobvalue['GStorageSecret'],'certificate_authority'=>true));
|
44 |
-
$gstorage->ssl_verification=false;
|
45 |
-
$gstorage->set_hostname('commondatastorage.googleapis.com');
|
46 |
-
$gstorage->allow_hostname_override(false);
|
47 |
-
$gstorage->delete_object($jobvalue['GStorageBucket'],$backupfile);
|
48 |
-
unset($gstorage);
|
49 |
-
} catch (Exception $e) {
|
50 |
-
$backwpup_message.=sprintf(__('GStorage API: %s','backwpup'),$e->getMessage()).'<br />';
|
51 |
-
}
|
52 |
-
}
|
53 |
-
}
|
54 |
-
}elseif ($dest=='MSAZURE') {
|
55 |
-
if (!class_exists('Microsoft_WindowsAzure_Storage_Blob'))
|
56 |
-
require_once(dirname(__FILE__).'/../libs/Microsoft/WindowsAzure/Storage/Blob.php');
|
57 |
-
if (class_exists('Microsoft_WindowsAzure_Storage_Blob')) {
|
58 |
-
if (!empty($jobvalue['msazureHost']) and !empty($jobvalue['msazureAccName']) and !empty($jobvalue['msazureKey']) and !empty($jobvalue['msazureContainer'])) {
|
59 |
-
try {
|
60 |
-
$storageClient = new Microsoft_WindowsAzure_Storage_Blob($jobvalue['msazureHost'],$jobvalue['msazureAccName'],$jobvalue['msazureKey']);
|
61 |
-
$storageClient->deleteBlob($jobvalue['msazureContainer'],$backupfile);
|
62 |
-
unset($storageClient);
|
63 |
-
} catch (Exception $e) {
|
64 |
-
$backwpup_message.='MS AZURE: '.$e->getMessage().'<br />';
|
65 |
-
}
|
66 |
-
}
|
67 |
-
}
|
68 |
-
} elseif ($dest=='DROPBOX') {
|
69 |
-
if (!class_exists('Dropbox_API'))
|
70 |
-
require_once(realpath(dirname(__FILE__).'/../libs/dropbox.php'));
|
71 |
-
if (!empty($jobvalue['dropetoken']) and !empty($jobvalue['dropesecret'])) {
|
72 |
-
try {
|
73 |
-
$dropbox = new backwpup_Dropbox(BACKWPUP_DROPBOX_APP_KEY, BACKWPUP_DROPBOX_APP_SECRET,'dropbox');
|
74 |
-
$dropbox->setOAuthTokens($jobvalue['dropetoken'],$jobvalue['dropesecret']);
|
75 |
-
$dropbox->fileopsDelete($backupfile);
|
76 |
-
unset($dropbox);
|
77 |
-
} catch (Exception $e) {
|
78 |
-
$backwpup_message.='DROPBOX: '.$e->getMessage().'<br />';
|
79 |
-
}
|
80 |
-
}
|
81 |
-
} elseif ($dest=='SUGARSYNC') {
|
82 |
-
if (!class_exists('SugarSync'))
|
83 |
-
require_once (realpath(dirname(__FILE__).'/../libs/sugarsync.php'));
|
84 |
-
if (class_exists('SugarSync')) {
|
85 |
-
if (!empty($jobvalue['sugaruser']) and !empty($jobvalue['sugarpass'])) {
|
86 |
-
try {
|
87 |
-
$sugarsync = new SugarSync($jobvalue['sugaruser'],base64_decode($jobvalue['sugarpass']),BACKWPUP_SUGARSYNC_ACCESSKEY, BACKWPUP_SUGARSYNC_PRIVATEACCESSKEY);
|
88 |
-
$sugarsync->delete(urldecode($backupfile));
|
89 |
-
unset($sugarsync);
|
90 |
-
} catch (Exception $e) {
|
91 |
-
$backwpup_message.='SUGARSYNC: '.$e->getMessage().'<br />';
|
92 |
-
}
|
93 |
-
}
|
94 |
-
}
|
95 |
-
} elseif ($dest=='RSC') {
|
96 |
-
if (!class_exists('CF_Authentication'))
|
97 |
-
require_once(realpath(dirname(__FILE__).'/../libs/rackspace/cloudfiles.php'));
|
98 |
-
if (class_exists('CF_Authentication')) {
|
99 |
-
if (!empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey']) and !empty($jobvalue['rscContainer'])) {
|
100 |
-
try {
|
101 |
-
$auth = new CF_Authentication($jobvalue['rscUsername'], $jobvalue['rscAPIKey']);
|
102 |
-
$auth->ssl_use_cabundle();
|
103 |
-
if ($auth->authenticate()) {
|
104 |
-
$conn = new CF_Connection($auth);
|
105 |
-
$conn->ssl_use_cabundle();
|
106 |
-
$backwpupcontainer = $conn->get_container($jobvalue['rscContainer']);
|
107 |
-
$backwpupcontainer->delete_object($backupfile);
|
108 |
-
}
|
109 |
-
unset($auth);
|
110 |
-
unset($conn);
|
111 |
-
unset($backwpupcontainer);
|
112 |
-
} catch (Exception $e) {
|
113 |
-
$backwpup_message.='RSC: '.$e->getMessage().'<br />';
|
114 |
-
}
|
115 |
-
}
|
116 |
-
}
|
117 |
-
} elseif ($dest=='FTP') {
|
118 |
-
if (!empty($jobvalue['ftphost']) and !empty($jobvalue['ftpuser']) and !empty($jobvalue['ftppass']) and function_exists('ftp_connect')) {
|
119 |
-
if (function_exists('ftp_ssl_connect') and $jobvalue['ftpssl']) { //make SSL FTP connection
|
120 |
-
$ftp_conn_id = ftp_ssl_connect($jobvalue['ftphost'],$jobvalue['ftphostport'],10);
|
121 |
-
} elseif (!$jobvalue['ftpssl']) { //make normal FTP conection if SSL not work
|
122 |
-
$ftp_conn_id = ftp_connect($jobvalue['ftphost'],$jobvalue['ftphostport'],10);
|
123 |
-
}
|
124 |
-
$loginok=false;
|
125 |
-
if ($ftp_conn_id) {
|
126 |
-
//FTP Login
|
127 |
-
if (@ftp_login($ftp_conn_id, $jobvalue['ftpuser'], base64_decode($jobvalue['ftppass']))) {
|
128 |
-
$loginok=true;
|
129 |
-
} else { //if PHP ftp login don't work use raw login
|
130 |
-
ftp_raw($ftp_conn_id,'USER '.$jobvalue['ftpuser']);
|
131 |
-
$return=ftp_raw($ftp_conn_id,'PASS '.base64_decode($jobvalue['ftppass']));
|
132 |
-
if (substr(trim($return[0]),0,3)<=400)
|
133 |
-
$loginok=true;
|
134 |
-
}
|
135 |
-
}
|
136 |
-
if ($loginok) {
|
137 |
-
ftp_pasv($ftp_conn_id, $jobvalue['ftppasv']);
|
138 |
-
ftp_delete($ftp_conn_id, $backupfile);
|
139 |
-
} else {
|
140 |
-
$backwpup_message.='FTP: '.__('Login failure!','backwpup').'<br />';
|
141 |
-
}
|
142 |
-
}
|
143 |
-
}
|
144 |
-
}
|
145 |
-
delete_transient('backwpup_backups_chache');
|
146 |
-
break;
|
147 |
-
case 'download': //Download Backup
|
148 |
-
check_admin_referer('download-backup');
|
149 |
-
if (is_file($_GET['file'])) {
|
150 |
-
header("Pragma: public");
|
151 |
-
header("Expires: 0");
|
152 |
-
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
153 |
-
header("Content-Type: application/force-download");
|
154 |
-
header("Content-Type: application/octet-stream");
|
155 |
-
header("Content-Type: application/download");
|
156 |
-
header("Content-Disposition: attachment; filename=".basename($_GET['file']).";");
|
157 |
-
header("Content-Transfer-Encoding: binary");
|
158 |
-
header("Content-Length: ".filesize($_GET['file']));
|
159 |
-
@readfile($_GET['file']);
|
160 |
-
die();
|
161 |
-
} else {
|
162 |
-
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
163 |
-
header("Status: 404 Not Found");
|
164 |
-
die();
|
165 |
-
}
|
166 |
-
break;
|
167 |
-
case 'downloads3': //Download S3 Backup
|
168 |
-
check_admin_referer('download-backup');
|
169 |
-
if (!class_exists('AmazonS3'))
|
170 |
-
require_once(realpath(dirname(__FILE__).'/../libs/aws/sdk.class.php'));
|
171 |
-
$jobs=get_option('backwpup_jobs');
|
172 |
-
$jobid=$_GET['jobid'];
|
173 |
-
try {
|
174 |
-
$s3 = new AmazonS3(array('key'=>$jobs[$jobid]['awsAccessKey'],'secret'=>$jobs[$jobid]['awsSecretKey'],'certificate_authority'=>true));
|
175 |
-
$s3file=$s3->get_object($jobs[$jobid]['awsBucket'], $_GET['file']);
|
176 |
-
} catch (Exception $e) {
|
177 |
-
die($e->getMessage());
|
178 |
-
}
|
179 |
-
if ($s3file->status==200) {
|
180 |
-
header("Pragma: public");
|
181 |
-
header("Expires: 0");
|
182 |
-
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
183 |
-
header("Content-Type: ".$s3file->header->_info->content_type);
|
184 |
-
header("Content-Type: application/force-download");
|
185 |
-
header("Content-Type: application/octet-stream");
|
186 |
-
header("Content-Type: application/download");
|
187 |
-
header("Content-Disposition: attachment; filename=".basename($_GET['file']).";");
|
188 |
-
header("Content-Transfer-Encoding: binary");
|
189 |
-
header("Content-Length: ".$s3file->header->_info->size_download);
|
190 |
-
echo $s3file->body;
|
191 |
-
die();
|
192 |
-
} else {
|
193 |
-
header('HTTP/1.0 '.$s3file->status.' Not Found');
|
194 |
-
die();
|
195 |
-
}
|
196 |
-
break;
|
197 |
-
case 'downloaddropbox': //Download Dropbox Backup
|
198 |
-
check_admin_referer('download-backup');
|
199 |
-
if (!class_exists('Dropbox_API'))
|
200 |
-
require_once(realpath(dirname(__FILE__).'/../libs/dropbox.php'));
|
201 |
-
$jobs=get_option('backwpup_jobs');
|
202 |
-
$jobid=$_GET['jobid'];
|
203 |
-
try {
|
204 |
-
$dropbox = new backwpup_Dropbox(BACKWPUP_DROPBOX_APP_KEY, BACKWPUP_DROPBOX_APP_SECRET,'dropbox');
|
205 |
-
$dropbox->setOAuthTokens($jobs[$jobid]['dropetoken'],$jobs[$jobid]['dropesecret']);
|
206 |
-
$filemeta=$dropbox->metadata($_GET['file'],false,1);
|
207 |
-
header("Pragma: public");
|
208 |
-
header("Expires: 0");
|
209 |
-
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
210 |
-
header("Content-Type: ".$filemeta['mime_type']);
|
211 |
-
header("Content-Type: application/force-download");
|
212 |
-
header("Content-Type: application/octet-stream");
|
213 |
-
header("Content-Type: application/download");
|
214 |
-
header("Content-Disposition: attachment; filename=".basename($_GET['file']).";");
|
215 |
-
header("Content-Transfer-Encoding: binary");
|
216 |
-
header("Content-Length: ".$filemeta['bytes']);
|
217 |
-
$dropbox->download($_GET['file'],true);
|
218 |
-
die();
|
219 |
-
} catch (Exception $e) {
|
220 |
-
die($e->getMessage());
|
221 |
-
}
|
222 |
-
break;
|
223 |
-
case 'downloadsugarsync': //Download Dropbox Backup
|
224 |
-
check_admin_referer('download-backup');
|
225 |
-
if (!class_exists('SugarSync'))
|
226 |
-
require_once(realpath(dirname(__FILE__).'/../libs/sugarsync.php'));
|
227 |
-
$jobs=get_option('backwpup_jobs');
|
228 |
-
$jobid=$_GET['jobid'];
|
229 |
-
try {
|
230 |
-
$sugarsync = new SugarSync($jobs[$jobid]['sugaruser'],base64_decode($jobs[$jobid]['sugarpass']),BACKWPUP_SUGARSYNC_ACCESSKEY, BACKWPUP_SUGARSYNC_PRIVATEACCESSKEY);
|
231 |
-
$response=$sugarsync->get(urldecode($_GET['file']));
|
232 |
-
header("Pragma: public");
|
233 |
-
header("Expires: 0");
|
234 |
-
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
235 |
-
header("Content-Type: ".(string)$response->mediaType);
|
236 |
-
header("Content-Type: application/force-download");
|
237 |
-
header("Content-Type: application/octet-stream");
|
238 |
-
header("Content-Type: application/download");
|
239 |
-
header("Content-Disposition: attachment; filename=".(string)$response->displayName.";");
|
240 |
-
header("Content-Transfer-Encoding: binary");
|
241 |
-
header("Content-Length: ".(int)$response->size);
|
242 |
-
echo $sugarsync->download(urldecode($_GET['file']));
|
243 |
-
die();
|
244 |
-
} catch (Exception $e) {
|
245 |
-
die($e->getMessage());
|
246 |
-
}
|
247 |
-
break;
|
248 |
-
case 'downloadmsazure': //Download Microsoft Azure Backup
|
249 |
-
check_admin_referer('download-backup');
|
250 |
-
if (!class_exists('Microsoft_WindowsAzure_Storage_Blob'))
|
251 |
-
require_once(dirname(__FILE__).'/../libs/Microsoft/WindowsAzure/Storage/Blob.php');
|
252 |
-
$jobs=get_option('backwpup_jobs');
|
253 |
-
$jobid=$_GET['jobid'];
|
254 |
-
try {
|
255 |
-
$storageClient = new Microsoft_WindowsAzure_Storage_Blob($jobs[$jobid]['msazureHost'],$jobs[$jobid]['msazureAccName'],$jobs[$jobid]['msazureKey']);
|
256 |
-
header("Pragma: public");
|
257 |
-
header("Expires: 0");
|
258 |
-
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
259 |
-
//header("Content-Type: ".$s3file->header->_info->content_type);
|
260 |
-
header("Content-Type: application/force-download");
|
261 |
-
header("Content-Type: application/octet-stream");
|
262 |
-
header("Content-Type: application/download");
|
263 |
-
header("Content-Disposition: attachment; filename=".basename($_GET['file']).";");
|
264 |
-
header("Content-Transfer-Encoding: binary");
|
265 |
-
//header("Content-Length: ".$s3file->header->_info->size_download);
|
266 |
-
echo $storageClient->getBlobData($jobs[$jobid]['msazureContainer'], $_GET['file']);
|
267 |
-
die();
|
268 |
-
} catch (Exception $e) {
|
269 |
-
die($e->getMessage());
|
270 |
-
}
|
271 |
-
break;
|
272 |
-
case 'downloadrsc': //Download RSC Backup
|
273 |
-
check_admin_referer('download-backup');
|
274 |
-
if (!class_exists('CF_Authentication'))
|
275 |
-
require_once(realpath(plugin_dir_path(__FILE__).'/../libs/rackspace/cloudfiles.php'));
|
276 |
-
$jobs=get_option('backwpup_jobs');
|
277 |
-
$jobid=$_GET['jobid'];
|
278 |
-
try {
|
279 |
-
$auth = new CF_Authentication($jobs[$jobid]['rscUsername'], $jobs[$jobid]['rscAPIKey']);
|
280 |
-
$auth->ssl_use_cabundle();
|
281 |
-
if ($auth->authenticate()) {
|
282 |
-
$conn = new CF_Connection($auth);
|
283 |
-
$conn->ssl_use_cabundle();
|
284 |
-
$backwpupcontainer = $conn->get_container($jobs[$jobid]['rscContainer']);
|
285 |
-
$backupfile=$backwpupcontainer->get_object($_GET['file']);
|
286 |
-
header("Pragma: public");
|
287 |
-
header("Expires: 0");
|
288 |
-
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
289 |
-
header("Content-Type: ".$backupfile->content_type);
|
290 |
-
header("Content-Type: application/force-download");
|
291 |
-
header("Content-Type: application/octet-stream");
|
292 |
-
header("Content-Type: application/download");
|
293 |
-
header("Content-Disposition: attachment; filename=".basename($_GET['file']).";");
|
294 |
-
header("Content-Transfer-Encoding: binary");
|
295 |
-
header("Content-Length: ".$backupfile->content_length);
|
296 |
-
$output = fopen("php://output", "w");
|
297 |
-
$backupfile->stream($output);
|
298 |
-
fclose($output);
|
299 |
-
die();
|
300 |
-
} else {
|
301 |
-
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
302 |
-
header("Status: 404 Not Found");
|
303 |
-
die();
|
304 |
-
}
|
305 |
-
} catch (Exception $e) {
|
306 |
-
die($e->getMessage());
|
307 |
-
}
|
308 |
-
break;
|
309 |
-
}
|
310 |
-
}
|
311 |
-
//Save per page
|
312 |
-
if (isset($_POST['screen-options-apply']) and isset($_POST['wp_screen_options']['option']) and isset($_POST['wp_screen_options']['value']) and $_POST['wp_screen_options']['option']=='backwpupbackups_per_page') {
|
313 |
-
check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
|
314 |
-
global $current_user;
|
315 |
-
if ($_POST['wp_screen_options']['value']>0 and $_POST['wp_screen_options']['value']<1000) {
|
316 |
-
update_user_option($current_user->ID,'backwpupbackups_per_page',(int) $_POST['wp_screen_options']['value']);
|
317 |
-
wp_redirect( remove_query_arg( array('pagenum', 'apage', 'paged'), wp_get_referer() ) );
|
318 |
-
exit;
|
319 |
-
}
|
320 |
-
}
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
//add Help
|
325 |
-
backwpup_contextual_help(__('Here you see a list of backup files. Change the destionation to jobname:destination to become a list of backups from other destinations and jobs. Then you kann delete or download backup files.','backwpup'));
|
326 |
-
|
327 |
-
add_screen_option( 'per_page', array('label' => __('Logs','backwpup'), 'default' => 20, 'option' =>'backwpupbackups_per_page') );
|
328 |
-
|
329 |
-
$backwpup_listtable->prepare_items();
|
330 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
if (!defined('ABSPATH'))
|
3 |
+
die();
|
4 |
+
|
5 |
+
//Create Table
|
6 |
+
$backwpup_listtable = new BackWPup_Backups_Table;
|
7 |
+
|
8 |
+
//get cuurent action
|
9 |
+
$doaction = $backwpup_listtable->current_action();
|
10 |
+
|
11 |
+
if (!empty($doaction)) {
|
12 |
+
switch($doaction) {
|
13 |
+
case 'delete': //Delete Backup archives
|
14 |
+
check_admin_referer('bulk-backups');
|
15 |
+
$jobs=get_option('backwpup_jobs'); //Load jobs
|
16 |
+
list($jobid,$dest)=explode(',',$_GET['jobdest']);
|
17 |
+
$jobvalue=$jobs[$jobid];
|
18 |
+
foreach ($_GET['backupfiles'] as $backupfile) {
|
19 |
+
if ($dest=='FOLDER') {
|
20 |
+
if (is_file($backupfile))
|
21 |
+
unlink($backupfile);
|
22 |
+
} elseif ($dest=='S3') {
|
23 |
+
if (!class_exists('AmazonS3'))
|
24 |
+
require_once(realpath(dirname(__FILE__).'/../libs/aws/sdk.class.php'));
|
25 |
+
if (class_exists('AmazonS3')) {
|
26 |
+
if (!empty($jobvalue['awsAccessKey']) and !empty($jobvalue['awsSecretKey']) and !empty($jobvalue['awsBucket'])) {
|
27 |
+
try {
|
28 |
+
$s3 = new AmazonS3(array('key'=>$jobvalue['awsAccessKey'],'secret'=>$jobvalue['awsSecretKey'],'certificate_authority'=>true));
|
29 |
+
$s3->ssl_verification=false;
|
30 |
+
$s3->delete_object($jobvalue['awsBucket'],$backupfile);
|
31 |
+
unset($s3);
|
32 |
+
} catch (Exception $e) {
|
33 |
+
$backwpup_message.='Amazon S3: '.$e->getMessage().'<br />';
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
37 |
+
} elseif ($dest=='GSTORAGE') {
|
38 |
+
if (!class_exists('AmazonS3'))
|
39 |
+
require_once(realpath(dirname(__FILE__).'/../libs/aws/sdk.class.php'));
|
40 |
+
if (class_exists('AmazonS3')) {
|
41 |
+
if (!empty($jobvalue['GStorageAccessKey']) and !empty($jobvalue['GStorageSecret']) and !empty($jobvalue['GStorageBucket'])) {
|
42 |
+
try {
|
43 |
+
$gstorage = new AmazonS3(array('key'=>$jobvalue['GStorageAccessKey'],'secret'=>$jobvalue['GStorageSecret'],'certificate_authority'=>true));
|
44 |
+
$gstorage->ssl_verification=false;
|
45 |
+
$gstorage->set_hostname('commondatastorage.googleapis.com');
|
46 |
+
$gstorage->allow_hostname_override(false);
|
47 |
+
$gstorage->delete_object($jobvalue['GStorageBucket'],$backupfile);
|
48 |
+
unset($gstorage);
|
49 |
+
} catch (Exception $e) {
|
50 |
+
$backwpup_message.=sprintf(__('GStorage API: %s','backwpup'),$e->getMessage()).'<br />';
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}elseif ($dest=='MSAZURE') {
|
55 |
+
if (!class_exists('Microsoft_WindowsAzure_Storage_Blob'))
|
56 |
+
require_once(dirname(__FILE__).'/../libs/Microsoft/WindowsAzure/Storage/Blob.php');
|
57 |
+
if (class_exists('Microsoft_WindowsAzure_Storage_Blob')) {
|
58 |
+
if (!empty($jobvalue['msazureHost']) and !empty($jobvalue['msazureAccName']) and !empty($jobvalue['msazureKey']) and !empty($jobvalue['msazureContainer'])) {
|
59 |
+
try {
|
60 |
+
$storageClient = new Microsoft_WindowsAzure_Storage_Blob($jobvalue['msazureHost'],$jobvalue['msazureAccName'],$jobvalue['msazureKey']);
|
61 |
+
$storageClient->deleteBlob($jobvalue['msazureContainer'],$backupfile);
|
62 |
+
unset($storageClient);
|
63 |
+
} catch (Exception $e) {
|
64 |
+
$backwpup_message.='MS AZURE: '.$e->getMessage().'<br />';
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
68 |
+
} elseif ($dest=='DROPBOX') {
|
69 |
+
if (!class_exists('Dropbox_API'))
|
70 |
+
require_once(realpath(dirname(__FILE__).'/../libs/dropbox.php'));
|
71 |
+
if (!empty($jobvalue['dropetoken']) and !empty($jobvalue['dropesecret'])) {
|
72 |
+
try {
|
73 |
+
$dropbox = new backwpup_Dropbox(BACKWPUP_DROPBOX_APP_KEY, BACKWPUP_DROPBOX_APP_SECRET,'dropbox');
|
74 |
+
$dropbox->setOAuthTokens($jobvalue['dropetoken'],$jobvalue['dropesecret']);
|
75 |
+
$dropbox->fileopsDelete($backupfile);
|
76 |
+
unset($dropbox);
|
77 |
+
} catch (Exception $e) {
|
78 |
+
$backwpup_message.='DROPBOX: '.$e->getMessage().'<br />';
|
79 |
+
}
|
80 |
+
}
|
81 |
+
} elseif ($dest=='SUGARSYNC') {
|
82 |
+
if (!class_exists('SugarSync'))
|
83 |
+
require_once (realpath(dirname(__FILE__).'/../libs/sugarsync.php'));
|
84 |
+
if (class_exists('SugarSync')) {
|
85 |
+
if (!empty($jobvalue['sugaruser']) and !empty($jobvalue['sugarpass'])) {
|
86 |
+
try {
|
87 |
+
$sugarsync = new SugarSync($jobvalue['sugaruser'],base64_decode($jobvalue['sugarpass']),BACKWPUP_SUGARSYNC_ACCESSKEY, BACKWPUP_SUGARSYNC_PRIVATEACCESSKEY);
|
88 |
+
$sugarsync->delete(urldecode($backupfile));
|
89 |
+
unset($sugarsync);
|
90 |
+
} catch (Exception $e) {
|
91 |
+
$backwpup_message.='SUGARSYNC: '.$e->getMessage().'<br />';
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
} elseif ($dest=='RSC') {
|
96 |
+
if (!class_exists('CF_Authentication'))
|
97 |
+
require_once(realpath(dirname(__FILE__).'/../libs/rackspace/cloudfiles.php'));
|
98 |
+
if (class_exists('CF_Authentication')) {
|
99 |
+
if (!empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey']) and !empty($jobvalue['rscContainer'])) {
|
100 |
+
try {
|
101 |
+
$auth = new CF_Authentication($jobvalue['rscUsername'], $jobvalue['rscAPIKey']);
|
102 |
+
$auth->ssl_use_cabundle();
|
103 |
+
if ($auth->authenticate()) {
|
104 |
+
$conn = new CF_Connection($auth);
|
105 |
+
$conn->ssl_use_cabundle();
|
106 |
+
$backwpupcontainer = $conn->get_container($jobvalue['rscContainer']);
|
107 |
+
$backwpupcontainer->delete_object($backupfile);
|
108 |
+
}
|
109 |
+
unset($auth);
|
110 |
+
unset($conn);
|
111 |
+
unset($backwpupcontainer);
|
112 |
+
} catch (Exception $e) {
|
113 |
+
$backwpup_message.='RSC: '.$e->getMessage().'<br />';
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
117 |
+
} elseif ($dest=='FTP') {
|
118 |
+
if (!empty($jobvalue['ftphost']) and !empty($jobvalue['ftpuser']) and !empty($jobvalue['ftppass']) and function_exists('ftp_connect')) {
|
119 |
+
if (function_exists('ftp_ssl_connect') and $jobvalue['ftpssl']) { //make SSL FTP connection
|
120 |
+
$ftp_conn_id = ftp_ssl_connect($jobvalue['ftphost'],$jobvalue['ftphostport'],10);
|
121 |
+
} elseif (!$jobvalue['ftpssl']) { //make normal FTP conection if SSL not work
|
122 |
+
$ftp_conn_id = ftp_connect($jobvalue['ftphost'],$jobvalue['ftphostport'],10);
|
123 |
+
}
|
124 |
+
$loginok=false;
|
125 |
+
if ($ftp_conn_id) {
|
126 |
+
//FTP Login
|
127 |
+
if (@ftp_login($ftp_conn_id, $jobvalue['ftpuser'], base64_decode($jobvalue['ftppass']))) {
|
128 |
+
$loginok=true;
|
129 |
+
} else { //if PHP ftp login don't work use raw login
|
130 |
+
ftp_raw($ftp_conn_id,'USER '.$jobvalue['ftpuser']);
|
131 |
+
$return=ftp_raw($ftp_conn_id,'PASS '.base64_decode($jobvalue['ftppass']));
|
132 |
+
if (substr(trim($return[0]),0,3)<=400)
|
133 |
+
$loginok=true;
|
134 |
+
}
|
135 |
+
}
|
136 |
+
if ($loginok) {
|
137 |
+
ftp_pasv($ftp_conn_id, $jobvalue['ftppasv']);
|
138 |
+
ftp_delete($ftp_conn_id, $backupfile);
|
139 |
+
} else {
|
140 |
+
$backwpup_message.='FTP: '.__('Login failure!','backwpup').'<br />';
|
141 |
+
}
|
142 |
+
}
|
143 |
+
}
|
144 |
+
}
|
145 |
+
delete_transient('backwpup_backups_chache');
|
146 |
+
break;
|
147 |
+
case 'download': //Download Backup
|
148 |
+
check_admin_referer('download-backup');
|
149 |
+
if (is_file($_GET['file'])) {
|
150 |
+
header("Pragma: public");
|
151 |
+
header("Expires: 0");
|
152 |
+
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
153 |
+
header("Content-Type: application/force-download");
|
154 |
+
header("Content-Type: application/octet-stream");
|
155 |
+
header("Content-Type: application/download");
|
156 |
+
header("Content-Disposition: attachment; filename=".basename($_GET['file']).";");
|
157 |
+
header("Content-Transfer-Encoding: binary");
|
158 |
+
header("Content-Length: ".filesize($_GET['file']));
|
159 |
+
@readfile($_GET['file']);
|
160 |
+
die();
|
161 |
+
} else {
|
162 |
+
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
163 |
+
header("Status: 404 Not Found");
|
164 |
+
die();
|
165 |
+
}
|
166 |
+
break;
|
167 |
+
case 'downloads3': //Download S3 Backup
|
168 |
+
check_admin_referer('download-backup');
|
169 |
+
if (!class_exists('AmazonS3'))
|
170 |
+
require_once(realpath(dirname(__FILE__).'/../libs/aws/sdk.class.php'));
|
171 |
+
$jobs=get_option('backwpup_jobs');
|
172 |
+
$jobid=$_GET['jobid'];
|
173 |
+
try {
|
174 |
+
$s3 = new AmazonS3(array('key'=>$jobs[$jobid]['awsAccessKey'],'secret'=>$jobs[$jobid]['awsSecretKey'],'certificate_authority'=>true));
|
175 |
+
$s3file=$s3->get_object($jobs[$jobid]['awsBucket'], $_GET['file']);
|
176 |
+
} catch (Exception $e) {
|
177 |
+
die($e->getMessage());
|
178 |
+
}
|
179 |
+
if ($s3file->status==200) {
|
180 |
+
header("Pragma: public");
|
181 |
+
header("Expires: 0");
|
182 |
+
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
183 |
+
header("Content-Type: ".$s3file->header->_info->content_type);
|
184 |
+
header("Content-Type: application/force-download");
|
185 |
+
header("Content-Type: application/octet-stream");
|
186 |
+
header("Content-Type: application/download");
|
187 |
+
header("Content-Disposition: attachment; filename=".basename($_GET['file']).";");
|
188 |
+
header("Content-Transfer-Encoding: binary");
|
189 |
+
header("Content-Length: ".$s3file->header->_info->size_download);
|
190 |
+
echo $s3file->body;
|
191 |
+
die();
|
192 |
+
} else {
|
193 |
+
header('HTTP/1.0 '.$s3file->status.' Not Found');
|
194 |
+
die();
|
195 |
+
}
|
196 |
+
break;
|
197 |
+
case 'downloaddropbox': //Download Dropbox Backup
|
198 |
+
check_admin_referer('download-backup');
|
199 |
+
if (!class_exists('Dropbox_API'))
|
200 |
+
require_once(realpath(dirname(__FILE__).'/../libs/dropbox.php'));
|
201 |
+
$jobs=get_option('backwpup_jobs');
|
202 |
+
$jobid=$_GET['jobid'];
|
203 |
+
try {
|
204 |
+
$dropbox = new backwpup_Dropbox(BACKWPUP_DROPBOX_APP_KEY, BACKWPUP_DROPBOX_APP_SECRET,'dropbox');
|
205 |
+
$dropbox->setOAuthTokens($jobs[$jobid]['dropetoken'],$jobs[$jobid]['dropesecret']);
|
206 |
+
$filemeta=$dropbox->metadata($_GET['file'],false,1);
|
207 |
+
header("Pragma: public");
|
208 |
+
header("Expires: 0");
|
209 |
+
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
210 |
+
header("Content-Type: ".$filemeta['mime_type']);
|
211 |
+
header("Content-Type: application/force-download");
|
212 |
+
header("Content-Type: application/octet-stream");
|
213 |
+
header("Content-Type: application/download");
|
214 |
+
header("Content-Disposition: attachment; filename=".basename($_GET['file']).";");
|
215 |
+
header("Content-Transfer-Encoding: binary");
|
216 |
+
header("Content-Length: ".$filemeta['bytes']);
|
217 |
+
$dropbox->download($_GET['file'],true);
|
218 |
+
die();
|
219 |
+
} catch (Exception $e) {
|
220 |
+
die($e->getMessage());
|
221 |
+
}
|
222 |
+
break;
|
223 |
+
case 'downloadsugarsync': //Download Dropbox Backup
|
224 |
+
check_admin_referer('download-backup');
|
225 |
+
if (!class_exists('SugarSync'))
|
226 |
+
require_once(realpath(dirname(__FILE__).'/../libs/sugarsync.php'));
|
227 |
+
$jobs=get_option('backwpup_jobs');
|
228 |
+
$jobid=$_GET['jobid'];
|
229 |
+
try {
|
230 |
+
$sugarsync = new SugarSync($jobs[$jobid]['sugaruser'],base64_decode($jobs[$jobid]['sugarpass']),BACKWPUP_SUGARSYNC_ACCESSKEY, BACKWPUP_SUGARSYNC_PRIVATEACCESSKEY);
|
231 |
+
$response=$sugarsync->get(urldecode($_GET['file']));
|
232 |
+
header("Pragma: public");
|
233 |
+
header("Expires: 0");
|
234 |
+
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
235 |
+
header("Content-Type: ".(string)$response->mediaType);
|
236 |
+
header("Content-Type: application/force-download");
|
237 |
+
header("Content-Type: application/octet-stream");
|
238 |
+
header("Content-Type: application/download");
|
239 |
+
header("Content-Disposition: attachment; filename=".(string)$response->displayName.";");
|
240 |
+
header("Content-Transfer-Encoding: binary");
|
241 |
+
header("Content-Length: ".(int)$response->size);
|
242 |
+
echo $sugarsync->download(urldecode($_GET['file']));
|
243 |
+
die();
|
244 |
+
} catch (Exception $e) {
|
245 |
+
die($e->getMessage());
|
246 |
+
}
|
247 |
+
break;
|
248 |
+
case 'downloadmsazure': //Download Microsoft Azure Backup
|
249 |
+
check_admin_referer('download-backup');
|
250 |
+
if (!class_exists('Microsoft_WindowsAzure_Storage_Blob'))
|
251 |
+
require_once(dirname(__FILE__).'/../libs/Microsoft/WindowsAzure/Storage/Blob.php');
|
252 |
+
$jobs=get_option('backwpup_jobs');
|
253 |
+
$jobid=$_GET['jobid'];
|
254 |
+
try {
|
255 |
+
$storageClient = new Microsoft_WindowsAzure_Storage_Blob($jobs[$jobid]['msazureHost'],$jobs[$jobid]['msazureAccName'],$jobs[$jobid]['msazureKey']);
|
256 |
+
header("Pragma: public");
|
257 |
+
header("Expires: 0");
|
258 |
+
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
259 |
+
//header("Content-Type: ".$s3file->header->_info->content_type);
|
260 |
+
header("Content-Type: application/force-download");
|
261 |
+
header("Content-Type: application/octet-stream");
|
262 |
+
header("Content-Type: application/download");
|
263 |
+
header("Content-Disposition: attachment; filename=".basename($_GET['file']).";");
|
264 |
+
header("Content-Transfer-Encoding: binary");
|
265 |
+
//header("Content-Length: ".$s3file->header->_info->size_download);
|
266 |
+
echo $storageClient->getBlobData($jobs[$jobid]['msazureContainer'], $_GET['file']);
|
267 |
+
die();
|
268 |
+
} catch (Exception $e) {
|
269 |
+
die($e->getMessage());
|
270 |
+
}
|
271 |
+
break;
|
272 |
+
case 'downloadrsc': //Download RSC Backup
|
273 |
+
check_admin_referer('download-backup');
|
274 |
+
if (!class_exists('CF_Authentication'))
|
275 |
+
require_once(realpath(plugin_dir_path(__FILE__).'/../libs/rackspace/cloudfiles.php'));
|
276 |
+
$jobs=get_option('backwpup_jobs');
|
277 |
+
$jobid=$_GET['jobid'];
|
278 |
+
try {
|
279 |
+
$auth = new CF_Authentication($jobs[$jobid]['rscUsername'], $jobs[$jobid]['rscAPIKey']);
|
280 |
+
$auth->ssl_use_cabundle();
|
281 |
+
if ($auth->authenticate()) {
|
282 |
+
$conn = new CF_Connection($auth);
|
283 |
+
$conn->ssl_use_cabundle();
|
284 |
+
$backwpupcontainer = $conn->get_container($jobs[$jobid]['rscContainer']);
|
285 |
+
$backupfile=$backwpupcontainer->get_object($_GET['file']);
|
286 |
+
header("Pragma: public");
|
287 |
+
header("Expires: 0");
|
288 |
+
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
289 |
+
header("Content-Type: ".$backupfile->content_type);
|
290 |
+
header("Content-Type: application/force-download");
|
291 |
+
header("Content-Type: application/octet-stream");
|
292 |
+
header("Content-Type: application/download");
|
293 |
+
header("Content-Disposition: attachment; filename=".basename($_GET['file']).";");
|
294 |
+
header("Content-Transfer-Encoding: binary");
|
295 |
+
header("Content-Length: ".$backupfile->content_length);
|
296 |
+
$output = fopen("php://output", "w");
|
297 |
+
$backupfile->stream($output);
|
298 |
+
fclose($output);
|
299 |
+
die();
|
300 |
+
} else {
|
301 |
+
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
302 |
+
header("Status: 404 Not Found");
|
303 |
+
die();
|
304 |
+
}
|
305 |
+
} catch (Exception $e) {
|
306 |
+
die($e->getMessage());
|
307 |
+
}
|
308 |
+
break;
|
309 |
+
}
|
310 |
+
}
|
311 |
+
//Save per page
|
312 |
+
if (isset($_POST['screen-options-apply']) and isset($_POST['wp_screen_options']['option']) and isset($_POST['wp_screen_options']['value']) and $_POST['wp_screen_options']['option']=='backwpupbackups_per_page') {
|
313 |
+
check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
|
314 |
+
global $current_user;
|
315 |
+
if ($_POST['wp_screen_options']['value']>0 and $_POST['wp_screen_options']['value']<1000) {
|
316 |
+
update_user_option($current_user->ID,'backwpupbackups_per_page',(int) $_POST['wp_screen_options']['value']);
|
317 |
+
wp_redirect( remove_query_arg( array('pagenum', 'apage', 'paged'), wp_get_referer() ) );
|
318 |
+
exit;
|
319 |
+
}
|
320 |
+
}
|
321 |
+
|
322 |
+
|
323 |
+
|
324 |
+
//add Help
|
325 |
+
backwpup_contextual_help(__('Here you see a list of backup files. Change the destionation to jobname:destination to become a list of backups from other destinations and jobs. Then you kann delete or download backup files.','backwpup'));
|
326 |
+
|
327 |
+
add_screen_option( 'per_page', array('label' => __('Logs','backwpup'), 'default' => 20, 'option' =>'backwpupbackups_per_page') );
|
328 |
+
|
329 |
+
$backwpup_listtable->prepare_items();
|
|
pages/header_backwpupeditjob.php
CHANGED
@@ -1,296 +1,295 @@
|
|
1 |
-
<?PHP
|
2 |
-
if (!defined('ABSPATH'))
|
3 |
-
die();
|
4 |
-
|
5 |
-
//Save Dropbox settings
|
6 |
-
if (isset($_GET['dropboxauth']) and $_GET['dropboxauth']=='AccessToken') {
|
7 |
-
$jobid = (int) $_GET['jobid'];
|
8 |
-
check_admin_referer('edit-job');
|
9 |
-
$backwpup_message='';
|
10 |
-
if ((int)$_GET['uid']>0 and !empty($_GET['oauth_token_backwpup'])) {
|
11 |
-
$reqtoken=get_transient('backwpup_dropboxrequest');
|
12 |
-
if ($reqtoken['oAuthRequestToken']==$_GET['oauth_token_backwpup']) {
|
13 |
-
//Get Access Tokens
|
14 |
-
require_once (dirname(__FILE__).'/../libs/dropbox.php');
|
15 |
-
$jobs=get_option('backwpup_jobs');
|
16 |
-
$dropbox = new backwpup_Dropbox(BACKWPUP_DROPBOX_APP_KEY, BACKWPUP_DROPBOX_APP_SECRET,'dropbox');
|
17 |
-
$oAuthStuff = $dropbox->oAuthAccessToken($reqtoken['oAuthRequestToken'],$reqtoken['oAuthRequestTokenSecret']);
|
18 |
-
//Save Tokens
|
19 |
-
$jobs[$jobid]['dropetoken']=$oAuthStuff['oauth_token'];
|
20 |
-
$jobs[$jobid]['dropesecret']=$oAuthStuff['oauth_token_secret'];
|
21 |
-
update_option('backwpup_jobs',$jobs);
|
22 |
-
$backwpup_message.=__('Dropbox authentication complete!','backwpup').'<br />';
|
23 |
-
} else {
|
24 |
-
$backwpup_message.=__('Wrong Token for Dropbox authentication received!','backwpup').'<br />';
|
25 |
-
}
|
26 |
-
} else {
|
27 |
-
$backwpup_message.=__('No Dropbox authentication received!','backwpup').'<br />';
|
28 |
-
}
|
29 |
-
delete_transient('backwpup_dropboxrequest');
|
30 |
-
$_POST['jobid']=$jobid;
|
31 |
-
}
|
32 |
-
|
33 |
-
//Save Job settings
|
34 |
-
if ((isset($_POST['save']) or isset($_POST['dropboxauth']) or isset($_POST['dropboxauthdel'])) and !empty($_POST['jobid'])) {
|
35 |
-
check_admin_referer('edit-job');
|
36 |
-
$jobvalues['jobid']=(int) $_POST['jobid'];
|
37 |
-
$jobvalues['type']= implode('+',(array)$_POST['type']);
|
38 |
-
$jobvalues['name']= esc_html($_POST['name']);
|
39 |
-
$jobvalues['activated']= (isset($_POST['activated']) && $_POST['activated']==1) ? true : false;
|
40 |
-
$jobvalues['cronselect']= $_POST['cronselect']=='basic' ? 'basic':'advanced';
|
41 |
-
if ($jobvalues['cronselect']=='advanced') {
|
42 |
-
if (empty($_POST['cronminutes']) or $_POST['cronminutes'][0]=='*') {
|
43 |
-
if (!empty($_POST['cronminutes'][1]))
|
44 |
-
$_POST['cronminutes']=array('*/'.$_POST['cronminutes'][1]);
|
45 |
-
else
|
46 |
-
$_POST['cronminutes']=array('*');
|
47 |
-
}
|
48 |
-
if (empty($_POST['cronhours']) or $_POST['cronhours'][0]=='*') {
|
49 |
-
if (!empty($_POST['cronhours'][1]))
|
50 |
-
$_POST['cronhours']=array('*/'.$_POST['cronhours'][1]);
|
51 |
-
else
|
52 |
-
$_POST['cronhours']=array('*');
|
53 |
-
}
|
54 |
-
if (empty($_POST['cronmday']) or $_POST['cronmday'][0]=='*') {
|
55 |
-
if (!empty($_POST['cronmday'][1]))
|
56 |
-
$_POST['cronmday']=array('*/'.$_POST['cronmday'][1]);
|
57 |
-
else
|
58 |
-
$_POST['cronmday']=array('*');
|
59 |
-
}
|
60 |
-
if (empty($_POST['cronmon']) or $_POST['cronmon'][0]=='*') {
|
61 |
-
if (!empty($_POST['cronmon'][1]))
|
62 |
-
$_POST['cronmon']=array('*/'.$_POST['cronmon'][1]);
|
63 |
-
else
|
64 |
-
$_POST['cronmon']=array('*');
|
65 |
-
}
|
66 |
-
if (empty($_POST['cronwday']) or $_POST['cronwday'][0]=='*') {
|
67 |
-
if (!empty($_POST['cronwday'][1]))
|
68 |
-
$_POST['cronwday']=array('*/'.$_POST['cronwday'][1]);
|
69 |
-
else
|
70 |
-
$_POST['cronwday']=array('*');
|
71 |
-
}
|
72 |
-
$jobvalues['cron']=implode(",",$_POST['cronminutes']).' '.implode(",",$_POST['cronhours']).' '.implode(",",$_POST['cronmday']).' '.implode(",",$_POST['cronmon']).' '.implode(",",$_POST['cronwday']);
|
73 |
-
} else {
|
74 |
-
if ($_POST['cronbtype']=='mon') {
|
75 |
-
$jobvalues['cron']=$_POST['moncronminutes'].' '.$_POST['moncronhours'].' '.$_POST['moncronmday'].' * *';
|
76 |
-
}
|
77 |
-
if ($_POST['cronbtype']=='week') {
|
78 |
-
$jobvalues['cron']=$_POST['weekcronminutes'].' '.$_POST['weekcronhours'].' * * '.$_POST['weekcronwday'];
|
79 |
-
}
|
80 |
-
if ($_POST['cronbtype']=='day') {
|
81 |
-
$jobvalues['cron']=$_POST['daycronminutes'].' '.$_POST['daycronhours'].' * * *';
|
82 |
-
}
|
83 |
-
if ($_POST['cronbtype']=='hour') {
|
84 |
-
$jobvalues['cron']=$_POST['hourcronminutes'].' * * * *';
|
85 |
-
}
|
86 |
-
}
|
87 |
-
$jobvalues['cronnextrun']=backwpup_cron_next($jobvalues['cron']);
|
88 |
-
$jobvalues['mailaddresslog']= isset($_POST['mailaddresslog']) ? sanitize_email($_POST['mailaddresslog']) : '';
|
89 |
-
$jobvalues['mailerroronly']= (isset($_POST['mailerroronly']) && $_POST['mailerroronly']==1) ? true : false;
|
90 |
-
$checedtables=array();
|
91 |
-
if (isset($_POST['jobtabs'])) {
|
92 |
-
foreach ($_POST['jobtabs'] as $dbtable) {
|
93 |
-
$checedtables[]=base64_decode($dbtable);
|
94 |
-
}
|
95 |
-
}
|
96 |
-
global $wpdb;
|
97 |
-
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
98 |
-
$jobvalues['dbexclude']=array();
|
99 |
-
foreach ($tables as $dbtable) {
|
100 |
-
if (!in_array($dbtable,$checedtables))
|
101 |
-
$jobvalues['dbexclude'][]=$dbtable;
|
102 |
-
}
|
103 |
-
$jobvalues['dbshortinsert']= (isset($_POST['dbshortinsert']) && $_POST['dbshortinsert']==1) ? true : false;
|
104 |
-
$jobvalues['maintenance']= (isset($_POST['maintenance']) && $_POST['maintenance']==1) ? true : false;
|
105 |
-
$jobvalues['fileexclude']=isset($_POST['fileexclude']) ? stripslashes($_POST['fileexclude']) : '';
|
106 |
-
$jobvalues['dirinclude']=isset($_POST['dirinclude']) ? stripslashes($_POST['dirinclude']) : '';
|
107 |
-
$jobvalues['backuproot']= (isset($_POST['backuproot']) && $_POST['backuproot']==1) ? true : false;
|
108 |
-
$jobvalues['backuprootexcludedirs']=!empty($_POST['backuprootexcludedirs']) ? (array)$_POST['backuprootexcludedirs'] : array();
|
109 |
-
$jobvalues['backupcontent']= (isset($_POST['backupcontent']) && $_POST['backupcontent']==1) ? true : false;
|
110 |
-
$jobvalues['backupcontentexcludedirs']=!empty($_POST['backupcontentexcludedirs']) ? (array)$_POST['backupcontentexcludedirs'] : array();
|
111 |
-
$jobvalues['backupplugins']= (isset($_POST['backupplugins']) && $_POST['backupplugins']==1) ? true : false;
|
112 |
-
$jobvalues['backuppluginsexcludedirs']=!empty($_POST['backuppluginsexcludedirs']) ? (array)$_POST['backuppluginsexcludedirs'] : array();
|
113 |
-
$jobvalues['backupthemes']= (isset($_POST['backupthemes']) && $_POST['backupthemes']==1) ? true : false;
|
114 |
-
$jobvalues['backupthemesexcludedirs']=!empty($_POST['backupthemesexcludedirs']) ? (array)$_POST['backupthemesexcludedirs'] : array();
|
115 |
-
$jobvalues['backupuploads']= (isset($_POST['backupuploads']) && $_POST['backupuploads']==1) ? true : false;
|
116 |
-
$jobvalues['backupuploadsexcludedirs']=!empty($_POST['backupuploadsexcludedirs']) ? (array)$_POST['backupuploadsexcludedirs'] : array();
|
117 |
-
$jobvalues['fileprefix']= isset($_POST['fileprefix']) ? $_POST['fileprefix'] : '';
|
118 |
-
$jobvalues['fileformart']=$_POST['fileformart'];
|
119 |
-
$jobvalues['mailefilesize']=isset($_POST['mailefilesize']) ? (float)$_POST['mailefilesize'] : 0;
|
120 |
-
$jobvalues['backupdir']=isset($_POST['backupdir']) ? stripslashes($_POST['backupdir']) : '';
|
121 |
-
$jobvalues['maxbackups']=isset($_POST['maxbackups']) ? (int)$_POST['maxbackups'] : 0;
|
122 |
-
$jobvalues['ftphost']=isset($_POST['ftphost']) ? $_POST['ftphost'] : '';
|
123 |
-
$jobvalues['ftphostport']=!empty($_POST['ftphostport']) ? (int)$_POST['ftphostport'] : 21;
|
124 |
-
$jobvalues['ftpuser']=isset($_POST['ftpuser']) ? $_POST['ftpuser'] : '';
|
125 |
-
$jobvalues['ftppass']=isset($_POST['ftppass']) ? base64_encode($_POST['ftppass']) : '';
|
126 |
-
$jobvalues['ftpdir']=isset($_POST['ftpdir']) ? stripslashes($_POST['ftpdir']) : '';
|
127 |
-
$jobvalues['ftpmaxbackups']=isset($_POST['ftpmaxbackups']) ? (int)$_POST['ftpmaxbackups'] : 0;
|
128 |
-
$jobvalues['ftpssl']= (isset($_POST['ftpssl']) && $_POST['ftpssl']==1) ? true : false;
|
129 |
-
$jobvalues['ftppasv']= (isset($_POST['ftppasv']) && $_POST['ftppasv']==1) ? true : false;
|
130 |
-
$jobvalues['dropemaxbackups']=isset($_POST['dropemaxbackups']) ? (int)$_POST['dropemaxbackups'] : 0;
|
131 |
-
$jobvalues['droperoot']=isset($_POST['droperoot']) ? $_POST['droperoot'] : 'dropbox';
|
132 |
-
$jobvalues['dropedir']=isset($_POST['dropedir']) ? $_POST['dropedir'] : '';
|
133 |
-
$jobvalues['awsAccessKey']=isset($_POST['awsAccessKey']) ? $_POST['awsAccessKey'] : '';
|
134 |
-
$jobvalues['awsSecretKey']=isset($_POST['awsSecretKey']) ? $_POST['awsSecretKey'] : '';
|
135 |
-
$jobvalues['awsrrs']= (isset($_POST['awsrrs']) && $_POST['awsrrs']==1) ? true : false;
|
136 |
-
$jobvalues['awsBucket']=isset($_POST['awsBucket']) ? $_POST['awsBucket'] : '';
|
137 |
-
$jobvalues['awsdir']=isset($_POST['awsdir']) ? stripslashes($_POST['awsdir']) : '';
|
138 |
-
$jobvalues['awsmaxbackups']=isset($_POST['awsmaxbackups']) ? (int)$_POST['awsmaxbackups'] : 0;
|
139 |
-
$jobvalues['GStorageAccessKey']=isset($_POST['GStorageAccessKey']) ? $_POST['GStorageAccessKey'] : '';
|
140 |
-
$jobvalues['GStorageSecret']=isset($_POST['GStorageSecret']) ? $_POST['GStorageSecret'] : '';
|
141 |
-
$jobvalues['GStorageBucket']=isset($_POST['GStorageBucket']) ? $_POST['GStorageBucket'] : '';
|
142 |
-
$jobvalues['GStoragedir']=isset($_POST['GStoragedir']) ? stripslashes($_POST['GStoragedir']) : '';
|
143 |
-
$jobvalues['GStoragemaxbackups']=isset($_POST['GStoragemaxbackups']) ? (int)$_POST['GStoragemaxbackups'] : 0;
|
144 |
-
$jobvalues['msazureHost']=isset($_POST['msazureHost']) ? $_POST['msazureHost'] : 'blob.core.windows.net';
|
145 |
-
$jobvalues['msazureAccName']=isset($_POST['msazureAccName']) ? $_POST['msazureAccName'] : '';
|
146 |
-
$jobvalues['msazureKey']=isset($_POST['msazureKey']) ? $_POST['msazureKey'] : '';
|
147 |
-
$jobvalues['msazureContainer']=isset($_POST['msazureContainer']) ? $_POST['msazureContainer'] : '';
|
148 |
-
$jobvalues['msazuredir']=isset($_POST['msazuredir']) ? stripslashes($_POST['msazuredir']) : '';
|
149 |
-
$jobvalues['msazuremaxbackups']=isset($_POST['msazuremaxbackups']) ? (int)$_POST['msazuremaxbackups'] : 0;
|
150 |
-
$jobvalues['sugaruser']=isset($_POST['sugaruser']) ? $_POST['sugaruser'] : '';
|
151 |
-
$jobvalues['sugarpass']=isset($_POST['sugarpass']) ? base64_encode($_POST['sugarpass']) : '';
|
152 |
-
$jobvalues['sugardir']=isset($_POST['sugardir']) ? stripslashes($_POST['sugardir']) : '';
|
153 |
-
$jobvalues['sugarroot']=isset($_POST['sugarroot']) ? $_POST['sugarroot'] : '';
|
154 |
-
$jobvalues['sugarmaxbackups']=isset($_POST['sugarmaxbackups']) ? (int)$_POST['sugarmaxbackups'] : 0;
|
155 |
-
$jobvalues['rscUsername']=isset($_POST['rscUsername']) ? $_POST['rscUsername'] : '';
|
156 |
-
$jobvalues['rscAPIKey']=isset($_POST['rscAPIKey']) ? $_POST['rscAPIKey'] : '';
|
157 |
-
$jobvalues['rscContainer']=isset($_POST['rscContainer']) ? $_POST['rscContainer'] : '';
|
158 |
-
$jobvalues['rscdir']=isset($_POST['rscdir']) ? stripslashes($_POST['rscdir']) : '';
|
159 |
-
$jobvalues['rscmaxbackups']=isset($_POST['rscmaxbackups']) ? (int)$_POST['rscmaxbackups'] : 0;
|
160 |
-
$jobvalues['mailaddress']=isset($_POST['mailaddress']) ? sanitize_email($_POST['mailaddress']) : '';
|
161 |
-
|
162 |
-
|
163 |
-
if (!empty($_POST['newawsBucket']) and !empty($_POST['awsAccessKey']) and !empty($_POST['awsSecretKey'])) { //create new s3 bucket if needed
|
164 |
-
if (!class_exists('CFRuntime'))
|
165 |
-
require_once(dirname(__FILE__).'/../libs/aws/sdk.class.php');
|
166 |
-
try {
|
167 |
-
CFCredentials::set(array('backwpup' => array('key'=>$_POST['awsAccessKey'],'secret'=>$_POST['awsSecretKey'],'default_cache_config'=>'','certificate_authority'=>true),'@default' => 'backwpup'));
|
168 |
-
$s3 = new AmazonS3();
|
169 |
-
$s3->create_bucket($_POST['newawsBucket'], $_POST['awsRegion']);
|
170 |
-
$jobvalues['awsBucket']=$_POST['newawsBucket'];
|
171 |
-
} catch (Exception $e) {
|
172 |
-
$backwpup_message.=__($e->getMessage(),'backwpup').'<br />';
|
173 |
-
}
|
174 |
-
}
|
175 |
-
|
176 |
-
if (!empty($_POST['GStorageAccessKey']) and !empty($_POST['GStorageSecret']) and !empty($_POST['newGStorageBucket'])) { //create new google storage bucket if needed
|
177 |
-
if (!class_exists('CFRuntime'))
|
178 |
-
require_once(dirname(__FILE__).'/../libs/aws/sdk.class.php');
|
179 |
-
try {
|
180 |
-
CFCredentials::set(array('backwpup' => array('key'=>$_POST['GStorageAccessKey'],'secret'=>$_POST['GStorageSecret'],'default_cache_config'=>'','certificate_authority'=>true),'@default' => 'backwpup'));
|
181 |
-
$gstorage = new AmazonS3();
|
182 |
-
$gstorage->set_hostname('commondatastorage.googleapis.com');
|
183 |
-
$gstorage->allow_hostname_override(false);
|
184 |
-
$gstorage->create_bucket($_POST['newGStorageBucket'],'');
|
185 |
-
$jobvalues['GStorageBucket']=$_POST['newGStorageBucket'];
|
186 |
-
sleep(1); //creation take a moment
|
187 |
-
} catch (Exception $e) {
|
188 |
-
$backwpup_message.=__($e->getMessage(),'backwpup').'<br />';
|
189 |
-
}
|
190 |
-
}
|
191 |
-
|
192 |
-
if (!empty($_POST['newmsazureContainer']) and !empty($_POST['msazureHost']) and !empty($_POST['msazureAccName']) and !empty($_POST['msazureKey'])) { //create new s3 bucket if needed
|
193 |
-
if (!class_exists('Microsoft_WindowsAzure_Storage_Blob')) {
|
194 |
-
require_once(dirname(__FILE__).'/../libs/Microsoft/WindowsAzure/Storage/Blob.php');
|
195 |
-
}
|
196 |
-
try {
|
197 |
-
$storageClient = new Microsoft_WindowsAzure_Storage_Blob($_POST['msazureHost'],$_POST['msazureAccName'],$_POST['msazureKey']);
|
198 |
-
$result = $storageClient->createContainer($_POST['newmsazureContainer']);
|
199 |
-
$jobvalues['msazureContainer']=$result->Name;
|
200 |
-
} catch (Exception $e) {
|
201 |
-
$backwpup_message.=__($e->getMessage(),'backwpup').'<br />';
|
202 |
-
}
|
203 |
-
}
|
204 |
-
|
205 |
-
if (!empty($_POST['rscUsername']) and !empty($_POST['rscAPIKey']) and !empty($_POST['newrscContainer'])) { //create new Rackspase Container if needed
|
206 |
-
if (!class_exists('CF_Authentication'))
|
207 |
-
require_once(dirname(__FILE__).'/../libs/rackspace/cloudfiles.php');
|
208 |
-
try {
|
209 |
-
$auth = new CF_Authentication($_POST['rscUsername'], $_POST['rscAPIKey']);
|
210 |
-
if ($auth->authenticate()) {
|
211 |
-
$conn = new CF_Connection($auth);
|
212 |
-
$public_container = $conn->create_container($_POST['newrscContainer']);
|
213 |
-
$public_container->make_private();
|
214 |
-
}
|
215 |
-
} catch (Exception $e) {
|
216 |
-
$backwpup_message.=__($e->getMessage(),'backwpup').'<br />';
|
217 |
-
}
|
218 |
-
}
|
219 |
-
|
220 |
-
|
221 |
-
if (isset($_POST['dropboxauthdel']) and !empty($_POST['dropboxauthdel'])) {
|
222 |
-
$jobvalues['dropetoken']='';
|
223 |
-
$jobvalues['dropesecret']='';
|
224 |
-
$backwpup_message.=__('Dropbox authentication deleted!','backwpup').'<br />';
|
225 |
-
}
|
226 |
-
|
227 |
-
//save chages
|
228 |
-
$jobs=get_option('backwpup_jobs'); //Load Settings
|
229 |
-
$jobs[$jobvalues['jobid']]=backwpup_get_job_vars($jobvalues['jobid'],$jobvalues);
|
230 |
-
update_option('backwpup_jobs',$jobs);
|
231 |
-
|
232 |
-
//activate/deactivate seduling if not needed
|
233 |
-
$activejobs=false;
|
234 |
-
foreach ($jobs as $jobid => $jobvalue) {
|
235 |
-
if (!empty($jobvalue['activated']))
|
236 |
-
$activejobs=true;
|
237 |
-
}
|
238 |
-
if ($activejobs and false === wp_next_scheduled('backwpup_cron')) {
|
239 |
-
wp_schedule_event(time(), 'backwpup_int', 'backwpup_cron');
|
240 |
-
}
|
241 |
-
if (!$activejobs and false !== wp_next_scheduled('backwpup_cron')) {
|
242 |
-
wp_clear_scheduled_hook('backwpup_cron');
|
243 |
-
}
|
244 |
-
|
245 |
-
//get dropbox auth
|
246 |
-
if (isset($_POST['dropboxauth']) and !empty($_POST['dropboxauth'])) {
|
247 |
-
require_once (dirname(__FILE__).'/../libs/dropbox.php');
|
248 |
-
$dropbox = new backwpup_Dropbox(BACKWPUP_DROPBOX_APP_KEY, BACKWPUP_DROPBOX_APP_SECRET,'dropbox');
|
249 |
-
// let the user authorize (user will be redirected)
|
250 |
-
$response = $dropbox->oAuthAuthorize(backwpup_admin_url('admin.php').'?page=backwpupeditjob&jobid='.$jobvalues['jobid'].'&dropboxauth=AccessToken&_wpnonce='.wp_create_nonce('edit-job'));
|
251 |
-
// save oauth_token_secret
|
252 |
-
set_transient('backwpup_dropboxrequest',array('oAuthRequestToken'=>$response['oauth_token'],'oAuthRequestTokenSecret' => $response['oauth_token_secret']),600);
|
253 |
-
//forward to auth page
|
254 |
-
wp_redirect($response['authurl']);
|
255 |
-
}
|
256 |
-
|
257 |
-
//make api call to backwpup.com
|
258 |
-
backwpup_api(true);
|
259 |
-
|
260 |
-
$_POST['jobid']=$jobvalues['jobid'];
|
261 |
-
$backwpup_message.=str_replace('%1',$jobvalues['name'],__('Job \'%1\' changes saved.', 'backwpup')).' <a href="'.backwpup_admin_url('admin.php').'?page=backwpup">'.__('Jobs overview.', 'backwpup').'</a>';
|
262 |
-
}
|
263 |
-
|
264 |
-
|
265 |
-
$dests=explode(',',strtoupper(BACKWPUP_DESTS));
|
266 |
-
|
267 |
-
//load java
|
268 |
-
wp_enqueue_script('common');
|
269 |
-
wp_enqueue_script('wp-lists');
|
270 |
-
wp_enqueue_script('postbox');
|
271 |
-
|
272 |
-
//add several metaboxes now, all metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
|
273 |
-
add_meta_box('backwpup_jobedit_backupfile', __('Backup File','backwpup'), 'backwpup_jobedit_metabox_backupfile', $current_screen->id, 'side', 'default');
|
274 |
-
add_meta_box('backwpup_jobedit_sendlog', __('Send log','backwpup'), 'backwpup_jobedit_metabox_sendlog', $current_screen->id, 'side', 'default');
|
275 |
-
add_meta_box('backwpup_jobedit_destfolder', __('Backup to Folder','backwpup'), 'backwpup_jobedit_metabox_destfolder', $current_screen->id, 'advanced', 'core');
|
276 |
-
add_meta_box('backwpup_jobedit_destmail', __('Backup to E-Mail','backwpup'), 'backwpup_jobedit_metabox_destmail', $current_screen->id, 'advanced', 'core');
|
277 |
-
if (in_array('FTP',$dests))
|
278 |
-
add_meta_box('backwpup_jobedit_destftp', __('Backup to FTP Server','backwpup'), 'backwpup_jobedit_metabox_destftp', $current_screen->id, 'advanced', 'default');
|
279 |
-
if (in_array('DROPBOX',$dests))
|
280 |
-
add_meta_box('backwpup_jobedit_destdropbox', __('Backup to Dropbox','backwpup'), 'backwpup_jobedit_metabox_destdropbox', $current_screen->id, 'advanced', 'default');
|
281 |
-
if (in_array('SUGARSYNC',$dests))
|
282 |
-
add_meta_box('backwpup_jobedit_destsugarsync', __('Backup to SugarSync','backwpup'), 'backwpup_jobedit_metabox_destsugarsync', $current_screen->id, 'advanced', 'default');
|
283 |
-
if (in_array('S3',$dests))
|
284 |
-
add_meta_box('backwpup_jobedit_dests3', __('Backup to Amazon S3','backwpup'), 'backwpup_jobedit_metabox_dests3', $current_screen->id, 'advanced', 'default');
|
285 |
-
if (in_array('GSTORAGE',$dests))
|
286 |
-
add_meta_box('backwpup_jobedit_destgstorage', __('Backup to Google storage','backwpup'), 'backwpup_jobedit_metabox_destgstorage', $current_screen->id, 'advanced', 'default');
|
287 |
-
if (in_array('MSAZURE',$dests))
|
288 |
-
add_meta_box('backwpup_jobedit_destazure', __('Backup to Micosoft Azure (Blob)','backwpup'), 'backwpup_jobedit_metabox_destazure', $current_screen->id, 'advanced', 'default');
|
289 |
-
if (in_array('RSC',$dests))
|
290 |
-
add_meta_box('backwpup_jobedit_destrsc', __('Backup to Rackspace Cloud','backwpup'), 'backwpup_jobedit_metabox_destrsc', $current_screen->id, 'advanced', 'default');
|
291 |
-
//add clumns
|
292 |
-
add_screen_option('layout_columns', array('max' => 2, 'default' => 2));
|
293 |
-
|
294 |
-
//add Help
|
295 |
-
backwpup_contextual_help(__('','backwpup'));
|
296 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
if (!defined('ABSPATH'))
|
3 |
+
die();
|
4 |
+
|
5 |
+
//Save Dropbox settings
|
6 |
+
if (isset($_GET['dropboxauth']) and $_GET['dropboxauth']=='AccessToken') {
|
7 |
+
$jobid = (int) $_GET['jobid'];
|
8 |
+
check_admin_referer('edit-job');
|
9 |
+
$backwpup_message='';
|
10 |
+
if ((int)$_GET['uid']>0 and !empty($_GET['oauth_token_backwpup'])) {
|
11 |
+
$reqtoken=get_transient('backwpup_dropboxrequest');
|
12 |
+
if ($reqtoken['oAuthRequestToken']==$_GET['oauth_token_backwpup']) {
|
13 |
+
//Get Access Tokens
|
14 |
+
require_once (dirname(__FILE__).'/../libs/dropbox.php');
|
15 |
+
$jobs=get_option('backwpup_jobs');
|
16 |
+
$dropbox = new backwpup_Dropbox(BACKWPUP_DROPBOX_APP_KEY, BACKWPUP_DROPBOX_APP_SECRET,'dropbox');
|
17 |
+
$oAuthStuff = $dropbox->oAuthAccessToken($reqtoken['oAuthRequestToken'],$reqtoken['oAuthRequestTokenSecret']);
|
18 |
+
//Save Tokens
|
19 |
+
$jobs[$jobid]['dropetoken']=$oAuthStuff['oauth_token'];
|
20 |
+
$jobs[$jobid]['dropesecret']=$oAuthStuff['oauth_token_secret'];
|
21 |
+
update_option('backwpup_jobs',$jobs);
|
22 |
+
$backwpup_message.=__('Dropbox authentication complete!','backwpup').'<br />';
|
23 |
+
} else {
|
24 |
+
$backwpup_message.=__('Wrong Token for Dropbox authentication received!','backwpup').'<br />';
|
25 |
+
}
|
26 |
+
} else {
|
27 |
+
$backwpup_message.=__('No Dropbox authentication received!','backwpup').'<br />';
|
28 |
+
}
|
29 |
+
delete_transient('backwpup_dropboxrequest');
|
30 |
+
$_POST['jobid']=$jobid;
|
31 |
+
}
|
32 |
+
|
33 |
+
//Save Job settings
|
34 |
+
if ((isset($_POST['save']) or isset($_POST['dropboxauth']) or isset($_POST['dropboxauthdel'])) and !empty($_POST['jobid'])) {
|
35 |
+
check_admin_referer('edit-job');
|
36 |
+
$jobvalues['jobid']=(int) $_POST['jobid'];
|
37 |
+
$jobvalues['type']= implode('+',(array)$_POST['type']);
|
38 |
+
$jobvalues['name']= esc_html($_POST['name']);
|
39 |
+
$jobvalues['activated']= (isset($_POST['activated']) && $_POST['activated']==1) ? true : false;
|
40 |
+
$jobvalues['cronselect']= $_POST['cronselect']=='basic' ? 'basic':'advanced';
|
41 |
+
if ($jobvalues['cronselect']=='advanced') {
|
42 |
+
if (empty($_POST['cronminutes']) or $_POST['cronminutes'][0]=='*') {
|
43 |
+
if (!empty($_POST['cronminutes'][1]))
|
44 |
+
$_POST['cronminutes']=array('*/'.$_POST['cronminutes'][1]);
|
45 |
+
else
|
46 |
+
$_POST['cronminutes']=array('*');
|
47 |
+
}
|
48 |
+
if (empty($_POST['cronhours']) or $_POST['cronhours'][0]=='*') {
|
49 |
+
if (!empty($_POST['cronhours'][1]))
|
50 |
+
$_POST['cronhours']=array('*/'.$_POST['cronhours'][1]);
|
51 |
+
else
|
52 |
+
$_POST['cronhours']=array('*');
|
53 |
+
}
|
54 |
+
if (empty($_POST['cronmday']) or $_POST['cronmday'][0]=='*') {
|
55 |
+
if (!empty($_POST['cronmday'][1]))
|
56 |
+
$_POST['cronmday']=array('*/'.$_POST['cronmday'][1]);
|
57 |
+
else
|
58 |
+
$_POST['cronmday']=array('*');
|
59 |
+
}
|
60 |
+
if (empty($_POST['cronmon']) or $_POST['cronmon'][0]=='*') {
|
61 |
+
if (!empty($_POST['cronmon'][1]))
|
62 |
+
$_POST['cronmon']=array('*/'.$_POST['cronmon'][1]);
|
63 |
+
else
|
64 |
+
$_POST['cronmon']=array('*');
|
65 |
+
}
|
66 |
+
if (empty($_POST['cronwday']) or $_POST['cronwday'][0]=='*') {
|
67 |
+
if (!empty($_POST['cronwday'][1]))
|
68 |
+
$_POST['cronwday']=array('*/'.$_POST['cronwday'][1]);
|
69 |
+
else
|
70 |
+
$_POST['cronwday']=array('*');
|
71 |
+
}
|
72 |
+
$jobvalues['cron']=implode(",",$_POST['cronminutes']).' '.implode(",",$_POST['cronhours']).' '.implode(",",$_POST['cronmday']).' '.implode(",",$_POST['cronmon']).' '.implode(",",$_POST['cronwday']);
|
73 |
+
} else {
|
74 |
+
if ($_POST['cronbtype']=='mon') {
|
75 |
+
$jobvalues['cron']=$_POST['moncronminutes'].' '.$_POST['moncronhours'].' '.$_POST['moncronmday'].' * *';
|
76 |
+
}
|
77 |
+
if ($_POST['cronbtype']=='week') {
|
78 |
+
$jobvalues['cron']=$_POST['weekcronminutes'].' '.$_POST['weekcronhours'].' * * '.$_POST['weekcronwday'];
|
79 |
+
}
|
80 |
+
if ($_POST['cronbtype']=='day') {
|
81 |
+
$jobvalues['cron']=$_POST['daycronminutes'].' '.$_POST['daycronhours'].' * * *';
|
82 |
+
}
|
83 |
+
if ($_POST['cronbtype']=='hour') {
|
84 |
+
$jobvalues['cron']=$_POST['hourcronminutes'].' * * * *';
|
85 |
+
}
|
86 |
+
}
|
87 |
+
$jobvalues['cronnextrun']=backwpup_cron_next($jobvalues['cron']);
|
88 |
+
$jobvalues['mailaddresslog']= isset($_POST['mailaddresslog']) ? sanitize_email($_POST['mailaddresslog']) : '';
|
89 |
+
$jobvalues['mailerroronly']= (isset($_POST['mailerroronly']) && $_POST['mailerroronly']==1) ? true : false;
|
90 |
+
$checedtables=array();
|
91 |
+
if (isset($_POST['jobtabs'])) {
|
92 |
+
foreach ($_POST['jobtabs'] as $dbtable) {
|
93 |
+
$checedtables[]=base64_decode($dbtable);
|
94 |
+
}
|
95 |
+
}
|
96 |
+
global $wpdb;
|
97 |
+
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
98 |
+
$jobvalues['dbexclude']=array();
|
99 |
+
foreach ($tables as $dbtable) {
|
100 |
+
if (!in_array($dbtable,$checedtables))
|
101 |
+
$jobvalues['dbexclude'][]=$dbtable;
|
102 |
+
}
|
103 |
+
$jobvalues['dbshortinsert']= (isset($_POST['dbshortinsert']) && $_POST['dbshortinsert']==1) ? true : false;
|
104 |
+
$jobvalues['maintenance']= (isset($_POST['maintenance']) && $_POST['maintenance']==1) ? true : false;
|
105 |
+
$jobvalues['fileexclude']=isset($_POST['fileexclude']) ? stripslashes($_POST['fileexclude']) : '';
|
106 |
+
$jobvalues['dirinclude']=isset($_POST['dirinclude']) ? stripslashes($_POST['dirinclude']) : '';
|
107 |
+
$jobvalues['backuproot']= (isset($_POST['backuproot']) && $_POST['backuproot']==1) ? true : false;
|
108 |
+
$jobvalues['backuprootexcludedirs']=!empty($_POST['backuprootexcludedirs']) ? (array)$_POST['backuprootexcludedirs'] : array();
|
109 |
+
$jobvalues['backupcontent']= (isset($_POST['backupcontent']) && $_POST['backupcontent']==1) ? true : false;
|
110 |
+
$jobvalues['backupcontentexcludedirs']=!empty($_POST['backupcontentexcludedirs']) ? (array)$_POST['backupcontentexcludedirs'] : array();
|
111 |
+
$jobvalues['backupplugins']= (isset($_POST['backupplugins']) && $_POST['backupplugins']==1) ? true : false;
|
112 |
+
$jobvalues['backuppluginsexcludedirs']=!empty($_POST['backuppluginsexcludedirs']) ? (array)$_POST['backuppluginsexcludedirs'] : array();
|
113 |
+
$jobvalues['backupthemes']= (isset($_POST['backupthemes']) && $_POST['backupthemes']==1) ? true : false;
|
114 |
+
$jobvalues['backupthemesexcludedirs']=!empty($_POST['backupthemesexcludedirs']) ? (array)$_POST['backupthemesexcludedirs'] : array();
|
115 |
+
$jobvalues['backupuploads']= (isset($_POST['backupuploads']) && $_POST['backupuploads']==1) ? true : false;
|
116 |
+
$jobvalues['backupuploadsexcludedirs']=!empty($_POST['backupuploadsexcludedirs']) ? (array)$_POST['backupuploadsexcludedirs'] : array();
|
117 |
+
$jobvalues['fileprefix']= isset($_POST['fileprefix']) ? $_POST['fileprefix'] : '';
|
118 |
+
$jobvalues['fileformart']=$_POST['fileformart'];
|
119 |
+
$jobvalues['mailefilesize']=isset($_POST['mailefilesize']) ? (float)$_POST['mailefilesize'] : 0;
|
120 |
+
$jobvalues['backupdir']=isset($_POST['backupdir']) ? stripslashes($_POST['backupdir']) : '';
|
121 |
+
$jobvalues['maxbackups']=isset($_POST['maxbackups']) ? (int)$_POST['maxbackups'] : 0;
|
122 |
+
$jobvalues['ftphost']=isset($_POST['ftphost']) ? $_POST['ftphost'] : '';
|
123 |
+
$jobvalues['ftphostport']=!empty($_POST['ftphostport']) ? (int)$_POST['ftphostport'] : 21;
|
124 |
+
$jobvalues['ftpuser']=isset($_POST['ftpuser']) ? $_POST['ftpuser'] : '';
|
125 |
+
$jobvalues['ftppass']=isset($_POST['ftppass']) ? base64_encode($_POST['ftppass']) : '';
|
126 |
+
$jobvalues['ftpdir']=isset($_POST['ftpdir']) ? stripslashes($_POST['ftpdir']) : '';
|
127 |
+
$jobvalues['ftpmaxbackups']=isset($_POST['ftpmaxbackups']) ? (int)$_POST['ftpmaxbackups'] : 0;
|
128 |
+
$jobvalues['ftpssl']= (isset($_POST['ftpssl']) && $_POST['ftpssl']==1) ? true : false;
|
129 |
+
$jobvalues['ftppasv']= (isset($_POST['ftppasv']) && $_POST['ftppasv']==1) ? true : false;
|
130 |
+
$jobvalues['dropemaxbackups']=isset($_POST['dropemaxbackups']) ? (int)$_POST['dropemaxbackups'] : 0;
|
131 |
+
$jobvalues['droperoot']=isset($_POST['droperoot']) ? $_POST['droperoot'] : 'dropbox';
|
132 |
+
$jobvalues['dropedir']=isset($_POST['dropedir']) ? $_POST['dropedir'] : '';
|
133 |
+
$jobvalues['awsAccessKey']=isset($_POST['awsAccessKey']) ? $_POST['awsAccessKey'] : '';
|
134 |
+
$jobvalues['awsSecretKey']=isset($_POST['awsSecretKey']) ? $_POST['awsSecretKey'] : '';
|
135 |
+
$jobvalues['awsrrs']= (isset($_POST['awsrrs']) && $_POST['awsrrs']==1) ? true : false;
|
136 |
+
$jobvalues['awsBucket']=isset($_POST['awsBucket']) ? $_POST['awsBucket'] : '';
|
137 |
+
$jobvalues['awsdir']=isset($_POST['awsdir']) ? stripslashes($_POST['awsdir']) : '';
|
138 |
+
$jobvalues['awsmaxbackups']=isset($_POST['awsmaxbackups']) ? (int)$_POST['awsmaxbackups'] : 0;
|
139 |
+
$jobvalues['GStorageAccessKey']=isset($_POST['GStorageAccessKey']) ? $_POST['GStorageAccessKey'] : '';
|
140 |
+
$jobvalues['GStorageSecret']=isset($_POST['GStorageSecret']) ? $_POST['GStorageSecret'] : '';
|
141 |
+
$jobvalues['GStorageBucket']=isset($_POST['GStorageBucket']) ? $_POST['GStorageBucket'] : '';
|
142 |
+
$jobvalues['GStoragedir']=isset($_POST['GStoragedir']) ? stripslashes($_POST['GStoragedir']) : '';
|
143 |
+
$jobvalues['GStoragemaxbackups']=isset($_POST['GStoragemaxbackups']) ? (int)$_POST['GStoragemaxbackups'] : 0;
|
144 |
+
$jobvalues['msazureHost']=isset($_POST['msazureHost']) ? $_POST['msazureHost'] : 'blob.core.windows.net';
|
145 |
+
$jobvalues['msazureAccName']=isset($_POST['msazureAccName']) ? $_POST['msazureAccName'] : '';
|
146 |
+
$jobvalues['msazureKey']=isset($_POST['msazureKey']) ? $_POST['msazureKey'] : '';
|
147 |
+
$jobvalues['msazureContainer']=isset($_POST['msazureContainer']) ? $_POST['msazureContainer'] : '';
|
148 |
+
$jobvalues['msazuredir']=isset($_POST['msazuredir']) ? stripslashes($_POST['msazuredir']) : '';
|
149 |
+
$jobvalues['msazuremaxbackups']=isset($_POST['msazuremaxbackups']) ? (int)$_POST['msazuremaxbackups'] : 0;
|
150 |
+
$jobvalues['sugaruser']=isset($_POST['sugaruser']) ? $_POST['sugaruser'] : '';
|
151 |
+
$jobvalues['sugarpass']=isset($_POST['sugarpass']) ? base64_encode($_POST['sugarpass']) : '';
|
152 |
+
$jobvalues['sugardir']=isset($_POST['sugardir']) ? stripslashes($_POST['sugardir']) : '';
|
153 |
+
$jobvalues['sugarroot']=isset($_POST['sugarroot']) ? $_POST['sugarroot'] : '';
|
154 |
+
$jobvalues['sugarmaxbackups']=isset($_POST['sugarmaxbackups']) ? (int)$_POST['sugarmaxbackups'] : 0;
|
155 |
+
$jobvalues['rscUsername']=isset($_POST['rscUsername']) ? $_POST['rscUsername'] : '';
|
156 |
+
$jobvalues['rscAPIKey']=isset($_POST['rscAPIKey']) ? $_POST['rscAPIKey'] : '';
|
157 |
+
$jobvalues['rscContainer']=isset($_POST['rscContainer']) ? $_POST['rscContainer'] : '';
|
158 |
+
$jobvalues['rscdir']=isset($_POST['rscdir']) ? stripslashes($_POST['rscdir']) : '';
|
159 |
+
$jobvalues['rscmaxbackups']=isset($_POST['rscmaxbackups']) ? (int)$_POST['rscmaxbackups'] : 0;
|
160 |
+
$jobvalues['mailaddress']=isset($_POST['mailaddress']) ? sanitize_email($_POST['mailaddress']) : '';
|
161 |
+
|
162 |
+
|
163 |
+
if (!empty($_POST['newawsBucket']) and !empty($_POST['awsAccessKey']) and !empty($_POST['awsSecretKey'])) { //create new s3 bucket if needed
|
164 |
+
if (!class_exists('CFRuntime'))
|
165 |
+
require_once(dirname(__FILE__).'/../libs/aws/sdk.class.php');
|
166 |
+
try {
|
167 |
+
CFCredentials::set(array('backwpup' => array('key'=>$_POST['awsAccessKey'],'secret'=>$_POST['awsSecretKey'],'default_cache_config'=>'','certificate_authority'=>true),'@default' => 'backwpup'));
|
168 |
+
$s3 = new AmazonS3();
|
169 |
+
$s3->create_bucket($_POST['newawsBucket'], $_POST['awsRegion']);
|
170 |
+
$jobvalues['awsBucket']=$_POST['newawsBucket'];
|
171 |
+
} catch (Exception $e) {
|
172 |
+
$backwpup_message.=__($e->getMessage(),'backwpup').'<br />';
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
if (!empty($_POST['GStorageAccessKey']) and !empty($_POST['GStorageSecret']) and !empty($_POST['newGStorageBucket'])) { //create new google storage bucket if needed
|
177 |
+
if (!class_exists('CFRuntime'))
|
178 |
+
require_once(dirname(__FILE__).'/../libs/aws/sdk.class.php');
|
179 |
+
try {
|
180 |
+
CFCredentials::set(array('backwpup' => array('key'=>$_POST['GStorageAccessKey'],'secret'=>$_POST['GStorageSecret'],'default_cache_config'=>'','certificate_authority'=>true),'@default' => 'backwpup'));
|
181 |
+
$gstorage = new AmazonS3();
|
182 |
+
$gstorage->set_hostname('commondatastorage.googleapis.com');
|
183 |
+
$gstorage->allow_hostname_override(false);
|
184 |
+
$gstorage->create_bucket($_POST['newGStorageBucket'],'');
|
185 |
+
$jobvalues['GStorageBucket']=$_POST['newGStorageBucket'];
|
186 |
+
sleep(1); //creation take a moment
|
187 |
+
} catch (Exception $e) {
|
188 |
+
$backwpup_message.=__($e->getMessage(),'backwpup').'<br />';
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
if (!empty($_POST['newmsazureContainer']) and !empty($_POST['msazureHost']) and !empty($_POST['msazureAccName']) and !empty($_POST['msazureKey'])) { //create new s3 bucket if needed
|
193 |
+
if (!class_exists('Microsoft_WindowsAzure_Storage_Blob')) {
|
194 |
+
require_once(dirname(__FILE__).'/../libs/Microsoft/WindowsAzure/Storage/Blob.php');
|
195 |
+
}
|
196 |
+
try {
|
197 |
+
$storageClient = new Microsoft_WindowsAzure_Storage_Blob($_POST['msazureHost'],$_POST['msazureAccName'],$_POST['msazureKey']);
|
198 |
+
$result = $storageClient->createContainer($_POST['newmsazureContainer']);
|
199 |
+
$jobvalues['msazureContainer']=$result->Name;
|
200 |
+
} catch (Exception $e) {
|
201 |
+
$backwpup_message.=__($e->getMessage(),'backwpup').'<br />';
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
if (!empty($_POST['rscUsername']) and !empty($_POST['rscAPIKey']) and !empty($_POST['newrscContainer'])) { //create new Rackspase Container if needed
|
206 |
+
if (!class_exists('CF_Authentication'))
|
207 |
+
require_once(dirname(__FILE__).'/../libs/rackspace/cloudfiles.php');
|
208 |
+
try {
|
209 |
+
$auth = new CF_Authentication($_POST['rscUsername'], $_POST['rscAPIKey']);
|
210 |
+
if ($auth->authenticate()) {
|
211 |
+
$conn = new CF_Connection($auth);
|
212 |
+
$public_container = $conn->create_container($_POST['newrscContainer']);
|
213 |
+
$public_container->make_private();
|
214 |
+
}
|
215 |
+
} catch (Exception $e) {
|
216 |
+
$backwpup_message.=__($e->getMessage(),'backwpup').'<br />';
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
|
221 |
+
if (isset($_POST['dropboxauthdel']) and !empty($_POST['dropboxauthdel'])) {
|
222 |
+
$jobvalues['dropetoken']='';
|
223 |
+
$jobvalues['dropesecret']='';
|
224 |
+
$backwpup_message.=__('Dropbox authentication deleted!','backwpup').'<br />';
|
225 |
+
}
|
226 |
+
|
227 |
+
//save chages
|
228 |
+
$jobs=get_option('backwpup_jobs'); //Load Settings
|
229 |
+
$jobs[$jobvalues['jobid']]=backwpup_get_job_vars($jobvalues['jobid'],$jobvalues);
|
230 |
+
update_option('backwpup_jobs',$jobs);
|
231 |
+
|
232 |
+
//activate/deactivate seduling if not needed
|
233 |
+
$activejobs=false;
|
234 |
+
foreach ($jobs as $jobid => $jobvalue) {
|
235 |
+
if (!empty($jobvalue['activated']))
|
236 |
+
$activejobs=true;
|
237 |
+
}
|
238 |
+
if ($activejobs and false === wp_next_scheduled('backwpup_cron')) {
|
239 |
+
wp_schedule_event(time(), 'backwpup_int', 'backwpup_cron');
|
240 |
+
}
|
241 |
+
if (!$activejobs and false !== wp_next_scheduled('backwpup_cron')) {
|
242 |
+
wp_clear_scheduled_hook('backwpup_cron');
|
243 |
+
}
|
244 |
+
|
245 |
+
//get dropbox auth
|
246 |
+
if (isset($_POST['dropboxauth']) and !empty($_POST['dropboxauth'])) {
|
247 |
+
require_once (dirname(__FILE__).'/../libs/dropbox.php');
|
248 |
+
$dropbox = new backwpup_Dropbox(BACKWPUP_DROPBOX_APP_KEY, BACKWPUP_DROPBOX_APP_SECRET,'dropbox');
|
249 |
+
// let the user authorize (user will be redirected)
|
250 |
+
$response = $dropbox->oAuthAuthorize(backwpup_admin_url('admin.php').'?page=backwpupeditjob&jobid='.$jobvalues['jobid'].'&dropboxauth=AccessToken&_wpnonce='.wp_create_nonce('edit-job'));
|
251 |
+
// save oauth_token_secret
|
252 |
+
set_transient('backwpup_dropboxrequest',array('oAuthRequestToken'=>$response['oauth_token'],'oAuthRequestTokenSecret' => $response['oauth_token_secret']),600);
|
253 |
+
//forward to auth page
|
254 |
+
wp_redirect($response['authurl']);
|
255 |
+
}
|
256 |
+
|
257 |
+
//make api call to backwpup.com
|
258 |
+
backwpup_api(true);
|
259 |
+
|
260 |
+
$_POST['jobid']=$jobvalues['jobid'];
|
261 |
+
$backwpup_message.=str_replace('%1',$jobvalues['name'],__('Job \'%1\' changes saved.', 'backwpup')).' <a href="'.backwpup_admin_url('admin.php').'?page=backwpup">'.__('Jobs overview.', 'backwpup').'</a>';
|
262 |
+
}
|
263 |
+
|
264 |
+
|
265 |
+
$dests=explode(',',strtoupper(BACKWPUP_DESTS));
|
266 |
+
|
267 |
+
//load java
|
268 |
+
wp_enqueue_script('common');
|
269 |
+
wp_enqueue_script('wp-lists');
|
270 |
+
wp_enqueue_script('postbox');
|
271 |
+
|
272 |
+
//add several metaboxes now, all metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
|
273 |
+
add_meta_box('backwpup_jobedit_backupfile', __('Backup File','backwpup'), 'backwpup_jobedit_metabox_backupfile', $current_screen->id, 'side', 'default');
|
274 |
+
add_meta_box('backwpup_jobedit_sendlog', __('Send log','backwpup'), 'backwpup_jobedit_metabox_sendlog', $current_screen->id, 'side', 'default');
|
275 |
+
add_meta_box('backwpup_jobedit_destfolder', __('Backup to Folder','backwpup'), 'backwpup_jobedit_metabox_destfolder', $current_screen->id, 'advanced', 'core');
|
276 |
+
add_meta_box('backwpup_jobedit_destmail', __('Backup to E-Mail','backwpup'), 'backwpup_jobedit_metabox_destmail', $current_screen->id, 'advanced', 'core');
|
277 |
+
if (in_array('FTP',$dests))
|
278 |
+
add_meta_box('backwpup_jobedit_destftp', __('Backup to FTP Server','backwpup'), 'backwpup_jobedit_metabox_destftp', $current_screen->id, 'advanced', 'default');
|
279 |
+
if (in_array('DROPBOX',$dests))
|
280 |
+
add_meta_box('backwpup_jobedit_destdropbox', __('Backup to Dropbox','backwpup'), 'backwpup_jobedit_metabox_destdropbox', $current_screen->id, 'advanced', 'default');
|
281 |
+
if (in_array('SUGARSYNC',$dests))
|
282 |
+
add_meta_box('backwpup_jobedit_destsugarsync', __('Backup to SugarSync','backwpup'), 'backwpup_jobedit_metabox_destsugarsync', $current_screen->id, 'advanced', 'default');
|
283 |
+
if (in_array('S3',$dests))
|
284 |
+
add_meta_box('backwpup_jobedit_dests3', __('Backup to Amazon S3','backwpup'), 'backwpup_jobedit_metabox_dests3', $current_screen->id, 'advanced', 'default');
|
285 |
+
if (in_array('GSTORAGE',$dests))
|
286 |
+
add_meta_box('backwpup_jobedit_destgstorage', __('Backup to Google storage','backwpup'), 'backwpup_jobedit_metabox_destgstorage', $current_screen->id, 'advanced', 'default');
|
287 |
+
if (in_array('MSAZURE',$dests))
|
288 |
+
add_meta_box('backwpup_jobedit_destazure', __('Backup to Micosoft Azure (Blob)','backwpup'), 'backwpup_jobedit_metabox_destazure', $current_screen->id, 'advanced', 'default');
|
289 |
+
if (in_array('RSC',$dests))
|
290 |
+
add_meta_box('backwpup_jobedit_destrsc', __('Backup to Rackspace Cloud','backwpup'), 'backwpup_jobedit_metabox_destrsc', $current_screen->id, 'advanced', 'default');
|
291 |
+
//add clumns
|
292 |
+
add_screen_option('layout_columns', array('max' => 2, 'default' => 2));
|
293 |
+
|
294 |
+
//add Help
|
295 |
+
backwpup_contextual_help(__('','backwpup'));
|
|
pages/header_backwpuplogs.php
CHANGED
@@ -1,64 +1,63 @@
|
|
1 |
-
<?PHP
|
2 |
-
if (!defined('ABSPATH'))
|
3 |
-
die();
|
4 |
-
|
5 |
-
|
6 |
-
//Create Table
|
7 |
-
$backwpup_listtable = new BackWPup_Logs_Table;
|
8 |
-
|
9 |
-
//get cuurent action
|
10 |
-
$doaction = $backwpup_listtable->current_action();
|
11 |
-
|
12 |
-
if (!empty($doaction)) {
|
13 |
-
switch($doaction) {
|
14 |
-
case 'delete':
|
15 |
-
$cfg=get_option('backwpup'); //Load Settings
|
16 |
-
if (is_array($_GET['logfiles'])) {
|
17 |
-
check_admin_referer('bulk-logs');
|
18 |
-
$num=0;
|
19 |
-
foreach ($_GET['logfiles'] as $logfile) {
|
20 |
-
if (is_file($cfg['dirlogs'].'/'.$logfile))
|
21 |
-
unlink($cfg['dirlogs'].'/'.$logfile);
|
22 |
-
$num++;
|
23 |
-
}
|
24 |
-
}
|
25 |
-
break;
|
26 |
-
case 'download': //Download Backup
|
27 |
-
check_admin_referer('download-backup_'.basename(trim($_GET['file'])));
|
28 |
-
if (is_file(trim($_GET['file']))) {
|
29 |
-
header("Pragma: public");
|
30 |
-
header("Expires: 0");
|
31 |
-
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
32 |
-
header("Content-Type: application/force-download");
|
33 |
-
header("Content-Type: application/octet-stream");
|
34 |
-
header("Content-Type: application/download");
|
35 |
-
header("Content-Disposition: attachment; filename=".basename(trim($_GET['file'])).";");
|
36 |
-
header("Content-Transfer-Encoding: binary");
|
37 |
-
header("Content-Length: ".filesize(trim($_GET['file'])));
|
38 |
-
@readfile(trim($_GET['file']));
|
39 |
-
die();
|
40 |
-
} else {
|
41 |
-
header('HTTP/1.0 404 Not Found');
|
42 |
-
die();
|
43 |
-
}
|
44 |
-
break;
|
45 |
-
}
|
46 |
-
}
|
47 |
-
//Save per page
|
48 |
-
if (isset($_POST['screen-options-apply']) and isset($_POST['wp_screen_options']['option']) and isset($_POST['wp_screen_options']['value']) and $_POST['wp_screen_options']['option']=='backwpuplogs_per_page') {
|
49 |
-
check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
|
50 |
-
global $current_user;
|
51 |
-
if ($_POST['wp_screen_options']['value']>0 and $_POST['wp_screen_options']['value']<1000) {
|
52 |
-
update_user_option($current_user->ID,'backwpuplogs_per_page',(int) $_POST['wp_screen_options']['value']);
|
53 |
-
wp_redirect( remove_query_arg( array('pagenum', 'apage', 'paged'), wp_get_referer() ) );
|
54 |
-
exit;
|
55 |
-
}
|
56 |
-
}
|
57 |
-
|
58 |
-
//add Help
|
59 |
-
backwpup_contextual_help(__('Here you can manage the log files of the jobs. You can download, view, or delete them.','backwpup'));
|
60 |
-
|
61 |
-
add_screen_option( 'per_page', array('label' => __('Logs','backwpup'), 'default' => 20, 'option' =>'backwpuplogs_per_page') );
|
62 |
-
|
63 |
-
$backwpup_listtable->prepare_items();
|
64 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
if (!defined('ABSPATH'))
|
3 |
+
die();
|
4 |
+
|
5 |
+
|
6 |
+
//Create Table
|
7 |
+
$backwpup_listtable = new BackWPup_Logs_Table;
|
8 |
+
|
9 |
+
//get cuurent action
|
10 |
+
$doaction = $backwpup_listtable->current_action();
|
11 |
+
|
12 |
+
if (!empty($doaction)) {
|
13 |
+
switch($doaction) {
|
14 |
+
case 'delete':
|
15 |
+
$cfg=get_option('backwpup'); //Load Settings
|
16 |
+
if (is_array($_GET['logfiles'])) {
|
17 |
+
check_admin_referer('bulk-logs');
|
18 |
+
$num=0;
|
19 |
+
foreach ($_GET['logfiles'] as $logfile) {
|
20 |
+
if (is_file($cfg['dirlogs'].'/'.$logfile))
|
21 |
+
unlink($cfg['dirlogs'].'/'.$logfile);
|
22 |
+
$num++;
|
23 |
+
}
|
24 |
+
}
|
25 |
+
break;
|
26 |
+
case 'download': //Download Backup
|
27 |
+
check_admin_referer('download-backup_'.basename(trim($_GET['file'])));
|
28 |
+
if (is_file(trim($_GET['file']))) {
|
29 |
+
header("Pragma: public");
|
30 |
+
header("Expires: 0");
|
31 |
+
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
32 |
+
header("Content-Type: application/force-download");
|
33 |
+
header("Content-Type: application/octet-stream");
|
34 |
+
header("Content-Type: application/download");
|
35 |
+
header("Content-Disposition: attachment; filename=".basename(trim($_GET['file'])).";");
|
36 |
+
header("Content-Transfer-Encoding: binary");
|
37 |
+
header("Content-Length: ".filesize(trim($_GET['file'])));
|
38 |
+
@readfile(trim($_GET['file']));
|
39 |
+
die();
|
40 |
+
} else {
|
41 |
+
header('HTTP/1.0 404 Not Found');
|
42 |
+
die();
|
43 |
+
}
|
44 |
+
break;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
//Save per page
|
48 |
+
if (isset($_POST['screen-options-apply']) and isset($_POST['wp_screen_options']['option']) and isset($_POST['wp_screen_options']['value']) and $_POST['wp_screen_options']['option']=='backwpuplogs_per_page') {
|
49 |
+
check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
|
50 |
+
global $current_user;
|
51 |
+
if ($_POST['wp_screen_options']['value']>0 and $_POST['wp_screen_options']['value']<1000) {
|
52 |
+
update_user_option($current_user->ID,'backwpuplogs_per_page',(int) $_POST['wp_screen_options']['value']);
|
53 |
+
wp_redirect( remove_query_arg( array('pagenum', 'apage', 'paged'), wp_get_referer() ) );
|
54 |
+
exit;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
//add Help
|
59 |
+
backwpup_contextual_help(__('Here you can manage the log files of the jobs. You can download, view, or delete them.','backwpup'));
|
60 |
+
|
61 |
+
add_screen_option( 'per_page', array('label' => __('Logs','backwpup'), 'default' => 20, 'option' =>'backwpuplogs_per_page') );
|
62 |
+
|
63 |
+
$backwpup_listtable->prepare_items();
|
|
pages/header_backwpupsettings.php
CHANGED
@@ -1,52 +1,51 @@
|
|
1 |
-
<?PHP
|
2 |
-
if (!defined('ABSPATH'))
|
3 |
-
die();
|
4 |
-
|
5 |
-
|
6 |
-
if (isset($_POST['submit']) and isset($_POST['action']) and $_POST['action']=='update') {
|
7 |
-
check_admin_referer('backwpup-cfg');
|
8 |
-
$cfg=get_option('backwpup'); //Load Settings
|
9 |
-
$cfg['mailsndemail']=sanitize_email($_POST['mailsndemail']);
|
10 |
-
$cfg['mailsndname']=$_POST['mailsndname'];
|
11 |
-
$cfg['mailmethod']=$_POST['mailmethod'];
|
12 |
-
$cfg['mailsendmail']=untrailingslashit(str_replace('//','/',str_replace('\\','/',stripslashes($_POST['mailsendmail']))));
|
13 |
-
$cfg['mailsecure']=$_POST['mailsecure'];
|
14 |
-
$cfg['mailhost']=$_POST['mailhost'];
|
15 |
-
$cfg['mailhostport']=empty($_POST['mailhostport']) ? 25 : (int)$_POST['mailhostport'];
|
16 |
-
$cfg['mailuser']=$_POST['mailuser'];
|
17 |
-
$cfg['mailpass']=base64_encode($_POST['mailpass']);
|
18 |
-
$cfg['disablewpcron']=isset($_POST['disablewpcron']) ? true : false;
|
19 |
-
$cfg['showadminbar']=isset($_POST['showadminbar']) ? true : false;
|
20 |
-
if (100>$_POST['jobstepretry'] and 0<$_POST['jobstepretry'])
|
21 |
-
$cfg['jobstepretry']=(int)$_POST['jobstepretry'];
|
22 |
-
if (100>$_POST['jobscriptretry'] and 0<$_POST['jobscriptretry'])
|
23 |
-
$cfg['jobscriptretry']=(int)$_POST['jobscriptretry'];
|
24 |
-
if (empty($cfg['jobstepretry']) or !is_int($cfg['jobstepretry']))
|
25 |
-
$cfg['jobstepretry']=3;
|
26 |
-
if (empty($cfg['jobscriptretry']) or !is_int($cfg['jobscriptretry']))
|
27 |
-
$cfg['jobscriptretry']=5;
|
28 |
-
$cfg['maxlogs']=abs((int)$_POST['maxlogs']);
|
29 |
-
$cfg['gzlogs']=isset($_POST['gzlogs']) ? true : false;
|
30 |
-
$cfg['phpzip']=isset($_POST['phpzip']) ? true : false;
|
31 |
-
$cfg['apicronservice']=isset($_POST['apicronservice']) ? true : false;
|
32 |
-
$cfg['httpauthuser']=$_POST['httpauthuser'];
|
33 |
-
$cfg['httpauthpassword']=base64_encode($_POST['httpauthpassword']);
|
34 |
-
$cfg['dirlogs']=trailingslashit(str_replace('//','/',str_replace('\\','/',stripslashes(trim($_POST['dirlogs'])))));
|
35 |
-
//set def. folders
|
36 |
-
if (!isset($cfg['dirlogs']) or $cfg['dirlogs']=='/' or empty($cfg['dirlogs'])) {
|
37 |
-
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
38 |
-
$cfg['dirlogs']=str_replace('\\','/',trailingslashit(WP_CONTENT_DIR)).'backwpup-'.$rand.'-logs/';
|
39 |
-
}
|
40 |
-
if (substr($cfg['dirlogs'],0,1)!='/' and substr($cfg['dirlogs'],1,1)!=':') //add abspath if not absolute
|
41 |
-
$cfg['dirlogs']=rtrim(str_replace('\\','/',ABSPATH),'/').'/'.$cfg['dirlogs'];
|
42 |
-
if (!isset($cfg['mailsendmail']) or empty($cfg['mailsendmail'])) {
|
43 |
-
$cfg['mailsendmail']=substr(ini_get('sendmail_path'),0,strpos(ini_get('sendmail_path'),' -'));
|
44 |
-
}
|
45 |
-
if (update_option('backwpup',$cfg))
|
46 |
-
$backwpup_message=__('Settings saved', 'backwpup');
|
47 |
-
backwpup_api(true);
|
48 |
-
}
|
49 |
-
|
50 |
-
//add Help
|
51 |
-
backwpup_contextual_help();
|
52 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
if (!defined('ABSPATH'))
|
3 |
+
die();
|
4 |
+
|
5 |
+
|
6 |
+
if (isset($_POST['submit']) and isset($_POST['action']) and $_POST['action']=='update') {
|
7 |
+
check_admin_referer('backwpup-cfg');
|
8 |
+
$cfg=get_option('backwpup'); //Load Settings
|
9 |
+
$cfg['mailsndemail']=sanitize_email($_POST['mailsndemail']);
|
10 |
+
$cfg['mailsndname']=$_POST['mailsndname'];
|
11 |
+
$cfg['mailmethod']=$_POST['mailmethod'];
|
12 |
+
$cfg['mailsendmail']=untrailingslashit(str_replace('//','/',str_replace('\\','/',stripslashes($_POST['mailsendmail']))));
|
13 |
+
$cfg['mailsecure']=$_POST['mailsecure'];
|
14 |
+
$cfg['mailhost']=$_POST['mailhost'];
|
15 |
+
$cfg['mailhostport']=empty($_POST['mailhostport']) ? 25 : (int)$_POST['mailhostport'];
|
16 |
+
$cfg['mailuser']=$_POST['mailuser'];
|
17 |
+
$cfg['mailpass']=base64_encode($_POST['mailpass']);
|
18 |
+
$cfg['disablewpcron']=isset($_POST['disablewpcron']) ? true : false;
|
19 |
+
$cfg['showadminbar']=isset($_POST['showadminbar']) ? true : false;
|
20 |
+
if (100>$_POST['jobstepretry'] and 0<$_POST['jobstepretry'])
|
21 |
+
$cfg['jobstepretry']=(int)$_POST['jobstepretry'];
|
22 |
+
if (100>$_POST['jobscriptretry'] and 0<$_POST['jobscriptretry'])
|
23 |
+
$cfg['jobscriptretry']=(int)$_POST['jobscriptretry'];
|
24 |
+
if (empty($cfg['jobstepretry']) or !is_int($cfg['jobstepretry']))
|
25 |
+
$cfg['jobstepretry']=3;
|
26 |
+
if (empty($cfg['jobscriptretry']) or !is_int($cfg['jobscriptretry']))
|
27 |
+
$cfg['jobscriptretry']=5;
|
28 |
+
$cfg['maxlogs']=abs((int)$_POST['maxlogs']);
|
29 |
+
$cfg['gzlogs']=isset($_POST['gzlogs']) ? true : false;
|
30 |
+
$cfg['phpzip']=isset($_POST['phpzip']) ? true : false;
|
31 |
+
$cfg['apicronservice']=isset($_POST['apicronservice']) ? true : false;
|
32 |
+
$cfg['httpauthuser']=$_POST['httpauthuser'];
|
33 |
+
$cfg['httpauthpassword']=base64_encode($_POST['httpauthpassword']);
|
34 |
+
$cfg['dirlogs']=trailingslashit(str_replace('//','/',str_replace('\\','/',stripslashes(trim($_POST['dirlogs'])))));
|
35 |
+
//set def. folders
|
36 |
+
if (!isset($cfg['dirlogs']) or $cfg['dirlogs']=='/' or empty($cfg['dirlogs'])) {
|
37 |
+
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
38 |
+
$cfg['dirlogs']=str_replace('\\','/',trailingslashit(WP_CONTENT_DIR)).'backwpup-'.$rand.'-logs/';
|
39 |
+
}
|
40 |
+
if (substr($cfg['dirlogs'],0,1)!='/' and substr($cfg['dirlogs'],1,1)!=':') //add abspath if not absolute
|
41 |
+
$cfg['dirlogs']=rtrim(str_replace('\\','/',ABSPATH),'/').'/'.$cfg['dirlogs'];
|
42 |
+
if (!isset($cfg['mailsendmail']) or empty($cfg['mailsendmail'])) {
|
43 |
+
$cfg['mailsendmail']=substr(ini_get('sendmail_path'),0,strpos(ini_get('sendmail_path'),' -'));
|
44 |
+
}
|
45 |
+
if (update_option('backwpup',$cfg))
|
46 |
+
$backwpup_message=__('Settings saved', 'backwpup');
|
47 |
+
backwpup_api(true);
|
48 |
+
}
|
49 |
+
|
50 |
+
//add Help
|
51 |
+
backwpup_contextual_help();
|
|
pages/header_backwpuptools.php
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
-
<?PHP
|
2 |
-
if (!defined('ABSPATH'))
|
3 |
-
die();
|
4 |
-
|
5 |
-
//add Help
|
6 |
-
backwpup_contextual_help();
|
7 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
if (!defined('ABSPATH'))
|
3 |
+
die();
|
4 |
+
|
5 |
+
//add Help
|
6 |
+
backwpup_contextual_help();
|
|
pages/header_backwpupworking.php
CHANGED
@@ -1,33 +1,32 @@
|
|
1 |
-
<?PHP
|
2 |
-
if (!defined('ABSPATH'))
|
3 |
-
die();
|
4 |
-
|
5 |
-
nocache_headers(); //no chache
|
6 |
-
|
7 |
-
if (isset($_GET['action']) and $_GET['action']=='runnow' and !empty($_GET['jobid'])) {
|
8 |
-
$jobid = (int) $_GET['jobid'];
|
9 |
-
check_admin_referer('runnow-job_'.$jobid);
|
10 |
-
if ($infile=backwpup_get_working_file()) {
|
11 |
-
$backwpup_message=__('A job alredy running!!! Pleace try again if its done.','backwpup');
|
12 |
-
$_GET['logfile']=$infile['LOGFILE'];
|
13 |
-
} else {
|
14 |
-
//include jobstart function
|
15 |
-
require_once(dirname(__FILE__).'/../job/job_start.php');
|
16 |
-
$_GET['logfile']=backwpup_jobstart($jobid,false);
|
17 |
-
}
|
18 |
-
}
|
19 |
-
elseif (!empty($_GET['logfile'])) {
|
20 |
-
check_admin_referer('view-log_'.basename(trim($_GET['logfile'])));
|
21 |
-
}
|
22 |
-
elseif ($infile=backwpup_get_working_file()) {
|
23 |
-
$backwpup_message=__('A job is running!!!','backwpup');
|
24 |
-
$_GET['logfile']=$infile['LOGFILE'];
|
25 |
-
}
|
26 |
-
elseif (!isset($_GET['action']) and !isset($_GET['logfile']) and empty($backwpup_message)) {
|
27 |
-
$backwpup_message=__('Nothing...','backwpup');
|
28 |
-
$_GET['logfile']='';
|
29 |
-
}
|
30 |
-
|
31 |
-
//add Help
|
32 |
-
backwpup_contextual_help(__('Here you see working jobs or logfiles','backwpup'));
|
33 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
if (!defined('ABSPATH'))
|
3 |
+
die();
|
4 |
+
|
5 |
+
nocache_headers(); //no chache
|
6 |
+
|
7 |
+
if (isset($_GET['action']) and $_GET['action']=='runnow' and !empty($_GET['jobid'])) {
|
8 |
+
$jobid = (int) $_GET['jobid'];
|
9 |
+
check_admin_referer('runnow-job_'.$jobid);
|
10 |
+
if ($infile=backwpup_get_working_file()) {
|
11 |
+
$backwpup_message=__('A job alredy running!!! Pleace try again if its done.','backwpup');
|
12 |
+
$_GET['logfile']=$infile['LOGFILE'];
|
13 |
+
} else {
|
14 |
+
//include jobstart function
|
15 |
+
require_once(dirname(__FILE__).'/../job/job_start.php');
|
16 |
+
$_GET['logfile']=backwpup_jobstart($jobid,false);
|
17 |
+
}
|
18 |
+
}
|
19 |
+
elseif (!empty($_GET['logfile'])) {
|
20 |
+
check_admin_referer('view-log_'.basename(trim($_GET['logfile'])));
|
21 |
+
}
|
22 |
+
elseif ($infile=backwpup_get_working_file()) {
|
23 |
+
$backwpup_message=__('A job is running!!!','backwpup');
|
24 |
+
$_GET['logfile']=$infile['LOGFILE'];
|
25 |
+
}
|
26 |
+
elseif (!isset($_GET['action']) and !isset($_GET['logfile']) and empty($backwpup_message)) {
|
27 |
+
$backwpup_message=__('Nothing...','backwpup');
|
28 |
+
$_GET['logfile']='';
|
29 |
+
}
|
30 |
+
|
31 |
+
//add Help
|
32 |
+
backwpup_contextual_help(__('Here you see working jobs or logfiles','backwpup'));
|
|
pages/page_backwpup.php
CHANGED
@@ -1,18 +1,17 @@
|
|
1 |
-
<?PHP
|
2 |
-
if (!defined('ABSPATH'))
|
3 |
-
die();
|
4 |
-
|
5 |
-
|
6 |
-
echo "<div class=\"wrap\">";
|
7 |
-
screen_icon();
|
8 |
-
echo "<h2>".esc_html( __('BackWPup Jobs', 'backwpup'))." <a href=\"".wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupeditjob', 'edit-job')."\" class=\"add-new-h2\">".esc_html__('Add New','backwpup')."</a></h2>";
|
9 |
-
if (isset($backwpup_message) and !empty($backwpup_message))
|
10 |
-
echo "<div id=\"message\" class=\"updated\"><p>".$backwpup_message."</p></div>";
|
11 |
-
echo "<form id=\"posts-filter\" action=\"\" method=\"get\">";
|
12 |
-
echo "<input type=\"hidden\" name=\"page\" value=\"backwpup\" />";
|
13 |
-
wp_nonce_field('backwpup_ajax_nonce', 'backwpupajaxnonce', false );
|
14 |
-
$backwpup_listtable->display();
|
15 |
-
echo "<div id=\"ajax-response\"></div>";
|
16 |
-
echo "</form>";
|
17 |
-
echo "</div>";
|
18 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
if (!defined('ABSPATH'))
|
3 |
+
die();
|
4 |
+
|
5 |
+
|
6 |
+
echo "<div class=\"wrap\">";
|
7 |
+
screen_icon();
|
8 |
+
echo "<h2>".esc_html( __('BackWPup Jobs', 'backwpup'))." <a href=\"".wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupeditjob', 'edit-job')."\" class=\"add-new-h2\">".esc_html__('Add New','backwpup')."</a></h2>";
|
9 |
+
if (isset($backwpup_message) and !empty($backwpup_message))
|
10 |
+
echo "<div id=\"message\" class=\"updated\"><p>".$backwpup_message."</p></div>";
|
11 |
+
echo "<form id=\"posts-filter\" action=\"\" method=\"get\">";
|
12 |
+
echo "<input type=\"hidden\" name=\"page\" value=\"backwpup\" />";
|
13 |
+
wp_nonce_field('backwpup_ajax_nonce', 'backwpupajaxnonce', false );
|
14 |
+
$backwpup_listtable->display();
|
15 |
+
echo "<div id=\"ajax-response\"></div>";
|
16 |
+
echo "</form>";
|
17 |
+
echo "</div>";
|
|
pages/page_backwpupbackups.php
CHANGED
@@ -1,17 +1,16 @@
|
|
1 |
-
<?PHP
|
2 |
-
if (!defined('ABSPATH'))
|
3 |
-
die();
|
4 |
-
|
5 |
-
|
6 |
-
echo "<div class=\"wrap\">";
|
7 |
-
screen_icon();
|
8 |
-
echo "<h2>".esc_html( __('BackWPup Manage Backups', 'backwpup'))."</h2>";
|
9 |
-
if (isset($backwpup_message) and !empty($backwpup_message))
|
10 |
-
echo "<div id=\"message\" class=\"updated\"><p>".$backwpup_message."</p></div>";
|
11 |
-
echo "<form id=\"posts-filter\" action=\"\" method=\"get\">";
|
12 |
-
echo "<input type=\"hidden\" name=\"page\" value=\"backwpupbackups\" />";
|
13 |
-
$backwpup_listtable->display();
|
14 |
-
echo "<div id=\"ajax-response\"></div>";
|
15 |
-
echo "</form>";
|
16 |
-
echo "</div>";
|
17 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
if (!defined('ABSPATH'))
|
3 |
+
die();
|
4 |
+
|
5 |
+
|
6 |
+
echo "<div class=\"wrap\">";
|
7 |
+
screen_icon();
|
8 |
+
echo "<h2>".esc_html( __('BackWPup Manage Backups', 'backwpup'))."</h2>";
|
9 |
+
if (isset($backwpup_message) and !empty($backwpup_message))
|
10 |
+
echo "<div id=\"message\" class=\"updated\"><p>".$backwpup_message."</p></div>";
|
11 |
+
echo "<form id=\"posts-filter\" action=\"\" method=\"get\">";
|
12 |
+
echo "<input type=\"hidden\" name=\"page\" value=\"backwpupbackups\" />";
|
13 |
+
$backwpup_listtable->display();
|
14 |
+
echo "<div id=\"ajax-response\"></div>";
|
15 |
+
echo "</form>";
|
16 |
+
echo "</div>";
|
|
pages/page_backwpupeditjob.php
CHANGED
@@ -1,210 +1,210 @@
|
|
1 |
-
<?PHP
|
2 |
-
if (!defined('ABSPATH'))
|
3 |
-
die();
|
4 |
-
|
5 |
-
global $wpdb,$screen_layout_columns;
|
6 |
-
|
7 |
-
//may be needed to ensure that a special box is always available
|
8 |
-
add_meta_box('backwpup_jobedit_save', __('Job Type','backwpup'), 'backwpup_jobedit_metabox_save', $current_screen->id, 'side', 'high');
|
9 |
-
add_meta_box('backwpup_jobedit_schedule', __('Job Schedule','backwpup'), 'backwpup_jobedit_metabox_schedule', $current_screen->id, 'side', 'core');
|
10 |
-
|
11 |
-
//get and check job id
|
12 |
-
if (isset($_REQUEST['jobid']) and !empty($_REQUEST['jobid'])) {
|
13 |
-
check_admin_referer('edit-job');
|
14 |
-
$jobvalue=backwpup_get_job_vars((int) $_REQUEST['jobid']);
|
15 |
-
} else {
|
16 |
-
$jobvalue=backwpup_get_job_vars();
|
17 |
-
}
|
18 |
-
//set extra vars
|
19 |
-
$todo=explode('+',$jobvalue['type']);
|
20 |
-
$dests=explode(',',strtoupper(BACKWPUP_DESTS));
|
21 |
-
?>
|
22 |
-
<div class="wrap columns-<?php echo (int) $screen_layout_columns ? (int) $screen_layout_columns : 'auto'; ?>">
|
23 |
-
<?php
|
24 |
-
screen_icon();
|
25 |
-
echo "<h2>".esc_html( __('BackWPup Job Settings', 'backwpup'))." <a href=\"".wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupeditjob', 'edit-job')."\" class=\"add-new-h2\">".esc_html__('Add New','backwpup')."</a></h2>";
|
26 |
-
?>
|
27 |
-
|
28 |
-
<?php if (isset($backwpup_message) and !empty($backwpup_message)) : ?>
|
29 |
-
<div id="message" class="updated"><p><?php echo $backwpup_message; ?></p></div>
|
30 |
-
<?php endif; ?>
|
31 |
-
|
32 |
-
<form name="editjob" id="editjob" method="post" action="<?PHP echo backwpup_admin_url('admin.php').'?page=backwpupeditjob';?>">
|
33 |
-
<input type="hidden" name="jobid" value="<?PHP echo $jobvalue['jobid'];?>" />
|
34 |
-
<?php wp_nonce_field('edit-job'); ?>
|
35 |
-
<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false ); ?>
|
36 |
-
<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false ); ?>
|
37 |
-
<?php wp_nonce_field('backwpupeditjob_ajax_nonce', 'backwpupeditjobajaxnonce', false ); ?>
|
38 |
-
<div id="poststuff">
|
39 |
-
<?php if (function_exists('wp_get_themes')) { ?>
|
40 |
-
<div id="post-body" class="metabox-holder columns-<?php echo 1 == $screen_layout_columns ? '1' : '2'; ?>">
|
41 |
-
<div id="post-body-content">
|
42 |
-
|
43 |
-
<div id="titlediv">
|
44 |
-
<div id="titlewrap">
|
45 |
-
<label class="hide-if-no-js" style="visibility:hidden" id="title-prompt-text" for="title"><?php _e( 'Enter Job name here', 'backwpup' ); ?></label>
|
46 |
-
<input type="text" name="name" size="30" tabindex="1" value="<?php echo $jobvalue['name'];?>" id="title" autocomplete="off" />
|
47 |
-
</div>
|
48 |
-
</div>
|
49 |
-
|
50 |
-
</div>
|
51 |
-
|
52 |
-
<div id="postbox-container-1" class="postbox-container">
|
53 |
-
|
54 |
-
<?php do_meta_boxes($current_screen->id, 'side', $jobvalue); ?>
|
55 |
-
|
56 |
-
</div>
|
57 |
-
|
58 |
-
<div id="postbox-container-2" class="postbox-container">
|
59 |
-
|
60 |
-
<?php } else { //for wp version older 3.4?>
|
61 |
-
<div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>">
|
62 |
-
<div id="side-info-column" class="inner-sidebar">
|
63 |
-
<?php do_meta_boxes($current_screen->id, 'side', $jobvalue); ?>
|
64 |
-
</div>
|
65 |
-
|
66 |
-
<div id="post-body">
|
67 |
-
<div id="post-body-content">
|
68 |
-
|
69 |
-
<div id="titlediv">
|
70 |
-
<div id="titlewrap">
|
71 |
-
<label class="hide-if-no-js" style="visibility:hidden" id="title-prompt-text" for="title"><?PHP _e('Enter Job name here','backwpup'); ?></label>
|
72 |
-
<input type="text" name="name" size="30" tabindex="1" value="<?PHP echo $jobvalue['name'];?>" id="title" autocomplete="off" />
|
73 |
-
</div>
|
74 |
-
</div>
|
75 |
-
<?php } ?>
|
76 |
-
<div id="databasejobs" class="stuffbox" <?PHP if (!in_array("CHECK",$todo) and !in_array("DB",$todo) and !in_array("OPTIMIZE",$todo)) echo 'style="display:none;"';?>>
|
77 |
-
<h3><label for="dbtables"><?PHP _e('Database Jobs','backwpup'); ?></label></h3>
|
78 |
-
<div class="inside">
|
79 |
-
<div>
|
80 |
-
<b><?PHP _e('Database tables to use:','backwpup'); ?></b>
|
81 |
-
<div id="dbtables">
|
82 |
-
<?php
|
83 |
-
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
84 |
-
foreach ($tables as $table) {
|
85 |
-
echo ' <input class="checkbox" type="checkbox"'.checked(!in_array($table,$jobvalue['dbexclude']),true,false).' name="jobtabs[]" value="'.base64_encode($table).'"/> '.$table.'<br />';
|
86 |
-
}
|
87 |
-
?>
|
88 |
-
</div>
|
89 |
-
</div>
|
90 |
-
<span id="dbshortinsert" <?PHP if (!in_array("DB",$todo)) echo 'style="display:none;"';?>><input class="checkbox" type="checkbox"<?php checked($jobvalue['dbshortinsert'],true,true);?> name="dbshortinsert" value="1"/> <?php _e('Use short INSERTs instead of full (with keys)','backwpup');?><br /></span>
|
91 |
-
<input class="checkbox" type="checkbox"<?php checked($jobvalue['maintenance'],true,true);?> name="maintenance" value="1"/> <?php _e('Set Blog Maintenance Mode on Database Operations','backwpup');?><br />
|
92 |
-
</div>
|
93 |
-
</div>
|
94 |
-
|
95 |
-
<div id="filebackup" class="stuffbox" <?PHP if (!in_array("FILE",$todo)) echo 'style="display:none;"';?>>
|
96 |
-
<h3><label for="backuproot"><?PHP _e('File Backup','backwpup'); ?></label></h3>
|
97 |
-
<div class="inside">
|
98 |
-
<b><?PHP _e('Blog Folders to Backup:','backwpup'); ?></b><br /> <br />
|
99 |
-
<div>
|
100 |
-
<div style="width:20%; float: left;">
|
101 |
-
<b><input class="checkbox" type="checkbox"<?php checked($jobvalue['backuproot'],true,true);?> name="backuproot" value="1"/> <?php _e('root','backwpup');?></b><br />
|
102 |
-
<div style="border-color:#CEE1EF; border-style:solid; border-width:2px; height:10em; width:90%; margin:2px; overflow:auto;">
|
103 |
-
<?PHP
|
104 |
-
echo '<i>'.__('Exclude:','backwpup').'</i><br />';
|
105 |
-
$folder=untrailingslashit(str_replace('\\','/',ABSPATH));
|
106 |
-
if ( $dir = @opendir( $folder ) ) {
|
107 |
-
while (($file = readdir( $dir ) ) !== false ) {
|
108 |
-
if ( !in_array($file, array('.', '..','.svn')) and is_dir($folder.'/'.$file) and !in_array($folder.'/'.$file.'/',backwpup_get_exclude_wp_dirs($folder)))
|
109 |
-
echo '<nobr><input class="checkbox" type="checkbox"'.checked(in_array($folder.'/'.$file.'/',$jobvalue['backuprootexcludedirs']),true,false).' name="backuprootexcludedirs[]" value="'.$folder.'/'.$file.'/"/> '.$file.'</nobr><br />';
|
110 |
-
}
|
111 |
-
@closedir( $dir );
|
112 |
-
}
|
113 |
-
?>
|
114 |
-
</div>
|
115 |
-
</div>
|
116 |
-
<div style="width:20%;float: left;">
|
117 |
-
<b><input class="checkbox" type="checkbox"<?php checked($jobvalue['backupcontent'],true,true);?> name="backupcontent" value="1"/> <?php _e('Content','backwpup');?></b><br />
|
118 |
-
<div style="border-color:#CEE1EF; border-style:solid; border-width:2px; height:10em; width:90%; margin:2px; overflow:auto;">
|
119 |
-
<?PHP
|
120 |
-
echo '<i>'.__('Exclude:','backwpup').'</i><br />';
|
121 |
-
$folder=untrailingslashit(str_replace('\\','/',WP_CONTENT_DIR));
|
122 |
-
if ( $dir = @opendir( $folder ) ) {
|
123 |
-
while (($file = readdir( $dir ) ) !== false ) {
|
124 |
-
if ( !in_array($file, array('.', '..','.svn')) and is_dir($folder.'/'.$file) and !in_array($folder.'/'.$file.'/',backwpup_get_exclude_wp_dirs($folder)))
|
125 |
-
echo '<nobr><input class="checkbox" type="checkbox"'.checked(in_array($folder.'/'.$file.'/',$jobvalue['backupcontentexcludedirs']),true,false).' name="backupcontentexcludedirs[]" value="'.$folder.'/'.$file.'/"/> '.$file.'</nobr><br />';
|
126 |
-
}
|
127 |
-
@closedir( $dir );
|
128 |
-
}
|
129 |
-
?>
|
130 |
-
</div>
|
131 |
-
</div>
|
132 |
-
<div style="width:20%; float: left;">
|
133 |
-
<b><input class="checkbox" type="checkbox"<?php checked($jobvalue['backupplugins'],true,true);?> name="backupplugins" value="1"/> <?php _e('Plugins','backwpup');?></b><br />
|
134 |
-
<div style="border-color:#CEE1EF; border-style:solid; border-width:2px; height:10em; width:90%; margin:2px; overflow:auto;">
|
135 |
-
<?PHP
|
136 |
-
echo '<i>'.__('Exclude:','backwpup').'</i><br />';
|
137 |
-
$folder=untrailingslashit(str_replace('\\','/',WP_PLUGIN_DIR));
|
138 |
-
if ( $dir = @opendir( $folder ) ) {
|
139 |
-
while (($file = readdir( $dir ) ) !== false ) {
|
140 |
-
if ( !in_array($file, array('.', '..','.svn')) and is_dir($folder.'/'.$file) and !in_array($folder.'/'.$file.'/',backwpup_get_exclude_wp_dirs($folder)))
|
141 |
-
echo '<nobr><input class="checkbox" type="checkbox"'.checked(in_array($folder.'/'.$file.'/',$jobvalue['backuppluginsexcludedirs']),true,false).' name="backuppluginsexcludedirs[]" value="'.$folder.'/'.$file.'/"/> '.$file.'</nobr><br />';
|
142 |
-
}
|
143 |
-
@closedir( $dir );
|
144 |
-
}
|
145 |
-
?>
|
146 |
-
</div>
|
147 |
-
</div>
|
148 |
-
<div style="width:20%; float: left;">
|
149 |
-
<b><input class="checkbox" type="checkbox"<?php checked($jobvalue['backupthemes'],true,true);?> name="backupthemes" value="1"/> <?php _e('Themes','backwpup');?></b><br />
|
150 |
-
<div style="border-color:#CEE1EF; border-style:solid; border-width:2px; height:10em; width:90%; margin:2px; overflow:auto;">
|
151 |
-
<?PHP
|
152 |
-
echo '<i>'.__('Exclude:','backwpup').'</i><br />';
|
153 |
-
$folder=untrailingslashit(str_replace('\\','/',trailingslashit(WP_CONTENT_DIR).'themes'));
|
154 |
-
if ( $dir = @opendir( $folder ) ) {
|
155 |
-
while (($file = readdir( $dir ) ) !== false ) {
|
156 |
-
if ( !in_array($file, array('.', '..','.svn')) and is_dir($folder.'/'.$file) and !in_array($folder.'/'.$file.'/',backwpup_get_exclude_wp_dirs($folder)))
|
157 |
-
echo '<nobr><input class="checkbox" type="checkbox"'.checked(in_array($folder.'/'.$file.'/',$jobvalue['backupthemesexcludedirs']),true,false).' name="backupthemesexcludedirs[]" value="'.$folder.'/'.$file.'/"/> '.$file.'</nobr><br />';
|
158 |
-
}
|
159 |
-
@closedir( $dir );
|
160 |
-
}
|
161 |
-
?>
|
162 |
-
</div>
|
163 |
-
</div>
|
164 |
-
<div style="width:20%; float: left;">
|
165 |
-
<b><input class="checkbox" type="checkbox"<?php checked($jobvalue['backupuploads'],true,true);?> name="backupuploads" value="1"/> <?php _e('Blog Uploads','backwpup');?></b><br />
|
166 |
-
<div style="border-color:#CEE1EF; border-style:solid; border-width:2px; height:10em; width:90%; margin:2px; overflow:auto;">
|
167 |
-
<?PHP
|
168 |
-
echo '<i>'.__('Exclude:','backwpup').'</i><br />';
|
169 |
-
$folder=untrailingslashit(backwpup_get_upload_dir());
|
170 |
-
if ( $dir = @opendir( $folder ) ) {
|
171 |
-
while (($file = readdir( $dir ) ) !== false ) {
|
172 |
-
if ( !in_array($file, array('.', '..','.svn')) and is_dir($folder.'/'.$file) and !in_array($folder.'/'.$file,backwpup_get_exclude_wp_dirs($folder)))
|
173 |
-
echo '<nobr><input class="checkbox" type="checkbox"'.checked(in_array($folder.'/'.$file.'/',$jobvalue['backupuploadsexcludedirs']),true,false).' name="backupuploadsexcludedirs[]" value="'.$folder.'/'.$file.'/"/> '.$file.'</nobr><br />';
|
174 |
-
}
|
175 |
-
@closedir( $dir );
|
176 |
-
}
|
177 |
-
?>
|
178 |
-
</div>
|
179 |
-
</div>
|
180 |
-
</div>
|
181 |
-
<br /> <br />
|
182 |
-
<b><?PHP _e('Include Folders to Backup:','backwpup'); ?></b><br />
|
183 |
-
<?PHP _e('Example:','backwpup'); ?> <?PHP echo str_replace('\\','/',ABSPATH); ?>,...<br />
|
184 |
-
<input name="dirinclude" id="dirinclude" type="text" value="<?PHP echo $jobvalue['dirinclude'];?>" class="large-text" /><br />
|
185 |
-
<br />
|
186 |
-
<b><?PHP _e('Exclude Files/Folders from Backup:','backwpup'); ?></b><br />
|
187 |
-
<?PHP _e('Example:','backwpup'); ?> /logs/,.log,.tmp,/temp/,....<br />
|
188 |
-
<input name="fileexclude" id="fileexclude" type="text" value="<?PHP echo $jobvalue['fileexclude'];?>" class="large-text" /><br />
|
189 |
-
</div>
|
190 |
-
</div>
|
191 |
-
|
192 |
-
|
193 |
-
<?php do_meta_boxes( $current_screen->id, 'normal', $jobvalue ); ?>
|
194 |
-
|
195 |
-
<?php do_meta_boxes( $current_screen->id, 'advanced', $jobvalue ); ?>
|
196 |
-
|
197 |
-
</div>
|
198 |
-
</div>
|
199 |
-
</div>
|
200 |
-
|
201 |
-
</form>
|
202 |
-
</div>
|
203 |
-
|
204 |
-
<script type="text/javascript">
|
205 |
-
//<![CDATA[
|
206 |
-
jQuery(document).ready( function($) {
|
207 |
-
postboxes.add_postbox_toggles('<?php echo $current_screen->id; ?>');
|
208 |
-
});
|
209 |
-
//]]>
|
210 |
</script>
|
1 |
+
<?PHP
|
2 |
+
if (!defined('ABSPATH'))
|
3 |
+
die();
|
4 |
+
|
5 |
+
global $wpdb,$screen_layout_columns;
|
6 |
+
|
7 |
+
//may be needed to ensure that a special box is always available
|
8 |
+
add_meta_box('backwpup_jobedit_save', __('Job Type','backwpup'), 'backwpup_jobedit_metabox_save', $current_screen->id, 'side', 'high');
|
9 |
+
add_meta_box('backwpup_jobedit_schedule', __('Job Schedule','backwpup'), 'backwpup_jobedit_metabox_schedule', $current_screen->id, 'side', 'core');
|
10 |
+
|
11 |
+
//get and check job id
|
12 |
+
if (isset($_REQUEST['jobid']) and !empty($_REQUEST['jobid'])) {
|
13 |
+
check_admin_referer('edit-job');
|
14 |
+
$jobvalue=backwpup_get_job_vars((int) $_REQUEST['jobid']);
|
15 |
+
} else {
|
16 |
+
$jobvalue=backwpup_get_job_vars();
|
17 |
+
}
|
18 |
+
//set extra vars
|
19 |
+
$todo=explode('+',$jobvalue['type']);
|
20 |
+
$dests=explode(',',strtoupper(BACKWPUP_DESTS));
|
21 |
+
?>
|
22 |
+
<div class="wrap columns-<?php echo (int) $screen_layout_columns ? (int) $screen_layout_columns : 'auto'; ?>">
|
23 |
+
<?php
|
24 |
+
screen_icon();
|
25 |
+
echo "<h2>".esc_html( __('BackWPup Job Settings', 'backwpup'))." <a href=\"".wp_nonce_url(backwpup_admin_url('admin.php').'?page=backwpupeditjob', 'edit-job')."\" class=\"add-new-h2\">".esc_html__('Add New','backwpup')."</a></h2>";
|
26 |
+
?>
|
27 |
+
|
28 |
+
<?php if (isset($backwpup_message) and !empty($backwpup_message)) : ?>
|
29 |
+
<div id="message" class="updated"><p><?php echo $backwpup_message; ?></p></div>
|
30 |
+
<?php endif; ?>
|
31 |
+
|
32 |
+
<form name="editjob" id="editjob" method="post" action="<?PHP echo backwpup_admin_url('admin.php').'?page=backwpupeditjob';?>">
|
33 |
+
<input type="hidden" name="jobid" value="<?PHP echo $jobvalue['jobid'];?>" />
|
34 |
+
<?php wp_nonce_field('edit-job'); ?>
|
35 |
+
<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false ); ?>
|
36 |
+
<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false ); ?>
|
37 |
+
<?php wp_nonce_field('backwpupeditjob_ajax_nonce', 'backwpupeditjobajaxnonce', false ); ?>
|
38 |
+
<div id="poststuff">
|
39 |
+
<?php if (function_exists('wp_get_themes')) { ?>
|
40 |
+
<div id="post-body" class="metabox-holder columns-<?php echo 1 == $screen_layout_columns ? '1' : '2'; ?>">
|
41 |
+
<div id="post-body-content">
|
42 |
+
|
43 |
+
<div id="titlediv">
|
44 |
+
<div id="titlewrap">
|
45 |
+
<label class="hide-if-no-js" style="visibility:hidden" id="title-prompt-text" for="title"><?php _e( 'Enter Job name here', 'backwpup' ); ?></label>
|
46 |
+
<input type="text" name="name" size="30" tabindex="1" value="<?php echo $jobvalue['name'];?>" id="title" autocomplete="off" />
|
47 |
+
</div>
|
48 |
+
</div>
|
49 |
+
|
50 |
+
</div>
|
51 |
+
|
52 |
+
<div id="postbox-container-1" class="postbox-container">
|
53 |
+
|
54 |
+
<?php do_meta_boxes($current_screen->id, 'side', $jobvalue); ?>
|
55 |
+
|
56 |
+
</div>
|
57 |
+
|
58 |
+
<div id="postbox-container-2" class="postbox-container">
|
59 |
+
|
60 |
+
<?php } else { //for wp version older 3.4?>
|
61 |
+
<div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>">
|
62 |
+
<div id="side-info-column" class="inner-sidebar">
|
63 |
+
<?php do_meta_boxes($current_screen->id, 'side', $jobvalue); ?>
|
64 |
+
</div>
|
65 |
+
|
66 |
+
<div id="post-body">
|
67 |
+
<div id="post-body-content">
|
68 |
+
|
69 |
+
<div id="titlediv">
|
70 |
+
<div id="titlewrap">
|
71 |
+
<label class="hide-if-no-js" style="visibility:hidden" id="title-prompt-text" for="title"><?PHP _e('Enter Job name here','backwpup'); ?></label>
|
72 |
+
<input type="text" name="name" size="30" tabindex="1" value="<?PHP echo $jobvalue['name'];?>" id="title" autocomplete="off" />
|
73 |
+
</div>
|
74 |
+
</div>
|
75 |
+
<?php } ?>
|
76 |
+
<div id="databasejobs" class="stuffbox" <?PHP if (!in_array("CHECK",$todo) and !in_array("DB",$todo) and !in_array("OPTIMIZE",$todo)) echo 'style="display:none;"';?>>
|
77 |
+
<h3><label for="dbtables"><?PHP _e('Database Jobs','backwpup'); ?></label></h3>
|
78 |
+
<div class="inside">
|
79 |
+
<div>
|
80 |
+
<b><?PHP _e('Database tables to use:','backwpup'); ?></b>
|
81 |
+
<div id="dbtables">
|
82 |
+
<?php
|
83 |
+
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
84 |
+
foreach ($tables as $table) {
|
85 |
+
echo ' <input class="checkbox" type="checkbox"'.checked(!in_array($table,$jobvalue['dbexclude']),true,false).' name="jobtabs[]" value="'.base64_encode($table).'"/> '.$table.'<br />';
|
86 |
+
}
|
87 |
+
?>
|
88 |
+
</div>
|
89 |
+
</div>
|
90 |
+
<span id="dbshortinsert" <?PHP if (!in_array("DB",$todo)) echo 'style="display:none;"';?>><input class="checkbox" type="checkbox"<?php checked($jobvalue['dbshortinsert'],true,true);?> name="dbshortinsert" value="1"/> <?php _e('Use short INSERTs instead of full (with keys)','backwpup');?><br /></span>
|
91 |
+
<input class="checkbox" type="checkbox"<?php checked($jobvalue['maintenance'],true,true);?> name="maintenance" value="1"/> <?php _e('Set Blog Maintenance Mode on Database Operations','backwpup');?><br />
|
92 |
+
</div>
|
93 |
+
</div>
|
94 |
+
|
95 |
+
<div id="filebackup" class="stuffbox" <?PHP if (!in_array("FILE",$todo)) echo 'style="display:none;"';?>>
|
96 |
+
<h3><label for="backuproot"><?PHP _e('File Backup','backwpup'); ?></label></h3>
|
97 |
+
<div class="inside">
|
98 |
+
<b><?PHP _e('Blog Folders to Backup:','backwpup'); ?></b><br /> <br />
|
99 |
+
<div>
|
100 |
+
<div style="width:20%; float: left;">
|
101 |
+
<b><input class="checkbox" type="checkbox"<?php checked($jobvalue['backuproot'],true,true);?> name="backuproot" value="1"/> <?php _e('root','backwpup');?></b><br />
|
102 |
+
<div style="border-color:#CEE1EF; border-style:solid; border-width:2px; height:10em; width:90%; margin:2px; overflow:auto;">
|
103 |
+
<?PHP
|
104 |
+
echo '<i>'.__('Exclude:','backwpup').'</i><br />';
|
105 |
+
$folder=untrailingslashit(str_replace('\\','/',ABSPATH));
|
106 |
+
if ( $dir = @opendir( $folder ) ) {
|
107 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
108 |
+
if ( !in_array($file, array('.', '..','.svn')) and is_dir($folder.'/'.$file) and !in_array($folder.'/'.$file.'/',backwpup_get_exclude_wp_dirs($folder)))
|
109 |
+
echo '<nobr><input class="checkbox" type="checkbox"'.checked(in_array($folder.'/'.$file.'/',$jobvalue['backuprootexcludedirs']),true,false).' name="backuprootexcludedirs[]" value="'.$folder.'/'.$file.'/"/> '.$file.'</nobr><br />';
|
110 |
+
}
|
111 |
+
@closedir( $dir );
|
112 |
+
}
|
113 |
+
?>
|
114 |
+
</div>
|
115 |
+
</div>
|
116 |
+
<div style="width:20%;float: left;">
|
117 |
+
<b><input class="checkbox" type="checkbox"<?php checked($jobvalue['backupcontent'],true,true);?> name="backupcontent" value="1"/> <?php _e('Content','backwpup');?></b><br />
|
118 |
+
<div style="border-color:#CEE1EF; border-style:solid; border-width:2px; height:10em; width:90%; margin:2px; overflow:auto;">
|
119 |
+
<?PHP
|
120 |
+
echo '<i>'.__('Exclude:','backwpup').'</i><br />';
|
121 |
+
$folder=untrailingslashit(str_replace('\\','/',WP_CONTENT_DIR));
|
122 |
+
if ( $dir = @opendir( $folder ) ) {
|
123 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
124 |
+
if ( !in_array($file, array('.', '..','.svn')) and is_dir($folder.'/'.$file) and !in_array($folder.'/'.$file.'/',backwpup_get_exclude_wp_dirs($folder)))
|
125 |
+
echo '<nobr><input class="checkbox" type="checkbox"'.checked(in_array($folder.'/'.$file.'/',$jobvalue['backupcontentexcludedirs']),true,false).' name="backupcontentexcludedirs[]" value="'.$folder.'/'.$file.'/"/> '.$file.'</nobr><br />';
|
126 |
+
}
|
127 |
+
@closedir( $dir );
|
128 |
+
}
|
129 |
+
?>
|
130 |
+
</div>
|
131 |
+
</div>
|
132 |
+
<div style="width:20%; float: left;">
|
133 |
+
<b><input class="checkbox" type="checkbox"<?php checked($jobvalue['backupplugins'],true,true);?> name="backupplugins" value="1"/> <?php _e('Plugins','backwpup');?></b><br />
|
134 |
+
<div style="border-color:#CEE1EF; border-style:solid; border-width:2px; height:10em; width:90%; margin:2px; overflow:auto;">
|
135 |
+
<?PHP
|
136 |
+
echo '<i>'.__('Exclude:','backwpup').'</i><br />';
|
137 |
+
$folder=untrailingslashit(str_replace('\\','/',WP_PLUGIN_DIR));
|
138 |
+
if ( $dir = @opendir( $folder ) ) {
|
139 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
140 |
+
if ( !in_array($file, array('.', '..','.svn')) and is_dir($folder.'/'.$file) and !in_array($folder.'/'.$file.'/',backwpup_get_exclude_wp_dirs($folder)))
|
141 |
+
echo '<nobr><input class="checkbox" type="checkbox"'.checked(in_array($folder.'/'.$file.'/',$jobvalue['backuppluginsexcludedirs']),true,false).' name="backuppluginsexcludedirs[]" value="'.$folder.'/'.$file.'/"/> '.$file.'</nobr><br />';
|
142 |
+
}
|
143 |
+
@closedir( $dir );
|
144 |
+
}
|
145 |
+
?>
|
146 |
+
</div>
|
147 |
+
</div>
|
148 |
+
<div style="width:20%; float: left;">
|
149 |
+
<b><input class="checkbox" type="checkbox"<?php checked($jobvalue['backupthemes'],true,true);?> name="backupthemes" value="1"/> <?php _e('Themes','backwpup');?></b><br />
|
150 |
+
<div style="border-color:#CEE1EF; border-style:solid; border-width:2px; height:10em; width:90%; margin:2px; overflow:auto;">
|
151 |
+
<?PHP
|
152 |
+
echo '<i>'.__('Exclude:','backwpup').'</i><br />';
|
153 |
+
$folder=untrailingslashit(str_replace('\\','/',trailingslashit(WP_CONTENT_DIR).'themes'));
|
154 |
+
if ( $dir = @opendir( $folder ) ) {
|
155 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
156 |
+
if ( !in_array($file, array('.', '..','.svn')) and is_dir($folder.'/'.$file) and !in_array($folder.'/'.$file.'/',backwpup_get_exclude_wp_dirs($folder)))
|
157 |
+
echo '<nobr><input class="checkbox" type="checkbox"'.checked(in_array($folder.'/'.$file.'/',$jobvalue['backupthemesexcludedirs']),true,false).' name="backupthemesexcludedirs[]" value="'.$folder.'/'.$file.'/"/> '.$file.'</nobr><br />';
|
158 |
+
}
|
159 |
+
@closedir( $dir );
|
160 |
+
}
|
161 |
+
?>
|
162 |
+
</div>
|
163 |
+
</div>
|
164 |
+
<div style="width:20%; float: left;">
|
165 |
+
<b><input class="checkbox" type="checkbox"<?php checked($jobvalue['backupuploads'],true,true);?> name="backupuploads" value="1"/> <?php _e('Blog Uploads','backwpup');?></b><br />
|
166 |
+
<div style="border-color:#CEE1EF; border-style:solid; border-width:2px; height:10em; width:90%; margin:2px; overflow:auto;">
|
167 |
+
<?PHP
|
168 |
+
echo '<i>'.__('Exclude:','backwpup').'</i><br />';
|
169 |
+
$folder=untrailingslashit(backwpup_get_upload_dir());
|
170 |
+
if ( $dir = @opendir( $folder ) ) {
|
171 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
172 |
+
if ( !in_array($file, array('.', '..','.svn')) and is_dir($folder.'/'.$file) and !in_array($folder.'/'.$file,backwpup_get_exclude_wp_dirs($folder)))
|
173 |
+
echo '<nobr><input class="checkbox" type="checkbox"'.checked(in_array($folder.'/'.$file.'/',$jobvalue['backupuploadsexcludedirs']),true,false).' name="backupuploadsexcludedirs[]" value="'.$folder.'/'.$file.'/"/> '.$file.'</nobr><br />';
|
174 |
+
}
|
175 |
+
@closedir( $dir );
|
176 |
+
}
|
177 |
+
?>
|
178 |
+
</div>
|
179 |
+
</div>
|
180 |
+
</div>
|
181 |
+
<br /> <br />
|
182 |
+
<b><?PHP _e('Include Folders to Backup:','backwpup'); ?></b><br />
|
183 |
+
<?PHP _e('Example:','backwpup'); ?> <?PHP echo str_replace('\\','/',ABSPATH); ?>,...<br />
|
184 |
+
<input name="dirinclude" id="dirinclude" type="text" value="<?PHP echo $jobvalue['dirinclude'];?>" class="large-text" /><br />
|
185 |
+
<br />
|
186 |
+
<b><?PHP _e('Exclude Files/Folders from Backup:','backwpup'); ?></b><br />
|
187 |
+
<?PHP _e('Example:','backwpup'); ?> /logs/,.log,.tmp,/temp/,....<br />
|
188 |
+
<input name="fileexclude" id="fileexclude" type="text" value="<?PHP echo $jobvalue['fileexclude'];?>" class="large-text" /><br />
|
189 |
+
</div>
|
190 |
+
</div>
|
191 |
+
|
192 |
+
|
193 |
+
<?php do_meta_boxes( $current_screen->id, 'normal', $jobvalue ); ?>
|
194 |
+
|
195 |
+
<?php do_meta_boxes( $current_screen->id, 'advanced', $jobvalue ); ?>
|
196 |
+
|
197 |
+
</div>
|
198 |
+
</div>
|
199 |
+
</div>
|
200 |
+
|
201 |
+
</form>
|
202 |
+
</div>
|
203 |
+
|
204 |
+
<script type="text/javascript">
|
205 |
+
//<![CDATA[
|
206 |
+
jQuery(document).ready( function($) {
|
207 |
+
postboxes.add_postbox_toggles('<?php echo $current_screen->id; ?>');
|
208 |
+
});
|
209 |
+
//]]>
|
210 |
</script>
|
pages/page_backwpuplogs.php
CHANGED
@@ -1,17 +1,16 @@
|
|
1 |
-
<?PHP
|
2 |
-
if (!defined('ABSPATH'))
|
3 |
-
die();
|
4 |
-
|
5 |
-
|
6 |
-
echo "<div class=\"wrap\">";
|
7 |
-
screen_icon();
|
8 |
-
echo "<h2>".esc_html( __('BackWPup Logs', 'backwpup'))."</h2>";
|
9 |
-
if (isset($backwpup_message) and !empty($backwpup_message))
|
10 |
-
echo "<div id=\"message\" class=\"updated\"><p>".$backwpup_message."</p></div>";
|
11 |
-
echo "<form id=\"posts-filter\" action=\"\" method=\"get\">";
|
12 |
-
echo "<input type=\"hidden\" name=\"page\" value=\"backwpuplogs\" />";
|
13 |
-
$backwpup_listtable->display();
|
14 |
-
echo "<div id=\"ajax-response\"></div>";
|
15 |
-
echo "</form>";
|
16 |
-
echo "</div>";
|
17 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
if (!defined('ABSPATH'))
|
3 |
+
die();
|
4 |
+
|
5 |
+
|
6 |
+
echo "<div class=\"wrap\">";
|
7 |
+
screen_icon();
|
8 |
+
echo "<h2>".esc_html( __('BackWPup Logs', 'backwpup'))."</h2>";
|
9 |
+
if (isset($backwpup_message) and !empty($backwpup_message))
|
10 |
+
echo "<div id=\"message\" class=\"updated\"><p>".$backwpup_message."</p></div>";
|
11 |
+
echo "<form id=\"posts-filter\" action=\"\" method=\"get\">";
|
12 |
+
echo "<input type=\"hidden\" name=\"page\" value=\"backwpuplogs\" />";
|
13 |
+
$backwpup_listtable->display();
|
14 |
+
echo "<div id=\"ajax-response\"></div>";
|
15 |
+
echo "</form>";
|
16 |
+
echo "</div>";
|
|
pages/page_backwpupsettings.php
CHANGED
@@ -1,171 +1,171 @@
|
|
1 |
-
<?PHP
|
2 |
-
if (!defined('ABSPATH'))
|
3 |
-
die();
|
4 |
-
|
5 |
-
|
6 |
-
$cfg=get_option('backwpup');
|
7 |
-
|
8 |
-
echo "<div class=\"wrap\">";
|
9 |
-
screen_icon();
|
10 |
-
echo "<h2>".esc_html( __('BackWPup Settings', 'backwpup'))."</h2>";
|
11 |
-
if (isset($backwpup_message) and !empty($backwpup_message))
|
12 |
-
echo "<div id=\"message\" class=\"updated\"><p>".$backwpup_message."</p></div>";
|
13 |
-
echo "<form id=\"posts-filter\" action=\"".backwpup_admin_url('admin.php')."?page=backwpupsettings\" method=\"post\">";
|
14 |
-
wp_nonce_field('backwpup-cfg');
|
15 |
-
?>
|
16 |
-
<input type="hidden" name="action" value="update" />
|
17 |
-
<h3><?PHP _e('Send Mail','backwpup'); ?></h3>
|
18 |
-
<p><?PHP _e('Here you can set the options for email sending. The settings will be used in jobs for sending backups via email or for sending log files.','backwpup'); ?></p>
|
19 |
-
<table class="form-table">
|
20 |
-
<tr valign="top">
|
21 |
-
<th scope="row"><label for="mailsndemail"><?PHP _e('Sender email','backwpup'); ?></label></th>
|
22 |
-
<td><input name="mailsndemail" type="text" id="mailsndemail" value="<?PHP echo $cfg['mailsndemail'];?>" class="regular-text" />
|
23 |
-
</td>
|
24 |
-
</tr>
|
25 |
-
<tr valign="top">
|
26 |
-
<th scope="row"><label for="mailsndname"><?PHP _e('Sender name','backwpup'); ?></label></th>
|
27 |
-
<td><input name="mailsndname" type="text" id="mailsndname" value="<?PHP echo $cfg['mailsndname'];?>" class="regular-text" /></td>
|
28 |
-
</tr>
|
29 |
-
<tr valign="top">
|
30 |
-
<th scope="row"><label for="mailmethod"><?PHP _e('Send mail method','backwpup'); ?></label></th>
|
31 |
-
<td>
|
32 |
-
<?PHP
|
33 |
-
echo '<select id="mailmethod" name="mailmethod">';
|
34 |
-
echo '<option class="level-0" value="mail"'.selected('mail',$cfg['mailmethod'],false).'>'.__('PHP: mail()','backwpup').'</option>';
|
35 |
-
echo '<option class="level-0" value="Sendmail"'.selected('Sendmail',$cfg['mailmethod'],false).'>'.__('Sendmail','backwpup').'</option>';
|
36 |
-
echo '<option class="level-0" value="SMTP"'.selected('SMTP',$cfg['mailmethod'],false).'>'.__('SMTP','backwpup').'</option>';
|
37 |
-
echo '</select>';
|
38 |
-
?>
|
39 |
-
</td>
|
40 |
-
</tr>
|
41 |
-
<tr valign="top" id="mailsendmail" <?PHP if ($cfg['mailmethod']!='Sendmail') echo 'style="display:none;"';?>>
|
42 |
-
<th scope="row"><label for="mailsendmail"><?PHP _e('Sendmail path','backwpup'); ?></label></th>
|
43 |
-
<td>
|
44 |
-
<input name="mailsendmail" id="sendmail" type="text" value="<?PHP echo $cfg['mailsendmail'];?>" class="regular-text code" />
|
45 |
-
</select>
|
46 |
-
</td>
|
47 |
-
</tr>
|
48 |
-
<tr valign="top" class="mailsmtp" <?PHP if ($cfg['mailmethod']!='SMTP') echo 'style="display:none;"';?>>
|
49 |
-
<th scope="row"><label for="mailhost"><?PHP _e('SMTP hostname','backwpup'); ?></label></th>
|
50 |
-
<td>
|
51 |
-
<input name="mailhost" id="mailhost" type="text" value="<?PHP echo $cfg['mailhost'];?>" class="regular-text code" />
|
52 |
-
<?PHP _e('Port:','backwpup'); ?><input name="mailhostport" id="mailhostport" type="text" value="<?PHP echo $cfg['mailhostport'];?>" class="small-text code" />
|
53 |
-
</td>
|
54 |
-
</tr>
|
55 |
-
<tr valign="top" class="mailsmtp" <?PHP if ($cfg['mailmethod']!='SMTP') echo 'style="display:none;"';?>>
|
56 |
-
<th scope="row"><label for="mailsecure"><?PHP _e('SMTP secure connection','backwpup'); ?></label></th>
|
57 |
-
<td>
|
58 |
-
<select name="mailsecure">
|
59 |
-
<option class="level-0" value=""<?PHP selected('',$cfg['mailsecure'],true); ?>><?PHP _e('none','backwpup'); ?></option>
|
60 |
-
<option class="level-0" value="ssl"<?PHP selected('ssl',$cfg['mailsecure'],true); ?>>SSL</option>
|
61 |
-
<option class="level-0" value="tls"<?PHP selected('tls',$cfg['mailsecure'],true); ?>>TLS</option>
|
62 |
-
</select>
|
63 |
-
</td>
|
64 |
-
</tr>
|
65 |
-
<tr valign="top" class="mailsmtp" <?PHP if ($cfg['mailmethod']!='SMTP') echo 'style="display:none;"';?>>
|
66 |
-
<th scope="row"><label for="mailuser"><?PHP _e('SMTP username','backwpup'); ?></label></th>
|
67 |
-
<td>
|
68 |
-
<input name="mailuser" id="mailuser" type="text" value="<?PHP echo $cfg['mailuser'];?>" class="regular-text" />
|
69 |
-
</td>
|
70 |
-
</tr>
|
71 |
-
<tr valign="top" class="mailsmtp" <?PHP if ($cfg['mailmethod']!='SMTP') echo 'style="display:none;"';?>>
|
72 |
-
<th scope="row"><label for="mailpass"><?PHP _e('SMTP password','backwpup'); ?></label></th>
|
73 |
-
<td>
|
74 |
-
<input name="mailpass" id="mailpass" type="password" value="<?PHP echo base64_decode($cfg['mailpass']);?>" class="regular-text" />
|
75 |
-
</td>
|
76 |
-
</tr>
|
77 |
-
</table>
|
78 |
-
|
79 |
-
<h3><?PHP _e('Logs','backwpup'); ?></h3>
|
80 |
-
<p><?PHP _e('Here you can set Logfile related options.','backwpup'); ?></p>
|
81 |
-
<table class="form-table">
|
82 |
-
<tr valign="top">
|
83 |
-
<th scope="row"><label for="dirlogs"><?PHP _e('Log file Folder','backwpup'); ?></label></th>
|
84 |
-
<td><input name="dirlogs" type="text" id="dirlogs" value="<?PHP echo $cfg['dirlogs'];?>" class="regular-text code" />
|
85 |
-
</td>
|
86 |
-
</tr>
|
87 |
-
<tr valign="top">
|
88 |
-
<th scope="row"><label for="maxlogs"><?PHP _e('Max. Log Files in Folder','backwpup'); ?></label></th>
|
89 |
-
<td><input name="maxlogs" type="text" id="maxlogs" value="<?PHP echo $cfg['maxlogs'];?>" class="small-text code" />
|
90 |
-
<span class="description"><?PHP _e('(Oldest files will deleted first.)','backwpup');?></span>
|
91 |
-
</td>
|
92 |
-
</tr>
|
93 |
-
<tr valign="top">
|
94 |
-
<th scope="row"><?PHP _e('Compression','backwpup'); ?></th>
|
95 |
-
<td><fieldset><legend class="screen-reader-text"><span><?PHP _e('Compression','backwpup'); ?></span></legend><label for="gzlogs">
|
96 |
-
<input name="gzlogs" type="checkbox" id="gzlogs" value="1" <?php checked($cfg['gzlogs'],true); ?><?php if (!function_exists('gzopen')) echo " disabled=\"disabled\""; ?> />
|
97 |
-
<?PHP _e('Gzip Log files!','backwpup'); ?></label>
|
98 |
-
</fieldset></td>
|
99 |
-
</tr>
|
100 |
-
</table>
|
101 |
-
<h3><?PHP _e('Jobs','backwpup'); ?></h3>
|
102 |
-
<p><?PHP _e('Here you can set Job related options.','backwpup'); ?></p>
|
103 |
-
<table class="form-table">
|
104 |
-
<tr valign="top">
|
105 |
-
<th scope="row"><label for="jobstepretry"><?PHP _e('Max. retrys for job steps','backwpup'); ?></label></th>
|
106 |
-
<td><input name="jobstepretry" type="text" id="jobstepretry" value="<?PHP echo $cfg['jobstepretry'];?>" class="small-text code" />
|
107 |
-
</td>
|
108 |
-
</tr>
|
109 |
-
<tr valign="top">
|
110 |
-
<th scope="row"><label for="jobscriptretry"><?PHP _e('Max. retrys for job script retries','backwpup'); ?></label></th>
|
111 |
-
<td><input name="jobscriptretry" type="text" id="jobscriptretry" value="<?PHP echo $cfg['jobscriptretry'];?>" class="small-text code" <?php if (defined('ALTERNATE_WP_CRON') and ALTERNATE_WP_CRON) echo " disabled=\"disabled\""; ?> />
|
112 |
-
</td>
|
113 |
-
</tr>
|
114 |
-
<tr valign="top">
|
115 |
-
<th scope="row"><?PHP _e('PHP zip class','backwpup'); ?></th>
|
116 |
-
<td><fieldset><legend class="screen-reader-text"><span><?PHP _e('PHP zip','backwpup'); ?></span></legend><label for="phpzip">
|
117 |
-
<input name="phpzip" type="checkbox" id="phpzip" value="1" <?php checked($cfg['phpzip'],true); ?><?php if (!class_exists('ZipArchive')) echo " disabled=\"disabled\""; ?> />
|
118 |
-
<?PHP _e('Use PHP zip class if available! Normaly PCL Zip class will used.','backwpup'); ?></label>
|
119 |
-
</fieldset></td>
|
120 |
-
</tr>
|
121 |
-
</table>
|
122 |
-
|
123 |
-
<h3><?PHP _e('WP Admin Bar','backwpup'); ?></h3>
|
124 |
-
<p><?PHP _e('Will you see BackWPup in the WordPress Admin Bar?','backwpup'); ?></p>
|
125 |
-
<table class="form-table">
|
126 |
-
<tr valign="top">
|
127 |
-
<th scope="row"><?PHP _e('Admin Bar','backwpup'); ?></th>
|
128 |
-
<td><fieldset><legend class="screen-reader-text"><span><?PHP _e('Admin Bar','backwpup'); ?></span></legend><label for="showadminbar">
|
129 |
-
<input name="showadminbar" type="checkbox" id="showadminbar" value="1" <?php checked($cfg['showadminbar'],true); ?> />
|
130 |
-
<?PHP _e('Show BackWPup Links in Admin Bar.','backwpup'); ?></label>
|
131 |
-
</fieldset></td>
|
132 |
-
</tr>
|
133 |
-
</table>
|
134 |
-
|
135 |
-
<h3><?PHP _e('Http basic authentication','backwpup'); ?></h3>
|
136 |
-
<p><?PHP _e('Is your blog behind a http basic authentication (.htaccess)? Then you must set the username and password four authentication.','backwpup'); ?></p>
|
137 |
-
<table class="form-table">
|
138 |
-
</tr>
|
139 |
-
<th scope="row"><label for="httpauthuser"><?PHP _e('Username:','backwpup'); ?></label></th>
|
140 |
-
<td><input name="httpauthuser" type="text" id="httpauthuser" value="<?PHP echo $cfg['httpauthuser'];?>" class="regular-text" />
|
141 |
-
</td>
|
142 |
-
</tr>
|
143 |
-
<tr valign="top">
|
144 |
-
<th scope="row"><label for="httpauthpassword"><?PHP _e('Password:','backwpup'); ?></label></th>
|
145 |
-
<td><input name="httpauthpassword" type="password" id="httpauthpassword" value="<?PHP echo base64_decode($cfg['httpauthpassword']);?>" class="regular-text" />
|
146 |
-
</tr>
|
147 |
-
</table>
|
148 |
-
|
149 |
-
<h3><?PHP _e('WP-Cron','backwpup'); ?></h3>
|
150 |
-
<p><?PHP _e('If you would use the cron job of your hoster you must point it to the url:','backwpup'); echo ' <i>'.get_option('siteurl').'/wp-cron.php</i>'; ?></p>
|
151 |
-
<table class="form-table">
|
152 |
-
<tr valign="top">
|
153 |
-
<th scope="row"><?PHP _e('Disable WP-Cron','backwpup'); ?></th>
|
154 |
-
<td><fieldset><legend class="screen-reader-text"><span><?PHP _e('Disable WP-Cron','backwpup'); ?></span></legend><label for="disablewpcron">
|
155 |
-
<input name="disablewpcron" type="checkbox" id="disablewpcron" value="1" <?php checked($cfg['disablewpcron'],true); ?> />
|
156 |
-
<?PHP _e('Use your host\'s Cron Job and disable WP-Cron','backwpup'); ?></label>
|
157 |
-
</fieldset></td>
|
158 |
-
</tr>
|
159 |
-
<tr valign="top">
|
160 |
-
<th scope="row"><?PHP _e('Use cron service of backwpup.com','backwpup'); ?></th>
|
161 |
-
<td><fieldset><legend class="screen-reader-text"><span><?PHP _e('Use cron service of backwpup.com','backwpup'); ?></span></legend><label for="apicronservice">
|
162 |
-
<input name="apicronservice" type="checkbox" id="apicronservice" value="1" <?php checked($cfg['apicronservice'],true); ?> />
|
163 |
-
<?PHP _e('If you check this, the job schedule will submited to backwpup.com. Backwpup.com will call your blog wp-cron.php to start. <em>Use this service only if you have not a cron service of your hoster, or a blog that has a few visitors.</em> The cron service can start cron behind a basic authentication, on that the http authentication data will transferd too! Please make a little donation for the plugin if you use this servcie. The service can be removed by me without a massage.','backwpup'); ?><br />
|
164 |
-
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q3QSVRSFXBLSE" target="_new"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" title="PayPal - The safer, easier way to pay online!"></a>
|
165 |
-
</label>
|
166 |
-
</fieldset>
|
167 |
-
</td>
|
168 |
-
</table>
|
169 |
-
<p class="submit"><input type="submit" name="submit" id="submit" class="button-primary" value="Save Changes" /></p>
|
170 |
-
</form>
|
171 |
</div>
|
1 |
+
<?PHP
|
2 |
+
if (!defined('ABSPATH'))
|
3 |
+
die();
|
4 |
+
|
5 |
+
|
6 |
+
$cfg=get_option('backwpup');
|
7 |
+
|
8 |
+
echo "<div class=\"wrap\">";
|
9 |
+
screen_icon();
|
10 |
+
echo "<h2>".esc_html( __('BackWPup Settings', 'backwpup'))."</h2>";
|
11 |
+
if (isset($backwpup_message) and !empty($backwpup_message))
|
12 |
+
echo "<div id=\"message\" class=\"updated\"><p>".$backwpup_message."</p></div>";
|
13 |
+
echo "<form id=\"posts-filter\" action=\"".backwpup_admin_url('admin.php')."?page=backwpupsettings\" method=\"post\">";
|
14 |
+
wp_nonce_field('backwpup-cfg');
|
15 |
+
?>
|
16 |
+
<input type="hidden" name="action" value="update" />
|
17 |
+
<h3><?PHP _e('Send Mail','backwpup'); ?></h3>
|
18 |
+
<p><?PHP _e('Here you can set the options for email sending. The settings will be used in jobs for sending backups via email or for sending log files.','backwpup'); ?></p>
|
19 |
+
<table class="form-table">
|
20 |
+
<tr valign="top">
|
21 |
+
<th scope="row"><label for="mailsndemail"><?PHP _e('Sender email','backwpup'); ?></label></th>
|
22 |
+
<td><input name="mailsndemail" type="text" id="mailsndemail" value="<?PHP echo $cfg['mailsndemail'];?>" class="regular-text" />
|
23 |
+
</td>
|
24 |
+
</tr>
|
25 |
+
<tr valign="top">
|
26 |
+
<th scope="row"><label for="mailsndname"><?PHP _e('Sender name','backwpup'); ?></label></th>
|
27 |
+
<td><input name="mailsndname" type="text" id="mailsndname" value="<?PHP echo $cfg['mailsndname'];?>" class="regular-text" /></td>
|
28 |
+
</tr>
|
29 |
+
<tr valign="top">
|
30 |
+
<th scope="row"><label for="mailmethod"><?PHP _e('Send mail method','backwpup'); ?></label></th>
|
31 |
+
<td>
|
32 |
+
<?PHP
|
33 |
+
echo '<select id="mailmethod" name="mailmethod">';
|
34 |
+
echo '<option class="level-0" value="mail"'.selected('mail',$cfg['mailmethod'],false).'>'.__('PHP: mail()','backwpup').'</option>';
|
35 |
+
echo '<option class="level-0" value="Sendmail"'.selected('Sendmail',$cfg['mailmethod'],false).'>'.__('Sendmail','backwpup').'</option>';
|
36 |
+
echo '<option class="level-0" value="SMTP"'.selected('SMTP',$cfg['mailmethod'],false).'>'.__('SMTP','backwpup').'</option>';
|
37 |
+
echo '</select>';
|
38 |
+
?>
|
39 |
+
</td>
|
40 |
+
</tr>
|
41 |
+
<tr valign="top" id="mailsendmail" <?PHP if ($cfg['mailmethod']!='Sendmail') echo 'style="display:none;"';?>>
|
42 |
+
<th scope="row"><label for="mailsendmail"><?PHP _e('Sendmail path','backwpup'); ?></label></th>
|
43 |
+
<td>
|
44 |
+
<input name="mailsendmail" id="sendmail" type="text" value="<?PHP echo $cfg['mailsendmail'];?>" class="regular-text code" />
|
45 |
+
</select>
|
46 |
+
</td>
|
47 |
+
</tr>
|
48 |
+
<tr valign="top" class="mailsmtp" <?PHP if ($cfg['mailmethod']!='SMTP') echo 'style="display:none;"';?>>
|
49 |
+
<th scope="row"><label for="mailhost"><?PHP _e('SMTP hostname','backwpup'); ?></label></th>
|
50 |
+
<td>
|
51 |
+
<input name="mailhost" id="mailhost" type="text" value="<?PHP echo $cfg['mailhost'];?>" class="regular-text code" />
|
52 |
+
<?PHP _e('Port:','backwpup'); ?><input name="mailhostport" id="mailhostport" type="text" value="<?PHP echo $cfg['mailhostport'];?>" class="small-text code" />
|
53 |
+
</td>
|
54 |
+
</tr>
|
55 |
+
<tr valign="top" class="mailsmtp" <?PHP if ($cfg['mailmethod']!='SMTP') echo 'style="display:none;"';?>>
|
56 |
+
<th scope="row"><label for="mailsecure"><?PHP _e('SMTP secure connection','backwpup'); ?></label></th>
|
57 |
+
<td>
|
58 |
+
<select name="mailsecure">
|
59 |
+
<option class="level-0" value=""<?PHP selected('',$cfg['mailsecure'],true); ?>><?PHP _e('none','backwpup'); ?></option>
|
60 |
+
<option class="level-0" value="ssl"<?PHP selected('ssl',$cfg['mailsecure'],true); ?>>SSL</option>
|
61 |
+
<option class="level-0" value="tls"<?PHP selected('tls',$cfg['mailsecure'],true); ?>>TLS</option>
|
62 |
+
</select>
|
63 |
+
</td>
|
64 |
+
</tr>
|
65 |
+
<tr valign="top" class="mailsmtp" <?PHP if ($cfg['mailmethod']!='SMTP') echo 'style="display:none;"';?>>
|
66 |
+
<th scope="row"><label for="mailuser"><?PHP _e('SMTP username','backwpup'); ?></label></th>
|
67 |
+
<td>
|
68 |
+
<input name="mailuser" id="mailuser" type="text" value="<?PHP echo $cfg['mailuser'];?>" class="regular-text" />
|
69 |
+
</td>
|
70 |
+
</tr>
|
71 |
+
<tr valign="top" class="mailsmtp" <?PHP if ($cfg['mailmethod']!='SMTP') echo 'style="display:none;"';?>>
|
72 |
+
<th scope="row"><label for="mailpass"><?PHP _e('SMTP password','backwpup'); ?></label></th>
|
73 |
+
<td>
|
74 |
+
<input name="mailpass" id="mailpass" type="password" value="<?PHP echo base64_decode($cfg['mailpass']);?>" class="regular-text" />
|
75 |
+
</td>
|
76 |
+
</tr>
|
77 |
+
</table>
|
78 |
+
|
79 |
+
<h3><?PHP _e('Logs','backwpup'); ?></h3>
|
80 |
+
<p><?PHP _e('Here you can set Logfile related options.','backwpup'); ?></p>
|
81 |
+
<table class="form-table">
|
82 |
+
<tr valign="top">
|
83 |
+
<th scope="row"><label for="dirlogs"><?PHP _e('Log file Folder','backwpup'); ?></label></th>
|
84 |
+
<td><input name="dirlogs" type="text" id="dirlogs" value="<?PHP echo $cfg['dirlogs'];?>" class="regular-text code" />
|
85 |
+
</td>
|
86 |
+
</tr>
|
87 |
+
<tr valign="top">
|
88 |
+
<th scope="row"><label for="maxlogs"><?PHP _e('Max. Log Files in Folder','backwpup'); ?></label></th>
|
89 |
+
<td><input name="maxlogs" type="text" id="maxlogs" value="<?PHP echo $cfg['maxlogs'];?>" class="small-text code" />
|
90 |
+
<span class="description"><?PHP _e('(Oldest files will deleted first.)','backwpup');?></span>
|
91 |
+
</td>
|
92 |
+
</tr>
|
93 |
+
<tr valign="top">
|
94 |
+
<th scope="row"><?PHP _e('Compression','backwpup'); ?></th>
|
95 |
+
<td><fieldset><legend class="screen-reader-text"><span><?PHP _e('Compression','backwpup'); ?></span></legend><label for="gzlogs">
|
96 |
+
<input name="gzlogs" type="checkbox" id="gzlogs" value="1" <?php checked($cfg['gzlogs'],true); ?><?php if (!function_exists('gzopen')) echo " disabled=\"disabled\""; ?> />
|
97 |
+
<?PHP _e('Gzip Log files!','backwpup'); ?></label>
|
98 |
+
</fieldset></td>
|
99 |
+
</tr>
|
100 |
+
</table>
|
101 |
+
<h3><?PHP _e('Jobs','backwpup'); ?></h3>
|
102 |
+
<p><?PHP _e('Here you can set Job related options.','backwpup'); ?></p>
|
103 |
+
<table class="form-table">
|
104 |
+
<tr valign="top">
|
105 |
+
<th scope="row"><label for="jobstepretry"><?PHP _e('Max. retrys for job steps','backwpup'); ?></label></th>
|
106 |
+
<td><input name="jobstepretry" type="text" id="jobstepretry" value="<?PHP echo $cfg['jobstepretry'];?>" class="small-text code" />
|
107 |
+
</td>
|
108 |
+
</tr>
|
109 |
+
<tr valign="top">
|
110 |
+
<th scope="row"><label for="jobscriptretry"><?PHP _e('Max. retrys for job script retries','backwpup'); ?></label></th>
|
111 |
+
<td><input name="jobscriptretry" type="text" id="jobscriptretry" value="<?PHP echo $cfg['jobscriptretry'];?>" class="small-text code" <?php if (defined('ALTERNATE_WP_CRON') and ALTERNATE_WP_CRON) echo " disabled=\"disabled\""; ?> />
|
112 |
+
</td>
|
113 |
+
</tr>
|
114 |
+
<tr valign="top">
|
115 |
+
<th scope="row"><?PHP _e('PHP zip class','backwpup'); ?></th>
|
116 |
+
<td><fieldset><legend class="screen-reader-text"><span><?PHP _e('PHP zip','backwpup'); ?></span></legend><label for="phpzip">
|
117 |
+
<input name="phpzip" type="checkbox" id="phpzip" value="1" <?php checked($cfg['phpzip'],true); ?><?php if (!class_exists('ZipArchive')) echo " disabled=\"disabled\""; ?> />
|
118 |
+
<?PHP _e('Use PHP zip class if available! Normaly PCL Zip class will used.','backwpup'); ?></label>
|
119 |
+
</fieldset></td>
|
120 |
+
</tr>
|
121 |
+
</table>
|
122 |
+
|
123 |
+
<h3><?PHP _e('WP Admin Bar','backwpup'); ?></h3>
|
124 |
+
<p><?PHP _e('Will you see BackWPup in the WordPress Admin Bar?','backwpup'); ?></p>
|
125 |
+
<table class="form-table">
|
126 |
+
<tr valign="top">
|
127 |
+
<th scope="row"><?PHP _e('Admin Bar','backwpup'); ?></th>
|
128 |
+
<td><fieldset><legend class="screen-reader-text"><span><?PHP _e('Admin Bar','backwpup'); ?></span></legend><label for="showadminbar">
|
129 |
+
<input name="showadminbar" type="checkbox" id="showadminbar" value="1" <?php checked($cfg['showadminbar'],true); ?> />
|
130 |
+
<?PHP _e('Show BackWPup Links in Admin Bar.','backwpup'); ?></label>
|
131 |
+
</fieldset></td>
|
132 |
+
</tr>
|
133 |
+
</table>
|
134 |
+
|
135 |
+
<h3><?PHP _e('Http basic authentication','backwpup'); ?></h3>
|
136 |
+
<p><?PHP _e('Is your blog behind a http basic authentication (.htaccess)? Then you must set the username and password four authentication.','backwpup'); ?></p>
|
137 |
+
<table class="form-table">
|
138 |
+
</tr>
|
139 |
+
<th scope="row"><label for="httpauthuser"><?PHP _e('Username:','backwpup'); ?></label></th>
|
140 |
+
<td><input name="httpauthuser" type="text" id="httpauthuser" value="<?PHP echo $cfg['httpauthuser'];?>" class="regular-text" />
|
141 |
+
</td>
|
142 |
+
</tr>
|
143 |
+
<tr valign="top">
|
144 |
+
<th scope="row"><label for="httpauthpassword"><?PHP _e('Password:','backwpup'); ?></label></th>
|
145 |
+
<td><input name="httpauthpassword" type="password" id="httpauthpassword" value="<?PHP echo base64_decode($cfg['httpauthpassword']);?>" class="regular-text" />
|
146 |
+
</tr>
|
147 |
+
</table>
|
148 |
+
|
149 |
+
<h3><?PHP _e('WP-Cron','backwpup'); ?></h3>
|
150 |
+
<p><?PHP _e('If you would use the cron job of your hoster you must point it to the url:','backwpup'); echo ' <i>'.get_option('siteurl').'/wp-cron.php</i>'; ?></p>
|
151 |
+
<table class="form-table">
|
152 |
+
<tr valign="top">
|
153 |
+
<th scope="row"><?PHP _e('Disable WP-Cron','backwpup'); ?></th>
|
154 |
+
<td><fieldset><legend class="screen-reader-text"><span><?PHP _e('Disable WP-Cron','backwpup'); ?></span></legend><label for="disablewpcron">
|
155 |
+
<input name="disablewpcron" type="checkbox" id="disablewpcron" value="1" <?php checked($cfg['disablewpcron'],true); ?> />
|
156 |
+
<?PHP _e('Use your host\'s Cron Job and disable WP-Cron','backwpup'); ?></label>
|
157 |
+
</fieldset></td>
|
158 |
+
</tr>
|
159 |
+
<tr valign="top">
|
160 |
+
<th scope="row"><?PHP _e('Use cron service of backwpup.com','backwpup'); ?></th>
|
161 |
+
<td><fieldset><legend class="screen-reader-text"><span><?PHP _e('Use cron service of backwpup.com','backwpup'); ?></span></legend><label for="apicronservice">
|
162 |
+
<input name="apicronservice" type="checkbox" id="apicronservice" value="1" <?php checked($cfg['apicronservice'],true); ?> />
|
163 |
+
<?PHP _e('If you check this, the job schedule will submited to backwpup.com. Backwpup.com will call your blog wp-cron.php to start. <em>Use this service only if you have not a cron service of your hoster, or a blog that has a few visitors.</em> The cron service can start cron behind a basic authentication, on that the http authentication data will transferd too! Please make a little donation for the plugin if you use this servcie. The service can be removed by me without a massage.','backwpup'); ?><br />
|
164 |
+
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q3QSVRSFXBLSE" target="_new"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" title="PayPal - The safer, easier way to pay online!"></a>
|
165 |
+
</label>
|
166 |
+
</fieldset>
|
167 |
+
</td>
|
168 |
+
</table>
|
169 |
+
<p class="submit"><input type="submit" name="submit" id="submit" class="button-primary" value="Save Changes" /></p>
|
170 |
+
</form>
|
171 |
</div>
|
pages/page_backwpuptools.php
CHANGED
@@ -1,122 +1,122 @@
|
|
1 |
-
<?PHP
|
2 |
-
if (!defined('ABSPATH'))
|
3 |
-
die();
|
4 |
-
|
5 |
-
|
6 |
-
echo "<div class=\"wrap\">";
|
7 |
-
screen_icon();
|
8 |
-
echo "<h2>".esc_html( __('BackWPup Tools', 'backwpup'))."</h2>";
|
9 |
-
if (isset($backwpup_message) and !empty($backwpup_message))
|
10 |
-
echo "<div id=\"message\" class=\"updated\"><p>".$backwpup_message."</p></div>";
|
11 |
-
echo "<form id=\"posts-filter\" enctype=\"multipart/form-data\" action=\"".backwpup_admin_url('admin.php')."?page=backwpuptools\" method=\"post\">";
|
12 |
-
wp_nonce_field('backwpup-tools');
|
13 |
-
?>
|
14 |
-
<input type="hidden" name="action" value="update" />
|
15 |
-
<h3><?PHP _e('Database restore','backwpup'); ?></h3>
|
16 |
-
<table class="form-table">
|
17 |
-
<tr valign="top">
|
18 |
-
<th scope="row"><label for="mailsndemail"><?PHP _e('DB Restore','backwpup'); ?></label></th>
|
19 |
-
<td>
|
20 |
-
<?PHP
|
21 |
-
if (isset($_POST['dbrestore']) and $_POST['dbrestore']==__('Restore', 'backwpup') and is_file(trim($_POST['sqlfile']))) {
|
22 |
-
check_admin_referer('backwpup-tools');
|
23 |
-
$sqlfile=trim($_POST['sqlfile']);
|
24 |
-
require(dirname(__FILE__).'/tools/db_restore.php');
|
25 |
-
} else {
|
26 |
-
if ( $dir = @opendir(ABSPATH)) {
|
27 |
-
$sqlfile="";
|
28 |
-
while (($file = readdir( $dir ) ) !== false ) {
|
29 |
-
if (strtolower(substr($file,-4))==".sql") {
|
30 |
-
$sqlfile=$file;
|
31 |
-
break;
|
32 |
-
}
|
33 |
-
}
|
34 |
-
@closedir( $dir );
|
35 |
-
}
|
36 |
-
if (!empty($sqlfile)) {
|
37 |
-
echo __('SQL File to restore:','backwpup').' '.trailingslashit(ABSPATH).$sqlfile."<br />";
|
38 |
-
?>
|
39 |
-
<input type="hidden" class="regular-text" name="sqlfile" id="sqlfile" value="<?PHP echo trailingslashit(ABSPATH).$sqlfile;?>" />
|
40 |
-
<input type="submit" name="dbrestore" class="button-primary" value="<?php _e('Restore', 'backwpup'); ?>" />
|
41 |
-
<?PHP
|
42 |
-
} else {
|
43 |
-
echo __('Copy SQL file to blog root folder to use for a restoring.', 'backwpup')."<br />";
|
44 |
-
}
|
45 |
-
}
|
46 |
-
?>
|
47 |
-
</td>
|
48 |
-
</tr>
|
49 |
-
</table>
|
50 |
-
|
51 |
-
<h3><?PHP _e('Import Jobs settings','backwpup'); ?></h3>
|
52 |
-
<table class="form-table">
|
53 |
-
<tr valign="top">
|
54 |
-
<th scope="row"><label for="importfile"><?php _e('Select file to import:', 'backwpup'); ?></label></th>
|
55 |
-
<td><input name="importfile" type="file" id="importfile" class="regular-text code" />
|
56 |
-
<input type="submit" name="upload" class="button-primary" value="<?php _e('Upload', 'backwpup'); ?>" />
|
57 |
-
</td>
|
58 |
-
</tr>
|
59 |
-
<tr valign="top">
|
60 |
-
<?PHP
|
61 |
-
if (isset($_POST['upload']) and is_uploaded_file($_FILES['importfile']['tmp_name']) and $_POST['upload']==__('Upload', 'backwpup')) {
|
62 |
-
echo "<th scope=\"row\"><label for=\"maxlogs\">".__('Select jobs to import','backwpup')."</label></th><td>";
|
63 |
-
$import=file_get_contents($_FILES['importfile']['tmp_name']);
|
64 |
-
$oldjobs=get_option('backwpup_jobs');
|
65 |
-
foreach ( unserialize($import) as $jobid => $jobvalue ) {
|
66 |
-
echo "<select name=\"importtype[".$jobid."]\" title=\"".__('Import Type', 'backwpup')."\"><option value=\"not\">".__('No Import', 'backwpup')."</option>";
|
67 |
-
if (is_array($oldjobs[$jobid]))
|
68 |
-
echo "<option value=\"over\">".__('Overwrite', 'backwpup')."</option><option value=\"append\">".__('Append', 'backwpup')."</option>";
|
69 |
-
else
|
70 |
-
echo "<option value=\"over\">".__('Import', 'backwpup')."</option>";
|
71 |
-
echo "</select>";
|
72 |
-
echo ' <span class="description">'.$jobid.". ".$jobvalue['name'].'</span><br />';
|
73 |
-
}
|
74 |
-
echo "<input type=\"hidden\" name=\"importfile\" value=\"".urlencode($import)."\" />";
|
75 |
-
echo "<input type=\"submit\" name=\"import\" class=\"button-primary\" value=\"".__('Import', 'backwpup')."\" />";
|
76 |
-
}
|
77 |
-
if (isset($_POST['import']) and $_POST['import']==__('Import', 'backwpup') and !empty($_POST['importfile'])) {
|
78 |
-
echo "<th scope=\"row\"><label for=\"maxlogs\">".__('Import','backwpup')."</label></th><td>";
|
79 |
-
$oldjobs=get_option('backwpup_jobs');
|
80 |
-
$import=unserialize(urldecode($_POST['importfile']));
|
81 |
-
foreach ( $_POST['importtype'] as $id => $type ) {
|
82 |
-
if ($type=='over') {
|
83 |
-
unset($oldjobs[$id]);
|
84 |
-
$oldjobs[$id]=$import[$id];
|
85 |
-
$oldjobs[$id]['activated']=false;
|
86 |
-
$oldjobs[$id]['cronnextrun']='';
|
87 |
-
$oldjobs[$id]['starttime']='';
|
88 |
-
$oldjobs[$id]['logfile']='';
|
89 |
-
$oldjobs[$id]['lastlogfile']='';
|
90 |
-
$oldjobs[$id]['lastrun']='';
|
91 |
-
$oldjobs[$id]['lastruntime']='';
|
92 |
-
$oldjobs[$id]['lastbackupdownloadurl']='';
|
93 |
-
} elseif ($type=='append') {
|
94 |
-
if (is_array($oldjobs)) { //generate a new id for new job
|
95 |
-
$heighestid=0;
|
96 |
-
foreach ($oldjobs as $jobkey => $jobvalue)
|
97 |
-
if ($jobkey>$heighestid) $heighestid=$jobkey;
|
98 |
-
$jobid=$heighestid+1;
|
99 |
-
} else {
|
100 |
-
$jobid=1;
|
101 |
-
}
|
102 |
-
$oldjobs[$jobid]=$import[$id];
|
103 |
-
$oldjobs[$jobid]['activated']=false;
|
104 |
-
$oldjobs[$jobid]['cronnextrun']='';
|
105 |
-
$oldjobs[$jobid]['starttime']='';
|
106 |
-
$oldjobs[$jobid]['logfile']='';
|
107 |
-
$oldjobs[$jobid]['lastlogfile']='';
|
108 |
-
$oldjobs[$jobid]['lastrun']='';
|
109 |
-
$oldjobs[$jobid]['lastruntime']='';
|
110 |
-
$oldjobs[$jobid]['lastbackupdownloadurl']='';
|
111 |
-
}
|
112 |
-
}
|
113 |
-
update_option('backwpup_jobs',$oldjobs);
|
114 |
-
_e('Jobs imported!', 'backwpup');
|
115 |
-
}
|
116 |
-
?>
|
117 |
-
</td>
|
118 |
-
</tr>
|
119 |
-
</table>
|
120 |
-
|
121 |
-
</form>
|
122 |
</div>
|
1 |
+
<?PHP
|
2 |
+
if (!defined('ABSPATH'))
|
3 |
+
die();
|
4 |
+
|
5 |
+
|
6 |
+
echo "<div class=\"wrap\">";
|
7 |
+
screen_icon();
|
8 |
+
echo "<h2>".esc_html( __('BackWPup Tools', 'backwpup'))."</h2>";
|
9 |
+
if (isset($backwpup_message) and !empty($backwpup_message))
|
10 |
+
echo "<div id=\"message\" class=\"updated\"><p>".$backwpup_message."</p></div>";
|
11 |
+
echo "<form id=\"posts-filter\" enctype=\"multipart/form-data\" action=\"".backwpup_admin_url('admin.php')."?page=backwpuptools\" method=\"post\">";
|
12 |
+
wp_nonce_field('backwpup-tools');
|
13 |
+
?>
|
14 |
+
<input type="hidden" name="action" value="update" />
|
15 |
+
<h3><?PHP _e('Database restore','backwpup'); ?></h3>
|
16 |
+
<table class="form-table">
|
17 |
+
<tr valign="top">
|
18 |
+
<th scope="row"><label for="mailsndemail"><?PHP _e('DB Restore','backwpup'); ?></label></th>
|
19 |
+
<td>
|
20 |
+
<?PHP
|
21 |
+
if (isset($_POST['dbrestore']) and $_POST['dbrestore']==__('Restore', 'backwpup') and is_file(trim($_POST['sqlfile']))) {
|
22 |
+
check_admin_referer('backwpup-tools');
|
23 |
+
$sqlfile=trim($_POST['sqlfile']);
|
24 |
+
require(dirname(__FILE__).'/tools/db_restore.php');
|
25 |
+
} else {
|
26 |
+
if ( $dir = @opendir(ABSPATH)) {
|
27 |
+
$sqlfile="";
|
28 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
29 |
+
if (strtolower(substr($file,-4))==".sql") {
|
30 |
+
$sqlfile=$file;
|
31 |
+
break;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
@closedir( $dir );
|
35 |
+
}
|
36 |
+
if (!empty($sqlfile)) {
|
37 |
+
echo __('SQL File to restore:','backwpup').' '.trailingslashit(ABSPATH).$sqlfile."<br />";
|
38 |
+
?>
|
39 |
+
<input type="hidden" class="regular-text" name="sqlfile" id="sqlfile" value="<?PHP echo trailingslashit(ABSPATH).$sqlfile;?>" />
|
40 |
+
<input type="submit" name="dbrestore" class="button-primary" value="<?php _e('Restore', 'backwpup'); ?>" />
|
41 |
+
<?PHP
|
42 |
+
} else {
|
43 |
+
echo __('Copy SQL file to blog root folder to use for a restoring.', 'backwpup')."<br />";
|
44 |
+
}
|
45 |
+
}
|
46 |
+
?>
|
47 |
+
</td>
|
48 |
+
</tr>
|
49 |
+
</table>
|
50 |
+
|
51 |
+
<h3><?PHP _e('Import Jobs settings','backwpup'); ?></h3>
|
52 |
+
<table class="form-table">
|
53 |
+
<tr valign="top">
|
54 |
+
<th scope="row"><label for="importfile"><?php _e('Select file to import:', 'backwpup'); ?></label></th>
|
55 |
+
<td><input name="importfile" type="file" id="importfile" class="regular-text code" />
|
56 |
+
<input type="submit" name="upload" class="button-primary" value="<?php _e('Upload', 'backwpup'); ?>" />
|
57 |
+
</td>
|
58 |
+
</tr>
|
59 |
+
<tr valign="top">
|
60 |
+
<?PHP
|
61 |
+
if (isset($_POST['upload']) and is_uploaded_file($_FILES['importfile']['tmp_name']) and $_POST['upload']==__('Upload', 'backwpup')) {
|
62 |
+
echo "<th scope=\"row\"><label for=\"maxlogs\">".__('Select jobs to import','backwpup')."</label></th><td>";
|
63 |
+
$import=file_get_contents($_FILES['importfile']['tmp_name']);
|
64 |
+
$oldjobs=get_option('backwpup_jobs');
|
65 |
+
foreach ( unserialize($import) as $jobid => $jobvalue ) {
|
66 |
+
echo "<select name=\"importtype[".$jobid."]\" title=\"".__('Import Type', 'backwpup')."\"><option value=\"not\">".__('No Import', 'backwpup')."</option>";
|
67 |
+
if (is_array($oldjobs[$jobid]))
|
68 |
+
echo "<option value=\"over\">".__('Overwrite', 'backwpup')."</option><option value=\"append\">".__('Append', 'backwpup')."</option>";
|
69 |
+
else
|
70 |
+
echo "<option value=\"over\">".__('Import', 'backwpup')."</option>";
|
71 |
+
echo "</select>";
|
72 |
+
echo ' <span class="description">'.$jobid.". ".$jobvalue['name'].'</span><br />';
|
73 |
+
}
|
74 |
+
echo "<input type=\"hidden\" name=\"importfile\" value=\"".urlencode($import)."\" />";
|
75 |
+
echo "<input type=\"submit\" name=\"import\" class=\"button-primary\" value=\"".__('Import', 'backwpup')."\" />";
|
76 |
+
}
|
77 |
+
if (isset($_POST['import']) and $_POST['import']==__('Import', 'backwpup') and !empty($_POST['importfile'])) {
|
78 |
+
echo "<th scope=\"row\"><label for=\"maxlogs\">".__('Import','backwpup')."</label></th><td>";
|
79 |
+
$oldjobs=get_option('backwpup_jobs');
|
80 |
+
$import=unserialize(urldecode($_POST['importfile']));
|
81 |
+
foreach ( $_POST['importtype'] as $id => $type ) {
|
82 |
+
if ($type=='over') {
|
83 |
+
unset($oldjobs[$id]);
|
84 |
+
$oldjobs[$id]=$import[$id];
|
85 |
+
$oldjobs[$id]['activated']=false;
|
86 |
+
$oldjobs[$id]['cronnextrun']='';
|
87 |
+
$oldjobs[$id]['starttime']='';
|
88 |
+
$oldjobs[$id]['logfile']='';
|
89 |
+
$oldjobs[$id]['lastlogfile']='';
|
90 |
+
$oldjobs[$id]['lastrun']='';
|
91 |
+
$oldjobs[$id]['lastruntime']='';
|
92 |
+
$oldjobs[$id]['lastbackupdownloadurl']='';
|
93 |
+
} elseif ($type=='append') {
|
94 |
+
if (is_array($oldjobs)) { //generate a new id for new job
|
95 |
+
$heighestid=0;
|
96 |
+
foreach ($oldjobs as $jobkey => $jobvalue)
|
97 |
+
if ($jobkey>$heighestid) $heighestid=$jobkey;
|
98 |
+
$jobid=$heighestid+1;
|
99 |
+
} else {
|
100 |
+
$jobid=1;
|
101 |
+
}
|
102 |
+
$oldjobs[$jobid]=$import[$id];
|
103 |
+
$oldjobs[$jobid]['activated']=false;
|
104 |
+
$oldjobs[$jobid]['cronnextrun']='';
|
105 |
+
$oldjobs[$jobid]['starttime']='';
|
106 |
+
$oldjobs[$jobid]['logfile']='';
|
107 |
+
$oldjobs[$jobid]['lastlogfile']='';
|
108 |
+
$oldjobs[$jobid]['lastrun']='';
|
109 |
+
$oldjobs[$jobid]['lastruntime']='';
|
110 |
+
$oldjobs[$jobid]['lastbackupdownloadurl']='';
|
111 |
+
}
|
112 |
+
}
|
113 |
+
update_option('backwpup_jobs',$oldjobs);
|
114 |
+
_e('Jobs imported!', 'backwpup');
|
115 |
+
}
|
116 |
+
?>
|
117 |
+
</td>
|
118 |
+
</tr>
|
119 |
+
</table>
|
120 |
+
|
121 |
+
</form>
|
122 |
</div>
|
pages/page_backwpupworking.php
CHANGED
@@ -1,51 +1,50 @@
|
|
1 |
-
<?PHP
|
2 |
-
if (!defined('ABSPATH'))
|
3 |
-
die();
|
4 |
-
|
5 |
-
|
6 |
-
?>
|
7 |
-
<div class="wrap">
|
8 |
-
<?php screen_icon(); ?>
|
9 |
-
<h2><?php echo esc_html( __('BackWPup Working', 'backwpup') ); ?></h2>
|
10 |
-
|
11 |
-
<?php if (isset($backwpup_message) and !empty($backwpup_message)) : ?>
|
12 |
-
<div id="message" class="updated"><p><?php echo $backwpup_message; ?></p></div>
|
13 |
-
<?php endif;
|
14 |
-
if ($infile=backwpup_get_working_file()) {
|
15 |
-
wp_nonce_field('backwpupworking_ajax_nonce', 'backwpupworkingajaxnonce', false );
|
16 |
-
$logfilarray=backwpup_read_logfile(trim($_GET['logfile']));
|
17 |
-
if (isset($_GET['action']) and defined('ALTERNATE_WP_CRON') and ALTERNATE_WP_CRON and $_GET['action']=='runnow') {
|
18 |
-
echo "<input type=\"hidden\" name=\"backwpupworkingajaxurl\" id=\"backwpuprunurl\" value=\"".BACKWPUP_PLUGIN_BASEURL."/job/job_run.php\">";
|
19 |
-
echo "<input type=\"hidden\" name=\"alternate_wp_cron\" id=\"alternate_wp_cron\" value=\"1\">";
|
20 |
-
echo "<input type=\"hidden\" name=\"alternate_wp_cron_nonce\" id=\"alternate_wp_cron_nonce\" value=\"".$infile['WORKING']['NONCE']."\">";
|
21 |
-
}
|
22 |
-
echo "<input type=\"hidden\" name=\"logfile\" id=\"logfile\" value=\"".trim($_GET['logfile'])."\">";
|
23 |
-
echo "<input type=\"hidden\" name=\"
|
24 |
-
echo "<input type=\"hidden\" name=\"
|
25 |
-
echo "<
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
echo "
|
30 |
-
|
31 |
-
$
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
$
|
36 |
-
|
37 |
-
|
38 |
-
echo "<
|
39 |
-
echo "<div>";
|
40 |
-
echo "<div class=\"
|
41 |
-
echo "<div class=\"progressbar\"><div id=\"
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
echo "
|
48 |
-
|
49 |
-
|
50 |
-
?>
|
51 |
</div>
|
1 |
+
<?PHP
|
2 |
+
if (!defined('ABSPATH'))
|
3 |
+
die();
|
4 |
+
|
5 |
+
|
6 |
+
?>
|
7 |
+
<div class="wrap">
|
8 |
+
<?php screen_icon(); ?>
|
9 |
+
<h2><?php echo esc_html( __('BackWPup Working', 'backwpup') ); ?></h2>
|
10 |
+
|
11 |
+
<?php if (isset($backwpup_message) and !empty($backwpup_message)) : ?>
|
12 |
+
<div id="message" class="updated"><p><?php echo $backwpup_message; ?></p></div>
|
13 |
+
<?php endif;
|
14 |
+
if ($infile=backwpup_get_working_file()) {
|
15 |
+
wp_nonce_field('backwpupworking_ajax_nonce', 'backwpupworkingajaxnonce', false );
|
16 |
+
$logfilarray=backwpup_read_logfile(trim($_GET['logfile']));
|
17 |
+
if (isset($_GET['action']) and defined('ALTERNATE_WP_CRON') and ALTERNATE_WP_CRON and $_GET['action']=='runnow') {
|
18 |
+
echo "<input type=\"hidden\" name=\"backwpupworkingajaxurl\" id=\"backwpuprunurl\" value=\"".BACKWPUP_PLUGIN_BASEURL."/job/job_run.php\">";
|
19 |
+
echo "<input type=\"hidden\" name=\"alternate_wp_cron\" id=\"alternate_wp_cron\" value=\"1\">";
|
20 |
+
echo "<input type=\"hidden\" name=\"alternate_wp_cron_nonce\" id=\"alternate_wp_cron_nonce\" value=\"".$infile['WORKING']['NONCE']."\">";
|
21 |
+
}
|
22 |
+
echo "<input type=\"hidden\" name=\"logfile\" id=\"logfile\" value=\"".trim($_GET['logfile'])."\">";
|
23 |
+
echo "<input type=\"hidden\" name=\"logpos\" id=\"logpos\" value=\"".count($logfilarray)."\">";
|
24 |
+
echo "<input type=\"hidden\" name=\"backwpupworkingajaxurl\" id=\"backwpupworkingajaxurl\" value=\"".BACKWPUP_PLUGIN_BASEURL."/job/show_working.php\">";
|
25 |
+
echo "<div id=\"showworking\">";
|
26 |
+
for ($i=0;$i<count($logfilarray);$i++)
|
27 |
+
echo $logfilarray[$i]."\n";
|
28 |
+
echo "</div>";
|
29 |
+
echo "<div id=\"runniginfos\">";
|
30 |
+
$stylewarning=" style=\"display:none;\"";
|
31 |
+
if ($infile['WORKING']['WARNING']>0)
|
32 |
+
$stylewarning="";
|
33 |
+
echo "<span id=\"warningsid\"".$stylewarning.">".__('Warnings:','backwpup')." <span id=\"warnings\">".$infile['WORKING']['WARNING']."</span></span><br/>";
|
34 |
+
$styleerror=" style=\"display:none;\"";
|
35 |
+
if ($infile['WORKING']['ERROR']>0)
|
36 |
+
$styleerror="";
|
37 |
+
echo "<span id=\"errorid\"".$styleerror.">".__('Errors:','backwpup')." <span id=\"errors\">".$infile['WORKING']['ERROR']."</span></span>";
|
38 |
+
echo "<div>";
|
39 |
+
echo "<div class=\"clear\"></div>";
|
40 |
+
echo "<div class=\"progressbar\"><div id=\"progressstep\" style=\"width:".$infile['STEPSPERSENT']."%;\">".$infile['STEPSPERSENT']."%</div></div>";
|
41 |
+
echo "<div class=\"progressbar\"><div id=\"progresssteps\" style=\"width:".$infile['STEPPERSENT']."%;\">".$infile['STEPPERSENT']."%</div></div>";
|
42 |
+
} elseif (is_file(trim($_GET['logfile']))) {
|
43 |
+
echo '<div id="showlogfile">';
|
44 |
+
foreach (backwpup_read_logfile(trim($_GET['logfile'])) as $line)
|
45 |
+
echo $line."\n";
|
46 |
+
echo "</div>";
|
47 |
+
echo "<div class=\"clear\"></div>";
|
48 |
+
}
|
49 |
+
?>
|
|
|
50 |
</div>
|
pages/tools/db_restore.php
CHANGED
@@ -1,97 +1,92 @@
|
|
1 |
-
<?PHP
|
2 |
-
if (!defined('ABSPATH')) {
|
3 |
-
die();
|
4 |
-
}
|
5 |
-
|
6 |
-
global $wpdb;
|
7 |
-
|
8 |
-
ignore_user_abort(true);
|
9 |
-
$cfg=get_option('backwpup'); //Load Settings
|
10 |
-
@set_time_limit($cfg['jobscriptruntimelong']); //300 is most webserver time limit.
|
11 |
-
|
12 |
-
//Vars
|
13 |
-
$oldblogabspath="";
|
14 |
-
$oldblogurl="";
|
15 |
-
$oldtabelprefix="";
|
16 |
-
$numcommands="";
|
17 |
-
if (defined(WP_SITEURL))
|
18 |
-
$blogurl=trailingslashit(WP_SITEURL);
|
19 |
-
else
|
20 |
-
$blogurl=trailingslashit(get_option('siteurl'));
|
21 |
-
$blogabspath=trailingslashit(ABSPATH);
|
22 |
-
|
23 |
-
$file = fopen ($sqlfile, "r");
|
24 |
-
while (!feof($file)){
|
25 |
-
$line = trim(fgets($file));
|
26 |
-
|
27 |
-
if (substr($line,0,12)=="-- Blog URL:")
|
28 |
-
$oldblogurl=trim(substr($line,13));
|
29 |
-
if (substr($line,0,16)=="-- Blog ABSPATH:")
|
30 |
-
$oldblogabspath=trim(substr($line,17));
|
31 |
-
if (substr($line,0,16)=="-- Table Prefix:") {
|
32 |
-
$oldtabelprefix=trim(substr($line,17));
|
33 |
-
if ($oldtabelprefix!=$wpdb->prefix and !empty($oldtabelprefix)) {
|
34 |
-
echo __('ERROR:','backwpup').' '.sprintf(__('Pleace set <i>$table_prefix = \'%1$s\';</i> in wp-config.php','backwpup'), $oldtabelprefix)."<br />\n";
|
35 |
-
break;
|
36 |
-
}
|
37 |
-
}
|
38 |
-
if (substr($line,0,2)=="--" or empty($line))
|
39 |
-
continue;
|
40 |
-
|
41 |
-
$line=str_replace("/*!40000","", $line);
|
42 |
-
$line=str_replace("/*!40101","", $line);
|
43 |
-
$line=str_replace("/*!40103","", $line);
|
44 |
-
$line=str_replace("/*!40014","", $line);
|
45 |
-
$line=str_replace("/*!40111","", $line);
|
46 |
-
$line=str_replace("*/;",";", trim($line));
|
47 |
-
|
48 |
-
if (substr($line,0,9)=="SET NAMES") {
|
49 |
-
$chrset=trim(str_replace("'","",substr($line,10,-1)));
|
50 |
-
if (function_exists("mysql_set_charset"))
|
51 |
-
mysql_set_charset($chrset);
|
52 |
-
if ((defined('DB_CHARSET') and $chrset!=DB_CHARSET) or ($chrset!=mysql_client_encoding())) {
|
53 |
-
echo __('ERROR:','backwpup').' '.sprintf(__('Pleace set <i>define(\'DB_CHARSET\', \'%1$s\');</i> in wp-config.php','backwpup'), $chrset)."<br />\n";
|
54 |
-
break;
|
55 |
-
}
|
56 |
-
}
|
57 |
-
|
58 |
-
$command="";
|
59 |
-
if (";"==substr($line,-1)) {
|
60 |
-
$command=$rest.$line;
|
61 |
-
$rest="";
|
62 |
-
} else {
|
63 |
-
$rest.=$line;
|
64 |
-
}
|
65 |
-
if (!empty($command)) {
|
66 |
-
$result=mysql_query($command);
|
67 |
-
if ($sqlerr=mysql_error($wpdb->dbh)) {
|
68 |
-
echo __('ERROR:','backwpup').' '.sprintf(__('BackWPup database error %1$s for query %2$s','backwpup'), $sqlerr, $command)."<br />\n";
|
69 |
-
}
|
70 |
-
$numcommands++;
|
71 |
-
}
|
72 |
-
}
|
73 |
-
fclose($file);
|
74 |
-
echo sprintf(__('%1$s Database Querys done.','backwpup'),$numcommands).'<br />';
|
75 |
-
echo __('Make changes for Blogurl and ABSPATH if needed.','backwpup')."<br />";
|
76 |
-
if (!empty($oldblogurl) and $oldblogurl!=$blogurl) {
|
77 |
-
mysql_query("UPDATE ".$wpdb->prefix."options SET option_value = replace(option_value, '".untrailingslashit($oldblogurl)."', '".untrailingslashit($blogurl)."');");
|
78 |
-
if ($sqlerr=mysql_error())
|
79 |
-
echo __('ERROR:','backwpup').' '.sprintf(__('BackWPup database error %1$s for query %2$s','backwpup'), $sqlerr, "UPDATE ".$wpdb->prefix."options SET option_value = replace(option_value, '".untrailingslashit($oldblogurl)."', '".untrailingslashit($blogurl)."');")."<br />\n";
|
80 |
-
mysql_query("UPDATE ".$wpdb->prefix."posts SET guid = replace(guid, '".untrailingslashit($oldblogurl)."','".untrailingslashit($blogurl)."');");
|
81 |
-
if ($sqlerr=mysql_error())
|
82 |
-
echo __('ERROR:','backwpup').' '.sprintf(__('BackWPup database error %1$s for query %2$s','backwpup'), $sqlerr, "UPDATE ".$wpdb->prefix."posts SET guid = replace(guid, '".untrailingslashit($oldblogurl)."','".untrailingslashit($blogurl)."');")."<br />\n";
|
83 |
-
mysql_query("UPDATE ".$wpdb->prefix."posts SET post_content = replace(post_content, '".untrailingslashit($oldblogurl)."', '".untrailingslashit($blogurl)."');");
|
84 |
-
if ($sqlerr=mysql_error())
|
85 |
-
echo __('ERROR:','backwpup').' '.sprintf(__('BackWPup database error %1$s for query %2$s','backwpup'), $sqlerr, "UPDATE ".$wpdb->prefix."posts SET post_content = replace(post_content, '".untrailingslashit($oldblogurl)."', '".untrailingslashit($blogurl)."');")."<br />\n";
|
86 |
-
}
|
87 |
-
if (!empty($oldblogabspath) and $oldblogabspath!=$blogabspath) {
|
88 |
-
mysql_query("UPDATE ".$wpdb->prefix."options SET option_value = replace(option_value, '".untrailingslashit($oldblogabspath)."', '".untrailingslashit($blogabspath)."');");
|
89 |
-
if ($sqlerr=mysql_error())
|
90 |
-
echo __('ERROR:','backwpup').' '.sprintf(__('BackWPup database error %1$s for query %2$s','backwpup'), $sqlerr, "UPDATE ".$wpdb->prefix."options SET option_value = replace(option_value, '".untrailingslashit($oldblogabspath)."', '".untrailingslashit($blogabspath)."');")."<br />\n";
|
91 |
-
}
|
92 |
-
echo __('Restore Done. Please delete the SQL file after restoring.','backwpup')."<br />";
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
if (!defined('ABSPATH')) {
|
3 |
+
die();
|
4 |
+
}
|
5 |
+
|
6 |
+
global $wpdb;
|
7 |
+
|
8 |
+
ignore_user_abort(true);
|
9 |
+
$cfg=get_option('backwpup'); //Load Settings
|
10 |
+
@set_time_limit($cfg['jobscriptruntimelong']); //300 is most webserver time limit.
|
11 |
+
|
12 |
+
//Vars
|
13 |
+
$oldblogabspath="";
|
14 |
+
$oldblogurl="";
|
15 |
+
$oldtabelprefix="";
|
16 |
+
$numcommands="";
|
17 |
+
if (defined(WP_SITEURL))
|
18 |
+
$blogurl=trailingslashit(WP_SITEURL);
|
19 |
+
else
|
20 |
+
$blogurl=trailingslashit(get_option('siteurl'));
|
21 |
+
$blogabspath=trailingslashit(ABSPATH);
|
22 |
+
|
23 |
+
$file = fopen ($sqlfile, "r");
|
24 |
+
while (!feof($file)){
|
25 |
+
$line = trim(fgets($file));
|
26 |
+
|
27 |
+
if (substr($line,0,12)=="-- Blog URL:")
|
28 |
+
$oldblogurl=trim(substr($line,13));
|
29 |
+
if (substr($line,0,16)=="-- Blog ABSPATH:")
|
30 |
+
$oldblogabspath=trim(substr($line,17));
|
31 |
+
if (substr($line,0,16)=="-- Table Prefix:") {
|
32 |
+
$oldtabelprefix=trim(substr($line,17));
|
33 |
+
if ($oldtabelprefix!=$wpdb->prefix and !empty($oldtabelprefix)) {
|
34 |
+
echo __('ERROR:','backwpup').' '.sprintf(__('Pleace set <i>$table_prefix = \'%1$s\';</i> in wp-config.php','backwpup'), $oldtabelprefix)."<br />\n";
|
35 |
+
break;
|
36 |
+
}
|
37 |
+
}
|
38 |
+
if (substr($line,0,2)=="--" or empty($line))
|
39 |
+
continue;
|
40 |
+
|
41 |
+
$line=str_replace("/*!40000","", $line);
|
42 |
+
$line=str_replace("/*!40101","", $line);
|
43 |
+
$line=str_replace("/*!40103","", $line);
|
44 |
+
$line=str_replace("/*!40014","", $line);
|
45 |
+
$line=str_replace("/*!40111","", $line);
|
46 |
+
$line=str_replace("*/;",";", trim($line));
|
47 |
+
|
48 |
+
if (substr($line,0,9)=="SET NAMES") {
|
49 |
+
$chrset=trim(str_replace("'","",substr($line,10,-1)));
|
50 |
+
if (function_exists("mysql_set_charset"))
|
51 |
+
mysql_set_charset($chrset);
|
52 |
+
if ((defined('DB_CHARSET') and $chrset!=DB_CHARSET) or ($chrset!=mysql_client_encoding())) {
|
53 |
+
echo __('ERROR:','backwpup').' '.sprintf(__('Pleace set <i>define(\'DB_CHARSET\', \'%1$s\');</i> in wp-config.php','backwpup'), $chrset)."<br />\n";
|
54 |
+
break;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
$command="";
|
59 |
+
if (";"==substr($line,-1)) {
|
60 |
+
$command=$rest.$line;
|
61 |
+
$rest="";
|
62 |
+
} else {
|
63 |
+
$rest.=$line;
|
64 |
+
}
|
65 |
+
if (!empty($command)) {
|
66 |
+
$result=mysql_query($command);
|
67 |
+
if ($sqlerr=mysql_error($wpdb->dbh)) {
|
68 |
+
echo __('ERROR:','backwpup').' '.sprintf(__('BackWPup database error %1$s for query %2$s','backwpup'), $sqlerr, $command)."<br />\n";
|
69 |
+
}
|
70 |
+
$numcommands++;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
fclose($file);
|
74 |
+
echo sprintf(__('%1$s Database Querys done.','backwpup'),$numcommands).'<br />';
|
75 |
+
echo __('Make changes for Blogurl and ABSPATH if needed.','backwpup')."<br />";
|
76 |
+
if (!empty($oldblogurl) and $oldblogurl!=$blogurl) {
|
77 |
+
mysql_query("UPDATE ".$wpdb->prefix."options SET option_value = replace(option_value, '".untrailingslashit($oldblogurl)."', '".untrailingslashit($blogurl)."');");
|
78 |
+
if ($sqlerr=mysql_error())
|
79 |
+
echo __('ERROR:','backwpup').' '.sprintf(__('BackWPup database error %1$s for query %2$s','backwpup'), $sqlerr, "UPDATE ".$wpdb->prefix."options SET option_value = replace(option_value, '".untrailingslashit($oldblogurl)."', '".untrailingslashit($blogurl)."');")."<br />\n";
|
80 |
+
mysql_query("UPDATE ".$wpdb->prefix."posts SET guid = replace(guid, '".untrailingslashit($oldblogurl)."','".untrailingslashit($blogurl)."');");
|
81 |
+
if ($sqlerr=mysql_error())
|
82 |
+
echo __('ERROR:','backwpup').' '.sprintf(__('BackWPup database error %1$s for query %2$s','backwpup'), $sqlerr, "UPDATE ".$wpdb->prefix."posts SET guid = replace(guid, '".untrailingslashit($oldblogurl)."','".untrailingslashit($blogurl)."');")."<br />\n";
|
83 |
+
mysql_query("UPDATE ".$wpdb->prefix."posts SET post_content = replace(post_content, '".untrailingslashit($oldblogurl)."', '".untrailingslashit($blogurl)."');");
|
84 |
+
if ($sqlerr=mysql_error())
|
85 |
+
echo __('ERROR:','backwpup').' '.sprintf(__('BackWPup database error %1$s for query %2$s','backwpup'), $sqlerr, "UPDATE ".$wpdb->prefix."posts SET post_content = replace(post_content, '".untrailingslashit($oldblogurl)."', '".untrailingslashit($blogurl)."');")."<br />\n";
|
86 |
+
}
|
87 |
+
if (!empty($oldblogabspath) and $oldblogabspath!=$blogabspath) {
|
88 |
+
mysql_query("UPDATE ".$wpdb->prefix."options SET option_value = replace(option_value, '".untrailingslashit($oldblogabspath)."', '".untrailingslashit($blogabspath)."');");
|
89 |
+
if ($sqlerr=mysql_error())
|
90 |
+
echo __('ERROR:','backwpup').' '.sprintf(__('BackWPup database error %1$s for query %2$s','backwpup'), $sqlerr, "UPDATE ".$wpdb->prefix."options SET option_value = replace(option_value, '".untrailingslashit($oldblogabspath)."', '".untrailingslashit($blogabspath)."');")."<br />\n";
|
91 |
+
}
|
92 |
+
echo __('Restore Done. Please delete the SQL file after restoring.','backwpup')."<br />";
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -1,477 +1,486 @@
|
|
1 |
-
=== BackWPup ===
|
2 |
-
Contributors: danielhuesken
|
3 |
-
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q3QSVRSFXBLSE
|
4 |
-
Tags: backup, database, file, ftp, xml, time, upload, multisite, cloud, dropbox, storage, amazon
|
5 |
-
Requires at least: 3.1
|
6 |
-
Tested up to: 3.4
|
7 |
-
Stable tag: 2.1.
|
8 |
-
License: GPLv2
|
9 |
-
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
-
|
11 |
-
WordPress Backup and more...
|
12 |
-
|
13 |
-
== Description ==
|
14 |
-
|
15 |
-
Do backups and more for your WordPress Blog.
|
16 |
-
|
17 |
-
* Database Backup
|
18 |
-
* WordPress XML Export
|
19 |
-
* Optimize Database
|
20 |
-
* Check\Repair Database
|
21 |
-
* File Backup
|
22 |
-
* Backups in zip, tar, tar.gz, tar.bz2 format
|
23 |
-
* Store backup to Folder
|
24 |
-
* Store backup to FTP Server
|
25 |
-
* Store backup to Amazon S3
|
26 |
-
* Store backup to Google Storage
|
27 |
-
* Store backup to Microsoft Azure (Blob)
|
28 |
-
* Store backup to RackSpaceCloud
|
29 |
-
* Store backup to Dropbox
|
30 |
-
* Store backup to SugarSync
|
31 |
-
* Send Log/Backup by Email
|
32 |
-
* Multisite Support only as Network Admin
|
33 |
-
|
34 |
-
** WP 3.1 and PHP 5.2.5 Required!! **
|
35 |
-
|
36 |
-
** NO WARRANTY SUPPLIED! **
|
37 |
-
** Test your Backups! **
|
38 |
-
|
39 |
-
== Installation ==
|
40 |
-
|
41 |
-
1. Download BackWPup Plugin.
|
42 |
-
2. Decompress and upload the contents of the archive into /wp-content/plugins/.
|
43 |
-
3. Activate the Plugin through the 'Plugins' menu in WordPress
|
44 |
-
|
45 |
-
== Frequently Asked Questions ==
|
46 |
-
= EN =
|
47 |
-
* FAQ: http://backwpup.com/faq
|
48 |
-
* Manual: http://backwpup.com/manual
|
49 |
-
* Support: http://backwpup.com/forums
|
50 |
-
|
51 |
-
= DE =
|
52 |
-
* FAQ: http://backwpup.de/faq
|
53 |
-
* Manual: http://backwpup.de/manual
|
54 |
-
* Support: http://backwpup.de/forums
|
55 |
-
|
56 |
-
== Screenshots ==
|
57 |
-
1. Job Page
|
58 |
-
2. Working Job
|
59 |
-
3. Logs Page
|
60 |
-
4. Backups Manage Page
|
61 |
-
|
62 |
-
== Changelog ==
|
63 |
-
= 2.1.
|
64 |
-
*
|
65 |
-
*
|
66 |
-
*
|
67 |
-
|
68 |
-
|
69 |
-
*
|
70 |
-
*
|
71 |
-
|
72 |
-
|
73 |
-
*
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
*
|
81 |
-
*
|
82 |
-
*
|
83 |
-
|
84 |
-
|
85 |
-
*
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
*
|
90 |
-
*
|
91 |
-
*
|
92 |
-
|
93 |
-
|
94 |
-
*
|
95 |
-
|
96 |
-
|
97 |
-
*
|
98 |
-
|
99 |
-
|
100 |
-
*
|
101 |
-
|
102 |
-
|
103 |
-
*
|
104 |
-
|
105 |
-
|
106 |
-
*
|
107 |
-
|
108 |
-
|
109 |
-
*
|
110 |
-
*
|
111 |
-
*
|
112 |
-
*
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
*
|
117 |
-
*
|
118 |
-
*
|
119 |
-
*
|
120 |
-
*
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
*
|
127 |
-
*
|
128 |
-
*
|
129 |
-
*
|
130 |
-
|
131 |
-
|
132 |
-
*
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
*
|
137 |
-
*
|
138 |
-
*
|
139 |
-
*
|
140 |
-
*
|
141 |
-
*
|
142 |
-
*
|
143 |
-
|
144 |
-
|
145 |
-
*
|
146 |
-
*
|
147 |
-
|
148 |
-
|
149 |
-
*
|
150 |
-
*
|
151 |
-
*
|
152 |
-
*
|
153 |
-
*
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
*
|
159 |
-
*
|
160 |
-
|
161 |
-
|
162 |
-
*
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
*
|
167 |
-
*
|
168 |
-
*
|
169 |
-
|
170 |
-
|
171 |
-
*
|
172 |
-
*
|
173 |
-
|
174 |
-
|
175 |
-
*
|
176 |
-
|
177 |
-
|
178 |
-
* Updated AWS
|
179 |
-
*
|
180 |
-
*
|
181 |
-
*
|
182 |
-
*
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
*
|
189 |
-
|
190 |
-
|
191 |
-
*
|
192 |
-
|
193 |
-
= 1.7.
|
194 |
-
*
|
195 |
-
|
196 |
-
|
197 |
-
*
|
198 |
-
|
199 |
-
= 1.7.
|
200 |
-
*
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
*
|
206 |
-
*
|
207 |
-
|
208 |
-
|
209 |
-
*
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
*
|
215 |
-
|
216 |
-
|
217 |
-
*
|
218 |
-
*
|
219 |
-
|
220 |
-
|
221 |
-
*
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
*
|
228 |
-
*
|
229 |
-
*
|
230 |
-
*
|
231 |
-
|
232 |
-
|
233 |
-
*
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
*
|
239 |
-
*
|
240 |
-
*
|
241 |
-
*
|
242 |
-
|
243 |
-
|
244 |
-
*
|
245 |
-
|
246 |
-
|
247 |
-
*
|
248 |
-
|
249 |
-
|
250 |
-
*
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
*
|
255 |
-
*
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
*
|
260 |
-
*
|
261 |
-
|
262 |
-
|
263 |
-
*
|
264 |
-
*
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
*
|
269 |
-
*
|
270 |
-
*
|
271 |
-
|
272 |
-
|
273 |
-
*
|
274 |
-
*
|
275 |
-
|
276 |
-
= 1.
|
277 |
-
*
|
278 |
-
*
|
279 |
-
*
|
280 |
-
|
281 |
-
|
282 |
-
*
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
*
|
287 |
-
*
|
288 |
-
|
289 |
-
|
290 |
-
*
|
291 |
-
*
|
292 |
-
|
293 |
-
= 1.3.
|
294 |
-
* fixed
|
295 |
-
*
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
*
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
*
|
304 |
-
* fixed bug
|
305 |
-
|
306 |
-
|
307 |
-
*
|
308 |
-
*
|
309 |
-
|
310 |
-
= 1.3.
|
311 |
-
* added
|
312 |
-
*
|
313 |
-
*
|
314 |
-
*
|
315 |
-
*
|
316 |
-
*
|
317 |
-
* added
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
*
|
323 |
-
*
|
324 |
-
*
|
325 |
-
|
326 |
-
|
327 |
-
*
|
328 |
-
*
|
329 |
-
|
330 |
-
|
331 |
-
*
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
* added
|
339 |
-
*
|
340 |
-
*
|
341 |
-
|
342 |
-
|
343 |
-
*
|
344 |
-
*
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
*
|
349 |
-
|
350 |
-
|
351 |
-
*
|
352 |
-
*
|
353 |
-
*
|
354 |
-
*
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
*
|
361 |
-
|
362 |
-
|
363 |
-
*
|
364 |
-
*
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
*
|
369 |
-
* removed
|
370 |
-
|
371 |
-
= 1.0.
|
372 |
-
*
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
*
|
386 |
-
|
387 |
-
= 1.0.
|
388 |
-
*
|
389 |
-
|
390 |
-
|
391 |
-
*
|
392 |
-
|
393 |
-
|
394 |
-
*
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
*
|
400 |
-
*
|
401 |
-
|
402 |
-
|
403 |
-
*
|
404 |
-
*
|
405 |
-
*
|
406 |
-
|
407 |
-
|
408 |
-
*
|
409 |
-
*
|
410 |
-
|
411 |
-
|
412 |
-
*
|
413 |
-
*
|
414 |
-
|
415 |
-
|
416 |
-
*
|
417 |
-
*
|
418 |
-
*
|
419 |
-
|
420 |
-
|
421 |
-
*
|
422 |
-
*
|
423 |
-
|
424 |
-
= 0.7.
|
425 |
-
*
|
426 |
-
*
|
427 |
-
*
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
*
|
435 |
-
*
|
436 |
-
*
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
*
|
442 |
-
*
|
443 |
-
*
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
*
|
449 |
-
*
|
450 |
-
*
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
*
|
456 |
-
*
|
457 |
-
|
458 |
-
|
459 |
-
*
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
*
|
465 |
-
*
|
466 |
-
|
467 |
-
|
468 |
-
*
|
469 |
-
* Optimize
|
470 |
-
*
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
*
|
475 |
-
|
476 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
477 |
* Initial release
|
1 |
+
=== BackWPup ===
|
2 |
+
Contributors: danielhuesken
|
3 |
+
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q3QSVRSFXBLSE
|
4 |
+
Tags: backup, database, file, ftp, xml, time, upload, multisite, cloud, dropbox, storage, amazon
|
5 |
+
Requires at least: 3.1
|
6 |
+
Tested up to: 3.4
|
7 |
+
Stable tag: 2.1.12
|
8 |
+
License: GPLv2
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
|
11 |
+
WordPress Backup and more...
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
Do backups and more for your WordPress Blog.
|
16 |
+
|
17 |
+
* Database Backup
|
18 |
+
* WordPress XML Export
|
19 |
+
* Optimize Database
|
20 |
+
* Check\Repair Database
|
21 |
+
* File Backup
|
22 |
+
* Backups in zip, tar, tar.gz, tar.bz2 format
|
23 |
+
* Store backup to Folder
|
24 |
+
* Store backup to FTP Server
|
25 |
+
* Store backup to Amazon S3
|
26 |
+
* Store backup to Google Storage
|
27 |
+
* Store backup to Microsoft Azure (Blob)
|
28 |
+
* Store backup to RackSpaceCloud
|
29 |
+
* Store backup to Dropbox
|
30 |
+
* Store backup to SugarSync
|
31 |
+
* Send Log/Backup by Email
|
32 |
+
* Multisite Support only as Network Admin
|
33 |
+
|
34 |
+
** WP 3.1 and PHP 5.2.5 Required!! **
|
35 |
+
|
36 |
+
** NO WARRANTY SUPPLIED! **
|
37 |
+
** Test your Backups! **
|
38 |
+
|
39 |
+
== Installation ==
|
40 |
+
|
41 |
+
1. Download BackWPup Plugin.
|
42 |
+
2. Decompress and upload the contents of the archive into /wp-content/plugins/.
|
43 |
+
3. Activate the Plugin through the 'Plugins' menu in WordPress
|
44 |
+
|
45 |
+
== Frequently Asked Questions ==
|
46 |
+
= EN =
|
47 |
+
* FAQ: http://backwpup.com/faq
|
48 |
+
* Manual: http://backwpup.com/manual
|
49 |
+
* Support: http://backwpup.com/forums
|
50 |
+
|
51 |
+
= DE =
|
52 |
+
* FAQ: http://backwpup.de/faq
|
53 |
+
* Manual: http://backwpup.de/manual
|
54 |
+
* Support: http://backwpup.de/forums
|
55 |
+
|
56 |
+
== Screenshots ==
|
57 |
+
1. Job Page
|
58 |
+
2. Working Job
|
59 |
+
3. Logs Page
|
60 |
+
4. Backups Manage Page
|
61 |
+
|
62 |
+
== Changelog ==
|
63 |
+
= 2.1.12 =
|
64 |
+
* always check existing .htaccess in log/temp/backup folder
|
65 |
+
* set tmp folder to plugindir/tmp
|
66 |
+
* removed input_filter function
|
67 |
+
* fixed problem with mb_string funktion on job start
|
68 |
+
* reduced needed memory for FTP upload.
|
69 |
+
* Updated Google Storage Url's
|
70 |
+
* Updated AWS lib to 1.5.8.1
|
71 |
+
|
72 |
+
= 2.1.11 =
|
73 |
+
* fixed bug in contextual help
|
74 |
+
* Updated AWS lib to 1.5.6
|
75 |
+
* changes for WordPress 3.4
|
76 |
+
|
77 |
+
= 2.1.10 =
|
78 |
+
* typo fix
|
79 |
+
* add robots noindex,nofollow in log header
|
80 |
+
* trigger job start errors
|
81 |
+
* Updated AWS lib to 1.5.3
|
82 |
+
* added support for help functions
|
83 |
+
|
84 |
+
= 2.1.9 =
|
85 |
+
* bypass Google Analytics by Yoast oauth
|
86 |
+
* improved working displaying
|
87 |
+
|
88 |
+
= 2.1.8 =
|
89 |
+
* Updated AWS lib to 1.5.2
|
90 |
+
* Security improvements
|
91 |
+
* Updated MS Azure to 4.1.0
|
92 |
+
* Updated RSC lib to 1.7.10
|
93 |
+
* Updatet oAuth lib for Dropbox
|
94 |
+
* increased memory on db dump
|
95 |
+
|
96 |
+
= 2.1.7 =
|
97 |
+
* New Logo
|
98 |
+
* Fixed not displayed save button
|
99 |
+
* Updated AWS lib to 1.5.0
|
100 |
+
* some tweaks
|
101 |
+
|
102 |
+
= 2.1.6 =
|
103 |
+
* fixed Dropbox with no path problem
|
104 |
+
* fixed Dropbox path with witespace
|
105 |
+
* Updated AWS lib to 1.4.5
|
106 |
+
* 2. fix for security vulnerability
|
107 |
+
|
108 |
+
= 2.1.5 =
|
109 |
+
* Updated AWS lib to 1.4.4
|
110 |
+
* use my own dropbox lib again and chaned it to new api
|
111 |
+
* Fixed security vulnerability
|
112 |
+
* some littel fixes
|
113 |
+
|
114 |
+
= 2.1.4 =
|
115 |
+
* correct some values on job copy/export
|
116 |
+
* fixed warning on dropbox upload.
|
117 |
+
* WP cron Job only set is a job activated
|
118 |
+
* now a manualy job starts with ajax is 'define('ALTERNATE_WP_CRON', true);'
|
119 |
+
* removed runtime settings
|
120 |
+
* send log mails with full text
|
121 |
+
* added aditional checks for job running
|
122 |
+
* Updated AWS lib to 1.4.0.1
|
123 |
+
|
124 |
+
= 2.1.3 =
|
125 |
+
* Preformance improvment
|
126 |
+
* Uses now dropbox-php.com lib (ver. 0.4.2)
|
127 |
+
* Updated AWS lib to 1.4.0
|
128 |
+
* changed Plugin activation function, because on update or upload activate is not called
|
129 |
+
* bug fixes
|
130 |
+
|
131 |
+
= 2.1.2 =
|
132 |
+
* removed http class, makes to many problems
|
133 |
+
|
134 |
+
= 2.1.1 =
|
135 |
+
* Fiexd problem with translation
|
136 |
+
* Don't display dashboard Wigets on Mulitsite for not super amdins
|
137 |
+
* Some improvements for Multisite
|
138 |
+
* Updated AWS lib to 1.3.7
|
139 |
+
* Google Storage uses now AWS lib
|
140 |
+
* Added http basic autentication support
|
141 |
+
* now DB jobs uses new not selected tabels too
|
142 |
+
* bug fixes
|
143 |
+
|
144 |
+
= 2.1.0 =
|
145 |
+
* No more sessions and curl needed
|
146 |
+
* Respect open_basdir for temp folder
|
147 |
+
* Dropbox changes, better uploads, but needs many memory
|
148 |
+
* Added Multiseite support (only for Network Admin)
|
149 |
+
* Uses now �WP_TEMP_DIR� for getting temp folder
|
150 |
+
* Updated AWS lib to 1.3.6
|
151 |
+
* Job runs now in UTC time. Time outputs will convert.
|
152 |
+
* Many languge strings changed for better translation
|
153 |
+
* Fixed double job run in same time
|
154 |
+
* Removed cache prevention for cron to resolve problems with W3 Total Cache
|
155 |
+
* Readded Support for WordPress 3.1
|
156 |
+
|
157 |
+
= 2.0.3 =
|
158 |
+
* Reimplemt deletion of backups in a folder
|
159 |
+
* Hopfuly fix of 'temp is not writeable'
|
160 |
+
* Fixed 'Black Screen'
|
161 |
+
* more error output on XML export
|
162 |
+
* satus on pcl zip create is back and use off the wordpress class
|
163 |
+
|
164 |
+
= 2.0.2 =
|
165 |
+
* fixed bug Class 'ZipArchive' not found now
|
166 |
+
* ficed bug in chnge logfile folder
|
167 |
+
* replase spaces bei _ in dropboxfolder
|
168 |
+
* some more bug fixes
|
169 |
+
|
170 |
+
= 2.0.1 =
|
171 |
+
* Zip file creation now faster agin but no stat output
|
172 |
+
* serverl bug fixes
|
173 |
+
|
174 |
+
= 2.0.0 =
|
175 |
+
* PHP Sessions, curl and PHP version 5.2.4 required!
|
176 |
+
* Wordpress 3.2 required!
|
177 |
+
* Using the system temp dir now
|
178 |
+
* Updated AWS lib to 1.3.5
|
179 |
+
* Updated RSC lib to 1.7.9
|
180 |
+
* Updated MS Azure lib to 3.0.0
|
181 |
+
* Added Google storage as destination
|
182 |
+
* Reworked GUI (WordPress Dropboxes, working screen options, ....)
|
183 |
+
* Complete new job working ot of Wordpress (less memory,automatic restart,...)
|
184 |
+
* Added easyer job sheduling selection
|
185 |
+
|
186 |
+
= 1.7.8 =
|
187 |
+
* Updated AWS SDK to ver.1.3.5 for Amazon S3
|
188 |
+
* some extra outputs on job start
|
189 |
+
* resart Script execution time on many job operations.
|
190 |
+
* some changes too prevent cache addons
|
191 |
+
* prevent job run twice on same time on background
|
192 |
+
|
193 |
+
= 1.7.7 =
|
194 |
+
* cleanup brocken buckupfiels on job start
|
195 |
+
|
196 |
+
= 1.7.6 =
|
197 |
+
* fix problem with a losing sql connection on job end
|
198 |
+
|
199 |
+
= 1.7.5 =
|
200 |
+
* fix problems in cron calculation
|
201 |
+
|
202 |
+
= 1.7.4 =
|
203 |
+
* jobs not longer work ever... max. time is 5 min.
|
204 |
+
* hopfuly fix for dropbox upload
|
205 |
+
* fix dropbox auth deletion
|
206 |
+
* fixed bug in Sugarsync qouta
|
207 |
+
|
208 |
+
= 1.7.3 =
|
209 |
+
* Fixed Dropbox PLAINTEXT signatre
|
210 |
+
* Updated pod
|
211 |
+
* Added/updated German translation (thx David Decker)
|
212 |
+
|
213 |
+
= 1.7.2 =
|
214 |
+
* try to disable Cache plugins for working job
|
215 |
+
* more dropbox improvements
|
216 |
+
* fixed Curl error on WP-Export
|
217 |
+
* fixed dashbord wigedt shown for all users
|
218 |
+
* bug fixes
|
219 |
+
|
220 |
+
= 1.7.1 =
|
221 |
+
* Bugfix on make new jobs
|
222 |
+
* Bugfix on job run with dbdump
|
223 |
+
* Bugfix on Backup Bulk actions
|
224 |
+
|
225 |
+
= 1.7.0 =
|
226 |
+
* Improved Dropbox referer handling
|
227 |
+
* Sycurity fix (thanks to Phil Taylor - Sense of Security)
|
228 |
+
* Added SugarSync support
|
229 |
+
* general improvements
|
230 |
+
* bug fixes
|
231 |
+
|
232 |
+
= 1.6.2 =
|
233 |
+
* Dropbox improvements and bug fixes
|
234 |
+
|
235 |
+
= 1.6.1 =
|
236 |
+
* Now use web OAuth login for DropBox! Best thanks to Tijs Verkoyen for his great DropBox class.
|
237 |
+
* Only DropBox OAuth tokens are saved!
|
238 |
+
* Check DropBox Quota/Upload Filesize on Job run
|
239 |
+
* fixed bug in .tar with file/folder names longer than 100 chars
|
240 |
+
* changed user capability back to '10' when working with WP lower than 3.0
|
241 |
+
* bug fixes for old WP versions
|
242 |
+
* English text updates! Best thanks to Marcy Capron.
|
243 |
+
* general improvements
|
244 |
+
* bug fixes
|
245 |
+
|
246 |
+
= 1.6.0 =
|
247 |
+
* new DropBox class to use all functions (download, delete, list)
|
248 |
+
* added useful links in job edit page
|
249 |
+
* renamed functions.php to resolve problems arising from other plugins
|
250 |
+
* general improvements
|
251 |
+
|
252 |
+
= 1.5.5 =
|
253 |
+
* Updated AWS SDK to ver.1.2.6 for Amazon S3
|
254 |
+
* Added AWS Region "Northeast" (Japan)
|
255 |
+
* Added Microsoft Azure (Blob) as backup destination
|
256 |
+
* bug fixes
|
257 |
+
|
258 |
+
= 1.5.2 =
|
259 |
+
* changes for user checking
|
260 |
+
* removed plugin init action
|
261 |
+
|
262 |
+
= 1.5.1 =
|
263 |
+
* changed user capability from '10' to 'export'
|
264 |
+
* Updated AWS SDK to ver.1.2.5 for Amazon S3
|
265 |
+
|
266 |
+
= 1.5.0 =
|
267 |
+
* use AWS SDK ver.1.2.4 now for Amazon S3
|
268 |
+
* Update Rackspase cloud files to ver.1.7.6
|
269 |
+
* Added job setting import/export
|
270 |
+
* Download link for last backup in jobs tab
|
271 |
+
* Link for last log in jobs tab
|
272 |
+
* Logs can now be compressed
|
273 |
+
* Backup destinations can now be disabled (see help)
|
274 |
+
* Bug fixes and improvements
|
275 |
+
|
276 |
+
= 1.4.1 =
|
277 |
+
* DropBox changes
|
278 |
+
* fixed problem on send log with email
|
279 |
+
* Security fix (thanks Massa Danilo)
|
280 |
+
|
281 |
+
= 1.4.0 =
|
282 |
+
* make SSL-FTP as option
|
283 |
+
* added DropBox support (zlli)
|
284 |
+
|
285 |
+
= 1.3.6 =
|
286 |
+
* long file list no longer displayed in logs.
|
287 |
+
* Added option to see detailed file list
|
288 |
+
* removed FTP Alloc command
|
289 |
+
* set FTP normal mode if passive mode disabled
|
290 |
+
* remove FTP helper function and use FTP PHP functions
|
291 |
+
* spend file list 2MB free memory
|
292 |
+
|
293 |
+
= 1.3.5 =
|
294 |
+
* fixed problem with folder include
|
295 |
+
* added option to deactivate FTP passive mode
|
296 |
+
* fixed bug for parsing errors because PHP 5 move PHP 5 functions in a seperate file
|
297 |
+
|
298 |
+
= 1.3.4 =
|
299 |
+
* fixed warning in send mail
|
300 |
+
* bug fixes
|
301 |
+
|
302 |
+
= 1.3.3 =
|
303 |
+
* fixed bug with clear only displayed
|
304 |
+
* fixed bug with Parse Error for some PHP versions
|
305 |
+
|
306 |
+
= 1.3.2 =
|
307 |
+
* added changable backup file prefix
|
308 |
+
* bug fixes
|
309 |
+
|
310 |
+
= 1.3.1 =
|
311 |
+
* added file and DB size information
|
312 |
+
* removed "LOCK TABLE" in sql dumps
|
313 |
+
* fixed bug in automatic job abortion
|
314 |
+
* fixed bug in ABSPATH if it '/'
|
315 |
+
* fixed bug in save settings
|
316 |
+
* fixed bugs if no jobs exists
|
317 |
+
* added link to clear running jobs
|
318 |
+
|
319 |
+
= 1.3.0 =
|
320 |
+
* added S3 new region codes for bucket creation
|
321 |
+
* added S3 REDUCED REDUNDANCY support on backups
|
322 |
+
* jobs will be aborted after 10 min. and can't run twice
|
323 |
+
* use curl for xml dump and copy if curl not works
|
324 |
+
* increased min. PHP version to 5.2.0, because then all works
|
325 |
+
* use linux cron based scheduling times
|
326 |
+
* added rackspacecloud.com support
|
327 |
+
* use WP 3.1 table creation
|
328 |
+
* added plugin checks for folder and new scheduling
|
329 |
+
|
330 |
+
= 1.2.1 =
|
331 |
+
* fixed "Wrong parameter count for array_unique()" for old php version
|
332 |
+
* added php version to log header
|
333 |
+
* added mysql version to log header
|
334 |
+
|
335 |
+
= 1.2.0 =
|
336 |
+
* Backup file size now in log file
|
337 |
+
* Paged Logs Table
|
338 |
+
* added Backup Archives Page
|
339 |
+
* Grammar fixes
|
340 |
+
* Bug fixes
|
341 |
+
|
342 |
+
= 1.1.1 =
|
343 |
+
* fixed "S3 lib not found" bug again.
|
344 |
+
* improved reschedule on activation problem.
|
345 |
+
|
346 |
+
= 1.1.0 =
|
347 |
+
* added function to check/update job settings
|
348 |
+
* added no Ajax bucket list to job page
|
349 |
+
* changed error handling a bit and remove PHP errors that can't handled
|
350 |
+
* fixed problem with not compiled --enable-memory-limit in PHP
|
351 |
+
* removed setting for memory limit use WP filter and default now (256M)
|
352 |
+
* now a time limit of 5 mins. is set again for job execution but it will be reseted on every message. (prevent never ending jobs.)
|
353 |
+
* added a shutdown function if __destruct not called for job
|
354 |
+
* added more flexible Backup file selection
|
355 |
+
|
356 |
+
= 1.0.10 =
|
357 |
+
* fix "Undefined index: dbshortinsert"
|
358 |
+
|
359 |
+
= 1.0.9 =
|
360 |
+
* change s3 class to hide warnings
|
361 |
+
* add option to make MySQL INSERTs shorter (smaller dump file size.)
|
362 |
+
* add requirements checks
|
363 |
+
* Ajaxed S3 bucket selection in job settings
|
364 |
+
* add S3 Bucket can made in job settings
|
365 |
+
|
366 |
+
= 1.0.8 =
|
367 |
+
* fix temp backup file not deleted if no destination folder
|
368 |
+
* some folder fixes
|
369 |
+
* removed some not used code
|
370 |
+
|
371 |
+
= 1.0.7 =
|
372 |
+
* added button in Help
|
373 |
+
* Fixed bug on S3 file deletion
|
374 |
+
* get files form S3 now faster for file deletion
|
375 |
+
|
376 |
+
= 1.0.6 =
|
377 |
+
* fixed false massage an send mail with backup
|
378 |
+
* removed test code for blank screen and fixed it!
|
379 |
+
|
380 |
+
= 1.0.5 =
|
381 |
+
* some ABSPATH changes
|
382 |
+
|
383 |
+
= 1.0.4 =
|
384 |
+
* fixed bugs in DB restore
|
385 |
+
* use WP functions to get Plugin dirs
|
386 |
+
|
387 |
+
= 1.0.3 =
|
388 |
+
* hopefully fixed a cache problem on run now
|
389 |
+
|
390 |
+
= 1.0.2 =
|
391 |
+
* fixed bug for file excludes
|
392 |
+
|
393 |
+
= 1.0.1 =
|
394 |
+
* fixed bug for https
|
395 |
+
|
396 |
+
= 1.0.0 =
|
397 |
+
* now WordPress Exports to XML can made
|
398 |
+
* new backup files formats tar, tar.gz, tar.bz2
|
399 |
+
* all job types can be created in one job
|
400 |
+
* added PHP zip extension support (use PclZip only if not supported)
|
401 |
+
* removed PclZip trace code
|
402 |
+
* fixed time display and schedule bugs
|
403 |
+
* added some security
|
404 |
+
* Maintenance Mode on MySQL Operations
|
405 |
+
* new Design on some Pages
|
406 |
+
|
407 |
+
= 0.8.1 =
|
408 |
+
* use global var instead of constant for log file
|
409 |
+
* PCLZip Trace included with setting for log Level
|
410 |
+
|
411 |
+
= 0.8.0 =
|
412 |
+
* Fixed not working default settings on settings page
|
413 |
+
* create .htaccess on Apache and index.html on other Webserver
|
414 |
+
* fixed global for $wp_version
|
415 |
+
* set max execution time to 0 for unlimited
|
416 |
+
* use WP function to generate options tables
|
417 |
+
* Backup file list and zip creation changes
|
418 |
+
* Added support for Amazon S3
|
419 |
+
* Only works with PHP 5 now
|
420 |
+
* Complete rewrite of job as PHP5 class
|
421 |
+
* PHP errors now in backup log
|
422 |
+
* Log now in files
|
423 |
+
|
424 |
+
= 0.7.2 =
|
425 |
+
* make FTP any more robust
|
426 |
+
* increased memory for Zip Files
|
427 |
+
* make date with date_i18n
|
428 |
+
|
429 |
+
= 0.7.1 =
|
430 |
+
* FTP Connection test changes
|
431 |
+
* no Errors in Log for FTP ALLO command.
|
432 |
+
|
433 |
+
= 0.7.0 =
|
434 |
+
* set ftp Connection timeout to 10 sec
|
435 |
+
* fix bug for DB tables exclude
|
436 |
+
* DB Backup in MySQL Client encoding now
|
437 |
+
* Fixed missing ; in DB Backup
|
438 |
+
* Added tool DB Restore with automatic Blog URL/Path change
|
439 |
+
|
440 |
+
= 0.6.5 =
|
441 |
+
* Prevent direct file loading
|
442 |
+
* job working in iFrame
|
443 |
+
* colored logs
|
444 |
+
* HTML fixes
|
445 |
+
* spell check
|
446 |
+
|
447 |
+
= 0.6.4 =
|
448 |
+
* New option to delete old logs
|
449 |
+
* Backup file deletion separated form logs deletion
|
450 |
+
* make dashboard widget smaller
|
451 |
+
* added massages
|
452 |
+
* bug fixes
|
453 |
+
|
454 |
+
= 0.6.3 =
|
455 |
+
* use ftp_row for login and other commands
|
456 |
+
* Add option to send only email on errors
|
457 |
+
* Internal structure changes
|
458 |
+
* Add option to disable WP-Cron and use host's cron
|
459 |
+
* bug fixes
|
460 |
+
|
461 |
+
= 0.6.2 =
|
462 |
+
* Added setting for memory_limit if needed
|
463 |
+
* Added setting for Max. Script execution time
|
464 |
+
* Added job option to make Max file size for sending via mail
|
465 |
+
* bug fixes and little improvements
|
466 |
+
|
467 |
+
= 0.6.1 =
|
468 |
+
* Added setting for send email type.
|
469 |
+
* Optimize memory usage again
|
470 |
+
* Fixed Bug that kept cron from working
|
471 |
+
|
472 |
+
= 0.6.0 =
|
473 |
+
* Add Dashboard Widget
|
474 |
+
* Add Database Check
|
475 |
+
* Add Backup file transfer to FTP Server
|
476 |
+
* Save log files in own database table
|
477 |
+
* Optimize Memory usage
|
478 |
+
* Optimize File system access
|
479 |
+
* DB dump with own function
|
480 |
+
* fixed some Bugs
|
481 |
+
|
482 |
+
= 0.5.5 =
|
483 |
+
* removed log files. Log now stored in Database
|
484 |
+
|
485 |
+
= 0.5.0 =
|
486 |
* Initial release
|
uninstall.php
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
-
<?PHP
|
2 |
-
if (!defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN')) {
|
3 |
-
die();
|
4 |
-
}
|
5 |
-
|
6 |
-
global $wp_version;
|
7 |
-
$blugurl=get_option('siteurl');
|
8 |
-
if (defined('WP_SITEURL'))
|
9 |
-
$blugurl=WP_SITEURL;
|
10 |
-
wp_remote_post( 'https://api.backwpup.com', array( 'sslverify' => false, 'body'=>array('URL'=>$blugurl,'ACTION'=>'delete'), 'user-agent'=>'BackWPup'));
|
11 |
-
delete_option('backwpup');
|
12 |
-
delete_option('backwpup_jobs');
|
13 |
-
?>
|
1 |
+
<?PHP
|
2 |
+
if (!defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN')) {
|
3 |
+
die();
|
4 |
+
}
|
5 |
+
|
6 |
+
global $wp_version;
|
7 |
+
$blugurl=get_option('siteurl');
|
8 |
+
if (defined('WP_SITEURL'))
|
9 |
+
$blugurl=WP_SITEURL;
|
10 |
+
wp_remote_post( 'https://api.backwpup.com', array( 'sslverify' => false, 'body'=>array('URL'=>$blugurl,'ACTION'=>'delete'), 'user-agent'=>'BackWPup'));
|
11 |
+
delete_option('backwpup');
|
12 |
+
delete_option('backwpup_jobs');
|
|