Backup & Restore Dropbox - Version 1.2.4

Version Description

Upgrade Notice

Download this release

Release Info

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

Code changes from version 1.1 to 1.2.4

class-wpadm-core.php CHANGED
@@ -155,14 +155,15 @@ if (!class_exists('WPAdm_Core')) {
155
  */
156
  private function auth() {
157
  $this->pub_key = get_option('wpadm_pub_key');
158
- if ('local_backup' == $this->request['method'] || 'local_restore' == $this->request['method'] || 'queue_controller' == $this->request['method'] || 'local' == $this->request['method']) {
 
159
  return true;
160
  }
161
  if (empty($this->pub_key)) {
162
  if ('connect' == $this->request['method']) {
163
  $this->pub_key = $this->request['params']['pub_key'];
164
  } else {
165
- $this->getResult()->setError('Активируйте сайт на wpadm.com для работы плагинов.');
166
  return false;
167
  }
168
  } elseif ('connect' == $this->request['method']) {
@@ -256,7 +257,7 @@ if (!class_exists('WPAdm_Core')) {
256
  }
257
  unlink($f);
258
  }
259
- rmdir($dir);
260
  }
261
  }
262
  }
155
  */
156
  private function auth() {
157
  $this->pub_key = get_option('wpadm_pub_key');
158
+ $methods_local = array('local_backup', 'send-to-dropbox', 'local_restore', 'local', 'queue_controller', 'local_send_to_s3');
159
+ if ( in_array($this->request['method'], $methods_local) ) {
160
  return true;
161
  }
162
  if (empty($this->pub_key)) {
163
  if ('connect' == $this->request['method']) {
164
  $this->pub_key = $this->request['params']['pub_key'];
165
  } else {
166
+ $this->getResult()->setError('Activate site in WPAdm.com for work to plugins.');
167
  return false;
168
  }
169
  } elseif ('connect' == $this->request['method']) {
257
  }
258
  unlink($f);
259
  }
260
+ @rmdir($dir);
261
  }
262
  }
263
  }
