Backup and Restore WordPress – WPBackItUp Backup Plugin - Version 1.6.2

Version Description

  • Fixed issue with version 1.6.1 update
Download this release

Release Info

Developer cssimmon
Plugin Icon 128x128 Backup and Restore WordPress – WPBackItUp Backup Plugin
Version 1.6.2
Comparing to
See all releases

Code changes from version 1.6.0 to 1.6.2

index.php CHANGED
@@ -7,13 +7,13 @@
7
  * @global object $wpdb
8
  *
9
  * @author cssimmon
10
- * @version 1.6.0
11
  */
12
  /*
13
  Plugin Name: WP Backitup
14
  Plugin URI: http://www.wpbackitup.com
15
  Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
16
- Version: 1.6.0
17
  Author: Chris Simmons
18
  Author URI: http://www.wpbackitup.com
19
  License: GPL3
@@ -43,7 +43,8 @@ class WPBackitup {
43
 
44
  // Default plugin options
45
  var $defaults = array(
46
- 'presstrends' => "enabled",
 
47
  'license_key' => "",
48
  'status' => "inactive"
49
  );
7
  * @global object $wpdb
8
  *
9
  * @author cssimmon
10
+ * @version 1.6.2
11
  */
12
  /*
13
  Plugin Name: WP Backitup
14
  Plugin URI: http://www.wpbackitup.com
15
  Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
16
+ Version: 1.6.1
17
  Author: Chris Simmons
18
  Author URI: http://www.wpbackitup.com
19
  License: GPL3
43
 
44
  // Default plugin options
45
  var $defaults = array(
46
+ 'presstrends' => "disabled",
47
+ 'logging' => "disabled",
48
  'license_key' => "",
49
  'status' => "inactive"
50
  );
js/admin.js CHANGED
@@ -235,12 +235,16 @@
235
  // built id of the row to be inserted dynamically
236
  if (data != undefined)
237
  {
 
238
  var newRow = '<tr ' + css_class + ' id="row' + cur_row + '">\n\
239
  <td>' + data.file +'</td>\n\
240
  <td><a href="' + data.link + '">Download</a></td>\n\
241
- <td><a href="#" title="' + data.file + '" class="deleteRow" id="deleteRow' + cur_row + '">Delete</a></td>\n\
242
- <td><a href="#" title="' + data.file + '" class="restoreRow" id="restoreRow' + cur_row + '">Restore</a></td>\n\
243
- </tr>';
 
 
 
244
 
245
  if ($('#nofiles'))
246
  $('#nofiles').remove();
235
  // built id of the row to be inserted dynamically
236
  if (data != undefined)
237
  {
238
+ var restoreColumn = '<td><a href="#" title="' + data.file + '" class="restoreRow" id="restoreRow' + cur_row + '">Restore</a></td>\n';
239
  var newRow = '<tr ' + css_class + ' id="row' + cur_row + '">\n\
240
  <td>' + data.file +'</td>\n\
241
  <td><a href="' + data.link + '">Download</a></td>\n\
242
+ <td><a href="#" title="' + data.file + '" class="deleteRow" id="deleteRow' + cur_row + '">Delete</a></td>\n';
243
+
244
+ if (true==data.license)
245
+ newRow +=restoreColumn;
246
+
247
+ newRow +='</tr>';
248
 
249
  if ($('#nofiles'))
250
  $('#nofiles').remove();
lib/constants.php CHANGED
@@ -9,7 +9,7 @@
9
  * @since 1.0.1
10
  */
11
 
12
- if( !defined( 'WPBACKITUP_VERSION' ) ) define( 'WPBACKITUP_VERSION', '1.6.0' );
13
 
14
  if( !defined( 'WPBACKITUP_DIRNAME' ) ) define( 'WPBACKITUP_DIRNAME', dirname( dirname( __FILE__ ) ) );
15
 
9
  * @since 1.0.1
10
  */
11
 
12
+ if( !defined( 'WPBACKITUP_VERSION' ) ) define( 'WPBACKITUP_VERSION', '1.6.2' );
13
 
14
  if( !defined( 'WPBACKITUP_DIRNAME' ) ) define( 'WPBACKITUP_DIRNAME', dirname( dirname( __FILE__ ) ) );
15
 
