InfiniteWP Client - Version 1.0.4

Version Description

  • Premium addons compatibility
  • Clearing cache and sending WP data
  • Bugs fixed
Download this release

Release Info

Developer infinitewp
Plugin Icon 128x128 InfiniteWP Client
Version 1.0.4
Comparing to
See all releases

Code changes from version 1.0.3 to 1.0.4

addons/backup_repository/backup_repository.class.php ADDED
@@ -0,0 +1,453 @@
1
+ <?php
2
+ class IWP_MMB_Backup_Repository extends IWP_MMB_Backup
3
+ {
4
+ /*var $site_name;
5
+ var $statuses;
6
+ var $tasks;
7
+ var $s3;
8
+ var $ftp;
9
+ var $dropbox;
10
+
11
+ function __construct()
12
+ {
13
+ parent::__construct();
14
+ $this->site_name = str_replace(array(
15
+ "_",
16
+ "/"
17
+ ), array(
18
+ "",
19
+ "-"
20
+ ), rtrim($this->remove_http(get_bloginfo('url')), "/"));
21
+ $this->statuses = array(
22
+ 'db_dump' => 1,
23
+ 'db_zip' => 2,
24
+ 'files_zip' => 3,
25
+ 's3' => 4,
26
+ 'dropbox' => 5,
27
+ 'ftp' => 6,
28
+ 'email' => 7,
29
+ 'finished' => 100
30
+ );
31
+
32
+ $this->tasks = get_option('iwp_client_backup_tasks');
33
+ }*/
34
+
35
+ function backup_repository($args){
36
+
37
+
38
+ if (!empty($args))
39
+ extract($args);
40
+
41
+ $tasks = $this->tasks;
42
+ $task = $tasks['Backup Now'];
43
+
44
+ @ini_set('memory_limit', '256M');
45
+ @set_time_limit(1200);
46
+
47
+ if (!empty($task)) {
48
+ extract($task['task_args']);
49
+ }
50
+
51
+ $results = $task['task_results'];
52
+
53
+ if (is_array($results) && count($results)) {
54
+ $backup_file = $results[count($results) - 1]['server']['file_path'];
55
+ }
56
+
57
+
58
+ if ($backup_file && file_exists($backup_file)) {
59
+ //FTP, Amazon S3 or Dropbox
60
+ if (isset($account_info['iwp_ftp']) && !empty($account_info)) {
61
+ $account_info['iwp_ftp']['backup_file'] = $backup_file;
62
+ $return = $this->ftp_backup($account_info['iwp_ftp']);
63
+ }
64
+
65
+ if (isset($account_info['iwp_amazon_s3']) && !empty($account_info['iwp_amazon_s3'])) {
66
+ $account_info['iwp_amazon_s3']['backup_file'] = $backup_file;
67
+ $return = $this->amazons3_backup($account_info['iwp_amazon_s3']);
68
+ }
69
+
70
+ if (isset($account_info['iwp_dropbox']) && !empty($account_info['iwp_dropbox'])) {
71
+ $account_info['iwp_dropbox']['backup_file'] = $backup_file;
72
+ $return = $this->dropbox_backup($account_info['iwp_dropbox']);
73
+ }
74
+
75
+ if (isset($account_info['iwp_email']) && !empty($account_info['iwp_email'])) {
76
+ $account_info['iwp_email']['file_path'] = $backup_file;
77
+ $account_info['iwp_email']['task_name'] = 'Backup Now';
78
+ $return = $this->email_backup($account_info['iwp_email']);
79
+ }
80
+
81
+
82
+ if ($return == true && $del_host_file) {
83
+ @unlink($backup_file);
84
+ unset($tasks['Backup Now']['task_results'][count($results) - 1]['server']);
85
+ $this->update_tasks($tasks);
86
+ //update_option('iwp_client_backup_tasks', $tasks);
87
+ }
88
+
89
+ } else {
90
+ $return = array(
91
+ 'error' => 'Backup file not found on your server. Please try again.'
92
+ );
93
+ }
94
+
95
+ return $return;
96
+
97
+ }
98
+ /*
99
+ function ftp_backup($args)
100
+ {
101
+ extract($args);
102
+ //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder, $ftp_site_folder
103
+ $port = $ftp_port ? $ftp_port : 21; //default port is 21
104
+ if ($ftp_ssl) {
105
+ if (function_exists('ftp_ssl_connect')) {
106
+ $conn_id = ftp_ssl_connect($ftp_hostname,$port);
107
+ } else {
108
+ return array(
109
+ 'error' => 'Your server doesn\'t support SFTP',
110
+ 'partial' => 1
111
+ );
112
+ }
113
+ } else {
114
+ if (function_exists('ftp_connect')) {
115
+ $conn_id = ftp_connect($ftp_hostname,$port);
116
+ if ($conn_id === false) {
117
+ return array(
118
+ 'error' => 'Failed to connect to ' . $ftp_hostname,
119
+ 'partial' => 1
120
+ );
121
+ }
122
+ } else {
123
+ return array(
124
+ 'error' => 'Your server doesn\'t support FTP',
125
+ 'partial' => 1
126
+ );
127
+ }
128
+ }
129
+ $login = @ftp_login($conn_id, $ftp_username, $ftp_password);
130
+ if ($login === false) {
131
+ return array(
132
+ 'error' => 'FTP login failed for ' . $ftp_username . ', ' . $ftp_password,
133
+ 'partial' => 1
134
+ );
135
+ }
136
+
137
+ if($ftp_passive){
138
+ @ftp_pasv($conn_id,true);
139
+ }
140
+
141
+ @ftp_mkdir($conn_id, $ftp_remote_folder);
142
+ if ($ftp_site_folder) {
143
+ $ftp_remote_folder .= '/' . $this->site_name;
144
+ }
145
+ @ftp_mkdir($conn_id, $ftp_remote_folder);
146
+
147
+ $upload = @ftp_put($conn_id, $ftp_remote_folder . '/' . basename($backup_file), $backup_file, FTP_BINARY);
148
+
149
+ if ($upload === false) { //Try ascii
150
+ $upload = @ftp_put($conn_id, $ftp_remote_folder . '/' . basename($backup_file), $backup_file, FTP_ASCII);
151
+ }
152
+ ftp_close($conn_id);
153
+
154
+ if ($upload === false) {
155
+ return array(
156
+ 'error' => 'Failed to upload file to FTP. Please check your specified path.',
157
+ 'partial' => 1
158
+ );
159
+ }
160
+
161
+ return true;
162
+ }
163
+
164
+ function remove_ftp_backup($args)
165
+ {
166
+ extract($args);
167
+ //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder
168
+ $port = $ftp_port ? $ftp_port : 21; //default port is 21
169
+ if ($ftp_ssl && function_exists('ftp_ssl_connect')) {
170
+ $conn_id = ftp_ssl_connect($ftp_hostname,$port);
171
+ } else if (function_exists('ftp_connect')) {
172
+ $conn_id = ftp_connect($ftp_hostname,$port);
173
+ }
174
+
175
+ if ($conn_id) {
176
+ $login = @ftp_login($conn_id, $ftp_username, $ftp_password);
177
+ if ($ftp_site_folder)
178
+ $ftp_remote_folder .= '/' . $this->site_name;
179
+
180
+ if($ftp_passive){
181
+ @ftp_pasv($conn_id,true);
182
+ }
183
+
184
+ $delete = ftp_delete($conn_id, $ftp_remote_folder . '/' . $backup_file);
185
+
186
+ ftp_close($conn_id);
187
+ }
188
+
189
+ }
190
+
191
+ function get_ftp_backup($args)
192
+ {
193
+ extract($args);
194
+ //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder
195
+ $port = $ftp_port ? $ftp_port : 21; //default port is 21
196
+ if ($ftp_ssl && function_exists('ftp_ssl_connect')) {
197
+ $conn_id = ftp_ssl_connect($ftp_hostname,$port);
198
+
199
+ } else if (function_exists('ftp_connect')) {
200
+ $conn_id = ftp_connect($ftp_hostname,$port);
201
+ if ($conn_id === false) {
202
+ return false;
203
+ }
204
+ }
205
+ $login = @ftp_login($conn_id, $ftp_username, $ftp_password);
206
+ if ($login === false) {
207
+ return false;
208
+ } else {
209
+ }
210
+
211
+ if ($ftp_site_folder)
212
+ $ftp_remote_folder .= '/' . $this->site_name;
213
+
214
+ if($ftp_passive){
215
+ @ftp_pasv($conn_id,true);
216
+ }
217
+
218
+ $temp = ABSPATH . 'iwp_temp_backup.zip';
219
+ $get = ftp_get($conn_id, $temp, $ftp_remote_folder . '/' . $backup_file, FTP_BINARY);
220
+ if ($get === false) {
221
+ return false;
222
+ } else {
223
+
224
+ }
225
+ ftp_close($conn_id);
226
+
227
+ return $temp;
228
+ }
229
+
230
+ function amazons3_backup($args)
231
+ {
232
+ if ($this->iwp_mmb_function_exists('curl_init')) {
233
+ require_once($iwp_mmb_plugin_dir.'/lib/s3.php');
234
+ extract($args);
235
+
236
+ if ($as3_site_folder == true)
237
+ $as3_directory .= '/' . $this->site_name;
238
+
239
+ $endpoint = isset($as3_bucket_region) ? $as3_bucket_region : 's3.amazonaws.com';
240
+
241
+ $s3 = new S3(trim($as3_access_key), trim(str_replace(' ', '+', $as3_secure_key)), false, $endpoint);
242
+
243
+ $s3->putBucket($as3_bucket, S3::ACL_PUBLIC_READ);
244
+
245
+ if ($s3->putObjectFile($backup_file, $as3_bucket, $as3_directory . '/' . basename($backup_file), S3::ACL_PRIVATE)) {
246
+ return true;
247
+ } else {
248
+ return array(
249
+ 'error' => 'Failed to upload to Amazon S3. Please check your details and set upload/delete permissions on your bucket.',
250
+ 'partial' => 1
251
+ );
252
+ }
253
+ } else {
254
+ return array(
255
+ 'error' => 'You cannot use Amazon S3 on your server. Please enable curl first.',
256
+ 'partial' => 1
257
+ );
258
+ }
259
+ }
260
+
261
+ function remove_amazons3_backup($args)
262
+ {
263
+ require_once($iwp_mmb_plugin_dir.'/lib/s3.php');
264
+ extract($args);
265
+ if ($as3_site_folder == true)
266
+ $as3_directory .= '/' . $this->site_name;
267
+ $endpoint = isset($as3_bucket_region) ? $as3_bucket_region : 's3.amazonaws.com';
268
+ $s3 = new S3($as3_access_key, str_replace(' ', '+', $as3_secure_key), false, $endpoint);
269
+ $s3->deleteObject($as3_bucket, $as3_directory . '/' . $backup_file);
270
+ }
271
+
272
+ function get_amazons3_backup($args)
273
+ {
274
+ require_once($iwp_mmb_plugin_dir.'/lib/s3.php');
275
+ extract($args);
276
+ $endpoint = isset($as3_bucket_region) ? $as3_bucket_region : 's3.amazonaws.com';
277
+ $s3 = new S3($as3_access_key, str_replace(' ', '+', $as3_secure_key), false, $endpoint);
278
+ if ($as3_site_folder == true)
279
+ $as3_directory .= '/' . $this->site_name;
280
+
281
+ $temp = ABSPATH . 'iwp_temp_backup.zip';
282
+ $s3->getObject($as3_bucket, $as3_directory . '/' . $backup_file, $temp);
283
+
284
+ return $temp;
285
+ }
286
+
287
+ function dropbox_backup($args)
288
+ {
289
+
290
+ extract($args);
291
+
292
+ if(isset($consumer_secret) && !empty($consumer_secret)){
293
+ //New way
294
+ require_once($iwp_mmb_plugin_dir.'/lib/dropbox.oauth.php');
295
+
296
+ $dropbox = new Dropbox($consumer_key, $consumer_secret);
297
+ $dropbox->setOAuthToken($oauth_token);
298
+ $dropbox->setOAuthTokenSecret($oauth_token_secret);
299
+
300
+ if ($dropbox_site_folder == true)
301
+ $dropbox_destination .= '/' . $this->site_name;
302
+
303
+ try{
304
+
305
+ $dropbox->filesPost($dropbox_destination, $backup_file,true);
306
+
307
+ } catch(Exception $e){
308
+ return array(
309
+ 'error' => 'Dropbox upload error. '.$e->getMessage()
310
+ );
311
+ }
312
+
313
+ return true;
314
+
315
+ } else {
316
+ //old way
317
+ require_once($iwp_mmb_plugin_dir.'/lib/dropbox.php');
318
+ // extract($args);
319
+
320
+ //$email, $password, $backup_file, $destination, $dropbox_site_folder
321
+
322
+ $size = ceil(filesize($backup_file) / 1024);
323
+ if ($size > 300000) {
324
+ return array(
325
+ 'error' => 'Cannot upload file to Dropbox. Dropbox has upload limit of 300Mb per file.',
326
+ 'partial' => 1
327
+ );
328
+ }
329
+
330
+ if ($dropbox_site_folder == true)
331
+ $dropbox_destination .= '/' . $this->site_name;
332
+
333
+ try {
334
+ $uploader = new DropboxUploader($dropbox_username, $dropbox_password);
335
+ $uploader->upload($backup_file, $dropbox_destination);
336
+ }
337
+ catch (Exception $e) {
338
+ return array(
339
+ 'error' => $e->getMessage(),
340
+ 'partial' => 1
341
+ );
342
+ }
343
+
344
+ return true;
345
+ }
346
+
347
+ }
348
+
349
+ function remove_dropbox_backup($args){
350
+ extract($args);
351
+ if(isset($consumer_secret) && !empty($consumer_secret)){
352
+ //New way
353
+ require_once($iwp_mmb_plugin_dir.'/lib/dropbox.oauth.php');
354
+
355
+ $dropbox = new Dropbox($consumer_key, $consumer_secret);
356
+ $dropbox->setOAuthToken($oauth_token);
357
+ $dropbox->setOAuthTokenSecret($oauth_token_secret);
358
+
359
+ if ($dropbox_site_folder == true)
360
+ $dropbox_destination .= '/' . $this->site_name;
361
+
362
+ try{
363
+ $dropbox->fileopsDelete($dropbox_destination.'/'.$backup_file, true);
364
+ } catch(Exception $e){
365
+
366
+ }
367
+ }
368
+ }
369
+
370
+ function get_dropbox_backup($args){
371
+ extract($args);
372
+
373
+ if(isset($consumer_secret) && !empty($consumer_secret)){
374
+ //New way
375
+ require_once($iwp_mmb_plugin_dir.'/lib/dropbox.oauth.php');
376
+
377
+ $dropbox = new Dropbox($consumer_key, $consumer_secret);
378
+ $dropbox->setOAuthToken($oauth_token);
379
+ $dropbox->setOAuthTokenSecret($oauth_token_secret);
380
+
381
+ if ($dropbox_site_folder == true)
382
+ $dropbox_destination .= '/' . $this->site_name;
383
+
384
+ $temp = ABSPATH . 'iwp_temp_backup.zip';
385
+
386
+ try{
387
+ $file = $dropbox->filesGet($dropbox_destination.'/'.$backup_file, true);
388
+
389
+ if(isset($file['data']) && !empty($file['data']) )
390
+ $stream = base64_decode($file['data']);
391
+ else
392
+ return false;
393
+
394
+ $handle = @fopen($temp, 'w+');
395
+ $result = fwrite($handle,$stream);
396
+ fclose($handle);
397
+
398
+ if($result)
399
+ return $temp;
400
+ else
401
+ return false;
402
+
403
+ } catch(Exception $e){
404
+
405
+
406
+ return false;
407
+ }
408
+
409
+ } else {
410
+ return false;
411
+ }
412
+ }
413
+
414
+ function email_backup($args)
415
+ {
416
+ $email = $args['email'];
417
+
418
+ if (!is_email($email)) {
419
+ return array(
420
+ 'error' => 'Your email (' . $email . ') is not correct'
421
+ );
422
+ }
423
+ $backup_file = $args['file_path'];
424
+ $task_name = isset($args['task_name']) ? $args['task_name'] : '';
425
+ if (file_exists($backup_file) && $email) {
426
+ $attachments = array(
427
+ $backup_file
428
+ );
429
+ $headers = 'From: InfiniteWP <no-reply@infinitewp.com>' . "\r\n";
430
+ $subject = "InfiniteWP - " . $task_name . " - " . $this->site_name;
431
+ ob_start();
432
+ $result = wp_mail($email, $subject, $subject, $headers, $attachments);
433
+ ob_end_clean();
434
+
435
+ }
436
+
437
+ if (!$result) {
438
+ return array(
439
+ 'error' => 'Email not sent. Maybe your backup is too big for email or email server is not available on your website.'
440
+ );
441
+ }
442
+ return true;
443
+
444
+ }
445
+
446
+ function update_tasks($tasks)
447
+ {
448
+ $this->tasks = $tasks;
449
+ update_option('iwp_client_backup_tasks', $tasks);
450
+ }*/
451
+
452
+ }
453
+ ?>
backup.class.php CHANGED
@@ -121,8 +121,18 @@ class IWP_MMB_Backup extends IWP_MMB_Core
121
'removed' => true
122
);
123
} else {
124
125
$before[$task_name]['task_args'] = $args;
126
$return = $before[$task_name];
127
}
128
@@ -224,6 +234,50 @@ class IWP_MMB_Backup extends IWP_MMB_Core
224
225
}
226
227
/*
228
* If Task Name not set then it's manual backup
229
* Backup args:
@@ -360,7 +414,24 @@ class IWP_MMB_Backup extends IWP_MMB_Core
360
'file_url' => $backup_url
361
);
362
}
363
-
364
$temp = $backup_settings[$task_name]['task_results'];
365
$temp = @array_values($temp);
366
$paths['time'] = time();
@@ -380,8 +451,68 @@ class IWP_MMB_Backup extends IWP_MMB_Core
380
}
381
382
//Additional: Email, ftp, amazon_s3, dropbox...
383
384
- if ($task_name != 'Backup Now') {
385
if ($del_host_file) {
386
@unlink($backup_file);
387
}
@@ -749,6 +880,44 @@ class IWP_MMB_Backup extends IWP_MMB_Core
749
$unlink_file = false; //Don't delete file if stored on server
750
}
751
752
$what = $tasks[$task_name]['task_args']['what'];
753
}
754
@@ -930,11 +1099,8 @@ class IWP_MMB_Backup extends IWP_MMB_Core
930
}
931
932
}
933
-
934
-
935
-
936
-
937
- return true;
938
}
939
940
function restore_db()
@@ -1212,6 +1378,428 @@ class IWP_MMB_Backup extends IWP_MMB_Core
1212
return $reqs;
1213
}
1214
1215
//Parse task arguments for info on IWP Admin Panel
1216
function get_backup_stats()
1217
{
@@ -1236,6 +1824,22 @@ class IWP_MMB_Backup extends IWP_MMB_Core
1236
return $stats;
1237
}
1238
1239
function remove_old_backups($task_name)
1240
{
1241
//Check for previous failed backups first
@@ -1259,6 +1863,27 @@ class IWP_MMB_Backup extends IWP_MMB_Core
1259
@unlink($backups[$task_name]['task_results'][$i]['server']['file_path']);
1260
}
1261
1262
//Remove database backup info
1263
unset($backups[$task_name]['task_results'][$i]);
1264
@@ -1293,6 +1918,33 @@ class IWP_MMB_Backup extends IWP_MMB_Core
1293
if (isset($backup['server'])) {
1294
@unlink($backup['server']['file_path']);
1295
}
1296
unset($backups[$result_id]);
1297
1298
if (count($backups)) {
@@ -1327,7 +1979,7 @@ class IWP_MMB_Backup extends IWP_MMB_Core
1327
1328
1329
//clean_old folder?
1330
- if ((basename($files[0]) == 'index.php' && count($files) == 1) || (empty($files))) {
1331
foreach ($files as $file) {
1332
@unlink($file);
1333
}
@@ -1335,7 +1987,7 @@ class IWP_MMB_Backup extends IWP_MMB_Core
1335
@rmdir(WP_CONTENT_DIR . '/' . md5('iwp_mmb-client'));
1336
}
1337
1338
-
1339
foreach ($new as $b) {
1340
$files[] = $b;
1341
}
121
'removed' => true
122
);
123
} else {
124
+
125
+ if (is_array($params['account_info'])) { //only if sends from IWP Admin Panel first time(secure data)
126
+ $args['account_info'] = $account_info;
127
+ }
128
129
$before[$task_name]['task_args'] = $args;
130
+ //$before[$task_name]['task_args'] = $task_name;
131
+
132
+ if (strlen($args['schedule']))
133
+ $before[$task_name]['task_args']['next'] = $this->schedule_next($args['type'], $args['schedule']);
134
+ $before[$task_name]['task_args']['task_name'] = $task_name;
135
+
136
$return = $before[$task_name];
137
}
138
234
235
}
236
237
+
238
+ function task_now($task_name){
239
+
240
+ $settings = $this->tasks;
241
+ if(!array_key_exists($task_name,$settings)){
242
+ return array('error' => $task_name." does not exist.");
243
+ } else {
244
+ $setting = $settings[$task_name];
245
+ }
246
+
247
+ $this->set_backup_task(array(
248
+ 'task_name' => $task_name,
249
+ 'args' => $settings[$task_name]['task_args'],
250
+ 'time' => time()
251
+ ));
252
+
253
+ //Run backup
254
+ $result = $this->backup($setting['task_args'], $task_name);
255
+
256
+ //Check for error
257
+ if (is_array($result) && array_key_exists('error', $result)) {
258
+ $this->set_backup_task(array(
259
+ 'task_name' => $task_name,
260
+ 'args' => $settings[$task_name]['task_args'],
261
+ 'error' => $result['error']
262
+ ));
263
+ return $result;
264
+ } else {
265
+ return $this->get_backup_stats();
266
+ }
267
+
268
+ }
269
+
270
+ function delete_task_now($task_name){
271
+ $tasks = $this->tasks;
272
+ unset($tasks[$task_name]);
273
+ $this->update_tasks($tasks);
274
+ $this->cleanup();
275
+
276
+ return $task_name;
277
+
278
+ }
279
+
280
+
281
/*
282
* If Task Name not set then it's manual backup
283
* Backup args:
414
'file_url' => $backup_url
415
);
416
}
417
+
418
+
419
+ if (isset($backup_settings[$task_name]['task_args']['account_info']['iwp_ftp'])) {
420
+ $paths['ftp'] = basename($backup_url);
421
+ }
422
+
423
+ if (isset($backup_settings[$task_name]['task_args']['account_info']['iwp_amazon_s3'])) {
424
+ $paths['amazons3'] = basename($backup_url);
425
+ }
426
+
427
+ if (isset($backup_settings[$task_name]['task_args']['account_info']['iwp_dropbox'])) {
428
+ $paths['dropbox'] = basename($backup_url);
429
+ }
430
+
431
+ if (isset($backup_settings[$task_name]['task_args']['account_info']['iwp_email'])) {
432
+ $paths['email'] = basename($backup_url);
433
+ }
434
+
435
$temp = $backup_settings[$task_name]['task_results'];
436
$temp = @array_values($temp);
437
$paths['time'] = time();
451
}
452
453
//Additional: Email, ftp, amazon_s3, dropbox...
454
+ /*
455
+ //IWP Remove starts here //IWP Remove ends here
456
+ */
457
+ if ($task_name != 'Backup Now') {
458
+
459
+ if (isset($account_info['iwp_ftp']) && !empty($account_info['iwp_ftp'])) {
460
+ $this->update_status($task_name, $this->statuses['ftp']);
461
+ $account_info['iwp_ftp']['backup_file'] = $backup_file;
462
+ $ftp_result = $this->ftp_backup($account_info['iwp_ftp']);
463
+
464
+ if ($ftp_result !== true && $del_host_file) {
465
+ @unlink($backup_file);
466
+ }
467
+
468
+ if (is_array($ftp_result) && isset($ftp_result['error'])) {
469
+ return $ftp_result;
470
+ }
471
+ $this->wpdb_reconnect();
472
+ $this->update_status($task_name, $this->statuses['ftp'], true);
473
+ }
474
+
475
+ if (isset($account_info['iwp_amazon_s3']) && !empty($account_info['iwp_amazon_s3'])) {
476
+ $this->update_status($task_name, $this->statuses['s3']);
477
+ $account_info['iwp_amazon_s3']['backup_file'] = $backup_file;
478
+ $amazons3_result = $this->amazons3_backup($account_info['iwp_amazon_s3']);
479
+ if ($amazons3_result !== true && $del_host_file) {
480
+ @unlink($backup_file);
481
+ }
482
+ if (is_array($amazons3_result) && isset($amazons3_result['error'])) {
483
+ return $amazons3_result;
484
+ }
485
+ $this->wpdb_reconnect();
486
+ $this->update_status($task_name, $this->statuses['s3'], true);
487
+ }
488
+
489
+ if (isset($account_info['iwp_dropbox']) && !empty($account_info['iwp_dropbox'])) {
490
+ $this->update_status($task_name, $this->statuses['dropbox']);
491
+ $account_info['iwp_dropbox']['backup_file'] = $backup_file;
492
+ $dropbox_result = $this->dropbox_backup($account_info['iwp_dropbox']);
493
+ if ($dropbox_result !== true && $del_host_file) {
494
+ @unlink($backup_file);
495
+ }
496
+
497
+ if (is_array($dropbox_result) && isset($dropbox_result['error'])) {
498
+ return $dropbox_result;
499
+ }
500
+ $this->wpdb_reconnect();
501
+ $this->update_status($task_name, $this->statuses['dropbox'], true);
502
+ }
503
+
504
+ if (isset($account_info['iwp_email']) && !empty($account_info['iwp_email'])) {
505
+ $this->update_status($task_name, $this->statuses['email']);
506
+ $account_info['iwp_email']['task_name'] = $task_name;
507
+ $account_info['iwp_email']['file_path'] = $backup_file;
508
+
509
+ $email_result = $this->email_backup($account_info['iwp_email']);
510
+ if (is_array($email_result) && isset($email_result['error'])) {
511
+ return $email_result;
512
+ }
513
+ $this->update_status($task_name, $this->statuses['email'], true);
514
+ }
515
516
if ($del_host_file) {
517
@unlink($backup_file);
518
}
880
$unlink_file = false; //Don't delete file if stored on server
881
}
882
883
+ /*
884
+ //IWP Remove starts here//IWP Remove ends here
885
+ */
886
+
887
+ elseif (isset($task['task_results'][$result_id]['ftp'])) {
888
+ $ftp_file = $task['task_results'][$result_id]['ftp'];
889
+ $args = $task['task_args']['account_info']['iwp_ftp'];
890
+ $args['backup_file'] = $ftp_file;
891
+ $backup_file = $this->get_ftp_backup($args);
892
+ if ($backup_file == false) {
893
+ return array(
894
+ 'error' => 'Failed to download file from FTP.'
895
+ );
896
+ }
897
+ } elseif (isset($task['task_results'][$result_id]['amazons3'])) {
898
+ $amazons3_file = $task['task_results'][$result_id]['amazons3'];
899
+ $args = $task['task_args']['account_info']['iwp_amazon_s3'];
900
+ $args['backup_file'] = $ftp_file;
901
+ $backup_file = $this->get_amazons3_backup($args);
902
+ if ($backup_file == false) {
903
+ return array(
904
+ 'error' => 'Failed to download file from Amazon S3.'
905
+ );
906
+ }
907
+ } elseif(isset($task['task_results'][$result_id]['dropbox'])){
908
+ $dropbox_file = $task['task_results'][$result_id]['dropbox'];
909
+ $args = $task['task_args']['account_info']['iwp_dropbox'];
910
+ $args['backup_file'] = $dropbox_file;
911
+ $backup_file = $this->get_dropbox_backup($args);
912
+
913
+ if ($backup_file == false) {
914
+ return array(
915
+ 'error' => 'Failed to download file from Dropbox.'
916
+ );
917
+ }
918
+ }
919
+
920
+
921
$what = $tasks[$task_name]['task_args']['what'];
922
}
923
1099
}
1100
1101
}
1102
+
1103
+ return !empty($new_user) ? $new_user : true ;
1104
}
1105
1106
function restore_db()
1378
return $reqs;
1379
}
1380
1381
+ function ftp_backup($args)
1382
+ {
1383
+ extract($args);
1384
+ //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder, $ftp_site_folder
1385
+ $port = $ftp_port ? $ftp_port : 21; //default port is 21
1386
+ if ($ftp_ssl) {
1387
+ if (function_exists('ftp_ssl_connect')) {
1388
+ $conn_id = ftp_ssl_connect($ftp_hostname,$port);
1389
+ } else {
1390
+ return array(
1391
+ 'error' => 'Your server doesn\'t support SFTP',
1392
+ 'partial' => 1
1393
+ );
1394
+ }
1395
+ } else {
1396
+ if (function_exists('ftp_connect')) {
1397
+ $conn_id = ftp_connect($ftp_hostname,$port);
1398
+ if ($conn_id === false) {
1399
+ return array(
1400
+ 'error' => 'Failed to connect to ' . $ftp_hostname,
1401
+ 'partial' => 1
1402
+ );
1403
+ }
1404
+ } else {
1405
+ return array(
1406
+ 'error' => 'Your server doesn\'t support FTP',
1407
+ 'partial' => 1
1408
+ );
1409
+ }
1410
+ }
1411
+ $login = @ftp_login($conn_id, $ftp_username, $ftp_password);
1412
+ if ($login === false) {
1413
+ return array(
1414
+ 'error' => 'FTP login failed for ' . $ftp_username . ', ' . $ftp_password,
1415
+ 'partial' => 1
1416
+ );
1417
+ }
1418
+
1419
+ if($ftp_passive){
1420
+ @ftp_pasv($conn_id,true);
1421
+ }
1422
+
1423
+ @ftp_mkdir($conn_id, $ftp_remote_folder);
1424
+ if ($ftp_site_folder) {
1425
+ $ftp_remote_folder .= '/' . $this->site_name;
1426
+ }
1427
+ @ftp_mkdir($conn_id, $ftp_remote_folder);
1428
+
1429
+ $upload = @ftp_put($conn_id, $ftp_remote_folder . '/' . basename($backup_file), $backup_file, FTP_BINARY);
1430
+
1431
+ if ($upload === false) { //Try ascii
1432
+ $upload = @ftp_put($conn_id, $ftp_remote_folder . '/' . basename($backup_file), $backup_file, FTP_ASCII);
1433
+ }
1434
+ ftp_close($conn_id);
1435
+
1436
+ if ($upload === false) {
1437
+ return array(
1438
+ 'error' => 'Failed to upload file to FTP. Please check your specified path.',
1439
+ 'partial' => 1
1440
+ );
1441
+ }
1442
+
1443
+ return true;
1444
+ }
1445
+
1446
+ function remove_ftp_backup($args)
1447
+ {
1448
+ extract($args);
1449
+ //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder
1450
+ $port = $ftp_port ? $ftp_port : 21; //default port is 21
1451
+ if ($ftp_ssl && function_exists('ftp_ssl_connect')) {
1452
+ $conn_id = ftp_ssl_connect($ftp_hostname,$port);
1453
+ } else if (function_exists('ftp_connect')) {
1454
+ $conn_id = ftp_connect($ftp_hostname,$port);
1455
+ }
1456
+
1457
+ if ($conn_id) {
1458
+ $login = @ftp_login($conn_id, $ftp_username, $ftp_password);
1459
+ if ($ftp_site_folder)
1460
+ $ftp_remote_folder .= '/' . $this->site_name;
1461
+
1462
+ if($ftp_passive){
1463
+ @ftp_pasv($conn_id,true);
1464
+ }
1465
+
1466
+ $delete = ftp_delete($conn_id, $ftp_remote_folder . '/' . $backup_file);
1467
+
1468
+ ftp_close($conn_id);
1469
+ }
1470
+
1471
+ }
1472
+
1473
+ function get_ftp_backup($args)
1474
+ {
1475
+ extract($args);
1476
+ //Args: $ftp_username, $ftp_password, $ftp_hostname, $backup_file, $ftp_remote_folder
1477
+ $port = $ftp_port ? $ftp_port : 21; //default port is 21
1478
+ if ($ftp_ssl && function_exists('ftp_ssl_connect')) {
1479
+ $conn_id = ftp_ssl_connect($ftp_hostname,$port);
1480
+
1481
+ } else if (function_exists('ftp_connect')) {
1482
+ $conn_id = ftp_connect($ftp_hostname,$port);
1483
+ if ($conn_id === false) {
1484
+ return false;
1485
+ }
1486
+ }
1487
+ $login = @ftp_login($conn_id, $ftp_username, $ftp_password);
1488
+ if ($login === false) {
1489
+ return false;
1490
+ } else {
1491
+ }
1492
+
1493
+ if ($ftp_site_folder)
1494
+ $ftp_remote_folder .= '/' . $this->site_name;
1495
+
1496
+ if($ftp_passive){
1497
+ @ftp_pasv($conn_id,true);
1498
+ }
1499
+
1500
+ $temp = ABSPATH . 'iwp_temp_backup.zip';
1501
+ $get = ftp_get($conn_id, $temp, $ftp_remote_folder . '/' . $backup_file, FTP_BINARY);
1502
+ if ($get === false) {
1503
+ return false;
1504
+ } else {
1505
+ }
1506
+ ftp_close($conn_id);
1507
+
1508
+ return $temp;
1509
+ }
1510
+
1511
+
1512
+ function dropbox_backup($args)
1513
+ {
1514
+
1515
+ extract($args);
1516
+
1517
+ if(isset($consumer_secret) && !empty($consumer_secret)){
1518
+ //New way
1519
+ require_once('lib/dropbox.oauth.php');
1520
+
1521
+ $dropbox = new Dropbox($consumer_key, $consumer_secret);
1522
+ $dropbox->setOAuthToken($oauth_token);
1523
+ $dropbox->setOAuthTokenSecret($oauth_token_secret);
1524
+
1525
+ if ($dropbox_site_folder == true)
1526
+ $dropbox_destination .= '/' . $this->site_name;
1527
+
1528
+ try{
1529
+
1530
+ $dropbox->filesPost($dropbox_destination, $backup_file,true);
1531
+
1532
+ } catch(Exception $e){
1533
+ return array(
1534
+ 'error' => 'Dropbox upload error. '.$e->getMessage()
1535
+ );
1536
+ }
1537
+
1538
+ return true;
1539
+
1540
+ } else {
1541
+ //old way
1542
+ require_once('lib/dropbox.php');
1543
+ // extract($args);
1544
+
1545
+ //$email, $password, $backup_file, $destination, $dropbox_site_folder
1546
+
1547
+ $size = ceil(filesize($backup_file) / 1024);
1548
+ if ($size > 300000) {
1549
+ return array(
1550
+ 'error' => 'Cannot upload file to Dropbox. Dropbox has upload limit of 300Mb per file.',
1551
+ 'partial' => 1
1552
+ );
1553
+ }
1554
+
1555
+ if ($dropbox_site_folder == true)
1556
+ $dropbox_destination .= '/' . $this->site_name;
1557
+
1558
+ try {
1559
+ $uploader = new DropboxUploader($dropbox_username, $dropbox_password);
1560
+ $uploader->upload($backup_file, $dropbox_destination);
1561
+ }
1562
+ catch (Exception $e) {
1563
+ return array(
1564
+ 'error' => $e->getMessage(),
1565
+ 'partial' => 1
1566
+ );
1567
+ }
1568
+
1569
+ return true;
1570
+ }
1571
+
1572
+ }
1573
+
1574
+ function remove_dropbox_backup($args){
1575
+ extract($args);
1576
+ if(isset($consumer_secret) && !empty($consumer_secret)){
1577
+ //New way
1578
+ require_once('lib/dropbox.oauth.php');
1579
+
1580
+ $dropbox = new Dropbox($consumer_key, $consumer_secret);
1581
+ $dropbox->setOAuthToken($oauth_token);
1582
+ $dropbox->setOAuthTokenSecret($oauth_token_secret);
1583
+
1584
+ if ($dropbox_site_folder == true)
1585
+ $dropbox_destination .= '/' . $this->site_name;
1586
+
1587
+ try{
1588
+ $dropbox->fileopsDelete($dropbox_destination.'/'.$backup_file, true);
1589
+ } catch(Exception $e){
1590
+
1591
+ }
1592
+ }
1593
+ }
1594
+
1595
+ function get_dropbox_backup($args){
1596
+ extract($args);
1597
+
1598
+ if(isset($consumer_secret) && !empty($consumer_secret)){
1599
+ //New way
1600
+ require_once('lib/dropbox.oauth.php');
1601
+
1602
+ $dropbox = new Dropbox($consumer_key, $consumer_secret);
1603
+ $dropbox->setOAuthToken($oauth_token);
1604
+ $dropbox->setOAuthTokenSecret($oauth_token_secret);
1605
+
1606
+ if ($dropbox_site_folder == true)
1607
+ $dropbox_destination .= '/' . $this->site_name;
1608
+
1609
+ $temp = ABSPATH . 'mwp_temp_backup.zip';
1610
+
1611
+ try{
1612
+ $file = $dropbox->filesGet($dropbox_destination.'/'.$backup_file, true);
1613
+
1614
+ if(isset($file['data']) && !empty($file['data']) )
1615
+ $stream = base64_decode($file['data']);
1616
+ else
1617
+ return false;
1618
+
1619
+ $handle = @fopen($temp, 'w+');
1620
+ $result = fwrite($handle,$stream);
1621
+ fclose($handle);
1622
+
1623
+ if($result)
1624
+ return $temp;
1625
+ else
1626
+ return false;
1627
+
1628
+ } catch(Exception $e){
1629
+
1630
+
1631
+ return false;
1632
+ }
1633
+
1634
+ } else {
1635
+ return false;
1636
+ }
1637
+
1638
+
1639
+ }
1640
+
1641
+ function amazons3_backup($args)
1642
+ {
1643
+ if ($this->iwp_mmb_function_exists('curl_init')) {
1644
+ require_once('lib/s3.php');
1645
+ extract($args);
1646
+
1647
+ if ($as3_site_folder == true)
1648
+ $as3_directory .= '/' . $this->site_name;
1649
+
1650
+ $endpoint = isset($as3_bucket_region) ? $as3_bucket_region : 's3.amazonaws.com';
1651
+
1652
+ $s3 = new S3(trim($as3_access_key), trim(str_replace(' ', '+', $as3_secure_key)), false, $endpoint);
1653
+
1654
+ $s3->putBucket($as3_bucket, S3::ACL_PUBLIC_READ);
1655
+
1656
+ if ($s3->putObjectFile($backup_file, $as3_bucket, $as3_directory . '/' . basename($backup_file), S3::ACL_PRIVATE)) {
1657
+ return true;
1658
+ } else {
1659
+ return array(
1660
+ 'error' => 'Failed to upload to Amazon S3. Please check your details and set upload/delete permissions on your bucket.',
1661
+ 'partial' => 1
1662
+ );
1663
+ }
1664
+
1665
+ }
1666
+ else {
1667
+ return array(
1668
+ 'error' => 'You cannot use Amazon S3 on your server. Please enable curl first.',
1669
+ 'partial' => 1
1670
+ );
1671
+ }
1672
+ }
1673
+
1674
+ function remove_amazons3_backup($args)
1675
+ {
1676
+ if ($this->iwp_mmb_function_exists('curl_init')) {
1677
+ require_once('lib/s3.php');
1678
+ extract($args);
1679
+ if ($as3_site_folder == true)
1680
+ $as3_directory .= '/' . $this->site_name;
1681
+ $endpoint = isset($as3_bucket_region) ? $as3_bucket_region : 's3.amazonaws.com';
1682
+ try{
1683
+ $s3 = new S3($as3_access_key, str_replace(' ', '+', $as3_secure_key), false, $endpoint);
1684
+ $s3->deleteObject($as3_bucket, $as3_directory . '/' . $backup_file);
1685
+ } catch (Exception $e){
1686
+
1687
+ }
1688
+ }
1689
+ }
1690
+
1691
+ function get_amazons3_backup($args)
1692
+ {
1693
+ require_once('lib/s3.php');
1694
+ extract($args);
1695
+ $endpoint = isset($as3_bucket_region) ? $as3_bucket_region : 's3.amazonaws.com';
1696
+ $temp = '';
1697
+ try{
1698
+ $s3 = new S3($as3_access_key, str_replace(' ', '+', $as3_secure_key), false, $endpoint);
1699
+ if ($as3_site_folder == true)
1700
+ $as3_directory .= '/' . $this->site_name;
1701
+
1702
+ $temp = ABSPATH . 'iwp_temp_backup.zip';
1703
+ $s3->getObject($as3_bucket, $as3_directory . '/' . $backup_file, $temp);
1704
+ } catch (Exception $e){
1705
+ return $temp;
1706
+ }
1707
+ return $temp;
1708
+ }
1709
+ //IWP Remove ends here
1710
+
1711
+
1712
+ function schedule_next($type, $schedule)
1713
+ {
1714
+ $schedule = explode("|", $schedule);
1715
+ if (empty($schedule))
1716
+ return false;
1717
+ switch ($type) {
1718
+
1719
+ case 'daily':
1720
+
1721
+ if (isset($schedule[1]) && $schedule[1]) {
1722
+ $delay_time = $schedule[1] * 60;
1723
+ }
1724
+
1725
+ $current_hour = date("H");
1726
+ $schedule_hour = $schedule[0];
1727
+ if ($current_hour >= $schedule_hour){
1728
+ $time = mktime($schedule_hour, 0, 0, date("m"), date("d") + 1, date("Y"));
1729
+ //$time ='0001#'.$current_hour.'|'.$schedule_hour;
1730
+
1731
+ }
1732
+
1733
+ else{
1734
+ $time = mktime($schedule_hour, 0, 0, date("m"), date("d"), date("Y"));
1735
+ //$time ='0000#'.$current_hour.'|'.$schedule_hour;
1736
+ }
1737
+ $time = time() + 30;
1738
+
1739
+ file_put_contents("timetest.txt", var_export($time, true).'|'.var_export($schedule_hour, true).'|'.var_export($current_hour, true));
1740
+ break;
1741
+
1742
+
1743
+ case 'weekly':
1744
+ if (isset($schedule[2]) && $schedule[2]) {
1745
+ $delay_time = $schedule[2] * 60;
1746
+ }
1747
+ $current_weekday = date('w');
1748
+ $schedule_weekday = $schedule[1];
1749
+ $current_hour = date("H");
1750
+ $schedule_hour = $schedule[0];
1751
+
1752
+ if ($current_weekday > $schedule_weekday)
1753
+ $weekday_offset = 7 - ($week_day - $task_schedule[1]);
1754
+ else
1755
+ $weekday_offset = $schedule_weekday - $current_weekday;
1756
+
1757
+
1758
+ if (!$weekday_offset) { //today is scheduled weekday
1759
+ if ($current_hour >= $schedule_hour)
1760
+ $time = mktime($schedule_hour, 0, 0, date("m"), date("d") + 7, date("Y"));
1761
+ else
1762
+ $time = mktime($schedule_hour, 0, 0, date("m"), date("d"), date("Y"));
1763
+ } else {
1764
+ $time = mktime($schedule_hour, 0, 0, date("m"), date("d") + $weekday_offset, date("Y"));
1765
+ }
1766
+
1767
+ break;
1768
+
1769
+ case 'monthly':
1770
+ if (isset($schedule[2]) && $schedule[2]) {
1771
+ $delay_time = $schedule[2] * 60;
1772
+ }
1773
+ $current_monthday = date('j');
1774
+ $schedule_monthday = $schedule[1];
1775
+ $current_hour = date("H");
1776
+ $schedule_hour = $schedule[0];
1777
+
1778
+ if ($current_monthday > $schedule_monthday) {
1779
+ $time = mktime($schedule_hour, 0, 0, date("m") + 1, $schedule_monthday, date("Y"));
1780
+ } else if ($current_monthday < $schedule_monthday) {
1781
+ $time = mktime($schedule_hour, 0, 0, date("m"), $schedule_monthday, date("Y"));
1782
+ } else if ($current_monthday == $schedule_monthday) {
1783
+ if ($current_hour >= $schedule_hour)
1784
+ $time = mktime($schedule_hour, 0, 0, date("m") + 1, $schedule_monthday, date("Y"));
1785
+ else
1786
+ $time = mktime($schedule_hour, 0, 0, date("m"), $schedule_monthday, date("Y"));
1787
+ break;
1788
+ }
1789
+
1790
+ break;
1791
+ default:
1792
+ break;
1793
+ }
1794
+
1795
+ if (isset($delay_time) && $delay_time) {
1796
+ $time += $delay_time;
1797
+ }
1798
+
1799
+ return $time;
1800
+ }
1801
+
1802
+
1803
//Parse task arguments for info on IWP Admin Panel
1804
function get_backup_stats()
1805
{
1824
return $stats;
1825
}
1826
1827
+ /*
1828
+ //IWP Remove starts here//IWP Remove ends here
1829
+ */
1830
+ function get_next_schedules()
1831
+ {
1832
+ $stats = array();
1833
+ $tasks = $this->tasks;
1834
+ if (is_array($tasks) && !empty($tasks)) {
1835
+ foreach ($tasks as $task_name => $info) {
1836
+ $stats[$task_name] = isset($info['task_args']['next']) ? $info['task_args']['next'] : array();
1837
+ }
1838
+ }
1839
+ return $stats;
1840
+ }
1841
+
1842
+
1843
function remove_old_backups($task_name)
1844
{
1845
//Check for previous failed backups first
1863
@unlink($backups[$task_name]['task_results'][$i]['server']['file_path']);
1864
}
1865
1866
+ if (isset($backups[$task_name]['task_results'][$i]['ftp'])) {
1867
+ $ftp_file = $backups[$task_name]['task_results'][$i]['ftp'];
1868
+ $args = $backups[$task_name]['task_args']['account_info']['iwp_ftp'];
1869
+ $args['backup_file'] = $ftp_file;
1870
+ $this->remove_ftp_backup($args);
1871
+ }
1872
+
1873
+ if (isset($backups[$task_name]['task_results'][$i]['amazons3'])) {
1874
+ $amazons3_file = $backups[$task_name]['task_results'][$i]['amazons3'];
1875
+ $args = $backups[$task_name]['task_args']['account_info']['iwp_amazon_s3'];
1876
+ $args['backup_file'] = $amazons3_file;
1877
+ $this->remove_amazons3_backup($args);
1878
+ }
1879
+
1880
+ if (isset($backups[$task_name]['task_results'][$i]['dropbox']) && isset($backups[$task_name]['task_args']['account_info']['mwp_dropbox'])) {
1881
+ //To do: dropbox remove
1882
+ $dropbox_file = $backups[$task_name]['task_results'][$i]['dropbox'];
1883
+ $args = $backups[$task_name]['task_args']['account_info']['mwp_dropbox'];
1884
+ $args['backup_file'] = $dropbox_file;
1885
+ $this->remove_dropbox_backup($args);
1886
+ }
1887
//Remove database backup info
1888
unset($backups[$task_name]['task_results'][$i]);
1889
1918
if (isset($backup['server'])) {
1919
@unlink($backup['server']['file_path']);
1920
}
1921
+
1922
+ /*
1923
+ //IWP Remove starts here//IWP Remove ends here
1924
+ */
1925
+ //Remove from ftp
1926
+ if (isset($backup['ftp'])) {
1927
+ $ftp_file = $backup['ftp'];
1928
+ $args = $tasks[$task_name]['task_args']['account_info']['iwp_ftp'];
1929
+ $args['backup_file'] = $ftp_file;
1930
+ $this->remove_ftp_backup($args);
1931
+ }
1932
+
1933
+ if (isset($backup['amazons3'])) {
1934
+ $amazons3_file = $backup['amazons3'];
1935
+ $args = $tasks[$task_name]['task_args']['account_info']['iwp_amazon_s3'];
1936
+ $args['backup_file'] = $amazons3_file;
1937
+ $this->remove_amazons3_backup($args);
1938
+ }
1939
+
1940
+ if (isset($backup['dropbox'])) {
1941
+ $dropbox_file = $backup['dropbox'];
1942
+ $args = $tasks[$task_name]['task_args']['account_info']['iwp_dropbox'];
1943
+ $args['backup_file'] = $dropbox_file;
1944
+ $this->remove_dropbox_backup($args);
1945
+ }
1946
+
1947
+
1948
unset($backups[$result_id]);
1949
1950
if (count($backups)) {
1979
1980
1981
//clean_old folder?
1982
+ if ((basename($files[0]) == 'index.php' && count($files) == 1) || (empty($files))) { //USE (!empty($files)
1983
foreach ($files as $file) {
1984
@unlink($file);
1985
}
1987
@rmdir(WP_CONTENT_DIR . '/' . md5('iwp_mmb-client'));
1988
}
1989
1990
+ // USE $new = array();
1991
foreach ($new as $b) {
1992
$files[] = $b;
1993
}
core.class.php CHANGED
@@ -35,6 +35,9 @@ class IWP_MMB_Core extends IWP_MMB_Helper
35
var $installer_instance;
36
var $iwp_mmb_multisite;
37
var $network_admin_install;
38
private $action_call;
39
private $action_params;
40
private $iwp_mmb_pre_init_actions;
@@ -122,6 +125,7 @@ class IWP_MMB_Core extends IWP_MMB_Helper
122
'check_backup_compat' => 'iwp_mmb_check_backup_compat',
123
'scheduled_backup' => 'iwp_mmb_scheduled_backup',
124
'run_task' => 'iwp_mmb_run_task_now',
125
'execute_php_code' => 'iwp_mmb_execute_php_code',
126
'delete_backup' => 'mmm_delete_backup',
127
'remote_backup_now' => 'iwp_mmb_remote_backup_now',
@@ -133,7 +137,9 @@ class IWP_MMB_Core extends IWP_MMB_Helper
133
'edit_plugins_themes' => 'iwp_mmb_edit_plugins_themes',
134
'client_brand' => 'iwp_mmb_client_brand',
135
'set_alerts' => 'iwp_mmb_set_alerts',
136
- 'maintenance' => 'iwp_mmb_maintenance_mode'
137
);
138
139
add_action('rightnow_end', array( &$this, 'add_right_now_info' ));
@@ -379,6 +385,15 @@ class IWP_MMB_Core extends IWP_MMB_Helper
379
return $this->backup_instance;
380
}
381
382
/**
383
* Gets an instance of links class
384
*
35
var $installer_instance;
36
var $iwp_mmb_multisite;
37
var $network_admin_install;
38
+
39
+ var $backup_repository_instance;
40
+
41
private $action_call;
42
private $action_params;
43
private $iwp_mmb_pre_init_actions;
125
'check_backup_compat' => 'iwp_mmb_check_backup_compat',
126
'scheduled_backup' => 'iwp_mmb_scheduled_backup',
127
'run_task' => 'iwp_mmb_run_task_now',
128
+ 'delete_schedule_task' => 'iwp_mmb_delete_task_now',
129
'execute_php_code' => 'iwp_mmb_execute_php_code',
130
'delete_backup' => 'mmm_delete_backup',
131
'remote_backup_now' => 'iwp_mmb_remote_backup_now',
137
'edit_plugins_themes' => 'iwp_mmb_edit_plugins_themes',
138
'client_brand' => 'iwp_mmb_client_brand',
139
'set_alerts' => 'iwp_mmb_set_alerts',
140
+ 'maintenance' => 'iwp_mmb_maintenance_mode',
141
+
142
+ 'backup_repository' => 'iwp_mmb_backup_repository'
143
);
144
145
add_action('rightnow_end', array( &$this, 'add_right_now_info' ));
385
return $this->backup_instance;
386
}
387
388
+ function get_backup_repository_instance()
389
+ {
390
+ if (!isset($this->backup_repository_instance)) {
391
+ $this->backup_repository_instance = new IWP_MMB_Backup_Repository();
392
+ }
393
+
394
+ return $this->backup_repository_instance;
395
+ }
396
+
397
/**
398
* Gets an instance of links class
399
*
helper.class.php CHANGED
@@ -16,6 +16,9 @@
16
* www.prelovac.com
17
**************************************************************/
18
19
class IWP_MMB_Helper
20
{
21
/**
@@ -357,7 +360,7 @@ class IWP_MMB_Helper
357
);
358
}
359
360
- if (function_exists('openssl_verify') && !$this->get_random_signature()) {
361
$verify = openssl_verify($data, $signature, $pl_key);
362
if ($verify == 1) {
363
$message_id = $this->set_client_message_id($message_id);
@@ -497,10 +500,5 @@ class IWP_MMB_Helper
497
die('Error downloading file ' . $url);
498
return $file_name;
499
}
500
-
501
-
502
-
503
-
504
-
505
}
506
?>
16
* www.prelovac.com
17
**************************************************************/
18
19
+ if(!defined('MMB_WORKER_VERSION'))
20
+ define('MMB_WORKER_VERSION', '0');
21
+
22
class IWP_MMB_Helper
23
{
24
/**
360
);
361
}
362
363
+ if (checkOpenSSL() && !$this->get_random_signature()) {
364
$verify = openssl_verify($data, $signature, $pl_key);
365
if ($verify == 1) {
366
$message_id = $this->set_client_message_id($message_id);
500
die('Error downloading file ' . $url);
501
return $file_name;
502
}
503
}
504
?>
init.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: InfiniteWP - Client
4
Plugin URI: http://infinitewp.com/
5
Description: This is the client plugin of InfiniteWP that communicates with the InfiniteWP Admin panel.
6
Author: Revmakx
7
- Version: 1.0.3
8
Author URI: http://www.revmakx.com
9
*/
10
/************************************************************
@@ -26,7 +26,8 @@ Author URI: http://www.revmakx.com
26
**************************************************************/
27
28
if(!defined('IWP_MMB_CLIENT_VERSION'))
29
- define('IWP_MMB_CLIENT_VERSION', '1.0.3');
30
31
if ( !defined('IWP_MMB_XFRAME_COOKIE')){
32
$siteurl = function_exists('get_site_option') ? get_site_option( 'siteurl' ) : get_option('siteurl');
@@ -46,6 +47,7 @@ require_once("$iwp_mmb_plugin_dir/core.class.php");
46
require_once("$iwp_mmb_plugin_dir/stats.class.php");
47
require_once("$iwp_mmb_plugin_dir/backup.class.php");
48
require_once("$iwp_mmb_plugin_dir/installer.class.php");
49
require_once("$iwp_mmb_plugin_dir/api.php");
50
require_once("$iwp_mmb_plugin_dir/plugins/search/search.php");
51
require_once("$iwp_mmb_plugin_dir/plugins/cleanup/cleanup.php");
@@ -133,12 +135,15 @@ if( !function_exists ('iwp_mmb_parse_request')) {
133
}
134
135
if(isset($params['secure'])){
136
if($decrypted = $iwp_mmb_core->_secure_data($params['secure'])){
137
$decrypted = maybe_unserialize($decrypted);
138
if(is_array($decrypted)){
139
foreach($decrypted as $key => $val){
140
if(!is_numeric($key))
141
$params[$key] = $val;
142
}
143
unset($params['secure']);
144
} else $params['secure'] = $decrypted;
@@ -199,7 +204,7 @@ if( !function_exists ( 'iwp_mmb_add_site' )) {
199
return;
200
}
201
202
- if (function_exists('openssl_verify') && !$user_random_key_signing) {
203
$verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
204
if ($verify == 1) {
205
$iwp_mmb_core->set_admin_panel_public_key($public_key);
@@ -341,6 +346,19 @@ if( !function_exists ( 'iwp_mmb_run_task_now' )) {
341
}
342
}
343
344
if( !function_exists ( 'iwp_mmb_check_backup_compat' )) {
345
function iwp_mmb_check_backup_compat($params)
346
{
@@ -420,6 +438,18 @@ if( !function_exists ( 'iwp_mmb_restore_now' )) {
420
}
421
422
423
424
425
if( !function_exists ( 'iwp_mmb_clean_orphan_backups' )) {
@@ -679,6 +709,26 @@ if( !function_exists('iwp_mmb_plugin_actions') ){
679
}
680
}
681
682
$iwp_mmb_core = new IWP_MMB_Core();
683
684
if(isset($_GET['auto_login']))
4
Plugin URI: http://infinitewp.com/
5
Description: This is the client plugin of InfiniteWP that communicates with the InfiniteWP Admin panel.
6
Author: Revmakx
7
+ Version: 1.0.4
8
Author URI: http://www.revmakx.com
9
*/
10
/************************************************************
26
**************************************************************/
27
28
if(!defined('IWP_MMB_CLIENT_VERSION'))
29
+ define('IWP_MMB_CLIENT_VERSION', '1.0.4');
30
+
31
32
if ( !defined('IWP_MMB_XFRAME_COOKIE')){
33
$siteurl = function_exists('get_site_option') ? get_site_option( 'siteurl' ) : get_option('siteurl');
47
require_once("$iwp_mmb_plugin_dir/stats.class.php");
48
require_once("$iwp_mmb_plugin_dir/backup.class.php");
49
require_once("$iwp_mmb_plugin_dir/installer.class.php");
50
+ require_once("$iwp_mmb_plugin_dir/addons/backup_repository/backup_repository.class.php");
51
require_once("$iwp_mmb_plugin_dir/api.php");
52
require_once("$iwp_mmb_plugin_dir/plugins/search/search.php");
53
require_once("$iwp_mmb_plugin_dir/plugins/cleanup/cleanup.php");
135
}
136
137
if(isset($params['secure'])){
138
+
139
if($decrypted = $iwp_mmb_core->_secure_data($params['secure'])){
140
$decrypted = maybe_unserialize($decrypted);
141
if(is_array($decrypted)){
142
+
143
foreach($decrypted as $key => $val){
144
if(!is_numeric($key))
145
$params[$key] = $val;
146
+
147
}
148
unset($params['secure']);
149
} else $params['secure'] = $decrypted;
204
return;
205
}
206
207
+ if (checkOpenSSL() && !$user_random_key_signing) {
208
$verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
209
if ($verify == 1) {
210
$iwp_mmb_core->set_admin_panel_public_key($public_key);
346
}
347
}
348
349
+ if( !function_exists ( 'iwp_mmb_delete_task_now' )) {
350
+ function iwp_mmb_delete_task_now($params)
351
+ {
352
+ global $iwp_mmb_core;
353
+ $iwp_mmb_core->get_backup_instance();
354
+ $return = $iwp_mmb_core->backup_instance->delete_task_now($params['task_name']);
355
+ if (is_array($return) && array_key_exists('error', $return))
356
+ iwp_mmb_response($return['error'], false);
357
+ else {
358
+ iwp_mmb_response($return, true);
359
+ }
360
+ }
361
+ }
362
if( !function_exists ( 'iwp_mmb_check_backup_compat' )) {
363
function iwp_mmb_check_backup_compat($params)
364
{
438
}
439
440
441
+ if( !function_exists ( 'iwp_mmb_backup_repository' )) {
442
+ function iwp_mmb_backup_repository($params)
443
+ {
444
+ global $iwp_mmb_core;
445
+ $iwp_mmb_core->get_backup_repository_instance();
446
+ $return = $iwp_mmb_core->backup_repository_instance->backup_repository($params);
447
+ if (is_array($return) && array_key_exists('error', $return))
448
+ iwp_mmb_response($return['error'], false);
449
+ else
450
+ iwp_mmb_response($return, true);
451
+ }
452
+ }
453
454
455
if( !function_exists ( 'iwp_mmb_clean_orphan_backups' )) {
709
}
710
}
711
712
+ if(!function_exists('checkOpenSSL')){
713
+ function checkOpenSSL(){
714
+ if(!function_exists('openssl_verify')){
715
+ return false;
716
+ }
717
+ else{
718
+ $key = @openssl_pkey_new();
719
+ @openssl_pkey_export($key, $privateKey);
720
+ $privateKey = base64_encode($privateKey);
721
+ $publicKey = @openssl_pkey_get_details($key);
722
+ $publicKey = $publicKey["key"];
723
+
724
+ if(empty($publicKey) || empty($privateKey)){
725
+ return false;
726
+ }
727
+ }
728
+ return true;
729
+ }
730
+ }
731
+
732
$iwp_mmb_core = new IWP_MMB_Core();
733
734
if(isset($_GET['auto_login']))
installer.class.php CHANGED
@@ -489,43 +489,96 @@ class IWP_MMB_Installer extends IWP_MMB_Core
489
490
$upgrader = false;
491
$pr_update = array();
492
$result = array();
493
$premium_update = array();
494
- $premium_update = apply_filters('iwp_premium_perform_update', $premium_update);
495
-
496
if (!empty($premium_update)) {
497
foreach ($premium as $pr) {
498
- foreach ($premium_update as $update) {
499
$update = array_change_key_case($update, CASE_LOWER);
500
-
501
if ($update['name'] == $pr['name']) {
502
$update_result = false;
503
if (isset($update['url'])) {
504
if (defined('WP_INSTALLING') && file_exists(ABSPATH . '.maintenance'))
505
$pr_update[$update['type'] . 's']['upgraded'][md5($update['name'])] = 'Site under maintanace.';
506
507
- if ($upgrader == false) {
508
$upgrader_skin = new WP_Upgrader_Skin();
509
$upgrader_skin->done_header = true;
510
-
511
$upgrader = new WP_Upgrader();
512
- }
513
-
514
@$update_result = $upgrader->run(array(
515
'package' => $update['url'],
516
'destination' => isset($update['type']) && $update['type'] == 'theme' ? WP_CONTENT_DIR . '/themes' : WP_PLUGIN_DIR,
517
'clear_destination' => true,
518
'clear_working' => true,
519
'hook_extra' => array()
520
));
521
$update_result = !$update_result || is_wp_error($update_result) ? $this->iwp_mmb_get_error($update_result) : 1;
522
523
} else if (isset($update['callback'])) {
524
if (is_array($update['callback'])) {
525
- $update_result = call_user_func(array(
526
- $update['callback'][0],
527
- $update['callback'][1]
528
- ));
529
} else if (is_string($update['callback'])) {
530
$update_result = call_user_func($update['callback']);
531
} else {
@@ -539,7 +592,6 @@ class IWP_MMB_Installer extends IWP_MMB_Core
539
$pr_update[$update['type'] . 's']['upgraded'][md5($update['name'])] = $update_result;
540
}
541
}
542
- }
543
return $pr_update;
544
} else {
545
foreach ($premium as $pr) {
@@ -653,12 +705,14 @@ class IWP_MMB_Installer extends IWP_MMB_Core
653
if (in_array($path, $activated_plugins)) {
654
$plugins['active'][$br_a]['path'] = $path;
655
$plugins['active'][$br_a]['name'] = strip_tags($plugin['Name']);
656
$br_a++;
657
}
658
659
if (!in_array($path, $activated_plugins)) {
660
$plugins['inactive'][$br_i]['path'] = $path;
661
$plugins['inactive'][$br_i]['name'] = strip_tags($plugin['Name']);
662
$br_i++;
663
}
664
@@ -708,6 +762,7 @@ class IWP_MMB_Installer extends IWP_MMB_Core
708
if ($current_theme == $theme_name) {
709
$themes['active'][$br_a]['path'] = $theme['Template'];
710
$themes['active'][$br_a]['name'] = strip_tags($theme['Name']);
711
$themes['active'][$br_a]['stylesheet'] = $theme['Stylesheet'];
712
$br_a++;
713
}
@@ -715,6 +770,7 @@ class IWP_MMB_Installer extends IWP_MMB_Core
715
if ($current_theme != $theme_name) {
716
$themes['inactive'][$br_i]['path'] = $theme['Template'];
717
$themes['inactive'][$br_i]['name'] = strip_tags($theme['Name']);
718
$themes['inactive'][$br_i]['stylesheet'] = $theme['Stylesheet'];
719
$br_i++;
720
}
489
490
$upgrader = false;
491
$pr_update = array();
492
+ $themes = array();
493
+ $plugins = array();
494
$result = array();
495
$premium_update = array();
496
+ $premium_update = apply_filters('mwp_premium_perform_update', $premium_update);
497
if (!empty($premium_update)) {
498
+
499
foreach ($premium as $pr) {
500
+ foreach ($premium_update as $key => $update) {
501
$update = array_change_key_case($update, CASE_LOWER);
502
if ($update['name'] == $pr['name']) {
503
+
504
+ // prepare bulk updates for premiums that use WordPress upgrader
505
+ if(isset($update['type'])){
506
+ if($update['type'] == 'plugin'){
507
+ if(isset($update['slug']) && !empty($update['slug']))
508
+ $plugins[$update['slug']] = $update;
509
+ }
510
+
511
+ if($update['type'] == 'theme'){
512
+ if(isset($update['template']) && !empty($update['template']))
513
+ $themes[$update['template']] = $update;
514
+ }
515
+ }
516
+ } else {
517
+ unset($premium_update[$key]);
518
+ }
519
+ }
520
+ }
521
+
522
+ // try default wordpress upgrader
523
+ if(!empty($plugins)){
524
+ $updateplugins = $this->upgrade_plugins(array_keys($plugins));
525
+ if(!empty($updateplugins) && isset($updateplugins['upgraded'])){
526
+ foreach ($premium_update as $key => $update) {
527
+ $update = array_change_key_case($update, CASE_LOWER);
528
+ foreach($updateplugins['upgraded'] as $slug => $upgrade){
529
+ if( isset($update['slug']) && $update['slug'] == $slug){
530
+ if( $upgrade == 1 )
531
+ unset($premium_update[$key]);
532
+
533
+ $pr_update['plugins']['upgraded'][md5($update['name'])] = $upgrade;
534
+ }
535
+ }
536
+ }
537
+ }
538
+ }
539
+
540
+ if(!empty($themes)){
541
+ $updatethemes = $this->upgrade_themes(array_keys($themes));
542
+ if(!empty($updatethemes) && isset($updatethemes['upgraded'])){
543
+ foreach ($premium_update as $key => $update) {
544
+ $update = array_change_key_case($update, CASE_LOWER);
545
+ foreach($updatethemes['upgraded'] as $template => $upgrade){
546
+ if( isset($update['template']) && $update['template'] == $template) {
547
+ if( $upgrade == 1 )
548
+ unset($premium_update[$key]);
549
+
550
+ $pr_update['themes']['upgraded'][md5($update['name'])] = $upgrade;
551
+ }
552
+ }
553
+ }
554
+ }
555
+ }
556
+
557
+ //try direct install with overwrite
558
+ if (!empty($premium_update)) {
559
+ foreach ($premium_update as $update) {
560
+ $update = array_change_key_case($update, CASE_LOWER);
561
$update_result = false;
562
if (isset($update['url'])) {
563
if (defined('WP_INSTALLING') && file_exists(ABSPATH . '.maintenance'))
564
$pr_update[$update['type'] . 's']['upgraded'][md5($update['name'])] = 'Site under maintanace.';
565
566
$upgrader_skin = new WP_Upgrader_Skin();
567
$upgrader_skin->done_header = true;
568
$upgrader = new WP_Upgrader();
569
@$update_result = $upgrader->run(array(
570
'package' => $update['url'],
571
'destination' => isset($update['type']) && $update['type'] == 'theme' ? WP_CONTENT_DIR . '/themes' : WP_PLUGIN_DIR,
572
'clear_destination' => true,
573
'clear_working' => true,
574
+ 'is_multi' => true,
575
'hook_extra' => array()
576
));
577
$update_result = !$update_result || is_wp_error($update_result) ? $this->iwp_mmb_get_error($update_result) : 1;
578
579
} else if (isset($update['callback'])) {
580
if (is_array($update['callback'])) {
581
+ $update_result = call_user_func(array( $update['callback'][0], $update['callback'][1] ));
582
} else if (is_string($update['callback'])) {
583
$update_result = call_user_func($update['callback']);
584
} else {
592
$pr_update[$update['type'] . 's']['upgraded'][md5($update['name'])] = $update_result;
593
}
594
}
595
return $pr_update;
596
} else {
597
foreach ($premium as $pr) {
705
if (in_array($path, $activated_plugins)) {
706
$plugins['active'][$br_a]['path'] = $path;
707
$plugins['active'][$br_a]['name'] = strip_tags($plugin['Name']);
708
+ $plugins['active'][$br_a]['version'] = $plugin['Version'];
709
$br_a++;
710
}
711
712
if (!in_array($path, $activated_plugins)) {
713
$plugins['inactive'][$br_i]['path'] = $path;
714
$plugins['inactive'][$br_i]['name'] = strip_tags($plugin['Name']);
715
+ $plugins['inactive'][$br_i]['version'] = $plugin['Version'];
716
$br_i++;
717
}
718
762
if ($current_theme == $theme_name) {
763
$themes['active'][$br_a]['path'] = $theme['Template'];
764
$themes['active'][$br_a]['name'] = strip_tags($theme['Name']);
765
+ $themes['active'][$br_a]['version'] = $theme['Version'];
766
$themes['active'][$br_a]['stylesheet'] = $theme['Stylesheet'];
767
$br_a++;
768
}
770
if ($current_theme != $theme_name) {
771
$themes['inactive'][$br_i]['path'] = $theme['Template'];
772
$themes['inactive'][$br_i]['name'] = strip_tags($theme['Name']);
773
+ $themes['inactive'][$br_i]['version'] = $theme['Version'];
774
$themes['inactive'][$br_i]['stylesheet'] = $theme['Stylesheet'];
775
$br_i++;
776
}
lib/dropbox.oauth.php ADDED
@@ -0,0 +1,1133 @@