commands/class-wpadm-command-send-to-dropbox.php CHANGED
@@ -8,9 +8,12 @@ if (!class_exists('WPadm_Command_Send_To_Dropbox')) {
8
  @session_start();
9
  require_once WPAdm_Core::getPluginDir() . '/modules/dropbox.class.php';
10
 
11
- WPAdm_Core::log('Send Files to Dropbox');
12
  $dropbox = new dropbox($context->get('key'), $context->get('secret'), $context->get('token'));
13
 
 
 
 
14
  if (!$dropbox->isAuth()) {
15
  $context->setError("Error auth in Dropbox");
16
  return false;
8
  @session_start();
9
  require_once WPAdm_Core::getPluginDir() . '/modules/dropbox.class.php';
10
 
11
+ WPAdm_Core::log('Send to drop box files');
12
  $dropbox = new dropbox($context->get('key'), $context->get('secret'), $context->get('token'));
13
 
14
+ //$token = $dropbox->getAccessToken($_SESSION['request_token']);
15
+ //WPAdm_Core::log('Token: ' . print_r($context->get('token'), true));
16
+
17
  if (!$dropbox->isAuth()) {
18
  $context->setError("Error auth in Dropbox");
19
  return false;
dropbox-backup.php CHANGED
@@ -1,22 +1,22 @@
1
  <?php
2
  /*
3
- Plugin Name: DropBox Backup
4
- Description: DropBox Backup Plugin to create DropBox Full Backup (Files + Database) of your Web Page
5
- Version: 1.1
6
  */
7
 
8
  require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'wpadm.php';
9
- if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'wpadm-class-wp.php')) {
10
- require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'wpadm-class-wp.php';
11
- }
12
 
13
  add_action('init', 'wpadm_full_backup_dropbox_run');
14
 
15
- add_action('admin_print_scripts', 'wpadm_include_admins_script' );
16
- // add item to menu
17
-
18
- add_action('admin_notices', 'wpadm_admin_notice');
19
 
 
 
 
20
 
21
  if (!function_exists('wpadm_full_backup_dropbox_run')) {
22
  function wpadm_full_backup_dropbox_run()
1
  <?php
2
  /*
3
+ Plugin Name: Dropbox Backup
4
+ Description: Dropbox Backup Plugin to create Dropbox Full Backup (Files + Database) of your Web Page
5
+ Version: 1.2.3
6
  */
7
 
8
  require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'wpadm.php';
9
+ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'wpadm-class-wp.php';
 
 
10
 
11
  add_action('init', 'wpadm_full_backup_dropbox_run');
12
 
13
+ add_action('admin_print_scripts', array('wpadm_wp_full_backup_dropbox', 'include_admins_script' ));
14
+ add_action('admin_menu', array('wpadm_wp_full_backup_dropbox', 'draw_menu'));
15
+ add_action('admin_post_activate_wpadm_full_backup_dropbox', array('wpadm_wp_full_backup_dropbox', 'activatePlugin') );
 
16
 
17
+ if ( !get_option('wpadm_pub_key')/* && (is_admin())*/) {
18
+ add_action('admin_notices', 'wpadm_admin_notice');
19
+ }
20
 
21
  if (!function_exists('wpadm_full_backup_dropbox_run')) {
22
  function wpadm_full_backup_dropbox_run()
img/dropbox.png ADDED
Binary file
img/stars-5.png ADDED
Binary file
libs/error.class.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * error
4
+ *
5
+ * 100 - mothod not exist
6
+ * 101 - error method api
7
+ * 102 - error in the received data
8
+ * 103 - error
9
+ *
10
+ * notice
11
+ * 401 - activate user
12
+ *
13
+ * success
14
+ * 201 - registaration and acivate ok
15
+ * 202 - acivate plugin ok
16
+ *
17
+ */
18
+ if ( ! class_exists("errorWPADM")) {
19
+ class errorWPADM {
20
+ private static $messages = array(
21
+ 100 => 'Method doesn\'t exist.',
22
+ 101 => 'Method has an error.',
23
+ 102 => 'Received data has an error.',
24
+ 103 => 'There is an error in plugin activation.',
25
+ 201 => 'Registration and activation was successful.',
26
+ 202 => 'Plugin activation was successful.',
27
+ 401 => 'The User at WPAdm is not activated. Please, activate you User at WPAdm-System in <url> and try again.',
28
+
29
+ );
30
+ public static function getMessage($code)
31
+ {
32
+ if (isset(self::$messages[$code])) {
33
+ return self::$messages[$code];
34
+ } else {
35
+ return "Server error: received data are invalid.";
36
+ }
37
+
38
+ }
39
+ }
40
+ }
libs/wpadm.server.main.class.php ADDED
@@ -0,0 +1,644 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined("SERVER_URL_INDEX")) {
4
+ define("SERVER_URL_INDEX", "http://www.wpadm.com/");
5
+ }
6
+ if (!defined("PHP_VERSION_DEFAULT")) {
7
+ define("PHP_VERSION_DEFAULT", '5.2.4' );
8
+ }
9
+ if (!defined("MYSQL_VERSION_DEFAULT")) {
10
+ define("MYSQL_VERSION_DEFAULT", '5.0' );
11
+ }
12
+
13
+ if (!defined("_PREFIX_STAT")) {
14
+ define("_PREFIX_STAT", "counter_free_wpadm_");
15
+ }
16
+
17
+ if (!defined("PREFIX_BACKUP_")) {
18
+ define("PREFIX_BACKUP_", "wpadm_backup_");
19
+ }
20
+ if (!defined("PAGES_NEXT_PREV_COUNT_STAT")) {
21
+ define("PAGES_NEXT_PREV_COUNT_STAT", 3);
22
+ }
23
+
24
+ if (!class_exists("wpadm_class")) {
25
+
26
+ add_action('admin_post_wpadm_activate_plugin', array('wpadm_class', 'activatePlugin') );
27
+ add_action('admin_post_wpadm_delete_pub_key', array('wpadm_class', 'delete_pub_key') );
28
+
29
+ //add_action('admin_post_wpadm_getJs', array('wpadm_class', 'getJs') );
30
+
31
+ //add_action('admin_print_scripts', array('wpadm_class', 'includeJs' ));
32
+
33
+ class wpadm_class {
34
+
35
+ protected static $result = "";
36
+ protected static $class = "";
37
+ protected static $title = "";
38
+ public static $type = "";
39
+ public static $plugin_name = "";
40
+ protected static $plugins = array('stats-counter' => '1.1',
41
+ 'wpadm_full_backup_storage' => '1.0',
42
+ 'wpadm_full_backup_s3' => '1.0',
43
+ 'wpadm_full_backup_ftp' => '1.0',
44
+ 'dropbox-backup' => '1.0',
45
+ 'wpadm_db_backup_storage' => '1.0',
46
+ 'database-backup-amazon-s3' => '1.0',
47
+ 'wpadm_file_backup_s3' => '1.0',
48
+ 'wpadm_file_backup_ftp' => '1.0',
49
+ 'wpadm_file_backup_dropbox' => '1.0',
50
+ 'wpadm_db_backup_ftp' => '1.0',
51
+ 'wpadm_db_backup_dropbox' => '1.0',
52
+ 'wpadm_file_backup_storage' => '1.0',
53
+ );
54
+ const MIN_PASSWORD = 6;
55
+
56
+
57
+ private static $backup = "1";
58
+
59
+ private static $status = "0";
60
+ private static $error = "";
61
+
62
+ public static function setBackup($b)
63
+ {
64
+ self::$backup = $b;
65
+ }
66
+
67
+ public static function setStatus($s)
68
+ {
69
+ self::$status = $s;
70
+ }
71
+ public static function setErrors($e)
72
+ {
73
+ self::$error = $e;
74
+ }
75
+
76
+ public static function getDateInName($name)
77
+ {
78
+ $date_ = explode(self::$type . '-', $name);
79
+ if (isset($date_[1])) {
80
+ $date = explode('_', $date_[1]);
81
+ $d = "{$date[0]}-{$date[1]}-{$date[2]} {$date[3]}:" . preg_replace("/\([0-9]+\)/", '', $date[4]);
82
+ }
83
+ return $d;
84
+
85
+ }
86
+ public static function backupSend()
87
+ {
88
+ $data['status'] = self::$backup . self::$status;
89
+ $data['error'] = self::$error;
90
+ $data['pl'] = WPAdm_Core::$plugin_name;
91
+ $data['site'] = get_option('siteurl');
92
+ $data['actApi'] = 'setBackup';
93
+ self::sendToServer($data);
94
+ }
95
+
96
+
97
+
98
+ static function delete_pub_key()
99
+ {
100
+ delete_option('wpadm_pub_key');
101
+ header("Location: " . $_SERVER['HTTP_REFERER']);
102
+ }
103
+ public static function checkInstallWpadmPlugins()
104
+ {
105
+ $return = false;
106
+ $i = 1;
107
+ foreach(self::$plugins as $plugin => $version) {
108
+ if (self::check_plugin($plugin)) {
109
+ $i ++;
110
+ }
111
+ }
112
+ if ($i > 2) {
113
+ $return = true;
114
+ }
115
+ return $return;
116
+ }
117
+
118
+ static function setResponse($data)
119
+ {
120
+ $msg = errorWPADM::getMessage($data['code']);
121
+ if(isset($data['data'])) {
122
+ if (isset($data['data']['replace'])) {
123
+ foreach($data['data']['replace'] as $key => $value) {
124
+ $msg = str_replace("<$key>", $value, $msg);
125
+ }
126
+ }
127
+ }
128
+ if ($data['status'] == 'success') {
129
+ self::setMessage($msg);
130
+ } else {
131
+ self::setError($msg);
132
+ }
133
+
134
+ return isset($data['data']) ? $data['data'] : array();
135
+
136
+ }
137
+
138
+
139
+ protected static function setError($msg = "")
140
+ {
141
+ if (!empty($msg)) {
142
+ $_SESSION['errorMsgWpadmDB'] = isset($_SESSION['errorMsgWpadmDB']) ? $_SESSION['errorMsgWpadmDB'] . '<br />' . $msg : $msg;
143
+ }
144
+ }
145
+ protected static function getError($del = false)
146
+ {
147
+ $error = "";
148
+ if (isset($_SESSION['errorMsgWpadmDB'])) {
149
+ $error = $_SESSION['errorMsgWpadmDB'];
150
+ if($del) {
151
+ unset($_SESSION['errorMsgWpadmDB']);
152
+ }
153
+ }
154
+ return $error;
155
+ }
156
+
157
+ protected static function setMessage($msg)
158
+ {
159
+ if (!empty($msg)) {
160
+ $_SESSION['msgWpadmDB'] = isset($_SESSION['msgWpadmDB']) ? $_SESSION['msgWpadmDB'] . '<br />' . $msg : $msg;
161
+ }
162
+ }
163
+ protected static function getMessage($del = false)
164
+ {
165
+ $msg = "";
166
+ if (isset($_SESSION['msgWpadmDB'])) {
167
+ $msg = $_SESSION['msgWpadmDB'];
168
+ if($del) {
169
+ unset($_SESSION['msgWpadmDB']);
170
+ }
171
+ }
172
+ return $msg;
173
+ }
174
+
175
+
176
+
177
+ public static function sendToServer($postdata = array(), $stat = false)
178
+ {
179
+ if (count($postdata) > 0) {
180
+
181
+ if ($stat) {
182
+ if ($counter_id = get_option(_PREFIX_STAT . 'counter_id')) {
183
+ $postdata['counter_id'] = $counter_id;
184
+ }
185
+ }
186
+ $postdata = http_build_query($postdata, '', '&');
187
+
188
+ $length = strlen($postdata);
189
+
190
+
191
+ if (function_exists("curl_init") && function_exists("curl_setopt") && function_exists("curl_exec") && function_exists("curl_close")) {
192
+ if ($stat) {
193
+ $url = SERVER_URL_VISIT_STAT . "/Api.php";
194
+ } else {
195
+ $url = WPADM_URL_BASE . "api/";
196
+ }
197
+ $curl = curl_init($url);
198
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
199
+ curl_setopt($curl, CURLOPT_POST, true);
200
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
201
+ curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
202
+ curl_setopt($curl, CURLOPT_USERPWD, "admin24:admin24");
203
+ self::$result = curl_exec($curl);
204
+ curl_close($curl);
205
+ if ($stat) {
206
+ return unserialize(self::$result);
207
+ } else {
208
+ return json_decode(self::$result, true);
209
+ }
210
+ } elseif (function_exists("fsockopen")) {
211
+ if ($stat) {
212
+ $url = SERVER_URL_STAT;
213
+ $req = '/Api.php';
214
+ } else {
215
+ $url = substr(WPADM_URL_BASE, 7);
216
+ $req = '/api/';
217
+ }
218
+ $out = "POST " . $req . " HTTP/1.1\r\n";
219
+ $out.= "HOST: " . $url . "\r\n";
220
+ $out.= "Content-Type: application/x-www-form-urlencoded\r\n";
221
+ $out.= "Content-Length: ".$length."\r\n";
222
+ $out.= "Connection:Close\r\n\r\n";
223
+ $out.= $postdata."\r\n\r\n";
224
+ try {
225
+ $errno='';
226
+ $errstr = '';
227
+ $socket = @fsockopen($url, 80, $errno, $errstr, 30);
228
+ if($socket) {
229
+ if(!fwrite($socket, $out)) {
230
+ throw new Exception("unable to write fsockopen");
231
+ } else {
232
+ while ($in = @fgets ($socket, 1024)) {
233
+ self::$result .= $in;
234
+ }
235
+ }
236
+ self::$result = explode("\r\n\r\n", self::$result);
237
+ if ($stat) {
238
+ return unserialize(self::$result);
239
+ } else {
240
+ return json_decode(self::$result, true);
241
+ }
242
+ throw new Exception("error in data");
243
+ } else {
244
+ throw new Exception("unable to create socket");
245
+ }
246
+ fclose($socket);
247
+ } catch(exception $e) {
248
+ return false;
249
+ }
250
+ }
251
+ }
252
+ }
253
+
254
+ public static function activatePlugin()
255
+ {
256
+ if (isset($_POST['email']) && isset($_POST['password']) && isset($_POST['password-confirm'])) {
257
+ $email = trim(stripslashes(strip_tags($_POST['email'])));
258
+ $password = trim(strip_tags($_POST['password']));
259
+ $password_confirm = trim(strip_tags($_POST['password-confirm']));
260
+ $sent = true;
261
+ if (empty($email)) {
262
+ parent::setError("Error, Email is empty.");
263
+ $sent = false;
264
+ }
265
+ if (!preg_match("/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i", $email)) {
266
+ parent::setError("Error, Incorrect Email");
267
+ $sent = false;
268
+ }
269
+ if (empty($password)) {
270
+ parent::setError("Error, Password is empty.");
271
+ $sent = false;
272
+ }
273
+ if (strlen($password) < self::MIN_PASSWORD) {
274
+ parent::setError("Error, the minimum number of characters for the password \"" . self::MIN_PASSWORD . "\".");
275
+ $sent = false;
276
+ }
277
+
278
+ if ($password != $password_confirm) {
279
+ parent::setError("Error, passwords do not match");
280
+ $sent = false;
281
+ }
282
+ if ($sent) {
283
+ $info = self::$plugin_name;
284
+ $mail = get_option(PREFIX_BACKUP_ . "email");
285
+ if ($mail) {
286
+ add_option(PREFIX_BACKUP_ . "email", $email);
287
+ } else {
288
+ update_option(PREFIX_BACKUP_ . "email",$email);
289
+ }
290
+ $data = self::sendToServer(
291
+ array(
292
+ 'actApi' => "activate",
293
+ 'email' => $email,
294
+ 'password' => $password,
295
+ 'url' => get_option("siteurl"),
296
+ 'plugin' => $info,
297
+ )
298
+ );
299
+ $res = self::setResponse($data);
300
+ }
301
+ }
302
+ if (isset($res['url']) && !empty($res['url'])) {
303
+ header("Location: " . $res['url']);
304
+ } else {
305
+ header("Location: " . admin_url("admin.php?page=wpadm_plugins"));
306
+ }
307
+ }
308
+
309
+ public static function include_admins_script()
310
+ {
311
+ wp_enqueue_style('css-admin-wpadm-db', plugins_url( "/template/css/admin-style-wpadm.css", dirname(__FILE__) ) );
312
+
313
+ wp_enqueue_script( 'js-admin-wpadm-db', plugins_url( "/template/js/admin-wpadm.js", dirname(__FILE__) ) );
314
+ wp_enqueue_script( 'postbox' );
315
+
316
+ }
317
+ protected static function read_backups($dirs_read = false)
318
+ {
319
+ $name = get_option('siteurl');
320
+
321
+ $name = str_replace("http://", '', $name);
322
+ $name = str_replace("https://", '', $name);
323
+ $name = preg_replace("|\W|", "_", $name);
324
+ $name .= '-' . self::$type . '-' . date("Y_m_d_H_i");
325
+
326
+ $dir_backup = ABSPATH . 'wpadm_backups';
327
+
328
+ $backups = array('data' => array(), 'md5' => '');
329
+ if (is_dir($dir_backup)) {
330
+ $i = 0;
331
+ $dir_open = opendir($dir_backup);
332
+ while($d = readdir($dir_open)) {
333
+ if ($d != '.' && $d != '..' && is_dir($dir_backup . "/$d") && strpos($d, self::$type) !== false) {
334
+ $backups['data'][$i]['dt'] = self::getDateInName($d);
335
+ $backups['data'][$i]['name'] = "$d";
336
+ if ($dirs_read === false) {
337
+ $size = 0;
338
+ $dir_b = opendir($dir_backup . "/$d");
339
+ $count_zip = 0;
340
+ $backups['data'][$i]['files'] = "[";
341
+ while($d_b = readdir($dir_b)) {
342
+ if ($d_b != '.' && $d_b != '..' && file_exists($dir_backup . "/$d/$d_b") && substr($d_b, -3) != "php") {
343
+ $backups['data'][$i]['files'] .= "$d_b,";
344
+ $size += filesize($dir_backup . "/$d/$d_b");
345
+ $count_zip = $count_zip + 1;
346
+ }
347
+ }
348
+ $backups['data'][$i]['files'] .= ']';
349
+ $backups['data'][$i]['size'] = $size;
350
+ $backups['data'][$i]['type'] = 'local';
351
+ $backups['data'][$i]['count'] = $count_zip;
352
+ }
353
+ $i += 1;
354
+ }
355
+ }
356
+ }
357
+ $backups['md5'] = md5( print_r($backups['data'] , 1) );
358
+ return $backups;
359
+ }
360
+ public static function check_plugin($name = "", $version = false)
361
+ {
362
+ if (!empty($name)) {
363
+ if ( ! function_exists( 'get_plugins' ) ) {
364
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
365
+ }
366
+ $name2 = str_replace("-", "_", $name);
367
+ $plugin = get_plugins("/$name");
368
+ if (empty($plugin)) {
369
+ $plugin = get_plugins("/$name2");
370
+ }
371
+ if (count($plugin) > 0) {
372
+ if (isset(self::$plugins[$name]) && (isset($plugin["$name.php"]) || isset($plugin["$name2.php"]))) {
373
+ if ($version) {
374
+ if (self::$plugins[$name] == $plugin["$name.php"]['Version']) {
375
+ return true;
376
+ }
377
+ if (self::$plugins[$name] == $plugin["$name2.php"]['Version']) {
378
+ return true;
379
+ }
380
+ } else {
381
+ if (is_plugin_active("$name/$name.php") || is_plugin_active("$name/$name2.php") || is_plugin_active("$name2/$name2.php")) {
382
+ return true;
383
+ }
384
+ }
385
+ }
386
+ }
387
+ return false;
388
+ }
389
+ }
390
+ }
391
+ }
392
+
393
+ if (! function_exists('wpadm_plugins')) {
394
+ function wpadm_plugins()
395
+ {
396
+ global $wp_version;
397
+
398
+ $c = get_system_data();
399
+ $phpVersion = $c['php_verion'];
400
+ $maxExecutionTime = $c['maxExecutionTime'];
401
+ $maxMemoryLimit = $c['maxMemoryLimit'];
402
+ $extensions = $c['extensions'];
403
+ $disabledFunctions = $c['disabledFunctions'];
404
+ //try set new max time
405
+
406
+ $newMaxExecutionTime = $c['newMaxExecutionTime'];
407
+ $upMaxExecutionTime = $c['upMaxExecutionTime'];
408
+ $maxExecutionTime = $c['maxExecutionTime'];
409
+
410
+ //try set new memory limit
411
+ $upMemoryLimit = $c['upMemoryLimit'];
412
+ $newMemoryLimit = $c['newMemoryLimit'];
413
+ $maxMemoryLimit = $c['maxMemoryLimit'];
414
+
415
+ //try get mysql version
416
+ $mysqlVersion = $c['mysqlVersion'];
417
+
418
+ $show = !get_option('wpadm_pub_key') || (!is_super_admin() || !is_admin()) || !get_option(_PREFIX_STAT . 'counter_id');
419
+ ?>
420
+
421
+
422
+ <?php if (!$show) {?>
423
+ <div class="cfTabsContainer">
424
+ <div id="cf_signin" class="cfContentContainer" style="display: block;">
425
+ <form method="post" action="<?php echo WPADM_URL_BASE . "user/login" ; ?>" autocomplete="off" target="_blank">
426
+ <div class="inline" style="width: 52%; margin-top: 0; color: #fff;">
427
+ WPAdm Sign-In:
428
+ <input class="input-small" type="email" required="required" name="username" placeholder="Email">
429
+ <input class="input-small" type="password" required="required" name="password" placeholder="Password">
430
+ <input class="button-wpadm" type="submit" value="Sign-In" name="submit" style="margin-top:1px;">
431
+ </div>
432
+ <div class="wpadm-info-auth" style="width: 45%;">
433
+ Enter your email and password from an account at <a href="http://www.wpadm.com" target="_blank" style="color: #fff;" >www.wpadm.com</a>.<br /> After submitting user credentials you will be redirected to your Admin area on <a href="http://www.wpadm.com" style="color: #fff;" target="_blank">www.wpadm.com</a>.
434
+ </div>
435
+ </form>
436
+ </div>
437
+ </div>
438
+ <?php } else {?>
439
+ <div class="cfTabsContainer" style="display: none;">
440
+ <div id="cf_activate" class="cfContentContainer">
441
+ <form method="post" action="<?php echo admin_url( 'admin-post.php?action=wpadm_activate_plugin' )?>" >
442
+ <div class="wpadm-info-title">
443
+ Free Sign Up to use more functionality...
444
+ </div>
445
+ <div class="wpadm-registr-info">
446
+ <table class="form-table">
447
+ <tbody>
448
+ <tr valign="top">
449
+ <th scope="row">
450
+ <label for="email">E-mail</label>
451
+ </th>
452
+ <td>
453
+ <input id="email" class="regular-text" type="text" name="email" value="">
454
+ </td>
455
+ </tr>
456
+ <tr valign="top">
457
+ <th scope="row">
458
+ <label for="password">Password</label>
459
+ </th>
460
+ <td>
461
+ <input id="password" class="regular-text" type="password" name="password" value="">
462
+ </td>
463
+ </tr>
464
+ <tr valign="top">
465
+ <th scope="row">
466
+ <label for="password-confirm">Password confirm</label>
467
+ </th>
468
+ <td>
469
+ <input id="password-confirm" class="regular-text" type="password" name="password-confirm" value="">
470
+ </td>
471
+ </tr>
472
+ <tr valign="top">
473
+ <th scope="row">
474
+ </th>
475
+ <td>
476
+ <input class="button-wpadm" type="submit" value="Register & Activate" name="submit">
477
+ </td>
478
+ </tr>
479
+ </tbody>
480
+ </table>
481
+ </div>
482
+ <div class="wpadm-info">
483
+ <span style="font-weight:bold; font-size: 14px;">If you are NOT registered at WPAdm,</span> enter your email and password to use as your Account Data for authorization on WPAdm. <br /><span style="font-weight: bold;font-size: 14px;">If you already have an account at WPAdm</span> and you want to Sign-In, so please, enter your registered credential data (email and password twice).
484
+ </div>
485
+ </form>
486
+ </div>
487
+ </div>
488
+ <?php } ?>
489
+
490
+ <script>
491
+ jQuery(document).ready(function() {
492
+ jQuery('.plugins-icon').click(function() {
493
+ title = jQuery(this).parent('.plugins-title');
494
+ box = title.parent('.plugins-box');
495
+ content = box.find('.plugins-info-content');
496
+ display = content.css('display');
497
+ if (display == 'none') {
498
+ content.show('slow');
499
+ } else {
500
+ content.hide('slow');
501
+ }
502
+ })
503
+ })
504
+ function showRegistartion(show)
505
+ {
506
+ if (show) {
507
+ jQuery('.cfTabsContainer').show('slow');
508
+ } else {
509
+ jQuery('.cfTabsContainer').hide('slow');
510
+ }
511
+ }
512
+ </script>
513
+
514
+ <div class="clear" style="margin-bottom: 50px;"></div>
515
+ <table class="wp-list-table widefat fixed" >
516
+ <thead>
517
+ <tr>
518
+ <th></th>
519
+ <th>Recommended value</th>
520
+ <th>Your value</th>
521
+ <th>Status</th>
522
+ </tr>
523
+ </thead>
524
+ <tbody>
525
+ <tr>
526
+ <th scope="row">PHP Version</th>
527
+ <td><?php echo PHP_VERSION_DEFAULT ?> or greater</td>
528
+ <td><?php echo check_version($phpVersion , PHP_VERSION_DEFAULT) === false ? '<span style="color:#fb8004;font-weight:bold;">' . $phpVersion .'</span>' : $phpVersion ?></td>
529
+ <td><?php echo (check_version($phpVersion , PHP_VERSION_DEFAULT) ? '<span style="color:green;font-weight:bold;">OK</span>' : '<span style="color:#fb8004;font-weight:bold;">Please update Your version for correct working of plugin</span>') ?></td>
530
+ </tr>
531
+ <tr>
532
+ <th scope="row">MySQL Version</th>
533
+ <td><?php echo MYSQL_VERSION_DEFAULT ?> or greater</td>
534
+ <td><?php echo check_version($mysqlVersion , MYSQL_VERSION_DEFAULT) === false ? '<span style="color:#fb8004;font-weight:bold;">' . $mysqlVersion .'</span>' : $mysqlVersion; ?></td>
535
+ <td><?php echo (check_version($mysqlVersion , MYSQL_VERSION_DEFAULT) ? '<span style="color:green;font-weight:bold;">OK</span>' : '<span style="color:#fb8004;font-weight:bold;">Please update Your version for correct working of plugin</span>') ?></td>
536
+ </tr>
537
+ <tr>
538
+ <th scope="row">Max Execution Time</th>
539
+ <td><?php echo $newMaxExecutionTime ?></td>
540
+ <td><?php echo ($upMaxExecutionTime == 0) ? '<span style="color:#fb8004;font-weight:bold;">' . $maxExecutionTime .'</span>' : $maxExecutionTime; ?></td>
541
+ <td><?php echo ($upMaxExecutionTime == 1) ? '<span style="color:green; font-weight:bold;">OK</span>' : '<span style="color:#fb8004;font-weight:bold;">Correct operation of the plugin can not be guaranteed</span>'; ?></td>
542
+ </tr>
543
+ <tr>
544
+ <th scope="row">Max Memory Limit</th>
545
+ <td><?php echo $newMemoryLimit . 'M' ?></td>
546
+ <td><?php echo ($upMemoryLimit == 0) ? '<span style="color:#fb8004;font-weight:bold;">' . $maxMemoryLimit .'</span>' : $maxMemoryLimit ?></td>
547
+ <td><?php echo ($upMemoryLimit == 1) ? '<span style="color:green;font-weight:bold;">OK</span>' : '<span style="color:#fb8004;font-weight:bold;">Correct operation of the plugin can not be guaranteed.</span>'; ?></td>
548
+ </tr>
549
+ <tr>
550
+ <th scope="row">PHP Extensions</th>
551
+ <?php $ex = $c['ex']; ?>
552
+ <td><?php echo ( $ex ) === false ? 'All present' : '<span style="color:#ffba00;font-weight:bold;">' . implode(", ", $ex) . '</span>'; ?></td>
553
+ <td><?php echo ( $ex ) === false ? 'Found' : '<span style="color:#ffba00;font-weight:bold;">Not Found</span>'; ?></td>
554
+ <td><?php echo ( $ex ) === false ? '<span style="color:green;font-weight:bold;">Ok</span>' : '<span style="color:#fb8004;font-weight:bold;">Functionality is not guaranteed</span>'; ?></td>
555
+ </tr>
556
+ <tr>
557
+ <th scope="row">Disabled Functions</th>
558
+ <td colspan="3" align="left"><?php echo ( $func = $c['func']) === false ? '<span style="color:green;font-weight:bold;">All the necessary functions are enabled</span>' : '<span style="color:#fb8004;font-weight:bold;">Please enable these functions for correct work of plugin: ' . implode(", ", $func) . '</span>'; ?></td>
559
+ </tr>
560
+ <tr>
561
+ <th scope="row">Plugin Access</th>
562
+ <td colspan="3" align="left"><?php echo ( ( is_admin() && is_super_admin() ) ? "<span style=\"color:green; font-weight:bold;\">Granted</span>" : "<span style=\"color:red; font-weight:bold;\">You can't administrate this WPAdm Plugin(s) as it requires an 'Admin' access for this website</span>")?></td>
563
+ </tr>
564
+ </tbody>
565
+ </table>
566
+ <?php
567
+ }
568
+ }
569
+
570
+ if (! function_exists('check_function')) {
571
+ function check_function($func, $search, $type = false)
572
+ {
573
+ if (is_string($func)) {
574
+ $func = explode(", ", $func);
575
+ }
576
+ if (is_string($search)) {
577
+ $search = explode(", ", $search);
578
+ }
579
+ $res = false;
580
+ $n = count($search);
581
+ for($i = 0; $i < $n; $i++) {
582
+ if (in_array($search[$i], $func) === $type) {
583
+ $res[] = $search[$i];
584
+ }
585
+ }
586
+ return $res;
587
+ }
588
+ }
589
+
590
+ if (! function_exists('check_version')) {
591
+ function check_version($ver, $ver2)
592
+ {
593
+ return version_compare($ver, $ver2, ">");
594
+ }
595
+ }
596
+ if (!function_exists("get_system_data")) {
597
+ function get_system_data()
598
+ {
599
+
600
+ global $wp_version;
601
+
602
+ $phpVersion = phpversion();
603
+ $maxExecutionTime = ini_get('max_execution_time');
604
+ $maxMemoryLimit = ini_get('memory_limit');
605
+ $extensions = implode(', ', get_loaded_extensions());
606
+ $disabledFunctions = ini_get('disable_functions');
607
+ $mysqlVersion = '';
608
+ $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD);
609
+ if (!mysqli_connect_errno()) {
610
+ $mysqlVersion = $mysqli->server_info;
611
+ }
612
+ $upMaxExecutionTime = 0;
613
+ $newMaxExecutionTime = intval($maxExecutionTime) + 60;
614
+ @set_time_limit( $newMaxExecutionTime );
615
+ if( ini_get('max_execution_time') == $newMaxExecutionTime ){
616
+ $upMaxExecutionTime = 1;
617
+ $maxExecutionTime = ini_get('max_execution_time');
618
+ }
619
+ $upMemoryLimit = 0;
620
+ $newMemoryLimit = intval($maxMemoryLimit) + 60;
621
+ ini_set('memory_limit', $newMemoryLimit.'M');
622
+ if( ini_get('memory_limit') == $newMemoryLimit ){
623
+ $upMemoryLimit = 1;
624
+ $maxMemoryLimit = ini_get('memory_limit');
625
+ }
626
+ $extensions_search = array('curl', 'json', 'mysqli', 'sockets', 'zip', 'ftp');
627
+ $disabledFunctions_search = array('set_time_limit', 'curl_init', 'fsockopen', 'ftp_connect');
628
+
629
+ $ex = check_function($extensions, $extensions_search);
630
+ $func = check_function($disabledFunctions, $disabledFunctions_search, true);
631
+
632
+ return array('wp_version' => $wp_version, 'php_verion' => phpversion(),
633
+ 'maxExecutionTime' => $maxExecutionTime, 'maxMemoryLimit' => $maxMemoryLimit,
634
+ 'extensions' => $extensions, 'disabledFunctions' => $disabledFunctions,
635
+ 'mysqlVersion' => $mysqlVersion, 'upMaxExecutionTime' => $upMaxExecutionTime,
636
+ 'newMaxExecutionTime' => $newMaxExecutionTime, 'upMemoryLimit' => $upMemoryLimit,
637
+ 'newMemoryLimit' => $newMaxExecutionTime, 'maxMemoryLimit' => $maxMemoryLimit,
638
+ 'ex' => $ex, 'func' => $func, 'wp_lang' => get_option('WPLANG'),
639
+ );
640
+
641
+ }
642
+ }
643
+
644
+ ?>
methods/class-wpadm-method-full-backup-dropbox.php CHANGED
@@ -140,7 +140,7 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
140
  $size = 0;
141
  $files2[$i] = array();
142
  }
143
- $f_size =(int)@filesize($f);
144
  if ($f_size == 0 || $f_size > 1000000) {
145
  WPAdm_Core::log('file '. $f .' size ' . $f_size);
146
  }
@@ -330,11 +330,16 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
330
 
331
  WPAdm_Core::log('Creating a backup is completed');
332
 
 
333
  if (!empty($errors)) {
334
  $this->result->setError(implode("\n", $errors));
335
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
 
 
 
 
336
  }
337
-
338
  return $this->result;
339
 
340
 
@@ -435,7 +440,9 @@ if (!class_exists('WPadm_Method_Full_Backup_Dropbox')) {
435
  $d1 = mb_strtolower($tmp[0]);
436
  unset($tmp[0]);
437
  $d2 = mb_strtolower(implode('/', $tmp));
438
- if (strpos($d2, 'cache') !== false && isset($tmp[0]) && !in_array($tmp[0], array('plugins', 'themes')) ) {
 
 
439
  WPAdm_Core::log('Skip dir(cache) ' . $directory);
440
  return array();
441
  }
140
  $size = 0;
141
  $files2[$i] = array();
142
  }
143
+ $f_size =(int)filesize($f);
144
  if ($f_size == 0 || $f_size > 1000000) {
145
  WPAdm_Core::log('file '. $f .' size ' . $f_size);
146
  }
330
 
331
  WPAdm_Core::log('Creating a backup is completed');
332
 
333
+ wpadm_class::setBackup(2);
334
  if (!empty($errors)) {
335
  $this->result->setError(implode("\n", $errors));
336
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
337
+ wpadm_class::setStatus(0);
338
+ wpadm_class::setErrors( implode(", ", $errors) );
339
+ } else {
340
+ wpadm_class::setStatus(1);
341
  }
342
+ wpadm_class::backupSend();
343
  return $this->result;
