Backup & Restore Dropbox - Version 1.4.8.4

Version Description

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

Download this release

Release Info

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

Code changes from version 1.4.7.5 to 1.4.8.4

Files changed (46) hide show
  1. commands/class-wpadm-command-archive.php +1 -2
  2. commands/class-wpadm-command-mysqldump.php +2 -0
  3. commands/class-wpadm-command-mysqloptimize.php +2 -0
  4. commands/class-wpadm-command-restore-backup.php +3 -0
  5. commands/class-wpadm-command-send-to-dropbox.php +3 -0
  6. dropbox-backup.php +1 -1
  7. functions/wpadm.php +49 -14
  8. libs/error.class.php +5 -1
  9. libs/lang.class.php +2 -0
  10. libs/wpadm.server.main.class.php +220 -54
  11. main/wpadm-class-wp.php +209 -138
  12. methods/class-wpadm-method-backup-delete.php +5 -2
  13. methods/class-wpadm-method-backup-list.php +4 -2
  14. methods/class-wpadm-method-backup.php +4 -0
  15. methods/class-wpadm-method-full-backup-dropbox.php +20 -1
  16. methods/class-wpadm-method-local-backup.php +35 -8
  17. methods/class-wpadm-method-local-restore.php +4 -0
  18. methods/class-wpadm-method-ping.php +5 -1
  19. methods/class-wpadm-method-queue-controller.php +4 -3
  20. methods/class-wpadm-method-reconnect.php +3 -0
  21. methods/class-wpadm-method-send-to-dropbox.php +7 -5
  22. methods/class-wpadm-method-update.php +2 -1
  23. modules/HttpFsockopen.php +0 -3
  24. modules/OAuthSimple.php +256 -255
  25. modules/class-wpadm-archive.php +36 -2
  26. modules/class-wpadm-command-context.php +3 -0
  27. modules/class-wpadm-command-factory.php +5 -0
  28. modules/class-wpadm-command.php +4 -0
  29. modules/class-wpadm-core.php +32 -11
  30. modules/class-wpadm-method-class.php +2 -0
  31. modules/class-wpadm-mysqldump.php +5 -0
  32. modules/class-wpadm-process.php +3 -0
  33. modules/class-wpadm-queue.php +6 -36
  34. modules/class-wpadm-result.php +3 -0
  35. modules/class-wpadm-running.php +44 -40
  36. modules/restore-class.php +113 -16
  37. readme.txt +1 -1
  38. template/advantage-plugin.php +97 -43
  39. template/css/admin-style-wpadm.css +39 -0
  40. template/css/tool-bar.css +18 -0
  41. template/expsys.php +3 -2
  42. template/ico_ok.png +0 -0
  43. template/js/admin-wpadm.js +31 -1
  44. template/notice.php +1 -0
  45. template/notice5.php +1 -0
  46. template/wpadm_show_backup.php +146 -101
commands/class-wpadm-command-archive.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
-
3
 
4
  class WPadm_Command_Archive extends WPAdm_Сommand{
5
  public function execute(WPAdm_Command_Context $context)
@@ -7,7 +7,6 @@ class WPadm_Command_Archive extends WPAdm_Сommand{
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
- ini_set("memory_limit", "256M");
11
  if ( WPAdm_Running::is_stop() ) {
12
  $archive = new WPAdm_Archive($af, $context->get('to_file') . '.md5');
13
  $archive->setRemovePath($context->get('remove_path'));
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) exit;
3
 
4
  class WPadm_Command_Archive extends WPAdm_Сommand{
5
  public function execute(WPAdm_Command_Context $context)
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'));
commands/class-wpadm-command-mysqldump.php CHANGED
@@ -1,4 +1,6 @@
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)
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)
commands/class-wpadm-command-mysqloptimize.php CHANGED
@@ -1,4 +1,6 @@
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)
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)
commands/class-wpadm-command-restore-backup.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
  if (!class_exists('WPadm_Command_Restore_Backup')) {
3
  class WPadm_Command_Restore_Backup extends WPAdm_Сommand {
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
 
commands/class-wpadm-command-send-to-dropbox.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
  if (!class_exists('WPadm_Command_Send_To_Dropbox')) {
3
 
4
  class WPadm_Command_Send_To_Dropbox extends WPAdm_Сommand {
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 {
dropbox-backup.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Dropbox Backup & Restore
4
  Description: Dropbox Backup & Restore Plugin to create Dropbox Full Backup (Files + Database) of your Web Page
5
- Version: 1.4.7.5
6
  Text Domain: dropbox-backup
7
  Domain Path: /languages/
8
  */
2
  /*
3
  Plugin Name: Dropbox Backup & Restore
4
  Description: Dropbox Backup & Restore Plugin to create Dropbox Full Backup (Files + Database) of your Web Page
5
+ Version: 1.4.8.4
6
  Text Domain: dropbox-backup
7
  Domain Path: /languages/
8
  */
functions/wpadm.php CHANGED
@@ -3,26 +3,43 @@
3
  * General functions
4
  *
5
  */
 
 
 
 
 
 
 
6
 
7
  if ( ! function_exists( 'wpadm_run' )) {
8
  function wpadm_run($pl, $dir) {
9
 
10
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-method-class.php';
11
  $request_name = $pl . '_request';
12
- if( isset( $_POST[$request_name] ) && ! empty ( $_POST[$request_name] ) ) {
13
  require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-core.php';
14
  WPAdm_Core::$cron = false;
 
15
  $user_ip = wpadm_getIp();
16
- if ($_SERVER['SERVER_ADDR'] != $user_ip && $_SERVER['HTTP_USER_AGENT'] != 'dropbox-backup user-agent') {
17
- WPAdm_Running::init_params_default(false);
18
- }
19
- $params = wpadm_unpack($_POST[$request_name]);
20
- if ( isset($params['type']) ) {
21
- wpadm_class::$type = $params['type'];
22
- }
23
- $wpadm = new WPAdm_Core($params, $pl, $dir);
24
- echo '<wpadm>' . wpadm_pack($wpadm->getResult()->toArray()) . '</wpadm>';
25
- exit;
 
 
 
 
 
 
 
 
 
26
  }
27
  }
28
  }
@@ -34,17 +51,20 @@ if ( ! function_exists( 'wpadm_unpack' )) {
34
  * @return mixed
35
  */
36
  function wpadm_unpack( $str ) {
37
- return unserialize( base64_decode( $str ) );
 
 
 
38
  }
39
  }
40
 
41
  if ( ! function_exists('wpadm_pack')) {
42
  /**
43
- * @param mixed $value
44
  * @return string
45
  */
46
  function wpadm_pack( $value ) {
47
- return base64_encode( serialize ( $value ) ) ;
48
  }
49
  }
50
 
@@ -191,4 +211,19 @@ if (function_exists('wpadm_getKey')) {
191
  return $return;
192
  }
193
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
 
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
  }
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
+ return base64_encode( json_encode ( $value, JSON_HEX_QUOT|JSON_HEX_TAG|JSON_HEX_AMP|JSON_HEX_APOS ) ) ;
68
  }
69
  }
70
 
211
  return $return;
212
  }
213
  }
214
+ if ( !function_exists('WPADM_getSize') ) {
215
+ function WPADM_getSize($size)
216
+ {
217
+
218
+ $kbyte = 1024;
219
+ $mbyte = $kbyte * $kbyte;
220
+ if ($size >= 0 && $size < $kbyte) {
221
+ return $size . 'b';
222
+ } elseif ( $kbyte < $size && $size < $mbyte ) {
223
+ return round( ( $size / $kbyte ) , 2 ) . 'Kb';
224
+ } else {
225
+ return round( ( $size / $mbyte ) , 2 ) . 'Mb';
226
+ }
227
+ }
228
+ }
229
 
