PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 1.6.11
JetBackup – Backup, Restore & Migrate v1.6.11
1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.8.1 1.4.9 1.5.0 1.5.1 1.5.1.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.10 1.6.11 1.6.12 1.6.13 1.6.15 1.6.5.1 1.6.8.8 1.6.9 1.6.9.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7.5 2.0.8.7 2.0.9.11 2.0.9.14 2.0.9.15 2.0.9.6 2.0.9.7 2.0.9.9 3.1.10.7 3.1.11.1 3.1.12.3 3.1.13.4 3.1.14.17 3.1.15.4 3.1.16.1 3.1.17.5 3.1.18.10 3.1.18.8 3.1.18.9 3.1.19.8 3.1.20.3 3.1.21.3 3.1.7.9 3.1.9.2 trunk 1.1.90 1.1.91 1.2.0 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2
backup / public / restore_wordpress.php
backup / public Last commit date
ajax 3 years ago config 4 years ago cron 6 years ago css 3 years ago fonts 5 years ago img 3 years ago include 3 years ago js 3 years ago templates 3 years ago backups.php 3 years ago boot.php 3 years ago cloud.php 3 years ago dashboardWidget.php 3 years ago pagesContent.php 3 years ago proFeatures.php 3 years ago restore_wordpress.php 3 years ago schedule.php 3 years ago security.php 3 years ago services.php 3 years ago settings.php 3 years ago support.php 3 years ago systemInfo.php 3 years ago videoTutorials.php 3 years ago
restore_wordpress.php
300 lines
1 <?php
2 #SG_DYNAMIC_DEFINES#
3
4 //validate key
5 if (@$_GET['k'] != BG_RESTORE_KEY) {
6 die('Invalid key');
7 }
8
9 // define('WP_CONTENT_DIR', ABSPATH.'wp-content');
10 define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins');
11 define('SG_APP_ROOT_DIRECTORY', dirname(WP_CONTENT_DIR) . "/");
12 define('SG_ENV_WORDPRESS', 'Wordpress');
13 define('SG_ENV_ADAPTER', SG_ENV_WORDPRESS);
14 define('SG_DB_ADAPTER', SG_ENV_ADAPTER);
15 define('WP_DEBUG', false);
16 define('WP_DEBUG_DISPLAY', false);
17 define('BG_EXTERNAL_RESTORE_RUNNING', true);
18
19 error_reporting(0);
20 ini_set('display_errors', 0);
21
22 //check if BackupGuard plugin exists
23 $pluginPath = WP_PLUGIN_DIR . '/' . SG_PLUGIN_NAME . '/com/config/';
24 if (!file_exists($pluginPath . 'config.php')) {
25 die('Plugin not found');
26 }
27
28 $action = @$_GET['action'];
29
30 function maintenanceMode($active = false)
31 {
32 if ($active) {
33 file_put_contents(ABSPATH . '.maintenance', '<?php $upgrading = ' . time() . '; ?>');
34 } else {
35 unlink(ABSPATH . '.maintenance');
36 }
37 }
38
39 if ($action == 'finalize') { //finalize action needs WordPress functions to work
40 maintenanceMode(false);
41
42 include_once ABSPATH . 'wp-load.php';
43 include_once ABSPATH . 'wp-admin/includes/plugin.php';
44 $action = 'finalize'; //for some reason $action gets reseted to null
45
46 //activate current BackupGuard plugin
47 //because maybe it was inactive at the time when the backup was made
48 //for example: the backup was made with the free version, the restore with pro
49 $proPluginFile = SG_PLUGIN_NAME . '/backup-guard-pro.php';
50 $freePluginFile = SG_PLUGIN_NAME . '/backup.php';
51 if (file_exists(WP_PLUGIN_DIR . '/' . $proPluginFile)) {
52 activate_plugin($proPluginFile);
53 } else if (file_exists(WP_PLUGIN_DIR . '/' . $freePluginFile)) {
54 activate_plugin($freePluginFile);
55 }
56 } else {
57 //require anything we need for only wpdb to run
58 include_once ABSPATH . 'wp-includes/version.php';
59 include_once ABSPATH . 'wp-includes/formatting.php';
60 include_once ABSPATH . 'wp-includes/plugin.php';
61 include_once ABSPATH . 'wp-includes/class-wp-error.php';
62
63 //starting from WordPress 4.7.1 is_wp_error() has been moved to another location
64 //wpdb needs it, so we create it here
65 if (!function_exists('is_wp_error')) {
66 function is_wp_error($thing)
67 {
68 return ($thing instanceof WP_Error);
69 }
70 }
71
72 include_once ABSPATH . 'wp-includes/wp-db.php';
73 global $wpdb;
74 $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
75 $wpdb->db_connect();
76
77 maintenanceMode(true);
78 }
79
80 //the mysql version is needed for the charset handler
81 if (!defined('SG_MYSQL_VERSION')) {
82 define('SG_MYSQL_VERSION', $wpdb->db_version());
83 }
84 $dbCharset = 'utf8';
85 if (@constant("DB_CHARSET")) {
86 $dbCharset = DB_CHARSET;
87 }
88 if (!defined('SG_DB_CHARSET')) {
89 define('SG_DB_CHARSET', $dbCharset);
90 }
91
92 //require BackupGuard plugin
93 if (file_exists($pluginPath . 'config.wordpress.pro.php')) {
94 include_once $pluginPath . 'config.wordpress.pro.php';
95 } else if (file_exists($pluginPath . 'config.wordpress.free.php')) {
96 include_once $pluginPath . 'config.wordpress.free.php';
97 }
98 require_once $pluginPath . 'config.php';
99 require_once SG_CORE_PATH . 'SGBoot.php';
100
101 //prcoess awake action (restore)
102 if ($action == 'awake') {
103 include_once SG_LIB_PATH . 'SGReloader.php';
104 SGReloader::awake();
105 die;
106 }
107
108 //process getAction action (get restore progress)
109 if ($action == 'getAction') {
110 include_once SG_BACKUP_PATH . 'SGBackup.php';
111 $currentAction = SGBackup::getAction(SG_ACTION_ID);
112 if ($currentAction) {
113 if (
114 $currentAction['status'] == SG_ACTION_STATUS_CREATED
115 || $currentAction['status'] == SG_ACTION_STATUS_IN_PROGRESS_FILES
116 || $currentAction['status'] == SG_ACTION_STATUS_IN_PROGRESS_DB
117 ) {
118 if (!SGPing::ping()) {
119 maintenanceMode(false);
120
121 $backup = new SGBackup();
122 $backup->handleExecutionTimeout(SG_ACTION_ID);
123 $currentAction = SGBackup::getAction(SG_ACTION_ID);
124 }
125 die(json_encode($currentAction));
126 } else if (
127 $currentAction['status'] == SG_ACTION_STATUS_FINISHED
128 || $currentAction['status'] == SG_ACTION_STATUS_FINISHED_WARNINGS
129 ) {
130 die('1');
131 }
132 die('0');
133 }
134 die('0');
135 }
136
137 //finalize restoration
138 if ($action == 'finalize') {
139 include_once SG_BACKUP_PATH . 'SGBackup.php';
140 $backup = new SGBackup();
141 $backup->finalizeExternalRestore(SG_ACTION_ID);
142 die;
143 }
144 ?>
145 <!DOCTYPE html>
146 <html>
147 <head>
148 <link rel="stylesheet" type="text/css" href="<?php echo SG_PUBLIC_URL; ?>css/spinner.css">
149 <link rel="stylesheet" type="text/css" href="<?php echo SG_PUBLIC_URL; ?>css/bgstyle.less.css">
150 <link rel="stylesheet" type="text/css" href="<?php echo SG_PUBLIC_URL; ?>css/main.css">
151 <style>
152 body {
153 background-color: #fff;
154 padding: 0;
155 margin: 0;
156 }
157
158 .sg-box-center {
159 width: 400px;
160 position: absolute;
161 left: 50%;
162 margin-left: -200px;
163 margin-top: 100px;
164 border: 1px solid #5c5c5c;
165 }
166
167 .sg-logo {
168 text-align: center;
169 padding: 20px 0;
170 background-color: #0021C8;
171 }
172
173 .sg-wrapper-less .sg-progress {
174 height: 4px;
175 margin: 1px 0 0;
176 }
177
178 .sg-progress-box p {
179 margin-top: 10px;
180 text-align: center;
181 }
182
183 .restore-warning {
184 color: #C20000;
185 }
186
187 .restore-progress-p {
188 font-size: 21px;
189 font-weight: bold;
190 }
191 </style>
192 </head>
193 <body>
194 <div class="sg-wrapper-less">
195 <div class="sg-wrapper">
196 <div class="sg-box-center">
197 <div class="sg-logo">
198 <img width="172px" src="<?php echo SG_PUBLIC_URL; ?>img/sglogo.png">
199 </div>
200 <div class="sg-progress-box">
201 <p class="restore-progress-p">Restoring <span id="progressItem">files</span>: <span
202 id="progressTxt">0%</span></p>
203 <p class="restore-warning"><small>NOTE: Please don't close your browser until finished.</small></p>
204 <div class="sg-progress progress">
205 <div id="progressBar" class="progress-bar" style="width: 0%;"></div>
206 </div>
207 </div>
208 </div>
209 </div>
210 </div>
211 <script>
212 function bgRunAjax(url, responseHandler, params) {
213 var req;
214 if (window.XMLHttpRequest) {
215 req = new XMLHttpRequest();
216 } else if (window.ActiveXObject) {
217 req = new ActiveXObject("Microsoft.XMLHTTP");
218 }
219 req.onreadystatechange = function () {
220 if (req.readyState == 4) {
221 if (req.status < 400) {
222 responseHandler(req, params);
223 }
224 }
225 };
226 req.open("POST", url, true);
227 req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
228 req.send(params);
229 }
230
231 function bgUpdateProgress(progress) {
232 var progressInPercents = progress + '%';
233 var progressBar = document.getElementById('progressBar');
234 progressBar.style.width = progressInPercents;
235 var progressTxt = document.getElementById('progressTxt');
236 progressTxt.innerHTML = progressInPercents;
237 }
238
239 var awakeRunning = false;
240
241 function awake() {
242 if (awakeRunning) return;
243 awakeRunning = true;
244 bgRunAjax("<?php echo BG_RESTORE_URL; ?>&action=awake", function () {
245 awakeRunning = false;
246 }, "");
247 }
248
249 var getActionRunning = false;
250
251 function getAction() {
252 if (getActionRunning) return;
253 getActionRunning = true;
254 bgRunAjax("<?php echo BG_RESTORE_URL; ?>&action=getAction", function (response) {
255 try {
256 var response = eval('(' + response.responseText + ')');
257 if (response === 1) {
258 clearInterval(getActionTimer);
259 clearInterval(awakeTimer);
260 bgRunAjax("<?php echo BG_RESTORE_URL; ?>&action=finalize", function (response) {
261 bgUpdateProgress(100);
262 location.href = '<?php echo BG_PLUGIN_URL; ?>';
263 }, "");
264 return;
265 } else if (response === 0) {
266 clearInterval(getActionTimer);
267 clearInterval(awakeTimer);
268 bgUpdateProgress(100);
269 location.href = '<?php echo BG_PLUGIN_URL; ?>';
270 return;
271 } else if (typeof response === 'object') {
272 bgUpdateProgress(response.progress);
273 if (response.status ==<?php echo SG_ACTION_STATUS_IN_PROGRESS_FILES; ?>) {
274 progressItem.innerHTML = 'files';
275 } else {
276 progressItem.innerHTML = 'database';
277 }
278 }
279 } catch (e) {
280 }
281
282 getActionRunning = false;
283 }, "");
284 }
285
286 //awake
287 var awakeTimer = setInterval(function () {
288 awake();
289 }, 3000);
290 awake();
291
292 //get action (for progress)
293 var getActionTimer = setInterval(function () {
294 getAction();
295 }, 4000);
296 getAction();
297 </script>
298 </body>
299 </html>
300