Backup & Restore Dropbox - Version 1.5

Version Description

Please, keep your Dropbox Backup and Restore plugin up-to-date.

Download this release

Release Info

Developer backup-dropbox
Plugin Icon 128x128 Backup & Restore Dropbox
Version 1.5
Comparing to
See all releases

Code changes from version 1.4.8.4 to 1.5

dropbox-backup.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Dropbox Backup & Restore
4
  Description: Dropbox Backup & Restore Plugin to create Dropbox Full Backup (Files + Database) of your Web Page
5
- Version: 1.4.8.4
6
  Text Domain: dropbox-backup
7
  Domain Path: /languages/
8
  */
2
  /*
3
  Plugin Name: Dropbox Backup & Restore
4
  Description: Dropbox Backup & Restore Plugin to create Dropbox Full Backup (Files + Database) of your Web Page
5
+ Version: 1.5
6
  Text Domain: dropbox-backup
7
  Domain Path: /languages/
8
  */
functions/wpadm.php CHANGED
@@ -16,33 +16,33 @@ if ( ! function_exists( 'wpadm_run' )) {
16
 
17
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-method-class.php';
18
  $request_name = $pl . '_request';
19
- if( isset( $_POST[$request_name] ) && !empty ( $_POST[$request_name] ) && isset( $_POST['sign'] ) && isset( $_POST['sign2'] ) ) {
20
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-core.php';
21
  WPAdm_Core::$cron = false;
22
-
23
- $user_ip = wpadm_getIp();
24
- $core_sign = WPAdm_Core::getInstance();
25
- $public_key = get_option('wpadm_pub_key', false);
26
- $sign = false;
27
- $sign_key = sanitize_text_field( $_POST['sign'] );
28
- $sign2_key = sanitize_text_field( $_POST['sign2'] );
29
- $verification_data = sanitize_text_field( $_POST[$request_name] );
30
- if ($public_key && $core_sign->verifySignature( base64_decode( $sign_key ), base64_decode( $sign2_key ), $public_key, md5( $verification_data ) ) ) { // Signature verification check
31
- if ($_SERVER['SERVER_ADDR'] != $user_ip && $_SERVER['HTTP_USER_AGENT'] != 'dropbox-backup user-agent') {
32
- WPAdm_Running::init_params_default(false);
33
- }
34
- $sign = true;
35
- $params = wpadm_unpack($verification_data);
36
- if ( isset($params['type']) ) {
37
- wpadm_class::$type = $params['type'];
38
- }
39
- $wpadm = new WPAdm_Core($params, $pl, $dir, $sign);
40
- echo '<wpadm>' . wpadm_pack($wpadm->getResult()->toArray()) . '</wpadm>';
41
- exit;
42
- }
43
  }
44
  }
45
- }
46
 
47
 
48
  if ( ! function_exists( 'wpadm_unpack' )) {
@@ -64,7 +64,38 @@ if ( ! function_exists('wpadm_pack')) {
64
  * @return string
65
  */
66
  function wpadm_pack( $value ) {
67
- return base64_encode( json_encode ( $value, JSON_HEX_QUOT|JSON_HEX_TAG|JSON_HEX_AMP|JSON_HEX_APOS ) ) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  }
69
  }
70
 
@@ -118,9 +149,9 @@ if ( ! function_exists('wpadm_send_blog_info')) {
118
  }
119
  }
120
  if (!function_exists('wpadm_getIp')) {
121
- function wpadm_getIp()
122
- {
123
- $user_ip = '';
124
  if ( getenv('REMOTE_ADDR') ){
125
  $user_ip = getenv('REMOTE_ADDR');
126
  }elseif ( getenv('HTTP_FORWARDED_FOR') ){
@@ -145,7 +176,7 @@ if (!function_exists('wpadm_getIp')) {
145
  return '';
146
  }
147
  return $user_ip;
148
- }
149
  }
150
 
151
  if ( ! function_exists('wpadm_get_blog_info')) {
@@ -214,7 +245,7 @@ if (function_exists('wpadm_getKey')) {
214
  if ( !function_exists('WPADM_getSize') ) {
215
  function WPADM_getSize($size)
216
  {
217
-
218
  $kbyte = 1024;
219
  $mbyte = $kbyte * $kbyte;
220
  if ($size >= 0 && $size < $kbyte) {
@@ -227,3 +258,37 @@ if ( !function_exists('WPADM_getSize') ) {
227
  }
228
  }
229
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-method-class.php';
18
  $request_name = $pl . '_request';
19
+ if( isset( $_POST[$request_name] ) && !empty ( $_POST[$request_name] ) && isset( $_POST['sign'] ) && isset( $_POST['sign2'] ) ) {
20
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-core.php';
21
  WPAdm_Core::$cron = false;
22
+
23
+ $user_ip = wpadm_getIp();
24
+ $core_sign = WPAdm_Core::getInstance();
25
+ $public_key = get_option('wpadm_pub_key', false);
26
+ $sign = false;
27
+ $sign_key = sanitize_text_field( $_POST['sign'] );
28
+ $sign2_key = sanitize_text_field( $_POST['sign2'] );
29
+ $verification_data = sanitize_text_field( $_POST[$request_name] );
30
+ if ($public_key && $core_sign->verifySignature( base64_decode( $sign_key ), base64_decode( $sign2_key ), $public_key, md5( $verification_data ) ) ) { // Signature verification check
31
+ if ($_SERVER['SERVER_ADDR'] != $user_ip && $_SERVER['HTTP_USER_AGENT'] != 'dropbox-backup user-agent') {
32
+ WPAdm_Running::init_params_default(false);
33
+ }
34
+ $sign = true;
35
+ $params = wpadm_unpack($verification_data);
36
+ if ( isset($params['type']) ) {
37
+ wpadm_class::$type = $params['type'];
38
+ }
39
+ $wpadm = new WPAdm_Core($params, $pl, $dir, $sign);
40
+ echo '<wpadm>' . wpadm_pack($wpadm->getResult()->toArray()) . '</wpadm>';
41
+ exit;
42
+ }
43
  }
44
  }
45
+ }
46
 
47
 
48
  if ( ! function_exists( 'wpadm_unpack' )) {
64
  * @return string
65
  */
66
  function wpadm_pack( $value ) {
67
+ if (defined('JSON_HEX_TAG') && defined('JSON_HEX_QUOT') && defined('JSON_HEX_AMP') && defined('JSON_HEX_APOS') ) {
68
+ $res = json_encode ( $value, JSON_HEX_QUOT|JSON_HEX_TAG|JSON_HEX_AMP|JSON_HEX_APOS );
69
+ } else {
70
+ $res = json_encode( $value );
71
+ }
72
+
73
+ if ($res === false) {
74
+ switch (json_last_error()) {
75
+ case JSON_ERROR_NONE:
76
+ WPAdm_Core::log( ' - No errors' );
77
+ break;
78
+ case JSON_ERROR_DEPTH:
79
+ WPAdm_Core::log( ' - Maximum stack depth exceeded' );
80
+ break;
81
+ case JSON_ERROR_STATE_MISMATCH:
82
+ WPAdm_Core::log( ' - Underflow or the modes mismatch' ) ;
83
+ break;
84
+ case JSON_ERROR_CTRL_CHAR:
85
+ WPAdm_Core::log( ' - Unexpected control character found' );
86
+ break;
87
+ case JSON_ERROR_SYNTAX:
88
+ WPAdm_Core::log( ' - Syntax error, malformed JSON' );
89
+ break;
90
+ case JSON_ERROR_UTF8:
91
+ WPAdm_Core::log( ' - Malformed UTF-8 characters, possibly incorrectly encoded' );
92
+ break;
93
+ default:
94
+ WPAdm_Core::log( ' - Unknown error' );
95
+ break;
96
+ }
97
+ }
98
+ return base64_encode( $res ) ;
99
  }
100
  }
101
 
149
  }
150
  }
151
  if (!function_exists('wpadm_getIp')) {
152
+ function wpadm_getIp()
153
+ {
154
+ $user_ip = '';
155
  if ( getenv('REMOTE_ADDR') ){
156
  $user_ip = getenv('REMOTE_ADDR');
157
  }elseif ( getenv('HTTP_FORWARDED_FOR') ){
176
  return '';
177
  }
178
  return $user_ip;
179
+ }
180
  }
181
 
182
  if ( ! function_exists('wpadm_get_blog_info')) {
245
  if ( !function_exists('WPADM_getSize') ) {
246
  function WPADM_getSize($size)
247
  {
248
+
249
  $kbyte = 1024;
250
  $mbyte = $kbyte * $kbyte;
251
  if ($size >= 0 && $size < $kbyte) {
258
  }
259
  }
260
 
261
+ if (!function_exists('BackupsFoldersExclude')) {
262
+ function BackupsFoldersExclude($folder_check = '', $prev_folder = '')
263
+ {
264
+ $folders = array('aiowps_backups' => 'wp-content', 'backup-db' => 'wp-content', 'backups' => 'wp-content', 'bps-backup' => 'wp-content',
265
+ 'updraft' => 'wp-content', 'wpbackitup_backups' => 'wp-content', 'wpbackitup_restore' => 'wp-content',
266
+ 'backup-guard' => 'uploads', 'ithemes-security' => 'uploads', 'wp-clone' => 'uploads');
267
+ $in_name_folders = array( 'backupwordpress' => 'wp-content' );
268
+
269
+ if ( empty( $folder_check ) ) {
270
+ return array('folder' => array_keys( $folder ), 'in_name_folder' => $in_name_folder);
271
+ } else {
272
+ $folder_check = strtolower( $folder_check );
273
+ if (!empty($prev_folder)) {
274
+ if ( isset( $folders[$folder_check] ) && $folders[$folder_check] == $folders[$folder_check] ) {
275
+ return true;
276
+ }
277
+ } else {
278
+ if (isset( $folders[$folder_check] )) {
279
+ return true;
280
+ }
281
+ }
282
+
283
+ foreach ($in_name_folders as $folder => $p_folder ) {
284
+ if (stripos($folder_check, $folder) !== false) {
285
+ if ( ( !empty($prev_folder) && $p_folder == $prev_folder ) || empty($prev_folder) ) {
286
+ return true;
287
+ }
288
+ }
289
+ }
290
+ }
291
+ return false;
292
+ }
293
+ }
294
+
libs/wpadm.server.main.class.php CHANGED
@@ -216,11 +216,11 @@
216
  if (strpos($arr[$i], ABSPATH ) !== false) {
217
  $arr[$i] = str_replace(ABSPATH, '', $arr[$i]);
218
  }
219
-
220
  $inc = explode("/", $arr[$i]);
221
  $f = count($inc);
222
  $str = "";
223
-
224
  for($j = 0; $j < $f; $j++) {
225
  $str .= '/' . $inc[$j];
226
  if ($first) {
@@ -232,7 +232,7 @@
232
  } elseif(empty($path_show)) {
233
  $in[$str] = $str;
234
  }
235
-
236
  }
237
  }
238
  }
@@ -393,7 +393,7 @@
393
  }
394
  return $files;
395
  }
396
- private static function directoryToArray($directory, $recursive) {
397
  $array_items = array();
398
 
399
  $d = str_replace(ABSPATH, '', $directory);
@@ -415,6 +415,9 @@
415
  $d2 = strtolower(implode('/', $tmp));
416
  }
417
 
 
 
 
418
  if (strpos($d2, 'cache') !== false && isset($tmp[0])&& !in_array($tmp[0], array('plugins', 'themes')) ) {
419
  return array();
420
  }
@@ -501,9 +504,9 @@
501
 
502
  }
503
  $data_save = trim($data_save, ',' );
504
-
505
  $data_save = implode(',', array_values( array_unique( explode(',', $data_save) ) ) );
506
-
507
  $data_save = trim($data_save, ',' );
508
 
509
  update_option(PREFIX_BACKUP_ . "plus-path", base64_encode( $data_save ) );
@@ -829,7 +832,7 @@
829
  $count_zip = 0;
830
  $backups[$i]['files'] = "[";
831
  while($d_b = readdir($dir_b)) {
832
- if ($d_b != '.' && $d_b != '..' && file_exists($dir_backup . "/$d/$d_b") && ( substr($d_b, -3) == "zip" || substr($d_b, -3) == 'md5' ) ) {
833
  $backups[$i]['files'] .= "$d_b,";
834
  $size += filesize($dir_backup . "/$d/$d_b");
835
  $count_zip = $count_zip + 1;
216
  if (strpos($arr[$i], ABSPATH ) !== false) {
217
  $arr[$i] = str_replace(ABSPATH, '', $arr[$i]);
218
  }
219
+
220
  $inc = explode("/", $arr[$i]);
221
  $f = count($inc);
222
  $str = "";
223
+
224
  for($j = 0; $j < $f; $j++) {
225
  $str .= '/' . $inc[$j];
226
  if ($first) {
232
  } elseif(empty($path_show)) {
233
  $in[$str] = $str;
234
  }
235
+
236
  }
237
  }
238
  }
393
  }
394
  return $files;
395
  }
396
+ public static function directoryToArray($directory, $recursive) {
397
  $array_items = array();
398
 
399
  $d = str_replace(ABSPATH, '', $directory);
415
  $d2 = strtolower(implode('/', $tmp));
416
  }
417
 
418
+
419
+
420
+
421
  if (strpos($d2, 'cache') !== false && isset($tmp[0])&& !in_array($tmp[0], array('plugins', 'themes')) ) {
422
  return array();
423
  }
504
 
505
  }
506
  $data_save = trim($data_save, ',' );
507
+
508
  $data_save = implode(',', array_values( array_unique( explode(',', $data_save) ) ) );
509
+
510
  $data_save = trim($data_save, ',' );
511
 
512
  update_option(PREFIX_BACKUP_ . "plus-path", base64_encode( $data_save ) );
832
  $count_zip = 0;
833
  $backups[$i]['files'] = "[";
