.htaccess
1 year ago
AbortQueueItem.php
1 year ago
AddToQueue.php
3 months ago
ClearAlerts.php
1 year ago
ClearCompletedQueueItems.php
1 year ago
CreateSupportUser.php
1 year ago
DeleteBackupJob.php
1 year ago
DeleteDestination.php
1 year ago
DeleteDownload.php
1 year ago
DeleteSchedule.php
1 year ago
DeleteSnapshot.php
1 year ago
DestinationSetExportConfig.php
1 year ago
DuplicateBackupJob.php
1 year ago
EditBackupNotes.php
1 year ago
EnableBackupJob.php
1 year ago
EnableDestination.php
1 year ago
ExecuteCron.php
1 year ago
FileManager.php
10 months ago
GetBackup.php
1 year ago
GetBackupJob.php
1 year ago
GetDashboard.php
1 year ago
GetDatabaseTables.php
1 year ago
GetDestination.php
1 year ago
GetLog.php
1 year ago
GetQRCode.php
1 year ago
GetQueueItem.php
1 year ago
GetSchedule.php
1 year ago
GetSettingsAutomation.php
1 year ago
GetSettingsGeneral.php
1 year ago
GetSettingsIntegrations.php
1 year ago
GetSettingsLogging.php
1 year ago
GetSettingsMaintenance.php
1 year ago
GetSettingsNotifications.php
1 year ago
GetSettingsPerformance.php
1 year ago
GetSettingsRestore.php
1 year ago
GetSettingsSecurity.php
1 year ago
GetSettingsUpdates.php
1 year ago
GetSystemInfo.php
11 months ago
ListAlerts.php
1 year ago
ListBackupJobs.php
1 year ago
ListBackups.php
1 year ago
ListDatabaseTables.php
1 year ago
ListDestinations.php
1 year ago
ListDownloads.php
1 year ago
ListQueueItems.php
4 months ago
ListSchedules.php
1 year ago
LockSnapshot.php
1 year ago
ManageBackupJob.php
1 year ago
ManageDestination.php
1 year ago
ManageSchedule.php
3 months ago
ManageSettingsAutomation.php
10 months ago
ManageSettingsGeneral.php
4 months ago
ManageSettingsIntegrations.php
1 year ago
ManageSettingsLogging.php
1 year ago
ManageSettingsMaintenance.php
1 year ago
ManageSettingsNotifications.php
1 year ago
ManageSettingsPerformance.php
1 year ago
ManageSettingsRestore.php
1 year ago
ManageSettingsSecurity.php
1 week ago
ManageSettingsUpdates.php
1 year ago
ManageShowcase.php
1 year ago
PanelPreload.php
1 year ago
SendTestEmail.php
1 year ago
StartOverQueueItem.php
1 year ago
ValidateDestination.php
1 year ago
ValidateMFA.php
1 year ago
index.html
1 year ago
web.config
1 year ago
ManageSettingsSecurity.php
92 lines
| 1 | <?php |
| 2 | |
| 3 | namespace JetBackup\Ajax\Calls; |
| 4 | |
| 5 | use JetBackup\Ajax\aAjax; |
| 6 | use JetBackup\Config\Config; |
| 7 | use JetBackup\Exception\AjaxException; |
| 8 | use JetBackup\Exception\FieldsValidationException; |
| 9 | use JetBackup\Exception\IOException; |
| 10 | use JetBackup\Factory; |
| 11 | use JetBackup\JetBackup; |
| 12 | use JetBackup\Queue\Queue; |
| 13 | use JetBackup\Settings\Security; |
| 14 | use JetBackup\UserInput\UserInput; |
| 15 | use SleekDB\Exceptions\InvalidArgumentException; |
| 16 | |
| 17 | if (!defined( '__JETBACKUP__')) die('Direct access is not allowed'); |
| 18 | |
| 19 | class ManageSettingsSecurity extends aAjax { |
| 20 | |
| 21 | /** |
| 22 | * @return bool |
| 23 | * @throws AjaxException |
| 24 | */ |
| 25 | private function _getMFAEnabled(): bool { return $this->getUserInput(Security::MFA_ENABLED, false, UserInput::BOOL); } |
| 26 | |
| 27 | /** |
| 28 | * @return bool |
| 29 | * @throws AjaxException |
| 30 | */ |
| 31 | private function _getMFAAllowCLI(): bool { return $this->getUserInput(Security::MFA_ALLOW_CLI, false, UserInput::BOOL); } |
| 32 | |
| 33 | /** |
| 34 | * @return bool |
| 35 | * @throws AjaxException |
| 36 | */ |
| 37 | private function _getAbilitiesEnabled(): bool { return $this->getUserInput(Security::ABILITIES_ENABLED, false, UserInput::BOOL); } |
| 38 | |
| 39 | /** |
| 40 | * @return bool |
| 41 | * @throws AjaxException |
| 42 | */ |
| 43 | private function _getMFAAllowAbilities(): bool { return $this->getUserInput(Security::MFA_ALLOW_ABILITIES, false, UserInput::BOOL); } |
| 44 | |
| 45 | /** |
| 46 | * @return bool |
| 47 | * @throws AjaxException |
| 48 | */ |
| 49 | private function _getValidateChecksums(): bool { return $this->getUserInput(Security::DAILY_CHECKSUM_CHECK, false, UserInput::BOOL); } |
| 50 | |
| 51 | /** |
| 52 | * @return string |
| 53 | * @throws AjaxException |
| 54 | */ |
| 55 | private function _getAlternateDataFolder(): string { return $this->getUserInput(Config::ALTERNATE_DATA_FOLDER, '', UserInput::STRING); } |
| 56 | |
| 57 | /** |
| 58 | * @return void |
| 59 | * @throws AjaxException |
| 60 | * @throws FieldsValidationException |
| 61 | * @throws IOException |
| 62 | * @throws InvalidArgumentException |
| 63 | * @throws \SleekDB\Exceptions\IOException |
| 64 | */ |
| 65 | public function execute(): void { |
| 66 | |
| 67 | $settings = Factory::getSettingsSecurity(); |
| 68 | |
| 69 | if($this->isset(Security::MFA_ENABLED)) $settings->setMFAEnabled($this->_getMFAEnabled()); |
| 70 | if($this->isset(Security::MFA_ALLOW_CLI)) $settings->setMFAAllowCLI($this->_getMFAAllowCLI()); |
| 71 | if($this->isset(Security::ABILITIES_ENABLED)) $settings->setAbilitiesEnabled($this->_getAbilitiesEnabled()); |
| 72 | if($this->isset(Security::MFA_ALLOW_ABILITIES)) $settings->setMFAAllowAbilities($this->_getMFAAllowAbilities()); |
| 73 | if($this->isset(Security::DAILY_CHECKSUM_CHECK)) $settings->setValidateChecksumsEnabled($this->_getValidateChecksums()); |
| 74 | |
| 75 | $settings->validateFields(); |
| 76 | |
| 77 | if($this->isset(Config::ALTERNATE_DATA_FOLDER)) { |
| 78 | $config = Factory::getConfig(); |
| 79 | $config->setAlternateDataFolder(rtrim($this->_getAlternateDataFolder(), JetBackup::SEP)); |
| 80 | $config->validateAltDataDir(); |
| 81 | if (Queue::getTotalActiveItems() > 0) throw new fieldsValidationException("Cannot change data folder with active running queue items"); |
| 82 | $config->save(); |
| 83 | $settings->save(); |
| 84 | $config->moveDataDir(); |
| 85 | } else { |
| 86 | $settings->save(); |
| 87 | } |
| 88 | |
| 89 | $this->setResponseMessage('Saved Successfully'); |
| 90 | $this->setResponseData($this->isCLI() ? $settings->getDisplayCLI() : $settings->getDisplay()); |
| 91 | } |
| 92 | } |