344
 
345
 
440
  $d1 = mb_strtolower($tmp[0]);
441
  unset($tmp[0]);
442
  $d2 = mb_strtolower(implode('/', $tmp));
443
+ if (strpos($d2, 'cache') !== false
444
+ && !in_array($tmp[0], array('plugins', 'themes'))
445
+ ) {
446
  WPAdm_Core::log('Skip dir(cache) ' . $directory);
447
  return array();
448
  }
methods/class-wpadm-method-local-backup.php CHANGED
@@ -3,6 +3,8 @@
3
  if (!class_exists('WPAdm_Method_Local_Backup')) {
4
  class WPAdm_Method_Local_Backup extends WPAdm_Method_Class {
5
 
 
 
6
  public function __construct($params)
7
  {
8
  parent::__construct($params);
@@ -23,20 +25,42 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
23
 
24
  $name = str_replace("http://", '', $name);
25
  $name = str_replace("https://", '', $name);
26
- $name = preg_replace("|\W|", "_", $name);
27
- $this->time = date("d.m.Y H:i"); //23.04.2015 13:45
28
- $name .= '-' . wpadm_class::$type . '-' . date("Y_m_d_H_i");
 
 
 
 
 
29
  $this->name = $name;
30
-
31
 
32
  // folder for backup
33
  $this->dir = ABSPATH . 'wpadm_backups/' . $this->name;
 
 
 
34
  WPAdm_Core::mkdir(ABSPATH . 'wpadm_backups/');
35
  WPAdm_Core::mkdir($this->dir);
36
  }
 
 
 
 
 
 
 
 
 
 
37
  public function getResult()
38
  {
39
-
 
 
 
 
40
  $errors = array();
41
 
42
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_SUCCESS);
@@ -54,7 +78,6 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
54
  }
55
  $wp_mysql_params = $this->getWpMysqlParams();
56
 
57
- // Table Optimization
58
  if (isset($this->params['optimize']) && ($this->params['optimize']==1)) {
59
  WPAdm_Core::log('Optimize Database Tables');
60
  $commandContext = new WPAdm_Command_Context();
@@ -67,7 +90,7 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
67
  ->add($commandContext);
68
  unset($commandContext);
69
  }
70
- // Creating of Database Backup
71
  $commandContext = new WPAdm_Command_Context();
72
  $commandContext ->addParam('command','mysqldump')
73
  ->addParam('host', $wp_mysql_params['host'])
@@ -86,13 +109,15 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
86
  $errors[] = 'MySQL Error: Database-Dump File is empty';
87
  WPAdm_Core::log('Dump of Database wasn\'t created (File of Database-Dump is empty!)');
88
  } else {
89
- WPAdm_Core::log('Database Dump was successfully created('.filesize($mysql_dump_file).'b):' . $mysql_dump_file);
 
90
  }
91
  unset($commandContext);
92
  }
93
 
94
 
95
  if (in_array('files', $this->params['types']) ) {
 
96
  WPAdm_Core::log('Create a list of files for Backup');
97
  $files = $this->createListFilesForArchive();
98
  }
@@ -115,7 +140,7 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
115
  $size = 0;
116
  $files2[$i] = array();
117
  }
118
- $f_size =(int)filesize($f);
119
  if ($f_size == 0 || $f_size > 1000000) {
120
  WPAdm_Core::log('File '. $f .' Size ' . $f_size);
121
  }
@@ -126,7 +151,7 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
126
  WPAdm_Core::log('List of Backup-Files was successfully created');
127
 
128
  $this->queue->clear();
129
- // Adding Wordpress Files and MySQL Dump to Archive
130
  foreach($files2 as $files) {
131
  $commandContext = new WPAdm_Command_Context();
132
  $commandContext ->addParam('command', 'archive')
@@ -184,17 +209,21 @@ if (!class_exists('WPAdm_Method_Local_Backup')) {
184
  }
185
  WPAdm_Core::log('Removing of old Backups was Finished');
186
  }
 
187
  if (!empty($errors)) {
188
  $this->result->setError(implode("\n", $errors));
189
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
 
 
190
  } else {
 
191
  WPAdm_Core::log('Backup creating is completed successfully!');
192
  }
 
193
 
194
  return $this->result;
195
 
196
  }
197
-
198
  public function createListFilesForArchive() {
199
  $folders = array();
200
  $files = array();
3
  if (!class_exists('WPAdm_Method_Local_Backup')) {
4
  class WPAdm_Method_Local_Backup extends WPAdm_Method_Class {
5
 
6
+ private $start = true;
7
+
8
  public function __construct($params)
9
  {
10
  parent::__construct($params);
25
 
26
  $name = str_replace("http://", '', $name);
27
  $name = str_replace("https://", '', $name);
28
+ $name = preg_replace("|\W|", "_", $name);
29
+ if (isset($params['time']) && !empty($params['time'])) { // time 1432751372
30
+ $this->time = date("d.m.Y H:i", $params['time']);
31
+ $name .= '-' . wpadm_class::$type . '-' . date("Y_m_d_H_i", $params['time']);
32
+ } else {
33
+ $this->time = date("d.m.Y H:i"); //23.04.2015 13:45
34
+ $name .= '-' . wpadm_class::$type . '-' . date("Y_m_d_H_i");
35
+ }
36
  $this->name = $name;
37
+
38
 
39
  // folder for backup
40
  $this->dir = ABSPATH . 'wpadm_backups/' . $this->name;
41
+ if (($f = $this->checkBackup()) !== false) {
42
+ $this->dir = ABSPATH . 'wpadm_backups/' . $f;
43
+ }
44
  WPAdm_Core::mkdir(ABSPATH . 'wpadm_backups/');
45
  WPAdm_Core::mkdir($this->dir);
46
  }
47
+ public function checkBackup()
48
+ {
49
+ $archives = glob("{$this->dir}");
50
+ if (empty($archives) && count($archives) <= 1) {
51
+ return false;
52
+ }
53
+ $n = count($archives);
54
+ $f = "{$this->name}({$n})";
55
+ return $f;
56
+ }
57
  public function getResult()
58
  {
59
+ if ($this->start === false) {
60
+ $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
61
+ $this->result->setError('Backup process was started, please, wait a few minutes...');
62
+ return $this->result;
63
+ }
64
  $errors = array();
65
 
66
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_SUCCESS);
78
  }
79
  $wp_mysql_params = $this->getWpMysqlParams();
80
 
 
81
  if (isset($this->params['optimize']) && ($this->params['optimize']==1)) {
82
  WPAdm_Core::log('Optimize Database Tables');
83
  $commandContext = new WPAdm_Command_Context();
90
  ->add($commandContext);
91
  unset($commandContext);
92
  }
93
+
94
  $commandContext = new WPAdm_Command_Context();
95
  $commandContext ->addParam('command','mysqldump')
96
  ->addParam('host', $wp_mysql_params['host'])
109
  $errors[] = 'MySQL Error: Database-Dump File is empty';
110
  WPAdm_Core::log('Dump of Database wasn\'t created (File of Database-Dump is empty!)');
111
  } else {
112
+ $size_dump = round( (filesize($mysql_dump_file) / 1024 / 1024) , 2);
113
+ WPAdm_Core::log('Database Dump was successfully created(' . $size_dump . 'Mb):' . $mysql_dump_file);
114
  }
115
  unset($commandContext);
116
  }
117
 
118
 
119
  if (in_array('files', $this->params['types']) ) {
120
+ #ЗАРХИВИРУЕМ ФАЙЛЫ
121
  WPAdm_Core::log('Create a list of files for Backup');
122
  $files = $this->createListFilesForArchive();
123
  }
140
  $size = 0;
141
  $files2[$i] = array();
142
  }
143
+ $f_size =(int)@filesize($f);
144
  if ($f_size == 0 || $f_size > 1000000) {
145
  WPAdm_Core::log('File '. $f .' Size ' . $f_size);
146
  }
151
  WPAdm_Core::log('List of Backup-Files was successfully created');
152
 
153
  $this->queue->clear();
154
+
155
  foreach($files2 as $files) {
156
  $commandContext = new WPAdm_Command_Context();
157
  $commandContext ->addParam('command', 'archive')
209
  }
210
  WPAdm_Core::log('Removing of old Backups was Finished');
211
  }
212
+ wpadm_class::setBackup(1);
213
  if (!empty($errors)) {
214
  $this->result->setError(implode("\n", $errors));
215
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
216
+ wpadm_class::setStatus(0);
217
+ wpadm_class::setErrors( implode(", ", $errors) );
218
  } else {
219
+ wpadm_class::setStatus(1);
220
  WPAdm_Core::log('Backup creating is completed successfully!');
221
  }
222
+ wpadm_class::backupSend();
223
 
224
  return $this->result;
225
 
226
  }
 
227
  public function createListFilesForArchive() {
228
  $folders = array();
229
  $files = array();
methods/class-wpadm-method-queue-controller.php CHANGED
@@ -76,13 +76,14 @@ if (!class_exists('WPAdm_Method_Queue_Controller')) {
76
  $this->done();
77
  return $this->result;
78
  } elseif (!$cmd->execute($context)) {
 
79
  $this->result->setError('Command error:' . $com . ': '. $context->getError());
80
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
81
  array_unshift($this->contexts, $context);
82
  $this->done();
83
  return $this->result;
84
  } else {
85
- //
86
  //WPAdm_Core::log("Команда выполнена: {$com}");
87
  }
88
  //продолжаем работу
@@ -139,13 +140,9 @@ if (!class_exists('WPAdm_Method_Queue_Controller')) {
139
  'sign' => '',
140
 
141
  );
142
- /**
143
- *
144
- * request to itself to predict multitasking
145
- *
146
- */
147
  $socket = fsockopen($host, 80, $errno, $errstr, 30);
148
-
149
  $dp = explode(DIRECTORY_SEPARATOR,dirname(dirname(__FILE__)));
150
  $pl = array_pop($dp) . '_';
151
  // $data = 'wpadm_'.$pl.'request='.base64_encode(serialize($data));
76
  $this->done();
77
  return $this->result;
78
  } elseif (!$cmd->execute($context)) {
79
+ //произошла какая то ошибка
80
  $this->result->setError('Command error:' . $com . ': '. $context->getError());
81
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
82
  array_unshift($this->contexts, $context);
83
  $this->done();
84
  return $this->result;
85
  } else {
86
+ //команда выполнена успешно
87
  //WPAdm_Core::log("Команда выполнена: {$com}");
88
  }
89
  //продолжаем работу
140
  'sign' => '',
141
 
142
  );
143
+
 
 
 
 
144
  $socket = fsockopen($host, 80, $errno, $errstr, 30);
145
+ // $pl = (defined('WPADM_PLUGIN')) ? WPADM_PLUGIN . '_' : '';
146
  $dp = explode(DIRECTORY_SEPARATOR,dirname(dirname(__FILE__)));
147
  $pl = array_pop($dp) . '_';
148
  // $data = 'wpadm_'.$pl.'request='.base64_encode(serialize($data));
methods/class-wpadm-method-send-to-dropbox.php CHANGED
@@ -25,13 +25,13 @@ if (!class_exists('WPadm_Method_Send_To_Dropbox')) {
25
  $this->queue = new WPAdm_Queue($this->id);
26
 
27
  $ad = $this->params['access_details'];
28
- WPAdm_Core::log('Copying of Files to Dropbox');
29
  $this->queue->clear();
30
  $files = $this->params['files'];
31
  //$this->getResult()->setData($files);
32
 
33
  $dir = (isset($ad['dir'])) ? $ad['dir'] : '/';
34
- // Task creating to copy files to Dropbox
35
  foreach($files as $file) {
36
  $commandContext = new WPAdm_Command_Context();
37
  $commandContext->addParam('command', 'send_to_dropbox')
@@ -50,17 +50,17 @@ if (!class_exists('WPadm_Method_Send_To_Dropbox')) {
50
  WPAdm_Core::log('Dropbox: ' . $this->queue->getError());
51
  $errors[] = 'Dropbox: '.$this->queue->getError();
52
  }
53
- WPAdm_Core::log('End of copying files to Dropbox');
54
  if (count($errors) > 0) {
55
  $this->result->setError(implode("\n", $errors));
56
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
57
- }
58
 
59
  return $this->result;
60
 
61
 
62
  }
63
-
64
  private function init(array $conf) {
65
  //todo: нормализация
66
  $this->id = $conf['id'];
25
  $this->queue = new WPAdm_Queue($this->id);
26
 
27
  $ad = $this->params['access_details'];
28
+ WPAdm_Core::log('Start copy to Dropbox Cloud');
29
  $this->queue->clear();
30
  $files = $this->params['files'];
31
  //$this->getResult()->setData($files);
32
 
33
  $dir = (isset($ad['dir'])) ? $ad['dir'] : '/';
34
+ //$dir = trim($dir, '/') . '/' . $this->name;
35
  foreach($files as $file) {
36
  $commandContext = new WPAdm_Command_Context();
37
  $commandContext->addParam('command', 'send_to_dropbox')
50
  WPAdm_Core::log('Dropbox: ' . $this->queue->getError());
51
  $errors[] = 'Dropbox: '.$this->queue->getError();
52
  }
53
+ WPAdm_Core::log('End Copy Files to Dropbox');
54
  if (count($errors) > 0) {
55
  $this->result->setError(implode("\n", $errors));
56
  $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR);
57
+ }
58
 
59
  return $this->result;
60
 
61
 
62
  }
63
+
64
  private function init(array $conf) {
65
  //todo: нормализация
66
  $this->id = $conf['id'];
methods/class-wpadm-method-update.php CHANGED
@@ -58,6 +58,7 @@ 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
  if (isset($f['body']) && !empty($f['body'])) {
62
  file_put_contents($d_ . "/" . $b, $f['body']);
63
  if (file_exists($d_ . "/" . $b)) {
@@ -83,10 +84,10 @@ if (!class_exists('WPAdm_Method_Update')) {
83
  PCLZIP_OPT_REPLACE_NEWER,
84
  PCLZIP_OPT_REMOVE_PATH, WPAdm_Core::$plugin_name
85
  );
 
86
  if ( $res ) {
87
  return true;
88
  }
89
- WPAdm_Core::log($this->archive->errorInfo(true));
90
  return false;
91
  }
92
  }
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)) {
84
  PCLZIP_OPT_REPLACE_NEWER,
85
  PCLZIP_OPT_REMOVE_PATH, WPAdm_Core::$plugin_name
86
  );
87
+ WPAdm_Core::log($this->archive->errorInfo(true));
88
  if ( $res ) {
89
  return true;
90
  }
 
91
  return false;
92
  }
93
  }
modules/class-wpadm-command-context.php CHANGED
@@ -1,28 +1,32 @@
1
- <?php
2
- if (!class_exists('WPAdm_Command_Context')) {
3
- class WPAdm_Command_Context {
4
- private $params = array();
5
- private $error = '';
6
-
7
- public function addParam($key, $val)
8
- {
9
- $this->params[$key] = $val;
10
- return $this;
11
- }
12
-
13
- public function get($key)
14
- {
15
- return $this->params[$key];
16
- }
17
-
18
- public function setError($error)
19
- {
20
- $this->error = $error;
21
- return $this;
22
- }
23
-
24
- public function getError() {
25
- return $this->error;
26
- }
27
- }
 
 
 
 
28
  }
1
+ <?php
2
+ if (!class_exists('WPAdm_Command_Context')) {
3
+ class WPAdm_Command_Context {
4
+ private $params = array();
5
+ private $error = '';
6
+
7
+ public function addParam($key, $val)
8
+ {
9
+ $this->params[$key] = $val;
10
+ return $this;
11
+ }
12
+
13
+ public function get($key)
14
+ {
15
+ if (isset($this->params[$key])) {
16
+ return $this->params[$key];
17
+ } else {
18
+ return false;
19
+ }
20
+ }
21
+
22
+ public function setError($error)
23
+ {
24
+ $this->error = $error;
25
+ return $this;
26
+ }
27
+
28
+ public function getError() {
29
+ return $this->error;
30
+ }
31
+ }
32
  }
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
- === DropBox Backup ===
2
- Plugin Name: DropBox Backup
3
- Version: 1.1
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, web page backup, site, site backup, back up, cloud, Cloud Files, db backup, dump, german, migrate, multisite, Russian, schedule, storage, time, upload
7
  Requires at least: 4.0.0
8
  Tested up to: 4.2.2
9
  Stable tag: trunk
@@ -12,27 +12,30 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  Author: WPAdm.com
13
  Contributors: WPAdm.com
14
 
15
- DropBox Backup Plugin to create DropBox Full Backup (Files + Database) of your Web Page
16
 
17
  == Description ==
18
 
19
- Supports WordPress backups to Local Storage or upload to DropBox.
20
 
21
- * Local Backup: create the Full Backup of Web Page (Files + Database) and store this at Local Storage of the Site
22
- * DropBox Backup: create the Full Backup (Files + Database) of Web Page at Local Storage and upload this to DropBox
 
23
 
24
 
 
 
25
 
26
  If you need help with the plugin or you want to report a bug please refer to http://www.wpadm.com/support/
27
 
28
  == Installation ==
29
 
30
- 1. Upload the plugin folder `DropBox Backup` to the `/wp-content/plugins/` directory of your WordPress installation.
31
  2. Activate the plugin through the `Plugins` menu in WordPress
32
 
33
 
34
 
35
- DropBox Backup Plugin have a settings section on WordPress plugin page.
36
  If you need help with the plugin or you want to report a bug please refer to http://www.wpadm.com/support/
37
 
38
  == Other ==
@@ -43,4 +46,25 @@ DropBox Backup is a new plugin, so we tryed have to provide a bug-free plugin/wi
43
  Information about privacy: AFTER the user has been registered at WPAdm service AND has confirmed their registration,
44
  our plugin will get the minimum requirements of php and mysql configuration, version and language of wordpress.
45
  This data will be send to WPAdm service, to get the plugin work correctly, to extend supported configurations of user sites with wpadm-extensions and support.
46
- WE DO NOT COLLECT AND DO NOT STORE THE PERSONAL DATA OF USERS FROM THIS PLUGIN!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Dropbox Backup ===
2
+ Plugin Name: Dropbox Backup
3
+ Version: 1.2.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, web page backup, site, site backup, back up, cloud, Cloud Files, cloud backup, db backup, dump, german, migrate, multisite, Russian, schedule, storage, time, upload, data bank
7
  Requires at least: 4.0.0
8
  Tested up to: 4.2.2
9
  Stable tag: trunk
12
  Author: WPAdm.com
13
  Contributors: WPAdm.com
14
 