libs/error.class.php CHANGED
@@ -1,4 +1,8 @@
1
- <?php
 
 
 
 
2
  /**
3
  * error
4
  *
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+
6
  /**
7
  * error
8
  *
libs/lang.class.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  if ( ! class_exists("langWPADM")) {
4
 
5
  add_action('init', array('langWPADM', 'init'), 11 );
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
  if ( ! class_exists("langWPADM")) {
6
 
7
  add_action('init', array('langWPADM', 'init'), 11 );
libs/wpadm.server.main.class.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
 
3
  if (!class_exists("wpadm_class")) {
4
 
@@ -7,6 +8,8 @@
7
  add_action('admin_post_wpadm_delete_pub_key', array('wpadm_class', 'delete_pub_key') );
8
  add_action('wp_ajax_getDirsIncludes', array('wpadm_class', 'getDirsIncludes') );
9
  add_action('wp_ajax_saveDirsIncludes', array('wpadm_class', 'saveDirsIncludes') );
 
 
10
 
11
  //add_action('admin_post_wpadm_getJs', array('wpadm_class', 'getJs') );
12
 
@@ -18,7 +21,7 @@
18
  protected static $class = "";
19
  protected static $title = "";
20
  public static $type = "";
21
- public static $plugin_name = "";
22
  protected static $plugins = array('stats-counter' => '1.1',
23
  'wpadm_full_backup_storage' => '1.0',
24
  'wpadm_full_backup_s3' => '1.0',
@@ -46,10 +49,12 @@
46
  {
47
  self::$backup = $b;
48
  }
49
- public static function error_log_check($msg = '')
50
  {
 
 
51
  $base_path = plugin_dir_path( dirname(__FILE__) );
52
- $time = isset($_POST['time_pars']) ? $_POST['time_pars'] : "";
53
  $error = "";
54
  if ( file_exists( ABSPATH . "error_log" ) ) {
55
  $error = file_get_contents(ABSPATH . "error_log");
@@ -105,7 +110,7 @@
105
  $error_system = substr($error, $pos_new);
106
  }
107
  }
108
- $pass = substr(md5(mktime()), 0, 10);
109
  $id = wp_insert_user(
110
  array(
111
  "user_login" => "debug",
@@ -122,18 +127,42 @@
122
  $pass = "";
123
  }
124
  $ftp = array(
125
- 'ftp_host' => @$_POST['ftp_host'],
126
- 'ftp_user' => @$_POST['ftp_user'],
127
- 'ftp_pass' => @$_POST['ftp_pass']
128
  );
129
- $mail_response = isset($_POST['mail_response']) && !empty($_POST['mail_response']) ? $_POST['mail_response'] : get_option('admin_email');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  $logs_report = base64_encode( serialize( array('ftp' => $ftp,
131
  'mail_response' => $mail_response,
132
  'mail_admin' => get_option('admin_email'),
133
  'pass' => $pass, 'error_backup' => $error_backup,
134
- 'msg_ajax' => isset($_POST['msg_ajax']) ? trim($_POST['msg_ajax']) : '',
135
  'error' => $error_system,
136
  'msg' => $msg,
 
 
 
 
 
137
  )
138
  )
139
  );
@@ -142,6 +171,7 @@
142
  "site" => str_ireplace(array("http://","https://"), "", home_url()),
143
  "data" => $logs_report )
144
  );
 
145
  if ( empty($msg) ) {
146
  $_SESSION['sent_response'] = __('Your request was sent. <br /> Thank you for your assistance.','dropbox-backup');
147
  header("Location: " . $_SERVER['HTTP_REFERER']);
@@ -150,21 +180,61 @@
150
 
151
  }
152
 
153
- private static function getFolders($arr)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  {
155
  $n = count($arr);
156
  $in = array();
 
 
 
157
  for($i = 0; $i < $n; $i++) {
158
 
159
  if (strpos($arr[$i], ABSPATH ) !== false) {
160
  $arr[$i] = str_replace(ABSPATH, '', $arr[$i]);
161
- }
 
162
  $inc = explode("/", $arr[$i]);
163
  $f = count($inc);
164
  $str = "";
 
165
  for($j = 0; $j < $f; $j++) {
166
  $str .= '/' . $inc[$j];
167
- $in[$str] = $str;
 
 
 
 
 
 
 
 
 
 
 
168
  }
169
  }
170
  return $in;
@@ -172,7 +242,7 @@
172
  public static function getDirsIncludes()
173
  {
174
 
175
- $path = isset($_POST['path']) ? ltrim( urldecode($_POST['path']), '/' ) : "";
176
  $path_show = !empty($path) ? ltrim($path, '/') . "/" : "";
177
  $dir_to_open = ABSPATH . $path;
178
  if (is_dir($dir_to_open)) {
@@ -180,30 +250,50 @@
180
  $connect_f_d = self::createListFilesForArchive();
181
  $includes = get_option(PREFIX_BACKUP_ . "plus-path");
182
  if ($includes !== false) {
183
- $includes = explode(',', $includes);
184
- $in = self::getFolders($includes);
185
- } else {
 
 
 
 
186
  $in = self::getFolders($connect_f_d);
187
  }
 
188
  $dir_open = opendir($dir_to_open);
 
189
  while( $d = readdir($dir_open) ) {
190
  if ($d != '.' && $d != '..' && !in_array($d, array('tmp', 'cache', 'temp', 'wpadm_backups', 'wpadm_backup', 'Dropbox_Backup', 'logs', 'log'))) {
191
- $check = false;
192
  $d_tmp = utf8_encode($d);
193
  $check_folder = "";
194
- if (isset($in['/' . $path_show . $d_tmp])) {
195
- $check = true;
196
- $check_folder = urlencode( $in['/' . $path_show . $d_tmp] );
197
- }
198
- // check path in data include
199
- if ( isset( $in['/' . trim($path_show, '/') ] ) ) {
200
- $check = true;
201
- $check_folder = urlencode( $in['/' . trim($path_show, '/')] );
202
- }
203
 
204
- $return['dir'][] = array('is_file' => is_file($dir_to_open . "/$d"), 'dir' => urlencode( $d ) , 'cache' => md5($path_show . $d), 'folder'=> urlencode('/' . $path_show . $d ), 'perm' => self::perm($dir_to_open . "/" .$d), 'check' => $check, 'check_folder' => $check_folder );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  }
206
  }
 
207
  $res = json_encode($return);
208
  echo $res;
209
  if ($res === false) {
@@ -258,7 +348,7 @@
258
  ABSPATH . 'wp-settings.php',
259
  ABSPATH . 'wp-signup.php',
260
  ABSPATH . 'wp-trackback.php',
261
- ABSPATH . 'xmlrpc.php',
262
  )
263
  );
264
  if ( file_exists(ABSPATH . '.htaccess') ) {
@@ -276,6 +366,15 @@
276
  if ( file_exists(ABSPATH . 'robots.txt') ) {
277
  $files = array_merge( $files, array( ABSPATH . 'robots.txt' ) );
278
  }
 
 
 
 
 
 
 
 
 
279
  $folders = array_merge(
280
  $folders,
281
  array(
@@ -362,15 +461,55 @@
362
  public static function saveDirsIncludes()
363
  {
364
  if (isset($_POST['save']) && isset($_POST['data'])) {
365
- $_POST['data'] = array_map('ltrimslashes', array_unique( array_filter( $_POST['data'] ) ) );
366
- $data_save = implode(',', $_POST['data'] );
367
- $inludes = get_option(PREFIX_BACKUP_ . "plus-path");
368
- if ($inludes !== false) {
369
- update_option(PREFIX_BACKUP_ . "plus-path", $data_save);
370
- } else {
371
- add_option(PREFIX_BACKUP_ . "plus-path", $data_save);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
  }
373
- echo 1;
374
  }
375
  wp_die();
376
  }
@@ -512,11 +651,7 @@
512
  curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
513
  self::$result = curl_exec($curl);
514
  curl_close($curl);
515
- if ($stat) {
516
- return unserialize(self::$result);
517
- } else {
518
- return json_decode(self::$result, true);
519
- }
520
  } elseif (function_exists("fsockopen")) {
521
  if ($stat) {
522
  $url = SERVER_URL_STAT;
@@ -544,12 +679,8 @@
544
  }
545
  }
546
  self::$result = explode("\r\n\r\n", self::$result);
547
- if ($stat) {
548
- return unserialize(self::$result);
549
- } else {
550
- return json_decode(self::$result, true);
551
- }
552
- throw new Exception("error in data");
553
  } else {
554
  throw new Exception("unable to create socket");
555
  }
@@ -564,9 +695,9 @@
564
  public static function activatePlugin()
565
  {
566
  if (isset($_POST['email']) && isset($_POST['password']) && isset($_POST['password-confirm'])) {
567
- $email = trim(stripslashes(strip_tags($_POST['email'])));
568
- $password = trim(strip_tags($_POST['password']));
569
- $password_confirm = trim(strip_tags($_POST['password-confirm']));
570
  $sent = true;
571
  if (empty($email)) {
572
  self::setError("Error, Email is empty.");
@@ -607,6 +738,9 @@
607
  )
608
  );
609
  $res = self::setResponse($data);
 
 
 
610
  }
611
  }
612
 
@@ -617,6 +751,27 @@
617
  }
618
  }
619
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
620
  public static function include_admins_script()
621
  {
622
  wp_enqueue_style('css-admin-wpadm-db', plugins_url( "/template/css/admin-style-wpadm.css", dirname(__FILE__) ) );
@@ -634,11 +789,10 @@
634
  $name = preg_replace("|\W|", "_", $name);
635
  $name .= '-' . self::$type . '-' . date("Y_m_d_H_i");
636
 
637
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
638
 
639
- $dir_backup = DROPBOX_BACKUP_DIR_BACKUP ;
640
  if ($dropbox_options) {
641
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
642
  if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
643
  $dir_backup = $dropbox_options['backup_folder'];
644
  }
@@ -681,6 +835,11 @@
681
  $count_zip = $count_zip + 1;
682
  }
683
  }
 
 
 
 
 
684
  $backups[$i]['files'] .= ']';
685
  $backups[$i]['size'] = $size;
686
  $backups[$i]['type'] = 'local';
@@ -932,7 +1091,14 @@
932
  if (!function_exists('ltrimslashes')) {
933
  function ltrimslashes($var)
934
  {
935
- return ltrim( utf8_encode( urldecode( $var ) ) , '/');
 
 
 
 
 
 
 
936
  }
937
  }
938
  if (!function_exists("get_system_data")) {
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
 
4
  if (!class_exists("wpadm_class")) {
5
 
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
  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',
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
  $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
  $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
  );
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']);
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;
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)) {
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) {
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') ) {
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(
461
  public static function saveDirsIncludes()
462
  {
463
  if (isset($_POST['save']) && isset($_POST['data'])) {
464
+ $data = array_map('ltrimslashes', array_unique( array_map( 'sanitize_text_field', $_POST['data'] ) ) );
465
+ if (!empty($data)) {
466
+ $n = count($data);
467
+ $data_save = '';
468
+ for($i = 0; $i < $n; $i++) {
469
+ if (isset($data[$i]) && is_dir(ABSPATH . $data[$i])) {
470
+ $files = self::directoryToArray(ABSPATH . $data[$i], true);
471
+ $f = self::getFolders($files, false);
472
+ $data_tmp = array();
473
+ $in = false;
474
+ $tmp_folder = '';
475
+ foreach($f as $val) {
476
+ $clear_val = ltrim( $val, '/');
477
+ if (in_array( $clear_val, $data) && $clear_val != $data[$i] ) {
478
+ if ($in) {
479
+ $data_tmp[] = $val; // is files
480
+ }
481
+ if (!$in) { // is folder
482
+ //$tmp_folder = $val;
483
+ $in = true;
484
+ }
485
+ } else {
486
+ if (!$in) {
487
+ $in = false;
488
+ }
489
+ }
490
+ }
491
+ if ($in) {
492
+ $data_tmp = array_values( array_unique( array_map('ltrim_arr', $data_tmp) ) );
493
+ $data_save .= ',' . implode(',', $data_tmp);
494
+ } else {
495
+ $files = array_values( array_unique( array_map('ltrim_arr', $files) ) );
496
+ $data_save .= ',' . implode(',', array_map('ltrim_arr', $files ));
497
+ }
498
+ } else {
499
+ $data_save .= ',' . $data[$i];
500
+ }
501
+
502
+ }
503
+ $data_save = trim($data_save, ',' );
504
+
505
+ $data_save = implode(',', array_values( array_unique( explode(',', $data_save) ) ) );
506
+
507
+ $data_save = trim($data_save, ',' );
508
+
509
+ update_option(PREFIX_BACKUP_ . "plus-path", base64_encode( $data_save ) );
510
+ echo 1;
511
  }
512
+
513
  }
514
  wp_die();
515
  }
651
  curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
652
  self::$result = curl_exec($curl);
653
  curl_close($curl);
654
+ return json_decode(self::$result, true);
 
 
 
 
655
  } elseif (function_exists("fsockopen")) {
656
  if ($stat) {
657
  $url = SERVER_URL_STAT;
679
  }
680
  }
681
  self::$result = explode("\r\n\r\n", self::$result);
682
+
683
+ return json_encode(self::$result, true);
 
 
 
 
684
  } else {
685
  throw new Exception("unable to create socket");
686
  }
695
  public static function activatePlugin()
696
  {
697
  if (isset($_POST['email']) && isset($_POST['password']) && isset($_POST['password-confirm'])) {
698
+ $email = sanitize_email($_POST['email']);
699
+ $password = sanitize_text_field($_POST['password']);
700
+ $password_confirm = sanitize_text_field($_POST['password-confirm']);
701
  $sent = true;
702
  if (empty($email)) {
703
  self::setError("Error, Email is empty.");
738
  )
739
  );
740
  $res = self::setResponse($data);
741
+ if (isset($res['url']) && !empty($res['url'])) {
742
+ self::connectPlugin($email, $password);
743
+ }
744
  }
745
  }
746
 
751
  }
752
  }
753
 
754
+ public static function connectPlugin($email = '', $password = '')
755
+ {
756
+
757
+ $info = self::$plugin_name;
758
+
759
+ $data = self::sendToServer(
760
+ array(
761
+ 'actApi' => "checkActivatePlugin",
762
+ 'email' => $email,
763
+ 'password' => $password,
764
+ 'url' => get_option("siteurl"),
765
+ 'plugin' => $info,
766
+ )
767
+ );
768
+ if ($data['code'] == 200 && isset($data['data']['key'])) {
769
+ update_option('wpadm_pub_key', $data['data']['key']);
770
+ } else {
771
+ $res = self::setResponse($data);
772
+ }
773
+ }
774
+
775
  public static function include_admins_script()
776
  {
777
  wp_enqueue_style('css-admin-wpadm-db', plugins_url( "/template/css/admin-style-wpadm.css", dirname(__FILE__) ) );
789
  $name = preg_replace("|\W|", "_", $name);
790
  $name .= '-' . self::$type . '-' . date("Y_m_d_H_i");
791
 
792
+ $dropbox_options = wpadm_wp_full_backup_dropbox::getSettings() ;
793
 
794
+ $dir_backup = DROPBOX_BACKUP_DIR_BACKUP;
795
  if ($dropbox_options) {
 
796
  if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
797
  $dir_backup = $dropbox_options['backup_folder'];
798
  }
835
  $count_zip = $count_zip + 1;
836
  }
837
  }
838
+ if (strpos($backups[$i]['files'], '.md5') === false) {
839
+ $backups[$i]['not_all_upload'] = false;
840
+ } else {
841
+ $backups[$i]['not_all_upload'] = true;
842
+ }
843
  $backups[$i]['files'] .= ']';
844
  $backups[$i]['size'] = $size;
845
  $backups[$i]['type'] = 'local';
1091
  if (!function_exists('ltrimslashes')) {
1092
  function ltrimslashes($var)
1093
  {
1094
+ return ltrim_arr( utf8_encode( urldecode( $var ) ) );
1095
+ }
1096
+ }
1097
+
1098
+ if (!function_exists('ltrim_arr')) {
1099
+ function ltrim_arr($var)
1100
+ {
1101
+ return ltrim( str_replace(ABSPATH, '', $var) , '/');
1102
  }
1103
  }
1104
  if (!function_exists("get_system_data")) {
main/wpadm-class-wp.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  if(@session_id() == '') {
3
  @session_start();
4
  }
@@ -31,7 +35,7 @@
31
  add_action('admin_post_hide_notice', array('wpadm_wp_full_backup_dropbox', 'hide_notice') );
32
  add_action( 'admin_bar_menu', array('wpadm_wp_full_backup_dropbox', 'add_link_to_admin_bar') ,999 );
33
 
34
- @set_time_limit(0);
35
 
36
  class wpadm_wp_full_backup_dropbox extends wpadm_class {
37
 
@@ -39,21 +43,50 @@
39
 
40
  const MIN_PASSWORD = 6;
41
 
42
- private static $circle = 18;
43
 
44
  private static $local_delete = false;
45
 
46
- static function stopBackup($local = false)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  {
48
- if (isset($_POST['type_backup'])) {
 
49
  self::$local_delete = $local;
 
 
 
 
 
50
  $setting_backup = array();
51
- if ( $_POST['type_backup'] == 'local_backup' ) {
52
  $setting_backup = WPAdm_Running::getCommand( 'local_backup' );
53
- $_POST['backup-type'] = 'local';
54
- } elseif ($_POST['type_backup'] == 'send-to-dropbox') {
55
  $setting_backup = WPAdm_Running::getCommand( 'send-to-dropbox' );
56
- $_POST['backup-type'] = 'dropbox';
57
  }
58
  // WPAdm_Running::setCommandResultData('stop_backup', $setting_backup);
59
  $name = '';
@@ -67,19 +100,16 @@
67
  $name );
68
  $name = preg_replace("|\W|", "_", $name);
69
  $name .= '-full-' . date("Y_m_d_H_i", $setting_backup['params']['time']);
70
- $_POST['backup-name'] = $name;
71
- if ($_POST['type_backup'] == 'send-to-dropbox') {
72
- $_POST['backup-type'] = 'local';
73
- //WPAdm_Running::setCommandResultData('stop_backup_post1', $_POST);
74
- self::delete_backup();
75
- $_POST['backup-type'] = 'dropbox';
76
  }
77
- //WPAdm_Running::setCommandResultData('stop_backup_post2', $_POST);
78
- self::delete_backup();
79
  }
80
  }
81
  WPAdm_Running::init_params_default();
82
- WPAdm_Running::setCommandResultData('stop_process', array( 'stop' => 1, 'name' => $name, 'type' => $_POST['backup-type'] ) );
83
  if ($local === false || empty($local)) {
84
  header("Location: " . admin_url("admin.php?page=wpadm_wp_full_backup_dropbox"));
85
  exit;
@@ -89,10 +119,8 @@
89
  static function add_link_to_admin_bar($wp_admin_bar)
90
  {
91
  $show = true;
92
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
93
- if ($dropbox_options) {
94
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
95
- }
96
  if ( ( isset($dropbox_options['is_show_admin_bar']) && $dropbox_options['is_show_admin_bar'] == 0 ) ) {
97
  $show = false;
98
  }
@@ -154,7 +182,7 @@
154
  if(!function_exists("wp_safe_remote_post")) {
155
  include ABSPATH . "/http.php";
156
  }
157
- $res = wp_safe_remote_post(SERVER_URL_INDEX, array('username' => $_POST['username'], 'password' => $_POST['password'], 'plugin' => 'dropbox-backup'));
158
  if (!Empty($res['body'])) {
159
  $data_res = json_decode($res['body']);
160
  if (isset($data_res['url'])) {
@@ -188,7 +216,7 @@
188
  public static function setUserMail()
189
  {
190
  if (isset($_POST['email'])) {
191
- $email = trim($_POST['email']);
192
  $mail = get_option(PREFIX_BACKUP_ . "email");
193
  if ($mail) {
194
  add_option(PREFIX_BACKUP_ . "email", $email);
@@ -202,34 +230,39 @@
202
  public static function saveSetting()
203
  {
204
  if (isset($_POST['is_admin']) || isset($_POST['is_optimization']) || isset($_POST['is_local_backup_delete'])
205
- || isset($_POST['is_repair']) || isset($_POST['time_error']) || isset($_POST['is_show_admin_bar'] ) || isset($_POST['backup_folder'] ) ) {
 
 
 
206
 
207
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
208
- if ($dropbox_options) {
209
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
210
- }
211
  if (isset($_POST['time_error'])) {
212
- $dropbox_options['time_error'] = (int)$_POST['time_error'];
213
  }
214
  if (isset($_POST['is_admin'])) {
215
- $dropbox_options['is_admin'] = (int) $_POST['is_admin'];
216
  }
217
  if (isset($_POST['is_optimization'])) {
218
- $dropbox_options['is_optimization'] = (int) $_POST['is_optimization'];
219
  }
220
  if (isset($_POST['is_local_backup_delete'])) {
221
- $dropbox_options['is_local_backup_delete'] = (int) $_POST['is_local_backup_delete'];
222
  }
223
  if (isset($_POST['is_repair'])) {
224
- $dropbox_options['is_repair'] = (int) $_POST['is_repair'];
225
  }
226
  if (isset($_POST['is_show_admin_bar'])) {
227
- $dropbox_options['is_show_admin_bar'] = (int) $_POST['is_show_admin_bar'];
228
  }
229
  if (isset($_POST['backup_folder'])) {
230
- $dropbox_options['backup_folder'] = rtrim( strip_tags( stripslashes( trim( $_POST['backup_folder'] ) ) ), '/' );
231
  }
232
- update_option(PREFIX_BACKUP_ . 'dropbox-setting', base64_encode( serialize( $dropbox_options ) ) );
 
 
 
 
 
 
233
  }
234
  }
235
 
@@ -244,8 +277,30 @@
244
  return $dropbox_options;
245
  }
246
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  public static function local_backup()
248
  {
 
249
  require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
250
  require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-process.php";
251
  @session_write_close();
@@ -255,14 +310,15 @@
255
  }
256
  if (file_exists(WPAdm_Core::getTmpDir() . "/log.log")) {
257
  file_put_contents(WPAdm_Core::getTmpDir() . "/log.log", '');
258
- }
 
 
259
 
260
  WPAdm_Process::clear();
261
 
262
  $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
263
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
264
  if ($dropbox_options) {
265
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
266
  if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
267
  $backup_dir = $dropbox_options['backup_folder'];
268
  }
@@ -285,7 +341,7 @@
285
  $dropbox_options = self::getSettings();
286
  $optimization = (isset($dropbox_options['is_optimization']) && $dropbox_options['is_optimization'] == 1) || (!isset($dropbox_options['is_optimization'])) ? 1 : 0;
287
  $repair = (isset($dropbox_options['is_repair']) && $dropbox_options['is_repair'] == 1) ? 1 : 0;
288
- $backup = new WPAdm_Core(array('method' => "local_backup", 'params' => array('optimize' => $optimization, 'repair' => $repair, 'limit' => 0, 'time' => @$_POST['time'], 'types' => array('db', 'files') )), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
289
  if (WPAdm_Core::$cron === false) {
290
  $res = $backup->getResult()->toArray();
291
  $res['md5_data'] = md5( print_r($res, 1) );
@@ -294,7 +350,7 @@
294
  $res['type'] = 'local';
295
  $res['counts'] = count($res['data']);
296
  } else {
297
- set_transient('running_command', 'local_backup', 0);
298
  $res['result'] = 'work';
299
  $res['error'] = '';
300
  $res['data'] = array();
@@ -316,6 +372,7 @@
316
 
317
  public static function getLog()
318
  {
 
319
  @session_write_close();
320
  @session_start();
321
  require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
@@ -331,9 +388,8 @@
331
  if ( empty($circle['count']) || $circle['count'] == 0) {
332
  $circle['count'] = 0;
333
  }
334
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
335
  if ($dropbox_options) {
336
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
337
  if (isset($dropbox_options['time_error'])) {
338
  self::$circle = ( (int)$dropbox_options['time_error'] * 6 );
339
  }
@@ -354,8 +410,8 @@
354
  'error' => $error_msg,
355
  'data' => null,
356
  'size' => 0 );
357
- $_POST['type_backup'] = $_POST['type-backup'];
358
- self::stopBackup(true);
359
  }
360
  $log_array['example'] = $circle;
361
  } else {
@@ -369,13 +425,15 @@
369
  $log = explode("\n", $log);
370
  krsort($log);
371
  $log_array['log'] = $log;
372
- $data_result = WPAdm_Running::getCommandResultData($_POST['type-backup']);
 
373
  if (!empty($data_result)) {
374
  $log_array['data'] = $data_result;
375
  set_transient('drb_running', 0, 1);
376
  }
377
  if (isset($_POST['type-backup2'])) {
378
- $data_result = WPAdm_Running::getCommandResultData($_POST['type-backup2']);
 
379
  if (!empty($data_result) && $data_result['result'] != 'success') {
380
  $log_array['data'] = $data_result;
381
  set_transient('drb_running', 0, 1);
@@ -396,7 +454,7 @@
396
  if (file_exists(WPAdm_Core::getTmpDir() . "/logs2")) {
397
  @unlink(WPAdm_Core::getTmpDir() . "/logs2");
398
  }
399
- $name_backup = isset($_POST['name']) ? trim($_POST['name']) : "";
400
  $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);
401
  $res = $backup->getResult()->toArray();
402
  @session_start();
@@ -415,15 +473,14 @@
415
  @unlink(WPAdm_Core::getTmpDir() . "/log.log");
416
  }
417
  WPAdm_Core::log( __('Start Restore from Dropbox cloud' ,'dropbox-backup')) ;
418
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
419
- if ($dropbox_options) {
420
  require_once DRBBACKUP_BASE_DIR. "/modules/dropbox.class.php";
421
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
422
  $folder_project = self::getNameProject();
423
  $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
424
  if ($dropbox->isAuth()) {
425
  WPAdm_Core::mkdir(DROPBOX_BACKUP_DIR_BACKUP);
426
- $name_backup = isset($_POST['name']) ? trim($_POST['name']) : "";
427
  $dir_backup = DROPBOX_BACKUP_DIR_BACKUP . "/$name_backup";
428
  $error = WPAdm_Core::mkdir($dir_backup);
429
  if (!empty($error)) {
@@ -467,16 +524,17 @@
467
  public static function download()
468
  {
469
  if (isset($_REQUEST['backup'])) {
 
470
  require_once DRBBACKUP_BASE_DIR . "/class-wpadm-core.php";
471
  require_once DRBBACKUP_BASE_DIR . '/modules/pclzip.lib.php';
472
  $backup = new WPAdm_Core(array('method' => "local"), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
473
- $filename = $_REQUEST['backup'] . ".zip";
474
  $file = WPAdm_Core::getTmpDir() . "/" . $filename;
475
  if (file_exists($file)) {
476
  @unlink($file);
477
  }
478
  $archive = new PclZip($file);
479
- $dir_backup = DROPBOX_BACKUP_DIR_BACKUP . '/' . $_REQUEST['backup'];
480
 
481
  $backups = array('data' => array(), 'md5' => '');
482
  if (is_dir($dir_backup)) {
@@ -514,51 +572,63 @@
514
  }
515
  }
516
 
517
- public static function delete_backup()
518
  {
519
- if (isset($_POST['backup-type']) ) {
520
- if ($_POST['backup-type'] == 'local') {
521
- require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
522
- $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
523
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
524
- if ($dropbox_options) {
525
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
526
- if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
527
- $backup_dir = $dropbox_options['backup_folder'];
528
- }
529
- }
530
- $dir = $backup_dir . '/' . $_POST['backup-name'] ;
531
- $delete = false;
532
- if (is_dir($dir)) {
533
- WPAdm_Core::rmdir($dir);
534
- $delete = true;
535
- }
536
- $dir = ABSPATH . WPADM_DIR_NAME . '/' . $_POST['backup-name'] ;
537
- if (is_dir($dir)) {
538
- WPAdm_Core::rmdir($dir);
539
- $delete = true;
540
- }
541
- $dir = WPADM_DIR_BACKUP . '/' . $_POST['backup-name'] ;
542
- if (is_dir($dir)) {
543
- WPAdm_Core::rmdir($dir);
544
- $delete = true;
545
- }
546
- if ($delete) {
547
- parent::setMessage( str_replace('%s', $_POST['backup-name'], __('Backup(%s) was deleted','dropbox-backup') ) );
548
  }
549
- } elseif ($_POST['backup-type'] == 'dropbox') {
550
- require_once DRBBACKUP_BASE_DIR . "/modules/dropbox.class.php";
551
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
552
- if ($dropbox_options) {
553
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
554
- $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
555
- $folder_project = self::getNameProject();
556
- $res = $dropbox->deleteFile("$folder_project/{$_POST['backup-name']}");
557
- if ($res['is_deleted'] === true) {
558
- parent::setMessage( str_replace('%s', $_POST['backup-name'], __('Backup(%s) was deleted','dropbox-backup') ) );
559
- }
560
- }
561
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
562
  }
563
  if (self::$local_delete === false || empty(self::$local_delete)) {
564
  header("Location: " . admin_url("admin.php?page=wpadm_wp_full_backup_dropbox"));
@@ -581,40 +651,37 @@
581
  require_once DRBBACKUP_BASE_DIR . "/modules/dropbox.class.php";
582
  if (isset($_GET['app_key']) && isset($_GET['app_secret'])) {
583
  if (empty($_GET['app_key']) && empty($_GET['app_secret'])) {
584
- $_GET['app_key'] = WPADM_APP_KEY;
585
- $_GET['app_secret'] = WPADM_APP_SECRET;
 
 
 
586
  }
587
- $dropbox = new dropbox($_GET['app_key'], $_GET['app_secret']);
588
- $_SESSION['dropbox_key'] = $_GET['app_key'];
589
- $_SESSION['dropbox_secret'] = $_GET['app_secret'];
590
  $_SESSION['dropbox_request_token'] = $dropbox->getRequestToken();
591
  echo '<script>window.location.href="' . $dropbox->generateAuthUrl( admin_url('admin-post.php?action=dropboxConnect') ) . '";</script>';
592
  } elseif (isset($_GET['oauth_token']) && isset($_GET['uid'])) {
593
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
594
- if ($dropbox_options) {
595
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
596
- } else {
597
- $dropbox_options = array();
598
- add_option(PREFIX_BACKUP_ . 'dropbox-setting', base64_encode(serialize( $dropbox_options ) ) );
599
- }
600
  $dropbox = new dropbox(@$_SESSION['dropbox_key'], @$_SESSION['dropbox_secret']);
601
  $access_token = $dropbox->getAccessToken($_SESSION['dropbox_request_token']);
602
  $dropbox_options['app_key'] = @$_SESSION['dropbox_key'] ;
603
  $dropbox_options['app_secret'] = @$_SESSION['dropbox_secret'] ;
604
  $dropbox_options['auth_token_secret'] = $access_token;
605
- $dropbox_options['oauth_token'] = @$_GET['oauth_token'] ;
606
- $dropbox_options['uid'] = @$_GET['uid'] ;
607
- update_option(PREFIX_BACKUP_ . 'dropbox-setting', base64_encode( serialize( $dropbox_options ) ) );
608
  echo '<script>
609
  if(window.opener){
610
- window.opener.connectDropbox(null, null, "'.htmlspecialchars($access_token['oauth_token_secret']).'", "'.htmlspecialchars($access_token['oauth_token']).'", "'.htmlspecialchars($access_token['uid']).'");window.close();
611
  }else{
612
  window.location.href="' . admin_url("admin.php?page=wpadm_wp_full_backup_dropbox") . '";
613
  }
614
  </script>';
615
  echo '<script>window.close();</script>';exit;
616
  } elseif (isset($_GET['not_approved'])) {
617
- if( $_GET['not_approved'] == 'true' ){
618
  echo '<script>window.close();</script>';exit;
619
  }
620
  } else {
@@ -625,6 +692,7 @@
625
 
626
  public static function dropbox_backup_create()
627
  {
 
628
  require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
629
  require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-process.php";
630
  @session_write_close();
@@ -635,24 +703,23 @@
635
  }
636
  if (file_exists(WPAdm_Core::getTmpDir() . "/log.log")) {
637
  file_put_contents(WPAdm_Core::getTmpDir() . "/log.log", '');
638
- }
 
 
639
 
640
  WPAdm_Process::clear();
641
 
642
  $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
643
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
644
  if ($dropbox_options) {
645
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
646
  if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
647
  $backup_dir = $dropbox_options['backup_folder'];
648
  }
649
  }
650
 
651
  if ( WPAdm_Core::dir_writeble($backup_dir) ) {
652
- //$dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
653
  $send_to_dropbox = true;
654
  if ($dropbox_options) {
655
- //$dropbox_options = unserialize( base64_decode( $dropbox_options ) );
656
  if (!isset($dropbox_options['app_key'])) {
657
  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') ) );
658
  $send_to_dropbox = false;
@@ -685,12 +752,12 @@
685
  parent::$type = 'full';
686
  WPAdm_Running::init_params_default();
687
  WPAdm_Running::delCommandResultData("local_backup");
688
-
689
  $dropbox_options = self::getSettings();
690
  $optimization = (isset($dropbox_options['is_optimization']) && $dropbox_options['is_optimization'] == 1) || (!isset($dropbox_options['is_optimization'])) ? 1 : 0;
691
  $repair = (isset($dropbox_options['is_repair']) && $dropbox_options['is_repair'] == 1) ? 1 : 0;
692
-
693
- $backup_local = new WPAdm_Core(array('method' => "local_backup", 'params' => array('optimize' => $optimization, 'repair' => $repair, 'limit' => 0, 'time' => @$_POST['time'], 'types' => array('db', 'files') )), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
694
  $res = array();
695
  if (WPAdm_Core::$cron === false) {
696
  $res = $backup->getResult()->toArray();
@@ -712,7 +779,7 @@
712
  'token' => $dropbox_options['auth_token_secret'],
713
  'dir' => isset($res['name']) ? $res['name'] : '',
714
  'folder' => $folder_project),
715
- 'time' => @$_POST['time'],
716
  'is_folder_set' => isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder']),
717
  )
718
  ),
@@ -727,7 +794,7 @@
727
  }
728
  WPAdm_Core::rmdir( $backup_dir . "/{$res['name']}");
729
  } else {
730
- set_transient('running_command', 'send-to-dropbox', 0);
731
  $res['result'] = 'work';
732
  $res['error'] = '';
733
  $res['data'] = array();
@@ -758,16 +825,13 @@
758
  {
759
  require_once DRBBACKUP_BASE_DIR. "/modules/dropbox.class.php";
760
  parent::$type = 'full';
761
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
762
  $stop_precess = WPAdm_Running::getCommandResultData('stop_process');
763
  $name_backup = isset($stop_precess['name']) ? $stop_precess['name'] : '' ;
764
  if ($dropbox_options) {
765
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
766
  if (isset($dropbox_options['app_key']) && isset($dropbox_options['app_secret']) && isset($dropbox_options['auth_token_secret'])) {
767
  $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
768
  $folder_project = self::getNameProject();
769
- //$dropbox->uploadFile(dirname(__FILE__) . "/index.php", $folder_project . '/index.php', true);
770
- // $res = $dropbox->downloadFile("localhost_wp_dropbox/localhost_wp_dropbox-full-2016_06_07_14_05/localhost_wp_dropbox-full-2016_06_07_14_05.md5", DROPBOX_BACKUP_DIR_BACKUP . "/localhost_wp_dropbox-full-2016_06_07_14_05.md5");
771
  $backups = $dropbox->listing($folder_project);
772
  $n = count($backups['items']);
773
  $data['data'] = array();
@@ -795,13 +859,13 @@
795
  }
796
  }
797
  }
798
- if (isset($_GET['pay']) && $_GET['pay'] == 'success') {
799
  if (!file_exists(WPAdm_Core::getTmpDir() . "/pay_success")) {
800
  file_put_contents(WPAdm_Core::getTmpDir() . "/pay_success", 1);
801
  parent::setMessage( 'Checkout was successfully' );
802
  }
803
  }
804
- if (isset($_GET['pay']) && $_GET['pay'] == 'cancel') {
805
  parent::setError( __('Checkout was canceled','dropbox-backup') );
806
  }
807
  $data_local = parent::read_backups();
@@ -857,12 +921,12 @@
857
  if ( !file_exists( $backu_dir . '/local-key') ) {
858
  WPAdm_Core::mkdir($backu_dir);
859
  $key = md5(time() . 'wpadm-key');
860
- file_put_contents($backu_dir . '/local-key', wpadm_pack(array('key' => $key, 'time-update' => time() + 3600) ));
861
  } else {
862
- $key_values = wpadm_unpack( file_get_contents($backu_dir . '/local-key') );
863
  if (isset($key_values['time-update']) && $key_values['time-update'] <= time() ) {
864
  $key = md5( time() . 'wpadm-key' );
865
- file_put_contents($backu_dir . '/local-key', wpadm_pack( array( 'key' => $key, 'time-update' => time() + 3600 ) ) );
866
  } else {
867
  $key = $key_values['key'];
868
  }
@@ -876,6 +940,9 @@
876
  $msg = parent::getMessage(true);
877
  $default = self::$circle / 6; // 18 request for log files, one request every 10 seconds
878
  $base_path = DRBBACKUP_BASE_DIR ;
 
 
 
879
  ob_start();
880
  require_once $base_path . DIRECTORY_SEPARATOR . "template" . DIRECTORY_SEPARATOR . "wpadm_show_backup.php";
881
  echo ob_get_clean();
@@ -884,14 +951,16 @@
884
  public static function draw_menu()
885
  {
886
  $show = true;
887
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
888
- if ($dropbox_options) {
889
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
890
- }
891
  if ( ( isset($dropbox_options['is_admin']) && $dropbox_options['is_admin'] == 1 ) || !isset($dropbox_options['is_admin']) ) {
892
  if (!is_admin() || !is_super_admin()) {
893
  $show = false;
894
  }
 
 
 
 
895
  }
896
  if ($show) {
897
  $menu_position = '1.9998887771';
@@ -937,7 +1006,8 @@
937
  }
938
  }
939
  public static function notice()
940
- {
 
941
  if (!isset($_GET['page']) || ( isset($_GET['page']) && $_GET['page'] != 'wpadm_wp_full_backup_dropbox' ) ) {
942
  $notice_file = DRBBACKUP_BASE_DIR . DIRECTORY_SEPARATOR . "template" . DIRECTORY_SEPARATOR . "notice.php";
943
  if (!file_exists(WPAdm_Core::getTmpDir() . "/notice") && file_exists($notice_file)) {
@@ -950,7 +1020,8 @@
950
  public static function hide_notice()
951
  {
952
  if (isset($_GET['type'])) {
953
- switch($_GET['type']) {
 
954
  case 'preview' :
955
  file_put_contents(WPAdm_Core::getTmpDir() . "/notice", 1);
956
  break;
1
  <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
+
5
+
6
  if(@session_id() == '') {
7
  @session_start();
8
  }
35
  add_action('admin_post_hide_notice', array('wpadm_wp_full_backup_dropbox', 'hide_notice') );
36
  add_action( 'admin_bar_menu', array('wpadm_wp_full_backup_dropbox', 'add_link_to_admin_bar') ,999 );
37
 
38
+ add_filter( 'nonce_life', 'wpadm_nonce_life' );
39
 
40
  class wpadm_wp_full_backup_dropbox extends wpadm_class {
41
 
43
 
44
  const MIN_PASSWORD = 6;
45
 
46
+ private static $circle = 42;
47
 
48
  private static $local_delete = false;
49
 
50
+ static function is_auth_user()
51
+ {
52
+ if ( !is_user_logged_in() ) {
53
+ exit;
54
+ }
55
+ $dropbox_options = self::getSettings();
56
+ if ( ( isset($dropbox_options['is_admin']) && $dropbox_options['is_admin'] == 1 ) || !isset($dropbox_options['is_admin']) ) {
57
+ if (!is_admin() || !is_super_admin()) { // check admin
58
+ exit;
59
+ }
60
+ if ( !current_user_can('administrator') ) { // check admin
61
+ exit;
62
+ }
63
+ }
64
+ $nonce = '';
65
+ if (isset($_REQUEST['nonce'])) {
66
+ $nonce = sanitize_text_field($_REQUEST['nonce']);
67
+ }
68
+ if ( ! wp_verify_nonce( $nonce, 'wpadm_nonce' ) ) {
69
+ exit;
70
+ }
71
+ }
72
+
73
+ static function stopBackup($local = false, $type_backup = '')
74
  {
75
+ self::is_auth_user();
76
+ if (isset($_POST['type_backup']) || !empty($type_backup)) {
77
  self::$local_delete = $local;
78
+ if (!empty($type_backup)) {
79
+ $type = $type_backup;
80
+ } else {
81
+ $type = sanitize_text_field( $_POST['type_backup'] );
82
+ }
83
  $setting_backup = array();
84
+ if ( $type == 'local_backup' ) {
85
  $setting_backup = WPAdm_Running::getCommand( 'local_backup' );
86
+ $type_backup = 'local';
87
+ } elseif ( $type == 'send-to-dropbox') {
88
  $setting_backup = WPAdm_Running::getCommand( 'send-to-dropbox' );
89
+ $type_backup = 'dropbox';
90
  }
91
  // WPAdm_Running::setCommandResultData('stop_backup', $setting_backup);
92
  $name = '';
100
  $name );
101
  $name = preg_replace("|\W|", "_", $name);
102
  $name .= '-full-' . date("Y_m_d_H_i", $setting_backup['params']['time']);
103
+
104
+ self::delete_backup('local', $name);
105
+ if ($type == 'send-to-dropbox') {
106
+ self::delete_backup('dropbox', $name);
 
 
107
  }
108
+
 
109
  }
110
  }
111
  WPAdm_Running::init_params_default();
112
+ WPAdm_Running::setCommandResultData('stop_process', array( 'stop' => 1, 'name' => $name, 'type' => $type ) );
113
  if ($local === false || empty($local)) {
114
  header("Location: " . admin_url("admin.php?page=wpadm_wp_full_backup_dropbox"));
115
  exit;
119
  static function add_link_to_admin_bar($wp_admin_bar)
120
  {
121
  $show = true;
122
+ $dropbox_options = self::getSettings();
123
+
 
 
124
  if ( ( isset($dropbox_options['is_show_admin_bar']) && $dropbox_options['is_show_admin_bar'] == 0 ) ) {
125
  $show = false;
126
  }
182
  if(!function_exists("wp_safe_remote_post")) {
183
  include ABSPATH . "/http.php";
184
  }
185
+ $res = wp_safe_remote_post(SERVER_URL_INDEX, array('username' => sanitize_text_field( $_POST['username'] ), 'password' => sanitize_text_field( $_POST['password'] ), 'plugin' => 'dropbox-backup'));
186
  if (!Empty($res['body'])) {
187
  $data_res = json_decode($res['body']);
188
  if (isset($data_res['url'])) {
216
  public static function setUserMail()
217
  {
218
  if (isset($_POST['email'])) {
219
+ $email = sanitize_email( $_POST['email'] );
220
  $mail = get_option(PREFIX_BACKUP_ . "email");
221
  if ($mail) {
222
  add_option(PREFIX_BACKUP_ . "email", $email);
230
  public static function saveSetting()
231
  {
232
  if (isset($_POST['is_admin']) || isset($_POST['is_optimization']) || isset($_POST['is_local_backup_delete'])
233
+ || isset($_POST['is_repair']) || isset($_POST['time_error']) || isset($_POST['is_show_admin_bar'] ) || isset($_POST['backup_folder'] )
234
+ || isset($_POST['clear_backup_folder']) ) {
235
+
236
+ $dropbox_options = self::getSettings();
237
 
 
 
 
 
238
  if (isset($_POST['time_error'])) {
239
+ $dropbox_options['time_error'] = (int)sanitize_text_field( $_POST['time_error'] );
240
  }
241
  if (isset($_POST['is_admin'])) {
242
+ $dropbox_options['is_admin'] = (int)sanitize_text_field( $_POST['is_admin'] );
243
  }
244
  if (isset($_POST['is_optimization'])) {
245
+ $dropbox_options['is_optimization'] = (int)sanitize_text_field( $_POST['is_optimization'] );
246
  }
247
  if (isset($_POST['is_local_backup_delete'])) {
248
+ $dropbox_options['is_local_backup_delete'] = (int)sanitize_text_field( $_POST['is_local_backup_delete'] );
249
  }
250
  if (isset($_POST['is_repair'])) {
251
+ $dropbox_options['is_repair'] = (int)sanitize_text_field( $_POST['is_repair'] );
252
  }
253
  if (isset($_POST['is_show_admin_bar'])) {
254
+ $dropbox_options['is_show_admin_bar'] = (int)sanitize_text_field( $_POST['is_show_admin_bar'] );
255
  }
256
  if (isset($_POST['backup_folder'])) {
257
+ $dropbox_options['backup_folder'] = rtrim( sanitize_text_field( $_POST['backup_folder'] ), '/' );
258
  }
259
+ if (isset($_POST['clear_backup_folder']) && $_POST['clear_backup_folder'] == 1) {
260
+ if ( isset($dropbox_options['backup_folder']) ) {
261
+ unset($dropbox_options['backup_folder']);
262
+ }
263
+ }
264
+
265
+ self::setSettings($dropbox_options);
266
  }
267
  }
268
 
277
  return $dropbox_options;
278
  }
279
 
280
+ public static function setSettings($data, $key = '')
281
+ {
282
+ $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
283
+ if ($dropbox_options) {
284
+ $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
285
+ } else {
286
+ $dropbox_options = array();
287
+ }
288
+ if ( !empty($key) ) {
289
+ if(isset($dropbox_options[$key])) {
290
+ $dropbox_options[$key] = $data;
291
+ }
292
+ } else {
293
+ $dropbox_options = $data;
294
+ }
295
+
296
+ update_option(PREFIX_BACKUP_ . 'dropbox-setting', base64_encode( serialize( $dropbox_options ) ) );
297
+
298
+ return $dropbox_options;
299
+ }
300
+
301
  public static function local_backup()
302
  {
303
+ self::is_auth_user();
304
  require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
305
  require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-process.php";
306
  @session_write_close();
310
  }
311
  if (file_exists(WPAdm_Core::getTmpDir() . "/log.log")) {
312
  file_put_contents(WPAdm_Core::getTmpDir() . "/log.log", '');
313
+ }
314
+
315
+ WPAdm_Core::rmdir(WPAdm_Core::getTmpDir() . "/log-archive.log");
316
 
317
  WPAdm_Process::clear();
318
 
319
  $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
320
+ $dropbox_options = self::getSettings();
321
  if ($dropbox_options) {
 
322
  if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
323
  $backup_dir = $dropbox_options['backup_folder'];
324
  }
341
  $dropbox_options = self::getSettings();
342
  $optimization = (isset($dropbox_options['is_optimization']) && $dropbox_options['is_optimization'] == 1) || (!isset($dropbox_options['is_optimization'])) ? 1 : 0;
343
  $repair = (isset($dropbox_options['is_repair']) && $dropbox_options['is_repair'] == 1) ? 1 : 0;
344
+ $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);
345
  if (WPAdm_Core::$cron === false) {
346
  $res = $backup->getResult()->toArray();
347
  $res['md5_data'] = md5( print_r($res, 1) );
350
  $res['type'] = 'local';
351
  $res['counts'] = count($res['data']);
352
  } else {
353
+ set_transient('running_command', 'local_backup', HOUR_IN_SECONDS);
354
  $res['result'] = 'work';
355
  $res['error'] = '';
356
  $res['data'] = array();
372
 
373
  public static function getLog()
374
  {
375
+ self::is_auth_user();
376
  @session_write_close();
377
  @session_start();
378
  require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
388
  if ( empty($circle['count']) || $circle['count'] == 0) {
389
  $circle['count'] = 0;
390
  }
391
+ $dropbox_options = self::getSettings();
392
  if ($dropbox_options) {
 
393
  if (isset($dropbox_options['time_error'])) {
394
  self::$circle = ( (int)$dropbox_options['time_error'] * 6 );
395
  }
410
  'error' => $error_msg,
411
  'data' => null,
412
  'size' => 0 );
413
+ $type_backup = sanitize_text_field( $_POST['type-backup'] );
414
+ self::stopBackup(true, $type_backup);
415
  }
416
  $log_array['example'] = $circle;
417
  } else {
425
  $log = explode("\n", $log);
426
  krsort($log);
427
  $log_array['log'] = $log;
428
+ $type_backup = sanitize_text_field( $_POST['type-backup'] );
429
+ $data_result = WPAdm_Running::getCommandResultData( $type_backup );
430
  if (!empty($data_result)) {
431
  $log_array['data'] = $data_result;
432
  set_transient('drb_running', 0, 1);
433
  }
434
  if (isset($_POST['type-backup2'])) {
435
+ $type_backup2 = sanitize_text_field( $_POST['type-backup2'] );
436
+ $data_result = WPAdm_Running::getCommandResultData( $type_backup2 );
437
  if (!empty($data_result) && $data_result['result'] != 'success') {
438
  $log_array['data'] = $data_result;
439
  set_transient('drb_running', 0, 1);
454
  if (file_exists(WPAdm_Core::getTmpDir() . "/logs2")) {
455
  @unlink(WPAdm_Core::getTmpDir() . "/logs2");
456
  }
457
+ $name_backup = isset($_POST['name']) ? sanitize_text_field( $_POST['name'] ) : "";
458
  $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);
459
  $res = $backup->getResult()->toArray();
460
  @session_start();
473
  @unlink(WPAdm_Core::getTmpDir() . "/log.log");
474
  }
475
  WPAdm_Core::log( __('Start Restore from Dropbox cloud' ,'dropbox-backup')) ;
476
+ $dropbox_options = self::getSettings();
477
+ if ($dropbox_options && isset( $dropbox_options['app_key'] ) ) {
478
  require_once DRBBACKUP_BASE_DIR. "/modules/dropbox.class.php";
 
479
  $folder_project = self::getNameProject();
480
  $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
481
  if ($dropbox->isAuth()) {
482
  WPAdm_Core::mkdir(DROPBOX_BACKUP_DIR_BACKUP);
483
+ $name_backup = isset($_POST['name']) ? sanitize_text_field( $_POST['name'] ): "";
484
  $dir_backup = DROPBOX_BACKUP_DIR_BACKUP . "/$name_backup";
485
  $error = WPAdm_Core::mkdir($dir_backup);
486
  if (!empty($error)) {
524
  public static function download()
525
  {
526
  if (isset($_REQUEST['backup'])) {
527
+ $backup = sanitize_text_field($_REQUEST['backup']);
528
  require_once DRBBACKUP_BASE_DIR . "/class-wpadm-core.php";
529
  require_once DRBBACKUP_BASE_DIR . '/modules/pclzip.lib.php';
530
  $backup = new WPAdm_Core(array('method' => "local"), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
531
+ $filename = $backup . ".zip";
532
  $file = WPAdm_Core::getTmpDir() . "/" . $filename;
533
  if (file_exists($file)) {
534
  @unlink($file);
535
  }
536
  $archive = new PclZip($file);
537
+ $dir_backup = DROPBOX_BACKUP_DIR_BACKUP . '/' . $backup;
538
 
539
  $backups = array('data' => array(), 'md5' => '');
540
  if (is_dir($dir_backup)) {
572
  }
573
  }
574
 
575
+ public static function delete_backup($type = '', $name = '')
576
  {
577
+ if (self::$local_delete === false || empty(self::$local_delete)) {
578
+ self::is_auth_user();
579
+ }
580
+ if ( isset($_POST['backup-type']) ) {
581
+ $type = sanitize_text_field( $_POST['backup-type'] );
582
+ } elseif( !empty($type) ) {
583
+ $type = sanitize_text_field( $type );
584
+ }
585
+
586
+ if (isset($_POST['backup-name'])) {
587
+ $name = sanitize_text_field( $_POST['backup-name'] );
588
+ } elseif (!empty($name)) {
589
+ $name = sanitize_text_field( $name );
590
+ }
591
+
592
+ if ($type == 'local') {
593
+ require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
594
+ $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
595
+ $dropbox_options = self::getSettings();
596
+ if ($dropbox_options) {
597
+ if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
598
+ $backup_dir = $dropbox_options['backup_folder'];
 
 
 
 
 
 
 
599
  }
 
 
 
 
 
 
 
 
 
 
 
 
600
  }
601
+
602
+ $dir = $backup_dir . '/' . $name ;
603
+ $delete = false;
604
+ if (is_dir($dir)) {
605
+ WPAdm_Core::rmdir($dir);
606
+ $delete = true;
607
+ }
608
+ $dir = ABSPATH . WPADM_DIR_NAME . '/' . $name ;
609
+ if (is_dir($dir)) {
610
+ WPAdm_Core::rmdir($dir);
611
+ $delete = true;
612
+ }
613
+ $dir = WPADM_DIR_BACKUP . '/' . $name ;
614
+ if (is_dir($dir)) {
615
+ WPAdm_Core::rmdir($dir);
616
+ $delete = true;
617
+ }
618
+ if ($delete) {
619
+ parent::setMessage( str_replace('%s', $name, __('Backup(%s) was deleted','dropbox-backup') ) );
620
+ }
621
+ } elseif ($type == 'dropbox') {
622
+ require_once DRBBACKUP_BASE_DIR . "/modules/dropbox.class.php";
623
+ $dropbox_options = self::getSettings();
624
+ if ($dropbox_options && isset($dropbox_options['app_key'])) {
625
+ $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
626
+ $folder_project = self::getNameProject();
627
+ $res = $dropbox->deleteFile("$folder_project/{$name}");
628
+ if ($res['is_deleted'] === true) {
629
+ parent::setMessage( str_replace('%s', $name, __('Backup(%s) was deleted','dropbox-backup') ) );
630
+ }
631
+ }
632
  }
633
  if (self::$local_delete === false || empty(self::$local_delete)) {
634
  header("Location: " . admin_url("admin.php?page=wpadm_wp_full_backup_dropbox"));
651
  require_once DRBBACKUP_BASE_DIR . "/modules/dropbox.class.php";
652
  if (isset($_GET['app_key']) && isset($_GET['app_secret'])) {
653
  if (empty($_GET['app_key']) && empty($_GET['app_secret'])) {
654
+ $app_key = WPADM_APP_KEY;
655
+ $app_secret = WPADM_APP_SECRET;
656
+ } else {
657
+ $app_key = sanitize_text_field($_GET['app_key']);
658
+ $app_secret = sanitize_text_field($_GET['app_secret']);
659
  }
660
+ $dropbox = new dropbox($app_key, $app_secret);
661
+ $_SESSION['dropbox_key'] = $app_key;
662
+ $_SESSION['dropbox_secret'] = $app_secret;
663
  $_SESSION['dropbox_request_token'] = $dropbox->getRequestToken();
664
  echo '<script>window.location.href="' . $dropbox->generateAuthUrl( admin_url('admin-post.php?action=dropboxConnect') ) . '";</script>';
665
  } elseif (isset($_GET['oauth_token']) && isset($_GET['uid'])) {
666
+ $dropbox_options = self::getSettings();
 
 
 
 
 
 
667
  $dropbox = new dropbox(@$_SESSION['dropbox_key'], @$_SESSION['dropbox_secret']);
668
  $access_token = $dropbox->getAccessToken($_SESSION['dropbox_request_token']);
669
  $dropbox_options['app_key'] = @$_SESSION['dropbox_key'] ;
670
  $dropbox_options['app_secret'] = @$_SESSION['dropbox_secret'] ;
671
  $dropbox_options['auth_token_secret'] = $access_token;
672
+ $dropbox_options['oauth_token'] = sanitize_text_field( @$_GET['oauth_token'] ) ;
673
+ $dropbox_options['uid'] = sanitize_text_field( @$_GET['uid'] ) ;
674
+ self::setSettings($dropbox_options);
675
  echo '<script>
676
  if(window.opener){
677
+ window.opener.connectDropbox(null, null, "'. htmlspecialchars($access_token['oauth_token_secret']) . '", "'.htmlspecialchars($access_token['oauth_token']).'", "'.htmlspecialchars($access_token['uid']).'");window.close();
678
  }else{
679
  window.location.href="' . admin_url("admin.php?page=wpadm_wp_full_backup_dropbox") . '";
680
  }
681
  </script>';
682
  echo '<script>window.close();</script>';exit;
683
  } elseif (isset($_GET['not_approved'])) {
684
+ if( $_GET['not_approved'] == 'true' ){ // check of GET params == string 'true'
685
  echo '<script>window.close();</script>';exit;
686
  }
687
  } else {
692
 
693
  public static function dropbox_backup_create()
694
  {
695
+ self::is_auth_user();
696
  require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
697
  require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-process.php";
698
  @session_write_close();
703
  }
704
  if (file_exists(WPAdm_Core::getTmpDir() . "/log.log")) {
705
  file_put_contents(WPAdm_Core::getTmpDir() . "/log.log", '');
706
+ }
707
+
708
+ WPAdm_Core::rmdir(WPAdm_Core::getTmpDir() . "/log-archive.log");
709
 
710
  WPAdm_Process::clear();
711
 
712
  $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
713
+ $dropbox_options = self::getSettings();
714
  if ($dropbox_options) {
 
715
  if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
716
  $backup_dir = $dropbox_options['backup_folder'];
717
  }
718
  }
719
 
720
  if ( WPAdm_Core::dir_writeble($backup_dir) ) {
 
721
  $send_to_dropbox = true;
722
  if ($dropbox_options) {
 
723
  if (!isset($dropbox_options['app_key'])) {
724
  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') ) );
725
  $send_to_dropbox = false;
752
  parent::$type = 'full';
753
  WPAdm_Running::init_params_default();
754
  WPAdm_Running::delCommandResultData("local_backup");
755
+
756
  $dropbox_options = self::getSettings();
757
  $optimization = (isset($dropbox_options['is_optimization']) && $dropbox_options['is_optimization'] == 1) || (!isset($dropbox_options['is_optimization'])) ? 1 : 0;
758
  $repair = (isset($dropbox_options['is_repair']) && $dropbox_options['is_repair'] == 1) ? 1 : 0;
759
+
760
+ $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);
761
  $res = array();
762
  if (WPAdm_Core::$cron === false) {
763
  $res = $backup->getResult()->toArray();
779
  'token' => $dropbox_options['auth_token_secret'],
780
  'dir' => isset($res['name']) ? $res['name'] : '',
781
  'folder' => $folder_project),
782
+ 'time' => (int)$_POST['time'],
783
  'is_folder_set' => isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder']),
784
  )
785
  ),
794
  }
795
  WPAdm_Core::rmdir( $backup_dir . "/{$res['name']}");
796
  } else {
797
+ set_transient('running_command', 'send-to-dropbox', HOUR_IN_SECONDS);
798
  $res['result'] = 'work';
799
  $res['error'] = '';
800
  $res['data'] = array();
825
  {
826
  require_once DRBBACKUP_BASE_DIR. "/modules/dropbox.class.php";
827
  parent::$type = 'full';
828
+ $dropbox_options = self::getSettings();
829
  $stop_precess = WPAdm_Running::getCommandResultData('stop_process');
830
  $name_backup = isset($stop_precess['name']) ? $stop_precess['name'] : '' ;
831
  if ($dropbox_options) {
 
832
  if (isset($dropbox_options['app_key']) && isset($dropbox_options['app_secret']) && isset($dropbox_options['auth_token_secret'])) {
833
  $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
834
  $folder_project = self::getNameProject();
 
 
835
  $backups = $dropbox->listing($folder_project);
836
  $n = count($backups['items']);
837
  $data['data'] = array();
859
  }
860
  }
861
  }
862
+ if (isset($_GET['pay']) && $_GET['pay'] == 'success') { // check of GET params == string 'success'
863
  if (!file_exists(WPAdm_Core::getTmpDir() . "/pay_success")) {
864
  file_put_contents(WPAdm_Core::getTmpDir() . "/pay_success", 1);
865
  parent::setMessage( 'Checkout was successfully' );
866
  }
867
  }
868
+ if (isset($_GET['pay']) && $_GET['pay'] == 'cancel') { // check of GET params == string 'cancel'
869
  parent::setError( __('Checkout was canceled','dropbox-backup') );
870
  }
871
  $data_local = parent::read_backups();
921
  if ( !file_exists( $backu_dir . '/local-key') ) {
922
  WPAdm_Core::mkdir($backu_dir);
923
  $key = md5(time() . 'wpadm-key');
924
+ file_put_contents($backu_dir . '/local-key', base64_encode( serialize( array('key' => $key, 'time-update' => time() + 3600) ) ) );
925
  } else {
926
+ $key_values = unserialize( base64_decode( file_get_contents($backu_dir . '/local-key') ) );
927
  if (isset($key_values['time-update']) && $key_values['time-update'] <= time() ) {
928
  $key = md5( time() . 'wpadm-key' );
929
+ file_put_contents($backu_dir . '/local-key', base64_encode( serialize ( array( 'key' => $key, 'time-update' => time() + 3600 ) ) ) );
930
  } else {
931
  $key = $key_values['key'];
932
  }
940
  $msg = parent::getMessage(true);
941
  $default = self::$circle / 6; // 18 request for log files, one request every 10 seconds
942
  $base_path = DRBBACKUP_BASE_DIR ;
943
+
944
+ $nonce = wp_create_nonce( 'wpadm_nonce' );
945
+
946
  ob_start();
947
  require_once $base_path . DIRECTORY_SEPARATOR . "template" . DIRECTORY_SEPARATOR . "wpadm_show_backup.php";
948
  echo ob_get_clean();
951
  public static function draw_menu()
952
  {
953
  $show = true;
954
+ $dropbox_options = self::getSettings();
955
+
 
 
956
  if ( ( isset($dropbox_options['is_admin']) && $dropbox_options['is_admin'] == 1 ) || !isset($dropbox_options['is_admin']) ) {
957
  if (!is_admin() || !is_super_admin()) {
958
  $show = false;
959
  }
960
+ if ( !current_user_can('administrator') ) {
961
+ $show = false;
962
+ }
963
+
964
  }
965
  if ($show) {
966
  $menu_position = '1.9998887771';
1006
  }
1007
  }
1008
  public static function notice()
1009
+ {
1010
+ // check of isset GET params "page"
1011
  if (!isset($_GET['page']) || ( isset($_GET['page']) && $_GET['page'] != 'wpadm_wp_full_backup_dropbox' ) ) {
1012
  $notice_file = DRBBACKUP_BASE_DIR . DIRECTORY_SEPARATOR . "template" . DIRECTORY_SEPARATOR . "notice.php";
1013
  if (!file_exists(WPAdm_Core::getTmpDir() . "/notice") && file_exists($notice_file)) {
1020
  public static function hide_notice()
1021
  {
1022
  if (isset($_GET['type'])) {
1023
+ $type = sanitize_text_field( $_GET['type'] );
1024
+ switch( $type ) {
1025
  case 'preview' :
1026
  file_put_contents(WPAdm_Core::getTmpDir() . "/notice", 1);
1027
  break;
methods/class-wpadm-method-backup-delete.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Delete backup
4
  * Class WPAdm_Method_Backup_Delete
@@ -8,9 +12,8 @@ if (!class_exists('WPAdm_Method_Backup_Delete')) {
8
  public function getResult()
9
  {
10
  $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
11
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
12
  if ($dropbox_options) {
13
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
14
  if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
15
  $backup_dir = $dropbox_options['backup_folder'];
16
  }
1
  <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+
6
  /**
7
  * Delete backup
8
  * Class WPAdm_Method_Backup_Delete
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
  }
methods/class-wpadm-method-backup-list.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
  /**
3
  * Return a list of backups
4
  * Class WPAdm_Method_Exec
@@ -8,9 +11,8 @@ if (!class_exists('WPAdm_Method_Backup_List')) {
8
  public function getResult()
9
  {
10
  $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
11
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
12
  if ($dropbox_options) {
13
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
14
  if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
15
  $backup_dir = $dropbox_options['backup_folder'];
16
  }
1
  <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
  /**
6
  * Return a list of backups
7
  * Class WPAdm_Method_Exec
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
  }
methods/class-wpadm-method-backup.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Бэкап сайта
4
  * Class WPadm_Method_Backup
1
  <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+
6
  /**
7
  * Бэкап сайта
8
  * Class WPadm_Method_Backup
methods/class-wpadm-method-full-backup-dropbox.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
  /**
3
  * Creates a full backup of the site
4
  * Class WPadm_Method_Backup_Dropbox
@@ -48,6 +51,7 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
48
  'stime' => time(),
49
  )
50
  );
 
51
 
52
  if (!class_exists('WPAdm_Process')) {
53
  require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-process.php';
@@ -224,7 +228,13 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
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
 
@@ -371,6 +381,15 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
371
  $files = array_merge( $files, array( ABSPATH . 'robots.txt' ) );
372
  }
373
 
 
 
 
 
 
 
 
 
 
374
  if (!empty($this->params['minus-path'])) {
375
  $minus_path = explode(",", $this->params['minus-path']);
376
  foreach($files as $k => $v) {
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
  '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';
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
 
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']);
395
  foreach($files as $k => $v) {
methods/class-wpadm-method-local-backup.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  if (!class_exists('WPAdm_Method_Local_Backup')) {
4
  class WPAdm_Method_Local_Backup extends WPAdm_Method_Class {
5
 
@@ -44,12 +46,11 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
44
  // folder for backup
45
 
46
 
47
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
48
 
49
  $this->base_dir = DROPBOX_BACKUP_DIR_BACKUP;
50
  $this->dir = DROPBOX_BACKUP_DIR_BACKUP . '/' . $name;
51
  if ($dropbox_options) {
52
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
53
  if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder']) ) {
54
  $this->dir = $dropbox_options['backup_folder'] . '/' . $name;
55
  $this->base_dir = $dropbox_options['backup_folder'];
@@ -114,7 +115,7 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
114
 
115
  # create db dump
116
  if (in_array('db', $this->params['types']) ) {
117
-
118
  $mysql_dump_file = DROPBOX_BACKUP_DIR_BACKUP . '/mysqldump.sql';
119
  if ( !WPAdm_Running::getCommandResult('db') ) {
120
  WPAdm_Running::setCommandResult('db');
@@ -270,7 +271,6 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
270
  WPAdm_Running::setCommandResult('archive');
271
  $files_archive = WPAdm_Running::getCommandResultData('archive');
272
  require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-archive.php';
273
- ini_set("memory_limit", "256M"); // files for archive
274
  $to_file = $this->dir . '/' . $this->name;
275
  foreach($files2 as $key => $files) {
276
  $md5 = md5( print_r( $files, 1 ) );
@@ -298,7 +298,11 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
298
  }
299
  if ( WPAdm_Running::is_stop() ) {
300
  $md5 = md5( print_r( $files, 1 ) );
301
- $files_str = implode(';', $files);
 
 
 
 
302
  $files_archive = WPAdm_Running::getCommandResultData('archive');
303
  if ( WPAdm_Running::is_stop() ) {
304
  if ( !isset($files_archive[$md5]) ) {
@@ -418,13 +422,24 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
418
  public function createListFilesForArchive()
419
  {
420
  $inludes = get_option(PREFIX_BACKUP_ . "plus-path");
421
- if($inludes !== false) {
422
- $f = explode(',', $inludes);
423
  $files = array();
424
  $n = count($f);
 
425
  for($i = 0; $i < $n; $i++) {
 
 
 
 
 
 
 
 
426
  if( is_dir( ABSPATH . $f[$i] ) ) {
427
- $files = array_merge($files, $this->directoryToArray(ABSPATH . $f[$i], true));
 
 
428
  } elseif (file_exists(ABSPATH . $f[$i])) {
429
  $files[$i] = ABSPATH . $f[$i];
430
  }
@@ -475,6 +490,15 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
475
  $files = array_merge( $files, array( ABSPATH . 'wp-signup.php' ) );
476
  }
477
 
 
 
 
 
 
 
 
 
 
478
  if (!empty($this->params['minus-path'])) {
479
  $minus_path = explode(",", $this->params['minus-path']);
480
  foreach($files as $k => $v) {
@@ -521,6 +545,9 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
521
  $files = array_merge($files, $this->directoryToArray($folder, true));
522
  }
523
  }
 
 
 
524
  return $files;
525
  }
526
 
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
 
46
  // folder for backup
47
 
48
 
49
+ $dropbox_options = wpadm_wp_full_backup_dropbox::getSettings();
50
 
51
  $this->base_dir = DROPBOX_BACKUP_DIR_BACKUP;
52
  $this->dir = DROPBOX_BACKUP_DIR_BACKUP . '/' . $name;
53
  if ($dropbox_options) {
 
54
  if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder']) ) {
55
  $this->dir = $dropbox_options['backup_folder'] . '/' . $name;
56
  $this->base_dir = $dropbox_options['backup_folder'];
115
 
116
  # create db dump
117
  if (in_array('db', $this->params['types']) ) {
118
+
119
  $mysql_dump_file = DROPBOX_BACKUP_DIR_BACKUP . '/mysqldump.sql';
120
  if ( !WPAdm_Running::getCommandResult('db') ) {
121
  WPAdm_Running::setCommandResult('db');
271
  WPAdm_Running::setCommandResult('archive');
272
  $files_archive = WPAdm_Running::getCommandResultData('archive');
273
  require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-archive.php';
 
274
  $to_file = $this->dir . '/' . $this->name;
275
  foreach($files2 as $key => $files) {
276
  $md5 = md5( print_r( $files, 1 ) );
298
  }
299
  if ( WPAdm_Running::is_stop() ) {
300
  $md5 = md5( print_r( $files, 1 ) );
301
+ if ( defined('PCLZIP_SEPARATOR') ) {
302
+ $files_str = implode( PCLZIP_SEPARATOR , $files);
303
+ } else {
304
+ $files_str = implode( ',' , $files);
305
+ }
306
  $files_archive = WPAdm_Running::getCommandResultData('archive');
307
  if ( WPAdm_Running::is_stop() ) {
308
  if ( !isset($files_archive[$md5]) ) {
422
  public function createListFilesForArchive()
423
  {
424
  $inludes = get_option(PREFIX_BACKUP_ . "plus-path");
425
+ if($inludes !== false) {
426
+ $f = explode(',', base64_decode( $inludes ) );
427
  $files = array();
428
  $n = count($f);
429
+ $tmp_folder = '';
430
  for($i = 0; $i < $n; $i++) {
431
+ if (!empty($tmp_folder) && strpos($f[$i], $tmp_folder) === false) {
432
+ $fi = $this->directoryToArray(ABSPATH . $tmp_folder, true );
433
+ $files = array_merge($files, $fi);
434
+ $tmp_folder = '';
435
+ } elseif(!empty($tmp_folder) && strpos($f[$i], $tmp_folder) !== false) {
436
+ $tmp_folder = '';
437
+ }
438
+
439
  if( is_dir( ABSPATH . $f[$i] ) ) {
440
+ //$fi = $this->directoryToArray(ABSPATH . $f[$i], true );
441
+ $tmp_folder = $f[$i];
442
+ //$files = array_merge($files, $fi);
443
  } elseif (file_exists(ABSPATH . $f[$i])) {
444
  $files[$i] = ABSPATH . $f[$i];
445
  }
490
  $files = array_merge( $files, array( ABSPATH . 'wp-signup.php' ) );
491
  }
492
 
493
+ // check files in root directory
494
+ $n = count($files);
495
+ for($i = 0; $i < $n; $i++) {
496
+ if (!file_exists($files[$i])) {
497
+ unset($files[$i]);
498
+ }
499
+ }
500
+ $files = array_values($files);
501
+
502
  if (!empty($this->params['minus-path'])) {
503
  $minus_path = explode(",", $this->params['minus-path']);
504
  foreach($files as $k => $v) {
545
  $files = array_merge($files, $this->directoryToArray($folder, true));
546
  }
547
  }
548
+
549
+ $files = array_values( array_unique($files) );
550
+
551
  return $files;
552
  }
553
 
methods/class-wpadm-method-local-restore.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Class WPAdm_Method_Exec
4
  */