834
  while($d_b = readdir($dir_b)) {
835
+ if ($d_b != '.' && $d_b != '..' && file_exists($dir_backup . "/$d/$d_b") && ( substr($d_b, -3) == "zip" || substr($d_b, -3) == 'md5' ) || substr($d_b, -6) == "tar.gz" ) {
836
  $backups[$i]['files'] .= "$d_b,";
837
  $size += filesize($dir_backup . "/$d/$d_b");
838
  $count_zip = $count_zip + 1;
main/wpadm-class-wp.php CHANGED
@@ -47,6 +47,8 @@
47
 
48
  private static $local_delete = false;
49
 
 
 
50
  static function is_auth_user()
51
  {
52
  if ( !is_user_logged_in() ) {
@@ -231,7 +233,7 @@
231
  {
232
  if (isset($_POST['is_admin']) || isset($_POST['is_optimization']) || isset($_POST['is_local_backup_delete'])
233
  || isset($_POST['is_repair']) || isset($_POST['time_error']) || isset($_POST['is_show_admin_bar'] ) || isset($_POST['backup_folder'] )
234
- || isset($_POST['clear_backup_folder']) ) {
235
 
236
  $dropbox_options = self::getSettings();
237
 
@@ -261,7 +263,31 @@
261
  unset($dropbox_options['backup_folder']);
262
  }
263
  }
264
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  self::setSettings($dropbox_options);
266
  }
267
  }
@@ -311,7 +337,7 @@
311
  if (file_exists(WPAdm_Core::getTmpDir() . "/log.log")) {
312
  file_put_contents(WPAdm_Core::getTmpDir() . "/log.log", '');
313
  }
314
-
315
  WPAdm_Core::rmdir(WPAdm_Core::getTmpDir() . "/log-archive.log");
316
 
317
  WPAdm_Process::clear();
@@ -325,6 +351,7 @@
325
  }
326
  WPAdm_Core::mkdir($backup_dir);
327
  WPAdm_Running::init_params_default();
 
328
  $res['result'] = 'success';
329
  if (defined('DISABLE_WP_CRON')) {
330
  if (DISABLE_WP_CRON === true || DISABLE_WP_CRON == 'true') {
@@ -704,7 +731,7 @@
704
  if (file_exists(WPAdm_Core::getTmpDir() . "/log.log")) {
705
  file_put_contents(WPAdm_Core::getTmpDir() . "/log.log", '');
706
  }
707
-
708
  WPAdm_Core::rmdir(WPAdm_Core::getTmpDir() . "/log-archive.log");
709
 
710
  WPAdm_Process::clear();
@@ -751,6 +778,7 @@
751
  if ($send_to_dropbox) {
752
  parent::$type = 'full';
753
  WPAdm_Running::init_params_default();
 
754
  WPAdm_Running::delCommandResultData("local_backup");
755
 
756
  $dropbox_options = self::getSettings();
@@ -825,6 +853,7 @@
825
  {
826
  require_once DRBBACKUP_BASE_DIR. "/modules/dropbox.class.php";
827
  parent::$type = 'full';
 
828
  $dropbox_options = self::getSettings();
829
  $stop_precess = WPAdm_Running::getCommandResultData('stop_process');
830
  $name_backup = isset($stop_precess['name']) ? $stop_precess['name'] : '' ;
@@ -847,7 +876,7 @@
847
  $k = $data['data'][$i]['count'];
848
  $data['data'][$i]['files'] = '[';
849
  for($j = 0; $j < $k; $j++) {
850
- if ( strpos($backup['items'][$j]['name'] , '.md5') !== false || strpos($backup['items'][$j]['name'] , '.zip') !== true ) {
851
  if ( strpos($backup['items'][$j]['name'] , '.md5') !== false ) {
852
  $not_all_upload = true;
853
  }
@@ -941,6 +970,12 @@
941
  $default = self::$circle / 6; // 18 request for log files, one request every 10 seconds
942
  $base_path = DRBBACKUP_BASE_DIR ;
943
 
 
 
 
 
 
 
944
  $nonce = wp_create_nonce( 'wpadm_nonce' );
945
 
946
  ob_start();
@@ -1037,6 +1072,36 @@
1037
  header('location:' . $_SERVER['HTTP_REFERER']);
1038
  exit;
1039
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1040
  }
1041
  }
1042
 
47
 
48
  private static $local_delete = false;
49
 
50
+ private static $type_archive = array('zip_archive' => 1, 'pclzip_archive' => 1, 'targz_archive' => 1);
51
+
52
  static function is_auth_user()
53
  {
54
  if ( !is_user_logged_in() ) {
233
  {
234
  if (isset($_POST['is_admin']) || isset($_POST['is_optimization']) || isset($_POST['is_local_backup_delete'])
235
  || isset($_POST['is_repair']) || isset($_POST['time_error']) || isset($_POST['is_show_admin_bar'] ) || isset($_POST['backup_folder'] )
236
+ || isset($_POST['clear_backup_folder']) || isset($_POST['zip_archive']) || isset( $_POST['tar_archive'] ) || isset( $_POST['targz_archive'] ) ) {
237
 
238
  $dropbox_options = self::getSettings();
239
 
263
  unset($dropbox_options['backup_folder']);
264
  }
265
  }
266
+
267
+ $type_archive = '';
268
+ if (isset($_POST['zip_archive']) ) {
269
+ $type_archive = 'zip_archive';
270
+ } elseif (isset($_POST['tar_archive'])) {
271
+ $type_archive = 'tar_archive';
272
+ } elseif (isset($_POST['targz_archive'])) {
273
+ $type_archive = 'targz_archive';
274
+ }
275
+
276
+ if ( !empty($type_archive) ) {
277
+ if (isset(self::$type_archive[$type_archive])) {
278
+ if (isset($dropbox_options['type_archive'])) {
279
+ $dropbox_options['type_archive'] = array_merge( self::$type_archive, $dropbox_options['type_archive'] );
280
+ } else {
281
+ $dropbox_options['type_archive'] = self::$type_archive;
282
+ }
283
+ if ($dropbox_options['type_archive'][$type_archive] == 1) {
284
+ $dropbox_options['type_archive'][$type_archive] = 0;
285
+ } else {
286
+ $dropbox_options['type_archive'][$type_archive] = 1;
287
+ }
288
+ }
289
+ }
290
+
291
  self::setSettings($dropbox_options);
292
  }
293
  }
337
  if (file_exists(WPAdm_Core::getTmpDir() . "/log.log")) {
338
  file_put_contents(WPAdm_Core::getTmpDir() . "/log.log", '');
339
  }
340
+
341
  WPAdm_Core::rmdir(WPAdm_Core::getTmpDir() . "/log-archive.log");
342
 
343
  WPAdm_Process::clear();
351
  }
352
  WPAdm_Core::mkdir($backup_dir);
353
  WPAdm_Running::init_params_default();
354
+ self::testOtherArchives();
355
  $res['result'] = 'success';
356
  if (defined('DISABLE_WP_CRON')) {
357
  if (DISABLE_WP_CRON === true || DISABLE_WP_CRON == 'true') {
731
  if (file_exists(WPAdm_Core::getTmpDir() . "/log.log")) {
732
  file_put_contents(WPAdm_Core::getTmpDir() . "/log.log", '');
733
  }
734
+
735
  WPAdm_Core::rmdir(WPAdm_Core::getTmpDir() . "/log-archive.log");
736
 
737
  WPAdm_Process::clear();
778
  if ($send_to_dropbox) {
779
  parent::$type = 'full';
780
  WPAdm_Running::init_params_default();
781
+ self::testOtherArchives();
782
  WPAdm_Running::delCommandResultData("local_backup");
783
 
784
  $dropbox_options = self::getSettings();
853
  {
854
  require_once DRBBACKUP_BASE_DIR. "/modules/dropbox.class.php";
855
  parent::$type = 'full';
856
+
857
  $dropbox_options = self::getSettings();
858
  $stop_precess = WPAdm_Running::getCommandResultData('stop_process');
859
  $name_backup = isset($stop_precess['name']) ? $stop_precess['name'] : '' ;
876
  $k = $data['data'][$i]['count'];
877
  $data['data'][$i]['files'] = '[';
878
  for($j = 0; $j < $k; $j++) {
879
+ if ( strpos($backup['items'][$j]['name'] , '.md5') !== false || strpos($backup['items'][$j]['name'] , '.zip') !== true || strpos($backup['items'][$j]['name'] , '.tar.gz' ) !== false ) {
880
  if ( strpos($backup['items'][$j]['name'] , '.md5') !== false ) {
881
  $not_all_upload = true;
882
  }
970
  $default = self::$circle / 6; // 18 request for log files, one request every 10 seconds
971
  $base_path = DRBBACKUP_BASE_DIR ;
972
 
973
+ if ( !isset( $dropbox_options['type_archive'] ) ) {
974
+ $dropbox_options['type_archive'] = self::$type_archive;
975
+ } else {
976
+ $dropbox_options['type_archive'] = array_merge( self::$type_archive, $dropbox_options['type_archive'] );
977
+ }
978
+
979
  $nonce = wp_create_nonce( 'wpadm_nonce' );
980
 
981
  ob_start();
1072
  header('location:' . $_SERVER['HTTP_REFERER']);
1073
  exit;
1074
  }
1075
+
1076
+ public static function testOtherArchives()
1077
+ {
1078
+ require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-archive.php";
1079
+ // test type archive
1080
+ $archive = new WPAdm_Archive(WPAdm_Core::getTmpDir() . '/test.zip');
1081
+ $archive->setRemovePath(rtrim( ABSPATH, '/' ) );
1082
+ $zip_test = $archive->zipArhive( array( WPAdm_Core::getTmpDir() . '/index.php' , WPAdm_Core::getTmpDir() . '/.htaccess' ) );
1083
+ if ( $zip_test ) {
1084
+ WPAdm_Running::setCommandResultData('test_zip_archive', true);
1085
+ WPAdm_Core::log( __('Testing of ZIP under shell was finished successfully', 'dropbox-backup') );
1086
+ }
1087
+
1088
+ $targz_archive = $archive->targzArchive( array( WPAdm_Core::getTmpDir() . '/index.php' , WPAdm_Core::getTmpDir() . '/.htaccess' ) );
1089
+ if ( $targz_archive ) {
1090
+ WPAdm_Running::setCommandResultData('test_targz_archive', true);
1091
+ WPAdm_Core::log( __('Testing of TarGz was finished successfully', 'dropbox-backup') );
1092
+ }
1093
+ }
1094
+
1095
+ static function getTypeBackup()
1096
+ {
1097
+ $dropbox_options = self::getSettings();
1098
+ if ( !isset( $dropbox_options['type_archive'] ) ) {
1099
+ $dropbox_options['type_archive'] = self::$type_archive;
1100
+ } else {
1101
+ $dropbox_options['type_archive'] = array_merge( self::$type_archive, $dropbox_options['type_archive'] );
1102
+ }
1103
+ return $dropbox_options['type_archive'];
1104
+ }
1105
  }
1106
  }
1107
 
methods/class-wpadm-method-full-backup-dropbox.php CHANGED
@@ -228,13 +228,13 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
228
  $archive = new WPAdm_Archive($af, $to_file . '.md5');
229
  $archive->setRemovePath( ABSPATH );
230
  }
231
-
232
  if ( defined('PCLZIP_SEPARATOR') ) {
233
  $files_str = implode( PCLZIP_SEPARATOR , $files);
234
  } else {
235
  $files_str = implode( ',' , $files); // default SEPARATOR in pclzip
236
  }
237
-
238
  $res = $archive->add($files_str);
239
  if ($res) {
240
 
@@ -468,6 +468,9 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
468
  WPAdm_Core::log('Skip dir(cache) ' . $directory);
469
  return array();
470
  }
 
 
 
471
  if(strpos($directory, DROPBOX_BACKUP_DIR_NAME) !== false) {
472
  return array();
473
  }
228
  $archive = new WPAdm_Archive($af, $to_file . '.md5');
229
  $archive->setRemovePath( ABSPATH );
230
  }
231
+
232
  if ( defined('PCLZIP_SEPARATOR') ) {
233
  $files_str = implode( PCLZIP_SEPARATOR , $files);
234
  } else {
235
  $files_str = implode( ',' , $files); // default SEPARATOR in pclzip
236
  }
237
+
238
  $res = $archive->add($files_str);
239
  if ($res) {
240
 
468
  WPAdm_Core::log('Skip dir(cache) ' . $directory);
469
  return array();
470
  }
471
+
472
+
473
+
474
  if(strpos($directory, DROPBOX_BACKUP_DIR_NAME) !== false) {
475
  return array();
476
  }
methods/class-wpadm-method-local-backup.php CHANGED
@@ -7,6 +7,8 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
7
 
8
  private $start = true;
9
 
 
 
10
  public function __construct($params)
11
  {
12
 
@@ -157,7 +159,7 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
157
  $opt_db = WPAdm_Running::getCommandResultData('db');
158
  if (!isset($opt_db['optimize'])) {
159
  if ( WPAdm_Running::is_stop() ) {
160
- WPAdm_Core::log(__('Optimize Database Tables','dropbox-backup'));
161
  if (!class_exists('WPAdm_Mysqldump')) {
162
  require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-mysqldump.php';
163
  }
@@ -221,6 +223,7 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
221
  $command_files_list = WPAdm_Running::getCommandResultData('files');
222
  if (in_array('files', $this->params['types']) && empty($command_files_list) ) {
223
  $files = $this->createListFilesForArchive();
 
224
  WPAdm_Running::setCommandResultData('files', $files);
225
  } else {
226
  $files = $command_files_list;
@@ -244,35 +247,61 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
244
  $files2[0] = array();
245
  $i = 0;
246
  $size = 0;
 
 
 
 
 
 
 
247
  foreach($files as $f) {
248
- if ($size > 170000) {//~170kbyte
 
249
  $i ++;
250
  $size = 0;
251
  $files2[$i] = array();
252
  }
253
  $f_size =(int)@filesize($f);
 
 
 
 
 
254
  if ($f_size == 0 || $f_size > 1000000) {
255
- WPAdm_Core::log('File ' . $f . ' Size ' . $f_size);
256
  }
257
  $size += $f_size;
258
- $files2[$i][] = $f;
 
259
  }
260
  WPAdm_Running::setCommandResultData('files2', $files2);
 
261
  }
262
  } else {
263
  return true;
264
  }
 
 
 
 
265
 
266
-
267
- WPAdm_Core::log(__('List of Backup-Files was successfully created','dropbox-backup') );
268
- //$this->queue->clear();
269
  if ( !WPAdm_Running::getCommandResult('archive') ) {
270
  if ( WPAdm_Running::is_stop() ) {
 
271
  WPAdm_Running::setCommandResult('archive');
272
  $files_archive = WPAdm_Running::getCommandResultData('archive');
273
  require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-archive.php';
274
  $to_file = $this->dir . '/' . $this->name;
 
275
  foreach($files2 as $key => $files) {
 
 
 
 
 
 
 
276
  $md5 = md5( print_r( $files, 1 ) );
277
  if ( !isset($files_archive[$md5]) ) {
278
  if ( WPAdm_Running::is_stop() ) {
@@ -283,7 +312,9 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
283
  WPAdm_Core::log(__('Create part ','dropbox-backup') . basename( $af ) );
284
  }
285
  }
286
- if (file_exists($af) && filesize($af) > 900000) {
 
 
287
  if ( WPAdm_Running::is_stop() ) {
288
  $af = $this->getNextArchiveName($to_file);
289
  unset($archive);
@@ -296,6 +327,7 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
296
  return true;
297
  }
298
  }
 
299
  if ( WPAdm_Running::is_stop() ) {
300
  $md5 = md5( print_r( $files, 1 ) );
301
  if ( defined('PCLZIP_SEPARATOR') ) {
@@ -326,19 +358,10 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
326
  return true;
327
  }
328
  }
329
- /*$commandContext = new WPAdm_Command_Context();
330
- $commandContext ->addParam('command', 'archive')
331
- ->addParam('files', $files)
332
- ->addParam('to_file', $this->dir . '/' . $this->name)
333
- ->addParam('max_file_size', 900000)
334
- ->addParam('remove_path', ABSPATH);
335
-
336
- $this->queue->add($commandContext);
337
- unset($commandContext); */
338
  }
339
  }
340
- WPAdm_Core::log( __('Backup of Files was started','dropbox-backup') );
341
- WPAdm_Core::log( __('End of File Backup','dropbox-backup') );
342
  WPAdm_Running::setCommandResult('archive', true);
343
 
344
  }
@@ -358,9 +381,8 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
358
  $this->result->setValue('time', $this->time);
359
  $this->result->setValue('type', 'local');
360
  $this->result->setValue('counts', count($urls) );
361
- $size = $totalSize / 1024 / 1024; /// MByte
362
- $size = round($size, 2);
363
- $log = str_replace("%s", $size , __('Backup Size %s Mb','dropbox-backup') ) ;
364
  WPAdm_Core::log($log);
365
 
366
  $remove_from_server = 0;
@@ -435,7 +457,7 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
435
  } elseif(!empty($tmp_folder) && strpos($f[$i], $tmp_folder) !== false) {
436
  $tmp_folder = '';
437
  }
438
-
439
  if( is_dir( ABSPATH . $f[$i] ) ) {
440
  //$fi = $this->directoryToArray(ABSPATH . $f[$i], true );
441
  $tmp_folder = $f[$i];
@@ -545,9 +567,9 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
545
  $files = array_merge($files, $this->directoryToArray($folder, true));
546
  }
547
  }
548
-
549
  $files = array_values( array_unique($files) );
550
-
551
  return $files;
552
  }
553
 
@@ -574,6 +596,7 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
574
  } else {
575
  $d1 = strtolower($tmp[0]);
576
  }
 
577
  unset($tmp[0]);
578
  if (function_exists('mb_strtolower')) {
579
  $d2 = mb_strtolower(implode('/', $tmp));
@@ -581,14 +604,21 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
581
  $d2 = strtolower(implode('/', $tmp));
582
  }
583
 
584
- if (stripos($d2, 'cache') !== false ) {
585
- WPAdm_Core::log( __('Skip of Cache-Folder ','dropbox-backup') . $directory);
586
- return array();
587
- }
 
588
  if (strpos($d2, 'cache') !== false && isset($tmp[0]) && !in_array($tmp[0], array('plugins', 'themes')) ) {
589
  WPAdm_Core::log(__('Skip of Cache-Folder ','dropbox-backup') . $directory);
590
  return array();
591
  }
 
 
 
 
 
 
592
  if(strpos($directory, 'wpadm_backups') !== false || strpos($directory, 'Dropbox_Backup') !== false) {
593
  return array();
594
  }
@@ -665,21 +695,43 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
665
  private function getArchiveName($name)
666
  {
667
  //WPAdm_Core::log("{$name}-*.zip");
668
- $archives = glob("{$name}-*.zip");
 
 
 
 
 
 
669
  if (empty($archives)) {
670
- return "{$name}-1.zip";
 
 
 
 
671
  }
672
  $n = count($archives);
673
- $f = "{$name}-{$n}.zip";
 
 
 
 
674
  return $f;
675
  }
676
 
677
  private function getNextArchiveName($name)
678
  {
679
- //WPAdm_Core::log("{$name}-*.zip");
680
- $archives = glob("{$name}-*.zip");
 
 
 
 
681
  $n = 1 + count($archives);
682
- $a = "{$name}-{$n}.zip";
 
 
 
 
683
  //WPAdm_Core::log($a);
684
  return $a;
685
  }
7
 
8
  private $start = true;
9
 
10
+ private $tar_gz = false;
11
+
12
  public function __construct($params)
13
  {
14
 
159
  $opt_db = WPAdm_Running::getCommandResultData('db');
160
  if (!isset($opt_db['optimize'])) {
161
  if ( WPAdm_Running::is_stop() ) {
162
+ //WPAdm_Core::log(__('Optimize Database Tables','dropbox-backup'));
163
  if (!class_exists('WPAdm_Mysqldump')) {
164
  require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-mysqldump.php';
165
  }
223
  $command_files_list = WPAdm_Running::getCommandResultData('files');
224
  if (in_array('files', $this->params['types']) && empty($command_files_list) ) {
225
  $files = $this->createListFilesForArchive();
226
+ $files = explode('<!>', utf8_encode( implode( '<!>', $files ) ) );
227
  WPAdm_Running::setCommandResultData('files', $files);
228
  } else {
229
  $files = $command_files_list;
247
  $files2[0] = array();
248
  $i = 0;
249
  $size = 0;
250
+ $chunk_size = 170000; //~170kbyte
251
+ $targz = WPAdm_Running::getCommandResultData('test_targz_archive');
252
+ $files_count = 0;
253
+ if (!empty($targz)) {
254
+ $chunk_size = 1572864; // ~ 1.5 Mbyte
255
+ }
256
+ $size_part = array();
257
  foreach($files as $f) {
258
+ if ($size > $chunk_size) {
259
+ $size_part[$i] = $size;
260
  $i ++;
261
  $size = 0;
262
  $files2[$i] = array();
263
  }
264
  $f_size =(int)@filesize($f);
265
+ $permission_file = wpadm_class::perm($f);
266
+ if ( ! version_compare($permission_file, '0400', '>=') ) {
267
+ WPAdm_Core::log('Skip file ' . $f . ' Size ' . WPADM_getSize($f_size) . " (" . $permission_file . ")" );
268
+ continue;
269
+ }
270
  if ($f_size == 0 || $f_size > 1000000) {
271
+ WPAdm_Core::log('File ' . $f . ' Size ' . WPADM_getSize($f_size) . " (" . $permission_file . ")" );
272
  }
273
  $size += $f_size;
274
+ $files2[$i][] = utf8_decode( $f );
275
+ $files_count ++;
276
  }
277
  WPAdm_Running::setCommandResultData('files2', $files2);
278
+ WPAdm_Running::setCommandResultData('files2_count', $files_count );
279
  }
280
  } else {
281
  return true;
282
  }
283
+ $files_count = WPAdm_Running::getCommandResultData('files2_count', $files_count );
284
+ if (!empty($files_count) && $files_count != count($files) ) {
285
+ WPAdm_Process::init('archiving', $files_count );
286
+ }
287
 
288
+ WPAdm_Core::log(__('List of backup files was successfully created','dropbox-backup') );
 
 
289
  if ( !WPAdm_Running::getCommandResult('archive') ) {
290
  if ( WPAdm_Running::is_stop() ) {
291
+ WPAdm_Core::log( __('Backup of files was started','dropbox-backup') );
292
  WPAdm_Running::setCommandResult('archive');
293
  $files_archive = WPAdm_Running::getCommandResultData('archive');
294
  require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-archive.php';
295
  $to_file = $this->dir . '/' . $this->name;
296
+ $processing_archive = 0;
297
  foreach($files2 as $key => $files) {
298
+ if (!WPAdm_Running::toEndWork( time()) ) {
299
+ // 2 steps of archive less 3MB
300
+ if ($size_part[$key] > 3145728 || $processing_archive >= 2) { // ~ 3 MB
301
+ return true;
302
+ }
303
+ $processing_archive ++;
304
+ }
305
  $md5 = md5( print_r( $files, 1 ) );
306
  if ( !isset($files_archive[$md5]) ) {
307
  if ( WPAdm_Running::is_stop() ) {
312
  WPAdm_Core::log(__('Create part ','dropbox-backup') . basename( $af ) );
313
  }
314
  }
315
+ $targz = WPAdm_Running::getCommandResultData('test_targz_archive');
316
+
317
+ if ( ( !empty($targz) && $targz === true ) || ( file_exists($af) && filesize($af) > 900000 ) ) {
318
  if ( WPAdm_Running::is_stop() ) {
319
  $af = $this->getNextArchiveName($to_file);
320
  unset($archive);
327
  return true;
328
  }
329
  }
330
+
331
  if ( WPAdm_Running::is_stop() ) {
332
  $md5 = md5( print_r( $files, 1 ) );
333
  if ( defined('PCLZIP_SEPARATOR') ) {
358
  return true;
359
  }
360
  }
 
 
 
 
 
 
 
 
 
361
  }
362
  }
363
+
364
+ WPAdm_Core::log( __('Backup of files was finished','dropbox-backup') );
365
  WPAdm_Running::setCommandResult('archive', true);
366
 
367
  }
381
  $this->result->setValue('time', $this->time);
382
  $this->result->setValue('type', 'local');
383
  $this->result->setValue('counts', count($urls) );
384
+ $size = WPADM_getSize( $totalSize ); /// MByte
385
+ $log = str_replace("%s", $size , __('Backup size %s','dropbox-backup') ) ;
 
386
  WPAdm_Core::log($log);
387
 
388
  $remove_from_server = 0;
457
  } elseif(!empty($tmp_folder) && strpos($f[$i], $tmp_folder) !== false) {
458
  $tmp_folder = '';
459
  }
460
+
461
  if( is_dir( ABSPATH . $f[$i] ) ) {
462
  //$fi = $this->directoryToArray(ABSPATH . $f[$i], true );
463
  $tmp_folder = $f[$i];
567
  $files = array_merge($files, $this->directoryToArray($folder, true));
568
  }
569
  }
570
+
571
  $files = array_values( array_unique($files) );
572
+
573
  return $files;
574
  }
575
 
596
  } else {
597
  $d1 = strtolower($tmp[0]);
598
  }
599
+ $base_dir = $tmp[0];
600
  unset($tmp[0]);
601
  if (function_exists('mb_strtolower')) {
602
  $d2 = mb_strtolower(implode('/', $tmp));
604
  $d2 = strtolower(implode('/', $tmp));
605
  }
606
 
607
+ /*if (stripos($d2, 'cache') !== false ) {
608
+ WPAdm_Core::log( __('Skip of Cache-Folder ','dropbox-backup') . $directory);
609
+ return array();
610
+ } */
611
+
612
  if (strpos($d2, 'cache') !== false && isset($tmp[0]) && !in_array($tmp[0], array('plugins', 'themes')) ) {
613
  WPAdm_Core::log(__('Skip of Cache-Folder ','dropbox-backup') . $directory);
614
  return array();
615
  }
616
+
617
+ if (!empty($d2) && isset( $base_dir ) && BackupsFoldersExclude( basename( $d2 ), $base_dir ) ) {
618
+ WPAdm_Core::log( sprintf( __('Skip backup folder of another backup plugin "%s" ','dropbox-backup'), basename( $d2 ) ) );
619
+ return array();
620
+ }
621
+
622
  if(strpos($directory, 'wpadm_backups') !== false || strpos($directory, 'Dropbox_Backup') !== false) {
623
  return array();
624
  }
695
  private function getArchiveName($name)
696
  {
697
  //WPAdm_Core::log("{$name}-*.zip");
698
+ $targz = WPAdm_Running::getCommandResultData('test_targz_archive');
699
+ if (!empty($targz) && $targz === true ) {
700
+ $archives = glob("{$name}-*.tar.gz");
701
+ } else {
702
+ $archives = glob("{$name}-*.zip");
703
+ }
704
+
705
  if (empty($archives)) {
706
+ if (!empty($targz) && $targz === true ) {
707
+ return "{$name}-1.tar.gz";
708
+ } else {
709
+ return "{$name}-1.zip";
710
+ }
711
  }
712
  $n = count($archives);
713
+ if (!empty($targz) && $targz === true ) {
714
+ $f = "{$name}-{$n}.tar.gz";
715
+ } else {
716
+ $f = "{$name}-{$n}.zip";
717
+ }
718
  return $f;
719
  }
720
 
721
  private function getNextArchiveName($name)
722
  {
723
+ $targz = WPAdm_Running::getCommandResultData('test_targz_archive');
724
+ if (!empty($targz) && $targz === true ) {
725
+ $archives = glob("{$name}-*.tar.gz");
726
+ } else {
727
+ $archives = glob("{$name}-*.zip");
728
+ }
729
  $n = 1 + count($archives);
730
+ if (!empty($targz) && $targz === true ) {
731
+ $a = "{$name}-{$n}.tar.gz";
732
+ } else {
733
+ $a = "{$name}-{$n}.zip";
734
+ }
735
  //WPAdm_Core::log($a);
736
  return $a;
737
  }
modules/archive.php ADDED
@@ -0,0 +1,783 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*--------------------------------------------------
3
+ | TAR/GZIP/BZIP2/ZIP ARCHIVE CLASSES 2.1
4
+ | By Devin Doucette
5
+ | Copyright (c) 2005 Devin Doucette
6
+ | Email: darksnoopy@shaw.ca
7
+ +--------------------------------------------------
8
+ | Email bugs/suggestions to darksnoopy@shaw.ca
9
+ +--------------------------------------------------
10
+ | This script has been created and released under
11
+ | the GNU GPL and is free to use and redistribute
12
+ | only if this copyright statement is not removed
13
+ +--------------------------------------------------*/
14
+
15
+ class wpadm_archive_class
16
+ {
17
+ function wpadm_archive_class($name = '')
18
+ {
19
+ $this->options = array (
20
+ 'basedir' => ".",
21
+ 'name' => $name,
22
+ 'prepend' => "",
23
+ 'delete_path_in_archive' => "",
24
+ 'inmemory' => 0,
25
+ 'overwrite' => 0,
26
+ 'recurse' => 1,
27
+ 'storepaths' => 1,
28
+ 'followlinks' => 0,
29
+ 'level' => 3,
30
+ 'method' => 1,
31
+ 'sfx' => "",
32
+ 'type' => "",
33
+ 'comment' => ""
34
+ );
35
+ $this->files = array ();
36
+ $this->exclude = array ();
37
+ $this->include = array ();
38
+ $this->storeonly = array ();
39
+ $this->error = array ();
40
+ $this->warning = array ();
41
+ }
42
+
43
+ function set_options($options)
44
+ {
45
+ foreach ($options as $key => $value)
46
+ $this->options[$key] = $value;
47
+ if (!empty ($this->options['basedir']))
48
+ {
49
+ $this->options['basedir'] = str_replace("\\", "/", $this->options['basedir']);
50
+ $this->options['basedir'] = preg_replace("/\/+/", "/", $this->options['basedir']);
51
+ $this->options['basedir'] = preg_replace("/\/$/", "", $this->options['basedir']);
52
+ }
53
+ if (!empty ($this->options['name']))
54
+ {
55
+ $this->options['name'] = str_replace("\\", "/", $this->options['name']);
56
+ $this->options['name'] = preg_replace("/\/+/", "/", $this->options['name']);
57
+ }
58
+ if (!empty ($this->options['prepend']))
59
+ {
60
+ $this->options['prepend'] = str_replace("\\", "/", $this->options['prepend']);
61
+ $this->options['prepend'] = preg_replace("/^(\.*\/+)+/", "", $this->options['prepend']);
62
+ $this->options['prepend'] = preg_replace("/\/+/", "/", $this->options['prepend']);
63
+ $this->options['prepend'] = preg_replace("/\/$/", "", $this->options['prepend']) . "/";
64
+ }
65
+ if ( !empty($this->options['delete_path_in_archive'])) {
66
+ $this->options['delete_path_in_archive'] = str_replace("\\", "/", $this->options['delete_path_in_archive']);
67
+ }
68
+ }
69
+
70
+ function create_archive()
71
+ {
72
+ $this->make_list();
73
+
74
+ if ($this->options['inmemory'] == 0)
75
+ {
76
+ $pwd = getcwd();
77
+ chdir($this->options['basedir']);
78
+ if ($this->options['overwrite'] == 0 && file_exists($this->options['name'] . ($this->options['type'] == "gzip" || $this->options['type'] == "bzip" ? ".tmp" : "")))
79
+ {
80
+ $this->error[] = "File {$this->options['name']} already exists.";
81
+ chdir($pwd);
82
+ return 0;
83
+ }
84
+ else if ($this->archive = @fopen($this->options['name'] . ($this->options['type'] == "gzip" || $this->options['type'] == "bzip" ? ".tmp" : ""), "wb+"))
85
+ chdir($pwd);
86
+ else
87
+ {
88
+ $this->error[] = "Could not open {$this->options['name']} for writing.";
89
+ chdir($pwd);
90
+ return 0;
91
+ }
92
+ }
93
+ else
94
+ $this->archive = "";
95
+
96
+ switch ($this->options['type'])
97
+ {
98
+ case "zip":
99
+ if (!$this->create_zip())
100
+ {
101
+ $this->error[] = "Could not create zip file.";
102
+ return 0;
103
+ }
104
+ break;
105
+ case "bzip":
106
+ if (!$this->create_tar())
107
+ {
108
+ $this->error[] = "Could not create tar file.";
109
+ return 0;
110
+ }
111
+ if (!$this->create_bzip())
112
+ {
113
+ $this->error[] = "Could not create bzip2 file.";
114
+ return 0;
115
+ }
116
+ break;
117
+ case "gzip":
118
+ if (!$this->create_tar())
119
+ {
120
+ $this->error[] = "Could not create tar file.";
121
+ return 0;
122
+ }
123
+ if (!$this->create_gzip())
124
+ {
125
+ $this->error[] = "Could not create gzip file.";
126
+ return 0;
127
+ }
128
+ break;
129
+ case "tar":
130
+ if (!$this->create_tar())
131
+ {
132
+ $this->error[] = "Could not create tar file.";
133
+ return 0;
134
+ }
135
+ }
136
+
137
+ if ($this->options['inmemory'] == 0)
138
+ {
139
+ fclose($this->archive);
140
+ if ($this->options['type'] == "gzip" || $this->options['type'] == "bzip") {
141
+ if (file_exists($this->options['basedir'] . "/" . $this->options['name'] . ".tmp")) {
142
+ unlink( $this->options['basedir'] . "/" . $this->options['name'] . ".tmp" );
143
+ } elseif (file_exists($this->options['name'] . ".tmp")) {
144
+ unlink( $this->options['name'] . ".tmp" );
145
+ }
146
+ }
147
+ }
148
+ }
149
+
150
+ function add_data($data)
151
+ {
152
+ if ($this->options['inmemory'] == 0)
153
+ fwrite($this->archive, $data);
154
+ else
155
+ $this->archive .= $data;
156
+ }
157
+
158
+ function make_list()
159
+ {
160
+ if (!empty ($this->exclude))
161
+ foreach ($this->files as $key => $value)
162
+ foreach ($this->exclude as $current)
163
+ if ($value['name'] == $current['name'])
164
+ unset ($this->files[$key]);
165
+ if (!empty ($this->storeonly))
166
+ foreach ($this->files as $key => $value)
167
+ foreach ($this->storeonly as $current)
168
+ if ($value['name'] == $current['name'])
169
+ $this->files[$key]['method'] = 0;
170
+ unset ($this->exclude, $this->storeonly);
171
+ }
172
+
173
+ function add_files($list)
174
+ {
175
+ $temp = $this->list_files($list);
176
+ foreach ($temp as $current)
177
+ $this->files[] = $current;
178
+
179
+ }
180
+
181
+ function exclude_files($list)
182
+ {
183
+ $temp = $this->list_files($list);
184
+ foreach ($temp as $current)
185
+ $this->exclude[] = $current;
186
+ }
187
+
188
+ function include_files($list)
189
+ {
190
+ if (is_array($list)) {
191
+ $temp = $this->list_files($list);
192
+ foreach ($temp as $current)
193
+ $this->include[] = $current;
194
+ } elseif (is_string($list)) {
195
+ $this->include = $list;
196
+ }
197
+ }
198
+
199
+ function store_files($list)
200
+ {
201
+ $temp = $this->list_files($list);
202
+ foreach ($temp as $current)
203
+ $this->storeonly[] = $current;
204
+ }
205
+
206
+ function list_files($list)
207
+ {
208
+ if (!is_array ($list))
209
+ {
210
+ $temp = $list;
211
+ $list = array ($temp);
212
+ unset ($temp);
213
+ }
214
+
215
+ $files = array ();
216
+
217
+ $pwd = getcwd();
218
+ chdir($this->options['basedir']);
219
+
220
+ foreach ($list as $current)
221
+ {
222
+ $current = str_replace("\\", "/", $current);
223
+ $current = preg_replace("/\/+/", "/", $current);
224
+ $current = preg_replace("/\/$/", "", $current);
225
+ if (strstr($current, "*"))
226
+ {
227
+ $regex = preg_replace("/([\\\^\$\.\[\]\|\(\)\?\+\{\}\/])/", "\\\\\\1", $current);
228
+ $regex = str_replace("*", ".*", $regex);
229
+ $dir = strstr($current, "/") ? substr($current, 0, strrpos($current, "/")) : ".";
230
+ $temp = $this->parse_dir($dir);
231
+ foreach ($temp as $current2)
232
+ if (preg_match("/^{$regex}$/i", $current2['name']))
233
+ $files[] = $current2;
234
+ unset ($regex, $dir, $temp, $current);
235
+ }
236
+ else if (@is_dir($current))
237
+ {
238
+ $temp = $this->parse_dir($current);
239
+ foreach ($temp as $file)
240
+ $files[] = $file;
241
+ unset ($temp, $file);
242
+ }
243
+ else if (@file_exists($current))
244
+ $files[] = array ('name' => $current, 'name2' => $this->options['prepend'] .
245
+ preg_replace("/(\.+\/+)+/", "", ($this->options['storepaths'] == 0 && strstr($current, "/")) ?
246
+ substr($current, strrpos($current, "/") + 1) : ( !empty($this->options['delete_path_in_archive'] ) ? str_replace($this->options['delete_path_in_archive'] , '', $current) : $current ) ),
247
+ 'type' => @is_link($current) && $this->options['followlinks'] == 0 ? 2 : 0,
248
+ 'ext' => substr($current, strrpos($current, ".")), 'stat' => stat($current));
249
+ }
250
+
251
+ chdir($pwd);
252
+
253
+ unset ($current, $pwd);
254
+
255
+ usort($files, array ("archive", "sort_files"));
256
+
257
+ return $files;
258
+ }
259
+
260
+ function parse_dir($dirname)
261
+ {
262
+ if ($this->options['storepaths'] == 1 && !preg_match("/^(\.+\/*)+$/", $dirname))
263
+ $files = array (array ('name' => $dirname, 'name2' => $this->options['prepend'] .
264
+ preg_replace("/(\.+\/+)+/", "", ($this->options['storepaths'] == 0 && strstr($dirname, "/")) ?
265
+ substr($dirname, strrpos($dirname, "/") + 1) : $dirname), 'type' => 5, 'stat' => stat($dirname)));
266
+ else
267
+ $files = array ();
268
+ $dir = @opendir($dirname);
269
+
270
+ while ($file = @readdir($dir))
271
+ {
272
+ $fullname = $dirname . "/" . $file;
273
+ if ($file == "." || $file == "..")
274
+ continue;
275
+ else if (@is_dir($fullname))
276
+ {
277
+ if (empty ($this->options['recurse']))
278
+ continue;
279
+ $temp = $this->parse_dir($fullname);
280
+ foreach ($temp as $file2)
281
+ $files[] = $file2;
282
+ }
283
+ else if (@file_exists($fullname))
284
+ $files[] = array ('name' => $fullname, 'name2' => $this->options['prepend'] .
285
+ preg_replace("/(\.+\/+)+/", "", ($this->options['storepaths'] == 0 && strstr($fullname, "/")) ?
286
+ substr($fullname, strrpos($fullname, "/") + 1) : $fullname),
287
+ 'type' => @is_link($fullname) && $this->options['followlinks'] == 0 ? 2 : 0,
288
+ 'ext' => substr($file, strrpos($file, ".")), 'stat' => stat($fullname));
289
+ }
290
+
291
+ @closedir($dir);
292
+
293
+ return $files;
294
+ }
295
+
296
+ function sort_files($a, $b)
297
+ {
298
+ if ($a['type'] != $b['type'])
299
+ if ($a['type'] == 5 || $b['type'] == 2)
300
+ return -1;
301
+ else if ($a['type'] == 2 || $b['type'] == 5)
302
+ return 1;
303
+ else if ($a['type'] == 5)
304
+ return strcmp(strtolower($a['name']), strtolower($b['name']));
305
+ else if ($a['ext'] != $b['ext'])
306
+ return strcmp($a['ext'], $b['ext']);
307
+ else if ($a['stat'][7] != $b['stat'][7])
308
+ return $a['stat'][7] > $b['stat'][7] ? -1 : 1;
309
+ else
310
+ return strcmp(strtolower($a['name']), strtolower($b['name']));
311
+ return 0;
312
+ }
313
+
314
+ function download_file()
315
+ {
316
+ if ($this->options['inmemory'] == 0)
317
+ {
318
+ $this->error[] = "Can only use download_file() if archive is in memory. Redirect to file otherwise, it is faster.";
319
+ return;
320
+ }
321
+ switch ($this->options['type'])
322
+ {
323
+ case "zip":
324
+ header("Content-Type: application/zip");
325
+ break;
326
+ case "bzip":
327
+ header("Content-Type: application/x-bzip2");
328
+ break;
329
+ case "gzip":
330
+ header("Content-Type: application/x-gzip");
331
+ break;
332
+ case "tar":
333
+ header("Content-Type: application/x-tar");
334
+ }
335
+ $header = "Content-Disposition: attachment; filename=\"";
336
+ $header .= strstr($this->options['name'], "/") ? substr($this->options['name'], strrpos($this->options['name'], "/") + 1) : $this->options['name'];
337
+ $header .= "\"";
338
+ header($header);
339
+ header("Content-Length: " . strlen($this->archive));
340
+ header("Content-Transfer-Encoding: binary");
341
+ header("Cache-Control: no-cache, must-revalidate, max-age=60");
342
+ header("Expires: Sat, 01 Jan 2000 12:00:00 GMT");
343
+ print($this->archive);
344
+ }
345
+
346
+ function createDir($dir, $dir_to)
347
+ {
348
+ $file = basename($dir);
349
+ if (strpos($file, '.') !== false) {
350
+ $dir = substr($dir, 0, strlen($dir) - strlen($file));
351
+ }
352
+ $dir = str_replace("\\", '/', $dir);
353
+ $dirs_array = explode("/", $dir);
354
+ $n = count($dirs_array);
355
+ $dir_tmp = str_replace("\\", '/', $dir_to);
356
+ for($i = 0; $i < $n; $i++) {
357
+ $dir_tmp .= "/" . $dirs_array[$i];
358
+ if (!is_dir($dir_tmp) && !file_exists( $dir_tmp ) ) {
359
+ mkdir( $dir_tmp );
360
+ }
361
+ }
362
+ }
363
+
364
+ }
365
+
366
+ class wpadm_tar_file extends wpadm_archive_class
367
+ {
368
+ function wpadm_tar_file($name)
369
+ {
370
+ $this->wpadm_archive_class($name);
371
+ $this->options['type'] = "tar";
372
+ }
373
+
374
+ function create_tar()
375
+ {
376
+ $pwd = getcwd();
377
+ chdir($this->options['basedir']);
378
+
379
+ foreach ($this->files as $current)
380
+ {
381
+ if ($current['name'] == $this->options['name'])
382
+ continue;
383
+ if (strlen($current['name2']) > 99)
384
+ {
385
+ $path = substr($current['name2'], 0, strpos($current['name2'], "/", strlen($current['name2']) - 100) + 1);
386
+ $current['name2'] = substr($current['name2'], strlen($path));
387
+ if (strlen($path) > 154 || strlen($current['name2']) > 99)
388
+ {
389
+ $this->error[] = "Could not add {$path}{$current['name2']} to archive because the filename is too long.";
390
+ continue;
391
+ }
392
+ }
393
+ $block = pack("a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155a12", $current['name2'], sprintf("%07o",
394
+ $current['stat'][2]), sprintf("%07o", $current['stat'][4]), sprintf("%07o", $current['stat'][5]),
395
+ sprintf("%011o", $current['type'] == 2 ? 0 : $current['stat'][7]), sprintf("%011o", $current['stat'][9]),
396
+ " ", $current['type'], $current['type'] == 2 ? @readlink($current['name']) : "", "ustar ", " ",
397
+ "Unknown", "Unknown", "", "", !empty ($path) ? $path : "", "");
398
+
399
+ $checksum = 0;
400
+ for ($i = 0; $i < 512; $i++)
401
+ $checksum += ord(substr($block, $i, 1));
402
+ $checksum = pack("a8", sprintf("%07o", $checksum));
403
+ $block = substr_replace($block, $checksum, 148, 8);
404
+
405
+ if ($current['type'] == 2 || $current['stat'][7] == 0)
406
+ $this->add_data($block);
407
+ else if ($fp = @fopen($current['name'], "rb"))
408
+ {
409
+ $this->add_data($block);
410
+ while ($temp = fread($fp, 1048576))
411
+ $this->add_data($temp);
412
+ if ($current['stat'][7] % 512 > 0)
413
+ {
414
+ $temp = "";
415
+ for ($i = 0; $i < 512 - $current['stat'][7] % 512; $i++)
416
+ $temp .= "\0";
417
+ $this->add_data($temp);
418
+ }
419
+ fclose($fp);
420
+ }
421
+ else
422
+ $this->error[] = "Could not open file {$current['name']} for reading. It was not added.";
423
+ }
424
+
425
+ $this->add_data(pack("a1024", ""));
426
+
427
+ chdir($pwd);
428
+
429
+ return 1;
430
+ }
431
+
432
+ function extract_files()
433
+ {
434
+ $pwd = getcwd();
435
+ chdir($this->options['basedir']);
436
+
437
+ if ($fp = $this->open_archive())
438
+ {
439
+ if ($this->options['inmemory'] == 1)
440
+ $this->files = array ();
441
+
442
+ while ($block = fread($fp, 512))
443
+ {
444
+ $temp = unpack("A100name/A8mode/A8uid/A8gid/A12size/A12mtime/A8checksum/A1type/A100symlink/A6magic/A2temp/A32temp/A32temp/A8temp/A8temp/A155prefix/A12temp", $block);
445
+
446
+ $file = array (
447
+ 'name' => trim( $temp['prefix'] ) . trim( $temp['name'] ),
448
+ 'stat' => array (
449
+ 2 => $temp['mode'],
450
+ 4 => octdec($temp['uid']),
451
+ 5 => octdec($temp['gid']),
452
+ 7 => octdec($temp['size']),
453
+ 9 => octdec($temp['mtime']),
454
+ ),
455
+ 'checksum' => octdec($temp['checksum']),
456
+ 'type' => (int)$temp['type'],
457
+ 'magic' => $temp['magic'],
458
+ );
459
+ if ($file['checksum'] == 0x00000000)
460
+ break;
461
+ else if (substr($file['magic'], 0, 5) != "ustar")
462
+ {
463
+ $this->error[] = "This script does not support extracting this type of tar file." . "(" . substr($file['magic'], 0, 5) . ")";
464
+ break;
465
+ }
466
+ $block = substr_replace($block, " ", 148, 8);
467
+ $checksum = 0;
468
+ for ($i = 0; $i < 512; $i++)
469
+ $checksum += ord(substr($block, $i, 1));
470
+ if ($file['checksum'] != $checksum)
471
+ $this->error[] = "Could not extract from {$this->options['name']}, it is corrupt.";
472
+
473
+ if ($file['type'] == 0) {
474
+ if ( !empty( $this->exclude ) ) {
475
+ if (is_array($this->exclude)) {
476
+ if ( in_array($file['name'], $this->exclude) ) {
477
+ continue;
478
+ }
479
+ } elseif (@function_exists($this->exclude)) {
480
+ $function = $this->exclude;
481
+ if ( $function($file['name']) === true ) {
482
+ continue;
483
+ }
484
+ }
485
+ }
486
+
487
+ if (!empty($this->include)) {
488
+ if (is_array($this->include)) {
489
+ if ( !in_array($file['name'], $this->include) ) {
490
+ continue;
491
+ } elseif (!preg_match($this->include, $file['name'])) {
492
+ continue;
493
+ }
494
+ }
495
+ }
496
+ $this->createDir($file['name'], $this->options['basedir']);
497
+ }
498
+ if ($this->options['inmemory'] == 1)
499
+ {
500
+ $file['data'] = fread($fp, $file['stat'][7]);
501
+ fread($fp, (512 - $file['stat'][7] % 512) == 512 ? 0 : (512 - $file['stat'][7] % 512));
502
+ unset ($file['checksum'], $file['magic']);
503
+ $this->files[] = $file;
504
+ }
505
+ else if ($file['type'] == 5)
506
+ {
507
+ if (!is_dir($file['name']))
508
+ mkdir($file['name'], $file['stat'][2]);
509
+ }
510
+ else if ($this->options['overwrite'] == 0 && file_exists($file['name']))
511
+ {
512
+ $this->error[] = "{$file['name']} already exists.";
513
+ continue;
514
+ }
515
+ else if ($file['type'] == 2)
516
+ {
517
+ symlink($temp['symlink'], $file['name']);
518
+ chmod($file['name'], $file['stat'][2]);
519
+ }
520
+ else if ($new = @fopen($file['name'], "wb"))
521
+ {
522
+ if ($file['stat'][7] == 0) {
523
+ fwrite($new, '');
524
+ } else {
525
+ fwrite($new, fread($fp, $file['stat'][7]));
526
+ }
527
+
528
+ $read_next = (512 - $file['stat'][7] % 512) == 512 ? 0 : (512 - $file['stat'][7] % 512);
529
+ if ($read_next != 0) {
530
+ fread($fp, $read_next);
531
+ }
532
+ fclose($new);
533
+ //chmod($file['name'], $file['stat'][2]);
534
+ }
535
+ else
536
+ {
537
+
538
+ $this->warning[] = "Could not open {$file['name']} for writing.";
539
+ continue;
540
+ }
541
+ //chown($file['name'], $file['stat'][4]);
542
+ //chgrp($file['name'], $file['stat'][5]);
543
+ //touch($file['name'], $file['stat'][9]);
544
+ unset ($file);
545
+ }
546
+ }
547
+ else
548
+ $this->error[] = "Could not open file {$this->options['name']}";
549
+
550
+ chdir($pwd);
551
+ }
552
+
553
+ function open_archive()
554
+ {
555
+ return @fopen($this->options['name'], "rb");
556
+ }
557
+ }
558
+
559
+ class wpadm_gzip_file extends wpadm_tar_file
560
+ {
561
+ function wpadm_gzip_file($name)
562
+ {
563
+ $this->wpadm_tar_file($name);
564
+ $this->options['type'] = "gzip";
565
+ }
566
+
567
+ function create_gzip()
568
+ {
569
+ if ($this->options['inmemory'] == 0)
570
+ {
571
+ $pwd = getcwd();
572
+ chdir($this->options['basedir']);
573
+ if ($fp = gzopen($this->options['name'], "wb{$this->options['level']}"))
574
+ {
575
+ fseek($this->archive, 0);
576
+ while ($temp = fread($this->archive, 1048576))
577
+ gzwrite($fp, $temp);
578
+ gzclose($fp);
579
+ chdir($pwd);
580
+ }
581
+ else
582
+ {
583
+ $this->error[] = "Could not open {$this->options['name']} for writing.";
584
+ chdir($pwd);
585
+ return 0;
586
+ }
587
+ }
588
+ else
589
+ $this->archive = gzencode($this->archive, $this->options['level']);
590
+
591
+ return 1;
592
+ }
593
+
594
+ function extract_gz_files()
595
+ {
596
+ $pwd = getcwd();
597
+ chdir($this->options['basedir']);
598
+ $tmp_file = $this->options['name'] . ".tmp" ;
599
+ $tmp_w = fopen($tmp_file, "wb");
600
+ if ($tmp_w) {
601
+ if ($fp = gzopen($this->options['name'], "rb{$this->options['level']}"))
602
+ {
603
+ fseek($tmp_w, 0);
604
+ while ($temp = gzread($fp, 1048576))
605
+ fwrite($tmp_w, $temp);
606
+ gzclose($fp);
607
+ chdir($pwd);
608
+ }
609
+ else
610
+ {
611
+ $this->error[] = "Could not open {$this->options['name']} for reading.";
612
+ chdir($pwd);
613
+ return 0;
614
+ }
615
+
616
+ fclose($tmp_w);
617
+ $this->options['name'] = $tmp_file;
618
+ $this->extract_files();
619
+ if (file_exists($tmp_file)) {
620
+ unlink($tmp_file);
621
+ }
622
+ } else {
623
+ $this->error[] = "Could not open {$tmp_file} for writing.";
624
+ chdir($pwd);
625
+ return 0;
626
+ }
627
+ return 1;
628
+ }
629
+
630
+ function open_archive()
631
+ {
632
+ return @gzopen($this->options['name'], "rb");
633
+ }
634
+ }
635
+
636
+ class wpadm_bzip_file extends wpadm_tar_file
637
+ {
638
+ function wpadm_bzip_file($name)
639
+ {
640
+ $this->wpadm_tar_file($name);
641
+ $this->options['type'] = "bzip";
642
+ }
643
+
644
+ function create_bzip()
645
+ {
646
+ if ($this->options['inmemory'] == 0)
647
+ {
648
+ $pwd = getcwd();
649
+ chdir($this->options['basedir']);
650
+ if ($fp = bzopen($this->options['name'], "wb"))
651
+ {
652
+ fseek($this->archive, 0);
653
+ while ($temp = fread($this->archive, 1048576))
654
+ bzwrite($fp, $temp);
655
+ bzclose($fp);
656
+ chdir($pwd);
657
+ }
658
+ else
659
+ {
660
+ $this->error[] = "Could not open {$this->options['name']} for writing.";
661
+ chdir($pwd);
662
+ return 0;
663
+ }
664
+ }
665
+ else
666
+ $this->archive = bzcompress($this->archive, $this->options['level']);
667
+
668
+ return 1;
669
+ }
670
+
671
+ function open_archive()
672
+ {
673
+ return @bzopen($this->options['name'], "rb");
674
+ }
675
+ }
676
+
677
+ class wpadm_zip_file extends wpadm_archive_class
678
+ {
679
+ function wpadm_zip_file($name)
680
+ {
681
+ $this->wpadm_archive_class($name);
682
+ $this->options['type'] = "zip";
683
+ }
684
+
685
+ function create_zip()
686
+ {
687
+ $files = 0;
688
+ $offset = 0;
689
+ $central = "";
690
+
691
+ if (!empty ($this->options['sfx']))
692
+ if ($fp = @fopen($this->options['sfx'], "rb"))
693
+ {
694
+ $temp = fread($fp, filesize($this->options['sfx']));
695
+ fclose($fp);
696
+ $this->add_data($temp);
697
+ $offset += strlen($temp);
698
+ unset ($temp);
699
+ }
700
+ else
701
+ $this->error[] = "Could not open sfx module from {$this->options['sfx']}.";
702
+
703
+ $pwd = getcwd();
704
+ chdir($this->options['basedir']);
705
+
706
+ foreach ($this->files as $current)
707
+ {
708
+ if ($current['name'] == $this->options['name'])
709
+ continue;
710
+
711
+ $timedate = explode(" ", date("Y n j G i s", $current['stat'][9]));
712
+ $timedate = ($timedate[0] - 1980 << 25) | ($timedate[1] << 21) | ($timedate[2] << 16) |
713
+ ($timedate[3] << 11) | ($timedate[4] << 5) | ($timedate[5]);
714
+
715
+ $block = pack("VvvvV", 0x04034b50, 0x000A, 0x0000, (isset($current['method']) || $this->options['method'] == 0) ? 0x0000 : 0x0008, $timedate);
716
+
717
+ if ($current['stat'][7] == 0 && $current['type'] == 5)
718
+ {
719
+ $block .= pack("VVVvv", 0x00000000, 0x00000000, 0x00000000, strlen($current['name2']) + 1, 0x0000);
720
+ $block .= $current['name2'] . "/";
721
+ $this->add_data($block);
722
+ $central .= pack("VvvvvVVVVvvvvvVV", 0x02014b50, 0x0014, $this->options['method'] == 0 ? 0x0000 : 0x000A, 0x0000,
723
+ (isset($current['method']) || $this->options['method'] == 0) ? 0x0000 : 0x0008, $timedate,
724
+ 0x00000000, 0x00000000, 0x00000000, strlen($current['name2']) + 1, 0x0000, 0x0000, 0x0000, 0x0000, $current['type'] == 5 ? 0x00000010 : 0x00000000, $offset);
725
+ $central .= $current['name2'] . "/";
726
+ $files++;
727
+ $offset += (31 + strlen($current['name2']));
728
+ }
729
+ else if ($current['stat'][7] == 0)
730
+ {
731
+ $block .= pack("VVVvv", 0x00000000, 0x00000000, 0x00000000, strlen($current['name2']), 0x0000);
732
+ $block .= $current['name2'];
733
+ $this->add_data($block);
734
+ $central .= pack("VvvvvVVVVvvvvvVV", 0x02014b50, 0x0014, $this->options['method'] == 0 ? 0x0000 : 0x000A, 0x0000,
735
+ (isset($current['method']) || $this->options['method'] == 0) ? 0x0000 : 0x0008, $timedate,
736
+ 0x00000000, 0x00000000, 0x00000000, strlen($current['name2']), 0x0000, 0x0000, 0x0000, 0x0000, $current['type'] == 5 ? 0x00000010 : 0x00000000, $offset);
737
+ $central .= $current['name2'];
738
+ $files++;
739
+ $offset += (30 + strlen($current['name2']));
740
+ }
741
+ else if ($fp = @fopen($current['name'], "rb"))
742
+ {
743
+ $temp = fread($fp, $current['stat'][7]);
744
+ fclose($fp);
745
+ $crc32 = crc32($temp);
746
+ if (!isset($current['method']) && $this->options['method'] == 1)
747
+ {
748
+ $temp = gzcompress($temp, $this->options['level']);
749
+ $size = strlen($temp) - 6;
750
+ $temp = substr($temp, 2, $size);
751
+ }
752
+ else
753
+ $size = strlen($temp);
754
+ $block .= pack("VVVvv", $crc32, $size, $current['stat'][7], strlen($current['name2']), 0x0000);
755
+ $block .= $current['name2'];
756
+ $this->add_data($block);
757
+ $this->add_data($temp);
758
+ unset ($temp);
759
+ $central .= pack("VvvvvVVVVvvvvvVV", 0x02014b50, 0x0014, $this->options['method'] == 0 ? 0x0000 : 0x000A, 0x0000,
760
+ (isset($current['method']) || $this->options['method'] == 0) ? 0x0000 : 0x0008, $timedate,
761
+ $crc32, $size, $current['stat'][7], strlen($current['name2']), 0x0000, 0x0000, 0x0000, 0x0000, 0x00000000, $offset);
762
+ $central .= $current['name2'];
763
+ $files++;
764
+ $offset += (30 + strlen($current['name2']) + $size);
765
+ }
766
+ else
767
+ $this->error[] = "Could not open file {$current['name']} for reading. It was not added.";
768
+ }
769
+
770
+ $this->add_data($central);
771
+
772
+ $this->add_data(pack("VvvvvVVv", 0x06054b50, 0x0000, 0x0000, $files, $files, strlen($central), $offset,
773
+ !empty ($this->options['comment']) ? strlen($this->options['comment']) : 0x0000));
774
+
775
+ if (!empty ($this->options['comment']))
776
+ $this->add_data($this->options['comment']);
777
+
778
+ chdir($pwd);
779
+
780
+ return 1;
781
+ }
782
+ }
783
+ ?>
modules/class-wpadm-archive.php CHANGED
@@ -4,7 +4,7 @@ if (!defined('PCLZIP_TEMPORARY_DIR')) {
4
  }
5
 
6
  if (!defined('PCLZIP_SEPARATOR')) {
7
- define('PCLZIP_SEPARATOR', ';');
8
  }
9
  if ( !class_exists("PclZip") ) {
10
  require_once dirname(__FILE__) . '/pclzip.lib.php';
@@ -13,7 +13,8 @@ if (!class_exists('WPAdm_Archive')) {
13
  class WPAdm_Archive {
14
  private $remove_path = '';
15
  private $files = array();
16
- private $file_zip = '';
 
17
  /**
18
  * @var PclZip
19
  */
@@ -22,13 +23,351 @@ if (!class_exists('WPAdm_Archive')) {
22
  public $error = '';
23
 
24
 
25
- public function __construct($file, $md5_file = '') {
 
 
 
 
 
26
  $this->file_zip = $file;
27
  $this->archive = new PclZip($file);
28
  $this->files[] = $file;
29
  $this->md5_file = $md5_file;
30
  }
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  public function add($file)
33
  {
34
  return $this->packed($file);
@@ -41,32 +380,42 @@ if (!class_exists('WPAdm_Archive')) {
41
  $n = count($files);
42
  $this->setToLogArhive( __('Add to archive: ', 'dropbox-backup') . $this->file_zip );
43
  for($i = 0; $i < $n; $i++) {
 
44
  $this->setToLogArhive(__("Add File: ", 'dropbox-backup' ) . $files[$i] . ' [' . WPADM_getSize( filesize($files[$i]) ) . ']' . '[' . wpadm_class::perm($files[$i]) . ']' );
45
  }
46
- WPAdm_Running::setCommandResultData('tmp_arhive_file2', $file);
47
- WPAdm_Running::setCommandResultData('tmp_arhive_name2', $this->file_zip);
48
- if (empty($this->remove_path)) {
 
49
  if ( WPAdm_Running::is_stop() ) {
50
- $res = $this->archive->add($file);
51
  }
52
- } else {
53
  if ( WPAdm_Running::is_stop() ) {
54
- $res = $this->archive->add($file, PCLZIP_OPT_REMOVE_PATH, $this->remove_path);
55
  }
56
- }
57
- if ( WPAdm_Running::is_stop() ) {
58
- if ($res == 0) {
59
- $this->checkError($file);
60
- WPAdm_Core::log( $this->archive->errorInfo(true) );
61
- if (file_exists($this->md5_file)) {
62
- unset($this->md5_file);
63
  }
64
- $this->error = $this->archive->errorInfo(true);
65
- return false;
66
- }
67
- WPAdm_Running::setCommandResultData('tmp_arhive_file', $file);
68
- WPAdm_Running::setCommandResultData('tmp_arhive_name', $this->file_zip);
69
- $this->saveMd5($file);
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
  }
72
  return true;
@@ -88,9 +437,9 @@ if (!class_exists('WPAdm_Archive')) {
88
 
89
  protected function saveMd5($file) {
90
  if ($this->md5_file) {
91
- $files = explode(',', $file); {
92
  foreach($files as $f) {
93
- file_put_contents($this->md5_file, $f . "\t" . @md5_file($f) . "\t" . basename($this->archive->zipname) . "\n", FILE_APPEND);
94
  }
95
  }
96
  }
@@ -99,7 +448,7 @@ if (!class_exists('WPAdm_Archive')) {
99
  public function setRemovePath($remove_path) {
100
  $this->remove_path = $remove_path;
101
  }
102
-
103
  public function setToLogArhive($msg)
104
  {
105
  $file_log = WPADM_Core::getTmpDir() . '/log-archive.log';
4
  }
5
 
6
  if (!defined('PCLZIP_SEPARATOR')) {
7
+ define('PCLZIP_SEPARATOR', '<|>');
8
  }
9
  if ( !class_exists("PclZip") ) {
10
  require_once dirname(__FILE__) . '/pclzip.lib.php';
13
  class WPAdm_Archive {
14
  private $remove_path = '';
15
  private $files = array();
16
+ public $file_zip = '';
17
+ private $type_backup = array();
18
  /**
19
  * @var PclZip
20
  */
23
  public $error = '';
24
 
25
 
26
+ private $method = '';
27
+
28
+ public function __construct($file, $md5_file = '') {
29
+ if (class_exists('wpadm_wp_full_backup_dropbox')) {
30
+ $this->type_backup = wpadm_wp_full_backup_dropbox::getTypeBackup();
31
+ }
32
  $this->file_zip = $file;
33
  $this->archive = new PclZip($file);
34
  $this->files[] = $file;
35
  $this->md5_file = $md5_file;
36
  }
37
 
38
+ public function zipArhive($file_to_arhive = array())
39
+ {
40
+ if ( isset( $this->type_backup['zip_archive'] ) && $this->type_backup['zip_archive'] == 1 && !empty($file_to_arhive) ) {
41
+ $command = $this->getCommandToArchive('zip_archive', $file_to_arhive);
42
+ if (!empty($command)) {
43
+ $result_command = @exec($command, $command_return);
44
+
45
+ $res = $this->parseResultZip($command_return);
46
+
47
+ if ($res['add'] == count($file_to_arhive)) {
48
+ $files = implode(PCLZIP_SEPARATOR, $file_to_arhive);
49
+ $this->saveMd5($files);
50
+ return true;
51
+ }
52
+ if ( file_exists( $this->file_zip ) && $res['error'] === 0 ) {
53
+ $files = implode(PCLZIP_SEPARATOR, $file_to_arhive);
54
+ $this->saveMd5($files);
55
+ return true;
56
+ }
57
+ }
58
+ }
59
+ return false;
60
+ }
61
+
62
+ public function targzArchive( $file_to_arhive = array() )
63
+ {
64
+ if ( isset( $this->type_backup['targz_archive'] ) && $this->type_backup['targz_archive'] == 1 && !empty($file_to_arhive) ) {
65
+
66
+ if ( $this->tarGzCommandArhive($file_to_arhive) ) {
67
+ return true;
68
+ }
69
+ if ( !function_exists( 'gzencode' ) ) {
70
+ $this->error = __( 'Functions for gz compression not available', 'dropbox-backup' );
71
+ return false;
72
+ }
73
+
74
+ if ( strpos($this->file_zip, '.zip') !== false ) {
75
+ $this->file_zip = str_replace('.zip', '.tar.gz', $this->file_zip);
76
+ }
77
+ $this->method = 'targz';
78
+
79
+ $this->archive = fopen( $this->file_zip, 'ab' );
80
+
81
+ $n = count($file_to_arhive);
82
+ for($i = 0; $i < $n; $i++) {
83
+ $this->addToTargz($file_to_arhive[$i], '');
84
+ $this->saveMd5( $file_to_arhive[$i] );
85
+ }
86
+ $this->close();
87
+ /* include_once dirname(__FILE__) . '/archive.php';
88
+ $gz = new wpadm_gzip_file($this->file_zip);
89
+ $gz->set_options( array('basedir' => ABSPATH, 'delete_path_in_archive' => $this->remove_path ) );
90
+ $gz->add_files( $file_to_arhive );
91
+ $gz->create_archive();
92
+ if (!empty( $gz->error ) ) {
93
+ $this->error = implode(" ", $gz->error );
94
+ WPAdm_Core::log( $this->error );
95
+ return false;
96
+ }
97
+ $this->saveMd5( implode( PCLZIP_SEPARATOR, $file_to_arhive) );
98
+ */
99
+
100
+ /*if ( strpos($this->file_zip, '.tar.gz') !== false ) {
101
+ $this->file_zip = str_replace('.tar.gz', '.zip', $this->file_zip);
102
+ } */
103
+
104
+ if ( file_exists($this->file_zip) ) {
105
+ return true;
106
+ }
107
+ }
108
+ return false;
109
+ }
110
+
111
+ private function addToTargz($file, $file_in)
112
+ {
113
+ $file = str_replace('\\', '/', $file);
114
+ if ( empty( $file_in ) ) {
115
+ $serach = str_replace('\\', '/', ABSPATH);
116
+ $file_in = str_replace($serach, '', $file);
117
+ }
118
+
119
+ $file_in = str_replace( array( "?", "<", ">", ":", "%","\"", "*", "|", chr(0) ) , '', $file_in );
120
+
121
+ if ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
122
+ clearstatcache(true, $file);
123
+ }
124
+
125
+ if ( ! is_readable( $file ) ) {
126
+ $this->error = sprintf( __( 'File %s is not readable or does not exist', 'dropbox-backup' ), $file );
127
+ return false;
128
+ }
129
+ $this->add_tar_file( $file, $file_in );
130
+
131
+ }
132
+
133
+ private function add_tar_file($file, $file_in)
134
+ {
135
+ if ( ! $this->check_archive( $file ) ) {
136
+ return false;
137
+ }
138
+ $chunk_size = 1024 * 1024 * 4;
139
+
140
+ //Limit string of file name in tar archive
141
+ if ( strlen( $file_in ) <= 100 ) {
142
+ $filename = $file_in;
143
+ $filename_prefix = "";
144
+ } else {
145
+ $filename_offset = strlen( $file_in ) - 100;
146
+ $split_pos = strpos( $file_in, '/', $filename_offset );
147
+ if ( $split_pos === FALSE ) {
148
+ $split_pos = strrpos( $file_in, '/' );
149
+ }
150
+ $filename = substr( $file_in, $split_pos + 1 );
151
+ $filename_prefix = substr( $file_in, 0, $split_pos );
152
+ if ( strlen( $filename ) > 100 ) {
153
+ $filename = substr( $filename, -100 );
154
+ WPAdm_Core::log( sprintf( __( 'File name "%1$s" is too long to be saved correctly in archive!', 'dropbox-backup' ), $file_in ) );
155
+ }
156
+ if ( strlen( $filename_prefix ) > 155 ) {
157
+ WPAdm_Core::log( sprintf( __( 'File path "%1$s" is too long to be saved correctly in archive!', 'dropbox-backup' ), $file_in) );
158
+ }
159
+ }
160
+ $file_stat = stat( $file );
161
+ if ( ! $file_stat ) {
162
+ return false;
163
+ }
164
+ $file_stat[ 'size' ] = abs( (int) $file_stat[ 'size' ] );
165
+ //open file
166
+ if ( $file_stat[ 'size' ] > 0 ) {
167
+ if ( ! ( $fd = fopen( $file, 'rb' ) ) ) {
168
+ $this->error = sprintf( __( 'Cannot open source file %s for archiving', 'dropbox-backup' ), $file );
169
+ return false;
170
+ }
171
+ }
172
+ $fileowner = __( "Unknown", "dropbox-backup" );
173
+ $filegroup = __( "Unknown", "dropbox-backup" );
174
+ if ( function_exists( 'posix_getpwuid' ) ) {
175
+ $info = posix_getpwuid( $file_stat[ 'uid' ] );
176
+ $fileowner = $info[ 'name' ];
177
+ $info = posix_getgrgid( $file_stat[ 'gid' ] );
178
+ $filegroup = $info[ 'name' ];
179
+ }
180
+ // Generate the TAR header for this file
181
+ $chunk = pack( "a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155a12",
182
+ $filename, //name of file 100
183
+ sprintf( "%07o", $file_stat[ 'mode' ] ), //file mode 8
184
+ sprintf( "%07o", $file_stat[ 'uid' ] ), //owner user ID 8
185
+ sprintf( "%07o", $file_stat[ 'gid' ] ), //owner group ID 8
186
+ sprintf( "%011o", $file_stat[ 'size' ] ), //length of file in bytes 12
187
+ sprintf( "%011o", $file_stat[ 'mtime' ] ), //modify time of file 12
188
+ " ", //checksum for header 8
189
+ 0, //type of file 0 or null = File, 5=Dir
190
+ "", //name of linked file 100
191
+ "ustar", //USTAR indicator 6
192
+ "00", //USTAR version 2
193
+ $fileowner, //owner user name 32
194
+ $filegroup, //owner group name 32
195
+ "", //device major number 8
196
+ "", //device minor number 8
197
+ $filename_prefix, //prefix for file name 155
198
+ "" ); //fill block 12
199
+
200
+ $checksum = 0;
201
+ for ( $i = 0; $i < 512; $i ++ ) {
202
+ $checksum += ord( substr( $chunk, $i, 1 ) );
203
+ }
204
+
205
+ $checksum = pack( "a8", sprintf( "%07o", $checksum ) );
206
+ $chunk = substr_replace( $chunk, $checksum, 148, 8 );
207
+
208
+ if ( isset( $fd ) && is_resource( $fd ) ) {
209
+ // read/write files in 512 bite Blocks
210
+ while ( ( $content = fread( $fd, 512 ) ) != '' ) {
211
+ $chunk .= pack( "a512", $content );
212
+ if ( strlen( $chunk ) >= $chunk_size ) {
213
+ if ( WPAdm_Running::is_stop() ) {
214
+ if ( $this->method == 'targz' ) {
215
+ $chunk = gzencode( $chunk );
216
+ }
217
+ if ( $this->method == 'tarbz2' ) {
218
+ $chunk = bzcompress( $chunk );
219
+ }
220
+ fwrite( $this->archive, $chunk );
221
+ $chunk = '';
222
+ }
223
+ }
224
+ }
225
+ fclose( $fd );
226
+ }
227
+
228
+ if ( ! empty( $chunk ) ) {
229
+ if ( $this->method == 'targz' ) {
230
+ $chunk = gzencode( $chunk );
231
+ }
232
+ if ( $this->method == 'tarbz2' ) {
233
+ $chunk = bzcompress( $chunk );
234
+ }
235
+ fwrite( $this->archive, $chunk );
236
+ }
237
+
238
+ return true;
239
+ }
240
+
241
+ private function check_archive( $file = '' ) {
242
+
243
+ $file_size = 0;
244
+ if ( ! empty( $file ) ) {
245
+ $file_size = filesize( $file );
246
+ if ( $file_size === FALSE ) {
247
+ $file_size = 0;
248
+ }
249
+ }
250
+
251
+ if ( is_resource( $this->archive ) ) {
252
+ $info_archive = fstat( $this->archive );
253
+ $archive_size = $info_archive[ 'size' ];
254
+ } else {
255
+ $archive_size = filesize( $this->file_zip );
256
+ if ( $archive_size === FALSE ) {
257
+ $archive_size = PHP_INT_MAX;
258
+ }
259
+ }
260
+
261
+ $archive_size = $archive_size + $file_size;
262
+ if ( $archive_size >= PHP_INT_MAX ) {
263
+ $this->error = sprintf( __( 'If %s will be added to your backup archive, the archive will be too large for operations with this PHP Version. You might want to consider splitting the backup job in multiple jobs with less files each.', 'dropbox-backup' ), $file_to_add );
264
+ return false;
265
+ }
266
+
267
+ return true;
268
+ }
269
+
270
+ public function close()
271
+ {
272
+ if ($this->method == 'targz') {
273
+ $end = pack( "a1024", "" );
274
+ if ( $this->method === 'targz' ) {
275
+ $end = gzencode( $end );
276
+ }
277
+ if ( $this->method === 'tarbz2' ) {
278
+ $end = bzcompress( $end );
279
+ }
280
+ fwrite( $this->archive, $end );
281
+ }
282
+ }
283
+
284
+ public function parseResultZip($command_return)
285
+ {
286
+ $add = 0;
287
+ $error = 0;
288
+ if (!empty( $command_return) ) {
289
+ $n = count($command_return);
290
+ for($i = 0; $i < $n; $i++) {
291
+ if (strpos($command_return[$i], 'add') !== false || strpos($command_return[$i], 'updating') !== false) {
292
+ $add ++;
293
+ } elseif (strpos($command_return[$i], 'error') !== false || strpos($command_return[$i], 'warning') !== false ) {
294
+ $error++;
295
+ $this->error .= " " . $command_return[$i];
296
+ }
297
+ }
298
+ }
299
+ return array( 'add' => $add, 'error' => $error );
300
+
301
+ }
302
+
303
+ public function tarGzCommandArhive($file_to_arhive = array())
304
+ {
305
+
306
+ $command = $this->getCommandToArchive('tar_archive', $file_to_arhive);
307
+ if (!empty($command)) {
308
+ $result_command = @exec ($command, $command_return);
309
+ if (count($file_to_arhive) == count($command_return)) {
310
+ $files = implode(PCLZIP_SEPARATOR, $file_to_arhive);
311
+ $this->saveMd5($files);
312
+ return true;
313
+ }
314
+ if (count($command_return) > 0) {
315
+ $files = implode(PCLZIP_SEPARATOR, $file_to_arhive);
316
+ $this->saveMd5($files);
317
+ return true;
318
+ }
319
+ if (file_exists($this->file_zip)) {
320
+ $files = implode(PCLZIP_SEPARATOR, $file_to_arhive);
321
+ $this->saveMd5($files);
322
+ return true;
323
+ }
324
+ $this->error = "Files not Adding to arhive";
325
+ if ( strpos($this->file_zip, '.tar.gz') !== false ) {
326
+ $this->file_zip = str_replace('.tar.gz', '.zip', $this->file_zip);
327
+ }
328
+ }
329
+ return false;
330
+ }
331
+
332
+ public function getCommandToArchive($type = 'zip_archive', $files = array() )
333
+ {
334
+ $return = '';
335
+ $remove_dir = '';
336
+ switch($type) {
337
+ case 'zip_archive':
338
+ if (!empty( $this->remove_path ) ) {
339
+ $remove_dir = 'cd ' . $this->remove_path . ' &&';
340
+ $files_str = '"' . implode('" "', $files) . '"';
341
+ $files_str = str_replace($this->remove_path, './', $files_str);
342
+ $zip = str_replace($this->remove_path, './', $this->file_zip);
343
+ } else {
344
+ $files_str = implode(' ', $files);
345
+ $zip = $this->file_zip;
346
+ }
347
+
348
+ $return .= trim( "$remove_dir zip {$zip} " . $files_str );
349
+ break;
350
+ case 'tar_archive':
351
+ if ( strpos($this->file_zip, '.zip') !== false ) {
352
+ $this->file_zip = str_replace('.zip', '.tar.gz', $this->file_zip);
353
+ }
354
+
355
+ if (!empty( $this->remove_path) ) {
356
+ $remove_dir = '-C ' . $this->remove_path . ' ';
357
+ }
358
+ $files_str = implode(' ', $files);
359
+ $files_str = str_replace($this->remove_path, './', $files_str);
360
+ $u = 'c';
361
+ if (file_exists($this->file_zip)) {
362
+ $u = 'r';
363
+ }
364
+ $return = trim( "tar -{$u}xvf {$this->file_zip} " . $remove_dir . $files_str );
365
+ break;
366
+ }
367
+ return $return;
368
+
369
+ }
370
+
371
  public function add($file)
372
  {
373
  return $this->packed($file);
380
  $n = count($files);
381
  $this->setToLogArhive( __('Add to archive: ', 'dropbox-backup') . $this->file_zip );
382
  for($i = 0; $i < $n; $i++) {
383
+
384
  $this->setToLogArhive(__("Add File: ", 'dropbox-backup' ) . $files[$i] . ' [' . WPADM_getSize( filesize($files[$i]) ) . ']' . '[' . wpadm_class::perm($files[$i]) . ']' );
385
  }
386
+ $file = implode(PCLZIP_SEPARATOR, $files);
387
+ $command_zip_test = WPAdm_Running::getCommandResultData('test_zip_archive');
388
+ $command_targz_test = WPAdm_Running::getCommandResultData('test_targz_archive');
389
+ if ( !empty($command_zip_test) && $command_zip_test === true ) {
390
  if ( WPAdm_Running::is_stop() ) {
391
+ return $this->zipArhive($files); // command zip
392
  }
393
+ } elseif( !empty($command_targz_test) && $command_targz_test === true ) {
394
  if ( WPAdm_Running::is_stop() ) {
395
+ return $this->targzArchive($files); // .tar.gz archive
396
  }
397
+ } else {
398
+ if (empty($this->remove_path)) {
399
+ if ( WPAdm_Running::is_stop() ) {
400
+ $res = $this->archive->add($file);
 
 
 
401
  }
402
+ } else {
403
+ if ( WPAdm_Running::is_stop() ) {
404
+ $res = $this->archive->add($file, PCLZIP_OPT_REMOVE_PATH, $this->remove_path);
405
+ }
406
+ }
407
+ if ( WPAdm_Running::is_stop() ) {
408
+ if ($res == 0) {
409
+ $this->checkError($file);
410
+ WPAdm_Core::log( $this->archive->errorInfo(true) );
411
+ if (file_exists($this->md5_file)) {
412
+ unset($this->md5_file);
413
+ }
414
+ $this->error = $this->archive->errorInfo(true);
415
+ return false;
416
+ }
417
+ $this->saveMd5($file);
418
+ }
419
  }
420
  }
421
  return true;
437
 
438
  protected function saveMd5($file) {
439
  if ($this->md5_file) {
440
+ $files = explode(PCLZIP_SEPARATOR, $file); {
441
  foreach($files as $f) {
442
+ file_put_contents($this->md5_file, $f . "\t" . @md5_file($f) . "\t" . basename($this->file_zip) . "\n", FILE_APPEND);
443
  }
444
  }
445
  }
448
  public function setRemovePath($remove_path) {
449
  $this->remove_path = $remove_path;
450
  }
451
+
452
  public function setToLogArhive($msg)
453
  {
454
  $file_log = WPADM_Core::getTmpDir() . '/log-archive.log';
modules/class-wpadm-mysqldump.php CHANGED
@@ -52,7 +52,7 @@ if (!class_exists('WPAdm_Mysqldump')) {
52
  if (!isset($proc_data['optimize'])) {
53
  if ( WPAdm_Running::is_stop() ) {
54
  $link = $this->connect($db);
55
- WPAdm_Core::log( __('Optimize Database Tables was started' ,'dropbox-backup') );
56
  $n = $link->query('SHOW TABLES');
57
  WPAdm_Process::init('optimization', $n);
58
  $result = $link->last_result;
@@ -70,10 +70,10 @@ if (!class_exists('WPAdm_Mysqldump')) {
70
  $tables[$res[0]] = 1;
71
  $proc_data['optimize_table'] = $tables;
72
  WPAdm_Running::setCommandResultData('db', $proc_data);
73
- $log = str_replace('%s', $res[0], __('Error to Optimize Table `%s`' ,'dropbox-backup') );
74
  WPAdm_Core::log($log);
75
  } else {
76
- $log = str_replace('%s', $res[0], __('Optimize Table `%s` was successfully' ,'dropbox-backup') );
77
  WPAdm_Core::log($log);
78
  WPAdm_Process::set('optimization', ( $i + 1 ) );
79
  }
@@ -81,7 +81,7 @@ if (!class_exists('WPAdm_Mysqldump')) {
81
  }
82
  }
83
  if ( WPAdm_Running::is_stop() ) {
84
- WPAdm_Core::log( __('Optimize Database Tables was Finished' ,'dropbox-backup') );
85
  $proc_data = WPAdm_Running::getCommandResultData('db');
86
  $proc_data['optimize'] = true;
87
  WPAdm_Running::setCommandResultData('db', $proc_data);
@@ -96,7 +96,7 @@ if (!class_exists('WPAdm_Mysqldump')) {
96
  if (!isset($proc_data['work'])) {
97
  $link = $this->connect($db);
98
  if ( WPAdm_Running::is_stop() ) {
99
- WPAdm_Core::log( __('MySQL of repair was started' ,'dropbox-backup') );
100
  $n = $link->query('SHOW TABLE STATUS;');
101
  WPAdm_Process::init('repair', $n);
102
  $result = $link->last_result;
@@ -113,7 +113,7 @@ if (!class_exists('WPAdm_Mysqldump')) {
113
  if ( WPAdm_Running::is_stop() ) {
114
  $row = get_object_vars( $result[$i] );
115
  $tables[] = $row;
116
- WPAdm_Core::log('Start repair table `' . $row['Name'] . '`' );
117
  $res = $link->query("REPAIR TABLE {$row['Name']};");
118
  if ($res == 1) {
119
  $proc_data = WPAdm_Running::getCommandResultData('repair');
@@ -123,7 +123,7 @@ if (!class_exists('WPAdm_Mysqldump')) {
123
  $this->setError($link->last_error);
124
  }
125
  WPAdm_Process::set('repair', ($i + 1) );
126
- WPAdm_Core::log('Finish repair table `' . $row['Name'] . '`');
127
  }
128
  }
129
  if ( WPAdm_Running::is_stop() ) {
@@ -141,7 +141,7 @@ if (!class_exists('WPAdm_Mysqldump')) {
141
  if (!isset($proc_data['mysqldump'])) {
142
  $link = $this->connect($db);
143
  if ( WPAdm_Running::is_stop() ) {
144
- WPAdm_Core::log( __('MySQL of Dump was started' ,'dropbox-backup') );
145
  $tables = array();
146
  $n = $link->query('SHOW TABLES');
147
  WPAdm_Process::init('mysqldump', $n);
@@ -189,36 +189,40 @@ if (!class_exists('WPAdm_Mysqldump')) {
189
  $proc_data = WPAdm_Running::getCommandResultData('db');
190
  $proc_data['mysqldump_table'][$table] = 1;
191
  WPAdm_Running::setCommandResultData('db', $proc_data);
192
- $log = str_replace('%s', $table, __('Add a table "%s" in the database dump' ,'dropbox-backup') );
193
  WPAdm_Core::log( $log );
194
  }
195
  }
196
  if ( WPAdm_Running::is_stop() ) {
197
  $while = true;
198
  while($while) {
199
- $insert_values = false;
200
  if ( WPAdm_Running::is_stop() ) {
201
  $table_db = WPAdm_Running::getCommandResultData('tabledb');
202
- if (isset($table_db[$table])) {
203
- if (isset($table_db[$table]['work']) && $table_db[$table]['work'] == 1) {
204
  $from = $table_db[$table]['from']; // value from
205
  $to = $table_db[$table]['to']; // value to
206
- $insert_values = true;
207
- }
208
  } else {
209
  $from = 0;
210
  $to = $this->rows;
211
- $insert_values = true;
212
  }
213
  }
214
-
215
  if (isset($from) && !empty($to) && $from >= 0 && $to >= 0 && $insert_values === true) {
216
  unset($link);
217
  $link = $this->connect($db);
218
- $num_fields = $link->query( 'SELECT * FROM ' . $table . " LIMIT {$from}, {$to}" );
219
  if ($num_fields > 0) {
220
- WPAdm_Core::log( $link->last_error ) ;
221
  $result2 = $link->last_result;
 
 
 
 
222
  for ($i = 0; $i < $num_fields; $i++) {
223
  if ( WPAdm_Running::is_stop() ) {
224
  $return = '';
@@ -235,41 +239,36 @@ if (!class_exists('WPAdm_Mysqldump')) {
235
  $return .= ");\n";
236
  file_put_contents($filename, $return, FILE_APPEND);
237
  $from += 1;
238
- $table_db = WPAdm_Running::getCommandResultData('tabledb');
239
- $table_db[$table]['from'] = $from;
240
  $table_db[$table]['to'] = $to;
241
  $table_db[$table]['work'] = 1;
242
  WPAdm_Running::setCommandResultData('tabledb', $table_db);
243
-
244
  }
245
  }
246
  }
247
- if ( WPAdm_Running::is_stop() ) {
248
- $log = str_replace(array('%s', '%from%', '%to%'), array($table, $from, $to), __('Add a table rows "%s" in the database dump from %from% to %to%' ,'dropbox-backup') );
249
- WPAdm_Core::log( $log );
250
- }
251
  } else {
252
  $while = false;
253
  if ( WPAdm_Running::is_stop() ) {
254
- $table_db = WPAdm_Running::getCommandResultData('tabledb');
255
  $table_db[$table]['work'] = 0;
256
- WPAdm_Running::setCommandResultData('tabledb', $table_db);
257
  WPAdm_Process::set('mysqldump', ( $key_tables + 1 ) );
258
  }
259
  }
260
  } else {
261
  $while = false;
262
  if ( WPAdm_Running::is_stop() ) {
263
- $table_db = WPAdm_Running::getCommandResultData('tabledb');
264
  $table_db[$table]['work'] = 0;
265
- WPAdm_Running::setCommandResultData('tabledb', $table_db);
266
  WPAdm_Process::set('mysqldump', ( $key_tables + 1 ) );
267
  }
268
  }
269
  }
270
  }
271
  if ( WPAdm_Running::is_stop() ) {
272
- $proc_data = WPAdm_Running::getCommandResultData('db');
273
  if (!isset($proc_data['mysqldump_table'][$table])) {
274
  $return ="\n\n\n";
275
  file_put_contents($filename, $return, FILE_APPEND);
@@ -279,7 +278,7 @@ if (!class_exists('WPAdm_Mysqldump')) {
279
  }
280
  if ( WPAdm_Running::is_stop() ) {
281
  unset($link);
282
- WPAdm_Core::log( __('MySQL of Dump was finished' ,'dropbox-backup') );
283
  $proc_data = WPAdm_Running::getCommandResultData('db');
284
  $proc_data['mysqldump'] = true;
285
  WPAdm_Running::setCommandResultData('db', $proc_data);
@@ -299,11 +298,11 @@ if (!class_exists('WPAdm_Mysqldump')) {
299
  public function restore($db, $file)
300
  {
301
  $link = $this->connect($db);
302
- WPAdm_Core::log( __('Restore Database was started' ,'dropbox-backup') );
303
  $fo = fopen($file, "r");
304
  if (!$fo) {
305
- WPAdm_Core::log( __('Error in open file dump' ,'dropbox-backup') );
306
- $this->setError( __('Error in open file dump' ,'dropbox-backup') );
307
  return false;
308
  }
309
  $sql = "";
@@ -324,7 +323,7 @@ if (!class_exists('WPAdm_Mysqldump')) {
324
  }
325
  }
326
  }
327
- WPAdm_Core::log(__('Restore Database was finished' ,'dropbox-backup'));
328
  }
329
  }
330
  }
52
  if (!isset($proc_data['optimize'])) {
53
  if ( WPAdm_Running::is_stop() ) {
54
  $link = $this->connect($db);
55
+ WPAdm_Core::log( __('Optimization of database tables was started' ,'dropbox-backup') );
56
  $n = $link->query('SHOW TABLES');
57
  WPAdm_Process::init('optimization', $n);
58
  $result = $link->last_result;
70
  $tables[$res[0]] = 1;
71
  $proc_data['optimize_table'] = $tables;
72
  WPAdm_Running::setCommandResultData('db', $proc_data);
73
+ $log = str_replace('%s', $res[0], __('Error during database table optimization: `%s`' ,'dropbox-backup') );
74
  WPAdm_Core::log($log);
75
  } else {
76
+ $log = str_replace('%s', $res[0], __('Database table optimization of `%s` was successfully' ,'dropbox-backup') );
77
  WPAdm_Core::log($log);
78
  WPAdm_Process::set('optimization', ( $i + 1 ) );
79
  }
81
  }
82
  }
83
  if ( WPAdm_Running::is_stop() ) {
84
+ WPAdm_Core::log( __('Optimization of database tables was Finished' ,'dropbox-backup') );
85
  $proc_data = WPAdm_Running::getCommandResultData('db');
86
  $proc_data['optimize'] = true;
87
  WPAdm_Running::setCommandResultData('db', $proc_data);
96
  if (!isset($proc_data['work'])) {
97
  $link = $this->connect($db);
98
  if ( WPAdm_Running::is_stop() ) {
99
+ WPAdm_Core::log( __('Repairing of MySQL database was started' ,'dropbox-backup') );
100
  $n = $link->query('SHOW TABLE STATUS;');
101
  WPAdm_Process::init('repair', $n);
102
  $result = $link->last_result;
113
  if ( WPAdm_Running::is_stop() ) {
114
  $row = get_object_vars( $result[$i] );
115
  $tables[] = $row;
116
+ WPAdm_Core::log('Start repairing of table `' . $row['Name'] . '`' );
117
  $res = $link->query("REPAIR TABLE {$row['Name']};");
118
  if ($res == 1) {
119
  $proc_data = WPAdm_Running::getCommandResultData('repair');
123
  $this->setError($link->last_error);
124
  }
125
  WPAdm_Process::set('repair', ($i + 1) );
126
+ WPAdm_Core::log('Table repairing of `' . $row['Name'] . '` was finished');
127
  }
128
  }
129
  if ( WPAdm_Running::is_stop() ) {
141
  if (!isset($proc_data['mysqldump'])) {
142
  $link = $this->connect($db);
143
  if ( WPAdm_Running::is_stop() ) {
144
+ WPAdm_Core::log( __('Creating of MySQL dump was started' ,'dropbox-backup') );
145
  $tables = array();
146
  $n = $link->query('SHOW TABLES');
147
  WPAdm_Process::init('mysqldump', $n);
189
  $proc_data = WPAdm_Running::getCommandResultData('db');
190
  $proc_data['mysqldump_table'][$table] = 1;
191
  WPAdm_Running::setCommandResultData('db', $proc_data);
192
+ $log = str_replace('%s', $table, __('Add table "%s" to the database dump' ,'dropbox-backup') );
193
  WPAdm_Core::log( $log );
194
  }
195
  }
196
  if ( WPAdm_Running::is_stop() ) {
197
  $while = true;
198
  while($while) {
199
+ $insert_values = false;
200
  if ( WPAdm_Running::is_stop() ) {
201
  $table_db = WPAdm_Running::getCommandResultData('tabledb');
202
+ if (isset($table_db[$table])) {
203
+ if (isset($table_db[$table]['work']) && $table_db[$table]['work'] == 1) {
204
  $from = $table_db[$table]['from']; // value from
205
  $to = $table_db[$table]['to']; // value to
206
+ $insert_values = true;
207
+ }
208
  } else {
209
  $from = 0;
210
  $to = $this->rows;
211
+ $insert_values = true;
212
  }
213
  }
214
+
215
  if (isset($from) && !empty($to) && $from >= 0 && $to >= 0 && $insert_values === true) {
216
  unset($link);
217
  $link = $this->connect($db);
218
+ $num_fields = $link->query( 'SELECT * FROM ' . $table . " LIMIT {$from}, {$to}" );
219
  if ($num_fields > 0) {
220
+ WPAdm_Core::log( $link->last_error ) ;
221
  $result2 = $link->last_result;
222
+ if ( WPAdm_Running::is_stop() ) {
223
+ $log = __('Performing of database query:' ,'dropbox-backup') . ' SELECT * FROM ' . $table . " LIMIT {$from}, {$to}";
224
+ WPAdm_Core::log( $log );
225
+ }
226
  for ($i = 0; $i < $num_fields; $i++) {
227
  if ( WPAdm_Running::is_stop() ) {
228
  $return = '';
239
  $return .= ");\n";
240
  file_put_contents($filename, $return, FILE_APPEND);
241
  $from += 1;
242
+ $table_db = WPAdm_Running::getCommandResultData('tabledb');
243
+ $table_db[$table]['from'] = $from;
244
  $table_db[$table]['to'] = $to;
245
  $table_db[$table]['work'] = 1;
246
  WPAdm_Running::setCommandResultData('tabledb', $table_db);
 
247
  }
248
  }
249
  }
 
 
 
 
250
  } else {
251
  $while = false;
252
  if ( WPAdm_Running::is_stop() ) {
253
+ $table_db = WPAdm_Running::getCommandResultData('tabledb');
254
  $table_db[$table]['work'] = 0;
255
+ WPAdm_Running::setCommandResultData('tabledb', $table_db);
256
  WPAdm_Process::set('mysqldump', ( $key_tables + 1 ) );
257
  }
258
  }
259
  } else {
260
  $while = false;
261
  if ( WPAdm_Running::is_stop() ) {
262
+ $table_db = WPAdm_Running::getCommandResultData('tabledb');
263
  $table_db[$table]['work'] = 0;
264
+ WPAdm_Running::setCommandResultData('tabledb', $table_db);
265
  WPAdm_Process::set('mysqldump', ( $key_tables + 1 ) );
266
  }
267
  }
268
  }
269
  }
270
  if ( WPAdm_Running::is_stop() ) {
271
+ $proc_data = WPAdm_Running::getCommandResultData('db');
272
  if (!isset($proc_data['mysqldump_table'][$table])) {
273
  $return ="\n\n\n";
274
  file_put_contents($filename, $return, FILE_APPEND);
278
  }
279
  if ( WPAdm_Running::is_stop() ) {
280
  unset($link);
281
+ WPAdm_Core::log( __('Creating of MySQL database dump was finished' ,'dropbox-backup') );
282
  $proc_data = WPAdm_Running::getCommandResultData('db');
283
  $proc_data['mysqldump'] = true;
284
  WPAdm_Running::setCommandResultData('db', $proc_data);
298
  public function restore($db, $file)
299
  {
300
  $link = $this->connect($db);
301
+ WPAdm_Core::log( __('Database restoring was started' ,'dropbox-backup') );
302
  $fo = fopen($file, "r");
303
  if (!$fo) {
304
+ WPAdm_Core::log( __('Error during openening of file dump' ,'dropbox-backup') );
305
+ $this->setError( __('Error during openening of file dump' ,'dropbox-backup') );
306
  return false;
307
  }
308
  $sql = "";
323
  }
324
  }
325
  }
326
+ WPAdm_Core::log(__('Database restoring was finished' ,'dropbox-backup'));
327
  }
328
  }
329
  }
modules/class-wpadm-running.php CHANGED
@@ -47,6 +47,11 @@ if (!class_exists('WPAdm_Running')) {
47
  WPAdm_Core::rmdir($path . "/tmp_arhive_name");
48
  WPAdm_Core::rmdir($path . "/tmp_arhive_name2");
49
  WPAdm_Core::rmdir($path . "/time_work");
 
 
 
 
 
50
 
51
  if ($method) {
52
  $files = glob($path ."/wpadm_method*.queue");
@@ -74,6 +79,29 @@ if (!class_exists('WPAdm_Running')) {
74
  }
75
  }
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  static function init()
78
  {
79
  $command = self::getCommand();
@@ -86,7 +114,7 @@ if (!class_exists('WPAdm_Running')) {
86
  //@set_time_limit(0);
87
  }
88
 
89
- self::run(60);
90
 
91
  if ( self::checkLock() ) {
92
  if ( self::is_stop() ) {
@@ -121,7 +149,7 @@ if (!class_exists('WPAdm_Running')) {
121
  // true - cron not running
122
  $running_cron = get_transient('drb_running');
123
  $time_work = self::getCommandResultData('time_work');
124
- if ( !empty($time_work) && ( $time_work + 45 ) > time() ) {
125
  return false;
126
  }
127
  if ($running_cron && $running_cron == 1) {
@@ -157,6 +185,8 @@ if (!class_exists('WPAdm_Running')) {
157
  } else {
158
  set_transient('drb_running', 1, $time + 30);
159
  }
 
 
160
  return true;
161
  }
162
 
47
  WPAdm_Core::rmdir($path . "/tmp_arhive_name");
48
  WPAdm_Core::rmdir($path . "/tmp_arhive_name2");
49
  WPAdm_Core::rmdir($path . "/time_work");
50
+ WPAdm_Core::rmdir($path . "/test.zip");
51
+ WPAdm_Core::rmdir($path . "/test.tar.gz");
52
+ WPAdm_Core::rmdir($path . "/test_zip_archive");
53
+ WPAdm_Core::rmdir($path . "/test_targz_archive");
54
+ WPAdm_Core::rmdir($path . "/start-process");
55
 
56
  if ($method) {
57
  $files = glob($path ."/wpadm_method*.queue");
79
  }
80
  }
81
 
82
+ static function toEndWork($time = 0)
83
+ {
84
+ $time_start_process = self::getCommandResultData('start-process');
85
+
86
+ if ($time == 0) {
87
+ $time = self::getCommandResultData('time_work');
88
+ }
89
+ $time_work = ini_get('max_execution_time');
90
+
91
+ $time_stop = 25;
92
+
93
+ if ($time_work <= 30) {
94
+ $time_stop = round($time_work / 2.5);
95
+ }
96
+
97
+ $time_is = ( $time_start_process + $time_work ) - $time;
98
+ if ( !empty($time_start_process) && !empty($time) && $time_is <= $time_stop ) { //second
99
+ //sleep($time_is + 2);
100
+ return false;
101
+ }
102
+ return true;
103
+ }
104
+
105
  static function init()
106
  {
107
  $command = self::getCommand();
114
  //@set_time_limit(0);
115
  }
116
 
117
+ self::run(35);
118
 
119
  if ( self::checkLock() ) {
120
  if ( self::is_stop() ) {
149
  // true - cron not running
150
  $running_cron = get_transient('drb_running');
151
  $time_work = self::getCommandResultData('time_work');
152
+ if ( !empty($time_work) && ( $time_work + 20 ) > time() ) {
153
  return false;
154
  }
155
  if ($running_cron && $running_cron == 1) {
185
  } else {
186
  set_transient('drb_running', 1, $time + 30);
187
  }
188
+
189
+ self::setCommandResultData('start-process', time() );
190
  return true;
191
  }
192
 
modules/restore-class.php CHANGED
@@ -13,6 +13,19 @@ if (!function_exists('dbr_extract_func')) {
13
  }
14
  }
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  if (!class_exists('dbr_gui')) {
18
  class dbr_gui {
@@ -52,7 +65,7 @@ if (!class_exists('dbr_database')) {
52
  self::$db_params = $db_params;
53
  if (isset($pr[1])) {
54
  self::$db_prefix = $pr[1];
55
- }
56
  } else {
57
  self::$db_params = $configs;
58
  $db_params = self::$db_params;
@@ -87,11 +100,11 @@ if (!class_exists('dbr_database')) {
87
  }
88
  } else {
89
  if (self::$is_mysqli) {
90
- self::$connect = mysqli_connect(self::$db_params['host'], self::$db_params['user'], self::$db_params['password']) or die(mysqli_error());
91
  mysqli_set_charset(self::$connect, self::$db_params['charset']) or die(mysqli_error());
92
  mysqli_select_db(self::$connect, self::$db_params['db']) or die(mysqli_error());
93
  } else {
94
- self::$connect = @mysql_connect(self::$db_params['host'], self::$db_params['user'], self::$db_params['password']) or die(mysql_error());
95
  mysql_set_charset(self::$db_params['charset'], self::$connect) or die(mysql_error());
96
  mysql_select_db(self::$db_params['db'], self::$connect) or die(mysql_error());
97
  }
@@ -541,7 +554,10 @@ if ( !class_exists('dbr_helper') ) {
541
 
542
  public static function pack($data)
543
  {
544
- return base64_encode( json_encode( $data, JSON_HEX_QUOT|JSON_HEX_TAG|JSON_HEX_AMP|JSON_HEX_APOS ) );
 
 
 
545
  }
546
 
547
  public static function unpack($data)
@@ -767,6 +783,13 @@ if ( !class_exists('dbr_methods') ) {
767
  $arr_sql = dbr_helper::getCommand('sql-restore');
768
  if ( !isset( $arr_sql[md5($sql)] ) || $arr_sql === false ) {
769
  $ress = dbr_database::query( $sql );
 
 
 
 
 
 
 
770
  $arr_sql[md5($sql)] = 1;
771
  dbr_helper::setCommand('sql-restore', $arr_sql);
772
  }
@@ -803,6 +826,10 @@ if ( !class_exists('dbr_methods') ) {
803
  if(strpos($d, ".zip") !== false) {
804
  $this->files_resotre[$d] = $this->dir_backup . "/$d";
805
  }
 
 
 
 
806
  if(strpos($d, ".md5") !== false) {
807
  $file_md5 = $this->dir_backup . "/$d";
808
  }
@@ -830,9 +857,13 @@ if ( !class_exists('dbr_methods') ) {
830
 
831
  }
832
 
 
 
 
 
 
833
  private function restoreFiles()
834
  {
835
- include 'pclzip.lib.php';
836
  $files = dbr_helper::getCommand('files-list-retore');
837
  if ($files) {
838
  dbr_helper::is_work(time(), 'start');
@@ -873,6 +904,10 @@ if ( !class_exists('dbr_methods') ) {
873
  dbr_helper::setCommand('zip-config', null);
874
  }
875
  }
 
 
 
 
876
  foreach($files as $f => $file) {
877
  $extract_files = dbr_helper::getCommand('extract-files-restore');
878
  if (!isset($extract_files[$f])) {
@@ -923,11 +958,11 @@ if ( !class_exists('dbr_methods') ) {
923
  if ($change_config) {
924
  dbr_log::log('Configure file "wp-config.php" was started');
925
  $patterns = array();
926
- $patterns[0] = "/define\('DB_PASSWORD', '(.*)'\)/";
927
- $patterns[1] = "/define\('DB_NAME', '(.*)'\)/";
928
- $patterns[2] = "/define\('DB_USER', '(.*)'\)/";
929
- $patterns[3] = "/define\('DB_HOST', '(.*)'\)/";
930
- $patterns[4] = "/define\('DB_CHARSET', '(.*)'\)/";
931
 
932
  $replacements = array();
933
  $replacements[0] = "define('DB_PASSWORD', '" . dbr_database::$db_params['password'] . "')";
@@ -964,6 +999,84 @@ if ( !class_exists('dbr_methods') ) {
964
  } else {
965
  dbr_helper::setError('File (' . $file . ') for restoring wasn\'t found or file size is 0 byte');
966
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
967
  }
968
  }
969
  }
@@ -1026,7 +1139,7 @@ if ( !class_exists('dbr_methods') ) {
1026
  }
1027
  $md5 = glob($this->dir_backup . '/*.md5');
1028
  if (count( $md5 ) == 0) {
1029
- dbr_helper::setError( "File list from MD5 file wasn\'t loaded. Please, check folder and folder rights " . $this->dir_backup . " and MD5 file in this folder with file rights");
1030
  }
1031
  dbr_helper::setCommand('download-with-dropbox-restore', true, 'success');
1032
  return true;
@@ -1069,34 +1182,38 @@ if (!class_exists('dbr_route')) {
1069
 
1070
  function __construct()
1071
  {
 
 
 
 
1072
  if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
1073
  if ( !isset($_POST['name']) ) {
1074
  $this->parsMethod();
1075
- } elseif( isset($_POST['name']) ) {
1076
-
1077
- dbr_helper::clearTMP();
1078
- dbr_database::inc_wp_config();
1079
- $setting = dbr_database::db_get('options', array('option_value'), array('option_name' => 'wpadm_backup_dropbox-setting'), 1);
1080
- if (isset($setting['option_value'])) {
1081
- $this->setting = dbr_helper::unpack_setting( $setting['option_value'] );
1082
- }
1083
- $this->setting['restore-key'] = md5( time() . microtime() . __FILE__);
1084
- include 'constant.php';
1085
- $plugin = $this->parsePlugin('/dropbox-backup');
1086
- $plugin_name = 'dropbox-backup';
1087
- $version = '1.0';
1088
- if (isset($plugin['/dropbox-backup']['Version'])) {
1089
- $version = $plugin['/dropbox-backup']['Version'];
1090
- } else{
1091
- $plugin = $this->parsePlugin('/dropbox-backup-pro');
1092
- if (isset($plugin['/dropbox-backup-pro']['Version'])) {
1093
- $version = $plugin['/dropbox-backup-pro']['Version'];
1094
- $plugin_name = 'dropbox-backup-pro';
1095
  }
1096
- }
1097
- $data = array('actApi' => 'setPluginCode', $plugin_name . '_request' => array('action' => 'restore', 'site' => SITE_HOME, 'pl' => $plugin_name, 'key' => $this->setting['restore-key'], 'pl_v' => $version, ) );
1098
- $res = dbr_api::post(WPADM_URL_BASE . 'api/', $data);
1099
- try {
 
 
 
 
 
 
 
 
 
 
 
 
 
1100
  if ( !empty( $res['res'] ) ) {
1101
  $result = json_decode($res['res'], true);
1102
  if (isset($result['code'])) {
@@ -1121,6 +1238,12 @@ if (!class_exists('dbr_route')) {
1121
  dbr_database::db_update('options', array('option_value' => dbr_helper::pack_setting( $this->setting ) ), array('option_name' => 'wpadm_backup_dropbox-setting') ) ;
1122
  }
1123
  dbr_helper::setCommand('restore-backup', array('name' => dbr_helper::sanitize( @$_POST['name'] ), 'action' => dbr_helper::sanitize( @$_POST['action'] ), 'key' => dbr_helper::sanitize( @$_POST['key'] ) ) ); // verify and sanitize post data
 
 
 
 
 
 
1124
  echo json_encode(array('result' => 'work'));
1125
  } catch(Exception $e) {
1126
  dbr_log::log($e->getMessage());
@@ -1134,18 +1257,15 @@ if (!class_exists('dbr_route')) {
1134
  private function parsMethod()
1135
  {
1136
  if ( isset($_POST['method']) ) {
 
1137
  try {
1138
  dbr_helper::mkdir(DBP_PATH_TMP);
1139
  if (!dbr_helper::is_work() || in_array($_POST['method'], $this->method_access ) ) {
1140
  if (isset($_POST['key'])) {
1141
- dbr_database::inc_wp_config();
1142
- include 'constant.php';
1143
- $setting = dbr_database::db_get('options', array('option_value'), array('option_name' => 'wpadm_backup_dropbox-setting'), 1);
1144
- $this->setting = dbr_helper::unpack_setting( $setting['option_value'] );
1145
- $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
1146
- if (isset($this->setting['backup_folder']) && !empty($this->setting['backup_folder'])) {
1147
- $backup_dir = $this->setting['backup_folder'];
1148
- }
1149
  if (file_exists($backup_dir . '/local-key')) {
1150
  $key_values = dbr_helper::unpack_setting( @file_get_contents($backup_dir . '/local-key') );
1151
  }
@@ -1182,6 +1302,16 @@ if (!class_exists('dbr_route')) {
1182
  } else {
1183
  dbr_helper::is_work(time(), 'start');
1184
  }
 
 
 
 
 
 
 
 
 
 
1185
  $methods->$method();
1186
  if (!isset($_POST['type-backup'])) {
1187
  dbr_helper::is_work(time(), 'finish');
@@ -1204,8 +1334,18 @@ if (!class_exists('dbr_route')) {
1204
  }
1205
 
1206
 
 
 
 
 
 
 
 
 
 
1207
 
1208
-
 
1209
  /**
1210
  * json encode
1211
  *
13
  }
14
  }
15
 
16
+ if (!function_exists('dbr_extract_func_targz')) {
17
+ function dbr_extract_func_targz($filename)
18
+ {
19
+ if (stripos($filename, 'wp-config.php') !== false) {
20
+ return true;
21
+ }
22
+ if (stripos($filename, 'dropbox-backup') !== false) {
23
+ return true;
24
+ }
25
+ return false;
26
+ }
27
+ }
28
+
29
 
30
  if (!class_exists('dbr_gui')) {
31
  class dbr_gui {
65
  self::$db_params = $db_params;
66
  if (isset($pr[1])) {
67
  self::$db_prefix = $pr[1];
68
+ }
69
  } else {
70
  self::$db_params = $configs;
71
  $db_params = self::$db_params;
100
  }
101
  } else {
102
  if (self::$is_mysqli) {
103
+ self::$connect = mysqli_connect(self::$db_params['host'], self::$db_params['user'], self::$db_params['password']) or die();
104
  mysqli_set_charset(self::$connect, self::$db_params['charset']) or die(mysqli_error());
105
  mysqli_select_db(self::$connect, self::$db_params['db']) or die(mysqli_error());
106
  } else {
107
+ self::$connect = @mysql_connect(self::$db_params['host'], self::$db_params['user'], self::$db_params['password']) or die();
108
  mysql_set_charset(self::$db_params['charset'], self::$connect) or die(mysql_error());
109
  mysql_select_db(self::$db_params['db'], self::$connect) or die(mysql_error());
110
  }
554
 
555
  public static function pack($data)
556
  {
557
+ if (defined('JSON_HEX_TAG') && defined('JSON_HEX_QUOT') && defined('JSON_HEX_AMP') && defined('JSON_HEX_APOS') ) {
558
+ return base64_encode( json_encode ( $data, JSON_HEX_QUOT|JSON_HEX_TAG|JSON_HEX_AMP|JSON_HEX_APOS ) ) ;
559
+ }
560
+ return base64_encode( json_encode ( $data ) ) ;
561
  }
562
 
563
  public static function unpack($data)
783
  $arr_sql = dbr_helper::getCommand('sql-restore');
784
  if ( !isset( $arr_sql[md5($sql)] ) || $arr_sql === false ) {
785
  $ress = dbr_database::query( $sql );
786
+ dbr_helper::is_work(time(), 'start');
787
+ if (stripos($sql, 'create') !== false) {
788
+ preg_match("/CREATE[\s]{1,}TABLE[\s]{1,}`(.*)`/iUu", $sql, $table_insert) ;
789
+ if (isset($table_insert[1]) && !empty($table_insert[1])) {
790
+ dbr_log::log('Restore table `' . $table_insert[1] . '`');
791
+ }
792
+ }
793
  $arr_sql[md5($sql)] = 1;
794
  dbr_helper::setCommand('sql-restore', $arr_sql);
795
  }
826
  if(strpos($d, ".zip") !== false) {
827
  $this->files_resotre[$d] = $this->dir_backup . "/$d";
828
  }
829
+ if(substr($d, -7) == '.tar.gz') {
830
+ $this->files_resotre[$d] = $this->dir_backup . "/$d";
831
+ dbr_helper::setCommand('targz', true);
832
+ }
833
  if(strpos($d, ".md5") !== false) {
834
  $file_md5 = $this->dir_backup . "/$d";
835
  }
857
 
858
  }
859
 
860
+ private function restoreTarGz($archive)
861
+ {
862
+
863
+ }
864
+
865
  private function restoreFiles()
866
  {
 
867
  $files = dbr_helper::getCommand('files-list-retore');
868
  if ($files) {
869
  dbr_helper::is_work(time(), 'start');
904
  dbr_helper::setCommand('zip-config', null);
905
  }
906
  }
907
+ $tar_gz = dbr_helper::getCommand('targz');
908
+ if (!$tar_gz) {
909
+ include 'pclzip.lib.php';
910
+ }
911
  foreach($files as $f => $file) {
912
  $extract_files = dbr_helper::getCommand('extract-files-restore');
913
  if (!isset($extract_files[$f])) {
958
  if ($change_config) {
959
  dbr_log::log('Configure file "wp-config.php" was started');
960
  $patterns = array();
961
+ $patterns[0] = "/define[\s]{0,}\([\s]{0,}'DB_PASSWORD'[\s]{0,},[\s]{0,}'(.*)'[\s]{0,}\)/";
962
+ $patterns[1] = "/define[\s]{0,}\([\s]{0,}'DB_NAME'[\s]{0,},[\s]{0,}'(.*)'[\s]{0,}\)/";
963
+ $patterns[2] = "/define[\s]{0,}\([\s]{0,}'DB_USER'[\s]{0,},[\s]{0,}'(.*)'[\s]{0,}\)/";
964
+ $patterns[3] = "/define[\s]{0,}\([\s]{0,}'DB_HOST'[\s]{0,},[\s]{0,}'(.*)'[\s]{0,}\)/";
965
+ $patterns[4] = "/define[\s]{0,}\([\s]{0,}'DB_CHARSET'[\s]{0,},[\s]{0,}'(.*)'[\s]{0,}\)/";
966
 
967
  $replacements = array();
968
  $replacements[0] = "define('DB_PASSWORD', '" . dbr_database::$db_params['password'] . "')";
999
  } else {
1000
  dbr_helper::setError('File (' . $file . ') for restoring wasn\'t found or file size is 0 byte');
1001
  }
1002
+ } elseif ($tar_gz) {
1003
+ if (file_exists($file) && filesize($file) > 0) {
1004
+ include_once 'archive.php' ;
1005
+ dbr_helper::is_work(time(), 'start');
1006
+ $gz = new wpadm_gzip_file($file);
1007
+ $gz->set_options(array( 'overwrite' => 1, 'basedir' => ABSPATH ) );
1008
+ $gz->exclude = 'dbr_extract_func_targz';
1009
+ $gz->extract_gz_files();
1010
+ dbr_helper::is_work(time(), 'start');
1011
+ if (!empty( $gz->warning ) ) {
1012
+ foreach($gz->warning as $warning) {
1013
+ dbr_log::log($warning);
1014
+ }
1015
+ }
1016
+ if (!empty($gz->error)) {
1017
+ dbr_helper::setError( implode("\n", $gz->error) );
1018
+ }
1019
+ unset($gz);
1020
+ if ($zip_config && strpos($file, $zip_config[2]) !== false) {
1021
+ dbr_helper::is_work(time(), 'start');
1022
+ if ( dbr_helper::is_writable(ABSPATH . 'wp-config.php') === false) {
1023
+ dbr_helper::setError( "File 'wp-config.php' is not writable" );
1024
+ }
1025
+ $gz = new wpadm_gzip_file($file);
1026
+ $gz->set_options(array( 'overwrite' => 1, 'basedir' => ABSPATH ) );
1027
+
1028
+ $gz->include_files("/wp-config\.php/");
1029
+ dbr_helper::is_work(time(), 'start');
1030
+ $gz->extract_gz_files();
1031
+ dbr_helper::is_work(time(), 'start');
1032
+ $db_params = array(
1033
+ 'password' => 'DB_PASSWORD',
1034
+ 'db' => 'DB_NAME',
1035
+ 'user' => 'DB_USER',
1036
+ 'host' => 'DB_HOST',
1037
+ 'charset' => 'DB_CHARSET',
1038
+ );
1039
+
1040
+ $r = "/define\([\s]{0,}['\"]{1}(.*)['\"]{1}[\s]{0,},[\s]{0,}['\"]{1}(.*)['\"]{1}[\s]{0,}\)/";
1041
+ $config = @file_get_contents(ABSPATH . "wp-config.php");
1042
+ preg_match_all($r, $config, $m);
1043
+ $params = array_combine( $m[1], $m[2] );
1044
+ $change_config = false;
1045
+ foreach($db_params as $k => $p) {
1046
+ $db_params[$k] = $params[$p];
1047
+ if (dbr_database::$db_params[$k] != $db_params[$k]) {
1048
+ $change_config = true;
1049
+ }
1050
+ }
1051
+ if ($change_config) {
1052
+ dbr_log::log('Configure file "wp-config.php" was started');
1053
+ $patterns = array();
1054
+ $patterns[0] = "/define[\s]{0,}\([\s]{0,}['\"]{1}DB_PASSWORD['\"]{1}[\s]{0,},[\s]{0,}['\"]{1}(.*)['\"]{1}[\s]{0,}\)/";
1055
+ $patterns[1] = "/define[\s]{0,}\([\s]{0,}['\"]{1}DB_NAME['\"]{1}[\s]{0,},[\s]{0,}['\"]{1}(.*)['\"]{1}[\s]{0,}\)/";
1056
+ $patterns[2] = "/define[\s]{0,}\([\s]{0,}['\"]{1}DB_USER['\"]{1}[\s]{0,},[\s]{0,}['\"]{1}(.*)['\"]{1}[\s]{0,}\)/";
1057
+ $patterns[3] = "/define[\s]{0,}\([\s]{0,}['\"]{1}DB_HOST['\"]{1}[\s]{0,},[\s]{0,}['\"]{1}(.*)['\"]{1}[\s]{0,}\)/";
1058
+ $patterns[4] = "/define[\s]{0,}\([\s]{0,}['\"]{1}DB_CHARSET['\"]{1}[\s]{0,},[\s]{0,}['\"]{1}(.*)['\"]{1}[\s]{0,}\)/";
1059
+
1060
+ $replacements = array();
1061
+ $replacements[0] = "define('DB_PASSWORD', '" . dbr_database::$db_params['password'] . "')";
1062
+ $replacements[1] = "define('DB_NAME', '" . dbr_database::$db_params['db'] . "')";
1063
+ $replacements[2] = "define('DB_USER', '" . dbr_database::$db_params['user'] . "')";
1064
+ $replacements[3] = "define('DB_HOST', '" . dbr_database::$db_params['host'] . "')";
1065
+ $replacements[4] = "define('DB_CHARSET', '" . dbr_database::$db_params['charset'] . "')";
1066
+ dbr_helper::is_work(time(), 'start');
1067
+ $config = preg_replace($patterns, $replacements, $config);
1068
+
1069
+ $config = preg_replace("/table_prefix[\s]{0,}=[\s]{0,}[\"']{1}(.*)[\"']{1}/U", "table_prefix = '" . dbr_database::$db_prefix . "'", $config);
1070
+
1071
+ $write = @file_put_contents(ABSPATH . "wp-config.php", $config);
1072
+ dbr_helper::is_work(time(), 'start');
1073
+ if (!$write) {
1074
+ dbr_helper::setError( "File 'wp-config.php' is not writable" );
1075
+ }
1076
+ dbr_log::log('Configure file "wp-config.php" was successfully');
1077
+ }
1078
+ }
1079
+ }
1080
  }
1081
  }
1082
  }
1139
  }
1140
  $md5 = glob($this->dir_backup . '/*.md5');
1141
  if (count( $md5 ) == 0) {
1142
+ dbr_helper::setError( "File list from MD5 file wasn't loaded. Please, check folder and file access permissions " . $this->dir_backup . " and MD5 file in this folder with file access permissions");
1143
  }
1144
  dbr_helper::setCommand('download-with-dropbox-restore', true, 'success');
1145
  return true;
1182
 
1183
  function __construct()
1184
  {
1185
+ @set_time_limit(0);
1186
+ if (function_exists('set_error_handler')) {
1187
+ set_error_handler(array($this, 'error_handler') );
1188
+ }
1189
  if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
1190
  if ( !isset($_POST['name']) ) {
1191
  $this->parsMethod();
1192
+ } elseif( isset($_POST['name'] ) ) {
1193
+ try {
1194
+ dbr_helper::clearTMP();
1195
+ dbr_database::inc_wp_config();
1196
+ $setting = dbr_database::db_get('options', array('option_value'), array('option_name' => 'wpadm_backup_dropbox-setting'), 1);
1197
+ if (isset($setting['option_value'])) {
1198
+ $this->setting = dbr_helper::unpack_setting( $setting['option_value'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
1199
  }
1200
+ $this->setting['restore-key'] = md5( time() . microtime() . __FILE__);
1201
+ include 'constant.php';
1202
+ $plugin = $this->parsePlugin('/dropbox-backup');
1203
+ $plugin_name = 'dropbox-backup';
1204
+ $version = '1.0';
1205
+ if (isset($plugin['/dropbox-backup']['Version'])) {
1206
+ $version = $plugin['/dropbox-backup']['Version'];
1207
+ } else{
1208
+ $plugin = $this->parsePlugin('/dropbox-backup-pro');
1209
+ if (isset($plugin['/dropbox-backup-pro']['Version'])) {
1210
+ $version = $plugin['/dropbox-backup-pro']['Version'];
1211
+ $plugin_name = 'dropbox-backup-pro';
1212
+ }
1213
+ }
1214
+ $data = array('actApi' => 'setPluginCode', $plugin_name . '_request' => array('action' => 'restore', 'site' => SITE_HOME, 'pl' => $plugin_name, 'key' => $this->setting['restore-key'], 'pl_v' => $version, ) );
1215
+ $res = dbr_api::post(WPADM_URL_BASE . 'api/', $data);
1216
+
1217
  if ( !empty( $res['res'] ) ) {
1218
  $result = json_decode($res['res'], true);
1219
  if (isset($result['code'])) {
1238
  dbr_database::db_update('options', array('option_value' => dbr_helper::pack_setting( $this->setting ) ), array('option_name' => 'wpadm_backup_dropbox-setting') ) ;
1239
  }
1240
  dbr_helper::setCommand('restore-backup', array('name' => dbr_helper::sanitize( @$_POST['name'] ), 'action' => dbr_helper::sanitize( @$_POST['action'] ), 'key' => dbr_helper::sanitize( @$_POST['key'] ) ) ); // verify and sanitize post data
1241
+ dbr_helper::setCommand('settings-plugin', $this->setting );
1242
+ $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
1243
+ if (isset($this->setting['backup_folder']) && !empty($this->setting['backup_folder'])) {
1244
+ $backup_dir = $this->setting['backup_folder'];
1245
+ }
1246
+ dbr_helper::setCommand('backup-folder', $backup_dir );
1247
  echo json_encode(array('result' => 'work'));
1248
  } catch(Exception $e) {
1249
  dbr_log::log($e->getMessage());
1257
  private function parsMethod()
1258
  {
1259
  if ( isset($_POST['method']) ) {
1260
+ $this->setting_restore = dbr_helper::getCommand('restore-backup');
1261
  try {
1262
  dbr_helper::mkdir(DBP_PATH_TMP);
1263
  if (!dbr_helper::is_work() || in_array($_POST['method'], $this->method_access ) ) {
1264
  if (isset($_POST['key'])) {
1265
+
1266
+ $backup_dir = dbr_helper::getCommand('backup-folder');
1267
+ $this->setting = dbr_helper::getCommand('settings-plugin');
1268
+
 
 
 
 
1269
  if (file_exists($backup_dir . '/local-key')) {
1270
  $key_values = dbr_helper::unpack_setting( @file_get_contents($backup_dir . '/local-key') );
1271
  }
1302
  } else {
1303
  dbr_helper::is_work(time(), 'start');
1304
  }
1305
+ if ($_POST['method'] != 'wpadm_logs') {
1306
+ dbr_database::inc_wp_config();
1307
+ include 'constant.php';
1308
+ $setting = dbr_database::db_get('options', array('option_value'), array('option_name' => 'wpadm_backup_dropbox-setting'), 1);
1309
+ $this->setting = dbr_helper::unpack_setting( $setting['option_value'] );
1310
+ $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
1311
+ if (isset($this->setting['backup_folder']) && !empty($this->setting['backup_folder'])) {
1312
+ $backup_dir = $this->setting['backup_folder'];
1313
+ }
1314
+ }
1315
  $methods->$method();
1316
  if (!isset($_POST['type-backup'])) {
1317
  dbr_helper::is_work(time(), 'finish');
1334
  }
1335
 
1336
 
1337
+ function error_handler($errno, $errstr, $errfile, $errline, array $errcontext)
1338
+ {
1339
+ // error was suppressed with the @-operator
1340
+ if (0 === error_reporting()) {
1341
+ return false;
1342
+ }
1343
+ if (!(error_reporting() & $errno)) {
1344
+ return false;
1345
+ }
1346
 
1347
+ throw new Exception($errstr . ' file ' . $errfile . ' line ' . $errline, $errno);
1348
+ }
1349
  /**
1350
  * json encode
1351
  *
readme.txt CHANGED
@@ -1,6 +1,6 @@
1
  === Backup & Restore Dropbox ===
2
  Plugin Name: Backup & Restore Dropbox
3
- Version: 1.4.8.4
4
  Donate link: http://www.wpadm.com/donate
5
  URI: http://www.wpadm.com/dropbox-backup
6
  Tags: dropbox, backup, dropbox backup, database, file, full backup, manage, sicherung, database backup, file backup, page backup, page, web, web backup, web page, synchronize, clone, duplicate, move, web page backup, site, site backup, back up, cloud, Cloud Files, cloud backup, db backup, dump, german, migrate, multisite, German, schedule, storage, time, upload, data bank, zip, archive, backups, restore, db, recover, recovery, restoration, wp backup, wordpress backup, wordpress backup to dropbox, plugin wordpress backup, wpadm, wpadm.com, website, website backup, website back up, wp backup, wordpress backup, scheduled backup, backup scheduler, tool, backup tool
1
  === Backup & Restore Dropbox ===
2
  Plugin Name: Backup & Restore Dropbox
3
+ Version: 1.5
4
  Donate link: http://www.wpadm.com/donate
5
  URI: http://www.wpadm.com/dropbox-backup
6
  Tags: dropbox, backup, dropbox backup, database, file, full backup, manage, sicherung, database backup, file backup, page backup, page, web, web backup, web page, synchronize, clone, duplicate, move, web page backup, site, site backup, back up, cloud, Cloud Files, cloud backup, db backup, dump, german, migrate, multisite, German, schedule, storage, time, upload, data bank, zip, archive, backups, restore, db, recover, recovery, restoration, wp backup, wordpress backup, wordpress backup to dropbox, plugin wordpress backup, wpadm, wpadm.com, website, website backup, website back up, wp backup, wordpress backup, scheduled backup, backup scheduler, tool, backup tool
template/css/admin-style-wpadm.css CHANGED
@@ -57,6 +57,16 @@
57
  margin-top: 20px;
58
  color:#fff;
59
  }
 
 
 
 
 
 
 
 
 
 
60
  .log-dropbox {
61
  background-repeat: no-repeat; background-position:center;
62
  background-color: #fff;
57
  margin-top: 20px;
58
  color:#fff;
59
  }
60
+ .inline-right {
61
+ float:right;
62
+ }
63
+ .inline {
64
+ float:left;
65
+ }
66
+ .inline-right, .inline {
67
+ margin-top:10px;
68
+ margin-left:10px;
69
+ }
70
  .log-dropbox {
71
  background-repeat: no-repeat; background-position:center;
72
  background-color: #fff;
template/css/tool-bar.css CHANGED
@@ -79,16 +79,7 @@ button.backup_button:disabled, button.backup_button:disabled:hover {
79
  background: #9eb7d8;
80
  }
81
 
82
- .inline-right {
83
- float:right;
84
- }
85
- .inline {
86
- float:left;
87
- }
88
- .inline-right, .inline {
89
- margin-top:10px;
90
- margin-left:10px;
91
- }
92
  @media only screen and (max-width: 1345px) {
93
 
94
  .block-advantage {
79
  background: #9eb7d8;
80
  }
81
 
82
+
 
 
 
 
 
 
 
 
 
83
  @media only screen and (max-width: 1345px) {
84
 
85
  .block-advantage {
template/wpadm_show_backup.php CHANGED
@@ -460,6 +460,7 @@
460
  }
461
  },
462
  error: function(jqXHR, textStatus, errorThrown){
 
463
  if (jqXHR.status != 0) {
464
  //processStop();
465
  //AjaxAlert(jqXHR, textStatus, errorThrown);
@@ -1305,6 +1306,26 @@
1305
  <input type="checkbox" <?php echo (isset($dropbox_options['is_show_admin_bar']) && (int)$dropbox_options['is_show_admin_bar'] == 1) ? 'checked="checked"' : ( !isset($dropbox_options['is_show_admin_bar']) ? 'checked="checked"' : '' ); ?> name="is_show_admin_bar" value="1" id="is_show_admin_bar" onclick="saveSetting('is_show_admin_bar')" />
1306
  <label for="is_show_admin_bar" style="font-size: 13px;"><?php _e('Show in a admin bar','dropbox-backup'); ?></label>
1307
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1308
  <div class="setting-checkbox">
1309
  <?php _e('Include/Exclude','dropbox-backup'); ?>
1310
  <a onclick="InludesSetting();" href="javascript:void(0);" style="color: #fff"><?php _e('Folders and files','dropbox-backup'); ?></a>
460
  }
461
  },
462
  error: function(jqXHR, textStatus, errorThrown){
463
+ setTimeout('processBar("' + method + '")', 10000);
464
  if (jqXHR.status != 0) {
465
  //processStop();
466
  //AjaxAlert(jqXHR, textStatus, errorThrown);
1306
  <input type="checkbox" <?php echo (isset($dropbox_options['is_show_admin_bar']) && (int)$dropbox_options['is_show_admin_bar'] == 1) ? 'checked="checked"' : ( !isset($dropbox_options['is_show_admin_bar']) ? 'checked="checked"' : '' ); ?> name="is_show_admin_bar" value="1" id="is_show_admin_bar" onclick="saveSetting('is_show_admin_bar')" />
1307
  <label for="is_show_admin_bar" style="font-size: 13px;"><?php _e('Show in a admin bar','dropbox-backup'); ?></label>
1308
  </div>
1309
+
1310
+ <!-- type archive -->
1311
+ <div class="setting-checkbox" style="margin-top:40px;">
1312
+ <label for="" style="font-size: 13px; font-weight: 600;"><?php _e('Create backup using following backup methods:','dropbox-backup'); ?></label>
1313
+ <span style="font-size: 11px; margin-top: -7px;">(<?php _e('ZIP method will be used as \'default\'')?>)</span>
1314
+ </div>
1315
+ <div class="setting-checkbox">
1316
+ <input autocomplete="off" type="checkbox" <?php echo ( isset($dropbox_options['type_archive']['zip_archive']) && $dropbox_options['type_archive']['zip_archive'] == 1 ) ? 'checked="checked"' : ''; ?> value="1" id="zip_archive" onclick="saveSetting('zip_archive')" />
1317
+ <label for="zip_archive" style="font-size: 13px;"><?php _e('Zip shell','dropbox-backup'); ?></label>
1318
+ </div>
1319
+ <div class="setting-checkbox">
1320
+ <input autocomplete="off" type="checkbox" <?php echo ( isset($dropbox_options['type_archive']['targz_archive']) && $dropbox_options['type_archive']['targz_archive'] == 1 ) ? 'checked="checked"' : ''; ?> value="1" id="targz_archive" onclick="saveSetting('targz_archive')" />
1321
+ <label for="targz_archive" style="font-size: 13px;"><?php _e('TarGz archive','dropbox-backup'); ?></label>
1322
+ </div>
1323
+ <!-- <div class="setting-checkbox">
1324
+ <input autocomplete="off" type="checkbox" <?php echo ( isset($dropbox_options['type_archive']['tar_archive']) && $dropbox_options['type_archive']['tar_archive'] == 1) ? 'checked="checked"' : ''; ?> name="type_archive" value="tar_archive" id="tar_archive" data-name="tar_archive" onclick="saveSetting('tar_archive')" />
1325
+ <label for="tar_archive" style="font-size: 13px;"><?php _e('Tar archive','dropbox-backup'); ?></label>
1326
+ </div> -->
1327
+ <div class="clear" style="margin-top: 15px;"></div>
1328
+ <!-- end type archive -->
1329
  <div class="setting-checkbox">
1330
  <?php _e('Include/Exclude','dropbox-backup'); ?>
1331
  <a onclick="InludesSetting();" href="javascript:void(0);" style="color: #fff"><?php _e('Folders and files','dropbox-backup'); ?></a>