15
+ Dropbox Backup Plugin to create Dropbox Full Backup (Files + Database) of your Web Page
16
 
17
  == Description ==
18
 
19
+ Supports WordPress Backups to Local Storage or upload Backup to Dropbox.
20
 
21
+ * Local Backup: create the Full Backup of Web Page (Files + Database) and store this at Local Storage of the Site;
22
+ * DropBox Backup: create the Full Backup (Files + Database) of Web Page at Local Storage and upload this to Dropbox;
23
+ * Administrate ALL of Backups for ALL of your sites from one place – WPAdm-account (FULLY FREE);
24
 
25
 
26
+ You can create your WPAdm account for central Backup administration at http://www.wpadm.com
27
+ WPAdm account is FULLY FREE.
28
 
29
  If you need help with the plugin or you want to report a bug please refer to http://www.wpadm.com/support/
30
 
31
  == Installation ==
32
 
33
+ 1. Upload the plugin folder `Dropbox Backup` to the `/wp-content/plugins/` directory of your WordPress installation.
34
  2. Activate the plugin through the `Plugins` menu in WordPress
35
 
36
 
37
 
38
+ Dropbox Backup Plugin have a settings section on WordPress plugin page.
39
  If you need help with the plugin or you want to report a bug please refer to http://www.wpadm.com/support/
40
 
41
  == Other ==
46
  Information about privacy: AFTER the user has been registered at WPAdm service AND has confirmed their registration,
47
  our plugin will get the minimum requirements of php and mysql configuration, version and language of wordpress.
48
  This data will be send to WPAdm service, to get the plugin work correctly, to extend supported configurations of user sites with wpadm-extensions and support.
49
+ WE DO NOT COLLECT AND DO NOT STORE THE PERSONAL DATA OF USERS FROM THIS PLUGIN!
50
+
51
+ == Frequently Asked Questions ==
52
+
53
+ = Where I get my app key & secret? =
54
+
55
+ You can get an API app key and secret by creating an app on the <a href="https://www.dropbox.com/developers/apps/create?app_type_checked=api" target="_blank">app creation page</a>.
56
+ Once you have an app created, the app key and secret will be available on the app's page on the <a href="https://www.dropbox.com/developers/apps" target="_blank">App Console</a>.
57
+ Note that Drop-ins have app keys but no app secrets.
58
+
59
+ == Changelog ==
60
+
61
+ ChangeLog
62
+
63
+ == Upgrade Notice ==
64
+
65
+ Upgrade Notice
66
+
67
+ == Screenshots ==
68
+
69
+
70
+ Screens coming soon
{css → template/css}/admin-style-wpadm.css RENAMED
@@ -1,38 +1,45 @@
1
 
2
- .wpadm-notice {
3
- background: #fff;
4
- border-left: 4px solid #dd3d36;
5
- box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
6
- font-size: 16px;
7
- overflow: hidden;
8
- position: relative;
9
- text-align: left;
10
- clear: both;
11
- height: 60px;
12
- margin-top: 15px;
13
- width: 95%;
14
- }
15
- .button-link {
16
- background:none!important;
17
- border:none;
18
- padding:0!important;
19
- font: inherit;
20
- color:#0074a2;
21
- border-bottom:1px solid #0074a2;
22
- padding-bottom: 1px;
23
- cursor: pointer;
24
- line-height: 15px;
25
- }
26
- .button-link:hover {
27
- color:#2ea2cc;
28
- border-bottom:1px solid #2ea2cc;
 
 
 
 
 
 
 
 
 
29
  }
30
- .wpadm-notice div.registr {
31
- margin-top : 20px;
32
- font-size: 16px;
33
- margin-left: 15px;
34
  }