lib/functions.php CHANGED
@@ -28,6 +28,27 @@ if( !class_exists( 'RecursiveFilter_Iterator' ) ) {
28
  // retrieve our license key from the DB
29
  $license_key = trim( $this->get_option( 'license_key' ) );
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  //define dbSize function
32
  function dbSize($dbname) {
33
  mysqli_select_db($dbname);
@@ -200,15 +221,9 @@ if(!function_exists('db_rename_wptables')) {
200
  function db_rename_wptables($sql_file_path,$table_prefix) {
201
  _log('(db_rename_wptables)Manually Create SQL Backup File:'.$sql_file_path);
202
 
203
- $db_name = DB_NAME;
204
- $db_user = DB_USER;
205
- $db_pass = DB_PASSWORD;
206
- $db_host = DB_HOST;
207
-
208
- //Get a connection to the DB
209
- $mysqli = new mysqli($db_host , $db_user , $db_pass , $db_name) ;
210
- if (mysqli_connect_errno()) {
211
- return false;
212
  }
213
 
214
  $tables = array() ;
@@ -241,7 +256,7 @@ if(!function_exists('db_rename_wptables')) {
241
  $return .= "--\n";
242
  $return .= '-- Created: ' . date("Y/m/d") . "\n";
243
  $return .= "--\n";
244
- $return .= "-- Database : " . $db_name . "\n";
245
  $return .= "--\n";
246
  $return .= "-- --------------------------------------------------\n";
247
  $return .= "-- ---------------------------------------------------\n";
@@ -277,35 +292,85 @@ if(!function_exists('db_rename_wptables')) {
277
  }
278
  }
279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
 
281
  //Define DB backup function
282
  if(!function_exists('db_backup')) {
283
  function db_backup($sql_file_path) {
284
  _log('(functions.db_backup)Manually Create SQL Backup File:'.$sql_file_path);
285
-
286
- $db_name = DB_NAME;
287
- $db_user = DB_USER;
288
- $db_pass = DB_PASSWORD;
289
- $db_host = DB_HOST;
290
 
291
- $mysqli = new mysqli($db_host , $db_user , $db_pass , $db_name) ;
292
- if (mysqli_connect_errno()) {
293
- return false;
 
 
294
  }
295
 
296
- // Introduction information
297
- $return = '';
 
 
298
  $return .= "--\n";
299
- $return .= "-- WP Backitup Database Backup \n";
300
  $return .= "--\n";
301
- $return .= '-- Created: ' . date("Y/m/d") . ' on ' . date("h:i") . "\n\n\n";
302
- $return = "--\n";
303
- $return .= "-- Database : " . $db_name . "\n";
304
  $return .= "--\n";
305
- $return .= "-- --------------------------------------------------\n";
306
- $return .= "-- ---------------------------------------------------\n";
 
 
307
  $return .= 'SET AUTOCOMMIT = 0 ;' ."\n" ;
308
  $return .= 'SET FOREIGN_KEY_CHECKS=0 ;' ."\n" ;
 
309
  $tables = array() ;
310
 
311
  // Exploring what tables this database has
@@ -350,11 +415,17 @@ if(!function_exists('db_backup')) {
350
  for($j=0; $j<$num_fields; $j++){
351
  $rowdata[$j] = addslashes($rowdata[$j]);
352
  $rowdata[$j] = str_replace("\n","\\n",$rowdata[$j]);
353
- if (isset($rowdata[$j])) {
354
- $return.= '"'.$rowdata[$j].'"' ;
355
- } else {
356
- $return.= '""';
357
- }
 
 
 
 
 
 
358
  if ($j<($num_fields-1)) { $return.= ','; }
359
  }
360
  $return.= ");\n";
@@ -372,14 +443,14 @@ if(!function_exists('db_backup')) {
372
  $handle = fopen($sql_file_path,'w+');
373
  fwrite($handle,$return);
374
  fclose($handle);
 
375
 
376
  //Did the export work
377
- $file_size = filesize($sql_file_path);
378
- if(empty($file_size)) {
379
- _log('(functions.db_backup) Failure: SQL Export file was empty.');
380
- return false;
381
- }
382
-
383
  _log('(functions.db_backup)SQL Backup File Created:'.$sql_file_path);
384
  return true;
385
  }
@@ -393,28 +464,44 @@ if(!function_exists('db_SQLDump')) {
393
  $db_name = DB_NAME;
394
  $db_user = DB_USER;
395
  $db_pass = DB_PASSWORD;
396
- $db_host = DB_HOST;
 
397
 
398
  //This is to ensure that exec() is enabled on the server
399
  if(exec('echo EXEC') == 'EXEC') {
400
  try {
401
  $process = 'mysqldump';
402
- //exec($process.' --user='.$db_user.' --password='.$db_pass.' --host='.$db_host.' '.$db_name.' > "'.$path_sql .'"');
403
  $command = $process
404
- . ' --host=' . $db_host
405
- . ' --user=' . $db_user
406
- . ' --password=' . $db_pass
407
- . ' ' . $db_name
 
 
 
 
 
 
 
408
  . ' > "' . $sql_file_path .'"';
409
 
410
- $output = shell_exec($command);
411
- _log('(functions.db_SQLDump) shell execute output:');
412
- _log($output);
 
 
 
 
 
 
 
 
413
 
414
  //Did the export work
415
- $file_size = filesize($sql_file_path);
416
- if(empty($file_size)) {
417
- _log('(functions.db_SQLDump) Failure: Dump was empty.');
418
  return false;
419
  }
420
  } catch(Exception $e) {
@@ -435,18 +522,17 @@ if(!function_exists('db_SQLDump')) {
435
  //define db_import function
436
  if(!function_exists('db_run_sql')) {
437
  function db_run_sql($sql_file) {
438
- $file_size = filesize($sql_file);
439
- _log('(functions.db_import)SQL Execute:' .$sql_file);
440
 
441
  //Is the backup sql file empty
442
- if(empty($file_size)) {
443
- _log('(functions.db_import) Failure: SQL File was empty:' .$sql_file);
444
  return false;
445
  }
446
 
447
  //This is to ensure that exec() is enabled on the server
448
  if(exec('echo EXEC') != 'EXEC') {
449
- _log('(functions.db_SQLDump) Failure: Exec() disabled.');
450
  return false;
451
  }
452
 
@@ -455,34 +541,37 @@ if(!function_exists('db_run_sql')) {
455
  $db_name = DB_NAME;
456
  $db_user = DB_USER;
457
  $db_pass = DB_PASSWORD;
458
- $db_host = DB_HOST;
459
-
460
- //Are you in test mode - this should be in the wp-config
461
- // if(!defined('DB_NAME_TESTDB' ) ) define( 'DB_NAME_TESTDB', '' );
462
- // if(!empty(DB_NAME_TESTDB)) {
463
- // $db_name=DB_NAME_TESTDB;
464
- // _log('(functions.db_import) Test Database:' .$db_name);
465
- // }
466
 
467
  $process = 'mysql';
468
  $command = $process
469
  . ' --host=' . $db_host
470
- . ' --user=' . $db_user
471
  . ' --password=' . $db_pass
472
  . ' --database=' . $db_name
473
  . ' --execute="SOURCE ' . $sql_file .'"';
474
 
475
- $output = shell_exec($command);
476
- _log('(functions.db_import) shell execute output:');
 
 
 
477
  _log($output);
 
 
 
 
 
 
478
 
479
  }catch(Exception $e) {
480
- _log('(functions.db_import) Exception: ' .$e);
481
  return false;
482
  }
483
 
484
  //Success
485
- _log('(functions.db_import)SQL Executed successfully:' .$sql_file);
486
  return true;
487
  }
488
  }
@@ -613,65 +702,70 @@ function zip($source, $destination, $ignore) {
613
  return $zip->close();
614
  }
615
 
616
- //load presstrends
617
- function load_presstrends() {
618
- global $WPBackitup;
619
- if($WPBackitup->get_option( 'presstrends' ) == 'enabled') {
620
- // PressTrends Account API Key
621
- $api_key = '7s4lfc8du5we4cjcdcw7wv3bedn596gjxmgy';
622
- $auth = 'uu8dz66bqreltwdq66hjculnyqkkwofy5';
623
-
624
- // Start of Metrics
625
- global $wpdb;
626
- $data = get_transient( 'presstrends_cache_data' );
627
- if ( !$data || $data == '' ) {
628
- $api_base = 'http://api.presstrends.io/index.php/api/pluginsites/update/auth/';
629
- $url = $api_base . $auth . '/api/' . $api_key . '/';
630
-
631
- $count_posts = wp_count_posts();
632
- $count_pages = wp_count_posts( 'page' );
633
- $comments_count = wp_count_comments();
634
-
635
- // wp_get_theme was introduced in 3.4, for compatibility with older versions, let's do a workaround for now.
636
- if ( function_exists( 'wp_get_theme' ) ) {
637
- $theme_data = wp_get_theme();
638
- $theme_name = urlencode( $theme_data->Name );
639
- } else {
640
- $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
641
- $theme_name = $theme_data['Name'];
642
- }
643
 
644
- $plugin_name = '&';
645
- foreach ( get_plugins() as $plugin_info ) {
646
- $plugin_name .= $plugin_info['Name'] . '&';
647
- }
648
- // CHANGE __FILE__ PATH IF LOCATED OUTSIDE MAIN PLUGIN FILE
649
- $plugin_data = get_plugin_data( __FILE__ );
650
- $posts_with_comments = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' AND comment_count > 0" );
651
- $data = array(
652
- 'url' => stripslashes( str_replace( array( 'http://', '/', ':' ), '', site_url() ) ),
653
- 'posts' => $count_posts->publish,
654
- 'pages' => $count_pages->publish,
655
- 'comments' => $comments_count->total_comments,
656
- 'approved' => $comments_count->approved,
657
- 'spam' => $comments_count->spam,
658
- 'pingbacks' => $wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_type = 'pingback'" ),
659
- 'post_conversion' => ( $count_posts->publish > 0 && $posts_with_comments > 0 ) ? number_format( ( $posts_with_comments / $count_posts->publish ) * 100, 0, '.', '' ) : 0,
660
- 'theme_version' => $plugin_data['Version'],
661
- 'theme_name' => $theme_name,
662
- 'site_name' => str_replace( ' ', '', get_bloginfo( 'name' ) ),
663
- 'plugins' => count( get_option( 'active_plugins' ) ),
664
- 'plugin' => urlencode( $plugin_name ),
665
- 'wpversion' => get_bloginfo( 'version' ),
666
- );
667
-
668
- foreach ( $data as $k => $v ) {
669
- $url .= $k . '/' . $v . '/';
670
- }
671
- wp_remote_get( $url );
672
- set_transient( 'presstrends_cache_data', $data, 60 * 60 * 24 );
673
- }
674
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
675
  }
676
 
677
  // PressTrends WordPress Action
@@ -680,13 +774,26 @@ add_action('admin_init', 'load_presstrends');
680
  //Get Status Log
681
  if(!function_exists('deleteDebugLog')){
682
  function deleteDebugLog() {
683
- $debugLog = WPBACKITUP_DIRNAME ."/logs/debug_" .$date .".log";
684
- if (file_exists($debugLog)){
685
- try{
686
- unlink($debugLog);
687
- } catch(Exception $e) {
688
- //Dont do anything
 
 
 
 
689
  }
 
 
 
 
 
 
 
 
 
690
  }
691
  }
692
  }
@@ -695,7 +802,8 @@ if(!function_exists('deleteDebugLog')){
695
  if(!function_exists('getDebugLogFile')){
696
  function getDebugLogFile() {
697
  try {
698
- if (WPBACKITUP_DEBUG===true){
 
699
  //Check to see if File exists
700
  $date = date_i18n('Y-m-d',current_time( 'timestamp' ));
701
  $debugLog = WPBACKITUP_DIRNAME ."/logs/debug_" .$date .".log";
@@ -712,9 +820,10 @@ if(!function_exists('getDebugLogFile')){
712
  if(!function_exists('_log')){
713
  function _log($message) {
714
  //Is debug ON
 
715
  try{
716
- if (WPBACKITUP_DEBUG===true){
717
- $dfh = getDebugLogFile("upload"); //Get File
718
  if (!is_null($dfh)){
719
  $date = date_i18n('Y-m-d Hi:i:s',current_time( 'timestamp' ));
720
  if( is_array( $message ) || is_object( $message ) ){
@@ -731,32 +840,15 @@ if(!function_exists('_log')){
731
  }
732
  }
733
 
734
- // if(!function_exists('_log')){
735
- // function _log( $message ) {
736
- // $debuglog = WPBACKITUP_CONTENT_PATH .'debug.log';
737
- // if( WPBACKITUP_DEBUG === true ){
738
- // try{
739
- // $dfh = fopen($debuglog,'w+');
740
- // if( is_array( $message ) || is_object( $message ) ){
741
- // //error_log( print_r( $message, true ) );
742
- // fwrite($dfh,print_r( $message, true ));
743
- // } else {
744
- // fwrite($dfh,$message);
745
- // }
746
-
747
- // fclose($dfh);
748
-
749
- // } catch(Exception $e) {
750
- // //Dont do anything
751
- // fclose($dfh);
752
- // }
753
- // }
754
- // }
755
- // }
756
-
757
  //Log all the constants
758
  if(!function_exists('_log_constants')){
759
  function _log_constants() {
 
 
 
 
 
 
760
  _log("**CONSTANTS**");
761
  _log("WPBACKITUP_VERSION:" . WPBACKITUP_VERSION);
762
  _log("WPBACKITUP_DIRNAME:" . WPBACKITUP_DIRNAME);
28
  // retrieve our license key from the DB
29
  $license_key = trim( $this->get_option( 'license_key' ) );
30
 
31
+
32
+ //Feth the debug status and set
33
+ global $WPBACKITUP_DEBUG;
34
+ $WPBACKITUP_DEBUG=false;
35
+ if ('enabled'==$this->get_option( 'logging' )){
36
+ $WPBACKITUP_DEBUG= true;
37
+ }
38
+
39
+ //Check the license key
40
+ function license_active(){
41
+ global $WPBackitup;
42
+ $license_key = $WPBackitup->get_option( 'license_key' );
43
+ $license_status = $WPBackitup->get_option( 'status' );
44
+
45
+ if(false !== $license_key && false !== $license_status && 'valid'== $license_status)
46
+ {
47
+ return true;
48
+ }
49
+ return false;
50
+ }
51
+
52
  //define dbSize function
53
  function dbSize($dbname) {
54
  mysqli_select_db($dbname);
221
  function db_rename_wptables($sql_file_path,$table_prefix) {
222
  _log('(db_rename_wptables)Manually Create SQL Backup File:'.$sql_file_path);
223
 
224
+ $mysqli = db_get_sqlconnection();
225
+ if (false===$mysqli) {
226
+ return false;
 
 
 
 
 
 
227
  }
228
 
229
  $tables = array() ;
256
  $return .= "--\n";
257
  $return .= '-- Created: ' . date("Y/m/d") . "\n";
258
  $return .= "--\n";
259
+ $return .= "-- Database : " . DB_NAME . "\n";
260
  $return .= "--\n";
261
  $return .= "-- --------------------------------------------------\n";
262
  $return .= "-- ---------------------------------------------------\n";
292
  }
293
  }
294
 
295
+ if(!function_exists('db_get_hostonly')) {
296
+ function db_get_hostonly($db_host) {
297
+ //Check for port
298
+ $host_array = explode(':',$db_host);
299
+ if (is_array($host_array)){
300
+ return $host_array[0];
301
+ }
302
+ return $db_host;
303
+ }
304
+ }
305
+ //Get rid of the port if its in the hostname
306
+ if(!function_exists('db_get_portonly')) {
307
+ function db_get_portonly($db_host) {
308
+ //Check for port
309
+ $host_array = explode(':',$db_host);
310
+ if (is_array($host_array) && count($host_array)>1){
311
+ return $host_array[1];
312
+ }
313
+
314
+ return false;
315
+ }
316
+ }
317
+
318
+ //Get SQL connection
319
+ if(!function_exists('db_get_sqlconnection')) {
320
+ function db_get_sqlconnection() {
321
+ _log('(functions.db_get_sqlconnection)Get SQL connection to database.');
322
+ $db_name = DB_NAME;
323
+ $db_user = DB_USER;
324
+ $db_pass = DB_PASSWORD;
325
+ $db_host = db_get_hostonly(DB_HOST);
326
+ $db_port = db_get_portonly(DB_HOST);
327
+
328
+ _log('(functions.db_get_sqlconnection)Host:' . $db_host);
329
+ _log('(functions.db_get_sqlconnection)Port:' . $db_port);
330
+
331
+ if (false===$db_port){
332
+ $mysqli = new mysqli($db_host , $db_user , $db_pass , $db_name);
333
+ }
334
+ else {
335
+ $mysqli = new mysqli($db_host , $db_user , $db_pass , $db_name,$db_port);
336
+ }
337
+
338
+ if ($mysqli->connect_errno) {
339
+ _log('(functions.db_get_sqlconnection)Cannot connect to database.' . $mysqli->connect_error);
340
+ return false;
341
+ }
342
+ return $mysqli;
343
+ }
344
+ }
345
 
346
  //Define DB backup function
347
  if(!function_exists('db_backup')) {
348
  function db_backup($sql_file_path) {
349
  _log('(functions.db_backup)Manually Create SQL Backup File:'.$sql_file_path);
 
 
 
 
 
350
 
351
+ $mysqli = db_get_sqlconnection();
352
+ $mysqli->set_charset('utf8');
353
+
354
+ if (false===$mysqli) {
355
+ return false;
356
  }
357
 
358
+ // Script Header Information
359
+ $return = '';
360
+ $return .= "-- ------------------------------------------------------\n";
361
+ $return .= "-- ------------------------------------------------------\n";
362
  $return .= "--\n";
363
+ $return .= "-- WP BackItUp Manual Database Backup \n";
364
  $return .= "--\n";
365
+ $return .= '-- Created: ' . date("Y/m/d") . ' on ' . date("h:i") . "\n";
 
 
366
  $return .= "--\n";
367
+ $return .= "-- Database : " . DB_NAME . "\n";
368
+ $return .= "--\n";
369
+ $return .= "-- ------------------------------------------------------\n";
370
+ $return .= "-- ------------------------------------------------------\n";
371
  $return .= 'SET AUTOCOMMIT = 0 ;' ."\n" ;
372
  $return .= 'SET FOREIGN_KEY_CHECKS=0 ;' ."\n" ;
373
+
374
  $tables = array() ;
375
 
376
  // Exploring what tables this database has
415
  for($j=0; $j<$num_fields; $j++){
416
  $rowdata[$j] = addslashes($rowdata[$j]);
417
  $rowdata[$j] = str_replace("\n","\\n",$rowdata[$j]);
418
+
419
+ if (isset($rowdata[$j])) {
420
+ $return.= '"'.$rowdata[$j].'"' ;
421
+ } else {
422
+ if (is_null($rowdata[$j])) {
423
+ $return.= 'NULL';//Dont think this is working but not causing issues
424
+ } else {
425
+ $return.= '""';
426
+ }
427
+ }
428
+
429
  if ($j<($num_fields-1)) { $return.= ','; }
430
  }
431
  $return.= ");\n";
443
  $handle = fopen($sql_file_path,'w+');
444
  fwrite($handle,$return);
445
  fclose($handle);
446
+ clearstatcache();
447
 
448
  //Did the export work
449
+ if (!file_exists($sql_file_path) || filesize($sql_file_path)<=0) {
450
+ _log('(functions.db_backup) Failure: SQL Export file was empty or didnt exist.');
451
+ return false;
452
+ }
453
+
 
454
  _log('(functions.db_backup)SQL Backup File Created:'.$sql_file_path);
455
  return true;
456
  }
464
  $db_name = DB_NAME;
465
  $db_user = DB_USER;
466
  $db_pass = DB_PASSWORD;
467
+ $db_host = db_get_hostonly(DB_HOST);
468
+ $db_port = db_get_portonly(DB_HOST);
469
 
470
  //This is to ensure that exec() is enabled on the server
471
  if(exec('echo EXEC') == 'EXEC') {
472
  try {
473
  $process = 'mysqldump';
474
+
475
  $command = $process
476
+ . ' --host=' . $db_host;
477
+
478
+ //Check for port
479
+ if (false!==$db_port){
480
+ $command .=' --port=' . $db_port;
481
+ }
482
+
483
+ $command .=
484
+ ' --user=' . $db_user
485
+ . ' --password=' . $db_pass
486
+ .=' ' . $db_name
487
  . ' > "' . $sql_file_path .'"';
488
 
489
+ //_log('(functions.db_SQLDump)Execute command:' . $command);
490
+
491
+ exec($command,$output,$rtn_var);
492
+ _log('(functions.db_SQLDump)Execute output:');
493
+ _log($output);
494
+ _log('Return Value:' .$rtn_var);
495
+
496
+ //0 is success
497
+ if ($rtn_var>0){
498
+ return false;
499
+ }
500
 
501
  //Did the export work
502
+ clearstatcache();
503
+ if (!file_exists($sql_file_path) || filesize($sql_file_path)<=0) {
504
+ _log('(functions.db_SQLDump) Failure: Dump was empty or missing.');
505
  return false;
506
  }
507
  } catch(Exception $e) {
522
  //define db_import function
523
  if(!function_exists('db_run_sql')) {
524
  function db_run_sql($sql_file) {
525
+ _log('(functions.db_run_sql)SQL Execute:' .$sql_file);
 
526
 
527
  //Is the backup sql file empty
528
+ if (!file_exists($sql_file) || filesize($sql_file)<=0) {
529
+ _log('(functions.db_run_sql) Failure: SQL File was empty:' .$sql_file);
530
  return false;
531
  }
532
 
533
  //This is to ensure that exec() is enabled on the server
534
  if(exec('echo EXEC') != 'EXEC') {
535
+ _log('(functions.db_run_sql) Failure: Exec() disabled.');
536
  return false;
537
  }
538
 
541
  $db_name = DB_NAME;
542
  $db_user = DB_USER;
543
  $db_pass = DB_PASSWORD;
544
+ $db_host = db_get_hostonly(DB_HOST);
545
+ $db_port = db_get_portonly(DB_HOST);
 
 
 
 
 
 
546
 
547
  $process = 'mysql';
548
  $command = $process
549
  . ' --host=' . $db_host
550
+ . ' --user=' . $db_user
551
  . ' --password=' . $db_pass
552
  . ' --database=' . $db_name
553
  . ' --execute="SOURCE ' . $sql_file .'"';
554
 
555
+ //_log('(functions.db_run_sql)Execute command:' . $command);
556
+
557
+ //$output = shell_exec($command);
558
+ exec($command,$output,$rtn_var);
559
+ _log('(functions.db_run_sql)Execute output:');
560
  _log($output);
561
+ _log('Return Value:' .$rtn_var);
562
+
563
+ //0 is success
564
+ if ($rtn_var>0){
565
+ return false;
566
+ }
567
 
568
  }catch(Exception $e) {
569
+ _log('(functions.db_run_sql) Exception: ' .$e);
570
  return false;
571
  }
572
 
573
  //Success
574
+ _log('(functions.db_run_sql)SQL Executed successfully:' .$sql_file);
575
  return true;
576
  }
577
  }
702
  return $zip->close();
703
  }
704
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
705
 
706
+ //Disable presstrends v 1.6.1
707
+ function load_presstrends() {
708
+ // global $WPBackitup;
709
+ // _log('Load Presstrends');
710
+ // if($WPBackitup->get_option( 'presstrends' ) == 'enabled') {
711
+ // _log('Presstrends enabled');
712
+ // // PressTrends Account API Key
713
+ // $api_key = '7s4lfc8du5we4cjcdcw7wv3bedn596gjxmgy';
714
+ // $auth = 'uu8dz66bqreltwdq66hjculnyqkkwofy5';
715
+
716
+ // // Start of Metrics
717
+ // global $wpdb;
718
+ // $data = get_transient( 'presstrends_cache_data' );
719
+ // if ( !$data || $data == '' ) {
720
+ // _log('Presstrends cached data:' . $data);
721
+ // $api_base = 'http://api.presstrends.io/index.php/api/pluginsites/update/auth/';
722
+ // $url = $api_base . $auth . '/api/' . $api_key . '/';
723
+
724
+ // $count_posts = wp_count_posts();
725
+ // $count_pages = wp_count_posts( 'page' );
726
+ // $comments_count = wp_count_comments();
727
+
728
+ // // wp_get_theme was introduced in 3.4, for compatibility with older versions, let's do a workaround for now.
729
+ // if ( function_exists( 'wp_get_theme' ) ) {
730
+ // $theme_data = wp_get_theme();
731
+ // $theme_name = urlencode( $theme_data->Name );
732
+ // } else {
733
+ // $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
734
+ // $theme_name = $theme_data['Name'];
735
+ // }
736
+
737
+ // $plugin_name = '&';
738
+ // foreach ( get_plugins() as $plugin_info ) {
739
+ // $plugin_name .= $plugin_info['Name'] . '&';
740
+ // }
741
+ // // CHANGE __FILE__ PATH IF LOCATED OUTSIDE MAIN PLUGIN FILE
742
+ // $plugin_data = get_plugin_data( __FILE__ );
743
+ // $posts_with_comments = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' AND comment_count > 0" );
744
+ // $data = array(
745
+ // 'url' => stripslashes( str_replace( array( 'http://', '/', ':' ), '', site_url() ) ),
746
+ // 'posts' => $count_posts->publish,
747
+ // 'pages' => $count_pages->publish,
748
+ // 'comments' => $comments_count->total_comments,
749
+ // 'approved' => $comments_count->approved,
750
+ // 'spam' => $comments_count->spam,
751
+ // 'pingbacks' => $wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_type = 'pingback'" ),
752
+ // 'post_conversion' => ( $count_posts->publish > 0 && $posts_with_comments > 0 ) ? number_format( ( $posts_with_comments / $count_posts->publish ) * 100, 0, '.', '' ) : 0,
753
+ // 'theme_version' => $plugin_data['Version'],
754
+ // 'theme_name' => $theme_name,
755
+ // 'site_name' => str_replace( ' ', '', get_bloginfo( 'name' ) ),
756
+ // 'plugins' => count( get_option( 'active_plugins' ) ),
757
+ // 'plugin' => urlencode( $plugin_name ),
758
+ // 'wpversion' => get_bloginfo( 'version' ),
759
+ // );
760
+
761
+ // foreach ( $data as $k => $v ) {
762
+ // $url .= $k . '/' . $v . '/';
763
+ // }
764
+ // _log('Prestrends URL' . $url);
765
+ // //wp_remote_get( $url ); - disable usage tracking
766
+ // set_transient( 'presstrends_cache_data', $data, 60 * 60 * 24 );
767
+ // }
768
+ // }
769
  }
770
 
771
  // PressTrends WordPress Action
774
  //Get Status Log
775
  if(!function_exists('deleteDebugLog')){
776
  function deleteDebugLog() {
777
+ global $WPBACKITUP_DEBUG;
778
+ if ($WPBACKITUP_DEBUG===true){
779
+ $date = date_i18n('Y-m-d',current_time( 'timestamp' ));
780
+ $mydebugLog = WPBACKITUP_DIRNAME ."/logs/debug_" .$date .".log";
781
+ if (file_exists($mydebugLog)){
782
+ try{
783
+ unlink($mydebugLog);
784
+ } catch(Exception $e) {
785
+ //Dont do anything
786
+ }
787
  }
788
+
789
+ $debugLog = WPBACKITUP_CONTENT_PATH ."debug.log";
790
+ if (file_exists($debugLog)){
791
+ try{
792
+ unlink($debugLog);
793
+ } catch(Exception $e) {
794
+ //Dont do anything
795
+ }
796
+ }
797
  }
798
  }
799
  }
802
  if(!function_exists('getDebugLogFile')){
803
  function getDebugLogFile() {
804
  try {
805
+ global $WPBACKITUP_DEBUG;
806
+ if ($WPBACKITUP_DEBUG===true){
807
  //Check to see if File exists
808
  $date = date_i18n('Y-m-d',current_time( 'timestamp' ));
809
  $debugLog = WPBACKITUP_DIRNAME ."/logs/debug_" .$date .".log";
820
  if(!function_exists('_log')){
821
  function _log($message) {
822
  //Is debug ON
823
+ global $WPBACKITUP_DEBUG;
824
  try{
825
+ if ($WPBACKITUP_DEBUG===true){
826
+ $dfh = getDebugLogFile(); //Get File
827
  if (!is_null($dfh)){
828
  $date = date_i18n('Y-m-d Hi:i:s',current_time( 'timestamp' ));
829
  if( is_array( $message ) || is_object( $message ) ){
840
  }
841
  }
842
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
843
  //Log all the constants
844
  if(!function_exists('_log_constants')){
845
  function _log_constants() {
846
+ _log("**SYSTEM CONSTANTS**");
847
+ _log("WPBackItUp License Active: " . (license_active() ? 'true' : 'false'));
848
+ _log("Wordpress Version:" . get_bloginfo( 'version'));
849
+ _log("PHP Version:" . phpversion());
850
+ _log("Operating System:" . php_uname());
851
+
852
  _log("**CONSTANTS**");
853
  _log("WPBACKITUP_VERSION:" . WPBACKITUP_VERSION);
854
  _log("WPBACKITUP_DIRNAME:" . WPBACKITUP_DIRNAME);
lib/includes/backup.php CHANGED
@@ -21,11 +21,12 @@ include_once dirname(dirname( __FILE__ )) . '/constants.php';
21
  global $WPBackitup;
22
  $fileUTCDateTime=current_time( 'timestamp' );
23
  $localDateTime = date_i18n('Y-m-d-Hi',$fileUTCDateTime);
24
- $backup_project_dirname = get_bloginfo('name') .'-Export-' .$localDateTime;
25
  $backup_project_path = WPBACKITUP_CONTENT_PATH .WPBACKITUP_BACKUP_FOLDER .'/'. $backup_project_dirname .'/';
26
  $backup_folder_root = WPBACKITUP_CONTENT_PATH .WPBACKITUP_BACKUP_FOLDER .'/';
27
  $restore_folder_root = WPBACKITUP_RESTORE_FOLDER;
28
 
 
29
  //*****************//
30
  //*** MAIN CODE ***//
31
  //*****************//
@@ -63,19 +64,14 @@ if(!is_writeable($backup_folder_root)) {
63
  @mkdir($backup_project_path, 0755);
64
  _log('Backup Content Folder Created:'.$backup_project_path);
65
  }
66
- //Why do we need to do this? - delete all zip files in backup folder
67
- //foreach(glob($backup_folder_root ."*.zip") as $zip) {
68
- // unlink($zip);
69
- // _log('Zip file removed:'.$zip);
70
- //}
71
  fwrite($fh, '<div class="prerequisites">1</div>');
72
  }
73
 
74
  //Try MySQLDump First
75
- _log('Create the SQL Backup File:'.$backup_project_path);
76
  $sqlFileName=$backup_project_path . WPBACKITUP_SQL_DBBACKUP_FILENAME;
 
77
  if(db_SQLDump($sqlFileName) ) {
78
- fwrite($fh, '<div class="backupdb">1</div>');
79
  } else {
80
  //Try manual extract if mysqldump isnt working
81
  if(db_backup($sqlFileName) ) {
@@ -83,11 +79,12 @@ if(db_SQLDump($sqlFileName) ) {
83
  } else {
84
  fwrite($fh, '<div class="backupdb">0</div>');
85
  fwrite($fh, '<div class="error104">1</div>');
86
- recursive_delete($backup_project_path);
87
  die();
88
  }
89
  }
90
- _log('Created the SQL Backup File:'.$backup_project_path);
 
91
 
92
  //Backup with copy
93
  _log('Recursive Copy FROM:'.WPBACKITUP_CONTENT_PATH);
@@ -110,7 +107,7 @@ _log('Create Site Info:'.$backup_project_path);
110
  if (!create_siteinfo($backup_project_path, $wpdb->prefix) ) {
111
  fwrite($fh, '<div class="infofile">0</div>');
112
  fwrite($fh, '<div class="error105">1</div>');
113
- recursive_delete($backup_project_path);
114
  die();
115
  } else {
116
  fwrite($fh, '<div class="infofile">1</div>');
@@ -138,8 +135,8 @@ fwrite($fh, '<div class="finalinfo">1</div>');
138
  fclose($fh);
139
 
140
  $response['file'] = basename($src) . '.zip';
141
- //$response['CreateDate'] = date('F j, Y g:i a',strtotime($localDateTime));
142
  $response['link'] = WPBACKITUP_BACKUPFILE_URLPATH . '/' . $backup_project_dirname . '.zip';
 
143
 
144
  _log('Jason Response Values:');
145
  _log(json_encode($response));
@@ -148,4 +145,16 @@ echo json_encode($response);
148
 
149
  _log("*** END BACKUP.PHP ***");
150
  die();
151
- //End backup function
 
 
 
 
 
 
 
 
 
 
 
 
21
  global $WPBackitup;
22
  $fileUTCDateTime=current_time( 'timestamp' );
23
  $localDateTime = date_i18n('Y-m-d-Hi',$fileUTCDateTime);
24
+ $backup_project_dirname = str_replace(' ','',get_bloginfo('name')) .'_Backup_' .$localDateTime;
25
  $backup_project_path = WPBACKITUP_CONTENT_PATH .WPBACKITUP_BACKUP_FOLDER .'/'. $backup_project_dirname .'/';
26
  $backup_folder_root = WPBACKITUP_CONTENT_PATH .WPBACKITUP_BACKUP_FOLDER .'/';
27
  $restore_folder_root = WPBACKITUP_RESTORE_FOLDER;
28
 
29
+
30
  //*****************//
31
  //*** MAIN CODE ***//
32
  //*****************//
64
  @mkdir($backup_project_path, 0755);
65
  _log('Backup Content Folder Created:'.$backup_project_path);
66
  }
 
 
 
 
 
67
  fwrite($fh, '<div class="prerequisites">1</div>');
68
  }
69
 
70
  //Try MySQLDump First
 
71
  $sqlFileName=$backup_project_path . WPBACKITUP_SQL_DBBACKUP_FILENAME;
72
+ _log('Create the SQL Backup File:'.$sqlFileName);
73
  if(db_SQLDump($sqlFileName) ) {
74
+ fwrite($fh, '<div class="backupdb">1</div>');
75
  } else {
76
  //Try manual extract if mysqldump isnt working
77
  if(db_backup($sqlFileName) ) {
79
  } else {
80
  fwrite($fh, '<div class="backupdb">0</div>');
81
  fwrite($fh, '<div class="error104">1</div>');
82
+ cleanup_on_failure($backup_project_path);
83
  die();
84
  }
85
  }
86
+
87
+ _log('Created the SQL Backup File:'.$sqlFileName);
88
 
89
  //Backup with copy
90
  _log('Recursive Copy FROM:'.WPBACKITUP_CONTENT_PATH);
107
  if (!create_siteinfo($backup_project_path, $wpdb->prefix) ) {
108
  fwrite($fh, '<div class="infofile">0</div>');
109
  fwrite($fh, '<div class="error105">1</div>');
110
+ cleanup_on_failure($backup_project_path);
111
  die();
112
  } else {
113
  fwrite($fh, '<div class="infofile">1</div>');
135
  fclose($fh);
136
 
137
  $response['file'] = basename($src) . '.zip';
 
138
  $response['link'] = WPBACKITUP_BACKUPFILE_URLPATH . '/' . $backup_project_dirname . '.zip';
139
+ $response['license'] = license_active();
140
 
141
  _log('Jason Response Values:');
142
  _log(json_encode($response));
145
 
146
  _log("*** END BACKUP.PHP ***");
147
  die();
148
+
149
+ /******************/
150
+ /*** Functions ***/
151
+ /******************/
152
+ function cleanup_on_failure($backup_project_path){
153
+ global $WPBACKITUP_DEBUG;
154
+ if ($WPBACKITUP_DEBUG===true){
155
+ _log('Cleanup On Fail suspended: debug on.');
156
+ }
157
+ else{
158
+ recursive_delete($backup_project_path);
159
+ }
160
+ }
lib/includes/recurse_zip.php CHANGED
@@ -1 +1 @@
1
- <?php
2
  * WP Backitup Recurse Zip Function
3
  *
4
  * @package WP Backitup
5
  *
6
  * @author jcpeden
7
  * @version 1.4.0
8
  * @since 1.0.1
9
  */
 
10
  * WP Backitup Recurse Zip Function
11
  *
12
  * @package WP Backitup
13
  *
14
  * @author jcpeden
15
  * @version 1.4.0
16
  * @since 1.0.1
17
  */
 
1
  * WP Backitup Recurse Zip Function
2
  *
3
  * @package WP Backitup
4
  *
5
  * @author jcpeden
6
  * @version 1.4.0
7
  * @since 1.0.1
8
  */
9
+ <?php
10
  * WP Backitup Recurse Zip Function
11
  *
12
  * @package WP Backitup
13
  *
14
  * @author jcpeden
15
  * @version 1.4.0
16
  * @since 1.0.1
17
  */
lib/includes/restore.php CHANGED
@@ -49,6 +49,12 @@ deleteDebugLog();
49
  _log('***BEGIN RESTORE.PHP***');
50
  _log_constants();
51
 
 
 
 
 
 
 
52
  //--Get form post values
53
  $backup_file_name = $_POST['selected_file'];//Get the backup file name
54
  if( $backup_file_name == '') {
@@ -288,7 +294,8 @@ function validate_restore_folder($restore_folder_root){
288
 
289
  // Backup the current database try dump first
290
  function backup_database($restore_folder_root){
291
- $backup_file = $restore_folder_root . 'db-backup.cur';
 
292
  _log('Backup the current database: ' .$backup_file);
293
  if(!db_SQLDump($backup_file)) {
294
  //Try a manual restore since dump didnt work
@@ -332,7 +339,7 @@ function validate_SQL_exists($restore_folder_root,$backupSQLFile){
332
  //Get SQL Connection
333
  function get_sql_connection($restoration_dir_path){
334
  //Connect to DB
335
- $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
336
  if ( !$dbc ) {
337
  _log('Error: Cant connect to database.');
338
  write_fatal_error_status('error206');
49
  _log('***BEGIN RESTORE.PHP***');
50
  _log_constants();
51
 
52
+ if (!license_active()){
53
+ _log('Restore is not available because pro license is not active.');
54
+ write_fatal_error_status('error225');
55
+ die();
56
+ }
57
+
58
  //--Get form post values
59
  $backup_file_name = $_POST['selected_file'];//Get the backup file name
60
  if( $backup_file_name == '') {
294
 
295
  // Backup the current database try dump first
296
  function backup_database($restore_folder_root){
297
+ $date = date_i18n('Y-m-d-Hi',current_time( 'timestamp' ));
298
+ $backup_file = $restore_folder_root . 'db-backup-' . $date .'.cur';
299
  _log('Backup the current database: ' .$backup_file);
300
  if(!db_SQLDump($backup_file)) {
301
  //Try a manual restore since dump didnt work
339
  //Get SQL Connection
340
  function get_sql_connection($restoration_dir_path){
341
  //Connect to DB
342
+ $dbc = db_get_sqlconnection();
343
  if ( !$dbc ) {
344
  _log('Error: Cant connect to database.');
345
  write_fatal_error_status('error206');
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.wpbackitup.com
4
  Tags: backup wordpress, database backup, backup database, download database, backup and restore, restoring wordpress, restore wordpress, restore wordpress backup,
5
  Requires at least: 3.4.2
6
  Tested up to: 3.8
7
- Stable tag: 1.6.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -91,6 +91,20 @@ Yes.
91
  3. When the backup has been created, click the download link to access a zipped backup of your site.
92
 
93
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  = 1.6.0 =
95
  * Significant performance improvements.
96
  * Many improvements to user interface.
@@ -98,6 +112,7 @@ Yes.
98
  * Added interface for large file uploads via FTP.
99
  * Added restore point and database recovery when fatal errors are encountered.
100
  * Added configurable debug logging.
 
101
 
102
  = 1.5.4 =
103
  Enabled plugin to work with version 3.8
4
  Tags: backup wordpress, database backup, backup database, download database, backup and restore, restoring wordpress, restore wordpress, restore wordpress backup,
5
  Requires at least: 3.4.2
6
  Tested up to: 3.8
7
+ Stable tag: 1.6.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
91
  3. When the backup has been created, click the download link to access a zipped backup of your site.
92
 
93
  == Changelog ==
94
+ = 1.6.2 =
95
+ * Fixed issue with version 1.6.1 update
96
+
97
+ = 1.6.1 =
98
+ * This release is mostly cosmetic changes and minor fixes to v1.6.0
99
+ * Corrected path issue occurring on unix platform
100
+ * Updated backup zip to remove blanks in file name
101
+ * Changed backup suffix to backup instead of export
102
+ * Corrected backup.sql export file size check
103
+ * Fix license check for restore option
104
+ * Update usage tracking default to off
105
+ * Correct issue with manual data export that contain non-ascii characters
106
+ * Add Date Time stamp on SQL restore export
107
+
108
  = 1.6.0 =
109
  * Significant performance improvements.
110
  * Many improvements to user interface.
112
  * Added interface for large file uploads via FTP.
113
  * Added restore point and database recovery when fatal errors are encountered.
114
  * Added configurable debug logging.
115
+ * Added logging option to options page.
116
 
117
  = 1.5.4 =
118
  Enabled plugin to work with version 3.8
views/options.php CHANGED
@@ -16,8 +16,7 @@
16
 
17
  <?php
18
  //Display a note for lite customers
19
- $status = $this->get_option( 'status' );
20
- if($status != 'valid' )
21
  {
22
  echo '<p> * WPBackItUp Lite customers may use these backup files to manually restore their site. Please visit <a href="http://www.wpbackitup.com/wp-backitup-pro/" target="_blank">www.wpbackitup.com</a> for manual restore instructions.</p>';
23
  }
@@ -50,7 +49,11 @@
50
  <td><?php echo $filename?></td>
51
  <td><a href="<?php echo WPBACKITUP_BACKUPFILE_URLPATH ?>/<?php echo $filename; ?>">Download</a></td>
52
  <td><a href="#" title="<?php echo $filename; ?>" class="deleteRow" id="deleteRow<?php echo $i; ?>">Delete</a></td>
53
- <td><a href="#" title="<?php echo $filename; ?>" class="restoreRow" id="restoreRow<?php echo $i; ?>">Restore</a></td>
 
 
 
 
54
  </tr>
55
  <?php
56
  $i++;
@@ -72,9 +75,7 @@
72
 
73
  <?php
74
  //Display restore note for lite customers
75
- $status = $this->get_option( 'status' );
76
- if($status != 'valid' )
77
- {
78
  echo '<p>* The automated restore feature is only available to Pro customers. Please visit <a href="http://www.wpbackitup.com/wp-backitup-pro/" target="_blank">www.wpbackitup.com</a> to get WPBackItUp Pro risk free for 30 days.</p>' ;
79
  }
80
  ?>
@@ -82,8 +83,7 @@
82
 
83
  <!--Disable upload form if the user has not activated-->
84
  <?php
85
- $status = $this->get_option( 'status' );
86
- if( $status !== false && $status == 'valid' )
87
  { ?>
88
  <div class="widget">
89
  <h3>
@@ -186,6 +186,7 @@
186
  <span class='error222'><div class='isa_error'><?php _e('Error: Unable to create restore folder', $namespace ); ?>.</div></span>
187
  <span class='error223'><div class='isa_error'><?php _e('Error: An error occurred during the restore. We attempted to restore the database to its previous state but were unsuccessful. Please contact wpbackitup customer support and do not attempt to perform any further restores', $namespace ); ?>.</div></span>
188
  <span class='error224'><div class='isa_error'><?php _e('Error: An error occurred during the restore, however, we have successfully restored your database to the previous state', $namespace ); ?>.</div></span>
 
189
  </div>
190
 
191
  <!--restore success messages-->
@@ -194,17 +195,18 @@
194
  </div>
195
 
196
  </div>
197
- <?php if (WPBACKITUP_DEBUG===true) {
198
- echo '<p><div id="php">Debug messages</p></div>';
 
 
199
  } ?>
200
  </div>
201
 
202
  <div id="sidebar">
203
 
204
  <!-- Display opt-in form if the user is unregistered -->
205
- <?php $license = $this->get_option( 'license_key' );
206
- $status = $this->get_option( 'status' );
207
- if( $status != 'valid' ) { ?>
208
  <div class="widget">
209
  <h3 class="promo"><?php _e('Get a license key', $namespace ); ?></h3>
210
  <p><?php _e('Tired of messing with FTP, MySQL and PHPMyAdmin? Restore your backups from this page in minutes or your money back', $namespace ); ?>.</p>
@@ -223,14 +225,14 @@
223
  <?php wp_nonce_field( $namespace . "-update-options" ); ?>
224
  <div class="widget">
225
  <h3 class="promo"><?php _e('License Key v '.WPBACKITUP_VERSION, $namespace); ?></h3>
226
- <?php $license = $this->get_option( 'license_key' );
227
- $status = $this->get_option( 'status' );
228
- if( $status != 'valid' ) { ?>
229
  <p><?php _e('Enter your license key to activate Pro features.', $namespace ); ?>.</p>
230
  <?php } ?>
231
  <p><input type="text" name="data[license_key]" id="license_key" value="<?php echo $license; ?>" />
232
- <?php if( false !== $license ) {
233
- if( $status !== false && $status == 'valid' ) { ?>
234
  <span style="color:green;"><?php _e('Pro License Active', $namespace); ?></span></p>
235
  <p class="submit"><input type="submit" name="Submit" class="button-secondary" value="<?php _e( "Update", $namespace ) ?>" /></p>
236
  <?php } else { ?>
@@ -238,25 +240,34 @@
238
  <p class="submit"><input type="submit" name="Submit" class="button-secondary" value="<?php _e( "Activate", $namespace ) ?>" /></p>
239
  <p><?php _e('Purchase a <a href="http://www.wpbackitup.com/plugins/wp-backitup-pro/" target="blank">no-risk </a>license using the purchase link above',$namespace); ?>.</p>
240
  <?php }
241
- } ?>
242
  </div>
243
 
244
  <!-- Display links widget -->
245
  <div class="widget">
246
  <h3 class="promo"><?php _e('Useful Links', $namespace ); ?></h3>
247
  <ul>
248
- <?php if( false !== $license ) {
249
- if( $status !== false && $status == 'valid' ) { ?>
250
  <li><a href="http://www.wpbackitup.com/your-account/" target="_blank"><?php _e('Your account',$namespace); ?></a></li>
251
  <li><a href="http://www.wpbackitup.com/plugins/wp-backitup-pro/" target="_blank"><?php _e('Upgrade your license',$namespace); ?></a></li>
252
  <?php }
253
- } ?>
254
  <li><a href="http://www.wpbackitup.com/support" target="_blank"><?php _e('Get support',$namespace); ?></a></li>
255
  <li><a href="http://www.wpbackitup.com/feature-request" target="_blank"><?php _e('Feature Request',$namespace); ?></a></li>
256
  <li>Have a suggestion? Why not submit a feature request.</li>
257
  </ul>
258
  </div>
259
 
 
 
 
 
 
 
 
 
 
260
  <div class="widget">
261
  <h3 class="promo">Allow Usage Tracking?</h3>
262
  <p><input type="radio" name="data[presstrends]" value="enabled" <?php if($this->get_option( 'presstrends' ) == 'enabled') echo 'checked'; ?>> <label><?php _e('Yes', $namespace ); ?></label></p>
@@ -264,6 +275,7 @@
264
  <p><?php _e('Allow WPBackItUp to track how this plugin is used so we can make it better. We only track usage data related to this plugin and will never share this data.', $namespace ); ?></p>
265
  <p class="submit"><input type="submit" name="Submit" class="button-secondary" value="<?php _e( "Save", $namespace ) ?>" /></p>
266
  </div>
 
267
  </form>
268
  </div>
269
  </div>
16
 
17
  <?php
18
  //Display a note for lite customers
19
+ if(!license_active())
 
20
  {
21
  echo '<p> * WPBackItUp Lite customers may use these backup files to manually restore their site. Please visit <a href="http://www.wpbackitup.com/wp-backitup-pro/" target="_blank">www.wpbackitup.com</a> for manual restore instructions.</p>';
22
  }
49
  <td><?php echo $filename?></td>
50
  <td><a href="<?php echo WPBACKITUP_BACKUPFILE_URLPATH ?>/<?php echo $filename; ?>">Download</a></td>
51
  <td><a href="#" title="<?php echo $filename; ?>" class="deleteRow" id="deleteRow<?php echo $i; ?>">Delete</a></td>
52
+ <?php
53
+ if (license_active()) {
54
+ echo '<td><a href="#" title="' . $filename . '" class="restoreRow" id="restoreRow' . $i . '">Restore</a></td>';
55
+ }
56
+ ?>
57
  </tr>
58
  <?php
59
  $i++;
75
 
76
  <?php
77
  //Display restore note for lite customers
78
+ if (!license_active()) {
 
 
79
  echo '<p>* The automated restore feature is only available to Pro customers. Please visit <a href="http://www.wpbackitup.com/wp-backitup-pro/" target="_blank">www.wpbackitup.com</a> to get WPBackItUp Pro risk free for 30 days.</p>' ;
80
  }
81
  ?>
83
 
84
  <!--Disable upload form if the user has not activated-->
85
  <?php
86
+ if( license_active())
 
87
  { ?>
88
  <div class="widget">
89
  <h3>
186
  <span class='error222'><div class='isa_error'><?php _e('Error: Unable to create restore folder', $namespace ); ?>.</div></span>
187
  <span class='error223'><div class='isa_error'><?php _e('Error: An error occurred during the restore. We attempted to restore the database to its previous state but were unsuccessful. Please contact wpbackitup customer support and do not attempt to perform any further restores', $namespace ); ?>.</div></span>
188
  <span class='error224'><div class='isa_error'><?php _e('Error: An error occurred during the restore, however, we have successfully restored your database to the previous state', $namespace ); ?>.</div></span>
189
+ <span class='error225'><div class='isa_error'><?php _e('Error: Restore option is only available to WP BackItUp Pro users', $namespace ); ?>.</div></span>
190
  </div>
191
 
192
  <!--restore success messages-->
195
  </div>
196
 
197
  </div>
198
+ <?php
199
+ global $WPBACKITUP_DEBUG;
200
+ if ($WPBACKITUP_DEBUG===true) {
201
+ echo '<p><div id="php">Logging messages</p></div>';
202
  } ?>
203
  </div>
204
 
205
  <div id="sidebar">
206
 
207
  <!-- Display opt-in form if the user is unregistered -->
208
+ <?php
209
+ if(!license_active()) { ?>
 
210
  <div class="widget">
211
  <h3 class="promo"><?php _e('Get a license key', $namespace ); ?></h3>
212
  <p><?php _e('Tired of messing with FTP, MySQL and PHPMyAdmin? Restore your backups from this page in minutes or your money back', $namespace ); ?>.</p>
225
  <?php wp_nonce_field( $namespace . "-update-options" ); ?>
226
  <div class="widget">
227
  <h3 class="promo"><?php _e('License Key v '.WPBACKITUP_VERSION, $namespace); ?></h3>
228
+ <?php
229
+ $license = $this->get_option( 'license_key' );
230
+ if(!license_active()) { ?>
231
  <p><?php _e('Enter your license key to activate Pro features.', $namespace ); ?>.</p>
232
  <?php } ?>
233
  <p><input type="text" name="data[license_key]" id="license_key" value="<?php echo $license; ?>" />
234
+ <?php
235
+ if(license_active() ) { ?>
236
  <span style="color:green;"><?php _e('Pro License Active', $namespace); ?></span></p>
237
  <p class="submit"><input type="submit" name="Submit" class="button-secondary" value="<?php _e( "Update", $namespace ) ?>" /></p>
238
  <?php } else { ?>
240
  <p class="submit"><input type="submit" name="Submit" class="button-secondary" value="<?php _e( "Activate", $namespace ) ?>" /></p>
241
  <p><?php _e('Purchase a <a href="http://www.wpbackitup.com/plugins/wp-backitup-pro/" target="blank">no-risk </a>license using the purchase link above',$namespace); ?>.</p>
242
  <?php }
243
+ ?>
244
  </div>
245
 
246
  <!-- Display links widget -->
247
  <div class="widget">
248
  <h3 class="promo"><?php _e('Useful Links', $namespace ); ?></h3>
249
  <ul>
250
+ <?php
251
+ if(license_active()) { ?>
252
  <li><a href="http://www.wpbackitup.com/your-account/" target="_blank"><?php _e('Your account',$namespace); ?></a></li>
253
  <li><a href="http://www.wpbackitup.com/plugins/wp-backitup-pro/" target="_blank"><?php _e('Upgrade your license',$namespace); ?></a></li>
254
  <?php }
255
+ ?>
256
  <li><a href="http://www.wpbackitup.com/support" target="_blank"><?php _e('Get support',$namespace); ?></a></li>
257
  <li><a href="http://www.wpbackitup.com/feature-request" target="_blank"><?php _e('Feature Request',$namespace); ?></a></li>
258
  <li>Have a suggestion? Why not submit a feature request.</li>
259
  </ul>
260
  </div>
261
 
262
+ <div class="widget">
263
+ <h3 class="promo">Turn on logging?</h3>
264
+ <p><input type="radio" name="data[logging]" value="enabled" <?php if($this->get_option( 'logging' ) == 'enabled') echo 'checked'; ?>> <label><?php _e('Yes', $namespace ); ?></label></p>
265
+ <p><input type="radio" name="data[logging]" value="disabled" <?php if($this->get_option( 'logging' ) == 'disabled') echo 'checked'; ?>> <label><?php _e('No', $namespace ); ?></label></p>
266
+ <p><?php _e('This option should only be turned on when troubleshooting issues with WPBackItUp support.', $namespace ); ?></p>
267
+ <p class="submit"><input type="submit" name="Submit" class="button-secondary" value="<?php _e( "Save", $namespace ) ?>" /></p>
268
+ </div>
269
+
270
+ <!--
271
  <div class="widget">
272
  <h3 class="promo">Allow Usage Tracking?</h3>
273
  <p><input type="radio" name="data[presstrends]" value="enabled" <?php if($this->get_option( 'presstrends' ) == 'enabled') echo 'checked'; ?>> <label><?php _e('Yes', $namespace ); ?></label></p>
275
  <p><?php _e('Allow WPBackItUp to track how this plugin is used so we can make it better. We only track usage data related to this plugin and will never share this data.', $namespace ); ?></p>
276
  <p class="submit"><input type="submit" name="Submit" class="button-secondary" value="<?php _e( "Save", $namespace ) ?>" /></p>
277
  </div>
278
+ -->
279
  </form>
280
  </div>
281
  </div>