PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 3.1.18.8
JetBackup – Backup, Restore & Migrate v3.1.18.8
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 / src / JetBackup / Settings / Security.php
backup / src / JetBackup / Settings Last commit date
.htaccess 5 months ago Automation.php 5 months ago General.php 5 months ago Integrations.php 5 months ago Logging.php 5 months ago Maintenance.php 5 months ago Notifications.php 5 months ago Performance.php 5 months ago Restore.php 5 months ago Security.php 5 months ago Settings.php 5 months ago Updates.php 5 months ago index.html 5 months ago web.config 5 months ago
Security.php
95 lines
1 <?php
2
3 namespace JetBackup\Settings;
4
5 use JetBackup\Config\Config;
6 use JetBackup\Config\System;
7 use JetBackup\Exception\AjaxException;
8 use JetBackup\Exception\FieldsValidationException;
9 use JetBackup\Exception\IOException;
10 use JetBackup\Factory;
11 use JetBackup\MFA\GoogleAuthenticator;
12 use JetBackup\Wordpress\UI;
13 use ReflectionException;
14
15 if (!defined( '__JETBACKUP__')) die('Direct access is not allowed');
16
17 class Security extends Settings {
18
19 const SECTION = 'security';
20
21 const MFA_ENABLED = 'MFA_ENABLED';
22 const MFA_ALLOW_CLI = 'MFA_ALLOW_CLI';
23 const DAILY_CHECKSUM_CHECK = 'DAILY_CHECKSUM_CHECK';
24 const DATADIR_SECURED = 'SECURITY_DATADIR_SECURED';
25 const DATADIR_RECOMMENDED = 'SECURITY_DATADIR_RECOMMENDED';
26
27 /**
28 * @throws IOException
29 * @throws ReflectionException
30 */
31 public function __construct() {
32 parent::__construct(self::SECTION);
33 }
34
35 /**
36 * @return bool
37 */
38 public function isMFAEnabled():bool { return (bool) $this->get(self::MFA_ENABLED, false); }
39 public function isMFAAllowCLI():bool { return (bool) $this->get(self::MFA_ALLOW_CLI, false); }
40
41 /**
42 * @param bool $value
43 *
44 * @return void
45 */
46 public function setMFAEnabled(bool $value):void { $this->set(self::MFA_ENABLED,$value); }
47 public function setMFAAllowCLI(bool $value):void { $this->set(self::MFA_ALLOW_CLI,$value); }
48
49 /**
50 * @return bool
51 */
52 public function isValidateChecksumsEnabled():bool { return (bool) $this->get(self::DAILY_CHECKSUM_CHECK, false); }
53
54 /**
55 * @param bool $value
56 *
57 * @return void
58 */
59 public function setValidateChecksumsEnabled(bool $value):void { $this->set(self::DAILY_CHECKSUM_CHECK, $value); }
60
61 /**
62 * @return array
63 */
64 public function getDisplay():array {
65 return [
66 self::DATADIR_SECURED => System::isDataDirSecured() ? 1 : 0,
67 self::DATADIR_RECOMMENDED => System::getRecommendSecurePath(),
68 self::MFA_ENABLED => $this->isMFAEnabled() ? 1 : 0,
69 self::MFA_ALLOW_CLI => $this->isMFAAllowCLI() ? 1 : 0,
70 Config::ALTERNATE_DATA_FOLDER => Factory::getConfig()->getAlternateDataFolder(),
71 self::DAILY_CHECKSUM_CHECK => $this->isValidateChecksumsEnabled() ? 1 : 0,
72 ];
73 }
74
75 /**
76 * @return array
77 */
78 public function getDisplayCLI():array {
79 return [
80 'MFA Enabled' => $this->isMFAEnabled() ? "Yes" : "No",
81 'MFA Allow CLI' => $this->isMFAAllowCLI() ? "Yes" : "No",
82 'Alternate Data Directory' => Factory::getConfig()->getAlternateDataFolder(),
83 'Validate System Files Checksums' => $this->isValidateChecksumsEnabled() ? "Yes" : "No",
84 ];
85 }
86
87 /**
88 */
89 public function validateFields():void {}
90
91 public function save(): void {
92 if (!$this->isMFAEnabled()) GoogleAuthenticator::clearCookie();
93 parent::save();
94 }
95 }