PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 1.4.5
JetBackup – Backup, Restore & Migrate v1.4.5
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 / com / core / functions.php
backup / com / core Last commit date
backup 5 years ago database 5 years ago exception 5 years ago extension 5 years ago log 5 years ago notice 5 years ago restore 5 years ago schedule 5 years ago storage 5 years ago widget 5 years ago SGBoot.php 5 years ago SGConfig.php 5 years ago SGPing.php 5 years ago functions.php 5 years ago
functions.php
753 lines
1 <?php
2
3 function backupGuardGetCapabilities()
4 {
5 switch (SG_PRODUCT_IDENTIFIER) {
6 case 'backup-guard-en':
7 case 'backup-guard-wp-platinum':
8 case 'backup-guard-en-regular':
9 case 'backup-guard-en-extended':
10 return BACKUP_GUARD_CAPABILITIES_PLATINUM;
11 case 'backup-guard-wp-gold':
12 return BACKUP_GUARD_CAPABILITIES_GOLD;
13 case 'backup-guard-wp-silver':
14 return BACKUP_GUARD_CAPABILITIES_SILVER;
15 case 'backup-guard-wp-free':
16 return BACKUP_GUARD_CAPABILITIES_FREE;
17 }
18 }
19
20 function convertToReadableSize($size)
21 {
22 if (!$size) {
23 return '';
24 }
25
26 $base = log($size) / log(1000);
27 $suffix = array("", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB");
28 $f_base = floor($base);
29
30 return round(pow(1000, $base - floor($base)), 1) . $suffix[$f_base];
31 }
32
33 function backupGuardgetSealPopup()
34 {
35 $currentDate = time();
36 $sgShouldShowPopup = SGConfig::get('SG_SHOULD_SHOW_POPUP') == null ? true : SGConfig::get('SG_SHOULD_SHOW_POPUP');
37 $sgPluginInstallUpdateDate = SGConfig::get('SG_PLUGIN_INSTALL_UPDATE_DATE') == null ? time() : SGConfig::get('SG_PLUGIN_INSTALL_UPDATE_DATE');
38
39 // check ig plugin is active for free days show poup
40 if (($currentDate - $sgPluginInstallUpdateDate >= SG_PLUGIN_ACTIVE_INTERVAL) && $sgShouldShowPopup) {
41 ?>
42 <script>
43 window.SGPMPopupLoader=window.SGPMPopupLoader||{ids:[],popups:{},call:function(w,d,s,l,id){
44 w['sgp']=w['sgp']||function(){(w['sgp'].q=w['sgp'].q||[]).push(arguments[0]);};
45 var sg1=d.createElement(s),sg0=d.getElementsByTagName(s)[0];
46 if(SGPMPopupLoader && SGPMPopupLoader.ids && SGPMPopupLoader.ids.length > 0){SGPMPopupLoader.ids.push(id); return;}
47 SGPMPopupLoader.ids.push(id);
48 sg1.onload = function(){SGPMPopup.openSGPMPopup();}; sg1.async=true; sg1.src=l;
49 sg0.parentNode.insertBefore(sg1,sg0);
50 return {};
51 }};
52 SGPMPopupLoader.call(window,document,'script','https://popupmaker.com/assets/lib/SGPMPopup.min.js','7c685e17');
53 </script>
54 <?php
55 SGConfig::set('SG_SHOULD_SHOW_POPUP', 0);
56 }
57
58 return;
59 }
60
61 function backupGuardConvertDateTimezone($date, $dateFormat = "Y-m-d H:i:s", $timezone = "UTC")
62 {
63 if (in_array($timezone, timezone_identifiers_list())) {
64 $date = date_create($date);
65 $timezone = timezone_open($timezone);
66 date_timezone_set($date, $timezone);
67
68 if (!$dateFormat) {
69 $dateFormat = "Y-m-d H:i:s";
70 }
71
72 return date_format($date, $dateFormat);
73 }
74
75 return $date;
76 }
77
78 function backupGuardRemoveSlashes($value)
79 {
80 if (SG_ENV_ADAPTER == SG_ENV_WORDPRESS) {
81 return wp_unslash($value);
82 }
83 else {
84 if (is_array($value)) {
85 return array_map('stripslashes', $value);
86 }
87
88 return stripslashes($value);
89 }
90 }
91
92 function backupGuardSanitizeTextField($value)
93 {
94 if (SG_ENV_ADAPTER == SG_ENV_WORDPRESS) {
95 if (is_array($value)) {
96 return array_map('sanitize_text_field', $value);
97 }
98
99 return sanitize_text_field($value);
100 }
101 else {
102 if (is_array($value)) {
103 return array_map('strip_tags', $value);
104 }
105
106 return strip_tags($value);
107 }
108 }
109
110 function backupGuardIsMultisite()
111 {
112 if (SG_ENV_ADAPTER == SG_ENV_WORDPRESS) {
113 return defined('BG_IS_MULTISITE')?BG_IS_MULTISITE:is_multisite();
114 }
115 else {
116 return false;
117 }
118 }
119
120 function backupGuardGetBanner($env, $type="plugin", $userType = null)
121 {
122 require_once(SG_LIB_PATH.'BackupGuard/Client.php');
123 $client = new BackupGuard\Client();
124 return $client->getBanner(strtolower($env), $type, $userType);
125 }
126
127 function backupGuardGetFilenameOptions($options)
128 {
129 $selectedPaths = explode(',', $options['SG_BACKUP_FILE_PATHS']);
130 $pathsToExclude = explode(',', $options['SG_BACKUP_FILE_PATHS_EXCLUDE']);
131
132 $opt = '';
133
134 if (SG_ENV_ADAPTER == SG_ENV_WORDPRESS) {
135 $opt .= 'opt(';
136
137 if ($options['SG_BACKUP_TYPE'] == SG_BACKUP_TYPE_CUSTOM) {
138 if ($options['SG_ACTION_BACKUP_DATABASE_AVAILABLE']) {
139 $opt .= 'db_';
140 }
141
142 if ($options['SG_ACTION_BACKUP_FILES_AVAILABLE']) {
143 if (in_array('wp-content', $selectedPaths)) {
144 $opt .= 'wpc_';
145 }
146 if (!in_array('wp-content/plugins', $pathsToExclude)) {
147 $opt .= 'plg_';
148 }
149 if (!in_array('wp-content/themes', $pathsToExclude)) {
150 $opt .= 'thm_';
151 }
152 if (!in_array('wp-content/uploads', $pathsToExclude)) {
153 $opt .= 'upl_';
154 }
155 }
156
157
158 }
159 else {
160 $opt .= 'full';
161 }
162
163 $opt = trim($opt, "_");
164 $opt .= ')_';
165 }
166
167 return $opt;
168 }
169
170 function backupGuardGenerateToken()
171 {
172 return md5(time());
173 }
174
175 // Parse a URL and return its components
176 function backupGuardParseUrl($url)
177 {
178 $urlComponents = parse_url($url);
179 $domain = $urlComponents['host'];
180 $port = '';
181
182 if (isset($urlComponents['port']) && strlen($urlComponents['port'])) {
183 $port = ":".$urlComponents['port'];
184 }
185
186 $domain = preg_replace("/(www|\dww|w\dw|ww\d)\./", "", $domain);
187
188 $path = "";
189 if (isset($urlComponents['path'])) {
190 $path = $urlComponents['path'];
191 }
192
193 return $domain.$port.$path;
194 }
195
196 function backupGuardIsReloadEnabled()
197 {
198 // Check if reloads option is turned on
199 return SGConfig::get('SG_BACKUP_WITH_RELOADINGS')?true:false;
200 }
201
202 function backupGuardGetBackupOptions($options)
203 {
204 $backupOptions = array(
205 'SG_BACKUP_UPLOAD_TO_STORAGES' => '',
206 'SG_BACKUP_FILE_PATHS_EXCLUDE' => '',
207 'SG_BACKUP_FILE_PATHS' => ''
208 );
209
210 if (isset($options['sg-custom-backup-name']) && $options['sg-custom-backup-name']) {
211 SGConfig::set("SG_CUSTOM_BACKUP_NAME", $options['sg-custom-backup-name']);
212 }
213 else {
214 SGConfig::set("SG_CUSTOM_BACKUP_NAME", '');
215 }
216
217 //If background mode
218 $isBackgroundMode = !empty($options['backgroundMode']) ? 1 : 0;
219
220 if ($isBackgroundMode) {
221 $backupOptions['SG_BACKUP_IN_BACKGROUND_MODE'] = $isBackgroundMode;
222 }
223
224 //If cloud backup
225 if (!empty($options['backupCloud']) && count($options['backupStorages'])) {
226 $clouds = $options['backupStorages'];
227 $backupOptions['SG_BACKUP_UPLOAD_TO_STORAGES'] = implode(',', $clouds);
228 }
229
230 $backupOptions['SG_BACKUP_TYPE'] = $options['backupType'];
231
232 if ($options['backupType'] == SG_BACKUP_TYPE_FULL) {
233 $backupOptions['SG_ACTION_BACKUP_DATABASE_AVAILABLE']= 1;
234 $backupOptions['SG_ACTION_BACKUP_FILES_AVAILABLE'] = 1;
235 $backupOptions['SG_BACKUP_FILE_PATHS_EXCLUDE'] = SG_BACKUP_FILE_PATHS_EXCLUDE;
236 $backupOptions['SG_BACKUP_FILE_PATHS'] = 'wp-content';
237 }
238 else if ($options['backupType'] == SG_BACKUP_TYPE_CUSTOM) {
239 //If database backup
240 $isDatabaseBackup = !empty($options['backupDatabase']) ? 1 : 0;
241 $backupOptions['SG_ACTION_BACKUP_DATABASE_AVAILABLE'] = $isDatabaseBackup;
242
243 //If db backup
244 if($options['backupDBType']){
245 $tablesToBackup = implode(',', $options['table']);
246 $backupOptions['SG_BACKUP_TABLES_TO_BACKUP'] = $tablesToBackup;
247 }
248
249 //If files backup
250 if (!empty($options['backupFiles']) && count($options['directory'])) {
251 $backupFiles = explode(',', SG_BACKUP_FILE_PATHS);
252 $filesToExclude = @array_diff($backupFiles, $options['directory']);
253
254 if (in_array('wp-content', $options['directory'])) {
255 $options['directory'] = array('wp-content');
256 }
257 else {
258 $filesToExclude = array_diff($filesToExclude, array('wp-content'));
259 }
260
261 $filesToExclude = implode(',', $filesToExclude);
262 if (strlen($filesToExclude)) {
263 $filesToExclude = ','.$filesToExclude;
264 }
265
266 $backupOptions['SG_BACKUP_FILE_PATHS_EXCLUDE'] = SG_BACKUP_FILE_PATHS_EXCLUDE.$filesToExclude;
267 $options['directory'] = backupGuardSanitizeTextField($options['directory']);
268 $backupOptions['SG_BACKUP_FILE_PATHS'] = implode(',', $options['directory']);
269 $backupOptions['SG_ACTION_BACKUP_FILES_AVAILABLE'] = 1;
270 }
271 else {
272 $backupOptions['SG_ACTION_BACKUP_FILES_AVAILABLE'] = 0;
273 $backupOptions['SG_BACKUP_FILE_PATHS'] = 0;
274 }
275 }
276 return $backupOptions;
277 }
278
279 function backupGuardLoadStateData()
280 {
281 if (file_exists(SG_BACKUP_DIRECTORY.SG_STATE_FILE_NAME)) {
282 $sgState = new SGState();
283 $stateFile = file_get_contents(SG_BACKUP_DIRECTORY.SG_STATE_FILE_NAME);
284 $sgState = $sgState->factory($stateFile);
285 return $sgState;
286 }
287
288 return false;
289 }
290
291 function backupGuardValidateApiCall($token)
292 {
293 if (!strlen($token)) {
294 exit();
295 }
296
297 $statePath = SG_BACKUP_DIRECTORY.SG_STATE_FILE_NAME;
298
299 if (!file_exists($statePath)) {
300 exit();
301 }
302
303 $state = file_get_contents($statePath);
304 $state = json_decode($state, true);
305 $stateToken = $state['token'];
306
307 if ($stateToken != $token) {
308 exit();
309 }
310
311 return true;
312 }
313
314 function backupGuardScanBackupsDirectory($path)
315 {
316 $backups = scandir($path);
317 $backupFolders = array();
318 foreach ($backups as $key => $backup) {
319 if ($backup == "." || $backup == "..") {
320 continue;
321 }
322
323 if (is_dir($path.$backup)) {
324 $backupFolders[$backup] = filemtime($path.$backup);
325 }
326 }
327 // Sort(from low to high) backups by creation date
328 asort($backupFolders);
329 return $backupFolders;
330 }
331
332 function backupGuardSymlinksCleanup($dir)
333 {
334 if (is_dir($dir)) {
335 $objects = scandir($dir);
336 foreach ($objects as $object) {
337 if ($object == "." || $object == "..") {
338 continue;
339 }
340
341 if (filetype($dir.$object) != "dir") {
342 @unlink($dir.$object);
343 }
344 else {
345 backupGuardSymlinksCleanup($dir.$object.'/');
346 @rmdir($dir.$object);
347 }
348 }
349 }
350 else if (file_exists($dir)) {
351 @unlink($dir);
352 }
353 return;
354 }
355
356 function backupGuardRealFilesize($filename)
357 {
358 $fp = fopen($filename, 'r');
359 $return = false;
360 if (is_resource($fp))
361 {
362 if (PHP_INT_SIZE < 8) // 32 bit
363 {
364 if (0 === fseek($fp, 0, SEEK_END))
365 {
366 $return = 0.0;
367 $step = 0x7FFFFFFF;
368 while ($step > 0)
369 {
370 if (0 === fseek($fp, - $step, SEEK_CUR))
371 {
372 $return += floatval($step);
373 }
374 else
375 {
376 $step >>= 1;
377 }
378 }
379 }
380 }
381 else if (0 === fseek($fp, 0, SEEK_END)) // 64 bit
382 {
383 $return = ftell($fp);
384 }
385 }
386
387 return $return;
388 }
389
390 function backupGuardFormattedDuration($startTs, $endTs)
391 {
392 $unit = 'seconds';
393 $duration = $endTs-$startTs;
394 if ($duration>=60 && $duration<3600)
395 {
396 $duration /= 60.0;
397 $unit = 'minutes';
398 }
399 else if ($duration>=3600)
400 {
401 $duration /= 3600.0;
402 $unit = 'hours';
403 }
404 $duration = number_format($duration, 2, '.', '');
405
406 return $duration.' '.$unit;
407 }
408
409 function backupGuardDeleteDirectory($dirName)
410 {
411 $dirHandle = null;
412 if (is_dir($dirName))
413 {
414 $dirHandle = opendir($dirName);
415 }
416
417 if (!$dirHandle)
418 {
419 return false;
420 }
421
422 while ($file = readdir($dirHandle))
423 {
424 if ($file != "." && $file != "..")
425 {
426 if (!is_dir($dirName."/".$file))
427 {
428 @unlink($dirName."/".$file);
429 }
430 else
431 {
432 backupGuardDeleteDirectory($dirName.'/'.$file);
433 }
434 }
435 }
436
437 closedir($dirHandle);
438 return @rmdir($dirName);
439 }
440
441 function backupGuardDownloadFile($file, $type = 'application/octet-stream')
442 {
443 $file = backupGuardRemoveSlashes($file);
444 if (file_exists($file)) {
445 header('Content-Description: File Transfer');
446 header('Content-Type: '.$type);
447 header('Content-Disposition: attachment; filename="'.basename($file).'";');
448 header('Expires: 0');
449 header('Cache-Control: must-revalidate');
450 header('Pragma: public');
451 header('Content-Length: ' . filesize($file));
452 readfile($file);
453 }
454
455 exit;
456 }
457
458 function backupGuardDownloadViaPhp($backupName, $fileName)
459 {
460 $str = backupGuardMakeSymlinkFolder($fileName);
461 @copy(SG_BACKUP_DIRECTORY.$backupName.'/'.$fileName, SG_SYMLINK_PATH.$str.'/'.$fileName);
462
463 if (file_exists(SG_SYMLINK_PATH.$str.'/'.$fileName)) {
464 $remoteGet = wp_remote_get(SG_SYMLINK_URL.$str.'/'.$fileName);
465 if (!is_wp_error($remoteGet)) {
466 $content = wp_remote_retrieve_body($remoteGet);
467 header('Pragma: public');
468 header('Expires: 0');
469 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
470 header('Cache-Control: private', false);
471 header('Content-Type: application/octet-stream');
472 header('Content-Disposition: attachment; filename='.$fileName.';');
473 header('Content-Transfer-Encoding: binary');
474 echo $content;
475 exit;
476 }
477 }
478 }
479
480 function backupGuardMakeSymlinkFolder($filename)
481 {
482 $filename = backupGuardRemoveSlashes($filename);
483
484 $downloaddir = SG_SYMLINK_PATH;
485 $downloadURL = SG_SYMLINK_URL;
486
487 if (!file_exists($downloaddir)) {
488 mkdir($downloaddir, 0777);
489 }
490
491 $letters = 'abcdefghijklmnopqrstuvwxyz';
492 srand((double) microtime() * 1000000);
493 $string = '';
494
495 for ($i = 1; $i <= rand(4,12); $i++) {
496 $q = rand(1,24);
497 $string = $string.$letters[$q];
498 }
499
500 $handle = opendir($downloaddir);
501 while ($dir = readdir($handle)) {
502 if ($dir == "." || $dir == "..") {
503 continue;
504 }
505
506 if (is_dir($downloaddir.$dir)) {
507 @unlink($downloaddir . $dir . "/" . $filename);
508 @rmdir($downloaddir . $dir);
509 }
510 }
511
512 closedir($handle);
513 mkdir($downloaddir . $string, 0777);
514
515 return $string;
516 }
517
518 function backupGuardDownloadFileSymlink($safedir, $filename)
519 {
520 $downloaddir = SG_SYMLINK_PATH;
521 $downloadURL = SG_SYMLINK_URL;
522
523 $safedir = backupGuardRemoveSlashes($safedir);
524 $string = backupGuardMakeSymlinkFolder($filename);
525
526 $res = @symlink($safedir . $filename, $downloaddir . $string . "/" . $filename);
527 if ($res) {
528 header('Content-Description: File Transfer');
529 header('Content-Type: application/octet-stream');
530 header('Content-Disposition: attachment;filename="'.$filename.'"');
531 header('Content-Transfer-Encoding: binary');
532 header("Location: " . $downloadURL . $string . "/" . $filename);
533 }
534 else{
535 wp_die(_backupGuardT("Symlink / shortcut creation failed! Seems your server configurations don't allow symlink creation, so we're unable to provide you the direct download url. You can download your backup using any FTP client. All backups and related stuff we locate '/wp-content/uploads/backup-guard' directory. If you need this functionality, you should check out your server configurations and make sure you don't have any limitation related to symlink creation.", true));
536 }
537 exit;
538 }
539
540 function backupGuardGetCurrentUrlScheme()
541 {
542 return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')?'https':'http';
543 }
544
545 function backupGuardValidateLicense()
546 {
547 $pluginCapabilities = backupGuardGetCapabilities();
548 if ($pluginCapabilities == BACKUP_GUARD_CAPABILITIES_FREE) {
549 return true;
550 }
551
552 //only check once per day
553 $ts = (int)SGConfig::get('SG_LICENSE_CHECK_TS');
554 if (time() - $ts < SG_LICENSE_CHECK_TIMEOUT) {
555 return true;
556 }
557
558 require_once(SG_LIB_PATH.'SGAuthClient.php');
559
560 $url = site_url();
561
562 $auth = SGAuthClient::getInstance();
563 $res = $auth->validateUrl($url);
564
565 if ($res === -1) { //login is required
566 backup_guard_login_page();
567 return false;
568 }
569 else if ($res === false) { //invalid license
570 backup_guard_link_license_page();
571 return false;
572 }
573 else {
574 SGConfig::set('SG_LICENSE_CHECK_TS', time(), true);
575 SGConfig::set('SG_LICENSE_KEY', $res, true);
576 }
577
578 return true;
579 }
580
581 //returns true if string $haystack ends with string $needle or $needle is an empty string
582 function backupGuardStringEndsWith($haystack, $needle)
583 {
584 $length = strlen($needle);
585
586 return $length === 0 ||
587 (substr($haystack, -$length) === $needle);
588 }
589 //returns true if string $haystack starts with string $needle
590 function backupGuardStringStartsWith($haystack, $needle)
591 {
592 $length = strlen($needle);
593 return (substr($haystack, 0, $length) === $needle);
594 }
595
596 function backupGuardGetDbTables(){
597 $sgdb = SGDatabase::getInstance();
598 $tables = $sgdb->query("SHOW TABLES");
599 $tablesKey = 'Tables_in_'.SG_DB_NAME;
600 $tableNames = array();
601 $customTablesToExclude = str_replace(' ', '', SGConfig::get('SG_TABLES_TO_EXCLUDE'));
602 $tablesToExclude = explode(',', $customTablesToExclude);
603 foreach ($tables as $table):
604 $tableName = $table[$tablesKey];
605 if($tableName != SG_ACTION_TABLE_NAME && $tableName != SG_CONFIG_TABLE_NAME && $tableName != SG_SCHEDULE_TABLE_NAME){
606 array_push($tableNames, array('name'=>$tableName,
607 'current'=> backupGuardStringStartsWith($tableName, SG_ENV_DB_PREFIX)? 'true':'false',
608 'disabled'=>in_array($tableName,$tablesToExclude)? 'disabled':''
609 ));
610 }
611 endforeach;
612 usort($tableNames, function ($name1, $name2){
613 if(backupGuardStringStartsWith($name1['name'], SG_ENV_DB_PREFIX)){
614 if(backupGuardStringStartsWith($name2['name'], SG_ENV_DB_PREFIX)){
615 return 0;
616 }
617 return -1;
618 }
619 return 1;
620 });
621 return $tableNames;
622 }
623
624 function backupGuardGetBackupTablesHTML($defaultChecked = false){
625 $tables = backupGuardGetDbTables();
626 ?>
627
628 <div class="checkbox">
629 <label for="custom-backupdb-chbx">
630 <input type="checkbox" class="sg-custom-option" name="backupDatabase" id="custom-backupdb-chbx" <?php echo $defaultChecked?'checked':'' ?>>
631 <span class="sg-checkbox-label-text"><?php _backupGuardT('Backup database'); ?></span>
632 </label>
633 <div class="col-md-12 sg-checkbox sg-backup-db-options">
634 <div class="checkbox">
635 <label for="custombackupdbfull-radio" class="sg-backup-db-mode" title="<?php _backupGuardT('Backup all tables found in the database')?>">
636 <input type="radio" name="backupDBType" id="custombackupdbfull-radio" value="0" checked>
637 <?php _backupGuardT('Full'); ?>
638 </label>
639 <label for="custombackupdbcurent-radio" class="sg-backup-db-mode" title="<?php echo _backupGuardT('Backup tables related to the current WordPress installation. Only tables with', true).' '.SG_ENV_DB_PREFIX.' '._backupGuardT('will be backed up', true)?>">
640 <input type="radio" name="backupDBType" id="custombackupdbcurent-radio" value="1">
641 <?php _backupGuardT('Only WordPress'); ?>
642 </label>
643 <label for="custombackupdbcustom-radio" class="sg-backup-db-mode" title="<?php _backupGuardT('Select tables you want to include in your backup') ?>">
644 <input type="radio" name="backupDBType" id="custombackupdbcustom-radio" value="2">
645 <?php _backupGuardT('Custom'); ?>
646 </label>
647 <!--Tables-->
648 <div class="col-md-12 sg-custom-backup-tables">
649 <?php foreach ($tables as $table): ?>
650 <div class="checkbox">
651 <label for="<?php echo $table['name']?>">
652 <input type="checkbox" name="table[]" current="<?php echo $table['current'] ?>" <?php echo $table['disabled'] ?> id="<?php echo $table['name']?>" value="<?php echo $table['name'];?>">
653 <span class="sg-checkbox-label-text"><?php echo basename($table['name']);?></span>
654 <?php if($table['disabled']) {?>
655 <span class="sg-disableText"><?php _backupGuardT('(excluded from settings)') ?></span>
656 <?php } ?>
657 </label>
658 </div>
659 <?php endforeach;?>
660 </div>
661 </div>
662 </div>
663
664 </div>
665
666 <?php
667
668 }
669
670 function backupGuardIsAccountGold()
671 {
672 return strpos("gold", SG_PRODUCT_IDENTIFIER)!== false;
673 }
674
675 function backupGuardGetProductName()
676 {
677 $name = '';
678 switch (SG_PRODUCT_IDENTIFIER) {
679 case 'backup-guard-wp-silver':
680 $name = 'Silver';
681 break;
682 case 'backup-guard-wp-platinum':
683 $name = 'Platinum';
684 break;
685 case 'backup-guard-en':
686 case 'backup-guard-en-regular':
687 $name = 'Regular';
688 break;
689 case 'backup-guard-en-extended':
690 $name = 'Extended';
691 break;
692 case 'backup-guard-wp-gold':
693 $name = 'Gold';
694 break;
695 case 'backup-guard-wp-free':
696 $name = 'Free';
697 break;
698 }
699
700 return $name;
701 }
702
703 function backupGuardGetFileSelectiveRestore()
704 {
705 ?>
706 <div class="col-md-12 sg-checkbox sg-restore-files-options">
707 <div class="checkbox">
708 <label for="restorefilesfull-radio" class="sg-restore-files-mode" >
709 <input type="radio" name="restoreFilesType" checked id="restorefilesfull-radio" value="0">
710 <?php _backupGuardT('Full'); ?>
711 </label>
712
713 <label for="restorefilescustom-radio" class="sg-restore-files-mode">
714 <input type="radio" name="restoreFilesType" id="restorefilescustom-radio" value="1">
715 <?php _backupGuardT('Custom'); ?>
716 </label>
717 <!--Files-->
718 <div class="col-md-12 sg-file-selective-restore">
719 <div id="fileSystemTreeContainer"></div>
720 </div>
721 </div>
722 </div>
723 <?php
724 }
725
726 function checkAllMissedTables()
727 {
728 $sgdb = SGDatabase::getInstance();
729 $allTables = array(SG_CONFIG_TABLE_NAME, SG_SCHEDULE_TABLE_NAME, SG_ACTION_TABLE_NAME);
730 $missedTables = array();
731 $status = true;
732
733 foreach ($allTables as $table) {
734 $query = $sgdb->query("SELECT count(*) as isExists
735 FROM information_schema.TABLES
736 WHERE (TABLE_SCHEMA = '".DB_NAME."') AND (TABLE_NAME = '$table')"
737 );
738
739 if (empty($query[0]['isExists'])) {
740 $status = false;
741 }
742 }
743
744 return $status;
745 }
746
747 function backupGuardIncludeFile($filePath)
748 {
749 if (file_exists($filePath)) {
750 include_once($filePath);
751 }
752 }
753