Version Description
- Fixed fatal errors with plugin classname.
Download this release
Release Info
Developer | jcpeden |
Plugin | Backup and Restore WordPress – WPBackItUp Backup Plugin |
Version | 1.2.2 |
Comparing to | |
See all releases |
Code changes from version 1.2.1 to 1.2.2
- index.php +64 -26
- js/admin.js +23 -24
- js/ajaxfileupload.js +1 -1
- lib/constants.php +6 -6
- lib/functions.php +13 -5
- lib/includes/backup.php +22 -24
- lib/includes/recurse_zip.php +1 -1
- readme.txt +7 -1
- views/options.php +11 -7
index.php
CHANGED
@@ -2,18 +2,18 @@
|
|
2 |
/**
|
3 |
* WP Backitup Lite
|
4 |
*
|
5 |
-
* @package
|
6 |
*
|
7 |
* @global object $wpdb
|
8 |
*
|
9 |
* @author jcpeden
|
10 |
-
* @version 1.2.
|
11 |
*/
|
12 |
/*
|
13 |
Plugin Name: WP Backitup Lite
|
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.2.
|
17 |
Author: John Peden
|
18 |
Author URI: http://www.johncpeden.com
|
19 |
License: GPL3
|
@@ -33,9 +33,8 @@ GNU General Public License for more details.
|
|
33 |
You should have received a copy of the GNU General Public License
|
34 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
35 |
*/
|
36 |
-
|
37 |
// Include constants file
|
38 |
-
|
39 |
|
40 |
class WPBackitupLite {
|
41 |
var $namespace = "wp-backitup-lite";
|
@@ -44,15 +43,17 @@ class WPBackitupLite {
|
|
44 |
|
45 |
// Default plugin options
|
46 |
var $defaults = array(
|
47 |
-
'presstrends' => "enabled"
|
|
|
|
|
48 |
);
|
49 |
|
50 |
/**
|
51 |
* Instantiation construction
|
52 |
*
|
53 |
* @uses add_action()
|
54 |
-
* @uses
|
55 |
-
* @uses
|
56 |
*/
|
57 |
function __construct() {
|
58 |
// Name of the option_value to store plugin options in
|
@@ -61,7 +62,7 @@ class WPBackitupLite {
|
|
61 |
// Load all library files used by this plugin
|
62 |
$libs = glob( WPBACKITUP_DIRNAME . '/lib/*.php' );
|
63 |
foreach( $libs as $lib ) {
|
64 |
-
include_once
|
65 |
}
|
66 |
|
67 |
/**
|
@@ -97,14 +98,17 @@ class WPBackitupLite {
|
|
97 |
/**
|
98 |
* Process update page form submissions
|
99 |
*
|
100 |
-
* @uses
|
101 |
* @uses wp_redirect()
|
102 |
* @uses wp_verify_nonce()
|
103 |
*/
|
104 |
private function _admin_options_update() {
|
|
|
105 |
// Verify submission for processing using wp_nonce
|
106 |
if( wp_verify_nonce( $_REQUEST['_wpnonce'], "{$this->namespace}-update-options" ) ) {
|
|
|
107 |
$data = array();
|
|
|
108 |
/**
|
109 |
* Loop through each POSTed value and sanitize it to protect against malicious code. Please
|
110 |
* note that rich text (or full HTML fields) should not be processed by this function and
|
@@ -113,16 +117,48 @@ class WPBackitupLite {
|
|
113 |
foreach( $_POST['data'] as $key => $val ) {
|
114 |
$data[$key] = $this->_sanitize( $val );
|
115 |
}
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
// Update the options value with the data submitted
|
122 |
update_option( $this->option_name, $data );
|
123 |
|
124 |
// Redirect back to the options page with the message flag to show the saved message
|
125 |
-
wp_safe_redirect( $_REQUEST['_wp_http_referer'] . '&
|
126 |
exit;
|
127 |
}
|
128 |
}
|
@@ -138,7 +174,7 @@ class WPBackitupLite {
|
|
138 |
*/
|
139 |
private function _sanitize( $str ) {
|
140 |
if ( !function_exists( 'wp_kses' ) ) {
|
141 |
-
|
142 |
}
|
143 |
global $allowedposttags;
|
144 |
global $allowedprotocols;
|
@@ -173,7 +209,7 @@ class WPBackitupLite {
|
|
173 |
* @uses add_options_page()
|
174 |
*/
|
175 |
function admin_menu() {
|
176 |
-
$page_hook = add_menu_page( $this->friendly_name, $this->friendly_name, 'administrator', $this->namespace, array( &$this, 'admin_options_page' ), WPBACKITUP_URLPATH .'/images/icon.png',
|
177 |
|
178 |
// Add print scripts and styles action based off the option page hook
|
179 |
add_action( 'admin_print_scripts-' . $page_hook, array( &$this, 'admin_print_scripts' ) );
|
@@ -195,7 +231,7 @@ class WPBackitupLite {
|
|
195 |
$page_title = $this->friendly_name . ' Options';
|
196 |
$namespace = $this->namespace;
|
197 |
|
198 |
-
include
|
199 |
}
|
200 |
|
201 |
/**
|
@@ -205,6 +241,7 @@ class WPBackitupLite {
|
|
205 |
*/
|
206 |
function admin_print_scripts() {
|
207 |
wp_enqueue_script( "{$this->namespace}-admin" );
|
|
|
208 |
}
|
209 |
|
210 |
/**
|
@@ -255,10 +292,10 @@ class WPBackitupLite {
|
|
255 |
* etc. up for use.
|
256 |
*/
|
257 |
static function instance() {
|
258 |
-
global $
|
259 |
|
260 |
// Only instantiate the Class if it hasn't been already
|
261 |
-
if( !isset( $
|
262 |
}
|
263 |
|
264 |
/**
|
@@ -274,7 +311,7 @@ class WPBackitupLite {
|
|
274 |
if( $file == plugin_basename( WPBACKITUP_DIRNAME . '/' . basename( __FILE__ ) ) ) {
|
275 |
$old_links = $links;
|
276 |
$new_links = array(
|
277 |
-
"settings" => '<a href="
|
278 |
);
|
279 |
$links = array_merge( $new_links, $old_links );
|
280 |
}
|
@@ -288,7 +325,7 @@ class WPBackitupLite {
|
|
288 |
* This function will handling routing of form submissions to the appropriate
|
289 |
* form processor.
|
290 |
*
|
291 |
-
* @uses
|
292 |
*/
|
293 |
function route() {
|
294 |
$uri = $_SERVER['REQUEST_URI'];
|
@@ -322,6 +359,7 @@ class WPBackitupLite {
|
|
322 |
function wp_register_scripts() {
|
323 |
// Admin JavaScript
|
324 |
wp_register_script( "{$this->namespace}-admin", WPBACKITUP_URLPATH . "/js/admin.js", array( 'jquery' ), $this->version, true );
|
|
|
325 |
}
|
326 |
|
327 |
/**
|
@@ -334,9 +372,9 @@ class WPBackitupLite {
|
|
334 |
wp_register_style( "{$this->namespace}-admin", WPBACKITUP_URLPATH . "/css/admin.css", array(), $this->version, 'screen' );
|
335 |
}
|
336 |
}
|
337 |
-
if( !isset( $
|
338 |
WPBackitupLite::instance();
|
339 |
}
|
340 |
|
341 |
-
register_activation_hook( __FILE__, array( '
|
342 |
-
register_deactivation_hook( __FILE__, array( '
|
2 |
/**
|
3 |
* WP Backitup Lite
|
4 |
*
|
5 |
+
* @package WP Backitup Lite
|
6 |
*
|
7 |
* @global object $wpdb
|
8 |
*
|
9 |
* @author jcpeden
|
10 |
+
* @version 1.2.2
|
11 |
*/
|
12 |
/*
|
13 |
Plugin Name: WP Backitup Lite
|
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.2.2
|
17 |
Author: John Peden
|
18 |
Author URI: http://www.johncpeden.com
|
19 |
License: GPL3
|
33 |
You should have received a copy of the GNU General Public License
|
34 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
35 |
*/
|
|
|
36 |
// Include constants file
|
37 |
+
include_once dirname( __FILE__ ) . '/lib/constants.php';
|
38 |
|
39 |
class WPBackitupLite {
|
40 |
var $namespace = "wp-backitup-lite";
|
43 |
|
44 |
// Default plugin options
|
45 |
var $defaults = array(
|
46 |
+
'presstrends' => "enabled",
|
47 |
+
'license_key' => "",
|
48 |
+
'status' => "inactive"
|
49 |
);
|
50 |
|
51 |
/**
|
52 |
* Instantiation construction
|
53 |
*
|
54 |
* @uses add_action()
|
55 |
+
* @uses WPBackitupLite::wp_register_scripts()
|
56 |
+
* @uses WPBackitupLite::wp_register_styles()
|
57 |
*/
|
58 |
function __construct() {
|
59 |
// Name of the option_value to store plugin options in
|
62 |
// Load all library files used by this plugin
|
63 |
$libs = glob( WPBACKITUP_DIRNAME . '/lib/*.php' );
|
64 |
foreach( $libs as $lib ) {
|
65 |
+
include_once $lib;
|
66 |
}
|
67 |
|
68 |
/**
|
98 |
/**
|
99 |
* Process update page form submissions
|
100 |
*
|
101 |
+
* @uses WPBackitupLite::sanitize()
|
102 |
* @uses wp_redirect()
|
103 |
* @uses wp_verify_nonce()
|
104 |
*/
|
105 |
private function _admin_options_update() {
|
106 |
+
|
107 |
// Verify submission for processing using wp_nonce
|
108 |
if( wp_verify_nonce( $_REQUEST['_wpnonce'], "{$this->namespace}-update-options" ) ) {
|
109 |
+
//create data array
|
110 |
$data = array();
|
111 |
+
|
112 |
/**
|
113 |
* Loop through each POSTed value and sanitize it to protect against malicious code. Please
|
114 |
* note that rich text (or full HTML fields) should not be processed by this function and
|
117 |
foreach( $_POST['data'] as $key => $val ) {
|
118 |
$data[$key] = $this->_sanitize( $val );
|
119 |
}
|
120 |
+
|
121 |
+
//check license status and try to activate if invalid
|
122 |
+
$license = trim ( $data['license_key'] );
|
123 |
+
|
124 |
+
// Check license
|
125 |
+
$api_params = array(
|
126 |
+
'edd_action' => 'check_license',
|
127 |
+
'license' => $license,
|
128 |
+
'item_name' => urlencode( WPBACKITUP_ITEM_NAME )
|
129 |
+
);
|
130 |
+
|
131 |
+
// Call the custom API
|
132 |
+
$response = wp_remote_get( add_query_arg( $api_params, WPBACKITUP_SITE_URL ), array( 'timeout' => 15, 'sslverify' => false ) );
|
133 |
+
|
134 |
+
// make sure the response came back okay
|
135 |
+
if ( is_wp_error( $response ) )
|
136 |
+
return false;
|
137 |
+
|
138 |
+
// decode the license data
|
139 |
+
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
|
140 |
+
|
141 |
+
if( $license_data->license != 'valid' ) {
|
142 |
+
// Try to activate license (process is almost identical to check_license)
|
143 |
+
$api_params = array(
|
144 |
+
'edd_action'=> 'activate_license',
|
145 |
+
'license' => $license,
|
146 |
+
'item_name' => urlencode( WPBACKITUP_ITEM_NAME ) // the name of our product in EDD
|
147 |
+
);
|
148 |
+
$response = wp_remote_get( add_query_arg( $api_params, WPBACKITUP_SITE_URL ) );
|
149 |
+
if ( is_wp_error( $response ) )
|
150 |
+
return false;
|
151 |
+
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
|
152 |
+
}
|
153 |
+
|
154 |
+
/* Manually define status value */
|
155 |
+
$data['status'] = $license_data->license;
|
156 |
+
|
157 |
// Update the options value with the data submitted
|
158 |
update_option( $this->option_name, $data );
|
159 |
|
160 |
// Redirect back to the options page with the message flag to show the saved message
|
161 |
+
wp_safe_redirect( $_REQUEST['_wp_http_referer'] . '&update=1' );
|
162 |
exit;
|
163 |
}
|
164 |
}
|
174 |
*/
|
175 |
private function _sanitize( $str ) {
|
176 |
if ( !function_exists( 'wp_kses' ) ) {
|
177 |
+
include_once ABSPATH . 'wp-includes/kses.php';
|
178 |
}
|
179 |
global $allowedposttags;
|
180 |
global $allowedprotocols;
|
209 |
* @uses add_options_page()
|
210 |
*/
|
211 |
function admin_menu() {
|
212 |
+
$page_hook = add_menu_page( $this->friendly_name, $this->friendly_name, 'administrator', $this->namespace, array( &$this, 'admin_options_page' ), WPBACKITUP_URLPATH .'/images/icon.png', 73);
|
213 |
|
214 |
// Add print scripts and styles action based off the option page hook
|
215 |
add_action( 'admin_print_scripts-' . $page_hook, array( &$this, 'admin_print_scripts' ) );
|
231 |
$page_title = $this->friendly_name . ' Options';
|
232 |
$namespace = $this->namespace;
|
233 |
|
234 |
+
include WPBACKITUP_DIRNAME . "/views/options.php";
|
235 |
}
|
236 |
|
237 |
/**
|
241 |
*/
|
242 |
function admin_print_scripts() {
|
243 |
wp_enqueue_script( "{$this->namespace}-admin" );
|
244 |
+
wp_enqueue_script( "{$this->namespace}-ajaxfileupload" );
|
245 |
}
|
246 |
|
247 |
/**
|
292 |
* etc. up for use.
|
293 |
*/
|
294 |
static function instance() {
|
295 |
+
global $WPBackitupLite;
|
296 |
|
297 |
// Only instantiate the Class if it hasn't been already
|
298 |
+
if( !isset( $WPBackitupLite ) ) $WPBackitupLite = new WPBackitupLite();
|
299 |
}
|
300 |
|
301 |
/**
|
311 |
if( $file == plugin_basename( WPBACKITUP_DIRNAME . '/' . basename( __FILE__ ) ) ) {
|
312 |
$old_links = $links;
|
313 |
$new_links = array(
|
314 |
+
"settings" => '<a href="admin.php?page=' . $this->namespace . '">' . __( 'Settings' ) . '</a>'
|
315 |
);
|
316 |
$links = array_merge( $new_links, $old_links );
|
317 |
}
|
325 |
* This function will handling routing of form submissions to the appropriate
|
326 |
* form processor.
|
327 |
*
|
328 |
+
* @uses WPBackitupLite::_admin_options_update()
|
329 |
*/
|
330 |
function route() {
|
331 |
$uri = $_SERVER['REQUEST_URI'];
|
359 |
function wp_register_scripts() {
|
360 |
// Admin JavaScript
|
361 |
wp_register_script( "{$this->namespace}-admin", WPBACKITUP_URLPATH . "/js/admin.js", array( 'jquery' ), $this->version, true );
|
362 |
+
wp_register_script( "{$this->namespace}-ajaxfileupload", WPBACKITUP_URLPATH . "/js/ajaxfileupload.js", array( 'jquery' ), $this->version, true );
|
363 |
}
|
364 |
|
365 |
/**
|
372 |
wp_register_style( "{$this->namespace}-admin", WPBACKITUP_URLPATH . "/css/admin.css", array(), $this->version, 'screen' );
|
373 |
}
|
374 |
}
|
375 |
+
if( !isset( $WPBackitupLite ) ) {
|
376 |
WPBackitupLite::instance();
|
377 |
}
|
378 |
|
379 |
+
register_activation_hook( __FILE__, array( 'WPBackitupLite', 'activate' ) );
|
380 |
+
register_deactivation_hook( __FILE__, array( 'WPBackitupLite', 'deactivate' ) );
|
js/admin.js
CHANGED
@@ -1,21 +1,19 @@
|
|
1 |
/**
|
2 |
* WP Backitup Admin Control Panel JavaScripts
|
3 |
*
|
4 |
-
* @version 1.2.
|
5 |
* @since 1.0.1
|
6 |
*/
|
7 |
|
8 |
(function($){
|
9 |
-
|
10 |
-
|
11 |
//define backup variables
|
12 |
var backup = {
|
13 |
action: 'backup',
|
14 |
beforeSend: function() {
|
15 |
$('.backup-icon').css('visibility','visible');
|
16 |
-
|
17 |
$("#status").html(htmlText);
|
18 |
-
|
19 |
}
|
20 |
};
|
21 |
//define download variables
|
@@ -30,14 +28,14 @@
|
|
30 |
function display_log() {
|
31 |
$.post(ajaxurl, logreader, function(response) {
|
32 |
var xmlObj = $(response);
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
});
|
42 |
}
|
43 |
//define download function
|
@@ -57,21 +55,21 @@
|
|
57 |
clearInterval(display_log);
|
58 |
$('.backup-icon').fadeOut(1000);
|
59 |
$("#php").html(response); //Return PHP messages, used for development
|
60 |
-
});
|
|
|
61 |
})
|
62 |
|
63 |
//execute restore on button click
|
64 |
$("#restore-form").submit(function() {
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
var htmlvals = '<div class="upload">Uploading file: <span class="currentStatus">Pending</span></div><div class="unzipping">Unzipping Files: <span class="currentStatus">Pending</span></div><div class="validation">Validating Zip File: <span class="currentStatus">Pending</span></div><div class="wpcontent">Replacing WP-CONTENT Directory: <span class="currentStatus">Pending</span></div><div class="database">Restoring Database: <span class="currentStatus">Pending</span></div><div class="infomessage"><span class="currentStatus"></span></div><div class="errorMessage"><span class="currentStatus"></span></div>';
|
75 |
|
76 |
$("#status").html(htmlvals);
|
77 |
$(".upload").find('.currentStatus').html('In Progress');
|
@@ -81,6 +79,7 @@
|
|
81 |
$("#upload_target").load(function (){
|
82 |
importRestore();
|
83 |
});
|
|
|
84 |
});
|
85 |
|
86 |
//define importRestore function
|
1 |
/**
|
2 |
* WP Backitup Admin Control Panel JavaScripts
|
3 |
*
|
4 |
+
* @version 1.2.0
|
5 |
* @since 1.0.1
|
6 |
*/
|
7 |
|
8 |
(function($){
|
|
|
|
|
9 |
//define backup variables
|
10 |
var backup = {
|
11 |
action: 'backup',
|
12 |
beforeSend: function() {
|
13 |
$('.backup-icon').css('visibility','visible');
|
14 |
+
var htmlText = "<div class='prerequisites'>Checking prerequisites: <span class='currentStatus'>Pending</span></div><div class='backupfiles'>Backing-up /wp-content/: <span class='currentStatus'>Pending</span></div><div class='backupdb'>Backing-up database: <span class='currentStatus'>Pending</span></div><div class='infofile'>Creating backup directory: <span class='currentStatus'>Pending</span></div><div class='zipfile'>Zipping backup directory: <span class='currentStatus'>Pending</span></div><div class='cleanup'>Cleaning up: <span class='currentStatus'>Pending</span></div><div class='errorMessage'><span class='currentStatus'></span></div>";
|
15 |
$("#status").html(htmlText);
|
16 |
+
window.intervalDefine = setInterval(display_log, 1000);
|
17 |
}
|
18 |
};
|
19 |
//define download variables
|
28 |
function display_log() {
|
29 |
$.post(ajaxurl, logreader, function(response) {
|
30 |
var xmlObj = $(response);
|
31 |
+
xmlObj.each(function(){
|
32 |
+
var attributename = "." + $(this).attr('code');
|
33 |
+
$(attributename).find(".currentStatus").html($(this).text());
|
34 |
+
if($(this).attr('code') == "finalinfo" || $(this).attr('code') == "errorMessage")
|
35 |
+
{
|
36 |
+
clearInterval(window.intervalDefine);
|
37 |
+
}
|
38 |
+
});
|
39 |
});
|
40 |
}
|
41 |
//define download function
|
55 |
clearInterval(display_log);
|
56 |
$('.backup-icon').fadeOut(1000);
|
57 |
$("#php").html(response); //Return PHP messages, used for development
|
58 |
+
});
|
59 |
+
return false;
|
60 |
})
|
61 |
|
62 |
//execute restore on button click
|
63 |
$("#restore-form").submit(function() {
|
64 |
+
var maximum = $("#maximum").val();
|
65 |
+
var fil = document.getElementById("wpbackitup-zip");
|
66 |
+
var sizes = fil.files[0].size;
|
67 |
+
var sizesd = sizes/(1024*1024);
|
68 |
+
if(sizesd > maximum) {
|
69 |
+
$("#status").html("<span style='color: red'>File size exceeds maxium upload size.</span>");
|
70 |
+
return false;
|
71 |
+
}
|
72 |
+
var htmlvals = '<div class="upload">Uploading: <span class="currentStatus">Pending</span></div><div class="unzipping">Unzipping: <span class="currentStatus">Pending</span></div><div class="validation">Validating restoration file: <span class="currentStatus">Pending</span></div><div class="wpcontent">Restoring /wp-content/ directory: <span class="currentStatus">Pending</span></div><div class="database">Restoring database: <span class="currentStatus">Pending</span></div><div class="infomessage"><span class="currentStatus"></span></div><div class="errorMessage"><span class="currentStatus"></span></div>';
|
|
|
73 |
|
74 |
$("#status").html(htmlvals);
|
75 |
$(".upload").find('.currentStatus').html('In Progress');
|
79 |
$("#upload_target").load(function (){
|
80 |
importRestore();
|
81 |
});
|
82 |
+
return false;
|
83 |
});
|
84 |
|
85 |
//define importRestore function
|
js/ajaxfileupload.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
/**
|
2 |
* WP Backitup Ajax File Upload
|
3 |
*
|
4 |
-
* @version 1.2.
|
5 |
* @since 1.0.1
|
6 |
*/
|
7 |
|
1 |
/**
|
2 |
* WP Backitup Ajax File Upload
|
3 |
*
|
4 |
+
* @version 1.2.0
|
5 |
* @since 1.0.1
|
6 |
*/
|
7 |
|
lib/constants.php
CHANGED
@@ -2,14 +2,16 @@
|
|
2 |
/**
|
3 |
* Constants used by this plugin
|
4 |
*
|
5 |
-
* @package WP Backitup
|
6 |
*
|
7 |
* @author jcpeden
|
8 |
-
* @version 1.2.
|
9 |
* @since 1.0.1
|
10 |
*/
|
11 |
|
12 |
-
if( !defined( '
|
|
|
|
|
13 |
|
14 |
if( !defined( 'WPBACKITUP_DIRNAME' ) ) define( 'WPBACKITUP_DIRNAME', dirname( dirname( __FILE__ ) ) );
|
15 |
|
@@ -19,6 +21,4 @@ if( !defined( 'WPBACKITUP_URLPATH' ) ) define( 'WPBACKITUP_URLPATH', WP_PLUGIN_U
|
|
19 |
|
20 |
if( !defined( 'IS_AJAX_REQUEST' ) ) define( 'IS_AJAX_REQUEST', ( !empty( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ) );
|
21 |
|
22 |
-
if( !defined( 'WPBACKITUP_SITE_URL' ) ) define( 'WPBACKITUP_SITE_URL', 'http://www.wpbackitup.com' );
|
23 |
-
|
24 |
-
if( !defined( 'WPBACKITUP_ITEM_NAME' ) ) define( 'WPBACKITUP_ITEM_NAME', 'WP Backitup Lite' );
|
2 |
/**
|
3 |
* Constants used by this plugin
|
4 |
*
|
5 |
+
* @package WP Backitup lite
|
6 |
*
|
7 |
* @author jcpeden
|
8 |
+
* @version 1.2.2
|
9 |
* @since 1.0.1
|
10 |
*/
|
11 |
|
12 |
+
if( !defined( 'WPBACKITUP_ITEM_NAME' ) ) define( 'WPBACKITUP_ITEM_NAME', 'WP Backitup Lite' );
|
13 |
+
|
14 |
+
if( !defined( 'WPBACKITUP_VERSION' ) ) define( 'WPBACKITUP_VERSION', '1.2.2' );
|
15 |
|
16 |
if( !defined( 'WPBACKITUP_DIRNAME' ) ) define( 'WPBACKITUP_DIRNAME', dirname( dirname( __FILE__ ) ) );
|
17 |
|
21 |
|
22 |
if( !defined( 'IS_AJAX_REQUEST' ) ) define( 'IS_AJAX_REQUEST', ( !empty( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ) );
|
23 |
|
24 |
+
if( !defined( 'WPBACKITUP_SITE_URL' ) ) define( 'WPBACKITUP_SITE_URL', 'http://www.wpbackitup.com' );
|
|
|
|
lib/functions.php
CHANGED
@@ -5,10 +5,17 @@
|
|
5 |
* @package WP Backitup Pro
|
6 |
*
|
7 |
* @author jcpeden
|
8 |
-
* @version 1.2.
|
9 |
* @since 1.0.1
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
// include recurseZip class
|
13 |
if( !class_exists( 'recurseZip' ) ) {
|
14 |
include_once 'includes/recurse_zip.php';
|
@@ -87,7 +94,8 @@ if(!function_exists('recursive_copy')) {
|
|
87 |
//Define DB backup function
|
88 |
if(!function_exists('db_backup')) {
|
89 |
function db_backup($path) {
|
90 |
-
|
|
|
91 |
|
92 |
|
93 |
$path_sql = $path .'/db-backup.sql';
|
@@ -171,8 +179,8 @@ function zip($source, $destination, $ignore) {
|
|
171 |
|
172 |
//load presstrends
|
173 |
function load_presstrends() {
|
174 |
-
global $
|
175 |
-
if($
|
176 |
// PressTrends Account API Key
|
177 |
$api_key = 'rwiyhqfp7eioeh62h6t3ulvcghn2q8cr7j5x';
|
178 |
$auth = 'lpa0nvlhyzbyikkwizk4navhtoaqujrbw';
|
@@ -230,4 +238,4 @@ function load_presstrends() {
|
|
230 |
}
|
231 |
}
|
232 |
// PressTrends WordPress Action
|
233 |
-
add_action('admin_init', 'load_presstrends');
|
5 |
* @package WP Backitup Pro
|
6 |
*
|
7 |
* @author jcpeden
|
8 |
+
* @version 1.2.2
|
9 |
* @since 1.0.1
|
10 |
*/
|
11 |
|
12 |
+
// localize the plugin
|
13 |
+
function lang_setup() {
|
14 |
+
global $WPBackitupLite;
|
15 |
+
load_plugin_textdomain($WPBackitupLite->namespace, false, dirname(plugin_basename(__FILE__)) . '/lang/');
|
16 |
+
}
|
17 |
+
add_action('after_setup_theme', 'lang_setup');
|
18 |
+
|
19 |
// include recurseZip class
|
20 |
if( !class_exists( 'recurseZip' ) ) {
|
21 |
include_once 'includes/recurse_zip.php';
|
94 |
//Define DB backup function
|
95 |
if(!function_exists('db_backup')) {
|
96 |
function db_backup($path) {
|
97 |
+
|
98 |
+
$handle = fopen($path .'db-backup.sql', 'w+');
|
99 |
|
100 |
|
101 |
$path_sql = $path .'/db-backup.sql';
|
179 |
|
180 |
//load presstrends
|
181 |
function load_presstrends() {
|
182 |
+
global $WPBackitupLite;
|
183 |
+
if($WPBackitupLite->get_option( 'presstrends' ) == 'enabled') {
|
184 |
// PressTrends Account API Key
|
185 |
$api_key = 'rwiyhqfp7eioeh62h6t3ulvcghn2q8cr7j5x';
|
186 |
$auth = 'lpa0nvlhyzbyikkwizk4navhtoaqujrbw';
|
238 |
}
|
239 |
}
|
240 |
// PressTrends WordPress Action
|
241 |
+
add_action('admin_init', 'load_presstrends');
|
lib/includes/backup.php
CHANGED
@@ -3,14 +3,14 @@
|
|
3 |
/**
|
4 |
* WP Backitup Backup Functions
|
5 |
*
|
6 |
-
* @package WP Backitup
|
7 |
*
|
8 |
* @author jcpeden
|
9 |
-
* @version 1.2.
|
10 |
* @since 1.0.1
|
11 |
*/
|
12 |
|
13 |
-
global $
|
14 |
|
15 |
//limit process to 15 minutes
|
16 |
@set_time_limit(900);
|
@@ -31,8 +31,8 @@ recursive_delete( WPBACKITUP_DIR_PATH .'/backups/' );
|
|
31 |
|
32 |
//Re-create and empty backup dir
|
33 |
if(!create_dir( WPBACKITUP_DIR_PATH .'/backups/' )) {
|
34 |
-
fwrite($fh, '<status code="prerequsites">Failed</status>');
|
35 |
-
fwrite($fh, '<error code="errorMessage">Error: Unable to create new directory for backup. Please check your CHMOD settings in ' .WPBACKITUP_DIR_PATH
|
36 |
|
37 |
fclose($fh);
|
38 |
|
@@ -42,29 +42,27 @@ if(!create_dir( WPBACKITUP_DIR_PATH .'/backups/' )) {
|
|
42 |
//Check to see if the directory is writeable
|
43 |
|
44 |
if(!is_writeable(WPBACKITUP_DIRNAME ."/backups/")) {
|
45 |
-
fwrite($fh, '<status code="prerequsites">Failed</status>');
|
46 |
-
fwrite($fh, '<error code="errorMessage">Error: Cannot create backup directory. Please check the CHMOD settings of your wp-backitup plugin directory
|
47 |
|
48 |
die();
|
49 |
} else {
|
50 |
//If the directory is writeable, create the backup folder if it doesn't exist
|
51 |
if( !is_dir($backup_project_path) ) {
|
52 |
@mkdir($backup_project_path, 0755);
|
53 |
-
fwrite($fh, '<status code="prerequisites">Done</status>');
|
54 |
}
|
55 |
foreach(glob(WPBACKITUP_DIRNAME ."/backups/*.zip") as $zip) {
|
56 |
unlink($zip);
|
57 |
}
|
|
|
58 |
}
|
59 |
|
60 |
-
//Backup content to project dir
|
61 |
-
|
62 |
//Backup with copy
|
63 |
if(recursive_copy($wp_content_path, $backup_project_path, $ignore = array( 'cgi-bin','.','..','._',$backup_project_dirname,'backupbuddy_backups','*.zip','cache' ) ) ) {
|
64 |
-
fwrite($fh, '<status code="backupfiles">Done</status>');
|
65 |
} else {
|
66 |
-
fwrite($fh, '<status code="backupfiles">Failed</status>');
|
67 |
-
fwrite($fh, '<error code="errorMessage">Error: Unable to backup your files. Please try again
|
68 |
die();
|
69 |
}
|
70 |
|
@@ -72,9 +70,9 @@ if(recursive_copy($wp_content_path, $backup_project_path, $ignore = array( 'cgi-
|
|
72 |
|
73 |
|
74 |
if( db_backup($backup_project_path) ) {
|
75 |
-
fwrite($fh, '<status code="backupdb">Done</status>');
|
76 |
} else {
|
77 |
-
fwrite($fh, '<error code="errorMessage">Error: Unable to backup your database. Please try again
|
78 |
recursive_delete($backup_project_path);
|
79 |
die();
|
80 |
}
|
@@ -83,15 +81,15 @@ if( db_backup($backup_project_path) ) {
|
|
83 |
global $wpdb;
|
84 |
|
85 |
if (!create_siteinfo($backup_project_path, $wpdb->prefix) ) {
|
86 |
-
fwrite($fh, '<status code="infofile">Failed</status>');
|
87 |
-
fwrite($fh, '<error code="errorMessage">Error: Unable to create site information file. Please try again
|
88 |
recursive_delete($backup_project_path);
|
89 |
|
90 |
die();
|
91 |
}
|
92 |
else
|
93 |
{
|
94 |
-
fwrite($fh, '<status code="infofile">Done</status>');
|
95 |
}
|
96 |
|
97 |
//Zip the project dir
|
@@ -99,22 +97,22 @@ else
|
|
99 |
$z = new recurseZip();
|
100 |
$src = rtrim($backup_project_path, '/');
|
101 |
$z->compress($src, WPBACKITUP_DIRNAME ."/backups/");
|
102 |
-
fwrite($fh, '<status code="zipfile">Done</status>');
|
103 |
|
104 |
//Delete backup dir
|
105 |
if(!recursive_delete($backup_project_path)) {
|
106 |
-
fwrite($fh, '<status code="cleanup">Failed</status>');
|
107 |
-
fwrite($fh, '<error code="errorMessage">
|
108 |
|
109 |
}
|
110 |
else
|
111 |
{
|
112 |
-
fwrite($fh, '<status code="cleanup">Done</status>');
|
113 |
}
|
114 |
|
115 |
//close log file
|
116 |
-
fwrite($fh, '<status code="finalinfo">Backup file created successfully. You can download your backup file using the link above
|
117 |
-
fwrite($fh, '<status code="end">End</status>');
|
118 |
fclose($fh);
|
119 |
|
120 |
//End backup function
|
3 |
/**
|
4 |
* WP Backitup Backup Functions
|
5 |
*
|
6 |
+
* @package WP Backitup Lite
|
7 |
*
|
8 |
* @author jcpeden
|
9 |
+
* @version 1.2.2
|
10 |
* @since 1.0.1
|
11 |
*/
|
12 |
|
13 |
+
global $WPBackitupLite;
|
14 |
|
15 |
//limit process to 15 minutes
|
16 |
@set_time_limit(900);
|
31 |
|
32 |
//Re-create and empty backup dir
|
33 |
if(!create_dir( WPBACKITUP_DIR_PATH .'/backups/' )) {
|
34 |
+
fwrite($fh, '<status code="prerequsites">'.__('Failed', $WPBackitupLite->namespace ).'</status>');
|
35 |
+
fwrite($fh, '<error code="errorMessage">' . __('Error: Unable to create new directory for backup. Please check your CHMOD settings in ' , $WPBackitupLite->namespace ).WPBACKITUP_DIR_PATH . '.</error>');
|
36 |
|
37 |
fclose($fh);
|
38 |
|
42 |
//Check to see if the directory is writeable
|
43 |
|
44 |
if(!is_writeable(WPBACKITUP_DIRNAME ."/backups/")) {
|
45 |
+
fwrite($fh, '<status code="prerequsites">' . __('Failed', $WPBackitupLite->namespace ) . '</status>');
|
46 |
+
fwrite($fh, '<error code="errorMessage">' . __('Error: Cannot create backup directory. Please check the CHMOD settings of your wp-backitup plugin directory.', $WPBackitupLite->namespace ) . '</error>');
|
47 |
|
48 |
die();
|
49 |
} else {
|
50 |
//If the directory is writeable, create the backup folder if it doesn't exist
|
51 |
if( !is_dir($backup_project_path) ) {
|
52 |
@mkdir($backup_project_path, 0755);
|
|
|
53 |
}
|
54 |
foreach(glob(WPBACKITUP_DIRNAME ."/backups/*.zip") as $zip) {
|
55 |
unlink($zip);
|
56 |
}
|
57 |
+
fwrite($fh, '<status code="prerequisites">' . __('Done', $WPBackitupLite->namespace ) . '</status>');
|
58 |
}
|
59 |
|
|
|
|
|
60 |
//Backup with copy
|
61 |
if(recursive_copy($wp_content_path, $backup_project_path, $ignore = array( 'cgi-bin','.','..','._',$backup_project_dirname,'backupbuddy_backups','*.zip','cache' ) ) ) {
|
62 |
+
fwrite($fh, '<status code="backupfiles">' . __('Done',$WPBackitupLite->namespace ) . '</status>');
|
63 |
} else {
|
64 |
+
fwrite($fh, '<status code="backupfiles">' . __('Failed', $WPBackitupLite->namespace ) . '</status>');
|
65 |
+
fwrite($fh, '<error code="errorMessage">' . __('Error: Unable to backup your files. Please try again.', $WPBackitupLite->namespace ) . "</error>");
|
66 |
die();
|
67 |
}
|
68 |
|
70 |
|
71 |
|
72 |
if( db_backup($backup_project_path) ) {
|
73 |
+
fwrite($fh, '<status code="backupdb">' . __('Done', $WPBackitupLite->namespace ) . '</status>');
|
74 |
} else {
|
75 |
+
fwrite($fh, '<error code="errorMessage">' . __('Error: Unable to backup your database. Please try again.', $WPBackitupLite->namespace ) . '</error>');
|
76 |
recursive_delete($backup_project_path);
|
77 |
die();
|
78 |
}
|
81 |
global $wpdb;
|
82 |
|
83 |
if (!create_siteinfo($backup_project_path, $wpdb->prefix) ) {
|
84 |
+
fwrite($fh, '<status code="infofile">' . __('Failed' , $WPBackitupLite->namespace ) . '</status>');
|
85 |
+
fwrite($fh, '<error code="errorMessage">' . __('Error: Unable to create site information file. Please try again.', $WPBackitupLite->namespace ) . '</error>');
|
86 |
recursive_delete($backup_project_path);
|
87 |
|
88 |
die();
|
89 |
}
|
90 |
else
|
91 |
{
|
92 |
+
fwrite($fh, '<status code="infofile">' . __('Done', $WPBackitupLite->namespace ) . '</status>');
|
93 |
}
|
94 |
|
95 |
//Zip the project dir
|
97 |
$z = new recurseZip();
|
98 |
$src = rtrim($backup_project_path, '/');
|
99 |
$z->compress($src, WPBACKITUP_DIRNAME ."/backups/");
|
100 |
+
fwrite($fh, '<status code="zipfile">' . __('Done', $WPBackitupLite->namespace ) . '</status>');
|
101 |
|
102 |
//Delete backup dir
|
103 |
if(!recursive_delete($backup_project_path)) {
|
104 |
+
fwrite($fh, '<status code="cleanup">' . __('Failed', $WPBackitupLite->namespace ). '</status>');
|
105 |
+
fwrite($fh, '<error code="errorMessage">' . __('Warning: Unable to cleanup your backup directory.', $WPBackitupLite->namespace ) . "</error>");
|
106 |
|
107 |
}
|
108 |
else
|
109 |
{
|
110 |
+
fwrite($fh, '<status code="cleanup">' . __('Done' , $WPBackitupLite->namespace ) . '</status>');
|
111 |
}
|
112 |
|
113 |
//close log file
|
114 |
+
fwrite($fh, '<status code="finalinfo">' . __('Backup file created successfully. You can download your backup file using the link above.', $WPBackitupLite->namespace ) . "</status>");
|
115 |
+
fwrite($fh, '<status code="end">' . __('End', $WPBackitupLite->namespace ) . '</status>');
|
116 |
fclose($fh);
|
117 |
|
118 |
//End backup function
|
lib/includes/recurse_zip.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php
|
2 |
* WP Backitup Recurse Zip Function
|
3 |
*
|
4 |
* @package WP Backitup Pro
|
5 |
*
|
6 |
* @author jcpeden
|
7 |
* @version 1.2.1
|
8 |
* @since 1.0.1
|
9 |
*/
|
|
|
10 |
* WP Backitup Recurse Zip Function
|
11 |
*
|
12 |
* @package WP Backitup Lite
|
13 |
*
|
14 |
* @author jcpeden
|
15 |
* @version 1.2.2
|
16 |
* @since 1.0.1
|
17 |
*/
|
|
|
1 |
* WP Backitup Recurse Zip Function
|
2 |
*
|
3 |
* @package WP Backitup Pro
|
4 |
*
|
5 |
* @author jcpeden
|
6 |
* @version 1.2.1
|
7 |
* @since 1.0.1
|
8 |
*/
|
9 |
+
<?php
|
10 |
* WP Backitup Recurse Zip Function
|
11 |
*
|
12 |
* @package WP Backitup Lite
|
13 |
*
|
14 |
* @author jcpeden
|
15 |
* @version 1.2.2
|
16 |
* @since 1.0.1
|
17 |
*/
|
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
|
6 |
Tested up to: 3.5.1
|
7 |
-
Stable tag: 1.2.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -96,6 +96,9 @@ Yes.
|
|
96 |
|
97 |
== Changelog ==
|
98 |
|
|
|
|
|
|
|
99 |
= 1.2.1 =
|
100 |
* Fixed issues with broken directory tree, brought versioning inline with WP Backitup Pro
|
101 |
|
@@ -155,6 +158,9 @@ Yes.
|
|
155 |
|
156 |
== Upgrade Notice ==
|
157 |
|
|
|
|
|
|
|
158 |
= 1.2.1 =
|
159 |
* Critical upgrade. Plugin broken for most users without this update.
|
160 |
|
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
|
6 |
Tested up to: 3.5.1
|
7 |
+
Stable tag: 1.2.2
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
96 |
|
97 |
== Changelog ==
|
98 |
|
99 |
+
= 1.2.2 =
|
100 |
+
* Fixed fatal errors with plugin classname.
|
101 |
+
|
102 |
= 1.2.1 =
|
103 |
* Fixed issues with broken directory tree, brought versioning inline with WP Backitup Pro
|
104 |
|
158 |
|
159 |
== Upgrade Notice ==
|
160 |
|
161 |
+
= 1.2.2 =
|
162 |
+
* Critical upgrade. Plugin broken for most users without this update.
|
163 |
+
|
164 |
= 1.2.1 =
|
165 |
* Critical upgrade. Plugin broken for most users without this update.
|
166 |
|
views/options.php
CHANGED
@@ -1,14 +1,18 @@
|
|
|
|
1 |
<div class="wrap">
|
2 |
<div id="wp-backitup-icon" class="icon32"><img src="<?php echo plugin_dir_url(dirname(__FILE__) ); ?>images/icon32.png" alt="WP Backitup Icon" height="32" width="32" /></div>
|
3 |
<h2><?php echo $page_title; ?></h2>
|
4 |
<div id="content">
|
5 |
-
<h3><?php _e('Backup', $
|
6 |
-
<p><?php _e('Create a backup file of this site\'s content and settings.', $
|
7 |
-
<p><a href="#" class="backup-button button-primary"><?php _e( "Backup", $
|
8 |
-
<h3
|
9 |
-
<p
|
10 |
-
<h3
|
11 |
-
<p><div id="status"
|
|
|
|
|
|
|
12 |
</div>
|
13 |
<div id="sidebar">
|
14 |
<div class="widget" id="restore-widget">
|
1 |
+
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
|
2 |
<div class="wrap">
|
3 |
<div id="wp-backitup-icon" class="icon32"><img src="<?php echo plugin_dir_url(dirname(__FILE__) ); ?>images/icon32.png" alt="WP Backitup Icon" height="32" width="32" /></div>
|
4 |
<h2><?php echo $page_title; ?></h2>
|
5 |
<div id="content">
|
6 |
+
<h3><?php _e('Backup', $namespace );?></h3>
|
7 |
+
<p><?php _e('Create a backup file of this site\'s content and settings.', $namespace ) ;?></p>
|
8 |
+
<p><a href="#" class="backup-button button-primary"><?php _e( "Backup", $namespace ) ?></a><img class="backup-icon status-icon" src="<?php echo WPBACKITUP_URLPATH. "/images/loader.gif"; ?>" height="16" width="16" /></p>
|
9 |
+
<h3><?php _e('Download', $namespace );?></h3>
|
10 |
+
<p id="download-link"></p>
|
11 |
+
<h3><?php _e('Status', $namespace );?></h3>
|
12 |
+
<p><div id="status"><?php _e('Nothing to report', $namespace );?></div></p>
|
13 |
+
<?php if (site_url() == 'http://localhost/wpbackitup') {
|
14 |
+
echo '<p><div id="php">PHP messages here</div></p>';
|
15 |
+
} ?>
|
16 |
</div>
|
17 |
<div id="sidebar">
|
18 |
<div class="widget" id="restore-widget">
|