PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 1.5.4
JetBackup – Backup, Restore & Migrate v1.5.4
3.1.22.3 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 5 years ago config 5 years ago cron 5 years ago css 5 years ago fonts 5 years ago img 5 years ago include 5 years ago js 5 years ago templates 5 years ago backups.php 5 years ago boot.php 5 years ago cloud.php 5 years ago dashboardWidget.php 5 years ago pagesContent.php 5 years ago proFeatures.php 5 years ago restore_wordpress.php 5 years ago schedule.php 5 years ago security.php 5 years ago services.php 5 years ago settings.php 5 years ago support.php 5 years ago systemInfo.php 5 years ago videoTutorials.php 5 years ago
restore_wordpress.php
275 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 if ($action == 'finalize') { //finalize action needs WordPress functions to work
31 require_once(ABSPATH.'wp-load.php');
32 require_once(ABSPATH.'wp-admin/includes/plugin.php');
33 $action = 'finalize'; //for some reason $action gets reseted to null
34
35 //activate current BackupGuard plugin
36 //because maybe it was inactive at the time when the backup was made
37 //for example: the backup was made with the free version, the restore with pro
38 $proPluginFile = SG_PLUGIN_NAME.'/backup-guard-pro.php';
39 $freePluginFile = SG_PLUGIN_NAME.'/backup.php';
40 if (file_exists(WP_PLUGIN_DIR.'/'.$proPluginFile)) {
41 activate_plugin($proPluginFile);
42 }
43 else if (file_exists(WP_PLUGIN_DIR.'/'.$freePluginFile)) {
44 activate_plugin($freePluginFile);
45 }
46 }
47 else {
48 //require anything we need for only wpdb to run
49 require_once(ABSPATH.'wp-includes/version.php');
50 require_once(ABSPATH.'wp-includes/formatting.php');
51 require_once(ABSPATH.'wp-includes/plugin.php');
52 require_once(ABSPATH.'wp-includes/class-wp-error.php');
53
54 //starting from WordPress 4.7.1 is_wp_error() has been moved to another location
55 //wpdb needs it, so we create it here
56 if (!function_exists('is_wp_error')) {
57 function is_wp_error($thing) {
58 return ($thing instanceof WP_Error);
59 }
60 }
61
62 require_once(ABSPATH.'wp-includes/wp-db.php');
63 global $wpdb;
64 $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
65 $wpdb->db_connect();
66 }
67
68 //the mysql version is needed for the charset handler
69 define('SG_MYSQL_VERSION', $wpdb->db_version());
70
71 $dbCharset = 'utf8';
72 if (@constant("DB_CHARSET")) {
73 $dbCharset = DB_CHARSET;
74 }
75 define('SG_DB_CHARSET', $dbCharset);
76
77 //require BackupGuard plugin
78 if (file_exists($pluginPath.'config.wordpress.pro.php')) {
79 require_once($pluginPath.'config.wordpress.pro.php');
80 }
81 else if (file_exists($pluginPath.'config.wordpress.free.php')) {
82 require_once($pluginPath.'config.wordpress.free.php');
83 }
84 require_once($pluginPath.'config.php');
85 require_once(SG_CORE_PATH.'SGBoot.php');
86
87 //prcoess awake action (restore)
88 if ($action == 'awake') {
89 require_once(SG_LIB_PATH.'SGReloader.php');
90 SGReloader::awake();
91 die;
92 }
93
94 //process getAction action (get restore progress)
95 if ($action == 'getAction') {
96 require_once(SG_BACKUP_PATH.'SGBackup.php');
97 $currentAction = SGBackup::getAction(SG_ACTION_ID);
98 if ($currentAction) {
99 if ($currentAction['status'] == SG_ACTION_STATUS_CREATED ||
100 $currentAction['status'] == SG_ACTION_STATUS_IN_PROGRESS_FILES ||
101 $currentAction['status'] == SG_ACTION_STATUS_IN_PROGRESS_DB) {
102 if (!SGPing::ping()) {
103 $backup = new SGBackup();
104 $backup->handleExecutionTimeout(SG_ACTION_ID);
105 $currentAction = SGBackup::getAction(SG_ACTION_ID);
106 }
107 die(json_encode($currentAction));
108 }
109 else if ($currentAction['status'] == SG_ACTION_STATUS_FINISHED ||
110 $currentAction['status'] == SG_ACTION_STATUS_FINISHED_WARNINGS) {
111 die('1');
112 }
113 die('0');
114 }
115 die('0');
116 }
117
118 //finalize restoration
119 if ($action == 'finalize') {
120 require_once(SG_BACKUP_PATH.'SGBackup.php');
121 $backup = new SGBackup();
122 $backup->finalizeExternalRestore(SG_ACTION_ID);
123 die;
124 }
125 ?>
126 <!DOCTYPE html>
127 <html>
128 <head>
129 <link rel="stylesheet" type="text/css" href="<?php echo SG_PUBLIC_URL; ?>css/spinner.css">
130 <link rel="stylesheet" type="text/css" href="<?php echo SG_PUBLIC_URL; ?>css/bgstyle.less.css">
131 <link rel="stylesheet" type="text/css" href="<?php echo SG_PUBLIC_URL; ?>css/main.css">
132 <style>
133 body {
134 background-color: #fff;
135 padding: 0;
136 margin: 0;
137 }
138 .sg-box-center {
139 width: 400px;
140 position: absolute;
141 left: 50%;
142 margin-left: -200px;
143 margin-top: 100px;
144 border: 1px solid #5c5c5c;
145 }
146 .sg-logo {
147 text-align: center;
148 padding: 20px 0;
149 background-color: #0021C8;
150 }
151 .sg-wrapper-less .sg-progress {
152 height: 4px;
153 margin: 1px 0 0;
154 }
155 .sg-progress-box p {
156 margin-top: 10px;
157 text-align: center;
158 }
159 .restore-warning {
160 color: #C20000;
161 }
162 .restore-progress-p {
163 font-size: 21px;
164 font-weight: bold;
165 }
166 </style>
167 </head>
168 <body>
169 <div class="sg-wrapper-less">
170 <div class="sg-wrapper">
171 <div class="sg-box-center">
172 <div class="sg-logo">
173 <img width="172px" src="<?php echo SG_PUBLIC_URL; ?>img/sglogo.png">
174 </div>
175 <div class="sg-progress-box">
176 <p class="restore-progress-p">Restoring <span id="progressItem">files</span>: <span id="progressTxt">0%</span></p>
177 <p class="restore-warning"><small>NOTE: Please don't close your browser until finished.</small></p>
178 <div class="sg-progress progress">
179 <div id="progressBar" class="progress-bar" style="width: 0%;"></div>
180 </div>
181 </div>
182 </div>
183 </div>
184 </div>
185 <script>
186 function bgRunAjax(url, responseHandler, params) {
187 var req;
188 if (window.XMLHttpRequest) {
189 req = new XMLHttpRequest();
190 }
191 else if (window.ActiveXObject) {
192 req = new ActiveXObject("Microsoft.XMLHTTP");
193 }
194 req.onreadystatechange = function() {
195 if (req.readyState == 4) {
196 if (req.status < 400) {
197 responseHandler(req, params);
198 }
199 }
200 };
201 req.open("POST", url, true);
202 req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
203 req.send(params);
204 }
205
206 function bgUpdateProgress(progress) {
207 var progressInPercents = progress+'%';
208 var progressBar = document.getElementById('progressBar');
209 progressBar.style.width = progressInPercents;
210 var progressTxt = document.getElementById('progressTxt');
211 progressTxt.innerHTML = progressInPercents;
212 }
213
214 var awakeRunning = false;
215 function awake() {
216 if (awakeRunning) return;
217 awakeRunning = true;
218 bgRunAjax("<?php echo BG_RESTORE_URL; ?>&action=awake", function() {
219 awakeRunning = false;
220 }, "");
221 }
222
223 var getActionRunning = false;
224 function getAction() {
225 if (getActionRunning) return;
226 getActionRunning = true;
227 bgRunAjax("<?php echo BG_RESTORE_URL; ?>&action=getAction", function(response) {
228 try {
229 var response = eval('('+response.responseText+')');
230 if (response === 1) {
231 clearInterval(getActionTimer);
232 clearInterval(awakeTimer);
233 bgRunAjax("<?php echo BG_RESTORE_URL; ?>&action=finalize", function(response) {
234 bgUpdateProgress(100);
235 location.href = '<?php echo BG_PLUGIN_URL; ?>';
236 }, "");
237 return;
238 }
239 else if (response === 0) {
240 clearInterval(getActionTimer);
241 clearInterval(awakeTimer);
242 bgUpdateProgress(100);
243 location.href = '<?php echo BG_PLUGIN_URL; ?>';
244 return;
245 }
246 else if (typeof response === 'object') {
247 bgUpdateProgress(response.progress);
248 if (response.status==<?php echo SG_ACTION_STATUS_IN_PROGRESS_FILES; ?>) {
249 progressItem.innerHTML = 'files';
250 }
251 else {
252 progressItem.innerHTML = 'database';
253 }
254 }
255 } catch (e) {}
256
257 getActionRunning = false;
258 }, "");
259 }
260
261 //awake
262 var awakeTimer = setInterval(function() {
263 awake();
264 }, 3000);
265 awake();
266
267 //get action (for progress)
268 var getActionTimer = setInterval(function() {
269 getAction();
270 }, 4000);
271 getAction();
272 </script>
273 </body>
274 </html>
275