35
-
36
  .form-counter {
37
  background: #0096d6;
38
  border: 1px solid #fff;
@@ -41,6 +48,99 @@
41
  margin-top: 20px;
42
  color:#fff;
43
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  .form-counter table tr td{
46
  padding: 10px;
@@ -280,16 +380,32 @@ h3.plugins-title {
280
  font-size:16px;
281
 
282
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  .table td {
284
  background: #fff;
285
- font-size: 14px;
286
  padding: 5px 0;
287
  border-bottom:1px solid #b7c6ff;
288
  text-align: center;
289
  }
290
  .info-path td {
291
- font-size: 11px;
292
- padding:0px;
293
  }
294
  .table tr:last td {
295
 
@@ -610,9 +726,8 @@ font-size: 10px;
610
  margin-bottom: 10px;
611
  padding-left: 0px;
612
  width:88%;
613
-
614
-
615
  }
 
616
  .stat-table-registr th, .stat-table-registr td {
617
  padding:2px;
618
  font-size:10px;
@@ -621,6 +736,9 @@ font-size:10px;
621
  margin-top: 10px;
622
  float:none;
623
  }
 
 
 
624
  .form-table th {
625
  line-height: 10px;
626
  }
1
 
2
+ .backup_button {
3
+ -moz-box-shadow:inset 0px 1px 0px 0px #9fb4f2;
4
+ -webkit-box-shadow:inset 0px 1px 0px 0px #9fb4f2;
5
+ box-shadow:inset 0px 1px 0px 0px #9fb4f2;
6
+ background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #7892c2), color-stop(1, #476e9e));
7
+ background:-moz-linear-gradient(top, #7892c2 5%, #476e9e 100%);
8
+ background:-webkit-linear-gradient(top, #7892c2 5%, #476e9e 100%);
9
+ background:-o-linear-gradient(top, #7892c2 5%, #476e9e 100%);
10
+ background:-ms-linear-gradient(top, #7892c2 5%, #476e9e 100%);
11
+ background:linear-gradient(to bottom, #7892c2 5%, #476e9e 100%);
12
+ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#7892c2', endColorstr='#476e9e',GradientType=0);
13
+ background-color:#7892c2;
14
+ -moz-border-radius:3px;
15
+ -webkit-border-radius:3px;
16
+ border-radius:3px;
17
+ border:1px solid #4e6096;
18
+ display:inline-block;
19
+ cursor:pointer;
20
+ color:#ffffff;
21
+ font-family:Arial;
22
+ font-size:17px;
23
+ font-weight:bold;
24
+ padding:10px 20px;
25
+ text-decoration:none;
26
+ text-shadow:0px 1px 0px #283966;
27
+ }
28
+ .backup_button:hover {
29
+ background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #476e9e), color-stop(1, #7892c2));
30
+ background:-moz-linear-gradient(top, #476e9e 5%, #7892c2 100%);
31
+ background:-webkit-linear-gradient(top, #476e9e 5%, #7892c2 100%);
32
+ background:-o-linear-gradient(top, #476e9e 5%, #7892c2 100%);
33
+ background:-ms-linear-gradient(top, #476e9e 5%, #7892c2 100%);
34
+ background:linear-gradient(to bottom, #476e9e 5%, #7892c2 100%);
35
+ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#476e9e', endColorstr='#7892c2',GradientType=0);
36
+ background-color:#476e9e;
37
+ color:#fff;
38
  }
39
+ .backup_button:active {
40
+ position:relative;
41
+ top:1px;
 
42
  }
 
43
  .form-counter {
44
  background: #0096d6;
45
  border: 1px solid #fff;
48
  margin-top: 20px;
49
  color:#fff;
50
  }
51
+ .log-dropbox {
52
+ background-repeat: no-repeat; background-position:center;
53
+ background-color: #fff;
54
+ height: 211px;
55
+ width: 170px;
56
+ float: left;
57
+ margin-top:-4px;
58
+ border: 1px solid #47a3ec;
59
+ border-radius:3px;
60
+ }
61
+ .block-content {
62
+ background-color: #fff;
63
+ border: 1px solid #e8e8e8;
64
+ padding: 10px;
65
+ }
66
+ #logs-form, #reviews-dropbox, #action-buttons {
67
+ float:left;
68
+ }
69
+ #logs-form, #reviews-dropbox {
70
+ padding: 10px; background: #ffffc8; border: 1px solid #0096d6; position: relative; height: 100px; text-align: center;
71
+ }
72
+ #reviews-dropbox {
73
+ float: right;
74
+ height: 150px;
75
+ width: 25%;
76
+ }
77
+ #action-buttons {
78
+ margin-right: 10px;
79
+ float:left;
80
+ margin-top:130px;
81
+ }
82
+ .form-field {
83
+ padding-top: 0px;
84
+ margin-bottom: 5px;
85
+ float: left;
86
+ margin-left:5px;
87
+ }
88
+
89
+ .title-reviews {
90
+ font-size: 20px;
91
+ margin-bottom: 24px;
92
+ margin-top:23px;
93
+ }
94
+ .desc-reviews {
95
+ font-size: 16px;
96
+ margin-top:10px;
97
+ margin-bottom: 20px;
98
+ }
99
+
100
+ .btn-danger {
101
+ background-color: #da4f49;
102
+ background-image: linear-gradient(to bottom, #ee5f5b, #bd362f);
103
+ background-repeat: repeat-x;
104
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
105
+ color: #fff;
106
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
107
+ border-radius: 3px;
108
+ font-size: 11.9px;
109
+ padding: 2px 10px;
110
+ cursor: pointer;
111
+ }
112
+ .btn-orange {
113
+ background-color: #f48326;
114
+ background-image: linear-gradient(to bottom, #cc5d00, #cc5d00);
115
+ background-repeat: repeat-x;
116
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
117
+ color: #fff;
118
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
119
+ border-radius: 3px;
120
+ font-size: 11.9px;
121
+ padding: 2px 10px;
122
+ cursor: pointer;
123
+ }
124
+ .btn-orange:hover {
125
+ color:#fff;
126
+ background-color: #f38325 ;
127
+ background-position: 0 -30px;
128
+ text-decoration: none;
129
+ transition: background-position 0.1s linear 0s;
130
+ }
131
+ .desc-wpadm {
132
+ clear: both;
133
+ color: #fff;
134
+ font-size: 12px;
135
+ font-style: italic;
136
+ }
137
+ .btn-danger:hover {
138
+ color:#fff;
139
+ background-color: #db362f ;
140
+ background-position: 0 -30px;
141
+ text-decoration: none;
142
+ transition: background-position 0.1s linear 0s;
143
+ }
144
 
145
  .form-counter table tr td{
146
  padding: 10px;
380
  font-size:16px;
381
 
382
  }
383
+ .title-logs, .title-status {
384
+ margin-bottom: 10px;
385
+ }
386
+ .help-key-secret {
387
+ font-size: 11px;
388
+ text-align: right;
389
+ color:#fff;
390
+ cursor: pointer;
391
+ }
392
+ .help-key-secret:hover {
393
+ color:#fff;
394
+ text-decoration:underline;
395
+ }
396
+ #log-backup div {
397
+ font-size:12px;
398
+ }
399
  .table td {
400
  background: #fff;
401
+ font-size: 12px;
402
  padding: 5px 0;
403
  border-bottom:1px solid #b7c6ff;
404
  text-align: center;
405
  }
406
  .info-path td {
407
+ font-size: 11px;
408
+ padding:0px;
409
  }
410
  .table tr:last td {
411
 
726
  margin-bottom: 10px;
727
  padding-left: 0px;
728
  width:88%;
 
 
729
  }
730
+
731
  .stat-table-registr th, .stat-table-registr td {
732
  padding:2px;
733
  font-size:10px;
736
  margin-top: 10px;
737
  float:none;
738
  }
739
+ .form-table label {
740
+ color:#fff;
741
+ }
742
  .form-table th {
743
  line-height: 10px;
744
  }
template/js/admin-wpadm.js ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function showTab (elem, type)
2
+ {
3
+ jQuery('.cfTab').removeClass('selected');
4
+ jQuery('.cfContentContainer').hide();
5
+ jQuery(elem).addClass('selected');
6
+ jQuery('#cf_' + type).fadeIn();
7
+ }
8
+
9
+ var shows_id = ""
10
+ function shows(id)
11
+ {
12
+ if(document.getElementById(id).style.display == "none") {
13
+ document.getElementById(id).style.display = "table-row";
14
+ if (shows_id == "") {
15
+ shows_id = id;
16
+ } else {
17
+ if(shows_id != id) {
18
+ document.getElementById(shows_id).style.display = "none";
19
+ }
20
+ shows_id = id;
21
+ }
22
+ } else if(document.getElementById(id).style.display == "table-row") {
23
+ document.getElementById(id).style.display = "none";
24
+ }
25
+ }
26
+ var bl = false;
27
+ function show_form_auth(file_val)
28
+ {
29
+ if (file_val == 'registr') {
30
+ showRegistInfo(false);
31
+ if (bl === false) {
32
+ blick('container-user');
33
+ bl = true;
34
+ }
35
+ } else {
36
+ html = '<input type="hidden" value="' + file_val +'" name="internal_identifier">';
37
+ jQuery('#form_auth_backup').html(html);
38
+ document.form_auth_backup.submit();
39
+ }
40
+ }
41
+ var blick_form = true;
42
+ function blick(id, border_)
43
+ {
44
+ if (border_ == 'undefined') {
45
+ border_ = 10;
46
+ }
47
+ jQuery('#' + id).css({
48
+ outline: "0px solid #cd433d",
49
+ border: "0px"
50
+ }).animate({
51
+ outlineWidth: border_ + 'px',
52
+ outlineColor: '#cd433d'
53
+ }, 400).animate({outlineWidth: '0px',outlineColor: '#cd433d' } , 400);
54
+ if (blick_form) {
55
+ setTimeout('blick("' + id + '", ' + border_ + ')', 800);
56
+ }
57
+ }
template/js/jquery.arcticmodal-0.3.css ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ .arcticmodal-overlay,
2
+ .arcticmodal-container { position: fixed; left: 0; top: 0; right: 0; bottom: 0; z-index: 99999; }
3
+ .arcticmodal-container { overflow: auto; margin: 0; padding: 0; border: 0; border-collapse: collapse; }
4
+ *:first-child+html .arcticmodal-container { height: 100% }
5
+ .arcticmodal-container_i { height: 100%; margin: 0 auto;background: none;border:none; }
6
+ .arcticmodal-container_i2 { padding: 24px; margin: 0; border: 0; vertical-align: middle; }
7
+ .arcticmodal-error { padding: 20px; border-radius: 10px; background: #000; color: #fff; }
8
+ .arcticmodal-loading { width: 80px; height: 80px; border-radius: 10px; background: #000 url(loading.gif) no-repeat 50% 50%; }
template/js/jquery.arcticmodal-0.3.min.js ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ arcticModal — jQuery plugin
4
+ Version: 0.3
5
+ Author: Sergey Predvoditelev (sergey.predvoditelev@gmail.com)
6
+ Company: Arctic Laboratory (http://arcticlab.ru/)
7
+
8
+ Docs & Examples: http://arcticlab.ru/arcticmodal/
9
+
10
+ */
11
+ (function(d){var g={type:"html",content:"",url:"",ajax:{},ajax_request:null,closeOnEsc:!0,closeOnOverlayClick:!0,clone:!1,overlay:{block:void 0,tpl:'<div class="arcticmodal-overlay"></div>',css:{backgroundColor:"#000",opacity:0.6}},container:{block:void 0,tpl:'<div class="arcticmodal-container"><table class="arcticmodal-container_i"><tr><td class="arcticmodal-container_i2"></td></tr></table></div>'},wrap:void 0,body:void 0,errors:{tpl:'<div class="arcticmodal-error arcticmodal-close"></div>',autoclose_delay:2E3,
12
+ ajax_unsuccessful_load:"Error"},openEffect:{type:"fade",speed:400},closeEffect:{type:"fade",speed:400},beforeOpen:d.noop,afterOpen:d.noop,beforeClose:d.noop,afterClose:d.noop,afterLoading:d.noop,afterLoadingOnShow:d.noop,errorLoading:d.noop},j=0,e=d([]),m={isEventOut:function(a,b){var c=!0;d(a).each(function(){d(b.target).get(0)==d(this).get(0)&&(c=!1);0==d(b.target).closest("HTML",d(this).get(0)).length&&(c=!1)});return c}},f={getParentEl:function(a){var b=d(a);return b.data("arcticmodal")?b:(b=
13
+ d(a).closest(".arcticmodal-container").data("arcticmodalParentEl"))?b:!1},transition:function(a,b,c,e){e=void 0==e?d.noop:e;switch(c.type){case "fade":"show"==b?a.fadeIn(c.speed,e):a.fadeOut(c.speed,e);break;case "none":"show"==b?a.show():a.hide(),e()}},prepare_body:function(a,b){d(".arcticmodal-close",a.body).unbind("click.arcticmodal").bind("click.arcticmodal",function(){b.arcticmodal("close");return!1})},init_el:function(a,b){var c=a.data("arcticmodal");if(!c){c=b;j++;c.modalID=j;c.overlay.block=
14
+ d(c.overlay.tpl);c.overlay.block.css(c.overlay.css);c.container.block=d(c.container.tpl);c.body=d(".arcticmodal-container_i2",c.container.block);b.clone?c.body.html(a.clone(!0)):(a.before('<div id="arcticmodalReserve'+c.modalID+'" style="display: none" />'),c.body.html(a));f.prepare_body(c,a);c.closeOnOverlayClick&&c.overlay.block.add(c.container.block).click(function(b){m.isEventOut(d(">*",c.body),b)&&a.arcticmodal("close")});c.container.block.data("arcticmodalParentEl",a);a.data("arcticmodal",c);
15
+ e=d.merge(e,a);d.proxy(h.show,a)();if("html"==c.type)return a;if(void 0!=c.ajax.beforeSend){var k=c.ajax.beforeSend;delete c.ajax.beforeSend}if(void 0!=c.ajax.success){var g=c.ajax.success;delete c.ajax.success}if(void 0!=c.ajax.error){var l=c.ajax.error;delete c.ajax.error}var n=d.extend(!0,{url:c.url,beforeSend:function(){void 0==k?c.body.html('<div class="arcticmodal-loading" />'):k(c,a)},success:function(b){a.trigger("afterLoading");c.afterLoading(c,a,b);void 0==g?c.body.html(b):g(c,a,b);f.prepare_body(c,
16
+ a);a.trigger("afterLoadingOnShow");c.afterLoadingOnShow(c,a,b)},error:function(){a.trigger("errorLoading");c.errorLoading(c,a);void 0==l?(c.body.html(c.errors.tpl),d(".arcticmodal-error",c.body).html(c.errors.ajax_unsuccessful_load),d(".arcticmodal-close",c.body).click(function(){a.arcticmodal("close");return!1}),c.errors.autoclose_delay&&setTimeout(function(){a.arcticmodal("close")},c.errors.autoclose_delay)):l(c,a)}},c.ajax);c.ajax_request=d.ajax(n);a.data("arcticmodal",c)}},init:function(a){a=
17
+ d.extend(!0,{},g,a);if(d.isFunction(this))if(void 0==a)d.error("jquery.arcticmodal: Uncorrect parameters");else if(""==a.type)d.error('jquery.arcticmodal: Don\'t set parameter "type"');else switch(a.type){case "html":if(""==a.content){d.error('jquery.arcticmodal: Don\'t set parameter "content"');break}var b=a.content;a.content="";return f.init_el(d(b),a);case "ajax":if(""==a.url){d.error('jquery.arcticmodal: Don\'t set parameter "url"');break}return f.init_el(d("<div />"),a)}else return this.each(function(){f.init_el(d(this),
18
+ d.extend(!0,{},a))})}},h={show:function(){var a=f.getParentEl(this);if(!1===a)d.error("jquery.arcticmodal: Uncorrect call");else{var b=a.data("arcticmodal");b.overlay.block.hide();b.container.block.hide();d("BODY").append(b.overlay.block);d("BODY").append(b.container.block);b.beforeOpen(b,a);a.trigger("beforeOpen");if("hidden"!=b.wrap.css("overflow")){b.wrap.data("arcticmodalOverflow",b.wrap.css("overflow"));var c=b.wrap.outerWidth(!0);b.wrap.css("overflow","hidden");var g=b.wrap.outerWidth(!0);g!=
19
+ c&&b.wrap.css("marginRight",g-c+"px")}e.not(a).each(function(){d(this).data("arcticmodal").overlay.block.hide()});f.transition(b.overlay.block,"show",1<e.length?{type:"none"}:b.openEffect);f.transition(b.container.block,"show",1<e.length?{type:"none"}:b.openEffect,function(){b.afterOpen(b,a);a.trigger("afterOpen")});return a}},close:function(){if(d.isFunction(this))e.each(function(){d(this).arcticmodal("close")});else return this.each(function(){var a=f.getParentEl(this);if(!1===a)d.error("jquery.arcticmodal: Uncorrect call");
20
+ else{var b=a.data("arcticmodal");!1!==b.beforeClose(b,a)&&(a.trigger("beforeClose"),e.not(a).last().each(function(){d(this).data("arcticmodal").overlay.block.show()}),f.transition(b.overlay.block,"hide",1<e.length?{type:"none"}:b.closeEffect),f.transition(b.container.block,"hide",1<e.length?{type:"none"}:b.closeEffect,function(){b.afterClose(b,a);a.trigger("afterClose");b.clone||d("#arcticmodalReserve"+b.modalID).replaceWith(b.body.find(">*"));b.overlay.block.remove();b.container.block.remove();a.data("arcticmodal",
21
+ null);d(".arcticmodal-container").length||(b.wrap.data("arcticmodalOverflow")&&b.wrap.css("overflow",b.wrap.data("arcticmodalOverflow")),b.wrap.css("marginRight",0))}),"ajax"==b.type&&b.ajax_request.abort(),e=e.not(a))}})},setDefault:function(a){d.extend(!0,g,a)}};d(function(){g.wrap=d(document.all&&!document.querySelector?"html":"body")});d(document).bind("keyup.arcticmodal",function(a){var b=e.last();b.length&&b.data("arcticmodal").closeOnEsc&&27===a.keyCode&&b.arcticmodal("close")});d.arcticmodal=
22
+ d.fn.arcticmodal=function(a){if(h[a])return h[a].apply(this,Array.prototype.slice.call(arguments,1));if("object"===typeof a||!a)return f.init.apply(this,arguments);d.error("jquery.arcticmodal: Method "+a+" does not exist")}})(jQuery);
template/not-ok.png ADDED
Binary file
template/ok.png ADDED
Binary file
template/wpadm_show_backup.php ADDED
@@ -0,0 +1,795 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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' />
4
+ <style>
5
+ .pointer {
6
+ cursor: pointer;
7
+ }
8
+ </style>
9
+ <script>
10
+ var global={};
11
+ function blickForm(id, t)
12
+ {
13
+ if(t.checked == true) {
14
+ t.checked = false;
15
+ }
16
+ l = jQuery('#' + id).length;
17
+ showRegistInfo(false);
18
+ if (l > 0) {
19
+ blick(id);
20
+ }
21
+ }
22
+ function showRegistInfo(show)
23
+ {
24
+ display = jQuery('#cf_activate').css('display');
25
+ if (display == 'none') {
26
+ jQuery('#cf_activate').show('slow');
27
+ jQuery('#registr-show').html("Hide");
28
+ jQuery('#title-regisr').css("padding" , "0px 0px");
29
+ jQuery('#registr-choice-icon').removeClass("dashicons-arrow-down").addClass('dashicons-arrow-up');
30
+ } else {
31
+ if (show) {
32
+ jQuery('#cf_activate').hide('slow');
33
+ jQuery('#registr-show').html("Show");
34
+ jQuery('#title-regisr').css("padding" , "20px 0px");
35
+ jQuery('#registr-choice-icon').removeClass("dashicons-arrow-up").addClass('dashicons-arrow-down');
36
+ }
37
+ }
38
+ }
39
+ function showSetting(show)
40
+ {
41
+ display = jQuery('#setting_active').css('display');
42
+ if (display == 'none') {
43
+ jQuery('#setting_active').show(1000);
44
+ jQuery('#setting-show').html("Hide");
45
+ jQuery('#title-setting').css("padding" , "0px 0px");
46
+ jQuery('#setting-choice-icon').removeClass("dashicons-arrow-down").addClass('dashicons-arrow-up');
47
+ } else {
48
+ if (show) {
49
+ jQuery('#setting_active').hide('slow');
50
+ jQuery('#setting-show').html("Show");
51
+ jQuery('#title-setting').css("padding" , "20px 0px");
52
+ jQuery('#setting-choice-icon').removeClass("dashicons-arrow-up").addClass('dashicons-arrow-down');
53
+ }
54
+ }
55
+ }
56
+ process_flag = 0;
57
+ function start_local_backup()
58
+ {
59
+ d = new Date();
60
+ var data_backup = {
61
+ 'action': 'wpadm_local_backup',
62
+ 'time': Math.ceil( (d.getTime() + (-d.getTimezoneOffset() * 60000 ) ) / 1000 )
63
+ };
64
+ jQuery("#logs-form").show("slow");
65
+ jQuery("#action-buttons").css('margin-top', '8px');
66
+ jQuery("#support-button").css('margin-top', '8px');
67
+ jQuery("#log-backup").html('');
68
+ jQuery(".title-logs").css('display', 'block');
69
+ jQuery(".title-status").css('display', 'none');
70
+ jQuery.ajax({
71
+ type: "POST",
72
+ url: ajaxurl,
73
+ data: data_backup,
74
+ beforeSend: function(){
75
+ process_flag = 1
76
+ processBar();
77
+ showTime();
78
+
79
+ },
80
+ success: function(data){
81
+ process_flag = 0;
82
+ if (data.result == 'success') {
83
+ jQuery('.title-logs').css('display', 'none');
84
+ jQuery('.title-status').css({'display':'block', 'color':'green'});
85
+ jQuery('.title-status').html('Local Backup was created successfully');
86
+ } else {
87
+ jQuery('.title-logs').css('display', 'none');
88
+ jQuery('.title-status').css({'display':'block', 'color':'red'});
89
+ jQuery('.title-status').html('Local Backup wasn\'t created');
90
+ }
91
+ showData(data);
92
+ jQuery('.table').css('display', 'table');
93
+
94
+ },
95
+ error: function(){
96
+ processStop();
97
+ },
98
+ dataType: 'json'
99
+ });
100
+ }
101
+
102
+ var auth_param = <?php echo isset($dropbox_options['app_key']) && isset($dropbox_options['app_secret']) && isset($dropbox_options['uid']) && $dropbox_options['uid'] != '' ? 'false' : 'true' ?>;
103
+ function start_dropbox_backup()
104
+ {
105
+ if (auth_param === false) {
106
+ d = new Date();
107
+ process_flag = 0;
108
+ var data_backup = {
109
+ 'action': 'wpadm_dropbox_create',
110
+ 'time': Math.ceil( (d.getTime() + (-d.getTimezoneOffset() * 60000 ) ) / 1000 ),
111
+ };
112
+ jQuery("#logs-form").show("slow");
113
+ jQuery("#action-buttons").css('margin-top', '8px');
114
+ jQuery("#support-button").css('margin-top', '8px');
115
+ jQuery("#log-backup").html('');
116
+ jQuery(".title-logs").css('display', 'block');
117
+ jQuery(".title-status").css('display', 'none');
118
+ jQuery.ajax({
119
+ type: "POST",
120
+ url: ajaxurl,
121
+ data: data_backup,
122
+ beforeSend: function(){
123
+ process_flag = 1
124
+ processBar();
125
+ showTime();
126
+
127
+ },
128
+ success: function(data){
129
+ process_flag = 0;
130
+ if (data.result == 'success') {
131
+ jQuery('.title-logs').css('display', 'none');
132
+ jQuery('.title-status').css({'display':'block', 'color':'green'});
133
+ jQuery('.title-status').html('Dropbox Backup was created successfully');
134
+ } else {
135
+ jQuery('.title-logs').css('display', 'none');
136
+ jQuery('.title-status').css({'display':'block', 'color':'red'});
137
+ jQuery('.title-status').html('Dropbox Backup wasn\'t created: ' + data.error);
138
+ }
139
+ showData(data);
140
+ jQuery('.table').css('display', 'table');
141
+
142
+ },
143
+ error: function(){
144
+ processStop();
145
+ },
146
+ dataType: 'json'
147
+ });
148
+ } else {
149
+ jQuery('#is-dropbox-auth').arcticmodal({
150
+ beforeOpen: function(data, el) {
151
+ jQuery('#is-dropbox-auth').css('display','block');
152
+
153
+ },
154
+ afterClose: function(data, el) {
155
+ jQuery('#is-dropbox-auth').css('display','none');
156
+ showSetting(false);
157
+ blick('app_key', 4);
158
+ blick('app_secret', 4);
159
+ }
160
+ });
161
+ }
162
+ }
163
+ function showData(data)
164
+ {
165
+ size_backup = data.size / 1024 / 1024;
166
+ info = "";
167
+ for(i = 0; i < data.data.length; i++) {
168
+ e = data.data[i].split('/');
169
+ info += '<tr style="border: 0;">' +
170
+ '<td style="border: 0;padding: 0px;"><a href="<?php echo get_option('siteurl') . "/wpadm_backups/"?>' + data.name + '/' + e[e.length - 1] + '">' + e[e.length - 1] + '</td>' +
171
+ '</tr>' ;
172
+ }
173
+
174
+ co = jQuery('.number-backup').length + 1;
175
+ jQuery('.table > tbody:last').after(
176
+ '<tr>'+
177
+ '<td class="number-backup" onclick="shows(\'' + data.md5_data + '\')">' +
178
+ co +
179
+ '</td>' +
180
+ '<td class="pointer" onclick="shows(\'' + data.md5_data + '\')" style="text-align: left; padding-left: 7px;" >' +
181
+ data.time +
182
+ '</td>' +
183
+ '<td class="pointer" onclick="shows(\'' + data.md5_data + '\')">' +
184
+ data.name +
185
+ '</td>' +
186
+ '<td class="pointer" onclick="shows(\'' + data.md5_data + '\')">' +
187
+ data.counts +
188
+ '</td>' +
189
+ '<td class="pointer" onclick="shows(\'' + data.md5_data + '\')">' +
190
+ '<img src="<?php echo plugin_dir_url(__FILE__) . "/ok.png" ;?>" title="Successful" alt="Successful" style="float: left; width:20px; hight:20px;" />'+
191
+ '<div style="margin-top :1px;float: left;"><?php echo 'Successful';?></div>' +
192
+ '</td>' +
193
+ '<td class="pointer" onclick="shows(\'' + data.md5_data + '\')">' +
194
+ data.type + ' backup' +
195
+ '</td>' +
196
+ '<td class="pointer" onclick="shows(\'' + data.md5_data + '\')">' +
197
+ size_backup.toFixed(2) + "Mb" +
198
+ '</td>' +
199
+ '<td>' +
200
+ '<a href="javascript:void(0)" class="button-wpadm" title="Restore" onclick="show_recovery_form(\'local\', \'' + data.name + '\')"><span class="pointer dashicons dashicons-backup"></span>Restore</a> &nbsp;' +
201
+ '<a href="javascript:void(0)" class="button-wpadm" title="Delete" onclick="delete_backup(\'' + data.name + '\', \'' + data.type + '\')"><span class="pointer dashicons dashicons-trash"></span>Delete</a> &nbsp;' +
202
+ '</td>' +
203
+ '</tr>'+
204
+ '<tr id="' + data.md5_data + '" style="display: none;">'+
205
+ '<td colspan="2">' +
206
+ '</td>' +
207
+ '<td align="center" style="padding: 0px; width: 350px;">' +
208
+ '<div style="overflow: auto; max-height: 150px;">' +
209
+ '<table border="0" align="center" style="width: 100%;" class="info-path">' +
210
+ info +
211
+ '</table>' +
212
+ '</div>' +
213
+ '</td>' +
214
+ '<td colspan="6"></td>' +
215
+ '</tr>')
216
+ }
217
+ var logs = [];
218
+ function processBar()
219
+ {
220
+ var data_log = {
221
+ 'action': 'wpadm_logs',
222
+ };
223
+ jQuery.ajax({
224
+ type: "POST",
225
+ url: ajaxurl,
226
+ data: data_log,
227
+ success: function(response){
228
+ eval("var data=" + response);
229
+ for(s in data.log) {
230
+ if (jQuery.inArray(s , logs) == -1) {
231
+ l = jQuery("#log-backup").html();
232
+ l = "<div>" + data.log[s] + "</div>" + l;
233
+ jQuery("#log-backup").html(l);
234
+ }
235
+ }
236
+ if (process_flag == 1) {
237
+ setTimeout('processBar()', 3000);
238
+ }
239
+ },
240
+ error: function(){
241
+ processStop();
242
+ },
243
+ });
244
+ }
245
+
246
+ function showTime(t)
247
+ {
248
+ if (process_flag == 1) {
249
+ if ( (typeof t) == 'undefined') {
250
+ t = 1;
251
+ } else {
252
+ t = t + 1;
253
+ }
254
+ time = t + " sec.";
255
+ jQuery("#time_backup").html(time);
256
+ setTimeout(function() { showTime(t) }, 1000);
257
+ }
258
+ }
259
+ function processStop()
260
+ {
261
+ process_flag = 0;
262
+ }
263
+ function delete_backup(backup, type)
264
+ {
265
+ document.delete_backups.backup_name.value = backup;
266
+ document.delete_backups.backup_type.value = type;
267
+ document.delete_backups.submit();
268
+ }
269
+ function create_backup (type) {
270
+ if (type == 'auth') {
271
+ document.form_auth_backup_create.submit();
272
+ }
273
+ }
274
+ function show_recovery_form(type, name)
275
+ {
276
+ var act = '';
277
+ if (type == 'local') {
278
+ act = 'wpadm_local_restore';
279
+ } else {
280
+ act = 'wpadm_restore_dropbox';
281
+ }
282
+ var data_backup = {
283
+ 'action': act,
284
+ 'name': name,
285
+ };
286
+ jQuery("#log-backup").html('');
287
+ jQuery("#action-buttons").css('margin-top', '8px');
288
+ jQuery("#support-button").css('margin-top', '8px');
289
+ jQuery(".title-logs").css('display', 'block');
290
+ jQuery(".title-status").css('display', 'none');
291
+ jQuery("#logs-form").show("slow");
292
+ jQuery("#action-buttons").css('margin-top', '8px');
293
+ jQuery.ajax({
294
+ type: "POST",
295
+ url: ajaxurl,
296
+ data: data_backup,
297
+ beforeSend: function(){
298
+ process_flag = 1
299
+ processBar();
300
+ showTime();
301
+
302
+ },
303
+ success: function(data){
304
+ process_flag = 0;
305
+ if (data.result == 'success') {
306
+ jQuery('.title-logs').css('display', 'none');
307
+ jQuery('.title-status').css({'display':'block', 'color':'green'});
308
+ if (type == 'local') {
309
+ jQuery('.title-status').html('Local Backup(' + name + ') was restore is successfully');
310
+ } else {
311
+ jQuery('.title-status').html('Dropbox Backup(' + name + ') was restore is successfully');
312
+ }
313
+ } else {
314
+ jQuery('.title-logs').css('display', 'none');
315
+ jQuery('.title-status').css({'display':'block', 'color':'red'});
316
+ if (type == 'local') {
317
+ jQuery('.title-status').html('Local Backup(' + name + ') wasn\'t restore');
318
+ } else {
319
+ jQuery('.title-status').html('Dropbox Backup(' + name + ') was restore is successfully');
320
+ }
321
+ }
322
+ },
323
+ error: function(){
324
+ processStop();
325
+ },
326
+ dataType: 'json'
327
+ });
328
+
329
+ }
330
+ function auth_form(t)
331
+ {
332
+ var button = jQuery(t);
333
+ var form = button.closest('form');
334
+ var data = {};
335
+
336
+ var reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/;
337
+ mail = document.auth.username.value;
338
+ send = false;
339
+ if (!reg.test(mail)) {
340
+ document.auth.username.style.border = "2px solid red";
341
+ } else {
342
+ document.auth.username.style.border = "1px solid #5b9dd9";
343
+ if(document.auth.password.value.length == 0) {
344
+ document.auth.password.style.border = "2px solid red";
345
+ } else {
346
+ send = true;
347
+ document.auth.password.style.border = "1px solid #5b9dd9";
348
+ }
349
+ }
350
+ if(send) {
351
+ form.find('#message-form').css('display', 'none');
352
+ data['password'] = document.auth.password.value;
353
+ data['username'] = document.auth.username.value;
354
+ backup = jQuery("#name_backup_restore").val();
355
+ jQuery.ajax({
356
+ url: form.attr('action'),
357
+ data: data,
358
+ type: 'POST',
359
+ dataType: 'json',
360
+ success: function(data_res) {
361
+ if( !data_res){
362
+ alert('error');
363
+ } else if(data_res.error) {
364
+ if(form.find('#message-form').length) {
365
+ form.find('#message-form').html("");
366
+ form.find('#message-form').css('display', 'block');
367
+ form.find('#message-form').css('margin', '0');
368
+ form.find('#message-form').css('margin-top', '6px');
369
+ form.find('#message-form').html(data_res.error);
370
+ }
371
+ } else if(data_res.url) {
372
+
373
+ jQuery.ajax({
374
+ url: ajaxurl,
375
+ data: {'action' : 'set_user_mail', 'email' : document.auth.username.value},
376
+ type: 'POST',
377
+ dataType: 'json',
378
+ success: function(res) {
379
+
380
+ }
381
+ });
382
+ form.attr('action', data_res.url);
383
+ jQuery(form).submit();
384
+ }
385
+ }
386
+
387
+ });
388
+ }
389
+ }
390
+ function disconnectDropbox()
391
+ {
392
+ var form = jQuery('form#dropbox_form');
393
+ form.find('#oauth_token_secret').val('');
394
+ form.find('#oauth_token').val('');
395
+ form.find('#uid').val('');
396
+ form.find('#dropbox_uid_text').text('');
397
+ form.find('.disconnect_btn').parents('.form_block_input').removeClass('connected');
398
+ }
399
+
400
+ var winParams = "left=0,top=0,height=600,width=1000,menubar=no,location=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no,directories=no"
401
+ //https://www.dropbox.com/1/oauth/authorize?oauth_token=mIF2gsXq2jijPL95&oauth_callback=http%3A%2F%2Fdev.wpadm.com%2Fbackup%2FdropboxConnect%3Fauth_callback%3D1
402
+ var dropboxBut, dropboxWin;
403
+ function connectDropbox(button, href, oauth_token_secret, oauth_token, uid){
404
+ if( button && href ){
405
+ dropboxBut = jQuery(button);
406
+ var form = dropboxBut.parents('form');
407
+ var url = href;
408
+
409
+ if (jQuery.trim(jQuery('#app_key').val()) != '' || jQuery.trim(jQuery('#app_secret').val()) != '') {
410
+ url += '&app_key='+jQuery('#app_key').val();
411
+ url += '&app_secret='+jQuery('#app_secret').val();
412
+ }
413
+
414
+ dropboxWin = window.open(url, "Dropbox", winParams);
415
+ if( dropboxWin ){
416
+ dropboxWin.focus();
417
+ }else{
418
+ alert('Please, permit the pop-up windows.');
419
+ }
420
+ }else{
421
+ var form = dropboxBut.parents('form');
422
+ if( dropboxWin ){
423
+ dropboxWin.close();
424
+ }
425
+ form.find('#oauth_token_secret').val(oauth_token_secret);
426
+ form.find('#oauth_token').val(oauth_token);
427
+ form.find('#uid').val(uid);
428
+ auth_param = false;
429
+ form.find('#dropbox_uid_text').html('<b>UID:</b>' + uid);
430
+ blick_form = false;
431
+ dropboxBut.parents('.form_block_input').addClass('connected');
432
+ }
433
+ }
434
+ function getHelperDropbox()
435
+ {
436
+ jQuery('#helper-keys').arcticmodal({
437
+ beforeOpen: function(data, el) {
438
+ jQuery('#helper-keys').css('display','block');
439
+
440
+ },
441
+ afterClose: function(data, el) {
442
+ jQuery('#helper-keys').css('display','none');
443
+ }
444
+ });
445
+ }
446
+
447
+ function setReadOnly(id)
448
+ {
449
+ r = jQuery('#' + id).attr('readonly');
450
+ if (r == 'readonly') {
451
+ jQuery('#' + id).prop('readonly', false);
452
+
453
+ } else {
454
+ jQuery('#' + id).prop('readonly', true);
455
+
456
+ }
457
+ }
458
+ </script>
459
+ <?php if (!empty($error)) {
460
+ echo '<div class="error" style="text-align: center; color: red; font-weight:bold;">
461
+ <p style="font-size: 16px;">
462
+ ' . $error . '
463
+ </p></div>';
464
+ }?>
465
+ <?php if (!empty($msg)) {
466
+ echo '<div class="updated" style="text-align: center; color: red; font-weight:bold;">
467
+ <p style="font-size: 16px;">
468
+ ' . $msg . '
469
+ </p></div>';
470
+ }?>
471
+ <div id="is-dropbox-auth" style="display: none; width: 380px; text-align: center; background: #fff; border: 2px solid #dde4ff; border-radius: 5px;">
472
+ <div class="title-description" style="font-size: 20px; text-align: center;padding-top:45px; line-height: 30px;">
473
+ Please, add your Dropbox credentials:<br />
474
+ <strong>"App key"</strong> & <strong>"App secret"</strong> <br />
475
+ in the Setting Form
476
+ </div>
477
+ <div class="button-description" style="padding:20px 0;padding-top:45px">
478
+ <input type="button" value="OK" onclick="jQuery('#is-dropbox-auth').arcticmodal('close');" style="text-align: center; width: 100px;" class="button-wpadm">
479
+ </div>
480
+ </div>
481
+ <div id="helper-keys" style="display: none;width: 400px; text-align: center; background: #fff; border: 2px solid #dde4ff; border-radius: 5px;">
482
+ <div class="title-description" style="font-size: 20px; text-align: center;padding-top:20px; line-height: 30px;">
483
+ Where can I find my app key and secret?
484
+ </div>
485
+ <div class="button-description" style="padding:20px 10px;padding-top:20px; text-align: left;">
486
+ You can get an API app key and secret by creating an app on the
487
+ <a href="https://www.dropbox.com/developers/apps/create?app_type_checked=api" target="_blank">app creation page</a>
488
+ . Once you have an app created, the app key and secret will be available on the app's page on the
489
+ <a href="https://www.dropbox.com/developers/apps" target="_blank">App Console</a>
490
+ . Note that Drop-ins have app keys but no app secrets.
491
+ </div>
492
+ <div class="button-description" style="padding:20px 0;padding-top:10px">
493
+ <input type="button" value="OK" onclick="jQuery('#helper-keys').arcticmodal('close');" style="text-align: center; width: 100px;" class="button-wpadm">
494
+ </div>
495
+ </div>
496
+
497
+ <div class="block-content" style="margin-top:20px;">
498
+ <div style="min-height : 215px; padding: 5px; padding-top: 10px;">
499
+ <div class="log-dropbox" style="background-image: url(<?php echo plugins_url('/img/dropbox.png', dirname(__FILE__));?>);">
500
+ </div>
501
+ <div style="float: bottom; font-size: 40px; font-weight: bold; text-shadow: 1px 2px 2px #666; margin-left: 189px;">
502
+ Dropbox Full Backup <span style="font-size: 20px;">(files+database)</span>
503
+ </div>
504
+ <?php if ($show) {?>
505
+ <div id="container-user" class="cfTabsContainer" style="width: 48%; padding-bottom: 0px; padding-top: 0px; float: left; margin-left: 20px;">
506
+ <div class="stat-wpadm-info-title" id="title-regisr" style="padding :20px 0px; margin-top:11px; line-height: 25px;">
507
+ Free Sign Up <br />to backup more than one web page...
508
+ </div>
509
+ <div id="cf_activate" class="cfContentContainer" style="display: none;">
510
+ <form method="post" id="dropbox_form" action="<?php echo admin_url( 'admin-post.php?action=wpadm_activate_plugin' )?>" >
511
+ <div class="stat-wpadm-registr-info" style="margin-bottom: 23px; margin-top: 10px;">
512
+ <table class="form-table stat-table-registr" style="">
513
+ <tbody>
514
+ <tr valign="top">
515
+ <th scope="row">
516
+ <label for="email">E-mail</label>
517
+ </th>
518
+ <td>
519
+ <input id="email" class="" type="text" name="email" value="">
520
+ </td>
521
+ </tr>
522
+ <tr valign="top">
523
+ <th scope="row">
524
+ <label for="password">Password</label>
525
+ </th>
526
+ <td>
527
+ <input id="password" class="" type="password" name="password" value="">
528
+ </td>
529
+ </tr>
530
+ <tr valign="top">
531
+ <th scope="row">
532
+ <label for="password-confirm">Password confirm</label>
533
+ </th>
534
+ <td>
535
+ <input id="password-confirm" class="" type="password" name="password-confirm" value="">
536
+ </td>
537
+ </tr>
538
+ <tr valign="top">
539
+ <th scope="row">
540
+ </th>
541
+ <td>
542
+ <input class="button-wpadm" type="submit" value="Register & Activate" name="send">
543
+ </td>
544
+ </tr>
545
+ </tbody>
546
+ </table>
547
+ </div>
548
+ <div class="stat-wpadm-info" id="registr-info" style="margin-bottom: 2px; margin-top: 30px;">
549
+ <span style="font-weight:bold; font-size: 14px;">If you are NOT registered at <a target="_blank" style="color: #fff" href="<?php echo SERVER_URL_INDEX; ?>">WPAdm</a>,</span> enter your email and password to use as your Account Data for authorization on WPAdm. <br /><span style="font-weight: bold;font-size: 14px;">If you already have an account at <a target="_blank" style="color: #fff" href="<?php echo SERVER_URL_INDEX; ?>">WPAdm</a></span> and you want to Sign-In, so please, enter your registered credential data (email and password twice).
550
+ </div>
551
+ </form>
552
+ </div>
553
+ <div class="clear"></div>
554
+ <div class="block-button-show" style="color: #fff;">
555
+ <div class="block-click" onclick="showRegistInfo(true);">
556
+ <span id="registr-show" style="color: #fff;">Show</span>
557
+ <div id="registr-choice-icon" class="dashicons dashicons-arrow-down" style=""></div>
558
+ </div>
559
+ </div>
560
+ </div>
561
+ <?php } else { ?>
562
+ <div id="container-user" class="cfTabsContainer" style="width: 48%; padding-bottom: 0px; padding-top: 0px; float: left; margin-left: 20px;">
563
+ <div class="stat-wpadm-info-title" id="title-regisr" style="padding :10px 0px; margin-top:11px; line-height: 25px;">
564
+ Sign In to backup more than one web page...
565
+ </div>
566
+ <div>
567
+ <form method="post" id="auth" name="auth" action="<?php echo SERVER_URL_INDEX . "login-process/" ; ?>" target="_blank">
568
+ <div>
569
+ <div id="message-form" style="color: red; float: left;margin: 10px;margin-top: 14px;"></div>
570
+ </div>
571
+ <div style="padding: 5px; clear: both;">
572
+ <div class="form-field">
573
+ <input class="input-small" type="text" id="username" value="<?php echo get_option(PREFIX_BACKUP_ . "email");?>" readonly="readonly" required="required" name="username" placeholder="Email" />
574
+ </div>
575
+ <div class="form-field">
576
+ <input class="input-small" type="password" required="required" name="password" placeholder="Password" />
577
+ </div>
578
+ <div class="form-field">
579
+ <input class="button-wpadm" type="button" value="Sign In" onclick="auth_form(this);" />
580
+ <input type="hidden" value="<?php echo 'dropbox-backup'?>" name="plugin" />
581
+ </div>
582
+ </div>
583
+ <div style="clear:both; padding: 5px; font-size: 11px; color: #fff;">
584
+ <div class="form-field" style="margin-bottom: 10px;">
585
+ <input type="checkbox" onclick="setReadOnly('username')" style="margin: 0px;"> set new mail
586
+ </div>
587
+ </div>
588
+ <div style="clear:both;"></div>
589
+
590
+ </form>
591
+ </div>
592
+ </div>
593
+ <?php } ?>
594
+ <div class="cfTabsContainer" style="width: 28%; float: left; margin-left: 10px; padding-bottom: 0px; padding-top: 0px;">
595
+ <div class="stat-wpadm-info-title" id="title-setting" style="padding :20px 0px; margin-top:11px; line-height: 50px;">
596
+ Settings
597
+ </div>
598
+ <div id="setting_active" class="cfContentContainer" style="display: none;">
599
+ <form method="post" action="" >
600
+ <div class="stat-wpadm-registr-info" style="width: auto; margin-bottom: 9px;">
601
+ <div style="margin-bottom: 12px; margin-top: 20px; font-size: 15px;">
602
+ Please, add your Dropbox credentials:
603
+ </div>
604
+ <table class="form-table stat-table-registr" style="margin-top:2px">
605
+ <tbody>
606
+ <tr valign="top">
607
+ <th scope="row">
608
+ <label for="email">App key*</label>
609
+ </th>
610
+ <td>
611
+ <input id="app_key" class="" type="text" name="app_key" value="<?php echo isset($dropbox_options['app_key']) ? $dropbox_options['app_key'] : ''?>">
612
+ </td>
613
+ </tr>
614
+ <tr valign="top">
615
+ <th scope="row">
616
+ <label for="password">App secret*</label>
617
+ </th>
618
+ <td>
619
+ <input id="app_secret" class="" type="text" name="app_secret" value="<?php echo isset($dropbox_options['app_secret']) ? $dropbox_options['app_secret'] : ''?>">
620
+ </td>
621
+ </tr>
622
+
623
+ <tr valign="top">
624
+ <th scope="row">
625
+ </th>
626
+ <td>
627
+ <input class="btn-orange" type="button" onclick="connectDropbox(this,'<?php echo admin_url( 'admin-post.php?action=dropboxConnect' )?>')" value="Connect" name="submit">
628
+ <span id="dropbox_uid_text"><?php echo isset($dropbox_options['oauth_token']) && isset($dropbox_options['uid']) ? "UID " . $dropbox_options['uid'] : ''; ?></span>
629
+ <div class="desc-wpadm">Click to Connect your Dropbox</div>
630
+ </td>
631
+ </tr>
632
+ </tbody>
633
+ <tr valign="top">
634
+
635
+ <td colspan="2" align="right">
636
+ <a class="help-key-secret" href="javascript:getHelperDropbox();" >Where to get App key & App secret?</a>
637
+ </td>
638
+ </tr>
639
+ </tbody>
640
+ </table>
641
+ </div>
642
+ </form>
643
+ </div>
644
+ <div class="clear"></div>
645
+ <div class="block-button-show" style="color: #fff;">
646
+ <div class="block-click" onclick="showSetting(true);">
647
+ <span id="setting-show" style="color: #fff;">Show</span>
648
+ <div id="setting-choice-icon" class="dashicons dashicons-arrow-down" style=""></div>
649
+ </div>
650
+ </div>
651
+ </div>
652
+ </div>
653
+ </div>
654
+ <div style="clear: both;"></div>
655
+ <div class="block-content">
656
+ <div class="" style="margin-top:10px;">
657
+ <div id="logs-form" style="display: none; float:left; width: 70%;">
658
+ <div class="title-logs"><span style="font-size:16px;">Please wait... <span id="time_backup">0 sec.</span></span></div>
659
+ <div class="title-status" style="font-size:16px; display: none;"></div>
660
+ <div style="border: 1px solid #ddd; text-align: left; background: #fff; padding: 2px;">
661
+ <div id="log-backup" style="overflow: auto; height: 60px; border: 5px solid #fff; "></div>
662
+ </div>
663
+ </div>
664
+
665
+ <div id="reviews-dropbox" class="pointer" onclick="window.open('https://wordpress.org/support/view/plugin-reviews/dropbox-backup?filter=5');">
666
+ <div class="title-reviews">++ Review ++</div>
667
+ <div class="desc-reviews">Your review is important for us</div>
668
+ <img src="<?php echo plugins_url('/img/stars-5.png', dirname(__FILE__));?>" alt=""></a>
669
+ </div>
670
+ <div id="support-button" style="float: right; margin-top: 130px; margin-right: 20px;">
671
+ <button onclick="window.open('<?php echo SERVER_URL_INDEX . 'support/'?>')" class="backup_button" style="padding: 5px 10px; margin-top: 10px; font-size: 15px;bottom: 0px;">Help</button> <br />
672
+ </div>
673
+ <div id="action-buttons" style="">
674
+ <div style="float: left;">
675
+ <button onclick="start_dropbox_backup();" class="backup_button" style="">Create Dropbox Backup</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
676
+ </div>
677
+ <div style="float: left; margin-top: 2px;">
678
+ <button onclick="start_local_backup()" class="backup_button" style="padding: 5px 10px; margin-top: 10px; font-size: 15px;bottom: 0px;">Create Local Backup</button> <br />
679
+ </div>
680
+ <div style="clear: both;"></div>
681
+ </div>
682
+ </div>
683
+ <div style="clear: both; margin-bottom: 10px;"></div>
684
+ <div>
685
+ <form action="<?php echo WPADM_URL_BASE;?>wpsite/recovery-backup" method="post" target="_blank" id="form_auth_backup" name="form_auth_backup">
686
+ </form>
687
+ <form action="<?php echo WPADM_URL_BASE;?>backup/tasks" method="post" target="_blank" id="form_auth_backup_create" name="form_auth_backup_create">
688
+ <input type="hidden" name="url_task_create" value="<?php echo get_option('siteurl');?>">
689
+ </form>
690
+ <form action="" method="post" id="form_auth_backup" name="form_auth_backup">
691
+ </form>
692
+ <form action="<?php echo admin_url( 'admin-post.php?action=wpadm_delete_backup' )?>" method="post" id="delete_backups" name="delete_backups">
693
+ <input type="hidden" name="backup-name" id="backup_name" value="" />
694
+ <input type="hidden" name="backup-type" id="backup_type" value="" />
695
+ </form>
696
+
697
+
698
+ <table class="table" style="margin-top: 5px; display: <?php echo isset($data['md5']) && ($n = count($data['data'])) && is_array($data['data'][0]) ? 'table' : 'none'?>;">
699
+ <thead>
700
+ <tr>
701
+ <th>#</th>
702
+ <th align="left">Create, Date/Time</th>
703
+ <th>Name of Backup</th>
704
+ <th>Arhive Parts</th>
705
+ <th>Status</th>
706
+ <th>Type of Backup</th>
707
+ <th>Size</th>
708
+ <?php if(is_admin() || is_super_admin()) {?>
709
+ <th>Action</th>
710
+ <?php
711
+ }
712
+ ?>
713
+ </tr>
714
+ </thead>
715
+ <tbody>
716
+ <?php if (isset($data['md5']) && ($n = count($data['data'])) && is_array($data['data'][0])) {
717
+ for($i = 0; $i < $n; $i++) {
718
+ $size = $data['data'][$i]['size'] / 1024 / 1024; /// MByte
719
+ $size = round($size, 2);
720
+ $files = explode(",", str_replace(array('"', "[", "]"), "", $data['data'][$i]['files'] ) );
721
+ $f = count($files);
722
+ ?>
723
+ <tr>
724
+ <td class="number-backup"><?php echo ($i + 1);?></td>
725
+ <td onclick="shows('<?php echo md5( print_r($data['data'][$i], 1) );?>')" class="pointer" style="text-align: left; padding-left: 7px;"><?php echo $data['data'][$i]['dt'];?></td>
726
+ <td onclick="shows('<?php echo md5( print_r($data['data'][$i], 1) );?>')" class="pointer">
727
+ <?php echo $data['data'][$i]['name'];?>
728
+ <script type="text/javascript">
729
+ backup_name = '<?php echo $data['data'][$i]['name']?>';
730
+ global[backup_name] = {};
731
+ </script>
732
+ </td>
733
+ <td onclick="shows('<?php echo md5( print_r($data['data'][$i], 1) );?>')" class="pointer"><?php echo isset($data['data'][$i]['count']) ? $data['data'][$i]['count'] : $f ;?></td>
734
+ <td onclick="shows('<?php echo md5( print_r($data['data'][$i], 1) );?>')" class="pointer" style="padding: 0px;">
735
+ <img src="<?php echo plugin_dir_url(__FILE__) . "ok.png" ;?>" title="Successful" alt="Successful" style="float: left; width: 20px; height: 20px;" />
736
+ <div style="margin-top :1px;float: left;"><?php echo 'Successful';?></div>
737
+ </td>
738
+ <td onclick="shows('<?php echo md5( print_r($data['data'][$i], 1) );?>')" class="pointer"><?php echo $data['data'][$i]['type'];?> backup</td>
739
+ <td onclick="shows('<?php echo md5( print_r($data['data'][$i], 1) );?>')" class="pointer"><?php echo $size . "Mb";?></td>
740
+ <td>
741
+ <?php if(is_admin() || is_super_admin()) {?>
742
+ <a class="button-wpadm" href="javascript:void(0)" title="Restore" onclick="show_recovery_form('<?php echo isset($data['data'][$i]['name']) && $data['data'][$i]['type'] != 'local' ? $data['data'][$i]['name'] : 'local' ?>', '<?php echo $data['data'][$i]['name']?>')" style="color: #fff;"><span class="pointer dashicons dashicons-backup" style="margin-top:3px;"></span>Restore</a>&nbsp;
743
+ <a class="button-wpadm" href="javascript:void(0)" title="Delete" onclick="delete_backup('<?php echo $data['data'][$i]['name']; ?>', '<?php echo $data['data'][$i]['type'];?>')" style="color: #fff;"><span class="pointer dashicons dashicons-trash" style="margin-top:3px;"></span>Delete</a>&nbsp;
744
+ <?php
745
+ }
746
+ ?>
747
+ </td>
748
+ </tr>
749
+ <tr id="<?php echo md5( print_r($data['data'][$i], 1) );?>" style="display:none; ">
750
+ <td colspan="2">
751
+ </td>
752
+ <td align="center" style="padding: 0px; width: 350px;">
753
+ <div style="overflow: auto; max-height: 150px;">
754
+ <?php
755
+ if ($f > 0) { ?>
756
+ <table border="0" align="center" class="info-path"> <?php
757
+ for($j = 0; $j < $f; $j++) {
758
+ if (!empty($files[$j])) {
759
+ ?>
760
+ <tr style="border: 0;">
761
+ <td style="border: 0;">
762
+ <?php if ($data['data'][$i]['type'] == 'local') {?>
763
+ <a href="<?php echo get_option('siteurl') . "/wpadm_backups/{$data['data'][$i]['name']}/{$files[$j]}"?>">
764
+ <?php echo $files[$j]; ?>
765
+ </a>
766
+ <?php
767
+ } else {
768
+ echo $files[$j];
769
+ }
770
+ ?>
771
+ </td>
772
+ </tr>
773
+ <?php
774
+ }
775
+ }
776
+ ?>
777
+ </table>
778
+ <?php
779
+ }
780
+ ?>
781
+ </div>
782
+ </td>
783
+ <td colspan="6"></td>
784
+ </tr>
785
+ <?php
786
+ } ?>
787
+
788
+ <?php } ?>
789
+ </tbody>
790
+ </table>
791
+
792
+ </div>
793
+ </div>
794
+
795
+ </div>
wpadm-class-wp.php ADDED
@@ -0,0 +1,449 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (! defined("WPADM_URL_BASE")) {
3
+ define("WPADM_URL_BASE", 'http://secure.wpadm.com/');
4
+ }
5
+
6
+ if(session_id() == '') {
7
+ session_start();
8
+ }
9
+
10
+ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "libs/error.class.php";
11
+ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "libs/wpadm.server.main.class.php";
12
+ if (! class_exists("wpadm_wp_full_backup_dropbox") ) {
13
+
14
+ add_action('wp_ajax_wpadm_local_restore', array('wpadm_wp_full_backup_dropbox', 'restore_backup') );
15
+ add_action('wp_ajax_wpadm_restore_dropbox', array('wpadm_wp_full_backup_dropbox', 'wpadm_restore_dropbox') );
16
+ add_action('wp_ajax_wpadm_logs', array('wpadm_wp_full_backup_dropbox', 'getLog') );
17
+ add_action('wp_ajax_wpadm_local_backup', array('wpadm_wp_full_backup_dropbox', 'local_backup') );
18
+ add_action('wp_ajax_wpadm_dropbox_create', array('wpadm_wp_full_backup_dropbox', 'dropbox_backup_create') );
19
+ add_action('wp_ajax_set_user_mail', array('wpadm_wp_full_backup_dropbox', 'setUserMail') );
20
+
21
+ add_action('admin_post_wpadm_delete_backup', array('wpadm_wp_full_backup_dropbox', 'delete_backup') );
22
+ add_action('admin_post_dropboxConnect', array('wpadm_wp_full_backup_dropbox', 'dropboxConnect') );
23
+
24
+ add_action('admin_post_wpadm_download', array('wpadm_wp_full_backup_dropbox', 'download') );
25
+
26
+ @set_time_limit(0);
27
+
28
+ class wpadm_wp_full_backup_dropbox extends wpadm_class {
29
+
30
+ const MIN_PASSWORD = 6;
31
+
32
+ static function include_admins_script()
33
+ {
34
+ wp_enqueue_style('css-admin-wpadm', plugins_url( "/template/css/admin-style-wpadm.css", __FILE__) );
35
+ wp_enqueue_script( 'js-admin-wpadm', plugins_url( "/template/js/admin-wpadm.js", __FILE__ ) );
36
+ wp_enqueue_script( 'postbox' );
37
+ }
38
+
39
+ public static function setUserMail()
40
+ {
41
+ if (isset($_POST['email'])) {
42
+ $email = trim($_POST['email']);
43
+ $mail = get_option(PREFIX_BACKUP_ . "email");
44
+ if ($mail) {
45
+ add_option(PREFIX_BACKUP_ . "email", $email);
46
+ } else {
47
+ update_option(PREFIX_BACKUP_ . "email",$email);
48
+ }
49
+ }
50
+ echo 'true';
51
+ wp_die();
52
+ }
53
+
54
+ public static function local_backup()
55
+ {
56
+ require_once dirname(__FILE__) . "/class-wpadm-core.php";
57
+ @session_write_close();
58
+ parent::$type = 'full';
59
+ if (file_exists(WPAdm_Core::getTmpDir() . "/logs2")) {
60
+ unlink(WPAdm_Core::getTmpDir() . "/logs2");
61
+ }
62
+ $backup = new WPAdm_Core(array('method' => "local_backup", 'params' => array('optimize' => 1, 'limit' => 0, 'time' => @$_POST['time'], 'types' => array('db', 'files') )), 'full_backup_dropbox', dirname(__FILE__));
63
+ $res = $backup->getResult()->toArray();
64
+ $res['md5_data'] = md5( print_r($res, 1) );
65
+ $res['name'] = $backup->name;
66
+ $res['time'] = $backup->time;
67
+ $res['type'] = 'local';
68
+ $res['counts'] = count($res['data']);
69
+
70
+ @session_start();
71
+ echo json_encode($res);
72
+ wp_die();
73
+
74
+ }
75
+ public static function getLog()
76
+ {
77
+ @session_write_close();
78
+ @session_start();
79
+ require_once dirname(__FILE__) . "/class-wpadm-core.php";
80
+ $backup = new WPAdm_Core(array('method' => "local"), 'full_backup_dropbox', dirname(__FILE__));
81
+ $log = WPAdm_Core::getLog();
82
+ $log2 = WPAdm_Core::getTmpDir() . "/logs2";
83
+ if (file_exists($log2)) {
84
+ $text = file_get_contents($log2);
85
+ $log = str_replace($text, "", $log);
86
+ file_put_contents($log2, $log);
87
+ } else {
88
+ file_put_contents($log2, $log);
89
+ }
90
+ $log = explode("\n", $log);
91
+ krsort($log);
92
+ echo json_encode(array('log' => $log));
93
+
94
+ exit;
95
+ }
96
+ public static function restore_backup()
97
+ {
98
+ require_once dirname(__FILE__) . "/class-wpadm-core.php";
99
+ @session_write_close();
100
+ parent::$type = 'full';
101
+ if (file_exists(WPAdm_Core::getTmpDir() . "/logs2")) {
102
+ unlink(WPAdm_Core::getTmpDir() . "/logs2");
103
+ }
104
+ $name_backup = isset($_POST['name']) ? trim($_POST['name']) : "";
105
+ $backup = new WPAdm_Core(array('method' => "local_restore", 'params' => array('types' => array('files', 'db'), 'name_backup' => $name_backup )), 'full_backup_dropbox', dirname(__FILE__));
106
+ $res = $backup->getResult()->toArray();
107
+ @session_start();
108
+ echo json_encode($res);
109
+ wp_die();
110
+ }
111
+ public static function wpadm_restore_dropbox()
112
+ {
113
+ require_once dirname(__FILE__) . "/class-wpadm-core.php";
114
+ @session_write_close();
115
+ $log = new WPAdm_Core(array('method' => "local"), 'full_backup_dropbox', dirname(__FILE__));
116
+ if (file_exists(WPAdm_Core::getTmpDir() . "/logs2")) {
117
+ unlink(WPAdm_Core::getTmpDir() . "/logs2");
118
+ }
119
+ if (file_exists(WPAdm_Core::getTmpDir() . "/log.log")) {
120
+ unlink(WPAdm_Core::getTmpDir() . "/log.log");
121
+ }
122
+ WPAdm_Core::log("Start Restore from Dropbox cloud");
123
+ $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
124
+ if ($dropbox_options) {
125
+ require_once dirname(__FILE__) . "/modules/dropbox.class.php";
126
+ $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
127
+ $folder_project = self::getNameProject();
128
+ $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
129
+ if ($dropbox->isAuth()) {
130
+ $name_backup = isset($_POST['name']) ? trim($_POST['name']) : "";
131
+ $dir_backup = ABSPATH . "wpadm_backups/$name_backup";
132
+ WPAdm_Core::mkdir($dir_backup);
133
+ $files = $dropbox->listing("$folder_project/$name_backup");
134
+ if (isset($files['items'])) {
135
+ $n = count($files['items']);
136
+ for($i = 0; $i < $n; $i++) {
137
+ $res = $dropbox->downloadFile("$folder_project/$name_backup/{$files['items'][$i]['name']}", "$dir_backup/{$files['items'][$i]['name']}");
138
+ if ($res != "$dir_backup/{$files['items'][$i]['name']}" && isset($res['text'])) {
139
+ WPAdm_Core::log("Error: " . $res['text'] );
140
+ } else {
141
+ WPAdm_Core::log("Download file({$files['items'][$i]['name']}) with Dropbox");
142
+ }
143
+ }
144
+ parent::$type = 'full';
145
+ $backup = new WPAdm_Core(array('method' => "local_restore", 'params' => array('types' => array('files', 'db'), 'name_backup' => $name_backup )), 'full_backup_dropbox', dirname(__FILE__));
146
+ $res = $backup->getResult()->toArray();
147
+ WPAdm_Core::rmdir($dir_backup);
148
+ }
149
+ } else {
150
+ WPAdm_Core::log("Error: Auth to Dropbox is empty, please repeat connection");
151
+ }
152
+ } else {
153
+ WPAdm_Core::log("Error: Auth to Dropbox is not connections");
154
+ }
155
+ @session_start();
156
+ echo json_encode($res);
157
+ wp_die();
158
+ }
159
+ public static function download()
160
+ {
161
+ if (isset($_REQUEST['backup'])) {
162
+ require_once dirname(__FILE__) . "/class-wpadm-core.php";
163
+ require_once dirname(__FILE__) . '/modules/pclzip.lib.php';
164
+ $backup = new WPAdm_Core(array('method' => "local"), 'full_backup_dropbox', dirname(__FILE__));
165
+ $filename = $_REQUEST['backup'] . ".zip";
166
+ $file = WPAdm_Core::getTmpDir() . "/" . $filename;
167
+ if (file_exists($file)) {
168
+ unlink($file);
169
+ }
170
+ $archive = new PclZip($file);
171
+ $dir_backup = ABSPATH . 'wpadm_backups/' . $_REQUEST['backup'];
172
+
173
+ $backups = array('data' => array(), 'md5' => '');
174
+ if (is_dir($dir_backup)) {
175
+ $i = 0;
176
+ $dir_open = opendir($dir_backup);
177
+ while($d = readdir($dir_open)) {
178
+ if ($d != '.' && $d != '..' && file_exists($dir_backup . "/$d") && substr($d, -3) != "php") {
179
+ $archive->add($dir_backup . "/$d", PCLZIP_OPT_REMOVE_PATH, ABSPATH . 'wpadm_backups');
180
+ }
181
+ }
182
+ }
183
+
184
+
185
+ $now = gmdate("D, d M Y H:i:s");
186
+ header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
187
+ header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate");
188
+ header("Last-Modified: {$now} GMT");
189
+
190
+ // force download
191
+ header("Content-Type: application/force-download");
192
+ header("Content-Type: application/octet-stream");
193
+ header("Content-Type: application/download");
194
+
195
+ // disposition / encoding on response body
196
+ header("Content-Disposition: attachment;filename={$filename}");
197
+ header("Content-Transfer-Encoding: binary");
198
+
199
+ ob_start();
200
+ $df = fopen("php://output", 'w');
201
+ echo file_get_contents($file);
202
+ fclose($df);
203
+ echo ob_get_clean();
204
+ unlink($file);
205
+ exit;
206
+ }
207
+ }
208
+
209
+ public static function delete_backup()
210
+ {
211
+ if (isset($_POST['backup-type']) ) {
212
+ if ($_POST['backup-type'] == 'local') {
213
+ require_once dirname(__FILE__) . "/class-wpadm-core.php";
214
+ $dir = ABSPATH . 'wpadm_backups/' . $_POST['backup-name'] ;
215
+ if (is_dir($dir)) {
216
+ WPAdm_Core::rmdir($dir);
217
+ }
218
+ } elseif ($_POST['backup-type'] == 'dropbox') {
219
+ require_once dirname(__FILE__) . "/modules/dropbox.class.php";
220
+ $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
221
+ if ($dropbox_options) {
222
+ $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
223
+ $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
224
+ $folder_project = self::getNameProject();
225
+ $res = $dropbox->deleteFile("$folder_project/{$_POST['backup-name']}");
226
+ if ($res['is_deleted'] == true) {
227
+
228
+ }
229
+ }
230
+ }
231
+ }
232
+ header("Location: " . admin_url("admin.php?page=wpadm_wp_full_backup_dropbox"));
233
+ }
234
+
235
+ protected static function getPluginName()
236
+ {
237
+
238
+ preg_match("|wpadm_wp_(.*)|", __CLASS__, $m);
239
+ return $m[1];
240
+ }
241
+ protected static function getPathPlugin()
242
+ {
243
+ return "wpadm_full_backup_dropbox";
244
+ }
245
+
246
+ public static function dropboxConnect()
247
+ {
248
+ require_once dirname(__FILE__) . "/modules/dropbox.class.php";
249
+ if (isset($_GET['app_key']) && isset($_GET['app_secret'])) {
250
+
251
+ $dropbox = new dropbox($_GET['app_key'], $_GET['app_secret']);
252
+ $_SESSION['dropbox_key'] = $_GET['app_key'];
253
+ $_SESSION['dropbox_secret'] = $_GET['app_secret'];
254
+ $_SESSION['dropbox_request_token'] = $dropbox->getRequestToken();
255
+ echo '<script>window.location.href="' . $dropbox->generateAuthUrl( admin_url('admin-post.php?action=dropboxConnect') ) . '";</script>';
256
+ } elseif (isset($_GET['oauth_token']) && isset($_GET['uid'])) {
257
+ $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
258
+ if ($dropbox_options) {
259
+ $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
260
+ } else {
261
+ $dropbox_options = array();
262
+ add_option(PREFIX_BACKUP_ . 'dropbox-setting', base64_encode(serialize( $dropbox_options ) ) );
263
+ }
264
+ $dropbox = new dropbox(@$_SESSION['dropbox_key'], @$_SESSION['dropbox_secret']);
265
+ $access_token = $dropbox->getAccessToken($_SESSION['dropbox_request_token']);
266
+ $dropbox_options['app_key'] = @$_SESSION['dropbox_key'] ;
267
+ $dropbox_options['app_secret'] = @$_SESSION['dropbox_secret'] ;
268
+ $dropbox_options['auth_token_secret'] = $access_token;
269
+ $dropbox_options['oauth_token'] = @$_GET['oauth_token'] ;
270
+ $dropbox_options['uid'] = @$_GET['uid'] ;
271
+ update_option(PREFIX_BACKUP_ . 'dropbox-setting', base64_encode( serialize( $dropbox_options ) ) );
272
+ echo '<script>
273
+ if(window.opener){
274
+ window.opener.connectDropbox(null, null, "'.htmlspecialchars($access_token['oauth_token_secret']).'", "'.htmlspecialchars($access_token['oauth_token']).'", "'.htmlspecialchars($access_token['uid']).'");window.close();
275
+ }else{
276
+ window.location.href="' . admin_url("admin.php?page=wpadm_wp_full_backup_dropbox") . '";
277
+ }
278
+ </script>';
279
+ echo '<script>window.close();</script>';exit;
280
+ } elseif (isset($_GET['not_approved'])) {
281
+ if( $_GET['not_approved'] == 'true' ){
282
+ echo '<script>window.close();</script>';exit;
283
+ }
284
+ } else {
285
+ echo 'Error App Key Or App Secret is empty';
286
+ }
287
+ exit;
288
+ }
289
+
290
+ public static function dropbox_backup_create()
291
+ {
292
+ require_once dirname(__FILE__) . "/class-wpadm-core.php";
293
+ @session_write_close();
294
+ $log = new WPAdm_Core(array('method' => "local"), 'full_backup_dropbox', dirname(__FILE__));
295
+ if (file_exists(WPAdm_Core::getTmpDir() . "/logs2")) {
296
+ unlink(WPAdm_Core::getTmpDir() . "/logs2");
297
+ }
298
+ $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
299
+ $send_to_dropbox = true;
300
+ if ($dropbox_options) {
301
+ $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
302
+ if (!isset($dropbox_options['app_key'])) {
303
+ WPAdm_Core::log("Error: \"App Key\" is not exist. You cannot make Auth in Dropbox cloud without \"App Key\". Please, type your \"App Key\" in the Settings form. This data can be found at your Dropbox account.");
304
+ $send_to_dropbox = false;
305
+ }
306
+ if (!isset($dropbox_options['app_secret'])) {
307
+ WPAdm_Core::log("Error: \"App Secret\" is not exist. You cannot make Auth in Dropbox cloud without \"App Secret\". Please, type your \"App Secret\" in the Settings form. This data can be found at your Dropbox account.");
308
+ $send_to_dropbox = false;
309
+ }
310
+ if (!isset($dropbox_options['oauth_token'])) {
311
+ WPAdm_Core::log("Error: \"Token\" is not exist. Files cannot be sent to Dropbox cloud. Please, test your connection within Settings form.");
312
+ $send_to_dropbox = false;
313
+ }
314
+ } else {
315
+ WPAdm_Core::log("Error: \"App Key\" && \"App Secret\" is not exist. ");
316
+ $res['type'] = 'local';
317
+ $send_to_dropbox = false;
318
+ }
319
+
320
+ if ($send_to_dropbox) {
321
+ parent::$type = 'full';
322
+
323
+ $backup = new WPAdm_Core(array('method' => "local_backup", 'params' => array('optimize' => 1, 'limit' => 0, 'time' => @$_POST['time'], 'types' => array('db', 'files') )), 'full_backup_dropbox', dirname(__FILE__));
324
+ $res = $backup->getResult()->toArray();
325
+ $res['md5_data'] = md5( print_r($res, 1) );
326
+ $res['name'] = $backup->name;
327
+ $res['time'] = $backup->time;
328
+ $res['type'] = 'dropbox';
329
+ $res['counts'] = count($res['data']);
330
+ unset($backup);
331
+ $folder_project = self::getNameProject();
332
+ $backup = new WPAdm_Core(array('method' => "send-to-dropbox",
333
+ 'params' => array('files' => $res['data'],
334
+ 'access_details' => array('key' => $dropbox_options['app_key'],
335
+ 'secret' => $dropbox_options['app_secret'],
336
+ 'token' => $dropbox_options['auth_token_secret'],
337
+ 'dir' => $res['name'],
338
+ 'folder' => $folder_project),
339
+ )
340
+ ),
341
+
342
+ 'full_backup_dropbox', dirname(__FILE__)) ;
343
+ WPAdm_Core::rmdir( ABSPATH . "wpadm_backups/{$res['name']}");
344
+ }
345
+ @session_start();
346
+ echo json_encode($res);
347
+ wp_die();
348
+ }
349
+ public static function getNameProject()
350
+ {
351
+ $folder_project = str_ireplace( array("http://", "https://"), '', home_url() );
352
+ $folder_project = str_ireplace( array( "-", '/', '.'), '_', $folder_project );
353
+ return $folder_project;
354
+ }
355
+
356
+
357
+ public static function wpadm_show_backup()
358
+ {
359
+
360
+ require_once dirname(__FILE__) . "/modules/dropbox.class.php";
361
+ parent::$type = 'full';
362
+ $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
363
+ if ($dropbox_options) {
364
+ $dropbox_options = unserialize( base64_decode( $dropbox_options ) );
365
+ if (isset($dropbox_options['app_key']) && isset($dropbox_options['app_secret']) && isset($dropbox_options['auth_token_secret'])) {
366
+ $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
367
+ $folder_project = self::getNameProject();
368
+ $backups = $dropbox->listing($folder_project);
369
+ $n = count($backups['items']);
370
+ $data['data'] = array();
371
+ for($i = 0; $i < $n; $i++) {
372
+ $backup = $dropbox->listing($folder_project . "/" . $backups['items'][$i]['name']);
373
+ $data['data'][$i]['name'] = $backups['items'][$i]['name'];
374
+ $data['data'][$i]['size'] = (int)$backup['size'] * 1024 * 1024;
375
+ $data['data'][$i]['dt'] = parent::getDateInName($backups['items'][$i]['name']);
376
+ $data['data'][$i]['count'] = count($backup['items']);
377
+ $data['data'][$i]['type'] = 'dropbox';
378
+ $k = $data['data'][$i]['count'];
379
+ $data['data'][$i]['files'] = '[';
380
+ for($j = 0; $j < $k; $j++) {
381
+ $data['data'][$i]['files'] .= $backup['items'][$i]['name'] . ',';
382
+ }
383
+ }
384
+ }
385
+ }
386
+ $data_local = parent::read_backups();
387
+ if (isset($data['data'])) {
388
+ $data['data'] = array_merge($data_local['data'], $data['data']);
389
+ $data['md5'] = md5( print_r( $data['data'] , 1 ) );
390
+ } else {
391
+ $data = $data_local;
392
+ }
393
+ $show = !get_option('wpadm_pub_key') && is_super_admin();
394
+ $error = parent::getError(true);
395
+ $msg = parent::getMessage(true);
396
+ ob_start();
397
+ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "template/wpadm_show_backup.php";
398
+ echo ob_get_clean();
399
+ }
400
+
401
+
402
+ public static function draw_menu()
403
+ {
404
+ $menu_position = '1.9998887771';
405
+ parent::$plugin_name = __CLASS__;
406
+ if(self::checkInstallWpadmPlugins()) {
407
+ $page = add_menu_page(
408
+ 'WPAdm',
409
+ 'WPAdm',
410
+ "read",
411
+ 'wpadm_plugins',
412
+ 'wpadm_plugins',
413
+ plugins_url('/wpadm-logo.png', __FILE__),
414
+ $menu_position
415
+ );
416
+ add_submenu_page(
417
+ 'wpadm_plugins',
418
+ "Dropbox Full Backup",
419
+ "Dropbox Full Backup",
420
+ 'read',
421
+ 'wpadm_wp_full_backup_dropbox',
422
+ array('wpadm_wp_full_backup_dropbox', 'wpadm_show_backup')
423
+ );
424
+ } else {
425
+ $page = add_menu_page(
426
+ 'Dropbox Full Backup',
427
+ 'Dropbox Full Backup',
428
+ "read",
429
+ 'wpadm_wp_full_backup_dropbox',
430
+ array('wpadm_wp_full_backup_dropbox', 'wpadm_show_backup'),
431
+ plugins_url('/wpadm-logo.png', __FILE__),
432
+ $menu_position
433
+ );
434
+
435
+ add_submenu_page(
436
+ 'wpadm_wp_full_backup_dropbox',
437
+ "WPAdm",
438
+ "WPAdm",
439
+ 'read',
440
+ 'wpadm_plugins',
441
+ 'wpadm_plugins'
442
+ );
443
+ }
444
+
445
+ }
446
+ }
447
+ }
448
+
449
+ ?>
wpadm.php CHANGED
@@ -1,106 +1,48 @@
1
  <?php
2
- if (! defined("WPADM_URL_BASE")) {
3
- define("WPADM_URL_BASE", 'http://secure.wpadm.com/');
4
- }
5
- /**
6
- * General functions
7
- *
8
- */
9
-
10
- if ( ! function_exists( 'wpadm_run' )) {
11
- function wpadm_run($pl, $dir) {
12
- @set_time_limit(0);
13
- require_once dirname(__FILE__) . '/class-wpadm-method-class.php';
14
- $request_name = $pl . '_request';
15
- if( isset( $_POST[$request_name] ) && ! empty ( $_POST[$request_name] ) ) {
16
- require_once dirname(__FILE__) . '/class-wpadm-core.php';
17
- $wpadm = new WPAdm_Core(wpadm_unpack($_POST[$request_name]), $pl, $dir);
18
- echo '<wpadm>'.wpadm_pack($wpadm->getResult()->toArray()).'</wpadm>';
19
- exit;
20
- }
21
- }
22
- }
23
- if ( ! function_exists('wpadm_include_admins_script') ) {
24
- function wpadm_include_admins_script()
25
- {
26
- wp_enqueue_style('css-admin-wpadm-db', plugins_url( "/css/admin-style-wpadm.css", __FILE__ ) );
27
  }
28
  }
 
29
 
30
 
31
- if ( ! function_exists( 'wpadm_unpack' )) {
32
- /**
33
- * @param str $str
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
 
51
- if ( ! function_exists('wpadm_admin_notice')) {
52
- function wpadm_admin_notice() {
53
- global $status, $page, $s;
54
- $context = $status;
55
- $plugin = 'dropbox-backup/dropbox-backup.php';
56
- $nonce = wp_create_nonce('deactivate-plugin_' . $plugin);
57
- $actions = 'plugins.php?action=deactivate&amp;plugin=' . urlencode($plugin) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s . '&amp;_wpnonce=' . $nonce;
58
- $wpadm_key = !get_option('wpadm_pub_key');
59
- $url = home_url();
60
- $url = str_ireplace(array('http://', 'https://'), "", $url);
61
- $url = str_ireplace(array('www.'), "", $url);
62
- if (substr($url, -1) == "/") {
63
- $url = substr($url, 0, strlen($url) );
64
- }
65
- $plugin = md5('dropbox-backup');
66
-
67
- ?>
68
-
69
-
70
- <?php if ($wpadm_key) { ?>
71
- <div class="wpadm-notice">
72
- <div class="registr">
73
- Please add this site to your
74
- <form action="<?php echo WPADM_URL_BASE?>user/registration" target="_blank" style="margin-bottom: 3px; display: inline;" method="post">
75
- <input type="hidden" name="site" value="<?php echo md5($url);?>" />
76
- <input type="hidden" name="plugin" value="<?php echo md5($plugin);?>" />
77
- <input type="submit" value="WPAdm" class="button-wpadm" style="margin-top: -3px;" />
78
- </form>
79
- account or <a href="<?php echo $actions;?>">deactivate DropBox Backup</a> plugin
80
- </div>
81
- </div>
82
- <?php } else { ?>
83
- <div class="wpadm-notice" style="height: 195px">
84
- <div class="registr" style="font-size: 14px; margin-top: 10px; line-height: 24px;">
85
- <form action="<?php echo WPADM_URL_BASE?>user/registration" target="_blank" style="margin-bottom: 3px; display: inline;" method="post">
86
- <input type="hidden" name="site" value="<?php echo md5($url);?>" />
87
- <input type="hidden" name="plugin" value="<?php echo md5($plugin);?>" />
88
- <input type="hidden" name="u" value="<?php echo 1;?>" />
89
- Dear user, <br />
90
- all Backups you have made by <strong>Dropbox Backup</strong> plugin are safe and available at their place, but, according to the rules of Wordpress system, we had to update the logic of <strong>Dropbox Backup</strong> plugin.<br />
91
- Now, if you want to see the <strong>Dropbox Backup</strong> plugin interface in your admin-panel again, you must upgrade this plugin from
92
- <input type="submit" value="our page" class="button-link" />.
93
- This is optional feature, you mustn’t do it, but you can. <br />
94
- Also, you can administrate all of your Backups for all of your web pages from one place – <input type="submit" value="WPAdm-account" class="button-link" />. This account is FULL FREE.<br />
95
- Here you can <input type="submit" value="login" class="button-wpadm" style="margin-top: -3px;" /> to your account or register in the WPAdm system.
96
- </form>
97
- </div>
98
- </div>
99
- <?php
100
- } ?>
101
-
102
-
103
- <?php
104
  }
105
  }
106
 
@@ -152,98 +94,18 @@ if ( ! function_exists('wpadm_get_blog_info')) {
152
  function wpadm_get_blog_info() {
153
  $info = array(
154
  'url' => get_site_url(),
 
155
  );
156
  $debug = debug_backtrace();
157
  $info['debug'] = $debug;
158
  $file = (is_array($debug[count($debug)-1]['args'][0]))?$debug[count($debug)-1]['args'][0][0] : $debug[count($debug)-1]['args'][0];
159
- preg_match("|wpadm_.*wpadm_(.*)\.php|", $file, $m); ;
160
- $info['plugin'] = $m[1];
 
 
 
161
 
162
  return $info;
163
  }
164
  }
165
 
166
- if (!function_exists("get_system_data")) {
167
- function get_system_data()
168
- {
169
-
170
- global $wp_version;
171
-
172
- /*
173
- *
174
- * Get the settings of php to show in plugin information-page.
175
- * It will get the minimum requirements of php and mysql configuration, version and language of wordpress
176
- * additionally, AFTER the user has been registered at WPAdm service AND has confirmed their registration(!) this data
177
- * will be send to WPAdm service, to get the plugin work correctly, to extend supported configurations of user sites with wpadm-extensions and support.
178
- * Information about sending of this data is published in readme.txt of this plugin
179
- * WE DO NOT COLLECT AND DO NOT STORE THE PERSONAL DATA OF USERS FROM THIS PLUGIN!
180
- *
181
- */
182
- $phpVersion = phpversion();
183
- $maxExecutionTime = ini_get('max_execution_time');
184
- $maxMemoryLimit = ini_get('memory_limit');
185
- $extensions = implode(', ', get_loaded_extensions());
186
- $disabledFunctions = ini_get('disable_functions');
187
- $mysqlVersion = '';
188
- $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD);
189
- if (!mysqli_connect_errno()) {
190
- $mysqlVersion = $mysqli->server_info;
191
- }
192
- $upMaxExecutionTime = 0;
193
- $newMaxExecutionTime = intval($maxExecutionTime) + 60;
194
- @set_time_limit( $newMaxExecutionTime );
195
- if( ini_get('max_execution_time') == $newMaxExecutionTime ){
196
- $upMaxExecutionTime = 1;
197
- $maxExecutionTime = ini_get('max_execution_time');
198
- }
199
- $upMemoryLimit = 0;
200
- $newMemoryLimit = intval($maxMemoryLimit) + 60;
201
- ini_set('memory_limit', $newMemoryLimit.'M');
202
- if( ini_get('memory_limit') == $newMemoryLimit ){
203
- $upMemoryLimit = 1;
204
- $maxMemoryLimit = ini_get('memory_limit');
205
- }
206
- $extensions_search = array('curl', 'json', 'mysqli', 'sockets', 'zip', 'ftp');
207
- $disabledFunctions_search = array('set_time_limit', 'curl_init', 'fsockopen', 'ftp_connect');
208
-
209
- $ex = check_function($extensions, $extensions_search);
210
- $func = check_function($disabledFunctions, $disabledFunctions_search, true);
211
-
212
- return array('wp_version' => $wp_version, 'php_verion' => phpversion(),
213
- 'maxExecutionTime' => $maxExecutionTime, 'maxMemoryLimit' => $maxMemoryLimit,
214
- 'extensions' => $extensions, 'disabledFunctions' => $disabledFunctions,
215
- 'mysqlVersion' => $mysqlVersion, 'upMaxExecutionTime' => $upMaxExecutionTime,
216
- 'newMaxExecutionTime' => $newMaxExecutionTime, 'upMemoryLimit' => $upMemoryLimit,
217
- 'newMemoryLimit' => $newMaxExecutionTime, 'maxMemoryLimit' => $maxMemoryLimit,
218
- 'ex' => $ex, 'func' => $func, 'wp_lang' => get_option('WPLANG'),
219
- );
220
-
221
- }
222
- }
223
- if (! function_exists('check_function')) {
224
- function check_function($func, $search, $type = false)
225
- {
226
- if (is_string($func)) {
227
- $func = explode(", ", $func);
228
- }
229
- if (is_string($search)) {
230
- $search = explode(", ", $search);
231
- }
232
- $res = false;
233
- $n = count($search);
234
- for($i = 0; $i < $n; $i++) {
235
- if (in_array($search[$i], $func) === $type) {
236
- $res[] = $search[$i];
237
- }
238
- }
239
- return $res;
240
- }
241
- }
242
-
243
- if (! function_exists('check_version')) {
244
- function check_version($ver, $ver2)
245
- {
246
- return version_compare($ver, $ver2, ">");
247
- }
248
- }
249
-
1
  <?php
2
+ /**
3
+ * General functions
4
+ *
5
+ */
6
+
7
+ @set_time_limit(0);
8
+ if ( ! function_exists( 'wpadm_run' )) {
9
+ function wpadm_run($pl, $dir) {
10
+
11
+ require_once dirname(__FILE__) . '/class-wpadm-method-class.php';
12
+ $request_name = $pl . '_request';
13
+ if( isset( $_POST[$request_name] ) && ! empty ( $_POST[$request_name] ) ) {
14
+ require_once dirname(__FILE__) . '/class-wpadm-core.php';
15
+ $wpadm = new WPAdm_Core(wpadm_unpack($_POST[$request_name]), $pl, $dir);
16
+ echo '<wpadm>'.wpadm_pack($wpadm->getResult()->toArray()).'</wpadm>';
17
+ exit;
 
 
 
 
 
 
 
 
 
18
  }
19
  }
20
+ }
21
 
22
 
23
+ if ( ! function_exists( 'wpadm_unpack' )) {
24
+ /**
25
+ * @param str $str
26
+ * @return mixed
27
+ */
28
+ function wpadm_unpack( $str ) {
29
+ return unserialize( base64_decode( $str ) );
 
30
  }
31
+ }
32
 
33
+ if ( ! function_exists('wpadm_pack')) {
34
+ /**
35
+ * @param mixed $value
36
+ * @return string
37
+ */
38
+ function wpadm_pack( $value ) {
39
+ return base64_encode( serialize ( $value ) ) ;
 
40
  }
41
+ }
42
+
43
+ if ( ! function_exists('wpadm_admin_notice')) {
44
+ function wpadm_admin_notice() {
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
47
  }
48
 
94
  function wpadm_get_blog_info() {
95
  $info = array(
96
  'url' => get_site_url(),
97
+ 'email' => get_option('admin_email')
98
  );
99
  $debug = debug_backtrace();
100
  $info['debug'] = $debug;
101
  $file = (is_array($debug[count($debug)-1]['args'][0]))?$debug[count($debug)-1]['args'][0][0] : $debug[count($debug)-1]['args'][0];
102
+ preg_match("|wpadm_.*wpadm_(.*)\.php|", $file, $m);
103
+ $info['plugin'] = '';
104
+ if (isset($m[1])) {
105
+ $info['plugin'] = $m[1];
106
+ }
107
 
108
  return $info;
109
  }
110
  }
111