.htaccess
5 months ago
AbortQueueItem.php
5 months ago
AddToQueue.php
5 months ago
ClearAlerts.php
5 months ago
ClearCompletedQueueItems.php
5 months ago
CreateSupportUser.php
5 months ago
DeleteBackupJob.php
5 months ago
DeleteDestination.php
5 months ago
DeleteDownload.php
5 months ago
DeleteSchedule.php
5 months ago
DeleteSnapshot.php
5 months ago
DestinationSetExportConfig.php
5 months ago
DuplicateBackupJob.php
5 months ago
EditBackupNotes.php
5 months ago
EnableBackupJob.php
5 months ago
EnableDestination.php
5 months ago
ExecuteCron.php
5 months ago
FileManager.php
5 months ago
GetBackup.php
5 months ago
GetBackupJob.php
5 months ago
GetDashboard.php
5 months ago
GetDatabaseTables.php
5 months ago
GetDestination.php
5 months ago
GetLog.php
5 months ago
GetQRCode.php
5 months ago
GetQueueItem.php
5 months ago
GetSchedule.php
5 months ago
GetSettingsAutomation.php
5 months ago
GetSettingsGeneral.php
5 months ago
GetSettingsIntegrations.php
5 months ago
GetSettingsLogging.php
5 months ago
GetSettingsMaintenance.php
5 months ago
GetSettingsNotifications.php
5 months ago
GetSettingsPerformance.php
5 months ago
GetSettingsRestore.php
5 months ago
GetSettingsSecurity.php
5 months ago
GetSettingsUpdates.php
5 months ago
GetSystemInfo.php
5 months ago
ListAlerts.php
5 months ago
ListBackupJobs.php
5 months ago
ListBackups.php
5 months ago
ListDatabaseTables.php
5 months ago
ListDestinations.php
5 months ago
ListDownloads.php
5 months ago
ListQueueItems.php
5 months ago
ListSchedules.php
5 months ago
LockSnapshot.php
5 months ago
ManageBackupJob.php
5 months ago
ManageDestination.php
5 months ago
ManageSchedule.php
5 months ago
ManageSettingsAutomation.php
5 months ago
ManageSettingsGeneral.php
5 months ago
ManageSettingsIntegrations.php
5 months ago
ManageSettingsLogging.php
5 months ago
ManageSettingsMaintenance.php
5 months ago
ManageSettingsNotifications.php
5 months ago
ManageSettingsPerformance.php
5 months ago
ManageSettingsRestore.php
5 months ago
ManageSettingsSecurity.php
5 months ago
ManageSettingsUpdates.php
5 months ago
ManageShowcase.php
5 months ago
PanelPreload.php
5 months ago
SendTestEmail.php
5 months ago
StartOverQueueItem.php
5 months ago
ValidateDestination.php
5 months ago
ValidateMFA.php
5 months ago
index.html
5 months ago
web.config
5 months ago
ManageSettingsPerformance.php
94 lines
| 1 | <?php |
| 2 | |
| 3 | namespace JetBackup\Ajax\Calls; |
| 4 | |
| 5 | use JetBackup\Ajax\aAjax; |
| 6 | use JetBackup\Exception\AjaxException; |
| 7 | use JetBackup\Exception\FieldsValidationException; |
| 8 | use JetBackup\Exception\IOException; |
| 9 | use JetBackup\Factory; |
| 10 | use JetBackup\Settings\Performance; |
| 11 | use JetBackup\UserInput\UserInput; |
| 12 | use SleekDB\Exceptions\InvalidArgumentException; |
| 13 | |
| 14 | if (!defined( '__JETBACKUP__')) die('Direct access is not allowed'); |
| 15 | |
| 16 | class ManageSettingsPerformance extends aAjax { |
| 17 | |
| 18 | /** |
| 19 | * @return int |
| 20 | * @throws AjaxException |
| 21 | */ |
| 22 | private function _getReadChunkSize(): int { return $this->getUserInput(Performance::READ_CHUNK_SIZE, 0, UserInput::UINT); } |
| 23 | |
| 24 | /** |
| 25 | * @return int |
| 26 | * @throws AjaxException |
| 27 | */ |
| 28 | private function _getExecutionTime(): int { return $this->getUserInput(Performance::EXECUTION_TIME, 0, UserInput::UINT); } |
| 29 | |
| 30 | /** |
| 31 | * @return bool |
| 32 | * @throws AjaxException |
| 33 | */ |
| 34 | private function _getSQLCleanupRevisions(): bool { return $this->getUserInput(Performance::SQL_CLEANUP_REVISIONS, false, UserInput::BOOL); } |
| 35 | |
| 36 | /** |
| 37 | * @return bool |
| 38 | * @throws AjaxException |
| 39 | */ |
| 40 | private function _getUseDefaultExcludes(): bool { return $this->getUserInput(Performance::USE_DEFAULT_EXCLUDES, false, UserInput::BOOL); } |
| 41 | |
| 42 | /** |
| 43 | * @return bool |
| 44 | * @throws AjaxException |
| 45 | */ |
| 46 | private function _getExcludeNestedSites(): bool { return $this->getUserInput(Performance::EXCLUDE_NESTED_SITES, false, UserInput::BOOL); } |
| 47 | |
| 48 | /** |
| 49 | * @return bool |
| 50 | * @throws AjaxException |
| 51 | */ |
| 52 | private function _getUseDefaultDBExcludes(): bool { return $this->getUserInput(Performance::USE_DEFAULT_DB_EXCLUDES, false, UserInput::BOOL); } |
| 53 | |
| 54 | /** |
| 55 | * @return bool |
| 56 | * @throws AjaxException |
| 57 | */ |
| 58 | private function _getGzipCompressArchive(): bool { return $this->getUserInput(Performance::GZIP_COMPRESS_ARCHIVE, false, UserInput::BOOL); } |
| 59 | |
| 60 | /** |
| 61 | * @return bool |
| 62 | * @throws AjaxException |
| 63 | */ |
| 64 | private function _getGzipCompressDB(): bool { return $this->getUserInput(Performance::GZIP_COMPRESS_DB, false, UserInput::BOOL); } |
| 65 | |
| 66 | /** |
| 67 | * @return void |
| 68 | * @throws AjaxException |
| 69 | * @throws FieldsValidationException |
| 70 | * @throws \SleekDB\Exceptions\IOException |
| 71 | * @throws InvalidArgumentException |
| 72 | */ |
| 73 | public function execute(): void { |
| 74 | |
| 75 | $settings = Factory::getSettingsPerformance(); |
| 76 | |
| 77 | if($this->isset(Performance::READ_CHUNK_SIZE)) $settings->setReadChunkSize($this->_getReadChunkSize()); |
| 78 | if($this->isset(Performance::EXECUTION_TIME)) $settings->setExecutionTime($this->_getExecutionTime()); |
| 79 | if($this->isset(Performance::SQL_CLEANUP_REVISIONS)) $settings->setSQLCleanupRevisionsEnabled($this->_getSQLCleanupRevisions()); |
| 80 | if($this->isset(Performance::USE_DEFAULT_EXCLUDES)) $settings->setUseDefaultExcludes($this->_getUseDefaultExcludes()); |
| 81 | if($this->isset(Performance::EXCLUDE_NESTED_SITES)) $settings->setExcludeNestedSites($this->_getExcludeNestedSites()); |
| 82 | if($this->isset(Performance::USE_DEFAULT_DB_EXCLUDES)) $settings->setUseDefaultDBExcludes($this->_getUseDefaultDBExcludes()); |
| 83 | if($this->isset(Performance::GZIP_COMPRESS_ARCHIVE)) $settings->setGzipCompressArchive($this->_getGzipCompressArchive()); |
| 84 | if($this->isset(Performance::GZIP_COMPRESS_DB)) $settings->setGzipCompressDB($this->_getGzipCompressDB()); |
| 85 | |
| 86 | $settings->validateFields(); |
| 87 | $settings->save(); |
| 88 | |
| 89 | $this->setResponseMessage('Saved Successfully'); |
| 90 | $this->setResponseData($this->isCLI() ? $settings->getDisplayCLI() : $settings->getDisplay()); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 |