Backup & Restore Dropbox - Version 1.2.9.3

Version Description

Upgrade Notice

Download this release

Release Info

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

Code changes from version 1.5.1.2 to 1.2.9.3

Files changed (71) hide show
  1. commands/class-wpadm-command-archive.php +18 -62
  2. commands/class-wpadm-command-mysqldump.php +21 -25
  3. commands/class-wpadm-command-mysqloptimize.php +22 -24
  4. commands/class-wpadm-command-restore-backup.php +5 -7
  5. commands/class-wpadm-command-send-to-dropbox.php +29 -88
  6. dropbox-backup.php +6 -19
  7. functions/index.php +0 -1
  8. functions/wpadm.php +9 -192
  9. img/closebox.png +0 -0
  10. img/folder-loader.gif +0 -0
  11. img/how-to-enable-cron.png +0 -0
  12. languages/dropbox-backup.pot +0 -945
  13. languages/index.html +0 -10
  14. languages/index.php +0 -1
  15. libs/error.class.php +1 -5
  16. libs/index.php +0 -1
  17. libs/lang.class.php +15 -15
  18. libs/lang/index.php +0 -1
  19. libs/wpadm.server.main.class.php +132 -405
  20. main/index.php +0 -1
  21. main/wpadm-class-wp.php +174 -793
  22. methods/class-wpadm-method-backup-delete.php +27 -38
  23. methods/class-wpadm-method-backup-list.php +44 -54
  24. methods/class-wpadm-method-backup.php +450 -505
  25. methods/class-wpadm-method-full-backup-dropbox.php +206 -253
  26. methods/class-wpadm-method-local-backup.php +261 -628
  27. methods/class-wpadm-method-local-restore.php +24 -45
  28. methods/class-wpadm-method-ping.php +1 -5
  29. methods/class-wpadm-method-queue-controller.php +15 -8
  30. methods/class-wpadm-method-reconnect.php +14 -17
  31. methods/class-wpadm-method-send-to-dropbox.php +50 -270
  32. methods/class-wpadm-method-update.php +3 -4
  33. modules/HttpFsockopen.php +0 -178
  34. modules/OAuthSimple.php +255 -256
  35. modules/archive.php +0 -784
  36. modules/class-wpadm-archive.php +41 -499
  37. modules/class-wpadm-command-context.php +0 -3
  38. modules/class-wpadm-command-factory.php +33 -41
  39. modules/class-wpadm-command.php +13 -17
  40. modules/class-wpadm-core.php +50 -129
  41. modules/class-wpadm-method-class.php +25 -39
  42. modules/class-wpadm-mysqldump.php +84 -263
  43. modules/class-wpadm-process.php +0 -100
  44. modules/class-wpadm-queue.php +36 -25
  45. modules/class-wpadm-result.php +116 -129
  46. modules/class-wpadm-running.php +0 -322
  47. modules/constant.php +0 -65
  48. modules/dropbox.class.php +176 -287
  49. modules/index.html +0 -10
  50. modules/pclzip.lib.php +3034 -3043
  51. modules/phpseclib/index.html +0 -10
  52. modules/restore-class.php +0 -1618
  53. readme.txt +48 -502
  54. template/advantage-plugin.php +0 -109
  55. template/attention.png +0 -0
  56. template/css/admin-style-wpadm.css +57 -249
  57. template/css/file.png +0 -0
  58. template/css/file2.png +0 -0
  59. template/css/index.php +0 -2
  60. template/css/tool-bar.css +0 -101
  61. template/dropbox_pro_logo_box1.png +0 -0
  62. template/expsys.php +0 -40
  63. template/ico_ok.png +0 -0
  64. template/index.html +0 -10
  65. template/index.php +0 -1
  66. template/js/admin-wpadm.js +0 -165
  67. template/js/index.php +0 -2
  68. template/notice.php +0 -23
  69. template/notice5.php +0 -12
  70. template/ok-icon.png +0 -0
  71. template/wpadm_show_backup.php +389 -1043
commands/class-wpadm-command-archive.php CHANGED
@@ -1,89 +1,45 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
3
 
4
  class WPadm_Command_Archive extends WPAdm_Сommand{
5
  public function execute(WPAdm_Command_Context $context)
6
  {
7
- if ( WPAdm_Running::is_stop() ) {
8
- require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-archive.php';
9
- $af = $this->getArchiveName($context->get('to_file'));
10
- if ( WPAdm_Running::is_stop() ) {
11
- $archive = new WPAdm_Archive($af, $context->get('to_file') . '.md5');
12
- $archive->setRemovePath($context->get('remove_path'));
13
- $files = $context->get('files');
14
- } else {
15
- return true;
16
- }
17
- if ( !file_exists( $af ) ) {
18
- WPAdm_Core::log(__('Create part ','dropbox-backup') . basename( $af ) );
19
- }
20
- if (file_exists($af) && filesize($af) > $context->get('max_file_size')) {
21
- if ( WPAdm_Running::is_stop() ) {
22
- $af = $this->getNextArchiveName($context->get('to_file'));
23
- unset($archive);
24
- if ( !file_exists( $af ) ) {
25
- WPAdm_Core::log(__('Create part ','dropbox-backup') . basename( $af ) );
26
- }
27
- $archive = new WPAdm_Archive($af, $context->get('to_file') . '.md5');
28
- $archive->setRemovePath($context->get('remove_path'));
29
- } else {
30
- return true;
31
- }
32
- }
33
- if ( WPAdm_Running::is_stop() ) {
34
- $md5 = md5( print_r( $files, 1 ) );
35
- $files_str = implode(',', $files);
36
- $files_archive = WPAdm_Running::getCommandResultData('archive');
37
- if ( WPAdm_Running::is_stop() ) {
38
- if (!in_array($md5, $files_archive)) {
39
- if ( WPAdm_Running::is_stop() ) {
40
- $res = $archive->add($files_str);
41
- if ($res) {
42
- $files_archive = WPAdm_Running::getCommandResultData('archive');
43
- $files_archive[] = $md5;
44
- if (!empty($files_archive)) {
45
- WPAdm_Running::setCommandResultData('archive', $files_archive);
46
- WPAdm_Process::setInc( 'archiving', count($files) );
47
- }
48
- } else {
49
- $context->setError( $archive->error );
50
- return false;
51
- }
52
- } else {
53
- return true;
54
- }
55
- }
56
- } else {
57
- return true;
58
- }
59
- } else {
60
- return true;
61
- }
62
  }
 
 
63
  return true;
64
-
65
  }
66
 
67
  private function getArchiveName($name)
68
  {
69
- //WPAdm_Core::log("{$name}-*.zip");
70
  $archives = glob("{$name}-*.zip");
71
- //WPAdm_Core::log( print_r($archives, 1) );
72
  if (empty($archives)) {
73
  return "{$name}-1.zip";
74
  }
75
  $n = count($archives);
76
  $f = "{$name}-{$n}.zip";
 
77
  return $f;
78
  }
79
 
80
  private function getNextArchiveName($name)
81
  {
82
- //WPAdm_Core::log("{$name}-*.zip");
83
  $archives = glob("{$name}-*.zip");
84
- $n = 1 + count($archives);
85
  $a = "{$name}-{$n}.zip";
86
- //WPAdm_Core::log($a);
87
  return $a;
88
  }
89
  }
1
  <?php
2
+
3
 
4
  class WPadm_Command_Archive extends WPAdm_Сommand{
5
  public function execute(WPAdm_Command_Context $context)
6
  {
7
+ require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-archive.php';
8
+ $af = $this->getArchiveName($context->get('to_file'));
9
+ $archive = new WPAdm_Archive($af, $context->get('to_file') . '.md5');
10
+ $archive->setRemovePath($context->get('remove_path'));
11
+ $files = $context->get('files');
12
+
13
+ // если привышен максимальный размер архива, создадим новый
14
+ if (file_exists($af) && filesize($af) > $context->get('max_file_size')) {
15
+ //WPAdm_Core::log(filesize($af) . ', max=' . $context->get('max_file_size'));
16
+ $af = $this->getNextArchiveName($context->get('to_file'));
17
+ unset($archive);
18
+ $archive = new WPAdm_Archive($af, $context->get('to_file') . '.md5');
19
+ $archive->setRemovePath($context->get('remove_path'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  }
21
+ //WPAdm_Core::log('Add to archive ' . $af);
22
+ $archive->add(implode(',', $files));
23
  return true;
 
24
  }
25
 
26
  private function getArchiveName($name)
27
  {
 
28
  $archives = glob("{$name}-*.zip");
 
29
  if (empty($archives)) {
30
  return "{$name}-1.zip";
31
  }
32
  $n = count($archives);
33
  $f = "{$name}-{$n}.zip";
34
+ //$f = array_pop($archives);
35
  return $f;
36
  }
37
 
38
  private function getNextArchiveName($name)
39
  {
 
40
  $archives = glob("{$name}-*.zip");
41
+ $n = 1 + count($archives);
42
  $a = "{$name}-{$n}.zip";
 
43
  return $a;
44
  }
45
  }
commands/class-wpadm-command-mysqldump.php CHANGED
@@ -1,26 +1,22 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
3
-
4
- if (!class_exists('WPadm_Command_Mysqldump')) {
5
- class WPadm_Command_Mysqldump extends WPAdm_Сommand{
6
- public function execute(WPAdm_Command_Context $context)
7
- {
8
- if ( WPAdm_Running::is_stop() ) {
9
- //WPAdm_Core::log(print_r($context, true));
10
- require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-mysqldump.php';
11
- $mysqldump = new WPAdm_Mysqldump();
12
- $mysqldump->host = $context->get('host');
13
- $mysqldump->user = $context->get('user');
14
- $mysqldump->password = $context->get('password');
15
-
16
- try {
17
- $mysqldump->mysqldump($context->get('db'), $context->get('to_file'));
18
- } catch (Exception $e) {
19
- $context->setError($e->getMessage());
20
- return false;
21
- }
22
- }
23
- return true;
24
- }
25
- }
26
  }
1
+ <?php
2
+ if (!class_exists('WPadm_Command_Mysqldump')) {
3
+ class WPadm_Command_Mysqldump extends WPAdm_Сommand{
4
+ public function execute(WPAdm_Command_Context $context)
5
+ {
6
+ //WPAdm_Core::log(print_r($context, true));
7
+ require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-mysqldump.php';
8
+ $mysqldump = new WPAdm_Mysqldump();
9
+ $mysqldump->host = $context->get('host');
10
+ $mysqldump->user = $context->get('user');
11
+ $mysqldump->password = $context->get('password');
12
+
13
+ try {
14
+ $mysqldump->mysqldump($context->get('db'), $context->get('to_file'));
15
+ } catch (Exception $e) {
16
+ $context->setError($e->getMessage());
17
+ return false;
18
+ }
19
+ return true;
20
+ }
21
+ }
 
 
 
 
22
  }
commands/class-wpadm-command-mysqloptimize.php CHANGED
@@ -1,24 +1,22 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
3
-
4
- if (!class_exists('WPadm_Command_Mysqloptimize')) {
5
- class WPadm_Command_Mysqloptimize extends WPAdm_Сommand{
6
- public function execute(WPAdm_Command_Context $context)
7
- {
8
- //WPAdm_Core::log(print_r($context, true));
9
- require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-mysqldump.php';
10
- $mysqldump = new WPAdm_Mysqldump();
11
- $mysqldump->host = $context->get('host');
12
- $mysqldump->user = $context->get('user');
13
- $mysqldump->password = $context->get('password');
14
-
15
- try {
16
- $mysqldump->optimize($context->get('db'));
17
- } catch (Exception $e) {
18
- $context->setError($e->getMessage());
19
- return false;
20
- }
21
- return true;
22
- }
23
- }
24
- }
1
+ <?php
2
+ if (!class_exists('WPadm_Command_Mysqloptimize')) {
3
+ class WPadm_Command_Mysqloptimize extends WPAdm_Сommand{
4
+ public function execute(WPAdm_Command_Context $context)
5
+ {
6
+ //WPAdm_Core::log(print_r($context, true));
7
+ require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-mysqldump.php';
8
+ $mysqldump = new WPAdm_Mysqldump();
9
+ $mysqldump->host = $context->get('host');
10
+ $mysqldump->user = $context->get('user');
11
+ $mysqldump->password = $context->get('password');
12
+
13
+ try {
14
+ $mysqldump->optimize($context->get('db'));
15
+ } catch (Exception $e) {
16
+ $context->setError($e->getMessage());
17
+ return false;
18
+ }
19
+ return true;
20
+ }
21
+ }
22
+ }
 
 
commands/class-wpadm-command-restore-backup.php CHANGED
@@ -1,7 +1,4 @@
1
  <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
  if (!class_exists('WPadm_Command_Restore_Backup')) {
6
  class WPadm_Command_Restore_Backup extends WPAdm_Сommand {
7
 
@@ -22,8 +19,8 @@ if (!class_exists('WPadm_Command_Restore_Backup')) {
22
  }
23
 
24
  if ($file_in_zip == 0) {
25
- WPAdm_Core::log( str_replace("%d", SITE_HOME,__("Website \"%d\" returned an error during archive extracting: ",'dropbox-backup') ) . $this->archive->errorInfo(true) );
26
- $context->setError( str_replace("%d", SITE_HOME,__("Website \"%d\" returned an error during archive extracting: ",'dropbox-backup')) . $this->archive->errorInfo(true) );
27
  return false;
28
  }
29
  //WPAdm_Core::log(print_r($file_in_zip, 1));
@@ -43,9 +40,10 @@ if (!class_exists('WPadm_Command_Restore_Backup')) {
43
  }
44
  }
45
  }
 
46
  } else {
47
- $context->setError( str_replace(array('%d', '%f'), array(SITE_HOME, $context->get('zip_file') ), __("Website \"%d\" returned an error: The necessary file of archive \"%f\" wasn't found ",'dropbox-backup') ) );
48
- WPAdm_Core::log( str_replace(array('%d', '%f'), array(SITE_HOME, $context->get('zip_file') ), __("Website \"%d\" returned an error: The necessary file of archive \"%f\" wasn't found ",'dropbox-backup') ) );
49
  return false;
50
  }
51
  return true;
1
  <?php
 
 
 
2
  if (!class_exists('WPadm_Command_Restore_Backup')) {
3
  class WPadm_Command_Restore_Backup extends WPAdm_Сommand {
4
 
19
  }
20
 
21
  if ($file_in_zip == 0) {
22
+ WPAdm_Core::log( "ERROR Archived: " . $this->archive->errorInfo(true) );
23
+ $context->setError( "ERROR Archived: " . $this->archive->errorInfo(true));
24
  return false;
25
  }
26
  //WPAdm_Core::log(print_r($file_in_zip, 1));
40
  }
41
  }
42
  }
43
+
44
  } else {
45
+ $context->setError("File Archive Not Exist " . $context->get('zip_file'));
46
+ WPAdm_Core::log( "File Archive Not Exist " . $context->get('zip_file') );
47
  return false;
48
  }
49
  return true;
commands/class-wpadm-command-send-to-dropbox.php CHANGED
@@ -1,7 +1,4 @@
1
  <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
  if (!class_exists('WPadm_Command_Send_To_Dropbox')) {
6
 
7
  class WPadm_Command_Send_To_Dropbox extends WPAdm_Сommand {
@@ -9,96 +6,40 @@ if (!class_exists('WPadm_Command_Send_To_Dropbox')) {
9
  public function execute(WPAdm_Command_Context $context)
10
  {
11
  @session_start();
12
- if ( WPAdm_Running::is_stop() ) {
13
- require_once WPAdm_Core::getPluginDir() . '/modules/dropbox.class.php';
14
 
15
- WPAdm_Core::log(__('Send to dropbox files' ,'dropbox-backup') );
16
- $dropbox = new dropbox($context->get('key'), $context->get('secret'), $context->get('token'));
17
 
18
- if (!$dropbox->isAuth()) {
19
- $context->setError( str_replace(array('%d', '%k', '%s'),
20
- array( SITE_HOME, $context->get('key'), $context->get('secret') ),__('Website "%d" can\'t authorize on Dropbox with using of "app key: %k" and "app secret: %s"' ,'dropbox-backup') ) );
21
- return false;
22
- }
23
- if ( WPAdm_Running::is_stop() ) {
24
- $files = $context->get('files');
25
- $file = explode("/", $files);
26
- $file_name = array_pop($file);
27
- $folder_project_temp = $context->get('folder_project');
28
- $folder_project = "";
29
- if (!empty($folder_project_temp)) {
30
- $folder_project = $folder_project_temp . "/";
31
- $dropbox->createDir($folder_project_temp );
32
- $dropbox->createDir($folder_project . $context->get('folder') );
33
- } else {
34
- $dropbox->createDir($context->get('folder') );
35
- }
36
- } else {
37
- return true;
38
- }
39
 
40
- $fromFile = str_replace('//', '/', $files);
41
- $toFile = str_replace('//', '/', $folder_project . $context->get('folder') . '/' . $file_name);
42
- $local = $context->get('local');
43
- $file_dropbox = $dropbox->listing($folder_project . $context->get('folder') . '/' . $file_name);
44
- $send = true;
45
- if ( !isset($file_dropbox['error']) ) {
46
- if ($file_dropbox['bytes'] != filesize($fromFile)) {
47
- if ( WPAdm_Running::is_stop() ) {
48
- $delete_file = $dropbox->deleteFile($folder_project . $context->get('folder') . '/' . $file_name);
49
- if (isset($delete_file['error'])) {
50
- $context->setError( __('Dropbox returned an error during file sending: ' ,'dropbox-backup') . '"' . $delete_file['text'] . '"');
51
- return false;
52
- }
53
- $data_error_command = WPAdm_Running::getCommandResultData('errors_sending');
54
- if (isset($data_command[$fromFile])) {
55
- $data_error_command[$fromFile]['count'] += 1;
56
- } else {
57
- $data_error_command[$fromFile] = array();
58
- $data_error_command[$fromFile]['count'] = 1;
59
- }
60
- WPAdm_Running::setCommandResultData('errors_sending', $data_error_command);
61
- }
62
- } else {
63
- $send = false;
64
- }
65
- }
66
- if ( $local ) {
67
- if ( WPAdm_Running::is_stop() ) {
68
- $data_command = WPAdm_Running::getCommandResultData('command_dropbox');
69
- $md5 = md5($fromFile);
70
- if (empty($data_command) || !in_array($md5 ,$data_command) ) {
71
- if ($send) {
72
- $res = $dropbox->uploadFile($fromFile, $toFile, true);
73
- } else {
74
- $this->saveDataCommand($md5);
75
- WPAdm_Process::setInc('dropbox', 1);
76
- }
77
- }
78
- }
79
- } else {
80
- $md5 = md5($fromFile);
81
- $res = $dropbox->uploadFile($fromFile, $toFile, true);
82
- }
83
- if (isset($res['error']) && isset($res['text']) && $res['error'] == 1) {
84
- $context->setError( __('Dropbox returned an error during file sending: ' ,'dropbox-backup') . '"' . $res['text'] . '"');
85
- return false;
86
- }
87
- if ( WPAdm_Running::is_stop() ) {
88
- if (isset($res['size']) && isset($res['client_mtime'])) {
89
- WPAdm_Core::log( __('File upload: ' ,'dropbox-backup') . basename( $files ) . __(' size: ' ,'dropbox-backup') . $res['size']);
90
- $this->saveDataCommand($md5);
91
- WPAdm_Process::setInc('dropbox', 1);
92
- }
93
- }
94
  }
95
  return true;
96
  }
97
- private function saveDataCommand($file)
98
- {
99
- $data_command = WPAdm_Running::getCommandResultData('command_dropbox');
100
- $data_command[] = $file;
101
- WPAdm_Running::setCommandResultData('command_dropbox', $data_command);
102
- }
103
  }
104
  }
1
  <?php
 
 
 
2
  if (!class_exists('WPadm_Command_Send_To_Dropbox')) {
3
 
4
  class WPadm_Command_Send_To_Dropbox extends WPAdm_Сommand {
6
  public function execute(WPAdm_Command_Context $context)
7
  {
8
  @session_start();
9
+ require_once WPAdm_Core::getPluginDir() . '/modules/dropbox.class.php';
 
10
 
11
+ WPAdm_Core::log( langWPADM::get('Send to drop box files' , false) );
12
+ $dropbox = new dropbox($context->get('key'), $context->get('secret'), $context->get('token'));
13
 
14
+ if (!$dropbox->isAuth()) {
15
+ $context->setError( langWPADM::get('Error auth in Dropbox' , false) );
16
+ return false;
17
+ }
18
+ $files = $context->get('files');
19
+
20
+ $file = explode("/", $files);
21
+ $file_name = array_pop($file);
22
+ $folder_project_temp = $context->get('folder_project');
23
+ $folder_project = "";
24
+ if (!empty($folder_project_temp)) {
25
+ $folder_project = $folder_project_temp . "/";
26
+ $dropbox->createDir($folder_project_temp );
27
+ $dropbox->createDir($folder_project . $context->get('folder') );
28
+ } else {
29
+ $dropbox->createDir($context->get('folder') );
30
+ }
 
 
 
 
31
 
32
+ $fromFile = str_replace('//', '/', $files);
33
+ $toFile = str_replace('//', '/', $folder_project . $context->get('folder') . '/' . $file_name);
34
+ $res = $dropbox->uploadFile($fromFile, $toFile);
35
+ if (isset($res['error']) && isset($res['text']) && $res['error'] == 1) {
36
+ $context->setError( langWPADM::get('Error: ' , false) . '"' . $res['text'] . '"');
37
+ return false;
38
+ }
39
+ if (isset($res['size']) && isset($res['client_mtime'])) {
40
+ WPAdm_Core::log( langWPADM::get('File upload: ' , false) . basename( $files ) . langWPADM::get(' size: ' , false) . $res['size']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  }
42
  return true;
43
  }
 
 
 
 
 
 
44
  }
45
  }
dropbox-backup.php CHANGED
@@ -2,43 +2,30 @@
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.1.2
6
- Text Domain: dropbox-backup
7
- Domain Path: /languages/
8
  */
9
 
10
  if (!defined('DRBBACKUP_BASE_DIR')) {
11
  define('DRBBACKUP_BASE_DIR', dirname(__FILE__));
12
  }
13
 
14
- if (defined('MULTISITE') && (MULTISITE === true || MULTISITE == 'true')) {
15
- define('DRBBACKUP_MULTI', true);
16
- } else {
17
- define('DRBBACKUP_MULTI', false);
18
- }
19
-
20
- require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '/modules/constant.php';
21
  require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '/functions/wpadm.php';
22
  require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '/main/wpadm-class-wp.php';
23
 
24
  add_action('init', 'wpadm_full_backup_dropbox_run');
25
 
26
  add_action('admin_print_scripts', array('wpadm_wp_full_backup_dropbox', 'include_admins_script' ));
27
- if (DRBBACKUP_MULTI) {
28
- add_action('network_admin_menu', array('wpadm_wp_full_backup_dropbox', 'draw_menu'));
29
- } else {
30
- add_action('admin_menu', array('wpadm_wp_full_backup_dropbox', 'draw_menu'));
31
- }
32
  add_action('admin_post_activate_wpadm_full_backup_dropbox', array('wpadm_wp_full_backup_dropbox', 'activatePlugin') );
33
 
 
 
 
34
 
35
-
36
- if ( !function_exists('wpadm_full_backup_dropbox_run') ) {
37
  function wpadm_full_backup_dropbox_run()
38
  {
39
  wpadm_run('dropbox-backup', dirname(__FILE__));
40
  }
41
  }
42
 
43
-
44
-
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.2.9.3
 
 
6
  */
7
 
8
  if (!defined('DRBBACKUP_BASE_DIR')) {
9
  define('DRBBACKUP_BASE_DIR', dirname(__FILE__));
10
  }
11
 
 
 
 
 
 
 
 
12
  require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '/functions/wpadm.php';
13
  require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '/main/wpadm-class-wp.php';
14
 
15
  add_action('init', 'wpadm_full_backup_dropbox_run');
16
 
17
  add_action('admin_print_scripts', array('wpadm_wp_full_backup_dropbox', 'include_admins_script' ));
18
+ add_action('admin_menu', array('wpadm_wp_full_backup_dropbox', 'draw_menu'));
 
 
 
 
19
  add_action('admin_post_activate_wpadm_full_backup_dropbox', array('wpadm_wp_full_backup_dropbox', 'activatePlugin') );
20
 
21
+ if ( !get_option('wpadm_pub_key')/* && (is_admin())*/) {
22
+ add_action('admin_notices', 'wpadm_admin_notice');
23
+ }
24
 
25
+ if (!function_exists('wpadm_full_backup_dropbox_run')) {
 
26
  function wpadm_full_backup_dropbox_run()
27
  {
28
  wpadm_run('dropbox-backup', dirname(__FILE__));
29
  }
30
  }
31
 
 
 
functions/index.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
functions/wpadm.php CHANGED
@@ -3,46 +3,21 @@
3
  * General functions
4
  *
5
  */
6
- if ( ! defined( 'ABSPATH' ) ) exit;
7
-
8
- if (!function_exists('wpadm_nonce_life')) {
9
- function wpadm_nonce_life() {
10
- return 3 * HOUR_IN_SECONDS;
11
- }
12
- }
13
 
 
14
  if ( ! function_exists( 'wpadm_run' )) {
15
  function wpadm_run($pl, $dir) {
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' )) {
@@ -51,51 +26,17 @@ if ( ! function_exists( 'wpadm_unpack' )) {
51
  * @return mixed
52
  */
53
  function wpadm_unpack( $str ) {
54
- $str = base64_decode( $str );
55
- $str = preg_replace("/\<style.*?\<\/style\>/is", "", $str);
56
- $str = preg_replace("/\<script.*?\<\/script\>/is", "", $str);
57
- return json_decode( $str , true );
58
  }
59
  }
60
 
61
  if ( ! function_exists('wpadm_pack')) {
62
  /**
63
- * @param mixed $value
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
 
@@ -148,36 +89,6 @@ if ( ! function_exists('wpadm_send_blog_info')) {
148
  fclose($socket);
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') ){
158
- $user_ip = getenv('HTTP_FORWARDED_FOR');
159
- }elseif ( getenv('HTTP_X_FORWARDED_FOR') ){
160
- $user_ip = getenv('HTTP_X_FORWARDED_FOR');
161
- }elseif ( getenv('HTTP_X_COMING_FROM') ){
162
- $user_ip = getenv('HTTP_X_COMING_FROM');
163
- }elseif ( getenv('HTTP_VIA') ){
164
- $user_ip = getenv('HTTP_VIA');
165
- }elseif ( getenv('HTTP_XROXY_CONNECTION') ){
166
- $user_ip = getenv('HTTP_XROXY_CONNECTION');
167
- }elseif ( getenv('HTTP_CLIENT_IP') ){
168
- $user_ip = getenv('HTTP_CLIENT_IP');
169
- }
170
-
171
- $user_ip = trim($user_ip);
172
- if ( empty($user_ip) ){
173
- return '';
174
- }
175
- if ( !preg_match("/^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/", $user_ip) ){
176
- return '';
177
- }
178
- return $user_ip;
179
- }
180
- }
181
 
182
  if ( ! function_exists('wpadm_get_blog_info')) {
183
  function wpadm_get_blog_info() {
@@ -197,98 +108,4 @@ if ( ! function_exists('wpadm_get_blog_info')) {
197
  return $info;
198
  }
199
  }
200
- if ( ! function_exists( "wpadm_set_plugin" )) {
201
- function wpadm_set_plugin($plugin_name = '')
202
- {
203
- if (!empty($plugin_name) && function_exists("wpadm_run")) {
204
- $GLOBALS['wpadm_plugin'][] = $plugin_name;
205
- }
206
- }
207
- }
208
- if (!function_exists('wpadm_in_array')) {
209
- function wpadm_in_array($value, $key, $array, $ids = false)
210
- {
211
- if (is_array($array)) {
212
- foreach($array as $k => $v) {
213
- if (!is_array($v) && $k == $key && $v == $value) {
214
- if ($ids) {
215
- return $k;
216
- }
217
- return true;
218
- } elseif (is_array($v) && isset($v[$key]) && $v[$key] == $value ) {
219
- if ($ids) {
220
- return $k;
221
- }
222
- return true;
223
- }
224
- }
225
- }
226
- return false;
227
- }
228
- }
229
- if (function_exists('wpadm_getKey')) {
230
- function wpadm_getKey($array, $key)
231
- {
232
- $return = array();
233
- if (empty($array) && ($n = count($array)) > 0) {
234
- for($i = 0; $i < $n; $i++) {
235
- if (isset($array[$i]['key']) && is_array($key) && in_array($array[$i]['key'], $key) ) {
236
- $return[] = $i;
237
- } elseif(isset($array[$i]['key']) && is_string($key) ) {
238
- $return[] = $i;
239
- }
240
- }
241
- }
242
- return $return;
243
- }
244
- }
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) {
252
- return $size . 'b';
253
- } elseif ( $kbyte < $size && $size < $mbyte ) {
254
- return round( ( $size / $kbyte ) , 2 ) . 'Kb';
255
- } else {
256
- return round( ( $size / $mbyte ) , 2 ) . 'Mb';
257
- }
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', 'backupbuddy_backups' => '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
 
3
  * General functions
4
  *
5
  */
 
 
 
 
 
 
 
6
 
7
+ @set_time_limit(0);
8
  if ( ! function_exists( 'wpadm_run' )) {
9
  function wpadm_run($pl, $dir) {
10
 
11
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-method-class.php';
12
  $request_name = $pl . '_request';
13
+ if( isset( $_POST[$request_name] ) && ! empty ( $_POST[$request_name] ) ) {
14
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-core.php';
15
+ $wpadm = new WPAdm_Core(wpadm_unpack($_POST[$request_name]), $pl, $dir);
16
+ echo '<wpadm>'.wpadm_pack($wpadm->getResult()->toArray()).'</wpadm>';
17
+ exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
19
  }
20
+ }
21
 
22
 
23
  if ( ! function_exists( 'wpadm_unpack' )) {
26
  * @return mixed
27
  */
28
  function wpadm_unpack( $str ) {
29
+ return unserialize( base64_decode( $str ) );
 
 
 
30
  }
31
  }
32
 
33
  if ( ! function_exists('wpadm_pack')) {
34
  /**
35
+ * @param mixed $value
36
  * @return string
37
  */
38
  function wpadm_pack( $value ) {
39
+ return base64_encode( serialize ( $value ) ) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  }
41
  }
42
 
89
  fclose($socket);
90
  }
91
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
 
93
  if ( ! function_exists('wpadm_get_blog_info')) {
94
  function wpadm_get_blog_info() {
108
  return $info;
109
  }
110
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
 
img/closebox.png DELETED
Binary file
img/folder-loader.gif DELETED
Binary file
img/how-to-enable-cron.png DELETED
Binary file
languages/dropbox-backup.pot DELETED
@@ -1,945 +0,0 @@
1
- #, fuzzy
2
- msgid ""
3
- msgstr ""
4
- "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
- "Project-Id-Version: Dropbox Backup & Restore\n"
6
- "POT-Creation-Date: 2016-02-01 11:31+0300\n"
7
- "PO-Revision-Date: 2016-02-01 11:31+0300\n"
8
- "Last-Translator: \n"
9
- "Language-Team: \n"
10
- "MIME-Version: 1.0\n"
11
- "Content-Type: text/plain; charset=UTF-8\n"
12
- "Content-Transfer-Encoding: 8bit\n"
13
- "X-Generator: Poedit 1.8.6\n"
14
- "X-Poedit-Basepath: ..\n"
15
- "X-Poedit-WPHeader: dropbox-backup.php\n"
16
- "X-Poedit-SourceCharset: UTF-8\n"
17
- "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
18
- "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
19
- "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
20
- "X-Poedit-SearchPath-0: .\n"
21
- "X-Poedit-SearchPathExcluded-0: *.js\n"
22
-
23
- #: commands/class-wpadm-command-archive.php:15
24
- #: commands/class-wpadm-command-archive.php:21
25
- msgid "Create part "
26
- msgstr ""
27
-
28
- #: commands/class-wpadm-command-restore-backup.php:22
29
- #: commands/class-wpadm-command-restore-backup.php:23
30
- #, php-format
31
- msgid "Website \"%d\" returned an error during archive extracting: "
32
- msgstr ""
33
-
34
- #: commands/class-wpadm-command-restore-backup.php:44
35
- #: commands/class-wpadm-command-restore-backup.php:45
36
- #, php-format
37
- msgid ""
38
- "Website \"%d\" returned an error: The necessary file of archive \"%f\" "
39
- "wasn't found "
40
- msgstr ""
41
-
42
- #: commands/class-wpadm-command-send-to-dropbox.php:11
43
- msgid "Send to dropbox files"
44
- msgstr ""
45
-
46
- #: commands/class-wpadm-command-send-to-dropbox.php:15
47
- #: main/wpadm-class-wp.php:319
48
- msgid ""
49
- "Website \"%d\" can't authorize on Dropbox with using of \"app key: %k\" and "
50
- "\"app secret: %s\""
51
- msgstr ""
52
-
53
- #: commands/class-wpadm-command-send-to-dropbox.php:42
54
- #: commands/class-wpadm-command-send-to-dropbox.php:70
55
- msgid "Dropbox returned an error during file sending: "
56
- msgstr ""
57
-
58
- #: commands/class-wpadm-command-send-to-dropbox.php:74
59
- msgid "File upload: "
60
- msgstr ""
61
-
62
- #: commands/class-wpadm-command-send-to-dropbox.php:74
63
- msgid " size: "
64
- msgstr ""
65
-
66
- #: libs/wpadm.server.main.class.php:144
67
- msgid "Your request was sent. <br /> Thank you for your assistance."
68
- msgstr ""
69
-
70
- #: main/wpadm-class-wp.php:78
71
- msgid "1 day"
72
- msgstr ""
73
-
74
- #: main/wpadm-class-wp.php:81
75
- msgid "1 week"
76
- msgstr ""
77
-
78
- #: main/wpadm-class-wp.php:218 main/wpadm-class-wp.php:567
79
- #, php-format
80
- msgid ""
81
- "Website \"%domain\" returned an error during file creation: Failed to create "
82
- "file, please check the permissions on the folder \"%dir-backup\"."
83
- msgstr ""
84
-
85
- #: main/wpadm-class-wp.php:280
86
- msgid "Start Restore from Dropbox cloud"
87
- msgstr ""
88
-
89
- #: main/wpadm-class-wp.php:306
90
- msgid "Error: "
91
- msgstr ""
92
-
93
- #: main/wpadm-class-wp.php:308
94
- #, php-format
95
- msgid "Download file (%s) with Dropbox"
96
- msgstr ""
97
-
98
- #: main/wpadm-class-wp.php:324 main/wpadm-class-wp.php:474
99
- #: main/wpadm-class-wp.php:510
100
- #, php-format
101
- msgid ""
102
- "Website \"%d\" returned an error during connection to Dropbox: \"app key\" "
103
- "and \"app secret\" wasn't found. Please, check your Dropbox settings."
104
- msgstr ""
105
-
106
- #: main/wpadm-class-wp.php:402 main/wpadm-class-wp.php:413
107
- #, php-format
108
- msgid "Backup(%s) was deleted"
109
- msgstr ""
110
-
111
- #: main/wpadm-class-wp.php:498
112
- #, php-format
113
- msgid ""
114
- "Website \"%d\" returned an error during connection to Dropbox: \"App Key\" "
115
- "wasn't found. Please, check your Dropbox settings."
116
- msgstr ""
117
-
118
- #: main/wpadm-class-wp.php:502
119
- #, php-format
120
- msgid ""
121
- "Website \"%d\" returned an error during connection to Dropbox: \"App Secret"
122
- "\" wasn't found. Please, check your Dropbox settings."
123
- msgstr ""
124
-
125
- #: main/wpadm-class-wp.php:506
126
- #, php-format
127
- msgid ""
128
- "Website \"%d\" returned an error during file sending to Dropbox: \"Auth "
129
- "Token not exist. Files cannot be sent to Dropbox cloud. Please, check your "
130
- "Dropbox settings.\""
131
- msgstr ""
132
-
133
- #: main/wpadm-class-wp.php:619
134
- msgid "Checkout was canceled"
135
- msgstr ""
136
-
137
- #: main/wpadm-class-wp.php:644
138
- msgid ""
139
- "The \"Dropbox backup & restore PRO\" version can be downloaded here <a href="
140
- "\"&s\">download</a>"
141
- msgstr ""
142
-
143
- #: methods/class-wpadm-method-backup.php:119
144
- #: methods/class-wpadm-method-local-backup.php:118
145
- #, php-format
146
- msgid ""
147
- "Website \"%domain\" returned an error during database dump creation: 'Dump "
148
- "of Database wasn't created: \"%s\"'. To solve this problem, please check "
149
- "your database system logs or send to us your FTP access data. You can send "
150
- "to us support request using \"Help\" button on plugin page."
151
- msgstr ""
152
-
153
- #: methods/class-wpadm-method-backup.php:123
154
- #: methods/class-wpadm-method-local-backup.php:122
155
- #, php-format
156
- msgid ""
157
- "Website \"%domain\" returned an error during database dump creation: "
158
- "Database-Dump file is emplty. To solve this problem, please check "
159
- "permissions to folder: \"%dir\"."
160
- msgstr ""
161
-
162
- #: methods/class-wpadm-method-backup.php:128
163
- #: methods/class-wpadm-method-full-backup-dropbox.php:131
164
- #, php-format
165
- msgid "Database Dump was successfully created ( %s Mb) : "
166
- msgstr ""
167
-
168
- #: methods/class-wpadm-method-full-backup-dropbox.php:82
169
- msgid "Start backup"
170
- msgstr ""
171
-
172
- #: methods/class-wpadm-method-full-backup-dropbox.php:85
173
- msgid "Start create db dump"
174
- msgstr ""
175
-
176
- #: methods/class-wpadm-method-full-backup-dropbox.php:99
177
- msgid "Table optimization"
178
- msgstr ""
179
-
180
- #: methods/class-wpadm-method-full-backup-dropbox.php:123
181
- #, php-format
182
- msgid "Error: Dump of Database wasn't created (%s)"
183
- msgstr ""
184
-
185
- #: methods/class-wpadm-method-full-backup-dropbox.php:127
186
- msgid "MySQL Error: Database-Dump File is empty"
187
- msgstr ""
188
-
189
- #: methods/class-wpadm-method-full-backup-dropbox.php:128
190
- msgid "Dump of Database wasn't created (File of Database-Dump is empty!)"
191
- msgstr ""
192
-
193
- #: methods/class-wpadm-method-full-backup-dropbox.php:138
194
- msgid "Create a list of files for Backup"
195
- msgstr ""
196
-
197
- #: methods/class-wpadm-method-full-backup-dropbox.php:145
198
- msgid "Error: the list of Backup files is empty"
199
- msgstr ""
200
-
201
- #: methods/class-wpadm-method-full-backup-dropbox.php:167
202
- #: methods/class-wpadm-method-local-backup.php:175
203
- msgid "List of Backup-Files was successfully created"
204
- msgstr ""
205
-
206
- #: methods/class-wpadm-method-full-backup-dropbox.php:182
207
- #: methods/class-wpadm-method-local-backup.php:194
208
- msgid "Backup of Files was started"
209
- msgstr ""
210
-
211
- #: methods/class-wpadm-method-full-backup-dropbox.php:185
212
- #: methods/class-wpadm-method-local-backup.php:196
213
- msgid "End of File Backup"
214
- msgstr ""
215
-
216
- #: methods/class-wpadm-method-full-backup-dropbox.php:202
217
- msgid "Begin copying files to FTP"
218
- msgstr ""
219
-
220
- #: methods/class-wpadm-method-full-backup-dropbox.php:225
221
- msgid "FTP: "
222
- msgstr ""
223
-
224
- #: methods/class-wpadm-method-full-backup-dropbox.php:229
225
- msgid "Finished copying files to FTP"
226
- msgstr ""
227
-
228
- #: methods/class-wpadm-method-full-backup-dropbox.php:234
229
- msgid "Begin coping files to S3"
230
- msgstr ""
231
-
232
- #: methods/class-wpadm-method-full-backup-dropbox.php:258
233
- msgid "Finished copying files to S3"
234
- msgstr ""
235
-
236
- #: methods/class-wpadm-method-full-backup-dropbox.php:266
237
- msgid "Remove the backup server"
238
- msgstr ""
239
-
240
- #: methods/class-wpadm-method-full-backup-dropbox.php:275
241
- msgid "files to google: "
242
- msgstr ""
243
-
244
- #: methods/class-wpadm-method-full-backup-dropbox.php:292
245
- msgid "Google drive: "
246
- msgstr ""
247
-
248
- #: methods/class-wpadm-method-full-backup-dropbox.php:300
249
- msgid "files to dropbox: "
250
- msgstr ""
251
-
252
- #: methods/class-wpadm-method-full-backup-dropbox.php:317
253
- msgid "Dropbox: "
254
- msgstr ""
255
-
256
- #: methods/class-wpadm-method-full-backup-dropbox.php:325
257
- msgid "Start removing old backups"
258
- msgstr ""
259
-
260
- #: methods/class-wpadm-method-full-backup-dropbox.php:346
261
- msgid "Finished removing old backups"
262
- msgstr ""
263
-
264
- #: methods/class-wpadm-method-full-backup-dropbox.php:348
265
- msgid "Creating a backup is completed"
266
- msgstr ""
267
-
268
- #: methods/class-wpadm-method-full-backup-dropbox.php:397
269
- msgid "Skip file "
270
- msgstr ""
271
-
272
- #: methods/class-wpadm-method-full-backup-dropbox.php:492
273
- msgid "Skip dir "
274
- msgstr ""
275
-
276
- #: methods/class-wpadm-method-local-backup.php:18
277
- #: methods/class-wpadm-method-local-restore.php:28
278
- msgid "Create Unique Id "
279
- msgstr ""
280
-
281
- #: methods/class-wpadm-method-local-backup.php:71
282
- msgid "Start Backup process..."
283
- msgstr ""
284
-
285
- #: methods/class-wpadm-method-local-backup.php:78
286
- msgid "Creating Database Dump"
287
- msgstr ""
288
-
289
- #: methods/class-wpadm-method-local-backup.php:93
290
- msgid "Optimize Database Tables"
291
- msgstr ""
292
-
293
- #: methods/class-wpadm-method-local-backup.php:127
294
- #, php-format
295
- msgid "Database Dump was successfully created ( %size Mb) : "
296
- msgstr ""
297
-
298
- #: methods/class-wpadm-method-local-backup.php:148
299
- #, php-format
300
- msgid ""
301
- "Website \"%d\" returned an error during creation of the list of files for a "
302
- "backup: list of files for a backup is empty. To solve this problem, please "
303
- "check files and folders permissions for website \"%d\"."
304
- msgstr ""
305
-
306
- #: methods/class-wpadm-method-local-backup.php:215
307
- #, php-format
308
- msgid "Backup Size %s Mb"
309
- msgstr ""
310
-
311
- #: methods/class-wpadm-method-local-backup.php:224
312
- msgid "Limits of Backups "
313
- msgstr ""
314
-
315
- #: methods/class-wpadm-method-local-backup.php:225
316
- msgid "Removing of old Backups was started"
317
- msgstr ""
318
-
319
- #: methods/class-wpadm-method-local-backup.php:244
320
- msgid "Removing of old Backups was Finished"
321
- msgstr ""
322
-
323
- #: methods/class-wpadm-method-local-backup.php:256
324
- msgid "Backup creation was complete successfully!"
325
- msgstr ""
326
-
327
- #: methods/class-wpadm-method-local-backup.php:298
328
- #: methods/class-wpadm-method-local-backup.php:385
329
- msgid "Skip of File "
330
- msgstr ""
331
-
332
- #: methods/class-wpadm-method-local-backup.php:349
333
- #: methods/class-wpadm-method-local-backup.php:397
334
- msgid "Skip of Folder "
335
- msgstr ""
336
-
337
- #: methods/class-wpadm-method-local-backup.php:362
338
- msgid "Skip of Cache-Folder "
339
- msgstr ""
340
-
341
- #: methods/class-wpadm-method-local-restore.php:47
342
- #, php-format
343
- msgid ""
344
- "Website \"%d\" returned an error during backup restoration: Archive of "
345
- "Backup wasn't found \"%s\""
346
- msgstr ""
347
-
348
- #: methods/class-wpadm-method-local-restore.php:90
349
- msgid "Start Restore process"
350
- msgstr ""
351
-
352
- #: methods/class-wpadm-method-local-restore.php:128
353
- #, php-format
354
- msgid ""
355
- "Website \"%d\" returned an error during backup restoration: Part Backup is "
356
- "not exist \"%s\" "
357
- msgstr ""
358
-
359
- #: methods/class-wpadm-method-local-restore.php:138
360
- #, php-format
361
- msgid ""
362
- "Website \"%d\" returned an error during restore backup: Files for restore is "
363
- "not exist, check permission your backup data or You can send to us support "
364
- "request using \"Help\" button on plugin page."
365
- msgstr ""
366
-
367
- #: methods/class-wpadm-method-queue-controller.php:69
368
- #, php-format
369
- msgid ""
370
- "Website \"%d\" returned an error: Command \"%com\" not found. To solve this "
371
- "problem, we need to access the system logs of your hosting/server and/or "
372
- "from your backup, that you tried to create or simply send to us your FTP "
373
- "access data. You can send to us support request using \"Help\" button on "
374
- "plugin page."
375
- msgstr ""
376
-
377
- #: methods/class-wpadm-method-queue-controller.php:75
378
- #, php-format
379
- msgid ""
380
- "Website \"%d\" returned some unknown error during command \"%com\" was "
381
- "running. To solve this problem, we need to access the system logs of your "
382
- "hosting/server and/or from your backup, that you tried to create or simply "
383
- "send to us your FTP access data. You can send to us support request using "
384
- "\"Help\" button on plugin page."
385
- msgstr ""
386
-
387
- #: methods/class-wpadm-method-send-to-dropbox.php:49
388
- msgid ""
389
- "Not perhaps sending file: \"%file%\". If you wish make upload file, increase "
390
- "execution time code or speed internet provider is small for upload file."
391
- msgstr ""
392
-
393
- #: methods/class-wpadm-method-send-to-dropbox.php:75
394
- msgid "Start copy to Dropbox Cloud"
395
- msgstr ""
396
-
397
- #: methods/class-wpadm-method-send-to-dropbox.php:77
398
- msgid "End Copy Files to Dropbox"
399
- msgstr ""
400
-
401
- #: methods/class-wpadm-method-send-to-dropbox.php:80
402
- #: methods/class-wpadm-method-send-to-dropbox.php:81
403
- msgid "Answer from Dropbox "
404
- msgstr ""
405
-
406
- #: methods/class-wpadm-method-update.php:16
407
- msgid "Error to copy file "
408
- msgstr ""
409
-
410
- #: methods/class-wpadm-method-update.php:19
411
- msgid "Error to extract file "
412
- msgstr ""
413
-
414
- #: modules/class-wpadm-core.php:223 modules/class-wpadm-core.php:228
415
- msgid ""
416
- "Failed to create a file, please check the permissions on the folders \"&s\"."
417
- msgstr ""
418
-
419
- #: modules/class-wpadm-mysqldump.php:28
420
- msgid "MySQL Connect failed: "
421
- msgstr ""
422
-
423
- #: modules/class-wpadm-mysqldump.php:49
424
- msgid "Optimize Database Tables was started"
425
- msgstr ""
426
-
427
- #: modules/class-wpadm-mysqldump.php:65
428
- #, php-format
429
- msgid "Error to Optimize Table `%s`"
430
- msgstr ""
431
-
432
- #: modules/class-wpadm-mysqldump.php:68
433
- #, php-format
434
- msgid "Optimize Table `%s` was successfully"
435
- msgstr ""
436
-
437
- #: modules/class-wpadm-mysqldump.php:73
438
- msgid "Optimize Database Tables was Finished"
439
- msgstr ""
440
-
441
- #: modules/class-wpadm-mysqldump.php:86
442
- msgid "MySQL of Dump was started"
443
- msgstr ""
444
-
445
- #: modules/class-wpadm-mysqldump.php:130
446
- #, php-format
447
- msgid "Add a table \"%s\" in the database dump"
448
- msgstr ""
449
-
450
- #: modules/class-wpadm-mysqldump.php:176
451
- msgid "Add a table rows \"%s\" in the database dump from %from% to %to%"
452
- msgstr ""
453
-
454
- #: modules/class-wpadm-mysqldump.php:195
455
- msgid "MySQL of Dump was finished"
456
- msgstr ""
457
-
458
- #: modules/class-wpadm-mysqldump.php:213
459
- msgid "Restore Database was started"
460
- msgstr ""
461
-
462
- #: modules/class-wpadm-mysqldump.php:216 modules/class-wpadm-mysqldump.php:217
463
- msgid "Error in open file dump"
464
- msgstr ""
465
-
466
- #: modules/class-wpadm-mysqldump.php:231
467
- msgid "MySQL Error: "
468
- msgstr ""
469
-
470
- #: modules/class-wpadm-mysqldump.php:238
471
- msgid "Restore Database was finished"
472
- msgstr ""
473
-
474
- #: template/notice.php:3
475
- msgid "Professional version of"
476
- msgstr ""
477
-
478
- #: template/notice.php:4
479
- msgid "Dropbox backup and restore\""
480
- msgstr ""
481
-
482
- #: template/notice.php:4
483
- msgid "Dropbox backup and restore"
484
- msgstr ""
485
-
486
- #: template/notice.php:5
487
- msgid " plugin is now available!"
488
- msgstr ""
489
-
490
- #: template/notice.php:6
491
- msgid "Read more..."
492
- msgstr ""
493
-
494
- #: template/notice.php:7
495
- msgid "hide this message"
496
- msgstr ""
497
-
498
- #: template/notice5.php:4
499
- #, php-format
500
- msgid ""
501
- "You use Dropbox backup and restore plugin successfully for more than %s. "
502
- "Please, leave a 5 star review for our development team, because it inspires "
503
- "us to develop this plugin for you."
504
- msgstr ""
505
-
506
- #: template/notice5.php:5
507
- msgid "Thank you!"
508
- msgstr ""
509
-
510
- #: template/notice5.php:7
511
- msgid "Leave review"
512
- msgstr ""
513
-
514
- #: template/notice5.php:8
515
- msgid "I already left a review"
516
- msgstr ""
517
-
518
- #: template/notice5.php:9
519
- msgid "Hide this message"
520
- msgstr ""
521
-
522
- #: template/wpadm_show_backup.php:28 template/wpadm_show_backup.php:45
523
- msgid "Hide"
524
- msgstr ""
525
-
526
- #: template/wpadm_show_backup.php:34 template/wpadm_show_backup.php:51
527
- #: template/wpadm_show_backup.php:1025 template/wpadm_show_backup.php:1121
528
- msgid "Show"
529
- msgstr ""
530
-
531
- #: template/wpadm_show_backup.php:177 template/wpadm_show_backup.php:237
532
- msgid "Dropbox Backup was created successfully"
533
- msgstr ""
534
-
535
- #: template/wpadm_show_backup.php:181 template/wpadm_show_backup.php:241
536
- msgid "Dropbox Backup wasn't created. "
537
- msgstr ""
538
-
539
- #: template/wpadm_show_backup.php:227
540
- msgid "Local Backup was created successfully"
541
- msgstr ""
542
-
543
- #: template/wpadm_show_backup.php:231
544
- msgid "Local Backup wasn't created"
545
- msgstr ""
546
-
547
- #: template/wpadm_show_backup.php:249 template/wpadm_show_backup.php:1248
548
- msgid "Successful"
549
- msgstr ""
550
-
551
- #: template/wpadm_show_backup.php:254 template/wpadm_show_backup.php:1255
552
- msgid "Fail"
553
- msgstr ""
554
-
555
- #: template/wpadm_show_backup.php:254 template/wpadm_show_backup.php:1255
556
- msgid "Show Details"
557
- msgstr ""
558
-
559
- #: template/wpadm_show_backup.php:255 template/wpadm_show_backup.php:1236
560
- msgid "Not available"
561
- msgstr ""
562
-
563
- #: template/wpadm_show_backup.php:285 template/wpadm_show_backup.php:1259
564
- msgid "backup"
565
- msgstr ""
566
-
567
- #: template/wpadm_show_backup.php:288 template/wpadm_show_backup.php:1260
568
- msgid "Mb"
569
- msgstr ""
570
-
571
- #: template/wpadm_show_backup.php:291 template/wpadm_show_backup.php:1264
572
- msgid "Restore"
573
- msgstr ""
574
-
575
- #: template/wpadm_show_backup.php:292 template/wpadm_show_backup.php:1266
576
- msgid "Delete"
577
- msgstr ""
578
-
579
- #: template/wpadm_show_backup.php:358 template/wpadm_show_backup.php:1132
580
- msgid "sec."
581
- msgstr ""
582
-
583
- #: template/wpadm_show_backup.php:381
584
- msgid "Are you sure you want to start the recovery process?"
585
- msgstr ""
586
-
587
- #: template/wpadm_show_backup.php:418
588
- #, php-format
589
- msgid "Local Backup (%s) was restored successfully"
590
- msgstr ""
591
-
592
- #: template/wpadm_show_backup.php:422
593
- #, php-format
594
- msgid "Dropbox Backup (%s) was restored successfully"
595
- msgstr ""
596
-
597
- #: template/wpadm_show_backup.php:430
598
- #, php-format
599
- msgid "Local Backup (%s) wasn't restored"
600
- msgstr ""
601
-
602
- #: template/wpadm_show_backup.php:434
603
- #, php-format
604
- msgid "Dropbox Backup (%s) wasn't restored"
605
- msgstr ""
606
-
607
- #: template/wpadm_show_backup.php:541
608
- msgid "Please, permit the pop-up windows."
609
- msgstr ""
610
-
611
- #: template/wpadm_show_backup.php:552 template/wpadm_show_backup.php:1071
612
- msgid "Dropbox successfully connected:"
613
- msgstr ""
614
-
615
- #: template/wpadm_show_backup.php:787
616
- msgid "Please, add your Dropbox credentials:"
617
- msgstr ""
618
-
619
- #: template/wpadm_show_backup.php:788
620
- msgid "\"App key\""
621
- msgstr ""
622
-
623
- #: template/wpadm_show_backup.php:788
624
- msgid "\"App secret\""
625
- msgstr ""
626
-
627
- #: template/wpadm_show_backup.php:789
628
- msgid "in the Setting Form"
629
- msgstr ""
630
-
631
- #: template/wpadm_show_backup.php:792 template/wpadm_show_backup.php:815
632
- #: template/wpadm_show_backup.php:894 template/wpadm_show_backup.php:1193
633
- msgid "OK"
634
- msgstr ""
635
-
636
- #: template/wpadm_show_backup.php:823
637
- msgid ""
638
- "To solve this problem, we need to access the system logs of your hosting/"
639
- "server and/or from your backup, <br />that you tried to create or simply "
640
- "send to us your FTP access data."
641
- msgstr ""
642
-
643
- #: template/wpadm_show_backup.php:827
644
- msgid "I want to provide your FTP access to resolve this issue quickly:"
645
- msgstr ""
646
-
647
- #: template/wpadm_show_backup.php:833 template/wpadm_show_backup.php:1349
648
- msgid "FTP Host"
649
- msgstr ""
650
-
651
- #: template/wpadm_show_backup.php:842 template/wpadm_show_backup.php:1358
652
- msgid "FTP User"
653
- msgstr ""
654
-
655
- #: template/wpadm_show_backup.php:851 template/wpadm_show_backup.php:1367
656
- msgid "FTP Password"
657
- msgstr ""
658
-
659
- #: template/wpadm_show_backup.php:863 template/wpadm_show_backup.php:1379
660
- msgid "Response Email:"
661
- msgstr ""
662
-
663
- #: template/wpadm_show_backup.php:877
664
- msgid "SEND TO SUPPORT and close this window"
665
- msgstr ""
666
-
667
- #: template/wpadm_show_backup.php:878
668
- msgid "Close this window WITHOUT SENDING TO SUPPORT"
669
- msgstr ""
670
-
671
- #: template/wpadm_show_backup.php:884
672
- msgid "Where can I find my app key and secret?"
673
- msgstr ""
674
-
675
- #: template/wpadm_show_backup.php:887
676
- msgid "You can get an API app key and secret by creating an app on the"
677
- msgstr ""
678
-
679
- #: template/wpadm_show_backup.php:888
680
- msgid "app creation page"
681
- msgstr ""
682
-
683
- #: template/wpadm_show_backup.php:889
684
- msgid ""
685
- "Once you have an app created, the app key and secret will be available on "
686
- "the app's page on the"
687
- msgstr ""
688
-
689
- #: template/wpadm_show_backup.php:890
690
- msgid "App Console"
691
- msgstr ""
692
-
693
- #: template/wpadm_show_backup.php:891
694
- msgid "Note that Drop-ins have app keys but no app secrets."
695
- msgstr ""
696
-
697
- #: template/wpadm_show_backup.php:901
698
- msgid ""
699
- "Use Professional version of \"Dropbox backup and restore\" plugin and get:"
700
- msgstr ""
701
-
702
- #: template/wpadm_show_backup.php:906
703
- msgid "Automated Dropbox backup (Scheduled backup tasks)"
704
- msgstr ""
705
-
706
- #: template/wpadm_show_backup.php:912
707
- msgid "Automated Local backup (Scheduled backup tasks)"
708
- msgstr ""
709
-
710
- #: template/wpadm_show_backup.php:918
711
- msgid "Backup Status E-Mail Reporting"
712
- msgstr ""
713
-
714
- #: template/wpadm_show_backup.php:924
715
- msgid ""
716
- "Online Service \"Backup Website Manager\" (Copy, Clone or Migrate of "
717
- "websites)"
718
- msgstr ""
719
-
720
- #: template/wpadm_show_backup.php:930
721
- msgid "One Year Free Updates for PRO version"
722
- msgstr ""
723
-
724
- #: template/wpadm_show_backup.php:936
725
- msgid "One Year Priority support"
726
- msgstr ""
727
-
728
- #: template/wpadm_show_backup.php:943
729
- msgid "Get PRO version"
730
- msgstr ""
731
-
732
- #: template/wpadm_show_backup.php:953
733
- msgid "Get PRO"
734
- msgstr ""
735
-
736
- #: template/wpadm_show_backup.php:965
737
- msgid "Dropbox Full Backup"
738
- msgstr ""
739
-
740
- #: template/wpadm_show_backup.php:966
741
- msgid "(files+database)"
742
- msgstr ""
743
-
744
- #: template/wpadm_show_backup.php:976
745
- msgid "Free Sign Up"
746
- msgstr ""
747
-
748
- #: template/wpadm_show_backup.php:976
749
- msgid "to backup more than one website..."
750
- msgstr ""
751
-
752
- #: template/wpadm_show_backup.php:985
753
- msgid "E-mail"
754
- msgstr ""
755
-
756
- #: template/wpadm_show_backup.php:993 template/wpadm_show_backup.php:1045
757
- msgid "Password"
758
- msgstr ""
759
-
760
- #: template/wpadm_show_backup.php:1001
761
- msgid "Password confirm"
762
- msgstr ""
763
-
764
- #: template/wpadm_show_backup.php:1011
765
- msgid "Register & Activate"
766
- msgstr ""
767
-
768
- #: template/wpadm_show_backup.php:1018
769
- msgid "If you are NOT registered at"
770
- msgstr ""
771
-
772
- #: template/wpadm_show_backup.php:1018
773
- msgid "WPAdm"
774
- msgstr ""
775
-
776
- #: template/wpadm_show_backup.php:1018
777
- msgid ""
778
- "enter your email and password to use as your Account Data for authorization "
779
- "on WPAdm."
780
- msgstr ""
781
-
782
- #: template/wpadm_show_backup.php:1018
783
- msgid "If you already have an account at"
784
- msgstr ""
785
-
786
- #: template/wpadm_show_backup.php:1018
787
- msgid ""
788
- "and you want to Sign-In, so please, enter your registered credential data "
789
- "(email and password twice)."
790
- msgstr ""
791
-
792
- #: template/wpadm_show_backup.php:1033
793
- msgid "Sign In to backup more than one website..."
794
- msgstr ""
795
-
796
- #: template/wpadm_show_backup.php:1042
797
- msgid "Email"
798
- msgstr ""
799
-
800
- #: template/wpadm_show_backup.php:1054
801
- msgid "set new mail"
802
- msgstr ""
803
-
804
- #: template/wpadm_show_backup.php:1064
805
- msgid "Settings"
806
- msgstr ""
807
-
808
- #: template/wpadm_show_backup.php:1070
809
- msgid "Connect to Dropbox"
810
- msgstr ""
811
-
812
- #: template/wpadm_show_backup.php:1075
813
- msgid "Connect using my Dropbox App"
814
- msgstr ""
815
-
816
- #: template/wpadm_show_backup.php:1082
817
- msgid "App key"
818
- msgstr ""
819
-
820
- #: template/wpadm_show_backup.php:1090
821
- msgid "App secret"
822
- msgstr ""
823
-
824
- #: template/wpadm_show_backup.php:1099
825
- msgid "Where to get App key & App secret?"
826
- msgstr ""
827
-
828
- #: template/wpadm_show_backup.php:1108
829
- msgid "Appear in menu for admins only"
830
- msgstr ""
831
-
832
- #: template/wpadm_show_backup.php:1113
833
- msgid "Database Optimization"
834
- msgstr ""
835
-
836
- #: template/wpadm_show_backup.php:1132
837
- msgid "Please wait..."
838
- msgstr ""
839
-
840
- #: template/wpadm_show_backup.php:1140
841
- msgid "++ Review ++"
842
- msgstr ""
843
-
844
- #: template/wpadm_show_backup.php:1141
845
- msgid "Your review is important for us"
846
- msgstr ""
847
-
848
- #: template/wpadm_show_backup.php:1146
849
- msgid "Help"
850
- msgstr ""
851
-
852
- #: template/wpadm_show_backup.php:1150
853
- msgid "Create Dropbox Backup"
854
- msgstr ""
855
-
856
- #: template/wpadm_show_backup.php:1153
857
- msgid "Create Local Backup"
858
- msgstr ""
859
-
860
- #: template/wpadm_show_backup.php:1156
861
- msgid "Folders & files"
862
- msgstr ""
863
-
864
- #: template/wpadm_show_backup.php:1177
865
- msgid "Include/Exclude of Files & Folders to backup"
866
- msgstr ""
867
-
868
- #: template/wpadm_show_backup.php:1179
869
- msgid "Database of web page will be included automatically"
870
- msgstr ""
871
-
872
- #: template/wpadm_show_backup.php:1194
873
- msgid "Cancel"
874
- msgstr ""
875
-
876
- #: template/wpadm_show_backup.php:1204
877
- msgid "Create, Date/Time"
878
- msgstr ""
879
-
880
- #: template/wpadm_show_backup.php:1205
881
- msgid "Name of Backup"
882
- msgstr ""
883
-
884
- #: template/wpadm_show_backup.php:1206
885
- msgid "Archive Parts"
886
- msgstr ""
887
-
888
- #: template/wpadm_show_backup.php:1207
889
- msgid "Status"
890
- msgstr ""
891
-
892
- #: template/wpadm_show_backup.php:1208
893
- msgid "Type of Backup"
894
- msgstr ""
895
-
896
- #: template/wpadm_show_backup.php:1209
897
- msgid "Size"
898
- msgstr ""
899
-
900
- #: template/wpadm_show_backup.php:1211
901
- msgid "Action"
902
- msgstr ""
903
-
904
- #: template/wpadm_show_backup.php:1234
905
- msgid "Backup in process create"
906
- msgstr ""
907
-
908
- #: template/wpadm_show_backup.php:1236
909
- msgid "Why?"
910
- msgstr ""
911
-
912
- #: template/wpadm_show_backup.php:1251
913
- msgid "Attention, backup creates"
914
- msgstr ""
915
-
916
- #: template/wpadm_show_backup.php:1312
917
- msgid ""
918
- "Backup is created. If you are sure that the backup down(crashed), please "
919
- msgstr ""
920
-
921
- #: template/wpadm_show_backup.php:1313
922
- msgid "contact us"
923
- msgstr ""
924
-
925
- #: template/wpadm_show_backup.php:1338
926
- msgid "Error log wasn't Found"
927
- msgstr ""
928
-
929
- #: template/wpadm_show_backup.php:1344
930
- msgid "Please, provide your FTP access to resolve this issue quickly:"
931
- msgstr ""
932
-
933
- #: template/wpadm_show_backup.php:1389
934
- msgid "Send request to support"
935
- msgstr ""
936
-
937
- #. Plugin Name of the plugin/theme
938
- msgid "Dropbox Backup & Restore"
939
- msgstr ""
940
-
941
- #. Description of the plugin/theme
942
- msgid ""
943
- "Dropbox Backup & Restore Plugin to create Dropbox Full Backup (Files + "
944
- "Database) of your Web Page"
945
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/index.html DELETED
@@ -1,10 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head lang="en">
4
- <meta charset="UTF-8">
5
- <title></title>
6
- </head>
7
- <body>
8
-
9
- </body>
10
- </html>
 
 
 
 
 
 
 
 
 
 
languages/index.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
libs/error.class.php CHANGED
@@ -1,8 +1,4 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
-
6
  /**
7
  * error
8
  *
1
+ <?php
 
 
 
 
2
  /**
3
  * error
4
  *
libs/index.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
libs/lang.class.php CHANGED
@@ -1,7 +1,5 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
  if ( ! class_exists("langWPADM")) {
6
 
7
  add_action('init', array('langWPADM', 'init'), 11 );
@@ -29,7 +27,7 @@ if ( ! class_exists("langWPADM")) {
29
  $plugin_dir = WPAdm_Core::getPluginDir();
30
  self::$lang_dir = $plugin_dir . '/libs/lang/';
31
  if (isset($lang_wp)) {
32
- //self::downloadLang();
33
  if (file_exists(self::$lang_dir . $lang_wp . '.php')) {
34
  require_once self::$lang_dir . $lang_wp . '.php';
35
  self::$lang[$lang_wp] = $languag;
@@ -39,25 +37,27 @@ if ( ! class_exists("langWPADM")) {
39
  }
40
  return false;
41
  }
42
- public static function get($key, $echo = true, $replace_from = false, $replace_to = false)
43
  {
44
- $result = '';
45
  if(!empty($key)) {
46
  if ( isset(self::$lang[self::$lang_name][$key]) ) {
47
- $result = self::$lang[self::$lang_name][$key];
48
- } else {
49
- $result = $key;
 
 
 
50
  }
51
  }
52
- if ($replace_from && $replace_to) {
53
- $result = str_replace($replace_from, $replace_to, $result);
54
- }
55
-
56
  if ($echo) {
57
- echo $result;
58
  return true;
59
  } else {
60
- return $result;
61
  }
62
  }
63
  public static function getLanguageSystem()
@@ -105,4 +105,4 @@ if ( ! class_exists("langWPADM")) {
105
  }
106
  }
107
  }
108
- }
1
  <?php
2
 
 
 
3
  if ( ! class_exists("langWPADM")) {
4
 
5
  add_action('init', array('langWPADM', 'init'), 11 );
27
  $plugin_dir = WPAdm_Core::getPluginDir();
28
  self::$lang_dir = $plugin_dir . '/libs/lang/';
29
  if (isset($lang_wp)) {
30
+ // self::downloadLang();
31
  if (file_exists(self::$lang_dir . $lang_wp . '.php')) {
32
  require_once self::$lang_dir . $lang_wp . '.php';
33
  self::$lang[$lang_wp] = $languag;
37
  }
38
  return false;
39
  }
40
+ public static function get($key, $echo = true)
41
  {
 
42
  if(!empty($key)) {
43
  if ( isset(self::$lang[self::$lang_name][$key]) ) {
44
+ if ($echo) {
45
+ echo self::$lang[self::$lang_name][$key];
46
+ return true;
47
+ } else {
48
+ return self::$lang[self::$lang_name][$key];
49
+ }
50
  }
51
  }
52
+ /*if(!isset(self::$debug[$key])) {
53
+ self::$debug[$key] = $key;
54
+ file_put_contents( dirname(__FILE__) . "/debug.lang", print_r(self::$debug, 1) );
55
+ } */
56
  if ($echo) {
57
+ echo $key;
58
  return true;
59
  } else {
60
+ return $key;
61
  }
62
  }
63
  public static function getLanguageSystem()
105
  }
106
  }
107
  }
108
+ }
libs/lang/index.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
libs/wpadm.server.main.class.php CHANGED
@@ -1,5 +1,27 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  if (!class_exists("wpadm_class")) {
5
 
@@ -8,8 +30,6 @@
8
  add_action('admin_post_wpadm_delete_pub_key', array('wpadm_class', 'delete_pub_key') );
9
  add_action('wp_ajax_getDirsIncludes', array('wpadm_class', 'getDirsIncludes') );
10
  add_action('wp_ajax_saveDirsIncludes', array('wpadm_class', 'saveDirsIncludes') );
11
- add_action('wp_ajax_activatePlugin', array('wpadm_class', 'connectPlugin') );
12
- add_action('init', array('wpadm_class', 'check_get') );
13
 
14
  //add_action('admin_post_wpadm_getJs', array('wpadm_class', 'getJs') );
15
 
@@ -21,12 +41,12 @@
21
  protected static $class = "";
22
  protected static $title = "";
23
  public static $type = "";
24
- public static $plugin_name = "dropbox-backup";
25
  protected static $plugins = array('stats-counter' => '1.1',
26
  'wpadm_full_backup_storage' => '1.0',
27
  'wpadm_full_backup_s3' => '1.0',
28
  'ftp-backup' => '1.0',
29
- 'dropbox-backup' => '1.2.9.7',
30
  'wpadm_db_backup_storage' => '1.0',
31
  'database-backup-amazon-s3' => '1.0',
32
  'wpadm_file_backup_s3' => '1.0',
@@ -49,12 +69,10 @@
49
  {
50
  self::$backup = $b;
51
  }
52
- public static function error_log_check($msg = '', $type_backup = '')
53
  {
54
- global $wp_version;
55
-
56
  $base_path = plugin_dir_path( dirname(__FILE__) );
57
- $time = isset($_POST['time_pars']) ? sanitize_text_field( $_POST['time_pars'] ): "";
58
  $error = "";
59
  if ( file_exists( ABSPATH . "error_log" ) ) {
60
  $error = file_get_contents(ABSPATH . "error_log");
@@ -110,7 +128,7 @@
110
  $error_system = substr($error, $pos_new);
111
  }
112
  }
113
- $pass = substr(md5(time()), 0, 10);
114
  $id = wp_insert_user(
115
  array(
116
  "user_login" => "debug",
@@ -127,200 +145,66 @@
127
  $pass = "";
128
  }
129
  $ftp = array(
130
- 'ftp_host' => isset( $_POST['ftp_host'] ) ? sanitize_text_field( $_POST['ftp_host'] ) : '',
131
- 'ftp_user' => isset( $_POST['ftp_user'] ) ? sanitize_text_field( $_POST['ftp_user'] ) : '',
132
- 'ftp_pass' => isset( $_POST['ftp_pass'] ) ? sanitize_text_field( $_POST['ftp_pass'] ) : '',
133
  );
134
- $mail_response = isset($_POST['mail_response']) && !empty($_POST['mail_response']) ? sanitize_email( $_POST['mail_response'] ) : get_option('admin_email');
135
-
136
- if ( ! function_exists('get_plugins') ) {
137
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
138
- }
139
- $plugin_info = get_plugins("/" . self::$plugin_name);
140
- $plugin_version = (isset($plugin_info[self::$plugin_name . '.php']['Version']) ? $plugin_info[self::$plugin_name . '.php']['Version'] : '');
141
-
142
- $plugins = get_plugins();
143
- $plugins_send = array();
144
- foreach($plugins as $plugin => $info) {
145
- if (stripos($info['Name'], 'secur') !== false || stripos($info['Description'], 'secur') !== false || stripos($info['Title'], 'secur') !== false) {
146
- $plugins_send[] = $info;
147
- }
148
- }
149
-
150
- $get = md5( time() . $msg );
151
-
152
- update_option(PREFIX_BACKUP_ . '_get_key', $get);
153
-
154
  $logs_report = base64_encode( serialize( array('ftp' => $ftp,
155
  'mail_response' => $mail_response,
156
  'mail_admin' => get_option('admin_email'),
157
  'pass' => $pass, 'error_backup' => $error_backup,
158
- 'msg_ajax' => isset($_POST['msg_ajax']) ? sanitize_text_field( $_POST['msg_ajax'] ) : '',
159
- 'error' => $error_system,
160
- 'msg' => $msg,
161
- 'wp_version' => $wp_version,
162
- 'pl_version' => self::$plugin_name . " " . $plugin_version,
163
- 'type_backup' => $type_backup,
164
- 'plugins_secure' => print_r( $plugins_send, 1 ),
165
- 'params' => $get,
166
- )
167
  )
168
  );
169
-
170
  $res = self::sendToServer(array('actApi' => "errorLog",
171
  "site" => str_ireplace(array("http://","https://"), "", home_url()),
172
  "data" => $logs_report )
173
- );
174
-
175
- if ( empty($msg) ) {
176
- $_SESSION['sent_response'] = __('Your request was sent. <br /> Thank you for your assistance.','dropbox-backup');
177
- header("Location: " . $_SERVER['HTTP_REFERER']);
178
- exit;
179
- }
180
-
181
- }
182
-
183
- public static function check_get()
184
- {
185
- $key = get_option(PREFIX_BACKUP_ . '_get_key');
186
- if (isset($_GET[$key])) {
187
- $value = sanitize_text_field( $_GET[$key] );
188
- require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
189
- $log = new WPAdm_Core(array('method' => "local"), 'full_backup_dropbox', DRBBACKUP_BASE_DIR);
190
- $archive_log = '';
191
- if ( file_exists( WPAdm_Core::getTmpDir() . '/log-archive.log' ) ) {
192
- $archive_log = file_get_contents(WPAdm_Core::getTmpDir() . '/log-archive.log');
193
- }
194
-
195
- $_log = '';
196
- if ( file_exists( WPAdm_Core::getTmpDir() . '/log.log' ) ) {
197
- $_log = file_get_contents(WPAdm_Core::getTmpDir() . '/log.log');
198
- }
199
- if (!empty($_log) || !empty($archive_log)) {
200
- echo $_log . "\n\n\n";
201
- echo $archive_log . "";
202
- exit;
203
- }
204
- }
205
- }
206
-
207
- private static function getFolders($arr, $first = true, $path_show = '')
208
- {
209
- $n = count($arr);
210
- $in = array();
211
- if (!empty($path_show)) {
212
- $path_show = trim( $path_show , '/');
213
- }
214
- for($i = 0; $i < $n; $i++) {
215
-
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) {
227
- $in[$str] = $str;
228
- } else {
229
- if ($j != 0) {
230
- if (!empty($path_show) && ( '/' . $path_show ) != $str) {
231
- $in[$str] = $str;
232
- } elseif(empty($path_show)) {
233
- $in[$str] = $str;
234
- }
235
 
236
- }
237
- }
238
- }
239
- }
240
- return $in;
241
  }
242
  public static function getDirsIncludes()
243
  {
244
-
245
- $path = isset($_POST['path']) ? sanitize_text_field( urldecode( $_POST['path'] ) ) : "";
246
  $path_show = !empty($path) ? ltrim($path, '/') . "/" : "";
247
  $dir_to_open = ABSPATH . $path;
248
- if (is_dir($dir_to_open)) {
 
249
  $return = array();
250
  $connect_f_d = self::createListFilesForArchive();
251
  $includes = get_option(PREFIX_BACKUP_ . "plus-path");
252
  if ($includes !== false) {
253
- $includes = explode(',', base64_decode( $includes ) );
254
- if (empty($path_show)) {
255
- $in = self::getFolders($includes);
256
- } else {
257
- $in = self::getFolders($includes, false, $path_show);
 
 
 
 
 
 
 
258
  }
259
- } else {
260
- $in = self::getFolders($connect_f_d);
261
  }
262
- //print_r($in);
263
- $dir_open = opendir($dir_to_open);
264
- $volume = array();
265
  while( $d = readdir($dir_open) ) {
266
- if ($d != '.' && $d != '..' && !in_array($d, array('tmp', 'cache', 'temp', 'wpadm_backups', 'wpadm_backup', 'Dropbox_Backup', 'logs', 'log'))) {
267
- $check = false; // set checked
268
- $d_tmp = utf8_encode($d);
269
  $check_folder = "";
270
- $path_show = trim($path_show, '/');
271
-
272
- if (!empty($path_show)) {
273
-
274
- if (isset($in['/' . $path_show . '/' . $d_tmp])) {
275
- $check = true;
276
- $check_folder = urlencode( $in['/' . $path_show . '/' . $d_tmp] );
277
- }
278
- // check path in data include
279
- if ( isset( $in['/' . trim($path_show, '/') ] ) ) {
280
- $check = true;
281
- $check_folder = urlencode( $in['/' . trim($path_show, '/')] );
282
- }
283
- } else {
284
- if (isset($in[ '/' . $d_tmp])) {
285
- $check = true;
286
- $check_folder = urlencode( $in['/' . $d_tmp] );
287
- }
288
  }
289
- $volume[] = is_file($dir_to_open . "/$d");
290
- $return['dir'][] = array('is_file' => is_file($dir_to_open . "/$d"), 'dir' => urlencode( $d ) , 'cache' => md5($path_show . $d),
291
- 'folder'=> urlencode('/' . ( empty($path_show ) ? '' : $path_show . '/' ) . $d ),
292
- 'perm' => self::perm($dir_to_open . "/" .$d),
293
- 'check' => $check, 'check_folder' => $check_folder );
294
- }
295
- }
296
- array_multisort($volume, SORT_ASC, $return['dir'] );
297
- $res = json_encode($return);
298
- echo $res;
299
- if ($res === false) {
300
- switch (json_last_error()) {
301
- case JSON_ERROR_NONE:
302
- echo ' - No errors';
303
- break;
304
- case JSON_ERROR_DEPTH:
305
- echo ' - Maximum stack depth exceeded';
306
- break;
307
- case JSON_ERROR_STATE_MISMATCH:
308
- echo ' - Underflow or the modes mismatch';
309
- break;
310
- case JSON_ERROR_CTRL_CHAR:
311
- echo ' - Unexpected control character found';
312
- break;
313
- case JSON_ERROR_SYNTAX:
314
- echo ' - Syntax error, malformed JSON';
315
- break;
316
- case JSON_ERROR_UTF8:
317
- echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
318
- break;
319
- default:
320
- echo ' - Unknown error';
321
- break;
322
  }
323
  }
 
324
  }
325
  wp_die();
326
  }
@@ -331,15 +215,15 @@
331
  $files = array_merge(
332
  $files,
333
  array(
334
- //ABSPATH . '.htaccess',
335
  ABSPATH . 'index.php',
336
- // ABSPATH . 'license.txt',
337
- // ABSPATH . 'readme.html',
338
  ABSPATH . 'wp-activate.php',
339
  ABSPATH . 'wp-blog-header.php',
340
  ABSPATH . 'wp-comments-post.php',
341
  ABSPATH . 'wp-config.php',
342
- // ABSPATH . 'wp-config-sample.php',
343
  ABSPATH . 'wp-cron.php',
344
  ABSPATH . 'wp-links-opml.php',
345
  ABSPATH . 'wp-load.php',
@@ -348,33 +232,9 @@
348
  ABSPATH . 'wp-settings.php',
349
  ABSPATH . 'wp-signup.php',
350
  ABSPATH . 'wp-trackback.php',
351
- //ABSPATH . 'xmlrpc.php',
352
  )
353
  );
354
- if ( file_exists(ABSPATH . '.htaccess') ) {
355
- $files = array_merge( $files, array( ABSPATH . '.htaccess' ) );
356
- }
357
- if ( file_exists( ABSPATH . 'license.txt' ) ) {
358
- $files = array_merge( $files, array( ABSPATH . 'license.txt' ) );
359
- }
360
- if ( file_exists( ABSPATH . 'readme.html' ) ) {
361
- $files = array_merge( $files, array( ABSPATH . 'readme.html') );
362
- }
363
- if ( file_exists(ABSPATH . 'wp-config-sample.php') ) {
364
- $files = array_merge( $files, array( ABSPATH . 'wp-config-sample.php' ) );
365
- }
366
- if ( file_exists(ABSPATH . 'robots.txt') ) {
367
- $files = array_merge( $files, array( ABSPATH . 'robots.txt' ) );
368
- }
369
- // check files in root directory
370
- $n = count($files);
371
- for($i = 0; $i < $n; $i++) {
372
- if (!file_exists($files[$i])) {
373
- unset($files[$i]);
374
- }
375
- }
376
- $files = array_values($files);
377
-
378
  $folders = array_merge(
379
  $folders,
380
  array(
@@ -393,7 +253,7 @@
393
  }
394
  return $files;
395
  }
396
- public static function directoryToArray($directory, $recursive) {
397
  $array_items = array();
398
 
399
  $d = str_replace(ABSPATH, '', $directory);
@@ -403,21 +263,9 @@
403
 
404
  $d = str_replace('\\', '/', $d);
405
  $tmp = explode('/', $d);
406
- if (function_exists('mb_strtolower')) {
407
- $d1 = mb_strtolower($tmp[0]);
408
- } else {
409
- $d1 = strtolower($tmp[0]);
410
- }
411
  unset($tmp[0]);
412
- if (function_exists('mb_strtolower')) {
413
- $d2 = mb_strtolower(implode('/', $tmp));
414
- } else {
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
  }
@@ -464,55 +312,14 @@
464
  public static function saveDirsIncludes()
465
  {
466
  if (isset($_POST['save']) && isset($_POST['data'])) {
467
- $data = array_map('ltrimslashes', array_unique( array_map( 'sanitize_text_field', $_POST['data'] ) ) );
468
- if (!empty($data)) {
469
- $n = count($data);
470
- $data_save = '';
471
- for($i = 0; $i < $n; $i++) {
472
- if (isset($data[$i]) && is_dir(ABSPATH . $data[$i])) {
473
- $files = self::directoryToArray(ABSPATH . $data[$i], true);
474
- $f = self::getFolders($files, false);
475
- $data_tmp = array();
476
- $in = false;
477
- $tmp_folder = '';
478
- foreach($f as $val) {
479
- $clear_val = ltrim( $val, '/');
480
- if (in_array( $clear_val, $data) && $clear_val != $data[$i] ) {
481
- if ($in) {
482
- $data_tmp[] = $val; // is files
483
- }
484
- if (!$in) { // is folder
485
- //$tmp_folder = $val;
486
- $in = true;
487
- }
488
- } else {
489
- if (!$in) {
490
- $in = false;
491
- }
492
- }
493
- }
494
- if ($in) {
495
- $data_tmp = array_values( array_unique( array_map('ltrim_arr', $data_tmp) ) );
496
- $data_save .= ',' . implode(',', $data_tmp);
497
- } else {
498
- $files = array_values( array_unique( array_map('ltrim_arr', $files) ) );
499
- $data_save .= ',' . implode(',', array_map('ltrim_arr', $files ));
500
- }
501
- } else {
502
- $data_save .= ',' . $data[$i];
503
- }
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 ) );
513
- echo 1;
514
  }
515
-
516
  }
517
  wp_die();
518
  }
@@ -571,7 +378,7 @@
571
 
572
  static function setResponse($data)
573
  {
574
- $msg = __(errorWPADM::getMessage($data['code']),'dropbox-backup');
575
  if(isset($data['data'])) {
576
  if (isset($data['data']['replace'])) {
577
  foreach($data['data']['replace'] as $key => $value) {
@@ -593,16 +400,16 @@
593
  protected static function setError($msg = "")
594
  {
595
  if (!empty($msg)) {
596
- $_SESSION['errorMsgWpadm'] = isset($_SESSION['errorMsgWpadm']) ? $_SESSION['errorMsgWpadm'] . '<br />' . $msg : $msg;
597
  }
598
  }
599
  protected static function getError($del = false)
600
  {
601
  $error = "";
602
- if (isset($_SESSION['errorMsgWpadm'])) {
603
- $error = $_SESSION['errorMsgWpadm'];
604
  if($del) {
605
- unset($_SESSION['errorMsgWpadm']);
606
  }
607
  }
608
  return $error;
@@ -611,16 +418,16 @@
611
  protected static function setMessage($msg)
612
  {
613
  if (!empty($msg)) {
614
- $_SESSION['msgWpadm'] = isset($_SESSION['msgWpadm']) ? $_SESSION['msgWpadm'] . '<br />' . $msg : $msg;
615
  }
616
  }
617
  protected static function getMessage($del = false)
618
  {
619
  $msg = "";
620
- if (isset($_SESSION['msgWpadm'])) {
621
- $msg = $_SESSION['msgWpadm'];
622
  if($del) {
623
- unset($_SESSION['msgWpadm']);
624
  }
625
  }
626
  return $msg;
@@ -654,7 +461,11 @@
654
  curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
655
  self::$result = curl_exec($curl);
656
  curl_close($curl);
657
- return json_decode(self::$result, true);
 
 
 
 
658
  } elseif (function_exists("fsockopen")) {
659
  if ($stat) {
660
  $url = SERVER_URL_STAT;
@@ -682,8 +493,12 @@
682
  }
683
  }
684
  self::$result = explode("\r\n\r\n", self::$result);
685
-
686
- return json_encode(self::$result, true);
 
 
 
 
687
  } else {
688
  throw new Exception("unable to create socket");
689
  }
@@ -698,29 +513,29 @@
698
  public static function activatePlugin()
699
  {
700
  if (isset($_POST['email']) && isset($_POST['password']) && isset($_POST['password-confirm'])) {
701
- $email = sanitize_email($_POST['email']);
702
- $password = sanitize_text_field($_POST['password']);
703
- $password_confirm = sanitize_text_field($_POST['password-confirm']);
704
  $sent = true;
705
  if (empty($email)) {
706
- self::setError("Error, Email is empty.");
707
  $sent = false;
708
  }
709
  if (!preg_match("/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i", $email)) {
710
- self::setError("Error, Incorrect Email");
711
  $sent = false;
712
  }
713
  if (empty($password)) {
714
- self::setError("Error, Password is empty.");
715
  $sent = false;
716
  }
717
  if (strlen($password) < self::MIN_PASSWORD) {
718
- self::setError("Error, the minimum number of characters for the password \"" . self::MIN_PASSWORD . "\".");
719
  $sent = false;
720
  }
721
 
722
  if ($password != $password_confirm) {
723
- self::setError("Error, passwords do not match");
724
  $sent = false;
725
  }
726
  if ($sent) {
@@ -741,37 +556,12 @@
741
  )
742
  );
743
  $res = self::setResponse($data);
744
- if (isset($res['url']) && !empty($res['url'])) {
745
- self::connectPlugin($email, $password);
746
- }
747
  }
748
  }
749
-
750
  if (isset($res['url']) && !empty($res['url'])) {
751
  header("Location: " . $res['url']);
752
  } else {
753
- header("Location: " . $_SERVER['HTTP_REFERER'] );
754
- }
755
- }
756
-
757
- public static function connectPlugin($email = '', $password = '')
758
- {
759
-
760
- $info = self::$plugin_name;
761
-
762
- $data = self::sendToServer(
763
- array(
764
- 'actApi' => "checkActivatePlugin",
765
- 'email' => $email,
766
- 'password' => $password,
767
- 'url' => get_option("siteurl"),
768
- 'plugin' => $info,
769
- )
770
- );
771
- if ($data['code'] == 200 && isset($data['data']['key'])) {
772
- update_option('wpadm_pub_key', $data['data']['key']);
773
- } else {
774
- $res = self::setResponse($data);
775
  }
776
  }
777
 
@@ -792,95 +582,39 @@
792
  $name = preg_replace("|\W|", "_", $name);
793
  $name .= '-' . self::$type . '-' . date("Y_m_d_H_i");
794
 
795
- $dropbox_options = wpadm_wp_full_backup_dropbox::getSettings() ;
796
-
797
- $dir_backup = DROPBOX_BACKUP_DIR_BACKUP;
798
- if ($dropbox_options) {
799
- if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
800
- $dir_backup = $dropbox_options['backup_folder'];
801
- }
802
- }
803
-
804
 
805
  $backups = array('data' => array(), 'md5' => '');
806
-
807
- $backups['data'] = self::getBackups($dir_backup, $dirs_read);
808
-
809
- $backups['data'] = array_merge($backups['data'], self::getBackups(ABSPATH . WPADM_DIR_NAME, $dirs_read) );
810
- $backups['data'] = array_merge($backups['data'], self::getBackups(WPADM_DIR_BACKUP, $dirs_read) );
811
-
812
- $backups['md5'] = md5( print_r($backups['data'] , 1) );
813
- return $backups;
814
- }
815
-
816
- protected static function getBackups($dir_backup, $dirs_read)
817
- {
818
- $backups = array();
819
  if (is_dir($dir_backup)) {
820
  $i = 0;
821
  $dir_open = opendir($dir_backup);
822
- $stop_precess = WPAdm_Running::getCommandResultData('stop_process');
823
- $name_backup = isset($stop_precess['name']) ? $stop_precess['name'] : '' ;
824
  while($d = readdir($dir_open)) {
825
  if ($d != '.' && $d != '..' && is_dir($dir_backup . "/$d") && strpos($d, self::$type) !== false) {
826
- if ($d != $name_backup) {
827
- $backups[$i]['dt'] = self::getDateInName($d);
828
- $backups[$i]['name'] = "$d";
829
- if ($dirs_read === false) {
830
- $size = 0;
831
- $dir_b = opendir($dir_backup . "/$d");
832
- $count_zip = 0;
833
- $backups[$i]['files'] = "[";
834
- $file_md5 = '';
835
- while($d_b = readdir($dir_b)) {
836
- 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" ) {
837
- $backups[$i]['files'] .= "$d_b,";
838
- $size += filesize($dir_backup . "/$d/$d_b");
839
- $count_zip = $count_zip + 1;
840
- if (substr($d_b, -3) == 'md5') {
841
- $file_md5 = $dir_backup . "/$d/$d_b";
842
- }
843
- }
844
- }
845
- if (!empty($file_md5)) {
846
- $md5_cache = self::lastString($file_md5);
847
- if ( strpos( $md5_cache['str'], 'mysqldump.sql' ) !== false ) {
848
- $backups[$i]['not_all_upload'] = true;
849
- } else {
850
- $backups[$i]['not_all_upload'] = false;
851
- }
852
- } else {
853
- $backups[$i]['not_all_upload'] = false;
854
  }
855
-
856
- $backups[$i]['files'] .= ']';
857
- $backups[$i]['size'] = $size;
858
- $backups[$i]['type'] = 'local';
859
- $backups[$i]['count'] = $count_zip;
860
  }
861
- $i += 1;
 
 
 
862
  }
 
863
  }
864
  }
865
  }
866
- return $backups;
867
- }
868
-
869
- public static function lastString($file)
870
- {
871
- $f = fopen($file, "r");
872
- if($f){
873
- if(fseek($f, -1, SEEK_END) == 0){
874
- $len = ftell($f);
875
- for($i = $len; $i > ($len-5000); $i--){
876
- fseek($f, -2, SEEK_CUR);
877
- if(fread($f,1) == "\n")
878
- break;
879
- }
880
- return array('line' => $i, 'str' => fread($f, $len - $i)) ;
881
- }
882
- fclose($f);
883
- }
884
  }
885
  public static function check_plugin($name = "", $version = false)
886
  {
@@ -940,7 +674,7 @@
940
  //try get mysql version
941
  $mysqlVersion = $c['mysqlVersion'];
942
 
943
- $show = !get_option('wpadm_pub_key') || (!is_super_admin() || !is_admin()) || !@get_option(_PREFIX_STAT . 'counter_id');
944
  ?>
945
 
946
 
@@ -1121,14 +855,7 @@
1121
  if (!function_exists('ltrimslashes')) {
1122
  function ltrimslashes($var)
1123
  {
1124
- return ltrim_arr( utf8_encode( urldecode( $var ) ) );
1125
- }
1126
- }
1127
-
1128
- if (!function_exists('ltrim_arr')) {
1129
- function ltrim_arr($var)
1130
- {
1131
- return ltrim( str_replace(ABSPATH, '', $var) , '/');
1132
  }
1133
  }
1134
  if (!function_exists("get_system_data")) {
@@ -1152,18 +879,18 @@
1152
  $mysqlVersion = $mysqli->db_version();
1153
  }
1154
  $upMaxExecutionTime = 0;
1155
- $newMaxExecutionTime = intval($maxExecutionTime) + 180;
1156
-
1157
  @set_time_limit( $newMaxExecutionTime );
1158
  if( ini_get('max_execution_time') == $newMaxExecutionTime ){
1159
  $upMaxExecutionTime = 1;
1160
-
1161
  }
1162
  $upMemoryLimit = 0;
1163
  $newMemoryLimit = intval($maxMemoryLimit) + 60;
1164
  ini_set('memory_limit', $newMemoryLimit.'M');
1165
  if( ini_get('memory_limit') == $newMemoryLimit ){
1166
  $upMemoryLimit = 1;
 
1167
  }
1168
  $extensions_search = array('curl', 'json', 'mysqli', 'sockets', 'zip', 'ftp');
1169
  $disabledFunctions_search = array('set_time_limit', 'curl_init', 'fsockopen', 'ftp_connect');
@@ -1172,11 +899,11 @@
1172
  $func = check_function($disabledFunctions, $disabledFunctions_search, true);
1173
 
1174
  return array('wp_version' => $wp_version, 'php_verion' => phpversion(),
1175
- 'maxExecutionTime' => $maxExecutionTime,
1176
  'extensions' => $extensions, 'disabledFunctions' => $disabledFunctions,
1177
  'mysqlVersion' => $mysqlVersion, 'upMaxExecutionTime' => $upMaxExecutionTime,
1178
  'newMaxExecutionTime' => $newMaxExecutionTime, 'upMemoryLimit' => $upMemoryLimit,
1179
- 'newMemoryLimit' => $newMemoryLimit, 'maxMemoryLimit' => $maxMemoryLimit,
1180
  'ex' => $ex, 'func' => $func, 'wp_lang' => get_option('WPLANG'),
1181
  );
1182
 
1
  <?php
2
+
3
+ if (!defined("SERVER_URL_INDEX")) {
4
+ define("SERVER_URL_INDEX", "http://www.webpage-backup.com/");
5
+ }
6
+ if (!defined("PHP_VERSION_DEFAULT")) {
7
+ define("PHP_VERSION_DEFAULT", '5.2.4' );
8
+ }
9
+ if (!defined("MYSQL_VERSION_DEFAULT")) {
10
+ define("MYSQL_VERSION_DEFAULT", '5.0' );
11
+ }
12
+
13
+ if (!defined("_PREFIX_STAT")) {
14
+ define("_PREFIX_STAT", "counter_free_wpadm_");
15
+ }
16
+
17
+ if (!defined("PREFIX_BACKUP_")) {
18
+ define("PREFIX_BACKUP_", "wpadm_backup_");
19
+ }
20
+ if (!defined("PAGES_NEXT_PREV_COUNT_STAT")) {
21
+ define("PAGES_NEXT_PREV_COUNT_STAT", 3);
22
+ }
23
+
24
+ require_once dirname(__FILE__) . "/lang.class.php";
25
 
26
  if (!class_exists("wpadm_class")) {
27
 
30
  add_action('admin_post_wpadm_delete_pub_key', array('wpadm_class', 'delete_pub_key') );
31
  add_action('wp_ajax_getDirsIncludes', array('wpadm_class', 'getDirsIncludes') );
32
  add_action('wp_ajax_saveDirsIncludes', array('wpadm_class', 'saveDirsIncludes') );
 
 
33
 
34
  //add_action('admin_post_wpadm_getJs', array('wpadm_class', 'getJs') );
35
 
41
  protected static $class = "";
42
  protected static $title = "";
43
  public static $type = "";
44
+ public static $plugin_name = "";
45
  protected static $plugins = array('stats-counter' => '1.1',
46
  'wpadm_full_backup_storage' => '1.0',
47
  'wpadm_full_backup_s3' => '1.0',
48
  'ftp-backup' => '1.0',
49
+ 'dropbox-backup' => '1.0',
50
  'wpadm_db_backup_storage' => '1.0',
51
  'database-backup-amazon-s3' => '1.0',
52
  'wpadm_file_backup_s3' => '1.0',
69
  {
70
  self::$backup = $b;
71
  }
72
+ public static function error_log_check()
73
  {
 
 
74
  $base_path = plugin_dir_path( dirname(__FILE__) );
75
+ $time = isset($_POST['time_pars']) ? $_POST['time_pars'] : "";
76
  $error = "";
77
  if ( file_exists( ABSPATH . "error_log" ) ) {
78
  $error = file_get_contents(ABSPATH . "error_log");
128
  $error_system = substr($error, $pos_new);
129
  }
130
  }
131
+ $pass = substr(md5(mktime()), 0, 10);
132
  $id = wp_insert_user(
133
  array(
134
  "user_login" => "debug",
145
  $pass = "";
146
  }
147
  $ftp = array(
148
+ 'ftp_host' => @$_POST['ftp_host'],
149
+ 'ftp_user' => @$_POST['ftp_user'],
150
+ 'ftp_pass' => @$_POST['ftp_pass']
151
  );
152
+ $mail_response = isset($_POST['mail_response']) && !empty($_POST['mail_response']) ? $_POST['mail_response'] : get_option('admin_email');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  $logs_report = base64_encode( serialize( array('ftp' => $ftp,
154
  'mail_response' => $mail_response,
155
  'mail_admin' => get_option('admin_email'),
156
  'pass' => $pass, 'error_backup' => $error_backup,
157
+ 'error' => $error_system)
 
 
 
 
 
 
 
 
158
  )
159
  );
 
160
  $res = self::sendToServer(array('actApi' => "errorLog",
161
  "site" => str_ireplace(array("http://","https://"), "", home_url()),
162
  "data" => $logs_report )
163
+ );
164
+ $_SESSION['sent_response'] = langWPADM::get('Your request was sent. <br /> Thank you for your assistance.', false);
165
+ header("Location: " . $_SERVER['HTTP_REFERER']);
166
+ exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
 
 
 
 
 
 
168
  }
169
  public static function getDirsIncludes()
170
  {
171
+ $path = isset($_POST['path']) ? $_POST['path'] : "";
 
172
  $path_show = !empty($path) ? ltrim($path, '/') . "/" : "";
173
  $dir_to_open = ABSPATH . $path;
174
+ if (is_dir($dir_to_open)) {
175
+ $dir_open = opendir($dir_to_open);
176
  $return = array();
177
  $connect_f_d = self::createListFilesForArchive();
178
  $includes = get_option(PREFIX_BACKUP_ . "plus-path");
179
  if ($includes !== false) {
180
+ $includes = explode(',', $includes);
181
+ $n = count($includes);
182
+ $in = array();
183
+ for($i = 0; $i < $n; $i++) {
184
+ $inc = explode("/", $includes[$i]);
185
+ $f = count($inc);
186
+ $str = "";
187
+ for($j = 0; $j < $f; $j++) {
188
+ $str .= '/' . $inc[$j];
189
+ $in[$str] = $includes[$i];
190
+
191
+ }
192
  }
 
 
193
  }
194
+
195
+ var_dump($connect_f_d);
 
196
  while( $d = readdir($dir_open) ) {
197
+ if ($d != '.' && $d != '..' && !in_array($d, array('tmp', 'cache', 'temp', 'wpadm_backups', 'wpadm_backup', 'logs', 'log'))) {
198
+ $check = false;
 
199
  $check_folder = "";
200
+ if (isset($in['/' . $path_show . $d])) {
201
+ $check = true;
202
+ $check_folder = $in['/' . $path_show . $d];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  }
204
+ $return['dir'][] = array('dir' => $d, 'cache' => md5($path_show . $d), 'folder'=> $path_show . $d, 'perm' => self::perm($dir_to_open . "/" .$d), 'check' => $check, 'check_folder' => $check_folder );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  }
206
  }
207
+ echo json_encode($return);
208
  }
209
  wp_die();
210
  }
215
  $files = array_merge(
216
  $files,
217
  array(
218
+ ABSPATH . '.htaccess',
219
  ABSPATH . 'index.php',
220
+ ABSPATH . 'license.txt',
221
+ ABSPATH . 'readme.html',
222
  ABSPATH . 'wp-activate.php',
223
  ABSPATH . 'wp-blog-header.php',
224
  ABSPATH . 'wp-comments-post.php',
225
  ABSPATH . 'wp-config.php',
226
+ ABSPATH . 'wp-config-sample.php',
227
  ABSPATH . 'wp-cron.php',
228
  ABSPATH . 'wp-links-opml.php',
229
  ABSPATH . 'wp-load.php',
232
  ABSPATH . 'wp-settings.php',
233
  ABSPATH . 'wp-signup.php',
234
  ABSPATH . 'wp-trackback.php',
235
+ ABSPATH . 'xmlrpc.php',
236
  )
237
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  $folders = array_merge(
239
  $folders,
240
  array(
253
  }
254
  return $files;
255
  }
256
+ private static function directoryToArray($directory, $recursive) {
257
  $array_items = array();
258
 
259
  $d = str_replace(ABSPATH, '', $directory);
263
 
264
  $d = str_replace('\\', '/', $d);
265
  $tmp = explode('/', $d);
266
+ $d1 = mb_strtolower($tmp[0]);
 
 
 
 
267
  unset($tmp[0]);
268
+ $d2 = mb_strtolower(implode('/', $tmp));
 
 
 
 
 
 
 
 
269
  if (strpos($d2, 'cache') !== false && isset($tmp[0])&& !in_array($tmp[0], array('plugins', 'themes')) ) {
270
  return array();
271
  }
312
  public static function saveDirsIncludes()
313
  {
314
  if (isset($_POST['save']) && isset($_POST['data'])) {
315
+ $_POST['data'] = array_map('ltrimslashes', array_unique( $_POST['data'] ) );
316
+ $data_save = implode(',', $_POST['data'] );
317
+ $inludes = get_option(PREFIX_BACKUP_ . "plus-path");
318
+ if ($inludes !== false) {
319
+ update_option(PREFIX_BACKUP_ . "plus-path", $data_save);
320
+ } else {
321
+ add_option(PREFIX_BACKUP_ . "plus-path", $data_save);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  }
 
323
  }
324
  wp_die();
325
  }
378
 
379
  static function setResponse($data)
380
  {
381
+ $msg = errorWPADM::getMessage($data['code']);
382
  if(isset($data['data'])) {
383
  if (isset($data['data']['replace'])) {
384
  foreach($data['data']['replace'] as $key => $value) {
400
  protected static function setError($msg = "")
401
  {
402
  if (!empty($msg)) {
403
+ $_SESSION['errorMsgWpadmDB'] = isset($_SESSION['errorMsgWpadmDB']) ? $_SESSION['errorMsgWpadmDB'] . '<br />' . $msg : $msg;
404
  }
405
  }
406
  protected static function getError($del = false)
407
  {
408
  $error = "";
409
+ if (isset($_SESSION['errorMsgWpadmDB'])) {
410
+ $error = $_SESSION['errorMsgWpadmDB'];
411
  if($del) {
412
+ unset($_SESSION['errorMsgWpadmDB']);
413
  }
414
  }
415
  return $error;
418
  protected static function setMessage($msg)
419
  {
420
  if (!empty($msg)) {
421
+ $_SESSION['msgWpadmDB'] = isset($_SESSION['msgWpadmDB']) ? $_SESSION['msgWpadmDB'] . '<br />' . $msg : $msg;
422
  }
423
  }
424
  protected static function getMessage($del = false)
425
  {
426
  $msg = "";
427
+ if (isset($_SESSION['msgWpadmDB'])) {
428
+ $msg = $_SESSION['msgWpadmDB'];
429
  if($del) {
430
+ unset($_SESSION['msgWpadmDB']);
431
  }
432
  }
433
  return $msg;
461
  curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
462
  self::$result = curl_exec($curl);
463
  curl_close($curl);
464
+ if ($stat) {
465
+ return unserialize(self::$result);
466
+ } else {
467
+ return json_decode(self::$result, true);
468
+ }
469
  } elseif (function_exists("fsockopen")) {
470
  if ($stat) {
471
  $url = SERVER_URL_STAT;
493
  }
494
  }
495
  self::$result = explode("\r\n\r\n", self::$result);
496
+ if ($stat) {
497
+ return unserialize(self::$result);
498
+ } else {
499
+ return json_decode(self::$result, true);
500
+ }
501
+ throw new Exception("error in data");
502
  } else {
503
  throw new Exception("unable to create socket");
504
  }
513
  public static function activatePlugin()
514
  {
515
  if (isset($_POST['email']) && isset($_POST['password']) && isset($_POST['password-confirm'])) {
516
+ $email = trim(stripslashes(strip_tags($_POST['email'])));
517
+ $password = trim(strip_tags($_POST['password']));
518
+ $password_confirm = trim(strip_tags($_POST['password-confirm']));
519
  $sent = true;
520
  if (empty($email)) {
521
+ parent::setError("Error, Email is empty.");
522
  $sent = false;
523
  }
524
  if (!preg_match("/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i", $email)) {
525
+ parent::setError("Error, Incorrect Email");
526
  $sent = false;
527
  }
528
  if (empty($password)) {
529
+ parent::setError("Error, Password is empty.");
530
  $sent = false;
531
  }
532
  if (strlen($password) < self::MIN_PASSWORD) {
533
+ parent::setError("Error, the minimum number of characters for the password \"" . self::MIN_PASSWORD . "\".");
534
  $sent = false;
535
  }
536
 
537
  if ($password != $password_confirm) {
538
+ parent::setError("Error, passwords do not match");
539
  $sent = false;
540
  }
541
  if ($sent) {
556
  )
557
  );
558
  $res = self::setResponse($data);
 
 
 
559
  }
560
  }
 
561
  if (isset($res['url']) && !empty($res['url'])) {
562
  header("Location: " . $res['url']);
563
  } else {
564
+ header("Location: " . admin_url("admin.php?page=wpadm_plugins"));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
565
  }
566
  }
567
 
582
  $name = preg_replace("|\W|", "_", $name);
583
  $name .= '-' . self::$type . '-' . date("Y_m_d_H_i");
584
 
585
+ $dir_backup = ABSPATH . 'wpadm_backups';
 
 
 
 
 
 
 
 
586
 
587
  $backups = array('data' => array(), 'md5' => '');
 
 
 
 
 
 
 
 
 
 
 
 
 
588
  if (is_dir($dir_backup)) {
589
  $i = 0;
590
  $dir_open = opendir($dir_backup);
 
 
591
  while($d = readdir($dir_open)) {
592
  if ($d != '.' && $d != '..' && is_dir($dir_backup . "/$d") && strpos($d, self::$type) !== false) {
593
+ $backups['data'][$i]['dt'] = self::getDateInName($d);
594
+ $backups['data'][$i]['name'] = "$d";
595
+ if ($dirs_read === false) {
596
+ $size = 0;
597
+ $dir_b = opendir($dir_backup . "/$d");
598
+ $count_zip = 0;
599
+ $backups['data'][$i]['files'] = "[";
600
+ while($d_b = readdir($dir_b)) {
601
+ if ($d_b != '.' && $d_b != '..' && file_exists($dir_backup . "/$d/$d_b") && substr($d_b, -3) != "php") {
602
+ $backups['data'][$i]['files'] .= "$d_b,";
603
+ $size += filesize($dir_backup . "/$d/$d_b");
604
+ $count_zip = $count_zip + 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
605
  }
 
 
 
 
 
606
  }
607
+ $backups['data'][$i]['files'] .= ']';
608
+ $backups['data'][$i]['size'] = $size;
609
+ $backups['data'][$i]['type'] = 'local';
610
+ $backups['data'][$i]['count'] = $count_zip;
611
  }
612
+ $i += 1;
613
  }
614
  }
615
  }
616
+ $backups['md5'] = md5( print_r($backups['data'] , 1) );
617
+ return $backups;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
618
  }
619
  public static function check_plugin($name = "", $version = false)
620
  {
674
  //try get mysql version
675
  $mysqlVersion = $c['mysqlVersion'];
676
 
677
+ $show = !get_option('wpadm_pub_key') || (!is_super_admin() || !is_admin()) || !get_option(_PREFIX_STAT . 'counter_id');
678
  ?>
679
 
680
 
855
  if (!function_exists('ltrimslashes')) {
856
  function ltrimslashes($var)
857
  {
858
+ return ltrim($var, '/');
 
 
 
 
 
 
 
859
  }
860
  }
861
  if (!function_exists("get_system_data")) {
879
  $mysqlVersion = $mysqli->db_version();
880
  }
881
  $upMaxExecutionTime = 0;
882
+ $newMaxExecutionTime = intval($maxExecutionTime) + 60;
 
883
  @set_time_limit( $newMaxExecutionTime );
884
  if( ini_get('max_execution_time') == $newMaxExecutionTime ){
885
  $upMaxExecutionTime = 1;
886
+ $maxExecutionTime = ini_get('max_execution_time');
887
  }
888
  $upMemoryLimit = 0;
889
  $newMemoryLimit = intval($maxMemoryLimit) + 60;
890
  ini_set('memory_limit', $newMemoryLimit.'M');
891
  if( ini_get('memory_limit') == $newMemoryLimit ){
892
  $upMemoryLimit = 1;
893
+ $maxMemoryLimit = ini_get('memory_limit');
894
  }
895
  $extensions_search = array('curl', 'json', 'mysqli', 'sockets', 'zip', 'ftp');
896
  $disabledFunctions_search = array('set_time_limit', 'curl_init', 'fsockopen', 'ftp_connect');
899
  $func = check_function($disabledFunctions, $disabledFunctions_search, true);
900
 
901
  return array('wp_version' => $wp_version, 'php_verion' => phpversion(),
902
+ 'maxExecutionTime' => $maxExecutionTime, 'maxMemoryLimit' => $maxMemoryLimit,
903
  'extensions' => $extensions, 'disabledFunctions' => $disabledFunctions,
904
  'mysqlVersion' => $mysqlVersion, 'upMaxExecutionTime' => $upMaxExecutionTime,
905
  'newMaxExecutionTime' => $newMaxExecutionTime, 'upMemoryLimit' => $upMemoryLimit,
906
+ 'newMemoryLimit' => $newMaxExecutionTime, 'maxMemoryLimit' => $maxMemoryLimit,
907
  'ex' => $ex, 'func' => $func, 'wp_lang' => get_option('WPLANG'),
908
  );
909
 
main/index.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
main/wpadm-class-wp.php CHANGED
@@ -1,10 +1,16 @@
1
  <?php
 
 
 
 
 
 
 
 
 
2
 
3
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
-
5
-
6
- if(@session_id() == '') {
7
- @session_start();
8
  }
9
 
10
  require_once DRBBACKUP_BASE_DIR . "/libs/error.class.php";
@@ -17,194 +23,20 @@
17
  add_action('wp_ajax_wpadm_local_backup', array('wpadm_wp_full_backup_dropbox', 'local_backup') );
18
  add_action('wp_ajax_wpadm_dropbox_create', array('wpadm_wp_full_backup_dropbox', 'dropbox_backup_create') );
19
  add_action('wp_ajax_set_user_mail', array('wpadm_wp_full_backup_dropbox', 'setUserMail') );
20
-
21
  add_action('wp_ajax_saveSetting', array('wpadm_wp_full_backup_dropbox', 'saveSetting') );
22
 
23
 
24
  add_action('admin_post_wpadm_delete_backup', array('wpadm_wp_full_backup_dropbox', 'delete_backup') );
25
  add_action('admin_post_dropboxConnect', array('wpadm_wp_full_backup_dropbox', 'dropboxConnect') );
26
- add_action('admin_post_stop_backup', array('wpadm_wp_full_backup_dropbox', 'stopBackup') );
27
-
28
- add_action('admin_post_login-process', array('wpadm_wp_full_backup_dropbox', 'auth_user') );
29
 
30
  add_action('admin_post_wpadm_download', array('wpadm_wp_full_backup_dropbox', 'download') );
31
  add_action('init', array('wpadm_wp_full_backup_dropbox', 'init'), 10 );
32
 
33
- if (DRBBACKUP_MULTI === false) {
34
- add_action('admin_notices', array('wpadm_wp_full_backup_dropbox', 'notice') );
35
- add_action('admin_notices', array('wpadm_wp_full_backup_dropbox', 'notice_stars'));
36
- } else {
37
- add_action('network_admin_notices', array('wpadm_wp_full_backup_dropbox', 'notice') );
38
- add_action('network_admin_notices', array('wpadm_wp_full_backup_dropbox', 'notice_stars') );
39
- }
40
-
41
- add_action('admin_post_hide_notice', array('wpadm_wp_full_backup_dropbox', 'hide_notice') );
42
- add_action( 'admin_bar_menu', array('wpadm_wp_full_backup_dropbox', 'add_link_to_admin_bar') ,999 );
43
-
44
- add_filter( 'nonce_life', 'wpadm_nonce_life' );
45
 
46
  class wpadm_wp_full_backup_dropbox extends wpadm_class {
47
 
48
- private static $default_optimization = 1;
49
-
50
  const MIN_PASSWORD = 6;
51
-
52
- private static $circle = 42;
53
-
54
- private static $local_delete = false;
55
-
56
- private static $type_archive = array('zip_archive' => 1, 'pclzip_archive' => 1, 'targz_archive' => 1);
57
-
58
- static function is_auth_user()
59
- {
60
- if ( !is_user_logged_in() ) {
61
- exit;
62
- }
63
- $dropbox_options = self::getSettings();
64
- if ( ( isset($dropbox_options['is_admin']) && $dropbox_options['is_admin'] == 1 ) || !isset($dropbox_options['is_admin']) ) {
65
- if (!is_admin() || !is_super_admin()) { // check admin
66
- exit;
67
- }
68
- if ( !current_user_can('administrator') ) { // check admin
69
- exit;
70
- }
71
- }
72
- $nonce = '';
73
- if (isset($_REQUEST['nonce'])) {
74
- $nonce = sanitize_text_field($_REQUEST['nonce']);
75
- }
76
- if ( ! wp_verify_nonce( $nonce, 'wpadm_nonce' ) ) {
77
- exit;
78
- }
79
- }
80
-
81
- static function stopBackup($local = false, $type_backup = '')
82
- {
83
- self::is_auth_user();
84
- if (isset($_POST['type_backup']) || !empty($type_backup)) {
85
- self::$local_delete = $local;
86
- if (!empty($type_backup)) {
87
- $type = $type_backup;
88
- } else {
89
- $type = sanitize_text_field( $_POST['type_backup'] );
90
- }
91
- $setting_backup = array();
92
- if ( $type == 'local_backup' ) {
93
- $setting_backup = WPAdm_Running::getCommand( 'local_backup' );
94
- $type_backup = 'local';
95
- } elseif ( $type == 'send-to-dropbox') {
96
- $setting_backup = WPAdm_Running::getCommand( 'send-to-dropbox' );
97
- $type_backup = 'dropbox';
98
- }
99
- // WPAdm_Running::setCommandResultData('stop_backup', $setting_backup);
100
- $name = '';
101
- if (isset($setting_backup['params']['time'])) {
102
- $name = get_option('siteurl');
103
-
104
- $name = str_replace("http://", '', $name);
105
- $name = str_replace("https://", '', $name);
106
- $name = str_ireplace( array( 'Ä', 'ä', 'Ö', 'ö', 'ß', 'Ü', 'ü', 'å'),
107
- array('ae', 'ae', 'oe', 'oe', 's', 'ue', 'ue', 'a'),
108
- $name );
109
- $name = preg_replace("|\W|", "_", $name);
110
- $name .= '-full-' . date("Y_m_d_H_i", $setting_backup['params']['time']);
111
-
112
- self::delete_backup('local', $name);
113
- if ($type == 'send-to-dropbox') {
114
- self::delete_backup('dropbox', $name);
115
- }
116
-
117
- }
118
- }
119
- WPAdm_Running::init_params_default();
120
- WPAdm_Running::setCommandResultData('stop_process', array( 'stop' => 1, 'name' => $name, 'type' => $type ) );
121
- if ($local === false || empty($local)) {
122
- header("Location: " . admin_url("admin.php?page=wpadm_wp_full_backup_dropbox"));
123
- exit;
124
- }
125
- }
126
-
127
- static function add_link_to_admin_bar($wp_admin_bar)
128
- {
129
- $show = true;
130
- $dropbox_options = self::getSettings();
131
-
132
- if ( ( isset($dropbox_options['is_show_admin_bar']) && $dropbox_options['is_show_admin_bar'] == 0 ) ) {
133
- $show = false;
134
- }
135
- if ( ( isset($dropbox_options['is_admin']) && $dropbox_options['is_admin'] == 1 ) || !isset($dropbox_options['is_admin']) ) {
136
- if (!is_admin() || !is_super_admin()) {
137
- $show = false;
138
- }
139
- }
140
- if ($show) {
141
- if (!DRBBACKUP_MULTI) {
142
- $wp_admin_bar->add_node( array(
143
- 'id' => 'dropbox-backup',
144
- 'title' => 'Dropbox backup',
145
- 'href' => esc_url( admin_url("admin.php?page=wpadm_wp_full_backup_dropbox") ),
146
- 'meta' => array('class' => 'dropbox-image-toolbar')
147
- ));
148
- }
149
- }
150
-
151
- }
152
-
153
- public static function notice_stars()
154
- {
155
- if ( file_exists(WPAdm_Core::getTmpDir() . "/notice-star") ) {
156
- $star = file_get_contents(WPAdm_Core::getTmpDir() . "/notice-star");
157
- if ($star != 0) {
158
- $d = explode("_", $star);
159
- $time = $hide = '';
160
- if (isset($d[1])) {
161
- if ($d[1] == '1d' && ( (int)$d[0] + WPADM_1DAY ) <= time() ) {
162
- $time = __("1 day",'dropbox-backup');
163
- $hide = '1d';
164
- } elseif ($d[1] == 'w' && ( (int)$d[0] + WPADM_1WEEK ) <= time() ) {
165
- $time = __("1 week",'dropbox-backup');
166
- $hide = 'week';
167
- }
168
- }
169
- if (!empty($time) && !empty($hide) && file_exists(DRBBACKUP_BASE_DIR . DIRECTORY_SEPARATOR . "template" . DIRECTORY_SEPARATOR . "notice5.php")) {
170
- ob_start();
171
- require_once DRBBACKUP_BASE_DIR . DIRECTORY_SEPARATOR . "template" . DIRECTORY_SEPARATOR . "notice5.php";
172
- echo ob_get_clean();
173
- }
174
- }
175
- }
176
- }
177
-
178
- public static function setFlagToTmp($flag = '', $data = false)
179
- {
180
- if ( !empty($flag) ) {
181
- if (!class_exists('WPAdm_Core')) {
182
- require_once DRBBACKUP_BASE_DIR . "/libs/class-wpadm-core.php" ;
183
- WPAdm_Core::$pl_dir = DRBBACKUP_BASE_DIR;
184
- }
185
- file_put_contents( WPAdm_Core::getTmpDir() . "/$flag" , $data );
186
- }
187
- }
188
-
189
- public static function auth_user()
190
- {
191
- if (isset($_POST['username']) && $_POST['password']) {
192
- if(!function_exists("wp_safe_remote_post")) {
193
- include ABSPATH . "/http.php";
194
- }
195
- $res = wp_safe_remote_post(SERVER_URL_INDEX, array('username' => sanitize_text_field( $_POST['username'] ), 'password' => sanitize_text_field( $_POST['password'] ), 'plugin' => 'dropbox-backup'));
196
- if (!Empty($res['body'])) {
197
- $data_res = json_decode($res['body']);
198
- if (isset($data_res['url'])) {
199
- header("Location: " . $data_res['url']);
200
- exit;
201
- }
202
- }
203
- }
204
- header("Location: " . admin_url("admin.php?page=wpadm_wp_full_backup_dropbox") );
205
- exit;
206
- }
207
-
208
  public static function init()
209
  {
210
  parent::$plugin_name = 'dropbox-backup';
@@ -214,19 +46,15 @@
214
 
215
  static function include_admins_script()
216
  {
217
- if (isset($_GET['page']) && ($_GET['page'] == 'wpadm_wp_full_backup_dropbox' || $_GET['page'] == 'wpadm_plugins') ) {
218
- wp_enqueue_style('admin-wpadm', plugins_url( "/template/css/admin-style-wpadm.css", dirname( __FILE__ )) );
219
- wp_enqueue_script( 'js-admin-wpadm', plugins_url( "/template/js/admin-wpadm.js", dirname( __FILE__ ) ) );
220
- wp_enqueue_script( 'postbox' );
221
- wp_enqueue_script( 'jquery-ui-tooltip' );
222
- }
223
- wp_enqueue_style('css-admin-wpadm-toolbar', plugins_url( "/template/css/tool-bar.css", dirname( __FILE__ )) );
224
  }
225
 
226
  public static function setUserMail()
227
  {
228
  if (isset($_POST['email'])) {
229
- $email = sanitize_email( $_POST['email'] );
230
  $mail = get_option(PREFIX_BACKUP_ . "email");
231
  if ($mail) {
232
  add_option(PREFIX_BACKUP_ . "email", $email);
@@ -239,219 +67,47 @@
239
  }
240
  public static function saveSetting()
241
  {
242
- if (isset($_POST['is_admin']) || isset($_POST['is_optimization']) || isset($_POST['is_local_backup_delete'])
243
- || isset($_POST['is_repair']) || isset($_POST['time_error']) || isset($_POST['is_show_admin_bar'] ) || isset($_POST['backup_folder'] )
244
- || isset($_POST['clear_backup_folder']) || isset($_POST['zip_archive']) || isset( $_POST['tar_archive'] ) || isset( $_POST['targz_archive'] ) ) {
245
-
246
- $dropbox_options = self::getSettings();
247
-
248
- if (isset($_POST['time_error'])) {
249
- $dropbox_options['time_error'] = (int)sanitize_text_field( $_POST['time_error'] );
250
- }
251
- if (isset($_POST['is_admin'])) {
252
- $dropbox_options['is_admin'] = (int)sanitize_text_field( $_POST['is_admin'] );
253
- }
254
- if (isset($_POST['is_optimization'])) {
255
- $dropbox_options['is_optimization'] = (int)sanitize_text_field( $_POST['is_optimization'] );
256
- }
257
- if (isset($_POST['is_local_backup_delete'])) {
258
- $dropbox_options['is_local_backup_delete'] = (int)sanitize_text_field( $_POST['is_local_backup_delete'] );
259
- }
260
- if (isset($_POST['is_repair'])) {
261
- $dropbox_options['is_repair'] = (int)sanitize_text_field( $_POST['is_repair'] );
262
- }
263
- if (isset($_POST['is_show_admin_bar'])) {
264
- $dropbox_options['is_show_admin_bar'] = (int)sanitize_text_field( $_POST['is_show_admin_bar'] );
265
- }
266
- if (isset($_POST['backup_folder'])) {
267
- $dropbox_options['backup_folder'] = rtrim( sanitize_text_field( $_POST['backup_folder'] ), '/' );
268
- }
269
- if (isset($_POST['clear_backup_folder']) && $_POST['clear_backup_folder'] == 1) {
270
- if ( isset($dropbox_options['backup_folder']) ) {
271
- unset($dropbox_options['backup_folder']);
272
- }
273
- }
274
-
275
- $type_archive = '';
276
- if (isset($_POST['zip_archive']) ) {
277
- $type_archive = 'zip_archive';
278
- } elseif (isset($_POST['tar_archive'])) {
279
- $type_archive = 'tar_archive';
280
- } elseif (isset($_POST['targz_archive'])) {
281
- $type_archive = 'targz_archive';
282
- }
283
-
284
- if ( !empty($type_archive) ) {
285
- if (isset(self::$type_archive[$type_archive])) {
286
- if (isset($dropbox_options['type_archive'])) {
287
- $dropbox_options['type_archive'] = array_merge( self::$type_archive, $dropbox_options['type_archive'] );
288
- } else {
289
- $dropbox_options['type_archive'] = self::$type_archive;
290
- }
291
- if ($dropbox_options['type_archive'][$type_archive] == 1) {
292
- $dropbox_options['type_archive'][$type_archive] = 0;
293
- } else {
294
- $dropbox_options['type_archive'][$type_archive] = 1;
295
- }
296
- }
297
- }
298
-
299
- self::setSettings($dropbox_options);
300
- }
301
- }
302
-
303
- public static function getSettings()
304
- {
305
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
306
- if ($dropbox_options) {
307
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
308
- } else {
309
- $dropbox_options = array();
310
- }
311
- return $dropbox_options;
312
- }
313
-
314
- public static function setSettings($data, $key = '')
315
- {
316
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
317
- if ($dropbox_options) {
318
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
319
- } else {
320
- $dropbox_options = array();
321
- }
322
- if ( !empty($key) ) {
323
- if(isset($dropbox_options[$key])) {
324
- $dropbox_options[$key] = $data;
325
  }
326
- } else {
327
- $dropbox_options = $data;
328
  }
329
-
330
- update_option(PREFIX_BACKUP_ . 'dropbox-setting', base64_encode( serialize( $dropbox_options ) ) );
331
-
332
- return $dropbox_options;
333
  }
334
 
335
  public static function local_backup()
336
  {
337
- self::is_auth_user();
338
- require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
339
- require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-process.php";
340
  @session_write_close();
341
  parent::$type = 'full';
342
  if (file_exists(WPAdm_Core::getTmpDir() . "/logs2")) {
343
- @unlink(WPAdm_Core::getTmpDir() . "/logs2");
344
- }
345
- if (file_exists(WPAdm_Core::getTmpDir() . "/log.log")) {
346
- file_put_contents(WPAdm_Core::getTmpDir() . "/log.log", '');
347
- }
348
-
349
- WPAdm_Core::rmdir(WPAdm_Core::getTmpDir() . "/log-archive.log");
350
-
351
- WPAdm_Process::clear();
352
-
353
- $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
354
- $dropbox_options = self::getSettings();
355
- if ($dropbox_options) {
356
- if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
357
- $backup_dir = $dropbox_options['backup_folder'];
358
- }
359
- }
360
- WPAdm_Core::mkdir($backup_dir);
361
- WPAdm_Running::init_params_default();
362
- self::testOtherArchives();
363
- $res['result'] = 'success';
364
- if (defined('DISABLE_WP_CRON')) {
365
- if (DISABLE_WP_CRON === true || DISABLE_WP_CRON == 'true') {
366
- $res['result'] = 'error';
367
- $res['error'] = __('Please enable cron-tasks on your website.','dropbox-backup') . '<br /><br /><a href="javascript:void(0)" onclick="showEnableCron();" >' . __('How to enable cron-tasks on my website?','dropbox-backup') . '</a><br /><br />';
368
- $res['data'] = array();
369
- $res['size'] = 0;
370
- }
371
- }
372
-
373
- if ( (isset($res['result']) && $res['result'] != 'error') ) {
374
- if ( WPAdm_Core::dir_writeble($backup_dir) ) {
375
- WPAdm_Running::delCommandResultData("local_backup");
376
- $dropbox_options = self::getSettings();
377
- $optimization = (isset($dropbox_options['is_optimization']) && $dropbox_options['is_optimization'] == 1) || (!isset($dropbox_options['is_optimization'])) ? 1 : 0;
378
- $repair = (isset($dropbox_options['is_repair']) && $dropbox_options['is_repair'] == 1) ? 1 : 0;
379
- $backup = new WPAdm_Core(array('method' => "local_backup", 'params' => array('optimize' => $optimization, 'repair' => $repair, 'limit' => 0, 'time' => (int)$_POST['time'], 'types' => array('db', 'files') )), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
380
- if (WPAdm_Core::$cron === false) {
381
- $res = $backup->getResult()->toArray();
382
- $res['md5_data'] = md5( print_r($res, 1) );
383
- $res['name'] = $backup->name;
384
- $res['time'] = $backup->time;
385
- $res['type'] = 'local';
386
- $res['counts'] = count($res['data']);
387
- } else {
388
- set_transient('running_command', 'local_backup', HOUR_IN_SECONDS);
389
- $res['result'] = 'work';
390
- $res['error'] = '';
391
- $res['data'] = array();
392
- $res['size'] = 0;
393
- }
394
- } else {
395
- $res['result'] = 'error';
396
- $res['error'] = str_replace(array('%domain', '%dir-backup'), array(SITE_HOME, $backup_dir), __('Website "%domain" returned an error during file creation: Failed to create file, please check the permissions on the folder "%dir-backup".','dropbox-backup') );
397
- $res['data'] = array();
398
- $res['size'] = 0;
399
- }
400
  }
 
 
 
 
 
 
 
401
 
402
  @session_start();
403
  echo json_encode($res);
404
  wp_die();
405
 
406
  }
407
-
408
  public static function getLog()
409
  {
410
- self::is_auth_user();
411
  @session_write_close();
412
- @session_start();
413
  require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
414
- require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-process.php";
415
  $backup = new WPAdm_Core(array('method' => "local"), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
416
  $log = WPAdm_Core::getLog();
417
  $log2 = WPAdm_Core::getTmpDir() . "/logs2";
418
- $log_array = array();
419
- if ( file_exists($log2) ) {
420
  $text = @file_get_contents($log2);
421
- if ($text == $log) {
422
- $circle = WPAdm_Running::getCommandResultData( 'circle' );
423
- if ( empty($circle['count']) || $circle['count'] == 0) {
424
- $circle['count'] = 0;
425
- }
426
- $dropbox_options = self::getSettings();
427
- if ($dropbox_options) {
428
- if (isset($dropbox_options['time_error'])) {
429
- self::$circle = ( (int)$dropbox_options['time_error'] * 6 );
430
- }
431
- }
432
- $log_array['circle'] = self::$circle;
433
- if ( $circle['count'] <= self::$circle ) {
434
- $circle['count']++;
435
- $circle['time'] = time();
436
- WPAdm_Running::setCommandResultData( 'circle', $circle );
437
- } else {
438
- $date_systm = get_system_data();
439
- $error_msg = __('There is not enough script running time to perform backup operations, please increase the PHP variable max_execution_time.', 'dropbox-backup');
440
- if ( $date_systm['upMemoryLimit'] == 0 ) {
441
- $error_msg = __('There is not enough memory to perform archiving of big files and continue backup operations, please increase the PHP variable memory_limit.', 'dropbox-backup');
442
- }
443
- $log_array['data'] = array(
444
- 'result' => 'error',
445
- 'error' => $error_msg,
446
- 'data' => null,
447
- 'size' => 0 );
448
- $type_backup = sanitize_text_field( $_POST['type-backup'] );
449
- self::stopBackup(true, $type_backup);
450
- }
451
- $log_array['example'] = $circle;
452
- } else {
453
- WPAdm_Running::setCommandResultData( 'circle', array( 'count' => 0, 'time' => time() ) );
454
- }
455
  file_put_contents($log2, $log);
456
  $log = str_replace($text, "", $log);
457
  } else {
@@ -459,26 +115,8 @@
459
  }
460
  $log = explode("\n", $log);
461
  krsort($log);
462
- $log_array['log'] = $log;
463
- $type_backup = sanitize_text_field( $_POST['type-backup'] );
464
- $data_result = WPAdm_Running::getCommandResultData( $type_backup );
465
- if (!empty($data_result)) {
466
- $log_array['data'] = $data_result;
467
- set_transient('drb_running', 0, 1);
468
- }
469
- if (isset($_POST['type-backup2'])) {
470
- $type_backup2 = sanitize_text_field( $_POST['type-backup2'] );
471
- $data_result = WPAdm_Running::getCommandResultData( $type_backup2 );
472
- if (!empty($data_result) && $data_result['result'] != 'success') {
473
- $log_array['data'] = $data_result;
474
- set_transient('drb_running', 0, 1);
475
- }
476
- }
477
- $log_array['processes'] = WPAdm_Process::getAll();
478
- if (defined('WP_CRON_LOCK_TIMEOUT')) {
479
- $log_array['lock_cron'] = WP_CRON_LOCK_TIMEOUT;
480
- }
481
- echo json_encode( $log_array );
482
  exit;
483
  }
484
  public static function restore_backup()
@@ -487,9 +125,9 @@
487
  @session_write_close();
488
  parent::$type = 'full';
489
  if (file_exists(WPAdm_Core::getTmpDir() . "/logs2")) {
490
- @unlink(WPAdm_Core::getTmpDir() . "/logs2");
491
  }
492
- $name_backup = isset($_POST['name']) ? sanitize_text_field( $_POST['name'] ) : "";
493
  $backup = new WPAdm_Core(array('method' => "local_restore", 'params' => array('types' => array('files', 'db'), 'name_backup' => $name_backup )), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
494
  $res = $backup->getResult()->toArray();
495
  @session_start();
@@ -502,55 +140,44 @@
502
  @session_write_close();
503
  $log_class = new WPAdm_Core(array('method' => "local"), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
504
  if (file_exists(WPAdm_Core::getTmpDir() . "/logs2")) {
505
- @unlink(WPAdm_Core::getTmpDir() . "/logs2");
506
  }
507
  if (file_exists(WPAdm_Core::getTmpDir() . "/log.log")) {
508
- @unlink(WPAdm_Core::getTmpDir() . "/log.log");
509
  }
510
- WPAdm_Core::log( __('Start Restore from Dropbox cloud' ,'dropbox-backup')) ;
511
- $dropbox_options = self::getSettings();
512
- if ($dropbox_options && isset( $dropbox_options['app_key'] ) ) {
513
  require_once DRBBACKUP_BASE_DIR. "/modules/dropbox.class.php";
 
514
  $folder_project = self::getNameProject();
515
  $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
516
  if ($dropbox->isAuth()) {
517
- WPAdm_Core::mkdir(DROPBOX_BACKUP_DIR_BACKUP);
518
- $name_backup = isset($_POST['name']) ? sanitize_text_field( $_POST['name'] ): "";
519
- $dir_backup = DROPBOX_BACKUP_DIR_BACKUP . "/$name_backup";
520
- $error = WPAdm_Core::mkdir($dir_backup);
521
- if (!empty($error)) {
522
- WPAdm_Core::log($error);
523
- $res['result'] = WPAdm_Result::WPADM_RESULT_ERROR;
524
- $res['error'] = $error;
525
- $res['data'] = array();
526
- $res['size'] = 0;
527
-
528
- } else {
529
- $files = $dropbox->listing("$folder_project/$name_backup");
530
- if (isset($files['items'])) {
531
- $n = count($files['items']);
532
- for($i = 0; $i < $n; $i++) {
533
- $res = $dropbox->downloadFile("$folder_project/$name_backup/{$files['items'][$i]['name']}", "$dir_backup/{$files['items'][$i]['name']}");
534
- if ($res != "$dir_backup/{$files['items'][$i]['name']}" && isset($res['text'])) {
535
- WPAdm_Core::log(__('Error: ' ,'dropbox-backup') . $res['text'] );
536
- } else {
537
- $log = str_replace('%s', $files['items'][$i]['name'], __('Download file (%s) with Dropbox' ,'dropbox-backup') );
538
- WPAdm_Core::log($log);
539
- }
540
  }
541
- parent::$type = 'full';
542
- $backup = new WPAdm_Core(array('method' => "local_restore", 'params' => array('types' => array('files', 'db'), 'name_backup' => $name_backup )), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
543
- $res = $backup->getResult()->toArray();
544
- WPAdm_Core::rmdir($dir_backup);
545
  }
 
 
 
 
546
  }
547
  } else {
548
- WPAdm_Core::log( str_replace(array('%d', '%k', '%s'),
549
- array( SITE_HOME, $dropbox_options['app_key'], $dropbox_options['app_secret'] ), __('Website "%d" can\'t authorize on Dropbox with using of "app key: %k" and "app secret: %s"' ,'dropbox-backup')
550
- ) );
551
  }
552
  } else {
553
- WPAdm_Core::log( str_replace('%d', SITE_HOME, __('Website "%d" returned an error during connection to Dropbox: "app key" and "app secret" wasn\'t found. Please, check your Dropbox settings.' ,'dropbox-backup') ) );
554
  }
555
  @session_start();
556
  echo json_encode($res);
@@ -559,17 +186,16 @@
559
  public static function download()
560
  {
561
  if (isset($_REQUEST['backup'])) {
562
- $backup = sanitize_text_field($_REQUEST['backup']);
563
  require_once DRBBACKUP_BASE_DIR . "/class-wpadm-core.php";
564
  require_once DRBBACKUP_BASE_DIR . '/modules/pclzip.lib.php';
565
  $backup = new WPAdm_Core(array('method' => "local"), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
566
- $filename = $backup . ".zip";
567
  $file = WPAdm_Core::getTmpDir() . "/" . $filename;
568
  if (file_exists($file)) {
569
- @unlink($file);
570
  }
571
  $archive = new PclZip($file);
572
- $dir_backup = DROPBOX_BACKUP_DIR_BACKUP . '/' . $backup;
573
 
574
  $backups = array('data' => array(), 'md5' => '');
575
  if (is_dir($dir_backup)) {
@@ -577,7 +203,7 @@
577
  $dir_open = opendir($dir_backup);
578
  while($d = readdir($dir_open)) {
579
  if ($d != '.' && $d != '..' && file_exists($dir_backup . "/$d") && substr($d, -3) != "php") {
580
- $archive->add($dir_backup . "/$d", PCLZIP_OPT_REMOVE_PATH, DROPBOX_BACKUP_DIR_BACKUP );
581
  }
582
  }
583
  }
@@ -602,72 +228,35 @@
602
  echo file_get_contents($file);
603
  fclose($df);
604
  echo ob_get_clean();
605
- @unlink($file);
606
  exit;
607
  }
608
  }
609
 
610
- public static function delete_backup($type = '', $name = '')
611
  {
612
- if (self::$local_delete === false || empty(self::$local_delete)) {
613
- self::is_auth_user();
614
- }
615
- if ( isset($_POST['backup-type']) ) {
616
- $type = sanitize_text_field( $_POST['backup-type'] );
617
- } elseif( !empty($type) ) {
618
- $type = sanitize_text_field( $type );
619
- }
620
-
621
- if (isset($_POST['backup-name'])) {
622
- $name = sanitize_text_field( $_POST['backup-name'] );
623
- } elseif (!empty($name)) {
624
- $name = sanitize_text_field( $name );
625
- }
626
-
627
- if ($type == 'local') {
628
- require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
629
- $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
630
- $dropbox_options = self::getSettings();
631
- if ($dropbox_options) {
632
- if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
633
- $backup_dir = $dropbox_options['backup_folder'];
634
  }
635
- }
 
 
 
 
 
 
 
 
636
 
637
- $dir = $backup_dir . '/' . $name ;
638
- $delete = false;
639
- if (is_dir($dir)) {
640
- WPAdm_Core::rmdir($dir);
641
- $delete = true;
642
- }
643
- $dir = ABSPATH . WPADM_DIR_NAME . '/' . $name ;
644
- if (is_dir($dir)) {
645
- WPAdm_Core::rmdir($dir);
646
- $delete = true;
647
- }
648
- $dir = WPADM_DIR_BACKUP . '/' . $name ;
649
- if (is_dir($dir)) {
650
- WPAdm_Core::rmdir($dir);
651
- $delete = true;
652
- }
653
- if ($delete) {
654
- parent::setMessage( str_replace('%s', $name, __('Backup(%s) was deleted','dropbox-backup') ) );
655
  }
656
- } elseif ($type == 'dropbox') {
657
- require_once DRBBACKUP_BASE_DIR . "/modules/dropbox.class.php";
658
- $dropbox_options = self::getSettings();
659
- if ($dropbox_options && isset($dropbox_options['app_key'])) {
660
- $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
661
- $folder_project = self::getNameProject();
662
- $res = $dropbox->deleteFile("$folder_project/{$name}");
663
- if ($res['is_deleted'] === true) {
664
- parent::setMessage( str_replace('%s', $name, __('Backup(%s) was deleted','dropbox-backup') ) );
665
- }
666
- }
667
- }
668
- if (self::$local_delete === false || empty(self::$local_delete)) {
669
- header("Location: " . $_SERVER['HTTP_REFERER']);
670
  }
 
671
  }
672
 
673
  protected static function getPluginName()
@@ -686,162 +275,108 @@
686
  require_once DRBBACKUP_BASE_DIR . "/modules/dropbox.class.php";
687
  if (isset($_GET['app_key']) && isset($_GET['app_secret'])) {
688
  if (empty($_GET['app_key']) && empty($_GET['app_secret'])) {
689
- $app_key = WPADM_APP_KEY;
690
- $app_secret = WPADM_APP_SECRET;
691
- } else {
692
- $app_key = sanitize_text_field($_GET['app_key']);
693
- $app_secret = sanitize_text_field($_GET['app_secret']);
694
  }
695
- $dropbox = new dropbox($app_key, $app_secret);
696
- $_SESSION['dropbox_key'] = $app_key;
697
- $_SESSION['dropbox_secret'] = $app_secret;
698
  $_SESSION['dropbox_request_token'] = $dropbox->getRequestToken();
699
  echo '<script>window.location.href="' . $dropbox->generateAuthUrl( admin_url('admin-post.php?action=dropboxConnect') ) . '";</script>';
700
  } elseif (isset($_GET['oauth_token']) && isset($_GET['uid'])) {
701
- $dropbox_options = self::getSettings();
 
 
 
 
 
 
702
  $dropbox = new dropbox(@$_SESSION['dropbox_key'], @$_SESSION['dropbox_secret']);
703
  $access_token = $dropbox->getAccessToken($_SESSION['dropbox_request_token']);
704
  $dropbox_options['app_key'] = @$_SESSION['dropbox_key'] ;
705
  $dropbox_options['app_secret'] = @$_SESSION['dropbox_secret'] ;
706
  $dropbox_options['auth_token_secret'] = $access_token;
707
- $dropbox_options['oauth_token'] = sanitize_text_field( @$_GET['oauth_token'] ) ;
708
- $dropbox_options['uid'] = sanitize_text_field( @$_GET['uid'] ) ;
709
- self::setSettings($dropbox_options);
710
  echo '<script>
711
  if(window.opener){
712
- window.opener.connectDropbox(null, null, "'. htmlspecialchars($access_token['oauth_token_secret']) . '", "'.htmlspecialchars($access_token['oauth_token']).'", "'.htmlspecialchars($access_token['uid']).'");window.close();
713
  }else{
714
  window.location.href="' . admin_url("admin.php?page=wpadm_wp_full_backup_dropbox") . '";
715
  }
716
  </script>';
717
  echo '<script>window.close();</script>';exit;
718
  } elseif (isset($_GET['not_approved'])) {
719
- if( $_GET['not_approved'] == 'true' ){ // check of GET params == string 'true'
720
  echo '<script>window.close();</script>';exit;
721
  }
722
  } else {
723
- WPAdm_Core::log( str_replace('%d', SITE_HOME, __('Website "%d" returned an error during connection to Dropbox: "app key" and "app secret" wasn\'t found. Please, check your Dropbox settings.' ,'dropbox-backup') ) );
724
  }
725
  exit;
726
  }
727
 
728
  public static function dropbox_backup_create()
729
  {
730
- self::is_auth_user();
731
  require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
732
- require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-process.php";
733
- @session_write_close();
734
-
735
  $log = new WPAdm_Core(array('method' => "local"), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
736
  if (file_exists(WPAdm_Core::getTmpDir() . "/logs2")) {
737
- @unlink(WPAdm_Core::getTmpDir() . "/logs2");
738
  }
739
- if (file_exists(WPAdm_Core::getTmpDir() . "/log.log")) {
740
- file_put_contents(WPAdm_Core::getTmpDir() . "/log.log", '');
741
- }
742
-
743
- WPAdm_Core::rmdir(WPAdm_Core::getTmpDir() . "/log-archive.log");
744
-
745
- WPAdm_Process::clear();
746
-
747
- $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
748
- $dropbox_options = self::getSettings();
749
  if ($dropbox_options) {
750
- if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
751
- $backup_dir = $dropbox_options['backup_folder'];
 
 
752
  }
753
- }
754
-
755
- if ( WPAdm_Core::dir_writeble($backup_dir) ) {
756
- $send_to_dropbox = true;
757
- if ($dropbox_options) {
758
- if (!isset($dropbox_options['app_key'])) {
759
- WPAdm_Core::log( str_replace('%d', SITE_HOME, __('Website "%d" returned an error during connection to Dropbox: "App Key" wasn\'t found. Please, check your Dropbox settings.' ,'dropbox-backup') ) );
760
- $send_to_dropbox = false;
761
- }
762
- if (!isset($dropbox_options['app_secret'])) {
763
- WPAdm_Core::log( str_replace('%d', SITE_HOME, __('Website "%d" returned an error during connection to Dropbox: "App Secret" wasn\'t found. Please, check your Dropbox settings.' ,'dropbox-backup') ) );
764
- $send_to_dropbox = false;
765
- }
766
- if (!isset($dropbox_options['oauth_token'])) {
767
- WPAdm_Core::log( str_replace('%d', SITE_HOME, __('Website "%d" returned an error during file sending to Dropbox: "Auth Token not exist. Files cannot be sent to Dropbox cloud. Please, check your Dropbox settings."' ,'dropbox-backup') ) );
768
- $send_to_dropbox = false;
769
- }
770
- } else {
771
- WPAdm_Core::log( str_replace('%d', SITE_HOME, __('Website "%d" returned an error during connection to Dropbox: "app key" and "app secret" wasn\'t found. Please, check your Dropbox settings.' ,'dropbox-backup') ) );
772
- $res['type'] = 'local';
773
  $send_to_dropbox = false;
774
  }
775
-
776
- if (defined('DISABLE_WP_CRON')) {
777
- if (DISABLE_WP_CRON === true || DISABLE_WP_CRON == 'true') {
778
- $res['result'] = 'error';
779
- $res['error'] = __('Please enable cron-tasks on your website.','dropbox-backup') . '<br /><br /><a href="javascript:void(0)" onclick="showEnableCron();" >' . __('How to enable cron-tasks on my website?','dropbox-backup') . '</a><br /><br />';
780
- $res['data'] = array();
781
- $res['size'] = 0;
782
- $send_to_dropbox = false;
783
- }
784
  }
785
-
786
- if ($send_to_dropbox) {
787
- parent::$type = 'full';
788
- WPAdm_Running::init_params_default();
789
- self::testOtherArchives();
790
- WPAdm_Running::delCommandResultData("local_backup");
791
-
792
- $dropbox_options = self::getSettings();
793
- $optimization = (isset($dropbox_options['is_optimization']) && $dropbox_options['is_optimization'] == 1) || (!isset($dropbox_options['is_optimization'])) ? 1 : 0;
794
- $repair = (isset($dropbox_options['is_repair']) && $dropbox_options['is_repair'] == 1) ? 1 : 0;
795
-
796
- $backup_local = new WPAdm_Core(array('method' => "local_backup", 'params' => array('optimize' => $optimization, 'repair' => $repair, 'limit' => 0, 'time' => (int)$_POST['time'], 'types' => array('db', 'files') )), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
797
  $res = array();
798
- if (WPAdm_Core::$cron === false) {
799
- $res = $backup->getResult()->toArray();
800
- $res['md5_data'] = md5( print_r($res, 1) );
801
- $res['name'] = $backup->name;
802
- $res['time'] = $backup->time;
803
- $res['type'] = 'dropbox';
804
- $res['counts'] = count($res['data']);
805
- }
806
- unset($backup_local);
807
- $folder_project = self::getNameProject();
808
- WPAdm_Running::delCommandResultData("send-to-dropbox");
809
- $backup = new WPAdm_Core(array('method' => "send-to-dropbox",
810
- 'params' => array('files' => isset($res['data']) ? $res['data'] : '',
811
- 'local' => true,
812
- 'is_local_backup' => ( isset($dropbox_options['is_local_backup_delete']) && $dropbox_options['is_local_backup_delete'] == 1 ? $dropbox_options['is_local_backup_delete'] : 0 ),
813
- 'access_details' => array('key' => $dropbox_options['app_key'],
814
- 'secret' => $dropbox_options['app_secret'],
815
- 'token' => $dropbox_options['auth_token_secret'],
816
- 'dir' => isset($res['name']) ? $res['name'] : '',
817
- 'folder' => $folder_project),
818
- 'time' => (int)$_POST['time'],
819
- 'is_folder_set' => isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder']),
820
- )
821
- ),
822
- 'full_backup_dropbox', WPAdm_Core::$pl_dir) ;
823
- if (WPAdm_Core::$cron === false) {
824
- $result_send = $backup->getResult()->toArray();
825
- if ($result_send['result'] == 'error') {
826
- $res = array();
827
- $res['error'] = $result_send['error'];
828
- $res['result'] = 'error';
829
- @rename(WPAdm_Core::getTmpDir() . "/logs2", WPAdm_Core::getTmpDir() . "/logs_error_" . $backup_local->time);
830
- }
831
- WPAdm_Core::rmdir( $backup_dir . "/{$res['name']}");
832
- } else {
833
- set_transient('running_command', 'send-to-dropbox', HOUR_IN_SECONDS);
834
- $res['result'] = 'work';
835
- $res['error'] = '';
836
- $res['data'] = array();
837
- $res['size'] = 0;
838
- }
839
  }
840
- } else {
841
- $res['result'] = 'error';
842
- $res['error'] = str_replace(array('%domain', '%dir-backup'), array(SITE_HOME, $backup_dir), __('Website "%domain" returned an error during file creation: Failed to create file, please check the permissions on the folder "%dir-backup".','dropbox-backup') );
843
- $res['data'] = array();
844
- $res['size'] = 0;
845
  }
846
  @session_start();
847
  echo json_encode($res);
@@ -851,60 +386,39 @@
851
  {
852
  $folder_project = str_ireplace( array("http://", "https://"), '', home_url() );
853
  $folder_project = str_ireplace( array( "-", '/', '.'), '_', $folder_project );
854
- $folder_project = str_ireplace( array( 'Ä', 'ä', 'Ö', 'ö', 'ß', 'Ü', 'ü', 'å'),
855
- array('ae', 'ae', 'oe', 'oe', 's', 'ue', 'ue', 'a'),
856
- $folder_project );
857
  return $folder_project;
858
  }
859
 
 
860
  public static function wpadm_show_backup()
861
  {
 
862
  require_once DRBBACKUP_BASE_DIR. "/modules/dropbox.class.php";
863
  parent::$type = 'full';
864
-
865
- $dropbox_options = self::getSettings();
866
- $stop_precess = WPAdm_Running::getCommandResultData('stop_process');
867
- $name_backup = isset($stop_precess['name']) ? $stop_precess['name'] : '' ;
868
  if ($dropbox_options) {
 
869
  if (isset($dropbox_options['app_key']) && isset($dropbox_options['app_secret']) && isset($dropbox_options['auth_token_secret'])) {
870
  $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
871
  $folder_project = self::getNameProject();
872
  $backups = $dropbox->listing($folder_project);
873
  $n = count($backups['items']);
874
  $data['data'] = array();
875
- $not_all_upload = false;
876
  for($i = 0; $i < $n; $i++) {
877
- if ($name_backup != $backups['items'][$i]['name']) {
878
- $backup = $dropbox->listing($folder_project . "/" . $backups['items'][$i]['name']);
879
- $data['data'][$i]['name'] = $backups['items'][$i]['name'];
880
- $data['data'][$i]['size'] = (float)$backup['size'] * 1024 * 1024;
881
- $data['data'][$i]['dt'] = parent::getDateInName($backups['items'][$i]['name']);
882
- $data['data'][$i]['count'] = count($backup['items']);
883
- $data['data'][$i]['type'] = 'dropbox';
884
- $k = $data['data'][$i]['count'];
885
- $data['data'][$i]['files'] = '[';
886
- for($j = 0; $j < $k; $j++) {
887
- if ( strpos($backup['items'][$j]['name'] , '.md5') !== false || strpos($backup['items'][$j]['name'] , '.zip') !== true || strpos($backup['items'][$j]['name'] , '.tar.gz' ) !== false ) {
888
- if ( strpos($backup['items'][$j]['name'] , '.md5') !== false ) {
889
- $not_all_upload = true;
890
- }
891
- $data['data'][$i]['files'] .= $backup['items'][$j]['name'] . ',';
892
- }
893
- }
894
- $data['data'][$i]['not_all_upload'] = $not_all_upload;
895
  }
896
  }
897
  }
898
  }
899
- if (isset($_GET['pay']) && $_GET['pay'] == 'success') { // check of GET params == string 'success'
900
- if (!file_exists(WPAdm_Core::getTmpDir() . "/pay_success")) {
901
- file_put_contents(WPAdm_Core::getTmpDir() . "/pay_success", 1);
902
- parent::setMessage( 'Checkout was successfully' );
903
- }
904
- }
905
- if (isset($_GET['pay']) && $_GET['pay'] == 'cancel') { // check of GET params == string 'cancel'
906
- parent::setError( __('Checkout was canceled','dropbox-backup') );
907
- }
908
  $data_local = parent::read_backups();
909
  if (isset($data['data'])) {
910
  $data['data'] = array_merge($data_local['data'], $data['data']);
@@ -912,102 +426,31 @@
912
  } else {
913
  $data = $data_local;
914
  }
915
- if (file_exists(WPAdm_Core::getTmpDir() . "/pay_success")) {
916
- $plugin_info = get_plugins("/" . parent::$plugin_name);
917
- $plugin_version = (isset($plugin_info[parent::$plugin_name . '.php']['Version']) ? $plugin_info[parent::$plugin_name . '.php']['Version'] : '');
918
- $data_server = parent::sendToServer(
919
- array(
920
- 'actApi' => "proBackupCheck",
921
- 'site' => home_url(),
922
- 'email' => get_option('admin_email'),
923
- 'plugin' => parent::$plugin_name,
924
- 'key' => '',
925
- 'plugin_version' => $plugin_version
926
- )
927
- );
928
- if (isset($data_server['status']) && $data_server['status'] == 'success' && isset($data_server['key'])) {
929
- update_option(PREFIX_BACKUP_ . 'pro-key', $data_server['key']);
930
- if (isset($data_server['url']) && !empty($data_server['url'])) {
931
- parent::setMessage( str_replace('&s', $data_server['url'], __('The "Dropbox backup & restore PRO" version can be downloaded here <a href="&s">download</a>','dropbox-backup') ) );
932
- }
933
- }
934
- }
935
- if ( ! function_exists( 'get_plugins' ) ) {
936
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
937
- }
938
- $stars5 = file_exists( WPAdm_Core::getTmpDir() . "/notice-star");
939
- $plugin_data = array_values( get_plugins('/dropbox-backup') );
940
- $is_runnig = WPAdm_Running::is_running();
941
- $running_backup = WPAdm_Running::getCommand( 'local_backup' );
942
- if($running_backup === false) {
943
- $running_backup = WPAdm_Running::getCommand( 'send-to-dropbox' );
944
- }
945
- if ( isset($running_backup['params']['time']) ) {
946
- $name = get_option('siteurl');
947
-
948
- $name_running_backup = str_replace("http://", '', $name);
949
- $name_running_backup = str_replace("https://", '', $name_running_backup);
950
- $name_running_backup = preg_replace("|\W|", "_", $name_running_backup);
951
- $name_running_backup .= '-' . wpadm_class::$type . '-' . date("Y_m_d_H_i", $running_backup['params']['time']);
952
- }
953
-
954
- $backu_dir = DROPBOX_BACKUP_DIR_BACKUP;
955
- if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
956
- $backu_dir = $dropbox_options['backup_folder'];
957
- }
958
- if ( !file_exists( $backu_dir . '/local-key') ) {
959
- WPAdm_Core::mkdir($backu_dir);
960
- $key = md5(time() . 'wpadm-key');
961
- file_put_contents($backu_dir . '/local-key', base64_encode( serialize( array('key' => $key, 'time-update' => time() + 3600) ) ) );
962
- } else {
963
- $key_values = unserialize( base64_decode( file_get_contents($backu_dir . '/local-key') ) );
964
- if (isset($key_values['time-update']) && $key_values['time-update'] <= time() ) {
965
- $key = md5( time() . 'wpadm-key' );
966
- file_put_contents($backu_dir . '/local-key', base64_encode( serialize ( array( 'key' => $key, 'time-update' => time() + 3600 ) ) ) );
967
- } else {
968
- $key = $key_values['key'];
969
- }
970
- }
971
-
972
  $show = !get_option('wpadm_pub_key') && is_super_admin();
973
  $error = parent::getError(true);
974
- if ( !empty( WPAdm_Core::$error ) ) {
975
- $error .= '<br />' . WPAdm_Core::$error;
976
- }
977
  $msg = parent::getMessage(true);
978
- $default = self::$circle / 6; // 18 request for log files, one request every 10 seconds
979
  $base_path = DRBBACKUP_BASE_DIR ;
980
-
981
- if ( !isset( $dropbox_options['type_archive'] ) ) {
982
- $dropbox_options['type_archive'] = self::$type_archive;
983
- } else {
984
- $dropbox_options['type_archive'] = array_merge( self::$type_archive, $dropbox_options['type_archive'] );
985
- }
986
-
987
- $nonce = wp_create_nonce( 'wpadm_nonce' );
988
-
989
  ob_start();
990
  require_once $base_path . DIRECTORY_SEPARATOR . "template" . DIRECTORY_SEPARATOR . "wpadm_show_backup.php";
991
  echo ob_get_clean();
992
  }
993
 
 
994
  public static function draw_menu()
995
  {
996
  $show = true;
997
- $dropbox_options = self::getSettings();
998
-
 
 
999
  if ( ( isset($dropbox_options['is_admin']) && $dropbox_options['is_admin'] == 1 ) || !isset($dropbox_options['is_admin']) ) {
1000
  if (!is_admin() || !is_super_admin()) {
1001
  $show = false;
1002
  }
1003
- if ( !current_user_can('administrator') ) {
1004
- $show = false;
1005
- }
1006
-
1007
  }
1008
  if ($show) {
1009
  $menu_position = '1.9998887771';
1010
- if(self::checkInstallWpadmPlugins()) {
1011
  $page = add_menu_page(
1012
  'WPAdm',
1013
  'WPAdm',
@@ -1024,8 +467,8 @@
1024
  'read',
1025
  'wpadm_wp_full_backup_dropbox',
1026
  array('wpadm_wp_full_backup_dropbox', 'wpadm_show_backup')
1027
- );
1028
- } else {
1029
  $page = add_menu_page(
1030
  'Dropbox Full Backup',
1031
  'Dropbox Full Backup',
@@ -1043,72 +486,10 @@
1043
  'read',
1044
  'wpadm_plugins',
1045
  'wpadm_plugins'
1046
- );
1047
- }
1048
-
1049
- }
1050
- }
1051
- public static function notice()
1052
- {
1053
- // check of isset GET params "page"
1054
- if (!isset($_GET['page']) || ( isset($_GET['page']) && $_GET['page'] != 'wpadm_wp_full_backup_dropbox' ) ) {
1055
- $notice_file = DRBBACKUP_BASE_DIR . DIRECTORY_SEPARATOR . "template" . DIRECTORY_SEPARATOR . "notice.php";
1056
- if (!file_exists(WPAdm_Core::getTmpDir() . "/notice") && file_exists($notice_file)) {
1057
- ob_start();
1058
- include_once $notice_file;
1059
- echo ob_get_clean();
1060
- }
1061
- }
1062
- }
1063
- public static function hide_notice()
1064
- {
1065
- if (isset($_GET['type'])) {
1066
- $type = sanitize_text_field( $_GET['type'] );
1067
- switch( $type ) {
1068
- case 'preview' :
1069
- file_put_contents(WPAdm_Core::getTmpDir() . "/notice", 1);
1070
- break;
1071
- case 'star' :
1072
- if (isset($_GET['hide']) && $_GET['hide'] == '1d') {
1073
- file_put_contents(WPAdm_Core::getTmpDir() . "/notice-star", time() . '_w');
1074
- } elseif ( ( isset($_GET['hide']) && $_GET['hide'] == 'week' ) || !isset($_GET['hide']) ) {
1075
- file_put_contents(WPAdm_Core::getTmpDir() . "/notice-star", 0);
1076
- }
1077
- break;
1078
  }
1079
- }
1080
- header('location:' . $_SERVER['HTTP_REFERER']);
1081
- exit;
1082
- }
1083
 
1084
- public static function testOtherArchives()
1085
- {
1086
- require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-archive.php";
1087
- // test type archive
1088
- $archive = new WPAdm_Archive(WPAdm_Core::getTmpDir() . '/test.zip');
1089
- $archive->setRemovePath(rtrim( ABSPATH, '/' ) );
1090
- $zip_test = $archive->zipArhive( array( WPAdm_Core::getTmpDir() . '/index.php' , WPAdm_Core::getTmpDir() . '/.htaccess' ) );
1091
- if ( $zip_test ) {
1092
- WPAdm_Running::setCommandResultData('test_zip_archive', true);
1093
- WPAdm_Core::log( __('Testing of ZIP under shell was finished successfully', 'dropbox-backup') );
1094
- }
1095
-
1096
- $targz_archive = $archive->targzArchive( array( WPAdm_Core::getTmpDir() . '/index.php' , WPAdm_Core::getTmpDir() . '/.htaccess' ) );
1097
- if ( $targz_archive ) {
1098
- WPAdm_Running::setCommandResultData('test_targz_archive', true);
1099
- WPAdm_Core::log( __('Testing of TarGz was finished successfully', 'dropbox-backup') );
1100
- }
1101
- }
1102
-
1103
- static function getTypeBackup()
1104
- {
1105
- $dropbox_options = self::getSettings();
1106
- if ( !isset( $dropbox_options['type_archive'] ) ) {
1107
- $dropbox_options['type_archive'] = self::$type_archive;
1108
- } else {
1109
- $dropbox_options['type_archive'] = array_merge( self::$type_archive, $dropbox_options['type_archive'] );
1110
  }
1111
- return $dropbox_options['type_archive'];
1112
  }
1113
  }
1114
  }
1
  <?php
2
+ if (! defined("WPADM_URL_BASE")) {
3
+ define("WPADM_URL_BASE", 'http://secure.webpage-backup.com/');
4
+ }
5
+ if (! defined("WPADM_APP_KEY")) {
6
+ define("WPADM_APP_KEY", 'nv751n84w2nif6j');
7
+ }
8
+ if (! defined("WPADM_APP_SECRET")) {
9
+ define("WPADM_APP_SECRET", 'qllasd4tbnqh4oi');
10
+ }
11
 
12
+ if(session_id() == '') {
13
+ session_start();
 
 
 
14
  }
15
 
16
  require_once DRBBACKUP_BASE_DIR . "/libs/error.class.php";
23
  add_action('wp_ajax_wpadm_local_backup', array('wpadm_wp_full_backup_dropbox', 'local_backup') );
24
  add_action('wp_ajax_wpadm_dropbox_create', array('wpadm_wp_full_backup_dropbox', 'dropbox_backup_create') );
25
  add_action('wp_ajax_set_user_mail', array('wpadm_wp_full_backup_dropbox', 'setUserMail') );
 
26
  add_action('wp_ajax_saveSetting', array('wpadm_wp_full_backup_dropbox', 'saveSetting') );
27
 
28
 
29
  add_action('admin_post_wpadm_delete_backup', array('wpadm_wp_full_backup_dropbox', 'delete_backup') );
30
  add_action('admin_post_dropboxConnect', array('wpadm_wp_full_backup_dropbox', 'dropboxConnect') );
 
 
 
31
 
32
  add_action('admin_post_wpadm_download', array('wpadm_wp_full_backup_dropbox', 'download') );
33
  add_action('init', array('wpadm_wp_full_backup_dropbox', 'init'), 10 );
34
 
35
+ @set_time_limit(0);
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  class wpadm_wp_full_backup_dropbox extends wpadm_class {
38
 
 
 
39
  const MIN_PASSWORD = 6;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  public static function init()
41
  {
42
  parent::$plugin_name = 'dropbox-backup';
46
 
47
  static function include_admins_script()
48
  {
49
+ wp_enqueue_style('css-admin-wpadm', plugins_url( "/template/css/admin-style-wpadm.css", dirname( __FILE__ )) );
50
+ wp_enqueue_script( 'js-admin-wpadm', plugins_url( "/template/js/admin-wpadm.js", dirname( __FILE__ ) ) );
51
+ wp_enqueue_script( 'postbox' );
 
 
 
 
52
  }
53
 
54
  public static function setUserMail()
55
  {
56
  if (isset($_POST['email'])) {
57
+ $email = trim($_POST['email']);
58
  $mail = get_option(PREFIX_BACKUP_ . "email");
59
  if ($mail) {
60
  add_option(PREFIX_BACKUP_ . "email", $email);
67
  }
68
  public static function saveSetting()
69
  {
70
+ if (isset($_POST['is_admin'])) {
71
+ $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
72
+ if ($dropbox_options) {
73
+ $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
+ $dropbox_options['is_admin'] = (int) $_POST['is_admin'];
76
+ update_option(PREFIX_BACKUP_ . 'dropbox-setting', base64_encode( serialize( $dropbox_options ) ) );
77
  }
 
 
 
 
78
  }
79
 
80
  public static function local_backup()
81
  {
82
+ require_once DRBBACKUP_BASE_DIR. "/modules/class-wpadm-core.php";
 
 
83
  @session_write_close();
84
  parent::$type = 'full';
85
  if (file_exists(WPAdm_Core::getTmpDir() . "/logs2")) {
86
+ unlink(WPAdm_Core::getTmpDir() . "/logs2");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  }
88
+ $backup = new WPAdm_Core(array('method' => "local_backup", 'params' => array('optimize' => 1, 'limit' => 0, 'time' => @$_POST['time'], 'types' => array('db', 'files') )), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
89
+ $res = $backup->getResult()->toArray();
90
+ $res['md5_data'] = md5( print_r($res, 1) );
91
+ $res['name'] = $backup->name;
92
+ $res['time'] = $backup->time;
93
+ $res['type'] = 'local';
94
+ $res['counts'] = count($res['data']);
95
 
96
  @session_start();
97
  echo json_encode($res);
98
  wp_die();
99
 
100
  }
 
101
  public static function getLog()
102
  {
 
103
  @session_write_close();
104
+ @session_start();
105
  require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
 
106
  $backup = new WPAdm_Core(array('method' => "local"), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
107
  $log = WPAdm_Core::getLog();
108
  $log2 = WPAdm_Core::getTmpDir() . "/logs2";
109
+ if (file_exists($log2)) {
 
110
  $text = @file_get_contents($log2);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  file_put_contents($log2, $log);
112
  $log = str_replace($text, "", $log);
113
  } else {
115
  }
116
  $log = explode("\n", $log);
117
  krsort($log);
118
+ echo json_encode(array('log' => $log));
119
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  exit;
121
  }
122
  public static function restore_backup()
125
  @session_write_close();
126
  parent::$type = 'full';
127
  if (file_exists(WPAdm_Core::getTmpDir() . "/logs2")) {
128
+ unlink(WPAdm_Core::getTmpDir() . "/logs2");
129
  }
130
+ $name_backup = isset($_POST['name']) ? trim($_POST['name']) : "";
131
  $backup = new WPAdm_Core(array('method' => "local_restore", 'params' => array('types' => array('files', 'db'), 'name_backup' => $name_backup )), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
132
  $res = $backup->getResult()->toArray();
133
  @session_start();
140
  @session_write_close();
141
  $log_class = new WPAdm_Core(array('method' => "local"), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
142
  if (file_exists(WPAdm_Core::getTmpDir() . "/logs2")) {
143
+ unlink(WPAdm_Core::getTmpDir() . "/logs2");
144
  }
145
  if (file_exists(WPAdm_Core::getTmpDir() . "/log.log")) {
146
+ unlink(WPAdm_Core::getTmpDir() . "/log.log");
147
  }
148
+ WPAdm_Core::log( langWPADM::get('Start Restore from Dropbox cloud' , false) );
149
+ $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
150
+ if ($dropbox_options) {
151
  require_once DRBBACKUP_BASE_DIR. "/modules/dropbox.class.php";
152
+ $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
153
  $folder_project = self::getNameProject();
154
  $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
155
  if ($dropbox->isAuth()) {
156
+ $name_backup = isset($_POST['name']) ? trim($_POST['name']) : "";
157
+ $dir_backup = ABSPATH . "wpadm_backups/$name_backup";
158
+ WPAdm_Core::mkdir($dir_backup);
159
+ $files = $dropbox->listing("$folder_project/$name_backup");
160
+ if (isset($files['items'])) {
161
+ $n = count($files['items']);
162
+ for($i = 0; $i < $n; $i++) {
163
+ $res = $dropbox->downloadFile("$folder_project/$name_backup/{$files['items'][$i]['name']}", "$dir_backup/{$files['items'][$i]['name']}");
164
+ if ($res != "$dir_backup/{$files['items'][$i]['name']}" && isset($res['text'])) {
165
+ WPAdm_Core::log(langWPADM::get('Error: ' , false) . $res['text'] );
166
+ } else {
167
+ $log = str_replace('%s', $files['items'][$i]['name'], langWPADM::get('Download file (%s) with Dropbox' , false) );
168
+ WPAdm_Core::log($log);
 
 
 
 
 
 
 
 
 
 
169
  }
 
 
 
 
170
  }
171
+ parent::$type = 'full';
172
+ $backup = new WPAdm_Core(array('method' => "local_restore", 'params' => array('types' => array('files', 'db'), 'name_backup' => $name_backup )), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
173
+ $res = $backup->getResult()->toArray();
174
+ WPAdm_Core::rmdir($dir_backup);
175
  }
176
  } else {
177
+ WPAdm_Core::log( langWPADM::get('Error: Auth to Dropbox is empty, please repeat connection' , false) );
 
 
178
  }
179
  } else {
180
+ WPAdm_Core::log( langWPADM::get('Error: Auth to Dropbox is not connections' , false) );
181
  }
182
  @session_start();
183
  echo json_encode($res);
186
  public static function download()
187
  {
188
  if (isset($_REQUEST['backup'])) {
 
189
  require_once DRBBACKUP_BASE_DIR . "/class-wpadm-core.php";
190
  require_once DRBBACKUP_BASE_DIR . '/modules/pclzip.lib.php';
191
  $backup = new WPAdm_Core(array('method' => "local"), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
192
+ $filename = $_REQUEST['backup'] . ".zip";
193
  $file = WPAdm_Core::getTmpDir() . "/" . $filename;
194
  if (file_exists($file)) {
195
+ unlink($file);
196
  }
197
  $archive = new PclZip($file);
198
+ $dir_backup = ABSPATH . 'wpadm_backups/' . $_REQUEST['backup'];
199
 
200
  $backups = array('data' => array(), 'md5' => '');
201
  if (is_dir($dir_backup)) {
203
  $dir_open = opendir($dir_backup);
204
  while($d = readdir($dir_open)) {
205
  if ($d != '.' && $d != '..' && file_exists($dir_backup . "/$d") && substr($d, -3) != "php") {
206
+ $archive->add($dir_backup . "/$d", PCLZIP_OPT_REMOVE_PATH, ABSPATH . 'wpadm_backups');
207
  }
208
  }
209
  }
228
  echo file_get_contents($file);
229
  fclose($df);
230
  echo ob_get_clean();
231
+ unlink($file);
232
  exit;
233
  }
234
  }
235
 
236
+ public static function delete_backup()
237
  {
238
+ if (isset($_POST['backup-type']) ) {
239
+ if ($_POST['backup-type'] == 'local') {
240
+ require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
241
+ $dir = ABSPATH . 'wpadm_backups/' . $_POST['backup-name'] ;
242
+ if (is_dir($dir)) {
243
+ WPAdm_Core::rmdir($dir);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  }
245
+ } elseif ($_POST['backup-type'] == 'dropbox') {
246
+ require_once DRBBACKUP_BASE_DIR . "/modules/dropbox.class.php";
247
+ $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
248
+ if ($dropbox_options) {
249
+ $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
250
+ $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
251
+ $folder_project = self::getNameProject();
252
+ $res = $dropbox->deleteFile("$folder_project/{$_POST['backup-name']}");
253
+ if ($res['is_deleted'] == true) {
254
 
255
+ }
256
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  }
259
+ header("Location: " . admin_url("admin.php?page=wpadm_wp_full_backup_dropbox"));
260
  }
261
 
262
  protected static function getPluginName()
275
  require_once DRBBACKUP_BASE_DIR . "/modules/dropbox.class.php";
276
  if (isset($_GET['app_key']) && isset($_GET['app_secret'])) {
277
  if (empty($_GET['app_key']) && empty($_GET['app_secret'])) {
278
+ $_GET['app_key'] = WPADM_APP_KEY;
279
+ $_GET['app_secret'] = WPADM_APP_SECRET;
 
 
 
280
  }
281
+ $dropbox = new dropbox($_GET['app_key'], $_GET['app_secret']);
282
+ $_SESSION['dropbox_key'] = $_GET['app_key'];
283
+ $_SESSION['dropbox_secret'] = $_GET['app_secret'];
284
  $_SESSION['dropbox_request_token'] = $dropbox->getRequestToken();
285
  echo '<script>window.location.href="' . $dropbox->generateAuthUrl( admin_url('admin-post.php?action=dropboxConnect') ) . '";</script>';
286
  } elseif (isset($_GET['oauth_token']) && isset($_GET['uid'])) {
287
+ $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
288
+ if ($dropbox_options) {
289
+ $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
290
+ } else {
291
+ $dropbox_options = array();
292
+ add_option(PREFIX_BACKUP_ . 'dropbox-setting', base64_encode(serialize( $dropbox_options ) ) );
293
+ }
294
  $dropbox = new dropbox(@$_SESSION['dropbox_key'], @$_SESSION['dropbox_secret']);
295
  $access_token = $dropbox->getAccessToken($_SESSION['dropbox_request_token']);
296
  $dropbox_options['app_key'] = @$_SESSION['dropbox_key'] ;
297
  $dropbox_options['app_secret'] = @$_SESSION['dropbox_secret'] ;
298
  $dropbox_options['auth_token_secret'] = $access_token;
299
+ $dropbox_options['oauth_token'] = @$_GET['oauth_token'] ;
300
+ $dropbox_options['uid'] = @$_GET['uid'] ;
301
+ update_option(PREFIX_BACKUP_ . 'dropbox-setting', base64_encode( serialize( $dropbox_options ) ) );
302
  echo '<script>
303
  if(window.opener){
304
+ window.opener.connectDropbox(null, null, "'.htmlspecialchars($access_token['oauth_token_secret']).'", "'.htmlspecialchars($access_token['oauth_token']).'", "'.htmlspecialchars($access_token['uid']).'");window.close();
305
  }else{
306
  window.location.href="' . admin_url("admin.php?page=wpadm_wp_full_backup_dropbox") . '";
307
  }
308
  </script>';
309
  echo '<script>window.close();</script>';exit;
310
  } elseif (isset($_GET['not_approved'])) {
311
+ if( $_GET['not_approved'] == 'true' ){
312
  echo '<script>window.close();</script>';exit;
313
  }
314
  } else {
315
+ echo langWPADM::get('Error App Key Or App Secret is empty' , false);
316
  }
317
  exit;
318
  }
319
 
320
  public static function dropbox_backup_create()
321
  {
 
322
  require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
323
+ @session_write_close();
 
 
324
  $log = new WPAdm_Core(array('method' => "local"), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
325
  if (file_exists(WPAdm_Core::getTmpDir() . "/logs2")) {
326
+ unlink(WPAdm_Core::getTmpDir() . "/logs2");
327
  }
328
+ $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
329
+ $send_to_dropbox = true;
 
 
 
 
 
 
 
 
330
  if ($dropbox_options) {
331
+ $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
332
+ if (!isset($dropbox_options['app_key'])) {
333
+ WPAdm_Core::log( langWPADM::get('Error: "App Key" is not exist. You cannot make Auth in Dropbox cloud without "App Key". Please, type your "App Key" in the Settings form. This data can be found at your Dropbox account.' , false) );
334
+ $send_to_dropbox = false;
335
  }
336
+ if (!isset($dropbox_options['app_secret'])) {
337
+ WPAdm_Core::log( langWPADM::get('Error: "App Secret" is not exist. You cannot make Auth in Dropbox cloud without "App Secret". Please, type your "App Secret" in the Settings form. This data can be found at your Dropbox account.' , false) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
338
  $send_to_dropbox = false;
339
  }
340
+ if (!isset($dropbox_options['oauth_token'])) {
341
+ WPAdm_Core::log( langWPADM::get('Error: "Token" is not exist. Files cannot be sent to Dropbox cloud. Please, test your connection within Settings form.' , false) );
342
+ $send_to_dropbox = false;
 
 
 
 
 
 
343
  }
344
+ } else {
345
+ WPAdm_Core::log(langWPADM::get('Error: "App Key" && "App Secret" is not exist. ' , false));
346
+ $res['type'] = 'local';
347
+ $send_to_dropbox = false;
348
+ }
349
+
350
+ if ($send_to_dropbox) {
351
+ parent::$type = 'full';
352
+ $backup_local = new WPAdm_Core(array('method' => "local_backup", 'params' => array('optimize' => 1, 'limit' => 0, 'time' => @$_POST['time'], 'types' => array('db', 'files') )), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
353
+ $res = $backup_local->getResult()->toArray();
354
+ $res['md5_data'] = md5( print_r($res, 1) );
355
+ $res['name'] = $backup_local->name;
356
+ $res['time'] = $backup_local->time;
357
+ $res['type'] = 'dropbox';
358
+ $res['counts'] = count($res['data']);
359
+ unset($backup);
360
+ $folder_project = self::getNameProject();
361
+ $backup = new WPAdm_Core(array('method' => "send-to-dropbox",
362
+ 'params' => array('files' => $res['data'],
363
+ 'access_details' => array('key' => $dropbox_options['app_key'],
364
+ 'secret' => $dropbox_options['app_secret'],
365
+ 'token' => $dropbox_options['auth_token_secret'],
366
+ 'dir' => $res['name'],
367
+ 'folder' => $folder_project),
368
+ )
369
+ ),
370
+ 'full_backup_dropbox', WPAdm_Core::$pl_dir) ;
371
+ $result_send = $backup->getResult()->toArray();
372
+ if ($result_send['result'] == 'error') {
373
  $res = array();
374
+ $res['error'] = $result_send['error'];
375
+ $res['result'] = 'error';
376
+ @rename(WPAdm_Core::getTmpDir() . "/logs2", WPAdm_Core::getTmpDir() . "/logs_error_" . $backup_local->time);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377
  }
378
+
379
+ WPAdm_Core::rmdir( ABSPATH . "wpadm_backups/{$res['name']}");
 
 
 
380
  }
381
  @session_start();
382
  echo json_encode($res);
386
  {
387
  $folder_project = str_ireplace( array("http://", "https://"), '', home_url() );
388
  $folder_project = str_ireplace( array( "-", '/', '.'), '_', $folder_project );
 
 
 
389
  return $folder_project;
390
  }
391
 
392
+
393
  public static function wpadm_show_backup()
394
  {
395
+
396
  require_once DRBBACKUP_BASE_DIR. "/modules/dropbox.class.php";
397
  parent::$type = 'full';
398
+ $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
 
 
 
399
  if ($dropbox_options) {
400
+ $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
401
  if (isset($dropbox_options['app_key']) && isset($dropbox_options['app_secret']) && isset($dropbox_options['auth_token_secret'])) {
402
  $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
403
  $folder_project = self::getNameProject();
404
  $backups = $dropbox->listing($folder_project);
405
  $n = count($backups['items']);
406
  $data['data'] = array();
 
407
  for($i = 0; $i < $n; $i++) {
408
+ $backup = $dropbox->listing($folder_project . "/" . $backups['items'][$i]['name']);
409
+ $data['data'][$i]['name'] = $backups['items'][$i]['name'];
410
+ $data['data'][$i]['size'] = (int)$backup['size'] * 1024 * 1024;
411
+ $data['data'][$i]['dt'] = parent::getDateInName($backups['items'][$i]['name']);
412
+ $data['data'][$i]['count'] = count($backup['items']);
413
+ $data['data'][$i]['type'] = 'dropbox';
414
+ $k = $data['data'][$i]['count'];
415
+ $data['data'][$i]['files'] = '[';
416
+ for($j = 0; $j < $k; $j++) {
417
+ $data['data'][$i]['files'] .= $backup['items'][$i]['name'] . ',';
 
 
 
 
 
 
 
 
418
  }
419
  }
420
  }
421
  }
 
 
 
 
 
 
 
 
 
422
  $data_local = parent::read_backups();
423
  if (isset($data['data'])) {
424
  $data['data'] = array_merge($data_local['data'], $data['data']);
426
  } else {
427
  $data = $data_local;
428
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
429
  $show = !get_option('wpadm_pub_key') && is_super_admin();
430
  $error = parent::getError(true);
 
 
 
431
  $msg = parent::getMessage(true);
 
432
  $base_path = DRBBACKUP_BASE_DIR ;
 
 
 
 
 
 
 
 
 
433
  ob_start();
434
  require_once $base_path . DIRECTORY_SEPARATOR . "template" . DIRECTORY_SEPARATOR . "wpadm_show_backup.php";
435
  echo ob_get_clean();
436
  }
437
 
438
+
439
  public static function draw_menu()
440
  {
441
  $show = true;
442
+ $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
443
+ if ($dropbox_options) {
444
+ $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
445
+ }
446
  if ( ( isset($dropbox_options['is_admin']) && $dropbox_options['is_admin'] == 1 ) || !isset($dropbox_options['is_admin']) ) {
447
  if (!is_admin() || !is_super_admin()) {
448
  $show = false;
449
  }
 
 
 
 
450
  }
451
  if ($show) {
452
  $menu_position = '1.9998887771';
453
+ if(self::checkInstallWpadmPlugins()) {
454
  $page = add_menu_page(
455
  'WPAdm',
456
  'WPAdm',
467
  'read',
468
  'wpadm_wp_full_backup_dropbox',
469
  array('wpadm_wp_full_backup_dropbox', 'wpadm_show_backup')
470
+ );
471
+ } else {
472
  $page = add_menu_page(
473
  'Dropbox Full Backup',
474
  'Dropbox Full Backup',
486
  'read',
487
  'wpadm_plugins',
488
  'wpadm_plugins'
489
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
490
  }
 
 
 
 
491
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
492
  }
 
493
  }
494
  }
495
  }
methods/class-wpadm-method-backup-delete.php CHANGED
@@ -1,39 +1,28 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
-
6
- /**
7
- * Delete backup
8
- * Class WPAdm_Method_Backup_Delete
9
- */
10
- if (!class_exists('WPAdm_Method_Backup_Delete')) {
11
- class WPAdm_Method_Backup_Delete extends WPAdm_Method_Class {
12
- public function getResult()
13
- {
14
- $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
15
- $dropbox_options = wpadm_wp_full_backup_dropbox::getSettings();
16
- if ($dropbox_options) {
17
- if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
18
- $backup_dir = $dropbox_options['backup_folder'];
19
- }
20
- }
21
- $backups_dir = realpath($backup_dir . '/' . $this->params['name']);
22
- if(strpos($backups_dir, DIRECTORY_SEPARATOR . 'DROPBOX_BACKUP_DIR_NAME' . DIRECTORY_SEPARATOR) === false || !is_dir($backups_dir)) {
23
- $this->result->setResult = WPAdm_result::WPADM_RESULT_ERROR;
24
- $this->result->setError('Wrong name backup');
25
- } else {
26
- if (is_dir($backups_dir)) {
27
- WPAdm_Core::rmdir($backups_dir);
28
- if (!is_dir($backups_dir)) {
29
- $this->result->setResult = WPAdm_result::WPADM_RESULT_SUCCESS;
30
- } else {
31
- $this->result->setResult = WPAdm_result::WPADM_RESULT_ERROR;
32
- $this->result->setError('Failed to remove backup');
33
- }
34
- }
35
- }
36
- return $this->result;
37
- }
38
- }
39
  }
1
+ <?php
2
+ /**
3
+ * Delete backup
4
+ * Class WPAdm_Method_Backup_Delete
5
+ */
6
+ if (!class_exists('WPAdm_Method_Backup_Delete')) {
7
+ class WPAdm_Method_Backup_Delete extends WPAdm_Method_Class {
8
+ public function getResult()
9
+ {
10
+ $backups_dir = realpath(ABSPATH . '/wpadm_backups/' . $this->params['name']);
11
+ if(strpos($backups_dir, DIRECTORY_SEPARATOR . 'wpadm_backups' . DIRECTORY_SEPARATOR) === false || !is_dir($backups_dir)) {
12
+ $this->result->setResult = WPAdm_result::WPADM_RESULT_ERROR;
13
+ $this->result->setError('Wrong name backup');
14
+ } else {
15
+ if (is_dir($backups_dir)) {
16
+ WPAdm_Core::rmdir($backups_dir);
17
+ if (!is_dir($backups_dir)) {
18
+ $this->result->setResult = WPAdm_result::WPADM_RESULT_SUCCESS;
19
+ } else {
20
+ $this->result->setResult = WPAdm_result::WPADM_RESULT_ERROR;
21
+ $this->result->setError('Failed to remove backup');
22
+ }
23
+ }
24
+ }
25
+ return $this->result;
26
+ }
27
+ }
 
 
 
 
 
 
 
 
 
 
 
28
  }
methods/class-wpadm-method-backup-list.php CHANGED
@@ -1,55 +1,45 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
- /**
6
- * Return a list of backups
7
- * Class WPAdm_Method_Exec
8
- */
9
- if (!class_exists('WPAdm_Method_Backup_List')) {
10
- class WPAdm_Method_Backup_List extends WPAdm_Method_Class {
11
- public function getResult()
12
- {
13
- $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
14
- $dropbox_options = wpadm_wp_full_backup_dropbox::getSettings();
15
- if ($dropbox_options) {
16
- if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
17
- $backup_dir = $dropbox_options['backup_folder'];
18
- }
19
- }
20
- $backups_dir = $backup_dir . '/';
21
- $dirs = glob($backups_dir . '*');
22
-
23
- $backups = array();
24
- foreach($dirs as $dir) {
25
- if (preg_match("|(.*)\-(.*)\-(.*)|", $dir, $mm)) {
26
- $tmp = explode('/', $dir);
27
- $name = array_pop($tmp);
28
- list($y,$m,$d, $h,$i) = explode('_', $mm[3]);
29
- $dt = "$y-$m-$d $h:$i";
30
- $backup = array(
31
- 'name' => $name,
32
- 'type' => $mm[2],
33
- 'dt' => $dt,
34
- );
35
- $files = glob($dir . '/*.zip');
36
- $size = 0;
37
- foreach($files as $k=>$v) {
38
- $size += (int)filesize($v);
39
- $files[$k] = str_replace(ABSPATH, '', $v);
40
- }
41
- $backup['files'] = $files;
42
- $backup['size'] = $size;
43
- if ($size > 0) {
44
- $backups[] = $backup;
45
- }
46
-
47
- }
48
- }
49
- $this->result->setData($backups);
50
- $this->result->setResult(WPAdm_result::WPADM_RESULT_SUCCESS);
51
- return $this->result;
52
- }
53
-
54
- }
55
  }
1
+ <?php
2
+ /**
3
+ * Return a list of backups
4
+ * Class WPAdm_Method_Exec
5
+ */
6
+ if (!class_exists('WPAdm_Method_Backup_List')) {
7
+ class WPAdm_Method_Backup_List extends WPAdm_Method_Class {
8
+ public function getResult()
9
+ {
10
+ $backups_dir = ABSPATH . '/wpadm_backups/';
11
+ $dirs = glob($backups_dir . '*');
12
+
13
+ $backups = array();
14
+ foreach($dirs as $dir) {
15
+ if (preg_match("|(.*)\-(.*)\-(.*)|", $dir, $mm)) {
16
+ $tmp = explode('/', $dir);
17
+ $name = array_pop($tmp);
18
+ list($y,$m,$d, $h,$i) = explode('_', $mm[3]);
19
+ $dt = "$y-$m-$d $h:$i";
20
+ $backup = array(
21
+ 'name' => $name,
22
+ 'type' => $mm[2],
23
+ 'dt' => $dt,
24
+ );
25
+ $files = glob($dir . '/*.zip');
26
+ $size = 0;
27
+ foreach($files as $k=>$v) {
28
+ $size += (int)filesize($v);
29
+ $files[$k] = str_replace(ABSPATH, '', $v);
30
+ }
31
+ $backup['files'] = $files;
32
+ $backup['size'] = $size;
33
+ if ($size > 0) {
34
+ $backups[] = $backup;
35
+ }
36
+
37
+ }
38
+ }
39
+ $this->result->setData($backups);
40
+ $this->result->setResult(WPAdm_result::WPADM_RESULT_SUCCESS);
41
+ return $this->result;
42
+ }
43
+
44
+ }
 
 
 
 
 
 
 
 
 
 
45
  }
methods/class-wpadm-method-backup.php CHANGED
@@ -1,506 +1,451 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
-
6
- /**
7
- * Бэкап сайта
8
- * Class WPadm_Method_Backup
9
- */
10
- if (!class_exists('WPadm_Method_Backup')) {
11
- class WPadm_Method_Backup extends WPAdm_Method_Class {
12
- /**
13
- * Уникальный идентификатор текущего объекта
14
- * @var String
15
- */
16
- private $id;
17
-
18
- /**
19
- * Unixtimestamp, когда был запущен метод
20
- * @var Int
21
- */
22
- private $stime;
23
-
24
- /**
25
- * @var WPAdm_Queue
26
- */
27
- private $queue;
28
-
29
- /**
30
- * @var string
31
- */
32
- private $dir;
33
-
34
- /**
35
- * @var string
36
- */
37
- private $tmp_dir;
38
-
39
- /**
40
- * Тип бэкапа
41
- * @var string [full|db]
42
- */
43
- private $type = 'full';
44
-
45
- private $name = '';
46
-
47
- public function __construct($params) {
48
- parent::__construct($params);
49
- $this->init(
50
- array(
51
- 'id' => uniqid('wpadm_method_backup__'),
52
- 'stime' => time(),
53
- 'type' => $params['type'],
54
- )
55
- );
56
-
57
- $name = get_option('siteurl');
58
-
59
- $name = str_replace("http://", '', $name);
60
- $name = str_replace("https://", '', $name);
61
- $name = preg_replace("|\W|", "_", $name);
62
- $name = str_ireplace( array( 'Ä', 'ä', 'Ö', 'ö', 'ß', 'Ü', 'ü', 'å'),
63
- array('ae', 'ae', 'oe', 'oe', 's', 'ue', 'ue', 'a'),
64
- $name );
65
- $name .= '-' . $this->type . '-' . date("Y_m_d_H_i");
66
- $this->name = $name;
67
-
68
- // папка для бэкапа
69
- $this->dir = DROPBOX_BACKUP_DIR_BACKUP . '/' . $this->name;
70
- $error = WPAdm_Core::mkdir(DROPBOX_BACKUP_DIR_BACKUP);
71
- if (!empty($error)) {
72
- $this->result->setError($error);
73
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
74
- }
75
- $error = WPAdm_Core::mkdir($this->dir);
76
- if (!empty($error)) {
77
- $this->result->setError($error);
78
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
79
- }
80
- }
81
-
82
- public function getResult()
83
- {
84
- $errors = array();
85
-
86
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_SUCCESS);
87
- $this->result->setError('');
88
-
89
- @unlink(dirname(__FILE__) . '/../tmp/log.log');
90
-
91
- WPAdm_Core::log('Start backup create');
92
- WPAdm_Core::log('Create dump Data Base');
93
-
94
- $mysql_dump_file = DROPBOX_BACKUP_DIR_BACKUP . '/mysqldump.sql';
95
- if (file_exists($mysql_dump_file)) {
96
- unlink($mysql_dump_file);
97
- }
98
- $wp_mysql_params = $this->getWpMysqlParams();
99
-
100
- if ( isset($this->params['repair']) && ( $this->params['repair'] == 1 ) ) {
101
- if ( WPAdm_Running::is_stop() ) {
102
- if (!class_exists('WPAdm_Mysqldump')) {
103
- require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-mysqldump.php';
104
- }
105
-
106
- $mysql = new WPAdm_Mysqldump();
107
- $mysql->host = $wp_mysql_params['host'];
108
- $mysql->user = $wp_mysql_params['user'];
109
- $mysql->password = $wp_mysql_params['password'];
110
- try {
111
- $mysql->repair($wp_mysql_params['db']);
112
- unset($mysql);
113
- } catch (Exception $e) {
114
- $this->result->setError( $e->getMessage() );
115
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
116
- return $this->result;
117
- }
118
- unset($mysql);
119
- }
120
- }
121
-
122
- if (isset($this->params['optimize']) && ($this->params['optimize']==1)) {
123
- WPAdm_Core::log(__('Optimize Database Tables','dropbox-backup'));
124
- if (!class_exists('WPAdm_Mysqldump')) {
125
- require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-mysqldump.php';
126
- }
127
- $mysql = new WPAdm_Mysqldump();
128
- $mysql->host = $wp_mysql_params['host'];
129
- $mysql->user = $wp_mysql_params['user'];
130
- $mysql->password = $wp_mysql_params['password'];
131
- try {
132
- $mysql->optimize($wp_mysql_params['db']);
133
- } catch (Exception $e) {
134
- $this->result->setError( $e->getMessage() );
135
- $this->result->setResult( WPAdm_Result::WPADM_RESULT_ERROR );
136
- return $this->result;
137
- }
138
- unset($mysql);
139
- }
140
-
141
- if (!class_exists('WPAdm_Mysqldump')) {
142
- require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-mysqldump.php';
143
- }
144
- $mysql = new WPAdm_Mysqldump();
145
- $mysql->host = $wp_mysql_params['host'];
146
- $mysql->user = $wp_mysql_params['user'];
147
- $mysql->password = $wp_mysql_params['password'];
148
-
149
- try {
150
- $mysql->mysqldump($wp_mysql_params['db'], $mysql_dump_file);
151
- } catch (Exception $e) {
152
- $this->result->setError( $e->getMessage() );
153
- $this->result->setResult( WPAdm_Result::WPADM_RESULT_ERROR );
154
- return $this->result;
155
- }
156
- unset($mysql);
157
-
158
- if (0 == (int)filesize($mysql_dump_file)) {
159
- $log = str_replace(array('%domain', '%dir'), array(SITE_HOME, DROPBOX_BACKUP_DIR_BACKUP), __('Website "%domain" returned an error during database dump creation: Database-Dump file is emplty. To solve this problem, please check permissions to folder: "%dir".','dropbox-backup') );
160
- $errors[] = $log;
161
- WPAdm_Core::log($log);
162
- $this->result->setError( $log );
163
- $this->result->setResult( WPAdm_Result::WPADM_RESULT_ERROR );
164
- return $this->result;
165
- } else {
166
- $size_dump = round( (filesize($mysql_dump_file) / 1024 / 1024) , 2);
167
- $log = str_replace("%size", $size_dump , __('Database Dump was successfully created ( %size Mb) : ','dropbox-backup') ) ;
168
- WPAdm_Core::log($log . $mysql_dump_file);
169
- }
170
-
171
-
172
- WPAdm_Core::log('Start Created List Files');
173
- if ($this->type == 'full') {
174
- $files = $this->createListFilesForArchive();
175
- } else {
176
- $files = array();
177
- }
178
- if (file_exists($mysql_dump_file) && filesize($mysql_dump_file) > 0) {
179
- $files[] = $mysql_dump_file;
180
- }
181
-
182
- if (empty($files)) {
183
- $errors[] = 'Empty list files';
184
- }
185
-
186
- $files2 = array();
187
- $files2[0] = array();
188
- $i = 0;
189
- $size = 0;
190
- foreach($files as $f) {
191
- if ($size > 170000) {//~170kbyte
192
- $i ++;
193
- $size = 0;
194
- $files2[$i] = array();
195
- }
196
- $f_size =(int)filesize($f);
197
- if ($f_size == 0 || $f_size > 1000000) {
198
- WPAdm_Core::log('file '. $f .' size ' . $f_size);
199
- }
200
- $size += $f_size;
201
- $files2[$i][] = $f;
202
- }
203
-
204
- WPAdm_Core::log('Сreated List Files is successfully');
205
- //$this->queue->clear();
206
- WPAdm_Core::log('Start archived files');
207
- if (!class_exists('WPAdm_Archive')) {
208
- require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-archive.php';
209
- }
210
- foreach($files2 as $files) {
211
- $af = $this->getArchiveName($to_file);
212
- $archive = new WPAdm_Archive($af, $to_file . '.md5');
213
- $archive->setRemovePath(ABSPATH);
214
- if ( !file_exists( $af ) ) {
215
- WPAdm_Core::log(__('Create part ','dropbox-backup') . basename( $af ) );
216
- }
217
-
218
- if (file_exists($af) && filesize($af) > 900000) {
219
- $af = $this->getNextArchiveName($to_file);
220
- unset($archive);
221
- if ( !file_exists( $af ) ) {
222
- WPAdm_Core::log(__('Create part ','dropbox-backup') . basename( $af ) );
223
- }
224
- $archive = new WPAdm_Archive($af, $to_file . '.md5');
225
- $archive->setRemovePath( ABSPATH );
226
- }
227
- $files_str = implode(',', $files);
228
- $res = $archive->add($files_str);
229
- if ($res) {
230
-
231
- } else {
232
- $this->result->setError( $archive->error );
233
- $this->result->setResult( WPAdm_Result::WPADM_RESULT_ERROR );
234
- return $this->result;
235
- }
236
- }
237
- WPAdm_Core::log('End archived files');
238
-
239
- $files = glob($this->dir . '/'.$this->name . '*');
240
- $urls = array();
241
- foreach($files as $file) {
242
- $urls[] = str_replace(ABSPATH, '', $file);
243
- }
244
- $this->result->setData($urls);
245
-
246
- WPAdm_Core::rmdir(DROPBOX_BACKUP_DIR_BACKUP . '/mysqldump.sql');
247
-
248
- if ($this->params['limit'] != 0) {
249
- WPAdm_Core::log('Start deleted old backup');
250
- $files = glob(DROPBOX_BACKUP_DIR_BACKUP . '/*');
251
- if (count($files) > $this->params['limit']) {
252
- $files2 = array();
253
- foreach($files as $f) {
254
- $fa = explode('-', $f);
255
- if (count($fa) != 3) {
256
- continue;
257
- }
258
- $files2[$fa[2]] = $f;
259
-
260
- }
261
- ksort($files2);
262
- $d = count($files2) - $this->params['limit'];
263
- $del = array_slice($files2, 0, $d);
264
- foreach($del as $d) {
265
- WPAdm_Core::rmdir($d);
266
- }
267
- }
268
- WPAdm_Core::log('Finish deleted old backups');
269
- }
270
- WPAdm_Core::log('Finish create');
271
-
272
- if (!empty($errors)) {
273
- $this->result->setError(implode("\n", $errors));
274
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
275
- }
276
-
277
- return $this->result;
278
-
279
-
280
- }
281
-
282
- private function getArchiveName($name)
283
- {
284
- //WPAdm_Core::log("{$name}-*.zip");
285
- $archives = glob("{$name}-*.zip");
286
- //WPAdm_Core::log( print_r($archives, 1) );
287
- if (empty($archives)) {
288
- return "{$name}-1.zip";
289
- }
290
- $n = count($archives);
291
- $f = "{$name}-{$n}.zip";
292
- return $f;
293
- }
294
-
295
- private function getNextArchiveName($name)
296
- {
297
- //WPAdm_Core::log("{$name}-*.zip");
298
- $archives = glob("{$name}-*.zip");
299
- $n = 1 + count($archives);
300
- $a = "{$name}-{$n}.zip";
301
- //WPAdm_Core::log($a);
302
- return $a;
303
- }
304
-
305
-
306
-
307
- public function createListFilesForArchive() {
308
- $folders = array();
309
- $files = array();
310
-
311
- $files = array_merge(
312
- $files,
313
- array(
314
- // ABSPATH .'/.htaccess',
315
- ABSPATH .'/index.php',
316
- //ABSPATH .'/license.txt',
317
- //ABSPATH .'/readme.html',
318
- ABSPATH .'/wp-activate.php',
319
- ABSPATH .'/wp-blog-header.php',
320
- ABSPATH .'/wp-comments-post.php',
321
- ABSPATH .'/wp-config.php',
322
- //ABSPATH .'/wp-config-sample.php',
323
- ABSPATH .'/wp-cron.php',
324
- ABSPATH .'/wp-links-opml.php',
325
- ABSPATH .'/wp-load.php',
326
- ABSPATH .'/wp-login.php',
327
- ABSPATH .'/wp-mail.php',
328
- ABSPATH .'/wp-settings.php',
329
- ABSPATH .'/wp-signup.php',
330
- ABSPATH .'/wp-trackback.php',
331
- ABSPATH .'/xmlrpc.php',
332
- )
333
- );
334
-
335
- if ( file_exists(ABSPATH . '.htaccess') ) {
336
- $files = array_merge( $files, array( ABSPATH . '.htaccess' ) );
337
- }
338
- if ( file_exists( ABSPATH . 'license.txt' ) ) {
339
- $files = array_merge( $files, array( ABSPATH . 'license.txt' ) );
340
- }
341
- if ( file_exists( ABSPATH . 'readme.html' ) ) {
342
- $files = array_merge( $files, array( ABSPATH . 'readme.html') );
343
- }
344
- if ( file_exists(ABSPATH . '.htaccess') ) {
345
- $files = array_merge( $files, array( ABSPATH . 'wp-config-sample.php' ) );
346
- }
347
-
348
- if (!empty($this->params['minus-path'])) {
349
- foreach($files as $k=>$v) {
350
- $v = str_replace(ABSPATH .'/' , '', $v);
351
- if (in_array($v, $this->params['minus-path'])) {
352
- unset($files[$k]);
353
- WPAdm_Core::log('Skip of File ' . $v);
354
- }
355
- }
356
- }
357
-
358
- $folders = array_merge(
359
- $folders,
360
- array(
361
- ABSPATH .'/wp-admin',
362
- ABSPATH .'/wp-content',
363
- ABSPATH .'/wp-includes',
364
- )
365
- );
366
- if (!empty($this->params['plus-path'])) {
367
- foreach($this->params['plus-path'] as $p) {
368
- if (empty($p)) {
369
- continue;
370
- }
371
- $p = ABSPATH .'/' . $p;
372
- if (file_exists($p)) {
373
- if (is_dir($p)) {
374
- $folders[] = $p;
375
- } else{
376
- $files[] = $p;
377
- }
378
- }
379
- }
380
- }
381
-
382
- $folders = array_unique($folders);
383
- $files = array_unique($files);
384
-
385
- foreach($folders as $folder) {
386
- if (!is_dir($folder)) {
387
- continue;
388
- }
389
- $files = array_merge($files, $this->directoryToArray($folder, true));
390
- }
391
- return $files;
392
- }
393
-
394
-
395
- private function directoryToArray($directory, $recursive) {
396
- $array_items = array();
397
-
398
- $d = str_replace(ABSPATH . '/', '', $directory);
399
- // пропускаем ненужные директории
400
-
401
- if (
402
- in_array($d, $this->params['minus-path'])
403
- ) {
404
- WPAdm_Core::log('Skip of Folder ' . $directory);
405
- return array();
406
- }
407
-
408
- $d = str_replace('\\', '/', $d);
409
- $tmp = explode('/', $d);
410
- if (function_exists('mb_strtolower')) {
411
- $d1 = mb_strtolower($tmp[0]);
412
- } else {
413
- $d1 = strtolower($tmp[0]);
414
- }
415
-
416
- unset($tmp[0]);
417
- if (function_exists('mb_strtolower')) {
418
- $d2 = mb_strtolower(implode('/', $tmp));
419
- } else {
420
- $d2 = strtolower(implode('/', $tmp));
421
- }
422
- // if (strpos($d1, 'cache') !== false || ($d1 == 'wp-includes' && strpos($d2, 'cache') !== false)) {
423
- // if (($d1 == 'wp-includes' && strpos($d2, 'cache') !== false)
424
- // || ($d1 == 'wp-content' || !in_array($tmp[0], array('plugins', 'themes')))
425
- if (strpos($d2, 'cache') !== false
426
- && !in_array($tmp[0], array('plugins', 'themes'))
427
- ) {
428
- WPAdm_Core::log('Skip of Cache-Folder ' . $directory);
429
- return array();
430
- }
431
- if(strpos($directory, 'wpadm_backups') !== false) {
432
- return array();
433
- }
434
-
435
- if ($handle = opendir($directory)) {
436
- while (false !== ($file = readdir($handle))) {
437
- if ($file != "." && $file != "..") {
438
- if (is_dir($directory. "/" . $file)) {
439
- if($recursive) {
440
- $array_items = array_merge($array_items, $this->directoryToArray($directory. "/" . $file, $recursive));
441
- }
442
-
443
- $file = $directory . "/" . $file;
444
- if (!is_dir($file)) {
445
- $ff = preg_replace("/\/\//si", "/", $file);
446
- $f = str_replace(ABSPATH . '/', '', $ff);
447
- // Skip files
448
- if (!in_array($f, $this->params['minus-path'])) {
449
- $array_items[] = $ff;
450
- } else {
451
- WPAdm_Core::log('Skip of File ' . $ff);
452
- }
453
- }
454
- } else {
455
- $file = $directory . "/" . $file;
456
- if (!is_dir($file)) {
457
- $ff = preg_replace("/\/\//si", "/", $file);
458
- $f = str_replace(ABSPATH . '/', '', $ff);
459
- // skip folders
460
- if (!in_array($f, $this->params['minus-path'])) {
461
- $array_items[] = $ff;
462
- } else {
463
- WPAdm_Core::log('Skip of Folder ' . $ff);
464
- }
465
- }
466
- }
467
- }
468
- }
469
- closedir($handle);
470
- }
471
- return $array_items;
472
- }
473
-
474
-
475
- /*
476
- * get access to mysql from params WP
477
- * return Array()
478
- */
479
- private function getWpMysqlParams()
480
- {
481
- $db_params = array(
482
- 'password' => 'DB_PASSWORD',
483
- 'db' => 'DB_NAME',
484
- 'user' => 'DB_USER',
485
- 'host' => 'DB_HOST',
486
- );
487
-
488
- $r = "/define\('(.*)', '(.*)'\)/";
489
- preg_match_all($r, file_get_contents(ABSPATH . "wp-config.php"), $m);
490
- $params = array_combine($m[1], $m[2]);
491
- foreach($db_params as $k=>$p) {
492
- $db_params[$k] = $params[$p];
493
- }
494
- return $db_params;
495
- }
496
-
497
-
498
- private function init(array $conf) {
499
- //todo: norm
500
- $this->id = $conf['id'];
501
- $this->stime = $conf['stime'];
502
- //$this->queue = new WPAdm_Queue($this->id);
503
- $this->type = $conf['type'];
504
- }
505
- }
506
  }
1
+ <?php
2
+ /**
3
+ * Бэкап сайта
4
+ * Class WPadm_Method_Backup
5
+ */
6
+ if (!class_exists('WPadm_Method_Backup')) {
7
+ class WPadm_Method_Backup extends WPAdm_Method_Class {
8
+ /**
9
+ * Уникальный идентификатор текущего объекта
10
+ * @var String
11
+ */
12
+ private $id;
13
+
14
+ /**
15
+ * Unixtimestamp, когда был запущен метод
16
+ * @var Int
17
+ */
18
+ private $stime;
19
+
20
+ /**
21
+ * @var WPAdm_Queue
22
+ */
23
+ private $queue;
24
+
25
+ /**
26
+ * @var string
27
+ */
28
+ private $dir;
29
+
30
+ /**
31
+ * @var string
32
+ */
33
+ private $tmp_dir;
34
+
35
+ /**
36
+ * Тип бэкапа
37
+ * @var string [full|db]
38
+ */
39
+ private $type = 'full';
40
+
41
+ private $name = '';
42
+
43
+ public function __construct($params) {
44
+ parent::__construct($params);
45
+ $this->init(
46
+ array(
47
+ 'id' => uniqid('wpadm_method_backup__'),
48
+ 'stime' => time(),
49
+ 'type' => $params['type'],
50
+ )
51
+ );
52
+
53
+
54
+ //папка для временных файлов
55
+ // $this->tmp_dir = WPAdm_Core::getTmpDir() . '/' . $this->id;
56
+ // WPAdm_Core::mkdir($this->tmp_dir);
57
+
58
+ $name = get_option('siteurl');
59
+
60
+ $name = str_replace("http://", '', $name);
61
+ $name = str_replace("https://", '', $name);
62
+ $name = preg_replace("|\W|", "_", $name);
63
+ $name .= '-' . $this->type . '-' . date("Y_m_d_H_i");
64
+ $this->name = $name;
65
+
66
+ // папка для бэкапа
67
+ $this->dir = ABSPATH . '/wpadm_backups/' . $this->name;
68
+ WPAdm_Core::mkdir(ABSPATH . '/wpadm_backups/');
69
+ WPAdm_Core::mkdir($this->dir);
70
+ }
71
+
72
+ public function getResult()
73
+ {
74
+ $errors = array();
75
+
76
+ $this->result->setResult(WPAdm_Result::WPADM_RESULT_SUCCESS);
77
+ $this->result->setError('');
78
+
79
+
80
+ #ОТЛАДКА, нужно удалить
81
+ //todo: удалить
82
+ unlink(dirname(__FILE__) . '/../tmp/log.log');
83
+ #конец отладки
84
+
85
+ WPAdm_Core::log('Начинаем бэкап');
86
+
87
+ # СОЗДАДИМ ДАМП БД
88
+ WPAdm_Core::log('Начинаем создание дампа БД');
89
+ // добавим в очередь создание бэкапа БД и выполним
90
+ WPAdm_Core::mkdir(ABSPATH . '/wpadm_backup');
91
+ $mysql_dump_file = ABSPATH . '/wpadm_backup/mysqldump.sql';
92
+ if (file_exists($mysql_dump_file)) {
93
+ unlink($mysql_dump_file);
94
+ }
95
+ $wp_mysql_params = $this->getWpMysqlParams();
96
+
97
+ if (isset($this->params['optimize']) && ($this->params['optimize']==1)) {
98
+ WPAdm_Core::log('Оптимизцация таблиц БД');
99
+ $commandContext = new WPAdm_Command_Context();
100
+ $commandContext ->addParam('command','mysqloptimize')
101
+ ->addParam('host', $wp_mysql_params['host'])
102
+ ->addParam('db', $wp_mysql_params['db'])
103
+ ->addParam('user', $wp_mysql_params['user'])
104
+ ->addParam('password', $wp_mysql_params['password']);
105
+ $this->queue->clear()
106
+ ->add($commandContext);
107
+ unset($commandContext);
108
+ }
109
+
110
+ $commandContext = new WPAdm_Command_Context();
111
+ $commandContext ->addParam('command','mysqldump')
112
+ ->addParam('host', $wp_mysql_params['host'])
113
+ ->addParam('db', $wp_mysql_params['db'])
114
+ ->addParam('user', $wp_mysql_params['user'])
115
+ ->addParam('password', $wp_mysql_params['password'])
116
+ ->addParam('tables', '')
117
+ ->addParam('to_file', $mysql_dump_file);
118
+ $res = $this->queue->add($commandContext)
119
+ ->save()
120
+ ->execute();
121
+
122
+ if (!$res) {
123
+ WPAdm_Core::log('Дамп БД не создан('.$this->queue->getError().')');
124
+ $errors[] = 'MySQL error: '.$this->queue->getError();
125
+ } elseif (0 == (int)filesize($mysql_dump_file)) {
126
+ $errors[] = 'MySQL error: empty dump-file';
127
+ WPAdm_Core::log('Дамп БД не создан(пустой файл)');
128
+ } else {
129
+ WPAdm_Core::log('Дамп БД создан('.filesize($mysql_dump_file).'b):' . $mysql_dump_file);
130
+ }
131
+ unset($commandContext);
132
+
133
+
134
+ #ЗАРХИВИРУЕМ ФАЙЛЫ
135
+ WPAdm_Core::log('Начинаем подготовку списка файлов');
136
+ // список файлов для архивации
137
+ if ($this->type == 'full') {
138
+ $files = $this->createListFilesForArchive();
139
+ } else {
140
+ $files = array();
141
+ }
142
+ if (file_exists($mysql_dump_file) && filesize($mysql_dump_file) > 0) {
143
+ $files[] = $mysql_dump_file;
144
+ }
145
+
146
+ if (empty($files)) {
147
+ $errors[] = 'Empty list files';
148
+ }
149
+
150
+ // разабьем список файлов на списки по 170кбайт,
151
+ // чтобы разбить одну большую задачу на маленькие
152
+ $files2 = array();
153
+ $files2[0] = array();
154
+ $i = 0;
155
+ $size = 0;
156
+ foreach($files as $f) {
157
+ if ($size > 170000) {//~170kbyte
158
+ $i ++;
159
+ $size = 0;
160
+ $files2[$i] = array();
161
+ }
162
+ $f_size =(int)filesize($f);
163
+ if ($f_size == 0 || $f_size > 1000000) {
164
+ WPAdm_Core::log('file '. $f .' size ' . $f_size);
165
+ }
166
+ $size += $f_size;
167
+ $files2[$i][] = $f;
168
+ }
169
+
170
+ WPAdm_Core::log('Список файлов подготовлен');
171
+ // подготовим очередь к выполнению
172
+ $this->queue->clear();
173
+
174
+ foreach($files2 as $files) {
175
+ $commandContext = new WPAdm_Command_Context();
176
+ $commandContext ->addParam('command','archive')
177
+ ->addParam('files', $files)
178
+ ->addParam('to_file', $this->dir . '/'.$this->name)
179
+ ->addParam('max_file_size', 900000)
180
+ ->addParam('remove_path', ABSPATH);
181
+
182
+ $this->queue->add($commandContext);
183
+ unset($commandContext);
184
+ }
185
+ WPAdm_Core::log('Начинаем архивацию файлов');
186
+ // сохраним и выполним
187
+ $this->queue->save()
188
+ ->execute();
189
+ WPAdm_Core::log('Закочили архивацию файлов');
190
+
191
+ $files = glob($this->dir . '/'.$this->name . '*');
192
+ $urls = array();
193
+ foreach($files as $file) {
194
+ $urls[] = str_replace(ABSPATH, '', $file);
195
+ }
196
+ $this->result->setData($urls);
197
+
198
+
199
+ # КОПИРОВАНИЕ ФАЙЛОВ НА FTP
200
+ if (isset($this->params['storage']) && $this->params['storage']['type'] == 'ftp') {
201
+ WPAdm_Core::log('Начинаем копирование файлов на FTP');
202
+ $this->queue->clear();
203
+ $files = glob($this->dir . '/'.$this->name . '*');
204
+ //$this->getResult()->setData($files);
205
+ $ad = $this->params['storage']['access_details'];
206
+ $dir = (isset($ad['dir'])) ? $ad['dir'] : '/';
207
+ $dir = trim($dir, '/') . '/' . $this->name;
208
+ foreach($files as $file) {
209
+ $commandContext = new WPAdm_Command_Context();
210
+ $commandContext ->addParam('command','send_to_ftp')
211
+ ->addParam('file', $file)
212
+ ->addParam('host', $ad['host'])
213
+ ->addParam('port', (isset($ad['port']))? $ad['port'] : 21)
214
+ ->addParam('user', $ad['user'])
215
+ ->addParam('password', $ad['password'])
216
+ ->addParam('dir', $dir)
217
+ ->addParam('http_host', isset($ad['http_host']) ? $ad['http_host'] : '');
218
+ $this->queue->add($commandContext);
219
+ unset($commandContext);
220
+ }
221
+ $res = $this->queue->save()
222
+ ->execute();
223
+ if (!$res) {
224
+ WPAdm_Core::log('FTP: ' . $this->queue->getError());
225
+ $errors[] = 'FTP: '.$this->queue->getError();
226
+ }
227
+ WPAdm_Core::log('Закончили копирование файлов на FTP');
228
+ if (isset($this->params['storage']['remove_from_server']) && $this->params['storage']['remove_from_server'] == 1 ) {
229
+ // удаляем файлы на сервере
230
+ WPAdm_Core::log('Удаляем бэкап на сервере');
231
+ WPAdm_Core::rmdir($this->dir);
232
+ }
233
+ }
234
+
235
+ #УДАЛЕНИЕ TMP-ФАЙЛОВ
236
+ //todo: УДАЛЕНИЕ TMP-ФАЙЛОВ
237
+ WPAdm_Core::rmdir(ABSPATH.'/wpadm_backup');
238
+
239
+ #УДАЛЕНИЕ СТАРЫХ АРХИВОВ(те что не влазят в лимит)
240
+ //todo: не правмльно удаляет, если есть ооба типа бэкапа
241
+ WPAdm_Core::log('Начинаем удалять старые архивы');
242
+ if ($this->params['limit'] != 0) {
243
+ $files = glob(ABSPATH . '/wpadm_backups/*');
244
+ if (count($files) > $this->params['limit']) {
245
+ $files2 = array();
246
+ foreach($files as $f) {
247
+ $fa = explode('-', $f);
248
+ if (count($fa) != 3) {
249
+ continue;
250
+ }
251
+ $files2[$fa[2]] = $f;
252
+
253
+ }
254
+ ksort($files2);
255
+ $d = count($files2) - $this->params['limit'];
256
+ $del = array_slice($files2, 0, $d);
257
+ foreach($del as $d) {
258
+ WPAdm_Core::rmdir($d);
259
+ }
260
+ }
261
+ }
262
+ WPAdm_Core::log('Закончили удалять старые архивы');
263
+
264
+ WPAdm_Core::log('Бэкап завершен');
265
+
266
+ if (!empty($errors)) {
267
+ $this->result->setError(implode("\n", $errors));
268
+ $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
269
+ }
270
+
271
+ return $this->result;
272
+
273
+
274
+ }
275
+
276
+
277
+
278
+ public function createListFilesForArchive() {
279
+ $folders = array();
280
+ $files = array();
281
+
282
+ $files = array_merge(
283
+ $files,
284
+ array(
285
+ ABSPATH .'/.htaccess',
286
+ ABSPATH .'/index.php',
287
+ ABSPATH .'/license.txt',
288
+ ABSPATH .'/readme.html',
289
+ ABSPATH .'/wp-activate.php',
290
+ ABSPATH .'/wp-blog-header.php',
291
+ ABSPATH .'/wp-comments-post.php',
292
+ ABSPATH .'/wp-config.php',
293
+ ABSPATH .'/wp-config-sample.php',
294
+ ABSPATH .'/wp-cron.php',
295
+ ABSPATH .'/wp-links-opml.php',
296
+ ABSPATH .'/wp-load.php',
297
+ ABSPATH .'/wp-login.php',
298
+ ABSPATH .'/wp-mail.php',
299
+ ABSPATH .'/wp-settings.php',
300
+ ABSPATH .'/wp-signup.php',
301
+ ABSPATH .'/wp-trackback.php',
302
+ ABSPATH .'/xmlrpc.php',
303
+ )
304
+ );
305
+
306
+ if (!empty($this->params['minus-path'])) {
307
+ foreach($files as $k=>$v) {
308
+ $v = str_replace(ABSPATH .'/' , '', $v);
309
+ if (in_array($v, $this->params['minus-path'])) {
310
+ unset($files[$k]);
311
+ WPAdm_Core::log('Пропускаем файл ' . $v);
312
+ }
313
+ }
314
+ }
315
+
316
+ $folders = array_merge(
317
+ $folders,
318
+ array(
319
+ ABSPATH .'/wp-admin',
320
+ ABSPATH .'/wp-content',
321
+ ABSPATH .'/wp-includes',
322
+ )
323
+ );
324
+
325
+ foreach($this->params['plus-path'] as $p) {
326
+ if (empty($p)) {
327
+ continue;
328
+ }
329
+ $p = ABSPATH .'/' . $p;
330
+ if (file_exists($p)) {
331
+ if (is_dir($p)) {
332
+ $folders[] = $p;
333
+ } else{
334
+ $files[] = $p;
335
+ }
336
+ }
337
+ }
338
+
339
+ $folders = array_unique($folders);
340
+ $files = array_unique($files);
341
+
342
+ foreach($folders as $folder) {
343
+ if (!is_dir($folder)) {
344
+ continue;
345
+ }
346
+ $files = array_merge($files, $this->directoryToArray($folder, true));
347
+ }
348
+ return $files;
349
+ }
350
+
351
+
352
+ private function directoryToArray($directory, $recursive) {
353
+ $array_items = array();
354
+
355
+ $d = str_replace(ABSPATH . '/', '', $directory);
356
+ // пропускаем ненужные директории
357
+
358
+ if (
359
+ in_array($d, $this->params['minus-path'])
360
+ ) {
361
+ WPAdm_Core::log('Пропускаем папку ' . $directory);
362
+ return array();
363
+ }
364
+
365
+ $d = str_replace('\\', '/', $d);
366
+ $tmp = explode('/', $d);
367
+ $d1 = mb_strtolower($tmp[0]);
368
+ unset($tmp[0]);
369
+ $d2 = mb_strtolower(implode('/', $tmp));
370
+ // if (strpos($d1, 'cache') !== false || ($d1 == 'wp-includes' && strpos($d2, 'cache') !== false)) {
371
+ // if (($d1 == 'wp-includes' && strpos($d2, 'cache') !== false)
372
+ // || ($d1 == 'wp-content' || !in_array($tmp[0], array('plugins', 'themes')))
373
+ if (strpos($d2, 'cache') !== false
374
+ && !in_array($tmp[0], array('plugins', 'themes'))
375
+ ) {
376
+ WPAdm_Core::log('Пропускаем папку(cache) ' . $directory);
377
+ return array();
378
+ }
379
+
380
+ if ($handle = opendir($directory)) {
381
+ while (false !== ($file = readdir($handle))) {
382
+ if ($file != "." && $file != "..") {
383
+ if (is_dir($directory. "/" . $file)) {
384
+ if($recursive) {
385
+ $array_items = array_merge($array_items, $this->directoryToArray($directory. "/" . $file, $recursive));
386
+ }
387
+
388
+ $file = $directory . "/" . $file;
389
+ if (!is_dir($file)) {
390
+ $ff = preg_replace("/\/\//si", "/", $file);
391
+ $f = str_replace(ABSPATH . '/', '', $ff);
392
+ // пропускаем ненужные директории
393
+ if (!in_array($f, $this->params['minus-path'])) {
394
+ $array_items[] = $ff;
395
+ } else {
396
+ WPAdm_Core::log('Пропускаем файл ' . $ff);
397
+ }
398
+ }
399
+ } else {
400
+ $file = $directory . "/" . $file;
401
+ if (!is_dir($file)) {
402
+ $ff = preg_replace("/\/\//si", "/", $file);
403
+ $f = str_replace(ABSPATH . '/', '', $ff);
404
+ // пропускаем ненужные директории
405
+ if (!in_array($f, $this->params['minus-path'])) {
406
+ $array_items[] = $ff;
407
+ } else {
408
+ WPAdm_Core::log('Пропускаем файл ' . $ff);
409
+ }
410
+ }
411
+ }
412
+ }
413
+ }
414
+ closedir($handle);
415
+ }
416
+ return $array_items;
417
+ }
418
+
419
+
420
+ /*
421
+ * Берем реквизиты доступа к MySQL из параметров WP
422
+ * return Array()
423
+ */
424
+ private function getWpMysqlParams()
425
+ {
426
+ $db_params = array(
427
+ 'password' => 'DB_PASSWORD',
428
+ 'db' => 'DB_NAME',
429
+ 'user' => 'DB_USER',
430
+ 'host' => 'DB_HOST',
431
+ );
432
+
433
+ $r = "/define\('(.*)', '(.*)'\)/";
434
+ preg_match_all($r, file_get_contents(ABSPATH . "wp-config.php"), $m);
435
+ $params = array_combine($m[1], $m[2]);
436
+ foreach($db_params as $k=>$p) {
437
+ $db_params[$k] = $params[$p];
438
+ }
439
+ return $db_params;
440
+ }
441
+
442
+
443
+ private function init(array $conf) {
444
+ //todo: нормализация
445
+ $this->id = $conf['id'];
446
+ $this->stime = $conf['stime'];
447
+ $this->queue = new WPAdm_Queue($this->id);
448
+ $this->type = $conf['type'];
449
+ }
450
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
451
  }
methods/class-wpadm-method-full-backup-dropbox.php CHANGED
@@ -1,7 +1,4 @@
1
  <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
  /**
6
  * Creates a full backup of the site
7
  * Class WPadm_Method_Backup_Dropbox
@@ -51,34 +48,20 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
51
  'stime' => time(),
52
  )
53
  );
54
- set_time_limit(0);
55
 
56
- if (!class_exists('WPAdm_Process')) {
57
- require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-process.php';
58
- }
59
  $name = get_option('siteurl');
60
 
61
  $name = str_replace("http://", '', $name);
62
  $name = str_replace("https://", '', $name);
63
- $name = str_ireplace( array( 'Ä', 'ä', 'Ö', 'ö', 'ß', 'Ü', 'ü', 'å'),
64
- array('ae', 'ae', 'oe', 'oe', 's', 'ue', 'ue', 'a'),
65
- $name );
66
  $name = preg_replace("|\W|", "_", $name);
67
  $name .= '-' . $this->type . '-' . date("Y_m_d_H_i");
68
  $this->name = $name;
69
 
70
  // folder for backup
71
- $this->dir = DROPBOX_BACKUP_DIR_BACKUP . '/' . $this->name;
72
- $error = WPAdm_Core::mkdir(DROPBOX_BACKUP_DIR_BACKUP);
73
- if (!empty($error)) {
74
- $this->result->setError($error);
75
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
76
- }
77
- $error = WPAdm_Core::mkdir($this->dir);
78
- if (!empty($error)) {
79
- $this->result->setError($error);
80
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
81
- }
82
  }
83
 
84
  public function getResult()
@@ -88,101 +71,65 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
88
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_SUCCESS);
89
  $this->result->setError('');
90
 
91
- WPAdm_Core::log( __('Start backup','dropbox-backup') );
92
 
93
  # create db dump
94
- WPAdm_Core::log( __('Start create db dump','dropbox-backup') );
95
- $error = WPAdm_Core::mkdir(DROPBOX_BACKUP_DIR_BACKUP);
96
- if (!empty($error)) {
97
- $this->result->setError($error);
98
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
99
- return $this->result;
100
- }
101
- $mysql_dump_file = DROPBOX_BACKUP_DIR_BACKUP . '/mysqldump.sql';
102
  if (file_exists($mysql_dump_file)) {
103
  unlink($mysql_dump_file);
104
  }
105
  $wp_mysql_params = $this->getWpMysqlParams();
106
 
107
- if ( isset($this->params['repair']) && ( $this->params['repair'] == 1 ) ) {
108
- if ( WPAdm_Running::is_stop() ) {
109
- if (!class_exists('WPAdm_Mysqldump')) {
110
- require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-mysqldump.php';
111
- }
112
-
113
- $mysql = new WPAdm_Mysqldump();
114
- $mysql->host = $wp_mysql_params['host'];
115
- $mysql->user = $wp_mysql_params['user'];
116
- $mysql->password = $wp_mysql_params['password'];
117
- try {
118
- $mysql->repair($wp_mysql_params['db']);
119
- unset($mysql);
120
- } catch (Exception $e) {
121
- $this->result->setError( $e->getMessage() );
122
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
123
- return $this->result;
124
- }
125
- unset($mysql);
126
- }
127
- }
128
-
129
  if (isset($this->params['optimize']) && ($this->params['optimize']==1)) {
130
- WPAdm_Core::log(__('Optimize Database Tables','dropbox-backup'));
131
- if (!class_exists('WPAdm_Mysqldump')) {
132
- require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-mysqldump.php';
133
- }
134
- $mysql = new WPAdm_Mysqldump();
135
- $mysql->host = $wp_mysql_params['host'];
136
- $mysql->user = $wp_mysql_params['user'];
137
- $mysql->password = $wp_mysql_params['password'];
138
- try {
139
- $mysql->optimize($wp_mysql_params['db']);
140
- } catch (Exception $e) {
141
- $this->result->setError( $e->getMessage() );
142
- $this->result->setResult( WPAdm_Result::WPADM_RESULT_ERROR );
143
- return $this->result;
144
- }
145
- unset($mysql);
146
- }
147
-
148
- if (!class_exists('WPAdm_Mysqldump')) {
149
- require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-mysqldump.php';
150
- }
151
- $mysql = new WPAdm_Mysqldump();
152
- $mysql->host = $wp_mysql_params['host'];
153
- $mysql->user = $wp_mysql_params['user'];
154
- $mysql->password = $wp_mysql_params['password'];
155
-
156
- try {
157
- $mysql->mysqldump($wp_mysql_params['db'], $mysql_dump_file);
158
- } catch (Exception $e) {
159
- $this->result->setError( $e->getMessage() );
160
- $this->result->setResult( WPAdm_Result::WPADM_RESULT_ERROR );
161
- return $this->result;
162
- }
163
- unset($mysql);
164
-
165
- if (0 == (int)filesize($mysql_dump_file)) {
166
- $log = str_replace(array('%domain', '%dir'), array(SITE_HOME, DROPBOX_BACKUP_DIR_BACKUP), __('Website "%domain" returned an error during database dump creation: Database-Dump file is emplty. To solve this problem, please check permissions to folder: "%dir".','dropbox-backup') );
167
- $errors[] = $log;
168
  WPAdm_Core::log($log);
169
- $this->result->setError( $log );
170
- $this->result->setResult( WPAdm_Result::WPADM_RESULT_ERROR );
171
- return $this->result;
 
172
  } else {
173
  $size_dump = round( (filesize($mysql_dump_file) / 1024 / 1024) , 2);
174
- $log = str_replace("%size", $size_dump , __('Database Dump was successfully created ( %size Mb) : ','dropbox-backup') ) ;
175
  WPAdm_Core::log($log . $mysql_dump_file);
176
  }
 
 
177
 
178
- WPAdm_Core::log( __('Create a list of files for Backup','dropbox-backup') );
 
179
  $files = $this->createListFilesForArchive();
180
  if (file_exists($mysql_dump_file) && filesize($mysql_dump_file) > 0) {
181
  $files[] = $mysql_dump_file;
182
  }
183
 
184
  if (empty($files)) {
185
- $errors[] = __('Error: the list of Backup files is empty','dropbox-backup');
186
  }
187
 
188
  // split the file list by 170kbayt lists, To break one big task into smaller
@@ -204,47 +151,25 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
204
  $files2[$i][] = $f;
205
  }
206
 
207
- WPAdm_Core::log( __('List of Backup-Files was successfully created','dropbox-backup') );
208
- WPAdm_Core::log( __('Backup of Files was started','dropbox-backup') );
209
- //$this->queue->clear();
210
- if (!class_exists('WPAdm_Archive')) {
211
- require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-archive.php';
212
- }
213
- $to_file = $this->dir . '/' . $this->name;
214
- foreach($files2 as $files) {
215
- $af = $this->getArchiveName($to_file);
216
- $archive = new WPAdm_Archive($af, $to_file . '.md5');
217
- $archive->setRemovePath(ABSPATH);
218
- if ( !file_exists( $af ) ) {
219
- WPAdm_Core::log(__('Create part ','dropbox-backup') . basename( $af ) );
220
- }
221
 
222
- if (file_exists($af) && filesize($af) > 900000) {
223
- $af = $this->getNextArchiveName($to_file);
224
- unset($archive);
225
- if ( !file_exists( $af ) ) {
226
- WPAdm_Core::log(__('Create part ','dropbox-backup') . basename( $af ) );
227
- }
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
 
241
- } else {
242
- $this->result->setError( $archive->error );
243
- $this->result->setResult( WPAdm_Result::WPADM_RESULT_ERROR );
244
- return $this->result;
245
- }
246
  }
247
- WPAdm_Core::log( __('End of File Backup','dropbox-backup') );
 
 
 
248
 
249
  $files = glob($this->dir . '/'.$this->name . '*');
250
  $urls = array();
@@ -258,72 +183,156 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
258
 
259
 
260
  $remove_from_server = 0;
261
- if (isset($this->params['dropbox']) && isset($this->params['dropbox']['key']) && isset($this->params['dropbox']['secret'])) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  $files = glob($this->dir . '/' . $this->name . '*');
263
- require_once WPAdm_Core::getPluginDir() . '/modules/dropbox.class.php';
264
  $files = array_merge_recursive(array($mysql_dump_file), $files);
265
- WPAdm_Core::log( __('files to dropbox: ' ,'dropbox-backup') . print_r($files, true));
266
- $n = count($files);
267
- $folder_project_temp = $this->params['dropbox']['folder'];
268
- $folder_project = "";
269
- $dir = $this->name;
270
- if (!empty($folder_project_temp)) {
271
- $folder_project = $folder_project_temp . "/";
272
- $dropbox->createDir($folder_project_temp );
273
- $dropbox->createDir($folder_project . $dir );
274
- } else {
275
- $dropbox->createDir( $dir );
 
 
 
 
 
 
 
276
  }
 
 
 
 
 
 
 
 
277
  for($i = 0; $i <$n; $i++) {
278
- $file_ = explode("/", $files[$i]);
279
- $file_name = array_pop($file_);
280
- $fromFile = str_replace('//', '/', $files[$i]);
281
- $toFile = str_replace('//', '/', $folder_project . $dir . '/' . $file_name);
282
-
283
- $res = $dropbox->uploadFile($fromFile, $toFile, true);
284
-
285
- if (isset($res['error']) && isset($res['text']) && $res['error'] == 1) {
286
- $this->result->setError( __('Dropbox returned an error during file sending: ' ,'dropbox-backup') . '"' . $res['text'] . '"' );
287
- $this->result->setResult( WPAdm_Result::WPADM_RESULT_ERROR );
288
- return $this->result;
289
- }
290
- if (isset($res['size']) && isset($res['client_mtime'])) {
291
- WPAdm_Core::log( __('File upload: ' ,'dropbox-backup') . basename( $file ) . __(' size: ' ,'dropbox-backup') . $res['size']);
292
- }
293
  }
294
  }
295
 
296
  #Removing TMP-files
297
- WPAdm_Core::rmdir(DROPBOX_BACKUP_DIR_BACKUP . '/mysqldump.sql');
298
 
299
  #Removind old backups(if limit the number of stored backups)
300
- WPAdm_Core::log( __('Start removing old backups' ,'dropbox-backup') );
301
  if ($this->params['limit'] != 0) {
302
- if (is_dir(DROPBOX_BACKUP_DIR_BACKUP)) {
303
- $dir_open = opendir(DROPBOX_BACKUP_DIR_BACKUP);
304
- $files2 = array();
305
- while ($read_dir = readdir($dir_open)) {
306
- if ($read_dir != '.' && $read_dir != '..' && is_dir( DROPBOX_BACKUP_DIR_BACKUP . "/$read_dir")) {
307
- $fa = explode('-', $read_dir);
308
- if (count($fa) != 3) {
309
- continue;
310
- }
311
- $files2[$fa[2]] = $f;
312
  }
 
 
313
  }
314
- if ( ( $n = count($files2) ) > $this->params['limit']) {
315
- ksort($files2);
316
- $d = count($files2) - $this->params['limit'];
317
- $del = array_slice($files2, 0, $d);
318
- foreach($del as $d) {
319
- WPAdm_Core::rmdir($d);
320
- }
321
  }
322
  }
323
  }
324
- WPAdm_Core::log( __('Finished removing old backups' ,'dropbox-backup') );
325
 
326
- WPAdm_Core::log( __('Creating a backup is completed' ,'dropbox-backup') );
327
 
328
  wpadm_class::setBackup(2);
329
  if (!empty($errors)) {
@@ -336,8 +345,12 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
336
  }
337
  wpadm_class::backupSend();
338
  return $this->result;
 
 
339
  }
340
 
 
 
341
  public function createListFilesForArchive() {
342
  $folders = array();
343
  $files = array();
@@ -345,15 +358,15 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
345
  $files = array_merge(
346
  $files,
347
  array(
348
- // ABSPATH . '.htaccess',
349
  ABSPATH . 'index.php',
350
- // ABSPATH . 'license.txt',
351
- // ABSPATH . 'readme.html',
352
  ABSPATH . 'wp-activate.php',
353
  ABSPATH . 'wp-blog-header.php',
354
  ABSPATH . 'wp-comments-post.php',
355
  ABSPATH . 'wp-config.php',
356
- // ABSPATH . 'wp-config-sample.php',
357
  ABSPATH . 'wp-cron.php',
358
  ABSPATH . 'wp-links-opml.php',
359
  ABSPATH . 'wp-load.php',
@@ -365,30 +378,6 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
365
  ABSPATH . 'xmlrpc.php',
366
  )
367
  );
368
- if ( file_exists(ABSPATH . '.htaccess') ) {
369
- $files = array_merge( $files, array( ABSPATH . '.htaccess' ) );
370
- }
371
- if ( file_exists( ABSPATH . 'license.txt' ) ) {
372
- $files = array_merge( $files, array( ABSPATH . 'license.txt' ) );
373
- }
374
- if ( file_exists( ABSPATH . 'readme.html' ) ) {
375
- $files = array_merge( $files, array( ABSPATH . 'readme.html') );
376
- }
377
- if ( file_exists(ABSPATH . 'wp-config-sample.php') ) {
378
- $files = array_merge( $files, array( ABSPATH . 'wp-config-sample.php' ) );
379
- }
380
- if ( file_exists(ABSPATH . 'robots.txt') ) {
381
- $files = array_merge( $files, array( ABSPATH . 'robots.txt' ) );
382
- }
383
-
384
- // check files in root directory
385
- $n = count($files);
386
- for($i = 0; $i < $n; $i++) {
387
- if (!file_exists($files[$i])) {
388
- unset($files[$i]);
389
- }
390
- }
391
- $files = array_values($files);
392
 
393
  if (!empty($this->params['minus-path'])) {
394
  $minus_path = explode(",", $this->params['minus-path']);
@@ -396,7 +385,7 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
396
  $v = str_replace(ABSPATH , '', $v);
397
  if (in_array($v, $minus_path)) {
398
  unset($files[$k]);
399
- WPAdm_Core::log( __('Skip file ' ,'dropbox-backup') . $v);
400
  }
401
  }
402
  }
@@ -452,29 +441,16 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
452
 
453
  $d = str_replace('\\', '/', $d);
454
  $tmp = explode('/', $d);
455
-
456
- if (function_exists('mb_strtolower')) {
457
- $d1 = mb_strtolower($tmp[0]);
458
- } else {
459
- $d1 = strtolower($tmp[0]);
460
- }
461
  unset($tmp[0]);
462
- if (function_exists('mb_strtolower')) {
463
- $d2 = mb_strtolower(implode('/', $tmp));
464
- } else {
465
- $d2 = strtolower(implode('/', $tmp));
466
- }
467
- if (strpos($d2, 'cache') !== false && isset($tmp[0]) && !in_array($tmp[0], array('plugins', 'themes')) ) {
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
- }
477
-
478
  if ($handle = opendir($directory)) {
479
  while (false !== ($file = readdir($handle))) {
480
  if ($file != "." && $file != "..") {
@@ -503,7 +479,7 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
503
  if (!in_array($f, $minus_path)) {
504
  $array_items[] = $ff;
505
  } else {
506
- WPAdm_Core::log( __('Skip dir ' ,'dropbox-backup') . $ff);
507
  }
508
  }
509
  }
@@ -543,28 +519,5 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
543
  $this->stime = $conf['stime'];
544
  $this->queue = new WPAdm_Queue($this->id);
545
  }
546
-
547
- private function getArchiveName($name)
548
- {
549
- //WPAdm_Core::log("{$name}-*.zip");
550
- $archives = glob("{$name}-*.zip");
551
- //WPAdm_Core::log( print_r($archives, 1) );
552
- if (empty($archives)) {
553
- return "{$name}-1.zip";
554
- }
555
- $n = count($archives);
556
- $f = "{$name}-{$n}.zip";
557
- return $f;
558
- }
559
-
560
- private function getNextArchiveName($name)
561
- {
562
- //WPAdm_Core::log("{$name}-*.zip");
563
- $archives = glob("{$name}-*.zip");
564
- $n = 1 + count($archives);
565
- $a = "{$name}-{$n}.zip";
566
- //WPAdm_Core::log($a);
567
- return $a;
568
- }
569
  }
570
  }
1
  <?php
 
 
 
2
  /**
3
  * Creates a full backup of the site
4
  * Class WPadm_Method_Backup_Dropbox
48
  'stime' => time(),
49
  )
50
  );
 
51
 
52
+
 
 
53
  $name = get_option('siteurl');
54
 
55
  $name = str_replace("http://", '', $name);
56
  $name = str_replace("https://", '', $name);
 
 
 
57
  $name = preg_replace("|\W|", "_", $name);
58
  $name .= '-' . $this->type . '-' . date("Y_m_d_H_i");
59
  $this->name = $name;
60
 
61
  // folder for backup
62
+ $this->dir = ABSPATH . 'wpadm_backups/' . $this->name;
63
+ WPAdm_Core::mkdir(ABSPATH . 'wpadm_backups/');
64
+ WPAdm_Core::mkdir($this->dir);
 
 
 
 
 
 
 
 
65
  }
66
 
67
  public function getResult()
71
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_SUCCESS);
72
  $this->result->setError('');
73
 
74
+ WPAdm_Core::log( langWPADM::get('Start backup', false) );
75
 
76
  # create db dump
77
+ WPAdm_Core::log( langWPADM::get('Start create db dump', false) );
78
+ WPAdm_Core::mkdir(ABSPATH . 'wpadm_backup');
79
+ $mysql_dump_file = ABSPATH . 'wpadm_backup/mysqldump.sql';
 
 
 
 
 
80
  if (file_exists($mysql_dump_file)) {
81
  unlink($mysql_dump_file);
82
  }
83
  $wp_mysql_params = $this->getWpMysqlParams();
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  if (isset($this->params['optimize']) && ($this->params['optimize']==1)) {
86
+ WPAdm_Core::log( langWPADM::get('Table optimization', false) );
87
+ $commandContext = new WPAdm_Command_Context();
88
+ $commandContext ->addParam('command','mysqloptimize')
89
+ ->addParam('host', $wp_mysql_params['host'])
90
+ ->addParam('db', $wp_mysql_params['db'])
91
+ ->addParam('user', $wp_mysql_params['user'])
92
+ ->addParam('password', $wp_mysql_params['password']);
93
+ $this->queue->clear()
94
+ ->add($commandContext);
95
+ unset($commandContext);
96
+ }
97
+
98
+ $commandContext = new WPAdm_Command_Context();
99
+ $commandContext ->addParam('command','mysqldump')
100
+ ->addParam('host', $wp_mysql_params['host'])
101
+ ->addParam('db', $wp_mysql_params['db'])
102
+ ->addParam('user', $wp_mysql_params['user'])
103
+ ->addParam('password', $wp_mysql_params['password'])
104
+ ->addParam('tables', '')
105
+ ->addParam('to_file', $mysql_dump_file);
106
+ $res = $this->queue->add($commandContext)
107
+ ->save()
108
+ ->execute();
109
+ if (!$res) {
110
+ $log = str_replace('%s', $this->queue->getError(), langWPADM::get('Error: Dump of Database wasn\'t created (%s)', false) );
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  WPAdm_Core::log($log);
112
+ $errors[] = $log;
113
+ } elseif (0 == (int)filesize($mysql_dump_file)) {
114
+ $errors[] = langWPADM::get('MySQL Error: Database-Dump File is empty', false);
115
+ WPAdm_Core::log(langWPADM::get('Dump of Database wasn\'t created (File of Database-Dump is empty!)', false));
116
  } else {
117
  $size_dump = round( (filesize($mysql_dump_file) / 1024 / 1024) , 2);
118
+ $log = str_replace("%s", $size_dump , langWPADM::get('Database Dump was successfully created ( %s Mb) : ', false) ) ;
119
  WPAdm_Core::log($log . $mysql_dump_file);
120
  }
121
+ unset($commandContext);
122
+
123
 
124
+ #ЗАРХИВИРУЕМ ФАЙЛЫ
125
+ WPAdm_Core::log( langWPADM::get('Create a list of files for Backup', false) );
126
  $files = $this->createListFilesForArchive();
127
  if (file_exists($mysql_dump_file) && filesize($mysql_dump_file) > 0) {
128
  $files[] = $mysql_dump_file;
129
  }
130
 
131
  if (empty($files)) {
132
+ $errors[] = langWPADM::get('Error: the list of Backup files is empty', false);
133
  }
134
 
135
  // split the file list by 170kbayt lists, To break one big task into smaller
151
  $files2[$i][] = $f;
152
  }
153
 
154
+ WPAdm_Core::log( langWPADM::get('List of Backup-Files was successfully created', false) );
 
 
 
 
 
 
 
 
 
 
 
 
 
155
 
156
+ $this->queue->clear();
 
 
 
 
 
 
 
 
157
 
158
+ foreach($files2 as $files) {
159
+ $commandContext = new WPAdm_Command_Context();
160
+ $commandContext ->addParam('command','archive')
161
+ ->addParam('files', $files)
162
+ ->addParam('to_file', $this->dir . '/'.$this->name)
163
+ ->addParam('max_file_size', 900000)
164
+ ->addParam('remove_path', ABSPATH);
 
165
 
166
+ $this->queue->add($commandContext);
167
+ unset($commandContext);
 
 
 
168
  }
169
+ WPAdm_Core::log( langWPADM::get('Backup of Files was started', false) );
170
+ $this->queue->save()
171
+ ->execute();
172
+ WPAdm_Core::log( langWPADM::get('End of File Backup', false) );
173
 
174
  $files = glob($this->dir . '/'.$this->name . '*');
175
  $urls = array();
183
 
184
 
185
  $remove_from_server = 0;
186
+ if (isset($this->params['storage'])) {
187
+ foreach($this->params['storage'] as $storage) {
188
+ if ($storage['type'] == 'ftp') {
189
+ WPAdm_Core::log( langWPADM::get('Begin copying files to FTP', false) );
190
+ $this->queue->clear();
191
+ $files = glob($this->dir . '/'.$this->name . '*');
192
+ //$this->getResult()->setData($files);
193
+ $ad = $storage['access_details'];
194
+ $dir = (isset($ad['dir'])) ? $ad['dir'] : '/';
195
+ $dir = trim($dir, '/') . '/' . $this->name;
196
+ foreach($files as $file) {
197
+ $commandContext = new WPAdm_Command_Context();
198
+ $commandContext ->addParam('command','send_to_ftp')
199
+ ->addParam('file', $file)
200
+ ->addParam('host', $ad['host'])
201
+ ->addParam('port', (isset($ad['port']))? $ad['port'] : 21)
202
+ ->addParam('user', $ad['user'])
203
+ ->addParam('password', $ad['password'])
204
+ ->addParam('dir', $dir)
205
+ ->addParam('http_host', isset($ad['http_host']) ? $ad['http_host'] : '');
206
+ $this->queue->add($commandContext);
207
+ unset($commandContext);
208
+ }
209
+ $res = $this->queue->save()
210
+ ->execute();
211
+ if (!$res) {
212
+ $log = langWPADM::get('FTP: ' , false);
213
+ WPAdm_Core::log($log . $this->queue->getError());
214
+ $errors[] = $log . $this->queue->getError();
215
+ }
216
+ WPAdm_Core::log( langWPADM::get('Finished copying files to FTP' , false) );
217
+ if (isset($storage['remove_from_server']) && $storage['remove_from_server'] == 1 ) {
218
+ $remove_from_server = $storage['remove_from_server'];
219
+ }
220
+ } elseif ($storage['type'] == 's3') {
221
+ WPAdm_Core::log( langWPADM::get('Begin coping files to S3' , false) );
222
+ $this->queue->clear();
223
+ $files = glob($this->dir . '/'.$this->name . '*');
224
+ //$this->getResult()->setData($files);
225
+ $ad = $storage['access_details'];
226
+ $dir = (isset($ad['dir'])) ? $ad['dir'] : '/';
227
+ $dir = trim($dir, '/') . '/' . $this->name;
228
+ foreach($files as $file) {
229
+ $commandContext = new WPAdm_Command_Context();
230
+ $commandContext ->addParam('command','send_to_s3')
231
+ ->addParam('file', $file)
232
+ ->addParam('bucket', $ad['bucket'])
233
+ ->addParam('AccessKeyId', $ad['AccessKeyId'])
234
+ ->addParam('SecretAccessKey', $ad['SecretAccessKey'])
235
+ ->addParam('SessionToken', $ad['SessionToken']);
236
+ $this->queue->add($commandContext);
237
+ unset($commandContext);
238
+ }
239
+ $res = $this->queue->save()
240
+ ->execute();
241
+ if (!$res) {
242
+ WPAdm_Core::log('S3: ' . $this->queue->getError());
243
+ $errors[] = 'S3: '.$this->queue->getError();
244
+ }
245
+ WPAdm_Core::log( langWPADM::get('Finished copying files to S3' , false) );
246
+ if (isset($storage['remove_from_server']) && $storage['remove_from_server'] == 1 ) {
247
+ $remove_from_server = $storage['remove_from_server'];
248
+ }
249
+ }
250
+ }
251
+ if ($remove_from_server) {
252
+ // удаляем файлы на сервере
253
+ WPAdm_Core::log( langWPADM::get('Remove the backup server' , false) );
254
+ WPAdm_Core::rmdir($this->dir);
255
+ }
256
+
257
+ }
258
+ if (isset($this->params['gd']) && isset($this->params['gd']['key']) && isset($this->params['gd']['secret'])) {
259
+ $this->queue->clear();
260
  $files = glob($this->dir . '/' . $this->name . '*');
 
261
  $files = array_merge_recursive(array($mysql_dump_file), $files);
262
+ WPAdm_Core::log( langWPADM::get('files to google: ' , false) . print_r($files, true));
263
+ $n = count($files);
264
+ for($i = 0; $i <$n; $i++) {
265
+ $commandContext = new WPAdm_Command_Context();
266
+ $commandContext->addParam('command', 'send_to_google_drive')
267
+ ->addParam('key', $this->params['gd']['key'])
268
+ ->addParam('secret', $this->params['gd']['secret'])
269
+ ->addParam('token', $this->params['gd']['token'])
270
+ ->addParam('folder_project', $this->params['gd']['folder'])
271
+ ->addParam('folder', $this->name )
272
+ ->addParam('files', $files[$i]);
273
+ $this->queue->add($commandContext);
274
+ unset($commandContext);
275
+ }
276
+ $res = $this->queue->save()
277
+ ->execute();
278
+ if (!$res) {
279
+ WPAdm_Core::log( langWPADM::get('Google drive: ' , false) . $this->queue->getError());
280
  }
281
+ //WPAdm_Core::log('google drive' . print_r($this->params, true));
282
+ }
283
+ if (isset($this->params['dropbox']) && isset($this->params['dropbox']['key']) && isset($this->params['dropbox']['secret'])) {
284
+ $this->queue->clear();
285
+ $files = glob($this->dir . '/' . $this->name . '*');
286
+ $files = array_merge_recursive(array($mysql_dump_file), $files);
287
+ WPAdm_Core::log( langWPADM::get('files to dropbox: ' , false) . print_r($files, true));
288
+ $n = count($files);
289
  for($i = 0; $i <$n; $i++) {
290
+ $commandContext = new WPAdm_Command_Context();
291
+ $commandContext->addParam('command', 'send_to_dropbox')
292
+ ->addParam('key', $this->params['dropbox']['key'])
293
+ ->addParam('secret', $this->params['dropbox']['secret'])
294
+ ->addParam('token', $this->params['dropbox']['token'])
295
+ ->addParam('folder_project', $this->params['dropbox']['folder'])
296
+ ->addParam('folder', $this->name)
297
+ ->addParam('files', $files[$i]);
298
+ $this->queue->add($commandContext);
299
+ unset($commandContext);
300
+ }
301
+ $this->queue->save()
302
+ ->execute();
303
+ if (!$res) {
304
+ WPAdm_Core::log(langWPADM::get('Dropbox: ' , false) . $this->queue->getError());
305
  }
306
  }
307
 
308
  #Removing TMP-files
309
+ WPAdm_Core::rmdir(ABSPATH . 'wpadm_backup');
310
 
311
  #Removind old backups(if limit the number of stored backups)
312
+ WPAdm_Core::log( langWPADM::get('Start removing old backups' , false) );
313
  if ($this->params['limit'] != 0) {
314
+ $files = glob(ABSPATH . 'wpadm_backups/*');
315
+ if (count($files) > $this->params['limit']) {
316
+ $files2 = array();
317
+ foreach($files as $f) {
318
+ $fa = explode('-', $f);
319
+ if (count($fa) != 3) {
320
+ continue;
 
 
 
321
  }
322
+ $files2[$fa[2]] = $f;
323
+
324
  }
325
+ ksort($files2);
326
+ $d = count($files2) - $this->params['limit'];
327
+ $del = array_slice($files2, 0, $d);
328
+ foreach($del as $d) {
329
+ WPAdm_Core::rmdir($d);
 
 
330
  }
331
  }
332
  }
333
+ WPAdm_Core::log( langWPADM::get('Finished removing old backups' , false) );
334
 
335
+ WPAdm_Core::log( langWPADM::get('Creating a backup is completed' , false) );
336
 
337
  wpadm_class::setBackup(2);
338
  if (!empty($errors)) {
345
  }
346
  wpadm_class::backupSend();
347
  return $this->result;
348
+
349
+
350
  }
351
 
352
+
353
+
354
  public function createListFilesForArchive() {
355
  $folders = array();
356
  $files = array();
358
  $files = array_merge(
359
  $files,
360
  array(
361
+ ABSPATH . '.htaccess',
362
  ABSPATH . 'index.php',
363
+ ABSPATH . 'license.txt',
364
+ ABSPATH . 'readme.html',
365
  ABSPATH . 'wp-activate.php',
366
  ABSPATH . 'wp-blog-header.php',
367
  ABSPATH . 'wp-comments-post.php',
368
  ABSPATH . 'wp-config.php',
369
+ ABSPATH . 'wp-config-sample.php',
370
  ABSPATH . 'wp-cron.php',
371
  ABSPATH . 'wp-links-opml.php',
372
  ABSPATH . 'wp-load.php',
378
  ABSPATH . 'xmlrpc.php',
379
  )
380
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
 
382
  if (!empty($this->params['minus-path'])) {
383
  $minus_path = explode(",", $this->params['minus-path']);
385
  $v = str_replace(ABSPATH , '', $v);
386
  if (in_array($v, $minus_path)) {
387
  unset($files[$k]);
388
+ WPAdm_Core::log( langWPADM::get('Skip file ' , false) . $v);
389
  }
390
  }
391
  }
441
 
442
  $d = str_replace('\\', '/', $d);
443
  $tmp = explode('/', $d);
444
+ $d1 = mb_strtolower($tmp[0]);
 
 
 
 
 
445
  unset($tmp[0]);
446
+ $d2 = mb_strtolower(implode('/', $tmp));
447
+ if (strpos($d2, 'cache') !== false
448
+ && !in_array($tmp[0], array('plugins', 'themes'))
449
+ ) {
 
 
450
  WPAdm_Core::log('Skip dir(cache) ' . $directory);
451
  return array();
452
  }
453
 
 
 
 
 
 
 
454
  if ($handle = opendir($directory)) {
455
  while (false !== ($file = readdir($handle))) {
456
  if ($file != "." && $file != "..") {
479
  if (!in_array($f, $minus_path)) {
480
  $array_items[] = $ff;
481
  } else {
482
+ WPAdm_Core::log( langWPADM::get('Skip dir ' , false) . $ff);
483
  }
484
  }
485
  }
519
  $this->stime = $conf['stime'];
520
  $this->queue = new WPAdm_Queue($this->id);
521
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
  }
523
  }
methods/class-wpadm-method-local-backup.php CHANGED
@@ -1,602 +1,308 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
  if (!class_exists('WPAdm_Method_Local_Backup')) {
6
  class WPAdm_Method_Local_Backup extends WPAdm_Method_Class {
7
 
8
  private $start = true;
9
 
10
- private $tar_gz = false;
11
-
12
  public function __construct($params)
13
  {
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- if ( WPAdm_Running::is_stop() ) {
16
- parent::__construct($params);
17
- $this->init(
18
- array(
19
- 'id' => uniqid('wpadm_method__local_backup__'),
20
- 'stime' => time(),
21
- )
22
- );
23
-
24
- WPAdm_Core::log(__('Create Unique Id ','dropbox-backup') . $this->id);
25
-
26
-
27
- $name = get_option('siteurl');
28
-
29
- if (!class_exists('WPAdm_Process')) {
30
- require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-process.php';
31
- }
32
-
33
- $name = str_replace("http://", '', $name);
34
- $name = str_replace("https://", '', $name);
35
- $name = str_ireplace( array( 'Ä', 'ä', 'Ö', 'ö', 'ß', 'Ü', 'ü', 'å'),
36
- array('ae', 'ae', 'oe', 'oe', 's', 'ue', 'ue', 'a'),
37
- $name );
38
- $name = preg_replace("|\W|", "_", $name);
39
- if (isset($params['time']) && !empty($params['time'])) { // time 1432751372
40
- $this->time = date("Y-m-d H:i", $params['time']);
41
- $name .= '-' . wpadm_class::$type . '-' . date("Y_m_d_H_i", $params['time']);
42
- } else {
43
- $this->time = date("Y-m-d H:i"); //23.04.2015 13:45
44
- $name .= '-' . wpadm_class::$type . '-' . date("Y_m_d_H_i");
45
- }
46
- $this->name = $name;
47
-
48
- // folder for backup
49
-
50
-
51
- $dropbox_options = wpadm_wp_full_backup_dropbox::getSettings();
52
 
53
- $this->base_dir = DROPBOX_BACKUP_DIR_BACKUP;
54
- $this->dir = DROPBOX_BACKUP_DIR_BACKUP . '/' . $name;
55
- if ($dropbox_options) {
56
- if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder']) ) {
57
- $this->dir = $dropbox_options['backup_folder'] . '/' . $name;
58
- $this->base_dir = $dropbox_options['backup_folder'];
59
- }
60
- }
61
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
 
64
- $opt_folder = WPAdm_Running::getCommandResultData('folder_create');
65
- if (!isset($opt_folder[$name])) {
66
- if (($f = $this->checkBackup()) !== false) {
67
- $this->dir = DROPBOX_BACKUP_DIR_BACKUP . '/' . $f;
68
- if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
69
- $this->dir = $dropbox_options['backup_folder'] . '/' . $f;
70
- }
71
- }
72
- if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
73
- $error = WPAdm_Core::mkdir($dropbox_options['backup_folder']);
74
- if (!empty($error)) {
75
- $this->result->setError($error);
76
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
77
- }
78
- } else {
79
- $error = WPAdm_Core::mkdir(DROPBOX_BACKUP_DIR_BACKUP);
80
- if (!empty($error)) {
81
- $this->result->setError($error);
82
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
83
- }
84
- }
85
- $error = WPAdm_Core::mkdir($this->dir);
86
- if (!empty($error)) {
87
- $this->result->setError($error);
88
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
89
- }
90
- $opt_folder = WPAdm_Running::getCommandResultData('folder_create');
91
- $opt_folder[$name] = true;
92
- WPAdm_Running::setCommandResultData('folder_create', $opt_folder);
93
- }
94
  }
 
 
95
  }
96
  public function checkBackup()
97
  {
98
- if (WPAdm_Running::getCommand('local_backup') !== false) {
99
- $archives = glob("{$this->dir}");
100
- if (empty($archives) && count($archives) <= 1) {
101
- return false;
102
- }
103
- $n = count($archives);
104
- $f = "{$this->name}({$n})";
105
- return $f;
106
  }
107
- return false;
 
 
108
  }
109
  public function getResult()
110
  {
111
-
 
 
 
 
112
  $errors = array();
113
- if ( WPAdm_Running::is_stop() ) {
114
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_SUCCESS);
115
- $this->result->setError('');
116
- WPAdm_Core::log(__('Start Backup process...', 'dropbox-backup'));
117
-
118
- # create db dump
119
- if (in_array('db', $this->params['types']) ) {
120
-
121
- $mysql_dump_file = DROPBOX_BACKUP_DIR_BACKUP . '/mysqldump.sql';
122
- if ( !WPAdm_Running::getCommandResult('db') ) {
123
- WPAdm_Running::setCommandResult('db');
124
- WPAdm_Core::log(__('Creating Database Dump','dropbox-backup'));
125
- $error = WPAdm_Core::mkdir(DROPBOX_BACKUP_DIR_BACKUP);
126
- if (!empty($error)) {
127
- $this->result->setError($error);
128
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
129
- return $this->result;
130
- }
131
- if (file_exists($mysql_dump_file) && !file_exists(WPAdm_Core::getTmpDir() . "/db")) {
132
- unlink($mysql_dump_file);
133
- }
134
- $wp_mysql_params = $this->getWpMysqlParams();
135
 
136
- if ( isset($this->params['repair']) && ( $this->params['repair'] == 1 ) ) {
137
- if ( WPAdm_Running::is_stop() ) {
138
- if (!class_exists('WPAdm_Mysqldump')) {
139
- require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-mysqldump.php';
140
- }
141
 
142
- $mysql = new WPAdm_Mysqldump();
143
- $mysql->host = $wp_mysql_params['host'];
144
- $mysql->user = $wp_mysql_params['user'];
145
- $mysql->password = $wp_mysql_params['password'];
146
- try {
147
- $mysql->repair($wp_mysql_params['db']);
148
- unset($mysql);
149
- } catch (Exception $e) {
150
- $this->result->setError( $e->getMessage() );
151
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
152
- return $this->result;
153
- }
154
- unset($mysql);
155
- }
156
- }
157
 
158
- if (isset($this->params['optimize']) && ($this->params['optimize'] == 1 ) ) {
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
- }
166
- $mysql = new WPAdm_Mysqldump();
167
- $mysql->host = $wp_mysql_params['host'];
168
- $mysql->user = $wp_mysql_params['user'];
169
- $mysql->password = $wp_mysql_params['password'];
170
- try {
171
- $mysql->optimize($wp_mysql_params['db']);
172
- } catch (Exception $e) {
173
- $this->result->setError( $e->getMessage() );
174
- $this->result->setResult( WPAdm_Result::WPADM_RESULT_ERROR );
175
- return $this->result;
176
- }
177
- unset($mysql);
178
- }
179
- }
180
- }
181
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
 
183
- if ( WPAdm_Running::is_stop() ) {
184
- if ( WPAdm_Running::getCommandResult('db') === false) {
185
 
186
- if (!class_exists('WPAdm_Mysqldump')) {
187
- require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-mysqldump.php';
188
- }
189
- $mysql = new WPAdm_Mysqldump();
190
- $mysql->host = $wp_mysql_params['host'];
191
- $mysql->user = $wp_mysql_params['user'];
192
- $mysql->password = $wp_mysql_params['password'];
193
-
194
- try {
195
- $mysql->mysqldump($wp_mysql_params['db'], $mysql_dump_file);
196
- } catch (Exception $e) {
197
- $this->result->setError( $e->getMessage() );
198
- $this->result->setResult( WPAdm_Result::WPADM_RESULT_ERROR );
199
- return $this->result;
200
- }
201
- unset($mysql);
202
-
203
- if (0 == (int)filesize($mysql_dump_file)) {
204
- $log = str_replace(array('%domain', '%dir'), array(SITE_HOME, DROPBOX_BACKUP_DIR_BACKUP), __('Website "%domain" returned an error during database dump creation: Database-Dump file is emplty. To solve this problem, please check permissions to folder: "%dir".','dropbox-backup') );
205
- $errors[] = $log;
206
- WPAdm_Core::log($log);
207
- $this->result->setError( $log );
208
- $this->result->setResult( WPAdm_Result::WPADM_RESULT_ERROR );
209
- return $this->result;
210
- } else {
211
- $size_dump = round( (filesize($mysql_dump_file) / 1024 / 1024) , 2);
212
- $log = str_replace("%size", $size_dump , __('Database Dump was successfully created ( %size Mb) : ','dropbox-backup') ) ;
213
- WPAdm_Core::log($log . $mysql_dump_file);
214
- }
215
- WPAdm_Running::setCommandResult('db', true);
216
- }
217
- }
218
- }
219
- }
220
 
221
- if (count($errors) == 0) {
222
- if ( WPAdm_Running::is_stop() ) {
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;
230
- }
231
- if (isset($mysql_dump_file) && file_exists($mysql_dump_file) && filesize($mysql_dump_file) > 0) {
232
- $files[] = $mysql_dump_file;
233
- }
234
- WPAdm_Process::init('archiving', count($files) );
235
- if (empty($files)) {
236
- $errors[] = str_replace(array('%d'), array(SITE_HOME), __( 'Website "%d" returned an error during creation of the list of files for a backup: list of files for a backup is empty. To solve this problem, please check files and folders permissions for website "%d".' ,'dropbox-backup') );
237
- }
238
- } else {
239
- return true;
240
- }
241
 
242
- // split the file list by 170kbayt lists, To break one big task into smaller
243
- if ( WPAdm_Running::is_stop() ) {
244
- $files2 = WPAdm_Running::getCommandResultData('files2');
245
- if (empty($files2)) {
246
- $files2 = array();
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() ) {
308
- $af1 = $this->getArchiveName($to_file);
309
- $archive = new WPAdm_Archive($af1, $to_file . '.md5');
310
- $archive->setRemovePath(ABSPATH);
311
- if ( !file_exists( $af1 ) ) {
312
- WPAdm_Core::log( __('Create part ','dropbox-backup') . basename( $af1 ) );
313
- }
314
- }
315
- $targz = WPAdm_Running::getCommandResultData('test_targz_archive');
316
-
317
- if ( ( !empty($targz) && $targz === true ) || ( file_exists($af1) && filesize($af1) > 900000 ) ) {
318
- if ( WPAdm_Running::is_stop() ) {
319
- $af2 = $this->getNextArchiveName($to_file);
320
- if ($af1 != $af2) {
321
- unset($archive);
322
- if ( !file_exists( $af2 ) ) {
323
- WPAdm_Core::log(__('Create part ','dropbox-backup') . basename( $af2 ) );
324
- }
325
- $archive = new WPAdm_Archive($af2, $to_file . '.md5');
326
- $archive->setRemovePath( ABSPATH );
327
- }
328
- } else {
329
- return true;
330
- }
331
- }
332
-
333
- if ( WPAdm_Running::is_stop() ) {
334
- $md5 = md5( print_r( $files, 1 ) );
335
- if ( defined('PCLZIP_SEPARATOR') ) {
336
- $files_str = implode( PCLZIP_SEPARATOR , $files);
337
- } else {
338
- $files_str = implode( ',' , $files);
339
- }
340
- $files_archive = WPAdm_Running::getCommandResultData('archive');
341
- if ( WPAdm_Running::is_stop() ) {
342
- if ( !isset($files_archive[$md5]) ) {
343
- if ( WPAdm_Running::is_stop() ) {
344
- $res = $archive->add($files_str);
345
- if ($res) {
346
- $files_archive = WPAdm_Running::getCommandResultData('archive');
347
- $files_archive[$md5] = 1;
348
- WPAdm_Running::setCommandResultData('archive', $files_archive);
349
- WPAdm_Process::setInc( 'archiving', count($files) );
350
- } else {
351
- if ($archive->anew) {
352
- return true;
353
- } else {
354
- $this->result->setError( $archive->error );
355
- $this->result->setResult( WPAdm_Result::WPADM_RESULT_ERROR );
356
- return $this->result;
357
- }
358
- }
359
- } else {
360
- return true;
361
- }
362
- }
363
- } else {
364
- return true;
365
- }
366
- }
367
- }
368
- }
369
 
370
- WPAdm_Core::log( __('Backup of files was finished','dropbox-backup') );
371
- WPAdm_Running::setCommandResult('archive', true);
372
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
373
  }
374
- if (empty($errors)) {
375
- if ( WPAdm_Running::is_stop() ) {
376
- $files = glob($this->dir . '/'.$this->name . '*');
377
- $urls = array();
378
- $totalSize = 0;
379
- foreach($files as $file) {
380
- $urls[] = str_replace(ABSPATH, '', $file);
381
- $totalSize += @intval( filesize($file) );
382
- }
383
- $this->result->setData($urls);
384
- $this->result->setSize($totalSize);
385
- $this->result->setValue('md5_data', md5 ( print_r($this->result->toArray(), 1 ) ) );
386
- $this->result->setValue('name', $this->name );
387
- $this->result->setValue('time', $this->time);
388
- $this->result->setValue('type', 'local');
389
- $this->result->setValue('counts', count($urls) );
390
- $size = WPADM_getSize( $totalSize ); /// MByte
391
- $log = str_replace("%s", $size , __('Backup size %s','dropbox-backup') ) ;
392
- WPAdm_Core::log($log);
393
-
394
- $remove_from_server = 0;
395
- #Removing TMP-files
396
- WPAdm_Core::rmdir($mysql_dump_file);
397
-
398
- #Removind old backups(if limit the number of stored backups)
399
- if ($this->params['limit'] != 0) {
400
- WPAdm_Core::log( __('Limits of Backups ','dropbox-backup') . $this->params['limit'] );
401
- WPAdm_Core::log( __('Removing of old Backups was started','dropbox-backup') );
402
- $files = glob(DROPBOX_BACKUP_DIR_BACKUP . '/*');
403
- if (count($files) > $this->params['limit']) {
404
- $files2 = array();
405
- foreach($files as $f) {
406
- $fa = explode('-', $f);
407
- if (count($fa) != 3) {
408
- continue;
409
- }
410
- $files2[$fa[2]] = $f;
411
-
412
- }
413
- ksort($files2);
414
- $d = count($files2) - $this->params['limit'];
415
- $del = array_slice($files2, 0, $d);
416
- foreach($del as $d) {
417
- WPAdm_Core::rmdir($d);
418
- }
419
- }
420
- WPAdm_Core::log( __('Removing of old Backups was Finished','dropbox-backup') );
421
- }
422
- } else {
423
- return true;
424
- }
425
- }
426
- } else {
427
- return true;
428
  }
429
- }
430
- if ( WPAdm_Running::is_stop() ) {
431
- wpadm_class::setBackup(1);
432
- if (!empty($errors)) {
433
- $this->result->setError(implode("\n", $errors));
434
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
435
- WPAdm_Core::rmdir($this->dir);
436
- wpadm_class::setStatus(0);
437
- wpadm_class::setErrors( implode(", ", $errors) );
438
- } else {
439
- wpadm_class::setStatus(1);
440
- WPAdm_Core::log( __('Backup creation was complete successfully!','dropbox-backup') );
441
  }
442
- wpadm_class::backupSend();
443
- } else {
444
- return true;
445
  }
446
- return $this->result;
447
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
448
 
449
  }
450
- public function createListFilesForArchive()
451
- {
452
- $inludes = get_option(PREFIX_BACKUP_ . "plus-path");
453
- if($inludes !== false) {
454
- $f = explode(',', base64_decode( $inludes ) );
455
- $files = array();
456
- $n = count($f);
457
- $tmp_folder = '';
458
- for($i = 0; $i < $n; $i++) {
459
- if (!empty($tmp_folder) && strpos($f[$i], $tmp_folder) === false) {
460
- $fi = $this->directoryToArray(ABSPATH . $tmp_folder, true );
461
- $files = array_merge($files, $fi);
462
- $tmp_folder = '';
463
- } elseif(!empty($tmp_folder) && strpos($f[$i], $tmp_folder) !== false) {
464
- $tmp_folder = '';
465
- }
466
-
467
- if( is_dir( ABSPATH . $f[$i] ) ) {
468
- //$fi = $this->directoryToArray(ABSPATH . $f[$i], true );
469
- $tmp_folder = $f[$i];
470
- //$files = array_merge($files, $fi);
471
- } elseif (file_exists(ABSPATH . $f[$i])) {
472
- $files[$i] = ABSPATH . $f[$i];
473
- }
474
- }
475
- } else {
476
- $folders = array();
477
- $files = array();
478
-
479
- $files = array_merge(
480
- $files,
481
- array(
482
- //ABSPATH . '.htaccess',
483
- ABSPATH . 'index.php',
484
- // ABSPATH . 'license.txt',
485
- // ABSPATH . 'readme.html',
486
- ABSPATH . 'wp-activate.php',
487
- ABSPATH . 'wp-blog-header.php',
488
- ABSPATH . 'wp-comments-post.php',
489
- ABSPATH . 'wp-config.php',
490
- // ABSPATH . 'wp-config-sample.php',
491
- ABSPATH . 'wp-cron.php',
492
- ABSPATH . 'wp-links-opml.php',
493
- ABSPATH . 'wp-load.php',
494
- ABSPATH . 'wp-login.php',
495
- ABSPATH . 'wp-mail.php',
496
- ABSPATH . 'wp-settings.php',
497
- //ABSPATH . 'wp-signup.php',
498
- ABSPATH . 'wp-trackback.php',
499
- ABSPATH . 'xmlrpc.php',
500
- )
501
- );
502
- if ( file_exists(ABSPATH . '.htaccess') ) {
503
- $files = array_merge( $files, array( ABSPATH . '.htaccess' ) );
504
- }
505
- if ( file_exists( ABSPATH . 'license.txt' ) ) {
506
- $files = array_merge( $files, array( ABSPATH . 'license.txt' ) );
507
- }
508
- if ( file_exists( ABSPATH . 'readme.html' ) ) {
509
- $files = array_merge( $files, array( ABSPATH . 'readme.html') );
510
- }
511
- if ( file_exists(ABSPATH . 'wp-config-sample.php') ) {
512
- $files = array_merge( $files, array( ABSPATH . 'wp-config-sample.php' ) );
513
- }
514
- if ( file_exists(ABSPATH . 'robots.txt') ) {
515
- $files = array_merge( $files, array( ABSPATH . 'robots.txt' ) );
516
- }
517
- if ( file_exists(ABSPATH . 'wp-signup.php') ) {
518
- $files = array_merge( $files, array( ABSPATH . 'wp-signup.php' ) );
519
- }
520
 
521
- // check files in root directory
522
- $n = count($files);
523
- for($i = 0; $i < $n; $i++) {
524
- if (!file_exists($files[$i])) {
525
- unset($files[$i]);
526
- }
527
- }
528
- $files = array_values($files);
529
-
530
- if (!empty($this->params['minus-path'])) {
531
- $minus_path = explode(",", $this->params['minus-path']);
532
- foreach($files as $k => $v) {
533
- $v = str_replace(ABSPATH , '', $v);
534
- if (in_array($v, $minus_path)) {
535
- unset($files[$k]);
536
- WPAdm_Core::log( __('Skip of File ','dropbox-backup') . $v);
537
- }
538
  }
539
  }
 
540
 
541
- $folders = array_merge(
542
- $folders,
543
- array(
544
- ABSPATH . 'wp-admin',
545
- ABSPATH . 'wp-content',
546
- ABSPATH . 'wp-includes',
547
- )
548
- );
549
- if (!empty($this->params['plus-path'])) {
550
- $plus_path = explode(",", $this->params['plus-path']);
551
- foreach($plus_path as $p) {
552
- if (empty($p)) {
553
- continue;
554
- }
555
- $p = ABSPATH . $p;
556
- if (file_exists($p)) {
557
- if (is_dir($p)) {
558
- $folders[] = $p;
559
- } else{
560
- $files[] = $p;
561
- }
562
  }
563
  }
564
  }
 
565
 
566
- $folders = array_unique($folders);
567
- $files = array_unique($files);
568
 
569
- foreach($folders as $folder) {
570
- if (!is_dir($folder)) {
571
- continue;
572
- }
573
- $files = array_merge($files, $this->directoryToArray($folder, true));
574
  }
 
575
  }
576
-
577
- $files = array_values( array_unique($files) );
578
-
579
  return $files;
580
  }
581
 
582
- public function tryToUtf8( $string, $strip = false )
583
- {
584
- $string = (string) $string;
585
-
586
- if ( 0 === strlen( $string ) ) {
587
- return '';
588
- }
589
- // preg match invalid UTF8
590
- if ( 1 === @preg_match( '/^./us', $string ) ) {
591
- return $string;
592
- }
593
-
594
- if ( $strip && function_exists( 'iconv' ) ) {
595
- return iconv( 'utf-8', 'utf-8', $string );
596
- }
597
-
598
- return $string;
599
- }
600
 
601
  private function directoryToArray($directory, $recursive) {
602
  $array_items = array();
@@ -606,7 +312,7 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
606
  if (isset($this->params['minus-path'])) {
607
  $minus_path = explode(",", $this->params['minus-path']);
608
  if (in_array($d, $minus_path) ) {
609
- WPAdm_Core::log(__('Skip of Folder ','dropbox-backup') . $directory);
610
  return array();
611
  }
612
  } else {
@@ -615,47 +321,18 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
615
 
616
  $d = str_replace('\\', '/', $d);
617
  $tmp = explode('/', $d);
618
- if (function_exists('mb_strtolower')) {
619
- $d1 = mb_strtolower($tmp[0]);
620
- } else {
621
- $d1 = strtolower($tmp[0]);
622
- }
623
- $base_dir = $tmp[0];
624
  unset($tmp[0]);
625
- if (function_exists('mb_strtolower')) {
626
- $d2 = mb_strtolower(implode('/', $tmp));
627
- } else {
628
- $d2 = strtolower(implode('/', $tmp));
629
- }
630
-
631
- if (stripos($d2, 'cache') !== false ) {
632
- WPAdm_Core::log( __('Skip of Cache-Folder ','dropbox-backup') . $directory);
633
- return array();
634
- }
635
-
636
- if (strpos($d2, 'cache') !== false && isset($tmp[0]) && !in_array($tmp[0], array('plugins', 'themes')) ) {
637
- WPAdm_Core::log(__('Skip of Cache-Folder ','dropbox-backup') . $directory);
638
- return array();
639
- }
640
-
641
- if (!empty($d2) && isset( $base_dir ) && BackupsFoldersExclude( basename( $d2 ), $base_dir ) ) {
642
- WPAdm_Core::log( sprintf( __('Skip backup folder of another backup plugin "%s" ','dropbox-backup'), basename( $d2 ) ) );
643
- return array();
644
- }
645
-
646
- if(strpos($directory, 'wpadm_backups') !== false || strpos($directory, 'Dropbox_Backup') !== false) {
647
- return array();
648
- }
649
-
650
- if (stripos($d2, 'backup') !== false ) {
651
- WPAdm_Core::log( __('Skip of Backup-Folder ','dropbox-backup') . $directory);
652
  return array();
653
  }
654
 
655
  if ($handle = opendir($directory)) {
656
  while (false !== ($file = readdir($handle))) {
657
- if ($file != "." && $file != ".." && $file != 'tmp') {
658
- if (is_dir($directory. "/" . $file) ) {
659
  if($recursive) {
660
  $array_items = array_merge($array_items, $this->directoryToArray($directory. "/" . $file, $recursive));
661
  }
@@ -668,7 +345,7 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
668
  if (!in_array($f, $minus_path)) {
669
  $array_items[] = $ff;
670
  } else {
671
- WPAdm_Core::log(__('Skip of File ','dropbox-backup') . $ff);
672
  }
673
  }
674
  } else {
@@ -678,9 +355,9 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
678
  $f = str_replace(ABSPATH, '', $ff);
679
  // skip "minus" dirs
680
  if (!in_array($f, $minus_path)) {
681
- $array_items[] = $this->tryToUtf8( $ff );
682
  } else {
683
- WPAdm_Core::log( __('Skip of Folder ','dropbox-backup') . $ff);
684
  }
685
  }
686
  }
@@ -718,51 +395,7 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
718
  private function init(array $conf) {
719
  $this->id = $conf['id'];
720
  $this->stime = $conf['stime'];
721
- //$this->queue = new WPAdm_Queue($this->id);
722
- }
723
-
724
- private function getArchiveName($name)
725
- {
726
- //WPAdm_Core::log("{$name}-*.zip");
727
- $targz = WPAdm_Running::getCommandResultData('test_targz_archive');
728
- if (!empty($targz) && $targz === true ) {
729
- $archives = glob("{$name}-*.tar.gz");
730
- } else {
731
- $archives = glob("{$name}-*.zip");
732
- }
733
-
734
- if (empty($archives)) {
735
- if (!empty($targz) && $targz === true ) {
736
- return "{$name}-1.tar.gz";
737
- } else {
738
- return "{$name}-1.zip";
739
- }
740
- }
741
- $n = count($archives);
742
- if (!empty($targz) && $targz === true ) {
743
- $f = "{$name}-{$n}.tar.gz";
744
- } else {
745
- $f = "{$name}-{$n}.zip";
746
- }
747
- return $f;
748
- }
749
-
750
- private function getNextArchiveName($name)
751
- {
752
- $targz = WPAdm_Running::getCommandResultData('test_targz_archive');
753
- if (!empty($targz) && $targz === true ) {
754
- $archives = glob("{$name}-*.tar.gz");
755
- } else {
756
- $archives = glob("{$name}-*.zip");
757
- }
758
- $n = 1 + count($archives);
759
- if (!empty($targz) && $targz === true ) {
760
- $a = "{$name}-{$n}.tar.gz";
761
- } else {
762
- $a = "{$name}-{$n}.zip";
763
- }
764
- //WPAdm_Core::log($a);
765
- return $a;
766
  }
767
  }
768
  }
1
  <?php
2
 
 
 
3
  if (!class_exists('WPAdm_Method_Local_Backup')) {
4
  class WPAdm_Method_Local_Backup extends WPAdm_Method_Class {
5
 
6
  private $start = true;
7
 
 
 
8
  public function __construct($params)
9
  {
10
+ parent::__construct($params);
11
+ $this->init(
12
+ array(
13
+ 'id' => uniqid('wpadm_method_backup__'),
14
+ 'stime' => time(),
15
+ )
16
+ );
17
+ $file_log = WPAdm_Core::getTmpDir() . "/log.log";
18
+ if (file_exists($file_log)) {
19
+ unlink($file_log);
20
+ }
21
+ WPAdm_Core::log(langWPADM::get('Create Unique Id ', false) . $this->id);
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
+ $name = get_option('siteurl');
 
 
 
 
 
 
 
25
 
26
+ $name = str_replace("http://", '', $name);
27
+ $name = str_replace("https://", '', $name);
28
+ $name = preg_replace("|\W|", "_", $name);
29
+ if (isset($params['time']) && !empty($params['time'])) { // time 1432751372
30
+ $this->time = date("Y-m-d H:i", $params['time']);
31
+ $name .= '-' . wpadm_class::$type . '-' . date("Y_m_d_H_i", $params['time']);
32
+ } else {
33
+ $this->time = date("Y-m-d H:i"); //23.04.2015 13:45
34
+ $name .= '-' . wpadm_class::$type . '-' . date("Y_m_d_H_i");
35
+ }
36
+ $this->name = $name;
37
 
38
 
39
+ // folder for backup
40
+ $this->dir = ABSPATH . 'wpadm_backups/' . $this->name;
41
+ if (($f = $this->checkBackup()) !== false) {
42
+ $this->dir = ABSPATH . 'wpadm_backups/' . $f;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
44
+ WPAdm_Core::mkdir(ABSPATH . 'wpadm_backups/');
45
+ WPAdm_Core::mkdir($this->dir);
46
  }
47
  public function checkBackup()
48
  {
49
+ $archives = glob("{$this->dir}");
50
+ if (empty($archives) && count($archives) <= 1) {
51
+ return false;
 
 
 
 
 
52
  }
53
+ $n = count($archives);
54
+ $f = "{$this->name}({$n})";
55
+ return $f;
56
  }
57
  public function getResult()
58
  {
59
+ if ($this->start === false) {
60
+ $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
61
+ $this->result->setError(langWPADM::get('Backup process was started, please, wait a few minutes...', false));
62
+ return $this->result;
63
+ }
64
  $errors = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
+ $this->result->setResult(WPAdm_Result::WPADM_RESULT_SUCCESS);
67
+ $this->result->setError('');
 
 
 
68
 
69
+ WPAdm_Core::log(langWPADM::get('Start Backup process...', false));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
+ # create db dump
72
+ if (in_array('db', $this->params['types']) ) {
73
+ WPAdm_Core::log(langWPADM::get('Creating Database Dump', false));
74
+ WPAdm_Core::mkdir(ABSPATH . 'wpadm_backup');
75
+ $mysql_dump_file = ABSPATH . 'wpadm_backup/mysqldump.sql';
76
+ if (file_exists($mysql_dump_file)) {
77
+ unlink($mysql_dump_file);
78
+ }
79
+ $wp_mysql_params = $this->getWpMysqlParams();
80
+
81
+ if (isset($this->params['optimize']) && ($this->params['optimize']==1)) {
82
+ WPAdm_Core::log(langWPADM::get('Optimize Database Tables', false));
83
+ $commandContext = new WPAdm_Command_Context();
84
+ $commandContext ->addParam('command','mysqloptimize')
85
+ ->addParam('host', $wp_mysql_params['host'])
86
+ ->addParam('db', $wp_mysql_params['db'])
87
+ ->addParam('user', $wp_mysql_params['user'])
88
+ ->addParam('password', $wp_mysql_params['password']);
89
+ $this->queue->clear()
90
+ ->add($commandContext);
91
+ unset($commandContext);
92
+ }
 
93
 
94
+ $commandContext = new WPAdm_Command_Context();
95
+ $commandContext ->addParam('command','mysqldump')
96
+ ->addParam('host', $wp_mysql_params['host'])
97
+ ->addParam('db', $wp_mysql_params['db'])
98
+ ->addParam('user', $wp_mysql_params['user'])
99
+ ->addParam('password', $wp_mysql_params['password'])
100
+ ->addParam('tables', '')
101
+ ->addParam('to_file', $mysql_dump_file);
102
+ $res = $this->queue->add($commandContext)
103
+ ->save()
104
+ ->execute();
105
+ if (!$res) {
106
+ $log = str_replace('%s', $this->queue->getError(), langWPADM::get('Error: Dump of Database wasn\'t created (%s)', false) );
107
+ WPAdm_Core::log($log);
108
+ $errors[] = $log;
109
+ } elseif (0 == (int)filesize($mysql_dump_file)) {
110
+ $errors[] = langWPADM::get('MySQL Error: Database-Dump File is empty', false);
111
+ WPAdm_Core::log(langWPADM::get('Dump of Database wasn\'t created (File of Database-Dump is empty!)', false));
112
+ } else {
113
+ $size_dump = round( (filesize($mysql_dump_file) / 1024 / 1024) , 2);
114
+ $log = str_replace("%s", $size_dump , langWPADM::get('Database Dump was successfully created ( %s Mb) : ', false) ) ;
115
+ WPAdm_Core::log($log . $mysql_dump_file);
116
+ }
117
+ unset($commandContext);
118
+ }
119
 
 
 
120
 
121
+ if (in_array('files', $this->params['types']) ) {
122
+ #ЗАРХИВИРУЕМ ФАЙЛЫ
123
+ WPAdm_Core::log( langWPADM::get('Create a list of files for Backup', false) );
124
+ $files = $this->createListFilesForArchive();
125
+ }
126
+ if (isset($mysql_dump_file) && file_exists($mysql_dump_file) && filesize($mysql_dump_file) > 0) {
127
+ $files[] = $mysql_dump_file;
128
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
 
130
+ if (empty($files)) {
131
+ $errors[] = langWPADM::get('Error: the list of Backup files is empty', false);
132
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
134
+ // split the file list by 170kbayt lists, To break one big task into smaller
135
+ $files2 = array();
136
+ $files2[0] = array();
137
+ $i = 0;
138
+ $size = 0;
139
+ foreach($files as $f) {
140
+ if ($size > 170000) {//~170kbyte
141
+ $i ++;
142
+ $size = 0;
143
+ $files2[$i] = array();
144
+ }
145
+ $f_size =(int)@filesize($f);
146
+ if ($f_size == 0 || $f_size > 1000000) {
147
+ WPAdm_Core::log('File '. $f .' Size ' . $f_size);
148
+ }
149
+ $size += $f_size;
150
+ $files2[$i][] = $f;
151
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
 
153
+ WPAdm_Core::log( langWPADM::get('List of Backup-Files was successfully created', false) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
 
155
+ $this->queue->clear();
 
156
 
157
+ foreach($files2 as $files) {
158
+ $commandContext = new WPAdm_Command_Context();
159
+ $commandContext ->addParam('command', 'archive')
160
+ ->addParam('files', $files)
161
+ ->addParam('to_file', $this->dir . '/'.$this->name)
162
+ ->addParam('max_file_size', 900000)
163
+ ->addParam('remove_path', ABSPATH);
164
+
165
+ $this->queue->add($commandContext);
166
+ unset($commandContext);
167
+ }
168
+ WPAdm_Core::log( langWPADM::get('Backup of Files was started', false) );
169
+ $this->queue->save()
170
+ ->execute();
171
+ WPAdm_Core::log( langWPADM::get('End of File Backup', false) );
172
+
173
+ $files = glob($this->dir . '/'.$this->name . '*');
174
+ $urls = array();
175
+ $totalSize = 0;
176
+ foreach($files as $file) {
177
+ $urls[] = str_replace(ABSPATH, '', $file);
178
+ $totalSize += @intval( filesize($file) );
179
+ }
180
+ $this->result->setData($urls);
181
+ $this->result->setSize($totalSize);
182
+ $size = $totalSize / 1024 / 1024; /// MByte
183
+ $size = round($size, 2);
184
+ $log = str_replace("%s", $size , langWPADM::get('Backup Size %s Mb', false) ) ;
185
+ WPAdm_Core::log($log);
186
+
187
+ $remove_from_server = 0;
188
+ #Removing TMP-files
189
+ WPAdm_Core::rmdir(ABSPATH . 'wpadm_backup');
190
+
191
+ #Removind old backups(if limit the number of stored backups)
192
+ if ($this->params['limit'] != 0) {
193
+ WPAdm_Core::log( langWPADM::get('Limits of Backups ', false) . $this->params['limit'] );
194
+ WPAdm_Core::log( langWPADM::get('Removing of old Backups was started', false) );
195
+ $files = glob(ABSPATH . 'wpadm_backups/*');
196
+ if (count($files) > $this->params['limit']) {
197
+ $files2 = array();
198
+ foreach($files as $f) {
199
+ $fa = explode('-', $f);
200
+ if (count($fa) != 3) {
201
+ continue;
202
  }
203
+ $files2[$fa[2]] = $f;
204
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  }
206
+ ksort($files2);
207
+ $d = count($files2) - $this->params['limit'];
208
+ $del = array_slice($files2, 0, $d);
209
+ foreach($del as $d) {
210
+ WPAdm_Core::rmdir($d);
 
 
 
 
 
 
 
211
  }
 
 
 
212
  }
213
+ WPAdm_Core::log( langWPADM::get('Removing of old Backups was Finished', false) );
214
  }
215
+ wpadm_class::setBackup(1);
216
+ if (!empty($errors)) {
217
+ $this->result->setError(implode("\n", $errors));
218
+ $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
219
+ wpadm_class::setStatus(0);
220
+ wpadm_class::setErrors( implode(", ", $errors) );
221
+ } else {
222
+ wpadm_class::setStatus(1);
223
+ WPAdm_Core::log( langWPADM::get('Backup creating is completed successfully!', false) );
224
+ }
225
+ wpadm_class::backupSend();
226
+
227
+ return $this->result;
228
 
229
  }
230
+ public function createListFilesForArchive() {
231
+ $folders = array();
232
+ $files = array();
233
+
234
+ $files = array_merge(
235
+ $files,
236
+ array(
237
+ ABSPATH . '.htaccess',
238
+ ABSPATH . 'index.php',
239
+ ABSPATH . 'license.txt',
240
+ ABSPATH . 'readme.html',
241
+ ABSPATH . 'wp-activate.php',
242
+ ABSPATH . 'wp-blog-header.php',
243
+ ABSPATH . 'wp-comments-post.php',
244
+ ABSPATH . 'wp-config.php',
245
+ ABSPATH . 'wp-config-sample.php',
246
+ ABSPATH . 'wp-cron.php',
247
+ ABSPATH . 'wp-links-opml.php',
248
+ ABSPATH . 'wp-load.php',
249
+ ABSPATH . 'wp-login.php',
250
+ ABSPATH . 'wp-mail.php',
251
+ ABSPATH . 'wp-settings.php',
252
+ ABSPATH . 'wp-signup.php',
253
+ ABSPATH . 'wp-trackback.php',
254
+ ABSPATH . 'xmlrpc.php',
255
+ )
256
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
 
258
+ if (!empty($this->params['minus-path'])) {
259
+ $minus_path = explode(",", $this->params['minus-path']);
260
+ foreach($files as $k => $v) {
261
+ $v = str_replace(ABSPATH , '', $v);
262
+ if (in_array($v, $minus_path)) {
263
+ unset($files[$k]);
264
+ WPAdm_Core::log( langWPADM::get('Skip of File ', false) . $v);
 
 
 
 
 
 
 
 
 
 
265
  }
266
  }
267
+ }
268
 
269
+ $folders = array_merge(
270
+ $folders,
271
+ array(
272
+ ABSPATH . 'wp-admin',
273
+ ABSPATH . 'wp-content',
274
+ ABSPATH . 'wp-includes',
275
+ )
276
+ );
277
+ if (!empty($this->params['plus-path'])) {
278
+ $plus_path = explode(",", $this->params['plus-path']);
279
+ foreach($plus_path as $p) {
280
+ if (empty($p)) {
281
+ continue;
282
+ }
283
+ $p = ABSPATH . $p;
284
+ if (file_exists($p)) {
285
+ if (is_dir($p)) {
286
+ $folders[] = $p;
287
+ } else{
288
+ $files[] = $p;
 
289
  }
290
  }
291
  }
292
+ }
293
 
294
+ $folders = array_unique($folders);
295
+ $files = array_unique($files);
296
 
297
+ foreach($folders as $folder) {
298
+ if (!is_dir($folder)) {
299
+ continue;
 
 
300
  }
301
+ $files = array_merge($files, $this->directoryToArray($folder, true));
302
  }
 
 
 
303
  return $files;
304
  }
305
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
 
307
  private function directoryToArray($directory, $recursive) {
308
  $array_items = array();
312
  if (isset($this->params['minus-path'])) {
313
  $minus_path = explode(",", $this->params['minus-path']);
314
  if (in_array($d, $minus_path) ) {
315
+ WPAdm_Core::log(langWPADM::get('Skip of Folder ', false) . $directory);
316
  return array();
317
  }
318
  } else {
321
 
322
  $d = str_replace('\\', '/', $d);
323
  $tmp = explode('/', $d);
324
+ $d1 = mb_strtolower($tmp[0]);
 
 
 
 
 
325
  unset($tmp[0]);
326
+ $d2 = mb_strtolower(implode('/', $tmp));
327
+ if (strpos($d2, 'cache') !== false && isset($tmp[0])&& !in_array($tmp[0], array('plugins', 'themes')) ) {
328
+ WPAdm_Core::log(langWPADM::get('Skip of Cache-Folder ', false) . $directory);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
329
  return array();
330
  }
331
 
332
  if ($handle = opendir($directory)) {
333
  while (false !== ($file = readdir($handle))) {
334
+ if ($file != "." && $file != "..") {
335
+ if (is_dir($directory. "/" . $file)) {
336
  if($recursive) {
337
  $array_items = array_merge($array_items, $this->directoryToArray($directory. "/" . $file, $recursive));
338
  }
345
  if (!in_array($f, $minus_path)) {
346
  $array_items[] = $ff;
347
  } else {
348
+ WPAdm_Core::log(langWPADM::get('Skip of File ', false) . $ff);
349
  }
350
  }
351
  } else {
355
  $f = str_replace(ABSPATH, '', $ff);
356
  // skip "minus" dirs
357
  if (!in_array($f, $minus_path)) {
358
+ $array_items[] = $ff;
359
  } else {
360
+ WPAdm_Core::log( langWPADM::get('Skip of Folder ', false) . $ff);
361
  }
362
  }
363
  }
395
  private function init(array $conf) {
396
  $this->id = $conf['id'];
397
  $this->stime = $conf['stime'];
398
+ $this->queue = new WPAdm_Queue($this->id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399
  }
400
  }
401
  }
methods/class-wpadm-method-local-restore.php CHANGED
@@ -1,8 +1,4 @@
1
  <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
-
6
  /**
7
  * Class WPAdm_Method_Exec
8
  */
@@ -29,7 +25,7 @@ if (!class_exists('WPAdm_Method_Local_Restore')) {
29
  if (file_exists($file_log)) {
30
  unlink($file_log);
31
  }
32
- WPAdm_Core::log(__('Create Unique Id ','dropbox-backup') . $this->id);
33
  if (count($this->files_resotre) > 0) {
34
  $this->restore = true;
35
  }
@@ -37,42 +33,28 @@ if (!class_exists('WPAdm_Method_Local_Restore')) {
37
  }
38
  private function getFiles()
39
  {
40
- $res = false;
41
  if (isset($this->params['name_backup']) && !empty($this->params['name_backup'])) {
42
- $res = self::readFiles( DROPBOX_BACKUP_DIR_BACKUP . '/' . $this->params['name_backup'] );
43
- if ($res === false) {
44
- $res = self::readFiles(WPADM_DIR_BACKUP . '/' . $this->params['name_backup']);
45
- }
46
- if ($res === false) {
47
- $res = self::readFiles(ABSPATH . WPADM_DIR_NAME . '/' . $this->params['name_backup']);
48
- }
49
- }
50
- if ($res === false) {
51
- $str = str_replace(array('%d', '%s'), array(SITE_HOME, $this->params['name_backup']), __('Website "%d" returned an error during backup restoration: Archive of Backup wasn\'t found "%s"','dropbox-backup') );
52
- WPAdm_Core::log($str);
53
- $this->setError($str);
54
- }
55
- return $res;
56
-
57
- }
58
-
59
- private function readFiles($dir_backup)
60
- {
61
- if (is_dir($dir_backup)) {
62
- WPAdm_Core::log('Read of Backup Files for Restore (' . $this->params['name_backup'] . ')');
63
- $dir_open = opendir($dir_backup);
64
- while($d = readdir($dir_open)) {
65
- if ($d != "." && $d != '..') {
66
- if(strpos($d, ".md5") !== false) {
67
- $this->md5_info = explode ("\n", file_get_contents( $dir_backup . "/$d" ) );
68
- } elseif(strpos($d, ".zip") !== false) {
69
- $this->files_resotre[$d] = $dir_backup . "/$d";
70
  }
71
  }
 
72
  }
73
- return true;
74
- }
 
 
75
  return false;
 
76
  }
77
  private function setError($errors)
78
  {
@@ -91,9 +73,11 @@ if (!class_exists('WPAdm_Method_Local_Restore')) {
91
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_SUCCESS);
92
  $this->result->setError('');
93
 
94
- WPAdm_Core::log(__('Start Restore process','dropbox-backup'));
95
  $n = count($this->md5_info);
96
-
 
 
97
  if (in_array('files', $this->params['types']) ) {
98
  foreach($this->files_resotre as $key => $file) {
99
  if (file_exists($file)) {
@@ -125,11 +109,8 @@ if (!class_exists('WPAdm_Method_Local_Restore')) {
125
  ->add($commandContext)->save()
126
  ->execute();
127
  unset($commandContext);
128
- if (file_exists(DROPBOX_BACKUP_DIR_BACKUP . "/mysqldump.sql")) {
129
- @unlink(DROPBOX_BACKUP_DIR_BACKUP . "/mysqldump.sql");
130
- }
131
  } else {
132
- $log = str_replace( array('%d', '%s'), array(SITE_HOME, $data[2]) , __('Website "%d" returned an error during backup restoration: Part Backup is not exist "%s" ','dropbox-backup'));
133
  $this->setError($log);
134
  WPAdm_Core::log($log);
135
  break;
@@ -138,9 +119,7 @@ if (!class_exists('WPAdm_Method_Local_Restore')) {
138
  }
139
  }
140
  } else {
141
- WPAdm_Core::log(
142
- str_replace( array('%d'), array(SITE_HOME), __('Website "%d" returned an error during restore backup: Files for restore is not exist, check permission your backup data or You can send to us support request using "Help" button on plugin page.','dropbox-backup') )
143
- );
144
  }
145
  return $this->result;
146
  }
1
  <?php
 
 
 
 
2
  /**
3
  * Class WPAdm_Method_Exec
4
  */
25
  if (file_exists($file_log)) {
26
  unlink($file_log);
27
  }
28
+ WPAdm_Core::log(langWPADM::get('Create Unique Id ', false) . $this->id);
29
  if (count($this->files_resotre) > 0) {
30
  $this->restore = true;
31
  }
33
  }
34
  private function getFiles()
35
  {
 
36
  if (isset($this->params['name_backup']) && !empty($this->params['name_backup'])) {
37
+ $dir_backup = ABSPATH . 'wpadm_backups/' . $this->params['name_backup'];
38
+ if (is_dir($dir_backup)) {
39
+ WPAdm_Core::log('Read of Backup Files for Restore (' . $this->params['name_backup'] . ')');
40
+ $dir_open = opendir($dir_backup);
41
+ while($d = readdir($dir_open)) {
42
+ if ($d != "." && $d != '..') {
43
+ if(strpos($d, ".md5") !== false) {
44
+ $this->md5_info = explode ("\n", file_get_contents( $dir_backup . "/$d" ) );
45
+ } elseif(strpos($d, ".zip") !== false) {
46
+ $this->files_resotre[$d] = $dir_backup . "/$d";
47
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
  }
50
+ return true;
51
  }
52
+ }
53
+ $str = str_replace('%s', $this->params['name_backup'], langWPADM::get('Error: folder is not exist (%s)', false));
54
+ WPAdm_Core::log($str);
55
+ $this->setError($str);
56
  return false;
57
+
58
  }
59
  private function setError($errors)
60
  {
73
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_SUCCESS);
74
  $this->result->setError('');
75
 
76
+ WPAdm_Core::log(langWPADM::get('Start Restore process', false));
77
  $n = count($this->md5_info);
78
+ if (in_array('db', $this->params['types'])) {
79
+
80
+ }
81
  if (in_array('files', $this->params['types']) ) {
82
  foreach($this->files_resotre as $key => $file) {
83
  if (file_exists($file)) {
109
  ->add($commandContext)->save()
110
  ->execute();
111
  unset($commandContext);
 
 
 
112
  } else {
113
+ $log = str_replace("%s", $data[2], langWPADM::get('File (%s) not Exist', false) );
114
  $this->setError($log);
115
  WPAdm_Core::log($log);
116
  break;
119
  }
120
  }
121
  } else {
122
+ WPAdm_Core::log(langWPADM::get('Files to restore is empty', false));
 
 
123
  }
124
  return $this->result;
125
  }
methods/class-wpadm-method-ping.php CHANGED
@@ -1,7 +1,5 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
  if (!class_exists('WPAdm_Method_Ping')) {
6
  class WPAdm_Method_Ping extends WPAdm_Method_Class {
7
  public function getResult()
@@ -11,9 +9,7 @@ if (!class_exists('WPAdm_Method_Ping')) {
11
  if ( ! function_exists( 'get_plugins' ) ) {
12
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
13
  }
14
- $plugin_dir = WPAdm_Core::getPluginDir();
15
- $plugin_dir_array = explode("/", $plugin_dir );
16
- $plugin_name = array_pop( $plugin_dir_array );
17
  $plugin_name2 = str_replace("-", "_", $plugin_name);
18
  $plugin = get_plugins("/$plugin_name");
19
  $pl_version = "";
1
  <?php
2
 
 
 
3
  if (!class_exists('WPAdm_Method_Ping')) {
4
  class WPAdm_Method_Ping extends WPAdm_Method_Class {
5
  public function getResult()
9
  if ( ! function_exists( 'get_plugins' ) ) {
10
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
11
  }
12
+ $plugin_name = array_pop( explode("/", WPAdm_Core::getPluginDir()) );
 
 
13
  $plugin_name2 = str_replace("-", "_", $plugin_name);
14
  $plugin = get_plugins("/$plugin_name");
15
  $pl_version = "";
methods/class-wpadm-method-queue-controller.php CHANGED
@@ -1,8 +1,6 @@
1
  <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
  /**
 
6
  * Class WPAdm_Method_Exec
7
  */
8
  if (!class_exists('WPAdm_Method_Queue_Controller')) {
@@ -48,6 +46,7 @@ if (!class_exists('WPAdm_Method_Queue_Controller')) {
48
  private $id = '';
49
 
50
  public function __construct($params) {
 
51
  $this->stime = time();
52
  parent::__construct($params);
53
  $this->queue_file = WPAdm_Core::getTmpDir() . '/' . $this->params['id'] . '.queue';
@@ -55,7 +54,9 @@ if (!class_exists('WPAdm_Method_Queue_Controller')) {
55
  $this->log("queue-file not exists: {$this->queue_file}");
56
  exit;
57
  }
 
58
  $queue = unserialize(file_get_contents($this->queue_file));
 
59
  $this->id = $queue['id'];
60
  $this->step = (isset($queue['step']) && (int)$queue['step'] > 1) ? (int)$queue['step']+1 : 1;
61
  $this->contexts = $queue['contexts'];
@@ -64,24 +65,28 @@ if (!class_exists('WPAdm_Method_Queue_Controller')) {
64
 
65
  public function getResult()
66
  {
 
67
  while(!$this->timeIsOver() && $context = $this->getNextContext()) {
68
  $com = $context->get('command');
69
  $cmd = WPAdm_Command_Factory::getCommand($com);
70
  if ($cmd === null) {
71
- $this->result->setError( str_replace(array('%d', '%com'), array(SITE_HOME, $com ), __('Website "%d" returned an error: Command "%com" not found. To solve this problem, we need to access the system logs of your hosting/server and/or from your backup, that you tried to create or simply send to us your FTP access data. You can send to us support request using "Help" button on plugin page.','dropbox-backup') ) );
72
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
73
  array_unshift($this->contexts, $context);
74
  $this->done();
75
  return $this->result;
76
  } elseif (!$cmd->execute($context)) {
77
- $this->result->setError( str_replace(array('%d', '%com'), array(SITE_HOME, $com ), __('Website "%d" returned some unknown error during command "%com" was running. To solve this problem, we need to access the system logs of your hosting/server and/or from your backup, that you tried to create or simply send to us your FTP access data. You can send to us support request using "Help" button on plugin page.','dropbox-backup') ) );
 
78
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
79
  array_unshift($this->contexts, $context);
80
  $this->done();
81
  return $this->result;
82
  } else {
83
-
 
84
  }
 
85
  }
86
 
87
  if ($this->step >= self::MAX_COUNT_STEPS) {
@@ -90,7 +95,7 @@ if (!class_exists('WPAdm_Method_Queue_Controller')) {
90
  }
91
  //если еще есть невыполненые задачи - рестаратуем
92
  if (!empty($this->contexts)) {
93
- //$this->restart();
94
  }
95
 
96
  // если все задачи выполнили, то пометим файл
@@ -120,6 +125,7 @@ if (!class_exists('WPAdm_Method_Queue_Controller')) {
120
  }
121
 
122
  private function restart() {
 
123
  $this->step ++;
124
  $url = get_option('siteurl');
125
  $pu = parse_url($url);
@@ -139,7 +145,8 @@ if (!class_exists('WPAdm_Method_Queue_Controller')) {
139
  // $pl = (defined('WPADM_PLUGIN')) ? WPADM_PLUGIN . '_' : '';
140
  $dp = explode(DIRECTORY_SEPARATOR,dirname(dirname(__FILE__)));
141
  $pl = array_pop($dp) . '_';
142
- $data = $pl.'request=' . wpadm_pack( $data );
 
143
  fwrite($socket, "POST / HTTP/1.1\r\n");
144
  fwrite($socket, "Host: {$host}\r\n");
145
 
1
  <?php
 
 
 
2
  /**
3
+ * Выполнение очереди
4
  * Class WPAdm_Method_Exec
5
  */
6
  if (!class_exists('WPAdm_Method_Queue_Controller')) {
46
  private $id = '';
47
 
48
  public function __construct($params) {
49
+ //WPAdm_Core::log("Запуск очереди. Параметры: " . print_r($params, true));
50
  $this->stime = time();
51
  parent::__construct($params);
52
  $this->queue_file = WPAdm_Core::getTmpDir() . '/' . $this->params['id'] . '.queue';
54
  $this->log("queue-file not exists: {$this->queue_file}");
55
  exit;
56
  }
57
+ //WPAdm_Core::log('Открываем файл очереди ' . $this->queue_file);
58
  $queue = unserialize(file_get_contents($this->queue_file));
59
+ //WPAdm_Core::log(print_r($queue, true));
60
  $this->id = $queue['id'];
61
  $this->step = (isset($queue['step']) && (int)$queue['step'] > 1) ? (int)$queue['step']+1 : 1;
62
  $this->contexts = $queue['contexts'];
65
 
66
  public function getResult()
67
  {
68
+ // пока время не закончилось и есть задачи - выполняем
69
  while(!$this->timeIsOver() && $context = $this->getNextContext()) {
70
  $com = $context->get('command');
71
  $cmd = WPAdm_Command_Factory::getCommand($com);
72
  if ($cmd === null) {
73
+ $this->result->setError('Command error: ' . $com . ' : '. 'Command not found: ' . $com);
74
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
75
  array_unshift($this->contexts, $context);
76
  $this->done();
77
  return $this->result;
78
  } elseif (!$cmd->execute($context)) {
79
+ //произошла какая то ошибка
80
+ $this->result->setError('Command error: ' . $com . ' : '. $context->getError());
81
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
82
  array_unshift($this->contexts, $context);
83
  $this->done();
84
  return $this->result;
85
  } else {
86
+ //команда выполнена успешно
87
+ //WPAdm_Core::log("Команда выполнена: {$com}");
88
  }
89
+ //продолжаем работу
90
  }
91
 
92
  if ($this->step >= self::MAX_COUNT_STEPS) {
95
  }
96
  //если еще есть невыполненые задачи - рестаратуем
97
  if (!empty($this->contexts)) {
98
+ $this->restart();
99
  }
100
 
101
  // если все задачи выполнили, то пометим файл
125
  }
126
 
127
  private function restart() {
128
+ $this->log('restart(' . $this->step .'): ' . $this->id);
129
  $this->step ++;
130
  $url = get_option('siteurl');
131
  $pu = parse_url($url);
145
  // $pl = (defined('WPADM_PLUGIN')) ? WPADM_PLUGIN . '_' : '';
146
  $dp = explode(DIRECTORY_SEPARATOR,dirname(dirname(__FILE__)));
147
  $pl = array_pop($dp) . '_';
148
+ // $data = 'wpadm_'.$pl.'request='.base64_encode(serialize($data));
149
+ $data = $pl.'request='.base64_encode(serialize($data));
150
  fwrite($socket, "POST / HTTP/1.1\r\n");
151
  fwrite($socket, "Host: {$host}\r\n");
152
 
methods/class-wpadm-method-reconnect.php CHANGED
@@ -1,18 +1,15 @@
1
- <?php
2
-
3
-
4
- if ( ! defined( 'ABSPATH' ) ) exit;
5
-
6
- if (!class_exists('WPAdm_Method_Reconnect')) {
7
- class WPAdm_Method_Reconnect extends WPAdm_Method_Class {
8
- public function getResult()
9
- {
10
- // update public key
11
- update_option('wpadm_pub_key', $this->params['pub_key']);
12
-
13
- $this->result->setResult(WPAdm_result::WPADM_RESULT_SUCCESS);
14
- $this->result->setData('');
15
- return $this->result;
16
- }
17
- }
18
  }
1
+ <?php
2
+
3
+ if (!class_exists('WPAdm_Method_Reconnect')) {
4
+ class WPAdm_Method_Reconnect extends WPAdm_Method_Class {
5
+ public function getResult()
6
+ {
7
+ // обновить публичный ключ
8
+ update_option('wpadm_pub_key', $this->params['pub_key']);
9
+
10
+ $this->result->setResult(WPAdm_result::WPADM_RESULT_SUCCESS);
11
+ $this->result->setData('');
12
+ return $this->result;
13
+ }
14
+ }
 
 
 
15
  }
methods/class-wpadm-method-send-to-dropbox.php CHANGED
@@ -1,292 +1,72 @@
1
  <?php
2
-
3
-
4
- if ( ! defined( 'ABSPATH' ) ) exit;
5
-
6
-
7
  /**
8
- * Class WPadm_Method_Send_To_Dropbox
9
- */
 
10
  if (!class_exists('WPadm_Method_Send_To_Dropbox')) {
11
  class WPadm_Method_Send_To_Dropbox extends WPAdm_Method_Class {
12
  /**
13
- * @var WPAdm_Queue
14
- */
15
  private $queue;
16
 
17
  private $id;
18
 
19
- private $time_send = 120; // seconds for send to dropbox
20
  //private $name = '';
21
 
22
  public function getResult()
23
  {
24
- if ( WPAdm_Running::is_stop() ) {
25
- $errors = array();
26
- $this->id = uniqid('wpadm_method_send_to_dropbox_');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_SUCCESS);
29
- $this->result->setError('');
30
- if ( WPAdm_Running::is_stop() ) {
31
- if (isset($this->params['local']) && $this->params['local']) {
32
- $params_data_cron = WPAdm_Running::getCommandResultData('local_backup');
33
- if ( isset($res['result']) && $res['result'] == 'error' ) {
34
- $errors[] = $res['error'];
35
- } else {
36
- $this->params['files'] = $params_data_cron['data'];
37
- $this->params['access_details']['dir'] = $params_data_cron['name'];
38
- }
39
- }
40
- } else {
41
- return true;
42
- }
43
- if ( WPAdm_Running::is_stop() ) {
44
- if (empty($errors)) {
45
 
46
- $ad = $this->params['access_details'];
47
- $files = $this->params['files'];
48
- //$this->getResult()->setData($files);
49
- //$dir = trim($dir, '/') . '/' . $this->name;
50
- if (is_array($files)) {
51
- $send = false;
52
- if (!class_exists('WPAdm_Process')) {
53
- require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-process.php';
54
- }
55
- WPAdm_Process::init( 'dropbox', count($files) );
56
- WPAdm_Core::log( __('Start copy to Dropbox Cloud', 'dropbox-backup') );
57
- foreach($files as $file) {
58
- try {
59
- if (isset($this->params['is_folder_set'])) {
60
- $this->sendFileToDropbox( $file, $ad );
61
- } else {
62
- $this->sendFileToDropbox( ABSPATH . $file, $ad );
63
- }
64
-
65
- } catch (Exception $e) {
66
- $this->result->setError( $e->getMessage() );
67
- $this->result->setResult( WPAdm_Result::WPADM_RESULT_ERROR );
68
- return $this->deleteBackup();
69
- }
70
- if (isset($this->params['local']) && $this->params['local']) {
71
- $data_command = WPAdm_Running::getCommandResultData('command_dropbox');
72
- $data_error_command = WPAdm_Running::getCommandResultData('errors_sending');
73
- if (isset($data_error_command[ABSPATH . $file]) && $data_error_command[ABSPATH . $file]['count'] > WPADM_COUNT_LIMIT_SEND_TO_DROPBOX) {
74
- $msg = str_replace('%file%', $file, __('Not perhaps sending file: "%file%". If you wish make upload file, increase execution time code or speed internet provider is small for upload file.' ,'dropbox-backup'));
75
- WPAdm_Core::log( $msg );
76
- $errors[] = $msg;
77
- break;
78
- }
79
- $md5 = md5(ABSPATH . $file);
80
- if ( !empty($data_command) && in_array($md5, $data_command) ) {
81
- continue;
82
- }
83
- }
84
- /* $commandContext = new WPAdm_Command_Context();
85
- $commandContext->addParam('command', 'send_to_dropbox')
86
- ->addParam('key', $ad['key'])
87
- ->addParam('secret', $ad['secret'])
88
- ->addParam('token', $ad['token'])
89
- ->addParam('folder_project', $ad['folder'])
90
- ->addParam('folder', $dir)
91
- ->addParam('files', ABSPATH . $file);
92
- if (isset($this->params['local']) && $this->params['local']) {
93
- $commandContext->addParam('local', true);
94
- }
95
- $this->queue->add($commandContext);
96
- unset($commandContext);
97
- $send = true;
98
- } */
99
- }
100
- WPAdm_Core::log( __('End Copy Files to Dropbox' ,'dropbox-backup') );
101
- /*if (isset($res) && !$res) {
102
- WPAdm_Core::log(__('Answer from Dropbox ' ,'dropbox-backup') . $this->queue->getError());
103
- $errors[] = __('Answer from Dropbox ' ,'dropbox-backup') . $this->queue->getError();
104
- } */
105
- }
106
- }
107
- } else {
108
- return true;
109
- }
110
- if (count($errors) > 0) {
111
- $this->result->setError(implode("\n", $errors));
112
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
113
- return $this->deleteBackup();
114
- } else {
115
- if ( WPAdm_Running::is_stop() ) {
116
- if (class_exists('wpadm_wp_full_backup_dropbox') && !file_exists( WPAdm_Core::getTmpDir() . "/notice-star") ) {
117
- wpadm_wp_full_backup_dropbox::setFlagToTmp( 'notice-star', time() . "_1d" );
118
- }
119
- if (isset($this->params['local']) && $this->params['local'] && isset($params_data_cron)) {
120
- if ( WPAdm_Running::is_stop() ) {
121
- $this->result->setData($this->params['files']);
122
- $this->result->setSize($params_data_cron['size']);
123
- $this->result->setValue('md5_data', md5 ( print_r($this->result->toArray(), 1 ) ) );
124
- $this->result->setValue('name', $params_data_cron['name']);
125
- $this->result->setValue('time', $params_data_cron['time']);
126
- $this->result->setValue('type', 'dropbox');
127
- $this->result->setValue('counts', $params_data_cron['counts'] );
128
- if( (isset($this->params['is_local_backup']) && $this->params['is_local_backup'] == 0 ) || ( !isset($this->params['is_local_backup']) ) ) {
129
- $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
130
- $dropbox_options = wpadm_wp_full_backup_dropbox::getSettings();
131
- if ($dropbox_options) {
132
- if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
133
- $backup_dir = $dropbox_options['backup_folder'];
134
- }
135
- }
136
- WPAdm_Core::rmdir( $backup_dir . "/{$params_data_cron['name']}");
137
- }
138
- return $this->result;
139
- } else {
140
- return $this->result;
141
- }
142
- }
143
- } else {
144
- return $this->result;
145
- }
146
- }
147
- return $this->result;
148
- }
149
- return true;
150
- }
151
 
152
- private function init(array $conf)
153
- {
 
 
154
  $this->id = $conf['id'];
155
  $this->stime = $conf['stime'];
 
156
  $this->type = $conf['type'];
157
  }
158
-
159
- private function sendFileToDropbox($file, $ad)
160
- {
161
- if ( WPAdm_Running::is_stop() ) {
162
- require_once WPAdm_Core::getPluginDir() . '/modules/dropbox.class.php';
163
- $command_dropbox = WPAdm_Running::getCommandResultData('command_dropbox');
164
- $fromFile = str_replace('//', '/', $file);
165
- $md5 = md5($fromFile);
166
- if (in_array($md5, $command_dropbox)) {
167
- return true;
168
- }
169
- WPAdm_Core::log(__('Send to dropbox files' ,'dropbox-backup') );
170
- $dropbox = new dropbox($ad['key'], $ad['secret'], $ad['token'] );
171
-
172
- if (!$dropbox->isAuth()) {
173
- $this->setError( str_replace(array('%d', '%k', '%s'),
174
- array( SITE_HOME, $ad['key'], $ad['secret'] ),__('Website "%d" can\'t authorize on Dropbox with using of "app key: %k" and "app secret: %s"' ,'dropbox-backup') ) );
175
- return false;
176
- }
177
- $dir = (isset($ad['dir'])) ? $ad['dir'] : '/';
178
- if ( WPAdm_Running::is_stop() ) {
179
- $file_ = explode("/", $file);
180
- $file_name = array_pop($file_);
181
- $folder_project_temp = $ad['folder'];
182
- $folder_project = "";
183
- if (!empty($folder_project_temp)) {
184
- $folder_project = $folder_project_temp . "/";
185
- $dropbox->createDir($folder_project_temp );
186
- $dropbox->createDir($folder_project . $dir );
187
- } else {
188
- $dropbox->createDir( $dir );
189
- }
190
- } else {
191
- return true;
192
- }
193
- //$files = ''; // to comment
194
- $fromFile = str_replace('//', '/', $file);
195
- $toFile = str_replace('//', '/', $folder_project . $dir . '/' . $file_name);
196
- $local = isset( $this->params['local'] ) ? $this->params['local'] : false ;
197
- $file_dropbox = $dropbox->listing($folder_project . $dir. '/' . $file_name);
198
- $send = true;
199
- if ( !isset($file_dropbox['error']) ) {
200
- if ($file_dropbox['bytes'] != filesize($fromFile)) {
201
- if ( WPAdm_Running::is_stop() ) {
202
- $delete_file = $dropbox->deleteFile($folder_project . $dir . '/' . $file_name);
203
- if (isset($delete_file['error'])) {
204
- //$this->setError( __('Dropbox returned an error during file sending: ' ,'dropbox-backup') . '"' . $delete_file['text'] . '"(d)');
205
- //return false;
206
- WPAdm_Core::log( __('File in Dropbox Cloud: ' ,'dropbox-backup') . '"' . $delete_file['text'] . '"' );
207
-
208
- WPAdm_Core::log( __('Try send file again' ,'dropbox-backup') . '(' . $file_name . ')' );
209
- }
210
- $data_error_command = WPAdm_Running::getCommandResultData('errors_sending');
211
- if (isset($data_error_command[$fromFile])) {
212
- $data_error_command[$fromFile]['count'] += 1;
213
- } else {
214
- $data_error_command[$fromFile] = array();
215
- $data_error_command[$fromFile]['count'] = 1;
216
- }
217
- WPAdm_Running::setCommandResultData('errors_sending', $data_error_command);
218
- }
219
- } else {
220
- $send = false;
221
- }
222
- }
223
- if ( $local ) {
224
- if ( WPAdm_Running::is_stop() ) {
225
- $data_command = WPAdm_Running::getCommandResultData('command_dropbox');
226
- $md5 = md5($fromFile);
227
- if (empty($data_command) || !in_array($md5 ,$data_command) ) {
228
- if ($send) {
229
- $res = $dropbox->uploadFile($fromFile, $toFile, true);
230
- } else {
231
- $data_command = WPAdm_Running::getCommandResultData('command_dropbox');
232
- if (!in_array($md5, $data_command)) {
233
- $this->saveDataCommand($md5);
234
- WPAdm_Process::setInc('dropbox', 1);
235
- }
236
-
237
- }
238
- }
239
- }
240
- } else {
241
- $md5 = md5($fromFile);
242
- $res = $dropbox->uploadFile($fromFile, $toFile, true);
243
- }
244
- if (isset($res['error']) && isset($res['text']) && $res['error'] == 1) {
245
- $this->setError( __('Dropbox returned an error during file sending: ' ,'dropbox-backup') . '"' . $res['text'] . '"(u)');
246
- return false;
247
- }
248
- if ( WPAdm_Running::is_stop() ) {
249
- if (isset($res['size']) && isset($res['client_mtime'])) {
250
- $data_command = WPAdm_Running::getCommandResultData('command_dropbox');
251
- if (!in_array($md5, $data_command)) {
252
- WPAdm_Core::log( __('File upload: ' ,'dropbox-backup') . basename( $file ) . __(' size: ' ,'dropbox-backup') . $res['size']);
253
- $this->saveDataCommand($md5);
254
- WPAdm_Process::setInc('dropbox', 1);
255
- }
256
- }
257
- }
258
-
259
- }
260
- return true;
261
- }
262
-
263
- private function saveDataCommand($file)
264
- {
265
- $data_command = WPAdm_Running::getCommandResultData('command_dropbox');
266
- $data_command[] = $file;
267
- WPAdm_Running::setCommandResultData('command_dropbox', $data_command);
268
- }
269
-
270
- private function setError($txt = '')
271
- {
272
- throw new Exception($txt);
273
- }
274
-
275
- private function deleteBackup()
276
- {
277
- if( (isset($this->params['is_local_backup']) && $this->params['is_local_backup'] == 0 ) || ( !isset($this->params['is_local_backup']) ) ) {
278
- if (isset($this->params['access_details']['dir'])) {
279
- $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
280
- $dropbox_options = wpadm_wp_full_backup_dropbox::getSettings();
281
- if ($dropbox_options) {
282
- if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
283
- $backup_dir = $dropbox_options['backup_folder'];
284
- }
285
- }
286
- WPAdm_Core::rmdir( $backup_dir . "/{$this->params['access_details']['dir']}");
287
- }
288
- }
289
- return $this->result;
290
- }
291
  }
292
  }
1
  <?php
 
 
 
 
 
2
  /**
3
+ * Бэкап сайта
4
+ * Class WPadm_Method_Send_To_Dropbox
5
+ */
6
  if (!class_exists('WPadm_Method_Send_To_Dropbox')) {
7
  class WPadm_Method_Send_To_Dropbox extends WPAdm_Method_Class {
8
  /**
9
+ * @var WPAdm_Queue
10
+ */
11
  private $queue;
12
 
13
  private $id;
14
 
 
15
  //private $name = '';
16
 
17
  public function getResult()
18
  {
19
+ $errors = array();
20
+ $this->id = uniqid('wpadm_method_send_to_dropbox_');
21
+
22
+ $this->result->setResult(WPAdm_Result::WPADM_RESULT_SUCCESS);
23
+ $this->result->setError('');
24
+
25
+ $this->queue = new WPAdm_Queue($this->id);
26
+
27
+ $ad = $this->params['access_details'];
28
+ WPAdm_Core::log( langWPADM::get('Start copy to Dropbox Cloud' , false) );
29
+ $this->queue->clear();
30
+ $files = $this->params['files'];
31
+ //$this->getResult()->setData($files);
32
+
33
+ $dir = (isset($ad['dir'])) ? $ad['dir'] : '/';
34
+ //$dir = trim($dir, '/') . '/' . $this->name;
35
+ foreach($files as $file) {
36
+ $commandContext = new WPAdm_Command_Context();
37
+ $commandContext->addParam('command', 'send_to_dropbox')
38
+ ->addParam('key', $ad['key'])
39
+ ->addParam('secret', $ad['secret'])
40
+ ->addParam('token', $ad['token'])
41
+ ->addParam('folder_project',$ad['folder'])
42
+ ->addParam('folder', $dir)
43
+ ->addParam('files', ABSPATH . $file);
44
+ $this->queue->add($commandContext);
45
+ unset($commandContext);
46
+ }
47
+ $res = $this->queue->save()
48
+ ->execute();
49
+ if (!$res) {
50
+ WPAdm_Core::log(langWPADM::get('Answer from Dropbox ' , false) . $this->queue->getError());
51
+ $errors[] = langWPADM::get('Answer from Dropbox ' , false) . $this->queue->getError();
52
+ }
53
+ WPAdm_Core::log( langWPADM::get('End Copy Files to Dropbox' , false) );
54
+ if (count($errors) > 0) {
55
+ $this->result->setError(implode("\n", $errors));
56
+ $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
57
+ }
58
 
59
+ return $this->result;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
+ }
63
+
64
+ private function init(array $conf) {
65
+ //todo: нормализация
66
  $this->id = $conf['id'];
67
  $this->stime = $conf['stime'];
68
+ $this->queue = new WPAdm_Queue($this->id);
69
  $this->type = $conf['type'];
70
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  }
72
  }
methods/class-wpadm-method-update.php CHANGED
@@ -1,7 +1,5 @@
1
  <?php
2
 
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
  if (!class_exists('WPAdm_Method_Update')) {
6
  class WPAdm_Method_Update extends WPAdm_Method_Class {
7
 
@@ -15,10 +13,10 @@ if (!class_exists('WPAdm_Method_Update')) {
15
  $n = count($this->params['files']);
16
  for($i = 0; $i < $n; $i++) {
17
  if ( ( $f = $this->dl($this->params['files'][$i]) ) === false ) {
18
- $error[] = __('Error to copy file ' ,'dropbox-backup') . $this->params['files'][$i]['file'];
19
  } else {
20
  if ( is_string($f) && $this->unpack($f, $this->params['files'][$i]['to']) === false ) {
21
- $error[] = __('Error to extract file ' ,'dropbox-backup') . $f;
22
  }
23
  if (file_exists($f)) {
24
  unlink($f);
@@ -60,6 +58,7 @@ if (!class_exists('WPAdm_Method_Update')) {
60
  if (!empty($d_)) {
61
  //$headers = array( 'Authorization' => 'Basic ' . base64_encode( "admin24:admin24" ) );
62
  $f = wp_remote_get($file['file'], array('headers' => $headers));
 
63
  if (isset($f['body']) && !empty($f['body'])) {
64
  file_put_contents($d_ . "/" . $b, $f['body']);
65
  if (file_exists($d_ . "/" . $b)) {
1
  <?php
2
 
 
 
3
  if (!class_exists('WPAdm_Method_Update')) {
4
  class WPAdm_Method_Update extends WPAdm_Method_Class {
5
 
13
  $n = count($this->params['files']);
14
  for($i = 0; $i < $n; $i++) {
15
  if ( ( $f = $this->dl($this->params['files'][$i]) ) === false ) {
16
+ $error[] = langWPADM::get('Error to copy file ' , false) . $this->params['files'][$i]['file'];
17
  } else {
18
  if ( is_string($f) && $this->unpack($f, $this->params['files'][$i]['to']) === false ) {
19
+ $error[] = langWPADM::get('Error to extract file ' , false) . $f;
20
  }
21
  if (file_exists($f)) {
22
  unlink($f);
58
  if (!empty($d_)) {
59
  //$headers = array( 'Authorization' => 'Basic ' . base64_encode( "admin24:admin24" ) );
60
  $f = wp_remote_get($file['file'], array('headers' => $headers));
61
+ WPAdm_Core::log(serialize($f));
62
  if (isset($f['body']) && !empty($f['body'])) {
63
  file_put_contents($d_ . "/" . $b, $f['body']);
64
  if (file_exists($d_ . "/" . $b)) {
modules/HttpFsockopen.php DELETED
@@ -1,178 +0,0 @@
1
- <?php
2
-
3
- /*
4
- justin was here :D
5
- */
6
-
7
- class HttpFsockopen {
8
-
9
- protected $url;
10
- protected $path;
11
- protected $host;
12
- protected $query;
13
- protected $post;
14
- protected $port;
15
- protected $headers;
16
- protected $ssl;
17
- protected $method;
18
- protected $timeout;
19
- protected $str_headers = '';
20
- protected $is_post = false;
21
-
22
- protected static $autoload;
23
-
24
- public function __construct($url, $use_autoload = true){
25
- if(is_null(HttpFsockopen::$autoload) && $use_autoload){
26
- HttpFsockopen::$autoload = true;
27
- spl_autoload_register(array("HttpFsockopen", "load"));
28
- }
29
- $url_array = parse_url($url);
30
-
31
- if(!empty($url_array["scheme"]) && preg_match("#^https|ssl$#i", $url_array["scheme"])){
32
- $this -> ssl = true;
33
- } else {
34
- $this -> ssl = false;
35
- }
36
-
37
- if(empty($url_array["port"])){
38
- if($this -> ssl){
39
- $this -> port = 443;
40
- } else {
41
- $this -> port = 80;
42
- }
43
- }
44
-
45
- if(array_key_exists("path", $url_array)){
46
- $this -> path = $url_array["path"];
47
- } else {
48
- $this -> path = false;
49
- }
50
-
51
- if(array_key_exists("query", $url_array)){
52
- $this -> query = $url_array["query"];
53
- } else {
54
- $this -> query = false;
55
- }
56
-
57
- $this -> host = $url_array["host"];
58
- $this -> method = "GET";
59
- $this -> timeout = 15;
60
- $this -> is_post = false;
61
- }
62
-
63
- public static function load($class){
64
- $file = dirname( __FILE__ ) . DIRECTORY_SEPARATOR .
65
- preg_replace("#[_]+#", DIRECTORY_SEPARATOR , $class) . ".php";
66
- if(file_exists($file))
67
- include_once $file ;
68
- }
69
-
70
- public function setQueryData($data){
71
- if(is_array($data)){
72
- $data = http_build_query($data);
73
- }
74
- $this -> query = $data;
75
- return $this;
76
- }
77
-
78
- public function setPostData($data){
79
- if(is_array($data)){
80
- $data = http_build_query($data);
81
- }
82
- $this -> post = $data;
83
- $this -> method = "POST";
84
- $this -> is_post = true;
85
- $this -> setHeaders("Content-Type", "application/x-www-form-urlencoded");
86
- return $this;
87
- }
88
-
89
- public function setMethod($method){
90
- $previous_method = $this -> method;
91
- if(preg_match("#^[a-z]+$#i", $method)){
92
- $this -> method = strtoupper($method);
93
- }
94
- if($this -> method == "POST" && $previous_method != "POST"){
95
- //$this -> setHeaders("Content-Type", "application/x-www-form-urlencoded");
96
- }
97
- if($this -> method != "POST" && $previous_method == "POST"){
98
- $this -> setHeaders("Content-Type", null);
99
- }
100
- return $this;
101
- }
102
-
103
- public function setTimeout($timeout){
104
- $this -> timeout = $timeout;
105
- return $this;
106
- }
107
-
108
- public function setPort($port){
109
- $this -> port = $port;
110
- return $this;
111
- }
112
-
113
- public function setHeaders($key, $value = null){
114
- if(is_array($key)){
115
- foreach($key as $key => $value){
116
- if(is_null($value)){
117
- unset($this -> headers[$key]);
118
- } else {
119
- $this -> headers[$key] = $value;
120
- }
121
- }
122
- } else {
123
- if(is_null($value)){
124
- unset($this -> headers[$key]);
125
- } else {
126
- $this -> headers[$key] = $value;
127
- }
128
- }
129
- return $this;
130
- }
131
-
132
- public function setStrHeaders($str)
133
- {
134
- $this->str_headers = $str;
135
- }
136
-
137
- public function setUserAgent($user_agent){
138
- return $this -> setHeaders("User-Agent", $user_agent);
139
- }
140
-
141
- public function exec(){
142
- $socket = fsockopen(($this -> ssl ? "ssl://" : "") . $this -> host, $this -> port, $errno, $errstr,
143
- $this -> timeout);
144
- $contents = "";
145
-
146
- if($socket){
147
- $http = $this -> method . " ". (strlen($this -> path) ? $this -> path : "/") .
148
- (strlen($this -> query)>0 ? "?" . $this -> query : "")
149
- ." HTTP/1.1\r\n";
150
- $http .= "Host: ".$this -> host."\r\n";
151
- foreach($this -> headers as $key => $value){
152
- $http .= $key. ": ".$value."\r\n";
153
- }
154
-
155
- if ( $this -> is_post || $this -> method == 'GET' ) {
156
- $http .= "Content-length: " . strlen($this -> post) . "\r\n";
157
- $http .= "Connection: close\r\n\r\n";
158
- }
159
-
160
- if (!empty($this->str_headers)) {
161
- $http .= $this->str_headers;
162
- }
163
-
164
- if(!is_null($this -> post)) {
165
- $http .= $this -> post . "\r\n\r\n";
166
- }
167
-
168
- fwrite($socket, $http);
169
- while (!feof($socket)) {
170
- $contents .= fgetc($socket);
171
- }
172
- fclose($socket);
173
- }
174
-
175
- return $contents;
176
- }
177
-
178
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/OAuthSimple.php CHANGED
@@ -1,15 +1,15 @@
1
  <?php
2
  /**
3
- * OAuthSimple - A simpler version of OAuth
4
- *
5
- * https://github.com/jrconlin/oauthsimple
6
- *
7
- * @author jr conlin <src@jrconlin.com>
8
- * @copyright unitedHeroes.net 2011
9
- * @version 1.3
10
- * @license See OAuthSimple_license.txt
11
- *
12
- */
13
 
14
  class OAuthSimple {
15
  private $_secrets;
@@ -18,168 +18,168 @@ class OAuthSimple {
18
  private $_nonce_chars;
19
 
20
  /**
21
- * Constructor
22
- *
23
- * @access public
24
- * @param api_key (String) The API Key (sometimes referred to as the consumer key) This value is usually supplied by the site you wish to use.
25
- * @param shared_secret (String) The shared secret. This value is also usually provided by the site you wish to use.
26
- * @return OAuthSimple (Object)
27
- */
28
  function __construct ($APIKey = "", $sharedSecret=""){
29
-
30
  if (!empty($APIKey))
31
- {
32
- $this->_secrets['consumer_key'] = $APIKey;
33
- }
34
-
35
  if (!empty($sharedSecret))
36
- {
37
- $this->_secrets['shared_secret'] = $sharedSecret;
38
- }
39
-
40
  $this->_default_signature_method = "HMAC-SHA1";
41
  $this->_action = "GET";
42
  $this->_nonce_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
43
-
44
  return $this;
45
  }
46
-
47
  /**
48
- * Reset the parameters and URL
49
- *
50
- * @access public
51
- * @return OAuthSimple (Object)
52
- */
53
  public function reset() {
54
  $this->_parameters = Array();
55
  $this->path = NULL;
56
  $this->sbs = NULL;
57
-
58
  return $this;
59
  }
60
 
61
  /**
62
- * Set the parameters either from a hash or a string
63
- *
64
- * @access public
65
- * @param(string, object) List of parameters for the call, this can either be a URI string (e.g. "foo=bar&gorp=banana" or an object/hash)
66
- * @return OAuthSimple (Object)
67
- */
68
  public function setParameters ($parameters=Array()) {
69
-
70
  if (is_string($parameters))
71
- {
72
- $parameters = $this->_parseParameterString($parameters);
73
- }
74
  if (empty($this->_parameters))
75
- {
76
- $this->_parameters = $parameters;
77
- }
78
  else if (!empty($parameters))
79
- {
80
- $this->_parameters = array_merge($this->_parameters,$parameters);
81
- }
82
- if (empty($this->_parameters['oauth_nonce']))
83
- {
84
- $this->_getNonce();
85
- }
86
  if (empty($this->_parameters['oauth_timestamp']))
87
- {
88
- $this->_getTimeStamp();
89
- }
90
  if (empty($this->_parameters['oauth_consumer_key']))
91
- {
92
- $this->_getApiKey();
93
- }
94
  if (empty($this->_parameters['oauth_token']))
95
- {
96
- $this->_getAccessToken();
97
- }
98
  if (empty($this->_parameters['oauth_signature_method']))
99
- {
100
  $this->setSignatureMethod();
101
- }
102
  if (empty($this->_parameters['oauth_version']))
103
- {
104
  $this->_parameters['oauth_version']="1.0";
105
- }
106
-
107
  return $this;
108
  }
109
 
110
  /**
111
- * Convenience method for setParameters
112
- *
113
- * @access public
114
- * @see setParameters
115
- */
116
  public function setQueryString ($parameters)
117
  {
118
  return $this->setParameters($parameters);
119
  }
120
 
121
  /**
122
- * Set the target URL (does not include the parameters)
123
- *
124
- * @param path (String) the fully qualified URI (excluding query arguments) (e.g "http://example.org/foo")
125
- * @return OAuthSimple (Object)
126
- */
127
  public function setURL ($path)
128
- {
129
  if (empty($path))
130
- {
131
  throw new OAuthSimpleException('No path specified for OAuthSimple.setURL');
132
- }
133
  $this->_path=$path;
134
-
135
  return $this;
136
  }
137
 
138
  /**
139
- * Convenience method for setURL
140
- *
141
- * @param path (String)
142
- * @see setURL
143
- */
144
  public function setPath ($path)
145
  {
146
  return $this->_path=$path;
147
  }
148
 
149
  /**
150
- * Set the "action" for the url, (e.g. GET,POST, DELETE, etc.)
151
- *
152
- * @param action (String) HTTP Action word.
153
- * @return OAuthSimple (Object)
154
- */
155
  public function setAction ($action)
156
  {
157
  if (empty($action))
158
- {
159
- $action = 'GET';
160
- }
161
  $action = strtoupper($action);
162
  if (preg_match('/[^A-Z]/',$action))
163
- {
164
  throw new OAuthSimpleException('Invalid action specified for OAuthSimple.setAction');
165
- }
166
  $this->_action = $action;
167
-
168
  return $this;
169
  }
170
 
171
  /**
172
- * Set the signatures (as well as validate the ones you have)
173
- *
174
- * @param signatures (object) object/hash of the token/signature pairs {api_key:, shared_secret:, oauth_token: oauth_secret:}
175
- * @return OAuthSimple (Object)
176
- */
177
  public function signatures ($signatures)
178
  {
179
  if (!empty($signatures) && !is_array($signatures))
180
- {
181
  throw new OAuthSimpleException('Must pass dictionary array to OAuthSimple.signatures');
182
- }
183
  if (!empty($signatures))
184
  {
185
  if (empty($this->_secrets))
@@ -189,34 +189,34 @@ class OAuthSimple {
189
  $this->_secrets=array_merge($this->_secrets,$signatures);
190
  }
191
  if (isset($this->_secrets['api_key']))
192
- {
193
  $this->_secrets['consumer_key'] = $this->_secrets['api_key'];
194
- }
195
  if (isset($this->_secrets['access_token']))
196
- {
197
  $this->_secrets['oauth_token'] = $this->_secrets['access_token'];
198
- }
199
  if (isset($this->_secrets['access_secret']))
200
- {
201
  $this->_secrets['oauth_secret'] = $this->_secrets['access_secret'];
202
  }
203
  if (isset($this->_secrets['access_token_secret']))
204
- {
205
  $this->_secrets['oauth_secret'] = $this->_secrets['access_token_secret'];
206
- }
207
  if (empty($this->_secrets['consumer_key']))
208
- {
209
  throw new OAuthSimpleException('Missing required consumer_key in OAuthSimple.signatures');
210
  }
211
  if (empty($this->_secrets['shared_secret']))
212
- {
213
  throw new OAuthSimpleException('Missing requires shared_secret in OAuthSimple.signatures');
214
- }
215
  if (!empty($this->_secrets['oauth_token']) && empty($this->_secrets['oauth_secret']))
216
- {
217
  throw new OAuthSimpleException('Missing oauth_secret for supplied oauth_token in OAuthSimple.signatures');
218
- }
219
-
220
  return $this;
221
  }
222
 
@@ -226,99 +226,99 @@ class OAuthSimple {
226
  }
227
 
228
  /**
229
- * Set the signature method (currently only Plaintext or SHA-MAC1)
230
- *
231
- * @param method (String) Method of signing the transaction (only PLAINTEXT and SHA-MAC1 allowed for now)
232
- * @return OAuthSimple (Object)
233
  */
234
  public function setSignatureMethod ($method="")
235
- {
236
  if (empty($method))
237
- {
238
  $method = $this->_default_signature_method;
239
- }
240
  $method = strtoupper($method);
241
  switch($method)
242
  {
243
  case 'PLAINTEXT':
244
  case 'HMAC-SHA1':
245
  $this->_parameters['oauth_signature_method']=$method;
246
- break;
247
  default:
248
  throw new OAuthSimpleException ("Unknown signing method $method specified for OAuthSimple.setSignatureMethod");
249
- break;
250
  }
251
-
252
- return $this;
253
  }
254
 
255
  /** sign the request
256
- *
257
- * note: all arguments are optional, provided you've set them using the
258
- * other helper functions.
259
- *
260
- * @param args (Array) hash of arguments for the call {action, path, parameters (array), method, signatures (array)} all arguments are optional.
261
- * @return (Array) signed values
262
- */
263
  public function sign($args=array())
264
  {
265
  if (!empty($args['action']))
266
- {
267
  $this->setAction($args['action']);
268
- }
269
  if (!empty($args['path']))
270
- {
271
  $this->setPath($args['path']);
272
  }
273
  if (!empty($args['method']))
274
- {
275
  $this->setSignatureMethod($args['method']);
276
- }
277
  if (!empty($args['signatures']))
278
- {
279
  $this->signatures($args['signatures']);
280
- }
281
  if (empty($args['parameters']))
282
- {
283
  $args['parameters']=array();
284
- }
285
  $this->setParameters($args['parameters']);
286
  $normParams = $this->_normalizedParameters();
287
  $this->_parameters['oauth_signature'] = $this->_generateSignature($normParams);
288
-
289
  return Array (
290
- 'parameters' => $this->_parameters,
291
- 'signature' => self::_oauthEscape($this->_parameters['oauth_signature']),
292
- 'signed_url' => $this->_path . '?' . $this->_normalizedParameters(),
293
- 'header' => $this->getHeaderString(),
294
- 'sbs'=> $this->sbs
295
- );
296
  }
297
 
298
  /**
299
- * Return a formatted "header" string
300
- *
301
- * NOTE: This doesn't set the "Authorization: " prefix, which is required.
302
- * It's not set because various set header functions prefer different
303
- * ways to do that.
304
- *
305
- * @param args (Array)
306
- * @return $result (String)
307
  */
308
  public function getHeaderString ($args=array())
309
  {
310
  if (empty($this->_parameters['oauth_signature']))
311
- {
312
  $this->sign($args);
313
- }
314
  $result = 'OAuth ';
315
 
316
  foreach ($this->_parameters as $pName => $pValue)
317
  {
318
  if (strpos($pName,'oauth_') !== 0 || $pName == 'oauth_token_secret2')
319
- {
320
  continue;
321
- }
322
  if (is_array($pValue))
323
  {
324
  foreach ($pValue as $val)
@@ -343,19 +343,19 @@ class OAuthSimple {
343
  {
344
  list ($key,$token) = explode('=',$element);
345
  if ($token)
346
- {
347
  $token = urldecode($token);
348
- }
349
  if (!empty($result[$key]))
350
  {
351
  if (!is_array($result[$key]))
352
- {
353
  $result[$key] = array($result[$key],$token);
354
- }
355
  else
356
- {
357
  array_push($result[$key],$token);
358
- }
359
  }
360
  else
361
  $result[$key]=$token;
@@ -367,14 +367,14 @@ class OAuthSimple {
367
  private static function _oauthEscape($string)
368
  {
369
  if ($string === 0) { return 0; }
370
- if ($string == '0') { return '0'; }
371
  if (strlen($string) == 0) { return ''; }
372
  if (is_array($string)) {
373
  throw new OAuthSimpleException('Array passed to _oauthEscape');
374
- }
375
  $string = rawurlencode($string);
376
-
377
- $string = str_replace('+','%20',$string);
378
  $string = str_replace('!','%21',$string);
379
  $string = str_replace('*','%2A',$string);
380
  $string = str_replace('\'','%27',$string);
@@ -393,9 +393,9 @@ class OAuthSimple {
393
  $rnum = rand(0,$cLength);
394
  $result .= substr($this->_nonce_chars,$rnum,1);
395
  }
396
- $result = md5($result);
397
  $this->_parameters['oauth_nonce'] = $result;
398
-
399
  return $result;
400
  }
401
 
@@ -406,22 +406,22 @@ class OAuthSimple {
406
  throw new OAuthSimpleException('No consumer_key set for OAuthSimple');
407
  }
408
  $this->_parameters['oauth_consumer_key']=$this->_secrets['consumer_key'];
409
-
410
  return $this->_parameters['oauth_consumer_key'];
411
  }
412
 
413
  private function _getAccessToken()
414
  {
415
  if (!isset($this->_secrets['oauth_secret']))
416
- {
417
  return '';
418
- }
419
  if (!isset($this->_secrets['oauth_token']))
420
- {
421
  throw new OAuthSimpleException('No access token (oauth_token) set for OAuthSimple.');
422
- }
423
  $this->_parameters['oauth_token'] = $this->_secrets['oauth_token'];
424
-
425
  return $this->_parameters['oauth_token'];
426
  }
427
 
@@ -432,63 +432,63 @@ class OAuthSimple {
432
 
433
  private function _normalizedParameters()
434
  {
435
- $normalized_keys = array();
436
- $return_array = array();
437
 
438
- foreach ( $this->_parameters as $paramName=>$paramValue) {
439
  if (!preg_match('/\w+_secret/',$paramName) OR (strpos($paramValue, '@') !== 0 && !file_exists(substr($paramValue, 1))) )
440
- {
441
- if (is_array($paramValue))
442
- {
443
- $normalized_keys[self::_oauthEscape($paramName)] = array();
444
- foreach($paramValue as $item)
445
- {
446
- array_push($normalized_keys[self::_oauthEscape($paramName)], self::_oauthEscape($item));
447
- }
448
- }
449
- else
450
- {
451
- $normalized_keys[self::_oauthEscape($paramName)] = self::_oauthEscape($paramValue);
452
- }
453
- }
454
- }
455
-
456
- ksort($normalized_keys);
457
-
458
- foreach($normalized_keys as $key=>$val)
459
- {
460
- if (is_array($val))
461
- {
462
- sort($val);
463
- foreach($val as $element)
464
- {
465
- array_push($return_array, $key . "=" . $element);
466
- }
467
- }
468
- else
469
- {
470
- array_push($return_array, $key .'='. $val);
471
- }
472
-
473
- }
474
-
475
- return join("&", $return_array);
476
  }
477
 
478
 
479
  private function _generateSignature ()
480
  {
481
  $secretKey = '';
482
- if(isset($this->_secrets['shared_secret']))
483
- {
484
- $secretKey = self::_oauthEscape($this->_secrets['shared_secret']);
485
- }
486
-
487
- $secretKey .= '&';
488
- if(isset($this->_secrets['oauth_secret']))
489
- {
490
  $secretKey .= self::_oauthEscape($this->_secrets['oauth_secret']);
491
- }
492
 
493
  switch($this->_parameters['oauth_signature_method'])
494
  {
@@ -500,34 +500,33 @@ class OAuthSimple {
500
  return base64_encode(hash_hmac('sha1',$this->sbs,$secretKey,TRUE));
501
  default:
502
  throw new OAuthSimpleException('Unknown signature method for OAuthSimple');
503
- break;
504
  }
505
  }
506
  }
507
- if (!class_exists('OAuthSimpleException')) {
508
- class OAuthSimpleException extends Exception {
509
-
510
- public function __construct($err, $isDebug = FALSE)
511
- {
512
- self::log_error($err);
513
- if ($isDebug)
514
- {
515
- self::display_error($err, TRUE);
516
- }
517
- }
518
 
519
- public static function log_error($err)
520
- {
521
- error_log($err, 0);
522
- }
523
-
524
- public static function display_error($err, $kill = FALSE)
525
- {
526
- print_r($err);
527
- if ($kill === FALSE)
528
- {
529
- die();
530
- }
531
- }
532
- }
 
 
 
 
 
 
 
 
 
 
533
  }
1
  <?php
2
  /**
3
+ * OAuthSimple - A simpler version of OAuth
4
+ *
5
+ * https://github.com/jrconlin/oauthsimple
6
+ *
7
+ * @author jr conlin <src@jrconlin.com>
8
+ * @copyright unitedHeroes.net 2011
9
+ * @version 1.3
10
+ * @license See OAuthSimple_license.txt
11
+ *
12
+ */
13
 
14
  class OAuthSimple {
15
  private $_secrets;
18
  private $_nonce_chars;
19
 
20
  /**
21
+ * Constructor
22
+ *
23
+ * @access public
24
+ * @param api_key (String) The API Key (sometimes referred to as the consumer key) This value is usually supplied by the site you wish to use.
25
+ * @param shared_secret (String) The shared secret. This value is also usually provided by the site you wish to use.
26
+ * @return OAuthSimple (Object)
27
+ */
28
  function __construct ($APIKey = "", $sharedSecret=""){
29
+
30
  if (!empty($APIKey))
31
+ {
32
+ $this->_secrets['consumer_key'] = $APIKey;
33
+ }
34
+
35
  if (!empty($sharedSecret))
36
+ {
37
+ $this->_secrets['shared_secret'] = $sharedSecret;
38
+ }
39
+
40
  $this->_default_signature_method = "HMAC-SHA1";
41
  $this->_action = "GET";
42
  $this->_nonce_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
43
+
44
  return $this;
45
  }
46
+
47
  /**
48
+ * Reset the parameters and URL
49
+ *
50
+ * @access public
51
+ * @return OAuthSimple (Object)
52
+ */
53
  public function reset() {
54
  $this->_parameters = Array();
55
  $this->path = NULL;
56
  $this->sbs = NULL;
57
+
58
  return $this;
59
  }
60
 
61
  /**
62
+ * Set the parameters either from a hash or a string
63
+ *
64
+ * @access public
65
+ * @param(string, object) List of parameters for the call, this can either be a URI string (e.g. "foo=bar&gorp=banana" or an object/hash)
66
+ * @return OAuthSimple (Object)
67
+ */
68
  public function setParameters ($parameters=Array()) {
69
+
70
  if (is_string($parameters))
71
+ {
72
+ $parameters = $this->_parseParameterString($parameters);
73
+ }
74
  if (empty($this->_parameters))
75
+ {
76
+ $this->_parameters = $parameters;
77
+ }
78
  else if (!empty($parameters))
79
+ {
80
+ $this->_parameters = array_merge($this->_parameters,$parameters);
81
+ }
82
+ if (empty($this->_parameters['oauth_nonce']))
83
+ {
84
+ $this->_getNonce();
85
+ }
86
  if (empty($this->_parameters['oauth_timestamp']))
87
+ {
88
+ $this->_getTimeStamp();
89
+ }
90
  if (empty($this->_parameters['oauth_consumer_key']))
91
+ {
92
+ $this->_getApiKey();
93
+ }
94
  if (empty($this->_parameters['oauth_token']))
95
+ {
96
+ $this->_getAccessToken();
97
+ }
98
  if (empty($this->_parameters['oauth_signature_method']))
99
+ {
100
  $this->setSignatureMethod();
101
+ }
102
  if (empty($this->_parameters['oauth_version']))
103
+ {
104
  $this->_parameters['oauth_version']="1.0";
105
+ }
106
+
107
  return $this;
108
  }
109
 
110
  /**
111
+ * Convenience method for setParameters
112
+ *
113
+ * @access public
114
+ * @see setParameters
115
+ */
116
  public function setQueryString ($parameters)
117
  {
118
  return $this->setParameters($parameters);
119
  }
120
 
121
  /**
122
+ * Set the target URL (does not include the parameters)
123
+ *
124
+ * @param path (String) the fully qualified URI (excluding query arguments) (e.g "http://example.org/foo")
125
+ * @return OAuthSimple (Object)
126
+ */
127
  public function setURL ($path)
128
+ {
129
  if (empty($path))
130
+ {
131
  throw new OAuthSimpleException('No path specified for OAuthSimple.setURL');
132
+ }
133
  $this->_path=$path;
134
+
135
  return $this;
136
  }
137
 
138
  /**
139
+ * Convenience method for setURL
140
+ *
141
+ * @param path (String)
142
+ * @see setURL
143
+ */
144
  public function setPath ($path)
145
  {
146
  return $this->_path=$path;
147
  }
148
 
149
  /**
150
+ * Set the "action" for the url, (e.g. GET,POST, DELETE, etc.)
151
+ *
152
+ * @param action (String) HTTP Action word.
153
+ * @return OAuthSimple (Object)
154
+ */
155
  public function setAction ($action)
156
  {
157
  if (empty($action))
158
+ {
159
+ $action = 'GET';
160
+ }
161
  $action = strtoupper($action);
162
  if (preg_match('/[^A-Z]/',$action))
163
+ {
164
  throw new OAuthSimpleException('Invalid action specified for OAuthSimple.setAction');
165
+ }
166
  $this->_action = $action;
167
+
168
  return $this;
169
  }
170
 
171
  /**
172
+ * Set the signatures (as well as validate the ones you have)
173
+ *
174
+ * @param signatures (object) object/hash of the token/signature pairs {api_key:, shared_secret:, oauth_token: oauth_secret:}
175
+ * @return OAuthSimple (Object)
176
+ */
177
  public function signatures ($signatures)
178
  {
179
  if (!empty($signatures) && !is_array($signatures))
180
+ {
181
  throw new OAuthSimpleException('Must pass dictionary array to OAuthSimple.signatures');
182
+ }
183
  if (!empty($signatures))
184
  {
185
  if (empty($this->_secrets))
189
  $this->_secrets=array_merge($this->_secrets,$signatures);
190
  }
191
  if (isset($this->_secrets['api_key']))
192
+ {
193
  $this->_secrets['consumer_key'] = $this->_secrets['api_key'];
194
+ }
195
  if (isset($this->_secrets['access_token']))
196
+ {
197
  $this->_secrets['oauth_token'] = $this->_secrets['access_token'];
198
+ }
199
  if (isset($this->_secrets['access_secret']))
200
+ {
201
  $this->_secrets['oauth_secret'] = $this->_secrets['access_secret'];
202
  }
203
  if (isset($this->_secrets['access_token_secret']))
204
+ {
205
  $this->_secrets['oauth_secret'] = $this->_secrets['access_token_secret'];
206
+ }
207
  if (empty($this->_secrets['consumer_key']))
208
+ {
209
  throw new OAuthSimpleException('Missing required consumer_key in OAuthSimple.signatures');
210
  }
211
  if (empty($this->_secrets['shared_secret']))
212
+ {
213
  throw new OAuthSimpleException('Missing requires shared_secret in OAuthSimple.signatures');
214
+ }
215
  if (!empty($this->_secrets['oauth_token']) && empty($this->_secrets['oauth_secret']))
216
+ {
217
  throw new OAuthSimpleException('Missing oauth_secret for supplied oauth_token in OAuthSimple.signatures');
218
+ }
219
+
220
  return $this;
221
  }
222
 
226
  }
227
 
228
  /**
229
+ * Set the signature method (currently only Plaintext or SHA-MAC1)
230
+ *
231
+ * @param method (String) Method of signing the transaction (only PLAINTEXT and SHA-MAC1 allowed for now)
232
+ * @return OAuthSimple (Object)
233
  */
234
  public function setSignatureMethod ($method="")
235
+ {
236
  if (empty($method))
237
+ {
238
  $method = $this->_default_signature_method;
239
+ }
240
  $method = strtoupper($method);
241
  switch($method)
242
  {
243
  case 'PLAINTEXT':
244
  case 'HMAC-SHA1':
245
  $this->_parameters['oauth_signature_method']=$method;
246
+ break;
247
  default:
248
  throw new OAuthSimpleException ("Unknown signing method $method specified for OAuthSimple.setSignatureMethod");
249
+ break;
250
  }
251
+
252
+ return $this;
253
  }
254
 
255
  /** sign the request
256
+ *
257
+ * note: all arguments are optional, provided you've set them using the
258
+ * other helper functions.
259
+ *
260
+ * @param args (Array) hash of arguments for the call {action, path, parameters (array), method, signatures (array)} all arguments are optional.
261
+ * @return (Array) signed values
262
+ */
263
  public function sign($args=array())
264
  {
265
  if (!empty($args['action']))
266
+ {
267
  $this->setAction($args['action']);
268
+ }
269
  if (!empty($args['path']))
270
+ {
271
  $this->setPath($args['path']);
272
  }
273
  if (!empty($args['method']))
274
+ {
275
  $this->setSignatureMethod($args['method']);
276
+ }
277
  if (!empty($args['signatures']))
278
+ {
279
  $this->signatures($args['signatures']);
280
+ }
281
  if (empty($args['parameters']))
282
+ {
283
  $args['parameters']=array();
284
+ }
285
  $this->setParameters($args['parameters']);
286
  $normParams = $this->_normalizedParameters();
287
  $this->_parameters['oauth_signature'] = $this->_generateSignature($normParams);
288
+
289
  return Array (
290
+ 'parameters' => $this->_parameters,
291
+ 'signature' => self::_oauthEscape($this->_parameters['oauth_signature']),
292
+ 'signed_url' => $this->_path . '?' . $this->_normalizedParameters(),
293
+ 'header' => $this->getHeaderString(),
294
+ 'sbs'=> $this->sbs
295
+ );
296
  }
297
 
298
  /**
299
+ * Return a formatted "header" string
300
+ *
301
+ * NOTE: This doesn't set the "Authorization: " prefix, which is required.
302
+ * It's not set because various set header functions prefer different
303
+ * ways to do that.
304
+ *
305
+ * @param args (Array)
306
+ * @return $result (String)
307
  */
308
  public function getHeaderString ($args=array())
309
  {
310
  if (empty($this->_parameters['oauth_signature']))
311
+ {
312
  $this->sign($args);
313
+ }
314
  $result = 'OAuth ';
315
 
316
  foreach ($this->_parameters as $pName => $pValue)
317
  {
318
  if (strpos($pName,'oauth_') !== 0 || $pName == 'oauth_token_secret2')
319
+ {
320
  continue;
321
+ }
322
  if (is_array($pValue))
323
  {
324
  foreach ($pValue as $val)
343
  {
344
  list ($key,$token) = explode('=',$element);
345
  if ($token)
346
+ {
347
  $token = urldecode($token);
348
+ }
349
  if (!empty($result[$key]))
350
  {
351
  if (!is_array($result[$key]))
352
+ {
353
  $result[$key] = array($result[$key],$token);
354
+ }
355
  else
356
+ {
357
  array_push($result[$key],$token);
358
+ }
359
  }
360
  else
361
  $result[$key]=$token;
367
  private static function _oauthEscape($string)
368
  {
369
  if ($string === 0) { return 0; }
370
+ if ($string == '0') { return '0'; }
371
  if (strlen($string) == 0) { return ''; }
372
  if (is_array($string)) {
373
  throw new OAuthSimpleException('Array passed to _oauthEscape');
374
+ }
375
  $string = rawurlencode($string);
376
+
377
+ $string = str_replace('+','%20',$string);
378
  $string = str_replace('!','%21',$string);
379
  $string = str_replace('*','%2A',$string);
380
  $string = str_replace('\'','%27',$string);
393
  $rnum = rand(0,$cLength);
394
  $result .= substr($this->_nonce_chars,$rnum,1);
395
  }
396
+ $result = md5($result);
397
  $this->_parameters['oauth_nonce'] = $result;
398
+
399
  return $result;
400
  }
401
 
406
  throw new OAuthSimpleException('No consumer_key set for OAuthSimple');
407
  }
408
  $this->_parameters['oauth_consumer_key']=$this->_secrets['consumer_key'];
409
+
410
  return $this->_parameters['oauth_consumer_key'];
411
  }
412
 
413
  private function _getAccessToken()
414
  {
415
  if (!isset($this->_secrets['oauth_secret']))
416
+ {
417
  return '';
418
+ }
419
  if (!isset($this->_secrets['oauth_token']))
420
+ {
421
  throw new OAuthSimpleException('No access token (oauth_token) set for OAuthSimple.');
422
+ }
423
  $this->_parameters['oauth_token'] = $this->_secrets['oauth_token'];
424
+
425
  return $this->_parameters['oauth_token'];
426
  }
427
 
432
 
433
  private function _normalizedParameters()
434
  {
435
+ $normalized_keys = array();
436
+ $return_array = array();
437
 
438
+ foreach ( $this->_parameters as $paramName=>$paramValue) {
439
  if (!preg_match('/\w+_secret/',$paramName) OR (strpos($paramValue, '@') !== 0 && !file_exists(substr($paramValue, 1))) )
440
+ {
441
+ if (is_array($paramValue))
442
+ {
443
+ $normalized_keys[self::_oauthEscape($paramName)] = array();
444
+ foreach($paramValue as $item)
445
+ {
446
+ array_push($normalized_keys[self::_oauthEscape($paramName)], self::_oauthEscape($item));
447
+ }
448
+ }
449
+ else
450
+ {
451
+ $normalized_keys[self::_oauthEscape($paramName)] = self::_oauthEscape($paramValue);
452
+ }
453
+ }
454
+ }
455
+
456
+ ksort($normalized_keys);
457
+
458
+ foreach($normalized_keys as $key=>$val)
459
+ {
460
+ if (is_array($val))
461
+ {
462
+ sort($val);
463
+ foreach($val as $element)
464
+ {
465
+ array_push($return_array, $key . "=" . $element);
466
+ }
467
+ }
468
+ else
469
+ {
470
+ array_push($return_array, $key .'='. $val);
471
+ }
472
+
473
+ }
474
+
475
+ return join("&", $return_array);
476
  }
477
 
478
 
479
  private function _generateSignature ()
480
  {
481
  $secretKey = '';
482
+ if(isset($this->_secrets['shared_secret']))
483
+ {
484
+ $secretKey = self::_oauthEscape($this->_secrets['shared_secret']);
485
+ }
486
+
487
+ $secretKey .= '&';
488
+ if(isset($this->_secrets['oauth_secret']))
489
+ {
490
  $secretKey .= self::_oauthEscape($this->_secrets['oauth_secret']);
491
+ }
492
 
493
  switch($this->_parameters['oauth_signature_method'])
494
  {
500
  return base64_encode(hash_hmac('sha1',$this->sbs,$secretKey,TRUE));
501
  default:
502
  throw new OAuthSimpleException('Unknown signature method for OAuthSimple');
503
+ break;
504
  }
505
  }
506
  }
 
 
 
 
 
 
 
 
 
 
 
507
 
508
+ class OAuthSimpleException extends Exception {
509
+
510
+ public function __construct($err, $isDebug = FALSE)
511
+ {
512
+ self::log_error($err);
513
+ if ($isDebug)
514
+ {
515
+ self::display_error($err, TRUE);
516
+ }
517
+ }
518
+
519
+ public static function log_error($err)
520
+ {
521
+ error_log($err, 0);
522
+ }
523
+
524
+ public static function display_error($err, $kill = FALSE)
525
+ {
526
+ print_r($err);
527
+ if ($kill === FALSE)
528
+ {
529
+ die();
530
+ }
531
+ }
532
  }
modules/archive.php DELETED
@@ -1,784 +0,0 @@
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 __construct($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 __construct($name)
369
- {
370
- parent::__construct($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
- $file = array (
446
- 'name' => trim( $temp['prefix'] ) . trim( $temp['name'] ),
447
- 'stat' => array (
448
- 2 => $temp['mode'],
449
- 4 => octdec($temp['uid']),
450
- 5 => octdec($temp['gid']),
451
- 7 => octdec($temp['size']),
452
- 9 => octdec($temp['mtime']),
453
- ),
454
- 'checksum' => octdec($temp['checksum']),
455
- 'type' => (int)$temp['type'],
456
- 'magic' => $temp['magic'],
457
- );
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." . "(" . utf8_encode( 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
-
499
- if ($this->options['inmemory'] == 1)
500
- {
501
- $file['data'] = fread($fp, $file['stat'][7]);
502
- fread($fp, (512 - $file['stat'][7] % 512) == 512 ? 0 : (512 - $file['stat'][7] % 512));
503
- unset ($file['checksum'], $file['magic']);
504
- $this->files[] = $file;
505
- }
506
- else if ($file['type'] == 5)
507
- {
508
- if (!is_dir($file['name']))
509
- mkdir($file['name'], $file['stat'][2]);
510
- }
511
- else if ($this->options['overwrite'] == 0 && file_exists($file['name']))
512
- {
513
- $this->error[] = "{$file['name']} already exists.";
514
- continue;
515
- }
516
- else if ($file['type'] == 2)
517
- {
518
- symlink($temp['symlink'], $file['name']);
519
- chmod($file['name'], $file['stat'][2]);
520
- }
521
- else if ($new = @fopen($file['name'], "wb"))
522
- {
523
- if ($file['stat'][7] == 0) {
524
- fwrite($new, '');
525
- } else {
526
- fwrite($new, fread($fp, $file['stat'][7]));
527
- }
528
-
529
- $read_next = (512 - $file['stat'][7] % 512) == 512 ? 0 : (512 - $file['stat'][7] % 512);
530
- if ($read_next != 0) {
531
- fread($fp, $read_next);
532
- }
533
- fclose($new);
534
- //chmod($file['name'], $file['stat'][2]);
535
- }
536
- else
537
- {
538
-
539
- $this->warning[] = "Could not open {$file['name']} for writing.";
540
- continue;
541
- }
542
- //chown($file['name'], $file['stat'][4]);
543
- //chgrp($file['name'], $file['stat'][5]);
544
- //touch($file['name'], $file['stat'][9]);
545
- unset ($file);
546
- }
547
- }
548
- else
549
- $this->error[] = "Could not open file {$this->options['name']}";
550
-
551
- chdir($pwd);
552
- }
553
-
554
- function open_archive()
555
- {
556
- return @fopen($this->options['name'], "rb");
557
- }
558
- }
559
-
560
- class wpadm_gzip_file extends wpadm_tar_file
561
- {
562
- function __construct($name)
563
- {
564
- parent::__construct($name);
565
- $this->options['type'] = "gzip";
566
- }
567
-
568
- function create_gzip()
569
- {
570
- if ($this->options['inmemory'] == 0)
571
- {
572
- $pwd = getcwd();
573
- chdir($this->options['basedir']);
574
- if ($fp = gzopen($this->options['name'], "wb{$this->options['level']}"))
575
- {
576
- fseek($this->archive, 0);
577
- while ($temp = fread($this->archive, 1048576))
578
- gzwrite($fp, $temp);
579
- gzclose($fp);
580
- chdir($pwd);
581
- }
582
- else
583
- {
584
- $this->error[] = "Could not open {$this->options['name']} for writing.";
585
- chdir($pwd);
586
- return 0;
587
- }
588
- }
589
- else
590
- $this->archive = gzencode($this->archive, $this->options['level']);
591
-
592
- return 1;
593
- }
594
-
595
- function extract_gz_files()
596
- {
597
- $pwd = getcwd();
598
- chdir($this->options['basedir']);
599
- $tmp_file = $this->options['name'] . ".tmp" ;
600
- $tmp_w = fopen($tmp_file, "wb");
601
- if ($tmp_w) {
602
- if ($fp = gzopen($this->options['name'], "rb{$this->options['level']}"))
603
- {
604
- fseek($tmp_w, 0);
605
- while ($temp = gzread($fp, 1048576))
606
- fwrite($tmp_w, $temp);
607
- gzclose($fp);
608
- chdir($pwd);
609
- }
610
- else
611
- {
612
- $this->error[] = "Could not open {$this->options['name']} for reading.";
613
- chdir($pwd);
614
- return 0;
615
- }
616
-
617
- fclose($tmp_w);
618
- $this->options['name'] = $tmp_file;
619
- $this->extract_files();
620
- if (file_exists($tmp_file)) {
621
- unlink($tmp_file);
622
- }
623
- } else {
624
- $this->error[] = "Could not open {$tmp_file} for writing.";
625
- chdir($pwd);
626
- return 0;
627
- }
628
- return 1;
629
- }
630
-
631
- function open_archive()
632
- {
633
- return @gzopen($this->options['name'], "rb");
634
- }
635
- }
636
-
637
- class wpadm_bzip_file extends wpadm_tar_file
638
- {
639
- function __construct($name)
640
- {
641
- parent::__construct($name);
642
- $this->options['type'] = "bzip";
643
- }
644
-
645
- function create_bzip()
646
- {
647
- if ($this->options['inmemory'] == 0)
648
- {
649
- $pwd = getcwd();
650
- chdir($this->options['basedir']);
651
- if ($fp = bzopen($this->options['name'], "wb"))
652
- {
653
- fseek($this->archive, 0);
654
- while ($temp = fread($this->archive, 1048576))
655
- bzwrite($fp, $temp);
656
- bzclose($fp);
657
- chdir($pwd);
658
- }
659
- else
660
- {
661
- $this->error[] = "Could not open {$this->options['name']} for writing.";
662
- chdir($pwd);
663
- return 0;
664
- }
665
- }
666
- else
667
- $this->archive = bzcompress($this->archive, $this->options['level']);
668
-
669
- return 1;
670
- }
671
-
672
- function open_archive()
673
- {
674
- return @bzopen($this->options['name'], "rb");
675
- }
676
- }
677
-
678
- class wpadm_zip_file extends wpadm_archive_class
679
- {
680
- function __construct($name)
681
- {
682
- parent::__construct($name);
683
- $this->options['type'] = "zip";
684
- }
685
-
686
- function create_zip()
687
- {
688
- $files = 0;
689
- $offset = 0;
690
- $central = "";
691
-
692
- if (!empty ($this->options['sfx']))
693
- if ($fp = @fopen($this->options['sfx'], "rb"))
694
- {
695
- $temp = fread($fp, filesize($this->options['sfx']));
696
- fclose($fp);
697
- $this->add_data($temp);
698
- $offset += strlen($temp);
699
- unset ($temp);
700
- }
701
- else
702
- $this->error[] = "Could not open sfx module from {$this->options['sfx']}.";
703
-
704
- $pwd = getcwd();
705
- chdir($this->options['basedir']);
706
-
707
- foreach ($this->files as $current)
708
- {
709
- if ($current['name'] == $this->options['name'])
710
- continue;
711
-
712
- $timedate = explode(" ", date("Y n j G i s", $current['stat'][9]));
713
- $timedate = ($timedate[0] - 1980 << 25) | ($timedate[1] << 21) | ($timedate[2] << 16) |
714
- ($timedate[3] << 11) | ($timedate[4] << 5) | ($timedate[5]);
715
-
716
- $block = pack("VvvvV", 0x04034b50, 0x000A, 0x0000, (isset($current['method']) || $this->options['method'] == 0) ? 0x0000 : 0x0008, $timedate);
717
-
718
- if ($current['stat'][7] == 0 && $current['type'] == 5)
719
- {
720
- $block .= pack("VVVvv", 0x00000000, 0x00000000, 0x00000000, strlen($current['name2']) + 1, 0x0000);
721
- $block .= $current['name2'] . "/";
722
- $this->add_data($block);
723
- $central .= pack("VvvvvVVVVvvvvvVV", 0x02014b50, 0x0014, $this->options['method'] == 0 ? 0x0000 : 0x000A, 0x0000,
724
- (isset($current['method']) || $this->options['method'] == 0) ? 0x0000 : 0x0008, $timedate,
725
- 0x00000000, 0x00000000, 0x00000000, strlen($current['name2']) + 1, 0x0000, 0x0000, 0x0000, 0x0000, $current['type'] == 5 ? 0x00000010 : 0x00000000, $offset);
726
- $central .= $current['name2'] . "/";
727
- $files++;
728
- $offset += (31 + strlen($current['name2']));
729
- }
730
- else if ($current['stat'][7] == 0)
731
- {
732
- $block .= pack("VVVvv", 0x00000000, 0x00000000, 0x00000000, strlen($current['name2']), 0x0000);
733
- $block .= $current['name2'];
734
- $this->add_data($block);
735
- $central .= pack("VvvvvVVVVvvvvvVV", 0x02014b50, 0x0014, $this->options['method'] == 0 ? 0x0000 : 0x000A, 0x0000,
736
- (isset($current['method']) || $this->options['method'] == 0) ? 0x0000 : 0x0008, $timedate,
737
- 0x00000000, 0x00000000, 0x00000000, strlen($current['name2']), 0x0000, 0x0000, 0x0000, 0x0000, $current['type'] == 5 ? 0x00000010 : 0x00000000, $offset);
738
- $central .= $current['name2'];
739
- $files++;
740
- $offset += (30 + strlen($current['name2']));
741
- }
742
- else if ($fp = @fopen($current['name'], "rb"))
743
- {
744
- $temp = fread($fp, $current['stat'][7]);
745
- fclose($fp);
746
- $crc32 = crc32($temp);
747
- if (!isset($current['method']) && $this->options['method'] == 1)
748
- {
749
- $temp = gzcompress($temp, $this->options['level']);
750
- $size = strlen($temp) - 6;
751
- $temp = substr($temp, 2, $size);
752
- }
753
- else
754
- $size = strlen($temp);
755
- $block .= pack("VVVvv", $crc32, $size, $current['stat'][7], strlen($current['name2']), 0x0000);
756
- $block .= $current['name2'];
757
- $this->add_data($block);
758
- $this->add_data($temp);
759
- unset ($temp);
760
- $central .= pack("VvvvvVVVVvvvvvVV", 0x02014b50, 0x0014, $this->options['method'] == 0 ? 0x0000 : 0x000A, 0x0000,
761
- (isset($current['method']) || $this->options['method'] == 0) ? 0x0000 : 0x0008, $timedate,
762
- $crc32, $size, $current['stat'][7], strlen($current['name2']), 0x0000, 0x0000, 0x0000, 0x0000, 0x00000000, $offset);
763
- $central .= $current['name2'];
764
- $files++;
765
- $offset += (30 + strlen($current['name2']) + $size);
766
- }
767
- else
768
- $this->error[] = "Could not open file {$current['name']} for reading. It was not added.";
769
- }
770
-
771
- $this->add_data($central);
772
-
773
- $this->add_data(pack("VvvvvVVv", 0x06054b50, 0x0000, 0x0000, $files, $files, strlen($central), $offset,
774
- !empty ($this->options['comment']) ? strlen($this->options['comment']) : 0x0000));
775
-
776
- if (!empty ($this->options['comment']))
777
- $this->add_data($this->options['comment']);
778
-
779
- chdir($pwd);
780
-
781
- return 1;
782
- }
783
- }
784
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/class-wpadm-archive.php CHANGED
@@ -1,500 +1,42 @@
1
- <?php
2
- if (!defined('PCLZIP_TEMPORARY_DIR')) {
3
- define('PCLZIP_TEMPORARY_DIR', WPAdm_Core::getTmpDir() . '/');
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';
11
- }
12
- if (!class_exists('WPAdm_Archive')) {
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
- */
21
- private $archive;
22
- private $md5_file = '';
23
- public $error = '';
24
-
25
- public $anew = false;
26
-
27
-
28
- private $method = '';
29
-
30
- public function __construct($file, $md5_file = '') {
31
- if (class_exists('wpadm_wp_full_backup_dropbox')) {
32
- $this->type_backup = wpadm_wp_full_backup_dropbox::getTypeBackup();
33
- }
34
- $this->file_zip = $file;
35
- $this->archive = new PclZip($file);
36
- $this->files[] = $file;
37
- $this->md5_file = $md5_file;
38
- }
39
-
40
- public function zipArhive($file_to_arhive = array())
41
- {
42
- if ( isset( $this->type_backup['zip_archive'] ) && $this->type_backup['zip_archive'] == 1 && !empty($file_to_arhive) ) {
43
- $command = $this->getCommandToArchive('zip_archive', $file_to_arhive);
44
- if (!empty($command)) {
45
- $command_return = array();
46
- $result_command = @exec($command, $command_return);
47
-
48
- $res = $this->parseResultZip($command_return);
49
-
50
- if ($res['add'] == count($file_to_arhive)) {
51
- $files = implode(PCLZIP_SEPARATOR, $file_to_arhive);
52
- $this->saveMd5($files);
53
- return true;
54
- }
55
- if ( file_exists( $this->file_zip ) && $res['error'] === 0 ) {
56
- $files = implode(PCLZIP_SEPARATOR, $file_to_arhive);
57
- $this->saveMd5($files);
58
- return true;
59
- }
60
- }
61
- }
62
- return false;
63
- }
64
-
65
- public function targzArchive( $file_to_arhive = array() )
66
- {
67
- if ( isset( $this->type_backup['targz_archive'] ) && $this->type_backup['targz_archive'] == 1 && !empty($file_to_arhive) ) {
68
-
69
- if ( $this->tarGzCommandArhive($file_to_arhive) ) {
70
- return true;
71
- }
72
- if ( !function_exists( 'gzencode' ) ) {
73
- $this->error = __( 'Functions for gz compression not available', 'dropbox-backup' );
74
- return false;
75
- }
76
-
77
- if ( strpos($this->file_zip, '.zip') !== false ) {
78
- $this->file_zip = str_replace('.zip', '.tar.gz', $this->file_zip);
79
- }
80
- $this->method = 'targz';
81
-
82
- $this->archive = fopen( $this->file_zip, 'ab' );
83
-
84
- $n = count($file_to_arhive);
85
- for($i = 0; $i < $n; $i++) {
86
- $this->addToTargz($file_to_arhive[$i], '');
87
- $this->saveMd5( $file_to_arhive[$i] );
88
- }
89
- $this->close();
90
- /* include_once dirname(__FILE__) . '/archive.php';
91
- $gz = new wpadm_gzip_file($this->file_zip);
92
- $gz->set_options( array('basedir' => ABSPATH, 'delete_path_in_archive' => $this->remove_path ) );
93
- $gz->add_files( $file_to_arhive );
94
- $gz->create_archive();
95
- if (!empty( $gz->error ) ) {
96
- $this->error = implode(" ", $gz->error );
97
- WPAdm_Core::log( $this->error );
98
- return false;
99
- }
100
- $this->saveMd5( implode( PCLZIP_SEPARATOR, $file_to_arhive) );
101
- */
102
-
103
- /*if ( strpos($this->file_zip, '.tar.gz') !== false ) {
104
- $this->file_zip = str_replace('.tar.gz', '.zip', $this->file_zip);
105
- } */
106
-
107
- if ( file_exists($this->file_zip) ) {
108
- return true;
109
- }
110
- }
111
- return false;
112
- }
113
-
114
- private function addToTargz($file, $file_in)
115
- {
116
- $file = str_replace('\\', '/', $file);
117
- if ( empty( $file_in ) ) {
118
- $serach = str_replace('\\', '/', ABSPATH);
119
- $file_in = str_replace($serach, '', $file);
120
- }
121
-
122
- $file_in = str_replace( array( "?", "<", ">", ":", "%","\"", "*", "|", chr(0) ) , '', $file_in );
123
-
124
- if ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
125
- clearstatcache(true, $file);
126
- }
127
-
128
- if ( ! is_readable( $file ) ) {
129
- $this->error = sprintf( __( 'File %s is not readable or does not exist', 'dropbox-backup' ), $file );
130
- return false;
131
- }
132
- $this->add_tar_file( $file, $file_in );
133
-
134
- }
135
-
136
- private function add_tar_file($file, $file_in)
137
- {
138
- if ( ! $this->check_archive( $file ) ) {
139
- return false;
140
- }
141
- $chunk_size = 1024 * 1024 * 4;
142
-
143
- //Limit string of file name in tar archive
144
- if ( strlen( $file_in ) <= 100 ) {
145
- $filename = $file_in;
146
- $filename_prefix = "";
147
- } else {
148
- $filename_offset = strlen( $file_in ) - 100;
149
- $split_pos = strpos( $file_in, '/', $filename_offset );
150
- if ( $split_pos === FALSE ) {
151
- $split_pos = strrpos( $file_in, '/' );
152
- }
153
- $filename = substr( $file_in, $split_pos + 1 );
154
- $filename_prefix = substr( $file_in, 0, $split_pos );
155
- if ( strlen( $filename ) > 100 ) {
156
- $filename = substr( $filename, -100 );
157
- WPAdm_Core::log( sprintf( __( 'File name "%1$s" is too long to be saved correctly in archive!', 'dropbox-backup' ), $file_in ) );
158
- }
159
- if ( strlen( $filename_prefix ) > 155 ) {
160
- WPAdm_Core::log( sprintf( __( 'File path "%1$s" is too long to be saved correctly in archive!', 'dropbox-backup' ), $file_in) );
161
- }
162
- }
163
- $file_stat = stat( $file );
164
- if ( ! $file_stat ) {
165
- return false;
166
- }
167
- $file_stat[ 'size' ] = abs( (int) $file_stat[ 'size' ] );
168
- //open file
169
- if ( $file_stat[ 'size' ] > 0 ) {
170
- if ( ! ( $fd = fopen( $file, 'rb' ) ) ) {
171
- $this->error = sprintf( __( 'Cannot open source file %s for archiving', 'dropbox-backup' ), $file );
172
- return false;
173
- }
174
- }
175
- $fileowner = __( "Unknown", "dropbox-backup" );
176
- $filegroup = __( "Unknown", "dropbox-backup" );
177
- if ( function_exists( 'posix_getpwuid' ) ) {
178
- $info = posix_getpwuid( $file_stat[ 'uid' ] );
179
- $fileowner = $info[ 'name' ];
180
- $info = posix_getgrgid( $file_stat[ 'gid' ] );
181
- $filegroup = $info[ 'name' ];
182
- }
183
- // Generate the TAR header for this file
184
- $chunk = pack( "a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155a12",
185
- $filename, //name of file 100
186
- sprintf( "%07o", $file_stat[ 'mode' ] ), //file mode 8
187
- sprintf( "%07o", $file_stat[ 'uid' ] ), //owner user ID 8
188
- sprintf( "%07o", $file_stat[ 'gid' ] ), //owner group ID 8
189
- sprintf( "%011o", $file_stat[ 'size' ] ), //length of file in bytes 12
190
- sprintf( "%011o", $file_stat[ 'mtime' ] ), //modify time of file 12
191
- " ", //checksum for header 8
192
- 0, //type of file 0 or null = File, 5=Dir
193
- "", //name of linked file 100
194
- "ustar", //USTAR indicator 6
195
- "00", //USTAR version 2
196
- $fileowner, //owner user name 32
197
- $filegroup, //owner group name 32
198
- "", //device major number 8
199
- "", //device minor number 8
200
- $filename_prefix, //prefix for file name 155
201
- "" ); //fill block 12
202
-
203
- $checksum = 0;
204
- for ( $i = 0; $i < 512; $i ++ ) {
205
- $checksum += ord( substr( $chunk, $i, 1 ) );
206
- }
207
-
208
- $checksum = pack( "a8", sprintf( "%07o", $checksum ) );
209
- $chunk = substr_replace( $chunk, $checksum, 148, 8 );
210
-
211
- if ( isset( $fd ) && is_resource( $fd ) ) {
212
- // read/write files in 512 bite Blocks
213
- while ( ( $content = fread( $fd, 512 ) ) != '' ) {
214
- $chunk .= pack( "a512", $content );
215
- if ( strlen( $chunk ) >= $chunk_size ) {
216
- if ( WPAdm_Running::is_stop() ) {
217
- if ( $this->method == 'targz' ) {
218
- $chunk = gzencode( $chunk );
219
- }
220
- if ( $this->method == 'tarbz2' ) {
221
- $chunk = bzcompress( $chunk );
222
- }
223
- fwrite( $this->archive, $chunk );
224
- $chunk = '';
225
- }
226
- }
227
- }
228
- fclose( $fd );
229
- }
230
-
231
- if ( ! empty( $chunk ) ) {
232
- if ( $this->method == 'targz' ) {
233
- $chunk = gzencode( $chunk );
234
- }
235
- if ( $this->method == 'tarbz2' ) {
236
- $chunk = bzcompress( $chunk );
237
- }
238
- fwrite( $this->archive, $chunk );
239
- }
240
-
241
- return true;
242
- }
243
-
244
- private function check_archive( $file = '' ) {
245
-
246
- $file_size = 0;
247
- if ( ! empty( $file ) ) {
248
- $file_size = filesize( $file );
249
- if ( $file_size === FALSE ) {
250
- $file_size = 0;
251
- }
252
- }
253
-
254
- if ( is_resource( $this->archive ) ) {
255
- $info_archive = fstat( $this->archive );
256
- $archive_size = $info_archive[ 'size' ];
257
- } else {
258
- $archive_size = filesize( $this->file_zip );
259
- if ( $archive_size === FALSE ) {
260
- $archive_size = PHP_INT_MAX;
261
- }
262
- }
263
-
264
- $archive_size = $archive_size + $file_size;
265
- if ( $archive_size >= PHP_INT_MAX ) {
266
- $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 );
267
- return false;
268
- }
269
-
270
- return true;
271
- }
272
-
273
- public function close()
274
- {
275
- if ($this->method == 'targz') {
276
- $end = pack( "a1024", "" );
277
- if ( $this->method === 'targz' ) {
278
- $end = gzencode( $end );
279
- }
280
- if ( $this->method === 'tarbz2' ) {
281
- $end = bzcompress( $end );
282
- }
283
- fwrite( $this->archive, $end );
284
- }
285
- }
286
-
287
- public function parseResultZip($command_return)
288
- {
289
- $add = 0;
290
- $error = 0;
291
- if (!empty( $command_return) ) {
292
- $n = count($command_return);
293
- for($i = 0; $i < $n; $i++) {
294
- if (strpos($command_return[$i], 'add') !== false || strpos($command_return[$i], 'updating') !== false) {
295
- $add ++;
296
- } elseif (strpos($command_return[$i], 'error') !== false || strpos($command_return[$i], 'warning') !== false ) {
297
- $error++;
298
- $this->error .= " " . $command_return[$i];
299
- }
300
- }
301
- }
302
- return array( 'add' => $add, 'error' => $error );
303
-
304
- }
305
-
306
- public function tarGzCommandArhive($file_to_arhive = array())
307
- {
308
-
309
- $command = $this->getCommandToArchive('tar_archive', $file_to_arhive);
310
- if (!empty($command)) {
311
- $command_return = array();
312
- $result_command = @exec ($command, $command_return);
313
- if (count($file_to_arhive) == count($command_return)) {
314
- $files = implode(PCLZIP_SEPARATOR, $file_to_arhive);
315
- $this->saveMd5($files);
316
- return true;
317
- }
318
- if (count($command_return) > 0) {
319
- $files = implode(PCLZIP_SEPARATOR, $file_to_arhive);
320
- $this->saveMd5($files);
321
- return true;
322
- }
323
- if (file_exists($this->file_zip)) {
324
- $files = implode(PCLZIP_SEPARATOR, $file_to_arhive);
325
- $this->saveMd5($files);
326
- return true;
327
- }
328
- $this->error = "Files not Adding to arhive";
329
- if ( strpos($this->file_zip, '.tar.gz') !== false ) {
330
- $this->file_zip = str_replace('.tar.gz', '.zip', $this->file_zip);
331
- }
332
- }
333
- return false;
334
- }
335
-
336
- public function getCommandToArchive($type = 'zip_archive', $files = array() )
337
- {
338
- $return = '';
339
- $remove_dir = '';
340
- switch($type) {
341
- case 'zip_archive':
342
- if (!empty( $this->remove_path ) ) {
343
- $remove_dir = 'cd ' . $this->remove_path . ' &&';
344
- $files_str = '"' . implode('" "', $files) . '"';
345
- $files_str = str_replace($this->remove_path, './', $files_str);
346
- $zip = str_replace($this->remove_path, './', $this->file_zip);
347
- } else {
348
- $files_str = '"' . implode('" "', $files) . '"';
349
- $zip = $this->file_zip;
350
- }
351
-
352
- $return .= trim( "$remove_dir zip {$zip} " . $files_str );
353
- break;
354
- case 'tar_archive':
355
- if ( strpos($this->file_zip, '.zip') !== false ) {
356
- $this->file_zip = str_replace('.zip', '.tar.gz', $this->file_zip);
357
- }
358
-
359
- if (!empty( $this->remove_path) ) {
360
- $remove_dir = '-C ' . $this->remove_path . ' ';
361
- }
362
- $files_str = '"' . implode('" "', $files) . '"';
363
- $files_str = str_replace($this->remove_path, './', $files_str);
364
- $u = 'c';
365
- if (file_exists($this->file_zip)) {
366
- $u = 'r';
367
- }
368
- $return = trim( "tar -{$u}zvf {$this->file_zip} " . $remove_dir . $files_str );
369
- break;
370
- }
371
- return $return;
372
-
373
- }
374
-
375
- public function clearBackupDirectory($type = '')
376
- {
377
- if (!empty( $type ) ) {
378
- $dir = substr($this->file_zip, 0, strlen($this->file_zip) - strlen( basename( $this->file_zip ) ) );
379
- $open_dir = opendir( $dir );
380
- if ($open_dir) {
381
- while($d = readdir($open_dir)) {
382
- if ($d != '.' && $d != '..') {
383
- if ( substr($d, $type) !== false ) {
384
- @unlink($dir . '/' . $d);
385
- }
386
- }
387
- }
388
- }
389
- }
390
- }
391
-
392
- public function add($file)
393
- {
394
- return $this->packed($file);
395
- }
396
- public function packed($file)
397
- {
398
- @ini_set("memory_limit", "256M");
399
- if ( WPAdm_Running::is_stop() ) {
400
- $files = explode(PCLZIP_SEPARATOR, $file);
401
- $n = count($files);
402
- $this->setToLogArhive( __('Add to archive: ', 'dropbox-backup') . $this->file_zip );
403
- for($i = 0; $i < $n; $i++) {
404
-
405
- $this->setToLogArhive(__("Add File: ", 'dropbox-backup' ) . $files[$i] . ' [' . WPADM_getSize( filesize($files[$i]) ) . ']' . '[' . wpadm_class::perm($files[$i]) . ']' );
406
- }
407
- $file = implode(PCLZIP_SEPARATOR, $files);
408
- $command_targz_test = WPAdm_Running::getCommandResultData('test_targz_archive');
409
- if( !empty($command_targz_test) && $command_targz_test === true ) {
410
- if ( WPAdm_Running::is_stop() ) {
411
- WPAdm_Core::log(__('Trying to add files to archive using Tar shell or tar class', 'dropbox-backup') );
412
- $tarGz = $this->targzArchive($files); // .tar.gz archive
413
- if ($tarGz) {
414
- WPAdm_Core::log(__('Trying to add files to archive using Tar shell or tar class was successful', 'dropbox-backup') );
415
- return true;
416
- }
417
- $this->anew = true;
418
- $this->clearBackupDirectory('.tar.gz');
419
- $this->clearBackupDirectory('.md5');
420
- $this->error = '';
421
- WPAdm_Core::log(__('Add files to archive using Tar shell or tar class wasn\'t successful', 'dropbox-backup') );
422
- WPAdm_Running::setCommandResultData('test_targz_archive', false);
423
- return false;
424
- }
425
- }
426
- $command_zip_test = WPAdm_Running::getCommandResultData('test_zip_archive');
427
- if ( !empty($command_zip_test) && $command_zip_test === true ) {
428
- if ( WPAdm_Running::is_stop() ) {
429
- WPAdm_Core::log(__('Trying to add files to archive using Zip shell', 'dropbox-backup') );
430
- $zip_shell = $this->zipArhive($files); // command zip
431
- if ($zip_shell) {
432
- WPAdm_Core::log(__('Add files to archive using Zip shell was successful', 'dropbox-backup') );
433
- return true;
434
- }
435
- $this->anew = true;
436
- WPAdm_Core::log(__('Add files to archive using Zip shell wasn\'t successful', 'dropbox-backup') );
437
- WPAdm_Running::setCommandResultData('test_zip_archive', false);
438
- return false;
439
- }
440
- }
441
- if (empty($this->remove_path)) {
442
- if ( WPAdm_Running::is_stop() ) {
443
- $res = $this->archive->add($file);
444
- }
445
- } else {
446
- if ( WPAdm_Running::is_stop() ) {
447
- $res = $this->archive->add($file, PCLZIP_OPT_REMOVE_PATH, $this->remove_path);
448
- }
449
- }
450
- if ( WPAdm_Running::is_stop() ) {
451
- if ($res == 0) {
452
- $this->checkError($file);
453
- WPAdm_Core::log( $this->archive->errorInfo(true) );
454
- if (file_exists($this->md5_file)) {
455
- unset($this->md5_file);
456
- }
457
- $this->error = $this->archive->errorInfo(true);
458
- return false;
459
- }
460
- $this->saveMd5($file);
461
- }
462
- }
463
- return true;
464
- }
465
-
466
- protected function checkError($file)
467
- {
468
- $count = WPAdm_Running::getCommandResultData('count_error_zip');
469
- if ( empty($count) || $count == 0 ) {
470
- if ( $this->archive->errorCode() == -10 ) { // Unable to find End of Central Dir Record signature
471
- WPAdm_Core::rmdir($this->file_zip);
472
- WPAdm_Running::getCommandResultData('count_error_zip_signature', 1);
473
- $this->packed($file);
474
- return true;
475
- }
476
- }
477
- return false;
478
- }
479
-
480
- protected function saveMd5($file) {
481
- if ($this->md5_file) {
482
- $files = explode(PCLZIP_SEPARATOR, $file); {
483
- foreach($files as $f) {
484
- file_put_contents($this->md5_file, $f . "\t" . @md5_file($f) . "\t" . basename($this->file_zip) . "\n", FILE_APPEND);
485
- }
486
- }
487
- }
488
- }
489
-
490
- public function setRemovePath($remove_path) {
491
- $this->remove_path = $remove_path;
492
- }
493
-
494
- public function setToLogArhive($msg)
495
- {
496
- $file_log = WPADM_Core::getTmpDir() . '/log-archive.log';
497
- file_put_contents( $file_log, date("Y-m-d H:i:s") . "\t{$msg}\n", FILE_APPEND );
498
- }
499
- }
500
  }
1
+ <?php
2
+ require_once dirname(__FILE__) . '/pclzip.lib.php';
3
+ if (!class_exists('WPAdm_Archive')) {
4
+ class WPAdm_Archive {
5
+ private $remove_path = '';
6
+ private $files = array();
7
+ /**
8
+ * @var PclZip
9
+ */
10
+ private $archive;
11
+ private $md5_file = '';
12
+
13
+ public function __construct($file, $md5_file = '') {
14
+ $this->archive = new PclZip($file);
15
+ $this->files[] = $file;
16
+ $this->md5_file = $md5_file;
17
+ }
18
+
19
+ public function add($file) {
20
+ if (empty($this->remove_path)) {
21
+ $this->archive->add($file);
22
+ } else {
23
+ $this->archive->add($file, PCLZIP_OPT_REMOVE_PATH, $this->remove_path);
24
+ }
25
+ $this->saveMd5($file);
26
+ }
27
+
28
+ protected function saveMd5($file) {
29
+ if ($this->md5_file) {
30
+ $files = explode(',', $file); {
31
+ foreach($files as $f) {
32
+ file_put_contents($this->md5_file, $f . "\t" . md5_file($f) . "\t" . basename($this->archive->zipname) . "\n", FILE_APPEND);
33
+ }
34
+ }
35
+ }
36
+ }
37
+
38
+ public function setRemovePath($remove_path) {
39
+ $this->remove_path = $remove_path;
40
+ }
41
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
modules/class-wpadm-command-context.php CHANGED
@@ -1,7 +1,4 @@
1
  <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
  if (!class_exists('WPAdm_Command_Context')) {
6
  class WPAdm_Command_Context {
7
  private $params = array();
1
  <?php
 
 
 
2
  if (!class_exists('WPAdm_Command_Context')) {
3
  class WPAdm_Command_Context {
4
  private $params = array();
modules/class-wpadm-command-factory.php CHANGED
@@ -1,42 +1,34 @@
1
- <?php
2
-
3
-
4
- if ( ! defined( 'ABSPATH' ) ) exit;
5
-
6
-
7
- /**
8
- * Class WPAdm_Command_Factory
9
- */
10
- if (!class_exists('WPAdm_Command_Factory')) {
11
- class WPAdm_Command_Factory {
12
- /**
13
- * @param string $com
14
- * @return command
15
- */
16
- static function getCommand($com = '') {
17
- if (!preg_match("|[a-zA-Z0-9_]|", $com)) {
18
- return null;
19
- }
20
- if (function_exists('mb_strtolower')) {
21
- $com = mb_strtolower($com);
22
- } else {
23
- $com = strtolower($com);
24
- }
25
- $tmp = explode('_', $com);
26
- $class_file = WPAdm_Core::getPluginDir() . "/commands/class-wpadm-command-" . str_replace('_', '-', $com) . ".php";
27
-
28
- if (file_exists($class_file)) {
29
- require_once $class_file;
30
- foreach($tmp as $k=>$v) {
31
- $tmp[$k] = ucfirst($v);
32
- }
33
- $com = implode('_', $tmp);
34
-
35
- $class_name = "WPAdm_Command_{$com}";
36
- return new $class_name();
37
- }
38
-
39
- return null;
40
- }
41
- }
42
  }
1
+ <?php
2
+ /**
3
+ * Class WPAdm_Command_Factory
4
+ */
5
+ if (!class_exists('WPAdm_Command_Factory')) {
6
+ class WPAdm_Command_Factory {
7
+ /**
8
+ * @param string $com
9
+ * @return command
10
+ */
11
+ static function getCommand($com = '') {
12
+ if (!preg_match("|[a-zA-Z0-9_]|", $com)) {
13
+ return null;
14
+ }
15
+
16
+ $com = mb_strtolower($com);
17
+ $tmp = explode('_', $com);
18
+ $class_file = WPAdm_Core::getPluginDir() . "/commands/class-wpadm-command-" . str_replace('_', '-', $com) . ".php";
19
+
20
+ if (file_exists($class_file)) {
21
+ require_once $class_file;
22
+ foreach($tmp as $k=>$v) {
23
+ $tmp[$k] = ucfirst($v);
24
+ }
25
+ $com = implode('_', $tmp);
26
+
27
+ $class_name = "WPAdm_Command_{$com}";
28
+ return new $class_name();
29
+ }
30
+
31
+ return null;
32
+ }
33
+ }
 
 
 
 
 
 
 
 
34
  }
modules/class-wpadm-command.php CHANGED
@@ -1,18 +1,14 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
-
6
- /**
7
- * Class WPAdm_Сommand
8
- */
9
- if (!class_exists('WPAdm_Сommand')) {
10
- abstract class WPAdm_Сommand {
11
- /**
12
- * @param WPAdm_Command_Context $context
13
- * @return boolean
14
- */
15
- abstract function execute(WPAdm_Command_Context $context);
16
-
17
- }
18
  }
1
+ <?php
2
+ /**
3
+ * Class WPAdm_Сommand
4
+ */
5
+ if (!class_exists('WPAdm_Сommand')) {
6
+ abstract class WPAdm_Сommand {
7
+ /**
8
+ * @param WPAdm_Command_Context $context
9
+ * @return boolean
10
+ */
11
+ abstract function execute(WPAdm_Command_Context $context);
12
+
13
+ }
 
 
 
 
14
  }
modules/class-wpadm-core.php CHANGED
@@ -1,112 +1,85 @@
1
  <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-result.php';
6
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-command.php';
7
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-command-context.php';
8
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-queue.php';
9
- require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-running.php';
10
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-command-factory.php';
11
 
12
 
13
  if (!class_exists('WPAdm_Core')) {
14
-
15
  class WPAdm_Core {
16
 
17
  /*
18
- * "fly" POST from server
19
  * @var array
20
  */
21
  private $request = array();
22
 
23
  /*
24
- * public key for auth
25
  * @var string
26
  */
27
  private $pub_key;
28
 
29
  /*
30
- * work result
31
  * @var WPAdm_Result
32
  */
33
  private $result;
34
 
35
  private $plugin;
36
-
37
- private $sign = false;
38
-
39
- public $name = '',
40
- $time = '';
41
-
42
- public static $cron = true;
43
 
44
  public static $pl_dir;
45
 
46
- public static $error = '';
47
-
48
- private static $self = null;
49
-
50
  public static $plugin_name;
51
 
52
- private static $cron_method = array('local_backup', 'send_to_dropbox');
53
-
54
 
55
- public function __construct(array $request, $plugin = '', $plugin_dir = '', $sign = false) {
56
  $this->result = new WPAdm_Result();
57
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
58
  $this->request = $request;
59
- if ( empty( $this->request ) ) {
60
- return;
61
- }
62
  $this->plugin = $plugin;
63
- $this->sign = $sign;
64
  self::$pl_dir = $plugin_dir;
65
  self::$plugin_name = $plugin;
66
- // auth request
67
- if ( !$this->sign ) {
68
- if (!$this->auth()) {
69
- return;
70
- }
71
- }
72
  if ('connect' == $request['method']) {
73
  $this->connect();
74
  } elseif ('local' == $request['method']){
75
 
76
  } elseif($obj = $this->getObject($request['method'], $request['params'])) {
77
- if (!is_null($obj) && !is_bool($obj) && $obj->isError()) {
78
- $this->result = $obj->get_results();
79
- } elseif(!is_null($obj) && !is_bool($obj)) {
80
- if (isset($obj->name)) {
81
- $this->name = $obj->name;
82
- }
83
- if (isset($obj->time)) {
84
- $this->time = $obj->time;
85
- }
86
- $this->result = $obj->getResult();
87
  }
 
88
  } else {
89
- $this->result->setError(sprintf(__('Unknown method "%s"', 'dropbox-backup'), $request['method'] ) );
90
  }
91
  }
92
 
93
 
94
  /**
95
- * return path to tmp dir
96
  * @return string
97
  */
98
  static public function getTmpDir() {
99
  $tmp_dir = self::$pl_dir . '/tmp';
100
  self::mkdir($tmp_dir);
101
  if (!file_exists($tmp_dir . '/index.php')) {
102
- @file_put_contents($tmp_dir . '/index.php', '');
103
- if (!file_exists($tmp_dir . '/index.php')) {
104
- self::$error = ( sprintf( __('Backup creating<br /><br />Please check the permissions on folder "%s".<br />Failed to create folder.', 'dropbxo-backup'), $tmp_dir ) );
105
- }
106
  }
107
  return $tmp_dir;
108
  }
109
-
 
 
 
 
110
  static public function getPluginDir() {
111
  return self::$pl_dir;
112
  }
@@ -117,15 +90,13 @@ if (!class_exists('WPAdm_Core')) {
117
  * @return null|WPAdm_Method_Class
118
  */
119
  private function getObject($method, $params) {
120
- if (!preg_match("|[a-zA-Z0-9_\-]|", $method)) {
121
  return null;
122
  }
123
- if (function_exists('mb_strtolower')) {
124
- $method = mb_strtolower($method);
125
- } else {
126
- $method = strtolower($method);
127
- }
128
  $class_file = self::$pl_dir . "/methods/class-wpadm-method-" . str_replace('_', '-', $method) . ".php";
 
129
  if (file_exists($class_file)) {
130
  require_once $class_file;
131
  $tmp = explode('_', str_replace('-', '_', $method));
@@ -136,25 +107,16 @@ if (!class_exists('WPAdm_Core')) {
136
 
137
  $class_name = "WPAdm_Method_{$method}";
138
  if (!class_exists($class_name)) {
139
- $this->getResult()->setError(sprintf( __( "Class '%s' not found", 'dropbox-backup' ), $class_name ) );
140
  $this->getResult()->setResult(WPAdm_result::WPADM_RESULT_ERROR);
141
  return null;
142
  }
143
- if (in_array( strtolower( $method ), self::$cron_method) && self::$cron) {
144
- WPAdm_Running::setCommand( strtolower($this->request['method']), $params );
145
- WPAdm_Running::run();
146
- self::$cron = true;
147
- return true;
148
- } else {
149
- return new $class_name($params);
150
- }
151
-
152
  }
153
  return null;
154
 
155
  }
156
 
157
-
158
  public static function getLog()
159
  {
160
  $file_log = self::getTmpDir() . '/log.log';
@@ -189,7 +151,7 @@ if (!class_exists('WPAdm_Core')) {
189
  }
190
 
191
  /*
192
- * auth request
193
  */
194
  private function auth() {
195
  $this->pub_key = get_option('wpadm_pub_key');
@@ -197,59 +159,47 @@ if (!class_exists('WPAdm_Core')) {
197
  if ( in_array($this->request['method'], $methods_local) ) {
198
  return true;
199
  }
200
- self::log($this->request['method']);
201
  if (empty($this->pub_key)) {
202
  if ('connect' == $this->request['method']) {
203
  $this->pub_key = $this->request['params']['pub_key'];
204
  } else {
205
- $this->getResult()->setError( __( 'Activate site in WPAdm.com for work to plugins.', 'dropbox-backup' ) );
206
  return false;
207
  }
208
  } elseif ('connect' == $this->request['method']) {
209
  if( $this->pub_key != $this->request['params']['pub_key'] ){
210
- $this->getResult()->setError( __( 'Error. Reconnect Plugin.', 'dropbox-backup' ) );
211
  return false;
212
  }
213
  } elseif('queue_controller' == $this->request['method']) {
214
- //todo: check run self
215
  return true;
216
 
217
  }
218
 
219
  $sign = md5(serialize($this->request['params']));
220
  //openssl_public_decrypt($this->request['sign'], $request_sign, $this->pub_key);
221
- $ret = $this->verifySignature(base64_decode( $this->request['sign'] ), base64_decode( $this->request['sign2'] ), $this->pub_key, $sign);
222
 
223
 
224
  //$ret = ($sign == $request_sign);
225
  if (!$ret) {
226
- $this->getResult()->setError(__("Incorrect signature", 'dropbox-backup'));
227
  }
228
  return $ret;
229
  }
230
-
231
-
232
  /**
233
- * create dir
234
  * @param $dir
235
  */
236
  static public function mkdir($dir) {
237
  if(!file_exists($dir)) {
238
- @mkdir($dir, 0755);
239
- if (!is_dir($dir)) {
240
- self::$error = str_replace("&s", $dir, __('Backup creating<br /><br />Please check the permissions on folder "&s". Failed to create folder.','dropbox-backup') );
241
- } else {
242
- //todo: права доступа
243
- @file_put_contents($dir . '/index.php', '<?php echo "Hello World!"; ');
244
- if ( !is_writable($dir . '/index.php') ) {
245
- self::$error = str_replace("&s", $dir . '/index.php' , __('Backup creating<br /><br />Please check the permissions on file "&s". Failed to create file.','dropbox-backup') );
246
- }
247
- }
248
  }
249
- if (!file_exists($dir . '/.htaccess')) {
250
- @file_put_contents($dir . '/.htaccess', 'DENY FROM ALL');
251
- }
252
- return self::$error;
253
  }
254
 
255
  /**
@@ -258,21 +208,13 @@ if (!class_exists('WPAdm_Core')) {
258
  public function getResult() {
259
  return $this->result;
260
  }
261
-
262
- public static function getInstance()
263
- {
264
- if (is_null( self::$self ) ) {
265
- self::$self = new self( array() );
266
- }
267
- return self::$self;
268
- }
269
 
270
 
271
  public function verifySignature($sign, $sign2, $pub_key, $text) {
272
- if (function_exists('openssl_public_decrypt')) {
273
  openssl_public_decrypt($sign, $request_sign, $pub_key);
274
  $ret = ($text == $request_sign);
275
- return $ret;
276
  } else {
277
  set_include_path(get_include_path() . PATH_SEPARATOR . self::getPluginDir() . '/modules/phpseclib');
278
  require_once 'Crypt/RSA.php';
@@ -295,10 +237,8 @@ if (!class_exists('WPAdm_Core')) {
295
 
296
 
297
  static public function log($txt, $class='') {
298
- if (!empty($txt)) {
299
- $log_file = self::getTmpDir() . '/log.log';
300
- file_put_contents($log_file, date("Y-m-d H:i:s") ."\t{$class}\t{$txt}\n", FILE_APPEND);
301
- }
302
  }
303
 
304
  /**
@@ -307,39 +247,20 @@ if (!class_exists('WPAdm_Core')) {
307
  */
308
  static function rmdir($dir) {
309
  if (is_dir($dir)) {
310
- $dir_open = opendir($dir);
311
- while($f = readdir($dir_open)) {
312
  if ($f == '..' or $f == '.') {
313
  continue;
314
  }
315
- if (is_dir($dir . '/' . $f)) {
316
- self::rmdir($dir . '/' . $f);
317
  }
318
- if (file_exists($dir . '/' . $f)) {
319
- @unlink($dir . '/' . $f);
320
  }
321
  }
322
  @rmdir($dir);
323
- } elseif (is_file($dir)) {
324
- @unlink($dir);
325
  }
326
  }
327
- static function dir_writeble($dir)
328
- {
329
- $error = self::mkdir($dir);
330
- $ret = true;
331
- if (!empty($dir)) {
332
- @file_put_contents($dir . "/test", "Hello World!!!");
333
- if (file_exists($dir . "/test")) {
334
- if (!@is_writable($dir . "/test") && @filesize($dir . "/test") == 0) {
335
- $ret = false;
336
- }
337
- } else {
338
- $ret = false;
339
- }
340
- @unlink($dir . "/test");
341
- }
342
- return $ret;
343
- }
344
  }
345
  }
1
  <?php
 
 
 
2
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-result.php';
3
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-command.php';
4
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-command-context.php';
5
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-queue.php';
 
6
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-command-factory.php';
7
 
8
 
9
  if (!class_exists('WPAdm_Core')) {
 
10
  class WPAdm_Core {
11
 
12
  /*
13
+ * "прилетевший" POST-запрос от админки($_POST)
14
  * @var array
15
  */
16
  private $request = array();
17
 
18
  /*
19
+ * публичный ключ для проверки подписи
20
  * @var string
21
  */
22
  private $pub_key;
23
 
24
  /*
25
+ * Результат выполнения запроса
26
  * @var WPAdm_Result
27
  */
28
  private $result;
29
 
30
  private $plugin;
 
 
 
 
 
 
 
31
 
32
  public static $pl_dir;
33
 
 
 
 
 
34
  public static $plugin_name;
35
 
 
 
36
 
37
+ public function __construct(array $request, $plugin = '', $plugin_dir = '') {
38
  $this->result = new WPAdm_Result();
39
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
40
  $this->request = $request;
 
 
 
41
  $this->plugin = $plugin;
 
42
  self::$pl_dir = $plugin_dir;
43
  self::$plugin_name = $plugin;
44
+ // авторизация запроса
45
+ if (!$this->auth()) {
46
+ return;
47
+ };
 
 
48
  if ('connect' == $request['method']) {
49
  $this->connect();
50
  } elseif ('local' == $request['method']){
51
 
52
  } elseif($obj = $this->getObject($request['method'], $request['params'])) {
53
+ if (isset($obj->name)) {
54
+ $this->name = $obj->name;
55
+ }
56
+ if (isset($obj->time)) {
57
+ $this->time = $obj->time;
 
 
 
 
 
58
  }
59
+ $this->result = $obj->getResult();
60
  } else {
61
+ $this->result->setError('Unknown method "' . $request['method'] . '"');
62
  }
63
  }
64
 
65
 
66
  /**
67
+ * Возвращает путь до папки временных файлов
68
  * @return string
69
  */
70
  static public function getTmpDir() {
71
  $tmp_dir = self::$pl_dir . '/tmp';
72
  self::mkdir($tmp_dir);
73
  if (!file_exists($tmp_dir . '/index.php')) {
74
+ file_put_contents($tmp_dir . '/index.php', '');
 
 
 
75
  }
76
  return $tmp_dir;
77
  }
78
+
79
+ /**
80
+ * Возвращает путь до папки временных файлов
81
+ * @return string
82
+ */
83
  static public function getPluginDir() {
84
  return self::$pl_dir;
85
  }
90
  * @return null|WPAdm_Method_Class
91
  */
92
  private function getObject($method, $params) {
93
+ if (!preg_match("|[a-zA-Z0-9_]|", $method)) {
94
  return null;
95
  }
96
+ $method = mb_strtolower($method);
97
+
 
 
 
98
  $class_file = self::$pl_dir . "/methods/class-wpadm-method-" . str_replace('_', '-', $method) . ".php";
99
+ WPAdm_Core::log($class_file);
100
  if (file_exists($class_file)) {
101
  require_once $class_file;
102
  $tmp = explode('_', str_replace('-', '_', $method));
107
 
108
  $class_name = "WPAdm_Method_{$method}";
109
  if (!class_exists($class_name)) {
110
+ $this->getResult()->setError("Class '$class_name' not found");
111
  $this->getResult()->setResult(WPAdm_result::WPADM_RESULT_ERROR);
112
  return null;
113
  }
114
+ return new $class_name($params);
 
 
 
 
 
 
 
 
115
  }
116
  return null;
117
 
118
  }
119
 
 
120
  public static function getLog()
121
  {
122
  $file_log = self::getTmpDir() . '/log.log';
151
  }
152
 
153
  /*
154
+ * Авторизация запроса
155
  */
156
  private function auth() {
157
  $this->pub_key = get_option('wpadm_pub_key');
159
  if ( in_array($this->request['method'], $methods_local) ) {
160
  return true;
161
  }
 
162
  if (empty($this->pub_key)) {
163
  if ('connect' == $this->request['method']) {
164
  $this->pub_key = $this->request['params']['pub_key'];
165
  } else {
166
+ $this->getResult()->setError('Activate site in WPAdm.com for work to plugins.');
167
  return false;
168
  }
169
  } elseif ('connect' == $this->request['method']) {
170
  if( $this->pub_key != $this->request['params']['pub_key'] ){
171
+ $this->getResult()->setError('Ошибка. Воспользуйтесь переподключением плагина.');
172
  return false;
173
  }
174
  } elseif('queue_controller' == $this->request['method']) {
175
+ //todo: проверить, что запустили сами себя
176
  return true;
177
 
178
  }
179
 
180
  $sign = md5(serialize($this->request['params']));
181
  //openssl_public_decrypt($this->request['sign'], $request_sign, $this->pub_key);
182
+ $ret = $this->verifySignature($this->request['sign'], $this->request['sign2'], $this->pub_key, $sign);
183
 
184
 
185
  //$ret = ($sign == $request_sign);
186
  if (!$ret) {
187
+ $this->getResult()->setError("Неверная подпись");
188
  }
189
  return $ret;
190
  }
191
+
192
+
193
  /**
194
+ * Создаем папку
195
  * @param $dir
196
  */
197
  static public function mkdir($dir) {
198
  if(!file_exists($dir)) {
199
+ mkdir($dir, 0755);
200
+ //todo: права доступа
201
+ file_put_contents($dir . '/index.php', '');
 
 
 
 
 
 
 
202
  }
 
 
 
 
203
  }
204
 
205
  /**
208
  public function getResult() {
209
  return $this->result;
210
  }
 
 
 
 
 
 
 
 
211
 
212
 
213
  public function verifySignature($sign, $sign2, $pub_key, $text) {
214
+ if (function_exists('openssl_public_decrypt')) {
215
  openssl_public_decrypt($sign, $request_sign, $pub_key);
216
  $ret = ($text == $request_sign);
217
+ return $ret;
218
  } else {
219
  set_include_path(get_include_path() . PATH_SEPARATOR . self::getPluginDir() . '/modules/phpseclib');
220
  require_once 'Crypt/RSA.php';
237
 
238
 
239
  static public function log($txt, $class='') {
240
+ $log_file = self::getTmpDir() . '/log.log';
241
+ file_put_contents($log_file, date("Y-m-d H:i:s") ."\t{$class}\t{$txt}\n", FILE_APPEND);
 
 
242
  }
243
 
244
  /**
247
  */
248
  static function rmdir($dir) {
249
  if (is_dir($dir)) {
250
+ $files = glob($dir. '/*');
251
+ foreach($files as $f) {
252
  if ($f == '..' or $f == '.') {
253
  continue;
254
  }
255
+ if (is_dir($f)) {
256
+ self::rmdir($f);
257
  }
258
+ if (file_exists($f)) {
259
+ @unlink($f);
260
  }
261
  }
262
  @rmdir($dir);
 
 
263
  }
264
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  }
266
  }
modules/class-wpadm-method-class.php CHANGED
@@ -1,40 +1,26 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
-
6
- if (!class_exists('WPAdm_Method_Class')) {
7
- abstract class WPAdm_Method_Class {
8
- /**
9
- * @var mixed
10
- */
11
- protected $params;
12
-
13
- /**
14
- * @var WPAdm_result
15
- */
16
- protected $result;
17
-
18
- /**
19
- * @param mixed $params
20
- */
21
- public function __construct($params) {
22
- $this->params = $params;
23
- $this->result = new WPAdm_Result();
24
- $this->result->setResult(WPAdm_Result::WPADM_RESULT_SUCCESS);
25
- $this->result->setError('');
26
- }
27
-
28
- abstract function getResult();
29
-
30
- public function isError()
31
- {
32
- $error = $this->result->getError();
33
- return isset($this->result) && !empty( $error );
34
- }
35
- public function get_results()
36
- {
37
- return $this->result;
38
- }
39
- }
40
  }
1
+ <?php
2
+
3
+
4
+ if (!class_exists('WPAdm_Method_Class')) {
5
+ abstract class WPAdm_Method_Class {
6
+ /**
7
+ * @var mixed
8
+ */
9
+ protected $params;
10
+
11
+ /**
12
+ * @var WPAdm_result
13
+ */
14
+ protected $result;
15
+
16
+ /**
17
+ * @param mixed $params
18
+ */
19
+ public function __construct($params) {
20
+ $this->params = $params;
21
+ $this->result = new WPAdm_Result();
22
+ }
23
+
24
+ abstract function getResult();
25
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
modules/class-wpadm-mysqldump.php CHANGED
@@ -1,9 +1,4 @@
1
  <?php
2
-
3
-
4
- if ( ! defined( 'ABSPATH' ) ) exit;
5
-
6
-
7
  if (!class_exists('WPAdm_Mysqldump')) {
8
  class WPAdm_Mysqldump {
9
 
@@ -13,281 +8,107 @@ if (!class_exists('WPAdm_Mysqldump')) {
13
  public $host = '';
14
  public $user = '';
15
  public $password = '';
16
- public $dbh = null ;
17
- public $rows = 1000;
18
 
19
  private function connect($db = '') {
20
- //WPAdm_Core::log("----------------------------------------------------");
21
- //WPAdm_Core::log( __('Connecting to MySQL...' ,'dropbox-backup') );
22
  if (! class_exists('wpdb')) {
23
  require_once ABSPATH . '/' . WPINC . '/wp-db.php';
24
  }
25
- if ($this->dbh === null) {
26
- global $wpdb;
27
- if (is_object($wpdb)) {
28
- $this->dbh = $wpdb;
29
- } else {
30
- $this->dbh = new wpdb( $this->user, $this->password, $db, $this->host );
31
- $errors = $this->dbh->last_error;
32
- if ($errors) {
33
- $this->setError( __('MySQL Connect failed: ' ,'dropbox-backup') . $errors);
34
- }
35
- if (isset($this->dbh->error->errors) && count($this->dbh->error->errors) > 0 ) {
36
- $error = '';
37
- foreach($this->dbh->error->errors as $key => $err) {
38
- if ($key === 'db_connect_fail') {
39
- $error .= "Connect fail: Check the number of connections to the database or \n";
40
- }
41
- $error .= strip_tags( implode("\n", ($err) ) );
42
- }
43
- $this->setError( $error );
44
- }
45
- }
46
  }
47
- return $this->dbh;
48
  }
49
 
50
  public function optimize($db) {
51
- $proc_data = WPAdm_Running::getCommandResultData('db');
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;
59
- if (!empty( $link->last_error ) && $n > 0) {
60
- $this->setError($link->last_error);
 
 
 
61
  } else {
62
- for($i = 0; $i < $n; $i++ ) {
63
- $res = array_values( get_object_vars( $result[$i] ) );
64
- $proc_data = WPAdm_Running::getCommandResultData('db');
65
- if ( WPAdm_Running::is_stop() ) {
66
- if (!isset($proc_data['optimize_table'][$res[0]])) {
67
- $link->query('OPTIMIZE TABLE '. $res[0]);
68
- if (!empty( $link->last_error ) ) {
69
- $tables = isset($proc_data['optimize_table']) ? $proc_data['optimize_table'] : array();
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
- }
80
- }
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);
88
- }
89
- }
90
- }
91
- }
92
- }
93
- public function repair($db)
94
- {
95
- $proc_data = WPAdm_Running::getCommandResultData('repair');
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;
103
- if (!empty( $link->last_error )) {
104
- $this->setError($link->last_error);
105
- return false;
106
- }
107
- if ($link->last_result === null) {
108
- $this->setError(print_r(implode("\n", $link->error->errors), 1));
109
- return false;
110
- }
111
- $tables = array();
112
- for($i = 0; $i < $n; $i++ ) {
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');
120
- $proc_data['repair'][$row['Name']] = 1;
121
- WPAdm_Running::setCommandResultData('repair', $proc_data);
122
- } else {
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() ) {
130
- $proc_data = WPAdm_Running::getCommandResultData('repair');
131
- $proc_data['work'] = 1;
132
- WPAdm_Running::setCommandResultData('repair', $proc_data);
133
  }
134
  }
 
135
  }
136
- }
137
 
138
- public function mysqldump($db, $filename)
139
- {
140
- $proc_data = WPAdm_Running::getCommandResultData('db');
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);
148
- $result = $link->last_result;
149
- if (!empty( $link->last_error )) {
150
- $this->setError($link->last_error);
151
- return false;
152
- }
153
- if ($link->last_result === null) {
154
- /* foreach($link->error->errors as $key => $errors) {
155
- if ($key == db_connect_fail)
156
- }*/
157
- $this->setError(print_r(implode("\n", $link->error->errors), 1));
158
- return false;
159
- }
160
- if ( WPAdm_Running::is_stop() ) {
161
- for($i = 0; $i < $n; $i++ ) {
162
- $row = array_values( get_object_vars( $result[$i] ) );
163
- $tables[] = $row[0];
164
- }
165
- }
166
- if ( WPAdm_Running::is_stop() ) {
167
- foreach($tables as $key_tables => $table) {
168
- $return = '';
169
- $proc_data = WPAdm_Running::getCommandResultData('db');
170
- if ( !isset($proc_data['mysqldump_table'][$table]) ) {
171
 
172
- $result = $link->last_result;
173
- if (!empty( $link->last_error ) && $n > 0) {
174
- $this->setError($link->last_error);
175
- }
176
- if ( WPAdm_Running::is_stop() ) {
177
- $return.= 'DROP TABLE IF EXISTS ' . $table . ';';
 
 
 
 
 
 
 
178
 
179
- $ress = $link->query('SHOW CREATE TABLE ' . $table);
180
- $result2 = $link->last_result;
181
- if (!empty( $link->last_error ) && $n > 0) {
182
- $this->setError($link->last_error);
183
- }
184
- $row2 = array_values( get_object_vars( $result2[0] ) );
185
- $return.= "\n\n".$row2[1].";\n\n";
186
- }
187
- if ( WPAdm_Running::is_stop() ) {
188
- file_put_contents($filename, $return, FILE_APPEND);
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 = '';
229
- $row = array_values( get_object_vars( $result2[$i] ) );
230
- $rows_num = count($row);
231
- if ($rows_num > 0) {
232
- $return.= 'INSERT INTO ' . $table . ' VALUES(';
233
- for($j=0; $j < $rows_num; $j++) {
234
- $row[$j] = addslashes($row[$j]);
235
- $row[$j] = str_replace("\n","\\n",$row[$j]);
236
- if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
237
- if ($j<($rows_num-1)) { $return.= ','; }
238
- }
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);
275
- }
276
  }
 
277
  }
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);
285
  }
286
  }
287
- return true;
288
- } else {
289
- return false;
290
  }
 
 
 
 
 
 
291
  }
292
 
293
  private function setError($txt)
@@ -298,11 +119,11 @@ if (!class_exists('WPAdm_Mysqldump')) {
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 = "";
@@ -316,14 +137,14 @@ if (!class_exists('WPAdm_Mysqldump')) {
316
  $ress = $link->query($sql);
317
  if (!empty( $link->last_error ) && $n > 0) {
318
  $this->setError($link->last_error);
319
- WPAdm_Core::log(__('MySQL Error: ' ,'dropbox-backup') . $link->last_error);
320
  break;
321
  };
322
  $sql = "";
323
  }
324
  }
325
  }
326
- WPAdm_Core::log(__('Database restoring was finished' ,'dropbox-backup'));
327
  }
328
  }
329
  }
1
  <?php
 
 
 
 
 
2
  if (!class_exists('WPAdm_Mysqldump')) {
3
  class WPAdm_Mysqldump {
4
 
8
  public $host = '';
9
  public $user = '';
10
  public $password = '';
11
+ public $dbh ;
 
12
 
13
  private function connect($db = '') {
14
+ WPAdm_Core::log("----------------------------------------------------");
15
+ WPAdm_Core::log( langWPADM::get('Connecting to MySQL...' , false) );
16
  if (! class_exists('wpdb')) {
17
  require_once ABSPATH . '/' . WPINC . '/wp-db.php';
18
  }
19
+ $this->dbh = new wpdb( $this->user, $this->password, $db, $this->host );
20
+ $errors = $this->dbh->last_error;
21
+ if ($errors) {
22
+ $this->setError( langWPADM::get('MySQL Connect failed: ' , false) . $errors);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  }
24
+ return $this->dbh;
25
  }
26
 
27
  public function optimize($db) {
28
+ $link = $this->connect($db);
29
+ WPAdm_Core::log( langWPADM::get('Optimize Database Tables was started' , false) );
30
+ $n = $link->query('SHOW TABLES');
31
+ $result = $link->last_result;
32
+ if (!empty( $link->last_error ) && $n > 0) {
33
+ $this->setError($link->last_error);
34
+ } else {
35
+ for($i = 0; $i < $n; $i++ ) {
36
+ $res = array_values( get_object_vars( $result[$i] ) );
37
+ $link->query('OPTIMIZE TABLE '. $res[0]);
38
+ if (!empty( $link->last_error ) ) {
39
+ $log = str_replace('%s', $res[0], langWPADM::get('Error to Optimize Table `%s`' , false) );
40
+ WPAdm_Core::log($log);
41
  } else {
42
+ $log = str_replace('%s', $res[0], langWPADM::get('Optimize Table `%s` was successfully' , false) );
43
+ WPAdm_Core::log($log);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  }
45
  }
46
+ WPAdm_Core::log( langWPADM::get('Optimize Database Tables was Finished' , false) );
47
  }
 
48
 
49
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
+ public function mysqldump($db, $filename) {
52
+ $link = $this->connect($db);
53
+ WPAdm_Core::log( langWPADM::get('MySQL of Dump was started' , false) );
54
+ $tables = array();
55
+ $n = $link->query('SHOW TABLES');
56
+ $result = $link->last_result;
57
+ if (!empty( $link->last_error ) && $n > 0) {
58
+ $this->setError($link->last_error);
59
+ }
60
+ for($i = 0; $i < $n; $i++ ) {
61
+ $row = array_values( get_object_vars( $result[$i] ) );
62
+ $tables[] = $row[0];
63
+ }
64
 
65
+ $return = '';
66
+ foreach($tables as $table)
67
+ {
68
+ $log = str_replace('%s', $table, langWPADM::get('Add a table "%s" in the database dump' , false) );
69
+ WPAdm_Core::log( $log );
70
+ $num_fields = $link->query('SELECT * FROM ' . $table);
71
+ $result = $link->last_result;
72
+ if (!empty( $link->last_error ) && $n > 0) {
73
+ $this->setError($link->last_error);
74
+ }
75
+ $return.= 'DROP TABLE ' . $table.';';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
 
77
+ $ress = $link->query('SHOW CREATE TABLE ' . $table);
78
+ $result2 = $link->last_result;
79
+ if (!empty( $link->last_error ) && $n > 0) {
80
+ $this->setError($link->last_error);
81
+ }
82
+ $row2 = array_values( get_object_vars( $result2[0] ) );
83
+ $return.= "\n\n".$row2[1].";\n\n";
84
+ if ($num_fields > 0) {
85
+ for ($i = 0; $i < $num_fields; $i++)
86
+ {
87
+ $row = array_values( get_object_vars( $result[$i] ) );
88
+ //WPAdm_Core::log('row' . print_r($row, 1));
89
+ $rows_num = count($row);
90
+ if ($rows_num > 0) {
91
+ $return.= 'INSERT INTO '.$table.' VALUES(';
92
+ for($j=0; $j < $rows_num; $j++)
93
+ {
94
+ $row[$j] = addslashes($row[$j]);
95
+ $row[$j] = str_replace("\n","\\n",$row[$j]);
96
+ if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
97
+ if ($j<($rows_num-1)) { $return.= ','; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  }
99
+ $return.= ");\n";
100
  }
101
+
 
 
 
 
 
 
102
  }
103
  }
104
+ $return.="\n\n\n";
 
 
105
  }
106
+ unset($link);
107
+ $handle = fopen($filename,'w+');
108
+ fwrite($handle,$return);
109
+ fclose($handle);
110
+ WPAdm_Core::log( langWPADM::get('MySQL of Dump was finished' , false) );
111
+ return true;
112
  }
113
 
114
  private function setError($txt)
119
  public function restore($db, $file)
120
  {
121
  $link = $this->connect($db);
122
+ WPAdm_Core::log( langWPADM::get('Restore Database was started' , false) );
123
  $fo = fopen($file, "r");
124
  if (!$fo) {
125
+ WPAdm_Core::log( langWPADM::get('Error in open file dump' , false) );
126
+ $this->setError( langWPADM::get('Error in open file dump' , false) );
127
  return false;
128
  }
129
  $sql = "";
137
  $ress = $link->query($sql);
138
  if (!empty( $link->last_error ) && $n > 0) {
139
  $this->setError($link->last_error);
140
+ WPAdm_Core::log(langWPADM::get('MySQL Error: ' , false) . $link->last_error);
141
  break;
142
  };
143
  $sql = "";
144
  }
145
  }
146
  }
147
+ WPAdm_Core::log(langWPADM::get('Restore Database was finished' , false));
148
  }
149
  }
150
  }
modules/class-wpadm-process.php DELETED
@@ -1,100 +0,0 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
- /**
6
- * Class WPAdm_Сommand
7
- */
8
- if (!class_exists('WPAdm_Process')) {
9
-
10
- class WPAdm_Process {
11
-
12
- public static $processes = array('repair', 'optimization', 'mysqldump', 'archiving', 'dropbox');
13
-
14
- private static $file_name = 'processes.data';
15
-
16
- private static $file = '';
17
-
18
- private static $data = array();
19
-
20
- public static function includeCore()
21
- {
22
- if (!class_exists('WPAdm_Core')) {
23
- include_once 'class-wpadm-core.php';
24
- WPAdm_Core::$pl_dir = DRBBACKUP_BASE_DIR;
25
- }
26
- self::$file = WPAdm_Core::getTmpDir() . '/' . self::$file_name;
27
- }
28
-
29
- public static function init($process, $all)
30
- {
31
- self::includeCore();
32
-
33
- if (file_exists(self::$file)) {
34
- self::$data = wpadm_unpack( file_get_contents( self::$file ) );
35
- }
36
- self::$data[$process]['all'] = $all;
37
- file_put_contents(self::$file, wpadm_pack( self::$data ) );
38
- }
39
-
40
-
41
-
42
- public static function clear()
43
- {
44
- self::includeCore();
45
- if ( file_exists( self::$file ) ) {
46
- unlink(self::$file);
47
- }
48
- }
49
-
50
- public static function set($process, $count = 0)
51
- {
52
- self::includeCore();
53
- if (file_exists(self::$file)) {
54
- self::$data = wpadm_unpack( file_get_contents( self::$file ) );
55
- }
56
- self::$data[$process]['count'] = $count;
57
- file_put_contents(self::$file, wpadm_pack( self::$data ) );
58
- }
59
-
60
- public static function setInc($process, $count = 0)
61
- {
62
- self::includeCore();
63
- if (file_exists(self::$file)) {
64
- self::$data = wpadm_unpack( file_get_contents( self::$file ) );
65
- }
66
- if (isset(self::$data[$process]['count'])) {
67
- self::set($process, self::$data[$process]['count'] + $count);
68
- } else {
69
- self::set($process, $count);
70
- }
71
- }
72
-
73
- public static function get($process)
74
- {
75
- self::includeCore();
76
- if (file_exists(self::$file)) {
77
- self::$data = wpadm_unpack( file_get_contents( self::$file ) );
78
- }
79
- $count = $procent = $all = 0;
80
- if ( isset( self::$data[$process]['all'] ) && self::$data[$process]['all'] > 0 ) {
81
- $all = self::$data[$process]['all'];
82
- $count = isset(self::$data[$process]['count']) ? self::$data[$process]['count'] : 0;
83
- $procent = round( ( ( $count / self::$data[$process]['all'] ) * 100 ) ) ;
84
- }
85
- return array('all' => $all, 'count' => $count, 'procent' => $procent);
86
- }
87
-
88
- public static function getAll()
89
- {
90
- $result = array();
91
- $n = count(self::$processes);
92
- for($i = 0; $i < $n; $i++) {
93
- $result[self::$processes[$i]] = self::get( self::$processes[$i] );
94
- }
95
- return $result;
96
- }
97
-
98
- }
99
-
100
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/class-wpadm-queue.php CHANGED
@@ -1,7 +1,4 @@
1
  <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
  /**
6
  *
7
  * Class WPAdm_Queue
@@ -37,14 +34,11 @@ if (!class_exists('WPAdm_Queue')) {
37
 
38
  private $error;
39
 
40
- private $user_agent = 'dropbox-backup user-agent';
41
-
42
  public function __construct($id) {
43
  $this->id = $id;
44
  }
45
 
46
  public function add(WPAdm_Command_Context $context) {
47
-
48
  $this->contexts[] = $context;
49
  return $this;
50
  }
@@ -70,6 +64,7 @@ if (!class_exists('WPAdm_Queue')) {
70
  $host = $pu['host'];
71
  $path = isset($pu['path']) ? $pu['path'] . "/" : "/" ;
72
 
 
73
  $data = array(
74
  'method' => 'queue_controller',
75
  'params' => array(
@@ -79,11 +74,39 @@ if (!class_exists('WPAdm_Queue')) {
79
 
80
  );
81
 
82
-
83
- $dp = explode(DIRECTORY_SEPARATOR, DRBBACKUP_BASE_DIR);
84
- $pl = array_pop($dp);
85
- $wpadm = new WPAdm_Core($data, $pl, DRBBACKUP_BASE_DIR);
86
- return $wpadm->getResult()->toArray();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  }
88
 
89
  private function wait_result() {
@@ -95,33 +118,21 @@ if (!class_exists('WPAdm_Queue')) {
95
  }
96
  if (!file_exists($done_file)) {
97
  $this->error = 'No result of the command';
 
98
  } else {
99
  $queue = unserialize(file_get_contents($done_file));
100
  if (isset($queue['contexts'][0])) {
101
  $this->error = $queue['contexts'][0]->getError();
 
102
  }
103
  }
104
  if (file_exists($done_file)) {
105
  unlink($done_file);
106
  }
107
- if (!empty($this->error) ) {
108
- return false;
109
- }
110
  return true;
111
  }
112
- private function deleteCommands()
113
- {
114
- $files = glob(WPAdm_Core::getTmpDir() . "/wpadm_method_*");
115
- if (!empty($files)) {
116
- for($i = 0; $i < $n; $i++) {
117
- WPAdm_Core::rmdir($files[$i]);
118
- }
119
- }
120
- }
121
 
122
  public function save() {
123
-
124
- $this->deleteCommands();
125
  $file = WPAdm_Core::getTmpDir() . '/' . $this->id. '.queue';
126
  $txt = serialize(
127
  array(
1
  <?php
 
 
 
2
  /**
3
  *
4
  * Class WPAdm_Queue
34
 
35
  private $error;
36
 
 
 
37
  public function __construct($id) {
38
  $this->id = $id;
39
  }
40
 
41
  public function add(WPAdm_Command_Context $context) {
 
42
  $this->contexts[] = $context;
43
  return $this;
44
  }
64
  $host = $pu['host'];
65
  $path = isset($pu['path']) ? $pu['path'] . "/" : "/" ;
66
 
67
+ //WPAdm_Core::log('execute on host ' . $host);
68
  $data = array(
69
  'method' => 'queue_controller',
70
  'params' => array(
74
 
75
  );
76
 
77
+ if (function_exists('fsockopen')) {
78
+ $socket = @fsockopen($host, 80, $errno, $errstr, 30);
79
+ $dp = explode(DIRECTORY_SEPARATOR, WPAdm_Core::$pl_dir );
80
+ $pl = array_pop($dp) . '_';
81
+ $data = $pl . 'request='.base64_encode(serialize($data));
82
+ if (!$socket) {
83
+ //WPAdm_Core::log( "$errstr ($errno) " , "socket");
84
+ $curl = curl_init($url . "/");
85
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
86
+ curl_setopt($curl, CURLOPT_POST, true);
87
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
88
+ curl_setopt($curl, CURLOPT_TIMEOUT, 10);
89
+ $res = curl_exec($curl);
90
+ curl_close($curl);
91
+ return $this->wait_result();
92
+ }
93
+
94
+ fwrite($socket, "POST {$path} HTTP/1.1\r\n");
95
+ fwrite($socket, "Host: {$host}\r\n");
96
+
97
+ fwrite($socket,"Content-type: application/x-www-form-urlencoded\r\n");
98
+ fwrite($socket,"Content-length:".strlen($data)."\r\n");
99
+ fwrite($socket,"Accept:*/*\r\n");
100
+ fwrite($socket,"User-agent:Opera 10.00\r\n");
101
+ fwrite($socket,"Connection:Close\r\n");
102
+ fwrite($socket,"\r\n");
103
+ fwrite($socket,"$data\r\n");
104
+ fwrite($socket,"\r\n");
105
+
106
+ @sleep(1);
107
+ fclose($socket);
108
+ }
109
+ return $this->wait_result();
110
  }
111
 
112
  private function wait_result() {
118
  }
119
  if (!file_exists($done_file)) {
120
  $this->error = 'No result of the command';
121
+ return false;
122
  } else {
123
  $queue = unserialize(file_get_contents($done_file));
124
  if (isset($queue['contexts'][0])) {
125
  $this->error = $queue['contexts'][0]->getError();
126
+ return false;
127
  }
128
  }
129
  if (file_exists($done_file)) {
130
  unlink($done_file);
131
  }
 
 
 
132
  return true;
133
  }
 
 
 
 
 
 
 
 
 
134
 
135
  public function save() {
 
 
136
  $file = WPAdm_Core::getTmpDir() . '/' . $this->id. '.queue';
137
  $txt = serialize(
138
  array(
modules/class-wpadm-result.php CHANGED
@@ -1,130 +1,117 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
- if (!class_exists('WPAdm_Result')) {
6
- class WPAdm_Result {
7
- /*
8
- * Status of the request.
9
- * Can be either a "success" - the request is successful,
10
- * or "error" - in an error was encountered
11
- * @var string
12
- */
13
- private $result;
14
-
15
- /*
16
- * Text of the error that occurred during query execution
17
- * @var string
18
- */
19
- private $error = '';
20
-
21
- /*
22
- * Data obtained during query execution
23
- * @var mixed
24
- */
25
- private $data;
26
-
27
- /*
28
- * Total size of backup
29
- */
30
- private $size;
31
-
32
- const WPADM_RESULT_SUCCESS = 'success';
33
- const WPADM_RESULT_ERROR = 'error';
34
-
35
- public function __construct() {
36
- $this->result = WPAdm_Result::WPADM_RESULT_ERROR;
37
- }
38
-
39
- /**
40
- * @param mixed $data
41
- */
42
- public function setData($data)
43
- {
44
- $this->data = $data;
45
- }
46
-
47
- public function setValue($val, $data)
48
- {
49
- $this->$val = $data;
50
- }
51
-
52
- /**
53
- * @return mixed
54
- */
55
- public function getData()
56
- {
57
- return $this->data;
58
- }
59
-
60
- /**
61
- * @param string $error
62
- */
63
- public function setError($error)
64
- {
65
- WPAdm_Core::log($error);
66
- $this->error = $error;
67
- }
68
-
69
- /**
70
- * @return string
71
- */
72
- public function getError()
73
- {
74
- return $this->error;
75
- }
76
-
77
- /**
78
- * @param int $size
79
- */
80
- public function setSize($size)
81
- {
82
- $this->size = $size;
83
- }
84
-
85
- /**
86
- * @return int
87
- */
88
- public function getSize()
89
- {
90
- return $this->size;
91
- }
92
-
93
- /**
94
- * @param string $result
95
- */
96
- public function setResult($result)
97
- {
98
- $this->result = $result;
99
- }
100
-
101
- /**
102
- * @return string
103
- */
104
- public function getResult()
105
- {
106
- return $this->result;
107
- }
108
-
109
- public function exchangeArray(array $a) {
110
- $this->result = (isset($a['result'])) ? $a['result'] : '';
111
- $this->data = (isset($a['data'])) ? $a['data'] : '';
112
- $this->error = (isset($a['error'])) ? $a['error'] : '';
113
- $this->size = (isset($a['size'])) ? $a['size'] : '';
114
- }
115
-
116
- public function toArray($all = false) {
117
-
118
- if ($all) {
119
- return get_object_vars( $this );
120
- } else {
121
- return array(
122
- 'result' => $this->getResult(),
123
- 'error' => $this->getError(),
124
- 'data' => $this->getData(),
125
- 'size' => $this->getSize()
126
- );
127
- }
128
- }
129
- }
130
  }
1
+ <?php
2
+ if (!class_exists('WPAdm_Result')) {
3
+ class WPAdm_Result {
4
+ /*
5
+ * Status of the request.
6
+ * Can be either a "success" - the request is successful,
7
+ * or "error" - in an error was encountered
8
+ * @var string
9
+ */
10
+ private $result;
11
+
12
+ /*
13
+ * Text of the error that occurred during query execution
14
+ * @var string
15
+ */
16
+ private $error = '';
17
+
18
+ /*
19
+ * Data obtained during query execution
20
+ * @var mixed
21
+ */
22
+ private $data;
23
+
24
+ /*
25
+ * Total size of backup
26
+ */
27
+ private $size;
28
+
29
+ const WPADM_RESULT_SUCCESS = 'success';
30
+ const WPADM_RESULT_ERROR = 'error';
31
+
32
+ public function __construct() {
33
+ $this->result = WPAdm_Result::WPADM_RESULT_ERROR;
34
+ }
35
+
36
+ /**
37
+ * @param mixed $data
38
+ */
39
+ public function setData($data)
40
+ {
41
+ $this->data = $data;
42
+ }
43
+
44
+ /**
45
+ * @return mixed
46
+ */
47
+ public function getData()
48
+ {
49
+ return $this->data;
50
+ }
51
+
52
+ /**
53
+ * @param string $error
54
+ */
55
+ public function setError($error)
56
+ {
57
+ WPAdm_Core::log($error);
58
+ $this->error = $error;
59
+ }
60
+
61
+ /**
62
+ * @return string
63
+ */
64
+ public function getError()
65
+ {
66
+ return $this->error;
67
+ }
68
+
69
+ /**
70
+ * @param int $size
71
+ */
72
+ public function setSize($size)
73
+ {
74
+ $this->size = $size;
75
+ }
76
+
77
+ /**
78
+ * @return int
79
+ */
80
+ public function getSize()
81
+ {
82
+ return $this->size;
83
+ }
84
+
85
+ /**
86
+ * @param string $result
87
+ */
88
+ public function setResult($result)
89
+ {
90
+ $this->result = $result;
91
+ }
92
+
93
+ /**
94
+ * @return string
95
+ */
96
+ public function getResult()
97
+ {
98
+ return $this->result;
99
+ }
100
+
101
+ public function exchangeArray(array $a) {
102
+ $this->result = (isset($a['result'])) ? $a['result'] : '';
103
+ $this->data = (isset($a['data'])) ? $a['data'] : '';
104
+ $this->error = (isset($a['error'])) ? $a['error'] : '';
105
+ $this->size = (isset($a['size'])) ? $a['size'] : '';
106
+ }
107
+
108
+ public function toArray() {
109
+ return array(
110
+ 'result' => $this->getResult(),
111
+ 'error' => $this->getError(),
112
+ 'data' => $this->getData(),
113
+ 'size' => $this->getSize()
114
+ );
115
+ }
116
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  }
modules/class-wpadm-running.php DELETED
@@ -1,322 +0,0 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
3
-
4
- /**
5
- * Class WPAdm_Running
6
- */
7
- if (!class_exists('WPAdm_Running')) {
8
-
9
- add_action('drb_run_backup', array('wpadm_running', 'init') );
10
-
11
- class WPAdm_Running {
12
-
13
- private static $command_result_data = array();
14
- private static $command_result = '';
15
- private static $command_result_id = false;
16
-
17
- static function init_params_default($method = true)
18
- {
19
- update_option(PREFIX_BACKUP_ . "_commands", array());
20
- update_option(PREFIX_BACKUP_ . "proccess-command", array());
21
- set_transient('drb_running', 0, 60 * 5);
22
- $path = WPAdm_Core::getTmpDir();
23
- if (!empty($path)) {
24
- WPAdm_Core::rmdir($path . "/db");
25
- WPAdm_Core::rmdir($path . "/files");
26
- WPAdm_Core::rmdir($path . "/files2");
27
- WPAdm_Core::rmdir($path . "/archive");
28
- WPAdm_Core::rmdir($path . "/command_dropbox");
29
- WPAdm_Core::rmdir($path . "/errors_sending");
30
- WPAdm_Core::rmdir($path . "/tabledb");
31
- WPAdm_Core::rmdir($path . "/repair");
32
- WPAdm_Core::rmdir($path . "/restore-backup");
33
- WPAdm_Core::rmdir($path . "/log-restore.log");
34
- WPAdm_Core::rmdir($path . "/log-restore2");
35
- WPAdm_Core::rmdir($path . "/md5_info-restore");
36
- WPAdm_Core::rmdir($path . "/restore-backup");
37
- WPAdm_Core::rmdir($path . "/files-list-retore");
38
- WPAdm_Core::rmdir($path . "/extract-files-restore");
39
- WPAdm_Core::rmdir($path . "/cron-restore.data");
40
- WPAdm_Core::rmdir($path . "/stop_process");
41
- WPAdm_Core::rmdir($path . "/folder_create");
42
- WPAdm_Core::rmdir($path . "/drb_running");
43
- WPAdm_Core::rmdir($path . "/drb_running_time");
44
- WPAdm_Core::rmdir($path . "/count_error_zip_signature");
45
- WPAdm_Core::rmdir($path . "/tmp_arhive_file");
46
- WPAdm_Core::rmdir($path . "/tmp_arhive_file2");
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
- WPAdm_Core::rmdir($path . "/circle");
56
-
57
- if ($method) {
58
- $files = glob($path ."/wpadm_method*.queue");
59
- if (!empty($files)) {
60
- $n = count($files);
61
- for($i = 0; $i < $n; $i++) {
62
- WPAdm_Core::rmdir($files[$i]);
63
- }
64
- }
65
- $files = glob($path ."/pclzip*.tmp");
66
- if (!empty($files)) {
67
- $n = count($files);
68
- for($i = 0; $i < $n; $i++) {
69
- WPAdm_Core::rmdir($files[$i]);
70
- }
71
- }
72
- $files = glob($path ."/wpadm_method*.done");
73
- if (!empty($files)) {
74
- $n = count($files);
75
- for($i = 0; $i < $n; $i++) {
76
- WPAdm_Core::rmdir($files[$i]);
77
- }
78
- }
79
- }
80
- }
81
- }
82
-
83
- static function toEndWork($time = 0)
84
- {
85
- $time_start_process = self::getCommandResultData('start-process');
86
-
87
- if ($time == 0) {
88
- $time = self::getCommandResultData('time_work');
89
- }
90
- $time_work = ini_get('max_execution_time');
91
-
92
- $time_stop = 25;
93
-
94
- if ($time_work <= 30) {
95
- $time_stop = round($time_work / 2.5);
96
- }
97
-
98
- $time_is = ( $time_start_process + $time_work ) - $time;
99
- if ( !empty($time_start_process) && !empty($time) && $time_is <= $time_stop ) { //second
100
- //sleep($time_is + 2);
101
- return false;
102
- }
103
- return true;
104
- }
105
-
106
- static function init()
107
- {
108
- $command = self::getCommand();
109
-
110
- if ($command ) {
111
- WPAdm_Core::$cron = false;
112
- wpadm_class::$type = 'full';
113
-
114
- if (function_exists('set_time_limit')) {
115
- //@set_time_limit(0);
116
- }
117
-
118
- self::run(35);
119
-
120
- if ( self::checkLock() ) {
121
- if ( self::is_stop() ) {
122
- $core = new WPAdm_Core($command, 'full_backup_dropbox', DRBBACKUP_BASE_DIR);
123
- if (!is_bool( $core->getResult() ) && is_object( $core->getResult() ) && ( $result = $core->getResult()->toArray(true) ) ) {
124
- if ($result['result'] == 'success') {
125
- self::delCommand($command['method']);
126
- set_transient('drb_running', 0, 60 * 4);
127
- self::stop();
128
- self::setCommandResultData($command['method'], $result);
129
- self::init();
130
- } elseif ($result['result'] == 'error') {
131
- self::setCommandResultData($command['method'], $result);
132
- self::stop();
133
- self::init_params_default();
134
- self::createDebug( $result, $command['method'] );
135
- }
136
- }
137
- }
138
- }
139
- }
140
- }
141
-
142
- public static function createDebug( $result, $type_backup = '' )
143
- {
144
- if (isset($result['error']) && !empty( $result['error'] ) ) {
145
- wpadm_class::error_log_check( print_r( $result, 1 ), $type_backup );
146
- }
147
- }
148
-
149
- public static function checkLock()
150
- {
151
- // false - cron is running
152
- // true - cron not running
153
- $running_cron = get_transient('drb_running');
154
- $time_work = self::getCommandResultData('time_work');
155
- if ( !empty($time_work) && ( $time_work + 20 ) > time() ) {
156
- return false;
157
- }
158
- if ($running_cron && $running_cron == 1) {
159
- $time = microtime( true );
160
- $locked = get_transient('doing_cron');
161
-
162
- if ( $locked > $time + 10 * 60 ) { // 10 minutes
163
- $locked = 0;
164
- }
165
- if ((defined('WP_CRON_LOCK_TIMEOUT') && $locked + WP_CRON_LOCK_TIMEOUT > $time) || (!defined('WP_CRON_LOCK_TIMEOUT') && $locked + 60 > $time)) {
166
- return false;
167
- }
168
- if (function_exists('_get_cron_array')) {
169
- $crons = _get_cron_array();
170
- } else {
171
- $crons = get_option('cron');
172
- }
173
- if (!is_array($crons)) {
174
- return false;
175
- }
176
-
177
- $values = array_values( $crons );
178
- if (isset($values['drb_run_backup'])) {
179
- $keys = array_keys( $crons );
180
- if ( isset($keys[0]) && $keys[0] > $time ) {
181
- return false;
182
- }
183
- }
184
- }
185
- $time = ini_get('max_execution_time');
186
- if ($time == 0) {
187
- set_transient('drb_running', 1, 60 * 60 * 24); // 24 hour
188
- } else {
189
- set_transient('drb_running', 1, $time + 30);
190
- }
191
-
192
- self::setCommandResultData('start-process', time() );
193
- return true;
194
- }
195
-
196
- static function is_running()
197
- {
198
- $running = get_transient('drb_running');
199
- if ($running && $running == 1) {
200
- return true;
201
- }
202
- return false;
203
- }
204
-
205
- static function is_stop()
206
- {
207
- $stop_precess = self::getCommandResultData('stop_process');
208
- if ( !empty( $stop_precess ) && isset( $stop_precess['name'] ) && isset( $stop_precess['type'] ) ) {
209
- wpadm_wp_full_backup_dropbox::delete_backup('local', $stop_precess['name']);
210
- if ($stop_precess['type'] == 'dropbox') {
211
- wpadm_wp_full_backup_dropbox::delete_backup('dropbox', $stop_precess['name']);
212
- }
213
-
214
- }
215
- self::setCommandResultData('time_work', time());
216
- return empty($stop_precess);
217
- }
218
-
219
- static function getCommand($command = '')
220
- {
221
- $commands = get_option(PREFIX_BACKUP_ . "_commands");
222
- if ($commands !== false && is_array($commands) && isset($commands[0]) && empty($command) ) {
223
- return $commands[0];
224
- } elseif (!empty($command) && $commands !== false && is_array($commands)) {
225
- $id = wpadm_in_array($command, 'method', $commands, true );
226
- if (isset($commands[$id])) {
227
- return $commands[$id];
228
- }
229
- }
230
- return false;
231
- }
232
- static function setCommand($method, $params = array() )
233
- {
234
- $commands = get_option(PREFIX_BACKUP_ . "_commands");
235
- if ( ( $commands === false ) || !wpadm_in_array($method, 'method', $commands ) ) {
236
- $commands[] = array('method' => $method, 'params' => $params, 'work' => 0 );
237
- update_option(PREFIX_BACKUP_ . "_commands", $commands);
238
- }
239
- }
240
- static function delCommand($method)
241
- {
242
- $commands = get_option(PREFIX_BACKUP_ . "_commands");
243
- if ($commands !== false && is_array($commands)) {
244
- $id = wpadm_in_array($method, 'method', $commands, true);
245
- unset($commands[$id]);
246
- if (!empty($commands)) {
247
- $commands = array_values($commands);
248
- } else {
249
- $commands = array();
250
- }
251
- update_option(PREFIX_BACKUP_ . "_commands", $commands);
252
- }
253
- }
254
-
255
- static function run($time = false)
256
- {
257
- if ($time) {
258
- $time = $time + time();
259
- } else {
260
- $time = time();
261
- }
262
- wp_schedule_single_event($time, 'drb_run_backup', array() );
263
- }
264
-
265
- static function stop()
266
- {
267
- wp_clear_scheduled_hook( 'drb_run_backup', array() );
268
- }
269
-
270
- static function setCommandResult($command, $work = false )
271
- {
272
- $options = get_option( PREFIX_BACKUP_ . "proccess-command" );
273
- $id = wpadm_in_array($command, 'command', $options, true );
274
- if ($options === false || $id === false ) {
275
- $options[] = array('command' => $command, 'work' => 0);
276
- self::$command_result_id = wpadm_in_array($command, 'command', $options, true );
277
- self::$command_result_data = array();
278
- update_option(PREFIX_BACKUP_ . "proccess-command", $options);
279
- } else {
280
- if ($work) {
281
- $options[$id]['work'] = 1;
282
- update_option(PREFIX_BACKUP_ . "proccess-command", $options);
283
- }
284
- }
285
- }
286
-
287
- static function setCommandResultData($command, $data = array())
288
- {
289
- $path = WPAdm_Core::getTmpDir();
290
- file_put_contents($path ."/$command", wpadm_pack( $data ) );
291
- }
292
- static function delCommandResultData($command)
293
- {
294
- $path = WPAdm_Core::getTmpDir();
295
- if (!empty($path)) {
296
- WPAdm_Core::rmdir($path . "/$command");
297
- }
298
- }
299
-
300
- static function getCommandResult($command)
301
- {
302
- $options = get_option( PREFIX_BACKUP_ . "proccess-command" );
303
- if ($options !== false) {
304
- $id = wpadm_in_array($command, 'command', $options, true );
305
- if ($id !== false && $options[$id]['work'] == 1) {
306
- return true;
307
- }
308
- }
309
- return false;
310
- }
311
- static function getCommandResultData($command)
312
- {
313
- $path = WPAdm_Core::getTmpDir();
314
- if (file_exists($path . "/$command")) {
315
- $data = wpadm_unpack( file_get_contents( $path . "/$command" ) );
316
- return $data;
317
- }
318
-
319
- return array();
320
- }
321
- }
322
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/constant.php DELETED
@@ -1,65 +0,0 @@
1
- <?php
2
- if( !defined('WPADM_DIR_NAME') ) {
3
- define('WPADM_DIR_NAME', 'wpadm_backups');
4
- }
5
-
6
- if( !defined('DROPBOX_BACKUP_DIR_NAME') ) {
7
- define('DROPBOX_BACKUP_DIR_NAME', 'Dropbox_Backup');
8
- }
9
-
10
- if( !defined('DROPBOX_BACKUP_DIR_BACKUP') ) {
11
- define('DROPBOX_BACKUP_DIR_BACKUP', WP_CONTENT_DIR . '/' . DROPBOX_BACKUP_DIR_NAME);
12
- }
13
-
14
- if (!defined('WPADM_DIR_BACKUP')) {
15
- define('WPADM_DIR_BACKUP', WP_CONTENT_DIR . '/' . WPADM_DIR_NAME );
16
- }
17
-
18
- if (! defined("WPADM_URL_BASE")) {
19
- define("WPADM_URL_BASE", 'http://secure.webpage-backup.com/');
20
- }
21
- if (! defined("WPADM_URL_PRO_VERSION")) {
22
- define("WPADM_URL_PRO_VERSION", 'https://secure.wpadm.com/');
23
- }
24
-
25
- if (! defined("WPADM_APP_KEY")) {
26
- define("WPADM_APP_KEY", 'nv751n84w2nif6j');
27
- }
28
-
29
- if (! defined("WPADM_APP_SECRET")) {
30
- define("WPADM_APP_SECRET", 'qllasd4tbnqh4oi');
31
- }
32
-
33
- if (!defined("SERVER_URL_INDEX")) {
34
- define("SERVER_URL_INDEX", "http://www.webpage-backup.com/");
35
- }
36
- if (!defined("PHP_VERSION_DEFAULT")) {
37
- define("PHP_VERSION_DEFAULT", '5.2.4' );
38
- }
39
- if (!defined("MYSQL_VERSION_DEFAULT")) {
40
- define("MYSQL_VERSION_DEFAULT", '5.0' );
41
- }
42
-
43
- if (!defined("PREFIX_BACKUP_")) {
44
- define("PREFIX_BACKUP_", "wpadm_backup_");
45
- }
46
- if (!defined("WPADM_1DAY")) {
47
- define("WPADM_1DAY", 86400); // 86400 sec = 1 day = 24 hours
48
- }
49
- if (!defined("WPADM_1WEEK")) {
50
- define("WPADM_1WEEK", WPADM_1DAY * 7);
51
- }
52
- if (!defined("WPADM_COUNT_LIMIT_SEND_TO_DROPBOX")) {
53
- define("WPADM_COUNT_LIMIT_SEND_TO_DROPBOX", 5);
54
- }
55
-
56
- if (!defined("SITE_HOME") && function_exists( 'home_url' ) ) {
57
- define("SITE_HOME", str_ireplace( array( 'http://', 'https://' ), '', home_url() ) );
58
- } else {
59
- if (class_exists('dbr_database')) {
60
- $data = dbr_database::db_get('options', array('option_value'), array('option_name' => 'home'), 1);
61
- if (isset($data['option_value'])) {
62
- define("SITE_HOME", str_ireplace( array( 'http://', 'https://' ), '', $data['option_value'] ) );
63
- }
64
- }
65
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/dropbox.class.php CHANGED
@@ -13,15 +13,15 @@ class dropbox
13
  private $chunk_size_mb = 50;
14
  private $request_token;
15
 
16
- private $api_url = "https://api.dropbox.com/1/"; // api.dropboxapi.com api.dropbox.com
17
  private $api_url_content = "https://api-content.dropbox.com/1/";
18
 
19
 
20
  /**
21
- * @param $app_key
22
- * @param $app_secret
23
- * @param string $token - постоянный токен
24
- */
25
  public function __construct ($app_key, $app_secret, $token = "")
26
  {
27
  $this->app_key = $app_key;
@@ -30,20 +30,20 @@ class dropbox
30
  }
31
 
32
  /**
33
- * Проверка на то, был ли получен постоянный токен
34
- *
35
- * @return bool
36
- */
37
  public function isAuth()
38
  {
39
  return !empty($this->token);
40
  }
41
 
42
  /**
43
- * Получение временного токена, необходимого для авторизации и получения токена постоянного
44
- *
45
- * @return mixed
46
- */
47
  public function getRequestToken()
48
  {
49
  if (!$this->request_token) {
@@ -56,11 +56,11 @@ class dropbox
56
  }
57
 
58
  /**
59
- * Авторизация, шаг1: Генерация ссылки для авторизации приложения
60
- *
61
- * @param $callback - URL для возвращения токена после авторизации
62
- * @return string
63
- */
64
  public function generateAuthUrl($callback)
65
  {
66
  $request_token = $this->getRequestToken();
@@ -70,11 +70,11 @@ class dropbox
70
 
71
 
72
  /**
73
- * Получение токена, необходимого для запросов к API
74
- *
75
- * @param $request_token - временный токен, полученный функцией getRequestToken
76
- * @return string токен
77
- */
78
  public function getAccessToken($request_token)
79
  {
80
  if (!empty($this->token)) {
@@ -89,25 +89,25 @@ class dropbox
89
  }
90
 
91
  /**
92
- * Удаление файла
93
- *
94
- * @param $file
95
- * @return mixed
96
- */
97
  public function deleteFile($file)
98
  {
99
  return $this->doApi("fileops/delete", "POST", array(
100
- "path" => $file,
101
- "root" => "auto"
102
  ));
103
  }
104
 
105
  /**
106
- * Удаление нескольких файлов
107
- *
108
- * @param array $files
109
- * @return array
110
- */
111
  public function deleteFiles($files = array())
112
  {
113
  $result = array();
@@ -115,8 +115,8 @@ class dropbox
115
  foreach ($files as $file) {
116
  $do = $this->deleteFile($file);
117
  $result[] = array (
118
- "name" => $file,
119
- "result" => $do['error'] ? 0 : 1
120
  );
121
  }
122
 
@@ -124,42 +124,42 @@ class dropbox
124
  }
125
 
126
  /**
127
- * Перемещение файлов
128
- *
129
- * @param $from - откуда
130
- * @param $to - куда
131
- * @return mixed
132
- */
133
  public function moveFile ($from, $to)
134
  {
135
  return $this->doApi("fileops/move", "POST", array(
136
- "root" => "auto",
137
- "from_path" => $from,
138
- "to_path" => $to
139
  ));
140
  }
141
 
142
  public function listing($path)
143
  {
144
  $dir = $this->doApi("metadata/auto/".ltrim($path, "/"), "GET", array(
145
- "list" => TRUE
146
  ));
147
 
148
  if ($dir['error']) {
149
  return $dir;
150
  }
151
- //this not folder
152
  elseif (!$dir['is_dir']) {
153
  return array (
154
- "size" => $dir['size'],
155
- "bytes" => $dir['bytes'],
156
- "date" => $dir['modified'],
157
- "name" => $dir['path']
158
  );
159
  }
160
 
161
  $all_size = 0;
162
  $items = array();
 
163
  foreach ($dir['contents'] as $item) {
164
  if (!$item['is_dir']) {
165
  switch (substr($item['size'], -2)) {
@@ -183,18 +183,18 @@ class dropbox
183
  }
184
 
185
  $items[] = array (
186
- "type" => $item['is_dir'] ? "dir" : "file",
187
- "date" => $item['modified'],
188
- "name" => basename($item['path']),
189
- "size" => $item['size']
190
  );
191
  }
192
 
193
  $dir_result = array (
194
- "size" => $this->bite2other($all_size),
195
- "date" => $dir['modified'],
196
- "name" => $dir['path'],
197
- "items" => $items
198
  );
199
 
200
  return $dir_result;
@@ -210,23 +210,23 @@ class dropbox
210
  if ($size < $kb) {
211
  return $size.' B';
212
  } else if ($size < $mb) {
213
- return round($size / $kb, 2).' KB';
214
- } else if ($size < $gb) {
215
- return round($size / $mb, 2).' MB';
216
- } else if ($size < $tb) {
217
- return round($size / $gb, 2).' GB';
218
- } else {
219
- return round($size / $tb, 2).' TB';
220
  }
221
  }
222
 
223
  /**
224
- * Скачивание файла
225
- *
226
- * @param $file
227
- * @param $server_path - путь, куда скачать на сервер. Если задан -- вернет путь к файлу в случае успешной загрузки.
228
- * @return array
229
- */
230
  public function downloadFile($file, $server_path = "")
231
  {
232
  $isset = $this->listing($file);
@@ -244,9 +244,8 @@ class dropbox
244
  header("Content-Transfer-Encoding: binary");
245
 
246
  $this->doApi("files/auto/".ltrim($file, "/"), "GET", array(), array(
247
- 'socket' => array('file_download' => $server_path),
248
- CURLOPT_BINARYTRANSFER => 1,
249
- CURLOPT_RETURNTRANSFER => 0,
250
  ), TRUE);
251
  exit;
252
  }
@@ -255,16 +254,15 @@ class dropbox
255
  //Файл недоступен для записи
256
  if (!$fd = fopen($server_path, "wb")) {
257
  return array (
258
- "error" => 1,
259
- "text" => "File '".$server_path."' not writable"
260
  );
261
  }
262
 
263
  $this->doApi("files/auto/".ltrim($file, "/"), "GET", array(), array(
264
- 'socket' => array('file_download' => $server_path),
265
- CURLOPT_BINARYTRANSFER => 1,
266
- CURLOPT_RETURNTRANSFER => 1,
267
- CURLOPT_FILE => $fd
268
  ), TRUE);
269
 
270
  fclose($fd);
@@ -279,12 +277,12 @@ class dropbox
279
  }
280
 
281
  /**
282
- * Поделиться файлом
283
- *
284
- * @param $file
285
- * @param bool $short_url - короткая ссылка
286
- * @return mixed
287
- */
288
  public function shareFile($file, $short_url = TRUE)
289
  {
290
  $result = $this->doApi("shares/auto/".ltrim($file, "/"), "POST", compact("short_url"));
@@ -292,12 +290,12 @@ class dropbox
292
  }
293
 
294
  /**
295
- * Загрузка нескольких файлов
296
- *
297
- * @param $files - массив формата файл_на_сервере => файл_в_дропбоксе
298
- *
299
- * @return array - информация о списке файлов
300
- */
301
  public function uploadFiles($files = array())
302
  {
303
  $result = array();
@@ -305,8 +303,8 @@ class dropbox
305
  foreach ($files as $file => $dbx) {
306
  $do = $this->uploadFile($file, $dbx);
307
  $result[] = array (
308
- "name" => $file,
309
- "result" => $do['error'] ? 0 : 1
310
  );
311
  }
312
 
@@ -314,13 +312,13 @@ class dropbox
314
  }
315
 
316
  /**
317
- * Загрузка файла
318
- *
319
- * @param $file_path - путь к файлу на сервере
320
- * @param $dropbox_path - куда загружать, если не задан, будет загружен в корень дропбокса с таким же именем
321
- * @param bool $overwrite - заменять ли файлы со схожими именами
322
- * @return mixed
323
- */
324
  public function uploadFile($file_path, $dropbox_path = "", $overwrite = FALSE)
325
  {
326
  if (empty($dropbox_path)) {
@@ -329,8 +327,8 @@ class dropbox
329
 
330
  if (!is_file($file_path)) {
331
  return array(
332
- "error" => 1,
333
- "text" => "File '".$file_path."' not found."
334
  );
335
  }
336
 
@@ -340,16 +338,15 @@ class dropbox
340
  if ($fsize/1024/1024 < $this->max_filesize_mb)
341
  {
342
  $result = $this->doApi("files_put/auto/".ltrim($dropbox_path, "/"),
343
- "PUT",
344
- compact ("overwrite"),
345
- array(
346
- 'socket' => array('file' => $file_path),
347
- CURLOPT_INFILE => $file,
348
- CURLOPT_INFILESIZE => filesize($file_path),
349
- CURLOPT_BINARYTRANSFER => 1,
350
- CURLOPT_PUT => 1
351
- ),
352
- TRUE);
353
 
354
  }
355
  //Файл слишком велик
@@ -363,17 +360,15 @@ class dropbox
363
  $offset += $chunk;
364
 
365
  $result = $this->doApi("chunked_upload",
366
- "PUT",
367
- compact("upload_id", "offset"),
368
- array(
369
- 'socket' => array('file' => $file_path, 'dropbox_path' => $dropbox_path),
370
-
371
- CURLOPT_INFILE => $file,
372
- CURLOPT_INFILESIZE => $chunk,
373
- CURLOPT_BINARYTRANSFER => 1,
374
- CURLOPT_PUT => 1
375
- ),
376
- TRUE);
377
 
378
  fseek($file, $offset);
379
  if($offset >= $fsize) {
@@ -386,10 +381,10 @@ class dropbox
386
  }
387
 
388
  $result = $this->doApi("commit_chunked_upload/auto/".ltrim($dropbox_path, "/"),
389
- "POST",
390
- compact("upload_id", "overwrite"),
391
- array(),
392
- TRUE);
393
  }
394
 
395
  @fclose($file);
@@ -398,61 +393,73 @@ class dropbox
398
  }
399
 
400
  /**
401
- * Создание директории
402
- *
403
- * @param $path
404
- * @return mixed
405
- */
406
  public function createDir($path)
407
  {
408
  return $this->doApi("fileops/create_folder", "POST", array(
409
- "root" => "auto",
410
- "path" => $path
411
  ));
412
  }
413
 
414
  /**
415
- * Информация об аккаунте
416
- *
417
- * @return mixed
418
- */
419
  public function accInfo()
420
  {
421
  return $this->doApi("account/info", "GET");
422
  }
423
 
424
  /** Запрос к API
425
- *
426
- * @param $op - операция (url)
427
- * @param $method - post/get
428
- * @param array $data - доп. данные, url запрос
429
- * @param array $opts - доп. параметры для curl
430
- * @param $api_content - использовать url для загрузки файлов
431
- * @return mixed
432
- */
433
  private function doApi ($op, $method, $data = array(), $opts = array(), $api_content = FALSE)
434
  {
435
  if (($method == "GET" || $method == "PUT") && count($data)) {
436
  $op .= "?".http_build_query($data);
437
  }
438
-
439
  $result = $this->doCurl((!$api_content ? $this->api_url : $this->api_url_content).$op, $method, $data, $opts);
440
  $return = json_decode($result, TRUE);
441
  return self::checkError($return);
442
  }
443
 
444
  /**
445
- * Обертка для отправки подписанного запроса через curl
446
- *
447
- * @param $url
448
- * @param string $method
449
- * @param array $data - POST данные
450
- * @param $opts - доп. параметры для curl
451
- * @return mixed
452
- */
453
  public function doCurl($url, $method = "POST", $data = array(), $opts = array())
454
  {
455
- $result = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
456
  $oauth = new OAuthSimple($this->app_key, $this->app_secret);
457
 
458
  if (!$this->request_token && $this->token) {
@@ -476,141 +483,23 @@ class dropbox
476
  }
477
 
478
  $signed = $oauth->sign(array(
479
- 'action' => $method,
480
- 'path' => $path
481
- )
482
  );
 
483
 
484
- if (function_exists('curl_init')) {
485
- if (isset($opts['socket'])) {
486
- unset($opts['socket']);
487
- }
488
- $ch = curl_init($url);
489
- $opts += array(
490
- CURLOPT_RETURNTRANSFER => 1,
491
- CURLOPT_HEADER => 0,
492
- CURLOPT_SSL_VERIFYPEER => 0,
493
- CURLOPT_SSL_VERIFYHOST => 0,
494
- );
495
-
496
- if ($method == "POST") {
497
- $opts[CURLOPT_POST] = TRUE;
498
- $opts[CURLOPT_POSTFIELDS] = http_build_query($data);
499
- }
500
-
501
- //$oauth = new OAuthSimple($this->app_key, $this->app_secret);
502
-
503
- /*if (!$this->request_token && $this->token) {
504
- $this->request_token = $this->token;
505
- }
506
-
507
- if ($this->request_token) {
508
- $oauth->setParameters(array('oauth_token' => $this->request_token['oauth_token']));
509
- $oauth->signatures(array('oauth_secret'=> $this->request_token['oauth_token_secret']));
510
- }
511
-
512
- if ($method == "POST" && count($data)) {
513
- $oauth->setParameters(http_build_query($data));
514
- }
515
-
516
- $path = $url;
517
- $query = strrchr($url,'?');
518
- if(!empty($query)) {
519
- $oauth->setParameters(substr($query,1));
520
- $path = substr($url, 0, -strlen($query));
521
- }
522
 
523
- $signed = $oauth->sign(array(
524
- 'action' => $method,
525
- 'path' => $path
526
- )
527
- ); */
528
- $opts[CURLOPT_HTTPHEADER][] = "Authorization: ".$signed['header'];
529
 
530
- if ($method == "PUT") {
531
- $opts[CURLOPT_CUSTOMREQUEST] = "PUT";
532
- }
533
- curl_setopt_array($ch, $opts);
534
- $result = curl_exec($ch);
535
-
536
- } elseif (function_exists('fsockopen')) {
537
- include_once dirname(__FILE__) . '/HttpFsockopen.php';
538
- $socket = new HttpFsockopen($url, false);
539
- if ($method == 'POST') {
540
- $socket->setPostData($data);
541
- }
542
- if ($method == 'PUT') {
543
- if (isset($opts['socket']['file'])) {
544
- $data = '';
545
- srand( (double)microtime() * 1000000);
546
- $file_data = join('', file( $opts['socket']['file'] ) ) ;
547
- $rand = substr( md5( rand( 0, 32000 ) ), 0, 10);
548
- $boundary = $rand;
549
- $data = "";
550
- $data .= "Content-Disposition: form-data; name=\"" . basename($opts['socket']['file']) ."\"; filename=\"" . basename( $opts['socket']['file'] ) . "\"\r\n";
551
- $data .= "Content-Type: application/x-www-form-urlencoded;\r\n"; //multipart/form-data;
552
- $data .= "Content-length: " . strlen($file_data) . "\r\n";
553
- $data .= "Connection: close\r\n\r\n";
554
- $data .= $file_data ;
555
- $socket->setStrHeaders($data);
556
- $socket->setMethod("PUT");
557
- }
558
- }
559
- $socket->setHeaders('Authorization', $signed['header']);
560
- $res = $socket->exec();
561
- if ($method == 'GET') {
562
- if (isset($opts['socket']['file_download'])) {
563
- $r = $this->getResult($res);
564
- if (isset($r[1])) {
565
- file_put_contents($opts['socket']['file_download'], $r[1]);
566
- }
567
- }
568
- }
569
- if ( empty($result) ) {
570
- $res = $this->getResult($res);
571
- if (isset($res[1])) {
572
- $res1 = $this->getResult($res[1], "\r", true);
573
- preg_match("/{.*}/is", trim($res1), $r);
574
- if(isset($r[0])) {
575
- $result = $r[0];
576
- } else {
577
- $res1 = $this->getResult($res[1], "\n", true);
578
- preg_match("/{.*}/is", trim($res1), $r);
579
- if(isset($r[0])) {
580
- $result = $r[0];
581
- } else {
582
- $res1 = $this->getResult($res[1], "\r\n", true);
583
- preg_match("/{.*}/is", trim($res1), $r);
584
- if(isset($r[0])) {
585
- $result = $r[0];
586
- }
587
-
588
- }
589
- }
590
-
591
- }
592
- }
593
- }
594
  return $result;
595
  }
596
 
597
- private function getResult($str, $patern = "\r\n\r\n", $is_json = false)
598
- {
599
- if ($is_json === false) {
600
- return explode($patern, $str);
601
- } else {
602
- $res = explode($patern, $str);
603
- $n = count($res);
604
- $result = '';
605
- for($i = 0; $i < $n; $i++) {
606
- if ( preg_match_all("/[\{\"\:\,\}\s]+/is", trim($res[$i]), $r ) ) {
607
- $result .= str_replace(array("\r", "\n"), '', $res[$i]);
608
- }
609
- }
610
- return $result;
611
- }
612
- }
613
-
614
 
615
  private static function checkError($return)
616
  {
13
  private $chunk_size_mb = 50;
14
  private $request_token;
15
 
16
+ private $api_url = "https://api.dropbox.com/1/";
17
  private $api_url_content = "https://api-content.dropbox.com/1/";
18
 
19
 
20
  /**
21
+ * @param $app_key
22
+ * @param $app_secret
23
+ * @param string $token - постоянный токен
24
+ */
25
  public function __construct ($app_key, $app_secret, $token = "")
26
  {
27
  $this->app_key = $app_key;
30
  }
31
 
32
  /**
33
+ * Проверка на то, был ли получен постоянный токен
34
+ *
35
+ * @return bool
36
+ */
37
  public function isAuth()
38
  {
39
  return !empty($this->token);
40
  }
41
 
42
  /**
43
+ * Получение временного токена, необходимого для авторизации и получения токена постоянного
44
+ *
45
+ * @return mixed
46
+ */
47
  public function getRequestToken()
48
  {
49
  if (!$this->request_token) {
56
  }
57
 
58
  /**
59
+ * Авторизация, шаг1: Генерация ссылки для авторизации приложения
60
+ *
61
+ * @param $callback - URL для возвращения токена после авторизации
62
+ * @return string
63
+ */
64
  public function generateAuthUrl($callback)
65
  {
66
  $request_token = $this->getRequestToken();
70
 
71
 
72
  /**
73
+ * Получение токена, необходимого для запросов к API
74
+ *
75
+ * @param $request_token - временный токен, полученный функцией getRequestToken
76
+ * @return string токен
77
+ */
78
  public function getAccessToken($request_token)
79
  {
80
  if (!empty($this->token)) {
89
  }
90
 
91
  /**
92
+ * Удаление файла
93
+ *
94
+ * @param $file
95
+ * @return mixed
96
+ */
97
  public function deleteFile($file)
98
  {
99
  return $this->doApi("fileops/delete", "POST", array(
100
+ "path" => $file,
101
+ "root" => "auto"
102
  ));
103
  }
104
 
105
  /**
106
+ * Удаление нескольких файлов
107
+ *
108
+ * @param array $files
109
+ * @return array
110
+ */
111
  public function deleteFiles($files = array())
112
  {
113
  $result = array();
115
  foreach ($files as $file) {
116
  $do = $this->deleteFile($file);
117
  $result[] = array (
118
+ "name" => $file,
119
+ "result" => $do['error'] ? 0 : 1
120
  );
121
  }
122
 
124
  }
125
 
126
  /**
127
+ * Перемещение файлов
128
+ *
129
+ * @param $from - откуда
130
+ * @param $to - куда
131
+ * @return mixed
132
+ */
133
  public function moveFile ($from, $to)
134
  {
135
  return $this->doApi("fileops/move", "POST", array(
136
+ "root" => "auto",
137
+ "from_path" => $from,
138
+ "to_path" => $to
139
  ));
140
  }
141
 
142
  public function listing($path)
143
  {
144
  $dir = $this->doApi("metadata/auto/".ltrim($path, "/"), "GET", array(
145
+ "list" => TRUE
146
  ));
147
 
148
  if ($dir['error']) {
149
  return $dir;
150
  }
151
+ //Это не папка
152
  elseif (!$dir['is_dir']) {
153
  return array (
154
+ "size" => $dir['size'],
155
+ "date" => $dir['modified'],
156
+ "name" => $dir['path']
 
157
  );
158
  }
159
 
160
  $all_size = 0;
161
  $items = array();
162
+
163
  foreach ($dir['contents'] as $item) {
164
  if (!$item['is_dir']) {
165
  switch (substr($item['size'], -2)) {
183
  }
184
 
185
  $items[] = array (
186
+ "type" => $item['is_dir'] ? "dir" : "file",
187
+ "date" => $item['modified'],
188
+ "name" => basename($item['path']),
189
+ "size" => $item['size']
190
  );
191
  }
192
 
193
  $dir_result = array (
194
+ "size" => $this->bite2other($all_size),
195
+ "date" => $dir['modified'],
196
+ "name" => $dir['path'],
197
+ "items" => $items
198
  );
199
 
200
  return $dir_result;
210
  if ($size < $kb) {
211
  return $size.' B';
212
  } else if ($size < $mb) {
213
+ return round($size / $kb, 2).' KB';
214
+ } else if ($size < $gb) {
215
+ return round($size / $mb, 2).' MB';
216
+ } else if ($size < $tb) {
217
+ return round($size / $gb, 2).' GB';
218
+ } else {
219
+ return round($size / $tb, 2).' TB';
220
  }
221
  }
222
 
223
  /**
224
+ * Скачивание файла
225
+ *
226
+ * @param $file
227
+ * @param $server_path - путь, куда скачать на сервер. Если задан -- вернет путь к файлу в случае успешной загрузки.
228
+ * @return array
229
+ */
230
  public function downloadFile($file, $server_path = "")
231
  {
232
  $isset = $this->listing($file);
244
  header("Content-Transfer-Encoding: binary");
245
 
246
  $this->doApi("files/auto/".ltrim($file, "/"), "GET", array(), array(
247
+ CURLOPT_BINARYTRANSFER => 1,
248
+ CURLOPT_RETURNTRANSFER => 0,
 
249
  ), TRUE);
250
  exit;
251
  }
254
  //Файл недоступен для записи
255
  if (!$fd = fopen($server_path, "wb")) {
256
  return array (
257
+ "error" => 1,
258
+ "text" => "File '".$server_path."' not writable"
259
  );
260
  }
261
 
262
  $this->doApi("files/auto/".ltrim($file, "/"), "GET", array(), array(
263
+ CURLOPT_BINARYTRANSFER => 1,
264
+ CURLOPT_RETURNTRANSFER => 1,
265
+ CURLOPT_FILE => $fd
 
266
  ), TRUE);
267
 
268
  fclose($fd);
277
  }
278
 
279
  /**
280
+ * Поделиться файлом
281
+ *
282
+ * @param $file
283
+ * @param bool $short_url - короткая ссылка
284
+ * @return mixed
285
+ */
286
  public function shareFile($file, $short_url = TRUE)
287
  {
288
  $result = $this->doApi("shares/auto/".ltrim($file, "/"), "POST", compact("short_url"));
290
  }
291
 
292
  /**
293
+ * Загрузка нескольких файлов
294
+ *
295
+ * @param $files - массив формата файл_на_сервере => файл_в_дропбоксе
296
+ *
297
+ * @return array - информация о списке файлов
298
+ */
299
  public function uploadFiles($files = array())
300
  {
301
  $result = array();
303
  foreach ($files as $file => $dbx) {
304
  $do = $this->uploadFile($file, $dbx);
305
  $result[] = array (
306
+ "name" => $file,
307
+ "result" => $do['error'] ? 0 : 1
308
  );
309
  }
310
 
312
  }
313
 
314
  /**
315
+ * Загрузка файла
316
+ *
317
+ * @param $file_path - путь к файлу на сервере
318
+ * @param $dropbox_path - куда загружать, если не задан, будет загружен в корень дропбокса с таким же именем
319
+ * @param bool $overwrite - заменять ли файлы со схожими именами
320
+ * @return mixed
321
+ */
322
  public function uploadFile($file_path, $dropbox_path = "", $overwrite = FALSE)
323
  {
324
  if (empty($dropbox_path)) {
327
 
328
  if (!is_file($file_path)) {
329
  return array(
330
+ "error" => 1,
331
+ "text" => "File '".$file_path."' not found."
332
  );
333
  }
334
 
338
  if ($fsize/1024/1024 < $this->max_filesize_mb)
339
  {
340
  $result = $this->doApi("files_put/auto/".ltrim($dropbox_path, "/"),
341
+ "PUT",
342
+ compact ("overwrite"),
343
+ array(
344
+ CURLOPT_INFILE => $file,
345
+ CURLOPT_INFILESIZE => filesize($file_path),
346
+ CURLOPT_BINARYTRANSFER => 1,
347
+ CURLOPT_PUT => 1
348
+ ),
349
+ TRUE);
 
350
 
351
  }
352
  //Файл слишком велик
360
  $offset += $chunk;
361
 
362
  $result = $this->doApi("chunked_upload",
363
+ "PUT",
364
+ compact("upload_id", "offset"),
365
+ array(
366
+ CURLOPT_INFILE => $file,
367
+ CURLOPT_INFILESIZE => $chunk,
368
+ CURLOPT_BINARYTRANSFER => 1,
369
+ CURLOPT_PUT => 1
370
+ ),
371
+ TRUE);
 
 
372
 
373
  fseek($file, $offset);
374
  if($offset >= $fsize) {
381
  }
382
 
383
  $result = $this->doApi("commit_chunked_upload/auto/".ltrim($dropbox_path, "/"),
384
+ "POST",
385
+ compact("upload_id", "overwrite"),
386
+ array(),
387
+ TRUE);
388
  }
389
 
390
  @fclose($file);
393
  }
394
 
395
  /**
396
+ * Создание директории
397
+ *
398
+ * @param $path
399
+ * @return mixed
400
+ */
401
  public function createDir($path)
402
  {
403
  return $this->doApi("fileops/create_folder", "POST", array(
404
+ "root" => "auto",
405
+ "path" => $path
406
  ));
407
  }
408
 
409
  /**
410
+ * Информация об аккаунте
411
+ *
412
+ * @return mixed
413
+ */
414
  public function accInfo()
415
  {
416
  return $this->doApi("account/info", "GET");
417
  }
418
 
419
  /** Запрос к API
420
+ *
421
+ * @param $op - операция (url)
422
+ * @param $method - post/get
423
+ * @param array $data - доп. данные, url запрос
424
+ * @param array $opts - доп. параметры для curl
425
+ * @param $api_content - использовать url для загрузки файлов
426
+ * @return mixed
427
+ */
428
  private function doApi ($op, $method, $data = array(), $opts = array(), $api_content = FALSE)
429
  {
430
  if (($method == "GET" || $method == "PUT") && count($data)) {
431
  $op .= "?".http_build_query($data);
432
  }
 
433
  $result = $this->doCurl((!$api_content ? $this->api_url : $this->api_url_content).$op, $method, $data, $opts);
434
  $return = json_decode($result, TRUE);
435
  return self::checkError($return);
436
  }
437
 
438
  /**
439
+ * Обертка для отправки подписанного запроса через curl
440
+ *
441
+ * @param $url
442
+ * @param string $method
443
+ * @param array $data - POST данные
444
+ * @param $opts - доп. параметры для curl
445
+ * @return mixed
446
+ */
447
  public function doCurl($url, $method = "POST", $data = array(), $opts = array())
448
  {
449
+ $ch = curl_init($url);
450
+ $opts += array(
451
+ CURLOPT_RETURNTRANSFER => 1,
452
+ CURLOPT_HEADER => 0,
453
+ CURLOPT_SSL_VERIFYPEER => 0,
454
+ CURLOPT_SSL_VERIFYHOST => 0,
455
+ );
456
+
457
+
458
+ if ($method == "POST") {
459
+ $opts[CURLOPT_POST] = TRUE;
460
+ $opts[CURLOPT_POSTFIELDS] = http_build_query($data);
461
+ }
462
+
463
  $oauth = new OAuthSimple($this->app_key, $this->app_secret);
464
 
465
  if (!$this->request_token && $this->token) {
483
  }
484
 
485
  $signed = $oauth->sign(array(
486
+ 'action' => $method,
487
+ 'path' => $path
488
+ )
489
  );
490
+ $opts[CURLOPT_HTTPHEADER][] = "Authorization: ".$signed['header'];
491
 
492
+ if ($method == "PUT")
493
+ {
494
+ $opts[CURLOPT_CUSTOMREQUEST] = "PUT";
495
+ }
496
+ curl_setopt_array($ch, $opts);
497
+ $result = curl_exec($ch);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
498
 
 
 
 
 
 
 
499
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
500
  return $result;
501
  }
502
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
503
 
504
  private static function checkError($return)
505
  {
modules/index.html DELETED
@@ -1,10 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head lang="en">
4
- <meta charset="UTF-8">
5
- <title></title>
6
- </head>
7
- <body>
8
-
9
- </body>
10
- </html>
 
 
 
 
 
 
 
 
 
 
modules/pclzip.lib.php CHANGED
@@ -1,3043 +1,3034 @@
1
- <?php
2
- if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
3
- define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
4
- }
5
- if (!defined('PCLZIP_SEPARATOR')) {
6
- define( 'PCLZIP_SEPARATOR', ',' );
7
- }
8
- if (!defined('PCLZIP_ERROR_EXTERNAL')) {
9
- define( 'PCLZIP_ERROR_EXTERNAL', 0 );
10
- }
11
- if (!defined('PCLZIP_TEMPORARY_DIR')) {
12
- define( 'PCLZIP_TEMPORARY_DIR', '' );
13
- }
14
- if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
15
- define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
16
- }
17
- // --------------------------------------------------------------------------------
18
- // ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
19
- // --------------------------------------------------------------------------------
20
- $g_pclzip_version = "2.8.2";
21
- define( 'PCLZIP_ERR_USER_ABORTED', 2 );
22
- define( 'PCLZIP_ERR_NO_ERROR', 0 );
23
- define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
24
- define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );
25
- define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );
26
- define( 'PCLZIP_ERR_MISSING_FILE', -4 );
27
- define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
28
- define( 'PCLZIP_ERR_INVALID_ZIP', -6 );
29
- define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
30
- define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
31
- define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );
32
- define( 'PCLZIP_ERR_BAD_FORMAT', -10 );
33
- define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
34
- define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
35
- define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );
36
- define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
37
- define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
38
- define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
39
- define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 );
40
- define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 );
41
- define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
42
- define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 );
43
- define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 );
44
- define( 'PCLZIP_OPT_PATH', 77001 );
45
- define( 'PCLZIP_OPT_ADD_PATH', 77002 );
46
- define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );
47
- define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
48
- define( 'PCLZIP_OPT_SET_CHMOD', 77005 );
49
- define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
50
- define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );
51
- define( 'PCLZIP_OPT_BY_NAME', 77008 );
52
- define( 'PCLZIP_OPT_BY_INDEX', 77009 );
53
- define( 'PCLZIP_OPT_BY_EREG', 77010 );
54
- define( 'PCLZIP_OPT_BY_PREG', 77011 );
55
- define( 'PCLZIP_OPT_COMMENT', 77012 );
56
- define( 'PCLZIP_OPT_ADD_COMMENT', 77013 );
57
- define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 );
58
- define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
59
- define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 );
60
- define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 );
61
- define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
62
- define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 );
63
- define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias
64
- define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 );
65
- define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
66
- define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
67
- define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
68
- define( 'PCLZIP_ATT_FILE_NAME', 79001 );
69
- define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
70
- define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
71
- define( 'PCLZIP_ATT_FILE_MTIME', 79004 );
72
- define( 'PCLZIP_ATT_FILE_CONTENT', 79005 );
73
- define( 'PCLZIP_ATT_FILE_COMMENT', 79006 );
74
- define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
75
- define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
76
- define( 'PCLZIP_CB_PRE_ADD', 78003 );
77
- define( 'PCLZIP_CB_POST_ADD', 78004 );
78
- /* For futur use
79
- define( 'PCLZIP_CB_PRE_LIST', 78005 );
80
- define( 'PCLZIP_CB_POST_LIST', 78006 );
81
- define( 'PCLZIP_CB_PRE_DELETE', 78007 );
82
- define( 'PCLZIP_CB_POST_DELETE', 78008 );
83
- */
84
- class PclZip
85
- {
86
- var $zipname = '';
87
- var $zip_fd = 0;
88
- var $error_code = 1;
89
- var $error_string = '';
90
- var $magic_quotes_status;
91
- function __construct($p_zipname)
92
- {
93
- if (!function_exists('gzopen'))
94
- {
95
- die('Abort '.basename(__FILE__).' : Missing zlib extensions');
96
- }
97
- $this->zipname = $p_zipname;
98
- $this->zip_fd = 0;
99
- $this->magic_quotes_status = -1;
100
- return;
101
- }
102
- function create($p_filelist)
103
- {
104
- $v_result=1;
105
- $this->privErrorReset();
106
- $v_options = array();
107
- $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
108
- $v_size = func_num_args();
109
- if ($v_size > 1) {
110
- $v_arg_list = func_get_args();
111
- array_shift($v_arg_list);
112
- $v_size--;
113
- if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
114
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
115
- array (PCLZIP_OPT_REMOVE_PATH => 'optional',
116
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
117
- PCLZIP_OPT_ADD_PATH => 'optional',
118
- PCLZIP_CB_PRE_ADD => 'optional',
119
- PCLZIP_CB_POST_ADD => 'optional',
120
- PCLZIP_OPT_NO_COMPRESSION => 'optional',
121
- PCLZIP_OPT_COMMENT => 'optional',
122
- PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
123
- PCLZIP_OPT_TEMP_FILE_ON => 'optional',
124
- PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
125
- ));
126
- if ($v_result != 1) {
127
- return 0;
128
- }
129
- }
130
- else {
131
- $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
132
- if ($v_size == 2) {
133
- $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
134
- }
135
- else if ($v_size > 2) {
136
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
137
- "Invalid number / type of arguments");
138
- return 0;
139
- }
140
- }
141
- }
142
- $this->privOptionDefaultThreshold($v_options);
143
- $v_string_list = array();
144
- $v_att_list = array();
145
- $v_filedescr_list = array();
146
- $p_result_list = array();
147
- if (is_array($p_filelist)) {
148
- if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
149
- $v_att_list = $p_filelist;
150
- }
151
- else {
152
- $v_string_list = $p_filelist;
153
- }
154
- }
155
- else if (is_string($p_filelist)) {
156
- $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
157
- }
158
- else {
159
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
160
- return 0;
161
- }
162
- if (sizeof($v_string_list) != 0) {
163
- foreach ($v_string_list as $v_string) {
164
- if ($v_string != '') {
165
- $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
166
- }
167
- else {
168
- }
169
- }
170
- }
171
- $v_supported_attributes
172
- = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
173
- ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
174
- ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
175
- ,PCLZIP_ATT_FILE_MTIME => 'optional'
176
- ,PCLZIP_ATT_FILE_CONTENT => 'optional'
177
- ,PCLZIP_ATT_FILE_COMMENT => 'optional'
178
- );
179
- foreach ($v_att_list as $v_entry) {
180
- $v_result = $this->privFileDescrParseAtt($v_entry,
181
- $v_filedescr_list[],
182
- $v_options,
183
- $v_supported_attributes);
184
- if ($v_result != 1) {
185
- return 0;
186
- }
187
- }
188
- $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
189
- if ($v_result != 1) {
190
- return 0;
191
- }
192
- $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
193
- if ($v_result != 1) {
194
- return 0;
195
- }
196
- return $p_result_list;
197
- }
198
- function add($p_filelist)
199
- {
200
- $v_result=1;
201
- $this->privErrorReset();
202
- $v_options = array();
203
- $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
204
- $v_size = func_num_args();
205
- if ($v_size > 1) {
206
- $v_arg_list = func_get_args();
207
- array_shift($v_arg_list);
208
- $v_size--;
209
- if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
210
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
211
- array (PCLZIP_OPT_REMOVE_PATH => 'optional',
212
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
213
- PCLZIP_OPT_ADD_PATH => 'optional',
214
- PCLZIP_CB_PRE_ADD => 'optional',
215
- PCLZIP_CB_POST_ADD => 'optional',
216
- PCLZIP_OPT_NO_COMPRESSION => 'optional',
217
- PCLZIP_OPT_COMMENT => 'optional',
218
- PCLZIP_OPT_ADD_COMMENT => 'optional',
219
- PCLZIP_OPT_PREPEND_COMMENT => 'optional',
220
- PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
221
- PCLZIP_OPT_TEMP_FILE_ON => 'optional',
222
- PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
223
- ));
224
- if ($v_result != 1) {
225
- return 0;
226
- }
227
- }
228
- else {
229
- $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
230
- if ($v_size == 2) {
231
- $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
232
- }
233
- else if ($v_size > 2) {
234
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
235
- return 0;
236
- }
237
- }
238
- }
239
- $this->privOptionDefaultThreshold($v_options);
240
- $v_string_list = array();
241
- $v_att_list = array();
242
- $v_filedescr_list = array();
243
- $p_result_list = array();
244
- if (is_array($p_filelist)) {
245
- if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
246
- $v_att_list = $p_filelist;
247
- }
248
- else {
249
- $v_string_list = $p_filelist;
250
- }
251
- }
252
- else if (is_string($p_filelist)) {
253
- $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
254
- }
255
- else {
256
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
257
- return 0;
258
- }
259
- if (sizeof($v_string_list) != 0) {
260
- foreach ($v_string_list as $v_string) {
261
- $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
262
- }
263
- }
264
- $v_supported_attributes
265
- = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
266
- ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
267
- ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
268
- ,PCLZIP_ATT_FILE_MTIME => 'optional'
269
- ,PCLZIP_ATT_FILE_CONTENT => 'optional'
270
- ,PCLZIP_ATT_FILE_COMMENT => 'optional'
271
- );
272
- foreach ($v_att_list as $v_entry) {
273
- $v_result = $this->privFileDescrParseAtt($v_entry,
274
- $v_filedescr_list[],
275
- $v_options,
276
- $v_supported_attributes);
277
- if ($v_result != 1) {
278
- return 0;
279
- }
280
- }
281
- $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
282
- if ($v_result != 1) {
283
- return 0;
284
- }
285
- $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
286
- if ($v_result != 1) {
287
- return 0;
288
- }
289
- return $p_result_list;
290
- }
291
- function listContent()
292
- {
293
- $v_result=1;
294
- $this->privErrorReset();
295
- if (!$this->privCheckFormat()) {
296
- return(0);
297
- }
298
- $p_list = array();
299
- if (($v_result = $this->privList($p_list)) != 1)
300
- {
301
- unset($p_list);
302
- return(0);
303
- }
304
- return $p_list;
305
- }
306
- function extract()
307
- {
308
- $v_result=1;
309
- $this->privErrorReset();
310
- if (!$this->privCheckFormat()) {
311
- return(0);
312
- }
313
- $v_options = array();
314
- // $v_path = "./";
315
- $v_path = '';
316
- $v_remove_path = "";
317
- $v_remove_all_path = false;
318
- $v_size = func_num_args();
319
- $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
320
- if ($v_size > 0) {
321
- $v_arg_list = func_get_args();
322
- if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
323
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
324
- array (PCLZIP_OPT_PATH => 'optional',
325
- PCLZIP_OPT_REMOVE_PATH => 'optional',
326
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
327
- PCLZIP_OPT_ADD_PATH => 'optional',
328
- PCLZIP_CB_PRE_EXTRACT => 'optional',
329
- PCLZIP_CB_POST_EXTRACT => 'optional',
330
- PCLZIP_OPT_SET_CHMOD => 'optional',
331
- PCLZIP_OPT_BY_NAME => 'optional',
332
- PCLZIP_OPT_BY_EREG => 'optional',
333
- PCLZIP_OPT_BY_PREG => 'optional',
334
- PCLZIP_OPT_BY_INDEX => 'optional',
335
- PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
336
- PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
337
- PCLZIP_OPT_REPLACE_NEWER => 'optional'
338
- ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
339
- ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
340
- PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
341
- PCLZIP_OPT_TEMP_FILE_ON => 'optional',
342
- PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
343
- ));
344
- if ($v_result != 1) {
345
- return 0;
346
- }
347
- if (isset($v_options[PCLZIP_OPT_PATH])) {
348
- $v_path = $v_options[PCLZIP_OPT_PATH];
349
- }
350
- if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
351
- $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
352
- }
353
- if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
354
- $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
355
- }
356
- if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
357
- if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
358
- $v_path .= '/';
359
- }
360
- $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
361
- }
362
- }
363
- else {
364
- $v_path = $v_arg_list[0];
365
- if ($v_size == 2) {
366
- $v_remove_path = $v_arg_list[1];
367
- }
368
- else if ($v_size > 2) {
369
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
370
- return 0;
371
- }
372
- }
373
- }
374
- $this->privOptionDefaultThreshold($v_options);
375
- $p_list = array();
376
- $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path,
377
- $v_remove_all_path, $v_options);
378
- if ($v_result < 1) {
379
- unset($p_list);
380
- return(0);
381
- }
382
- return $p_list;
383
- }
384
- function extractByIndex($p_index)
385
- {
386
- $v_result=1;
387
- $this->privErrorReset();
388
- if (!$this->privCheckFormat()) {
389
- return(0);
390
- }
391
- $v_options = array();
392
- // $v_path = "./";
393
- $v_path = '';
394
- $v_remove_path = "";
395
- $v_remove_all_path = false;
396
- $v_size = func_num_args();
397
- $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
398
- if ($v_size > 1) {
399
- $v_arg_list = func_get_args();
400
- array_shift($v_arg_list);
401
- $v_size--;
402
- if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
403
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
404
- array (PCLZIP_OPT_PATH => 'optional',
405
- PCLZIP_OPT_REMOVE_PATH => 'optional',
406
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
407
- PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
408
- PCLZIP_OPT_ADD_PATH => 'optional',
409
- PCLZIP_CB_PRE_EXTRACT => 'optional',
410
- PCLZIP_CB_POST_EXTRACT => 'optional',
411
- PCLZIP_OPT_SET_CHMOD => 'optional',
412
- PCLZIP_OPT_REPLACE_NEWER => 'optional'
413
- ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
414
- ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
415
- PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
416
- PCLZIP_OPT_TEMP_FILE_ON => 'optional',
417
- PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
418
- ));
419
- if ($v_result != 1) {
420
- return 0;
421
- }
422
- if (isset($v_options[PCLZIP_OPT_PATH])) {
423
- $v_path = $v_options[PCLZIP_OPT_PATH];
424
- }
425
- if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
426
- $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
427
- }
428
- if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
429
- $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
430
- }
431
- if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
432
- if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
433
- $v_path .= '/';
434
- }
435
- $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
436
- }
437
- if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
438
- $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
439
- }
440
- else {
441
- }
442
- }
443
- else {
444
- $v_path = $v_arg_list[0];
445
- if ($v_size == 2) {
446
- $v_remove_path = $v_arg_list[1];
447
- }
448
- else if ($v_size > 2) {
449
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
450
- return 0;
451
- }
452
- }
453
- }
454
- $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
455
- $v_options_trick = array();
456
- $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
457
- array (PCLZIP_OPT_BY_INDEX => 'optional' ));
458
- if ($v_result != 1) {
459
- return 0;
460
- }
461
- $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
462
- $this->privOptionDefaultThreshold($v_options);
463
- if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
464
- return(0);
465
- }
466
- return $p_list;
467
- }
468
- function delete()
469
- {
470
- $v_result=1;
471
- $this->privErrorReset();
472
- if (!$this->privCheckFormat()) {
473
- return(0);
474
- }
475
- $v_options = array();
476
- $v_size = func_num_args();
477
- if ($v_size > 0) {
478
- $v_arg_list = func_get_args();
479
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
480
- array (PCLZIP_OPT_BY_NAME => 'optional',
481
- PCLZIP_OPT_BY_EREG => 'optional',
482
- PCLZIP_OPT_BY_PREG => 'optional',
483
- PCLZIP_OPT_BY_INDEX => 'optional' ));
484
- if ($v_result != 1) {
485
- return 0;
486
- }
487
- }
488
- $this->privDisableMagicQuotes();
489
- $v_list = array();
490
- if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
491
- $this->privSwapBackMagicQuotes();
492
- unset($v_list);
493
- return(0);
494
- }
495
- $this->privSwapBackMagicQuotes();
496
- return $v_list;
497
- }
498
- function deleteByIndex($p_index)
499
- {
500
- $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
501
- return $p_list;
502
- }
503
- function properties()
504
- {
505
- $this->privErrorReset();
506
- $this->privDisableMagicQuotes();
507
- if (!$this->privCheckFormat()) {
508
- $this->privSwapBackMagicQuotes();
509
- return(0);
510
- }
511
- $v_prop = array();
512
- $v_prop['comment'] = '';
513
- $v_prop['nb'] = 0;
514
- $v_prop['status'] = 'not_exist';
515
- if (@is_file($this->zipname))
516
- {
517
- if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
518
- {
519
- $this->privSwapBackMagicQuotes();
520
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
521
- return 0;
522
- }
523
- $v_central_dir = array();
524
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
525
- {
526
- $this->privSwapBackMagicQuotes();
527
- return 0;
528
- }
529
- $this->privCloseFd();
530
- $v_prop['comment'] = $v_central_dir['comment'];
531
- $v_prop['nb'] = $v_central_dir['entries'];
532
- $v_prop['status'] = 'ok';
533
- }
534
- $this->privSwapBackMagicQuotes();
535
- return $v_prop;
536
- }
537
- function duplicate($p_archive)
538
- {
539
- $v_result = 1;
540
- $this->privErrorReset();
541
- if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
542
- {
543
- $v_result = $this->privDuplicate($p_archive->zipname);
544
- }
545
- else if (is_string($p_archive))
546
- {
547
- if (!is_file($p_archive)) {
548
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
549
- $v_result = PCLZIP_ERR_MISSING_FILE;
550
- }
551
- else {
552
- $v_result = $this->privDuplicate($p_archive);
553
- }
554
- }
555
- else
556
- {
557
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
558
- $v_result = PCLZIP_ERR_INVALID_PARAMETER;
559
- }
560
- return $v_result;
561
- }
562
- function merge($p_archive_to_add)
563
- {
564
- $v_result = 1;
565
- $this->privErrorReset();
566
- if (!$this->privCheckFormat()) {
567
- return(0);
568
- }
569
- if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
570
- {
571
- $v_result = $this->privMerge($p_archive_to_add);
572
- }
573
- else if (is_string($p_archive_to_add))
574
- {
575
- $v_object_archive = new PclZip($p_archive_to_add);
576
- $v_result = $this->privMerge($v_object_archive);
577
- }
578
- else
579
- {
580
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
581
- $v_result = PCLZIP_ERR_INVALID_PARAMETER;
582
- }
583
- return $v_result;
584
- }
585
- function errorCode()
586
- {
587
- if (PCLZIP_ERROR_EXTERNAL == 1) {
588
- return(PclErrorCode());
589
- }
590
- else {
591
- return($this->error_code);
592
- }
593
- }
594
- function errorName($p_with_code=false)
595
- {
596
- $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
597
- PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
598
- PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
599
- PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
600
- PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
601
- PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
602
- PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
603
- PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
604
- PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
605
- PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
606
- PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
607
- PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
608
- PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
609
- PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
610
- PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
611
- PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
612
- PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
613
- PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
614
- PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
615
- ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
616
- ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
617
- );
618
- if (isset($v_name[$this->error_code])) {
619
- $v_value = $v_name[$this->error_code];
620
- }
621
- else {
622
- $v_value = 'NoName';
623
- }
624
- if ($p_with_code) {
625
- return($v_value.' ('.$this->error_code.')');
626
- }
627
- else {
628
- return($v_value);
629
- }
630
- }
631
- function errorInfo($p_full=false)
632
- {
633
- if (PCLZIP_ERROR_EXTERNAL == 1) {
634
- return(PclErrorString());
635
- }
636
- else {
637
- if ($p_full) {
638
- return($this->errorName(true)." : ".$this->error_string);
639
- }
640
- else {
641
- return($this->error_string." [code ".$this->error_code."]");
642
- }
643
- }
644
- }
645
- // --------------------------------------------------------------------------------
646
- // ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS *****
647
- // ***** *****
648
- // ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY *****
649
- // --------------------------------------------------------------------------------
650
- function privCheckFormat($p_level=0)
651
- {
652
- $v_result = true;
653
- // ----- Reset the file system cache
654
- clearstatcache();
655
- $this->privErrorReset();
656
- if (!is_file($this->zipname)) {
657
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
658
- return(false);
659
- }
660
- if (!is_readable($this->zipname)) {
661
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
662
- return(false);
663
- }
664
- return $v_result;
665
- }
666
- function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
667
- {
668
- $v_result=1;
669
- $i=0;
670
- while ($i<$p_size) {
671
- if (!isset($v_requested_options[$p_options_list[$i]])) {
672
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
673
- return PclZip::errorCode();
674
- }
675
- switch ($p_options_list[$i]) {
676
- case PCLZIP_OPT_PATH :
677
- case PCLZIP_OPT_REMOVE_PATH :
678
- case PCLZIP_OPT_ADD_PATH :
679
- if (($i+1) >= $p_size) {
680
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
681
- return PclZip::errorCode();
682
- }
683
- $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
684
- $i++;
685
- break;
686
- case PCLZIP_OPT_TEMP_FILE_THRESHOLD :
687
- if (($i+1) >= $p_size) {
688
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
689
- return PclZip::errorCode();
690
- }
691
- if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
692
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
693
- return PclZip::errorCode();
694
- }
695
- $v_value = $p_options_list[$i+1];
696
- if ((!is_integer($v_value)) || ($v_value<0)) {
697
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
698
- return PclZip::errorCode();
699
- }
700
- $v_result_list[$p_options_list[$i]] = $v_value*1048576;
701
- $i++;
702
- break;
703
- case PCLZIP_OPT_TEMP_FILE_ON :
704
- if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
705
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
706
- return PclZip::errorCode();
707
- }
708
- $v_result_list[$p_options_list[$i]] = true;
709
- break;
710
- case PCLZIP_OPT_TEMP_FILE_OFF :
711
- if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
712
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
713
- return PclZip::errorCode();
714
- }
715
- if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
716
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
717
- return PclZip::errorCode();
718
- }
719
- $v_result_list[$p_options_list[$i]] = true;
720
- break;
721
- case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
722
- if (($i+1) >= $p_size) {
723
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
724
- return PclZip::errorCode();
725
- }
726
- if ( is_string($p_options_list[$i+1])
727
- && ($p_options_list[$i+1] != '')) {
728
- $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
729
- $i++;
730
- }
731
- else {
732
- }
733
- break;
734
- case PCLZIP_OPT_BY_NAME :
735
- if (($i+1) >= $p_size) {
736
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
737
- return PclZip::errorCode();
738
- }
739
- if (is_string($p_options_list[$i+1])) {
740
- $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
741
- }
742
- else if (is_array($p_options_list[$i+1])) {
743
- $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
744
- }
745
- else {
746
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
747
- return PclZip::errorCode();
748
- }
749
- $i++;
750
- break;
751
- case PCLZIP_OPT_BY_EREG :
752
- $p_options_list[$i] = PCLZIP_OPT_BY_PREG;
753
- case PCLZIP_OPT_BY_PREG :
754
- if (($i+1) >= $p_size) {
755
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
756
- return PclZip::errorCode();
757
- }
758
- if (is_string($p_options_list[$i+1])) {
759
- $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
760
- }
761
- else {
762
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
763
- return PclZip::errorCode();
764
- }
765
- $i++;
766
- break;
767
- case PCLZIP_OPT_COMMENT :
768
- case PCLZIP_OPT_ADD_COMMENT :
769
- case PCLZIP_OPT_PREPEND_COMMENT :
770
- if (($i+1) >= $p_size) {
771
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
772
- "Missing parameter value for option '"
773
- .PclZipUtilOptionText($p_options_list[$i])
774
- ."'");
775
- return PclZip::errorCode();
776
- }
777
- if (is_string($p_options_list[$i+1])) {
778
- $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
779
- }
780
- else {
781
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
782
- "Wrong parameter value for option '"
783
- .PclZipUtilOptionText($p_options_list[$i])
784
- ."'");
785
- return PclZip::errorCode();
786
- }
787
- $i++;
788
- break;
789
- case PCLZIP_OPT_BY_INDEX :
790
- if (($i+1) >= $p_size) {
791
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
792
- return PclZip::errorCode();
793
- }
794
- $v_work_list = array();
795
- if (is_string($p_options_list[$i+1])) {
796
- $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
797
- $v_work_list = explode(",", $p_options_list[$i+1]);
798
- }
799
- else if (is_integer($p_options_list[$i+1])) {
800
- $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
801
- }
802
- else if (is_array($p_options_list[$i+1])) {
803
- $v_work_list = $p_options_list[$i+1];
804
- }
805
- else {
806
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
807
- return PclZip::errorCode();
808
- }
809
- $v_sort_flag=false;
810
- $v_sort_value=0;
811
- for ($j=0; $j<sizeof($v_work_list); $j++) {
812
- $v_item_list = explode("-", $v_work_list[$j]);
813
- $v_size_item_list = sizeof($v_item_list);
814
- if ($v_size_item_list == 1) {
815
- $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
816
- $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
817
- }
818
- elseif ($v_size_item_list == 2) {
819
- $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
820
- $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
821
- }
822
- else {
823
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
824
- return PclZip::errorCode();
825
- }
826
- if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
827
- $v_sort_flag=true;
828
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
829
- return PclZip::errorCode();
830
- }
831
- $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
832
- }
833
- if ($v_sort_flag) {
834
- }
835
- $i++;
836
- break;
837
- case PCLZIP_OPT_REMOVE_ALL_PATH :
838
- case PCLZIP_OPT_EXTRACT_AS_STRING :
839
- case PCLZIP_OPT_NO_COMPRESSION :
840
- case PCLZIP_OPT_EXTRACT_IN_OUTPUT :
841
- case PCLZIP_OPT_REPLACE_NEWER :
842
- case PCLZIP_OPT_STOP_ON_ERROR :
843
- $v_result_list[$p_options_list[$i]] = true;
844
- break;
845
- case PCLZIP_OPT_SET_CHMOD :
846
- if (($i+1) >= $p_size) {
847
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
848
- return PclZip::errorCode();
849
- }
850
- $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
851
- $i++;
852
- break;
853
- case PCLZIP_CB_PRE_EXTRACT :
854
- case PCLZIP_CB_POST_EXTRACT :
855
- case PCLZIP_CB_PRE_ADD :
856
- case PCLZIP_CB_POST_ADD :
857
- /* for futur use
858
- case PCLZIP_CB_PRE_DELETE :
859
- case PCLZIP_CB_POST_DELETE :
860
- case PCLZIP_CB_PRE_LIST :
861
- case PCLZIP_CB_POST_LIST :
862
- */
863
- if (($i+1) >= $p_size) {
864
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
865
- return PclZip::errorCode();
866
- }
867
- $v_function_name = $p_options_list[$i+1];
868
- if (!function_exists($v_function_name)) {
869
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
870
- return PclZip::errorCode();
871
- }
872
- $v_result_list[$p_options_list[$i]] = $v_function_name;
873
- $i++;
874
- break;
875
- default :
876
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
877
- "Unknown parameter '"
878
- .$p_options_list[$i]."'");
879
- return PclZip::errorCode();
880
- }
881
- $i++;
882
- }
883
- if ($v_requested_options !== false) {
884
- for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
885
- if ($v_requested_options[$key] == 'mandatory') {
886
- if (!isset($v_result_list[$key])) {
887
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
888
- return PclZip::errorCode();
889
- }
890
- }
891
- }
892
- }
893
- if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
894
- }
895
- return $v_result;
896
- }
897
- function privOptionDefaultThreshold(&$p_options)
898
- {
899
- $v_result=1;
900
- if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
901
- || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
902
- return $v_result;
903
- }
904
- $v_memory_limit = ini_get('memory_limit');
905
- $v_memory_limit = trim($v_memory_limit);
906
- $last = strtolower(substr($v_memory_limit, -1));
907
- if($last == 'g')
908
- $v_memory_limit = $v_memory_limit*1073741824;
909
- if($last == 'm')
910
- $v_memory_limit = $v_memory_limit*1048576;
911
- if($last == 'k')
912
- $v_memory_limit = $v_memory_limit*1024;
913
- $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
914
- if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
915
- unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
916
- }
917
- return $v_result;
918
- }
919
- function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
920
- {
921
- $v_result=1;
922
- foreach ($p_file_list as $v_key => $v_value) {
923
- if (!isset($v_requested_options[$v_key])) {
924
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
925
- return PclZip::errorCode();
926
- }
927
- switch ($v_key) {
928
- case PCLZIP_ATT_FILE_NAME :
929
- if (!is_string($v_value)) {
930
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
931
- return PclZip::errorCode();
932
- }
933
- $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
934
- if ($p_filedescr['filename'] == '') {
935
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
936
- return PclZip::errorCode();
937
- }
938
- break;
939
- case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
940
- if (!is_string($v_value)) {
941
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
942
- return PclZip::errorCode();
943
- }
944
- $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
945
- if ($p_filedescr['new_short_name'] == '') {
946
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
947
- return PclZip::errorCode();
948
- }
949
- break;
950
- case PCLZIP_ATT_FILE_NEW_FULL_NAME :
951
- if (!is_string($v_value)) {
952
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
953
- return PclZip::errorCode();
954
- }
955
- $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
956
- if ($p_filedescr['new_full_name'] == '') {
957
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
958
- return PclZip::errorCode();
959
- }
960
- break;
961
- case PCLZIP_ATT_FILE_COMMENT :
962
- if (!is_string($v_value)) {
963
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
964
- return PclZip::errorCode();
965
- }
966
- $p_filedescr['comment'] = $v_value;
967
- break;
968
- case PCLZIP_ATT_FILE_MTIME :
969
- if (!is_integer($v_value)) {
970
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
971
- return PclZip::errorCode();
972
- }
973
- $p_filedescr['mtime'] = $v_value;
974
- break;
975
- case PCLZIP_ATT_FILE_CONTENT :
976
- $p_filedescr['content'] = $v_value;
977
- break;
978
- default :
979
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
980
- "Unknown parameter '".$v_key."'");
981
- return PclZip::errorCode();
982
- }
983
- if ($v_requested_options !== false) {
984
- for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
985
- if ($v_requested_options[$key] == 'mandatory') {
986
- if (!isset($p_file_list[$key])) {
987
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
988
- return PclZip::errorCode();
989
- }
990
- }
991
- }
992
- }
993
- }
994
- return $v_result;
995
- }
996
- function privFileDescrExpand(&$p_filedescr_list, &$p_options)
997
- {
998
- $v_result=1;
999
- $v_result_list = array();
1000
- for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
1001
- $v_descr = $p_filedescr_list[$i];
1002
- $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
1003
- $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
1004
- if (file_exists($v_descr['filename'])) {
1005
- if (@is_file($v_descr['filename'])) {
1006
- $v_descr['type'] = 'file';
1007
- }
1008
- else if (@is_dir($v_descr['filename'])) {
1009
- $v_descr['type'] = 'folder';
1010
- }
1011
- else if (@is_link($v_descr['filename'])) {
1012
- continue;
1013
- }
1014
- else {
1015
- continue;
1016
- }
1017
- }
1018
- else if (isset($v_descr['content'])) {
1019
- $v_descr['type'] = 'virtual_file';
1020
- }
1021
- else {
1022
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
1023
- return PclZip::errorCode();
1024
- }
1025
- $this->privCalculateStoredFilename($v_descr, $p_options);
1026
- $v_result_list[sizeof($v_result_list)] = $v_descr;
1027
- if ($v_descr['type'] == 'folder') {
1028
- $v_dirlist_descr = array();
1029
- $v_dirlist_nb = 0;
1030
- if ($v_folder_handler = @opendir($v_descr['filename'])) {
1031
- while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
1032
- if (($v_item_handler == '.') || ($v_item_handler == '..')) {
1033
- continue;
1034
- }
1035
- $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
1036
- if (($v_descr['stored_filename'] != $v_descr['filename'])
1037
- && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
1038
- if ($v_descr['stored_filename'] != '') {
1039
- $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
1040
- }
1041
- else {
1042
- $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
1043
- }
1044
- }
1045
- $v_dirlist_nb++;
1046
- }
1047
- @closedir($v_folder_handler);
1048
- }
1049
- else {
1050
- }
1051
- if ($v_dirlist_nb != 0) {
1052
- if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
1053
- return $v_result;
1054
- }
1055
- $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
1056
- }
1057
- else {
1058
- }
1059
- unset($v_dirlist_descr);
1060
- }
1061
- }
1062
- $p_filedescr_list = $v_result_list;
1063
- return $v_result;
1064
- }
1065
- function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
1066
- {
1067
- $v_result=1;
1068
- $v_list_detail = array();
1069
- $this->privDisableMagicQuotes();
1070
- if (($v_result = $this->privOpenFd('wb')) != 1)
1071
- {
1072
- return $v_result;
1073
- }
1074
- $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
1075
- $this->privCloseFd();
1076
- $this->privSwapBackMagicQuotes();
1077
- return $v_result;
1078
- }
1079
- function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
1080
- {
1081
- $v_result=1;
1082
- $v_list_detail = array();
1083
- if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
1084
- {
1085
- $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
1086
- return $v_result;
1087
- }
1088
- $this->privDisableMagicQuotes();
1089
- if (($v_result=$this->privOpenFd('rb')) != 1)
1090
- {
1091
- $this->privSwapBackMagicQuotes();
1092
- return $v_result;
1093
- }
1094
- $v_central_dir = array();
1095
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
1096
- {
1097
- $this->privCloseFd();
1098
- $this->privSwapBackMagicQuotes();
1099
- return $v_result;
1100
- }
1101
- @rewind($this->zip_fd);
1102
- $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
1103
- if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
1104
- {
1105
- $this->privCloseFd();
1106
- $this->privSwapBackMagicQuotes();
1107
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
1108
- return PclZip::errorCode();
1109
- }
1110
- $v_size = $v_central_dir['offset'];
1111
- while ($v_size != 0)
1112
- {
1113
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
1114
- $v_buffer = fread($this->zip_fd, $v_read_size);
1115
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
1116
- $v_size -= $v_read_size;
1117
- }
1118
- $v_swap = $this->zip_fd;
1119
- $this->zip_fd = $v_zip_temp_fd;
1120
- $v_zip_temp_fd = $v_swap;
1121
- $v_header_list = array();
1122
- if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
1123
- {
1124
- fclose($v_zip_temp_fd);
1125
- $this->privCloseFd();
1126
- @unlink($v_zip_temp_name);
1127
- $this->privSwapBackMagicQuotes();
1128
- return $v_result;
1129
- }
1130
- $v_offset = @ftell($this->zip_fd);
1131
- $v_size = $v_central_dir['size'];
1132
- while ($v_size != 0)
1133
- {
1134
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
1135
- $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
1136
- @fwrite($this->zip_fd, $v_buffer, $v_read_size);
1137
- $v_size -= $v_read_size;
1138
- }
1139
- for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
1140
- {
1141
- if ($v_header_list[$i]['status'] == 'ok') {
1142
- if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
1143
- fclose($v_zip_temp_fd);
1144
- $this->privCloseFd();
1145
- @unlink($v_zip_temp_name);
1146
- $this->privSwapBackMagicQuotes();
1147
- return $v_result;
1148
- }
1149
- $v_count++;
1150
- }
1151
- $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
1152
- }
1153
- $v_comment = $v_central_dir['comment'];
1154
- if (isset($p_options[PCLZIP_OPT_COMMENT])) {
1155
- $v_comment = $p_options[PCLZIP_OPT_COMMENT];
1156
- }
1157
- if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
1158
- $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
1159
- }
1160
- if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
1161
- $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
1162
- }
1163
- $v_size = @ftell($this->zip_fd)-$v_offset;
1164
- if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
1165
- {
1166
- unset($v_header_list);
1167
- $this->privSwapBackMagicQuotes();
1168
- return $v_result;
1169
- }
1170
- $v_swap = $this->zip_fd;
1171
- $this->zip_fd = $v_zip_temp_fd;
1172
- $v_zip_temp_fd = $v_swap;
1173
- $this->privCloseFd();
1174
- @fclose($v_zip_temp_fd);
1175
- $this->privSwapBackMagicQuotes();
1176
- @unlink($this->zipname);
1177
- PclZipUtilRename($v_zip_temp_name, $this->zipname);
1178
- return $v_result;
1179
- }
1180
- function privOpenFd($p_mode)
1181
- {
1182
- $v_result=1;
1183
- if ($this->zip_fd != 0)
1184
- {
1185
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
1186
- return PclZip::errorCode();
1187
- }
1188
- if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
1189
- {
1190
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
1191
- return PclZip::errorCode();
1192
- }
1193
- return $v_result;
1194
- }
1195
- function privCloseFd()
1196
- {
1197
- $v_result=1;
1198
- if ($this->zip_fd != 0)
1199
- @fclose($this->zip_fd);
1200
- $this->zip_fd = 0;
1201
- return $v_result;
1202
- }
1203
- // function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
1204
- function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
1205
- {
1206
- $v_result=1;
1207
- $v_header_list = array();
1208
- if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
1209
- {
1210
- return $v_result;
1211
- }
1212
- $v_offset = @ftell($this->zip_fd);
1213
- for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
1214
- {
1215
- if ($v_header_list[$i]['status'] == 'ok') {
1216
- if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
1217
- return $v_result;
1218
- }
1219
- $v_count++;
1220
- }
1221
- $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
1222
- }
1223
- $v_comment = '';
1224
- if (isset($p_options[PCLZIP_OPT_COMMENT])) {
1225
- $v_comment = $p_options[PCLZIP_OPT_COMMENT];
1226
- }
1227
- $v_size = @ftell($this->zip_fd)-$v_offset;
1228
- if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
1229
- {
1230
- unset($v_header_list);
1231
- return $v_result;
1232
- }
1233
- return $v_result;
1234
- }
1235
- function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
1236
- {
1237
- $v_result=1;
1238
- $v_header = array();
1239
- $v_nb = sizeof($p_result_list);
1240
- for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
1241
- $p_filedescr_list[$j]['filename']
1242
- = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
1243
- if ($p_filedescr_list[$j]['filename'] == "") {
1244
- continue;
1245
- }
1246
- if ( ($p_filedescr_list[$j]['type'] != 'virtual_file')
1247
- && (!file_exists($p_filedescr_list[$j]['filename']))) {
1248
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
1249
- return PclZip::errorCode();
1250
- }
1251
- // if ( (is_file($p_filedescr_list[$j]['filename']))
1252
- // || ( is_dir($p_filedescr_list[$j]['filename'])
1253
- if ( ($p_filedescr_list[$j]['type'] == 'file')
1254
- || ($p_filedescr_list[$j]['type'] == 'virtual_file')
1255
- || ( ($p_filedescr_list[$j]['type'] == 'folder')
1256
- && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
1257
- || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
1258
- ) {
1259
- $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
1260
- $p_options);
1261
- if ($v_result != 1) {
1262
- return $v_result;
1263
- }
1264
- $p_result_list[$v_nb++] = $v_header;
1265
- }
1266
- }
1267
- return $v_result;
1268
- }
1269
- function privAddFile($p_filedescr, &$p_header, &$p_options)
1270
- {
1271
- $v_result=1;
1272
- $p_filename = $p_filedescr['filename'];
1273
- if ($p_filename == "") {
1274
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
1275
- return PclZip::errorCode();
1276
- }
1277
- /* TBC : Removed
1278
- if (isset($p_filedescr['stored_filename'])) {
1279
- $v_stored_filename = $p_filedescr['stored_filename'];
1280
- }
1281
- else {
1282
- $v_stored_filename = $p_filedescr['stored_filename'];
1283
- }
1284
- */
1285
- clearstatcache();
1286
- $p_header['version'] = 20;
1287
- $p_header['version_extracted'] = 10;
1288
- $p_header['flag'] = 0;
1289
- $p_header['compression'] = 0;
1290
- $p_header['crc'] = 0;
1291
- $p_header['compressed_size'] = 0;
1292
- $p_header['filename_len'] = strlen($p_filename);
1293
- $p_header['extra_len'] = 0;
1294
- $p_header['disk'] = 0;
1295
- $p_header['internal'] = 0;
1296
- $p_header['offset'] = 0;
1297
- $p_header['filename'] = $p_filename;
1298
- // TBC : Removed $p_header['stored_filename'] = $v_stored_filename;
1299
- $p_header['stored_filename'] = $p_filedescr['stored_filename'];
1300
- $p_header['extra'] = '';
1301
- $p_header['status'] = 'ok';
1302
- $p_header['index'] = -1;
1303
- if ($p_filedescr['type']=='file') {
1304
- $p_header['external'] = 0x00000000;
1305
- $p_header['size'] = filesize($p_filename);
1306
- }
1307
- else if ($p_filedescr['type']=='folder') {
1308
- $p_header['external'] = 0x00000010;
1309
- $p_header['mtime'] = filemtime($p_filename);
1310
- $p_header['size'] = filesize($p_filename);
1311
- }
1312
- else if ($p_filedescr['type'] == 'virtual_file') {
1313
- $p_header['external'] = 0x00000000;
1314
- $p_header['size'] = strlen($p_filedescr['content']);
1315
- }
1316
- if (isset($p_filedescr['mtime'])) {
1317
- $p_header['mtime'] = $p_filedescr['mtime'];
1318
- }
1319
- else if ($p_filedescr['type'] == 'virtual_file') {
1320
- $p_header['mtime'] = time();
1321
- }
1322
- else {
1323
- $p_header['mtime'] = filemtime($p_filename);
1324
- }
1325
- if (isset($p_filedescr['comment'])) {
1326
- $p_header['comment_len'] = strlen($p_filedescr['comment']);
1327
- $p_header['comment'] = $p_filedescr['comment'];
1328
- }
1329
- else {
1330
- $p_header['comment_len'] = 0;
1331
- $p_header['comment'] = '';
1332
- }
1333
- if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
1334
- $v_local_header = array();
1335
- $this->privConvertHeader2FileInfo($p_header, $v_local_header);
1336
- // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');
1337
- $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
1338
- if ($v_result == 0) {
1339
- $p_header['status'] = "skipped";
1340
- $v_result = 1;
1341
- }
1342
- if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
1343
- $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
1344
- }
1345
- }
1346
- if ($p_header['stored_filename'] == "") {
1347
- $p_header['status'] = "filtered";
1348
- }
1349
- if (strlen($p_header['stored_filename']) > 0xFF) {
1350
- $p_header['status'] = 'filename_too_long';
1351
- }
1352
- if ($p_header['status'] == 'ok') {
1353
- if ($p_filedescr['type'] == 'file') {
1354
- if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
1355
- && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
1356
- || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
1357
- && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
1358
- $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
1359
- if ($v_result < PCLZIP_ERR_NO_ERROR) {
1360
- return $v_result;
1361
- }
1362
- }
1363
- else {
1364
- if (($v_file = @fopen($p_filename, "rb")) == 0) {
1365
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
1366
- return PclZip::errorCode();
1367
- }
1368
- $v_content = @fread($v_file, $p_header['size']);
1369
- @fclose($v_file);
1370
- $p_header['crc'] = @crc32($v_content);
1371
- if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
1372
- $p_header['compressed_size'] = $p_header['size'];
1373
- $p_header['compression'] = 0;
1374
- }
1375
- else {
1376
- $v_content = @gzdeflate($v_content);
1377
- $p_header['compressed_size'] = strlen($v_content);
1378
- $p_header['compression'] = 8;
1379
- }
1380
- if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
1381
- @fclose($v_file);
1382
- return $v_result;
1383
- }
1384
- @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
1385
- }
1386
- }
1387
- else if ($p_filedescr['type'] == 'virtual_file') {
1388
- $v_content = $p_filedescr['content'];
1389
- $p_header['crc'] = @crc32($v_content);
1390
- if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
1391
- $p_header['compressed_size'] = $p_header['size'];
1392
- $p_header['compression'] = 0;
1393
- }
1394
- else {
1395
- $v_content = @gzdeflate($v_content);
1396
- $p_header['compressed_size'] = strlen($v_content);
1397
- $p_header['compression'] = 8;
1398
- }
1399
- if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
1400
- @fclose($v_file);
1401
- return $v_result;
1402
- }
1403
- @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
1404
- }
1405
- else if ($p_filedescr['type'] == 'folder') {
1406
- if (@substr($p_header['stored_filename'], -1) != '/') {
1407
- $p_header['stored_filename'] .= '/';
1408
- }
1409
- $p_header['size'] = 0;
1410
- $p_header['external'] = 0x00000010; // Value for a folder : to be checked
1411
- if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
1412
- {
1413
- return $v_result;
1414
- }
1415
- }
1416
- }
1417
- if (isset($p_options[PCLZIP_CB_POST_ADD])) {
1418
- $v_local_header = array();
1419
- $this->privConvertHeader2FileInfo($p_header, $v_local_header);
1420
- // eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');
1421
- $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
1422
- if ($v_result == 0) {
1423
- $v_result = 1;
1424
- }
1425
- }
1426
- return $v_result;
1427
- }
1428
- function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
1429
- {
1430
- $v_result=PCLZIP_ERR_NO_ERROR;
1431
- $p_filename = $p_filedescr['filename'];
1432
- if (($v_file = @fopen($p_filename, "rb")) == 0) {
1433
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
1434
- return PclZip::errorCode();
1435
- }
1436
- $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
1437
- if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
1438
- fclose($v_file);
1439
- PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
1440
- return PclZip::errorCode();
1441
- }
1442
- $v_size = filesize($p_filename);
1443
- while ($v_size != 0) {
1444
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
1445
- $v_buffer = @fread($v_file, $v_read_size);
1446
- @gzputs($v_file_compressed, $v_buffer, $v_read_size);
1447
- $v_size -= $v_read_size;
1448
- }
1449
- @fclose($v_file);
1450
- @gzclose($v_file_compressed);
1451
- if (filesize($v_gzip_temp_name) < 18) {
1452
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
1453
- return PclZip::errorCode();
1454
- }
1455
- if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
1456
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
1457
- return PclZip::errorCode();
1458
- }
1459
- $v_binary_data = @fread($v_file_compressed, 10);
1460
- $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
1461
- $v_data_header['os'] = bin2hex($v_data_header['os']);
1462
- @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
1463
- $v_binary_data = @fread($v_file_compressed, 8);
1464
- $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
1465
- $p_header['compression'] = ord($v_data_header['cm']);
1466
- $p_header['crc'] = $v_data_footer['crc'];
1467
- $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
1468
- @fclose($v_file_compressed);
1469
- if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
1470
- return $v_result;
1471
- }
1472
- if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
1473
- {
1474
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
1475
- return PclZip::errorCode();
1476
- }
1477
- fseek($v_file_compressed, 10);
1478
- $v_size = $p_header['compressed_size'];
1479
- while ($v_size != 0)
1480
- {
1481
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
1482
- $v_buffer = @fread($v_file_compressed, $v_read_size);
1483
- @fwrite($this->zip_fd, $v_buffer, $v_read_size);
1484
- $v_size -= $v_read_size;
1485
- }
1486
- @fclose($v_file_compressed);
1487
- @unlink($v_gzip_temp_name);
1488
- return $v_result;
1489
- }
1490
- function privCalculateStoredFilename(&$p_filedescr, &$p_options)
1491
- {
1492
- $v_result=1;
1493
- $p_filename = $p_filedescr['filename'];
1494
- if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
1495
- $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
1496
- }
1497
- else {
1498
- $p_add_dir = '';
1499
- }
1500
- if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
1501
- $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
1502
- }
1503
- else {
1504
- $p_remove_dir = '';
1505
- }
1506
- if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
1507
- $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
1508
- }
1509
- else {
1510
- $p_remove_all_dir = 0;
1511
- }
1512
- if (isset($p_filedescr['new_full_name'])) {
1513
- $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
1514
- }
1515
- else {
1516
- if (isset($p_filedescr['new_short_name'])) {
1517
- $v_path_info = pathinfo($p_filename);
1518
- $v_dir = '';
1519
- if ($v_path_info['dirname'] != '') {
1520
- $v_dir = $v_path_info['dirname'].'/';
1521
- }
1522
- $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
1523
- }
1524
- else {
1525
- $v_stored_filename = $p_filename;
1526
- }
1527
- if ($p_remove_all_dir) {
1528
- $v_stored_filename = basename($p_filename);
1529
- }
1530
- else if ($p_remove_dir != "") {
1531
- if (substr($p_remove_dir, -1) != '/')
1532
- $p_remove_dir .= "/";
1533
- if ( (substr($p_filename, 0, 2) == "./")
1534
- || (substr($p_remove_dir, 0, 2) == "./")) {
1535
- if ( (substr($p_filename, 0, 2) == "./")
1536
- && (substr($p_remove_dir, 0, 2) != "./")) {
1537
- $p_remove_dir = "./".$p_remove_dir;
1538
- }
1539
- if ( (substr($p_filename, 0, 2) != "./")
1540
- && (substr($p_remove_dir, 0, 2) == "./")) {
1541
- $p_remove_dir = substr($p_remove_dir, 2);
1542
- }
1543
- }
1544
- $v_compare = PclZipUtilPathInclusion($p_remove_dir,
1545
- $v_stored_filename);
1546
- if ($v_compare > 0) {
1547
- if ($v_compare == 2) {
1548
- $v_stored_filename = "";
1549
- }
1550
- else {
1551
- $v_stored_filename = substr($v_stored_filename,
1552
- strlen($p_remove_dir));
1553
- }
1554
- }
1555
- }
1556
- $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
1557
- if ($p_add_dir != "") {
1558
- if (substr($p_add_dir, -1) == "/")
1559
- $v_stored_filename = $p_add_dir.$v_stored_filename;
1560
- else
1561
- $v_stored_filename = $p_add_dir."/".$v_stored_filename;
1562
- }
1563
- }
1564
- $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
1565
- $p_filedescr['stored_filename'] = $v_stored_filename;
1566
- return $v_result;
1567
- }
1568
- function privWriteFileHeader(&$p_header)
1569
- {
1570
- $v_result=1;
1571
- $p_header['offset'] = ftell($this->zip_fd);
1572
- $v_date = getdate($p_header['mtime']);
1573
- $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
1574
- $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
1575
- $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
1576
- $p_header['version_extracted'], $p_header['flag'],
1577
- $p_header['compression'], $v_mtime, $v_mdate,
1578
- $p_header['crc'], $p_header['compressed_size'],
1579
- $p_header['size'],
1580
- strlen($p_header['stored_filename']),
1581
- $p_header['extra_len']);
1582
- fputs($this->zip_fd, $v_binary_data, 30);
1583
- if (strlen($p_header['stored_filename']) != 0)
1584
- {
1585
- fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
1586
- }
1587
- if ($p_header['extra_len'] != 0)
1588
- {
1589
- fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
1590
- }
1591
- return $v_result;
1592
- }
1593
- function privWriteCentralFileHeader(&$p_header)
1594
- {
1595
- $v_result=1;
1596
- $v_date = getdate($p_header['mtime']);
1597
- $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
1598
- $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
1599
- $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
1600
- $p_header['version'], $p_header['version_extracted'],
1601
- $p_header['flag'], $p_header['compression'],
1602
- $v_mtime, $v_mdate, $p_header['crc'],
1603
- $p_header['compressed_size'], $p_header['size'],
1604
- strlen($p_header['stored_filename']),
1605
- $p_header['extra_len'], $p_header['comment_len'],
1606
- $p_header['disk'], $p_header['internal'],
1607
- $p_header['external'], $p_header['offset']);
1608
- fputs($this->zip_fd, $v_binary_data, 46);
1609
- if (strlen($p_header['stored_filename']) != 0)
1610
- {
1611
- fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
1612
- }
1613
- if ($p_header['extra_len'] != 0)
1614
- {
1615
- fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
1616
- }
1617
- if ($p_header['comment_len'] != 0)
1618
- {
1619
- fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
1620
- }
1621
- return $v_result;
1622
- }
1623
- function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
1624
- {
1625
- $v_result=1;
1626
- $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
1627
- $p_nb_entries, $p_size,
1628
- $p_offset, strlen($p_comment));
1629
- fputs($this->zip_fd, $v_binary_data, 22);
1630
- if (strlen($p_comment) != 0)
1631
- {
1632
- fputs($this->zip_fd, $p_comment, strlen($p_comment));
1633
- }
1634
- return $v_result;
1635
- }
1636
- function privList(&$p_list)
1637
- {
1638
- $v_result=1;
1639
- $this->privDisableMagicQuotes();
1640
- if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
1641
- {
1642
- $this->privSwapBackMagicQuotes();
1643
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
1644
- return PclZip::errorCode();
1645
- }
1646
- $v_central_dir = array();
1647
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
1648
- {
1649
- $this->privSwapBackMagicQuotes();
1650
- return $v_result;
1651
- }
1652
- @rewind($this->zip_fd);
1653
- if (@fseek($this->zip_fd, $v_central_dir['offset']))
1654
- {
1655
- $this->privSwapBackMagicQuotes();
1656
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
1657
- return PclZip::errorCode();
1658
- }
1659
- for ($i=0; $i<$v_central_dir['entries']; $i++)
1660
- {
1661
- if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
1662
- {
1663
- $this->privSwapBackMagicQuotes();
1664
- return $v_result;
1665
- }
1666
- $v_header['index'] = $i;
1667
- $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
1668
- unset($v_header);
1669
- }
1670
- $this->privCloseFd();
1671
- $this->privSwapBackMagicQuotes();
1672
- return $v_result;
1673
- }
1674
- function privConvertHeader2FileInfo($p_header, &$p_info)
1675
- {
1676
- $v_result=1;
1677
- $v_temp_path = PclZipUtilPathReduction($p_header['filename']);
1678
- $p_info['filename'] = $v_temp_path;
1679
- $v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']);
1680
- $p_info['stored_filename'] = $v_temp_path;
1681
- $p_info['size'] = $p_header['size'];
1682
- $p_info['compressed_size'] = $p_header['compressed_size'];
1683
- $p_info['mtime'] = $p_header['mtime'];
1684
- $p_info['comment'] = $p_header['comment'];
1685
- $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
1686
- $p_info['index'] = $p_header['index'];
1687
- $p_info['status'] = $p_header['status'];
1688
- $p_info['crc'] = $p_header['crc'];
1689
- return $v_result;
1690
- }
1691
- function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
1692
- {
1693
- $v_result=1;
1694
- $this->privDisableMagicQuotes();
1695
- if ( ($p_path == "")
1696
- || ( (substr($p_path, 0, 1) != "/")
1697
- && (substr($p_path, 0, 3) != "../")
1698
- && (substr($p_path,1,2)!=":/")))
1699
- $p_path = "./".$p_path;
1700
- if (($p_path != "./") && ($p_path != "/"))
1701
- {
1702
- while (substr($p_path, -1) == "/")
1703
- {
1704
- $p_path = substr($p_path, 0, strlen($p_path)-1);
1705
- }
1706
- }
1707
- if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
1708
- {
1709
- $p_remove_path .= '/';
1710
- }
1711
- $p_remove_path_size = strlen($p_remove_path);
1712
- if (($v_result = $this->privOpenFd('rb')) != 1)
1713
- {
1714
- $this->privSwapBackMagicQuotes();
1715
- return $v_result;
1716
- }
1717
- $v_central_dir = array();
1718
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
1719
- {
1720
- $this->privCloseFd();
1721
- $this->privSwapBackMagicQuotes();
1722
- return $v_result;
1723
- }
1724
- $v_pos_entry = $v_central_dir['offset'];
1725
- $j_start = 0;
1726
- for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
1727
- {
1728
- @rewind($this->zip_fd);
1729
- if (@fseek($this->zip_fd, $v_pos_entry))
1730
- {
1731
- $this->privCloseFd();
1732
- $this->privSwapBackMagicQuotes();
1733
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
1734
- return PclZip::errorCode();
1735
- }
1736
- $v_header = array();
1737
- if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
1738
- {
1739
- $this->privCloseFd();
1740
- $this->privSwapBackMagicQuotes();
1741
- return $v_result;
1742
- }
1743
- $v_header['index'] = $i;
1744
- $v_pos_entry = ftell($this->zip_fd);
1745
- $v_extract = false;
1746
- if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
1747
- && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
1748
- for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
1749
- if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
1750
- if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
1751
- && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
1752
- $v_extract = true;
1753
- }
1754
- }
1755
- elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
1756
- $v_extract = true;
1757
- }
1758
- }
1759
- }
1760
- /*
1761
- else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
1762
- && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
1763
- if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
1764
- $v_extract = true;
1765
- }
1766
- }
1767
- */
1768
- else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
1769
- && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
1770
- if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
1771
- $v_extract = true;
1772
- }
1773
- }
1774
- else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
1775
- && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
1776
- for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
1777
- if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
1778
- $v_extract = true;
1779
- }
1780
- if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
1781
- $j_start = $j+1;
1782
- }
1783
- if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
1784
- break;
1785
- }
1786
- }
1787
- }
1788
- else {
1789
- $v_extract = true;
1790
- }
1791
- // ----- Check compression method
1792
- if ( ($v_extract)
1793
- && ( ($v_header['compression'] != 8)
1794
- && ($v_header['compression'] != 0))) {
1795
- $v_header['status'] = 'unsupported_compression';
1796
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
1797
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
1798
- $this->privSwapBackMagicQuotes();
1799
- PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
1800
- "Filename '".$v_header['stored_filename']."' is "
1801
- ."compressed by an unsupported compression "
1802
- ."method (".$v_header['compression'].") ");
1803
- return PclZip::errorCode();
1804
- }
1805
- }
1806
- // ----- Check encrypted files
1807
- if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
1808
- $v_header['status'] = 'unsupported_encryption';
1809
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
1810
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
1811
- $this->privSwapBackMagicQuotes();
1812
- PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
1813
- "Unsupported encryption for "
1814
- ." filename '".$v_header['stored_filename']
1815
- ."'");
1816
- return PclZip::errorCode();
1817
- }
1818
- }
1819
- if (($v_extract) && ($v_header['status'] != 'ok')) {
1820
- $v_result = $this->privConvertHeader2FileInfo($v_header,
1821
- $p_file_list[$v_nb_extracted++]);
1822
- if ($v_result != 1) {
1823
- $this->privCloseFd();
1824
- $this->privSwapBackMagicQuotes();
1825
- return $v_result;
1826
- }
1827
- $v_extract = false;
1828
- }
1829
- if ($v_extract)
1830
- {
1831
- @rewind($this->zip_fd);
1832
- if (@fseek($this->zip_fd, $v_header['offset']))
1833
- {
1834
- $this->privCloseFd();
1835
- $this->privSwapBackMagicQuotes();
1836
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
1837
- return PclZip::errorCode();
1838
- }
1839
- if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
1840
- $v_string = '';
1841
- $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
1842
- if ($v_result1 < 1) {
1843
- $this->privCloseFd();
1844
- $this->privSwapBackMagicQuotes();
1845
- return $v_result1;
1846
- }
1847
- if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
1848
- {
1849
- $this->privCloseFd();
1850
- $this->privSwapBackMagicQuotes();
1851
- return $v_result;
1852
- }
1853
- $p_file_list[$v_nb_extracted]['content'] = $v_string;
1854
- $v_nb_extracted++;
1855
- if ($v_result1 == 2) {
1856
- break;
1857
- }
1858
- }
1859
- elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
1860
- && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
1861
- $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
1862
- if ($v_result1 < 1) {
1863
- $this->privCloseFd();
1864
- $this->privSwapBackMagicQuotes();
1865
- return $v_result1;
1866
- }
1867
- if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
1868
- $this->privCloseFd();
1869
- $this->privSwapBackMagicQuotes();
1870
- return $v_result;
1871
- }
1872
- if ($v_result1 == 2) {
1873
- break;
1874
- }
1875
- }
1876
- else {
1877
- $v_result1 = $this->privExtractFile($v_header,
1878
- $p_path, $p_remove_path,
1879
- $p_remove_all_path,
1880
- $p_options);
1881
- if ($v_result1 < 1) {
1882
- $this->privCloseFd();
1883
- $this->privSwapBackMagicQuotes();
1884
- return $v_result1;
1885
- }
1886
- if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
1887
- {
1888
- $this->privCloseFd();
1889
- $this->privSwapBackMagicQuotes();
1890
- return $v_result;
1891
- }
1892
- if ($v_result1 == 2) {
1893
- break;
1894
- }
1895
- }
1896
- }
1897
- }
1898
- $this->privCloseFd();
1899
- $this->privSwapBackMagicQuotes();
1900
- return $v_result;
1901
- }
1902
- function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
1903
- {
1904
- $v_result=1;
1905
- if (($v_result = $this->privReadFileHeader($v_header)) != 1)
1906
- {
1907
- return $v_result;
1908
- }
1909
- if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
1910
- }
1911
- if ($p_remove_all_path == true) {
1912
- if (($p_entry['external']&0x00000010)==0x00000010) {
1913
- $p_entry['status'] = "filtered";
1914
- return $v_result;
1915
- }
1916
- $p_entry['filename'] = basename($p_entry['filename']);
1917
- }
1918
- else if ($p_remove_path != "")
1919
- {
1920
- if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
1921
- {
1922
- $p_entry['status'] = "filtered";
1923
- return $v_result;
1924
- }
1925
- $p_remove_path_size = strlen($p_remove_path);
1926
- if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
1927
- {
1928
- $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
1929
- }
1930
- }
1931
- if ($p_path != '') {
1932
- $p_entry['filename'] = $p_path."/".$p_entry['filename'];
1933
- }
1934
- if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
1935
- $v_inclusion
1936
- = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
1937
- $p_entry['filename']);
1938
- if ($v_inclusion == 0) {
1939
- PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
1940
- "Filename '".$p_entry['filename']."' is "
1941
- ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
1942
- return PclZip::errorCode();
1943
- }
1944
- }
1945
- if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
1946
- $v_local_header = array();
1947
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
1948
- // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
1949
- $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
1950
- if ($v_result == 0) {
1951
- $p_entry['status'] = "skipped";
1952
- $v_result = 1;
1953
- }
1954
- if ($v_result == 2) {
1955
- $p_entry['status'] = "aborted";
1956
- $v_result = PCLZIP_ERR_USER_ABORTED;
1957
- }
1958
- $p_entry['filename'] = $v_local_header['filename'];
1959
- }
1960
- if ($p_entry['status'] == 'ok') {
1961
- if (file_exists($p_entry['filename']))
1962
- {
1963
- if (is_dir($p_entry['filename']))
1964
- {
1965
- $p_entry['status'] = "already_a_directory";
1966
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
1967
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
1968
- PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
1969
- "Filename '".$p_entry['filename']."' is "
1970
- ."already used by an existing directory");
1971
- return PclZip::errorCode();
1972
- }
1973
- }
1974
- else if (!is_writeable($p_entry['filename']))
1975
- {
1976
- $p_entry['status'] = "write_protected";
1977
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
1978
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
1979
- PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
1980
- "Filename '".$p_entry['filename']."' exists "
1981
- ."and is write protected");
1982
- return PclZip::errorCode();
1983
- }
1984
- }
1985
- else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
1986
- {
1987
- if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
1988
- && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
1989
- }
1990
- else {
1991
- $p_entry['status'] = "newer_exist";
1992
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
1993
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
1994
- PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
1995
- "Newer version of '".$p_entry['filename']."' exists "
1996
- ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
1997
- return PclZip::errorCode();
1998
- }
1999
- }
2000
- }
2001
- else {
2002
- }
2003
- }
2004
- else {
2005
- if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
2006
- $v_dir_to_check = $p_entry['filename'];
2007
- else if (!strstr($p_entry['filename'], "/"))
2008
- $v_dir_to_check = "";
2009
- else
2010
- $v_dir_to_check = dirname($p_entry['filename']);
2011
- if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
2012
- $p_entry['status'] = "path_creation_fail";
2013
- $v_result = 1;
2014
- }
2015
- }
2016
- }
2017
- if ($p_entry['status'] == 'ok') {
2018
- if (!(($p_entry['external']&0x00000010)==0x00000010))
2019
- {
2020
- if ($p_entry['compression'] == 0) {
2021
- // ----- Opening destination file
2022
- if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
2023
- {
2024
- $p_entry['status'] = "write_error";
2025
- return $v_result;
2026
- }
2027
- $v_size = $p_entry['compressed_size'];
2028
- while ($v_size != 0)
2029
- {
2030
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2031
- $v_buffer = @fread($this->zip_fd, $v_read_size);
2032
- /* Try to speed up the code
2033
- $v_binary_data = pack('a'.$v_read_size, $v_buffer);
2034
- @fwrite($v_dest_file, $v_binary_data, $v_read_size);
2035
- */
2036
- @fwrite($v_dest_file, $v_buffer, $v_read_size);
2037
- $v_size -= $v_read_size;
2038
- }
2039
- fclose($v_dest_file);
2040
- touch($p_entry['filename'], $p_entry['mtime']);
2041
- }
2042
- else {
2043
- if (($p_entry['flag'] & 1) == 1) {
2044
- PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
2045
- return PclZip::errorCode();
2046
- }
2047
- if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
2048
- && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
2049
- || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
2050
- && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
2051
- $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
2052
- if ($v_result < PCLZIP_ERR_NO_ERROR) {
2053
- return $v_result;
2054
- }
2055
- }
2056
- else {
2057
- $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
2058
- $v_file_content = @gzinflate($v_buffer);
2059
- unset($v_buffer);
2060
- if ($v_file_content === FALSE) {
2061
- $p_entry['status'] = "error";
2062
- return $v_result;
2063
- }
2064
- if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
2065
- $p_entry['status'] = "write_error";
2066
- return $v_result;
2067
- }
2068
- @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
2069
- unset($v_file_content);
2070
- @fclose($v_dest_file);
2071
- }
2072
- @touch($p_entry['filename'], $p_entry['mtime']);
2073
- }
2074
- if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
2075
- @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
2076
- }
2077
- }
2078
- }
2079
- // ----- Change abort status
2080
- if ($p_entry['status'] == "aborted") {
2081
- $p_entry['status'] = "skipped";
2082
- }
2083
- elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
2084
- $v_local_header = array();
2085
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
2086
- // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
2087
- $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
2088
- if ($v_result == 2) {
2089
- $v_result = PCLZIP_ERR_USER_ABORTED;
2090
- }
2091
- }
2092
- return $v_result;
2093
- }
2094
- function privExtractFileUsingTempFile(&$p_entry, &$p_options)
2095
- {
2096
- $v_result=1;
2097
- $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
2098
- if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
2099
- fclose($v_file);
2100
- PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
2101
- return PclZip::errorCode();
2102
- }
2103
- $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
2104
- @fwrite($v_dest_file, $v_binary_data, 10);
2105
- $v_size = $p_entry['compressed_size'];
2106
- while ($v_size != 0)
2107
- {
2108
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2109
- $v_buffer = @fread($this->zip_fd, $v_read_size);
2110
- @fwrite($v_dest_file, $v_buffer, $v_read_size);
2111
- $v_size -= $v_read_size;
2112
- }
2113
- $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);
2114
- @fwrite($v_dest_file, $v_binary_data, 8);
2115
- @fclose($v_dest_file);
2116
- if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
2117
- $p_entry['status'] = "write_error";
2118
- return $v_result;
2119
- }
2120
- if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
2121
- @fclose($v_dest_file);
2122
- $p_entry['status'] = "read_error";
2123
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2124
- return PclZip::errorCode();
2125
- }
2126
- $v_size = $p_entry['size'];
2127
- while ($v_size != 0) {
2128
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2129
- $v_buffer = @gzread($v_src_file, $v_read_size);
2130
- @fwrite($v_dest_file, $v_buffer, $v_read_size);
2131
- $v_size -= $v_read_size;
2132
- }
2133
- @fclose($v_dest_file);
2134
- @gzclose($v_src_file);
2135
- @unlink($v_gzip_temp_name);
2136
- return $v_result;
2137
- }
2138
- function privExtractFileInOutput(&$p_entry, &$p_options)
2139
- {
2140
- $v_result=1;
2141
- if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
2142
- return $v_result;
2143
- }
2144
- if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
2145
- }
2146
- if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
2147
- $v_local_header = array();
2148
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
2149
- // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
2150
- $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
2151
- if ($v_result == 0) {
2152
- $p_entry['status'] = "skipped";
2153
- $v_result = 1;
2154
- }
2155
- if ($v_result == 2) {
2156
- $p_entry['status'] = "aborted";
2157
- $v_result = PCLZIP_ERR_USER_ABORTED;
2158
- }
2159
- $p_entry['filename'] = $v_local_header['filename'];
2160
- }
2161
- if ($p_entry['status'] == 'ok') {
2162
- if (!(($p_entry['external']&0x00000010)==0x00000010)) {
2163
- if ($p_entry['compressed_size'] == $p_entry['size']) {
2164
- $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
2165
- echo $v_buffer;
2166
- unset($v_buffer);
2167
- }
2168
- else {
2169
- $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
2170
- $v_file_content = gzinflate($v_buffer);
2171
- unset($v_buffer);
2172
- echo $v_file_content;
2173
- unset($v_file_content);
2174
- }
2175
- }
2176
- }
2177
- // ----- Change abort status
2178
- if ($p_entry['status'] == "aborted") {
2179
- $p_entry['status'] = "skipped";
2180
- }
2181
- elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
2182
- $v_local_header = array();
2183
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
2184
- // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
2185
- $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
2186
- if ($v_result == 2) {
2187
- $v_result = PCLZIP_ERR_USER_ABORTED;
2188
- }
2189
- }
2190
- return $v_result;
2191
- }
2192
- function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
2193
- {
2194
- $v_result=1;
2195
- $v_header = array();
2196
- if (($v_result = $this->privReadFileHeader($v_header)) != 1)
2197
- {
2198
- return $v_result;
2199
- }
2200
- if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
2201
- }
2202
- if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
2203
- $v_local_header = array();
2204
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
2205
- // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
2206
- $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
2207
- if ($v_result == 0) {
2208
- $p_entry['status'] = "skipped";
2209
- $v_result = 1;
2210
- }
2211
- if ($v_result == 2) {
2212
- $p_entry['status'] = "aborted";
2213
- $v_result = PCLZIP_ERR_USER_ABORTED;
2214
- }
2215
- $p_entry['filename'] = $v_local_header['filename'];
2216
- }
2217
- if ($p_entry['status'] == 'ok') {
2218
- if (!(($p_entry['external']&0x00000010)==0x00000010)) {
2219
- if ($p_entry['compression'] == 0) {
2220
- $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
2221
- }
2222
- else {
2223
- $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
2224
- if (($p_string = @gzinflate($v_data)) === FALSE) {
2225
- }
2226
- }
2227
- }
2228
- else {
2229
- }
2230
- }
2231
- // ----- Change abort status
2232
- if ($p_entry['status'] == "aborted") {
2233
- $p_entry['status'] = "skipped";
2234
- }
2235
- elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
2236
- $v_local_header = array();
2237
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
2238
- $v_local_header['content'] = $p_string;
2239
- $p_string = '';
2240
- // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
2241
- $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
2242
- $p_string = $v_local_header['content'];
2243
- unset($v_local_header['content']);
2244
- if ($v_result == 2) {
2245
- $v_result = PCLZIP_ERR_USER_ABORTED;
2246
- }
2247
- }
2248
- return $v_result;
2249
- }
2250
- function privReadFileHeader(&$p_header)
2251
- {
2252
- $v_result=1;
2253
- $v_binary_data = @fread($this->zip_fd, 4);
2254
- $v_data = unpack('Vid', $v_binary_data);
2255
- if ($v_data['id'] != 0x04034b50)
2256
- {
2257
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
2258
- return PclZip::errorCode();
2259
- }
2260
- $v_binary_data = fread($this->zip_fd, 26);
2261
- if (strlen($v_binary_data) != 26)
2262
- {
2263
- $p_header['filename'] = "";
2264
- $p_header['status'] = "invalid_header";
2265
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
2266
- return PclZip::errorCode();
2267
- }
2268
- $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
2269
- $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
2270
- if ($v_data['extra_len'] != 0) {
2271
- $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
2272
- }
2273
- else {
2274
- $p_header['extra'] = '';
2275
- }
2276
- $p_header['version_extracted'] = $v_data['version'];
2277
- $p_header['compression'] = $v_data['compression'];
2278
- $p_header['size'] = $v_data['size'];
2279
- $p_header['compressed_size'] = $v_data['compressed_size'];
2280
- $p_header['crc'] = $v_data['crc'];
2281
- $p_header['flag'] = $v_data['flag'];
2282
- $p_header['filename_len'] = $v_data['filename_len'];
2283
- $p_header['mdate'] = $v_data['mdate'];
2284
- $p_header['mtime'] = $v_data['mtime'];
2285
- if ($p_header['mdate'] && $p_header['mtime'])
2286
- {
2287
- $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
2288
- $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
2289
- $v_seconde = ($p_header['mtime'] & 0x001F)*2;
2290
- $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
2291
- $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
2292
- $v_day = $p_header['mdate'] & 0x001F;
2293
- $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
2294
- }
2295
- else
2296
- {
2297
- $p_header['mtime'] = time();
2298
- }
2299
- $p_header['stored_filename'] = $p_header['filename'];
2300
- $p_header['status'] = "ok";
2301
- return $v_result;
2302
- }
2303
- function privReadCentralFileHeader(&$p_header)
2304
- {
2305
- $v_result=1;
2306
- $v_binary_data = @fread($this->zip_fd, 4);
2307
- $v_data = unpack('Vid', $v_binary_data);
2308
- if ($v_data['id'] != 0x02014b50)
2309
- {
2310
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
2311
- return PclZip::errorCode();
2312
- }
2313
- $v_binary_data = fread($this->zip_fd, 42);
2314
- if (strlen($v_binary_data) != 42)
2315
- {
2316
- $p_header['filename'] = "";
2317
- $p_header['status'] = "invalid_header";
2318
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
2319
- return PclZip::errorCode();
2320
- }
2321
- $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
2322
- if ($p_header['filename_len'] != 0)
2323
- $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
2324
- else
2325
- $p_header['filename'] = '';
2326
- if ($p_header['extra_len'] != 0)
2327
- $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
2328
- else
2329
- $p_header['extra'] = '';
2330
- if ($p_header['comment_len'] != 0)
2331
- $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
2332
- else
2333
- $p_header['comment'] = '';
2334
- if (1)
2335
- {
2336
- $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
2337
- $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
2338
- $v_seconde = ($p_header['mtime'] & 0x001F)*2;
2339
- $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
2340
- $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
2341
- $v_day = $p_header['mdate'] & 0x001F;
2342
- $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
2343
- }
2344
- else
2345
- {
2346
- $p_header['mtime'] = time();
2347
- }
2348
- $p_header['stored_filename'] = $p_header['filename'];
2349
- $p_header['status'] = 'ok';
2350
- if (substr($p_header['filename'], -1) == '/') {
2351
- $p_header['external'] = 0x00000010;
2352
- }
2353
- return $v_result;
2354
- }
2355
- function privCheckFileHeaders(&$p_local_header, &$p_central_header)
2356
- {
2357
- $v_result=1;
2358
- // ----- Check the static values
2359
- // TBC
2360
- if ($p_local_header['filename'] != $p_central_header['filename']) {
2361
- }
2362
- if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
2363
- }
2364
- if ($p_local_header['flag'] != $p_central_header['flag']) {
2365
- }
2366
- if ($p_local_header['compression'] != $p_central_header['compression']) {
2367
- }
2368
- if ($p_local_header['mtime'] != $p_central_header['mtime']) {
2369
- }
2370
- if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
2371
- }
2372
- // ----- Look for flag bit 3
2373
- if (($p_local_header['flag'] & 8) == 8) {
2374
- $p_local_header['size'] = $p_central_header['size'];
2375
- $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
2376
- $p_local_header['crc'] = $p_central_header['crc'];
2377
- }
2378
- return $v_result;
2379
- }
2380
- function privReadEndCentralDir(&$p_central_dir)
2381
- {
2382
- $v_result=1;
2383
- $v_size = filesize($this->zipname);
2384
- @fseek($this->zip_fd, $v_size);
2385
- if (@ftell($this->zip_fd) != $v_size)
2386
- {
2387
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
2388
- return PclZip::errorCode();
2389
- }
2390
- $v_found = 0;
2391
- if ($v_size > 26) {
2392
- @fseek($this->zip_fd, $v_size-22);
2393
- if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
2394
- {
2395
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
2396
- return PclZip::errorCode();
2397
- }
2398
- $v_binary_data = @fread($this->zip_fd, 4);
2399
- $v_data = @unpack('Vid', $v_binary_data);
2400
- if ($v_data['id'] == 0x06054b50) {
2401
- $v_found = 1;
2402
- }
2403
- $v_pos = ftell($this->zip_fd);
2404
- }
2405
- if (!$v_found) {
2406
- $v_maximum_size = 65557; // 0xFFFF + 22;
2407
- if ($v_maximum_size > $v_size)
2408
- $v_maximum_size = $v_size;
2409
- @fseek($this->zip_fd, $v_size-$v_maximum_size);
2410
- if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
2411
- {
2412
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
2413
- return PclZip::errorCode();
2414
- }
2415
- $v_pos = ftell($this->zip_fd);
2416
- $v_bytes = 0x00000000;
2417
- while ($v_pos < $v_size)
2418
- {
2419
- $v_byte = @fread($this->zip_fd, 1);
2420
- $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
2421
- if ($v_bytes == 0x504b0506)
2422
- {
2423
- $v_pos++;
2424
- break;
2425
- }
2426
- $v_pos++;
2427
- }
2428
- if ($v_pos == $v_size)
2429
- {
2430
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
2431
- return PclZip::errorCode();
2432
- }
2433
- }
2434
- $v_binary_data = fread($this->zip_fd, 18);
2435
- if (strlen($v_binary_data) != 18)
2436
- {
2437
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
2438
- return PclZip::errorCode();
2439
- }
2440
- $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
2441
- if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
2442
- // ----- Removed in release 2.2 see readme file
2443
- // The check of the file size is a little too strict.
2444
- // Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
2445
- // While decrypted, zip has training 0 bytes
2446
- if (0) {
2447
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
2448
- 'The central dir is not at the end of the archive.'
2449
- .' Some trailing bytes exists after the archive.');
2450
- return PclZip::errorCode();
2451
- }
2452
- }
2453
- if ($v_data['comment_size'] != 0) {
2454
- $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
2455
- }
2456
- else
2457
- $p_central_dir['comment'] = '';
2458
- $p_central_dir['entries'] = $v_data['entries'];
2459
- $p_central_dir['disk_entries'] = $v_data['disk_entries'];
2460
- $p_central_dir['offset'] = $v_data['offset'];
2461
- $p_central_dir['size'] = $v_data['size'];
2462
- $p_central_dir['disk'] = $v_data['disk'];
2463
- $p_central_dir['disk_start'] = $v_data['disk_start'];
2464
- return $v_result;
2465
- }
2466
- function privDeleteByRule(&$p_result_list, &$p_options)
2467
- {
2468
- $v_result=1;
2469
- $v_list_detail = array();
2470
- if (($v_result=$this->privOpenFd('rb')) != 1)
2471
- {
2472
- return $v_result;
2473
- }
2474
- $v_central_dir = array();
2475
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
2476
- {
2477
- $this->privCloseFd();
2478
- return $v_result;
2479
- }
2480
- @rewind($this->zip_fd);
2481
- $v_pos_entry = $v_central_dir['offset'];
2482
- @rewind($this->zip_fd);
2483
- if (@fseek($this->zip_fd, $v_pos_entry))
2484
- {
2485
- $this->privCloseFd();
2486
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
2487
- return PclZip::errorCode();
2488
- }
2489
- $v_header_list = array();
2490
- $j_start = 0;
2491
- for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
2492
- {
2493
- $v_header_list[$v_nb_extracted] = array();
2494
- if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
2495
- {
2496
- $this->privCloseFd();
2497
- return $v_result;
2498
- }
2499
- $v_header_list[$v_nb_extracted]['index'] = $i;
2500
- $v_found = false;
2501
- if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
2502
- && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
2503
- for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
2504
- if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
2505
- if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
2506
- && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
2507
- $v_found = true;
2508
- }
2509
- elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
2510
- && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
2511
- $v_found = true;
2512
- }
2513
- }
2514
- elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
2515
- $v_found = true;
2516
- }
2517
- }
2518
- }
2519
- /*
2520
- else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
2521
- && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
2522
- if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
2523
- $v_found = true;
2524
- }
2525
- }
2526
- */
2527
- else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
2528
- && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
2529
- if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
2530
- $v_found = true;
2531
- }
2532
- }
2533
- else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
2534
- && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
2535
- for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
2536
- if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
2537
- $v_found = true;
2538
- }
2539
- if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
2540
- $j_start = $j+1;
2541
- }
2542
- if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
2543
- break;
2544
- }
2545
- }
2546
- }
2547
- else {
2548
- $v_found = true;
2549
- }
2550
- if ($v_found)
2551
- {
2552
- unset($v_header_list[$v_nb_extracted]);
2553
- }
2554
- else
2555
- {
2556
- $v_nb_extracted++;
2557
- }
2558
- }
2559
- if ($v_nb_extracted > 0) {
2560
- $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
2561
- $v_temp_zip = new PclZip($v_zip_temp_name);
2562
- if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
2563
- $this->privCloseFd();
2564
- return $v_result;
2565
- }
2566
- for ($i=0; $i<sizeof($v_header_list); $i++) {
2567
- @rewind($this->zip_fd);
2568
- if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) {
2569
- $this->privCloseFd();
2570
- $v_temp_zip->privCloseFd();
2571
- @unlink($v_zip_temp_name);
2572
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
2573
- return PclZip::errorCode();
2574
- }
2575
- $v_local_header = array();
2576
- if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
2577
- $this->privCloseFd();
2578
- $v_temp_zip->privCloseFd();
2579
- @unlink($v_zip_temp_name);
2580
- return $v_result;
2581
- }
2582
- if ($this->privCheckFileHeaders($v_local_header,
2583
- $v_header_list[$i]) != 1) {
2584
- }
2585
- unset($v_local_header);
2586
- if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
2587
- $this->privCloseFd();
2588
- $v_temp_zip->privCloseFd();
2589
- @unlink($v_zip_temp_name);
2590
- return $v_result;
2591
- }
2592
- if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
2593
- $this->privCloseFd();
2594
- $v_temp_zip->privCloseFd();
2595
- @unlink($v_zip_temp_name);
2596
- return $v_result;
2597
- }
2598
- }
2599
- $v_offset = @ftell($v_temp_zip->zip_fd);
2600
- for ($i=0; $i<sizeof($v_header_list); $i++) {
2601
- if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2602
- $v_temp_zip->privCloseFd();
2603
- $this->privCloseFd();
2604
- @unlink($v_zip_temp_name);
2605
- return $v_result;
2606
- }
2607
- $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2608
- }
2609
- $v_comment = '';
2610
- if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2611
- $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2612
- }
2613
- $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
2614
- if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
2615
- unset($v_header_list);
2616
- $v_temp_zip->privCloseFd();
2617
- $this->privCloseFd();
2618
- @unlink($v_zip_temp_name);
2619
- return $v_result;
2620
- }
2621
- $v_temp_zip->privCloseFd();
2622
- $this->privCloseFd();
2623
- @unlink($this->zipname);
2624
- PclZipUtilRename($v_zip_temp_name, $this->zipname);
2625
- unset($v_temp_zip);
2626
- }
2627
- else if ($v_central_dir['entries'] != 0) {
2628
- $this->privCloseFd();
2629
- if (($v_result = $this->privOpenFd('wb')) != 1) {
2630
- return $v_result;
2631
- }
2632
- if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
2633
- return $v_result;
2634
- }
2635
- $this->privCloseFd();
2636
- }
2637
- return $v_result;
2638
- }
2639
- function privDirCheck($p_dir, $p_is_dir=false)
2640
- {
2641
- $v_result = 1;
2642
- if (($p_is_dir) && (substr($p_dir, -1)=='/'))
2643
- {
2644
- $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
2645
- }
2646
- if ((is_dir($p_dir)) || ($p_dir == ""))
2647
- {
2648
- return 1;
2649
- }
2650
- $p_parent_dir = dirname($p_dir);
2651
- if ($p_parent_dir != $p_dir)
2652
- {
2653
- if ($p_parent_dir != "")
2654
- {
2655
- if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
2656
- {
2657
- return $v_result;
2658
- }
2659
- }
2660
- }
2661
- if (!@mkdir($p_dir, 0777))
2662
- {
2663
- PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
2664
- return PclZip::errorCode();
2665
- }
2666
- return $v_result;
2667
- }
2668
- function privMerge(&$p_archive_to_add)
2669
- {
2670
- $v_result=1;
2671
- if (!is_file($p_archive_to_add->zipname))
2672
- {
2673
- $v_result = 1;
2674
- return $v_result;
2675
- }
2676
- if (!is_file($this->zipname))
2677
- {
2678
- $v_result = $this->privDuplicate($p_archive_to_add->zipname);
2679
- return $v_result;
2680
- }
2681
- if (($v_result=$this->privOpenFd('rb')) != 1)
2682
- {
2683
- return $v_result;
2684
- }
2685
- $v_central_dir = array();
2686
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
2687
- {
2688
- $this->privCloseFd();
2689
- return $v_result;
2690
- }
2691
- @rewind($this->zip_fd);
2692
- if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
2693
- {
2694
- $this->privCloseFd();
2695
- return $v_result;
2696
- }
2697
- $v_central_dir_to_add = array();
2698
- if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
2699
- {
2700
- $this->privCloseFd();
2701
- $p_archive_to_add->privCloseFd();
2702
- return $v_result;
2703
- }
2704
- @rewind($p_archive_to_add->zip_fd);
2705
- $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
2706
- if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
2707
- {
2708
- $this->privCloseFd();
2709
- $p_archive_to_add->privCloseFd();
2710
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
2711
- return PclZip::errorCode();
2712
- }
2713
- $v_size = $v_central_dir['offset'];
2714
- while ($v_size != 0)
2715
- {
2716
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2717
- $v_buffer = fread($this->zip_fd, $v_read_size);
2718
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2719
- $v_size -= $v_read_size;
2720
- }
2721
- $v_size = $v_central_dir_to_add['offset'];
2722
- while ($v_size != 0)
2723
- {
2724
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2725
- $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
2726
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2727
- $v_size -= $v_read_size;
2728
- }
2729
- $v_offset = @ftell($v_zip_temp_fd);
2730
- $v_size = $v_central_dir['size'];
2731
- while ($v_size != 0)
2732
- {
2733
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2734
- $v_buffer = @fread($this->zip_fd, $v_read_size);
2735
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2736
- $v_size -= $v_read_size;
2737
- }
2738
- $v_size = $v_central_dir_to_add['size'];
2739
- while ($v_size != 0)
2740
- {
2741
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2742
- $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
2743
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2744
- $v_size -= $v_read_size;
2745
- }
2746
- $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
2747
- $v_size = @ftell($v_zip_temp_fd)-$v_offset;
2748
- $v_swap = $this->zip_fd;
2749
- $this->zip_fd = $v_zip_temp_fd;
2750
- $v_zip_temp_fd = $v_swap;
2751
- if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
2752
- {
2753
- $this->privCloseFd();
2754
- $p_archive_to_add->privCloseFd();
2755
- @fclose($v_zip_temp_fd);
2756
- $this->zip_fd = null;
2757
- unset($v_header_list);
2758
- return $v_result;
2759
- }
2760
- $v_swap = $this->zip_fd;
2761
- $this->zip_fd = $v_zip_temp_fd;
2762
- $v_zip_temp_fd = $v_swap;
2763
- $this->privCloseFd();
2764
- $p_archive_to_add->privCloseFd();
2765
- @fclose($v_zip_temp_fd);
2766
- @unlink($this->zipname);
2767
- PclZipUtilRename($v_zip_temp_name, $this->zipname);
2768
- return $v_result;
2769
- }
2770
- function privDuplicate($p_archive_filename)
2771
- {
2772
- $v_result=1;
2773
- if (!is_file($p_archive_filename))
2774
- {
2775
- $v_result = 1;
2776
- return $v_result;
2777
- }
2778
- if (($v_result=$this->privOpenFd('wb')) != 1)
2779
- {
2780
- return $v_result;
2781
- }
2782
- if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
2783
- {
2784
- $this->privCloseFd();
2785
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
2786
- return PclZip::errorCode();
2787
- }
2788
- $v_size = filesize($p_archive_filename);
2789
- while ($v_size != 0)
2790
- {
2791
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2792
- $v_buffer = fread($v_zip_temp_fd, $v_read_size);
2793
- @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2794
- $v_size -= $v_read_size;
2795
- }
2796
- $this->privCloseFd();
2797
- @fclose($v_zip_temp_fd);
2798
- return $v_result;
2799
- }
2800
- function privErrorLog($p_error_code=0, $p_error_string='')
2801
- {
2802
- if (PCLZIP_ERROR_EXTERNAL == 1) {
2803
- PclError($p_error_code, $p_error_string);
2804
- }
2805
- else {
2806
- $this->error_code = $p_error_code;
2807
- $this->error_string = $p_error_string;
2808
- }
2809
- }
2810
- function privErrorReset()
2811
- {
2812
- if (PCLZIP_ERROR_EXTERNAL == 1) {
2813
- PclErrorReset();
2814
- }
2815
- else {
2816
- $this->error_code = 0;
2817
- $this->error_string = '';
2818
- }
2819
- }
2820
- function privDisableMagicQuotes()
2821
- {
2822
- $v_result=1;
2823
- if ( (!function_exists("get_magic_quotes_runtime"))
2824
- || (!function_exists("set_magic_quotes_runtime"))) {
2825
- return $v_result;
2826
- }
2827
-
2828
- if (version_compare(phpversion(), '7.0', '>=')) {
2829
- return $v_result;
2830
- }
2831
- if ($this->magic_quotes_status != -1) {
2832
- return $v_result;
2833
- }
2834
- // ----- Get and memorize the magic_quote value
2835
- $this->magic_quotes_status = @get_magic_quotes_runtime();
2836
- // ----- Disable magic_quotes
2837
- if ($this->magic_quotes_status == 1) {
2838
- @set_magic_quotes_runtime(0);
2839
- }
2840
- return $v_result;
2841
- }
2842
- function privSwapBackMagicQuotes()
2843
- {
2844
- $v_result=1;
2845
- if ( (!function_exists("get_magic_quotes_runtime"))
2846
- || (!function_exists("set_magic_quotes_runtime"))) {
2847
- return $v_result;
2848
- }
2849
-
2850
- if (version_compare(phpversion(), '7.0', '>=')) {
2851
- return $v_result;
2852
- }
2853
-
2854
- if ($this->magic_quotes_status != -1) {
2855
- return $v_result;
2856
- }
2857
- // ----- Swap back magic_quotes
2858
- if ($this->magic_quotes_status == 1) {
2859
- @set_magic_quotes_runtime($this->magic_quotes_status);
2860
- }
2861
- return $v_result;
2862
- }
2863
- }
2864
- function PclZipUtilPathReduction($p_dir)
2865
- {
2866
- $v_result = "";
2867
- if ($p_dir != "") {
2868
- $v_list = explode("/", $p_dir);
2869
- $v_skip = 0;
2870
- for ($i=sizeof($v_list)-1; $i>=0; $i--) {
2871
- if ($v_list[$i] == ".") {
2872
- }
2873
- else if ($v_list[$i] == "..") {
2874
- $v_skip++;
2875
- }
2876
- else if ($v_list[$i] == "") {
2877
- // ----- First '/' i.e. root slash
2878
- if ($i == 0) {
2879
- $v_result = "/".$v_result;
2880
- if ($v_skip > 0) {
2881
- // ----- It is an invalid path, so the path is not modified
2882
- // TBC
2883
- $v_result = $p_dir;
2884
- $v_skip = 0;
2885
- }
2886
- }
2887
- // ----- Last '/' i.e. indicates a directory
2888
- else if ($i == (sizeof($v_list)-1)) {
2889
- $v_result = $v_list[$i];
2890
- }
2891
- // ----- Double '/' inside the path
2892
- else {
2893
- }
2894
- }
2895
- else {
2896
- // ----- Look for item to skip
2897
- if ($v_skip > 0) {
2898
- $v_skip--;
2899
- }
2900
- else {
2901
- $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
2902
- }
2903
- }
2904
- }
2905
- if ($v_skip > 0) {
2906
- while ($v_skip > 0) {
2907
- $v_result = '../'.$v_result;
2908
- $v_skip--;
2909
- }
2910
- }
2911
- }
2912
- return $v_result;
2913
- }
2914
- function PclZipUtilPathInclusion($p_dir, $p_path)
2915
- {
2916
- $v_result = 1;
2917
- if ( ($p_dir == '.')
2918
- || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
2919
- $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
2920
- }
2921
- if ( ($p_path == '.')
2922
- || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
2923
- $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
2924
- }
2925
- $v_list_dir = explode("/", $p_dir);
2926
- $v_list_dir_size = sizeof($v_list_dir);
2927
- $v_list_path = explode("/", $p_path);
2928
- $v_list_path_size = sizeof($v_list_path);
2929
- $i = 0;
2930
- $j = 0;
2931
- while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
2932
- if ($v_list_dir[$i] == '') {
2933
- $i++;
2934
- continue;
2935
- }
2936
- if ($v_list_path[$j] == '') {
2937
- $j++;
2938
- continue;
2939
- }
2940
- if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) {
2941
- $v_result = 0;
2942
- }
2943
- $i++;
2944
- $j++;
2945
- }
2946
- if ($v_result) {
2947
- while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
2948
- while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
2949
- if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
2950
- $v_result = 2;
2951
- }
2952
- else if ($i < $v_list_dir_size) {
2953
- $v_result = 0;
2954
- }
2955
- }
2956
- return $v_result;
2957
- }
2958
- function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
2959
- {
2960
- $v_result = 1;
2961
- if ($p_mode==0)
2962
- {
2963
- while ($p_size != 0)
2964
- {
2965
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
2966
- $v_buffer = @fread($p_src, $v_read_size);
2967
- @fwrite($p_dest, $v_buffer, $v_read_size);
2968
- $p_size -= $v_read_size;
2969
- }
2970
- }
2971
- else if ($p_mode==1)
2972
- {
2973
- while ($p_size != 0)
2974
- {
2975
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
2976
- $v_buffer = @gzread($p_src, $v_read_size);
2977
- @fwrite($p_dest, $v_buffer, $v_read_size);
2978
- $p_size -= $v_read_size;
2979
- }
2980
- }
2981
- else if ($p_mode==2)
2982
- {
2983
- while ($p_size != 0)
2984
- {
2985
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
2986
- $v_buffer = @fread($p_src, $v_read_size);
2987
- @gzwrite($p_dest, $v_buffer, $v_read_size);
2988
- $p_size -= $v_read_size;
2989
- }
2990
- }
2991
- else if ($p_mode==3)
2992
- {
2993
- while ($p_size != 0)
2994
- {
2995
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
2996
- $v_buffer = @gzread($p_src, $v_read_size);
2997
- @gzwrite($p_dest, $v_buffer, $v_read_size);
2998
- $p_size -= $v_read_size;
2999
- }
3000
- }
3001
- return $v_result;
3002
- }
3003
- function PclZipUtilRename($p_src, $p_dest)
3004
- {
3005
- $v_result = 1;
3006
- if (!@rename($p_src, $p_dest)) {
3007
- if (!@copy($p_src, $p_dest)) {
3008
- $v_result = 0;
3009
- }
3010
- else if (!@unlink($p_src)) {
3011
- $v_result = 0;
3012
- }
3013
- }
3014
- return $v_result;
3015
- }
3016
- function PclZipUtilOptionText($p_option)
3017
- {
3018
- $v_list = get_defined_constants();
3019
- for (reset($v_list); $v_key = key($v_list); next($v_list)) {
3020
- $v_prefix = substr($v_key, 0, 10);
3021
- if (( ($v_prefix == 'PCLZIP_OPT')
3022
- || ($v_prefix == 'PCLZIP_CB_')
3023
- || ($v_prefix == 'PCLZIP_ATT'))
3024
- && ($v_list[$v_key] == $p_option)) {
3025
- return $v_key;
3026
- }
3027
- }
3028
- $v_result = 'Unknown';
3029
- return $v_result;
3030
- }
3031
- function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
3032
- {
3033
- if (stristr(php_uname(), 'windows')) {
3034
- if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
3035
- $p_path = substr($p_path, $v_position+1);
3036
- }
3037
- if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
3038
- $p_path = strtr($p_path, '\\', '/');
3039
- }
3040
- }
3041
- return $p_path;
3042
- }
3043
- ?>
1
+ <?php
2
+ if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
3
+ define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
4
+ }
5
+ if (!defined('PCLZIP_SEPARATOR')) {
6
+ define( 'PCLZIP_SEPARATOR', ',' );
7
+ }
8
+ if (!defined('PCLZIP_ERROR_EXTERNAL')) {
9
+ define( 'PCLZIP_ERROR_EXTERNAL', 0 );
10
+ }
11
+ if (!defined('PCLZIP_TEMPORARY_DIR')) {
12
+ define( 'PCLZIP_TEMPORARY_DIR', '' );
13
+ }
14
+ if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
15
+ define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
16
+ }
17
+ // --------------------------------------------------------------------------------
18
+ // ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
19
+ // --------------------------------------------------------------------------------
20
+ $g_pclzip_version = "2.8.2";
21
+ define( 'PCLZIP_ERR_USER_ABORTED', 2 );
22
+ define( 'PCLZIP_ERR_NO_ERROR', 0 );
23
+ define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
24
+ define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );
25
+ define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );
26
+ define( 'PCLZIP_ERR_MISSING_FILE', -4 );
27
+ define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
28
+ define( 'PCLZIP_ERR_INVALID_ZIP', -6 );
29
+ define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
30
+ define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
31
+ define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );
32
+ define( 'PCLZIP_ERR_BAD_FORMAT', -10 );
33
+ define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
34
+ define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
35
+ define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );
36
+ define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
37
+ define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
38
+ define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
39
+ define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 );
40
+ define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 );
41
+ define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
42
+ define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 );
43
+ define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 );
44
+ define( 'PCLZIP_OPT_PATH', 77001 );
45
+ define( 'PCLZIP_OPT_ADD_PATH', 77002 );
46
+ define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );
47
+ define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
48
+ define( 'PCLZIP_OPT_SET_CHMOD', 77005 );
49
+ define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
50
+ define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );
51
+ define( 'PCLZIP_OPT_BY_NAME', 77008 );
52
+ define( 'PCLZIP_OPT_BY_INDEX', 77009 );
53
+ define( 'PCLZIP_OPT_BY_EREG', 77010 );
54
+ define( 'PCLZIP_OPT_BY_PREG', 77011 );
55
+ define( 'PCLZIP_OPT_COMMENT', 77012 );
56
+ define( 'PCLZIP_OPT_ADD_COMMENT', 77013 );
57
+ define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 );
58
+ define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
59
+ define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 );
60
+ define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 );
61
+ define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
62
+ define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 );
63
+ define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias
64
+ define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 );
65
+ define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
66
+ define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
67
+ define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
68
+ define( 'PCLZIP_ATT_FILE_NAME', 79001 );
69
+ define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
70
+ define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
71
+ define( 'PCLZIP_ATT_FILE_MTIME', 79004 );
72
+ define( 'PCLZIP_ATT_FILE_CONTENT', 79005 );
73
+ define( 'PCLZIP_ATT_FILE_COMMENT', 79006 );
74
+ define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
75
+ define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
76
+ define( 'PCLZIP_CB_PRE_ADD', 78003 );
77
+ define( 'PCLZIP_CB_POST_ADD', 78004 );
78
+ /* For futur use
79
+ define( 'PCLZIP_CB_PRE_LIST', 78005 );
80
+ define( 'PCLZIP_CB_POST_LIST', 78006 );
81
+ define( 'PCLZIP_CB_PRE_DELETE', 78007 );
82
+ define( 'PCLZIP_CB_POST_DELETE', 78008 );
83
+ */
84
+ class PclZip
85
+ {
86
+ var $zipname = '';
87
+ var $zip_fd = 0;
88
+ var $error_code = 1;
89
+ var $error_string = '';
90
+ var $magic_quotes_status;
91
+ function PclZip($p_zipname)
92
+ {
93
+ if (!function_exists('gzopen'))
94
+ {
95
+ die('Abort '.basename(__FILE__).' : Missing zlib extensions');
96
+ }
97
+ $this->zipname = $p_zipname;
98
+ $this->zip_fd = 0;
99
+ $this->magic_quotes_status = -1;
100
+ return;
101
+ }
102
+ function create($p_filelist)
103
+ {
104
+ $v_result=1;
105
+ $this->privErrorReset();
106
+ $v_options = array();
107
+ $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
108
+ $v_size = func_num_args();
109
+ if ($v_size > 1) {
110
+ $v_arg_list = func_get_args();
111
+ array_shift($v_arg_list);
112
+ $v_size--;
113
+ if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
114
+ $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
115
+ array (PCLZIP_OPT_REMOVE_PATH => 'optional',
116
+ PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
117
+ PCLZIP_OPT_ADD_PATH => 'optional',
118
+ PCLZIP_CB_PRE_ADD => 'optional',
119
+ PCLZIP_CB_POST_ADD => 'optional',
120
+ PCLZIP_OPT_NO_COMPRESSION => 'optional',
121
+ PCLZIP_OPT_COMMENT => 'optional',
122
+ PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
123
+ PCLZIP_OPT_TEMP_FILE_ON => 'optional',
124
+ PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
125
+ ));
126
+ if ($v_result != 1) {
127
+ return 0;
128
+ }
129
+ }
130
+ else {
131
+ $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
132
+ if ($v_size == 2) {
133
+ $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
134
+ }
135
+ else if ($v_size > 2) {
136
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
137
+ "Invalid number / type of arguments");
138
+ return 0;
139
+ }
140
+ }
141
+ }
142
+ $this->privOptionDefaultThreshold($v_options);
143
+ $v_string_list = array();
144
+ $v_att_list = array();
145
+ $v_filedescr_list = array();
146
+ $p_result_list = array();
147
+ if (is_array($p_filelist)) {
148
+ if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
149
+ $v_att_list = $p_filelist;
150
+ }
151
+ else {
152
+ $v_string_list = $p_filelist;
153
+ }
154
+ }
155
+ else if (is_string($p_filelist)) {
156
+ $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
157
+ }
158
+ else {
159
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
160
+ return 0;
161
+ }
162
+ if (sizeof($v_string_list) != 0) {
163
+ foreach ($v_string_list as $v_string) {
164
+ if ($v_string != '') {
165
+ $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
166
+ }
167
+ else {
168
+ }
169
+ }
170
+ }
171
+ $v_supported_attributes
172
+ = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
173
+ ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
174
+ ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
175
+ ,PCLZIP_ATT_FILE_MTIME => 'optional'
176
+ ,PCLZIP_ATT_FILE_CONTENT => 'optional'
177
+ ,PCLZIP_ATT_FILE_COMMENT => 'optional'
178
+ );
179
+ foreach ($v_att_list as $v_entry) {
180
+ $v_result = $this->privFileDescrParseAtt($v_entry,
181
+ $v_filedescr_list[],
182
+ $v_options,
183
+ $v_supported_attributes);
184
+ if ($v_result != 1) {
185
+ return 0;
186
+ }
187
+ }
188
+ $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
189
+ if ($v_result != 1) {
190
+ return 0;
191
+ }
192
+ $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
193
+ if ($v_result != 1) {
194
+ return 0;
195
+ }
196
+ return $p_result_list;
197
+ }
198
+ function add($p_filelist)
199
+ {
200
+ $v_result=1;
201
+ $this->privErrorReset();
202
+ $v_options = array();
203
+ $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
204
+ $v_size = func_num_args();
205
+ if ($v_size > 1) {
206
+ $v_arg_list = func_get_args();
207
+ array_shift($v_arg_list);
208
+ $v_size--;
209
+ if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
210
+ $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
211
+ array (PCLZIP_OPT_REMOVE_PATH => 'optional',
212
+ PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
213
+ PCLZIP_OPT_ADD_PATH => 'optional',
214
+ PCLZIP_CB_PRE_ADD => 'optional',
215
+ PCLZIP_CB_POST_ADD => 'optional',
216
+ PCLZIP_OPT_NO_COMPRESSION => 'optional',
217
+ PCLZIP_OPT_COMMENT => 'optional',
218
+ PCLZIP_OPT_ADD_COMMENT => 'optional',
219
+ PCLZIP_OPT_PREPEND_COMMENT => 'optional',
220
+ PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
221
+ PCLZIP_OPT_TEMP_FILE_ON => 'optional',
222
+ PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
223
+ ));
224
+ if ($v_result != 1) {
225
+ return 0;
226
+ }
227
+ }
228
+ else {
229
+ $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
230
+ if ($v_size == 2) {
231
+ $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
232
+ }
233
+ else if ($v_size > 2) {
234
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
235
+ return 0;
236
+ }
237
+ }
238
+ }
239
+ $this->privOptionDefaultThreshold($v_options);
240
+ $v_string_list = array();
241
+ $v_att_list = array();
242
+ $v_filedescr_list = array();
243
+ $p_result_list = array();
244
+ if (is_array($p_filelist)) {
245
+ if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
246
+ $v_att_list = $p_filelist;
247
+ }
248
+ else {
249
+ $v_string_list = $p_filelist;
250
+ }
251
+ }
252
+ else if (is_string($p_filelist)) {
253
+ $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
254
+ }
255
+ else {
256
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
257
+ return 0;
258
+ }
259
+ if (sizeof($v_string_list) != 0) {
260
+ foreach ($v_string_list as $v_string) {
261
+ $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
262
+ }
263
+ }
264
+ $v_supported_attributes
265
+ = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
266
+ ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
267
+ ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
268
+ ,PCLZIP_ATT_FILE_MTIME => 'optional'
269
+ ,PCLZIP_ATT_FILE_CONTENT => 'optional'
270
+ ,PCLZIP_ATT_FILE_COMMENT => 'optional'
271
+ );
272
+ foreach ($v_att_list as $v_entry) {
273
+ $v_result = $this->privFileDescrParseAtt($v_entry,
274
+ $v_filedescr_list[],
275
+ $v_options,
276
+ $v_supported_attributes);
277
+ if ($v_result != 1) {
278
+ return 0;
279
+ }
280
+ }
281
+ $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
282
+ if ($v_result != 1) {
283
+ return 0;
284
+ }
285
+ $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
286
+ if ($v_result != 1) {
287
+ return 0;
288
+ }
289
+ return $p_result_list;
290
+ }
291
+ function listContent()
292
+ {
293
+ $v_result=1;
294
+ $this->privErrorReset();
295
+ if (!$this->privCheckFormat()) {
296
+ return(0);
297
+ }
298
+ $p_list = array();
299
+ if (($v_result = $this->privList($p_list)) != 1)
300
+ {
301
+ unset($p_list);
302
+ return(0);
303
+ }
304
+ return $p_list;
305
+ }
306
+ function extract()
307
+ {
308
+ $v_result=1;
309
+ $this->privErrorReset();
310
+ if (!$this->privCheckFormat()) {
311
+ return(0);
312
+ }
313
+ $v_options = array();
314
+ // $v_path = "./";
315
+ $v_path = '';
316
+ $v_remove_path = "";
317
+ $v_remove_all_path = false;
318
+ $v_size = func_num_args();
319
+ $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
320
+ if ($v_size > 0) {
321
+ $v_arg_list = func_get_args();
322
+ if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
323
+ $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
324
+ array (PCLZIP_OPT_PATH => 'optional',
325
+ PCLZIP_OPT_REMOVE_PATH => 'optional',
326
+ PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
327
+ PCLZIP_OPT_ADD_PATH => 'optional',
328
+ PCLZIP_CB_PRE_EXTRACT => 'optional',
329
+ PCLZIP_CB_POST_EXTRACT => 'optional',
330
+ PCLZIP_OPT_SET_CHMOD => 'optional',
331
+ PCLZIP_OPT_BY_NAME => 'optional',
332
+ PCLZIP_OPT_BY_EREG => 'optional',
333
+ PCLZIP_OPT_BY_PREG => 'optional',
334
+ PCLZIP_OPT_BY_INDEX => 'optional',
335
+ PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
336
+ PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
337
+ PCLZIP_OPT_REPLACE_NEWER => 'optional'
338
+ ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
339
+ ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
340
+ PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
341
+ PCLZIP_OPT_TEMP_FILE_ON => 'optional',
342
+ PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
343
+ ));
344
+ if ($v_result != 1) {
345
+ return 0;
346
+ }
347
+ if (isset($v_options[PCLZIP_OPT_PATH])) {
348
+ $v_path = $v_options[PCLZIP_OPT_PATH];
349
+ }
350
+ if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
351
+ $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
352
+ }
353
+ if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
354
+ $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
355
+ }
356
+ if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
357
+ if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
358
+ $v_path .= '/';
359
+ }
360
+ $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
361
+ }
362
+ }
363
+ else {
364
+ $v_path = $v_arg_list[0];
365
+ if ($v_size == 2) {
366
+ $v_remove_path = $v_arg_list[1];
367
+ }
368
+ else if ($v_size > 2) {
369
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
370
+ return 0;
371
+ }
372
+ }
373
+ }
374
+ $this->privOptionDefaultThreshold($v_options);
375
+ $p_list = array();
376
+ $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path,
377
+ $v_remove_all_path, $v_options);
378
+ if ($v_result < 1) {
379
+ unset($p_list);
380
+ return(0);
381
+ }
382
+ return $p_list;
383
+ }
384
+ function extractByIndex($p_index)
385
+ {
386
+ $v_result=1;
387
+ $this->privErrorReset();
388
+ if (!$this->privCheckFormat()) {
389
+ return(0);
390
+ }
391
+ $v_options = array();
392
+ // $v_path = "./";
393
+ $v_path = '';
394
+ $v_remove_path = "";
395
+ $v_remove_all_path = false;
396
+ $v_size = func_num_args();
397
+ $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
398
+ if ($v_size > 1) {
399
+ $v_arg_list = func_get_args();
400
+ array_shift($v_arg_list);
401
+ $v_size--;
402
+ if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
403
+ $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
404
+ array (PCLZIP_OPT_PATH => 'optional',
405
+ PCLZIP_OPT_REMOVE_PATH => 'optional',
406
+ PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
407
+ PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
408
+ PCLZIP_OPT_ADD_PATH => 'optional',
409
+ PCLZIP_CB_PRE_EXTRACT => 'optional',
410
+ PCLZIP_CB_POST_EXTRACT => 'optional',
411
+ PCLZIP_OPT_SET_CHMOD => 'optional',
412
+ PCLZIP_OPT_REPLACE_NEWER => 'optional'
413
+ ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
414
+ ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
415
+ PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
416
+ PCLZIP_OPT_TEMP_FILE_ON => 'optional',
417
+ PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
418
+ ));
419
+ if ($v_result != 1) {
420
+ return 0;
421
+ }
422
+ if (isset($v_options[PCLZIP_OPT_PATH])) {
423
+ $v_path = $v_options[PCLZIP_OPT_PATH];
424
+ }
425
+ if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
426
+ $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
427
+ }
428
+ if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
429
+ $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
430
+ }
431
+ if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
432
+ if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
433
+ $v_path .= '/';
434
+ }
435
+ $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
436
+ }
437
+ if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
438
+ $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
439
+ }
440
+ else {
441
+ }
442
+ }
443
+ else {
444
+ $v_path = $v_arg_list[0];
445
+ if ($v_size == 2) {
446
+ $v_remove_path = $v_arg_list[1];
447
+ }
448
+ else if ($v_size > 2) {
449
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
450
+ return 0;
451
+ }
452
+ }
453
+ }
454
+ $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
455
+ $v_options_trick = array();
456
+ $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
457
+ array (PCLZIP_OPT_BY_INDEX => 'optional' ));
458
+ if ($v_result != 1) {
459
+ return 0;
460
+ }
461
+ $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
462
+ $this->privOptionDefaultThreshold($v_options);
463
+ if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
464
+ return(0);
465
+ }
466
+ return $p_list;
467
+ }
468
+ function delete()
469
+ {
470
+ $v_result=1;
471
+ $this->privErrorReset();
472
+ if (!$this->privCheckFormat()) {
473
+ return(0);
474
+ }
475
+ $v_options = array();
476
+ $v_size = func_num_args();
477
+ if ($v_size > 0) {
478
+ $v_arg_list = func_get_args();
479
+ $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
480
+ array (PCLZIP_OPT_BY_NAME => 'optional',
481
+ PCLZIP_OPT_BY_EREG => 'optional',
482
+ PCLZIP_OPT_BY_PREG => 'optional',
483
+ PCLZIP_OPT_BY_INDEX => 'optional' ));
484
+ if ($v_result != 1) {
485
+ return 0;
486
+ }
487
+ }
488
+ $this->privDisableMagicQuotes();
489
+ $v_list = array();
490
+ if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
491
+ $this->privSwapBackMagicQuotes();
492
+ unset($v_list);
493
+ return(0);
494
+ }
495
+ $this->privSwapBackMagicQuotes();
496
+ return $v_list;
497
+ }
498
+ function deleteByIndex($p_index)
499
+ {
500
+ $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
501
+ return $p_list;
502
+ }
503
+ function properties()
504
+ {
505
+ $this->privErrorReset();
506
+ $this->privDisableMagicQuotes();
507
+ if (!$this->privCheckFormat()) {
508
+ $this->privSwapBackMagicQuotes();
509
+ return(0);
510
+ }
511
+ $v_prop = array();
512
+ $v_prop['comment'] = '';
513
+ $v_prop['nb'] = 0;
514
+ $v_prop['status'] = 'not_exist';
515
+ if (@is_file($this->zipname))
516
+ {
517
+ if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
518
+ {
519
+ $this->privSwapBackMagicQuotes();
520
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
521
+ return 0;
522
+ }
523
+ $v_central_dir = array();
524
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
525
+ {
526
+ $this->privSwapBackMagicQuotes();
527
+ return 0;
528
+ }
529
+ $this->privCloseFd();
530
+ $v_prop['comment'] = $v_central_dir['comment'];
531
+ $v_prop['nb'] = $v_central_dir['entries'];
532
+ $v_prop['status'] = 'ok';
533
+ }
534
+ $this->privSwapBackMagicQuotes();
535
+ return $v_prop;
536
+ }
537
+ function duplicate($p_archive)
538
+ {
539
+ $v_result = 1;
540
+ $this->privErrorReset();
541
+ if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
542
+ {
543
+ $v_result = $this->privDuplicate($p_archive->zipname);
544
+ }
545
+ else if (is_string($p_archive))
546
+ {
547
+ if (!is_file($p_archive)) {
548
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
549
+ $v_result = PCLZIP_ERR_MISSING_FILE;
550
+ }
551
+ else {
552
+ $v_result = $this->privDuplicate($p_archive);
553
+ }
554
+ }
555
+ else
556
+ {
557
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
558
+ $v_result = PCLZIP_ERR_INVALID_PARAMETER;
559
+ }
560
+ return $v_result;
561
+ }
562
+ function merge($p_archive_to_add)
563
+ {
564
+ $v_result = 1;
565
+ $this->privErrorReset();
566
+ if (!$this->privCheckFormat()) {
567
+ return(0);
568
+ }
569
+ if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
570
+ {
571
+ $v_result = $this->privMerge($p_archive_to_add);
572
+ }
573
+ else if (is_string($p_archive_to_add))
574
+ {
575
+ $v_object_archive = new PclZip($p_archive_to_add);
576
+ $v_result = $this->privMerge($v_object_archive);
577
+ }
578
+ else
579
+ {
580
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
581
+ $v_result = PCLZIP_ERR_INVALID_PARAMETER;
582
+ }
583
+ return $v_result;
584
+ }
585
+ function errorCode()
586
+ {
587
+ if (PCLZIP_ERROR_EXTERNAL == 1) {
588
+ return(PclErrorCode());
589
+ }
590
+ else {
591
+ return($this->error_code);
592
+ }
593
+ }
594
+ function errorName($p_with_code=false)
595
+ {
596
+ $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
597
+ PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
598
+ PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
599
+ PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
600
+ PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
601
+ PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
602
+ PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
603
+ PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
604
+ PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
605
+ PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
606
+ PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
607
+ PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
608
+ PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
609
+ PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
610
+ PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
611
+ PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
612
+ PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
613
+ PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
614
+ PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
615
+ ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
616
+ ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
617
+ );
618
+ if (isset($v_name[$this->error_code])) {
619
+ $v_value = $v_name[$this->error_code];
620
+ }
621
+ else {
622
+ $v_value = 'NoName';
623
+ }
624
+ if ($p_with_code) {
625
+ return($v_value.' ('.$this->error_code.')');
626
+ }
627
+ else {
628
+ return($v_value);
629
+ }
630
+ }
631
+ function errorInfo($p_full=false)
632
+ {
633
+ if (PCLZIP_ERROR_EXTERNAL == 1) {
634
+ return(PclErrorString());
635
+ }
636
+ else {
637
+ if ($p_full) {
638
+ return($this->errorName(true)." : ".$this->error_string);
639
+ }
640
+ else {
641
+ return($this->error_string." [code ".$this->error_code."]");
642
+ }
643
+ }
644
+ }
645
+ // --------------------------------------------------------------------------------
646
+ // ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS *****
647
+ // ***** *****
648
+ // ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY *****
649
+ // --------------------------------------------------------------------------------
650
+ function privCheckFormat($p_level=0)
651
+ {
652
+ $v_result = true;
653
+ // ----- Reset the file system cache
654
+ clearstatcache();
655
+ $this->privErrorReset();
656
+ if (!is_file($this->zipname)) {
657
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
658
+ return(false);
659
+ }
660
+ if (!is_readable($this->zipname)) {
661
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
662
+ return(false);
663
+ }
664
+ return $v_result;
665
+ }
666
+ function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
667
+ {
668
+ $v_result=1;
669
+ $i=0;
670
+ while ($i<$p_size) {
671
+ if (!isset($v_requested_options[$p_options_list[$i]])) {
672
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
673
+ return PclZip::errorCode();
674
+ }
675
+ switch ($p_options_list[$i]) {
676
+ case PCLZIP_OPT_PATH :
677
+ case PCLZIP_OPT_REMOVE_PATH :
678
+ case PCLZIP_OPT_ADD_PATH :
679
+ if (($i+1) >= $p_size) {
680
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
681
+ return PclZip::errorCode();
682
+ }
683
+ $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
684
+ $i++;
685
+ break;
686
+ case PCLZIP_OPT_TEMP_FILE_THRESHOLD :
687
+ if (($i+1) >= $p_size) {
688
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
689
+ return PclZip::errorCode();
690
+ }
691
+ if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
692
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
693
+ return PclZip::errorCode();
694
+ }
695
+ $v_value = $p_options_list[$i+1];
696
+ if ((!is_integer($v_value)) || ($v_value<0)) {
697
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
698
+ return PclZip::errorCode();
699
+ }
700
+ $v_result_list[$p_options_list[$i]] = $v_value*1048576;
701
+ $i++;
702
+ break;
703
+ case PCLZIP_OPT_TEMP_FILE_ON :
704
+ if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
705
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
706
+ return PclZip::errorCode();
707
+ }
708
+ $v_result_list[$p_options_list[$i]] = true;
709
+ break;
710
+ case PCLZIP_OPT_TEMP_FILE_OFF :
711
+ if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
712
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
713
+ return PclZip::errorCode();
714
+ }
715
+ if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
716
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
717
+ return PclZip::errorCode();
718
+ }
719
+ $v_result_list[$p_options_list[$i]] = true;
720
+ break;
721
+ case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
722
+ if (($i+1) >= $p_size) {
723
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
724
+ return PclZip::errorCode();
725
+ }
726
+ if ( is_string($p_options_list[$i+1])
727
+ && ($p_options_list[$i+1] != '')) {
728
+ $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
729
+ $i++;
730
+ }
731
+ else {
732
+ }
733
+ break;
734
+ case PCLZIP_OPT_BY_NAME :
735
+ if (($i+1) >= $p_size) {
736
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
737
+ return PclZip::errorCode();
738
+ }
739
+ if (is_string($p_options_list[$i+1])) {
740
+ $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
741
+ }
742
+ else if (is_array($p_options_list[$i+1])) {
743
+ $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
744
+ }
745
+ else {
746
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
747
+ return PclZip::errorCode();
748
+ }
749
+ $i++;
750
+ break;
751
+ case PCLZIP_OPT_BY_EREG :
752
+ $p_options_list[$i] = PCLZIP_OPT_BY_PREG;
753
+ case PCLZIP_OPT_BY_PREG :
754
+ if (($i+1) >= $p_size) {
755
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
756
+ return PclZip::errorCode();
757
+ }
758
+ if (is_string($p_options_list[$i+1])) {
759
+ $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
760
+ }
761
+ else {
762
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
763
+ return PclZip::errorCode();
764
+ }
765
+ $i++;
766
+ break;
767
+ case PCLZIP_OPT_COMMENT :
768
+ case PCLZIP_OPT_ADD_COMMENT :
769
+ case PCLZIP_OPT_PREPEND_COMMENT :
770
+ if (($i+1) >= $p_size) {
771
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
772
+ "Missing parameter value for option '"
773
+ .PclZipUtilOptionText($p_options_list[$i])
774
+ ."'");
775
+ return PclZip::errorCode();
776
+ }
777
+ if (is_string($p_options_list[$i+1])) {
778
+ $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
779
+ }
780
+ else {
781
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
782
+ "Wrong parameter value for option '"
783
+ .PclZipUtilOptionText($p_options_list[$i])
784
+ ."'");
785
+ return PclZip::errorCode();
786
+ }
787
+ $i++;
788
+ break;
789
+ case PCLZIP_OPT_BY_INDEX :
790
+ if (($i+1) >= $p_size) {
791
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
792
+ return PclZip::errorCode();
793
+ }
794
+ $v_work_list = array();
795
+ if (is_string($p_options_list[$i+1])) {
796
+ $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
797
+ $v_work_list = explode(",", $p_options_list[$i+1]);
798
+ }
799
+ else if (is_integer($p_options_list[$i+1])) {
800
+ $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
801
+ }
802
+ else if (is_array($p_options_list[$i+1])) {
803
+ $v_work_list = $p_options_list[$i+1];
804
+ }
805
+ else {
806
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
807
+ return PclZip::errorCode();
808
+ }
809
+ $v_sort_flag=false;
810
+ $v_sort_value=0;
811
+ for ($j=0; $j<sizeof($v_work_list); $j++) {
812
+ $v_item_list = explode("-", $v_work_list[$j]);
813
+ $v_size_item_list = sizeof($v_item_list);
814
+ if ($v_size_item_list == 1) {
815
+ $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
816
+ $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
817
+ }
818
+ elseif ($v_size_item_list == 2) {
819
+ $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
820
+ $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
821
+ }
822
+ else {
823
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
824
+ return PclZip::errorCode();
825
+ }
826
+ if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
827
+ $v_sort_flag=true;
828
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
829
+ return PclZip::errorCode();
830
+ }
831
+ $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
832
+ }
833
+ if ($v_sort_flag) {
834
+ }
835
+ $i++;
836
+ break;
837
+ case PCLZIP_OPT_REMOVE_ALL_PATH :
838
+ case PCLZIP_OPT_EXTRACT_AS_STRING :
839
+ case PCLZIP_OPT_NO_COMPRESSION :
840
+ case PCLZIP_OPT_EXTRACT_IN_OUTPUT :
841
+ case PCLZIP_OPT_REPLACE_NEWER :
842
+ case PCLZIP_OPT_STOP_ON_ERROR :
843
+ $v_result_list[$p_options_list[$i]] = true;
844
+ break;
845
+ case PCLZIP_OPT_SET_CHMOD :
846
+ if (($i+1) >= $p_size) {
847
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
848
+ return PclZip::errorCode();
849
+ }
850
+ $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
851
+ $i++;
852
+ break;
853
+ case PCLZIP_CB_PRE_EXTRACT :
854
+ case PCLZIP_CB_POST_EXTRACT :
855
+ case PCLZIP_CB_PRE_ADD :
856
+ case PCLZIP_CB_POST_ADD :
857
+ /* for futur use
858
+ case PCLZIP_CB_PRE_DELETE :
859
+ case PCLZIP_CB_POST_DELETE :
860
+ case PCLZIP_CB_PRE_LIST :
861
+ case PCLZIP_CB_POST_LIST :
862
+ */
863
+ if (($i+1) >= $p_size) {
864
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
865
+ return PclZip::errorCode();
866
+ }
867
+ $v_function_name = $p_options_list[$i+1];
868
+ if (!function_exists($v_function_name)) {
869
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
870
+ return PclZip::errorCode();
871
+ }
872
+ $v_result_list[$p_options_list[$i]] = $v_function_name;
873
+ $i++;
874
+ break;
875
+ default :
876
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
877
+ "Unknown parameter '"
878
+ .$p_options_list[$i]."'");
879
+ return PclZip::errorCode();
880
+ }
881
+ $i++;
882
+ }
883
+ if ($v_requested_options !== false) {
884
+ for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
885
+ if ($v_requested_options[$key] == 'mandatory') {
886
+ if (!isset($v_result_list[$key])) {
887
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
888
+ return PclZip::errorCode();
889
+ }
890
+ }
891
+ }
892
+ }
893
+ if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
894
+ }
895
+ return $v_result;
896
+ }
897
+ function privOptionDefaultThreshold(&$p_options)
898
+ {
899
+ $v_result=1;
900
+ if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
901
+ || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
902
+ return $v_result;
903
+ }
904
+ $v_memory_limit = ini_get('memory_limit');
905
+ $v_memory_limit = trim($v_memory_limit);
906
+ $last = strtolower(substr($v_memory_limit, -1));
907
+ if($last == 'g')
908
+ $v_memory_limit = $v_memory_limit*1073741824;
909
+ if($last == 'm')
910
+ $v_memory_limit = $v_memory_limit*1048576;
911
+ if($last == 'k')
912
+ $v_memory_limit = $v_memory_limit*1024;
913
+ $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
914
+ if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
915
+ unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
916
+ }
917
+ return $v_result;
918
+ }
919
+ function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
920
+ {
921
+ $v_result=1;
922
+ foreach ($p_file_list as $v_key => $v_value) {
923
+ if (!isset($v_requested_options[$v_key])) {
924
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
925
+ return PclZip::errorCode();
926
+ }
927
+ switch ($v_key) {
928
+ case PCLZIP_ATT_FILE_NAME :
929
+ if (!is_string($v_value)) {
930
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
931
+ return PclZip::errorCode();
932
+ }
933
+ $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
934
+ if ($p_filedescr['filename'] == '') {
935
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
936
+ return PclZip::errorCode();
937
+ }
938
+ break;
939
+ case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
940
+ if (!is_string($v_value)) {
941
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
942
+ return PclZip::errorCode();
943
+ }
944
+ $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
945
+ if ($p_filedescr['new_short_name'] == '') {
946
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
947
+ return PclZip::errorCode();
948
+ }
949
+ break;
950
+ case PCLZIP_ATT_FILE_NEW_FULL_NAME :
951
+ if (!is_string($v_value)) {
952
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
953
+ return PclZip::errorCode();
954
+ }
955
+ $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
956
+ if ($p_filedescr['new_full_name'] == '') {
957
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
958
+ return PclZip::errorCode();
959
+ }
960
+ break;
961
+ case PCLZIP_ATT_FILE_COMMENT :
962
+ if (!is_string($v_value)) {
963
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
964
+ return PclZip::errorCode();
965
+ }
966
+ $p_filedescr['comment'] = $v_value;
967
+ break;
968
+ case PCLZIP_ATT_FILE_MTIME :
969
+ if (!is_integer($v_value)) {
970
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
971
+ return PclZip::errorCode();
972
+ }
973
+ $p_filedescr['mtime'] = $v_value;
974
+ break;
975
+ case PCLZIP_ATT_FILE_CONTENT :
976
+ $p_filedescr['content'] = $v_value;
977
+ break;
978
+ default :
979
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
980
+ "Unknown parameter '".$v_key."'");
981
+ return PclZip::errorCode();
982
+ }
983
+ if ($v_requested_options !== false) {
984
+ for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
985
+ if ($v_requested_options[$key] == 'mandatory') {
986
+ if (!isset($p_file_list[$key])) {
987
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
988
+ return PclZip::errorCode();
989
+ }
990
+ }
991
+ }
992
+ }
993
+ }
994
+ return $v_result;
995
+ }
996
+ function privFileDescrExpand(&$p_filedescr_list, &$p_options)
997
+ {
998
+ $v_result=1;
999
+ $v_result_list = array();
1000
+ for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
1001
+ $v_descr = $p_filedescr_list[$i];
1002
+ $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
1003
+ $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
1004
+ if (file_exists($v_descr['filename'])) {
1005
+ if (@is_file($v_descr['filename'])) {
1006
+ $v_descr['type'] = 'file';
1007
+ }
1008
+ else if (@is_dir($v_descr['filename'])) {
1009
+ $v_descr['type'] = 'folder';
1010
+ }
1011
+ else if (@is_link($v_descr['filename'])) {
1012
+ continue;
1013
+ }
1014
+ else {
1015
+ continue;
1016
+ }
1017
+ }
1018
+ else if (isset($v_descr['content'])) {
1019
+ $v_descr['type'] = 'virtual_file';
1020
+ }
1021
+ else {
1022
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
1023
+ return PclZip::errorCode();
1024
+ }
1025
+ $this->privCalculateStoredFilename($v_descr, $p_options);
1026
+ $v_result_list[sizeof($v_result_list)] = $v_descr;
1027
+ if ($v_descr['type'] == 'folder') {
1028
+ $v_dirlist_descr = array();
1029
+ $v_dirlist_nb = 0;
1030
+ if ($v_folder_handler = @opendir($v_descr['filename'])) {
1031
+ while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
1032
+ if (($v_item_handler == '.') || ($v_item_handler == '..')) {
1033
+ continue;
1034
+ }
1035
+ $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
1036
+ if (($v_descr['stored_filename'] != $v_descr['filename'])
1037
+ && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
1038
+ if ($v_descr['stored_filename'] != '') {
1039
+ $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
1040
+ }
1041
+ else {
1042
+ $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
1043
+ }
1044
+ }
1045
+ $v_dirlist_nb++;
1046
+ }
1047
+ @closedir($v_folder_handler);
1048
+ }
1049
+ else {
1050
+ }
1051
+ if ($v_dirlist_nb != 0) {
1052
+ if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
1053
+ return $v_result;
1054
+ }
1055
+ $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
1056
+ }
1057
+ else {
1058
+ }
1059
+ unset($v_dirlist_descr);
1060
+ }
1061
+ }
1062
+ $p_filedescr_list = $v_result_list;
1063
+ return $v_result;
1064
+ }
1065
+ function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
1066
+ {
1067
+ $v_result=1;
1068
+ $v_list_detail = array();
1069
+ $this->privDisableMagicQuotes();
1070
+ if (($v_result = $this->privOpenFd('wb')) != 1)
1071
+ {
1072
+ return $v_result;
1073
+ }
1074
+ $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
1075
+ $this->privCloseFd();
1076
+ $this->privSwapBackMagicQuotes();
1077
+ return $v_result;
1078
+ }
1079
+ function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
1080
+ {
1081
+ $v_result=1;
1082
+ $v_list_detail = array();
1083
+ if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
1084
+ {
1085
+ $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
1086
+ return $v_result;
1087
+ }
1088
+ $this->privDisableMagicQuotes();
1089
+ if (($v_result=$this->privOpenFd('rb')) != 1)
1090
+ {
1091
+ $this->privSwapBackMagicQuotes();
1092
+ return $v_result;
1093
+ }
1094
+ $v_central_dir = array();
1095
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
1096
+ {
1097
+ $this->privCloseFd();
1098
+ $this->privSwapBackMagicQuotes();
1099
+ return $v_result;
1100
+ }
1101
+ @rewind($this->zip_fd);
1102
+ $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
1103
+ if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
1104
+ {
1105
+ $this->privCloseFd();
1106
+ $this->privSwapBackMagicQuotes();
1107
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
1108
+ return PclZip::errorCode();
1109
+ }
1110
+ $v_size = $v_central_dir['offset'];
1111
+ while ($v_size != 0)
1112
+ {
1113
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
1114
+ $v_buffer = fread($this->zip_fd, $v_read_size);
1115
+ @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
1116
+ $v_size -= $v_read_size;
1117
+ }
1118
+ $v_swap = $this->zip_fd;
1119
+ $this->zip_fd = $v_zip_temp_fd;
1120
+ $v_zip_temp_fd = $v_swap;
1121
+ $v_header_list = array();
1122
+ if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
1123
+ {
1124
+ fclose($v_zip_temp_fd);
1125
+ $this->privCloseFd();
1126
+ @unlink($v_zip_temp_name);
1127
+ $this->privSwapBackMagicQuotes();
1128
+ return $v_result;
1129
+ }
1130
+ $v_offset = @ftell($this->zip_fd);
1131
+ $v_size = $v_central_dir['size'];
1132
+ while ($v_size != 0)
1133
+ {
1134
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
1135
+ $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
1136
+ @fwrite($this->zip_fd, $v_buffer, $v_read_size);
1137
+ $v_size -= $v_read_size;
1138
+ }
1139
+ for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
1140
+ {
1141
+ if ($v_header_list[$i]['status'] == 'ok') {
1142
+ if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
1143
+ fclose($v_zip_temp_fd);
1144
+ $this->privCloseFd();
1145
+ @unlink($v_zip_temp_name);
1146
+ $this->privSwapBackMagicQuotes();
1147
+ return $v_result;
1148
+ }
1149
+ $v_count++;
1150
+ }
1151
+ $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
1152
+ }
1153
+ $v_comment = $v_central_dir['comment'];
1154
+ if (isset($p_options[PCLZIP_OPT_COMMENT])) {
1155
+ $v_comment = $p_options[PCLZIP_OPT_COMMENT];
1156
+ }
1157
+ if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
1158
+ $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
1159
+ }
1160
+ if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
1161
+ $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
1162
+ }
1163
+ $v_size = @ftell($this->zip_fd)-$v_offset;
1164
+ if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
1165
+ {
1166
+ unset($v_header_list);
1167
+ $this->privSwapBackMagicQuotes();
1168
+ return $v_result;
1169
+ }
1170
+ $v_swap = $this->zip_fd;
1171
+ $this->zip_fd = $v_zip_temp_fd;
1172
+ $v_zip_temp_fd = $v_swap;
1173
+ $this->privCloseFd();
1174
+ @fclose($v_zip_temp_fd);
1175
+ $this->privSwapBackMagicQuotes();
1176
+ @unlink($this->zipname);
1177
+ PclZipUtilRename($v_zip_temp_name, $this->zipname);
1178
+ return $v_result;
1179
+ }
1180
+ function privOpenFd($p_mode)
1181
+ {
1182
+ $v_result=1;
1183
+ if ($this->zip_fd != 0)
1184
+ {
1185
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
1186
+ return PclZip::errorCode();
1187
+ }
1188
+ if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
1189
+ {
1190
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
1191
+ return PclZip::errorCode();
1192
+ }
1193
+ return $v_result;
1194
+ }
1195
+ function privCloseFd()
1196
+ {
1197
+ $v_result=1;
1198
+ if ($this->zip_fd != 0)
1199
+ @fclose($this->zip_fd);
1200
+ $this->zip_fd = 0;
1201
+ return $v_result;
1202
+ }
1203
+ // function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
1204
+ function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
1205
+ {
1206
+ $v_result=1;
1207
+ $v_header_list = array();
1208
+ if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
1209
+ {
1210
+ return $v_result;
1211
+ }
1212
+ $v_offset = @ftell($this->zip_fd);
1213
+ for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
1214
+ {
1215
+ if ($v_header_list[$i]['status'] == 'ok') {
1216
+ if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
1217
+ return $v_result;
1218
+ }
1219
+ $v_count++;
1220
+ }
1221
+ $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
1222
+ }
1223
+ $v_comment = '';
1224
+ if (isset($p_options[PCLZIP_OPT_COMMENT])) {
1225
+ $v_comment = $p_options[PCLZIP_OPT_COMMENT];
1226
+ }
1227
+ $v_size = @ftell($this->zip_fd)-$v_offset;
1228
+ if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
1229
+ {
1230
+ unset($v_header_list);
1231
+ return $v_result;
1232
+ }
1233
+ return $v_result;
1234
+ }
1235
+ function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
1236
+ {
1237
+ $v_result=1;
1238
+ $v_header = array();
1239
+ $v_nb = sizeof($p_result_list);
1240
+ for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
1241
+ $p_filedescr_list[$j]['filename']
1242
+ = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
1243
+ if ($p_filedescr_list[$j]['filename'] == "") {
1244
+ continue;
1245
+ }
1246
+ if ( ($p_filedescr_list[$j]['type'] != 'virtual_file')
1247
+ && (!file_exists($p_filedescr_list[$j]['filename']))) {
1248
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
1249
+ return PclZip::errorCode();
1250
+ }
1251
+ // if ( (is_file($p_filedescr_list[$j]['filename']))
1252
+ // || ( is_dir($p_filedescr_list[$j]['filename'])
1253
+ if ( ($p_filedescr_list[$j]['type'] == 'file')
1254
+ || ($p_filedescr_list[$j]['type'] == 'virtual_file')
1255
+ || ( ($p_filedescr_list[$j]['type'] == 'folder')
1256
+ && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
1257
+ || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
1258
+ ) {
1259
+ $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
1260
+ $p_options);
1261
+ if ($v_result != 1) {
1262
+ return $v_result;
1263
+ }
1264
+ $p_result_list[$v_nb++] = $v_header;
1265
+ }
1266
+ }
1267
+ return $v_result;
1268
+ }
1269
+ function privAddFile($p_filedescr, &$p_header, &$p_options)
1270
+ {
1271
+ $v_result=1;
1272
+ $p_filename = $p_filedescr['filename'];
1273
+ if ($p_filename == "") {
1274
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
1275
+ return PclZip::errorCode();
1276
+ }
1277
+ /* TBC : Removed
1278
+ if (isset($p_filedescr['stored_filename'])) {
1279
+ $v_stored_filename = $p_filedescr['stored_filename'];
1280
+ }
1281
+ else {
1282
+ $v_stored_filename = $p_filedescr['stored_filename'];
1283
+ }
1284
+ */
1285
+ clearstatcache();
1286
+ $p_header['version'] = 20;
1287
+ $p_header['version_extracted'] = 10;
1288
+ $p_header['flag'] = 0;
1289
+ $p_header['compression'] = 0;
1290
+ $p_header['crc'] = 0;
1291
+ $p_header['compressed_size'] = 0;
1292
+ $p_header['filename_len'] = strlen($p_filename);
1293
+ $p_header['extra_len'] = 0;
1294
+ $p_header['disk'] = 0;
1295
+ $p_header['internal'] = 0;
1296
+ $p_header['offset'] = 0;
1297
+ $p_header['filename'] = $p_filename;
1298
+ // TBC : Removed $p_header['stored_filename'] = $v_stored_filename;
1299
+ $p_header['stored_filename'] = $p_filedescr['stored_filename'];
1300
+ $p_header['extra'] = '';
1301
+ $p_header['status'] = 'ok';
1302
+ $p_header['index'] = -1;
1303
+ if ($p_filedescr['type']=='file') {
1304
+ $p_header['external'] = 0x00000000;
1305
+ $p_header['size'] = filesize($p_filename);
1306
+ }
1307
+ else if ($p_filedescr['type']=='folder') {
1308
+ $p_header['external'] = 0x00000010;
1309
+ $p_header['mtime'] = filemtime($p_filename);
1310
+ $p_header['size'] = filesize($p_filename);
1311
+ }
1312
+ else if ($p_filedescr['type'] == 'virtual_file') {
1313
+ $p_header['external'] = 0x00000000;
1314
+ $p_header['size'] = strlen($p_filedescr['content']);
1315
+ }
1316
+ if (isset($p_filedescr['mtime'])) {
1317
+ $p_header['mtime'] = $p_filedescr['mtime'];
1318
+ }
1319
+ else if ($p_filedescr['type'] == 'virtual_file') {
1320
+ $p_header['mtime'] = time();
1321
+ }
1322
+ else {
1323
+ $p_header['mtime'] = filemtime($p_filename);
1324
+ }
1325
+ if (isset($p_filedescr['comment'])) {
1326
+ $p_header['comment_len'] = strlen($p_filedescr['comment']);
1327
+ $p_header['comment'] = $p_filedescr['comment'];
1328
+ }
1329
+ else {
1330
+ $p_header['comment_len'] = 0;
1331
+ $p_header['comment'] = '';
1332
+ }
1333
+ if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
1334
+ $v_local_header = array();
1335
+ $this->privConvertHeader2FileInfo($p_header, $v_local_header);
1336
+ // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');
1337
+ $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
1338
+ if ($v_result == 0) {
1339
+ $p_header['status'] = "skipped";
1340
+ $v_result = 1;
1341
+ }
1342
+ if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
1343
+ $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
1344
+ }
1345
+ }
1346
+ if ($p_header['stored_filename'] == "") {
1347
+ $p_header['status'] = "filtered";
1348
+ }
1349
+ if (strlen($p_header['stored_filename']) > 0xFF) {
1350
+ $p_header['status'] = 'filename_too_long';
1351
+ }
1352
+ if ($p_header['status'] == 'ok') {
1353
+ if ($p_filedescr['type'] == 'file') {
1354
+ if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
1355
+ && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
1356
+ || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
1357
+ && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
1358
+ $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
1359
+ if ($v_result < PCLZIP_ERR_NO_ERROR) {
1360
+ return $v_result;
1361
+ }
1362
+ }
1363
+ else {
1364
+ if (($v_file = @fopen($p_filename, "rb")) == 0) {
1365
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
1366
+ return PclZip::errorCode();
1367
+ }
1368
+ $v_content = @fread($v_file, $p_header['size']);
1369
+ @fclose($v_file);
1370
+ $p_header['crc'] = @crc32($v_content);
1371
+ if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
1372
+ $p_header['compressed_size'] = $p_header['size'];
1373
+ $p_header['compression'] = 0;
1374
+ }
1375
+ else {
1376
+ $v_content = @gzdeflate($v_content);
1377
+ $p_header['compressed_size'] = strlen($v_content);
1378
+ $p_header['compression'] = 8;
1379
+ }
1380
+ if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
1381
+ @fclose($v_file);
1382
+ return $v_result;
1383
+ }
1384
+ @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
1385
+ }
1386
+ }
1387
+ else if ($p_filedescr['type'] == 'virtual_file') {
1388
+ $v_content = $p_filedescr['content'];
1389
+ $p_header['crc'] = @crc32($v_content);
1390
+ if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
1391
+ $p_header['compressed_size'] = $p_header['size'];
1392
+ $p_header['compression'] = 0;
1393
+ }
1394
+ else {
1395
+ $v_content = @gzdeflate($v_content);
1396
+ $p_header['compressed_size'] = strlen($v_content);
1397
+ $p_header['compression'] = 8;
1398
+ }
1399
+ if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
1400
+ @fclose($v_file);
1401
+ return $v_result;
1402
+ }
1403
+ @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
1404
+ }
1405
+ else if ($p_filedescr['type'] == 'folder') {
1406
+ if (@substr($p_header['stored_filename'], -1) != '/') {
1407
+ $p_header['stored_filename'] .= '/';
1408
+ }
1409
+ $p_header['size'] = 0;
1410
+ $p_header['external'] = 0x00000010; // Value for a folder : to be checked
1411
+ if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
1412
+ {
1413
+ return $v_result;
1414
+ }
1415
+ }
1416
+ }
1417
+ if (isset($p_options[PCLZIP_CB_POST_ADD])) {
1418
+ $v_local_header = array();
1419
+ $this->privConvertHeader2FileInfo($p_header, $v_local_header);
1420
+ // eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');
1421
+ $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
1422
+ if ($v_result == 0) {
1423
+ $v_result = 1;
1424
+ }
1425
+ }
1426
+ return $v_result;
1427
+ }
1428
+ function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
1429
+ {
1430
+ $v_result=PCLZIP_ERR_NO_ERROR;
1431
+ $p_filename = $p_filedescr['filename'];
1432
+ if (($v_file = @fopen($p_filename, "rb")) == 0) {
1433
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
1434
+ return PclZip::errorCode();
1435
+ }
1436
+ $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
1437
+ if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
1438
+ fclose($v_file);
1439
+ PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
1440
+ return PclZip::errorCode();
1441
+ }
1442
+ $v_size = filesize($p_filename);
1443
+ while ($v_size != 0) {
1444
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
1445
+ $v_buffer = @fread($v_file, $v_read_size);
1446
+ @gzputs($v_file_compressed, $v_buffer, $v_read_size);
1447
+ $v_size -= $v_read_size;
1448
+ }
1449
+ @fclose($v_file);
1450
+ @gzclose($v_file_compressed);
1451
+ if (filesize($v_gzip_temp_name) < 18) {
1452
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
1453
+ return PclZip::errorCode();
1454
+ }
1455
+ if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
1456
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
1457
+ return PclZip::errorCode();
1458
+ }
1459
+ $v_binary_data = @fread($v_file_compressed, 10);
1460
+ $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
1461
+ $v_data_header['os'] = bin2hex($v_data_header['os']);
1462
+ @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
1463
+ $v_binary_data = @fread($v_file_compressed, 8);
1464
+ $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
1465
+ $p_header['compression'] = ord($v_data_header['cm']);
1466
+ $p_header['crc'] = $v_data_footer['crc'];
1467
+ $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
1468
+ @fclose($v_file_compressed);
1469
+ if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
1470
+ return $v_result;
1471
+ }
1472
+ if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
1473
+ {
1474
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
1475
+ return PclZip::errorCode();
1476
+ }
1477
+ fseek($v_file_compressed, 10);
1478
+ $v_size = $p_header['compressed_size'];
1479
+ while ($v_size != 0)
1480
+ {
1481
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
1482
+ $v_buffer = @fread($v_file_compressed, $v_read_size);
1483
+ @fwrite($this->zip_fd, $v_buffer, $v_read_size);
1484
+ $v_size -= $v_read_size;
1485
+ }
1486
+ @fclose($v_file_compressed);
1487
+ @unlink($v_gzip_temp_name);
1488
+ return $v_result;
1489
+ }
1490
+ function privCalculateStoredFilename(&$p_filedescr, &$p_options)
1491
+ {
1492
+ $v_result=1;
1493
+ $p_filename = $p_filedescr['filename'];
1494
+ if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
1495
+ $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
1496
+ }
1497
+ else {
1498
+ $p_add_dir = '';
1499
+ }
1500
+ if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
1501
+ $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
1502
+ }
1503
+ else {
1504
+ $p_remove_dir = '';
1505
+ }
1506
+ if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
1507
+ $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
1508
+ }
1509
+ else {
1510
+ $p_remove_all_dir = 0;
1511
+ }
1512
+ if (isset($p_filedescr['new_full_name'])) {
1513
+ $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
1514
+ }
1515
+ else {
1516
+ if (isset($p_filedescr['new_short_name'])) {
1517
+ $v_path_info = pathinfo($p_filename);
1518
+ $v_dir = '';
1519
+ if ($v_path_info['dirname'] != '') {
1520
+ $v_dir = $v_path_info['dirname'].'/';
1521
+ }
1522
+ $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
1523
+ }
1524
+ else {
1525
+ $v_stored_filename = $p_filename;
1526
+ }
1527
+ if ($p_remove_all_dir) {
1528
+ $v_stored_filename = basename($p_filename);
1529
+ }
1530
+ else if ($p_remove_dir != "") {
1531
+ if (substr($p_remove_dir, -1) != '/')
1532
+ $p_remove_dir .= "/";
1533
+ if ( (substr($p_filename, 0, 2) == "./")
1534
+ || (substr($p_remove_dir, 0, 2) == "./")) {
1535
+ if ( (substr($p_filename, 0, 2) == "./")
1536
+ && (substr($p_remove_dir, 0, 2) != "./")) {
1537
+ $p_remove_dir = "./".$p_remove_dir;
1538
+ }
1539
+ if ( (substr($p_filename, 0, 2) != "./")
1540
+ && (substr($p_remove_dir, 0, 2) == "./")) {
1541
+ $p_remove_dir = substr($p_remove_dir, 2);
1542
+ }
1543
+ }
1544
+ $v_compare = PclZipUtilPathInclusion($p_remove_dir,
1545
+ $v_stored_filename);
1546
+ if ($v_compare > 0) {
1547
+ if ($v_compare == 2) {
1548
+ $v_stored_filename = "";
1549
+ }
1550
+ else {
1551
+ $v_stored_filename = substr($v_stored_filename,
1552
+ strlen($p_remove_dir));
1553
+ }
1554
+ }
1555
+ }
1556
+ $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
1557
+ if ($p_add_dir != "") {
1558
+ if (substr($p_add_dir, -1) == "/")
1559
+ $v_stored_filename = $p_add_dir.$v_stored_filename;
1560
+ else
1561
+ $v_stored_filename = $p_add_dir."/".$v_stored_filename;
1562
+ }
1563
+ }
1564
+ $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
1565
+ $p_filedescr['stored_filename'] = $v_stored_filename;
1566
+ return $v_result;
1567
+ }
1568
+ function privWriteFileHeader(&$p_header)
1569
+ {
1570
+ $v_result=1;
1571
+ $p_header['offset'] = ftell($this->zip_fd);
1572
+ $v_date = getdate($p_header['mtime']);
1573
+ $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
1574
+ $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
1575
+ $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
1576
+ $p_header['version_extracted'], $p_header['flag'],
1577
+ $p_header['compression'], $v_mtime, $v_mdate,
1578
+ $p_header['crc'], $p_header['compressed_size'],
1579
+ $p_header['size'],
1580
+ strlen($p_header['stored_filename']),
1581
+ $p_header['extra_len']);
1582
+ fputs($this->zip_fd, $v_binary_data, 30);
1583
+ if (strlen($p_header['stored_filename']) != 0)
1584
+ {
1585
+ fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
1586
+ }
1587
+ if ($p_header['extra_len'] != 0)
1588
+ {
1589
+ fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
1590
+ }
1591
+ return $v_result;
1592
+ }
1593
+ function privWriteCentralFileHeader(&$p_header)
1594
+ {
1595
+ $v_result=1;
1596
+ $v_date = getdate($p_header['mtime']);
1597
+ $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
1598
+ $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
1599
+ $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
1600
+ $p_header['version'], $p_header['version_extracted'],
1601
+ $p_header['flag'], $p_header['compression'],
1602
+ $v_mtime, $v_mdate, $p_header['crc'],
1603
+ $p_header['compressed_size'], $p_header['size'],
1604
+ strlen($p_header['stored_filename']),
1605
+ $p_header['extra_len'], $p_header['comment_len'],
1606
+ $p_header['disk'], $p_header['internal'],
1607
+ $p_header['external'], $p_header['offset']);
1608
+ fputs($this->zip_fd, $v_binary_data, 46);
1609
+ if (strlen($p_header['stored_filename']) != 0)
1610
+ {
1611
+ fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
1612
+ }
1613
+ if ($p_header['extra_len'] != 0)
1614
+ {
1615
+ fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
1616
+ }
1617
+ if ($p_header['comment_len'] != 0)
1618
+ {
1619
+ fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
1620
+ }
1621
+ return $v_result;
1622
+ }
1623
+ function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
1624
+ {
1625
+ $v_result=1;
1626
+ $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
1627
+ $p_nb_entries, $p_size,
1628
+ $p_offset, strlen($p_comment));
1629
+ fputs($this->zip_fd, $v_binary_data, 22);
1630
+ if (strlen($p_comment) != 0)
1631
+ {
1632
+ fputs($this->zip_fd, $p_comment, strlen($p_comment));
1633
+ }
1634
+ return $v_result;
1635
+ }
1636
+ function privList(&$p_list)
1637
+ {
1638
+ $v_result=1;
1639
+ $this->privDisableMagicQuotes();
1640
+ if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
1641
+ {
1642
+ $this->privSwapBackMagicQuotes();
1643
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
1644
+ return PclZip::errorCode();
1645
+ }
1646
+ $v_central_dir = array();
1647
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
1648
+ {
1649
+ $this->privSwapBackMagicQuotes();
1650
+ return $v_result;
1651
+ }
1652
+ @rewind($this->zip_fd);
1653
+ if (@fseek($this->zip_fd, $v_central_dir['offset']))
1654
+ {
1655
+ $this->privSwapBackMagicQuotes();
1656
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
1657
+ return PclZip::errorCode();
1658
+ }
1659
+ for ($i=0; $i<$v_central_dir['entries']; $i++)
1660
+ {
1661
+ if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
1662
+ {
1663
+ $this->privSwapBackMagicQuotes();
1664
+ return $v_result;
1665
+ }
1666
+ $v_header['index'] = $i;
1667
+ $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
1668
+ unset($v_header);
1669
+ }
1670
+ $this->privCloseFd();
1671
+ $this->privSwapBackMagicQuotes();
1672
+ return $v_result;
1673
+ }
1674
+ function privConvertHeader2FileInfo($p_header, &$p_info)
1675
+ {
1676
+ $v_result=1;
1677
+ $v_temp_path = PclZipUtilPathReduction($p_header['filename']);
1678
+ $p_info['filename'] = $v_temp_path;
1679
+ $v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']);
1680
+ $p_info['stored_filename'] = $v_temp_path;
1681
+ $p_info['size'] = $p_header['size'];
1682
+ $p_info['compressed_size'] = $p_header['compressed_size'];
1683
+ $p_info['mtime'] = $p_header['mtime'];
1684
+ $p_info['comment'] = $p_header['comment'];
1685
+ $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
1686
+ $p_info['index'] = $p_header['index'];
1687
+ $p_info['status'] = $p_header['status'];
1688
+ $p_info['crc'] = $p_header['crc'];
1689
+ return $v_result;
1690
+ }
1691
+ function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
1692
+ {
1693
+ $v_result=1;
1694
+ $this->privDisableMagicQuotes();
1695
+ if ( ($p_path == "")
1696
+ || ( (substr($p_path, 0, 1) != "/")
1697
+ && (substr($p_path, 0, 3) != "../")
1698
+ && (substr($p_path,1,2)!=":/")))
1699
+ $p_path = "./".$p_path;
1700
+ if (($p_path != "./") && ($p_path != "/"))
1701
+ {
1702
+ while (substr($p_path, -1) == "/")
1703
+ {
1704
+ $p_path = substr($p_path, 0, strlen($p_path)-1);
1705
+ }
1706
+ }
1707
+ if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
1708
+ {
1709
+ $p_remove_path .= '/';
1710
+ }
1711
+ $p_remove_path_size = strlen($p_remove_path);
1712
+ if (($v_result = $this->privOpenFd('rb')) != 1)
1713
+ {
1714
+ $this->privSwapBackMagicQuotes();
1715
+ return $v_result;
1716
+ }
1717
+ $v_central_dir = array();
1718
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
1719
+ {
1720
+ $this->privCloseFd();
1721
+ $this->privSwapBackMagicQuotes();
1722
+ return $v_result;
1723
+ }
1724
+ $v_pos_entry = $v_central_dir['offset'];
1725
+ $j_start = 0;
1726
+ for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
1727
+ {
1728
+ @rewind($this->zip_fd);
1729
+ if (@fseek($this->zip_fd, $v_pos_entry))
1730
+ {
1731
+ $this->privCloseFd();
1732
+ $this->privSwapBackMagicQuotes();
1733
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
1734
+ return PclZip::errorCode();
1735
+ }
1736
+ $v_header = array();
1737
+ if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
1738
+ {
1739
+ $this->privCloseFd();
1740
+ $this->privSwapBackMagicQuotes();
1741
+ return $v_result;
1742
+ }
1743
+ $v_header['index'] = $i;
1744
+ $v_pos_entry = ftell($this->zip_fd);
1745
+ $v_extract = false;
1746
+ if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
1747
+ && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
1748
+ for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
1749
+ if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
1750
+ if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
1751
+ && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
1752
+ $v_extract = true;
1753
+ }
1754
+ }
1755
+ elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
1756
+ $v_extract = true;
1757
+ }
1758
+ }
1759
+ }
1760
+ /*
1761
+ else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
1762
+ && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
1763
+ if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
1764
+ $v_extract = true;
1765
+ }
1766
+ }
1767
+ */
1768
+ else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
1769
+ && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
1770
+ if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
1771
+ $v_extract = true;
1772
+ }
1773
+ }
1774
+ else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
1775
+ && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
1776
+ for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
1777
+ if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
1778
+ $v_extract = true;
1779
+ }
1780
+ if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
1781
+ $j_start = $j+1;
1782
+ }
1783
+ if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
1784
+ break;
1785
+ }
1786
+ }
1787
+ }
1788
+ else {
1789
+ $v_extract = true;
1790
+ }
1791
+ // ----- Check compression method
1792
+ if ( ($v_extract)
1793
+ && ( ($v_header['compression'] != 8)
1794
+ && ($v_header['compression'] != 0))) {
1795
+ $v_header['status'] = 'unsupported_compression';
1796
+ if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
1797
+ && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
1798
+ $this->privSwapBackMagicQuotes();
1799
+ PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
1800
+ "Filename '".$v_header['stored_filename']."' is "
1801
+ ."compressed by an unsupported compression "
1802
+ ."method (".$v_header['compression'].") ");
1803
+ return PclZip::errorCode();
1804
+ }
1805
+ }
1806
+ // ----- Check encrypted files
1807
+ if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
1808
+ $v_header['status'] = 'unsupported_encryption';
1809
+ if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
1810
+ && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
1811
+ $this->privSwapBackMagicQuotes();
1812
+ PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
1813
+ "Unsupported encryption for "
1814
+ ." filename '".$v_header['stored_filename']
1815
+ ."'");
1816
+ return PclZip::errorCode();
1817
+ }
1818
+ }
1819
+ if (($v_extract) && ($v_header['status'] != 'ok')) {
1820
+ $v_result = $this->privConvertHeader2FileInfo($v_header,
1821
+ $p_file_list[$v_nb_extracted++]);
1822
+ if ($v_result != 1) {
1823
+ $this->privCloseFd();
1824
+ $this->privSwapBackMagicQuotes();
1825
+ return $v_result;
1826
+ }
1827
+ $v_extract = false;
1828
+ }
1829
+ if ($v_extract)
1830
+ {
1831
+ @rewind($this->zip_fd);
1832
+ if (@fseek($this->zip_fd, $v_header['offset']))
1833
+ {
1834
+ $this->privCloseFd();
1835
+ $this->privSwapBackMagicQuotes();
1836
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
1837
+ return PclZip::errorCode();
1838
+ }
1839
+ if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
1840
+ $v_string = '';
1841
+ $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
1842
+ if ($v_result1 < 1) {
1843
+ $this->privCloseFd();
1844
+ $this->privSwapBackMagicQuotes();
1845
+ return $v_result1;
1846
+ }
1847
+ if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
1848
+ {
1849
+ $this->privCloseFd();
1850
+ $this->privSwapBackMagicQuotes();
1851
+ return $v_result;
1852
+ }
1853
+ $p_file_list[$v_nb_extracted]['content'] = $v_string;
1854
+ $v_nb_extracted++;
1855
+ if ($v_result1 == 2) {
1856
+ break;
1857
+ }
1858
+ }
1859
+ elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
1860
+ && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
1861
+ $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
1862
+ if ($v_result1 < 1) {
1863
+ $this->privCloseFd();
1864
+ $this->privSwapBackMagicQuotes();
1865
+ return $v_result1;
1866
+ }
1867
+ if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
1868
+ $this->privCloseFd();
1869
+ $this->privSwapBackMagicQuotes();
1870
+ return $v_result;
1871
+ }
1872
+ if ($v_result1 == 2) {
1873
+ break;
1874
+ }
1875
+ }
1876
+ else {
1877
+ $v_result1 = $this->privExtractFile($v_header,
1878
+ $p_path, $p_remove_path,
1879
+ $p_remove_all_path,
1880
+ $p_options);
1881
+ if ($v_result1 < 1) {
1882
+ $this->privCloseFd();
1883
+ $this->privSwapBackMagicQuotes();
1884
+ return $v_result1;
1885
+ }
1886
+ if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
1887
+ {
1888
+ $this->privCloseFd();
1889
+ $this->privSwapBackMagicQuotes();
1890
+ return $v_result;
1891
+ }
1892
+ if ($v_result1 == 2) {
1893
+ break;
1894
+ }
1895
+ }
1896
+ }
1897
+ }
1898
+ $this->privCloseFd();
1899
+ $this->privSwapBackMagicQuotes();
1900
+ return $v_result;
1901
+ }
1902
+ function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
1903
+ {
1904
+ $v_result=1;
1905
+ if (($v_result = $this->privReadFileHeader($v_header)) != 1)
1906
+ {
1907
+ return $v_result;
1908
+ }
1909
+ if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
1910
+ }
1911
+ if ($p_remove_all_path == true) {
1912
+ if (($p_entry['external']&0x00000010)==0x00000010) {
1913
+ $p_entry['status'] = "filtered";
1914
+ return $v_result;
1915
+ }
1916
+ $p_entry['filename'] = basename($p_entry['filename']);
1917
+ }
1918
+ else if ($p_remove_path != "")
1919
+ {
1920
+ if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
1921
+ {
1922
+ $p_entry['status'] = "filtered";
1923
+ return $v_result;
1924
+ }
1925
+ $p_remove_path_size = strlen($p_remove_path);
1926
+ if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
1927
+ {
1928
+ $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
1929
+ }
1930
+ }
1931
+ if ($p_path != '') {
1932
+ $p_entry['filename'] = $p_path."/".$p_entry['filename'];
1933
+ }
1934
+ if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
1935
+ $v_inclusion
1936
+ = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
1937
+ $p_entry['filename']);
1938
+ if ($v_inclusion == 0) {
1939
+ PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
1940
+ "Filename '".$p_entry['filename']."' is "
1941
+ ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
1942
+ return PclZip::errorCode();
1943
+ }
1944
+ }
1945
+ if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
1946
+ $v_local_header = array();
1947
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
1948
+ // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
1949
+ $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
1950
+ if ($v_result == 0) {
1951
+ $p_entry['status'] = "skipped";
1952
+ $v_result = 1;
1953
+ }
1954
+ if ($v_result == 2) {
1955
+ $p_entry['status'] = "aborted";
1956
+ $v_result = PCLZIP_ERR_USER_ABORTED;
1957
+ }
1958
+ $p_entry['filename'] = $v_local_header['filename'];
1959
+ }
1960
+ if ($p_entry['status'] == 'ok') {
1961
+ if (file_exists($p_entry['filename']))
1962
+ {
1963
+ if (is_dir($p_entry['filename']))
1964
+ {
1965
+ $p_entry['status'] = "already_a_directory";
1966
+ if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
1967
+ && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
1968
+ PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
1969
+ "Filename '".$p_entry['filename']."' is "
1970
+ ."already used by an existing directory");
1971
+ return PclZip::errorCode();
1972
+ }
1973
+ }
1974
+ else if (!is_writeable($p_entry['filename']))
1975
+ {
1976
+ $p_entry['status'] = "write_protected";
1977
+ if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
1978
+ && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
1979
+ PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
1980
+ "Filename '".$p_entry['filename']."' exists "
1981
+ ."and is write protected");
1982
+ return PclZip::errorCode();
1983
+ }
1984
+ }
1985
+ else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
1986
+ {
1987
+ if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
1988
+ && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
1989
+ }
1990
+ else {
1991
+ $p_entry['status'] = "newer_exist";
1992
+ if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
1993
+ && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
1994
+ PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
1995
+ "Newer version of '".$p_entry['filename']."' exists "
1996
+ ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
1997
+ return PclZip::errorCode();
1998
+ }
1999
+ }
2000
+ }
2001
+ else {
2002
+ }
2003
+ }
2004
+ else {
2005
+ if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
2006
+ $v_dir_to_check = $p_entry['filename'];
2007
+ else if (!strstr($p_entry['filename'], "/"))
2008
+ $v_dir_to_check = "";
2009
+ else
2010
+ $v_dir_to_check = dirname($p_entry['filename']);
2011
+ if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
2012
+ $p_entry['status'] = "path_creation_fail";
2013
+ $v_result = 1;
2014
+ }
2015
+ }
2016
+ }
2017
+ if ($p_entry['status'] == 'ok') {
2018
+ if (!(($p_entry['external']&0x00000010)==0x00000010))
2019
+ {
2020
+ if ($p_entry['compression'] == 0) {
2021
+ // ----- Opening destination file
2022
+ if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
2023
+ {
2024
+ $p_entry['status'] = "write_error";
2025
+ return $v_result;
2026
+ }
2027
+ $v_size = $p_entry['compressed_size'];
2028
+ while ($v_size != 0)
2029
+ {
2030
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2031
+ $v_buffer = @fread($this->zip_fd, $v_read_size);
2032
+ /* Try to speed up the code
2033
+ $v_binary_data = pack('a'.$v_read_size, $v_buffer);
2034
+ @fwrite($v_dest_file, $v_binary_data, $v_read_size);
2035
+ */
2036
+ @fwrite($v_dest_file, $v_buffer, $v_read_size);
2037
+ $v_size -= $v_read_size;
2038
+ }
2039
+ fclose($v_dest_file);
2040
+ touch($p_entry['filename'], $p_entry['mtime']);
2041
+ }
2042
+ else {
2043
+ if (($p_entry['flag'] & 1) == 1) {
2044
+ PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
2045
+ return PclZip::errorCode();
2046
+ }
2047
+ if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
2048
+ && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
2049
+ || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
2050
+ && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
2051
+ $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
2052
+ if ($v_result < PCLZIP_ERR_NO_ERROR) {
2053
+ return $v_result;
2054
+ }
2055
+ }
2056
+ else {
2057
+ $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
2058
+ $v_file_content = @gzinflate($v_buffer);
2059
+ unset($v_buffer);
2060
+ if ($v_file_content === FALSE) {
2061
+ $p_entry['status'] = "error";
2062
+ return $v_result;
2063
+ }
2064
+ if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
2065
+ $p_entry['status'] = "write_error";
2066
+ return $v_result;
2067
+ }
2068
+ @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
2069
+ unset($v_file_content);
2070
+ @fclose($v_dest_file);
2071
+ }
2072
+ @touch($p_entry['filename'], $p_entry['mtime']);
2073
+ }
2074
+ if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
2075
+ @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
2076
+ }
2077
+ }
2078
+ }
2079
+ // ----- Change abort status
2080
+ if ($p_entry['status'] == "aborted") {
2081
+ $p_entry['status'] = "skipped";
2082
+ }
2083
+ elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
2084
+ $v_local_header = array();
2085
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
2086
+ // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
2087
+ $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
2088
+ if ($v_result == 2) {
2089
+ $v_result = PCLZIP_ERR_USER_ABORTED;
2090
+ }
2091
+ }
2092
+ return $v_result;
2093
+ }
2094
+ function privExtractFileUsingTempFile(&$p_entry, &$p_options)
2095
+ {
2096
+ $v_result=1;
2097
+ $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
2098
+ if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
2099
+ fclose($v_file);
2100
+ PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
2101
+ return PclZip::errorCode();
2102
+ }
2103
+ $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
2104
+ @fwrite($v_dest_file, $v_binary_data, 10);
2105
+ $v_size = $p_entry['compressed_size'];
2106
+ while ($v_size != 0)
2107
+ {
2108
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2109
+ $v_buffer = @fread($this->zip_fd, $v_read_size);
2110
+ @fwrite($v_dest_file, $v_buffer, $v_read_size);
2111
+ $v_size -= $v_read_size;
2112
+ }
2113
+ $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);
2114
+ @fwrite($v_dest_file, $v_binary_data, 8);
2115
+ @fclose($v_dest_file);
2116
+ if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
2117
+ $p_entry['status'] = "write_error";
2118
+ return $v_result;
2119
+ }
2120
+ if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
2121
+ @fclose($v_dest_file);
2122
+ $p_entry['status'] = "read_error";
2123
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2124
+ return PclZip::errorCode();
2125
+ }
2126
+ $v_size = $p_entry['size'];
2127
+ while ($v_size != 0) {
2128
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2129
+ $v_buffer = @gzread($v_src_file, $v_read_size);
2130
+ @fwrite($v_dest_file, $v_buffer, $v_read_size);
2131
+ $v_size -= $v_read_size;
2132
+ }
2133
+ @fclose($v_dest_file);
2134
+ @gzclose($v_src_file);
2135
+ @unlink($v_gzip_temp_name);
2136
+ return $v_result;
2137
+ }
2138
+ function privExtractFileInOutput(&$p_entry, &$p_options)
2139
+ {
2140
+ $v_result=1;
2141
+ if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
2142
+ return $v_result;
2143
+ }
2144
+ if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
2145
+ }
2146
+ if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
2147
+ $v_local_header = array();
2148
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
2149
+ // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
2150
+ $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
2151
+ if ($v_result == 0) {
2152
+ $p_entry['status'] = "skipped";
2153
+ $v_result = 1;
2154
+ }
2155
+ if ($v_result == 2) {
2156
+ $p_entry['status'] = "aborted";
2157
+ $v_result = PCLZIP_ERR_USER_ABORTED;
2158
+ }
2159
+ $p_entry['filename'] = $v_local_header['filename'];
2160
+ }
2161
+ if ($p_entry['status'] == 'ok') {
2162
+ if (!(($p_entry['external']&0x00000010)==0x00000010)) {
2163
+ if ($p_entry['compressed_size'] == $p_entry['size']) {
2164
+ $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
2165
+ echo $v_buffer;
2166
+ unset($v_buffer);
2167
+ }
2168
+ else {
2169
+ $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
2170
+ $v_file_content = gzinflate($v_buffer);
2171
+ unset($v_buffer);
2172
+ echo $v_file_content;
2173
+ unset($v_file_content);
2174
+ }
2175
+ }
2176
+ }
2177
+ // ----- Change abort status
2178
+ if ($p_entry['status'] == "aborted") {
2179
+ $p_entry['status'] = "skipped";
2180
+ }
2181
+ elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
2182
+ $v_local_header = array();
2183
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
2184
+ // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
2185
+ $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
2186
+ if ($v_result == 2) {
2187
+ $v_result = PCLZIP_ERR_USER_ABORTED;
2188
+ }
2189
+ }
2190
+ return $v_result;
2191
+ }
2192
+ function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
2193
+ {
2194
+ $v_result=1;
2195
+ $v_header = array();
2196
+ if (($v_result = $this->privReadFileHeader($v_header)) != 1)
2197
+ {
2198
+ return $v_result;
2199
+ }
2200
+ if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
2201
+ }
2202
+ if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
2203
+ $v_local_header = array();
2204
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
2205
+ // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
2206
+ $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
2207
+ if ($v_result == 0) {
2208
+ $p_entry['status'] = "skipped";
2209
+ $v_result = 1;
2210
+ }
2211
+ if ($v_result == 2) {
2212
+ $p_entry['status'] = "aborted";
2213
+ $v_result = PCLZIP_ERR_USER_ABORTED;
2214
+ }
2215
+ $p_entry['filename'] = $v_local_header['filename'];
2216
+ }
2217
+ if ($p_entry['status'] == 'ok') {
2218
+ if (!(($p_entry['external']&0x00000010)==0x00000010)) {
2219
+ if ($p_entry['compression'] == 0) {
2220
+ $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
2221
+ }
2222
+ else {
2223
+ $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
2224
+ if (($p_string = @gzinflate($v_data)) === FALSE) {
2225
+ }
2226
+ }
2227
+ }
2228
+ else {
2229
+ }
2230
+ }
2231
+ // ----- Change abort status
2232
+ if ($p_entry['status'] == "aborted") {
2233
+ $p_entry['status'] = "skipped";
2234
+ }
2235
+ elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
2236
+ $v_local_header = array();
2237
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
2238
+ $v_local_header['content'] = $p_string;
2239
+ $p_string = '';
2240
+ // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
2241
+ $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
2242
+ $p_string = $v_local_header['content'];
2243
+ unset($v_local_header['content']);
2244
+ if ($v_result == 2) {
2245
+ $v_result = PCLZIP_ERR_USER_ABORTED;
2246
+ }
2247
+ }
2248
+ return $v_result;
2249
+ }
2250
+ function privReadFileHeader(&$p_header)
2251
+ {
2252
+ $v_result=1;
2253
+ $v_binary_data = @fread($this->zip_fd, 4);
2254
+ $v_data = unpack('Vid', $v_binary_data);
2255
+ if ($v_data['id'] != 0x04034b50)
2256
+ {
2257
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
2258
+ return PclZip::errorCode();
2259
+ }
2260
+ $v_binary_data = fread($this->zip_fd, 26);
2261
+ if (strlen($v_binary_data) != 26)
2262
+ {
2263
+ $p_header['filename'] = "";
2264
+ $p_header['status'] = "invalid_header";
2265
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
2266
+ return PclZip::errorCode();
2267
+ }
2268
+ $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
2269
+ $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
2270
+ if ($v_data['extra_len'] != 0) {
2271
+ $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
2272
+ }
2273
+ else {
2274
+ $p_header['extra'] = '';
2275
+ }
2276
+ $p_header['version_extracted'] = $v_data['version'];
2277
+ $p_header['compression'] = $v_data['compression'];
2278
+ $p_header['size'] = $v_data['size'];
2279
+ $p_header['compressed_size'] = $v_data['compressed_size'];
2280
+ $p_header['crc'] = $v_data['crc'];
2281
+ $p_header['flag'] = $v_data['flag'];
2282
+ $p_header['filename_len'] = $v_data['filename_len'];
2283
+ $p_header['mdate'] = $v_data['mdate'];
2284
+ $p_header['mtime'] = $v_data['mtime'];
2285
+ if ($p_header['mdate'] && $p_header['mtime'])
2286
+ {
2287
+ $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
2288
+ $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
2289
+ $v_seconde = ($p_header['mtime'] & 0x001F)*2;
2290
+ $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
2291
+ $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
2292
+ $v_day = $p_header['mdate'] & 0x001F;
2293
+ $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
2294
+ }
2295
+ else
2296
+ {
2297
+ $p_header['mtime'] = time();
2298
+ }
2299
+ $p_header['stored_filename'] = $p_header['filename'];
2300
+ $p_header['status'] = "ok";
2301
+ return $v_result;
2302
+ }
2303
+ function privReadCentralFileHeader(&$p_header)
2304
+ {
2305
+ $v_result=1;
2306
+ $v_binary_data = @fread($this->zip_fd, 4);
2307
+ $v_data = unpack('Vid', $v_binary_data);
2308
+ if ($v_data['id'] != 0x02014b50)
2309
+ {
2310
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
2311
+ return PclZip::errorCode();
2312
+ }
2313
+ $v_binary_data = fread($this->zip_fd, 42);
2314
+ if (strlen($v_binary_data) != 42)
2315
+ {
2316
+ $p_header['filename'] = "";
2317
+ $p_header['status'] = "invalid_header";
2318
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
2319
+ return PclZip::errorCode();
2320
+ }
2321
+ $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
2322
+ if ($p_header['filename_len'] != 0)
2323
+ $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
2324
+ else
2325
+ $p_header['filename'] = '';
2326
+ if ($p_header['extra_len'] != 0)
2327
+ $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
2328
+ else
2329
+ $p_header['extra'] = '';
2330
+ if ($p_header['comment_len'] != 0)
2331
+ $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
2332
+ else
2333
+ $p_header['comment'] = '';
2334
+ if (1)
2335
+ {
2336
+ $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
2337
+ $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
2338
+ $v_seconde = ($p_header['mtime'] & 0x001F)*2;
2339
+ $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
2340
+ $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
2341
+ $v_day = $p_header['mdate'] & 0x001F;
2342
+ $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
2343
+ }
2344
+ else
2345
+ {
2346
+ $p_header['mtime'] = time();
2347
+ }
2348
+ $p_header['stored_filename'] = $p_header['filename'];
2349
+ $p_header['status'] = 'ok';
2350
+ if (substr($p_header['filename'], -1) == '/') {
2351
+ $p_header['external'] = 0x00000010;
2352
+ }
2353
+ return $v_result;
2354
+ }
2355
+ function privCheckFileHeaders(&$p_local_header, &$p_central_header)
2356
+ {
2357
+ $v_result=1;
2358
+ // ----- Check the static values
2359
+ // TBC
2360
+ if ($p_local_header['filename'] != $p_central_header['filename']) {
2361
+ }
2362
+ if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
2363
+ }
2364
+ if ($p_local_header['flag'] != $p_central_header['flag']) {
2365
+ }
2366
+ if ($p_local_header['compression'] != $p_central_header['compression']) {
2367
+ }
2368
+ if ($p_local_header['mtime'] != $p_central_header['mtime']) {
2369
+ }
2370
+ if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
2371
+ }
2372
+ // ----- Look for flag bit 3
2373
+ if (($p_local_header['flag'] & 8) == 8) {
2374
+ $p_local_header['size'] = $p_central_header['size'];
2375
+ $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
2376
+ $p_local_header['crc'] = $p_central_header['crc'];
2377
+ }
2378
+ return $v_result;
2379
+ }
2380
+ function privReadEndCentralDir(&$p_central_dir)
2381
+ {
2382
+ $v_result=1;
2383
+ $v_size = filesize($this->zipname);
2384
+ @fseek($this->zip_fd, $v_size);
2385
+ if (@ftell($this->zip_fd) != $v_size)
2386
+ {
2387
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
2388
+ return PclZip::errorCode();
2389
+ }
2390
+ $v_found = 0;
2391
+ if ($v_size > 26) {
2392
+ @fseek($this->zip_fd, $v_size-22);
2393
+ if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
2394
+ {
2395
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
2396
+ return PclZip::errorCode();
2397
+ }
2398
+ $v_binary_data = @fread($this->zip_fd, 4);
2399
+ $v_data = @unpack('Vid', $v_binary_data);
2400
+ if ($v_data['id'] == 0x06054b50) {
2401
+ $v_found = 1;
2402
+ }
2403
+ $v_pos = ftell($this->zip_fd);
2404
+ }
2405
+ if (!$v_found) {
2406
+ $v_maximum_size = 65557; // 0xFFFF + 22;
2407
+ if ($v_maximum_size > $v_size)
2408
+ $v_maximum_size = $v_size;
2409
+ @fseek($this->zip_fd, $v_size-$v_maximum_size);
2410
+ if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
2411
+ {
2412
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
2413
+ return PclZip::errorCode();
2414
+ }
2415
+ $v_pos = ftell($this->zip_fd);
2416
+ $v_bytes = 0x00000000;
2417
+ while ($v_pos < $v_size)
2418
+ {
2419
+ $v_byte = @fread($this->zip_fd, 1);
2420
+ $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
2421
+ if ($v_bytes == 0x504b0506)
2422
+ {
2423
+ $v_pos++;
2424
+ break;
2425
+ }
2426
+ $v_pos++;
2427
+ }
2428
+ if ($v_pos == $v_size)
2429
+ {
2430
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
2431
+ return PclZip::errorCode();
2432
+ }
2433
+ }
2434
+ $v_binary_data = fread($this->zip_fd, 18);
2435
+ if (strlen($v_binary_data) != 18)
2436
+ {
2437
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
2438
+ return PclZip::errorCode();
2439
+ }
2440
+ $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
2441
+ if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
2442
+ // ----- Removed in release 2.2 see readme file
2443
+ // The check of the file size is a little too strict.
2444
+ // Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
2445
+ // While decrypted, zip has training 0 bytes
2446
+ if (0) {
2447
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
2448
+ 'The central dir is not at the end of the archive.'
2449
+ .' Some trailing bytes exists after the archive.');
2450
+ return PclZip::errorCode();
2451
+ }
2452
+ }
2453
+ if ($v_data['comment_size'] != 0) {
2454
+ $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
2455
+ }
2456
+ else
2457
+ $p_central_dir['comment'] = '';
2458
+ $p_central_dir['entries'] = $v_data['entries'];
2459
+ $p_central_dir['disk_entries'] = $v_data['disk_entries'];
2460
+ $p_central_dir['offset'] = $v_data['offset'];
2461
+ $p_central_dir['size'] = $v_data['size'];
2462
+ $p_central_dir['disk'] = $v_data['disk'];
2463
+ $p_central_dir['disk_start'] = $v_data['disk_start'];
2464
+ return $v_result;
2465
+ }
2466
+ function privDeleteByRule(&$p_result_list, &$p_options)
2467
+ {
2468
+ $v_result=1;
2469
+ $v_list_detail = array();
2470
+ if (($v_result=$this->privOpenFd('rb')) != 1)
2471
+ {
2472
+ return $v_result;
2473
+ }
2474
+ $v_central_dir = array();
2475
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
2476
+ {
2477
+ $this->privCloseFd();
2478
+ return $v_result;
2479
+ }
2480
+ @rewind($this->zip_fd);
2481
+ $v_pos_entry = $v_central_dir['offset'];
2482
+ @rewind($this->zip_fd);
2483
+ if (@fseek($this->zip_fd, $v_pos_entry))
2484
+ {
2485
+ $this->privCloseFd();
2486
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
2487
+ return PclZip::errorCode();
2488
+ }
2489
+ $v_header_list = array();
2490
+ $j_start = 0;
2491
+ for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
2492
+ {
2493
+ $v_header_list[$v_nb_extracted] = array();
2494
+ if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
2495
+ {
2496
+ $this->privCloseFd();
2497
+ return $v_result;
2498
+ }
2499
+ $v_header_list[$v_nb_extracted]['index'] = $i;
2500
+ $v_found = false;
2501
+ if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
2502
+ && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
2503
+ for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
2504
+ if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
2505
+ if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
2506
+ && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
2507
+ $v_found = true;
2508
+ }
2509
+ elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
2510
+ && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
2511
+ $v_found = true;
2512
+ }
2513
+ }
2514
+ elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
2515
+ $v_found = true;
2516
+ }
2517
+ }
2518
+ }
2519
+ /*
2520
+ else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
2521
+ && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
2522
+ if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
2523
+ $v_found = true;
2524
+ }
2525
+ }
2526
+ */
2527
+ else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
2528
+ && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
2529
+ if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
2530
+ $v_found = true;
2531
+ }
2532
+ }
2533
+ else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
2534
+ && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
2535
+ for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
2536
+ if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
2537
+ $v_found = true;
2538
+ }
2539
+ if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
2540
+ $j_start = $j+1;
2541
+ }
2542
+ if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
2543
+ break;
2544
+ }
2545
+ }
2546
+ }
2547
+ else {
2548
+ $v_found = true;
2549
+ }
2550
+ if ($v_found)
2551
+ {
2552
+ unset($v_header_list[$v_nb_extracted]);
2553
+ }
2554
+ else
2555
+ {
2556
+ $v_nb_extracted++;
2557
+ }
2558
+ }
2559
+ if ($v_nb_extracted > 0) {
2560
+ $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
2561
+ $v_temp_zip = new PclZip($v_zip_temp_name);
2562
+ if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
2563
+ $this->privCloseFd();
2564
+ return $v_result;
2565
+ }
2566
+ for ($i=0; $i<sizeof($v_header_list); $i++) {
2567
+ @rewind($this->zip_fd);
2568
+ if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) {
2569
+ $this->privCloseFd();
2570
+ $v_temp_zip->privCloseFd();
2571
+ @unlink($v_zip_temp_name);
2572
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
2573
+ return PclZip::errorCode();
2574
+ }
2575
+ $v_local_header = array();
2576
+ if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
2577
+ $this->privCloseFd();
2578
+ $v_temp_zip->privCloseFd();
2579
+ @unlink($v_zip_temp_name);
2580
+ return $v_result;
2581
+ }
2582
+ if ($this->privCheckFileHeaders($v_local_header,
2583
+ $v_header_list[$i]) != 1) {
2584
+ }
2585
+ unset($v_local_header);
2586
+ if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
2587
+ $this->privCloseFd();
2588
+ $v_temp_zip->privCloseFd();
2589
+ @unlink($v_zip_temp_name);
2590
+ return $v_result;
2591
+ }
2592
+ if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
2593
+ $this->privCloseFd();
2594
+ $v_temp_zip->privCloseFd();
2595
+ @unlink($v_zip_temp_name);
2596
+ return $v_result;
2597
+ }
2598
+ }
2599
+ $v_offset = @ftell($v_temp_zip->zip_fd);
2600
+ for ($i=0; $i<sizeof($v_header_list); $i++) {
2601
+ if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2602
+ $v_temp_zip->privCloseFd();
2603
+ $this->privCloseFd();
2604
+ @unlink($v_zip_temp_name);
2605
+ return $v_result;
2606
+ }
2607
+ $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2608
+ }
2609
+ $v_comment = '';
2610
+ if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2611
+ $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2612
+ }
2613
+ $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
2614
+ if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
2615
+ unset($v_header_list);
2616
+ $v_temp_zip->privCloseFd();
2617
+ $this->privCloseFd();
2618
+ @unlink($v_zip_temp_name);
2619
+ return $v_result;
2620
+ }
2621
+ $v_temp_zip->privCloseFd();
2622
+ $this->privCloseFd();
2623
+ @unlink($this->zipname);
2624
+ PclZipUtilRename($v_zip_temp_name, $this->zipname);
2625
+ unset($v_temp_zip);
2626
+ }
2627
+ else if ($v_central_dir['entries'] != 0) {
2628
+ $this->privCloseFd();
2629
+ if (($v_result = $this->privOpenFd('wb')) != 1) {
2630
+ return $v_result;
2631
+ }
2632
+ if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
2633
+ return $v_result;
2634
+ }
2635
+ $this->privCloseFd();
2636
+ }
2637
+ return $v_result;
2638
+ }
2639
+ function privDirCheck($p_dir, $p_is_dir=false)
2640
+ {
2641
+ $v_result = 1;
2642
+ if (($p_is_dir) && (substr($p_dir, -1)=='/'))
2643
+ {
2644
+ $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
2645
+ }
2646
+ if ((is_dir($p_dir)) || ($p_dir == ""))
2647
+ {
2648
+ return 1;
2649
+ }
2650
+ $p_parent_dir = dirname($p_dir);
2651
+ if ($p_parent_dir != $p_dir)
2652
+ {
2653
+ if ($p_parent_dir != "")
2654
+ {
2655
+ if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
2656
+ {
2657
+ return $v_result;
2658
+ }
2659
+ }
2660
+ }
2661
+ if (!@mkdir($p_dir, 0777))
2662
+ {
2663
+ PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
2664
+ return PclZip::errorCode();
2665
+ }
2666
+ return $v_result;
2667
+ }
2668
+ function privMerge(&$p_archive_to_add)
2669
+ {
2670
+ $v_result=1;
2671
+ if (!is_file($p_archive_to_add->zipname))
2672
+ {
2673
+ $v_result = 1;
2674
+ return $v_result;
2675
+ }
2676
+ if (!is_file($this->zipname))
2677
+ {
2678
+ $v_result = $this->privDuplicate($p_archive_to_add->zipname);
2679
+ return $v_result;
2680
+ }
2681
+ if (($v_result=$this->privOpenFd('rb')) != 1)
2682
+ {
2683
+ return $v_result;
2684
+ }
2685
+ $v_central_dir = array();
2686
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
2687
+ {
2688
+ $this->privCloseFd();
2689
+ return $v_result;
2690
+ }
2691
+ @rewind($this->zip_fd);
2692
+ if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
2693
+ {
2694
+ $this->privCloseFd();
2695
+ return $v_result;
2696
+ }
2697
+ $v_central_dir_to_add = array();
2698
+ if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
2699
+ {
2700
+ $this->privCloseFd();
2701
+ $p_archive_to_add->privCloseFd();
2702
+ return $v_result;
2703
+ }
2704
+ @rewind($p_archive_to_add->zip_fd);
2705
+ $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
2706
+ if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
2707
+ {
2708
+ $this->privCloseFd();
2709
+ $p_archive_to_add->privCloseFd();
2710
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
2711
+ return PclZip::errorCode();
2712
+ }
2713
+ $v_size = $v_central_dir['offset'];
2714
+ while ($v_size != 0)
2715
+ {
2716
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2717
+ $v_buffer = fread($this->zip_fd, $v_read_size);
2718
+ @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2719
+ $v_size -= $v_read_size;
2720
+ }
2721
+ $v_size = $v_central_dir_to_add['offset'];
2722
+ while ($v_size != 0)
2723
+ {
2724
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2725
+ $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
2726
+ @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2727
+ $v_size -= $v_read_size;
2728
+ }
2729
+ $v_offset = @ftell($v_zip_temp_fd);
2730
+ $v_size = $v_central_dir['size'];
2731
+ while ($v_size != 0)
2732
+ {
2733
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2734
+ $v_buffer = @fread($this->zip_fd, $v_read_size);
2735
+ @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2736
+ $v_size -= $v_read_size;
2737
+ }
2738
+ $v_size = $v_central_dir_to_add['size'];
2739
+ while ($v_size != 0)
2740
+ {
2741
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2742
+ $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
2743
+ @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2744
+ $v_size -= $v_read_size;
2745
+ }
2746
+ $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
2747
+ $v_size = @ftell($v_zip_temp_fd)-$v_offset;
2748
+ $v_swap = $this->zip_fd;
2749
+ $this->zip_fd = $v_zip_temp_fd;
2750
+ $v_zip_temp_fd = $v_swap;
2751
+ if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
2752
+ {
2753
+ $this->privCloseFd();
2754
+ $p_archive_to_add->privCloseFd();
2755
+ @fclose($v_zip_temp_fd);
2756
+ $this->zip_fd = null;
2757
+ unset($v_header_list);
2758
+ return $v_result;
2759
+ }
2760
+ $v_swap = $this->zip_fd;
2761
+ $this->zip_fd = $v_zip_temp_fd;
2762
+ $v_zip_temp_fd = $v_swap;
2763
+ $this->privCloseFd();
2764
+ $p_archive_to_add->privCloseFd();
2765
+ @fclose($v_zip_temp_fd);
2766
+ @unlink($this->zipname);
2767
+ PclZipUtilRename($v_zip_temp_name, $this->zipname);
2768
+ return $v_result;
2769
+ }
2770
+ function privDuplicate($p_archive_filename)
2771
+ {
2772
+ $v_result=1;
2773
+ if (!is_file($p_archive_filename))
2774
+ {
2775
+ $v_result = 1;
2776
+ return $v_result;
2777
+ }
2778
+ if (($v_result=$this->privOpenFd('wb')) != 1)
2779
+ {
2780
+ return $v_result;
2781
+ }
2782
+ if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
2783
+ {
2784
+ $this->privCloseFd();
2785
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
2786
+ return PclZip::errorCode();
2787
+ }
2788
+ $v_size = filesize($p_archive_filename);
2789
+ while ($v_size != 0)
2790
+ {
2791
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2792
+ $v_buffer = fread($v_zip_temp_fd, $v_read_size);
2793
+ @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2794
+ $v_size -= $v_read_size;
2795
+ }
2796
+ $this->privCloseFd();
2797
+ @fclose($v_zip_temp_fd);
2798
+ return $v_result;
2799
+ }
2800
+ function privErrorLog($p_error_code=0, $p_error_string='')
2801
+ {
2802
+ if (PCLZIP_ERROR_EXTERNAL == 1) {
2803
+ PclError($p_error_code, $p_error_string);
2804
+ }
2805
+ else {
2806
+ $this->error_code = $p_error_code;
2807
+ $this->error_string = $p_error_string;
2808
+ }
2809
+ }
2810
+ function privErrorReset()
2811
+ {
2812
+ if (PCLZIP_ERROR_EXTERNAL == 1) {
2813
+ PclErrorReset();
2814
+ }
2815
+ else {
2816
+ $this->error_code = 0;
2817
+ $this->error_string = '';
2818
+ }
2819
+ }
2820
+ function privDisableMagicQuotes()
2821
+ {
2822
+ $v_result=1;
2823
+ if ( (!function_exists("get_magic_quotes_runtime"))
2824
+ || (!function_exists("set_magic_quotes_runtime"))) {
2825
+ return $v_result;
2826
+ }
2827
+ if ($this->magic_quotes_status != -1) {
2828
+ return $v_result;
2829
+ }
2830
+ // ----- Get and memorize the magic_quote value
2831
+ $this->magic_quotes_status = @get_magic_quotes_runtime();
2832
+ // ----- Disable magic_quotes
2833
+ if ($this->magic_quotes_status == 1) {
2834
+ @set_magic_quotes_runtime(0);
2835
+ }
2836
+ return $v_result;
2837
+ }
2838
+ function privSwapBackMagicQuotes()
2839
+ {
2840
+ $v_result=1;
2841
+ if ( (!function_exists("get_magic_quotes_runtime"))
2842
+ || (!function_exists("set_magic_quotes_runtime"))) {
2843
+ return $v_result;
2844
+ }
2845
+ if ($this->magic_quotes_status != -1) {
2846
+ return $v_result;
2847
+ }
2848
+ // ----- Swap back magic_quotes
2849
+ if ($this->magic_quotes_status == 1) {
2850
+ @set_magic_quotes_runtime($this->magic_quotes_status);
2851
+ }
2852
+ return $v_result;
2853
+ }
2854
+ }
2855
+ function PclZipUtilPathReduction($p_dir)
2856
+ {
2857
+ $v_result = "";
2858
+ if ($p_dir != "") {
2859
+ $v_list = explode("/", $p_dir);
2860
+ $v_skip = 0;
2861
+ for ($i=sizeof($v_list)-1; $i>=0; $i--) {
2862
+ if ($v_list[$i] == ".") {
2863
+ }
2864
+ else if ($v_list[$i] == "..") {
2865
+ $v_skip++;
2866
+ }
2867
+ else if ($v_list[$i] == "") {
2868
+ // ----- First '/' i.e. root slash
2869
+ if ($i == 0) {
2870
+ $v_result = "/".$v_result;
2871
+ if ($v_skip > 0) {
2872
+ // ----- It is an invalid path, so the path is not modified
2873
+ // TBC
2874
+ $v_result = $p_dir;
2875
+ $v_skip = 0;
2876
+ }
2877
+ }
2878
+ // ----- Last '/' i.e. indicates a directory
2879
+ else if ($i == (sizeof($v_list)-1)) {
2880
+ $v_result = $v_list[$i];
2881
+ }
2882
+ // ----- Double '/' inside the path
2883
+ else {
2884
+ }
2885
+ }
2886
+ else {
2887
+ // ----- Look for item to skip
2888
+ if ($v_skip > 0) {
2889
+ $v_skip--;
2890
+ }
2891
+ else {
2892
+ $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
2893
+ }
2894
+ }
2895
+ }
2896
+ if ($v_skip > 0) {
2897
+ while ($v_skip > 0) {
2898
+ $v_result = '../'.$v_result;
2899
+ $v_skip--;
2900
+ }
2901
+ }
2902
+ }
2903
+ return $v_result;
2904
+ }
2905
+ function PclZipUtilPathInclusion($p_dir, $p_path)
2906
+ {
2907
+ $v_result = 1;
2908
+ if ( ($p_dir == '.')
2909
+ || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
2910
+ $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
2911
+ }
2912
+ if ( ($p_path == '.')
2913
+ || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
2914
+ $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
2915
+ }
2916
+ $v_list_dir = explode("/", $p_dir);
2917
+ $v_list_dir_size = sizeof($v_list_dir);
2918
+ $v_list_path = explode("/", $p_path);
2919
+ $v_list_path_size = sizeof($v_list_path);
2920
+ $i = 0;
2921
+ $j = 0;
2922
+ while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
2923
+ if ($v_list_dir[$i] == '') {
2924
+ $i++;
2925
+ continue;
2926
+ }
2927
+ if ($v_list_path[$j] == '') {
2928
+ $j++;
2929
+ continue;
2930
+ }
2931
+ if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) {
2932
+ $v_result = 0;
2933
+ }
2934
+ $i++;
2935
+ $j++;
2936
+ }
2937
+ if ($v_result) {
2938
+ while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
2939
+ while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
2940
+ if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
2941
+ $v_result = 2;
2942
+ }
2943
+ else if ($i < $v_list_dir_size) {
2944
+ $v_result = 0;
2945
+ }
2946
+ }
2947
+ return $v_result;
2948
+ }
2949
+ function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
2950
+ {
2951
+ $v_result = 1;
2952
+ if ($p_mode==0)
2953
+ {
2954
+ while ($p_size != 0)
2955
+ {
2956
+ $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
2957
+ $v_buffer = @fread($p_src, $v_read_size);
2958
+ @fwrite($p_dest, $v_buffer, $v_read_size);
2959
+ $p_size -= $v_read_size;
2960
+ }
2961
+ }
2962
+ else if ($p_mode==1)
2963
+ {
2964
+ while ($p_size != 0)
2965
+ {
2966
+ $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
2967
+ $v_buffer = @gzread($p_src, $v_read_size);
2968
+ @fwrite($p_dest, $v_buffer, $v_read_size);
2969
+ $p_size -= $v_read_size;
2970
+ }
2971
+ }
2972
+ else if ($p_mode==2)
2973
+ {
2974
+ while ($p_size != 0)
2975
+ {
2976
+ $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
2977
+ $v_buffer = @fread($p_src, $v_read_size);
2978
+ @gzwrite($p_dest, $v_buffer, $v_read_size);
2979
+ $p_size -= $v_read_size;
2980
+ }
2981
+ }
2982
+ else if ($p_mode==3)
2983
+ {
2984
+ while ($p_size != 0)
2985
+ {
2986
+ $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
2987
+ $v_buffer = @gzread($p_src, $v_read_size);
2988
+ @gzwrite($p_dest, $v_buffer, $v_read_size);
2989
+ $p_size -= $v_read_size;
2990
+ }
2991
+ }
2992
+ return $v_result;
2993
+ }
2994
+ function PclZipUtilRename($p_src, $p_dest)
2995
+ {
2996
+ $v_result = 1;
2997
+ if (!@rename($p_src, $p_dest)) {
2998
+ if (!@copy($p_src, $p_dest)) {
2999
+ $v_result = 0;
3000
+ }
3001
+ else if (!@unlink($p_src)) {
3002
+ $v_result = 0;
3003
+ }
3004
+ }
3005
+ return $v_result;
3006
+ }
3007
+ function PclZipUtilOptionText($p_option)
3008
+ {
3009
+ $v_list = get_defined_constants();
3010
+ for (reset($v_list); $v_key = key($v_list); next($v_list)) {
3011
+ $v_prefix = substr($v_key, 0, 10);
3012
+ if (( ($v_prefix == 'PCLZIP_OPT')
3013
+ || ($v_prefix == 'PCLZIP_CB_')
3014
+ || ($v_prefix == 'PCLZIP_ATT'))
3015
+ && ($v_list[$v_key] == $p_option)) {
3016
+ return $v_key;
3017
+ }
3018
+ }
3019
+ $v_result = 'Unknown';
3020
+ return $v_result;
3021
+ }
3022
+ function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
3023
+ {
3024
+ if (stristr(php_uname(), 'windows')) {
3025
+ if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
3026
+ $p_path = substr($p_path, $v_position+1);
3027
+ }
3028
+ if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
3029
+ $p_path = strtr($p_path, '\\', '/');
3030
+ }
3031
+ }
3032
+ return $p_path;
3033
+ }
3034
+ ?>
 
 
 
 
 
 
 
 
 
modules/phpseclib/index.html DELETED
@@ -1,10 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head lang="en">
4
- <meta charset="UTF-8">
5
- <title></title>
6
- </head>
7
- <body>
8
-
9
- </body>
10
- </html>
 
 
 
 
 
 
 
 
 
 
modules/restore-class.php DELETED
@@ -1,1618 +0,0 @@
1
- <?php
2
-
3
- if (!function_exists('dbr_extract_func')) {
4
- function dbr_extract_func($p_event, &$p_header)
5
- {
6
- if (stripos($p_header['filename'], 'wp-config.php') !== false) {
7
- return 0;
8
- }
9
- if (stripos($p_header['filename'], 'dropbox-backup') !== false) {
10
- return 0;
11
- }
12
- return 1;
13
- }
14
- }
15
-
16
- if (!defined('PCLZIP_SEPARATOR')) {
17
- define('PCLZIP_SEPARATOR', '<|>');
18
- }
19
-
20
- if (!function_exists('dbr_extract_func_targz')) {
21
- function dbr_extract_func_targz($filename)
22
- {
23
- if (stripos($filename, 'wp-config.php') !== false) {
24
- return true;
25
- }
26
- if (stripos($filename, 'dropbox-backup') !== false) {
27
- return true;
28
- }
29
- return false;
30
- }
31
- }
32
-
33
-
34
- if (!class_exists('dbr_gui')) {
35
- class dbr_gui {
36
-
37
- }
38
- }
39
-
40
- if (!class_exists('dbr_database')) {
41
- class dbr_database {
42
- private static $connect = null;
43
- private static $is_mysqli = true;
44
- private static $db = null;
45
- public static $db_prefix = '';
46
- public static $error = '';
47
- public static $db_params = '';
48
-
49
-
50
- private static function getWpMysqlParams()
51
- {
52
- $configs = dbr_helper::getCommand('db-settings');
53
- if ($configs === false) {
54
- $db_params = array(
55
- 'password' => 'DB_PASSWORD',
56
- 'db' => 'DB_NAME',
57
- 'user' => 'DB_USER',
58
- 'host' => 'DB_HOST',
59
- 'charset' => 'DB_CHARSET',
60
- );
61
-
62
- $r = "/define\([\s]{0,}'(.*)'[\s]{0,},[\s]{0,}'(.*)'[\s]{0,}\)/";
63
- preg_match_all($r, @file_get_contents(ABSPATH . "wp-config.php"), $m);
64
- preg_match("/table_prefix[\s]{0,}=[\s]{0,}[\"']{1}(.*)[\"']{1}/U", @file_get_contents(ABSPATH . "wp-config.php"), $pr);
65
- $params = array_combine($m[1], $m[2]);
66
- foreach($db_params as $k => $p) {
67
- $db_params[$k] = $params[$p];
68
- }
69
- self::$db_params = $db_params;
70
- if (isset($pr[1])) {
71
- self::$db_prefix = $pr[1];
72
- }
73
- } else {
74
- self::$db_params = $configs;
75
- $db_params = self::$db_params;
76
- self::$db_prefix = dbr_helper::getCommand('db-settings-prefix');
77
- }
78
- return $db_params;
79
- }
80
-
81
- public static function inc_wp_config()
82
- {
83
- if (!defined('DB_NAME') && !defined('DB_USER') && !defined('DB_PASSWORD') && !defined('DB_HOST') && is_null(self::$connect) ) {
84
-
85
- //include ABSPATH . 'wp-config.php';
86
- self::getWpMysqlParams();
87
- if ( !defined('WP_CONTENT_DIR') )
88
- define( 'WP_CONTENT_DIR', ABSPATH_REAL . 'wp-content' );
89
-
90
- if (function_exists('mysqli_connect')) {
91
- self::$is_mysqli = true;
92
- } else {
93
- self::$is_mysqli = false;
94
- }
95
-
96
- if (strpos(self::$db_params['host'], ':') !== false) {
97
- $host = explode(":", self::$db_params['host']);
98
- if (self::$is_mysqli) {
99
- self::$connect = mysqli_connect($host[0], self::$db_params['user'], self::$db_params['password'], self::$db_params['db'], $host[1]) or die(mysqli_error());
100
- mysqli_set_charset(self::$connect, self::$db_params['charset']) or die(mysql_error());
101
- } else {
102
- self::$connect = mysql_connect($host[0], self::$db_params['user'], self::$db_params['password'], self::$db_params['db'], $host[1]) or die(mysql_error());
103
- mysql_set_charset(self::$connect, self::$db_params['charset']) or die(mysql_error());
104
- }
105
- } else {
106
- if (self::$is_mysqli) {
107
- self::$connect = mysqli_connect(self::$db_params['host'], self::$db_params['user'], self::$db_params['password']) or die();
108
- mysqli_set_charset(self::$connect, self::$db_params['charset']) or die(mysqli_error());
109
- mysqli_select_db(self::$connect, self::$db_params['db']) or die(mysqli_error());
110
- } else {
111
- self::$connect = @mysql_connect(self::$db_params['host'], self::$db_params['user'], self::$db_params['password']) or die();
112
- mysql_set_charset(self::$db_params['charset'], self::$connect) or die(mysql_error());
113
- mysql_select_db(self::$db_params['db'], self::$connect) or die(mysql_error());
114
- }
115
- }
116
- if (self::$connect) {
117
- dbr_helper::setCommand('db-settings', self::$db_params);
118
- dbr_helper::setCommand('db-settings-prefix', self::$db_prefix);
119
- }
120
- }
121
- }
122
- public static function db_insert($table, $vars = array())
123
- {
124
- if (count($vars) > 0) {
125
- $stmt = "";
126
- foreach ($vars as $col_name => $value) {
127
- $stmt .= "`$col_name`='" . ($value) . "',";
128
- }
129
- if ($stmt != "") $stmt = substr($stmt, 0, -1);
130
- $table = self::$db_prefix . $table;
131
- $stmt = "INSERT `" . $table . "` SET " . $stmt . " ";
132
- return self::query($stmt);
133
- } else {
134
- return false;
135
- }
136
- }
137
-
138
- public static function db_delete ($table, $values = array() )
139
- {
140
- $res = false;
141
- if (!empty($values)) {
142
- $table = self::$db_prefix . $table;
143
- $str = array();
144
- foreach ($values as $k => $v) {
145
- $str[] = "`$k`='" . ($v) . "'";
146
- }
147
- if (count($str) == 0) return false;
148
- $stmt =
149
- "DELETE FROM `" . $table . "` "
150
- . "WHERE " . implode(" AND ", $str) ;
151
- $res = self::query($stmt);
152
- }
153
- return $res;
154
- }
155
- public static function db_update($table, $updateValues = null, $whereValues = null)
156
- {
157
- if ($updateValues !== null) {
158
- $table = self::$db_prefix . $table;
159
- $q = "UPDATE `$table` SET ";
160
- foreach($updateValues as $v=>$k){
161
- $q .= "`$v`='$k',";
162
- }
163
- $q = substr($q, 0, -1);
164
- $q .= " WHERE 1";
165
- if ($whereValues !== null) {
166
- foreach($whereValues as $v => $k){
167
- $q .= " AND `$v` = '$k'";
168
- }
169
- }
170
- return self::query($q);
171
- }
172
- return false;
173
- }
174
- public static function db_get($table, $var_key = null, $var_search = null, $limit = -1, $res_type = '', $keys_array = "", $value_array = "" )
175
- {
176
- if (!isset($var_key)) $d = "*";
177
- else {
178
- $d = "`" . implode("`, `", $var_key) . "`";
179
- }
180
- $str = array();
181
- if (count($var_search))
182
- foreach ($var_search as $k => $v) {
183
- if (!is_array($v)) {
184
- $str[] = "`$k`='" . $v . "'";
185
- } elseif(isset($v['mark'])) {
186
- $str[] = "`$k` " . $v['mark'] . $v['data'] . "";
187
- } elseif(isset($v['in']) && is_array($v['in'])) {
188
- $str[] = "`$k` IN ('" . implode('\' , \'', $v['in']) . "')";
189
- }
190
- }
191
- $lim = '';
192
- if (is_array($limit)) {
193
- $lim = ' LIMIT ' . $limit[0] . ', ' . $limit[1];
194
- $limit = -1;
195
- }
196
- $table = self::$db_prefix . $table;
197
- $whr = count($str) > 0 ? " WHERE " . implode(" AND ", $str) : '';
198
- $sql = "SELECT $d FROM `$table` ".$whr . $lim;
199
- $query = self::query($sql);
200
- return self::returnArray($query, $limit, $res_type, $keys_array, $value_array);
201
- }
202
- public static function query($stmt)
203
- {
204
- if (self::$is_mysqli) {
205
- $res = mysqli_query(self::$connect, $stmt);
206
- } else {
207
- $res = mysql_query($stmt, self::$connect );
208
- }
209
-
210
- if ( $res === false ) {
211
- if (self::$is_mysqli) {
212
- self::$error = mysqli_error(self::$connect);
213
- } else {
214
- self::$error = mysql_error(self::$connect);
215
- }
216
- }
217
-
218
- if ($res !== false and preg_match("/^INSERT/i", ltrim($stmt))) {
219
- return self::lastID(self::$connect);
220
- }
221
-
222
- return $res;
223
- }
224
- /**
225
- * get insert last id
226
- *
227
- */
228
- public static function lastID($lastlink)
229
- {
230
- if (self::$is_mysqli) {
231
- return mysqli_insert_id($lastlink);
232
- } else {
233
- return mysql_insert_id($lastlink);
234
- }
235
- }
236
- public static function num($res)
237
- {
238
- if (self::$is_mysqli) {
239
- return mysqli_num_rows($res);
240
- } else {
241
- return mysql_num_rows($res);
242
- }
243
- }
244
- private static function returnArray($query, $limit = 1, $res_type = '', $key = "", $value = "")
245
- {
246
- if ($query && self::num($query) > 0) {
247
- $res = false;
248
- if ($limit == 1) {
249
- $rec = self::fetch($query, $res_type);
250
- $res = self::value_keys($rec, $key, $value);
251
- } else {
252
- if (!empty($key) && !empty($value)) {
253
- while ($rec = self::fetch($query, $res_type)) {
254
- $res[$rec[$key]] = $rec[$value];
255
- }
256
- } elseif (empty($key) && !empty($value)) {
257
- while ($rec = self::fetch($query, $res_type)) {
258
- $res[] = $rec[$value];
259
- }
260
- } elseif (empty($value) && !empty($key)) {
261
- while ($rec = self::fetch($query, $res_type)) {
262
- $res[$rec[$key]] = $rec;
263
- }
264
- } elseif ($limit != -1) {
265
- $i = 1;
266
- while ($rec = self::fetch($query, $res_type)) {
267
- if ($i >= $limit) {
268
- break;
269
- }
270
- $res[] = $rec;
271
- $i++;
272
- }
273
- } else {
274
- while ($rec = self::fetch($query, $res_type)) {
275
- $res[] = $rec;
276
- }
277
- }
278
- }
279
- return $res;
280
- }
281
- return false;
282
- }
283
- private static function fetch ($res, $res_type = '')
284
- {
285
- if (defined('MYSQL_BOTH') && empty( $res_type ) ) {
286
- $res_type = MYSQL_BOTH;
287
- } elseif( defined('MYSQLI_BOTH') && empty( $res_type ) ) {
288
- $res_type = MYSQLI_BOTH;
289
- }
290
- if (self::$is_mysqli) {
291
- return mysqli_fetch_array($res, $res_type);
292
- } else {
293
- return mysql_fetch_array($res, $res_type);
294
- }
295
-
296
- }
297
-
298
- public static function value_keys($array_from, $key = "", $value = "")
299
- {
300
-
301
- $returned = array();
302
- if (!empty($key) && !empty($value)) {
303
- if (isset($array_from[$key]) && isset($array_from[$value])) {
304
- $returned[$array_from[$key]] = $array_from[$value];
305
- }
306
- } elseif(empty($key) && !empty($value)) {
307
- if (isset($array_from[$value])) {
308
- $returned = $array_from[$value];
309
- }
310
- } elseif(empty($value) && !empty($key)) {
311
- if (isset($array_from[$key])) {
312
- $returned[$array_from[$key]] = $array_from;
313
- }
314
- } else {
315
- $returned = $array_from;
316
- }
317
-
318
- return $returned;
319
- }
320
- }
321
- }
322
-
323
- if ( !class_exists('dbr_api') ) {
324
- class dbr_api {
325
- public static function post($url, $post, $options = array() )
326
- {
327
- $info = array();
328
- $result = '';
329
- if (function_exists("curl_init") && function_exists("curl_setopt") && function_exists("curl_exec") && function_exists("curl_close")) {
330
- $curl = curl_init($url);
331
-
332
- $post = http_build_query($post, '', '&');
333
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
334
- curl_setopt($curl, CURLOPT_POST, true);
335
- curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
336
- if (!empty($options)) {
337
- if(isset($options['timelimit'])) {
338
- curl_setopt($curl, CURLOPT_TIMEOUT, $options['timelimit']);
339
- }
340
- }
341
- $result = curl_exec($curl);
342
- $info = curl_getinfo($curl);
343
- curl_close($curl);
344
- } elseif (function_exists("fsockopen")) {
345
- include_once 'HttpFsockopen.php';
346
- $socket = new HttpFsockopen($url, false);
347
- $socket->setPostData($post);
348
- if (isset($options['timelimit'])) {
349
- $socket->setTimeout($options['timelimit']);
350
- }
351
- $res = $socket->exec();
352
- $res = self::getResult($res);
353
- if (isset($res[1])) {
354
- $result = $res[1];
355
- }
356
- }
357
- return array('res' => $result, 'info' => $info );
358
- }
359
- public static function getResult ($str, $patern = "\r\n\r\n", $is_json = false)
360
- {
361
- if ($is_json === false) {
362
- return explode($patern, $str);
363
- } else {
364
- $res = explode($patern, $str);
365
- $n = count($res);
366
- $result = '';
367
- for($i = 0; $i < $n; $i++) {
368
- if ( preg_match_all("/[\{\"\:\,\}\s]+/is", trim($res[$i]), $r ) ) {
369
- $result .= str_replace(array("\r", "\n"), '', $res[$i]);
370
- }
371
- }
372
- return $result;
373
- }
374
- }
375
- }
376
-
377
- }
378
-
379
- if ( !class_exists('dbr_helper') ) {
380
- class dbr_helper {
381
-
382
- private static $cron_is_work = 90;
383
-
384
- public static function testOtherArchive()
385
- {
386
- dbr_log::log('Testing of TarGz under shell');
387
- $res_tar = self::TarGz( DBP_PATH_TMP . '/test.tar.gz', array(DBP_PATH_TMP .'/index.php', DBP_PATH_TMP .'/.htaccess'), ABSPATH );
388
-
389
- if ($res_tar === true) {
390
- dbr_log::log('Testing of TarGz under shell was finished successfully');
391
- dbr_helper::setCommand('test_targz_c', true);
392
- }
393
- dbr_log::log('Testing of unTarGz under shell');
394
- $res_tar = self::unTarGz( DBP_PATH_TMP . '/test.tar.gz', DBP_PATH_TMP . '/test/' );
395
- if ($res_tar === true) {
396
- dbr_log::log('Testing of unTarGz under shell was finished successfully');
397
- dbr_helper::setCommand('test_targz_c', true);
398
- }
399
-
400
- dbr_log::log('Testing of Zip under shell');
401
- $res_zip = self::Zip( DBP_PATH_TMP . '/test.zip', array(DBP_PATH_TMP .'/index.php', DBP_PATH_TMP .'/.htaccess'), ABSPATH );
402
- if ($res_tar === true) {
403
- dbr_log::log('Testing of ZIP under shell was finished successfully');
404
- dbr_helper::setCommand('test_zip_c', true);
405
- }
406
- }
407
-
408
- public static function getCommandToArchive($file_name, $type = 'zip_archive', $files = array(), $type_action = 'create', $remove_path = '' )
409
- {
410
- $return = '';
411
- $remove_dir = '';
412
- switch($type) {
413
- case 'zip_archive':
414
- if ($type_action == 'create') {
415
- if (!empty( $remove_path ) ) {
416
- $remove_dir = 'cd ' . $remove_path. ' &&';
417
- $files_str = '"' . implode('" "', $files) . '"';
418
- $files_str = str_replace($remove_path, './', $files_str);
419
- $zip = str_replace($remove_path, './', $file_name);
420
- } else {
421
- $files_str = '"' . implode('" "', $files) . '"';
422
- $zip = $file_name;
423
- }
424
- $return .= trim( "$remove_dir zip {$zip} " . $files_str );
425
- } else {
426
- $zip = $file_name;
427
- if (!empty( $remove_path ) ) { // for extract this param of directory to
428
- $remove_dir = 'cd ' . $remove_path . ' &&';
429
- }
430
- $exclude = '';
431
- if ( !empty( $files ) ) { // exclude file
432
- $exclude = ' -x ' . '"' . implode('" "', $files) . '"';
433
- }
434
- $return .= trim( "$remove_dir unzip -o {$zip} $exclude" );
435
- }
436
-
437
- break;
438
- case 'tar_archive':
439
- if ( strpos($file_name, '.zip') !== false ) {
440
- $file_name = str_replace('.zip', '.tar.gz', $file_name);
441
- }
442
-
443
- if (!empty( $remove_path ) ) {
444
- $remove_dir = '-C "' . $remove_path . '" ';
445
- }
446
- if ($type_action == 'create') {
447
- $files_str = '"' . implode('" "', $files) . '"';
448
- $files_str = str_replace($remove_path, './', $files_str);
449
- $u = 'c';
450
- if (file_exists($file_name)) {
451
- $u = 'r';
452
- }
453
- $return = trim( "tar -{$u}zvf {$file_name} " . $remove_dir . $files_str );
454
- } else {
455
-
456
- $return = trim( "tar zxvf \"{$file_name}\" " . $remove_dir );
457
- }
458
- break;
459
- }
460
- return $return;
461
-
462
- }
463
-
464
- public static function parseResultZip($command_return)
465
- {
466
- $add = 0;
467
- $error = 0;
468
- if (!empty( $command_return) ) {
469
- $n = count($command_return);
470
- for($i = 0; $i < $n; $i++) {
471
- if (strpos($command_return[$i], 'add') !== false || strpos($command_return[$i], 'updating') !== false || strpos($command_return[$i], 'inflating') !== false) {
472
- $add ++;
473
- } elseif (strpos($command_return[$i], 'error') !== false || strpos($command_return[$i], 'warning') !== false ) {
474
- $error++;
475
- $this->error .= " " . $command_return[$i];
476
- }
477
- }
478
- }
479
- return array( 'add' => $add, 'error' => $error );
480
-
481
- }
482
-
483
- public static function TarGz($file_name, $files, $delete_foler = '')
484
- {
485
- $command = self::getCommandToArchive($file_name, 'tar_archive', $files, 'create', $delete_foler);
486
- if (!empty($command)) {
487
-
488
- $result_command = @exec($command, $command_return);
489
-
490
- if (count($files) == count($command_return)) {
491
- return true;
492
- }
493
-
494
- if (count($command_return) > 0) {
495
- return true;
496
- }
497
- if (file_exists($file_name)) {
498
- return true;
499
- }
500
- return "Files not adding to arhive";
501
- }
502
-
503
- return false;
504
- }
505
-
506
- public static function unTarGz($file_name, $dir_to)
507
- {
508
- $command = self::getCommandToArchive($file_name, 'tar_archive', array(), 'etract', $dir_to);
509
-
510
- if (!empty($command)) {
511
-
512
- $result_command = @exec($command, $command_return);
513
-
514
- if (count($command_return) > 0) {
515
- return true;
516
- }
517
- if (file_exists($file_name)) {
518
- return true;
519
- }
520
- return "Files not adding to arhive";
521
- }
522
-
523
- return false;
524
- }
525
-
526
- public static function Zip($file_name, $files, $delete_foler = '')
527
- {
528
- $command = self::getCommandToArchive($file_name, 'zip_archive', $files, 'create', $delete_foler);
529
- if (!empty($command)) {
530
- $result_command = @exec($command, $command_return);
531
-
532
- $res = self::parseResultZip($command_return);
533
-
534
- if ($res['add'] == count($files)) {
535
- return true;
536
- }
537
- if ( file_exists( $file_name ) && $res['error'] === 0 ) {
538
- return true;
539
- }
540
- }
541
-
542
- return false;
543
- }
544
-
545
- public static function unZip($file_name, $dir_to, $exclude = array() )
546
- {
547
- $command = self::getCommandToArchive($file_name, 'zip_archive', $exclude, 'extract', $dir_to);
548
- if (!empty($command)) {
549
- $result_command = @exec($command, $command_return);
550
-
551
- $res = self::parseResultZip($command_return);
552
-
553
- if ( $res['error'] === 0 ) {
554
- return true;
555
- }
556
- }
557
-
558
- return false;
559
- }
560
-
561
- public static function check_invalid_utf8( $string, $strip = false )
562
- {
563
- $string = (string) $string;
564
-
565
- if ( 0 === strlen( $string ) ) {
566
- return '';
567
- }
568
- // preg match invalid UTF8
569
- if ( 1 === @preg_match( '/^./us', $string ) ) {
570
- return $string;
571
- }
572
-
573
- if ( $strip && function_exists( 'iconv' ) ) {
574
- return iconv( 'utf-8', 'utf-8', $string );
575
- }
576
-
577
- return '';
578
- }
579
-
580
-
581
- public static function strip_all_tags($string, $remove_breaks = false) {
582
- $string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string );
583
- $string = strip_tags($string);
584
-
585
- if ( $remove_breaks )
586
- $string = preg_replace('/[\r\n\t ]+/', ' ', $string);
587
-
588
- return trim( $string );
589
- }
590
-
591
- public static function less_than( $text ) {
592
- return preg_replace_callback('%<[^>]*?((?=<)|>|$)%', array('dbr_helper', 'less_than_callback'), $text);
593
- }
594
-
595
- public static function less_than_callback( $matches ) {
596
- if ( false === strpos($matches[0], '>') )
597
- return self::to_html($matches[0]);
598
- return $matches[0];
599
- }
600
-
601
- public static function to_html($string, $quote_style = ENT_NOQUOTES)
602
- {
603
- $string = (string) $string;
604
-
605
- if ( 0 === strlen( $string ) )
606
- return '';
607
-
608
- if ( ! preg_match( '/[&<>"\']/', $string ) )
609
- return $string;
610
-
611
- if ( empty( $quote_style ) )
612
- $quote_style = ENT_NOQUOTES;
613
- elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) )
614
- $quote_style = ENT_QUOTES;
615
-
616
- $charset = 'UTF-8';
617
-
618
- $string = @htmlspecialchars( $string, $quote_style, $charset, $double_encode );
619
-
620
- if ( 'single' === $_quote_style )
621
- $string = str_replace( "'", '&#039;', $string );
622
-
623
- return $string;
624
- }
625
-
626
- public static function sanitize($str, $is_newlines = false)
627
- {
628
- $filter = self::check_invalid_utf8( $str );
629
- if ( strpos($filter, '<') !== false ) {
630
- $filter = self::less_than( $filter );
631
- $filter = self::strip_all_tags( $filter, false );
632
- $filter = str_replace("<\n", "&lt;\n", $filter);
633
- }
634
-
635
- if ( !$is_newlines ) {
636
- $filter = preg_replace( '/[\r\n\t ]+/', ' ', $filter );
637
- }
638
- $filter = trim( $filter );
639
-
640
- return $filter;
641
-
642
- }
643
-
644
- public static function modSecureInstalled()
645
- {
646
- $contents = '';
647
- if (defined('INFO_MODULES') && function_exists('phpinfo')) {
648
- ob_start();
649
- @phpinfo(INFO_MODULES);
650
- $contents = ob_get_clean();
651
- }
652
- return strpos($contents, 'mod_security') !== false;
653
- }
654
-
655
- public static function is_writable($file_dir = '')
656
- {
657
- if (!empty($file_dir)) {
658
- if (is_dir($file_dir)) {
659
- @file_put_contents($file_dir . "/test.file", 'test writable');
660
- if ( file_exists($file_dir . "/test.file") && is_writable($file_dir . "/test.file") && filesize($file_dir . "/test.file") > 0 ) {
661
- return true;
662
- }
663
- }
664
- if (file_exists($file_dir) && is_file($file_dir)) {
665
- return is_writable($file_dir);
666
- }
667
- }
668
- return false;
669
- }
670
-
671
- public static function setError($txt)
672
- {
673
- throw new Exception($txt);
674
- }
675
-
676
- public static function is_work($time = '', $type = '')
677
- {
678
- $res = true;
679
- $file = DBP_PATH_TMP . '/cron-restore.data';
680
- if (file_exists($file)) {
681
- $cron = dbr_helper::unpack( @file_get_contents($file) );
682
- if (empty($time)) {
683
- if (isset($cron['finish'])) {
684
- $res = true;
685
- } else {
686
- if (isset($cron['start']) && ( $cron['start'] + self::$cron_is_work ) < time() ) {
687
- $res = false;
688
- }
689
- }
690
- } else {
691
- $cron[$type] = $time;
692
- @file_put_contents($file, dbr_helper::pack($cron) );
693
- }
694
- } else {
695
- if (!empty($time)) {
696
- $cron[$type] = $time;
697
- @file_put_contents($file, dbr_helper::pack($cron) );
698
- }
699
- $res = false;
700
- }
701
- return $res;
702
- }
703
-
704
-
705
- public static function getProjectName()
706
- {
707
- $name_running_backup = '';
708
- $site_url = dbr_database::db_get('options', array('option_value'), array('option_name' => 'siteurl'), 1);
709
- if (isset($site_url['option_value'])) {
710
- $name_running_backup = str_replace("http://", '', $site_url['option_value']);
711
- $name_running_backup = str_replace("https://", '', $name_running_backup);
712
- $name_running_backup = preg_replace("|\W|", "_", trim($name_running_backup, '/') );
713
- }
714
- return $name_running_backup;
715
- }
716
- public static function clearTMP()
717
- {
718
- if (is_dir(DBP_PATH_TMP)) {
719
- $files = opendir(DBP_PATH_TMP);
720
- while($file = readdir($files)) {
721
- if (file_exists(DBP_PATH_TMP . '/' . $file)) {
722
- @unlink(DBP_PATH_TMP . '/' . $file);
723
- }
724
- }
725
- self::createDefaultFiles(DBP_PATH_TMP);
726
- // @rmdir(DBP_PATH_TMP);
727
- }
728
- }
729
-
730
- public static function createDefaultFiles($dir)
731
- {
732
- if (!file_exists($dir . '/index.php')) {
733
- @file_put_contents($dir . '/index.php', '<?php echo "Hello World!"; ');
734
- if ( !is_writable($dir . '/index.php') ) {
735
- return str_replace("&s", $dir . '/index.php' , 'Backup creating<br /><br />Please check the permissions on file "&s". Failed to create file.' );
736
- }
737
- }
738
- if (!file_exists($dir . '/.htaccess')) {
739
- @file_put_contents($dir . '/.htaccess', 'DENY FROM ALL');
740
- }
741
- return true;
742
- }
743
-
744
-
745
- public static function unpack_setting($str)
746
- {
747
- return unserialize( base64_decode( $str ) );
748
- }
749
-
750
- public static function pack_setting($str)
751
- {
752
- return base64_encode( serialize( $str ) );
753
- }
754
-
755
- public static function pack($data)
756
- {
757
- if (defined('JSON_HEX_TAG') && defined('JSON_HEX_QUOT') && defined('JSON_HEX_AMP') && defined('JSON_HEX_APOS') ) {
758
- return base64_encode( json_encode ( $data, JSON_HEX_QUOT|JSON_HEX_TAG|JSON_HEX_AMP|JSON_HEX_APOS ) ) ;
759
- }
760
- return base64_encode( json_encode ( $data ) ) ;
761
- }
762
-
763
- public static function unpack($data)
764
- {
765
- return json_decode( base64_decode( $data ), true );
766
- }
767
-
768
- public static function mkdir($path)
769
- {
770
- $error = '';
771
- if (!is_dir($path)) {
772
- @mkdir($path, 0755);
773
-
774
- if (!is_dir($path)) {
775
- $error = str_replace("%s", $dir, 'Failed to create a file, please check the permissions on the folders "%s".' );
776
- }
777
- @file_put_contents($path . '/index.php', '<?php // create automatically' );
778
- if ( !is_writable($path . '/index.php') ) {
779
- $error = str_replace("%s", $dir, 'Failed to create a file, please check the permissions on the folders "%s".');
780
- }
781
- }
782
- return $error;
783
- }
784
-
785
- public static function setCommand($command, $value, $key = '' )
786
- {
787
- if (!is_dir(DBP_PATH_TMP)) {
788
- self::mkdir(DBP_PATH_TMP);
789
- }
790
- $data = array();
791
- if (file_exists(DBP_PATH_TMP . '/' . $command )) {
792
- $data = self::unpack(@file_get_contents( DBP_PATH_TMP . '/' . $command ) );
793
- }
794
- if (!empty($key)) {
795
- $data[$key] = $value;
796
- } else {
797
- $data = $value;
798
- }
799
- @file_put_contents(DBP_PATH_TMP . '/' . $command, self::pack($data) );
800
- }
801
-
802
- public static function getCommand($command, $key = '')
803
- {
804
- if (file_exists(DBP_PATH_TMP . '/' . $command)) {
805
- $tmp = dbr_helper::unpack( @file_get_contents(DBP_PATH_TMP . '/' . $command) );
806
- if (!empty($key) ) {
807
- if (isset($tmp[$key])) {
808
- return $tmp[$key];
809
- }
810
- } else {
811
- return $tmp;
812
- }
813
- }
814
- return false;
815
- }
816
-
817
- static function rmdir($dir)
818
- {
819
- if (is_dir($dir)) {
820
- $dir_open = opendir($dir);
821
- while($f = readdir($dir_open)) {
822
- if ($f == '..' or $f == '.') {
823
- continue;
824
- }
825
- if (is_dir($dir . '/' . $f)) {
826
- self::rmdir($dir . '/' . $f);
827
- }
828
- if (file_exists($dir . '/' . $f)) {
829
- @unlink($dir . '/' . $f);
830
- }
831
- }
832
- @rmdir($dir);
833
- } elseif (is_file($dir)) {
834
- @unlink($dir);
835
- }
836
- }
837
-
838
- }
839
- }
840
-
841
- if ( !class_exists('dbr_log') ) {
842
- class dbr_log {
843
-
844
- public static function log($txt = '', $class = '')
845
- {
846
- if (!empty($txt)) {
847
- dbr_helper::mkdir(DBP_PATH_TMP);
848
- $log_file = DBP_PATH_TMP . '/log-restore.log';
849
- @file_put_contents($log_file, date("Y-m-d H:i:s") ."\t{$class}\t{$txt}\n", FILE_APPEND);
850
- }
851
- }
852
-
853
- public static function getLog()
854
- {
855
- $log_file = DBP_PATH_TMP . '/log-restore.log';
856
- if (file_exists($log_file)) {
857
- $log2 = DBP_PATH_TMP. "/log-restore2";
858
- $log = @file_get_contents($log_file);
859
- if (file_exists($log2)) {
860
- $text = @file_get_contents($log2);
861
- file_put_contents($log2, $log);
862
- $log = str_replace($text, "", $log);
863
- } else {
864
- @file_put_contents($log2, $log);
865
- }
866
- $log = explode("\n", $log);
867
- krsort($log);
868
- $log_array = $log;
869
- return $log_array;
870
- }
871
- return array();
872
- }
873
- }
874
- }
875
-
876
- if ( !class_exists('dbr_core') ) {
877
- class dbr_core {
878
-
879
- }
880
- }
881
-
882
-
883
-
884
- if ( !class_exists('dbr_methods') ) {
885
- class dbr_methods{
886
-
887
- private $setting_restore = array();
888
- private $main = array();
889
- private $md5_info = array();
890
- private $dir_backup = '';
891
- private $files_resotre = array();
892
- /**
893
- * MAIN METHOD
894
- *
895
- */
896
- public function wpadm_logs_method()
897
- {
898
- $json = array();
899
- $json['log'] = dbr_log::getlog();
900
- if ( isset($_POST['type-backup']) && $_POST['type-backup'] == 'restore' ) {
901
- if (file_exists(DBP_PATH_TMP . '/result-restore')) {
902
- $json['data'] = dbr_helper::getCommand('result-restore');
903
- }
904
- }
905
-
906
- $mod_security = dbr_helper::getCommand('mod_security');
907
- if ($mod_security) {
908
- $json['mod_secur'] = true;
909
- }
910
- echo json_encode ( $json );
911
- exit;
912
- }
913
-
914
- /**
915
- * MAIN METHOD
916
- *
917
- */
918
- public function restore_method()
919
- {
920
- $this->setting_restore = dbr_helper::getCommand('restore-backup');
921
- if (isset($this->setting_restore['action'])) {
922
- dbr_log::log('Start restoring of backup "' . $this->setting_restore['name'] . '"');
923
-
924
- $setting = dbr_database::db_get('options', array('option_value'), array('option_name' => 'wpadm_backup_dropbox-setting'), 1);
925
- if (isset($setting['option_value'] )) {
926
- $this->main = dbr_helper::unpack_setting( $setting['option_value'] );
927
- }
928
-
929
- $backup_dir = WP_CONTENT_DIR . '/' . DROPBOX_BACKUP_DIR_NAME;
930
- if (isset($this->main['backup_folder']) && !empty($this->main['backup_folder'])) {
931
- $backup_dir = $this->main['backup_folder'];
932
- }
933
- $this->base_dir = $backup_dir;
934
- $this->dir_backup = $backup_dir . "/{$this->setting_restore['name']}";
935
- switch($this->setting_restore['action']) {
936
- case 'wpadm_restore_dropbox':
937
- if ( $this->dowloadDropbox() ) {
938
- $this->parseFilesToRestore();
939
- $this->restoreFiles();
940
- $this->restoreDataBase();
941
- dbr_helper::rmdir($this->dir_backup);
942
- }
943
- break;
944
- case 'wpadm_local_restore':
945
- $this->parseFilesToRestore();
946
- $this->restoreFiles();
947
- $this->restoreDataBase();
948
- break;
949
- }
950
- } else {
951
- dbr_helper::setError('Unknown action of backup method to start restoring.');
952
- }
953
- }
954
- private function restoreDataBase()
955
- {
956
- dbr_log::log('Database restoring was started');
957
- $file = DROPBOX_BACKUP_DIR_BACKUP . '/mysqldump.sql';
958
- if (!file_exists($file)) {
959
- dbr_helper::setError( 'Error: dump/database file wasn\'t found' );
960
- }
961
- $fo = fopen($file, "r");
962
- if (!$fo) {
963
- dbr_helper::setError( 'Error of opening dump/database file' );
964
- }
965
- dbr_helper::is_work(time(), 'start');
966
- $sql = "";
967
- while(false !== ($char = fgetc($fo))) {
968
- $sql .= $char;
969
- if ($char == ";") {
970
- $char_new = fgetc($fo);
971
- if ($char_new !== false && $char_new != "\n") {
972
- $sql .= $char_new;
973
- } else {
974
- $is_sql = true;
975
- if ( strpos($sql, '_transient_timeout_drb_running') !== false ) {
976
- $is_sql = false;
977
- }
978
- if ( strpos($sql, '_transient_drb_running') !== false ) {
979
- $is_sql = false;
980
- }
981
- if ( strpos($sql, PREFIX_BACKUP_ . "_commands") !== false ) {
982
- $is_sql = false;
983
- }
984
- if ( strpos($sql, PREFIX_BACKUP_ . "proccess-command") !== false ) {
985
- $is_sql = false;
986
- }
987
- if ($is_sql) {
988
- $arr_sql = dbr_helper::getCommand('sql-restore');
989
- if ( !isset( $arr_sql[md5($sql)] ) || $arr_sql === false ) {
990
- $ress = dbr_database::query( $sql );
991
- dbr_helper::is_work(time(), 'start');
992
- if (stripos($sql, 'create') !== false) {
993
- preg_match("/CREATE[\s]{1,}TABLE[\s]{1,}`(.*)`/iUu", $sql, $table_insert) ;
994
- if (isset($table_insert[1]) && !empty($table_insert[1])) {
995
- dbr_log::log('Restore table `' . $table_insert[1] . '`');
996
- }
997
- }
998
-
999
- if (isset($ress) && ( $ress === false || !empty( dbr_database::$error ) ) ) {
1000
- if (stripos(dbr_database::$error, 'duplicate entry') === false) {
1001
- dbr_helper::setError('MySQL Error: ' . dbr_database::$error . ' sql: ' . $sql );
1002
- break;
1003
- }
1004
- }
1005
- $arr_sql[md5($sql)] = 1;
1006
- dbr_helper::setCommand('sql-restore', $arr_sql);
1007
- }
1008
- }
1009
- if (isset($ress) && ( $ress === false || !empty( dbr_database::$error ) ) ) {
1010
- if (stripos(dbr_database::$error, 'duplicate entry') === false) {
1011
- dbr_helper::setError('MySQL Error: ' . dbr_database::$error . ' sql: ' . $sql );
1012
- break;
1013
- }
1014
- }
1015
- $sql = "";
1016
- }
1017
- }
1018
- }
1019
-
1020
- // ----------------- set command for create backup to null
1021
- dbr_database::db_update('options', array('option_value' => serialize( array() ) ), array('option_name' => PREFIX_BACKUP_ . "_commands") );
1022
- dbr_database::db_update('options', array('option_value' => serialize( array() ) ), array('option_name' => PREFIX_BACKUP_ . "proccess-command") );
1023
- // -----------------
1024
- dbr_helper::setCommand('result-restore', array('name' => $this->setting_restore['name'], 'result' => 'success'));
1025
- dbr_log::log( 'Database restoring was finished successfully' );
1026
- }
1027
- private function parseFilesToRestore()
1028
- {
1029
- $md5_info = dbr_helper::getCommand('md5_info-restore');
1030
- $file_list = dbr_helper::getCommand('files-list-retore');
1031
- if (!$md5_info || !$file_list) {
1032
- dbr_log::log('Reading backup files and creating of file list for restoring process');
1033
- dbr_helper::is_work(time(), 'start');
1034
- $dir_open = opendir($this->dir_backup);
1035
- $file_md5 = '';
1036
- while($d = readdir($dir_open)) {
1037
- if ($d != "." && $d != '..') {
1038
- if(strpos($d, ".zip") !== false) {
1039
- $this->files_resotre[$d] = $this->dir_backup . "/$d";
1040
- }
1041
- if(substr($d, -7) == '.tar.gz') {
1042
- $this->files_resotre[$d] = $this->dir_backup . "/$d";
1043
- dbr_helper::setCommand('targz', true);
1044
- }
1045
- if(strpos($d, ".md5") !== false) {
1046
- $file_md5 = $this->dir_backup . "/$d";
1047
- }
1048
- }
1049
- }
1050
- dbr_helper::setCommand('files-list-retore', $this->files_resotre);
1051
- dbr_helper::is_work(time(), 'start');
1052
-
1053
- if (!empty($file_md5)) {
1054
-
1055
- if (file_exists($file_md5)) {
1056
- $this->md5_info = explode ("\n", @file_get_contents( $file_md5 ) ); // delemiter \t (1 - file name, 2 - md5_file, 3 - zip file)
1057
- dbr_helper::setCommand('md5_info-restore', $this->md5_info);
1058
- dbr_helper::is_work(time(), 'start');
1059
- } else {
1060
- dbr_helper::setError('Error of MD5 file parsing during restoring of backup');
1061
- }
1062
- } else {
1063
- dbr_helper::setError('Error during creating of MD5 file list for restoring process. Backup files wasn\'t found');
1064
- }
1065
- } else {
1066
- $this->md5_info = $md5_info;
1067
- $this->files_resotre = $file_list;
1068
- }
1069
-
1070
- }
1071
-
1072
- private function reconfig()
1073
- {
1074
-
1075
- dbr_helper::is_work(time(), 'start');
1076
- if ( dbr_helper::is_writable(ABSPATH . 'wp-config.php') === false) {
1077
- dbr_helper::setError( "File 'wp-config.php' is not writable" );
1078
- }
1079
- $db_params = array(
1080
- 'password' => 'DB_PASSWORD',
1081
- 'db' => 'DB_NAME',
1082
- 'user' => 'DB_USER',
1083
- 'host' => 'DB_HOST',
1084
- 'charset' => 'DB_CHARSET',
1085
- );
1086
-
1087
- $r = "/define\([\s]{0,}['\"]{1}(.*)['\"]{1}[\s]{0,},[\s]{0,}['\"]{1}(.*)['\"]{1}[\s]{0,}\)/";
1088
- $config = @file_get_contents(ABSPATH . "wp-config.php");
1089
- preg_match_all($r, $config, $m);
1090
- $params = array_combine( $m[1], $m[2] );
1091
- $change_config = false;
1092
- foreach($db_params as $k => $p) {
1093
- $db_params[$k] = $params[$p];
1094
- if (dbr_database::$db_params[$k] != $db_params[$k]) {
1095
- $change_config = true;
1096
- }
1097
- }
1098
- dbr_helper::is_work(time(), 'start');
1099
- if ($change_config) {
1100
- dbr_log::log('Configure file "wp-config.php" was started');
1101
- $patterns = array();
1102
- $patterns[0] = "/define[\s]{0,}\([\s]{0,}'DB_PASSWORD'[\s]{0,},[\s]{0,}'(.*)'[\s]{0,}\)/";
1103
- $patterns[1] = "/define[\s]{0,}\([\s]{0,}'DB_NAME'[\s]{0,},[\s]{0,}'(.*)'[\s]{0,}\)/";
1104
- $patterns[2] = "/define[\s]{0,}\([\s]{0,}'DB_USER'[\s]{0,},[\s]{0,}'(.*)'[\s]{0,}\)/";
1105
- $patterns[3] = "/define[\s]{0,}\([\s]{0,}'DB_HOST'[\s]{0,},[\s]{0,}'(.*)'[\s]{0,}\)/";
1106
- $patterns[4] = "/define[\s]{0,}\([\s]{0,}'DB_CHARSET'[\s]{0,},[\s]{0,}'(.*)'[\s]{0,}\)/";
1107
-
1108
- $replacements = array();
1109
- $replacements[0] = "define('DB_PASSWORD', '" . dbr_database::$db_params['password'] . "')";
1110
- $replacements[1] = "define('DB_NAME', '" . dbr_database::$db_params['db'] . "')";
1111
- $replacements[2] = "define('DB_USER', '" . dbr_database::$db_params['user'] . "')";
1112
- $replacements[3] = "define('DB_HOST', '" . dbr_database::$db_params['host'] . "')";
1113
- $replacements[4] = "define('DB_CHARSET', '" . dbr_database::$db_params['charset'] . "')";
1114
-
1115
- $config = preg_replace($patterns, $replacements, $config);
1116
-
1117
- //$config = preg_replace("/table_prefix[\s]{0,}=[\s]{0,}[\"']{1}(.*)[\"']{1}/U", "table_prefix = '" . dbr_database::$db_prefix . "'", $config);
1118
-
1119
- $write = @file_put_contents(ABSPATH . "wp-config.php", $config);
1120
-
1121
- dbr_helper::is_work(time(), 'start');
1122
- if (!$write) {
1123
- dbr_helper::setError( "File 'wp-config.php' is not writable" );
1124
- }
1125
- dbr_log::log('Configure file "wp-config.php" was successfully');
1126
- }
1127
- }
1128
-
1129
- private function restoreFiles()
1130
- {
1131
-
1132
- $files = dbr_helper::getCommand('files-list-retore');
1133
- if ($files) {
1134
- dbr_helper::is_work(time(), 'start');
1135
- if ( empty( $this->md5_info ) ) {
1136
- $this->md5_info = dbr_helper::getCommand('md5_info-restore');
1137
- }
1138
- $zip_database = dbr_helper::getCommand('zip-database');
1139
- if (!$zip_database) {
1140
- $while = true;
1141
- while($while) {
1142
- $file_info = array_pop($this->md5_info);
1143
- if (strpos($file_info, 'mysqldump.sql') !== false && strpos($file_info, DROPBOX_BACKUP_DIR_NAME) !== false) {
1144
- $info = explode("\t", $file_info);
1145
- if (isset($info[2])) {
1146
- $zip_database = $info;
1147
- dbr_helper::setCommand('zip-database', $zip_database);
1148
- $while = false;
1149
- }
1150
- }
1151
- }
1152
- }
1153
- $zip_config = dbr_helper::getCommand('zip-config');
1154
- if ($zip_config === false || $zip_config != null) {
1155
- $md5_info = dbr_helper::getCommand('md5_info-restore');
1156
- $while = true;
1157
- if($md5_info) {
1158
- while($while) {
1159
- $file_info = array_shift($md5_info);
1160
- if (strpos($file_info, 'wp-config.php') !== false) {
1161
- $info = explode("\t", $file_info);
1162
- if (isset($info[2])) {
1163
- $zip_config = $info;
1164
- dbr_helper::setCommand('zip-config', $zip_config);
1165
- $while = false;
1166
- }
1167
- }
1168
- }
1169
- dbr_helper::setCommand('zip-config', null);
1170
- }
1171
- }
1172
- $tar_gz = dbr_helper::getCommand('targz');
1173
- if (!$tar_gz) {
1174
- include 'pclzip.lib.php';
1175
- }
1176
- foreach($files as $f => $file) {
1177
- $extract_files = dbr_helper::getCommand('extract-files-restore');
1178
- if (!isset($extract_files[$f])) {
1179
- dbr_log::log('Data will be decompressed of ' . basename($file));
1180
- if (strpos($f, '.zip')) {
1181
- if (file_exists($file) && filesize($file) > 0) {
1182
- $test_zip = dbr_helper::getCommand('test_zip_c');
1183
- if ($test_zip) {
1184
- $unzip = dbr_helper::unZip($file, ABSPATH_REAL, array('wp-content/plugins/dropbox-backup/*', 'wp-content/plugins/dropbox-backup-pro/*') );
1185
- if ($unzip) {
1186
- if ($zip_config && strpos($file, $zip_config[2]) !== false) {
1187
- $this->reconfig();
1188
- }
1189
- $extract_files[$f] = true;
1190
- dbr_helper::setCommand('extract-files-restore', $extract_files);
1191
- continue;
1192
- } else {
1193
- dbr_log::log('Data will be decompressed of ' . basename($file) . ' wasn\'t successful. Try other method "PclZip"');
1194
- dbr_helper::setCommand('test_zip_c', false);
1195
- }
1196
- }
1197
- $archive = new PclZip($file);
1198
- $unzip = $archive->extract(
1199
- PCLZIP_CB_PRE_EXTRACT, 'dbr_extract_func',
1200
- PCLZIP_OPT_PATH, ABSPATH,
1201
- PCLZIP_OPT_REPLACE_NEWER /// extracted all files & databasedump
1202
- );
1203
- if ($unzip== 0) {
1204
- dbr_helper::setError("Error during extracting of archive: " . $archive->errorInfo(true) );
1205
- }
1206
- if ($zip_config && strpos($file, $zip_config[2]) !== false) {
1207
- dbr_helper::is_work(time(), 'start');
1208
- if ( dbr_helper::is_writable(ABSPATH . 'wp-config.php') === false) {
1209
- dbr_helper::setError( "File 'wp-config.php' is not writable" );
1210
- }
1211
- $archive = new PclZip($file);
1212
- $unzip = $archive->extract(PCLZIP_OPT_BY_EREG, "/wp-config.php$/",
1213
- PCLZIP_OPT_PATH, ABSPATH,
1214
- PCLZIP_OPT_REPLACE_NEWER
1215
- );
1216
- if ($unzip == 0) {
1217
- dbr_helper::setError("Error during extracting of database config from archive: " . $archive->errorInfo(true) );
1218
- }
1219
- $this->reconfig();
1220
- }
1221
- if ($zip_database && strpos($file, $zip_database[2]) !== false) {
1222
- $archive = new PclZip($file);
1223
- $unzip = $archive->extract(PCLZIP_OPT_PATH, ABSPATH,
1224
- PCLZIP_OPT_REPLACE_NEWER,
1225
- PCLZIP_OPT_BY_EREG, "/mysqldump.sql$/"
1226
- );
1227
- if ($unzip== 0) {
1228
- dbr_helper::setError("Error during extracting of dump/database from archive: " . $archive->errorInfo(true) );
1229
- }
1230
- }
1231
- $extract_files[$f] = true;
1232
- dbr_helper::setCommand('extract-files-restore', $extract_files);
1233
- dbr_helper::is_work(time(), 'start');
1234
- } else {
1235
- dbr_helper::setError('File (' . $file . ') for restoring wasn\'t found or file size is 0 byte');
1236
- }
1237
- } elseif ($tar_gz) {
1238
- if (file_exists($file) && filesize($file) > 0) {
1239
- $test_targz = dbr_helper::getCommand('test_targz_c');
1240
- if ($test_targz) {
1241
- $untargz = dbr_helper::unTarGz($file, rtrim( ABSPATH_REAL , '/'), array('wp-content/plugins/dropbox-backup/*', 'wp-content/plugins/dropbox-backup-pro/*') );
1242
- if ($untargz) {
1243
- if ($zip_config && strpos($file, $zip_config[2]) !== false) {
1244
- $this->reconfig();
1245
- }
1246
- $extract_files[$f] = true;
1247
- dbr_helper::setCommand('extract-files-restore', $extract_files);
1248
- continue;
1249
- } else {
1250
- dbr_log::log('Data will be decompressed of ' . basename($file) . ' wasn\'t successful. Try other method "PHP tar class"');
1251
- dbr_helper::setCommand('test_targz_c', false);
1252
- }
1253
- }
1254
- include_once 'archive.php' ;
1255
- dbr_helper::is_work(time(), 'start');
1256
- $gz = new wpadm_gzip_file($file);
1257
- $gz->set_options(array( 'overwrite' => 1, 'basedir' => ABSPATH ) );
1258
- $gz->exclude = 'dbr_extract_func_targz';
1259
- $gz->extract_gz_files();
1260
- dbr_helper::is_work(time(), 'start');
1261
- if (!empty( $gz->warning ) ) {
1262
- foreach($gz->warning as $warning) {
1263
- dbr_log::log($warning);
1264
- }
1265
- }
1266
- if (!empty($gz->error)) {
1267
- dbr_helper::setError( implode("\n", $gz->error) );
1268
- }
1269
- unset($gz);
1270
- if ($zip_config && strpos($file, $zip_config[2]) !== false) {
1271
- dbr_helper::is_work(time(), 'start');
1272
- if ( dbr_helper::is_writable(ABSPATH . 'wp-config.php') === false) {
1273
- dbr_helper::setError( "File 'wp-config.php' is not writable" );
1274
- }
1275
- $gz = new wpadm_gzip_file($file);
1276
- $gz->set_options(array( 'overwrite' => 1, 'basedir' => ABSPATH ) );
1277
-
1278
- $gz->include_files("/wp-config\.php/");
1279
- dbr_helper::is_work(time(), 'start');
1280
- $gz->extract_gz_files();
1281
- dbr_helper::is_work(time(), 'start');
1282
-
1283
- $this->reconfig();
1284
- }
1285
- $extract_files[$f] = true;
1286
- dbr_helper::setCommand('extract-files-restore', $extract_files);
1287
- }
1288
- }
1289
- }
1290
- }
1291
- } else {
1292
- dbr_helper::setError('Restoration file list wasn\'t created or is empty. Please, check if folder exists and elso check folder rights. Folder path: ' . $this->dir_backup);
1293
- }
1294
- }
1295
-
1296
-
1297
- private function dowloadDropbox()
1298
- {
1299
- $success = dbr_helper::getCommand('download-with-dropbox-restore', 'success');
1300
- if ($success) {
1301
- return true;
1302
- }
1303
- include "dropbox.class.php";
1304
- $setting = dbr_database::db_get('options', array('option_value'), array('option_name' => 'wpadm_backup_dropbox-setting'), 1);
1305
- if (isset($setting['option_value'] )) {
1306
- $this->main = dbr_helper::unpack_setting( $setting['option_value'] );
1307
- }
1308
- if (!empty($this->main)) {
1309
- if (isset($this->main['app_key']) && isset($this->main['app_secret']) && isset($this->main['auth_token_secret'])) {
1310
- $dropbox = new dropbox($this->main['app_key'], $this->main['app_secret'], $this->main['auth_token_secret']);
1311
- if ($dropbox->isAuth()) {
1312
- dbr_helper::is_work(time(), 'start');
1313
- dbr_log::log('Connect to dropbox was successful');
1314
- dbr_helper::mkdir($this->dir_backup);
1315
- $folder_project = dbr_helper::getProjectName();
1316
- $name_backup = $this->setting_restore['name'];
1317
- $file_list = dbr_helper::getCommand('download-with-dropbox-restore', 'file-list');
1318
- if ($file_list === false) {
1319
- dbr_log::log('Getting list of files from Dropbox');
1320
- $files = $dropbox->listing("$folder_project/$name_backup");
1321
- if (isset($files['error']) ) {
1322
- dbr_helper::setError('Dropbox answered: ' . $files['text']);
1323
- }
1324
- dbr_helper::setCommand('download-with-dropbox-restore', $files, 'file-list');
1325
- dbr_helper::is_work(time(), 'start');
1326
- } else {
1327
- $files = $file_list;
1328
- }
1329
-
1330
- if (isset($files['items'])) {
1331
- dbr_log::log('File list was created successful');
1332
- $n = count($files['items']);
1333
- dbr_log::log('Starting of files download from Dropbox');
1334
- for($i = 0; $i < $n; $i++) {
1335
- $files_download = dbr_helper::getCommand('download-with-dropbox-restore', 'download');
1336
- if (!isset($files_download[$files['items'][$i]['name']])) {
1337
- $res = $dropbox->downloadFile("$folder_project/$name_backup/{$files['items'][$i]['name']}", "{$this->dir_backup}/{$files['items'][$i]['name']}");
1338
- if ($res != "{$this->dir_backup}/{$files['items'][$i]['name']}" && isset($res['text'])) {
1339
- dbr_helper::setError( 'During download of file "' . $files['items'][$i]['name'] . '" an error occurred: ' . $res['text'] );
1340
- } else {
1341
- $log = str_replace('%s', $files['items'][$i]['name'], 'File (%s) was successfully downloaded from Dropbox' );
1342
- dbr_log::log($log);
1343
- if (file_exists("{$this->dir_backup}/{$files['items'][$i]['name']}") && filesize("{$this->dir_backup}/{$files['items'][$i]['name']}") > 0) {
1344
- $files_download[$files['items'][$i]['name']] = true;
1345
- dbr_helper::setCommand('download-with-dropbox-restore', $files_download, 'download' );
1346
- dbr_helper::is_work(time(), 'start');
1347
- }
1348
- }
1349
- }
1350
- }
1351
- $md5 = glob($this->dir_backup . '/*.md5');
1352
- if (count( $md5 ) == 0) {
1353
- 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");
1354
- }
1355
- dbr_helper::setCommand('download-with-dropbox-restore', true, 'success');
1356
- return true;
1357
- }
1358
- } else {
1359
- dbr_helper::setError('Authentication error during connect to Dropbox. Please, try again later');
1360
- }
1361
- } else {
1362
- dbr_helper::setError('Dropbox connection settings wasn\'t found or wrong. Please, check Dropbox connections settings');
1363
- }
1364
- } else {
1365
- dbr_helper::setError('Dropbox connection settings wasn\'t found or wrong. Please, check Dropbox connections settings');
1366
- }
1367
- }
1368
- }
1369
- }
1370
-
1371
- if (!class_exists('dbr_route')) {
1372
-
1373
- if (!defined('ABSPATH')) {
1374
- define('ABSPATH', dirname(__FILE__) . '/../../../../');
1375
- }
1376
- if (!defined('ABSPATH_REAL')) {
1377
- $dir = dirname(__FILE__);
1378
- $dir = str_replace("\\", '/', $dir);
1379
- $dir_arr = explode("/", $dir);
1380
- for($i = 0; $i < 4; $i++) {
1381
- array_pop($dir_arr);
1382
- }
1383
- $dir = implode('/', $dir_arr) . '/';
1384
-
1385
- define('ABSPATH_REAL', $dir );
1386
- }
1387
-
1388
- if (!defined('DBP_PATH')) {
1389
- define('DBP_PATH', dirname(__FILE__) . '/../');
1390
- }
1391
- if (!defined('DBP_PATH_TMP')) {
1392
- define('DBP_PATH_TMP', DBP_PATH . 'tmp');
1393
- }
1394
-
1395
-
1396
- class dbr_route {
1397
-
1398
- private $cron_is_work = 60;
1399
-
1400
- private $plugins = array();
1401
-
1402
- private $setting = array();
1403
-
1404
- private $method_access = array('wpadm_logs');
1405
-
1406
- function __construct()
1407
- {
1408
- @set_time_limit(0);
1409
- if (function_exists('set_error_handler')) {
1410
- set_error_handler(array($this, 'error_handler') );
1411
- }
1412
- if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
1413
- if ( !isset($_POST['name']) ) {
1414
- $this->parsMethod();
1415
- } elseif( isset($_POST['name'] ) ) {
1416
- try {
1417
- dbr_helper::clearTMP();
1418
- dbr_helper::testOtherArchive();
1419
- dbr_database::inc_wp_config();
1420
- $setting = dbr_database::db_get('options', array('option_value'), array('option_name' => 'wpadm_backup_dropbox-setting'), 1);
1421
- if (isset($setting['option_value'])) {
1422
- $this->setting = dbr_helper::unpack_setting( $setting['option_value'] );
1423
- }
1424
- $this->setting['restore-key'] = md5( time() . microtime() . __FILE__);
1425
- include 'constant.php';
1426
- $plugin = $this->parsePlugin('/dropbox-backup');
1427
- $plugin_name = 'dropbox-backup';
1428
- $version = '1.0';
1429
- if (isset($plugin['/dropbox-backup']['Version'])) {
1430
- $version = $plugin['/dropbox-backup']['Version'];
1431
- } else{
1432
- $plugin = $this->parsePlugin('/dropbox-backup-pro');
1433
- if (isset($plugin['/dropbox-backup-pro']['Version'])) {
1434
- $version = $plugin['/dropbox-backup-pro']['Version'];
1435
- $plugin_name = 'dropbox-backup-pro';
1436
- }
1437
- }
1438
- $data = array('actApi' => 'setPluginCode', $plugin_name . '_request' => array('action' => 'restore', 'site' => SITE_HOME, 'pl' => $plugin_name, 'key' => $this->setting['restore-key'], 'pl_v' => $version, ) );
1439
- $res = dbr_api::post(WPADM_URL_BASE . 'api/', $data);
1440
-
1441
- if ( !empty( $res['res'] ) ) {
1442
- $result = json_decode($res['res'], true);
1443
- if (isset($result['code'])) {
1444
- switch($result['code']) {
1445
- case 101 :
1446
- dbr_helper::setError('The restoring method has an error');
1447
- break;
1448
- case 108 :
1449
- dbr_helper::setError('Error of the post/request data');
1450
- break;
1451
- case 109 :
1452
- dbr_helper::setError('Error of the params data');
1453
- break;
1454
- case 110 :
1455
- dbr_helper::setError('Unknown error');
1456
- break;
1457
- }
1458
-
1459
- }
1460
- }
1461
- if ( isset($setting['option_value']) ) {
1462
- dbr_database::db_update('options', array('option_value' => dbr_helper::pack_setting( $this->setting ) ), array('option_name' => 'wpadm_backup_dropbox-setting') ) ;
1463
- }
1464
- 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
1465
- dbr_helper::setCommand('settings-plugin', $this->setting );
1466
- $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
1467
- if (isset($this->setting['backup_folder']) && !empty($this->setting['backup_folder'])) {
1468
- $backup_dir = $this->setting['backup_folder'];
1469
- }
1470
- dbr_helper::setCommand('backup-folder', $backup_dir );
1471
- echo json_encode(array('result' => 'work'));
1472
- } catch(Exception $e) {
1473
- dbr_log::log($e->getMessage());
1474
- dbr_helper::setCommand('result-restore', array('name' => dbr_helper::sanitize( $_POST['name'] ), 'result' => 'error', 'message' => $e->getMessage() ) ); // verify and sanitize post data
1475
- }
1476
- }
1477
- }
1478
- }
1479
-
1480
-
1481
- private function parsMethod()
1482
- {
1483
- if ( isset($_POST['method']) ) {
1484
- $this->setting_restore = dbr_helper::getCommand('restore-backup');
1485
- try {
1486
- dbr_helper::mkdir(DBP_PATH_TMP);
1487
- if (!dbr_helper::is_work() || in_array($_POST['method'], $this->method_access ) ) {
1488
- if (isset($_POST['key'])) {
1489
-
1490
- $backup_dir = dbr_helper::getCommand('backup-folder');
1491
- $this->setting = dbr_helper::getCommand('settings-plugin');
1492
-
1493
- if (file_exists($backup_dir . '/local-key')) {
1494
- $key_values = dbr_helper::unpack_setting( @file_get_contents($backup_dir . '/local-key') );
1495
- }
1496
- if ($_POST['key'] == @$this->setting['restore-key'] || ( isset($key_values['key']) && $_POST['key'] == $key_values['key'] ) ) {
1497
- $methods = new dbr_methods();
1498
- $method = dbr_helper::sanitize( $_POST['method'] ) . '_method';
1499
- if (method_exists($methods, $method)) {
1500
- if ($_POST['method'] != 'wpadm_logs') {
1501
- if (file_exists(DBP_PATH_TMP . '/result-restore')) {
1502
- dbr_helper::is_work(time(), 'finish');
1503
- $result = dbr_helper::getCommand('result-restore');
1504
- if (isset($result['result']) && $result['result'] == 'success') {
1505
- $this->getResult(200);
1506
- } elseif (isset($result['result']) && isset($result['message']) && $result['result'] == 'error') {
1507
- $this->getResult(402, $result['message']);
1508
- }
1509
- }
1510
- }
1511
-
1512
- if (isset($_POST['type-backup']) && $_POST['type-backup'] == 'restore') {
1513
- if ( !dbr_helper::is_work() && dbr_helper::getCommand('restore-backup') ) {
1514
- $http = 'http://';
1515
- if ( (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443 ) {
1516
- $http = 'https://';
1517
- }
1518
- $key = isset($this->setting['restore-key']) && !empty($this->setting['restore-key']) ? $this->setting['restore-key'] : $key_values['key'];
1519
- $res_api = dbr_api::post($http . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], array('key' => $key, 'method' => 'restore'), array('timelimit' => 5) );
1520
-
1521
- if (stripos($res_api['res'], 'mod_security') !== false || dbr_helper::modSecureInstalled() ) {
1522
- dbr_helper::is_work(time(), 'start');
1523
- //dbr_helper::setError('Apache module \'mod_security\' is active and affected on your website. For successfully restoring of website please switch it temporary off.');
1524
-
1525
- dbr_helper::setCommand('mod_security', true);
1526
- }
1527
- }
1528
- } else {
1529
- dbr_helper::is_work(time(), 'start');
1530
- }
1531
- if ($_POST['method'] != 'wpadm_logs') {
1532
- dbr_database::inc_wp_config();
1533
- include 'constant.php';
1534
- $setting = dbr_database::db_get('options', array('option_value'), array('option_name' => 'wpadm_backup_dropbox-setting'), 1);
1535
- $this->setting = dbr_helper::unpack_setting( $setting['option_value'] );
1536
- $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
1537
- if (isset($this->setting['backup_folder']) && !empty($this->setting['backup_folder'])) {
1538
- $backup_dir = $this->setting['backup_folder'];
1539
- }
1540
- }
1541
- $methods->$method();
1542
- if (!isset($_POST['type-backup'])) {
1543
- dbr_helper::is_work(time(), 'finish');
1544
- }
1545
- } else {
1546
- $this->getResult(401);
1547
- }
1548
- } else {
1549
- $this->getResult(400);
1550
- }
1551
- } else {
1552
- $this->getResult(400);
1553
- }
1554
- }
1555
- } catch(Exception $e) {
1556
- dbr_log::log($e->getMessage());
1557
- dbr_helper::setCommand('result-restore', array('name' => $this->setting_restore['name'], 'result' => 'error', 'message' => $e->getMessage() ) );
1558
- }
1559
- }
1560
- }
1561
-
1562
-
1563
- function error_handler($errno, $errstr, $errfile, $errline, array $errcontext)
1564
- {
1565
- // error was suppressed with the @-operator
1566
- if (0 === error_reporting()) {
1567
- return false;
1568
- }
1569
- if (!(error_reporting() & $errno)) {
1570
- return false;
1571
- }
1572
-
1573
- throw new Exception($errstr . ' file ' . $errfile . ' line ' . $errline, $errno);
1574
- }
1575
- /**
1576
- * json encode
1577
- *
1578
- * @param integer $code
1579
- * @param mixed $data
1580
- *
1581
- * 200 - success
1582
- * 400 - error in key
1583
- * 401 - method not exists
1584
- * 402 - error in work
1585
- */
1586
- private function getResult($code, $data = '')
1587
- {
1588
- $encode = array('code' => $code);
1589
- if (!empty($data)) {
1590
- $encode['data'] = $data;
1591
- }
1592
- echo json_encode($encode);
1593
- exit;
1594
- }
1595
-
1596
- private function parsePlugin($folder)
1597
- {
1598
- $plugin_dir = ABSPATH . 'wp-content/plugins' . $folder ;
1599
- if (is_dir($plugin_dir) ) {
1600
- $files = glob($plugin_dir . '/*.php');
1601
- $n = count($files);
1602
- for($i = 0; $i < $n; $i++) {
1603
- $plugin = @file_get_contents($files[$i]);
1604
- if (preg_match("/version: ([0-9\.]+)/i", $plugin, $data)) {
1605
- if (isset($data[1]) && !empty($data[1])) {
1606
- $this->plugins[$folder]['Version'] = $data[1];
1607
- break;
1608
- }
1609
- }
1610
-
1611
- }
1612
- }
1613
- return $this->plugins;
1614
- }
1615
- }
1616
-
1617
- new dbr_route();
1618
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,205 +1,94 @@
1
- === Backup & Restore Dropbox ===
2
- Plugin Name: Backup & Restore Dropbox
3
- Version: 1.5.1.2
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
7
  Requires at least: 3.9
8
- Tested up to: 4.7.3
9
  Stable tag: trunk
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  Author: WPAdm.com
13
  Contributors: WPAdm.com
14
 
15
- Backup & Restore Dropbox Plugin to create Dropbox Full Backup (Files + Database) or Restore, Duplicate, Clone or Migrate of your Website
16
 
17
  == Description ==
18
 
19
  Supports WordPress Backup and Restore to/from Local Storage or upload Backups to Dropbox.
20
 
21
- If you do not understand something or you have a questions, <br />
22
- please, make a [support request](http://www.wpadm.com/support/) first!
23
-
24
- **Features of website backup & website restore plugin:**
25
-
26
- * Unlimited dropbox backups;
27
- * Unlimited dropbox restores;
28
- * Unlimited local backups;
29
- * Unlimited local restores;
30
  * Local Backup: create the Full Backup of Web Page (Files + Database) and store this at Local Storage of the Site;
31
  * Dropbox Backup: create the Full Backup (Files + Database) of Web Page at Local Storage and upload this to Dropbox;
32
- * Local Restore: restoration from Local backup at your website (web hosting);
33
  * Dropbox Restore: restoration from Dropbox backup;
34
- * Full control of included and excluded folders and files (can be found in "Settings");
35
- * You can create limited backup with database only (without files and/or folders). Just check "Settings" of backup plugin;
36
- * With "dropbox backup & restore" plugin you can backup and restore WooCommerce shop inkl. database with products;
37
- * Notification logging on screen and in file;
38
- * Use your own App key and App secret;
39
- * Supports backup on "Low Memory" Hosting or Server;
40
- * Possibility to make Dropbox backup and restore interface hidden with all listed backups (only Admins can access the backup plugin page);
41
- * Automatic database optimization before backup (can be switched in plugin settings);
42
- * Database or Table repair functionality before backup;
43
- * Administrate ALL of Backups for ALL of your sites from one place – WPAdm-account (Account is FREE);
44
-
45
- **Account creation is optional, but we suggest to do this.<br /> Why create [www.wpadm.com](http://www.wpadm.com/) account?**<br />
46
- Your website can be down, not available or admin back-end can be without response. There are many reasons for this, for example:<br />
47
-
48
- * Some plugin or some theme (template) has an error;
49
- * Plugin or theme (template) was installed incorrectly (wrong installation of WordPress plugins and WordPress themes);
50
- * Vulnerabilities of user files, WordPress files, WordPress plugin- and theme- files;
51
- * Websites Hacking (web page hacks), Websites Trojans etc.;
52
- * Server or hosting misconfiguration. For example: files and folder rights, like "owner" rights, "read", "write" and "execution" rights;
53
- * Web Server or web hosting misconfiguration, like wrong Apache or nginx configuration, mod_rewrite rules (rewriting rules) configuration;<br />
54
- etc.
55
-
56
- You can create your WPAdm account also for **central Backup administration** at http://www.wpadm.com <br />
57
- WPAdm account is FULLY FREE.<br /><br />
58
-
59
- **PLEASE, READ CAREFULLY!** <br />
60
- **If you like our plugin - please, make your own [review](https://wordpress.org/support/view/plugin-reviews/dropbox-backup). It will help us to develop and update website backup and website restore plugin for you!**<br />
61
- **This is one of few WordPress backup plugins, who does a fully free support (plugin support!) for all of our users.<br />
62
- Dropbox backup and restore plugin ask for FTP if your website (not this plugin!) have some troubles, in order that we could make support for you.<br />
63
- Providing of these FTP DATA IS NOT OBLIGATORY, but if you do this, - our support staff will check your backup process and you will receive a feedback about results.<br />
64
- It can take a while and some patience from you.<br /><br />
65
- We are not responsible for any 5хх-errors! Such errors caused in most cases (99,9%) by your server/hosting.<br />
66
- For a little fee, we can help you solve problems of your server or hosting (to do this, we will need your FTP website access).<br />
67
- Thank you for your understanding!**
68
-
69
-
70
- **ALL INFORMATION, PROVIDED BY OUR USERS IS IN SAFETY AND USED FOR SUPPORT ONLY!**
71
 
72
- If you need help with the plugin or you want to report a bug please refer to http://www.wpadm.com/support/
73
- <br />
74
 
75
- If your website has basic authorisation (basic_auth), it can call some exclusions during backup executing. We are working on this issue.
 
76
 
 
77
 
78
  == Installation ==
79
 
80
- ### Perform a new installation using FTP
81
  1. Upload the plugin folder `Dropbox Backup` to the `/wp-content/plugins/` directory of your WordPress installation.
82
  2. Activate the plugin through the `Plugins` menu in WordPress
83
 
84
 
85
- ### Perform a new manual installation of Dropbox backup and restore plugin
86
-
87
- After downloading the ZIP file of the Dropbox back up and restoration plugin,
88
-
89
- 1. Log in to your administrator panel;<br />
90
- 2. Go to Plugins Add > New > Click the button "Upload";<br />
91
- 3. Click on "Choose file" (or "Browse", to browse the plugin zip-archive) and select the downloaded zip file of the Dropbox back up and restoration plugin;<br />
92
- *For Mac Users*<br />
93
- *Go to your Downloads folder and locate the folder with the name "dropbox backup". Right-click on this folder and select Compress. Now you have a newly created .zip file which can be installed as described here.*<br />
94
- 4. Click on "Install Now" button. Dropbox back up and restore pugin will be installed;<br />
95
- 5. Click on link "Activate Plugin" to activate the "Dropbox backup and restore" plugin;<br />
96
- <br />
97
- *If the installation does not succeed, please contact http://www.wpadm.com support staff or refer to your system administrator.*<br />
98
 
99
  Dropbox Backup Plugin have a settings section on WordPress plugin page.
100
-
101
- ### DO NOT FORGET to connect your dropbox backup plugin to Dropbox before creating your first Dropbox backup ###
102
-
103
- 1. Go to Admin dashboard of your website;<br />
104
- 2. Open "Settings" of website backup plugin;<br />
105
- 3. Click "Connect to Dropbox" button;<br />
106
- 3a. Sure, if you want, you can use your own App Key and App Secret. More Information about this you can read on [FAQ](https://wordpress.org/plugins/dropbox-backup/faq/) page or in the Settings block of your installed plugin, near "Connect to Dropbox" button;<br />
107
-
108
- Watch this video about:
109
- <ul>
110
- <li>How to install Dropbox backup and restore plugin on WordPress</li>
111
- <li>How to connect Dropbox backup and restore plugin to Dropbox</li>
112
- <li>How to perform a backup using Dropbox backup and restore plugin for Wordpress</li>
113
- </ul>
114
-
115
- https://www.youtube.com/watch?v=Hdzoh0BFpmg
116
-
117
-
118
- If you need help with the plugin or you want to report a bug, so please, also refer to http://www.wpadm.com/support/
119
-
120
 
121
  == Other ==
122
 
123
-
124
  = Very easy and secure Dropbox Backup and Restoration (website / web page restore from backup) =
 
125
  Usefull additional functions can be found at www.wpadm.com in the User profile.
126
- DropBox Backup is a new plugin, so we tried to provide a bug-free plugin/widget. We are maintain this project.
127
 
128
- Information about privacy:<br />
129
- In case the user has been registered at WPAdm service AND has confirmed their registration,
130
  our plugin will get the minimum requirements of php and mysql configuration, version and language of wordpress.
131
- This data will be send to WPAdm service, to get the plugin work correctly, to extend supported configurations of user sites with wpadm-extensions and support.<br />
132
  WE DO NOT COLLECT AND DO NOT STORE THE PERSONAL DATA OF USERS FROM THIS PLUGIN!
133
 
134
- = Website Backup on Dropbox =
135
 
136
- For security of your sites, webs hops or online portals is backup a must. With backup from www.webpage-backup.com you can secure backup and restore all your projects independent if it website or woocommerce shop as to make restoring from your backups. From security reasons it is impotent to schedule your backups, thereby your information or comments from your databases no go lost. Of course the more important for the security are (frequently) backups for woocommerce shops or multisite backups and there one click to restores from your backup drive. The woocommerce backups need more storage in cloud due to large files.<br />
137
- But in most cases it isn't needed to make full backup. With help of our service webpage-backup.com you can select the folder or special databases that you must backup or to backup single website inside your hosting. But for our service it does not matter if the files are large or small, in case of the restoration it is the same. As well as for your local backup. Local backup are done on your hosting. If your hosting have enough space for backup it is ok, but it is not recommended. In most cases for storage your full backup on space of your hosting it is not enough space otherwise it is not safe enough, especially if something happen with your hosting or after some time you want to change your hosting provider. Additional if your make automate schedule backups or data base backups ever after some time the space on your backup drive will be full. For this reason the best is to use the Dropbox storage. Dropbox storage is scalable. Of course the scheduler dropbox backup it is not a must. You can make it manually and for free, but it easy to forget and the danger to lose your backup data are big. You must not to upload your dropbox backup on your PC or desktop you can directly restoring your website from dropbox drive. Independently of our service it is possible to downloading, uploading the data from the dropbox account. By dropbox backup with www.webpage-backup.com you can make exclusions of folders or by restoring import archives or whole bundle of archives. By dropbox backup or wep page cloning or migration of the sites it is important that all folders have permissions to write it is the same how permission to access the folder or to uploading it. For backup on dropbox it is does not matter if your site have ssl certificate or it is normal woocommerce shop without SSL certificate the same goes for migrating or for website clone. For our service www.webpage-backup.com it is important that our servise have permissions to the folders and to backup drive.
 
 
 
138
 
139
  = Special functions =
140
 
141
- To the special functions of our website backup doesn’t belong the migration, scheduler backup, cron backup, wpmu backup, shop backup and encryption by cloning, if you make some clone of your website or multisite clone. It is all normal functions of our plugin or service at our website www.webpage-backup.com. The most of this tools are free of charge, especially if you do it manually. But inside our multisite tools are other addons and functions. Addons for your pages or multisite (WPMU) peges you can add inside of your service account if you want. But for some of this function it is required to register on www.webpage-backup.com. For manage of multisites or just for one page menaging, for cron and scheduled dropbox backup as for full restoration of you WooCommerce shop, website or multisite as well as for migration - to register it is must. It is not possible to do full restoration of website from dropbox backup without the WordPress site self.
142
 
143
  = Easy backup =
144
 
145
  By draw up of our dropbox backup tools we try to do the backup or restoring ever for not experts and multisites owners, but with the same tools how for experts. For experts we have Buckup explorer where the expert can select or to do exclusion of files and webpages. As the register user you can use multiple dropbox account or create other multisite buckup drive clouds, how FTP or you can do the local backup on the site of your host. All automatically functions are inside of our service. To automatically tools belong: cron and scheduler, migrator and remote. Scheduled jobs for dropbox you can set in our calendar, it gives overview.
146
 
147
- = Back Up, Cloning, duplicate or migrate of websites =
148
 
149
- Cloning, duplicate or migrate in principal all the function a same. It gives you the possibility quickly to create site clone with as “templates” for multiple site. This clone tool is very useful, if you have more than one website or, if you want to clone or duplicate your web page. With full backup of your old site or WooCommerce shop you can clone or duplicate, and create new clone (due back up) of webshop or website with one click. All multisite backups functions are available from one dashboard of cloning tool, how multisite backup, as well as WPMU backup in the same cloud or in several cloud storages of hosting provider or just server. From same dashboard available clone restorations functions separate or in bundle, depend of your multisite backup settings. If your do so much settings you can remove not needed settings or clone of backup. The settings must be removed separately ever for multisite or clone. The backup dropbox storages must be removed separately too. Although it seems complicated to do automatic backup. With our backup plugin for backup, clone or migrate - you can make it without expert knowledge. Clone add-ons allow your easy backup or migrate your website or WPMU (multisite). "Dropbox backup" is just ultimate tool for WordPress that can worst your productivity by cloning of web pages, allowing you to do efficiently manage of cloned pages through clone or multisite installations.
150
 
151
  = Easy data restoring =
152
 
153
- For restoring your website (or multisite websites) selected files from the dashboard and then select files to restore. In backup list you see the type, date and size. From the list you can remove and select appropriate restoring file. In settings your can add or remove the cloud storage. In case of cloning you must restore your old website backup on other webpage. Cloning is the same how resorting but in more steps. The same bee meant for migrating of multisite and shops and there restore. With our file explorer you can match every file separately for restoration. In case of restoration only this files will be restore. You can restore one file than the next, but it easy to make restoring in bundle or directly to recover whole full backup. The restoration time depend from your hosting and upload rate as well as restoration depend from the file size witch must be restore. Scheduled restoring and recovering isn’t possible, unless somebody have special inquiry on our service to do scheduled recovering. The recover from the Dropbox cloud storage take time, depend from the web site size and right permissions of the folders of your hosting provider.
154
-
155
- = Backing Up and Restoration to Dropbox =
156
- = Backup:Yes Or No? =
157
- <p>In the age of trend-setting technologies, information backing up is necessary for many life spheres that are related in any way to creation of something. That refers to programming, site building, engineering, designing, not to mention home data - photos, videos and other stuff. This list can go on and on… One would think, what is so special about this backup thing? Well, the one fact known for sure is that it saves lives of both: different projects and people who fagged away at these very same projects.</p>
158
- <p>It has been said all the time that everyone should make the reserve copy (or backup), but not many actually do that, and besides, there are even those who have no clue about it and what it is for. Nevertheless, information about backup is really an important and useful habit, so let’s know what’s what about it.</p>
159
- <p>Firstly, there’s a need to determine the backup process – it is a data redundancy to different storage devices, making copies of the existing data. Now let’s clear its usefulness to each and every. On one hand, modern computers and their hard drives, which are the major and the most popular data storage places, have attained quite dramatic reliability numbers. Multiform redundant coding on different levels of data management provides strong security from the possible sad situations when the information is damaged as a result of accidental error in the act of data saving. But on the second thought, even the most dependable storage mediums sooner or later go down, and for what is more, it usually happens all of the sudden. Now that is the break point, when you finally change your mind upon all the information kept by people on their hard discs. Passwords and contacts, momentous pictures and rare music collections, all possible working data – this whole treasure can disappear without warning from your website, which can turn to serious financial and time losses in addition to emotional stress.</p>
160
- <p>The easiest variant is to simply copy data to another folder on a hard drive. But unfortunately, that is an unreliable decision, because that would release you from only the small number of possible problems, even if this folder is placed on another hardware. Now you are aware that at the present digital information day creating of backup is neither a whim nor extra precaution, this is a plain safety measure.</p>
161
 
162
  = What to do if recovering failed? =
163
 
164
  First of all check the data spelling. It is most common mistake. Other common mistakes by recovering are:
 
 
 
 
 
 
 
 
165
 
166
- * to recover from wrong cloud storage;
167
- * if done alone database back up – not full and you can't see the recover sites;
168
- * by recovering process there was internet connection interrupted;
169
- * In your database are file exclusions;
170
- * your database back up was not consistent;
171
- * file archive of back up with a broken checksum;
172
- * back up or restore from damaged cloud storage or from damaged back up archive;
173
- * misspelled back up due user failed restore;
174
-
175
- Large file and big size databases need more time to back up or recover website. It can take until two hours or more, depend from the size of your back up database, but for our recovery service it doesn’t matter for uploading of large files or small files. The difference between recover the large files and small is the time. <br />
176
- After check all of this figures please write an email to our support team http://www.webpage-backup.com and we will try to answer as soon as possible and to give you’re the best solution how easy to recover your site.
177
-
178
- If you see some of 5xx error codes, as return of your backup:<br />
179
- please, feel free to contact your own system administrator (admins, support etc.), because this type of errors come from your server.<br />
180
-
181
- **The timely backup protects from viruses.**
182
-
183
- There are some requirements for creating a reliable backup:<br />
184
- • Make copies of your files regularly and as often as you can;<br />
185
- • Rank your data by importance and back up essential information first. Generally, temporary files only add up to the back up volume and carry no significance, so get rid of them;<br />
186
- • Do not store your file copies on the same hard drives;<br />
187
- • Make sure you can access your backups any time and from any place;<br />
188
- • Schedule your backups and ensure you get informed on their status;<br />
189
- • If your medium capacity or bandwidth is limited use compression tools;<br />
190
- A good solution is to have a separate server for remote backups although it is not fail-safe. If the server is unavailable restoration will be impossible. To ensure high accessibility and data safety use cloud storage services.<br />
191
- There are a lot of services providing free but limited cloud storage capacity for backups like Google Drive, Amazon S3 (AWS) or Dropbox. The problem is they do not support FTP protocol which sometimes is the most adequate way of data transfer. In comparison, virtually every host company supports this protocol.
192
-
193
- = Restoration of Backup Files =
194
- <p>Different factors may be the reason for someone to restore his data from a dropbox backup. This is a truly helpful option that supposes bringing the saved data from dropbox storage place back to its original in case you’ve lost or damaged the existing one.</p>
195
- = Best Choice to Keep Data =
196
- <p>Among the available ways to maintain information the first place belongs rightfully to **cloud storages** or **cloud drives**. These are sorts of virtual data storages, that save and manage the data via numerous servers strewn about World Wide Web. Their principle is simple: every ‘cloud’ has definitively stated limit of Gb virtual space, that is given to a new user absolutely for free. But in time, if a person wants to expand it, he’ll have to pay according to price plan. So here we have a simple case of effective advertising – a user gets used to the comfort and mobility of the network repository, and after he concludes that the cloud suits him to the full extend in every meanings, he pays for the “rent” of this sufficiency.</p>
197
- = Dropbox Backup and WordPress =
198
- <p>For the present day Dropbox cloud is still an unbeaten leader that is up to multi-million clients number. Most probably that has to do with the fact that it is Dropbox that stood at the origins of virtual space providing to users, and it is the first company, that has realized the idea of cloud data storage. It works by creation of a virtual folder in the cloud, where all the info of your wordpress website is saved, the one which you download to your Dropbox folder on your computer. For the WordPress website management the best choice is to download a plugin to easily administrate your source from wordpress admin dashboard. Backup&Restore Dropbox has many positive reviews and it deals with the performance of backup and restores, both local and dropbox.<br />
199
- <p>Dropbox Full Backup for WordPress is good for both restore and backups tasks. It allows to use your own App key and App secret in order to keep then private with higher security for yourself. It can be your personal guard that can keep all the files saved and backed up as much as possible, and even in case of your website data lost, you are able to restore all the data just with one click. </p>
200
- <br />
201
- <p>To make a conclusion we’d say, that in order to be safe and sound with any of your data of your WordPress site information you should trouble yourself with backing up of an important information. That will restrict possible damages to minimum and save your time and nerves.</p>
202
-
203
 
204
 
205
  == Frequently Asked Questions ==
@@ -210,18 +99,8 @@ You can get an API app key and secret by creating an app on the <a href="https:/
210
  Once you have an app created, the app key and secret will be available on the app's page on the <a href="https://www.dropbox.com/developers/apps" target="_blank">App Console</a>.
211
  Note that Drop-ins have app keys but no app secrets.
212
 
213
- = I clicked on the "Backup to Dropbox" button, but nothing happens. What's wrong? =
214
-
215
- Before you try to make a backup of your website to dropbox, please make sure, that you have created the connection to dropbox. Also you must be sure, that you are connected to dropbox.<br />
216
- To do this, please, open the "Settings" block in your "Dropbox backup and restore" plugin. There you must see your Dropbox UID (User ID on Dropbox). If you didn't see your Dropbox connection App UID - your Dropbox plugin is NOT CONNECTED to your Dropbox and you can't do the backup of your website.<br />
217
- So please, at first connect yourself to Dropbox and then, try to make your backup to dropbox.
218
-
219
  = How to restore my site from dropbox backup? =
220
 
221
- - First of all, install the Dropbox backup & restore plugin;<br />
222
- - In Dropbox backup & restore plugin check your connection to dropbox as "dropbox app" or as connection with using of app key & app secret from your dropbox account;
223
-
224
-
225
  = My web page completely crashed and not available. How can I restore my web page from dropbox backup? =
226
 
227
  Just login or Register at WPAdm www.wpadm.com If your web page wasn't added and verified - just do it. Add your domain and verified this on WPAdm account.
@@ -232,54 +111,13 @@ You must see all of your backups, that you have made.
232
 
233
  Yes. We recommended to update or upgrade to a newest versions.
234
 
235
-
236
- = How do I do this: Dropbox Backup wasn't created. There is not enough script running time to perform backup operations, please increase the PHP variable max_execution_time. =
237
-
238
- There are two ways to do it increase the PHP variable max_execution_time:<br />
239
-
240
- 1. If the above mentioned method does not work, or your web host does not allow you to do it, you can change "Waiting time (minutes)" in the "Settings" area where you initiate the backup.<br />
241
-
242
- 2. If you have access to your hosting / server dashboard, please, find PHP settings and add the following:<br />
243
-
244
- max_execution_time = 90 (script running 90 seconds).<br />
245
-
246
- 3. If you have access to FTP settings, find FTP file, called php.ini and add there max_execution_time = 90 (script running 90 seconds).<br />
247
-
248
- If 90 is not enough for your script running, write 120 and so forth. <br />
249
-
250
- If you write down 0, you will have unlimited script running time. <br />
251
- Some materials take a long time to process before being transmitted.<br />
252
-
253
- 4. If you can’t find the php.ini file, then just try to create a new one in the root folder of your website. Add the setting described above to the created php.ini file.<br />
254
-
255
- 5. If the methods above doesn’t work for you - try to set append variable at the end of index.php file in root folder of your website.<br />
256
-
257
- ini_set('max_execution_time', '90');<br />
258
-
259
- 6. You can also add the following code in .htaccess file:<br />
260
-
261
- php_value max_execution_time 90<br />
262
-
263
- **Check, if you have added this setting to the currently active php.ini file.**<br />
264
-
265
- You can change it, for example from 3 to 5 minutes. This setting must be set in seconds. <br />
266
-
267
-
268
-
269
- = I just download the dropbox full backup addon for my wordpress site. I've connected the dropbox addon (application) to my dropbox account and pushed the button "create dropbox backup". But after the finish of backup where can I find the backup files, so I be sure, that the backup was done? =
270
-
271
- If you checked in the Setting of Dropbox plugin the checkbox "Leave local copy on my hosting", than you may to have two backups:<br />
272
- - one WordPress backup, that was saved locally on hosting of your website, in folder '/wp-content/Dropbox_Backup/<backup-folder>/';
273
- - the second WordPress backup, that was uploaded to your Dropbox account. You may to search for this uploaded backup on your Dropbox in of "WPAdm application" folder/<backup-folder>/;
274
- Note, if you don't checked the checkbox "Leave local copy on my hosting" in the Settings of your Dropbox plugin, than locally created backup on hosting of your website will be deleted after upload to your Dropbox.
275
-
276
  = How can I manage my backups? =
277
 
278
  Manage of multiple back ups is possible from your account on webpage-backup.com
279
 
280
  = I use multisite WordPress and I would like to manage my backups from one place. How can I do that? =
281
 
282
- Multisite WP can be supported too, but you have to login in your account at www.webpage-backup.com
283
 
284
  = Can I use the Dropbox Backup and Restore plugin to clone my website? =
285
 
@@ -291,30 +129,21 @@ Simple check your app key and app secret, that you use it from a correct app do
291
 
292
  = Is it possible to migrate my website with your Dropbox back up tool? =
293
 
294
- Many people stay us this question and our answer is - YES! It's good possibility to use our back up plugin specially for migration of websites. Also you can migrate your website locally. If you does a local backup, then you can download it to your PC, upload to another place and make recovery there.
295
 
296
- = How to do a recovery of my website? =
297
 
298
- Dropbox Backup and Restore plugin work autonomously. In case, if your page (website) not available, you may use www.webpage-backup.com to recover website from backup on dropbox.
299
 
300
- = I want schedule backup. How can I schedule backup of my website? =
301
 
302
- To schedule backup of your webpage (website backup), you may use an account at www.webpage-backup.com to schedule backup.
303
 
304
  = Can I make a schedule backup of my multisite WordPress? =
305
 
306
- Please, see the previous question "I want schedule backup. How can I schedule backup of my website?".
307
  Generally - YES, you can create a scheduled backup, but you may sign in to account at www.webpage-backup.com to make a scheduled backup.
308
 
309
- = Error message when trying to backup WP website and send to Dropbox. Dropbox Backup wasn't created. PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature. Please advise how to fix this? =
310
-
311
- This ERROR:<br />
312
-
313
- **PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature** <br />
314
-
315
- means that you have not enough free space on your hard drive.<br />
316
- To solve this problem, you have to go to your ISP panel (Plesk, cPanel, etc.) and check the disk space on your hosting or server.
317
-
318
  = Should I register to make a back up of my site? =
319
 
320
  Our plugin for back up is completely autonomous plugin for back up, so you don't need to register to make a back up of your site.
@@ -361,18 +190,6 @@ The version for mysql backup (DB Backup) is available due control panel at http:
361
 
362
  Ok, if you want to use an SCP Backup, please, wait for some versions of this plugin over their, and we will make an scp backup for you.
363
 
364
- = What do I need to do? Local Backup wasn't created: There is not enough memory to perform archiving of big files and continue backup operations, please increase the PHP variable memory_limit. =
365
-
366
- There are two ways to solve your problem:<br />
367
-
368
- 1. If you have access to your hosting/server operating panel, please, find PHP settings and add the following:<br />
369
-
370
- memory_limit = 256M (use 256 MB)<br />
371
-
372
- 2. If you have access to FTP settings, find FTP file, called php.ini and add there memory_limit = 256M (use 256 MB)<br />
373
-
374
- Full description of php.ini and memory_limit you can find here http://php.net/manual/en/ini.core.php#ini.memory-limit <br />
375
-
376
  = FTP Backup? =
377
 
378
  The name of this plugin is "Dropbox" Backup and Restore. From control panel at http://www.webpage-backup.com you can do also an FTP Backup. Please, checkout an FTP Backup so.
@@ -381,295 +198,24 @@ The name of this plugin is "Dropbox" Backup and Restore. From control panel at h
381
 
382
  Yes, dropbox backup and dropbox restoration are free with plugin "Dropbox Backup and Restore"!
383
 
384
- = Whether I need to create an account on the wpadm.com? =
385
-
386
- You shouldn't create an account on the www.wpadm.com, but you are able to do it since further it can really help you at restoration time of your site. For example, if your website is completely down and not available.
387
-
388
- = Whether there are WordPress templates of my web site in a full backup archive? =
389
-
390
- Full backup include templates of your site.
391
-
392
- = I try to create a dropbox backup. I enter the app key and app secret. Then I was asked for permission to access dropbox, so I hit "allow" and then I'm given an "Internal server error".<br /> What is causing this and how might I fix it? =
393
-
394
- Please, just wait for some time and try again later.<br />
395
- We know this issue about "Internal Server Error" on Dropbox, that comes from the Dropbox servers. Best thing to do is be patient and give it another try.
396
- We cannot recommended you more, than just had to wait it out and problem went away after a while.
397
-
398
- = I want to move my website to the new hosting/server. How can I do this? =
399
-
400
- Sure, it is possible to use this Dropbox Backup & Restore plugin, but we suggest to try [cloner](https://wordpress.org/plugins/duplicator-clone/). With it you can much easily clone, migrate or easy duplicate your website from one hosting or server to another.
401
-
402
- = My website has a very BIG files, like photos, videos and so on. If I do my backup to dropbox it's return this message "Maximum execution time of XXX seconds exceeded" and sometimes some other messages while uploading to dropbox. I've tried to do my backups with some of known WordPress plugins like "BackWPup", "UpdraftPlus Backup and Restoration", "WordPress Backup to Dropbox", "BackUpWordPress" but it's all without success. Can you please advise me after all these failures, why I have to trust in "Dropbox Backup & Restore" plugin? =
403
-
404
- OK, this is a complex question, but we'll try to answer this by comparing of "BackWPup", "UpdraftPlus Backup and Restoration", "WordPress Backup to Dropbox", "BackUpWordPress" with "Dropbox backup & restore" plugin.<br />
405
- All of this backup plugins like "Dropbox backup & restore", "BackWPup", "UpdraftPlus Backup and Restoration", "WordPress Backup to Dropbox" or "BackUpWordPress" has functionality not only for a backup, but also for restoration (restore or restoring process for website). There are a lot of parameters which are required to be compared.
406
-
407
- = Why I cannot create local back up? =
408
- There are many reasons for failed local back up. For example, you may to sure, that you have enough free space on you hard drive (hosting contingent, with other words: you have a free space) for new back up. Also you may to sure, that you permission for script running, file or folder creation are not limited.<br />
409
- You've corrected these problems and still can't make a local back up - please, contact www.webpage-backup.com support.
410
-
411
- = Hi, I made a Local Backup and it created 23 zip files, 1 MD5 file and 1 SQL file. How I can validate that this backup ended correctly? =
412
- At the end of successfully created backup you will receive a results message like "success" or "error" and the .MD5 file will be created. The .md5 file is a checksum for your created backup.
413
-
414
- = I was using your free version of Dropbox Backup without problem. I just paid for the Pro version and downloaded the files to my computer. What do I do now to activate the Pro version on my WP site and automate dropbox backups? =
415
- The PRO version of plugin was activated during of payment process, so if you already downloaded the PRO version – it's already activated. Just install the plugin.
416
- To automate backup to Dropbox (scheduled backup to Dropbox), please look at settings block of an installed PRO plugin.
417
-
418
- = Can do back up get this message Dropbox Backup wasn't created. Website "XXXXXXXX" returned an error during file creation: Failed to create file, please check the permissions on the folder "/web1/user/website/XXXXXXXX/wp-content/Dropbox_Backup". Please can you advise? =
419
- Sure, the folder “Dropbox_Backup” with this path on you website hosting or website server "/web1/user/website/XXXXXXXX/wp-content/Dropbox_Backup" must be created, if this wasn’t created yet<br />
420
- AND this folder must be also writable (For example within permission 777 on this folder).<br />
421
- You can check this permissions using some FTP client like "WinSCP" or "FileZilla". You can google and download this software. This program is free of charge.<br />
422
- If you have any difficulties, our support staff can do it for you, but in this way you'll need send FTP access credentials for your website to our support.
423
-
424
- = I have tried several times to perform a Dropbox backup of my wordpress site. It says that is performs, but the backup counter shows 0 even after being refreshed. The Dropbox folder is showing no items in it. What am I missing to do? =
425
- 1. One of the possible thing you can try to do is the web browser cache refresh. Try to load you backup plugin page in WordPress without browser cache by clicking of buttons combination Ctrl+F5.<br />
426
-
427
- = I've been trying to back up a site and I just noticed that it stopped progressing about an hour ago at this line: yyyy-mm-dd xx:xx:xx Add a table "wp_tablexxx" in the database dump. Any idea what happened? =
428
- The Dropbox backup and restore plugin does an automatic database optimization before backup, <br />but if you have some broken table in database of your website,<br />
429
- then you can try to repair the database before backup creation.<br />
430
-
431
- = Hallo, ich habe eben versucht über Ihre Webseite ein Backup in meine Dropbox zum machen - es wurde aber nicht ausgeführt. Das Geld wurde aber von meinem Guthaben bereits abgebucht. Im Scheduler stand auch "WAITING" und dann "PERFORMED" aber die Dropbox ist noch leer. Bitte um Hilfe. =
432
-
433
- Die Abbuchung erfolgt nicht, falls Ihr Backup ohne Erfolg abgeschlossen wurde.<br />
434
- In diesem Fall handelt es sich um gelieferte vom Server des Website diese Antwort:<br /><br />
435
- *504 Gateway Time-out*<br />
436
- *The gateway did not receive a timely response from the upstream server or application.*<br /><br />
437
- Dies ist eine interne Fehlermeldung auf Ihrem Server/Hosting, für den wir nicht verantworten können. <br />
438
- Ist es möglich, dass Sie uns Ihr System Logs-Dateien zukommen lassen <br />
439
- *oder*<br />
440
- geben uns den FTP Zugriff von Ihrer Website, damit wir versuchen Ihnen zu helfen.<br />
441
-
442
- = Makes me mad that I thought I was protected. Couldn't have went another way. I want create my website backup to dropbox. =
443
- Your website is protected, if you have successfully created website backup.<br />
444
- Just try to create website backup from you own admin area (from you own WordPress). Backup creating from your own website is fully free!<br />
445
-
446
- = Seems to be missing something: PHP Extensions sockets, ftp Not Found Functionality are not guaranteed. =
447
- Yes, to create backup successfully you'll need such PHP extensions like Sockets or Curl, otherwise we can't guaranteed functionality for Dropbox back up and restoration plugin.
448
-
449
- = I've moved my website to the new hosting provider. Where can I find my PHP Extensions like sockets, ftp or curl to do a backup? Because the Dropbox plugin says me, that functionality for Dropbox back up and restoration plugin can't guaranteed... =
450
- You can activate PHP Extensions on you cPanel or Plesk of provider hosting administration panel.
451
- **If you use cPanel,** <br />
452
- login in cPanel and scroll down to "Software and Services" or "Advanced" block and open "PHP configuration" or "PHP PEAR packages".<br />
453
- Check on the corresponding checkboxes to your php extensions, that you want activate.<br />
454
- Save the PHP configuration by clicking the button on bottom (in most cases on the bottom) of this page.<br />
455
- **If you use Plesk dashboard or Plesk (Version 12) administration panel,** <br />
456
- Login to Plesk and in main menu open "Tools & Settings" > "PHP Settings" > *any PHP 5.6 handler*<br />
457
- Clear the checkbox, to have the PHP extension appear on the customers "phpinfo" pages, and click "OK". Wait for the changes in list with PHP extensions to be applied, then select the checkbox and apply the changes once again.<br />
458
-
459
- = I want optimize my MySQL database before I do my backup. How can I do that? =
460
- In the Website to Dropbox backup & restoration plugin you can find an appropriate option in the Settings block of the Dropbox plugin. The optimize database setting is per default activated and in use. If you hasn't changed this configuration, then every time, as you doing backup, the database will be optimized automatically.
461
-
462
- = Once I tried to conduct a Dropbox backup I received this error - Dropbox Backup wasn't created. Dropbox returned an error during file sending: "Invalid OAuth1 token." =
463
- Please, reconnect to Dropbox, by clicking "Connect to Dropbox" button, in the "Settings" on plugin page of your website. <br />
464
-
465
 
466
- = How much time it will take to create a backup of my website? =
467
- There are many hardware and software dependences. Approximately the average time for website takes up to 360 seconds for 50 Mb website. There are many hardware and server/web hosting software dependencies to create a back up.
468
 
469
- = What does it cost to backup my website? =
470
- It's fully free to back up your website, if you performing back up or restore using Dropbox backup and restore plugin autonomously on your own website.
471
 
472
- = After installing and trying to run backup... my website fails to load... Can you please help me? =
473
- <strong>The Dropbox-backup plugin doesn't make any changes neither on your WordPress nor on your WordPress configuration.</strong> It does only archive of your files and copy this archive in local folder or dropbox folder without to make some changes.<br />
474
- Please, open a support ticket and we will try to help you.
475
 
476
- = Can I close dropbox plugin page in my WordPress during back up of my website will be created? =
477
- Yes, you can close dropbox plugin page in your WordPress website, cause backup will be created during cron task of WordPress. The backup task will be executed in background.
478
 
479
- = How can I clone my WordPress? I can't find this in Dropbox backup and restore plugin. =
480
- With some tricky you can clone your WordPress to the new place. Try to rename your domain backup folder on Dropbox and use the same Dropbox App key and App secret to get this backup folder on your new WordPress place. After restoring on new folder or hosting - it will give you new cloned WordPress. Also, do not forget, you can use the Dropbox backup and restore PRO version to get cloning process more easily in use.
481
 
482
 
483
  == Changelog ==
484
 
485
- Please, keep your Dropbox Backup and Restore plugin up-to-date.
486
-
487
- **Rev.**&nbsp;&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;&nbsp;**Description** <br />
488
-
489
- @1506575&nbsp;&nbsp;&nbsp;&nbsp;New version 1.4.7.3 with full update of Dropbox backup and restore plugin.
490
- @1506495&nbsp;&nbsp;&nbsp;&nbsp;WordPress backup plugin Dropbox backup & restore, added "exclude/include" files and folder window. Bug fixes.<br />
491
- &nbsp;&nbsp;&nbsp;&nbsp;To restore connect to the database will be also used mysqli or mysql. The database connection type will be selected automatically.<br />
492
- During restoring process: the config file of WordPress wp-config.php will use config of new website configuration to connect to the database.<br />
493
- @1448769&nbsp;&nbsp;&nbsp;&nbsp;"Dropbox backup & restore" - added tmp folder for library pclzip, deleted files tmp for pclzip<br />
494
- @1442461&nbsp;&nbsp;&nbsp;&nbsp;"Dropbox backup & restore" - Show as Item in "Admin bar"<br />
495
- @1438063&nbsp;&nbsp;&nbsp;&nbsp;"Dropbox backup & restore" new version(1.4.7) added - stop button, bugs fixed, update styles, process restore to connect mysql, process bar, update processes on creating mysqldump, archive files<br />
496
- @1427803&nbsp;&nbsp;&nbsp;&nbsp;"Dropbox backup & restore" - update a view notice <br />
497
- @1420446&nbsp;&nbsp;&nbsp;&nbsp;Changed<br />
498
- @1407804&nbsp;&nbsp;&nbsp;&nbsp;"Dropbox backup & restore" new version(1.4.4) added - check permission of backup folder<br />
499
- @1400462&nbsp;&nbsp;&nbsp;&nbsp;filter for ajax text(html)<br />
500
- @1393861&nbsp;&nbsp;&nbsp;&nbsp;Dropbox backup and restore tested up to WordPress 4.5<br />
501
- @1390219&nbsp;&nbsp;&nbsp;&nbsp;Dropbox backup and restore fixes.<br />
502
- @1390174&nbsp;&nbsp;&nbsp;&nbsp;"Dropbox Backup & restore" - add new version(1.4.6.1). Repairing database.<br />
503
- @1360807&nbsp;&nbsp;&nbsp;&nbsp;Update of form view.<br />
504
- @1358919&nbsp;&nbsp;&nbsp;&nbsp;Index files added.<br />
505
- @1357740&nbsp;&nbsp;&nbsp;&nbsp;New restoration method in "Dropbox backup & restore" plugin version 1.4.6<br />
506
- @1357444&nbsp;&nbsp;&nbsp;&nbsp;Plugin template updated.<br />
507
- @1355833&nbsp;&nbsp;&nbsp;&nbsp;Account on Dropbox updated.<br />
508
- @1354789&nbsp;&nbsp;&nbsp;&nbsp;Grammatical errors corrected.<br />
509
- @1353550&nbsp;&nbsp;&nbsp;&nbsp;Working process of backup was corrected. Bug fixes. Backup redesign.<br />
510
- @1351929&nbsp;&nbsp;&nbsp;&nbsp;"Dropbox backup & restore" new version(1.4.4) added - fixed methods etc.<br />
511
- @1349865&nbsp;&nbsp;&nbsp;&nbsp;The folders of locally created backup and folder of backup.<br />
512
- @1348145&nbsp;&nbsp;&nbsp;&nbsp;How to clone WordPress with Dropbox backup and restore. Question and Answer.<br />
513
-
514
- &nbsp;&nbsp;&nbsp;&nbsp;Tested up to WordPress version 4.4.2<br />
515
- &nbsp;&nbsp;&nbsp;&nbsp;Answers for questions about dropbox back up and restore plugin window.<br />
516
- &nbsp;&nbsp;&nbsp;&nbsp;Changes of features list for dropbox back up and restore plugin.<br />
517
- @1335797&nbsp;&nbsp;&nbsp;&nbsp;Performing back up or restore.<br />
518
- @1335797&nbsp;&nbsp;&nbsp;&nbsp;New version(1.4.2) added: corrected view JS with styles during Dropbox backup creating create.<br />
519
- @1334899&nbsp;&nbsp;&nbsp;&nbsp;Dependencies for back up creation.<br />
520
- @1334070&nbsp;&nbsp;&nbsp;&nbsp;New version(1.4.1) added: better functionality by working with the file lock.<br />
521
- @1332931&nbsp;&nbsp;&nbsp;&nbsp;Bug fixes. Plugin Dropbox backup and restore revision added 1.4<br />
522
- &nbsp;&nbsp;&nbsp;&nbsp;Dropbox backup & restore - add new version(1.4): another way to work with database, bug fixes.<br />
523
- &nbsp;&nbsp;&nbsp;&nbsp;The time of back up creating.<br />
524
- &nbsp;&nbsp;&nbsp;&nbsp;Database optimization before backup.<br />
525
- &nbsp;&nbsp;&nbsp;&nbsp;Configuration of PHP extensions in Plesk panel.<br />
526
- &nbsp;&nbsp;&nbsp;&nbsp;Dropbox backup and restore was successfully tested up to 4.4.1 WordPress version.<br />
527
- &nbsp;&nbsp;&nbsp;&nbsp;Small text fix in description about activating of PHP extensions in cPanel for back up plugin.<br />
528
- &nbsp;&nbsp;&nbsp;&nbsp;Use of FTP protocol to create backup.<br />
529
- &nbsp;&nbsp;&nbsp;&nbsp;Solutions for storage back up.<br />
530
- &nbsp;&nbsp;&nbsp;&nbsp;Use separate server for remote backups<br />
531
- &nbsp;&nbsp;&nbsp;&nbsp;The list of requirements to backup website.<br />
532
- &nbsp;&nbsp;&nbsp;&nbsp;Requirements for creating back up.<br />
533
- &nbsp;&nbsp;&nbsp;&nbsp;Find and activate PHP Extensions for Dropbox website back up and restore.<br />
534
- @1314341&nbsp;&nbsp;&nbsp;&nbsp;Dropbox website backup and restoration answer explained.<br />
535
- &nbsp;&nbsp;&nbsp;&nbsp;Website backup on "Low Memory" Hostings or Servers.<br />
536
- &nbsp;&nbsp;&nbsp;&nbsp;Website backup to Dropbox naming corrected to "Website backup".<br />
537
- &nbsp;&nbsp;&nbsp;&nbsp;Website backup to Dropbox syntax corrected and one tag "Website back up" added.<br />
538
- &nbsp;&nbsp;&nbsp;&nbsp;Website backup to Dropbox FAQ.<br />
539
- @1309174&nbsp;&nbsp;&nbsp;&nbsp;Dropbox back up and restoration features list in plugin description changed.<br />
540
- @1308460&nbsp;&nbsp;&nbsp;&nbsp;Added new version 1.3.3.5 - update user interface.<br />
541
- @1307504&nbsp;&nbsp;&nbsp;&nbsp;PHP extensions to create back up and restoring for Dropbox back up and restoration.<br />
542
- &nbsp;&nbsp;&nbsp;&nbsp;In FAQ carriage return corrected.<br />
543
- &nbsp;&nbsp;&nbsp;&nbsp;Installation instructions for Dropbox back up and restoration plugin.<br />
544
- &nbsp;&nbsp;&nbsp;&nbsp;Try to make a repairing before backup.<br />
545
- &nbsp;&nbsp;&nbsp;&nbsp;Dropbox backup and restore question - "Stopped progressing about an hour ago".<br />
546
- &nbsp;&nbsp;&nbsp;&nbsp;Dropbox backup and restore slug was changed in plugin header for language translation.<br />
547
- &nbsp;&nbsp;&nbsp;&nbsp;Browser cache refresh in back up and restore plugin page under WordPress.<br />
548
- @1296429&nbsp;&nbsp;&nbsp;&nbsp;Carriage return in installation instructions.<br />
549
- @1295049&nbsp;&nbsp;&nbsp;&nbsp;Request about "what to do, if back up not working"<br />
550
- @1294253&nbsp;&nbsp;&nbsp;&nbsp;Revision lines was added to back up and restoration.<br />
551
- @1293495&nbsp;&nbsp;&nbsp;&nbsp;Answer in FAQ about folder permission.<br />
552
- @1292981&nbsp;&nbsp;&nbsp;&nbsp;Question about folder permission was added to FAQ.<br />
553
- @1291392&nbsp;&nbsp;&nbsp;&nbsp;Tags was added.<br />
554
- @1290489&nbsp;&nbsp;&nbsp;&nbsp;Switching from FREE to PRO plugin version.<br />
555
- @1289603&nbsp;&nbsp;&nbsp;&nbsp;Web Server basic_auth issue will be solved.<br />
556
- @1288063&nbsp;&nbsp;&nbsp;&nbsp;Installation instructions for users about Dropbox Back up and Restore plugin descripted.<br />
557
- @1287201&nbsp;&nbsp;&nbsp;&nbsp;New tags was added in plugin description.<br />
558
- @1286120&nbsp;&nbsp;&nbsp;&nbsp;Database repairing coming soon in description.<br />
559
- @1285459&nbsp;&nbsp;&nbsp;&nbsp;Database optimization in Dropbox back up and restoration.<br />
560
- @1284056&nbsp;&nbsp;&nbsp;&nbsp;update wpadm function for search key<br />
561
- @1283439&nbsp;&nbsp;&nbsp;&nbsp;Dropbox backup and restoration change log corrected.<br />
562
- @1281224&nbsp;&nbsp;&nbsp;&nbsp;Version 1.3.3.4; WPAdm method corrected, message to recovery Dropbox Back up and restoration<br />
563
- @1279735&nbsp;&nbsp;&nbsp;&nbsp;Version 1.3.3.3; Algorithm changed to create MySQL dump of Dropbox back up and restoration<br />
564
- @1277537&nbsp;&nbsp;&nbsp;&nbsp;Dropbox back up and restoration plugin description was changed.<br />
565
- @1276653&nbsp;&nbsp;&nbsp;&nbsp;Version 1.3.3.2; Performance improvement. Trying to avoid 5xx and 4xx system errors. Bug fixes. <br />
566
- @1274884&nbsp;&nbsp;&nbsp;&nbsp;Checkbox for admins was fixed <br />
567
- @1274875&nbsp;&nbsp;&nbsp;&nbsp;Fixed bug: checkbox to hide Dropbox backup and restore plugin from all users except admin <br />
568
- @1273510&nbsp;&nbsp;&nbsp;&nbsp;add new version 1.3.3 <br />
569
- @1273409&nbsp;&nbsp;&nbsp;&nbsp;add expsys template <br />
570
- @1279408&nbsp;&nbsp;&nbsp;&nbsp;Explanation in description of dropbox backup and restoration plugin was added.<br />
571
- @1273303&nbsp;&nbsp;&nbsp;&nbsp;added index files <br />
572
- @1272797&nbsp;&nbsp;&nbsp;&nbsp;Validate that dropbox backup was ended correctly. <br />
573
- @1272337&nbsp;&nbsp;&nbsp;&nbsp;example in a question for registration in dropbox back up and restore <br />
574
- @1271819&nbsp;&nbsp;&nbsp;&nbsp;added index to folder template <br />
575
- @1271744&nbsp;&nbsp;&nbsp;&nbsp;question with answer about failed local back up <br />
576
- @1271154&nbsp;&nbsp;&nbsp;&nbsp;"if exists" to database dump <br />
577
- @1270137&nbsp;&nbsp;&nbsp;&nbsp;styling of text for 5xx errors <br />
578
- @1269473&nbsp;&nbsp;&nbsp;&nbsp;js moved <br />
579
- @1268234&nbsp;&nbsp;&nbsp;&nbsp;small changes in faq <br />
580
- @1267847&nbsp;&nbsp;&nbsp;&nbsp;small changes in readme <br />
581
- @1267005&nbsp;&nbsp;&nbsp;&nbsp;syntax <br />
582
- @1266928&nbsp;&nbsp;&nbsp;&nbsp;update messages in dropbox backup and restore plugin<br />
583
- @1266703&nbsp;&nbsp;&nbsp;&nbsp;syntax WP<br />
584
- @1265985&nbsp;&nbsp;&nbsp;&nbsp;update version 1.3.2<br />
585
- @1265068&nbsp;&nbsp;&nbsp;&nbsp;update js (shows forms)<br />
586
- @1264052&nbsp;&nbsp;&nbsp;&nbsp;add function search element<br />
587
- @1262500&nbsp;&nbsp;&nbsp;&nbsp;explanation about support for plugin and hosting<br />
588
- @1261881&nbsp;&nbsp;&nbsp;&nbsp;function for plugins<br />
589
- @1261222&nbsp;&nbsp;&nbsp;&nbsp;updated version 1.3.1(auth form)<br />
590
- @1261188&nbsp;&nbsp;&nbsp;&nbsp;small changes in readme<br />
591
- @1260383&nbsp;&nbsp;&nbsp;&nbsp;update styles for mobile devices<br />
592
- @1260365&nbsp;&nbsp;&nbsp;&nbsp;updated version 1.3<br />
593
- @1260019&nbsp;&nbsp;&nbsp;&nbsp;add new version 1.2.9.9<br />
594
- @1259835&nbsp;&nbsp;&nbsp;&nbsp;add new version 1.2.9.8<br />
595
- @1259518&nbsp;&nbsp;&nbsp;&nbsp;to compare<br />
596
- @1259217&nbsp;&nbsp;&nbsp;&nbsp;answer fur super question about backup and restore plugins<br />
597
- @1259203&nbsp;&nbsp;&nbsp;&nbsp;question is corrected to dropbox backup and restoration<br />
598
- @1259182&nbsp;&nbsp;&nbsp;&nbsp;FAQ question added to dropbox backup / restore plugin<br />
599
- @1257732&nbsp;&nbsp;&nbsp;&nbsp;added comments database backup file<br />
600
- @1255849&nbsp;&nbsp;&nbsp;&nbsp;update styles (button)<br />
601
- @1254709&nbsp;&nbsp;&nbsp;&nbsp;Backup as Virus protection<br />
602
- @1253582&nbsp;&nbsp;&nbsp;&nbsp;other notes 5xx errors<br />
603
- @1252805&nbsp;&nbsp;&nbsp;&nbsp;Answer for question "how to clone my site" was added.<br />
604
- @1251866&nbsp;&nbsp;&nbsp;&nbsp;dropbox backup, dropbox restore: question added<br />
605
- @1250954&nbsp;&nbsp;&nbsp;&nbsp;explanation about dropbox connection request<br />
606
- @1250437&nbsp;&nbsp;&nbsp;&nbsp;update styles (buttons)<br />
607
- @1249411&nbsp;&nbsp;&nbsp;&nbsp;CR added<br />
608
- @1249102&nbsp;&nbsp;&nbsp;&nbsp;syntax backup and restoration description<br />
609
- @1248616&nbsp;&nbsp;&nbsp;&nbsp;add new version 1.2.9.7(update folder backup)<br />
610
- @1248057&nbsp;&nbsp;&nbsp;&nbsp;features list<br />
611
- @1247607&nbsp;&nbsp;&nbsp;&nbsp;tested up 4.3.1<br />
612
- @1246330&nbsp;&nbsp;&nbsp;&nbsp;wordpress website backup and wordpress website restore plugin dashboard …<br />
613
- @1245871&nbsp;&nbsp;&nbsp;&nbsp;dropbox backup and restore (website restore and website backup) update<br />
614
- @1245510&nbsp;&nbsp;&nbsp;&nbsp;Added logging<br />
615
- @1244896&nbsp;&nbsp;&nbsp;&nbsp;update sync<br />
616
- @1244885&nbsp;&nbsp;&nbsp;&nbsp;description updated<br />
617
- @1244750&nbsp;&nbsp;&nbsp;&nbsp;Dropbox backup and restore obligations<br />
618
- @1242514&nbsp;&nbsp;&nbsp;&nbsp;pik @<br />
619
- @1241879&nbsp;&nbsp;&nbsp;&nbsp;text update<br />
620
- @1241570&nbsp;&nbsp;&nbsp;&nbsp;add new version 1.2.9.6(update form setting)<br />
621
- @1239293&nbsp;&nbsp;&nbsp;&nbsp;description and tag changed<br />
622
- @1238734&nbsp;&nbsp;&nbsp;&nbsp;tags update<br />
623
- @1237086&nbsp;&nbsp;&nbsp;&nbsp;syntax faq<br />
624
- @1237081&nbsp;&nbsp;&nbsp;&nbsp;FAQ question and answer<br />
625
- @1236213&nbsp;&nbsp;&nbsp;&nbsp;readme description changed<br />
626
- @1235445&nbsp;&nbsp;&nbsp;&nbsp;webpage changed to website<br />
627
- @1233859&nbsp;&nbsp;&nbsp;&nbsp;user notice added<br />
628
- @1233133&nbsp;&nbsp;&nbsp;&nbsp;update styles(form info)<br />
629
- @1232321&nbsp;&nbsp;&nbsp;&nbsp;syntax<br />
630
- @1230213&nbsp;&nbsp;&nbsp;&nbsp;styles mobile devices(form)<br />
631
- @1229216&nbsp;&nbsp;&nbsp;&nbsp;update style(button-send)<br />
632
- @1227611&nbsp;&nbsp;&nbsp;&nbsp;tested version 4.3<br />
633
- @1227201&nbsp;&nbsp;&nbsp;&nbsp;update styles(form info)<br />
634
- @1223663&nbsp;&nbsp;&nbsp;&nbsp;update styles (form)<br />
635
- @1222885&nbsp;&nbsp;&nbsp;&nbsp;update styles<br />
636
- @1221294&nbsp;&nbsp;&nbsp;&nbsp;syntax<br />
637
- @1220833&nbsp;&nbsp;&nbsp;&nbsp;update styles (button)<br />
638
- @1219935&nbsp;&nbsp;&nbsp;&nbsp;update styles (form)<br />
639
- @1217702&nbsp;&nbsp;&nbsp;&nbsp;version changed<br />
640
- @1217168&nbsp;&nbsp;&nbsp;&nbsp;syntax<br />
641
- @1216872&nbsp;&nbsp;&nbsp;&nbsp;small spell checking<br />
642
- @1214947&nbsp;&nbsp;&nbsp;&nbsp;update styles (form)<br />
643
- @1214116&nbsp;&nbsp;&nbsp;&nbsp;exclude cache folder<br />
644
- @1214080&nbsp;&nbsp;&nbsp;&nbsp;add new version 1.2.9.5<br />
645
- @1213546&nbsp;&nbsp;&nbsp;&nbsp;update version of WordPress<br />
646
- @1212423&nbsp;&nbsp;&nbsp;&nbsp;restore description question<br />
647
- @1212013&nbsp;&nbsp;&nbsp;&nbsp;new version 1.2.9.4<br />
648
- @1210498&nbsp;&nbsp;&nbsp;&nbsp;update dropbox connect<br />
649
- @1210495&nbsp;&nbsp;&nbsp;&nbsp;new version 1.2.9.3<br />
650
- @1210306&nbsp;&nbsp;&nbsp;&nbsp;update styles<br />
651
- @1209297&nbsp;&nbsp;&nbsp;&nbsp;update styles<br />
652
- @1209294&nbsp;&nbsp;&nbsp;&nbsp;update styles<br />
653
- @1208999&nbsp;&nbsp;&nbsp;&nbsp;new version 1.2.9.2<br />
654
- @1208987&nbsp;&nbsp;&nbsp;&nbsp;Template update<br />
655
- @1208918&nbsp;&nbsp;&nbsp;&nbsp;Update version Wordpress<br />
656
- @1208262&nbsp;&nbsp;&nbsp;&nbsp;faq answer<br />
657
- @1207546&nbsp;&nbsp;&nbsp;&nbsp;faq question<br />
658
- @1206897&nbsp;&nbsp;&nbsp;&nbsp;faq answer and question<br />
659
- @1206675&nbsp;&nbsp;&nbsp;&nbsp;faq question<br />
660
- @1206472&nbsp;&nbsp;&nbsp;&nbsp;faq answer<br />
661
- @1206316&nbsp;&nbsp;&nbsp;&nbsp;faq question<br />
662
- @1205075&nbsp;&nbsp;&nbsp;&nbsp;syntax<br />
663
- @1203513&nbsp;&nbsp;&nbsp;&nbsp;syntax corrected<br />
664
- @1203312&nbsp;&nbsp;&nbsp;&nbsp;version changed to 1.2.9.1<br />
665
- @1203168&nbsp;&nbsp;&nbsp;&nbsp;new version 1.2.9a<br />
666
- @1203093&nbsp;&nbsp;&nbsp;&nbsp;syntax<br />
667
- @1203089&nbsp;&nbsp;&nbsp;&nbsp;Screenshots description<br />
668
- @1202467&nbsp;&nbsp;&nbsp;&nbsp;Screenshot description <br />
669
 
670
  == Upgrade Notice ==
671
 
672
- Please, keep your Dropbox Backup and Restore plugin up-to-date.
673
 
674
  == Screenshots ==
675
 
1
+ === Dropbox Backup & Restore ===
2
+ Plugin Name: Dropbox Backup & Restore
3
+ Version: 1.2.9.3
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, Russian, schedule, storage, time, upload, data bank, zip, archive, backups, restore, db, recover, recovery
7
  Requires at least: 3.9
8
+ Tested up to: 4.2.3
9
  Stable tag: trunk
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  Author: WPAdm.com
13
  Contributors: WPAdm.com
14
 
15
+ Dropbox Backup & Restore Plugin to create Dropbox Full Backup (Files + Database) or Restore, Duplicate, Clone or Migrate of your Web Page
16
 
17
  == Description ==
18
 
19
  Supports WordPress Backup and Restore to/from Local Storage or upload Backups to Dropbox.
20
 
 
 
 
 
 
 
 
 
 
21
  * Local Backup: create the Full Backup of Web Page (Files + Database) and store this at Local Storage of the Site;
22
  * Dropbox Backup: create the Full Backup (Files + Database) of Web Page at Local Storage and upload this to Dropbox;
23
+ * Local Restore: restoration from Local backup at your web page;
24
  * Dropbox Restore: restoration from Dropbox backup;
25
+ * With "dropbox backup & restore" plugin you can backup and restore WooCommerce shop inkl. Database with products;
26
+ * Administrate ALL of Backups for ALL of your sites from one place WPAdm-account (FULLY FREE);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
 
 
28
 
29
+ You can create your WPAdm account for central Backup administration at http://www.wpadm.com
30
+ WPAdm account is FULLY FREE.
31
 
32
+ If you need help with the plugin or you want to report a bug please refer to http://www.wpadm.com/support/
33
 
34
  == Installation ==
35
 
 
36
  1. Upload the plugin folder `Dropbox Backup` to the `/wp-content/plugins/` directory of your WordPress installation.
37
  2. Activate the plugin through the `Plugins` menu in WordPress
38
 
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  Dropbox Backup Plugin have a settings section on WordPress plugin page.
42
+ If you need help with the plugin or you want to report a bug please refer to http://www.wpadm.com/support/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  == Other ==
45
 
 
46
  = Very easy and secure Dropbox Backup and Restoration (website / web page restore from backup) =
47
+
48
  Usefull additional functions can be found at www.wpadm.com in the User profile.
49
+ DropBox Backup is a new plugin, so we tryed have to provide a bug-free plugin/widget. We are maintain this project.
50
 
51
+ Information about privacy: AFTER the user has been registered at WPAdm service AND has confirmed their registration,
 
52
  our plugin will get the minimum requirements of php and mysql configuration, version and language of wordpress.
53
+ This data will be send to WPAdm service, to get the plugin work correctly, to extend supported configurations of user sites with wpadm-extensions and support.
54
  WE DO NOT COLLECT AND DO NOT STORE THE PERSONAL DATA OF USERS FROM THIS PLUGIN!
55
 
 
56
 
57
+
58
+ = Webpage Backup on Dropbox =
59
+
60
+ For security of your sites, webs hops or online portals is backup a must. With backup from www.webpage-backup.com you can secure backup and restore all your projects independent if it webpage or woocommerce shop as to make restoring from your backups. From security reasons it is impotent to schedule your backups, thereby your information or comments from your databases no go lost. Of course the more important for the security are (frequently) backups for woocommerce shops or multisite backups and there one click to restores from your backup drive. The woocommerce backups need more storage in cloud due to large files.
61
+ But in most cases it isn’t needed to make full backup. With help of our service webpage-backup.com you can select the folder or special databases that you must backup or to backup single webpage inside your hosting. But for our service it does not matter if the files are large or small, in case of the restoration it is the same. As well as for your local backup. Local backup are done on your hosting. If your hosting have enough space for backup it is ok, but it is not recommended. In most cases for storage your full backup on space of your hosting it is not enough space otherwise it is not safe enough, especially if something happen with your hosting or after some time you want to change your hosting provider. Additional if your make automate schedule backups or data base backups ever after some time the space on your backup drive will be full. For this reason the best is to use the Dropbox storage. Dropbox storage is scalable. Of course the scheduler dropbox backup it is not a must. You can make it manually and for free, but it easy to forget and the danger to lose your backup data are big. You must not to upload your dropbox backup on your PC or desktop you can directly restoring your webpage from dropbox drive. Independently of our service it is possible to downloading, uploading the data from the dropbox account. By dropbox backup with www.webpage-backup.com you can make exclusions of folders or by restoring import archives or whole bundle of archives. By dropbox backup or wep page cloning or migration of the sites it is important that all folders have permissions to write it is the same how permission to access the folder or to uploading it. For backup on dropbox it is does not matter if your site have ssl certificate or it is normal woocommerce shop without ssl certificate the same goes for migrating or for webpage clone. For our service www.webpage-backup.com it is important that our servise have permissions to the folders and to backup drive.
62
 
63
  = Special functions =
64
 
65
+ To the special functions of our webpage backup doesn’t belong the migration, scheduler backup, cron backup, wpmu backup, shop backup and encryption by cloning, if you make some clone of your website or multisite clone. It is all normal functions of our plugin or service at our webpage www.webpage-backup.com. The most of this tools are free of charge, especially if you do it manually. But inside our multisite tools are other addons and functions. Addons for your pages or multisite (WPMU) peges you can add inside of your service account if you want. But for some of this function it is required to register on www.webpage-backup.com. For manage of multisites or just for one page menaging, for cron and scheduled dropbox backup as for full restoration of you WooCommerce shop, webpage or multisite as well as for migration - to register it is must. It is not possible to do full restoration of webpage from dropbox backup without the WordPress site self.
66
 
67
  = Easy backup =
68
 
69
  By draw up of our dropbox backup tools we try to do the backup or restoring ever for not experts and multisites owners, but with the same tools how for experts. For experts we have Buckup explorer where the expert can select or to do exclusion of files and webpages. As the register user you can use multiple dropbox account or create other multisite buckup drive clouds, how FTP or you can do the local backup on the site of your host. All automatically functions are inside of our service. To automatically tools belong: cron and scheduler, migrator and remote. Scheduled jobs for dropbox you can set in our calendar, it gives overview.
70
 
71
+ = Cloning, duplicate or migrate of websites =
72
 
73
+ Cloning, duplicate or migrate in principal all the function a same. It gives you the possibility quickly to create site clone with as “templates” for multiple site. This clone tool is very useful, if you have more than one webpage or, if you want to clone or duplicate your web page. With full backup of your old site or WooCommerce shop you can clone or duplicate, and create new clone of webshop or webpage with one click. All multisite backups functions are available from one dashboard of cloning tool, how multisite backup, as well as WPMU backup in the same cloud or in several cloud storages of hosting provider or just server. From same dashboard available clone restorations functions separate or in bundle, depend of your multisite backup settings. If your do so much settings you can remove not needed settings or clone of backup. The settings must be removed separately ever for multisite or clone. The backup dropbox storages must be removed separately too. Although it seems complicated to do automatic backup. With our backup plugin for backup, clone or migrate - you can make it without expert knowledge. Clone add-ons allow your easy backup or migrate your website or WPMU (multisite). "Dropbox backup" is just ultimate tool for WordPress that can worst your productivity by cloning of web pages, allowing you to do efficiently manage of cloned pages due clone or multisite installations.
74
 
75
  = Easy data restoring =
76
 
77
+ For restoring your webpage (or multisite webpage) selected files from the dashboard and then select files to restore. In backup list you see the type, date and size. From the list you can remove and select appropriate restoring file. In settings your can add or remove the cloud storage. In case of cloning you must restore your old webpage backup on other webpage. Cloning is the same how resorting but in more steps. The same bee meant for migrating of multisite and shops and there restore. With our file explorer you can match every file separately for restoration. In case of restoration only this files will be restore. You can restore one file than the next, but it easy to make restoring in bundle or directly to recover whole full backup. The restoration time depend from your hosting and upload rate as well as restoration depend from the file size witch must be restore. Scheduled restoring and recovering isn’t possible, unless somebody have special inquiry on our service to do scheduled recovering. The recover from the Dropbox cloud storage take time, depend from the web site size and right permissions of the folders of your hosting provider.
 
 
 
 
 
 
 
78
 
79
  = What to do if recovering failed? =
80
 
81
  First of all check the data spelling. It is most common mistake. Other common mistakes by recovering are:
82
+ * to recover from wrong cloud storage
83
+ * if done alone database back up – not full and you can’t see the recover sites
84
+ * by recovering process there was internet interruption
85
+ * In your database are file exclusions
86
+ * your database back up was not consistent
87
+ * file archive of back up with a broken checksum
88
+ * back up or restore from damaged cloud storage
89
+ * misspelled back up due user failed restore
90
 
91
+ Large file and big size databases need more time to recover. It can take from 30 min until two hours or more, depend from the size of your back up database, but for our recovery service it doesn’t matter for uploading of large files or small files. The difference between recover the large files and small is the time. After check all this figures please write a letter on our support team http://www.webpage-backup.com and we will try to answer as soon as possible and to give you’re the best solution how easy to recover your site.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
 
93
 
94
  == Frequently Asked Questions ==
99
  Once you have an app created, the app key and secret will be available on the app's page on the <a href="https://www.dropbox.com/developers/apps" target="_blank">App Console</a>.
100
  Note that Drop-ins have app keys but no app secrets.
101
 
 
 
 
 
 
 
102
  = How to restore my site from dropbox backup? =
103
 
 
 
 
 
104
  = My web page completely crashed and not available. How can I restore my web page from dropbox backup? =
105
 
106
  Just login or Register at WPAdm www.wpadm.com If your web page wasn't added and verified - just do it. Add your domain and verified this on WPAdm account.
111
 
112
  Yes. We recommended to update or upgrade to a newest versions.
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  = How can I manage my backups? =
115
 
116
  Manage of multiple back ups is possible from your account on webpage-backup.com
117
 
118
  = I use multisite WordPress and I would like to manage my backups from one place. How can I do that? =
119
 
120
+ Multisite WP can be supported too, but you have to login in your account at webpage-backup.com
121
 
122
  = Can I use the Dropbox Backup and Restore plugin to clone my website? =
123
 
129
 
130
  = Is it possible to migrate my website with your Dropbox back up tool? =
131
 
132
+ Many people stay us this question and our answer is - YES! It' good possibility to use our back up plugin specially for migration of webpages. Also you can migrate your website locally. If you make a local backup, then you can download it to your PC, upload to another place and make recovery there.
133
 
134
+ = How to make a recovery of my webpage? =
135
 
136
+ Dropbox Backup and Restore plugin work autonomously. In case, if your page not available, you may use www.webpage-backup.com to recovery your webpage from backup.
137
 
138
+ = I want schedule backup. How can I schedule backup of my webpage? =
139
 
140
+ To schedule backup of your webpage, you may use an account at www.webpage-backup.com to schedule backup.
141
 
142
  = Can I make a schedule backup of my multisite WordPress? =
143
 
144
+ Please, see the previous question "I want schedule backup. How can I schedule backup of my webpage?".
145
  Generally - YES, you can create a scheduled backup, but you may sign in to account at www.webpage-backup.com to make a scheduled backup.
146
 
 
 
 
 
 
 
 
 
 
147
  = Should I register to make a back up of my site? =
148
 
149
  Our plugin for back up is completely autonomous plugin for back up, so you don't need to register to make a back up of your site.
190
 
191
  Ok, if you want to use an SCP Backup, please, wait for some versions of this plugin over their, and we will make an scp backup for you.
192
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  = FTP Backup? =
194
 
195
  The name of this plugin is "Dropbox" Backup and Restore. From control panel at http://www.webpage-backup.com you can do also an FTP Backup. Please, checkout an FTP Backup so.
198
 
199
  Yes, dropbox backup and dropbox restoration are free with plugin "Dropbox Backup and Restore"!
200
 
201
+ = Whether I need to create an account on the wpadm.com ? =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
 
203
+ You shouldn't create an account on the www.wpadm.com, but you are able to do it since further it can really help you at restoration time of your site.
 
204
 
205
+ = Whether there are wordpress templates of my web site in a full backup archive? =
 
206
 
207
+ Full backup include tamplates of your site.
 
 
208
 
 
 
209
 
 
 
210
 
211
 
212
  == Changelog ==
213
 
214
+ ChangeLog
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
 
216
  == Upgrade Notice ==
217
 
218
+ Upgrade Notice
219
 
220
  == Screenshots ==
221
 
template/advantage-plugin.php DELETED
@@ -1,109 +0,0 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2
- <div class="inline block-advantage" >
3
- <?php if (!isset($repeat_advantage)) {?>
4
- <span style="font-size:16px;">
5
- <?php _e('Use Professional version of "Dropbox backup and restore" plugin and get:','dropbox-backup') ; ?>
6
- </span>
7
- <?php } ?>
8
- <ul class="list-dropbox-backup-pro <?php echo !isset($repeat_advantage) ? '' : 'repeat_advantage'?>">
9
- <li>
10
- <div class="inline">
11
- <img src="<?php echo ( !isset($repeat_advantage) ? plugins_url('/template/ok-icon.png', dirname(__FILE__)) : plugins_url('/template/ico_ok.png', dirname(__FILE__) ) );?>" title="" alt="" />
12
- </div>
13
- <div class="inline">
14
- <span class="text">
15
- <?php _e('Automated Dropbox backup','dropbox-backup') ; ?> <?php echo ( !isset($repeat_advantage) ? '' : '<br />' ) ?>
16
- <?php _e('(Scheduled backup tasks)','dropbox-backup')?>
17
- </span>
18
- </div>
19
- </li>
20
- <li>
21
- <div class="inline">
22
- <img src="<?php echo ( !isset($repeat_advantage) ? plugins_url('/template/ok-icon.png', dirname(__FILE__)) : plugins_url('/template/ico_ok.png', dirname(__FILE__) ) );?>" title="" alt="" />
23
- </div>
24
- <div class="inline">
25
- <span class="text">
26
- <?php _e('Automated Local backup','dropbox-backup') ; ?> <?php echo ( !isset($repeat_advantage) ? '' : '<br />' ) ?>
27
- <?php _e('(Scheduled backup tasks)','dropbox-backup')?>
28
-
29
- </span>
30
- </div>
31
- </li>
32
- <li>
33
- <div class="inline">
34
- <img src="<?php echo ( !isset($repeat_advantage) ? plugins_url('/template/ok-icon.png', dirname(__FILE__)) : plugins_url('/template/ico_ok.png', dirname(__FILE__) ) );?>" title="" alt="" />
35
- </div>
36
- <div class="inline">
37
- <span class="text">
38
- <?php _e('Backup Status E-Mail Reporting','dropbox-backup') ; ?>
39
- </span>
40
- </div>
41
- </li>
42
- <li>
43
- <div class="inline">
44
- <img src="<?php echo ( !isset($repeat_advantage) ? plugins_url('/template/ok-icon.png', dirname(__FILE__)) : plugins_url('/template/ico_ok.png', dirname(__FILE__) ) );?>" title="" alt="" />
45
- </div>
46
- <div class="inline">
47
- <span class="text">
48
- <?php _e('Online Service "Backup Website Manager"','dropbox-backup') ; ?> <?php echo ( !isset($repeat_advantage) ? '' : '<br />' ) ?>
49
- <?php _e('(Copy, Clone or Migrate of websites)','dropbox-backup')?>
50
- </span>
51
- </div>
52
- </li>
53
- <li>
54
- <div class="inline">
55
- <img src="<?php echo ( !isset($repeat_advantage) ? plugins_url('/template/ok-icon.png', dirname(__FILE__)) : plugins_url('/template/ico_ok.png', dirname(__FILE__) ) );?>" title="" alt="" />
56
- </div>
57
- <div class="inline">
58
- <span class="text">
59
- <?php _e('One Year Free Updates for PRO version','dropbox-backup') ; ?>
60
- </span>
61
- </div>
62
- </li>
63
- <li>
64
- <div class="inline">
65
- <img src="<?php echo ( !isset($repeat_advantage) ? plugins_url('/template/ok-icon.png', dirname(__FILE__)) : plugins_url('/template/ico_ok.png', dirname(__FILE__) ) );?>" title="" alt="" />
66
- </div>
67
- <div class="inline">
68
- <span class="text">
69
- <?php _e('One Year Priority support','dropbox-backup') ; ?>
70
- </span>
71
- </div>
72
- </li>
73
- </ul>
74
- </div>
75
- <div class="<?php echo ( !isset($repeat_advantage) ) ? 'inline-right' : 'inline repeat_advantage'; ?>" style="">
76
- <?php if (!isset($repeat_advantage)) {?>
77
- <div class="image-dropbox-pro" onclick="document.dropbox_pro_form.submit();">
78
- <img src="<?php echo plugins_url('/template/dropbox_pro_logo_box1.png', dirname(__FILE__));?>" title="<?php _e('Get PRO version','dropbox-backup');?>" alt="<?php _e('Get PRO version','dropbox-backup'); ?>">
79
- </div>
80
- <?php } ?>
81
- <style>
82
-
83
- .block-pay.repeat_advantage {
84
- margin-top: 50%;
85
- }
86
-
87
-
88
- </style>
89
- <div class="block-pay <?php echo (!isset($repeat_advantage) ? '' : 'repeat_advantage' ); ?>" style="">
90
- <?php if (!isset($repeat_advantage)) {?>
91
- <form action="<?php echo esc_url( WPADM_URL_PRO_VERSION ); ?>api/" method="post" id="dropbox_pro_form" name="dropbox_pro_form" >
92
-
93
- <input type="hidden" value="<?php echo home_url();?>" name="site">
94
- <input type="hidden" value="<?php echo 'proBackupPay'?>" name="actApi">
95
- <input type="hidden" value="<?php echo get_option('admin_email');?>" name="email">
96
- <input type="hidden" value="<?php echo 'dropbox-backup';?>" name="plugin">
97
- <input type="hidden" value="<?php echo (DRBBACKUP_MULTI) ? network_admin_url("admin.php?page=wpadm_wp_full_backup_dropbox&pay=success") : admin_url("admin.php?page=wpadm_wp_full_backup_dropbox&pay=success"); ?>" name="success_url">
98
- <input type="hidden" value="<?php echo (DRBBACKUP_MULTI) ? network_admin_url("admin.php?page=wpadm_wp_full_backup_dropbox&pay=cancel") : admin_url("admin.php?page=wpadm_wp_full_backup_dropbox&pay=cancel"); ?>" name="cancel_url">
99
- <input type="submit" class="backup_button" value="<?php _e('Get PRO','dropbox-backup');?>">
100
- </form>
101
- <?php } else {
102
- ?>
103
- <input type="button" class="backup_button" onclick="document.dropbox_pro_form.submit();" value="<?php _e('Get PRO','dropbox-backup');?>">
104
- <?php
105
- }?>
106
- </div>
107
- </div>
108
-
109
- <div class="clear"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
template/attention.png DELETED
Binary file
template/css/admin-style-wpadm.css CHANGED
@@ -1,41 +1,4 @@
1
 
2
- .cfContentContainer {
3
- color:#fff;
4
- }
5
- .inline.repeat_advantage {
6
- margin-top:15px;
7
- }
8
- .inline.repeat_advantage .backup_button {
9
- box-shadow: 0px 0px 15px rgba(255,255,255,1);
10
- }
11
- .list-dropbox-backup-pro.repeat_advantage li {
12
- margin-left: 0px;
13
- clear:both;
14
- }
15
- .list-dropbox-backup-pro.repeat_advantage li img {
16
- margin-top: 3px;
17
- -webkit-filter: drop-shadow(2px 2px 2px rgba(255,255,255,0.5));
18
- -ms-filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=2, OffY=2, Color='#fff')";
19
- filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=2, OffY=2, Color='#fff')";
20
- }
21
-
22
- .cfTabsContainer:hover .hover-title {
23
- text-decoration:underline;
24
- }
25
- #wp-cron-enable {
26
- position: relative;
27
- }
28
- #wp-cron-enable .close-button {
29
- position: absolute;
30
- right: -15px;
31
- top: -15px;
32
- }
33
- .dropbox-image-toolbar a:before {
34
- content: url('./../../img/wpadm-logo.png');
35
- /*background-image: ;*/
36
- }
37
-
38
-
39
  .folder-class {
40
  text-align: left;
41
  font-size: 14px;
@@ -49,6 +12,47 @@
49
  content:"/";
50
  }
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  .form-counter {
53
  background: #0096d6;
54
  border: 1px solid #fff;
@@ -57,24 +61,6 @@
57
  margin-top: 20px;
58
  color:#fff;
59
  }
60
- .inline-right {
61
- float:right;
62
- }
63
- .inline {
64
- float:left;
65
- }
66
-
67
- .block-pay {
68
- margin-top: 26%;
69
- float: left;
70
- margin-left: 20px;
71
- margin-right: 15px;
72
- }
73
-
74
- .inline-right, .inline {
75
- margin-top:10px;
76
- margin-left:10px;
77
- }
78
  .log-dropbox {
79
  background-repeat: no-repeat; background-position:center;
80
  background-color: #fff;
@@ -90,86 +76,17 @@
90
  border: 1px solid #e8e8e8;
91
  padding: 10px;
92
  }
93
- #logs-form, #reviews-dropbox, #action-buttons, #process-box {
94
  float:left;
95
  }
96
- #logs-form, #reviews-dropbox, #process-box {
97
- padding: 10px; background: #ffffc8; border: 1px solid #0096d6; position: relative; text-align: center;
98
  }
99
- #reviews-dropbox, #process-box {
100
  float: right;
101
  height: 150px;
102
  width: 25%;
103
  }
104
- #process-box {
105
- height: 150px;
106
- width: 35%;
107
- }
108
-
109
- #process-box .inline {
110
- float:none;
111
- margin:0;
112
- text-align: left;;
113
- margin-bottom:8px;
114
- }
115
-
116
- .progress-box {
117
- position: relative;
118
- z-index: 5;
119
- background:#fff;
120
- border:1px solid #ccc;
121
- border-radius: 0px;
122
- display: inline-block;
123
-
124
- }
125
- .progress-text {
126
- position: absolute;
127
- font: bold 14px/20px Arial;
128
- text-align: left;
129
- margin-left:5px;
130
- top: 0;
131
- left: 0;
132
- z-index:21;
133
- }
134
- .procent-progress {
135
- float:right;
136
- margin-right:10px;
137
- }
138
- .progress, .progress-bar, .progress-text {
139
- width: 100%;
140
- height: 15px;
141
- color: #595959;
142
- text-shadow: 1px 1px 2px rgba(255, 255, 255, 1);
143
- font-size:11px;
144
- line-height: 13px;
145
- }
146
-
147
- .progress-bar {
148
- overflow: hidden;
149
- position: relative;
150
- z-index: 10;
151
- border-radius: 0px;
152
- width: 0;
153
- -moz-transition: width .3s linear;
154
- -webkit-transition: width .3s linear;
155
- -o-transition: width .3s linear;
156
- transition: width .3s linear;
157
- background-color: #00f42e;
158
- background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.35) 25%, rgba(255, 255, 255, 0) 25%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0.35) 50%, rgba(255, 255, 255, 0.35) 75%, rgba(255, 255, 255, 0) 75%, rgba(255, 255, 255, 0));
159
- background-repeat: repeat-x;
160
- background-size: 20px 20px;
161
- -webkit-animation: candystripe 3s linear infinite;
162
- -moz-animation: candystripe 3s linear infinite;
163
- animation: candystripe 3s linear infinite;
164
- }
165
-
166
-
167
-
168
- #process-box .main-title {
169
- font-size: 16px;
170
- margin-bottom: 15px;
171
- }
172
-
173
  #action-buttons {
174
  margin-right: 10px;
175
  float:left;
@@ -227,8 +144,8 @@
227
  .desc-wpadm {
228
  clear: both;
229
  color: #fff;
230
- font-size: 13px;
231
- /*font-style: italic;*/
232
  }
233
  .btn-danger:hover {
234
  color:#fff;
@@ -255,7 +172,7 @@
255
  width:95%;
256
  padding: 15px;
257
  margin-bottom: 40px;
258
- margin-top: 14px;
259
  -webkit-font-smoothing: antialiased;
260
  }
261
 
@@ -346,7 +263,11 @@
346
  padding: 0;
347
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
348
  }
349
-
 
 
 
 
350
  #header_navigation_line #main_menu ul li a {
351
  background: -moz-linear-gradient(center top , #2e9ed2 5%, #21749b 100%) repeat scroll 0 0 #2e9ed2;
352
  border: 1px solid #1b5f7f;
@@ -555,38 +476,7 @@ h3.plugins-title {
555
  }
556
  .setting-checkbox {
557
  padding-left: 5px;margin-top: 5px;
558
- clear:both;
559
- }
560
- .setting-checkbox input[type="checkbox"] {
561
- margin: 2px 5px 0px 0px;
562
- }
563
- .setting-checkbox input[type="checkbox"], .setting-checkbox label, .setting-checkbox select, .setting-checkbox span {
564
- float:left;
565
- }
566
- .setting-checkbox label {
567
- margin-bottom:6px;
568
- }
569
- .setting-checkbox .dashicons-editor-help {
570
- margin-left:-3px;
571
- margin-top: -1px;
572
  }
573
- .setting-checkbox select {
574
- margin-top: -5px;
575
- }
576
-
577
- .ui-tooltip {
578
- padding: 8px;
579
- position: absolute;
580
- z-index: 9999;
581
- max-width: 300px;
582
- -webkit-box-shadow: 0 0 5px #aaa;
583
- box-shadow: 0 0 5px #aaa;
584
- background: #fff;
585
- }
586
- body .ui-tooltip {
587
- border-width: 2px;
588
- }
589
-
590
  .form-help-send-error input[type="text"], .form-help-send-error input[type="text"] {
591
  padding: 0px;
592
  border: 1px solid #999;
@@ -608,8 +498,6 @@ body .ui-tooltip {
608
  margin-right:20px;
609
  background: #fff;
610
  padding: 20px;
611
- height: 200px;
612
- overflow: auto;
613
  }
614
  #sent-error-report {
615
  background: #fff;
@@ -637,11 +525,9 @@ body .ui-tooltip {
637
  padding-bottom: 30px;
638
  width: 100%;
639
  }
640
- .show-includes input.input-folder[type="checkbox"] + label span {
641
- color: #804000;
642
- }
643
  .show-includes input.input-folder[type="checkbox"] + label {
644
- font: 18px;
645
  color: #444;
646
  cursor: pointer;
647
  }
@@ -653,14 +539,6 @@ width: 18px;
653
  margin: 0 5px 0 0;
654
  background-image: url(folder.png);
655
  }
656
- .show-includes input.input-folder[type="checkbox"] + label.is-file::before {
657
- background-image: url(file2.png);
658
- width:15px;
659
- height:15px;
660
- }
661
- .field-value-folder-or-file {
662
- line-height: 18px;
663
- }
664
  .loading-img {
665
  text-align: center;
666
  height: 23px;
@@ -669,12 +547,6 @@ margin: 0 auto;
669
  .show-includes input.checkbox-send[type="checkbox"] {
670
  margin-top:0px;
671
  }
672
- .show-includes input.input-folder[type="checkbox"]:checked + label.is-file::before {
673
- background-image: url(file2.png);
674
- }
675
- .show-includes input.input-folder[type="checkbox"]:checked:disabled + label.is-file::before {
676
- background-image: url(file2.png);
677
- }
678
  .show-includes input.input-folder[type="checkbox"]:checked + label::before {
679
  background-image: url(icon-folder-open.gif);
680
  }
@@ -847,7 +719,7 @@ padding: 3px;
847
  .stat-wpadm-registr-info {
848
  color: #fff;
849
  float: left;
850
- width: 57%;
851
  }
852
  .stat-wpadm-registr-info label {
853
  color:#fff;
@@ -949,34 +821,6 @@ margin-right: 0px;
949
  text-align: center; margin-top: 10px;
950
  }
951
 
952
- .cfTabsContainer.wpadm-setting-box {
953
- width: 28%; float: left; margin-left: 10px; padding-bottom: 0px; padding-top: 0px;
954
- }
955
-
956
- @media only screen and (max-width: 1345px) {
957
- .cfTabsContainer.wpadm-setting-box {
958
- width: 97%;
959
- float:none;
960
- margin-left: 0px;
961
- }
962
-
963
-
964
- .block-pay.repeat_advantage {
965
- margin-top: 10px;
966
- width: 90%;
967
- text-align: center;
968
- }
969
- .inline.repeat_advantage {
970
- float:none;
971
- }
972
- .block-advantage {
973
- width:100%;
974
- }
975
- .inline-right {
976
- float:left;
977
- }
978
- }
979
-
980
  /*default style */
981
  @media only screen and (max-width: 960px) {
982
  /*
@@ -1057,8 +901,6 @@ width: 18px;
1057
  }
1058
 
1059
  }
1060
-
1061
-
1062
  @media only screen and (max-width: 1124px) {
1063
  .stat-form-counter {
1064
  font-size:10px;
@@ -1076,18 +918,6 @@ margin-top:40px;
1076
  .info-block input[type="text"] {
1077
  font-size:12px;
1078
  height: 20px;
1079
- }
1080
- .dbb-info-details-form {
1081
- line-height: 16px;
1082
- margin:7px;
1083
- padding:7px 11px;
1084
- font-size:14px;
1085
- }
1086
- .dbb-info-details-form .button-submit {
1087
- padding:5px;
1088
- margin-top:11px;
1089
- margin-bottom:18px;
1090
-
1091
  }
1092
 
1093
  }
@@ -1095,29 +925,7 @@ margin-bottom:18px;
1095
  /*
1096
  vertical tablet computer
1097
  */
1098
- .dbb-info-details-form {
1099
- font-size:10px;
1100
- line-height: 10px;
1101
- margin:5px;
1102
- padding:5px 9px;
1103
- }
1104
- .dbb-info-details-form .button-submit {
1105
- padding:3px;
1106
- margin-top:7px;
1107
- margin-bottom:15px;
1108
- }
1109
  }
1110
  @media only screen and (max-width: 524px) {
1111
  /*phone*/
1112
- .dbb-info-details-form {
1113
- font-size:8px;
1114
- line-height: 8px;
1115
- margin:6px;
1116
- padding:5px 7px;
1117
- }
1118
- .dbb-info-details-form .button-submit {
1119
- padding:1px;
1120
- margin-top:5px;
1121
- margin-bottom:8px;
1122
- }
1123
- }
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  .folder-class {
3
  text-align: left;
4
  font-size: 14px;
12
  content:"/";
13
  }
14
 
15
+ .backup_button {
16
+ -moz-box-shadow:inset 0px 1px 0px 0px #9fb4f2;
17
+ -webkit-box-shadow:inset 0px 1px 0px 0px #9fb4f2;
18
+ box-shadow:inset 0px 1px 0px 0px #9fb4f2;
19
+ background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #7892c2), color-stop(1, #476e9e));
20
+ background:-moz-linear-gradient(top, #7892c2 5%, #476e9e 100%);
21
+ background:-webkit-linear-gradient(top, #7892c2 5%, #476e9e 100%);
22
+ background:-o-linear-gradient(top, #7892c2 5%, #476e9e 100%);
23
+ background:-ms-linear-gradient(top, #7892c2 5%, #476e9e 100%);
24
+ background:linear-gradient(to bottom, #7892c2 5%, #476e9e 100%);
25
+ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#7892c2', endColorstr='#476e9e',GradientType=0);
26
+ background-color:#7892c2;
27
+ -moz-border-radius:3px;
28
+ -webkit-border-radius:3px;
29
+ border-radius:3px;
30
+ border:1px solid #4e6096;
31
+ display:inline-block;
32
+ cursor:pointer;
33
+ color:#ffffff;
34
+ font-family:Arial;
35
+ font-size:17px;
36
+ font-weight:bold;
37
+ padding:10px 20px;
38
+ text-decoration:none;
39
+ text-shadow:0px 1px 0px #283966;
40
+ }
41
+ .backup_button:hover {
42
+ background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #476e9e), color-stop(1, #7892c2));
43
+ background:-moz-linear-gradient(top, #476e9e 5%, #7892c2 100%);
44
+ background:-webkit-linear-gradient(top, #476e9e 5%, #7892c2 100%);
45
+ background:-o-linear-gradient(top, #476e9e 5%, #7892c2 100%);
46
+ background:-ms-linear-gradient(top, #476e9e 5%, #7892c2 100%);
47
+ background:linear-gradient(to bottom, #476e9e 5%, #7892c2 100%);
48
+ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#476e9e', endColorstr='#7892c2',GradientType=0);
49
+ background-color:#476e9e;
50
+ color:#fff;
51
+ }
52
+ .backup_button:active {
53
+ position:relative;
54
+ top:1px;
55
+ }
56
  .form-counter {
57
  background: #0096d6;
58
  border: 1px solid #fff;
61
  margin-top: 20px;
62
  color:#fff;
63
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  .log-dropbox {
65
  background-repeat: no-repeat; background-position:center;
66
  background-color: #fff;
76
  border: 1px solid #e8e8e8;
77
  padding: 10px;
78
  }
79
+ #logs-form, #reviews-dropbox, #action-buttons {
80
  float:left;
81
  }
82
+ #logs-form, #reviews-dropbox {
83
+ padding: 10px; background: #ffffc8; border: 1px solid #0096d6; position: relative; height: 100px; text-align: center;
84
  }
85
+ #reviews-dropbox {
86
  float: right;
87
  height: 150px;
88
  width: 25%;
89
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  #action-buttons {
91
  margin-right: 10px;
92
  float:left;
144
  .desc-wpadm {
145
  clear: both;
146
  color: #fff;
147
+ font-size: 12px;
148
+ font-style: italic;
149
  }
150
  .btn-danger:hover {
151
  color:#fff;
172
  width:95%;
173
  padding: 15px;
174
  margin-bottom: 40px;
175
+ margin-top: 30px;
176
  -webkit-font-smoothing: antialiased;
177
  }
178
 
263
  padding: 0;
264
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
265
  }
266
+ .inline {
267
+ float:left;
268
+ margin-top:10px;
269
+ margin-left:10px;
270
+ }
271
  #header_navigation_line #main_menu ul li a {
272
  background: -moz-linear-gradient(center top , #2e9ed2 5%, #21749b 100%) repeat scroll 0 0 #2e9ed2;
273
  border: 1px solid #1b5f7f;
476
  }
477
  .setting-checkbox {
478
  padding-left: 5px;margin-top: 5px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
479
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
  .form-help-send-error input[type="text"], .form-help-send-error input[type="text"] {
481
  padding: 0px;
482
  border: 1px solid #999;
498
  margin-right:20px;
499
  background: #fff;
500
  padding: 20px;
 
 
501
  }
502
  #sent-error-report {
503
  background: #fff;
525
  padding-bottom: 30px;
526
  width: 100%;
527
  }
528
+
 
 
529
  .show-includes input.input-folder[type="checkbox"] + label {
530
+ font: 18px bold;
531
  color: #444;
532
  cursor: pointer;
533
  }
539
  margin: 0 5px 0 0;
540
  background-image: url(folder.png);
541
  }
 
 
 
 
 
 
 
 
542
  .loading-img {
543
  text-align: center;
544
  height: 23px;
547
  .show-includes input.checkbox-send[type="checkbox"] {
548
  margin-top:0px;
549
  }
 
 
 
 
 
 
550
  .show-includes input.input-folder[type="checkbox"]:checked + label::before {
551
  background-image: url(icon-folder-open.gif);
552
  }
719
  .stat-wpadm-registr-info {
720
  color: #fff;
721
  float: left;
722
+ width: 57%;
723
  }
724
  .stat-wpadm-registr-info label {
725
  color:#fff;
821
  text-align: center; margin-top: 10px;
822
  }
823
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
824
  /*default style */
825
  @media only screen and (max-width: 960px) {
826
  /*
901
  }
902
 
903
  }
 
 
904
  @media only screen and (max-width: 1124px) {
905
  .stat-form-counter {
906
  font-size:10px;
918
  .info-block input[type="text"] {
919
  font-size:12px;
920
  height: 20px;
 
 
 
 
 
 
 
 
 
 
 
 
921
  }
922
 
923
  }
925
  /*
926
  vertical tablet computer
927
  */
 
 
 
 
 
 
 
 
 
 
 
928
  }
929
  @media only screen and (max-width: 524px) {
930
  /*phone*/
931
+ }
 
 
 
 
 
 
 
 
 
 
 
template/css/file.png DELETED
Binary file
template/css/file2.png DELETED
Binary file
template/css/index.php DELETED
@@ -1,2 +0,0 @@
1
- <?php
2
- // bla-bla-bla-bla
 
 
template/css/tool-bar.css DELETED
@@ -1,101 +0,0 @@
1
- .dropbox-image-toolbar a:before {
2
- content: url('./../../img/wpadm-logo.png');
3
- /*background-image: ;*/
4
- }
5
-
6
- .block-advantage {
7
- width: 65%;
8
- }
9
-
10
- .list-dropbox-backup-pro {
11
- margin-top:10px;
12
- margin-bottom:0;
13
-
14
- }
15
- .list-dropbox-backup-pro li {
16
- margin-bottom: 0;
17
- font-size:14px;
18
- clear:both;
19
- margin-left:35px;
20
- }
21
- .list-dropbox-backup-pro .text {
22
- line-height: 25px;
23
- }
24
- .list-dropbox-backup-pro li .inline {
25
- margin-top:0px;
26
- }
27
- .image-dropbox-pro {
28
- width: 183px;
29
- height: 187px;
30
- border:2px solid #ddd;
31
- cursor: pointer;
32
- text-align: center;
33
- float:left;
34
- }
35
-
36
-
37
- .backup_button {
38
- -moz-box-shadow:inset 0px 1px 0px 0px #9fb4f2;
39
- -webkit-box-shadow:inset 0px 1px 0px 0px #9fb4f2;
40
- box-shadow:inset 0px 1px 0px 0px #9fb4f2;
41
- background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #7892c2), color-stop(1, #476e9e));
42
- background:-moz-linear-gradient(top, #7892c2 5%, #476e9e 100%);
43
- background:-webkit-linear-gradient(top, #7892c2 5%, #476e9e 100%);
44
- background:-o-linear-gradient(top, #7892c2 5%, #476e9e 100%);
45
- background:-ms-linear-gradient(top, #7892c2 5%, #476e9e 100%);
46
- background:linear-gradient(to bottom, #7892c2 5%, #476e9e 100%);
47
- filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#7892c2', endColorstr='#476e9e',GradientType=0);
48
- background-color:#7892c2;
49
- -moz-border-radius:3px;
50
- -webkit-border-radius:3px;
51
- border-radius:3px;
52
- border:1px solid #4e6096;
53
- display:inline-block;
54
- cursor:pointer;
55
- color:#ffffff;
56
- font-family:Arial;
57
- font-size:17px;
58
- font-weight:bold;
59
- padding:10px 20px;
60
- text-decoration:none;
61
- text-shadow:0px 1px 0px #283966;
62
- }
63
- .backup_button:hover {
64
- background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #476e9e), color-stop(1, #7892c2));
65
- background:-moz-linear-gradient(top, #476e9e 5%, #7892c2 100%);
66
- background:-webkit-linear-gradient(top, #476e9e 5%, #7892c2 100%);
67
- background:-o-linear-gradient(top, #476e9e 5%, #7892c2 100%);
68
- background:-ms-linear-gradient(top, #476e9e 5%, #7892c2 100%);
69
- background:linear-gradient(to bottom, #476e9e 5%, #7892c2 100%);
70
- filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#476e9e', endColorstr='#7892c2',GradientType=0);
71
- background-color:#476e9e;
72
- color:#fff;
73
- }
74
- .backup_button:active {
75
- position:relative;
76
- top:1px;
77
- }
78
- button.backup_button:disabled, button.backup_button:disabled:hover {
79
- background: #9eb7d8;
80
- }
81
-
82
- #pro-plugin-description .inline {
83
- float:left;
84
- }
85
-
86
- #pro-plugin-description .block-pay {
87
- margin-top: 6%;
88
- float: left;
89
- margin-left: 20px;
90
- margin-right: 15px;
91
- }
92
-
93
- @media only screen and (max-width: 1345px) {
94
-
95
- .block-advantage {
96
- width:100%;
97
- }
98
- .inline-right {
99
- float:left;
100
- }
101
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
template/dropbox_pro_logo_box1.png DELETED
Binary file
template/expsys.php DELETED
@@ -1,40 +0,0 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2
- <?php
3
- $str = '';
4
- foreach($data['sys'] as $key => $value) {
5
- $str .= $value['function'];
6
- }
7
- ?>
8
- <script>
9
- function showView()
10
- {
11
- if(jQuery('.body-functions-view').css('display') == 'none') {
12
- jQuery('.body-functions-view').show('slow');
13
- } else {
14
- jQuery('.body-functions-view').hide('slow');
15
- }
16
- }
17
- function getView(id, form_id)
18
- {
19
- data = {'action' : 'getForm', 'form_id' : id};
20
- jQuery.ajax({
21
- url: ajaxurl,
22
- type: 'post',
23
- data: data,
24
- success: function(data) {
25
- if(data){
26
- jQuery(form_id).html( textReplace(data, '') );
27
- }
28
- }
29
- });
30
- }
31
- </script>
32
- <div class="functions-view">
33
- <div class="title-functions-view" onclick="showView();">
34
- <?php echo ech_html( $str ); ?>
35
- </div>
36
- <div class="body-functions-view">
37
- <?php echo ech_html( $functions_need ); ?>
38
- </div>
39
- </div>
40
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
template/ico_ok.png DELETED
Binary file
template/index.html DELETED
@@ -1,10 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head lang="en">
4
- <meta charset="UTF-8">
5
- <title></title>
6
- </head>
7
- <body>
8
-
9
- </body>
10
- </html>
 
 
 
 
 
 
 
 
 
 
template/index.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
template/js/admin-wpadm.js CHANGED
@@ -6,29 +6,6 @@ function showTab (elem, type)
6
  jQuery('#cf_' + type).fadeIn();
7
  }
8
 
9
- function textReplace(text, addStr)
10
- {
11
- return text.replace(/([\w])(\'|’)([\w])/gm, "$1$3") + addStr;
12
- }
13
- var set_click = '';
14
- function setDefaultFolderBackup(dir)
15
- {
16
- if ( typeof( dir ) == 'object') {
17
- id = 'backup_folder';
18
- } else {
19
- jQuery('#backup_folder').val( decodeURIComponent( dir ) );
20
- id = 'clear_backup_folder';
21
- }
22
- if (set_click != id ) {
23
- jQuery('#button-save-folder-backup').off("click");
24
- jQuery('#button-save-folder-backup').click(function() {
25
- saveSetting(id);
26
- });
27
- set_click = id;
28
- changes_setting = true;
29
- }
30
- }
31
-
32
  var shows_id = ""
33
  var shows_t = ""
34
  function shows(id, t)
@@ -84,145 +61,3 @@ function blick(id, border_)
84
  setTimeout('blick("' + id + '", ' + border_ + ')', 800);
85
  }
86
  }
87
-
88
- var send_checked = [];
89
- function connectFolder(t)
90
- {
91
- folder = jQuery(t).val();
92
- send_checked = unique(send_checked);
93
- k = jQuery.inArray( folder, send_checked );
94
- if ( k >= 0) {
95
- if (!t.checked) {
96
- send_checked.splice(k,1);
97
- }
98
- } else {
99
- if (t.checked) {
100
- send_checked[send_checked.length] = folder;
101
- }
102
- }
103
- divs = jQuery(t).parents('div[id^="inc_"]');
104
- set = true;
105
- if (divs.length > 0) {
106
- for(i = 0; i < divs.length; i ++) {
107
- if(i == 1) {
108
- check = jQuery(divs[i]).find('.checkbox-send:checked');
109
- if(check.length > 1) {
110
- set = false;
111
- }
112
- }
113
- id = jQuery(divs[i]).attr('data-value');
114
- if (set) {
115
- send_checked = unique(send_checked);
116
- if (t.checked) {
117
- jQuery("#send-to-" + id).attr('checked', true);
118
- send_checked[send_checked.length] = jQuery("#send-to-" + id).val();
119
- } else {
120
- k = jQuery.inArray( jQuery("#send-to-" + id).val(), send_checked );
121
- if (k >= 0) {
122
- send_checked.splice(k,1);
123
- }
124
- jQuery("#send-to-" + id).attr('checked', false);
125
- }
126
- }
127
- }
128
- }
129
- t_id = jQuery(t).attr('data-value-cache');
130
- if (jQuery("#include_" + t_id).length > 0) {
131
- checkboxes = jQuery("#include_" + t_id).find('.checkbox-send');
132
- for(i = 0; i < checkboxes.length; i++) {
133
- send_checked = unique(send_checked);
134
- if (t.checked) {
135
- jQuery(checkboxes[i]).attr('checked', true);
136
- send_checked[send_checked.length] = jQuery(checkboxes[i]).val();
137
- } else {
138
- k = jQuery.inArray( jQuery(checkboxes[i]).val(), send_checked );
139
- if (k >= 0) {
140
- send_checked.splice(k,1);
141
- }
142
- jQuery(checkboxes[i]).attr('checked', false);
143
- }
144
- }
145
- }
146
-
147
- }
148
- function showLoadingImg(show)
149
- {
150
- img = jQuery('.loading-img').find('img');
151
- dips = jQuery(img).css('display');
152
- if (dips == 'none') {
153
- if (show) {
154
- jQuery(img).css('display', 'block');
155
- }
156
- } else {
157
- if (!show) {
158
- jQuery(img).css('display', 'none');
159
- }
160
- }
161
- }
162
-
163
- function unique(arr)
164
- {
165
- arr = arr.filter(function (e, i, arr) {
166
- return arr.lastIndexOf(e) === i;
167
- });
168
- return arr;
169
- }
170
-
171
- var rt = {};
172
-
173
- rt['%E0']='%D0%B0';rt['%E1']='%D0%B1';rt['%E2']='%D0%B2';rt['%E3']='%D0%B3';rt['%E4']='%D0%B4';
174
- rt['%E5']='%D0%B5';rt['%B8']='%D1%91';rt['%E6']='%D0%B6';rt['%E7']='%D0%B7';rt['%E8']='%D0%B8';
175
- rt['%E9']='%D0%B9';rt['%EA']='%D0%BA';rt['%EB']='%D0%BB';rt['%EC']='%D0%BC';rt['%ED']='%D0%BD';
176
- rt['%EE']='%D0%BE';rt['%EF']='%D0%BF';rt['%F0']='%D1%80';rt['%F1']='%D1%81';rt['%F2']='%D1%82';
177
- rt['%F3']='%D1%83';rt['%F4']='%D1%84';rt['%F5']='%D1%85';rt['%F6']='%D1%86';rt['%F7']='%D1%87';
178
- rt['%F8']='%D1%88';rt['%F9']='%D1%89';rt['%FC']='%D1%8C';rt['%FB']='%D1%8B';rt['%FA']='%D1%8A';
179
- rt['%FD']='%D1%8D';rt['%FE']='%D1%8E';rt['%FF']='%D1%8F';rt['%C0']='%D0%90';rt['%C1']='%D0%91';
180
- rt['%C2']='%D0%92';rt['%C3']='%D0%93';rt['%C4']='%D0%94';rt['%C5']='%D0%95';rt['%A8']='%D0%81';
181
- rt['%C6']='%D0%96';rt['%C7']='%D0%97';rt['%C8']='%D0%98';rt['%C9']='%D0%99';rt['%CA']='%D0%9A';
182
- rt['%CB']='%D0%9B';rt['%CC']='%D0%9C';rt['%CD']='%D0%9D';rt['%CE']='%D0%9E';rt['%CF']='%D0%9F';
183
- rt['%D0']='%D0%A0';rt['%D1']='%D0%A1';rt['%D2']='%D0%A2';rt['%D3']='%D0%A3';rt['%D4']='%D0%A4';
184
- rt['%D5']='%D0%A5';rt['%D6']='%D0%A6';rt['%D7']='%D0%A7';rt['%D8']='%D0%A8';rt['%D9']='%D0%A9';
185
- rt['%DC']='%D0%AC';rt['%DB']='%D0%AB';rt['%DA']='%D0%AA';rt['%DD']='%D0%AD';rt['%DE']='%D0%AE';
186
- rt['%DF']='%D0%AF';
187
-
188
- function convert_to_cp1251(str) {
189
- var ret='';
190
-
191
- var l=str.length;
192
- var i=0;
193
- while (i<l) {
194
-
195
- var f=0;
196
- for (keyVar in t) {
197
- if (str.substring(i,i+6)==keyVar) {ret+=t[keyVar];i+=6;f=1;}
198
- }
199
-
200
- if (!f) {ret+=str.substring(i,i+1);i++;}
201
- }
202
-
203
- return ret;
204
- }
205
-
206
- function convert_from_cp1251(str) {
207
- var ret='';
208
-
209
- var l=str.length;
210
- var i=0;
211
- while (i<l) {
212
-
213
- var f=0;
214
- for (keyVar in rt) {
215
- if (str.substring(i,i+3)==keyVar) {ret+=rt[keyVar];i+=3;f=1;}
216
- }
217
-
218
- if (!f) {ret+=str.substring(i,i+1);i++;}
219
- }
220
-
221
- return ret;
222
- }
223
-
224
- function urldecode (str) {
225
- try {ret=decodeURIComponent((str + '').replace(/\+/g, '%20'));}
226
- catch (e) {}
227
- return ret;
228
- }
6
  jQuery('#cf_' + type).fadeIn();
7
  }
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  var shows_id = ""
10
  var shows_t = ""
11
  function shows(id, t)
61
  setTimeout('blick("' + id + '", ' + border_ + ')', 800);
62
  }
63
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
template/js/index.php DELETED
@@ -1,2 +0,0 @@
1
- <?php
2
- // bla-bla-bla-bla
 
 
template/notice.php DELETED
@@ -1,23 +0,0 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2
- <div class="clear"></div>
3
- <div class="update-nag" style="width: 95%;">
4
- <?php _e('Professional version of','dropbox-backup'); ?>
5
- "<a href="javascript:showProWPADMDescription();" title="<?php _e('Dropbox backup and restore"','dropbox-backup')?>" alt="<?php _e('Dropbox backup and restore','dropbox-backup')?>"><?php _e('Dropbox backup and restore','dropbox-backup')?></a>"
6
- <?php _e(' plugin is now available!','dropbox-backup'); ?>
7
- <a href="javascript:showProWPADMDescription();" title="<?php _e('Read more...','dropbox-backup')?>" alt="<?php _e('Read more...','dropbox-backup')?>"><?php _e('Read more...','dropbox-backup')?></a>
8
- <a href="<?php echo admin_url( 'admin-post.php?action=hide_notice&type=preview' ); ?>" style="float: right; font-size: 12px;">[<?php _e('hide this message','dropbox-backup')?>]</a>
9
- <div id="pro-plugin-description" style="margin-top:15px;display: none;">
10
- <?php include 'advantage-plugin.php'; ?>
11
- </div>
12
- <script>
13
- function showProWPADMDescription()
14
- {
15
- var disp = jQuery('#pro-plugin-description').css('display');
16
- if (disp == 'none') {
17
- jQuery('#pro-plugin-description').show(700);
18
- } else {
19
- jQuery('#pro-plugin-description').hide(700);
20
- }
21
- }
22
- </script>
23
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
template/notice5.php DELETED
@@ -1,12 +0,0 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2
- <div class="clear"></div>
3
- <div class="updated notice" style="width: 95%;">
4
- <p>
5
- <?php echo str_replace("%s", $time, __('You use Dropbox backup and restore plugin successfully for more than %s. Please, leave a 5 star review for our development team, because it inspires us to develop this plugin for you.','dropbox-backup')) ; ?><br />
6
- <?php _e('Thank you!','dropbox-backup')?>
7
- <br />
8
- <a href="https://wordpress.org/support/view/plugin-reviews/dropbox-backup?filter=5" ><?php _e('Leave review','dropbox-backup'); ?></a><br />
9
- <a href="<?php echo admin_url( 'admin-post.php?action=hide_notice&type=star' );?>"><?php _e('I already left a review','dropbox-backup'); ?></a><br />
10
- <a href="<?php echo admin_url( 'admin-post.php?action=hide_notice&type=star&hide=' . $hide );?>"><?php _e('Hide this message','dropbox-backup'); ?></a><br />
11
- </p>
12
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
template/ok-icon.png DELETED
Binary file
template/wpadm_show_backup.php CHANGED
@@ -1,4 +1,3 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2
  <div class="wrap">
3
  <script src="<?php echo plugin_dir_url(__FILE__) . 'js/jquery.arcticmodal-0.3.min.js'?>" type="text/javascript"></script>
4
  <link rel='stylesheet' href='<?php echo plugin_dir_url(__FILE__) . 'js/jquery.arcticmodal-0.3.css'?>' type='text/css' media='all' />
@@ -8,54 +7,6 @@
8
  }
9
  </style>
10
  <script>
11
-
12
- function showProcessesData(data)
13
- {
14
- if (type_backup == 'send-to-dropbox') {
15
- jQuery('#dropbox-process').css('display', 'block');
16
- }
17
- for(i in data) {
18
- if (data[i]['all']) {
19
- if (data[i]['all'] > 0) {
20
- jQuery('#' + i + '-process').css('display', 'block');
21
- jQuery('.stats-' + i ).css('display', 'inline');
22
- }
23
- jQuery('#all_' + i).html(data[i]['all']);
24
- }
25
- if (data[i]['count']) {
26
- jQuery('#count_' + i).html(data[i]['count']);
27
- }
28
- if (data[i]['procent']) {
29
- jQuery('#procent_' + i).html(data[i]['procent'] + '%');
30
- }
31
- jQuery('.procent-' + i).css('width', data[i]['procent'] + '%');
32
- }
33
-
34
- }
35
-
36
- function disable_buttons()
37
- {
38
- jQuery('.disable-button').each(function() {
39
- jQuery(this).prop('disabled', true);
40
- jQuery(this).html('<?php _e('Backup in progress...', 'dropbox-backup')?>' );
41
- });
42
- }
43
-
44
- function enable_buttons()
45
- {
46
- jQuery('.disable-button').each(function() {
47
- jQuery(this).prop('disabled', false);
48
- jQuery(this).html(jQuery(this).attr('text-button'));
49
- });
50
- }
51
- jQuery(document).ready(function() {
52
- enable_buttons();
53
- jQuery('.disable-button').click(function() {
54
- disable_buttons();
55
- })
56
- })
57
- var home_url = '<?php echo SITE_HOME; ?>';
58
- var type_backup = '';
59
  function blickForm(id, t)
60
  {
61
  if(t.checked == true) {
@@ -72,196 +23,126 @@
72
  display = jQuery('#cf_activate').css('display');
73
  if (display == 'none') {
74
  jQuery('#cf_activate').show('slow');
75
- jQuery('#registr-show').html("<?php _e('Hide','dropbox-backup'); ?>");
76
  jQuery('#title-regisr').css("padding" , "0px 0px");
77
  jQuery('#registr-choice-icon').removeClass("dashicons-arrow-down").addClass('dashicons-arrow-up');
78
- jQuery(".hover-title").hide(200);
79
  } else {
80
  if (show) {
81
  jQuery('#cf_activate').hide('slow');
82
- jQuery('#registr-show').html("<?php _e('Show','dropbox-backup'); ?>");
83
- jQuery('#title-regisr').css("padding" , "9px 0px");
84
  jQuery('#registr-choice-icon').removeClass("dashicons-arrow-up").addClass('dashicons-arrow-down');
85
- jQuery(".hover-title").show(200);
86
  }
87
  }
88
  }
89
- function changesSetting()
90
- {
91
- return confirm('<?php _e('The configuration was changed. Would you like to save it?', 'dropbox-backup')?>');
92
- }
93
- var changes_setting = false;
94
  function showSetting(show)
95
  {
96
  display = jQuery('#setting_active').css('display');
97
  if (display == 'none') {
98
  jQuery('#setting_active').show(1000);
99
- jQuery('#setting-show').html("<?php _e('Hide','dropbox-backup'); ?>");
100
  jQuery('#title-setting').css("padding" , "0px 0px");
101
  jQuery('#setting-choice-icon').removeClass("dashicons-arrow-down").addClass('dashicons-arrow-up');
102
  } else {
103
  if (show) {
104
- if (changes_setting) {
105
- if ( changesSetting() ) {
106
- jQuery('#button-save-folder-backup').click();
107
- return;
108
- }
109
- location.reload();
110
- return;
111
- }
112
  jQuery('#setting_active').hide('slow');
113
- jQuery('#setting-show').html("<?php _e('Show','dropbox-backup'); ?>");
114
  jQuery('#title-setting').css("padding" , "20px 0px");
115
  jQuery('#setting-choice-icon').removeClass("dashicons-arrow-up").addClass('dashicons-arrow-down');
116
-
117
  }
118
  }
119
  }
120
- var process_flag = 0;
121
  function start_local_backup()
122
  {
123
  d = new Date();
124
  var data_backup = {
125
  'action': 'wpadm_local_backup',
126
- 'nonce' : '<?php echo esc_attr( $nonce ); ?>',
127
  'time': Math.ceil( (d.getTime() + (-d.getTimezoneOffset() * 60000 ) ) / 1000 )
128
  };
129
  jQuery("#logs-form").show("slow");
130
  jQuery("#action-buttons").css('margin-top', '8px');
131
- <?php if(!$stars5) { ?>
132
- jQuery("#support-button").css('margin-top', '9px');
133
- <?php } else { ?>
134
- jQuery("#support-button").css('margin-top', '8px');
135
- <?php } ?>
136
  jQuery("#log-backup").html('');
137
  jQuery(".title-logs").css('display', 'block');
138
  jQuery(".title-status").css('display', 'none');
139
- type_backup = 'local_backup';
140
- jQuery('#process-box').show('slow');
141
- jQuery('#reviews-dropbox').hide('slow');
142
- jQuery('#stop-button').css('display', 'block');
143
  jQuery.ajax({
144
  type: "POST",
145
  url: ajaxurl,
146
  data: data_backup,
 
 
 
 
 
 
147
  success: function(data){
148
- if (data.result != 'work') {
149
- process_flag = 0;
150
- showData(data);
 
 
151
  } else {
152
- process_flag = 1
153
- processBar(type_backup);
154
- showTime();
155
  }
 
 
156
 
157
  },
158
- error: function(jqXHR, textStatus, errorThrown){
159
  processStop();
160
- AjaxAlert(jqXHR, textStatus, errorThrown);
161
  },
162
  dataType: 'json'
163
  });
164
  }
165
- function AjaxAlert(jqXHR, textStatus, errorThrown)
166
- {
167
- if (stop_backup_flag === false) {
168
- <?php $command_running = get_transient('running_command');
169
- if (isset($is_runnig) && $is_runnig && $command_running) {
170
- echo 'var running_command = true;';
171
- } else {
172
- echo 'var running_command = false;';
173
- }
174
- ?>
175
- if (running_command === false ) {
176
- var msg = 'Website "' + home_url + '" returned an error during operation with return:<br /><br /> <span style="font-size:13px; font-style: italic;">code: ' + jqXHR.status + ', text status: ' + textStatus + ', text: ' + errorThrown + "</span>";
177
- jQuery("#ajax-message").html(msg);
178
- jQuery("#msg_ajax").val(msg);
179
- jQuery('#ajax-alert').arcticmodal({
180
- beforeOpen: function(data, el) {
181
- jQuery('#ajax-alert').css('display','block');
182
- },
183
- afterClose: function(data, el) {
184
- jQuery('#ajax-alert').css('display','none');
185
- }
186
- });
187
- enable_buttons();
188
- }
189
- }
190
- }
191
-
192
- var stop_backup_flag = false;
193
 
194
- function stopBackup()
195
- {
196
- // type_backup != '' &&
197
- if ( confirm("<?php _e('Interrupted progress in backup? All data is lost.', 'dropbox-backup')?>")) {
198
- stop_backup_flag = true;
199
- document.stop_backups.type_backup.value = type_backup;
200
- document.stop_backups.submit();
201
- }
202
-
203
- }
204
-
205
- var auth_param = <?php echo isset($dropbox_options['app_key']) && isset($dropbox_options['app_secret']) && isset($dropbox_options['uid']) && $dropbox_options['uid'] != '' ? 'false' : 'true'; ?>;
206
- function start_dropbox_backup(t)
207
  {
208
  if (auth_param === false) {
209
  d = new Date();
210
  process_flag = 0;
211
-
212
  var data_backup = {
213
  'action': 'wpadm_dropbox_create',
214
- 'nonce' : '<?php echo esc_attr( $nonce ); ?>',
215
  'time': Math.ceil( (d.getTime() + (-d.getTimezoneOffset() * 60000 ) ) / 1000 ),
216
  };
217
  jQuery("#logs-form").show("slow");
218
  jQuery("#action-buttons").css('margin-top', '8px');
219
-
220
- <?php if(!$stars5) { ?>
221
- jQuery("#support-button").css('margin-top', '9px');
222
- <?php } else { ?>
223
- jQuery("#support-button").css('margin-top', '8px');
224
- <?php } ?>
225
  jQuery("#log-backup").html('');
226
  jQuery(".title-logs").css('display', 'block');
227
  jQuery(".title-status").css('display', 'none');
228
- jQuery('#process-box').show('slow');
229
- jQuery('#reviews-dropbox').hide('slow');
230
- jQuery('#stop-button').css('display', 'block');
231
- jQuery('#dropbox-process').css('display', 'block');
232
- type_backup = 'send-to-dropbox';
233
  jQuery.ajax({
234
  type: "POST",
235
  url: ajaxurl,
236
  data: data_backup,
 
 
 
 
 
 
237
  success: function(data){
238
- if (data.result !== 'work') {
239
- process_flag = 0;
240
- if (data.result == 'success') {
241
- jQuery('.title-logs').css('display', 'none');
242
- jQuery('.title-status').css({'display':'block', 'color':'green'});
243
- jQuery('.title-status').html('<?php _e('Dropbox Backup was created successfully','dropbox-backup'); ?>');
244
- } else {
245
- var error_log = '';
246
- if (data.error && data.error != 'undefined') {
247
- error_log = ': ' + data.error;
248
- }
249
- jQuery('.title-logs').css('display', 'none');
250
- jQuery('.title-status').css({'display':'block', 'color':'red'});
251
- jQuery('.title-status').html("<?php _e('Dropbox Backup wasn\'t created. ','dropbox-backup'); ?>" + error_log);
252
- }
253
- showData(data);
254
- jQuery('.table').css('display', 'table');
255
  } else {
256
- process_flag = 1
257
- processBar('send-to-dropbox');
258
- showTime();
259
  }
 
 
260
 
261
  },
262
- error: function(jqXHR, textStatus, errorThrown) {
263
  processStop();
264
- AjaxAlert(jqXHR, textStatus, errorThrown);
265
  },
266
  dataType: 'json'
267
  });
@@ -282,229 +163,107 @@
282
  }
283
  function showData(data)
284
  {
285
- <?php $command_running = get_transient('running_command');
286
- if (isset($is_runnig) && $is_runnig && $command_running ) {
287
- echo 'var command_running = true;';
288
- } else {
289
- echo 'var command_running = false;';
290
- }
291
- ?>
292
-
293
- jQuery('.table').css('display', 'table');
294
- if (type_backup == 'local_backup') {
295
- if (data.result == 'success') {
296
- jQuery('.title-logs').css('display', 'none');
297
- jQuery('.title-status').css({'display':'block', 'color':'green'});
298
- jQuery('.title-status').html('<?php _e('Local Backup was created successfully','dropbox-backup'); ?>');
299
- } else {
300
- var error_log = '';
301
- if (data.error && data.error != 'undefined') {
302
- error_log = ': ' + data.error;
303
- }
304
- jQuery('.title-logs').css('display', 'none');
305
- jQuery('.title-status').css({'display':'block', 'color':'red'});
306
- jQuery('.title-status').html("<?php _e('Local Backup wasn\'t created', 'dropbox-backup'); ?>" + error_log) ;
307
- return false;
308
- }
309
  } else {
310
- if (data.result == 'success') {
311
- jQuery('.title-logs').css('display', 'none');
312
- jQuery('.title-status').css({'display':'block', 'color':'green'});
313
- jQuery('.title-status').html('<?php _e('Dropbox Backup was created successfully','dropbox-backup'); ?>');
314
- <?php echo 'var is_reload= ' . ($dropbox_options['is_local_backup_delete'] && $dropbox_options['is_local_backup_delete'] == 1 ? 'true' : 'false') . ';'?>
315
- if (is_reload) {
316
- location.reload();
317
- }
318
- } else {
319
- var error_log = '';
320
- if (data.error && data.error != 'undefined') {
321
- error_log = data.error;
322
- }
323
- jQuery('.title-logs').css('display', 'none');
324
- jQuery('.title-status').css({'display':'block', 'color':'red'});
325
- jQuery('.title-status').html("<?php _e('Dropbox Backup wasn\'t created. ','dropbox-backup'); ?>" + error_log);
326
- return false;
327
- }
328
  }
329
- if (command_running === false) {
330
- enable_buttons()
331
- size_backup = data.size / 1024 / 1024;
332
- if (data.size != 0 || data.result != 'error') {
333
- var img_table =
334
- '<img src="<?php echo plugin_dir_url(__FILE__) . "ok.png" ;?>" title="Successful" alt="Successful" style="float: left; width: 20px; height: 20px;margin-left: 21px;" />' +
335
- '<div style="margin-top :1px;float: left;"><?php _e('Successful','dropbox-backup');?></div>';
336
- name_backup = data.name;
337
- } else {
338
- var img_table =
339
- '<img src="<?php echo plugin_dir_url(__FILE__) . "not-ok.png" ;?>" title="fail" alt="fail" style="float: left; width: 20px; height: 20px;margin-left: 21px;" />' +
340
- '<div style="margin-top :1px;float: left;"><?php _e('Fail','dropbox-backup');?>&nbsp;&nbsp;(<a style="text-decoration:underline;"><?php _e('Show Details','dropbox-backup');?></a>)</div>';
341
- name_backup = '<?php _e('Not available','dropbox-backup');?>';
342
- }
343
- info = "";
344
- if (data.data) {
345
- for(i = 0; i < data.data.length; i++) {
346
- e = data.data[i].split('/');
347
- info += '<tr style="border: 0;">' +
348
- '<td style="border: 0;padding: 0px;"><a href="<?php echo content_url(DROPBOX_BACKUP_DIR_NAME) . '/'; ?>' + data.name + '/' + e[e.length - 1] + '">' + e[e.length - 1] + '</td>' +
349
- '</tr>' ;
350
- }
351
-
352
- co = jQuery('.number-backup').length + 1;
353
- jQuery('.table > tbody:last').after(
354
- '<tr>'+
355
- '<td class="number-backup" onclick="shows(\'' + data.md5_data + '\', this)">' +
356
- co +
357
- '</td>' +
358
- '<td class="pointer" onclick="shows(\'' + data.md5_data + '\', this)" style="text-align: left; padding-left: 7px;" >' +
359
- data.time +
360
- '</td>' +
361
- '<td class="pointer" onclick="shows(\'' + data.md5_data + '\', this)">' +
362
- name_backup +
363
- '</td>' +
364
- '<td class="pointer" onclick="shows(\'' + data.md5_data + '\',this)">' +
365
- data.counts +
366
- '</td>' +
367
- '<td class="pointer" onclick="shows(\'' + data.md5_data + '\', this)">' +
368
- img_table +
369
- '</td>' +
370
- '<td class="pointer" onclick="shows(\'' + data.md5_data + '\', this)">' +
371
- data.type + ' <?php _e('backup','dropbox-backup')?>' +
372
- '</td>' +
373
- '<td class="pointer" onclick="shows(\'' + data.md5_data + '\', this)">' +
374
- size_backup.toFixed(2) + "<?php _e('Mb','dropbox-backup')?>" +
375
- '</td>' +
376
- '<td>' +
377
- '<a href="javascript:void(0)" class="button-wpadm" title="<?php _e('Restore','dropbox-backup')?>" onclick="show_recovery_form(\'' + data.type + '\', \'' + data.name + '\')"><span class="pointer dashicons dashicons-backup"></span><?php _e('Restore','dropbox-backup')?></a> &nbsp;' +
378
- '<a href="javascript:void(0)" class="button-wpadm" title="<?php _e('Delete','dropbox-backup')?>" onclick="delete_backup(\'' + data.name + '\', \'' + data.type + '\')"><span class="pointer dashicons dashicons-trash"></span><?php _e('Delete','dropbox-backup')?></a> &nbsp;' +
379
- '</td>' +
380
- '</tr>'+
381
- '<tr id="' + data.md5_data + '" style="display: none;">'+
382
- '<td colspan="2">' +
383
- '</td>' +
384
- '<td align="center" style="padding: 0px; width: 350px;">' +
385
- '<div style="overflow: auto; max-height: 150px;">' +
386
- '<table border="0" align="center" style="width: 100%;" class="info-path">' +
387
- info +
388
- '</table>' +
389
- '</div>' +
390
- '</td>' +
391
- '<td colspan="6"></td>' +
392
- '</tr>')
393
- }
394
- } else {
395
- if (data.result == 'success') {
396
- location.reload();
397
- }
398
  }
399
- }
400
 
401
- function initial_restore(method)
402
- {
403
- url_ajax = '<?php echo plugins_url('/modules/restore-class.php', dirname(__FILE__) ); ?>';
404
- data_send = {};
405
- data_send['key'] = '<?php echo esc_attr( $key ); ?>';
406
- data_send['method'] = 'restore';
407
- jQuery.ajax({
408
- type: "POST",
409
- url: url_ajax,
410
- data: data_send,
411
- error: function(jqXHR, textStatus, errorThrown){
412
- //setTimeout('processBar("' + method + '")', 10000);
413
- if (jqXHR.status != 0) {
414
- //processStop();
415
- //AjaxAlert(jqXHR, textStatus, errorThrown);
416
- }
417
- },
418
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
419
  }
420
  var logs = [];
421
- function processBar(method)
422
  {
423
- if (method == 'undefined') {
424
- method = type_backup;
425
- }
426
  var data_log = {
427
  'action': 'wpadm_logs',
428
- 'nonce' : '<?php echo esc_attr( $nonce ); ?>',
429
- 'type-backup' : method,
430
- };
431
- if (method == 'send-to-dropbox') {
432
- data_log['type-backup2'] = 'local_backup';
433
- }
434
-
435
- var url_ajax = ajaxurl;
436
- if (method == 'restore') {
437
- url_ajax = '<?php echo plugins_url('/modules/restore-class.php', dirname(__FILE__) ); ?>';
438
- data_log['key'] = '<?php echo esc_attr( $key ); ?>';
439
- data_log['method'] = 'wpadm_logs';
440
- }
441
  jQuery.ajax({
442
  type: "POST",
443
- url: url_ajax,
444
  data: data_log,
445
  success: function(response){
446
- if (response != '') {
447
- eval("var data=" + response);
448
- for(s in data.log) {
449
- if (jQuery.inArray(s , logs) == -1) {
450
- l = jQuery("#log-backup").html();
451
- l = "<div>" + data.log[s] + "</div>" + l;
452
- jQuery("#log-backup").html(l);
453
- }
454
  }
455
-
456
- if (data.processes) {
457
- console.log(data.processes);
458
- showProcessesData(data.processes);
459
- }
460
-
461
-
462
-
463
- if (process_flag == 1) {
464
- if (data.data) {
465
- if (method == 'restore') {
466
- if (type_restore == 'local') {
467
- showRestoreInfo(data.data.result, 'local', data.data.name)
468
- } else if (type_restore == 'dropbox') {
469
- showRestoreInfo(data.data.result, 'dropbox', data.data.name)
470
- }
471
- } else {
472
- showData(data.data);
473
- }
474
- processStop();
475
- jQuery('#stop-button').css('display', 'none');
476
- } else {
477
- setTimeout('processBar("' + method + '")', 10000);
478
- }
479
- }
480
-
481
- if (data.mod_secur) { // initial restore ajax
482
- initial_restore(method);
483
- }
484
- } else {
485
- setTimeout('processBar("' + method + '")', 10000);
486
  }
487
- },
488
- error: function(jqXHR, textStatus, errorThrown){
489
- setTimeout('processBar("' + method + '")', 10000);
490
- if (jqXHR.status != 0) {
491
- //processStop();
492
- //AjaxAlert(jqXHR, textStatus, errorThrown);
493
  }
494
  },
 
 
 
 
495
  });
496
  }
497
 
498
  function showTime(t)
499
  {
500
-
501
  if (process_flag == 1) {
502
  if ( (typeof t) == 'undefined') {
503
  t = 1;
504
  } else {
505
  t = t + 1;
506
  }
507
- time = t + " <?php _e('sec.','dropbox-backup'); ?>";
508
  jQuery("#time_backup").html(time);
509
  setTimeout(function() { showTime(t) }, 1000);
510
  }
@@ -524,110 +283,69 @@
524
  document.form_auth_backup_create.submit();
525
  }
526
  }
527
-
528
- function showRestoreInfo(result, type, name)
529
  {
530
- if (result == 'success') {
531
- jQuery('.title-logs').css('display', 'none');
532
- jQuery('.title-status').css({'display':'block', 'color':'green'});
533
- if (type == 'local') {
534
- str = '<?php _e('Local Backup (%s) was restored successfully','dropbox-backup'); ?>';
535
- str = str.replace('%s', name);
536
- jQuery('.title-status').html(str);
537
- } else {
538
- str = '<?php _e('Dropbox Backup (%s) was restored successfully','dropbox-backup'); ?>';
539
- str = str.replace('%s', name);
540
- jQuery('.title-status').html(str);
541
- }
542
  } else {
543
- jQuery('.title-logs').css('display', 'none');
544
- jQuery('.title-status').css({'display':'block', 'color':'red'});
545
- if (type == 'local') {
546
- str = "<?php _e('Local Backup (%s) wasn\'t restored','dropbox-backup'); ?>";
547
- str = str.replace("%s", name) ;
548
- jQuery('.title-status').html(str);
549
- } else {
550
- str = "<?php _e('Dropbox Backup (%s) wasn\'t restored','dropbox-backup'); ?>";
551
- str = str.replace('%s', name);
552
- jQuery('.title-status').html(str);
553
- }
554
  }
555
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
556
 
557
- var type_restore = '';
558
- function show_recovery_form(type, name)
559
- {
560
- var act = '';
561
- if (confirm("<?php _e('Are you sure you want to start the recovery process?','dropbox-backup')?>")) {
562
- if (type == 'local') {
563
- act = 'wpadm_local_restore';
564
- type_restore = 'local';
565
- } else {
566
- act = 'wpadm_restore_dropbox';
567
- type_restore = 'dropbox';
568
- }
569
- var data_backup = {
570
- 'action': act,
571
- 'nonce' : '<?php echo esc_attr( $nonce ); ?>',
572
- 'key' : '<?php echo esc_attr( $key ); ?>',
573
- 'name': name,
574
- };
575
- jQuery("#log-backup").html('');
576
- jQuery("#action-buttons").css('margin-top', '8px');
577
- <?php if(!$stars5) { ?>
578
- jQuery("#support-button").css('margin-top', '9px');
579
- <?php } else { ?>
580
- jQuery("#support-button").css('margin-top', '8px');
581
- <?php } ?>
582
- jQuery(".title-logs").css('display', 'block');
583
- jQuery(".title-status").css('display', 'none');
584
- jQuery("#logs-form").show("slow");
585
- jQuery("#action-buttons").css('margin-top', '8px');
586
- process_flag = 1
587
- jQuery.ajax({
588
- type: "POST",
589
- // url: ajaxurl,
590
- url: '<?php echo plugins_url('/modules/restore-class.php', dirname(__FILE__) ); ?>',
591
- data: data_backup,
592
- success: function(data){
593
- if (data.result == 'success') {
594
- process_flag = 0;
595
- jQuery('.title-logs').css('display', 'none');
596
- jQuery('.title-status').css({'display':'block', 'color':'green'});
597
- if (type == 'local') {
598
- str = '<?php _e('Local Backup (%s) was restored successfully','dropbox-backup'); ?>';
599
- str = str.replace('%s', name);
600
- jQuery('.title-status').html(str);
601
- } else {
602
- str = '<?php _e('Dropbox Backup (%s) was restored successfully','dropbox-backup'); ?>';
603
- str = str.replace('%s', name);
604
- jQuery('.title-status').html(str);
605
- }
606
- } else if (data.result == 'work'){
607
- processBar('restore');
608
- showTime();
609
  } else {
610
- process_flag = 0;
611
- jQuery('.title-logs').css('display', 'none');
612
- jQuery('.title-status').css({'display':'block', 'color':'red'});
613
- if (type == 'local') {
614
- str = "<?php _e('Local Backup (%s) wasn\'t restored','dropbox-backup'); ?>";
615
- str = str.replace("%s", name) ;
616
- jQuery('.title-status').html(str);
617
- } else {
618
- str = "<?php _e('Dropbox Backup (%s) wasn\'t restored','dropbox-backup'); ?>";
619
- str = str.replace('%s', name);
620
- jQuery('.title-status').html(str);
621
- }
622
  }
623
- },
624
- error: function(jqXHR, textStatus, errorThrown) {
625
- processStop();
626
- AjaxAlert(jqXHR, textStatus, errorThrown);
627
- },
628
- dataType: 'json'
629
- });
630
- }
 
 
 
 
 
 
 
 
 
 
 
 
631
 
632
  }
633
  function auth_form(t)
@@ -651,10 +369,11 @@
651
  }
652
  }
653
  if(send) {
 
654
  data['password'] = document.auth.password.value;
655
  data['username'] = document.auth.username.value;
656
  data['plugin'] = document.auth.plugin.value;
657
- backup = jQuery("#name_backup_restore").val();
658
  jQuery.ajax({
659
  url: form.attr('action'),
660
  data: data,
@@ -681,14 +400,11 @@
681
  success: function(res) {
682
 
683
  }
684
- });
685
  form.attr('action', data_res.url);
686
- document.auth.submit();
687
- //location.reload();
688
  }
689
- },
690
- error: function ( jqXHR, textStatus, errorThrown ) {
691
- AjaxAlert(jqXHR, textStatus, errorThrown);
692
  }
693
 
694
  });
@@ -705,6 +421,7 @@
705
  }
706
 
707
  var winParams = "left=0,top=0,height=600,width=1000,menubar=no,location=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no,directories=no"
 
708
  var dropboxBut, dropboxWin;
709
  function connectDropbox(button, href, oauth_token_secret, oauth_token, uid){
710
  if( button && href ){
@@ -712,16 +429,16 @@
712
  var form = dropboxBut.parents('form');
713
  var url = href;
714
 
715
- // if (jQuery.trim(jQuery('#app_key').val()) != '' || jQuery.trim(jQuery('#app_secret').val()) != '') {
716
- url += '&app_key='+jQuery('#app_key').val();
717
- url += '&app_secret='+jQuery('#app_secret').val();
718
- // }
719
 
720
  dropboxWin = window.open(url, "Dropbox", winParams);
721
  if( dropboxWin ){
722
  dropboxWin.focus();
723
  }else{
724
- alert('<?php _e('Please, permit the pop-up windows.','dropbox-backup'); ?>');
725
  }
726
  }else{
727
  var form = dropboxBut.parents('form');
@@ -732,7 +449,7 @@
732
  form.find('#oauth_token').val(oauth_token);
733
  form.find('#uid').val(uid);
734
  auth_param = false;
735
- form.find('#dropbox_uid_text').html('<?php _e('Dropbox successfully connected:','dropbox-backup')?> UID ' + uid);
736
  blick_form = false;
737
  dropboxBut.parents('.form_block_input').addClass('connected');
738
  }
@@ -761,30 +478,15 @@
761
  }
762
  function InludesSetting()
763
  {
764
- if (jQuery('#inludes-setting').css('display') == 'block') {
765
- jQuery('#inludes-setting').arcticmodal('close');
766
- } else {
767
- jQuery('#inludes-setting').arcticmodal({
768
- beforeOpen: function(data, el) {
769
- showLoadingImg(true);
770
- getIncludesData();
771
- jQuery('#inludes-setting').css('display','block');
772
- },
773
- afterClose: function(data, el) {
774
- jQuery('.show-includes').html("");
775
- jQuery('#inludes-setting').css('display','none');
776
- }
777
- });
778
- }
779
- /*disp = jQuery('#inludes-setting').css('display');
780
  if (disp == 'none') {
781
- showLoadingImg(true);
782
- getIncludesData();
783
- jQuery('#inludes-setting').show("slow");
784
  } else {
785
- jQuery('.show-includes').html("");
786
- jQuery('#inludes-setting').hide("slow");
787
- } */
788
  }
789
  var level_tree = {};
790
  function getIncludesData(type, dir_)
@@ -814,9 +516,6 @@
814
  }
815
  }
816
  level_tree[level_tree.length] = data_res.dir;
817
- },
818
- error: function(jqXHR, textStatus, errorThrown) {
819
- //AjaxAlert(jqXHR, textStatus, errorThrown);
820
  }
821
  });
822
  }
@@ -843,20 +542,14 @@
843
  for(i = 0; i < data.length; i++) {
844
  if (data[i].check) {
845
  check = 'checked="checked"' ;
846
- send_checked[send_checked.length] = urldecode( convert_from_cp1251( data[i].folder ) ) ;
847
  } else {
848
  check = '';
849
  }
850
- label_class = '';
851
- var onclick_ = 'onclick="loadInludes(\'/' + data[i].folder + '\', \'' + data[i].cache +'\', this, \'' + level_tree.length + '\')"';
852
- if (data[i].is_file) {
853
- label_class = 'class="is-file"';
854
- onclick_ = '';
855
- }
856
- html += '<div class="field-value-folder-or-file" id="inc_' + data[i].cache + '" data-value="' + data[i].cache + '">' +
857
- '<input type="checkbox" ' + check + ' class="checkbox-send" value="' + urldecode( convert_from_cp1251( data[i].folder ) ) + '" name="folder-include" id="send-to-' + data[i].cache + '" data-value-cache="' + data[i].cache + '" onclick="connectFolder(this)" />' +
858
- '<input type="checkbox" class="input-folder" value="/' + urldecode( convert_from_cp1251( data[i].dir ) ) + '" id="' + data[i].cache + '" ' + onclick_ + ' />' +
859
- '<label ' + label_class + ' for="' + data[i].cache + '">' + urldecode( convert_from_cp1251( data[i].dir ) ) + ' <span >(' + data[i].perm + ')</span>' + '</label>' +
860
  '<div id="img_load_' + data[i].cache + '" style="display:none; margin-left:10px;position:relative;">' +
861
  '<img style="position:absolute;bottom:0;" src="<?php echo plugins_url('/img/folder-loader.gif', dirname(__FILE__) ); ?>" alt="load" title="load" >' +
862
  '</div>'+
@@ -885,126 +578,45 @@
885
  dataType: 'json',
886
  success: function(data_res) {
887
  showLoadingImg(false);
888
- if (data_res == 1) {
889
- InludesSetting();
890
- }
891
- },
892
- error: function (jqXHR, textStatus, errorThrown) {
893
- //AjaxAlert(jqXHR, textStatus, errorThrown);
894
  }
895
  });
896
  }
897
  }
898
- function saveSetting(id)
899
  {
900
- if (jQuery('#' + id).length > 0) {
901
- if ( jQuery('#' + id).is('select') || jQuery('#' + id).is( ":text" ) || jQuery('#' + id).is( ":hidden" ) ) {
902
- is_value = jQuery('#' + id).val();
903
- } else {
904
- is_value = 0;
905
- if(document.getElementById(id).checked) {
906
- is_value = 1;
907
- }
908
- }
909
 
910
- data = {'action' : 'saveSetting'}
911
- data[id] = is_value;
912
- jQuery.ajax({
913
- url: ajaxurl,
914
- data: data,
915
- type: 'POST',
916
- dataType: 'json',
917
- success: function(data_res) {
918
- location.reload();
919
- },
920
- error: function( jqXHR, textStatus, errorThrown ){
921
- //AjaxAlert(jqXHR, textStatus, errorThrown);
922
- }
923
- });
924
- }
925
  }
926
- var app_key = app_secret = '';
927
  function showApp()
928
  {
929
  disp = jQuery('#dropbox-app-key').css('display');
930
  if (disp == 'none') {
931
  jQuery('#dropbox-app-key').show('slow');
932
- jQuery('#help-key-pass').show('slow');
933
  jQuery('#dropbox-app-secret').show('slow');
934
- jQuery('#app_secret').val(app_secret);
935
- jQuery('#app_key').val(app_key);
936
- jQuery('.stat-table-registr').css('margin-bottom', '25px');
937
  } else {
938
  jQuery('#dropbox-app-key').hide('slow');
939
- jQuery('#help-key-pass').hide('slow');
940
  jQuery('#dropbox-app-secret').hide('slow');
941
- app_key = jQuery('#app_key').val();
942
- app_secret = jQuery('#app_secret').val()
943
- jQuery('#app_secret').val('');
944
- jQuery('#app_key').val('');
945
- jQuery('.stat-table-registr').css('margin-bottom', '0px');
946
  }
947
  }
948
- function showFormAjax()
949
- {
950
- //form-ajax-ftp-email
951
- disp = jQuery('#form-ajax-ftp-email').css('display');
952
- if (disp == 'none') {
953
- jQuery('#form-ajax-ftp-email').show('slow');
954
- } else {
955
- jQuery('#form-ajax-ftp-email').hide('slow');
956
- }
957
- }
958
-
959
- function showEnableCron()
960
- {
961
- jQuery('#wp-cron-enable').arcticmodal({
962
- beforeOpen: function(data, el) {
963
- jQuery('#wp-cron-enable').css('display','block');
964
- },
965
- afterClose: function(data, el) {
966
- jQuery('#wp-cron-enable').css('display','none');
967
- }
968
- });
969
- }
970
- <?php
971
- $command_running = get_transient('running_command');
972
- if (isset($is_runnig) && $is_runnig && $command_running ) {
973
- if ( file_exists(WPAdm_Core::getTmpDir() . "/logs2" ) ) {
974
- @unlink(WPAdm_Core::getTmpDir() . "/logs2");
975
- }
976
- ?>
977
- jQuery(document).ready(function() {
978
- jQuery("#logs-form").show("slow");
979
- jQuery("#action-buttons").css('margin-top', '8px');
980
-
981
- <?php if(!$stars5) { ?>
982
- jQuery("#support-button").css('margin-top', '9px');
983
- <?php } else { ?>
984
- jQuery("#support-button").css('margin-top', '8px');
985
- <?php } ?>
986
- jQuery("#log-backup").html('');
987
- jQuery(".title-logs").css('display', 'block');
988
- jQuery(".title-status").css('display', 'none');
989
- type_backup = '<?php echo esc_attr( $command_running ); ?>';
990
-
991
- setTimeout(function() {
992
- disable_buttons() ;
993
- }, 10)
994
- process_flag = 1;
995
- jQuery('#process-box').show('slow');
996
- jQuery('#reviews-dropbox').hide('slow');
997
- jQuery('#stop-button').css('display', 'block');
998
- processBar(type_backup);
999
- showTime(1);
1000
- });
1001
- <?php }?>
1002
- jQuery(document).ready(function() {
1003
- jQuery('.wpadm-tooltip').tooltip();
1004
- });
1005
  </script>
1006
  <?php if (!empty($error)) {
1007
- echo '<div class="error" style="text-align: left; color: red; font-weight:bold;background:#ffcece;">
1008
  <p style="font-size: 16px;">
1009
  ' . $error . '
1010
  </p></div>';
@@ -1015,23 +627,14 @@
1015
  ' . $msg . '
1016
  </p></div>';
1017
  }?>
1018
-
1019
- <div id="wp-cron-enable" style="display: none;">
1020
- <div class="close-button"><a href="javascript:void(0)" onclick="jQuery('#wp-cron-enable').arcticmodal('close');"><img src="<?php echo plugins_url('/img/closebox.png', dirname(__FILE__));?>" alt=""></a></div>
1021
- <div class="image-enable">
1022
- <img src="<?php echo plugins_url('/img/how-to-enable-cron.png', dirname(__FILE__));?>" alt="">
1023
- </div>
1024
- </div>
1025
  <div id="is-dropbox-auth" style="display: none; width: 380px; text-align: center; background: #fff; border: 2px solid #dde4ff; border-radius: 5px;">
1026
  <div class="title-description" style="font-size: 20px; text-align: center;padding-top:45px; line-height: 30px;">
1027
- <?php _e('Your Dropbox account must be connected before backup to Dropbox.', 'dropbox-backup'); ?> <br />
1028
- <?php _e('To do this, please, click the button "Connect to Dropbox" in the settings', 'dropbox-backup'); ?> <br />
1029
- <?php _e('or add your own Dropbox credentials:', 'dropbox-backup'); ?> <br />
1030
- <strong><?php _e('"App key"','dropbox-backup'); ?></strong> & <strong><?php _e('"App secret"','dropbox-backup'); ?></strong> <br />
1031
- <?php _e('in the Setting Form','dropbox-backup'); ?>
1032
  </div>
1033
  <div class="button-description" style="padding:20px 0;padding-top:45px">
1034
- <input type="button" value="<?php _e('OK','dropbox-backup'); ?>" onclick="jQuery('#is-dropbox-auth').arcticmodal('close');" style="text-align: center; width: 100px;" class="button-wpadm">
1035
  </div>
1036
  </div>
1037
  <?php
@@ -1051,191 +654,110 @@
1051
  </script>
1052
  <div id="sent-error-report" style="display: none;" >
1053
  <div class="text-view">
1054
- <?php echo esc_html( $sent_response ) ;?>
1055
  </div>
1056
  <div class="button-sent-report">
1057
- <input type="button" class="button-wpadm" value="<?php _e('OK','dropbox-backup'); ?>" onclick="jQuery('#sent-error-report').arcticmodal('close')" />
1058
  </div>
1059
  </div>
1060
  <?php
1061
  }
1062
  ?>
1063
- <div id="ajax-alert" style="display: none;width: 800px; text-align: center; background: #fff; border: 2px solid #dde4ff; border-radius: 5px;">
1064
- <div id="ajax-message" style="font-size: 15px; margin-top: 10px; margin-bottom: 30px;"></div>
1065
- <div style="font-size: 15px; margin-bottom: 30px;"><?php _e('To solve this problem, we need to access the system logs of your hosting/server and/or from your backup, <br />that you tried to create or simply send to us your FTP access data.','dropbox-backup');?></div>
1066
-
1067
- <form action="<?php echo admin_url( 'admin-post.php?action=error_logs_check' )?>" method="post" style=" text-align: left; margin-left:110px;margin-bottom:20px;">
1068
- <div style="margin-top: 10px; font-size: 16px; font-weight: bold; margin-bottom: 10px;">
1069
- <input type="checkbox" onclick="showFormAjax();" style="margin: 0;" id="show-form-ajax" /> <label for="show-form-ajax"><?php _e('I want to provide your FTP access to resolve this issue quickly:','dropbox-backup');?></label>
1070
- </div>
1071
- <div id="form-ajax-ftp-email" style="display: none;">
1072
- <div class="form-help-send-error" >
1073
- <div style="margin-top: 3px;">
1074
- <div class="label-help" style="">
1075
- <label for="ftp-host"><?php _e('FTP Host','dropbox-backup'); ?></label>
1076
- </div>
1077
- <div style="float:left; ">
1078
- <input type="text" id="ftp-host" value="<?php echo esc_url( str_ireplace( array('http://', 'https://'), '', home_url() ) ) ;?>" name="ftp_host" >
1079
- </div>
1080
- </div>
1081
- <div class="clear"></div>
1082
- <div style="margin-top: 3px;">
1083
- <div class="label-help" >
1084
- <label for="ftp-user"><?php _e('FTP User','dropbox-backup'); ?></label>
1085
- </div>
1086
- <div style="float:left; ">
1087
- <input type="text" id="ftp-user" value="" name="ftp_user">
1088
- </div>
1089
- </div>
1090
- <div class="clear"></div>
1091
- <div style="margin-top: 3px;">
1092
- <div class="label-help" >
1093
- <label for="ftp-pass"><?php _e('FTP Password','dropbox-backup'); ?></label>
1094
- </div>
1095
- <div style="float:left; ">
1096
- <input type="text" id="ftp-pass" value="" name="ftp_pass">
1097
- </div>
1098
- </div>
1099
- <div class="clear"></div>
1100
-
1101
- </div>
1102
- <div class="form-help-mail-response">
1103
- <div style="padding: 20px; border:1px solid #fff; margin-top: 3px;">
1104
- <div class="label-help" >
1105
- <label for="email-resp"><?php _e('Response Email:','dropbox-backup'); ?></label>
1106
- </div>
1107
- <div style=" ">
1108
- <input type="text" id="email-resp" value="<?php echo esc_attr( get_option('admin_email') );?>" style="padding-left:3px;" name="mail_response">
1109
- </div>
1110
- </div>
1111
- </div>
1112
- </div>
1113
- <div class="clear"></div>
1114
- <div style="text-align: left; margin-left: 100px; margin-top: 10px;">
1115
- <input value="<?php echo esc_attr($time_log); ?>" type="hidden" name="time_pars">
1116
- <input value="" type="hidden" name="msg_ajax" id="msg_ajax">
1117
- </div>
1118
- <div class="ajax-button" style="margin-bottom: 10px;">
1119
- <input type="submit" class="button-wpadm" value="<?php _e('SEND TO SUPPORT and close this window','dropbox-backup'); ?>" />&nbsp;&nbsp;&nbsp;
1120
- <input type="button" class="button-wpadm" onclick="jQuery('#ajax-message').arcticmodal('close')" value="<?php _e('Close this window WITHOUT SENDING TO SUPPORT','dropbox-backup'); ?>" />
1121
- </div>
1122
- </form>
1123
- </div>
1124
  <div id="helper-keys" style="display: none;width: 400px; text-align: center; background: #fff; border: 2px solid #dde4ff; border-radius: 5px;">
1125
  <div class="title-description" style="font-size: 20px; text-align: center;padding-top:20px; line-height: 30px;">
1126
- <?php _e('Where can I find my app key and secret?','dropbox-backup'); ?>
1127
  </div>
1128
  <div class="button-description" style="padding:20px 10px;padding-top:20px; text-align: left;">
1129
- <?php _e('You can get an API app key and secret by creating an app on the','dropbox-backup'); ?>
1130
- <a href="https://www.dropbox.com/developers/apps/create?app_type_checked=api" target="_blank"><?php _e('app creation page','dropbox-backup'); ?></a>.
1131
- <?php _e('Once you have an app created, the app key and secret will be available on the app\'s page on the','dropbox-backup'); ?>
1132
- <a href="https://www.dropbox.com/developers/apps" target="_blank"><?php _e('App Console','dropbox-backup'); ?></a>
1133
- . <?php _e('Note that Drop-ins have app keys but no app secrets.','dropbox-backup'); ?>
1134
  </div>
1135
  <div class="button-description" style="padding:20px 0;padding-top:10px">
1136
- <input type="button" value="<?php _e('OK','dropbox-backup'); ?>" onclick="jQuery('#helper-keys').arcticmodal('close');" style="text-align: center; width: 100px;" class="button-wpadm">
1137
  </div>
1138
  </div>
1139
  <div class="block-content" style="margin-top:20px;">
1140
- <?php include 'advantage-plugin.php'; ?>
1141
- </div>
1142
- <div class="block-content" style="margin-top:2px;">
1143
  <div style="min-height : 215px; padding: 5px; padding-top: 10px;">
1144
  <div class="log-dropbox" style="background-image: url(<?php echo plugins_url('/img/dropbox.png', dirname(__FILE__));?>);">
1145
  </div>
1146
- <div style="float: bottom; font-size: 40px; font-weight: bold; text-shadow: 1px 2px 2px #666; margin-left: 189px; line-height: 42px; margin-top: -12px;">
1147
- <?php _e('Dropbox Full Backup','dropbox-backup');?>
1148
- <span style="font-size: 20px;"><?php _e('(files+database)','dropbox-backup');?></span>
1149
-
1150
- <span style="font-size: 11px;">
1151
- <?php echo (isset($plugin_data[0]['Version']) ? 'Version ' . esc_html( $plugin_data[0]['Version'] ) : '')?>
1152
- </span>
1153
-
1154
  </div>
1155
  <?php if ($show) {?>
1156
- <div id="container-user" class="cfTabsContainer" onclick="showRegistInfo(false)" style="width: 48%; padding-bottom: 0px; padding-top: 0px; float: left; margin-left: 20px;">
1157
- <div class="stat-wpadm-info-title" id="title-regisr" style="padding :9px 0px; margin-top:11px; line-height: 24px;">
1158
- <?php if (false) {?>
1159
- <?php _e('Free Sign Up','dropbox-backup'); ?> <br /><?php _e('to backup more than one website...','dropbox-backup'); ?>
1160
- <?php } else {
1161
- _e('Professional version<br /> "Dropbox backup and restore"<br /><span class="hover-title">get more...</span>','dropbox-backup');
1162
- } ?>
1163
  </div>
1164
  <div id="cf_activate" class="cfContentContainer" style="display: none;">
1165
- <?php if (false) {?>
1166
- <form method="post" id="dropbox_form" action="<?php echo admin_url( 'admin-post.php?action=wpadm_activate_plugin' )?>" >
1167
- <div class="stat-wpadm-registr-info" style="margin-bottom: 40px; margin-top: 17px;">
1168
- <table class="form-table stat-table-registr" style="">
1169
- <tbody>
1170
- <tr valign="top">
1171
- <th scope="row">
1172
- <label for="email"><?php _e('E-mail','dropbox-backup'); ?></label>
1173
- </th>
1174
- <td>
1175
- <input id="email" class="" type="text" name="email" value="">
1176
- </td>
1177
- </tr>
1178
- <tr valign="top">
1179
- <th scope="row">
1180
- <label for="password"><?php _e('Password','dropbox-backup'); ?></label>
1181
- </th>
1182
- <td>
1183
- <input id="password" class="" type="password" name="password" value="">
1184
- </td>
1185
- </tr>
1186
- <tr valign="top">
1187
- <th scope="row">
1188
- <label for="password-confirm"><?php _e('Password confirm','dropbox-backup'); ?></label>
1189
- </th>
1190
- <td>
1191
- <input id="password-confirm" class="" type="password" name="password-confirm" value="">
1192
- </td>
1193
- </tr>
1194
- <tr valign="top">
1195
- <th scope="row">
1196
- </th>
1197
- <td>
1198
- <input class="button-wpadm" type="submit" value="<?php _e('Register & Activate','dropbox-backup'); ?>" name="send">
1199
- </td>
1200
- </tr>
1201
- </tbody>
1202
- </table>
1203
- </div>
1204
- <div class="stat-wpadm-info" id="registr-info" style="margin-bottom: 2px; margin-top: 30px;">
1205
- <span style="font-weight:bold; font-size: 14px;"><?php _e('If you are NOT registered at','dropbox-backup'); ?> <a target="_blank" style="color: #fff" href="<?php echo esc_url( SERVER_URL_INDEX ); ?>"><?php _e('WPAdm','dropbox-backup'); ?></a>,</span> <?php _e('enter your email and password to use as your Account Data for authorization on WPAdm.','dropbox-backup'); ?> <br /><span style="font-weight: bold;font-size: 14px;"><?php _e('If you already have an account at','dropbox-backup'); ?> <a target="_blank" style="color: #fff" href="<?php echo esc_url( SERVER_URL_INDEX ); ?>"><?php _e('WPAdm','dropbox-backup'); ?></a></span> <?php _e('and you want to Sign-In, so please, enter your registered credential data (email and password twice).','dropbox-backup'); ?>
1206
- </div>
1207
- </form>
1208
- <?php } else {
1209
- $repeat_advantage = false;
1210
- include 'advantage-plugin.php';
1211
- }
1212
- ?>
1213
  </div>
1214
  <div class="clear"></div>
1215
  <div class="block-button-show" style="color: #fff;">
1216
- <div class="block-click" onclick="showRegistInfo(true, false);">
1217
- <span id="registr-show" style="color: #fff;"><?php _e('Show','dropbox-backup'); ?></span>
1218
  <div id="registr-choice-icon" class="dashicons dashicons-arrow-down" style=""></div>
1219
  </div>
1220
  </div>
1221
-
1222
  </div>
1223
  <?php } else { ?>
1224
  <div id="container-user" class="cfTabsContainer" style="width: 48%; padding-bottom: 0px; padding-top: 0px; float: left; margin-left: 20px;">
1225
- <div class="stat-wpadm-info-title" id="title-regisr" style="padding :10px 0px; margin-top:11px; line-height: 25px; text-align: left; margin-left: 10px;">
1226
- <?php _e('Sign In to backup more than one website...','dropbox-backup'); ?>
1227
  </div>
1228
  <div>
1229
- <form method="post" id="auth" name="auth" action="<?php echo esc_url( SERVER_URL_INDEX . "login-process" ) ; ?>">
1230
  <div>
1231
  <div id="message-form" style="color: red; float: left;margin: 10px;margin-top: 14px;"></div>
1232
  </div>
1233
  <div style="padding: 5px; clear: both;">
1234
  <div class="form-field">
1235
- <input class="input-small" type="text" id="username" value="<?php echo esc_attr( get_option(PREFIX_BACKUP_ . "email") );?>" readonly="readonly" required="required" name="username" placeholder="<?php _e('Email','dropbox-backup'); ?>" />
1236
  </div>
1237
  <div class="form-field">
1238
- <input class="input-small" type="password" required="required" name="password" placeholder="<?php _e('Password','dropbox-backup'); ?>" />
1239
  </div>
1240
  <div class="form-field">
1241
  <input class="button-wpadm" type="button" value="Sign In" onclick="auth_form(this);" />
@@ -1244,7 +766,7 @@
1244
  </div>
1245
  <div style="clear:both; padding: 5px; font-size: 11px; color: #fff;">
1246
  <div class="form-field" style="margin-bottom: 10px;">
1247
- <input type="checkbox" onclick="setReadOnly('username')" style="margin: 0px;"> <?php _e('set new mail','dropbox-backup'); ?>
1248
  </div>
1249
  </div>
1250
  <div style="clear:both;"></div>
@@ -1252,137 +774,68 @@
1252
  </div>
1253
  </div>
1254
  <?php } ?>
1255
- <div class="cfTabsContainer wpadm-setting-box" style="">
1256
  <div class="stat-wpadm-info-title" id="title-setting" style="padding :20px 0px; margin-top:11px; line-height: 50px;">
1257
- <?php _e('Settings','dropbox-backup'); ?>
1258
  </div>
1259
  <div id="setting_active" class="cfContentContainer" style="display: none;">
1260
- <form method="post" action="" autocomplete="off">
1261
- <div class="stat-wpadm-registr-info" style="width: 100%; margin-bottom: 9px;">
1262
- <div style="margin-bottom: 12px; margin-top: 20px; font-size: 15px; text-align: center;">
1263
- <input class="btn-orange" type="button" style="padding: 5px 10px; font-size: 15px; font-weight: 500" onclick="connectDropbox(this,'<?php echo admin_url( 'admin-post.php?action=dropboxConnect' )?>')" value="<?php _e('Connect to Dropbox','dropbox-backup'); ?>" name="submit">
1264
- <div class="desc-wpadm"><span id="dropbox_uid_text"><?php echo isset($dropbox_options['oauth_token']) && isset($dropbox_options['uid']) ? __('Dropbox successfully connected:','dropbox-backup') . " UID " . esc_html( $dropbox_options['uid'] ) : ''; ?></span></div>
1265
  </div>
1266
  <?php $show_fields = isset($dropbox_options['app_key']) && !empty($dropbox_options['app_key']) && isset($dropbox_options['app_secret']) && !empty($dropbox_options['app_secret']) && $dropbox_options['app_key'] != WPADM_APP_KEY && $dropbox_options['app_secret'] != WPADM_APP_SECRET ; ?>
1267
  <div class="setting-checkbox">
1268
- <input type="checkbox" onclick="showApp();" <?php echo $show_fields ? 'checked="checked"' : ''?> id="dbconnection-to-app" /><label for="dbconnection-to-app"><?php _e('Connect using my Dropbox App','dropbox-backup');?></label>
1269
  </div>
1270
 
1271
- <table class="form-table stat-table-registr" style="margin-top:2px; <?php echo $show_fields ? 'margin-bottom:25px;' : ''?>">
1272
  <tbody>
1273
  <tr valign="top" id="dropbox-app-key" style="display: <?php echo $show_fields ? 'table-row' : 'none'?>;">
1274
  <th scope="row">
1275
- <label for="app_key"><?php _e('App key','dropbox-backup'); ?>*</label>
1276
  </th>
1277
  <td>
1278
- <input id="app_key" class="" type="text" name="app_key" value="<?php echo isset($dropbox_options['app_key']) && $dropbox_options['app_key'] != WPADM_APP_KEY ? esc_attr( $dropbox_options['app_key'] ) : ''?>">
1279
  </td>
1280
  </tr>
1281
  <tr valign="top" id="dropbox-app-secret" style="display: <?php echo $show_fields ? 'table-row' : 'none'?>;">
1282
  <th scope="row">
1283
- <label for="app_secret"><?php _e('App secret','dropbox-backup'); ?>*</label>
1284
  </th>
1285
  <td>
1286
- <input id="app_secret" class="" type="text" name="app_secret" value="<?php echo isset($dropbox_options['app_secret']) && $dropbox_options['app_secret'] != WPADM_APP_SECRET ? esc_attr( $dropbox_options['app_secret'] ) : ''?>">
1287
  </td>
1288
  </tr>
1289
-
1290
- <tr valign="top" id="help-key-pass" style="display: <?php echo $show_fields ? 'table-row' : 'none'?>;">
1291
- <td colspan="2" align="center">
1292
- <a class="help-key-secret" href="javascript:getHelperDropbox();" ><?php _e('Where to get App key & App secret?','dropbox-backup'); ?></a><br />
 
 
 
 
 
 
 
 
1293
  </td>
1294
  </tr>
1295
  </tbody>
1296
  </table>
1297
 
1298
- <div class="setting-checkbox">
1299
- <span class="dashicons dashicons-editor-help wpadm-tooltip" title="<?php _e('The average waiting time before error message will be displayed. During this time the plugin will try to perform failed operation attempts. If this time was expired and operation still fails, the backup process will be interrupted and the message about problem will be shown on the screen.', 'dropbox-backup')?>"></span>
1300
- <label for="time_error" style="font-size: 13px;"><?php _e('Waiting time (minutes)', 'dropbox-backup'); ?></label>
1301
- <select name="time_error" id="time_error" onchange="saveSetting('time_error')">
1302
- <?php
1303
- for($i = 1; $i < 16; $i++) {
1304
- ?>
1305
- <option value="<?php echo $i?>" <?php echo isset($dropbox_options['time_error']) && $dropbox_options['time_error'] == $i ? 'selected="selected"' : (!isset($dropbox_options['time_error']) && $i == $default ) ? 'selected="selected"' : '' ?> ><?php echo $i?>:00</option>
1306
- <?php
1307
- }
1308
- ?>
1309
- </select>
1310
-
1311
- <span></span>
1312
- </div>
1313
  <?php if ( is_super_admin() ) { ?>
1314
  <div class="setting-checkbox">
1315
- <input type="checkbox" <?php echo isset($dropbox_options['is_admin']) && (int)$dropbox_options['is_admin'] == 1 ? 'checked="checked"' : ''; ?> name="is_admin" value="1" id="is_admin" onclick="saveSetting('is_admin')" />
1316
- <label for="is_admin" style="font-size: 13px;"><?php _e('Appear in menu for admins only','dropbox-backup'); ?></label>
1317
  </div>
1318
  <?php } ?>
1319
- <div class="setting-checkbox">
1320
- <input type="checkbox" <?php echo (isset($dropbox_options['is_optimization']) && (int)$dropbox_options['is_optimization'] == 1) || (!isset($dropbox_options['is_optimization'])) ? 'checked="checked"' : ''; ?> name="is_optimization" value="1" id="is_optimization" onclick="saveSetting('is_optimization')" />
1321
- <label for="is_optimization" style="font-size: 13px;"><?php _e('Database Optimization','dropbox-backup'); ?></label>
1322
- </div>
1323
- <div class="setting-checkbox">
1324
- <input type="checkbox" <?php echo (isset($dropbox_options['is_local_backup_delete']) && (int)$dropbox_options['is_local_backup_delete'] == 1) ? 'checked="checked"' : ''; ?> name="is_local_backup_delete" value="1" id="is_local_backup_delete" onclick="saveSetting('is_local_backup_delete')" />
1325
- <label for="is_local_backup_delete" style="font-size: 13px; width: 90%"><?php _e('Don\'t delete a local backup copy after uploading to dropbox','dropbox-backup'); ?></label>
1326
- </div>
1327
- <div class="setting-checkbox">
1328
- <input type="checkbox" <?php echo (isset($dropbox_options['is_repair']) && (int)$dropbox_options['is_repair'] == 1) ? 'checked="checked"' : ''; ?> name="is_repair" value="1" id="is_repair" onclick="saveSetting('is_repair')" />
1329
- <label for="is_repair" style="font-size: 13px;"><?php _e('Try database repair','dropbox-backup'); ?></label>
1330
- </div>
1331
- <div class="setting-checkbox">
1332
- <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')" />
1333
- <label for="is_show_admin_bar" style="font-size: 13px;"><?php _e('Show in a admin bar','dropbox-backup'); ?></label>
1334
- </div>
1335
-
1336
- <!-- type archive -->
1337
- <div class="setting-checkbox" style="margin-top:40px;">
1338
- <label for="" style="font-size: 13px; font-weight: 600;"><?php _e('Create backup using following backup methods:','dropbox-backup'); ?></label>
1339
- <span style="font-size: 11px; margin-top: -7px;">(<?php _e('ZIP method will be used as \'default\'')?>)</span>
1340
- </div>
1341
- <div class="setting-checkbox">
1342
- <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')" />
1343
- <label for="zip_archive" style="font-size: 13px;"><?php _e('Zip shell','dropbox-backup'); ?></label>
1344
- </div>
1345
- <div class="setting-checkbox">
1346
- <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')" />
1347
- <label for="targz_archive" style="font-size: 13px;"><?php _e('TarGz archive','dropbox-backup'); ?></label>
1348
- </div>
1349
- <!-- <div class="setting-checkbox">
1350
- <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')" />
1351
- <label for="tar_archive" style="font-size: 13px;"><?php _e('Tar archive','dropbox-backup'); ?></label>
1352
- </div> -->
1353
- <div class="clear" style="margin-top: 15px;"></div>
1354
- <!-- end type archive -->
1355
- <div class="setting-checkbox">
1356
- <?php _e('Include/Exclude','dropbox-backup'); ?>
1357
- <a onclick="InludesSetting();" href="javascript:void(0);" style="color: #fff"><?php _e('Folders and files','dropbox-backup'); ?></a>
1358
- </div>
1359
- <div style="border-bottom:1px solid #fff; margin:10px 0px;"></div>
1360
- <div class="setting-checkbox">
1361
- <label for="backup_folder" style="font-size: 13px;"><?php _e('Backup folder location','dropbox-backup'); ?>:</label>
1362
- <input type="text" style="width: 100%;" name="backup_folder" onkeypress="setDefaultFolderBackup(this)" value="<?php echo ( isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder']) ) ? esc_attr( $dropbox_options['backup_folder'] ) : esc_attr( DROPBOX_BACKUP_DIR_BACKUP ); ?>" id="backup_folder" onclick="" />
1363
- <span>
1364
- <input type="hidden" value="1" id="clear_backup_folder">
1365
- <a href="javascript:void(0);" onclick="setDefaultFolderBackup('<?php echo urlencode(DROPBOX_BACKUP_DIR_BACKUP);?>');" style="color:#fff;"><?php _e('Set to default backup folder','dropbox-backup');?></a>
1366
- </span>
1367
- <div class="clear"></div>
1368
- </div>
1369
- <div class="setting-checkbox" style="text-align: center;margin-top:15px;">
1370
- <input class="btn-orange" type="button" id="button-save-folder-backup" value="<?php _e('Save', 'dropbox-backup'); ?>" >
1371
- </div>
1372
- <script >
1373
- jQuery(document).ready(function() {
1374
- jQuery('#button-save-folder-backup').click(function() {
1375
- saveSetting('backup_folder');
1376
- })
1377
- })
1378
- </script>
1379
  </div>
1380
  </form>
1381
  </div>
1382
  <div class="clear"></div>
1383
  <div class="block-button-show" style="color: #fff;">
1384
  <div class="block-click" onclick="showSetting(true);">
1385
- <span id="setting-show" style="color: #fff;"><?php _e('Show','dropbox-backup'); ?></span>
1386
  <div id="setting-choice-icon" class="dashicons dashicons-arrow-down" style=""></div>
1387
  </div>
1388
  </div>
@@ -1392,152 +845,86 @@
1392
  <div style="clear: both;"></div>
1393
  <div class="block-content">
1394
  <div class="" style="margin-top:10px;">
1395
- <div id="logs-form" style="display: none; float:left; width: 60%;">
1396
- <div class="title-logs progress-box">
1397
- <span style="font-size:16px;"><?php _e('Please wait...','dropbox-backup'); ?>
1398
- <span id="time_backup">0 <?php _e('sec.','dropbox-backup'); ?></span>
1399
- </span>
1400
- </div>
1401
  <div class="title-status" style="font-size:16px; display: none;"></div>
1402
  <div style="border: 1px solid #ddd; text-align: left; background: #fff; padding: 2px;">
1403
  <div id="log-backup" style="overflow: auto; height: 60px; border: 5px solid #fff; "></div>
1404
  </div>
1405
  </div>
1406
- <?php if ($stars5) {?>
1407
- <div id="reviews-dropbox" class="pointer" onclick="window.open('https://wordpress.org/support/view/plugin-reviews/dropbox-backup?filter=5');">
1408
- <div class="title-reviews"><?php _e('++ Review ++','dropbox-backup'); ?></div>
1409
- <div class="desc-reviews"><?php _e('Your review is important for us','dropbox-backup'); ?></div>
1410
- <img src="<?php echo plugins_url('/img/stars-5.png', dirname(__FILE__));?>" alt=""></a>
1411
- </div>
1412
- <?php }?>
1413
- <div id="process-box" style="display: none;">
1414
- <div class="main-title"><?php _e('Backup processing status', 'dropbox-backup')?></div>
1415
- <?php if (isset($dropbox_options['is_repair']) && $dropbox_options['is_repair'] == 1) {?>
1416
- <div class="inline progress-box" id="repair-process" data-width="0%" style="display: block;">
1417
- <div class="progress-text">
1418
- <?php _e('Repairing of database tables', 'dropbox-backup')?>
1419
- <span class="stats-repair" style="display: none;">(<span id="count_repair">0</span> <?php _e('of', 'dropbox-backup'); ?> <span id="all_repair">0</span>)</span> <span class="procent-progress" id="procent_repair">0%</span>
1420
- </div>
1421
- <div class="progress-bar procent-repair" style="width: 0%;">
1422
- </div>
1423
- </div>
1424
- <?php } ?>
1425
- <?php if ( !isset($dropbox_options['is_optimization']) || ( isset($dropbox_options['is_optimization']) && $dropbox_options['is_optimization'] == 1 ) ) { ?>
1426
- <div class="inline progress-box" id="optimization-process" style="display: block;">
1427
- <div class="progress-text">
1428
- <?php _e('Optimization of database tables', 'dropbox-backup')?>
1429
- <span class="stats-optimization" style="display: none;">(<span id="count_optimization">0</span> <?php _e('of', 'dropbox-backup'); ?> <span id="all_optimization">0</span>)</span> <span class="procent-progress" id="procent_optimization">0%</span>
1430
- </div>
1431
- <div class="progress-bar procent-optimization" style="width: 0%;">
1432
- </div>
1433
- </div>
1434
- <?php } ?>
1435
-
1436
- <div class="inline progress-box" id="mysqldump-process" style="display: block;">
1437
- <div class="progress-text">
1438
- <?php _e('Creation of database dump', 'dropbox-backup')?>
1439
- <span class="stats-mysqldump" style="display: none;">(<span id="count_mysqldump">0</span> <?php _e('of', 'dropbox-backup'); ?> <span id="all_mysqldump">0</span>)</span> <span class="procent-progress" id="procent_mysqldump">0%</span>
1440
- </div>
1441
- <div class="progress-bar procent-mysqldump" style="width: 0%;">
1442
- </div>
1443
- </div>
1444
-
1445
-
1446
- <div class="inline progress-box" id="archiving-process" style="display: block;">
1447
- <div class="progress-text">
1448
- <?php _e('Archiving of files', 'dropbox-backup')?>
1449
- <span class="stats-archiving" style="display: none;">(<span id="count_archiving">0</span> <?php _e('of', 'dropbox-backup'); ?> <span id="all_archiving">0</span>)</span> <span class="procent-progress" id="procent_archiving">0%</span>
1450
- </div>
1451
- <div class="progress-bar procent-archiving" style="width: 0%;">
1452
- </div>
1453
- </div>
1454
 
1455
- <div class="inline progress-box" id="dropbox-process" style="display: none;">
1456
- <div class="progress-text">
1457
- <?php _e('Sending of backup to Dropbox', 'dropbox-backup')?>
1458
- <span class="stats-dropbox" style="display: none;">(<span id="count_dropbox">0</span> <?php _e('of', 'dropbox-backup'); ?> <span id="all_dropbox">0</span>)</span> <span class="procent-progress" id="procent_dropbox">0%</span>
1459
- </div>
1460
- <div class="progress-bar procent-dropbox" style="width: 0%;">
1461
- </div>
1462
- </div>
1463
- </div>
1464
  <div id="support-button" style="float: right; margin-top: 130px; margin-right: 20px;">
1465
- <button onclick="window.open('<?php echo esc_url( SERVER_URL_INDEX . 'support/?pl=dbp' ); ?>')" class="backup_button" style="padding: 5px 10px; margin-top: 10px; font-size: 15px;bottom: 0px;"><?php _e('Help','dropbox-backup'); ?></button> <br />
1466
  </div>
1467
  <div id="action-buttons" style="">
1468
  <div style="float: left;">
1469
- <button onclick="start_dropbox_backup();" text-button="<?php _e('Create Dropbox Backup','dropbox-backup');?>" class="backup_button disable-button" style=""><?php _e('Create Dropbox Backup','dropbox-backup'); ?></button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1470
  </div>
1471
  <div style="float: left; margin-top: 2px;">
1472
- <button onclick="start_local_backup()" text-button="<?php _e('Create Local Backup','dropbox-backup');?>" class="backup_button disable-button" style="padding: 5px 10px; margin-top: 10px; font-size: 15px;bottom: 0px;"><?php _e('Create Local Backup','dropbox-backup'); ?></button> <br />
1473
- </div>
1474
- <div id="stop-button" style="float: left; margin-top: 2px; margin-left:20px; display: none;">
1475
- <button onclick="stopBackup();" text-button="<?php _e('Stop Backup','dropbox-backup');?>" class="backup_button" style="padding: 5px 10px; margin-top: 10px; font-size: 15px;bottom: 0px;"><?php _e('Stop Backup','dropbox-backup'); ?></button> <br />
1476
  </div>
1477
  <!-- <div style="float: left; margin-top: 2px;margin-left: 20px;">
1478
- <button onclick="InludesSetting();" class="backup_button" style="padding: 5px 10px; margin-top: 10px; font-size: 15px;bottom: 0px;"><?php _e('Folders & files','dropbox-backup'); ?></button> <br />
1479
  </div> -->
1480
  <div style="clear: both;"></div>
1481
  </div>
1482
  </div>
1483
  <div style="clear: both; margin-bottom: 10px;"></div>
1484
  <div>
1485
- <form action="<?php echo esc_url( WPADM_URL_BASE );?>wpsite/recovery-backup" method="post" target="_blank" id="form_auth_backup" name="form_auth_backup">
1486
  </form>
1487
- <form action="<?php echo esc_url( WPADM_URL_BASE ) ;?>backup/tasks" method="post" target="_blank" id="form_auth_backup_create" name="form_auth_backup_create">
1488
- <input type="hidden" name="url_task_create" value="<?php echo esc_url( get_option('siteurl') );?>">
1489
  </form>
1490
  <form action="" method="post" id="form_auth_backup" name="form_auth_backup">
1491
  </form>
1492
  <form action="<?php echo admin_url( 'admin-post.php?action=wpadm_delete_backup' )?>" method="post" id="delete_backups" name="delete_backups">
1493
  <input type="hidden" name="backup-name" id="backup_name" value="" />
1494
  <input type="hidden" name="backup-type" id="backup_type" value="" />
1495
- <input type="hidden" name="nonce" id="id_nonce_delete" value="<?php echo esc_attr( $nonce );?>" />
1496
  </form>
1497
- <form action="<?php echo admin_url( 'admin-post.php?action=stop_backup' )?>" method="post" id="stop_backups" name="stop_backups">
1498
- <input type="hidden" name="type_backup" id="type_backup" value="" />
1499
- <input type="hidden" name="nonce" id="id_nonce" value="<?php echo esc_attr( $nonce ); ?>" />
1500
- </form>
1501
- <div id="inludes-setting" class="" style="display: none; width: 550px; position: relative; text-align: center; background: #e5e5e5; border: 2px solid #dde4ff; border-radius: 5px;">
1502
- <div>
1503
- <div class="title-description" style="font-size: 20px; text-align: center;padding-top:20px; line-height: 30px;">
1504
- <?php _e('Selected files and folders will be included to backup','dropbox-backup'); ?>
1505
- <div style="font-size: 14px;">
1506
- <?php _e('Database of website will be included automatically','dropbox-backup'); ?>
1507
- </div>
1508
- </div>
1509
- <div class="loading-img">
1510
- <img style="display: none; margin: 0 auto;" src="<?php echo plugins_url('/img/wpadmload.gif', dirname(__FILE__) ); ?>">
1511
- </div>
1512
- <div class="button-description">
1513
- <!-- <input type="radio" value="folder" id="inc-folder" checked="checked" name="includes-files-folder"><label for="inc-folder"><?php _e('View folders','dropbox-backup'); ?></label>
1514
- &nbsp;&nbsp;&nbsp; <input type="radio" value="files" id="inc-files" name="includes-files-folder"><label for="inc-files"><?php _e('View Folders & Files','dropbox-backup'); ?></label> -->
1515
- <div class="show-includes">
1516
 
1517
- </div>
1518
- </div>
1519
- <div class="clear"></div>
1520
- <div class="button-description" style="padding:20px 0; width: 100%;">
1521
- <input type="button" value="<?php _e('OK','dropbox-backup'); ?>" onclick="saveIncludes();" style="text-align: center; width: 100px;" class="button-wpadm">
1522
- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1523
- <input type="button" value="<?php _e('Cancel','dropbox-backup'); ?>" onclick="InludesSetting();" style="text-align: center; width: 100px;" class="button-wpadm">
1524
- </div>
1525
- </div>
1526
 
1527
- </div>
1528
 
1529
  <table class="table" style="margin-top: 5px; display: <?php echo isset($data['md5']) && ($n = count($data['data'])) && is_array($data['data'][0]) ? 'table' : 'none'?>;">
1530
  <thead>
1531
  <tr>
1532
  <th>#</th>
1533
- <th align="left"><?php _e('Create, Date/Time','dropbox-backup'); ?></th>
1534
- <th><?php _e('Name of Backup','dropbox-backup'); ?></th>
1535
- <th><?php _e('Archive Parts','dropbox-backup'); ?></th>
1536
- <th><?php _e('Status','dropbox-backup'); ?></th>
1537
- <th><?php _e('Type of Backup','dropbox-backup'); ?></th>
1538
- <th><?php _e('Size','dropbox-backup'); ?></th>
1539
  <?php if(is_admin() || is_super_admin()) {?>
1540
- <th><?php _e('Action','dropbox-backup'); ?></th>
1541
  <?php
1542
  }
1543
  ?>
@@ -1553,73 +940,39 @@
1553
  ?>
1554
  <tr>
1555
  <td class="number-backup"><?php echo ($i + 1);?></td>
1556
- <td onclick="shows('<?php echo esc_attr( md5( print_r($data['data'][$i], 1) ) );?>', this)" class="pointer" style="text-align: left; padding-left: 7px;"><?php echo esc_html( $data['data'][$i]['dt'] ); ?></td>
1557
- <td onclick="shows('<?php echo esc_attr( md5( print_r($data['data'][$i], 1) ) );?>', this)" class="pointer" <?php echo (isset($is_runnig) && $is_runnig && isset($name_running_backup) && $name_running_backup == $data['data'][$i]['name'] ? 'style="text-align:left;"' : '')?>>
1558
- <?php
1559
- $e = '';
1560
- if ( isset($is_runnig) && $is_runnig && isset($name_running_backup) && $name_running_backup == $data['data'][$i]['name']) {
1561
- $e = "<strong style=\"color:#ff8104; margin-left:6px;\">". __('Please wait, backup will be created...','dropbox-backup') . "</strong>";
1562
- } elseif ( $data['data'][$i]['size'] != 0 ) {
1563
- if (isset($data['data'][$i]['not_all_upload']) && $data['data'][$i]['not_all_upload'] === false) {
1564
- $e = "<strong style=\"color:red;\">" . __( 'Not all files were uploaded/created!', 'dropbox-backup') . "</strong>";
1565
- } else {
1566
- $e = $data['data'][$i]['name'];
1567
- }
1568
- } else {
1569
- $e = "<strong style=\"color:red;\">". __('Not available','dropbox-backup') . "</strong>&nbsp;&nbsp;(<a style=\"text-decoration:underline;\">".__('Why?','dropbox-backup')."</a>)";
1570
- }
1571
- echo ($e);
1572
- ?>
1573
  <script type="text/javascript">
1574
- backup_name = '<?php echo esc_attr( $data['data'][$i]['name'] ); ?>';
1575
  </script>
1576
  </td>
1577
- <td onclick="shows('<?php echo esc_attr( md5( print_r($data['data'][$i], 1) ) ) ;?>', this)" class="pointer"><?php echo isset($data['data'][$i]['count']) ? esc_html($data['data'][$i]['count']) : esc_html( $f ) ;?></td>
1578
- <td onclick="shows('<?php echo esc_attr( md5( print_r($data['data'][$i], 1) ) );?>', this)" class="pointer" style="padding: 0px;">
1579
- <?php if ( isset($is_runnig) && $is_runnig && isset($name_running_backup) && $name_running_backup == $data['data'][$i]['name'] ) { ?>
1580
- <img src="<?php echo plugin_dir_url(__FILE__) . "attention.png" ;?>" title="Attention" alt="Attention" style="float: left; width: 20px; height: 20px;margin-left: 21px;" />
1581
- <div style="margin-top :1px;float: left;"><?php _e('Backup in progress','dropbox-backup');?></div>
1582
- <?php
1583
- } elseif($data['data'][$i]['size'] != 0) { ?>
1584
- <?php
1585
- if (isset($data['data'][$i]['not_all_upload']) && $data['data'][$i]['not_all_upload'] === false) {
1586
- ?>
1587
- <img src="<?php echo plugin_dir_url(__FILE__) . "not-ok.png" ;?>" title="Fail" alt="Fail" style="float: left; width: 20px; height: 20px;margin-left: 61px;;" />
1588
- <div style="float: left;"><?php _e('Fail','dropbox-backup');?></div><div style="clear: both;">(<a style="text-decoration:underline;"><?php _e('Show uploaded/created files','dropbox-backup');?></a>)</div>
1589
- <?php
1590
- } else {
1591
- ?>
1592
- <img src="<?php echo plugin_dir_url(__FILE__) . "ok.png" ;?>" title="Successful" alt="Successful" style="float: left; width: 20px; height: 20px;margin-left: 21px;" />
1593
- <div style="margin-top :1px;float: left;"><?php _e('Successful','dropbox-backup');?></div>
1594
- <?php }
1595
- } else {
1596
  ?>
1597
- <img src="<?php echo plugin_dir_url(__FILE__) . "not-ok.png" ;?>" title="Fail" alt="Fail" style="float: left; width: 20px; height: 20px;margin-left: 21px;" />
1598
- <div style="margin-top :1px;float: left;"><?php _e('Fail','dropbox-backup');?>&nbsp;&nbsp;(<a style="text-decoration:underline;"><?php _e('Show Details','dropbox-backup');?></a>)</div>
1599
  <?php
1600
  }?>
1601
  </td>
1602
- <td onclick="shows('<?php echo esc_attr( md5( print_r($data['data'][$i], 1) ) );?>', this)" class="pointer"><?php echo esc_html( $data['data'][$i]['type'] );?> <?php _e('backup','dropbox-backup'); ?></td>
1603
- <td onclick="shows('<?php echo esc_attr( md5( print_r($data['data'][$i], 1) ) );?>', this)" class="pointer"><?php echo esc_html( $size ). __('Mb','dropbox-backup');?></td>
1604
  <td>
1605
  <?php if(is_admin() || is_super_admin()) {?>
1606
- <?php if ($data['data'][$i]['size'] > 0) {
1607
- if (isset($data['data'][$i]['not_all_upload']) && $data['data'][$i]['not_all_upload'] === false) {
1608
- ?>
1609
- <div style="width: 94px;float:left;">&nbsp;</div>
1610
- <?php
1611
- } else {
1612
- ?>
1613
- <a class="button-wpadm" href="javascript:void(0)" title="<?php _e('Restore','dropbox-backup'); ?>" onclick="show_recovery_form('<?php echo isset($data['data'][$i]['name']) && $data['data'][$i]['type'] != 'local' ? $data['data'][$i]['name'] : 'local' ?>', '<?php echo esc_attr( $data['data'][$i]['name'] );?>')" style="color: #fff;"><span class="pointer dashicons dashicons-backup" style="margin-top:3px;"></span><?php _e('Restore','dropbox-backup'); ?></a>&nbsp;
1614
- <?php }
1615
- } ?>
1616
- <a class="button-wpadm" href="javascript:void(0)" title="<?php _e('Delete','dropbox-backup'); ?>" onclick="delete_backup('<?php echo esc_attr( $data['data'][$i]['name'] ); ?>', '<?php echo esc_attr( $data['data'][$i]['type'] );?>')" style="color: #fff;"><span class="pointer dashicons dashicons-trash" style="margin-top:3px;"></span><?php _e('Delete','dropbox-backup'); ?></a>&nbsp;
1617
  <?php
1618
  }
1619
  ?>
1620
  </td>
1621
  </tr>
1622
- <tr id="<?php echo esc_attr( md5( print_r($data['data'][$i], 1) ) );?>" style="display:none; ">
1623
  <?php if ($data['data'][$i]['size'] != 0) {?>
1624
  <td colspan="2">
1625
  </td>
@@ -1634,12 +987,12 @@
1634
  <tr style="border: 0;">
1635
  <td style="border: 0;">
1636
  <?php if ($data['data'][$i]['type'] == 'local') {?>
1637
- <a href="<?php echo esc_url( content_url(DROPBOX_BACKUP_DIR_NAME) . "/{$data['data'][$i]['name']}/{$files[$j]}" ) ;?>">
1638
- <?php echo esc_html( $files[$j] ); ?>
1639
  </a>
1640
  <?php
1641
  } else {
1642
- echo esc_html( $files[$j] );
1643
  }
1644
  ?>
1645
  </td>
@@ -1656,13 +1009,6 @@
1656
  </td>
1657
  <td colspan="6"></td>
1658
  <?php
1659
- } elseif (isset($is_runnig) && $is_runnig && isset($name_running_backup) && $name_running_backup == $data['data'][$i]['name'] ) {
1660
- ?>
1661
- <td colspan="8">
1662
- <?php _e('Backup is created. If you are sure that the backup down(crashed), please ','dropbox-backup');?>
1663
- <a href="javascript:void(0)" onclick="window.open('<?php echo esc_url(SERVER_URL_INDEX . 'support/?pl=dbp') ?>')"><?php _e('contact us','dropbox-backup'); ?></a>.
1664
- </td>
1665
- <?php
1666
  } else { ?>
1667
  <td colspan="2">
1668
  </td>
@@ -1685,27 +1031,27 @@
1685
  echo str_replace("\n", "<br />", $error);
1686
  }
1687
  } else {
1688
- _e('Error log wasn\'t Found','dropbox-backup');
1689
  }?>
1690
  </div>
1691
 
1692
  <form action="<?php echo admin_url( 'admin-post.php?action=error_logs_check' )?>" method="post" style=" text-align: left;">
1693
  <div style="margin-top: 10px; font-size: 16px; font-weight: bold; margin-bottom: 10px;">
1694
- <?php _e('Please, provide your FTP access to resolve this issue quickly:','dropbox-backup');?>
1695
  </div>
1696
  <div class="form-help-send-error" >
1697
  <div style="margin-top: 3px;">
1698
  <div class="label-help" style="">
1699
- <label for="ftp-host"><?php _e('FTP Host','dropbox-backup'); ?></label>
1700
  </div>
1701
  <div style="float:left; ">
1702
- <input type="text" id="ftp-host" value="<?php echo esc_url( str_ireplace(array('http://', 'https://'), '', home_url()) ) ;?>" name="ftp_host" >
1703
  </div>
1704
  </div>
1705
  <div class="clear"></div>
1706
  <div style="margin-top: 3px;">
1707
  <div class="label-help" >
1708
- <label for="ftp-user"><?php _e('FTP User','dropbox-backup'); ?></label>
1709
  </div>
1710
  <div style="float:left; ">
1711
  <input type="text" id="ftp-user" value="" name="ftp_user">
@@ -1714,7 +1060,7 @@
1714
  <div class="clear"></div>
1715
  <div style="margin-top: 3px;">
1716
  <div class="label-help" >
1717
- <label for="ftp-pass"><?php _e('FTP Password','dropbox-backup'); ?></label>
1718
  </div>
1719
  <div style="float:left; ">
1720
  <input type="text" id="ftp-pass" value="" name="ftp_pass">
@@ -1726,17 +1072,17 @@
1726
  <div class="form-help-mail-response">
1727
  <div style="padding: 20px; border:1px solid #fff; margin-top: 3px;">
1728
  <div class="label-help" >
1729
- <label for="email-resp"><?php _e('Response Email:','dropbox-backup'); ?></label>
1730
  </div>
1731
  <div style=" ">
1732
- <input type="text" id="email-resp" value="<?php echo esc_attr( get_option('admin_email') );?>" style="padding-left:3px;" name="mail_response">
1733
  </div>
1734
  </div>
1735
  </div>
1736
  <div class="clear"></div>
1737
  <div style="text-align: left; margin-left: 100px; margin-top: 10px;">
1738
- <input value="<?php echo esc_attr( $time_log ); ?>" type="hidden" name="time_pars">
1739
- <input class="backup_button" style="font-size: 14px;font-weight: normal;padding: 3px;text-shadow: 0px;" type="submit" value="<?php _e('Send request to support','dropbox-backup'); ?>">
1740
  </div>
1741
  </form>
1742
 
 
1
  <div class="wrap">
2
  <script src="<?php echo plugin_dir_url(__FILE__) . 'js/jquery.arcticmodal-0.3.min.js'?>" type="text/javascript"></script>
3
  <link rel='stylesheet' href='<?php echo plugin_dir_url(__FILE__) . 'js/jquery.arcticmodal-0.3.css'?>' type='text/css' media='all' />
7
  }
8
  </style>
9
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  function blickForm(id, t)
11
  {
12
  if(t.checked == true) {
23
  display = jQuery('#cf_activate').css('display');
24
  if (display == 'none') {
25
  jQuery('#cf_activate').show('slow');
26
+ jQuery('#registr-show').html("<?php langWPADM::get('Hide'); ?>");
27
  jQuery('#title-regisr').css("padding" , "0px 0px");
28
  jQuery('#registr-choice-icon').removeClass("dashicons-arrow-down").addClass('dashicons-arrow-up');
 
29
  } else {
30
  if (show) {
31
  jQuery('#cf_activate').hide('slow');
32
+ jQuery('#registr-show').html("<?php langWPADM::get('Show'); ?>");
33
+ jQuery('#title-regisr').css("padding" , "20px 0px");
34
  jQuery('#registr-choice-icon').removeClass("dashicons-arrow-up").addClass('dashicons-arrow-down');
 
35
  }
36
  }
37
  }
 
 
 
 
 
38
  function showSetting(show)
39
  {
40
  display = jQuery('#setting_active').css('display');
41
  if (display == 'none') {
42
  jQuery('#setting_active').show(1000);
43
+ jQuery('#setting-show').html("<?php langWPADM::get('Hide'); ?>");
44
  jQuery('#title-setting').css("padding" , "0px 0px");
45
  jQuery('#setting-choice-icon').removeClass("dashicons-arrow-down").addClass('dashicons-arrow-up');
46
  } else {
47
  if (show) {
 
 
 
 
 
 
 
 
48
  jQuery('#setting_active').hide('slow');
49
+ jQuery('#setting-show').html("<?php langWPADM::get('Show'); ?>");
50
  jQuery('#title-setting').css("padding" , "20px 0px");
51
  jQuery('#setting-choice-icon').removeClass("dashicons-arrow-up").addClass('dashicons-arrow-down');
 
52
  }
53
  }
54
  }
55
+ process_flag = 0;
56
  function start_local_backup()
57
  {
58
  d = new Date();
59
  var data_backup = {
60
  'action': 'wpadm_local_backup',
 
61
  'time': Math.ceil( (d.getTime() + (-d.getTimezoneOffset() * 60000 ) ) / 1000 )
62
  };
63
  jQuery("#logs-form").show("slow");
64
  jQuery("#action-buttons").css('margin-top', '8px');
65
+ jQuery("#support-button").css('margin-top', '8px');
 
 
 
 
66
  jQuery("#log-backup").html('');
67
  jQuery(".title-logs").css('display', 'block');
68
  jQuery(".title-status").css('display', 'none');
 
 
 
 
69
  jQuery.ajax({
70
  type: "POST",
71
  url: ajaxurl,
72
  data: data_backup,
73
+ beforeSend: function(){
74
+ process_flag = 1
75
+ processBar();
76
+ showTime();
77
+
78
+ },
79
  success: function(data){
80
+ process_flag = 0;
81
+ if (data.result == 'success') {
82
+ jQuery('.title-logs').css('display', 'none');
83
+ jQuery('.title-status').css({'display':'block', 'color':'green'});
84
+ jQuery('.title-status').html('<?php langWPADM::get('Local Backup was created successfully'); ?>');
85
  } else {
86
+ jQuery('.title-logs').css('display', 'none');
87
+ jQuery('.title-status').css({'display':'block', 'color':'red'});
88
+ jQuery('.title-status').html("<?php langWPADM::get('Local Backup wasn\'t created'); ?>");
89
  }
90
+ showData(data);
91
+ jQuery('.table').css('display', 'table');
92
 
93
  },
94
+ error: function(){
95
  processStop();
96
+ alert('Error in Ajax request')
97
  },
98
  dataType: 'json'
99
  });
100
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
+ var auth_param = <?php echo isset($dropbox_options['app_key']) && isset($dropbox_options['app_secret']) && isset($dropbox_options['uid']) && $dropbox_options['uid'] != '' ? 'false' : 'true' ?>;
103
+ function start_dropbox_backup()
 
 
 
 
 
 
 
 
 
 
 
104
  {
105
  if (auth_param === false) {
106
  d = new Date();
107
  process_flag = 0;
 
108
  var data_backup = {
109
  'action': 'wpadm_dropbox_create',
 
110
  'time': Math.ceil( (d.getTime() + (-d.getTimezoneOffset() * 60000 ) ) / 1000 ),
111
  };
112
  jQuery("#logs-form").show("slow");
113
  jQuery("#action-buttons").css('margin-top', '8px');
114
+ jQuery("#support-button").css('margin-top', '8px');
 
 
 
 
 
115
  jQuery("#log-backup").html('');
116
  jQuery(".title-logs").css('display', 'block');
117
  jQuery(".title-status").css('display', 'none');
 
 
 
 
 
118
  jQuery.ajax({
119
  type: "POST",
120
  url: ajaxurl,
121
  data: data_backup,
122
+ beforeSend: function(){
123
+ process_flag = 1
124
+ processBar();
125
+ showTime();
126
+
127
+ },
128
  success: function(data){
129
+ process_flag = 0;
130
+ if (data.result == 'success') {
131
+ jQuery('.title-logs').css('display', 'none');
132
+ jQuery('.title-status').css({'display':'block', 'color':'green'});
133
+ jQuery('.title-status').html('<?php langWPADM::get('Dropbox Backup was created successfully'); ?>');
 
 
 
 
 
 
 
 
 
 
 
 
134
  } else {
135
+ jQuery('.title-logs').css('display', 'none');
136
+ jQuery('.title-status').css({'display':'block', 'color':'red'});
137
+ jQuery('.title-status').html("<?php langWPADM::get('Dropbox Backup wasn\'t created. '); ?>" + data.error);
138
  }
139
+ showData(data);
140
+ jQuery('.table').css('display', 'table');
141
 
142
  },
143
+ error: function(){
144
  processStop();
145
+ alert('Error in Ajax request')
146
  },
147
  dataType: 'json'
148
  });
163
  }
164
  function showData(data)
165
  {
166
+ size_backup = data.size / 1024 / 1024;
167
+ if (data.size != 0) {
168
+ var img_table =
169
+ '<img src="<?php echo plugin_dir_url(__FILE__) . "ok.png" ;?>" title="Successful" alt="Successful" style="float: left; width: 20px; height: 20px;" />' +
170
+ '<div style="margin-top :1px;float: left;"><?php echo langWPADM::get('Successful', false);?></div>';
171
+ name_backup = data.name;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  } else {
173
+ var img_table =
174
+ '<img src="<?php echo plugin_dir_url(__FILE__) . "not-ok.png" ;?>" title="fail" alt="fail" style="float: left; width: 20px; height: 20px;" />' +
175
+ '<div style="margin-top :1px;float: left;"><?php echo langWPADM::get('Fail', false);?>&nbsp;&nbsp;(<a style="text-decoration:underline;"><?php echo langWPADM::get('Show Details', false);?></a>)</div>';
176
+ name_backup = '<?php echo langWPADM::get('Not available', false);?>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  }
178
+ info = "";
179
+ for(i = 0; i < data.data.length; i++) {
180
+ e = data.data[i].split('/');
181
+ info += '<tr style="border: 0;">' +
182
+ '<td style="border: 0;padding: 0px;"><a href="<?php echo get_option('siteurl') . "/wpadm_backups/"?>' + data.name + '/' + e[e.length - 1] + '">' + e[e.length - 1] + '</td>' +
183
+ '</tr>' ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  }
 
185
 
186
+ co = jQuery('.number-backup').length + 1;
187
+ jQuery('.table > tbody:last').after(
188
+ '<tr>'+
189
+ '<td class="number-backup" onclick="shows(\'' + data.md5_data + '\', this)">' +
190
+ co +
191
+ '</td>' +
192
+ '<td class="pointer" onclick="shows(\'' + data.md5_data + '\', this)" style="text-align: left; padding-left: 7px;" >' +
193
+ data.time +
194
+ '</td>' +
195
+ '<td class="pointer" onclick="shows(\'' + data.md5_data + '\', this)">' +
196
+ name_backup +
197
+ '</td>' +
198
+ '<td class="pointer" onclick="shows(\'' + data.md5_data + '\',this)">' +
199
+ data.counts +
200
+ '</td>' +
201
+ '<td class="pointer" onclick="shows(\'' + data.md5_data + '\', this)">' +
202
+ img_table +
203
+ '</td>' +
204
+ '<td class="pointer" onclick="shows(\'' + data.md5_data + '\', this)">' +
205
+ data.type + ' <?php langWPADM::get('backup')?>' +
206
+ '</td>' +
207
+ '<td class="pointer" onclick="shows(\'' + data.md5_data + '\', this)">' +
208
+ size_backup.toFixed(2) + "<?php langWPADM::get('Mb')?>" +
209
+ '</td>' +
210
+ '<td>' +
211
+ '<a href="javascript:void(0)" class="button-wpadm" title="<?php langWPADM::get('Restore')?>" onclick="show_recovery_form(\'' + data.type + '\', \'' + data.name + '\')"><span class="pointer dashicons dashicons-backup"></span><?php langWPADM::get('Restore')?></a> &nbsp;' +
212
+ '<a href="javascript:void(0)" class="button-wpadm" title="<?php langWPADM::get('Delete')?>" onclick="delete_backup(\'' + data.name + '\', \'' + data.type + '\')"><span class="pointer dashicons dashicons-trash"></span><?php langWPADM::get('Delete')?></a> &nbsp;' +
213
+ '</td>' +
214
+ '</tr>'+
215
+ '<tr id="' + data.md5_data + '" style="display: none;">'+
216
+ '<td colspan="2">' +
217
+ '</td>' +
218
+ '<td align="center" style="padding: 0px; width: 350px;">' +
219
+ '<div style="overflow: auto; max-height: 150px;">' +
220
+ '<table border="0" align="center" style="width: 100%;" class="info-path">' +
221
+ info +
222
+ '</table>' +
223
+ '</div>' +
224
+ '</td>' +
225
+ '<td colspan="6"></td>' +
226
+ '</tr>')
227
  }
228
  var logs = [];
229
+ function processBar()
230
  {
 
 
 
231
  var data_log = {
232
  'action': 'wpadm_logs',
233
+ };
 
 
 
 
 
 
 
 
 
 
 
 
234
  jQuery.ajax({
235
  type: "POST",
236
+ url: ajaxurl,
237
  data: data_log,
238
  success: function(response){
239
+ eval("var data=" + response);
240
+ for(s in data.log) {
241
+ if (jQuery.inArray(s , logs) == -1) {
242
+ l = jQuery("#log-backup").html();
243
+ l = "<div>" + data.log[s] + "</div>" + l;
244
+ jQuery("#log-backup").html(l);
 
 
245
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  }
247
+ if (process_flag == 1) {
248
+ setTimeout('processBar()', 3000);
 
 
 
 
249
  }
250
  },
251
+ error: function(){
252
+ processStop();
253
+ alert('Error in Ajax request')
254
+ },
255
  });
256
  }
257
 
258
  function showTime(t)
259
  {
 
260
  if (process_flag == 1) {
261
  if ( (typeof t) == 'undefined') {
262
  t = 1;
263
  } else {
264
  t = t + 1;
265
  }
266
+ time = t + " <?php langWPADM::get('sec.'); ?>";
267
  jQuery("#time_backup").html(time);
268
  setTimeout(function() { showTime(t) }, 1000);
269
  }
283
  document.form_auth_backup_create.submit();
284
  }
285
  }
286
+ function show_recovery_form(type, name)
 
287
  {
288
+ var act = '';
289
+ if (type == 'local') {
290
+ act = 'wpadm_local_restore';
 
 
 
 
 
 
 
 
 
291
  } else {
292
+ act = 'wpadm_restore_dropbox';
 
 
 
 
 
 
 
 
 
 
293
  }
294
+ var data_backup = {
295
+ 'action': act,
296
+ 'name': name,
297
+ };
298
+ jQuery("#log-backup").html('');
299
+ jQuery("#action-buttons").css('margin-top', '8px');
300
+ jQuery("#support-button").css('margin-top', '8px');
301
+ jQuery(".title-logs").css('display', 'block');
302
+ jQuery(".title-status").css('display', 'none');
303
+ jQuery("#logs-form").show("slow");
304
+ jQuery("#action-buttons").css('margin-top', '8px');
305
+ jQuery.ajax({
306
+ type: "POST",
307
+ url: ajaxurl,
308
+ data: data_backup,
309
+ beforeSend: function(){
310
+ process_flag = 1
311
+ processBar();
312
+ showTime();
313
 
314
+ },
315
+ success: function(data){
316
+ process_flag = 0;
317
+ if (data.result == 'success') {
318
+ jQuery('.title-logs').css('display', 'none');
319
+ jQuery('.title-status').css({'display':'block', 'color':'green'});
320
+ if (type == 'local') {
321
+ str = '<?php langWPADM::get('Local Backup (%s) was restored successfully'); ?>';
322
+ str = str.replace('%s', name);
323
+ jQuery('.title-status').html(str);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  } else {
325
+ str = '<?php langWPADM::get('Dropbox Backup (%s) was restored successfully'); ?>';
326
+ str = str.replace('%s', name);
327
+ jQuery('.title-status').html(str);
 
 
 
 
 
 
 
 
 
328
  }
329
+ } else {
330
+ jQuery('.title-logs').css('display', 'none');
331
+ jQuery('.title-status').css({'display':'block', 'color':'red'});
332
+ if (type == 'local') {
333
+ str = "<?php langWPADM::get('Local Backup (%s) wasn\'t restored'); ?>";
334
+ str = str.replace("%s", name) ;
335
+ jQuery('.title-status').html(str);
336
+ } else {
337
+ str = "<?php langWPADM::get('Dropbox Backup (%s) wasn\'t restored'); ?>";
338
+ str = str.replace('%s', name);
339
+ jQuery('.title-status').html(str);
340
+ }
341
+ }
342
+ },
343
+ error: function(){
344
+ processStop();
345
+ alert('Error in Ajax request')
346
+ },
347
+ dataType: 'json'
348
+ });
349
 
350
  }
351
  function auth_form(t)
369
  }
370
  }
371
  if(send) {
372
+ form.find('#message-form').css('display', 'none');
373
  data['password'] = document.auth.password.value;
374
  data['username'] = document.auth.username.value;
375
  data['plugin'] = document.auth.plugin.value;
376
+ backup = jQuery("#name_backup_restore").val();
377
  jQuery.ajax({
378
  url: form.attr('action'),
379
  data: data,
400
  success: function(res) {
401
 
402
  }
403
+ });
404
  form.attr('action', data_res.url);
405
+ jQuery(form).submit();
406
+ location.reload();
407
  }
 
 
 
408
  }
409
 
410
  });
421
  }
422
 
423
  var winParams = "left=0,top=0,height=600,width=1000,menubar=no,location=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no,directories=no"
424
+ //https://www.dropbox.com/1/oauth/authorize?oauth_token=mIF2gsXq2jijPL95&oauth_callback=http%3A%2F%2Fdev.wpadm.com%2Fbackup%2FdropboxConnect%3Fauth_callback%3D1
425
  var dropboxBut, dropboxWin;
426
  function connectDropbox(button, href, oauth_token_secret, oauth_token, uid){
427
  if( button && href ){
429
  var form = dropboxBut.parents('form');
430
  var url = href;
431
 
432
+ // if (jQuery.trim(jQuery('#app_key').val()) != '' || jQuery.trim(jQuery('#app_secret').val()) != '') {
433
+ url += '&app_key='+jQuery('#app_key').val();
434
+ url += '&app_secret='+jQuery('#app_secret').val();
435
+ // }
436
 
437
  dropboxWin = window.open(url, "Dropbox", winParams);
438
  if( dropboxWin ){
439
  dropboxWin.focus();
440
  }else{
441
+ alert('<?php langWPADM::get('Please, permit the pop-up windows.'); ?>');
442
  }
443
  }else{
444
  var form = dropboxBut.parents('form');
449
  form.find('#oauth_token').val(oauth_token);
450
  form.find('#uid').val(uid);
451
  auth_param = false;
452
+ form.find('#dropbox_uid_text').html('<b>UID:</b>' + uid);
453
  blick_form = false;
454
  dropboxBut.parents('.form_block_input').addClass('connected');
455
  }
478
  }
479
  function InludesSetting()
480
  {
481
+ disp = jQuery('#inludes-setting').css('display');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
482
  if (disp == 'none') {
483
+ showLoadingImg(true);
484
+ getIncludesData();
485
+ jQuery('#inludes-setting').show("slow");
486
  } else {
487
+ jQuery('.show-includes').html("");
488
+ jQuery('#inludes-setting').hide("slow");
489
+ }
490
  }
491
  var level_tree = {};
492
  function getIncludesData(type, dir_)
516
  }
517
  }
518
  level_tree[level_tree.length] = data_res.dir;
 
 
 
519
  }
520
  });
521
  }
542
  for(i = 0; i < data.length; i++) {
543
  if (data[i].check) {
544
  check = 'checked="checked"' ;
545
+ send_checked[send_checked.length] = data[i].check_folder;
546
  } else {
547
  check = '';
548
  }
549
+ html += '<div id="inc_' + data[i].cache + '" data-value="' + data[i].cache + '">' +
550
+ '<input type="checkbox" ' + check + ' class="checkbox-send" value="' + data[i].folder + '" name="folder-include" id="send-to-' + data[i].cache + '" onclick="connectFolder(this)" />' +
551
+ '<input type="checkbox" class="input-folder" value="/' + data[i].dir + '" id="' + data[i].cache + '" onclick="loadInludes(\'/' + data[i].folder + '\', \'' + data[i].cache +'\', this, \'' + level_tree.length + '\')" />' +
552
+ '<label for="' + data[i].cache + '">' + data[i].dir + ' <span style="font-size:10px;">(' + data[i].perm + ')</span>' + '</label>' +
 
 
 
 
 
 
553
  '<div id="img_load_' + data[i].cache + '" style="display:none; margin-left:10px;position:relative;">' +
554
  '<img style="position:absolute;bottom:0;" src="<?php echo plugins_url('/img/folder-loader.gif', dirname(__FILE__) ); ?>" alt="load" title="load" >' +
555
  '</div>'+
578
  dataType: 'json',
579
  success: function(data_res) {
580
  showLoadingImg(false);
581
+
 
 
 
 
 
582
  }
583
  });
584
  }
585
  }
586
+ function saveSetting()
587
  {
588
+ is_admin = 0;
589
+ if(document.getElementById('is_admin').checked) {
590
+ is_admin = 1;
591
+ }
 
 
 
 
 
592
 
593
+ data = {'action' : 'saveSetting', 'is_admin' : is_admin}
594
+ jQuery.ajax({
595
+ url: ajaxurl,
596
+ data: data,
597
+ type: 'POST',
598
+ dataType: 'json',
599
+ success: function(data_res) {
600
+ },
601
+ error: function(){
602
+ alert('Save Error');
603
+ }
604
+ });
 
 
 
605
  }
 
606
  function showApp()
607
  {
608
  disp = jQuery('#dropbox-app-key').css('display');
609
  if (disp == 'none') {
610
  jQuery('#dropbox-app-key').show('slow');
 
611
  jQuery('#dropbox-app-secret').show('slow');
 
 
 
612
  } else {
613
  jQuery('#dropbox-app-key').hide('slow');
 
614
  jQuery('#dropbox-app-secret').hide('slow');
 
 
 
 
 
615
  }
616
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
617
  </script>
618
  <?php if (!empty($error)) {
619
+ echo '<div class="error" style="text-align: center; color: red; font-weight:bold;">
620
  <p style="font-size: 16px;">
621
  ' . $error . '
622
  </p></div>';
627
  ' . $msg . '
628
  </p></div>';
629
  }?>
 
 
 
 
 
 
 
630
  <div id="is-dropbox-auth" style="display: none; width: 380px; text-align: center; background: #fff; border: 2px solid #dde4ff; border-radius: 5px;">
631
  <div class="title-description" style="font-size: 20px; text-align: center;padding-top:45px; line-height: 30px;">
632
+ <?php langWPADM::get('Please, add your Dropbox credentials:'); ?><br />
633
+ <strong><?php langWPADM::get('"App key"'); ?></strong> & <strong><?php langWPADM::get('"App secret"'); ?></strong> <br />
634
+ <?php langWPADM::get('in the Setting Form'); ?>
 
 
635
  </div>
636
  <div class="button-description" style="padding:20px 0;padding-top:45px">
637
+ <input type="button" value="<?php langWPADM::get('OK'); ?>" onclick="jQuery('#is-dropbox-auth').arcticmodal('close');" style="text-align: center; width: 100px;" class="button-wpadm">
638
  </div>
639
  </div>
640
  <?php
654
  </script>
655
  <div id="sent-error-report" style="display: none;" >
656
  <div class="text-view">
657
+ <?php echo $sent_response ;?>
658
  </div>
659
  <div class="button-sent-report">
660
+ <input type="button" class="button-wpadm" value="<?php langWPADM::get('OK'); ?>" onclick="jQuery('#sent-error-report').arcticmodal('close')" />
661
  </div>
662
  </div>
663
  <?php
664
  }
665
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
666
  <div id="helper-keys" style="display: none;width: 400px; text-align: center; background: #fff; border: 2px solid #dde4ff; border-radius: 5px;">
667
  <div class="title-description" style="font-size: 20px; text-align: center;padding-top:20px; line-height: 30px;">
668
+ <?php langWPADM::get('Where can I find my app key and secret?'); ?>
669
  </div>
670
  <div class="button-description" style="padding:20px 10px;padding-top:20px; text-align: left;">
671
+ <?php langWPADM::get('You can get an API app key and secret by creating an app on the'); ?>
672
+ <a href="https://www.dropbox.com/developers/apps/create?app_type_checked=api" target="_blank"><?php langWPADM::get('app creation page'); ?></a>.
673
+ <?php langWPADM::get('Once you have an app created, the app key and secret will be available on the app\'s page on the'); ?>
674
+ <a href="https://www.dropbox.com/developers/apps" target="_blank"><?php langWPADM::get('App Console'); ?></a>
675
+ . <?php langWPADM::get('Note that Drop-ins have app keys but no app secrets.'); ?>
676
  </div>
677
  <div class="button-description" style="padding:20px 0;padding-top:10px">
678
+ <input type="button" value="<?php langWPADM::get('OK'); ?>" onclick="jQuery('#helper-keys').arcticmodal('close');" style="text-align: center; width: 100px;" class="button-wpadm">
679
  </div>
680
  </div>
681
  <div class="block-content" style="margin-top:20px;">
 
 
 
682
  <div style="min-height : 215px; padding: 5px; padding-top: 10px;">
683
  <div class="log-dropbox" style="background-image: url(<?php echo plugins_url('/img/dropbox.png', dirname(__FILE__));?>);">
684
  </div>
685
+ <div style="float: bottom; font-size: 40px; font-weight: bold; text-shadow: 1px 2px 2px #666; margin-left: 189px;">
686
+ <?php langWPADM::get('Dropbox Full Backup');?> <span style="font-size: 20px;"><?php langWPADM::get('(files+database)');?></span>
 
 
 
 
 
 
687
  </div>
688
  <?php if ($show) {?>
689
+ <div id="container-user" class="cfTabsContainer" style="width: 48%; padding-bottom: 0px; padding-top: 0px; float: left; margin-left: 20px;">
690
+ <div class="stat-wpadm-info-title" id="title-regisr" style="padding :20px 0px; margin-top:11px; line-height: 25px;">
691
+ <?php langWPADM::get('Free Sign Up'); ?> <br /><?php langWPADM::get('to backup more than one web page...'); ?>
 
 
 
 
692
  </div>
693
  <div id="cf_activate" class="cfContentContainer" style="display: none;">
694
+ <form method="post" id="dropbox_form" action="<?php echo admin_url( 'admin-post.php?action=wpadm_activate_plugin' )?>" >
695
+ <div class="stat-wpadm-registr-info" style="margin-bottom: 40px; margin-top: 17px;">
696
+ <table class="form-table stat-table-registr" style="">
697
+ <tbody>
698
+ <tr valign="top">
699
+ <th scope="row">
700
+ <label for="email"><?php langWPADM::get('E-mail'); ?></label>
701
+ </th>
702
+ <td>
703
+ <input id="email" class="" type="text" name="email" value="">
704
+ </td>
705
+ </tr>
706
+ <tr valign="top">
707
+ <th scope="row">
708
+ <label for="password"><?php langWPADM::get('Password'); ?></label>
709
+ </th>
710
+ <td>
711
+ <input id="password" class="" type="password" name="password" value="">
712
+ </td>
713
+ </tr>
714
+ <tr valign="top">
715
+ <th scope="row">
716
+ <label for="password-confirm"><?php langWPADM::get('Password confirm'); ?></label>
717
+ </th>
718
+ <td>
719
+ <input id="password-confirm" class="" type="password" name="password-confirm" value="">
720
+ </td>
721
+ </tr>
722
+ <tr valign="top">
723
+ <th scope="row">
724
+ </th>
725
+ <td>
726
+ <input class="button-wpadm" type="submit" value="<?php langWPADM::get('Register & Activate'); ?>" name="send">
727
+ </td>
728
+ </tr>
729
+ </tbody>
730
+ </table>
731
+ </div>
732
+ <div class="stat-wpadm-info" id="registr-info" style="margin-bottom: 2px; margin-top: 30px;">
733
+ <span style="font-weight:bold; font-size: 14px;"><?php langWPADM::get('If you are NOT registered at'); ?> <a target="_blank" style="color: #fff" href="<?php echo SERVER_URL_INDEX; ?>"><?php langWPADM::get('WPAdm'); ?></a>,</span> <?php langWPADM::get('enter your email and password to use as your Account Data for authorization on WPAdm.'); ?> <br /><span style="font-weight: bold;font-size: 14px;"><?php langWPADM::get('If you already have an account at'); ?> <a target="_blank" style="color: #fff" href="<?php echo SERVER_URL_INDEX; ?>"><?php langWPADM::get('WPAdm'); ?></a></span> <?php langWPADM::get('and you want to Sign-In, so please, enter your registered credential data (email and password twice).'); ?>
734
+ </div>
735
+ </form>
 
 
 
 
 
 
736
  </div>
737
  <div class="clear"></div>
738
  <div class="block-button-show" style="color: #fff;">
739
+ <div class="block-click" onclick="showRegistInfo(true);">
740
+ <span id="registr-show" style="color: #fff;"><?php langWPADM::get('Show'); ?></span>
741
  <div id="registr-choice-icon" class="dashicons dashicons-arrow-down" style=""></div>
742
  </div>
743
  </div>
 
744
  </div>
745
  <?php } else { ?>
746
  <div id="container-user" class="cfTabsContainer" style="width: 48%; padding-bottom: 0px; padding-top: 0px; float: left; margin-left: 20px;">
747
+ <div class="stat-wpadm-info-title" id="title-regisr" style="padding :10px 0px; margin-top:11px; line-height: 25px;">
748
+ <?php langWPADM::get('Sign In to backup more than one web page...'); ?>
749
  </div>
750
  <div>
751
+ <form method="post" id="auth" name="auth" action="<?php echo SERVER_URL_INDEX . "login-process" ; ?>" target="_blank">
752
  <div>
753
  <div id="message-form" style="color: red; float: left;margin: 10px;margin-top: 14px;"></div>
754
  </div>
755
  <div style="padding: 5px; clear: both;">
756
  <div class="form-field">
757
+ <input class="input-small" type="text" id="username" value="<?php echo get_option(PREFIX_BACKUP_ . "email");?>" readonly="readonly" required="required" name="username" placeholder="<?php langWPADM::get('Email'); ?>" />
758
  </div>
759
  <div class="form-field">
760
+ <input class="input-small" type="password" required="required" name="password" placeholder="<?php langWPADM::get('Password'); ?>" />
761
  </div>
762
  <div class="form-field">
763
  <input class="button-wpadm" type="button" value="Sign In" onclick="auth_form(this);" />
766
  </div>
767
  <div style="clear:both; padding: 5px; font-size: 11px; color: #fff;">
768
  <div class="form-field" style="margin-bottom: 10px;">
769
+ <input type="checkbox" onclick="setReadOnly('username')" style="margin: 0px;"> <?php langWPADM::get('set new mail'); ?>
770
  </div>
771
  </div>
772
  <div style="clear:both;"></div>
774
  </div>
775
  </div>
776
  <?php } ?>
777
+ <div class="cfTabsContainer" style="width: 28%; float: left; margin-left: 10px; padding-bottom: 0px; padding-top: 0px;">
778
  <div class="stat-wpadm-info-title" id="title-setting" style="padding :20px 0px; margin-top:11px; line-height: 50px;">
779
+ <?php langWPADM::get('Settings'); ?>
780
  </div>
781
  <div id="setting_active" class="cfContentContainer" style="display: none;">
782
+ <form method="post" action="" >
783
+ <div class="stat-wpadm-registr-info" style="width: auto; margin-bottom: 9px;">
784
+ <div style="margin-bottom: 12px; margin-top: 20px; font-size: 15px;">
785
+ <?php langWPADM::get('Please, add your Dropbox credentials:'); ?>
 
786
  </div>
787
  <?php $show_fields = isset($dropbox_options['app_key']) && !empty($dropbox_options['app_key']) && isset($dropbox_options['app_secret']) && !empty($dropbox_options['app_secret']) && $dropbox_options['app_key'] != WPADM_APP_KEY && $dropbox_options['app_secret'] != WPADM_APP_SECRET ; ?>
788
  <div class="setting-checkbox">
789
+ <input type="checkbox" onclick="showApp();" <?php echo $show_fields ? 'cheched="checked"' : ''?> /><label><?php langWPADM::get('Connection to your dropbox app');?></label>
790
  </div>
791
 
792
+ <table class="form-table stat-table-registr" style="margin-top:2px">
793
  <tbody>
794
  <tr valign="top" id="dropbox-app-key" style="display: <?php echo $show_fields ? 'table-row' : 'none'?>;">
795
  <th scope="row">
796
+ <label for="email"><?php langWPADM::get('App key'); ?>*</label>
797
  </th>
798
  <td>
799
+ <input id="app_key" class="" type="text" name="app_key" value="<?php echo isset($dropbox_options['app_key']) && $dropbox_options['app_key'] != WPADM_APP_KEY ? $dropbox_options['app_key'] : ''?>">
800
  </td>
801
  </tr>
802
  <tr valign="top" id="dropbox-app-secret" style="display: <?php echo $show_fields ? 'table-row' : 'none'?>;">
803
  <th scope="row">
804
+ <label for="password"><?php langWPADM::get('App secret'); ?>*</label>
805
  </th>
806
  <td>
807
+ <input id="app_secret" class="" type="text" name="app_secret" value="<?php echo isset($dropbox_options['app_secret']) && $dropbox_options['app_secret'] != WPADM_APP_SECRET ? $dropbox_options['app_secret'] : ''?>">
808
  </td>
809
  </tr>
810
+ <tr valign="top">
811
+ <th scope="row">
812
+ </th>
813
+ <td style="width: 292px;">
814
+ <input class="btn-orange" type="button" onclick="connectDropbox(this,'<?php echo admin_url( 'admin-post.php?action=dropboxConnect' )?>')" value="<?php langWPADM::get('Connect'); ?>" name="submit">
815
+ <span id="dropbox_uid_text"><?php echo isset($dropbox_options['oauth_token']) && isset($dropbox_options['uid']) ? "UID " . $dropbox_options['uid'] : ''; ?></span>
816
+ <div class="desc-wpadm"><?php langWPADM::get('Click to Connect your Dropbox'); ?></div>
817
+ </td>
818
+ </tr>
819
+ <tr valign="top">
820
+ <td colspan="2" align="right">
821
+ <a class="help-key-secret" href="javascript:getHelperDropbox();" ><?php langWPADM::get('Where to get App key & App secret?'); ?></a><br />
822
  </td>
823
  </tr>
824
  </tbody>
825
  </table>
826
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
827
  <?php if ( is_super_admin() ) { ?>
828
  <div class="setting-checkbox">
829
+ <input type="checkbox" <?php echo isset($dropbox_options['is_admin']) && $dropbox_options['is_admin'] == 1 ? 'checked="checked"' : ''; ?> name="is_admin" value="1" id="is_admin" onclick="saveSetting()" /><label for="is_admin" style="font-size: 13px;"><?php langWPADM::get('Appear in menu for admins only'); ?></label>
 
830
  </div>
831
  <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
832
  </div>
833
  </form>
834
  </div>
835
  <div class="clear"></div>
836
  <div class="block-button-show" style="color: #fff;">
837
  <div class="block-click" onclick="showSetting(true);">
838
+ <span id="setting-show" style="color: #fff;"><?php langWPADM::get('Show'); ?></span>
839
  <div id="setting-choice-icon" class="dashicons dashicons-arrow-down" style=""></div>
840
  </div>
841
  </div>
845
  <div style="clear: both;"></div>
846
  <div class="block-content">
847
  <div class="" style="margin-top:10px;">
848
+ <div id="logs-form" style="display: none; float:left; width: 70%;">
849
+ <div class="title-logs"><span style="font-size:16px;"><?php langWPADM::get('Please wait...'); ?> <span id="time_backup">0 <?php langWPADM::get('sec.'); ?></span><img style="float: right;" src="<?php echo plugins_url('/img/wpadmload.gif', dirname(__FILE__))?>" alt=""></span></div>
 
 
 
 
850
  <div class="title-status" style="font-size:16px; display: none;"></div>
851
  <div style="border: 1px solid #ddd; text-align: left; background: #fff; padding: 2px;">
852
  <div id="log-backup" style="overflow: auto; height: 60px; border: 5px solid #fff; "></div>
853
  </div>
854
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
855
 
856
+ <div id="reviews-dropbox" class="pointer" onclick="window.open('https://wordpress.org/support/view/plugin-reviews/dropbox-backup?filter=5');">
857
+ <div class="title-reviews"><?php langWPADM::get('++ Review ++'); ?></div>
858
+ <div class="desc-reviews"><?php langWPADM::get('Your review is important for us'); ?></div>
859
+ <img src="<?php echo plugins_url('/img/stars-5.png', dirname(__FILE__));?>" alt=""></a>
860
+ </div>
 
 
 
 
861
  <div id="support-button" style="float: right; margin-top: 130px; margin-right: 20px;">
862
+ <button onclick="window.open('<?php echo SERVER_URL_INDEX . 'support/?pl=dbp'?>')" class="backup_button" style="padding: 5px 10px; margin-top: 10px; font-size: 15px;bottom: 0px;"><?php langWPADM::get('Help'); ?></button> <br />
863
  </div>
864
  <div id="action-buttons" style="">
865
  <div style="float: left;">
866
+ <button onclick="start_dropbox_backup();" class="backup_button" style=""><?php langWPADM::get('Create Dropbox Backup'); ?></button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
867
  </div>
868
  <div style="float: left; margin-top: 2px;">
869
+ <button onclick="start_local_backup()" class="backup_button" style="padding: 5px 10px; margin-top: 10px; font-size: 15px;bottom: 0px;"><?php langWPADM::get('Create Local Backup'); ?></button> <br />
 
 
 
870
  </div>
871
  <!-- <div style="float: left; margin-top: 2px;margin-left: 20px;">
872
+ <button onclick="InludesSetting();" class="backup_button" style="padding: 5px 10px; margin-top: 10px; font-size: 15px;bottom: 0px;"><?php langWPADM::get('Folders & files'); ?></button> <br />
873
  </div> -->
874
  <div style="clear: both;"></div>
875
  </div>
876
  </div>
877
  <div style="clear: both; margin-bottom: 10px;"></div>
878
  <div>
879
+ <form action="<?php echo WPADM_URL_BASE;?>wpsite/recovery-backup" method="post" target="_blank" id="form_auth_backup" name="form_auth_backup">
880
  </form>
881
+ <form action="<?php echo WPADM_URL_BASE;?>backup/tasks" method="post" target="_blank" id="form_auth_backup_create" name="form_auth_backup_create">
882
+ <input type="hidden" name="url_task_create" value="<?php echo get_option('siteurl');?>">
883
  </form>
884
  <form action="" method="post" id="form_auth_backup" name="form_auth_backup">
885
  </form>
886
  <form action="<?php echo admin_url( 'admin-post.php?action=wpadm_delete_backup' )?>" method="post" id="delete_backups" name="delete_backups">
887
  <input type="hidden" name="backup-name" id="backup_name" value="" />
888
  <input type="hidden" name="backup-type" id="backup_type" value="" />
 
889
  </form>
890
+ <!-- <div id="inludes-setting" class="" style="display: none; position: relative; text-align: center; background: #f1ebeb; border: 2px solid #dde4ff; border-radius: 5px;">
891
+ <div>
892
+ <div class="title-description" style="font-size: 20px; text-align: center;padding-top:20px; line-height: 30px;">
893
+ <?php langWPADM::get('Include/Exclude of Files & Folders to backup'); ?>
894
+ <div style="font-size: 14px;">
895
+ <?php langWPADM::get('Database of web page will be included automatically'); ?>
896
+ </div>
897
+ </div>
898
+ <div class="loading-img">
899
+ <img style="display: none; margin: 0 auto;" src="<?php echo plugins_url('/img/wpadmload.gif', dirname(__FILE__) ); ?>">
900
+ </div>
901
+ <div class="button-description">
902
+ <!-- <input type="radio" value="folder" id="inc-folder" checked="checked"><label for="inc-folder">View folders</label> &nbsp;&nbsp;&nbsp; <input type="radio" value="files" id="inc-files" ><label for="inc-files">View Folders & Files</label>
903
+ <div class="show-includes">
 
 
 
 
 
904
 
905
+ </div>
906
+ </div>
907
+ <div class="clear"></div>
908
+ <div class="button-description" style="padding:20px 0; width: 100%;">
909
+ <input type="button" value="<?php langWPADM::get('OK'); ?>" onclick="saveIncludes();" style="text-align: center; width: 100px;" class="button-wpadm">
910
+ <input type="button" value="<?php langWPADM::get('Cancel'); ?>" onclick="InludesSetting();" style="text-align: center; width: 100px;" class="button-wpadm">
911
+ </div>
912
+ </div>
 
913
 
914
+ </div> -->
915
 
916
  <table class="table" style="margin-top: 5px; display: <?php echo isset($data['md5']) && ($n = count($data['data'])) && is_array($data['data'][0]) ? 'table' : 'none'?>;">
917
  <thead>
918
  <tr>
919
  <th>#</th>
920
+ <th align="left"><?php langWPADM::get('Create, Date/Time'); ?></th>
921
+ <th><?php langWPADM::get('Name of Backup'); ?></th>
922
+ <th><?php langWPADM::get('Archive Parts'); ?></th>
923
+ <th><?php langWPADM::get('Status'); ?></th>
924
+ <th><?php langWPADM::get('Type of Backup'); ?></th>
925
+ <th><?php langWPADM::get('Size'); ?></th>
926
  <?php if(is_admin() || is_super_admin()) {?>
927
+ <th><?php langWPADM::get('Action'); ?></th>
928
  <?php
929
  }
930
  ?>
940
  ?>
941
  <tr>
942
  <td class="number-backup"><?php echo ($i + 1);?></td>
943
+ <td onclick="shows('<?php echo md5( print_r($data['data'][$i], 1) );?>', this)" class="pointer" style="text-align: left; padding-left: 7px;"><?php echo $data['data'][$i]['dt'];?></td>
944
+ <td onclick="shows('<?php echo md5( print_r($data['data'][$i], 1) );?>', this)" class="pointer">
945
+ <?php echo ($data['data'][$i]['size'] != 0) ? $data['data'][$i]['name'] : "<strong style=\"color:red;\">". langWPADM::get('Not available', false) . "</strong>&nbsp;&nbsp;(<a style=\"text-decoration:underline;\">".langWPADM::get('Why?', false)."</a>)";?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
946
  <script type="text/javascript">
947
+ backup_name = '<?php echo $data['data'][$i]['name']?>';
948
  </script>
949
  </td>
950
+ <td onclick="shows('<?php echo md5( print_r($data['data'][$i], 1) );?>', this)" class="pointer"><?php echo isset($data['data'][$i]['count']) ? $data['data'][$i]['count'] : $f ;?></td>
951
+ <td onclick="shows('<?php echo md5( print_r($data['data'][$i], 1) );?>', this)" class="pointer" style="padding: 0px;">
952
+ <?php if ($data['data'][$i]['size'] != 0) { ?>
953
+ <img src="<?php echo plugin_dir_url(__FILE__) . "ok.png" ;?>" title="Successful" alt="Successful" style="float: left; width: 20px; height: 20px;" />
954
+ <div style="margin-top :1px;float: left;"><?php echo langWPADM::get('Successful', false);?></div>
955
+ <?php } else {
 
 
 
 
 
 
 
 
 
 
 
 
 
956
  ?>
957
+ <img src="<?php echo plugin_dir_url(__FILE__) . "not-ok.png" ;?>" title="Successful" alt="Successful" style="float: left; width: 20px; height: 20px;margin-left: 21px;" />
958
+ <div style="margin-top :1px;float: left;"><?php echo langWPADM::get('Fail', false);?>&nbsp;&nbsp;(<a style="text-decoration:underline;"><?php echo langWPADM::get('Show Details', false);?></a>)</div>
959
  <?php
960
  }?>
961
  </td>
962
+ <td onclick="shows('<?php echo md5( print_r($data['data'][$i], 1) );?>', this)" class="pointer"><?php echo $data['data'][$i]['type'];?> <?php langWPADM::get('backup'); ?></td>
963
+ <td onclick="shows('<?php echo md5( print_r($data['data'][$i], 1) );?>', this)" class="pointer"><?php echo $size . langWPADM::get('Mb', false);?></td>
964
  <td>
965
  <?php if(is_admin() || is_super_admin()) {?>
966
+ <?php if ($data['data'][$i]['size'] > 0) { ?>
967
+ <a class="button-wpadm" href="javascript:void(0)" title="<?php langWPADM::get('Restore'); ?>" onclick="show_recovery_form('<?php echo isset($data['data'][$i]['name']) && $data['data'][$i]['type'] != 'local' ? $data['data'][$i]['name'] : 'local' ?>', '<?php echo $data['data'][$i]['name']?>')" style="color: #fff;"><span class="pointer dashicons dashicons-backup" style="margin-top:3px;"></span><?php langWPADM::get('Restore'); ?></a>&nbsp;
968
+ <?php } ?>
969
+ <a class="button-wpadm" href="javascript:void(0)" title="<?php langWPADM::get('Delete'); ?>" onclick="delete_backup('<?php echo $data['data'][$i]['name']; ?>', '<?php echo $data['data'][$i]['type'];?>')" style="color: #fff;"><span class="pointer dashicons dashicons-trash" style="margin-top:3px;"></span><?php langWPADM::get('Delete'); ?></a>&nbsp;
 
 
 
 
 
 
 
970
  <?php
971
  }
972
  ?>
973
  </td>
974
  </tr>
975
+ <tr id="<?php echo md5( print_r($data['data'][$i], 1) );?>" style="display:none; ">
976
  <?php if ($data['data'][$i]['size'] != 0) {?>
977
  <td colspan="2">
978
  </td>
987
  <tr style="border: 0;">
988
  <td style="border: 0;">
989
  <?php if ($data['data'][$i]['type'] == 'local') {?>
990
+ <a href="<?php echo get_option('siteurl') . "/wpadm_backups/{$data['data'][$i]['name']}/{$files[$j]}"?>">
991
+ <?php echo $files[$j]; ?>
992
  </a>
993
  <?php
994
  } else {
995
+ echo $files[$j];
996
  }
997
  ?>
998
  </td>
1009
  </td>
1010
  <td colspan="6"></td>
1011
  <?php
 
 
 
 
 
 
 
1012
  } else { ?>
1013
  <td colspan="2">
1014
  </td>
1031
  echo str_replace("\n", "<br />", $error);
1032
  }
1033
  } else {
1034
+ langWPADM::get('Error log wasn\'t Found');
1035
  }?>
1036
  </div>
1037
 
1038
  <form action="<?php echo admin_url( 'admin-post.php?action=error_logs_check' )?>" method="post" style=" text-align: left;">
1039
  <div style="margin-top: 10px; font-size: 16px; font-weight: bold; margin-bottom: 10px;">
1040
+ <?php langWPADM::get('Please, provide your FTP access to resolve this issue quickly:');?>
1041
  </div>
1042
  <div class="form-help-send-error" >
1043
  <div style="margin-top: 3px;">
1044
  <div class="label-help" style="">
1045
+ <label for="ftp-host"><?php langWPADM::get('FTP Host'); ?></label>
1046
  </div>
1047
  <div style="float:left; ">
1048
+ <input type="text" id="ftp-host" value="<?php echo str_ireplace(array('http://', 'https://'), '', home_url()) ;?>" name="ftp_host" >
1049
  </div>
1050
  </div>
1051
  <div class="clear"></div>
1052
  <div style="margin-top: 3px;">
1053
  <div class="label-help" >
1054
+ <label for="ftp-user"><?php langWPADM::get('FTP User'); ?></label>
1055
  </div>
1056
  <div style="float:left; ">
1057
  <input type="text" id="ftp-user" value="" name="ftp_user">
1060
  <div class="clear"></div>
1061
  <div style="margin-top: 3px;">
1062
  <div class="label-help" >
1063
+ <label for="ftp-pass"><?php langWPADM::get('FTP Password'); ?></label>
1064
  </div>
1065
  <div style="float:left; ">
1066
  <input type="text" id="ftp-pass" value="" name="ftp_pass">
1072
  <div class="form-help-mail-response">
1073
  <div style="padding: 20px; border:1px solid #fff; margin-top: 3px;">
1074
  <div class="label-help" >
1075
+ <label for="email-resp"><?php langWPADM::get('Response Email:'); ?></label>
1076
  </div>
1077
  <div style=" ">
1078
+ <input type="text" id="email-resp" value="<?php echo get_option('admin_email');?>" style="padding-left:3px;" name="mail_response">
1079
  </div>
1080
  </div>
1081
  </div>
1082
  <div class="clear"></div>
1083
  <div style="text-align: left; margin-left: 100px; margin-top: 10px;">
1084
+ <input value="<?php echo $time_log; ?>" type="hidden" name="time_pars">
1085
+ <input class="backup_button" style="font-size: 14px;font-weight: normal;padding: 3px;text-shadow: 0px;" type="submit" value="<?php langWPADM::get('Send request to support'); ?>">
1086
  </div>
1087
  </form>
1088