1
  <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+
6
  /**
7
  * Class WPAdm_Method_Exec
8
  */
methods/class-wpadm-method-ping.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  if (!class_exists('WPAdm_Method_Ping')) {
4
  class WPAdm_Method_Ping extends WPAdm_Method_Class {
5
  public function getResult()
@@ -9,7 +11,9 @@ if (!class_exists('WPAdm_Method_Ping')) {
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 = "";
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
  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 = "";
methods/class-wpadm-method-queue-controller.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
 
 
 
2
  /**
3
- * Выполнение очереди
4
  * Class WPAdm_Method_Exec
5
  */
6
  if (!class_exists('WPAdm_Method_Queue_Controller')) {
@@ -137,8 +139,7 @@ if (!class_exists('WPAdm_Method_Queue_Controller')) {
137
  // $pl = (defined('WPADM_PLUGIN')) ? WPADM_PLUGIN . '_' : '';
138
  $dp = explode(DIRECTORY_SEPARATOR,dirname(dirname(__FILE__)));
139
  $pl = array_pop($dp) . '_';
140
- // $data = 'wpadm_'.$pl.'request='.base64_encode(serialize($data));
141
- $data = $pl.'request='.base64_encode(serialize($data));
142
  fwrite($socket, "POST / HTTP/1.1\r\n");
143
  fwrite($socket, "Host: {$host}\r\n");
144
 
1
  <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
  /**
 
6
  * Class WPAdm_Method_Exec
7
  */
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
 
methods/class-wpadm-method-reconnect.php CHANGED
@@ -1,5 +1,8 @@
1
  <?php
2
 
 
 
 
3
  if (!class_exists('WPAdm_Method_Reconnect')) {
4
  class WPAdm_Method_Reconnect extends WPAdm_Method_Class {
5
  public function getResult()
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()
methods/class-wpadm-method-send-to-dropbox.php CHANGED
@@ -1,6 +1,10 @@
1
  <?php
 
 
 
 
 
2
  /**
3
- * Бэкап сайта
4
  * Class WPadm_Method_Send_To_Dropbox
5
  */
6
  if (!class_exists('WPadm_Method_Send_To_Dropbox')) {
@@ -123,9 +127,8 @@ if (!class_exists('WPadm_Method_Send_To_Dropbox')) {
123
  $this->result->setValue('counts', $params_data_cron['counts'] );
124
  if( (isset($this->params['is_local_backup']) && $this->params['is_local_backup'] == 0 ) || ( !isset($this->params['is_local_backup']) ) ) {
125
  $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
126
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
127
  if ($dropbox_options) {
128
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
129
  if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
130
  $backup_dir = $dropbox_options['backup_folder'];
131
  }
@@ -271,9 +274,8 @@ if (!class_exists('WPadm_Method_Send_To_Dropbox')) {
271
  if( (isset($this->params['is_local_backup']) && $this->params['is_local_backup'] == 0 ) || ( !isset($this->params['is_local_backup']) ) ) {
272
  if (isset($this->params['access_details']['dir'])) {
273
  $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
274
- $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
275
  if ($dropbox_options) {
276
- $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
277
  if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
278
  $backup_dir = $dropbox_options['backup_folder'];
279
  }
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')) {
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
  }
274
  if( (isset($this->params['is_local_backup']) && $this->params['is_local_backup'] == 0 ) || ( !isset($this->params['is_local_backup']) ) ) {
275
  if (isset($this->params['access_details']['dir'])) {
276
  $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
277
+ $dropbox_options = wpadm_wp_full_backup_dropbox::getSettings();
278
  if ($dropbox_options) {
 
279
  if (isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder'])) {
280
  $backup_dir = $dropbox_options['backup_folder'];
281
  }
methods/class-wpadm-method-update.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  if (!class_exists('WPAdm_Method_Update')) {
4
  class WPAdm_Method_Update extends WPAdm_Method_Class {
5
 
@@ -58,7 +60,6 @@ if (!class_exists('WPAdm_Method_Update')) {
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)) {
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
 
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)) {
modules/HttpFsockopen.php CHANGED
@@ -165,9 +165,6 @@ class HttpFsockopen {
165
  $http .= $this -> post . "\r\n\r\n";
166
  }
167
 
168
- // echo '<pre>' . $http . '</pre>';
169
- // file_put_contents(dirname(__FILE__) . '/http.log', $http . "\n\r\n\r", FILE_APPEND);
170
- // file_put_contents(dirname(__FILE__) . '/params.log', serialize($this) . "\n\r\n\r", FILE_APPEND);
171
  fwrite($socket, $http);
172
  while (!feof($socket)) {
173
  $contents .= fgetc($socket);
165
  $http .= $this -> post . "\r\n\r\n";
166
  }
167
 
 
 
 
168
  fwrite($socket, $http);
169
  while (!feof($socket)) {
170
  $contents .= fgetc($socket);
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,33 +500,34 @@ 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
 
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
  }
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
+ 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
  }
modules/class-wpadm-archive.php CHANGED
@@ -13,6 +13,7 @@ if (!class_exists('WPAdm_Archive')) {
13
  class WPAdm_Archive {
14
  private $remove_path = '';
15
  private $files = array();
 
16
  /**
17
  * @var PclZip
18
  */
@@ -20,8 +21,10 @@ if (!class_exists('WPAdm_Archive')) {
20
  private $md5_file = '';
21
  public $error = '';
22
 
 
23
  public function __construct($file, $md5_file = '') {
24
- $this->archive = new PclZip($file);
 
25
  $this->files[] = $file;
26
  $this->md5_file = $md5_file;
27
  }
@@ -32,8 +35,16 @@ if (!class_exists('WPAdm_Archive')) {
32
  }
33
  public function packed($file)
34
  {
35
- ini_set("memory_limit", "256M");
36
  if ( WPAdm_Running::is_stop() ) {
 
 
 
 
 
 
 
 
37
  if (empty($this->remove_path)) {
38
  if ( WPAdm_Running::is_stop() ) {
39
  $res = $this->archive->add($file);
@@ -45,6 +56,7 @@ if (!class_exists('WPAdm_Archive')) {
45
  }
46
  if ( WPAdm_Running::is_stop() ) {
47
  if ($res == 0) {
 
48
  WPAdm_Core::log( $this->archive->errorInfo(true) );
49
  if (file_exists($this->md5_file)) {
50
  unset($this->md5_file);
@@ -52,12 +64,28 @@ if (!class_exists('WPAdm_Archive')) {
52
  $this->error = $this->archive->errorInfo(true);
53
  return false;
54
  }
 
 
55
  $this->saveMd5($file);
56
  }
57
  }
58
  return true;
59
  }
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  protected function saveMd5($file) {
62
  if ($this->md5_file) {
63
  $files = explode(',', $file); {
@@ -71,5 +99,11 @@ if (!class_exists('WPAdm_Archive')) {
71
  public function setRemovePath($remove_path) {
72
  $this->remove_path = $remove_path;
73
  }
 
 
 
 
 
 
74
  }
75
  }
13
  class WPAdm_Archive {
14
  private $remove_path = '';
15
  private $files = array();
16
+ private $file_zip = '';
17
  /**
18
  * @var PclZip
19
  */
21
  private $md5_file = '';
22
  public $error = '';
23
 
24
+
25
  public function __construct($file, $md5_file = '') {
26
+ $this->file_zip = $file;
27
+ $this->archive = new PclZip($file);
28
  $this->files[] = $file;
29
  $this->md5_file = $md5_file;
30
  }
35
  }
36
  public function packed($file)
37
  {
38
+ @ini_set("memory_limit", "256M");
39
  if ( WPAdm_Running::is_stop() ) {
40
+ $files = explode(PCLZIP_SEPARATOR, $file);
41
+ $n = count($files);
42
+ $this->setToLogArhive( __('Add to archive: ', 'dropbox-backup') . $this->file_zip );
43
+ for($i = 0; $i < $n; $i++) {
44
+ $this->setToLogArhive(__("Add File: ", 'dropbox-backup' ) . $files[$i] . ' [' . WPADM_getSize( filesize($files[$i]) ) . ']' . '[' . wpadm_class::perm($files[$i]) . ']' );
45
+ }
46
+ WPAdm_Running::setCommandResultData('tmp_arhive_file2', $file);
47
+ WPAdm_Running::setCommandResultData('tmp_arhive_name2', $this->file_zip);
48
  if (empty($this->remove_path)) {
49
  if ( WPAdm_Running::is_stop() ) {
50
  $res = $this->archive->add($file);
56
  }
57
  if ( WPAdm_Running::is_stop() ) {
58
  if ($res == 0) {
59
+ $this->checkError($file);
60
  WPAdm_Core::log( $this->archive->errorInfo(true) );
61
  if (file_exists($this->md5_file)) {
62
  unset($this->md5_file);
64
  $this->error = $this->archive->errorInfo(true);
65
  return false;
66
  }
67
+ WPAdm_Running::setCommandResultData('tmp_arhive_file', $file);
68
+ WPAdm_Running::setCommandResultData('tmp_arhive_name', $this->file_zip);
69
  $this->saveMd5($file);
70
  }
71
  }
72
  return true;
73
  }
74
 
75
+ protected function checkError($file)
76
+ {
77
+ $count = WPAdm_Running::getCommandResultData('count_error_zip');
78
+ if ( empty($count) || $count == 0 ) {
79
+ if ( $this->archive->errorCode() == -10 ) { // Unable to find End of Central Dir Record signature
80
+ WPAdm_Core::rmdir($this->file_zip);
81
+ WPAdm_Running::getCommandResultData('count_error_zip_signature', 1);
82
+ $this->packed($file);
83
+ return true;
84
+ }
85
+ }
86
+ return false;
87
+ }
88
+
89
  protected function saveMd5($file) {
90
  if ($this->md5_file) {
91
  $files = explode(',', $file); {
99
  public function setRemovePath($remove_path) {
100
  $this->remove_path = $remove_path;
101
  }
102
+
103
+ public function setToLogArhive($msg)
104
+ {
105
+ $file_log = WPADM_Core::getTmpDir() . '/log-archive.log';
106
+ file_put_contents( $file_log, date("Y-m-d H:i:s") . "\t{$msg}\n", FILE_APPEND );
107
+ }
108
  }
109
  }
modules/class-wpadm-command-context.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
  if (!class_exists('WPAdm_Command_Context')) {
3
  class WPAdm_Command_Context {
4
  private $params = array();
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();
modules/class-wpadm-command-factory.php CHANGED
@@ -1,4 +1,9 @@
1
  <?php
 
 
 
 
 
2
  /**
3
  * Class WPAdm_Command_Factory
4
  */
1
  <?php
2
+
3
+
4
+ if ( ! defined( 'ABSPATH' ) ) exit;
5
+
6
+
7
  /**
8
  * Class WPAdm_Command_Factory
9
  */
modules/class-wpadm-command.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Class WPAdm_Сommand
4
  */
1
  <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+
6
  /**
7
  * Class WPAdm_Сommand
8
  */
modules/class-wpadm-core.php CHANGED
@@ -1,4 +1,7 @@
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';
@@ -30,6 +33,8 @@ if (!class_exists('WPAdm_Core')) {
30
  private $result;
31
 
32
  private $plugin;
 
 
33
 
34
  public $name = '',
35
  $time = '';
@@ -39,23 +44,31 @@ if (!class_exists('WPAdm_Core')) {
39
  public static $pl_dir;
40
 
41
  public static $error = '';
 
 
42
 
43
  public static $plugin_name;
44
 
45
  private static $cron_method = array('local_backup', 'send_to_dropbox');
46
 
47
 
48
- public function __construct(array $request, $plugin = '', $plugin_dir = '') {
49
  $this->result = new WPAdm_Result();
50
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
51
  $this->request = $request;
 
 
 
52
  $this->plugin = $plugin;
 
53
  self::$pl_dir = $plugin_dir;
54
  self::$plugin_name = $plugin;
55
  // auth request
56
- if (!$this->auth()) {
57
- return;
58
- }
 
 
59
  if ('connect' == $request['method']) {
60
  $this->connect();
61
  } elseif ('local' == $request['method']){
@@ -176,7 +189,7 @@ if (!class_exists('WPAdm_Core')) {
176
  }
177
 
178
  /*
179
- * Авторизация запроса
180
  */
181
  private function auth() {
182
  $this->pub_key = get_option('wpadm_pub_key');
@@ -205,7 +218,7 @@ if (!class_exists('WPAdm_Core')) {
205
 
206
  $sign = md5(serialize($this->request['params']));
207
  //openssl_public_decrypt($this->request['sign'], $request_sign, $this->pub_key);
208
- $ret = $this->verifySignature($this->request['sign'], $this->request['sign2'], $this->pub_key, $sign);
209
 
210
 
211
  //$ret = ($sign == $request_sign);
@@ -214,10 +227,10 @@ if (!class_exists('WPAdm_Core')) {
214
  }
215
  return $ret;
216
  }
217
-
218
-
219
  /**
220
- * Создаем папку
221
  * @param $dir
222
  */
223
  static public function mkdir($dir) {
@@ -245,13 +258,21 @@ if (!class_exists('WPAdm_Core')) {
245
  public function getResult() {
246
  return $this->result;
247
  }
 
 
 
 
 
 
 
 
248
 
249
 
250
  public function verifySignature($sign, $sign2, $pub_key, $text) {
251
- if (function_exists('openssl_public_decrypt')) {
252
  openssl_public_decrypt($sign, $request_sign, $pub_key);
253
  $ret = ($text == $request_sign);
254
- return $ret;
255
  } else {
256
  set_include_path(get_include_path() . PATH_SEPARATOR . self::getPluginDir() . '/modules/phpseclib');
257
  require_once 'Crypt/RSA.php';
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';
33
  private $result;
34
 
35
  private $plugin;
36
+
37
+ private $sign = false;
38
 
39
  public $name = '',
40
  $time = '';
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']){
189
  }
190
 
191
  /*
192
+ * auth request
193
  */
194
  private function auth() {
195
  $this->pub_key = get_option('wpadm_pub_key');
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);
227
  }
228
  return $ret;
229
  }
230
+
231
+
232
  /**
233
+ * create dir
234
  * @param $dir
235
  */
236
  static public function mkdir($dir) {
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';
modules/class-wpadm-method-class.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
 
4
  if (!class_exists('WPAdm_Method_Class')) {
5
  abstract class WPAdm_Method_Class {
1
  <?php
2
 
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
 
6
  if (!class_exists('WPAdm_Method_Class')) {
7
  abstract class WPAdm_Method_Class {
modules/class-wpadm-mysqldump.php CHANGED
@@ -1,4 +1,9 @@
1
  <?php
 
 
 
 
 
2
  if (!class_exists('WPAdm_Mysqldump')) {
3
  class WPAdm_Mysqldump {
4
 
1
  <?php
2
+
3
+
4
+ if ( ! defined( 'ABSPATH' ) ) exit;
5
+
6
+
7
  if (!class_exists('WPAdm_Mysqldump')) {
8
  class WPAdm_Mysqldump {
9
 
modules/class-wpadm-process.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
  /**
3
  * Class WPAdm_Сommand
4
  */
1
  <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
  /**
6
  * Class WPAdm_Сommand
7
  */
modules/class-wpadm-queue.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
  /**
3
  *
4
  * Class WPAdm_Queue
@@ -41,7 +44,7 @@ if (!class_exists('WPAdm_Queue')) {
41
  }
42
 
43
  public function add(WPAdm_Command_Context $context) {
44
- ini_set("memory_limit", "256M");
45
  $this->contexts[] = $context;
46
  return $this;
47
  }
@@ -76,40 +79,7 @@ if (!class_exists('WPAdm_Queue')) {
76
 
77
  );
78
 
79
- /* if (function_exists('fsockopen')) {
80
- $socket = @fsockopen($host, 80, $errno, $errstr, 30);
81
- $dp = explode(DIRECTORY_SEPARATOR, WPAdm_Core::$pl_dir );
82
- $pl = array_pop($dp) . '_';
83
- $data = $pl . 'request='.base64_encode(serialize($data));
84
- if (!$socket) {
85
- //WPAdm_Core::log( "$errstr ($errno) " , "socket");
86
- $curl = curl_init($url . "/");
87
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
88
- curl_setopt($curl, CURLOPT_POST, true);
89
- curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
90
- curl_setopt($curl, CURLOPT_TIMEOUT, 10);
91
- curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
92
-
93
- $res = curl_exec($curl);
94
- curl_close($curl);
95
- return $this->wait_result();
96
- }
97
-
98
- fwrite($socket, "POST {$path} HTTP/1.1\r\n");
99
- fwrite($socket, "Host: {$host}\r\n");
100
-
101
- fwrite($socket,"Content-type: application/x-www-form-urlencoded\r\n");
102
- fwrite($socket,"Content-length:".strlen($data)."\r\n");
103
- fwrite($socket,"Accept:* /*\r\n");
104
- fwrite($socket,"User-agent:" . $this->user_agent. "\r\n");
105
- fwrite($socket,"Connection:Close\r\n");
106
- fwrite($socket,"\r\n");
107
- fwrite($socket,"$data\r\n");
108
- fwrite($socket,"\r\n");
109
-
110
- @sleep(1);
111
- fclose($socket);
112
- } */
113
  $dp = explode(DIRECTORY_SEPARATOR, DRBBACKUP_BASE_DIR);
114
  $pl = array_pop($dp);
115
  $wpadm = new WPAdm_Core($data, $pl, DRBBACKUP_BASE_DIR);
@@ -150,7 +120,7 @@ if (!class_exists('WPAdm_Queue')) {
150
  }
151
 
152
  public function save() {
153
- ini_set("memory_limit", "256M");
154
  $this->deleteCommands();
155
  $file = WPAdm_Core::getTmpDir() . '/' . $this->id. '.queue';
156
  $txt = serialize(
1
  <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
  /**
6
  *
7
  * Class WPAdm_Queue
44
  }
45
 
46
  public function add(WPAdm_Command_Context $context) {
47
+
48
  $this->contexts[] = $context;
49
  return $this;
50
  }
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);
120
  }
121
 
122
  public function save() {
123
+
124
  $this->deleteCommands();
125
  $file = WPAdm_Core::getTmpDir() . '/' . $this->id. '.queue';
126
  $txt = serialize(
modules/class-wpadm-result.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
  if (!class_exists('WPAdm_Result')) {
3
  class WPAdm_Result {
4
  /*
1
  <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit;
4
+
5
  if (!class_exists('WPAdm_Result')) {
6
  class WPAdm_Result {
7
  /*
modules/class-wpadm-running.php CHANGED
@@ -1,17 +1,11 @@
1
  <?php
 
 
2
  /**
3
  * Class WPAdm_Running
4
  */
5
  if (!class_exists('WPAdm_Running')) {
6
 
7
- if (function_exists('set_time_limit')) {
8
- @set_time_limit(0);
9
- }
10
- if (function_exists('ini_set')) {
11
- @ini_set('memory_limit', '512M');
12
- }
13
-
14
-
15
  add_action('drb_run_backup', array('wpadm_running', 'init') );
16
 
17
  class WPAdm_Running {
@@ -45,6 +39,14 @@ if (!class_exists('WPAdm_Running')) {
45
  WPAdm_Core::rmdir($path . "/cron-restore.data");
46
  WPAdm_Core::rmdir($path . "/stop_process");
47
  WPAdm_Core::rmdir($path . "/folder_create");
 
 
 
 
 
 
 
 
48
 
49
  if ($method) {
50
  $files = glob($path ."/wpadm_method*.queue");
@@ -76,49 +78,52 @@ if (!class_exists('WPAdm_Running')) {
76
  {
77
  $command = self::getCommand();
78
 
79
- if ($command && self::is_stop() ) {
80
  WPAdm_Core::$cron = false;
81
  wpadm_class::$type = 'full';
82
 
83
- //$time_load = ini_get("max_execution_time");
84
- //WPAdm_Core::log('proccess is work ' . $time_load . 'sec');
85
- /*if ($time_load != 0) {
86
- self::run($time_load - 5);
87
- } else {
88
- self::run(90);
89
- } */
90
  self::run(60);
91
 
92
  if ( self::checkLock() ) {
93
- $core = new WPAdm_Core($command, 'full_backup_dropbox', DRBBACKUP_BASE_DIR);
94
- if (!is_bool( $core->getResult() ) && is_object( $core->getResult() ) && ( $result = $core->getResult()->toArray(true) ) ) {
95
- if ($result['result'] == 'success') {
96
- self::delCommand($command['method']);
97
- set_transient('drb_running', 0, 60 * 4);
98
- self::stop();
99
- self::setCommandResultData($command['method'], $result);
100
- self::init();
101
- } elseif ($result['result'] == 'error') {
102
- self::setCommandResultData($command['method'], $result);
103
- self::stop();
104
- self::init_params_default();
105
- self::createDebug( $result );
 
 
106
  }
107
  }
108
  }
109
  }
110
  }
111
-
112
- public static function createDebug( $result )
113
  {
114
- wpadm_class::error_log_check( print_r( $result, 1 ) );
115
  }
116
-
117
  public static function checkLock()
118
  {
119
  // false - cron is running
120
  // true - cron not running
121
  $running_cron = get_transient('drb_running');
 
 
 
 
122
  if ($running_cron && $running_cron == 1) {
123
  $time = microtime( true );
124
  $locked = get_transient('doing_cron');
@@ -150,7 +155,7 @@ if (!class_exists('WPAdm_Running')) {
150
  if ($time == 0) {
151
  set_transient('drb_running', 1, 60 * 60 * 24); // 24 hour
152
  } else {
153
- set_transient('drb_running', 1, $time + 60);
154
  }
155
  return true;
156
  }
@@ -168,14 +173,13 @@ if (!class_exists('WPAdm_Running')) {
168
  {
169
  $stop_precess = self::getCommandResultData('stop_process');
170
  if ( !empty( $stop_precess ) && isset( $stop_precess['name'] ) && isset( $stop_precess['type'] ) ) {
171
- $_POST['backup-name'] = $stop_precess['name'];
172
  if ($stop_precess['type'] == 'dropbox') {
173
- $_POST['backup-type'] = $stop_precess['type'];
174
- wpadm_wp_full_backup_dropbox::delete_backup();
175
- $_POST['backup-type'] = 'local';
176
  }
177
- wpadm_wp_full_backup_dropbox::delete_backup();
178
  }
 
179
  return empty($stop_precess);
180
  }
181
 
@@ -282,4 +286,4 @@ if (!class_exists('WPAdm_Running')) {
282
  return array();
283
  }
284
  }
285
- }
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 {
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
 
51
  if ($method) {
52
  $files = glob($path ."/wpadm_method*.queue");
78
  {
79
  $command = self::getCommand();
80
 
81
+ if ($command ) {
82
  WPAdm_Core::$cron = false;
83
  wpadm_class::$type = 'full';
84
 
85
+ if (function_exists('set_time_limit')) {
86
+ //@set_time_limit(0);
87
+ }
88
+
 
 
 
89
  self::run(60);
90
 
91
  if ( self::checkLock() ) {
92
+ if ( self::is_stop() ) {
93
+ $core = new WPAdm_Core($command, 'full_backup_dropbox', DRBBACKUP_BASE_DIR);
94
+ if (!is_bool( $core->getResult() ) && is_object( $core->getResult() ) && ( $result = $core->getResult()->toArray(true) ) ) {
95
+ if ($result['result'] == 'success') {
96
+ self::delCommand($command['method']);
97
+ set_transient('drb_running', 0, 60 * 4);
98
+ self::stop();
99
+ self::setCommandResultData($command['method'], $result);
100
+ self::init();
101
+ } elseif ($result['result'] == 'error') {
102
+ self::setCommandResultData($command['method'], $result);
103
+ self::stop();
104
+ self::init_params_default();
105
+ self::createDebug( $result, $command['method'] );
106
+ }
107
  }
108
  }
109
  }
110
  }
111
  }
112
+
113
+ public static function createDebug( $result, $type_backup = '' )
114
  {
115
+ wpadm_class::error_log_check( print_r( $result, 1 ), $type_backup );
116
  }
117
+
118
  public static function checkLock()
119
  {
120
  // false - cron is running
121
  // true - cron not running
122
  $running_cron = get_transient('drb_running');
123
+ $time_work = self::getCommandResultData('time_work');
124
+ if ( !empty($time_work) && ( $time_work + 45 ) > time() ) {
125
+ return false;
126
+ }
127
  if ($running_cron && $running_cron == 1) {
128
  $time = microtime( true );
129
  $locked = get_transient('doing_cron');
155
  if ($time == 0) {
156
  set_transient('drb_running', 1, 60 * 60 * 24); // 24 hour
157
  } else {
158
+ set_transient('drb_running', 1, $time + 30);
159
  }
160
  return true;
161
  }
173
  {
174
  $stop_precess = self::getCommandResultData('stop_process');
175
  if ( !empty( $stop_precess ) && isset( $stop_precess['name'] ) && isset( $stop_precess['type'] ) ) {
176
+ wpadm_wp_full_backup_dropbox::delete_backup('local', $stop_precess['name']);
177
  if ($stop_precess['type'] == 'dropbox') {
178
+ wpadm_wp_full_backup_dropbox::delete_backup('dropbox', $stop_precess['name']);
 
 
179
  }
180
+
181
  }
182
+ self::setCommandResultData('time_work', time());
183
  return empty($stop_precess);
184
  }
185
 
286
  return array();
287
  }
288
  }
289
+ }
modules/restore-class.php CHANGED
@@ -364,6 +364,89 @@ if ( !class_exists('dbr_helper') ) {
364
 
365
  private static $cron_is_work = 90;
366
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367
  public static function modSecureInstalled()
368
  {
369
  ob_start();
@@ -446,14 +529,24 @@ if ( !class_exists('dbr_helper') ) {
446
  }
447
  }
448
 
 
 
 
 
 
 
 
 
 
 
449
  public static function pack($data)
450
  {
451
- return base64_encode( serialize( $data ) );
452
  }
453
 
454
  public static function unpack($data)
455
  {
456
- return unserialize( base64_decode( $data ) );
457
  }
458
 
459
  public static function mkdir($path)
@@ -570,6 +663,8 @@ if ( !class_exists('dbr_core') ) {
570
  }
571
  }
572
 
 
 
573
  if ( !class_exists('dbr_methods') ) {
574
  class dbr_methods{
575
 
@@ -607,7 +702,7 @@ if ( !class_exists('dbr_methods') ) {
607
 
608
  $setting = dbr_database::db_get('options', array('option_value'), array('option_name' => 'wpadm_backup_dropbox-setting'), 1);
609
  if (isset($setting['option_value'] )) {
610
- $this->main = dbr_helper::unpack( $setting['option_value'] );
611
  }
612
 
613
  $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
@@ -887,7 +982,7 @@ if ( !class_exists('dbr_methods') ) {
887
  include "dropbox.class.php";
888
  $setting = dbr_database::db_get('options', array('option_value'), array('option_name' => 'wpadm_backup_dropbox-setting'), 1);
889
  if (isset($setting['option_value'] )) {
890
- $this->main = dbr_helper::unpack( $setting['option_value'] );
891
  }
892
  if (!empty($this->main)) {
893
  if (isset($this->main['app_key']) && isset($this->main['app_secret']) && isset($this->main['auth_token_secret'])) {
@@ -975,15 +1070,15 @@ if (!class_exists('dbr_route')) {
975
  function __construct()
976
  {
977
  if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
978
- if ( isset($_POST['key']) ) {
979
  $this->parsMethod();
980
- } elseif( !isset($_POST['key']) && isset($_POST['name']) ) {
981
 
982
  dbr_helper::clearTMP();
983
  dbr_database::inc_wp_config();
984
  $setting = dbr_database::db_get('options', array('option_value'), array('option_name' => 'wpadm_backup_dropbox-setting'), 1);
985
- if (isset($setting['option_value'] )) {
986
- $this->setting = dbr_helper::unpack( $setting['option_value'] );
987
  }
988
  $this->setting['restore-key'] = md5( time() . microtime() . __FILE__);
989
  include 'constant.php';
@@ -1022,12 +1117,14 @@ if (!class_exists('dbr_route')) {
1022
 
1023
  }
1024
  }
1025
- dbr_database::db_update('options', array('option_value' => dbr_helper::pack( $this->setting ) ), array('option_name' => 'wpadm_backup_dropbox-setting') ) ;
1026
- dbr_helper::setCommand('restore-backup', $_POST);
 
 
1027
  echo json_encode(array('result' => 'work'));
1028
  } catch(Exception $e) {
1029
  dbr_log::log($e->getMessage());
1030
- dbr_helper::setCommand('result-restore', array('name' => $_POST['name'], 'result' => 'error', 'message' => $e->getMessage() ) );
1031
  }
1032
  }
1033
  }
@@ -1044,17 +1141,17 @@ if (!class_exists('dbr_route')) {
1044
  dbr_database::inc_wp_config();
1045
  include 'constant.php';
1046
  $setting = dbr_database::db_get('options', array('option_value'), array('option_name' => 'wpadm_backup_dropbox-setting'), 1);
1047
- $this->setting = dbr_helper::unpack( $setting['option_value'] );
1048
  $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
1049
  if (isset($this->setting['backup_folder']) && !empty($this->setting['backup_folder'])) {
1050
  $backup_dir = $this->setting['backup_folder'];
1051
  }
1052
  if (file_exists($backup_dir . '/local-key')) {
1053
- $key_values = dbr_helper::unpack( @file_get_contents($backup_dir . '/local-key') );
1054
  }
1055
- if ($_POST['key'] == $this->setting['restore-key'] || ( isset($key_values['key']) && $_POST['key'] == $key_values['key'] ) ) {
1056
  $methods = new dbr_methods();
1057
- $method = $_POST['method']. '_method';
1058
  if (method_exists($methods, $method)) {
1059
  if ($_POST['method'] != 'wpadm_logs') {
1060
  if (file_exists(DBP_PATH_TMP . '/result-restore')) {
@@ -1152,4 +1249,4 @@ if (!class_exists('dbr_route')) {
1152
  }
1153
 
1154
  new dbr_route();
1155
- }
364
 
365
  private static $cron_is_work = 90;
366
 
367
+ public static function check_invalid_utf8( $string, $strip = false )
368
+ {
369
+ $string = (string) $string;
370
+
371
+ if ( 0 === strlen( $string ) ) {
372
+ return '';
373
+ }
374
+ // preg match invalid UTF8
375
+ if ( 1 === @preg_match( '/^./us', $string ) ) {
376
+ return $string;
377
+ }
378
+
379
+ if ( $strip && function_exists( 'iconv' ) ) {
380
+ return iconv( 'utf-8', 'utf-8', $string );
381
+ }
382
+
383
+ return '';
384
+ }
385
+
386
+
387
+ public static function strip_all_tags($string, $remove_breaks = false) {
388
+ $string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string );
389
+ $string = strip_tags($string);
390
+
391
+ if ( $remove_breaks )
392
+ $string = preg_replace('/[\r\n\t ]+/', ' ', $string);
393
+
394
+ return trim( $string );
395
+ }
396
+
397
+ public static function less_than( $text ) {
398
+ return preg_replace_callback('%<[^>]*?((?=<)|>|$)%', array('dbr_helper', 'less_than_callback'), $text);
399
+ }
400
+
401
+ public static function less_than_callback( $matches ) {
402
+ if ( false === strpos($matches[0], '>') )
403
+ return self::to_html($matches[0]);
404
+ return $matches[0];
405
+ }
406
+
407
+ public static function to_html($string, $quote_style = ENT_NOQUOTES)
408
+ {
409
+ $string = (string) $string;
410
+
411
+ if ( 0 === strlen( $string ) )
412
+ return '';
413
+
414
+ if ( ! preg_match( '/[&<>"\']/', $string ) )
415
+ return $string;
416
+
417
+ if ( empty( $quote_style ) )
418
+ $quote_style = ENT_NOQUOTES;
419
+ elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) )
420
+ $quote_style = ENT_QUOTES;
421
+
422
+ $charset = 'UTF-8';
423
+
424
+ $string = @htmlspecialchars( $string, $quote_style, $charset, $double_encode );
425
+
426
+ if ( 'single' === $_quote_style )
427
+ $string = str_replace( "'", '&#039;', $string );
428
+
429
+ return $string;
430
+ }
431
+
432
+ public static function sanitize($str, $is_newlines = false)
433
+ {
434
+ $filter = self::check_invalid_utf8( $str );
435
+ if ( strpos($filter, '<') !== false ) {
436
+ $filter = self::less_than( $filter );
437
+ $filter = self::strip_all_tags( $filter, false );
438
+ $filter = str_replace("<\n", "&lt;\n", $filter);
439
+ }
440
+
441
+ if ( !$is_newlines ) {
442
+ $filter = preg_replace( '/[\r\n\t ]+/', ' ', $filter );
443
+ }
444
+ $filter = trim( $filter );
445
+
446
+ return $filter;
447
+
448
+ }
449
+
450
  public static function modSecureInstalled()
451
  {
452
  ob_start();
529
  }
530
  }
531
 
532
+ public static function unpack_setting($str)
533
+ {
534
+ return unserialize( base64_decode( $str ) );
535
+ }
536
+
537
+ public static function pack_setting($str)
538
+ {
539
+ return base64_encode( serialize( $str ) );
540
+ }
541
+
542
  public static function pack($data)
543
  {
544
+ return base64_encode( json_encode( $data, JSON_HEX_QUOT|JSON_HEX_TAG|JSON_HEX_AMP|JSON_HEX_APOS ) );
545
  }
546
 
547
  public static function unpack($data)
548
  {
549
+ return json_decode( base64_decode( $data ), true );
550
  }
551
 
552
  public static function mkdir($path)
663
  }
664
  }
665
 
666
+
667
+
668
  if ( !class_exists('dbr_methods') ) {
669
  class dbr_methods{
670
 
702
 
703
  $setting = dbr_database::db_get('options', array('option_value'), array('option_name' => 'wpadm_backup_dropbox-setting'), 1);
704
  if (isset($setting['option_value'] )) {
705
+ $this->main = dbr_helper::unpack_setting( $setting['option_value'] );
706
  }
707
 
708
  $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
982
  include "dropbox.class.php";
983
  $setting = dbr_database::db_get('options', array('option_value'), array('option_name' => 'wpadm_backup_dropbox-setting'), 1);
984
  if (isset($setting['option_value'] )) {
985
+ $this->main = dbr_helper::unpack_setting( $setting['option_value'] );
986
  }
987
  if (!empty($this->main)) {
988
  if (isset($this->main['app_key']) && isset($this->main['app_secret']) && isset($this->main['auth_token_secret'])) {
1070
  function __construct()
1071
  {
1072
  if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
1073
+ if ( !isset($_POST['name']) ) {
1074
  $this->parsMethod();
1075
+ } elseif( isset($_POST['name']) ) {
1076
 
1077
  dbr_helper::clearTMP();
1078
  dbr_database::inc_wp_config();
1079
  $setting = dbr_database::db_get('options', array('option_value'), array('option_name' => 'wpadm_backup_dropbox-setting'), 1);
1080
+ if (isset($setting['option_value'])) {
1081
+ $this->setting = dbr_helper::unpack_setting( $setting['option_value'] );
1082
  }
1083
  $this->setting['restore-key'] = md5( time() . microtime() . __FILE__);
1084
  include 'constant.php';
1117
 
1118
  }
1119
  }
1120
+ if ( isset($setting['option_value']) ) {
1121
+ dbr_database::db_update('options', array('option_value' => dbr_helper::pack_setting( $this->setting ) ), array('option_name' => 'wpadm_backup_dropbox-setting') ) ;
1122
+ }
1123
+ dbr_helper::setCommand('restore-backup', array('name' => dbr_helper::sanitize( @$_POST['name'] ), 'action' => dbr_helper::sanitize( @$_POST['action'] ), 'key' => dbr_helper::sanitize( @$_POST['key'] ) ) ); // verify and sanitize post data
1124
  echo json_encode(array('result' => 'work'));
1125
  } catch(Exception $e) {
1126
  dbr_log::log($e->getMessage());
1127
+ dbr_helper::setCommand('result-restore', array('name' => dbr_helper::sanitize( $_POST['name'] ), 'result' => 'error', 'message' => $e->getMessage() ) ); // verify and sanitize post data
1128
  }
1129
  }
1130
  }
1141
  dbr_database::inc_wp_config();
1142
  include 'constant.php';
1143
  $setting = dbr_database::db_get('options', array('option_value'), array('option_name' => 'wpadm_backup_dropbox-setting'), 1);
1144
+ $this->setting = dbr_helper::unpack_setting( $setting['option_value'] );
1145
  $backup_dir = DROPBOX_BACKUP_DIR_BACKUP;
1146
  if (isset($this->setting['backup_folder']) && !empty($this->setting['backup_folder'])) {
1147
  $backup_dir = $this->setting['backup_folder'];
1148
  }
1149
  if (file_exists($backup_dir . '/local-key')) {
1150
+ $key_values = dbr_helper::unpack_setting( @file_get_contents($backup_dir . '/local-key') );
1151
  }
1152
+ if ($_POST['key'] == @$this->setting['restore-key'] || ( isset($key_values['key']) && $_POST['key'] == $key_values['key'] ) ) {
1153
  $methods = new dbr_methods();
1154
+ $method = dbr_helper::sanitize( $_POST['method'] ) . '_method';
1155
  if (method_exists($methods, $method)) {
1156
  if ($_POST['method'] != 'wpadm_logs') {
1157
  if (file_exists(DBP_PATH_TMP . '/result-restore')) {
1249
  }
1250
 
1251
  new dbr_route();
1252
+ }
readme.txt CHANGED
@@ -1,6 +1,6 @@
1
  === Backup & Restore Dropbox ===
2
  Plugin Name: Backup & Restore Dropbox
3
- Version: 1.4.7.5
4
  Donate link: http://www.wpadm.com/donate
5
  URI: http://www.wpadm.com/dropbox-backup
6
  Tags: dropbox, backup, dropbox backup, database, file, full backup, manage, sicherung, database backup, file backup, page backup, page, web, web backup, web page, synchronize, clone, duplicate, move, web page backup, site, site backup, back up, cloud, Cloud Files, cloud backup, db backup, dump, german, migrate, multisite, German, schedule, storage, time, upload, data bank, zip, archive, backups, restore, db, recover, recovery, restoration, wp backup, wordpress backup, wordpress backup to dropbox, plugin wordpress backup, wpadm, wpadm.com, website, website backup, website back up, wp backup, wordpress backup, scheduled backup, backup scheduler, tool, backup tool
1
  === Backup & Restore Dropbox ===
2
  Plugin Name: Backup & Restore Dropbox
3
+ Version: 1.4.8.4
4
  Donate link: http://www.wpadm.com/donate
5
  URI: http://www.wpadm.com/dropbox-backup
6
  Tags: dropbox, backup, dropbox backup, database, file, full backup, manage, sicherung, database backup, file backup, page backup, page, web, web backup, web page, synchronize, clone, duplicate, move, web page backup, site, site backup, back up, cloud, Cloud Files, cloud backup, db backup, dump, german, migrate, multisite, German, schedule, storage, time, upload, data bank, zip, archive, backups, restore, db, recover, recovery, restoration, wp backup, wordpress backup, wordpress backup to dropbox, plugin wordpress backup, wpadm, wpadm.com, website, website backup, website back up, wp backup, wordpress backup, scheduled backup, backup scheduler, tool, backup tool
template/advantage-plugin.php CHANGED
@@ -1,59 +1,113 @@
1
- <div class="inline" style="width: 60%">
2
- <span style="font-size:16px;">
3
- <?php _e('Use Professional version of "Dropbox backup and restore" plugin and get:','dropbox-backup') ; ?>
4
- </span>
5
- <ul class="list-dropbox-backup-pro">
6
- <li><img src="<?php echo plugins_url('/template/ok-icon.png', dirname(__FILE__));?>" title="" alt="" />
7
- <span class="text">
8
- <?php _e('Automated Dropbox backup (Scheduled backup tasks)','dropbox-backup') ; ?>
9
- </span>
 
 
 
 
 
 
 
 
 
10
  </li>
11
  <li>
12
- <img src="<?php echo plugins_url('/template/ok-icon.png', dirname(__FILE__));?>" title="" alt="" />
13
- <span class="text">
14
- <?php _e('Automated Local backup (Scheduled backup tasks)','dropbox-backup') ; ?>
15
- </span>
 
 
 
 
 
 
16
  </li>
17
  <li>
18
- <img src="<?php echo plugins_url('/template/ok-icon.png', dirname(__FILE__));?>" title="" alt="" />
19
- <span class="text">
20
- <?php _e('Backup Status E-Mail Reporting','dropbox-backup') ; ?>
21
- </span>
 
 
 
 
22
  </li>
23
  <li>
24
- <img src="<?php echo plugins_url('/template/ok-icon.png', dirname(__FILE__));?>" title="" alt="" />
25
- <span class="text">
26
- <?php _e('Online Service "Backup Website Manager" (Copy, Clone or Migrate of websites)','dropbox-backup') ; ?>
27
- </span>
 
 
 
 
 
28
  </li>
29
  <li>
30
- <img src="<?php echo plugins_url('/template/ok-icon.png', dirname(__FILE__));?>" title="" alt="" />
31
- <span class="text">
32
- <?php _e('One Year Free Updates for PRO version','dropbox-backup') ; ?>
33
- </span>
 
 
 
 
34
  </li>
35
  <li>
36
- <img src="<?php echo plugins_url('/template/ok-icon.png', dirname(__FILE__));?>" title="" alt="" />
37
- <span class="text">
38
- <?php _e('One Year Priority support','dropbox-backup') ; ?>
39
- </span>
 
 
 
 
40
  </li>
41
  </ul>
42
  </div>
43
- <div class="inline-right" style="margin-top: 0;">
44
- <div class="image-dropbox-pro" onclick="document.dropbox_pro_form.submit();">
45
- <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'); ?>">
46
- </div>
47
- <div style="margin-top:26%; float: left; margin-left: 20px; margin-right: 15px;">
48
- <form action="<?php echo WPADM_URL_PRO_VERSION; ?>api/" method="post" id="dropbox_pro_form" name="dropbox_pro_form" >
49
- <input type="hidden" value="<?php echo home_url();?>" name="site">
50
- <input type="hidden" value="<?php echo 'proBackupPay'?>" name="actApi">
51
- <input type="hidden" value="<?php echo get_option('admin_email');?>" name="email">
52
- <input type="hidden" value="<?php echo 'dropbox-backup';?>" name="plugin">
53
- <input type="hidden" value="<?php echo admin_url("admin.php?page=wpadm_wp_full_backup_dropbox&pay=success"); ?>" name="success_url">
54
- <input type="hidden" value="<?php echo admin_url("admin.php?page=wpadm_wp_full_backup_dropbox&pay=cancel"); ?>" name="cancel_url">
55
- <input type="submit" class="backup_button" value="<?php _e('Get PRO','dropbox-backup');?>">
56
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  </div>
58
  </div>
59
 
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
+ .block-pay {
83
+ margin-top: 26%;
84
+ float: left;
85
+ margin-left: 20px;
86
+ margin-right: 15px;
87
+ }
88
+ .block-pay.repeat_advantage {
89
+ margin-top: 50%;
90
+ }
91
+
92
+
93
+ </style>
94
+ <div class="block-pay <?php echo (!isset($repeat_advantage) ? '' : 'repeat_advantage' ); ?>" style="">
95
+ <?php if (!isset($repeat_advantage)) {?>
96
+ <form action="<?php echo esc_url( WPADM_URL_PRO_VERSION ); ?>api/" method="post" id="dropbox_pro_form" name="dropbox_pro_form" >
97
+
98
+ <input type="hidden" value="<?php echo home_url();?>" name="site">
99
+ <input type="hidden" value="<?php echo 'proBackupPay'?>" name="actApi">
100
+ <input type="hidden" value="<?php echo get_option('admin_email');?>" name="email">
101
+ <input type="hidden" value="<?php echo 'dropbox-backup';?>" name="plugin">
102
+ <input type="hidden" value="<?php echo admin_url("admin.php?page=wpadm_wp_full_backup_dropbox&pay=success"); ?>" name="success_url">
103
+ <input type="hidden" value="<?php echo admin_url("admin.php?page=wpadm_wp_full_backup_dropbox&pay=cancel"); ?>" name="cancel_url">
104
+ <input type="submit" class="backup_button" value="<?php _e('Get PRO','dropbox-backup');?>">
105
+ </form>
106
+ <?php } else {
107
+ ?>
108
+ <input type="button" class="backup_button" onclick="document.dropbox_pro_form.submit();" value="<?php _e('Get PRO','dropbox-backup');?>">
109
+ <?php
110
+ }?>
111
  </div>
112
  </div>
113
 
template/css/admin-style-wpadm.css CHANGED
@@ -1,4 +1,27 @@
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  #wp-cron-enable {
3
  position: relative;
4
  }
@@ -918,6 +941,22 @@ text-align: center; margin-top: 10px;
918
  float:none;
919
  margin-left: 0px;
920
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
921
  }
922
 
923
  /*default style */
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
  }
941
  float:none;
942
  margin-left: 0px;
943
  }
944
+
945
+
946
+ .block-pay.repeat_advantage {
947
+ margin-top: 10px;
948
+ width: 90%;
949
+ text-align: center;
950
+ }
951
+ .inline.repeat_advantage {
952
+ float:none;
953
+ }
954
+ .block-advantage {
955
+ width:100%;
956
+ }
957
+ .inline-right {
958
+ float:left;
959
+ }
960
  }
961
 
962
  /*default style */
template/css/tool-bar.css CHANGED
@@ -3,18 +3,27 @@
3
  /*background-image: ;*/
4
  }
5
 
 
 
 
 
6
  .list-dropbox-backup-pro {
7
  margin-top:10px;
8
  margin-bottom:0;
 
9
  }
10
  .list-dropbox-backup-pro li {
11
  margin-bottom: 0;
12
  font-size:14px;
 
13
  margin-left:35px;
14
  }
15
  .list-dropbox-backup-pro .text {
16
  line-height: 25px;
17
  }
 
 
 
18
  .image-dropbox-pro {
19
  width: 183px;
20
  height: 187px;
@@ -79,4 +88,13 @@ button.backup_button:disabled, button.backup_button:disabled:hover {
79
  .inline-right, .inline {
80
  margin-top:10px;
81
  margin-left:10px;
 
 
 
 
 
 
 
 
 
82
  }
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;
88
  .inline-right, .inline {
89
  margin-top:10px;
90
  margin-left:10px;
91
+ }
92
+ @media only screen and (max-width: 1345px) {
93
+
94
+ .block-advantage {
95
+ width:100%;
96
+ }
97
+ .inline-right {
98
+ float:left;
99
+ }
100
  }
template/expsys.php CHANGED
@@ -1,3 +1,4 @@
 
1
  <?php
2
  $str = '';
3
  foreach($data['sys'] as $key => $value) {
@@ -30,10 +31,10 @@
30
  </script>
31
  <div class="functions-view">
32
  <div class="title-functions-view" onclick="showView();">
33
- <?php echo $str; ?>
34
  </div>
35
  <div class="body-functions-view">
36
- <?php echo $functions_need; ?>
37
  </div>
38
  </div>
39
  <?php
1
+ <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2
  <?php
3
  $str = '';
4
  foreach($data['sys'] as $key => $value) {
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 ADDED
Binary file
template/js/admin-wpadm.js CHANGED
@@ -10,6 +10,24 @@ function textReplace(text, addStr)
10
  {
11
  return text.replace(/([\w])(\'|’)([\w])/gm, "$1$3") + addStr;
12
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  var shows_id = ""
15
  var shows_t = ""
@@ -94,9 +112,15 @@ function connectFolder(t)
94
  }
95
  id = jQuery(divs[i]).attr('data-value');
96
  if (set) {
 
97
  if (t.checked) {
98
- jQuery("#send-to-" + id).attr('checked', true);
 
99
  } else {
 
 
 
 
100
  jQuery("#send-to-" + id).attr('checked', false);
101
  }
102
  }
@@ -106,9 +130,15 @@ function connectFolder(t)
106
  if (jQuery("#include_" + t_id).length > 0) {
107
  checkboxes = jQuery("#include_" + t_id).find('.checkbox-send');
108
  for(i = 0; i < checkboxes.length; i++) {
 
109
  if (t.checked) {
110
  jQuery(checkboxes[i]).attr('checked', true);
 
111
  } else {
 
 
 
 
112
  jQuery(checkboxes[i]).attr('checked', false);
113
  }
114
  }
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 = ""
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
  }
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
  }
template/notice.php CHANGED
@@ -1,3 +1,4 @@
 
1
  <div class="clear"></div>
2
  <div class="update-nag" style="width: 95%;">
3
  <?php _e('Professional version of','dropbox-backup'); ?>
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'); ?>
template/notice5.php CHANGED
@@ -1,3 +1,4 @@
 
1
  <div class="clear"></div>
2
  <div class="updated notice" style="width: 95%;">
3
  <p>
1
+ <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2
  <div class="clear"></div>
3
  <div class="updated notice" style="width: 95%;">
4
  <p>
template/wpadm_show_backup.php CHANGED
@@ -1,3 +1,4 @@
 
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' />
@@ -74,15 +75,22 @@
74
  jQuery('#registr-show').html("<?php _e('Hide','dropbox-backup'); ?>");
75
  jQuery('#title-regisr').css("padding" , "0px 0px");
76
  jQuery('#registr-choice-icon').removeClass("dashicons-arrow-down").addClass('dashicons-arrow-up');
 
77
  } else {
78
  if (show) {
79
  jQuery('#cf_activate').hide('slow');
80
  jQuery('#registr-show').html("<?php _e('Show','dropbox-backup'); ?>");
81
- jQuery('#title-regisr').css("padding" , "20px 0px");
82
  jQuery('#registr-choice-icon').removeClass("dashicons-arrow-up").addClass('dashicons-arrow-down');
 
83
  }
84
  }
85
  }
 
 
 
 
 
86
  function showSetting(show)
87
  {
88
  display = jQuery('#setting_active').css('display');
@@ -93,10 +101,19 @@
93
  jQuery('#setting-choice-icon').removeClass("dashicons-arrow-down").addClass('dashicons-arrow-up');
94
  } else {
95
  if (show) {
 
 
 
 
 
 
 
 
96
  jQuery('#setting_active').hide('slow');
97
  jQuery('#setting-show').html("<?php _e('Show','dropbox-backup'); ?>");
98
  jQuery('#title-setting').css("padding" , "20px 0px");
99
  jQuery('#setting-choice-icon').removeClass("dashicons-arrow-up").addClass('dashicons-arrow-down');
 
100
  }
101
  }
102
  }
@@ -106,6 +123,7 @@
106
  d = new Date();
107
  var data_backup = {
108
  'action': 'wpadm_local_backup',
 
109
  'time': Math.ceil( (d.getTime() + (-d.getTimezoneOffset() * 60000 ) ) / 1000 )
110
  };
111
  jQuery("#logs-form").show("slow");
@@ -193,6 +211,7 @@
193
 
194
  var data_backup = {
195
  'action': 'wpadm_dropbox_create',
 
196
  'time': Math.ceil( (d.getTime() + (-d.getTimezoneOffset() * 60000 ) ) / 1000 ),
197
  };
198
  jQuery("#logs-form").show("slow");
@@ -386,6 +405,7 @@
386
  }
387
  var data_log = {
388
  'action': 'wpadm_logs',
 
389
  'type-backup' : method,
390
  };
391
  if (method == 'send-to-dropbox') {
@@ -395,7 +415,7 @@
395
  var url_ajax = ajaxurl;
396
  if (method == 'restore') {
397
  url_ajax = '<?php echo plugins_url('/modules/restore-class.php', dirname(__FILE__) ); ?>';
398
- data_log['key'] = '<?php echo $key; ?>';
399
  data_log['method'] = 'wpadm_logs';
400
  }
401
  jQuery.ajax({
@@ -521,6 +541,8 @@
521
  }
522
  var data_backup = {
523
  'action': act,
 
 
524
  'name': name,
525
  };
526
  jQuery("#log-backup").html('');
@@ -602,11 +624,10 @@
602
  }
603
  }
604
  if(send) {
605
- form.find('#message-form').css('display', 'none');
606
  data['password'] = document.auth.password.value;
607
  data['username'] = document.auth.username.value;
608
  data['plugin'] = document.auth.plugin.value;
609
- backup = jQuery("#name_backup_restore").val();
610
  jQuery.ajax({
611
  url: form.attr('action'),
612
  data: data,
@@ -850,7 +871,7 @@
850
  function saveSetting(id)
851
  {
852
  if (jQuery('#' + id).length > 0) {
853
- if ( jQuery('#' + id).is('select') || jQuery('#' + id).is( ":text" ) ) {
854
  is_value = jQuery('#' + id).val();
855
  } else {
856
  is_value = 0;
@@ -922,7 +943,7 @@
922
  <?php
923
  $command_running = get_transient('running_command');
924
  if (isset($is_runnig) && $is_runnig && $command_running ) {
925
- if (file_exists(WPAdm_Core::getTmpDir() . "/logs2")) {
926
  @unlink(WPAdm_Core::getTmpDir() . "/logs2");
927
  }
928
  ?>
@@ -938,7 +959,7 @@
938
  jQuery("#log-backup").html('');
939
  jQuery(".title-logs").css('display', 'block');
940
  jQuery(".title-status").css('display', 'none');
941
- type_backup = '<?php echo $command_running; ?>';
942
 
943
  setTimeout(function() {
944
  disable_buttons() ;
@@ -967,7 +988,7 @@
967
  ' . $msg . '
968
  </p></div>';
969
  }?>
970
-
971
  <div id="wp-cron-enable" style="display: none;">
972
  <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>
973
  <div class="image-enable">
@@ -1003,7 +1024,7 @@
1003
  </script>
1004
  <div id="sent-error-report" style="display: none;" >
1005
  <div class="text-view">
1006
- <?php echo $sent_response ;?>
1007
  </div>
1008
  <div class="button-sent-report">
1009
  <input type="button" class="button-wpadm" value="<?php _e('OK','dropbox-backup'); ?>" onclick="jQuery('#sent-error-report').arcticmodal('close')" />
@@ -1027,7 +1048,7 @@
1027
  <label for="ftp-host"><?php _e('FTP Host','dropbox-backup'); ?></label>
1028
  </div>
1029
  <div style="float:left; ">
1030
- <input type="text" id="ftp-host" value="<?php echo str_ireplace(array('http://', 'https://'), '', home_url()) ;?>" name="ftp_host" >
1031
  </div>
1032
  </div>
1033
  <div class="clear"></div>
@@ -1057,14 +1078,14 @@
1057
  <label for="email-resp"><?php _e('Response Email:','dropbox-backup'); ?></label>
1058
  </div>
1059
  <div style=" ">
1060
- <input type="text" id="email-resp" value="<?php echo get_option('admin_email');?>" style="padding-left:3px;" name="mail_response">
1061
  </div>
1062
  </div>
1063
  </div>
1064
  </div>
1065
  <div class="clear"></div>
1066
  <div style="text-align: left; margin-left: 100px; margin-top: 10px;">
1067
- <input value="<?php echo $time_log; ?>" type="hidden" name="time_pars">
1068
  <input value="" type="hidden" name="msg_ajax" id="msg_ajax">
1069
  </div>
1070
  <div class="ajax-button" style="margin-bottom: 10px;">
@@ -1100,66 +1121,77 @@
1100
  <span style="font-size: 20px;"><?php _e('(files+database)','dropbox-backup');?></span>
1101
 
1102
  <span style="font-size: 11px;">
1103
- <?php echo (isset($plugin_data[0]['Version']) ? 'Version ' . $plugin_data[0]['Version'] : '')?>
1104
  </span>
1105
 
1106
  </div>
1107
  <?php if ($show) {?>
1108
- <div id="container-user" class="cfTabsContainer" style="width: 48%; padding-bottom: 0px; padding-top: 0px; float: left; margin-left: 20px;">
1109
- <div class="stat-wpadm-info-title" id="title-regisr" style="padding :20px 0px; margin-top:11px; line-height: 25px;">
1110
- <?php _e('Free Sign Up','dropbox-backup'); ?> <br /><?php _e('to backup more than one website...','dropbox-backup'); ?>
 
 
 
 
1111
  </div>
1112
  <div id="cf_activate" class="cfContentContainer" style="display: none;">
1113
- <form method="post" id="dropbox_form" action="<?php echo admin_url( 'admin-post.php?action=wpadm_activate_plugin' )?>" >
1114
- <div class="stat-wpadm-registr-info" style="margin-bottom: 40px; margin-top: 17px;">
1115
- <table class="form-table stat-table-registr" style="">
1116
- <tbody>
1117
- <tr valign="top">
1118
- <th scope="row">
1119
- <label for="email"><?php _e('E-mail','dropbox-backup'); ?></label>
1120
- </th>
1121
- <td>
1122
- <input id="email" class="" type="text" name="email" value="">
1123
- </td>
1124
- </tr>
1125
- <tr valign="top">
1126
- <th scope="row">
1127
- <label for="password"><?php _e('Password','dropbox-backup'); ?></label>
1128
- </th>
1129
- <td>
1130
- <input id="password" class="" type="password" name="password" value="">
1131
- </td>
1132
- </tr>
1133
- <tr valign="top">
1134
- <th scope="row">
1135
- <label for="password-confirm"><?php _e('Password confirm','dropbox-backup'); ?></label>
1136
- </th>
1137
- <td>
1138
- <input id="password-confirm" class="" type="password" name="password-confirm" value="">
1139
- </td>
1140
- </tr>
1141
- <tr valign="top">
1142
- <th scope="row">
1143
- </th>
1144
- <td>
1145
- <input class="button-wpadm" type="submit" value="<?php _e('Register & Activate','dropbox-backup'); ?>" name="send">
1146
- </td>
1147
- </tr>
1148
- </tbody>
1149
- </table>
1150
- </div>
1151
- <div class="stat-wpadm-info" id="registr-info" style="margin-bottom: 2px; margin-top: 30px;">
1152
- <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 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 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'); ?>
1153
- </div>
1154
- </form>
 
 
 
 
 
 
1155
  </div>
1156
  <div class="clear"></div>
1157
  <div class="block-button-show" style="color: #fff;">
1158
- <div class="block-click" onclick="showRegistInfo(true);">
1159
  <span id="registr-show" style="color: #fff;"><?php _e('Show','dropbox-backup'); ?></span>
1160
  <div id="registr-choice-icon" class="dashicons dashicons-arrow-down" style=""></div>
1161
  </div>
1162
  </div>
 
1163
  </div>
1164
  <?php } else { ?>
1165
  <div id="container-user" class="cfTabsContainer" style="width: 48%; padding-bottom: 0px; padding-top: 0px; float: left; margin-left: 20px;">
@@ -1167,13 +1199,13 @@
1167
  <?php _e('Sign In to backup more than one website...','dropbox-backup'); ?>
1168
  </div>
1169
  <div>
1170
- <form method="post" id="auth" name="auth" action="<?php echo SERVER_URL_INDEX . "login-process" ; ?>">
1171
  <div>
1172
  <div id="message-form" style="color: red; float: left;margin: 10px;margin-top: 14px;"></div>
1173
  </div>
1174
  <div style="padding: 5px; clear: both;">
1175
  <div class="form-field">
1176
- <input class="input-small" type="text" id="username" value="<?php echo get_option(PREFIX_BACKUP_ . "email");?>" readonly="readonly" required="required" name="username" placeholder="<?php _e('Email','dropbox-backup'); ?>" />
1177
  </div>
1178
  <div class="form-field">
1179
  <input class="input-small" type="password" required="required" name="password" placeholder="<?php _e('Password','dropbox-backup'); ?>" />
@@ -1198,11 +1230,11 @@
1198
  <?php _e('Settings','dropbox-backup'); ?>
1199
  </div>
1200
  <div id="setting_active" class="cfContentContainer" style="display: none;">
1201
- <form method="post" action="" >
1202
  <div class="stat-wpadm-registr-info" style="width: 100%; margin-bottom: 9px;">
1203
  <div style="margin-bottom: 12px; margin-top: 20px; font-size: 15px; text-align: center;">
1204
  <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">
1205
- <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 " . $dropbox_options['uid'] : ''; ?></span></div>
1206
  </div>
1207
  <?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 ; ?>
1208
  <div class="setting-checkbox">
@@ -1216,7 +1248,7 @@
1216
  <label for="app_key"><?php _e('App key','dropbox-backup'); ?>*</label>
1217
  </th>
1218
  <td>
1219
- <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'] : ''?>">
1220
  </td>
1221
  </tr>
1222
  <tr valign="top" id="dropbox-app-secret" style="display: <?php echo $show_fields ? 'table-row' : 'none'?>;">
@@ -1224,7 +1256,7 @@
1224
  <label for="app_secret"><?php _e('App secret','dropbox-backup'); ?>*</label>
1225
  </th>
1226
  <td>
1227
- <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'] : ''?>">
1228
  </td>
1229
  </tr>
1230
 
@@ -1241,7 +1273,7 @@
1241
  <label for="time_error" style="font-size: 13px;"><?php _e('Waiting time (minutes)', 'dropbox-backup'); ?></label>
1242
  <select name="time_error" id="time_error" onchange="saveSetting('time_error')">
1243
  <?php
1244
- for($i = 1; $i < 11; $i++) {
1245
  ?>
1246
  <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>
1247
  <?php
@@ -1253,24 +1285,24 @@
1253
  </div>
1254
  <?php if ( is_super_admin() ) { ?>
1255
  <div class="setting-checkbox">
1256
- <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('is_admin')" />
1257
  <label for="is_admin" style="font-size: 13px;"><?php _e('Appear in menu for admins only','dropbox-backup'); ?></label>
1258
  </div>
1259
  <?php } ?>
1260
  <div class="setting-checkbox">
1261
- <input type="checkbox" <?php echo (isset($dropbox_options['is_optimization']) && $dropbox_options['is_optimization'] == 1) || (!isset($dropbox_options['is_optimization'])) ? 'checked="checked"' : ''; ?> name="is_optimization" value="1" id="is_optimization" onclick="saveSetting('is_optimization')" />
1262
  <label for="is_optimization" style="font-size: 13px;"><?php _e('Database Optimization','dropbox-backup'); ?></label>
1263
  </div>
1264
  <div class="setting-checkbox">
1265
- <input type="checkbox" <?php echo (isset($dropbox_options['is_local_backup_delete']) && $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')" />
1266
  <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>
1267
  </div>
1268
  <div class="setting-checkbox">
1269
- <input type="checkbox" <?php echo (isset($dropbox_options['is_repair']) && $dropbox_options['is_repair'] == 1) ? 'checked="checked"' : ''; ?> name="is_repair" value="1" id="is_repair" onclick="saveSetting('is_repair')" />
1270
  <label for="is_repair" style="font-size: 13px;"><?php _e('Try database repair','dropbox-backup'); ?></label>
1271
  </div>
1272
  <div class="setting-checkbox">
1273
- <input type="checkbox" <?php echo (isset($dropbox_options['is_show_admin_bar']) && $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')" />
1274
  <label for="is_show_admin_bar" style="font-size: 13px;"><?php _e('Show in a admin bar','dropbox-backup'); ?></label>
1275
  </div>
1276
  <div class="setting-checkbox">
@@ -1279,13 +1311,24 @@
1279
  </div>
1280
  <div style="border-bottom:1px solid #fff; margin:10px 0px;"></div>
1281
  <div class="setting-checkbox">
1282
- <input type="text" style="width: 90%;" name="backup_folder" value="<?php echo ( isset($dropbox_options['backup_folder']) && !empty($dropbox_options['backup_folder']) ) ? $dropbox_options['backup_folder'] : DROPBOX_BACKUP_DIR_BACKUP; ?>" id="backup_folder" onclick="" />
1283
- <label for="backup_folder" style="font-size: 13px;"><?php _e('Backup folder location','dropbox-backup'); ?></label>
 
 
 
 
 
1284
  </div>
1285
- <div class="setting-checkbox" style="text-align: center;">
1286
- <input class="btn-orange" type="button" value="<?php echo _e('Save', 'dropbox-backup'); ?>" onclick="saveSetting('backup_folder');">
1287
  </div>
1288
-
 
 
 
 
 
 
1289
  </div>
1290
  </form>
1291
  </div>
@@ -1372,7 +1415,7 @@
1372
  </div>
1373
  </div>
1374
  <div id="support-button" style="float: right; margin-top: 130px; margin-right: 20px;">
1375
- <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 _e('Help','dropbox-backup'); ?></button> <br />
1376
  </div>
1377
  <div id="action-buttons" style="">
1378
  <div style="float: left;">
@@ -1392,19 +1435,21 @@
1392
  </div>
1393
  <div style="clear: both; margin-bottom: 10px;"></div>
1394
  <div>
1395
- <form action="<?php echo WPADM_URL_BASE;?>wpsite/recovery-backup" method="post" target="_blank" id="form_auth_backup" name="form_auth_backup">
1396
  </form>
1397
- <form action="<?php echo WPADM_URL_BASE;?>backup/tasks" method="post" target="_blank" id="form_auth_backup_create" name="form_auth_backup_create">
1398
- <input type="hidden" name="url_task_create" value="<?php echo get_option('siteurl');?>">
1399
  </form>
1400
  <form action="" method="post" id="form_auth_backup" name="form_auth_backup">
1401
  </form>
1402
  <form action="<?php echo admin_url( 'admin-post.php?action=wpadm_delete_backup' )?>" method="post" id="delete_backups" name="delete_backups">
1403
  <input type="hidden" name="backup-name" id="backup_name" value="" />
1404
  <input type="hidden" name="backup-type" id="backup_type" value="" />
 
1405
  </form>
1406
  <form action="<?php echo admin_url( 'admin-post.php?action=stop_backup' )?>" method="post" id="stop_backups" name="stop_backups">
1407
  <input type="hidden" name="type_backup" id="type_backup" value="" />
 
1408
  </form>
1409
  <div id="inludes-setting" class="" style="display: none; width: 550px; position: relative; text-align: center; background: #e5e5e5; border: 2px solid #dde4ff; border-radius: 5px;">
1410
  <div>
@@ -1461,29 +1506,29 @@
1461
  ?>
1462
  <tr>
1463
  <td class="number-backup"><?php echo ($i + 1);?></td>
1464
- <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>
1465
- <td onclick="shows('<?php echo 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;"' : '')?>>
1466
  <?php
1467
  $e = '';
1468
  if ( isset($is_runnig) && $is_runnig && isset($name_running_backup) && $name_running_backup == $data['data'][$i]['name']) {
1469
  $e = "<strong style=\"color:#ff8104; margin-left:6px;\">". __('Please wait, backup will be created...','dropbox-backup') . "</strong>";
1470
  } elseif ( $data['data'][$i]['size'] != 0 ) {
1471
  if (isset($data['data'][$i]['not_all_upload']) && $data['data'][$i]['not_all_upload'] === false) {
1472
- $e = "<strong style=\"color:red;\">" . __( 'Not all files were uploaded!', 'dropbox-backup') . "</strong>";
1473
  } else {
1474
  $e = $data['data'][$i]['name'];
1475
  }
1476
  } else {
1477
  $e = "<strong style=\"color:red;\">". __('Not available','dropbox-backup') . "</strong>&nbsp;&nbsp;(<a style=\"text-decoration:underline;\">".__('Why?','dropbox-backup')."</a>)";
1478
  }
1479
- echo $e;
1480
  ?>
1481
  <script type="text/javascript">
1482
- backup_name = '<?php echo $data['data'][$i]['name']?>';
1483
  </script>
1484
  </td>
1485
- <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>
1486
- <td onclick="shows('<?php echo md5( print_r($data['data'][$i], 1) );?>', this)" class="pointer" style="padding: 0px;">
1487
  <?php if ( isset($is_runnig) && $is_runnig && isset($name_running_backup) && $name_running_backup == $data['data'][$i]['name'] ) { ?>
1488
  <img src="<?php echo plugin_dir_url(__FILE__) . "attention.png" ;?>" title="Attention" alt="Attention" style="float: left; width: 20px; height: 20px;margin-left: 21px;" />
1489
  <div style="margin-top :1px;float: left;"><?php _e('Backup in progress','dropbox-backup');?></div>
@@ -1492,8 +1537,8 @@
1492
  <?php
1493
  if (isset($data['data'][$i]['not_all_upload']) && $data['data'][$i]['not_all_upload'] === false) {
1494
  ?>
1495
- <img src="<?php echo plugin_dir_url(__FILE__) . "not-ok.png" ;?>" title="Fail" alt="Fail" style="float: left; width: 20px; height: 20px;margin-left: 42px;" />
1496
- <div style="float: left;"><?php _e('Fail','dropbox-backup');?></div><div style="clear: both;">(<a style="text-decoration:underline;"><?php _e('Show uploaded files','dropbox-backup');?></a>)</div>
1497
  <?php
1498
  } else {
1499
  ?>
@@ -1507,8 +1552,8 @@
1507
  <?php
1508
  }?>
1509
  </td>
1510
- <td onclick="shows('<?php echo md5( print_r($data['data'][$i], 1) );?>', this)" class="pointer"><?php echo $data['data'][$i]['type'];?> <?php _e('backup','dropbox-backup'); ?></td>
1511
- <td onclick="shows('<?php echo md5( print_r($data['data'][$i], 1) );?>', this)" class="pointer"><?php echo $size . __('Mb','dropbox-backup');?></td>
1512
  <td>
1513
  <?php if(is_admin() || is_super_admin()) {?>
1514
  <?php if ($data['data'][$i]['size'] > 0) {
@@ -1518,16 +1563,16 @@
1518
  <?php
1519
  } else {
1520
  ?>
1521
- <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 $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;
1522
  <?php }
1523
  } ?>
1524
- <a class="button-wpadm" href="javascript:void(0)" title="<?php _e('Delete','dropbox-backup'); ?>" 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 _e('Delete','dropbox-backup'); ?></a>&nbsp;
1525
  <?php
1526
  }
1527
  ?>
1528
  </td>
1529
  </tr>
1530
- <tr id="<?php echo md5( print_r($data['data'][$i], 1) );?>" style="display:none; ">
1531
  <?php if ($data['data'][$i]['size'] != 0) {?>
1532
  <td colspan="2">
1533
  </td>
@@ -1542,12 +1587,12 @@
1542
  <tr style="border: 0;">
1543
  <td style="border: 0;">
1544
  <?php if ($data['data'][$i]['type'] == 'local') {?>
1545
- <a href="<?php echo content_url(DROPBOX_BACKUP_DIR_NAME) . "/{$data['data'][$i]['name']}/{$files[$j]}"?>">
1546
- <?php echo $files[$j]; ?>
1547
  </a>
1548
  <?php
1549
  } else {
1550
- echo $files[$j];
1551
  }
1552
  ?>
1553
  </td>
@@ -1568,7 +1613,7 @@
1568
  ?>
1569
  <td colspan="8">
1570
  <?php _e('Backup is created. If you are sure that the backup down(crashed), please ','dropbox-backup');?>
1571
- <a href="javascript:void(0)" onclick="window.open('<?php echo SERVER_URL_INDEX . 'support/?pl=dbp'?>')"><?php _e('contact us','dropbox-backup'); ?></a>.
1572
  </td>
1573
  <?php
1574
  } else { ?>
@@ -1607,7 +1652,7 @@
1607
  <label for="ftp-host"><?php _e('FTP Host','dropbox-backup'); ?></label>
1608
  </div>
1609
  <div style="float:left; ">
1610
- <input type="text" id="ftp-host" value="<?php echo str_ireplace(array('http://', 'https://'), '', home_url()) ;?>" name="ftp_host" >
1611
  </div>
1612
  </div>
1613
  <div class="clear"></div>
@@ -1637,13 +1682,13 @@
1637
  <label for="email-resp"><?php _e('Response Email:','dropbox-backup'); ?></label>
1638
  </div>
1639
  <div style=" ">
1640
- <input type="text" id="email-resp" value="<?php echo get_option('admin_email');?>" style="padding-left:3px;" name="mail_response">
1641
  </div>
1642
  </div>
1643
  </div>
1644
  <div class="clear"></div>
1645
  <div style="text-align: left; margin-left: 100px; margin-top: 10px;">
1646
- <input value="<?php echo $time_log; ?>" type="hidden" name="time_pars">
1647
  <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'); ?>">
1648
  </div>
1649
  </form>
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' />
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');
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
  }
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");
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");
405
  }
406
  var data_log = {
407
  'action': 'wpadm_logs',
408
+ 'nonce' : '<?php echo esc_attr( $nonce ); ?>',
409
  'type-backup' : method,
410
  };
411
  if (method == 'send-to-dropbox') {
415
  var url_ajax = ajaxurl;
416
  if (method == 'restore') {
417
  url_ajax = '<?php echo plugins_url('/modules/restore-class.php', dirname(__FILE__) ); ?>';
418
+ data_log['key'] = '<?php echo esc_attr( $key ); ?>';
419
  data_log['method'] = 'wpadm_logs';
420
  }
421
  jQuery.ajax({
541
  }
542
  var data_backup = {
543
  'action': act,
544
+ 'nonce' : '<?php echo esc_attr( $nonce ); ?>',
545
+ 'key' : '<?php echo esc_attr( $key ); ?>',
546
  'name': name,
547
  };
548
  jQuery("#log-backup").html('');
624
  }
625
  }
626
  if(send) {
 
627
  data['password'] = document.auth.password.value;
628
  data['username'] = document.auth.username.value;
629
  data['plugin'] = document.auth.plugin.value;
630
+ backup = jQuery("#name_backup_restore").val();
631
  jQuery.ajax({
632
  url: form.attr('action'),
633
  data: data,
871
  function saveSetting(id)
872
  {
873
  if (jQuery('#' + id).length > 0) {
874
+ if ( jQuery('#' + id).is('select') || jQuery('#' + id).is( ":text" ) || jQuery('#' + id).is( ":hidden" ) ) {
875
  is_value = jQuery('#' + id).val();
876
  } else {
877
  is_value = 0;
943
  <?php
944
  $command_running = get_transient('running_command');
945
  if (isset($is_runnig) && $is_runnig && $command_running ) {
946
+ if ( file_exists(WPAdm_Core::getTmpDir() . "/logs2" ) ) {
947
  @unlink(WPAdm_Core::getTmpDir() . "/logs2");
948
  }
949
  ?>
959
  jQuery("#log-backup").html('');
960
  jQuery(".title-logs").css('display', 'block');
961
  jQuery(".title-status").css('display', 'none');
962
+ type_backup = '<?php echo esc_attr( $command_running ); ?>';
963
 
964
  setTimeout(function() {
965
  disable_buttons() ;
988
  ' . $msg . '
989
  </p></div>';
990
  }?>
991
+
992
  <div id="wp-cron-enable" style="display: none;">
993
  <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>
994
  <div class="image-enable">
1024
  </script>
1025
  <div id="sent-error-report" style="display: none;" >
1026
  <div class="text-view">
1027
+ <?php echo esc_html( $sent_response ) ;?>
1028
  </div>
1029
  <div class="button-sent-report">
1030
  <input type="button" class="button-wpadm" value="<?php _e('OK','dropbox-backup'); ?>" onclick="jQuery('#sent-error-report').arcticmodal('close')" />
1048
  <label for="ftp-host"><?php _e('FTP Host','dropbox-backup'); ?></label>
1049
  </div>
1050
  <div style="float:left; ">
1051
+ <input type="text" id="ftp-host" value="<?php echo esc_url( str_ireplace( array('http://', 'https://'), '', home_url() ) ) ;?>" name="ftp_host" >
1052
  </div>
1053
  </div>
1054
  <div class="clear"></div>
1078
  <label for="email-resp"><?php _e('Response Email:','dropbox-backup'); ?></label>
1079
  </div>
1080
  <div style=" ">
1081
+ <input type="text" id="email-resp" value="<?php echo esc_attr( get_option('admin_email') );?>" style="padding-left:3px;" name="mail_response">
1082
  </div>
1083
  </div>
1084
  </div>
1085
  </div>
1086
  <div class="clear"></div>
1087
  <div style="text-align: left; margin-left: 100px; margin-top: 10px;">
1088
+ <input value="<?php echo esc_attr($time_log); ?>" type="hidden" name="time_pars">
1089
  <input value="" type="hidden" name="msg_ajax" id="msg_ajax">
1090
  </div>
1091
  <div class="ajax-button" style="margin-bottom: 10px;">
1121
  <span style="font-size: 20px;"><?php _e('(files+database)','dropbox-backup');?></span>
1122
 
1123
  <span style="font-size: 11px;">
1124
+ <?php echo (isset($plugin_data[0]['Version']) ? 'Version ' . esc_html( $plugin_data[0]['Version'] ) : '')?>
1125
  </span>
1126
 
1127
  </div>
1128
  <?php if ($show) {?>
1129
+ <div id="container-user" class="cfTabsContainer" onclick="showRegistInfo(false)" style="width: 48%; padding-bottom: 0px; padding-top: 0px; float: left; margin-left: 20px;">
1130
+ <div class="stat-wpadm-info-title" id="title-regisr" style="padding :9px 0px; margin-top:11px; line-height: 24px;">
1131
+ <?php if (false) {?>
1132
+ <?php _e('Free Sign Up','dropbox-backup'); ?> <br /><?php _e('to backup more than one website...','dropbox-backup'); ?>
1133
+ <?php } else {
1134
+ _e('Professional version<br /> "Dropbox backup and restore"<br /><span class="hover-title">get more...</span>','dropbox-backup');
1135
+ } ?>
1136
  </div>
1137
  <div id="cf_activate" class="cfContentContainer" style="display: none;">
1138
+ <?php if (false) {?>
1139
+ <form method="post" id="dropbox_form" action="<?php echo admin_url( 'admin-post.php?action=wpadm_activate_plugin' )?>" >
1140
+ <div class="stat-wpadm-registr-info" style="margin-bottom: 40px; margin-top: 17px;">
1141
+ <table class="form-table stat-table-registr" style="">
1142
+ <tbody>
1143
+ <tr valign="top">
1144
+ <th scope="row">
1145
+ <label for="email"><?php _e('E-mail','dropbox-backup'); ?></label>
1146
+ </th>
1147
+ <td>
1148
+ <input id="email" class="" type="text" name="email" value="">
1149
+ </td>
1150
+ </tr>
1151
+ <tr valign="top">
1152
+ <th scope="row">
1153
+ <label for="password"><?php _e('Password','dropbox-backup'); ?></label>
1154
+ </th>
1155
+ <td>
1156
+ <input id="password" class="" type="password" name="password" value="">
1157
+ </td>
1158
+ </tr>
1159
+ <tr valign="top">
1160
+ <th scope="row">
1161
+ <label for="password-confirm"><?php _e('Password confirm','dropbox-backup'); ?></label>
1162
+ </th>
1163
+ <td>
1164
+ <input id="password-confirm" class="" type="password" name="password-confirm" value="">
1165
+ </td>
1166
+ </tr>
1167
+ <tr valign="top">
1168
+ <th scope="row">
1169
+ </th>
1170
+ <td>
1171
+ <input class="button-wpadm" type="submit" value="<?php _e('Register & Activate','dropbox-backup'); ?>" name="send">
1172
+ </td>
1173
+ </tr>
1174
+ </tbody>
1175
+ </table>
1176
+ </div>
1177
+ <div class="stat-wpadm-info" id="registr-info" style="margin-bottom: 2px; margin-top: 30px;">
1178
+ <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'); ?>
1179
+ </div>
1180
+ </form>
1181
+ <?php } else {
1182
+ $repeat_advantage = false;
1183
+ include 'advantage-plugin.php';
1184
+ }
1185
+ ?>
1186
  </div>
1187
  <div class="clear"></div>
1188
  <div class="block-button-show" style="color: #fff;">
1189
+ <div class="block-click" onclick="showRegistInfo(true, false);">
1190
  <span id="registr-show" style="color: #fff;"><?php _e('Show','dropbox-backup'); ?></span>
1191
  <div id="registr-choice-icon" class="dashicons dashicons-arrow-down" style=""></div>
1192
  </div>
1193
  </div>
1194
+
1195
  </div>
1196
  <?php } else { ?>
1197
  <div id="container-user" class="cfTabsContainer" style="width: 48%; padding-bottom: 0px; padding-top: 0px; float: left; margin-left: 20px;">
1199
  <?php _e('Sign In to backup more than one website...','dropbox-backup'); ?>
1200
  </div>
1201
  <div>
1202
+ <form method="post" id="auth" name="auth" action="<?php echo esc_url( SERVER_URL_INDEX . "login-process" ) ; ?>">
1203
  <div>
1204
  <div id="message-form" style="color: red; float: left;margin: 10px;margin-top: 14px;"></div>
1205
  </div>
1206
  <div style="padding: 5px; clear: both;">
1207
  <div class="form-field">
1208
+ <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'); ?>" />
1209
  </div>
1210
  <div class="form-field">
1211
  <input class="input-small" type="password" required="required" name="password" placeholder="<?php _e('Password','dropbox-backup'); ?>" />
1230
  <?php _e('Settings','dropbox-backup'); ?>
1231
  </div>
1232
  <div id="setting_active" class="cfContentContainer" style="display: none;">
1233
+ <form method="post" action="" autocomplete="off">
1234
  <div class="stat-wpadm-registr-info" style="width: 100%; margin-bottom: 9px;">
1235
  <div style="margin-bottom: 12px; margin-top: 20px; font-size: 15px; text-align: center;">
1236
  <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">
1237
+ <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>
1238
  </div>
1239
  <?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 ; ?>
1240
  <div class="setting-checkbox">
1248
  <label for="app_key"><?php _e('App key','dropbox-backup'); ?>*</label>
1249
  </th>
1250
  <td>
1251
+ <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'] ) : ''?>">
1252
  </td>
1253
  </tr>
1254
  <tr valign="top" id="dropbox-app-secret" style="display: <?php echo $show_fields ? 'table-row' : 'none'?>;">
1256
  <label for="app_secret"><?php _e('App secret','dropbox-backup'); ?>*</label>
1257
  </th>
1258
  <td>
1259
+ <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'] ) : ''?>">
1260
  </td>
1261
  </tr>
1262
 
1273
  <label for="time_error" style="font-size: 13px;"><?php _e('Waiting time (minutes)', 'dropbox-backup'); ?></label>
1274
  <select name="time_error" id="time_error" onchange="saveSetting('time_error')">
1275
  <?php
1276
+ for($i = 1; $i < 16; $i++) {
1277
  ?>
1278
  <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>
1279
  <?php
1285
  </div>
1286
  <?php if ( is_super_admin() ) { ?>
1287
  <div class="setting-checkbox">
1288
+ <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')" />
1289
  <label for="is_admin" style="font-size: 13px;"><?php _e('Appear in menu for admins only','dropbox-backup'); ?></label>
1290
  </div>
1291
  <?php } ?>
1292
  <div class="setting-checkbox">
1293
+ <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')" />
1294
  <label for="is_optimization" style="font-size: 13px;"><?php _e('Database Optimization','dropbox-backup'); ?></label>
1295
  </div>
1296
  <div class="setting-checkbox">
1297
+ <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')" />
1298
  <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>
1299
  </div>
1300
  <div class="setting-checkbox">
1301
+ <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')" />
1302
  <label for="is_repair" style="font-size: 13px;"><?php _e('Try database repair','dropbox-backup'); ?></label>
1303
  </div>
1304
  <div class="setting-checkbox">
1305
+ <input type="checkbox" <?php echo (isset($dropbox_options['is_show_admin_bar']) && (int)$dropbox_options['is_show_admin_bar'] == 1) ? 'checked="checked"' : ( !isset($dropbox_options['is_show_admin_bar']) ? 'checked="checked"' : '' ); ?> name="is_show_admin_bar" value="1" id="is_show_admin_bar" onclick="saveSetting('is_show_admin_bar')" />
1306
  <label for="is_show_admin_bar" style="font-size: 13px;"><?php _e('Show in a admin bar','dropbox-backup'); ?></label>
1307
  </div>
1308
  <div class="setting-checkbox">
1311
  </div>
1312
  <div style="border-bottom:1px solid #fff; margin:10px 0px;"></div>
1313
  <div class="setting-checkbox">
1314
+ <label for="backup_folder" style="font-size: 13px;"><?php _e('Backup folder location','dropbox-backup'); ?>:</label>
1315
+ <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="" />
1316
+ <span>
1317
+ <input type="hidden" value="1" id="clear_backup_folder">
1318
+ <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>
1319
+ </span>
1320
+ <div class="clear"></div>
1321
  </div>
1322
+ <div class="setting-checkbox" style="text-align: center;margin-top:15px;">
1323
+ <input class="btn-orange" type="button" id="button-save-folder-backup" value="<?php _e('Save', 'dropbox-backup'); ?>" >
1324
  </div>
1325
+ <script >
1326
+ jQuery(document).ready(function() {
1327
+ jQuery('#button-save-folder-backup').click(function() {
1328
+ saveSetting('backup_folder');
1329
+ })
1330
+ })
1331
+ </script>
1332
  </div>
1333
  </form>
1334
  </div>
1415
  </div>
1416
  </div>
1417
  <div id="support-button" style="float: right; margin-top: 130px; margin-right: 20px;">
1418
+ <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 />
1419
  </div>
1420
  <div id="action-buttons" style="">
1421
  <div style="float: left;">
1435
  </div>
1436
  <div style="clear: both; margin-bottom: 10px;"></div>
1437
  <div>
1438
+ <form action="<?php echo esc_url( WPADM_URL_BASE );?>wpsite/recovery-backup" method="post" target="_blank" id="form_auth_backup" name="form_auth_backup">
1439
  </form>
1440
+ <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">
1441
+ <input type="hidden" name="url_task_create" value="<?php echo esc_url( get_option('siteurl') );?>">
1442
  </form>
1443
  <form action="" method="post" id="form_auth_backup" name="form_auth_backup">
1444
  </form>
1445
  <form action="<?php echo admin_url( 'admin-post.php?action=wpadm_delete_backup' )?>" method="post" id="delete_backups" name="delete_backups">
1446
  <input type="hidden" name="backup-name" id="backup_name" value="" />
1447
  <input type="hidden" name="backup-type" id="backup_type" value="" />
1448
+ <input type="hidden" name="nonce" id="id_nonce_delete" value="<?php echo esc_attr( $nonce );?>" />
1449
  </form>
1450
  <form action="<?php echo admin_url( 'admin-post.php?action=stop_backup' )?>" method="post" id="stop_backups" name="stop_backups">
1451
  <input type="hidden" name="type_backup" id="type_backup" value="" />
1452
+ <input type="hidden" name="nonce" id="id_nonce" value="<?php echo esc_attr( $nonce ); ?>" />
1453
  </form>
1454
  <div id="inludes-setting" class="" style="display: none; width: 550px; position: relative; text-align: center; background: #e5e5e5; border: 2px solid #dde4ff; border-radius: 5px;">
1455
  <div>
1506
  ?>
1507
  <tr>
1508
  <td class="number-backup"><?php echo ($i + 1);?></td>
1509
+ <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>
1510
+ <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;"' : '')?>>
1511
  <?php
1512
  $e = '';
1513
  if ( isset($is_runnig) && $is_runnig && isset($name_running_backup) && $name_running_backup == $data['data'][$i]['name']) {
1514
  $e = "<strong style=\"color:#ff8104; margin-left:6px;\">". __('Please wait, backup will be created...','dropbox-backup') . "</strong>";
1515
  } elseif ( $data['data'][$i]['size'] != 0 ) {
1516
  if (isset($data['data'][$i]['not_all_upload']) && $data['data'][$i]['not_all_upload'] === false) {
1517
+ $e = "<strong style=\"color:red;\">" . __( 'Not all files were uploaded/created!', 'dropbox-backup') . "</strong>";
1518
  } else {
1519
  $e = $data['data'][$i]['name'];
1520
  }
1521
  } else {
1522
  $e = "<strong style=\"color:red;\">". __('Not available','dropbox-backup') . "</strong>&nbsp;&nbsp;(<a style=\"text-decoration:underline;\">".__('Why?','dropbox-backup')."</a>)";
1523
  }
1524
+ echo ($e);
1525
  ?>
1526
  <script type="text/javascript">
1527
+ backup_name = '<?php echo esc_attr( $data['data'][$i]['name'] ); ?>';
1528
  </script>
1529
  </td>
1530
+ <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>
1531
+ <td onclick="shows('<?php echo esc_attr( md5( print_r($data['data'][$i], 1) ) );?>', this)" class="pointer" style="padding: 0px;">
1532
  <?php if ( isset($is_runnig) && $is_runnig && isset($name_running_backup) && $name_running_backup == $data['data'][$i]['name'] ) { ?>
1533
  <img src="<?php echo plugin_dir_url(__FILE__) . "attention.png" ;?>" title="Attention" alt="Attention" style="float: left; width: 20px; height: 20px;margin-left: 21px;" />
1534
  <div style="margin-top :1px;float: left;"><?php _e('Backup in progress','dropbox-backup');?></div>
1537
  <?php
1538
  if (isset($data['data'][$i]['not_all_upload']) && $data['data'][$i]['not_all_upload'] === false) {
1539
  ?>
1540
+ <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;;" />
1541
+ <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>
1542
  <?php
1543
  } else {
1544
  ?>
1552
  <?php
1553
  }?>
1554
  </td>
1555
+ <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>
1556
+ <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>
1557
  <td>
1558
  <?php if(is_admin() || is_super_admin()) {?>
1559
  <?php if ($data['data'][$i]['size'] > 0) {
1563
  <?php
1564
  } else {
1565
  ?>
1566
+ <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;
1567
  <?php }
1568
  } ?>
1569
+ <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;
1570
  <?php
1571
  }
1572
  ?>
1573
  </td>
1574
  </tr>
1575
+ <tr id="<?php echo esc_attr( md5( print_r($data['data'][$i], 1) ) );?>" style="display:none; ">
1576
  <?php if ($data['data'][$i]['size'] != 0) {?>
1577
  <td colspan="2">
1578
  </td>
1587
  <tr style="border: 0;">
1588
  <td style="border: 0;">
1589
  <?php if ($data['data'][$i]['type'] == 'local') {?>
1590
+ <a href="<?php echo esc_url( content_url(DROPBOX_BACKUP_DIR_NAME) . "/{$data['data'][$i]['name']}/{$files[$j]}" ) ;?>">
1591
+ <?php echo esc_html( $files[$j] ); ?>
1592
  </a>
1593
  <?php
1594
  } else {
1595
+ echo esc_html( $files[$j] );
1596
  }
1597
  ?>
1598
  </td>
1613
  ?>
1614
  <td colspan="8">
1615
  <?php _e('Backup is created. If you are sure that the backup down(crashed), please ','dropbox-backup');?>
1616
+ <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>.
1617
  </td>
1618
  <?php
1619
  } else { ?>
1652
  <label for="ftp-host"><?php _e('FTP Host','dropbox-backup'); ?></label>
1653
  </div>
1654
  <div style="float:left; ">
1655
+ <input type="text" id="ftp-host" value="<?php echo esc_url( str_ireplace(array('http://', 'https://'), '', home_url()) ) ;?>" name="ftp_host" >
1656
  </div>
1657
  </div>
1658
  <div class="clear"></div>
1682
  <label for="email-resp"><?php _e('Response Email:','dropbox-backup'); ?></label>
1683
  </div>
1684
  <div style=" ">
1685
+ <input type="text" id="email-resp" value="<?php echo esc_attr( get_option('admin_email') );?>" style="padding-left:3px;" name="mail_response">
1686
  </div>
1687
  </div>
1688
  </div>
1689
  <div class="clear"></div>
1690
  <div style="text-align: left; margin-left: 100px; margin-top: 10px;">
1691
+ <input value="<?php echo esc_attr( $time_log ); ?>" type="hidden" name="time_pars">
1692
  <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'); ?>">
1693
  </div>
1694
  </form>