.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
2 weeks 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
GetLog.php
62 lines
| 1 | <?php |
| 2 | |
| 3 | namespace JetBackup\Ajax\Calls; |
| 4 | |
| 5 | if (!defined( '__JETBACKUP__')) die('Direct access is not allowed'); |
| 6 | |
| 7 | use JetBackup\Ajax\aAjax; |
| 8 | use JetBackup\Entities\Util; |
| 9 | use JetBackup\Exception\AjaxException; |
| 10 | use JetBackup\Exception\DBException; |
| 11 | use JetBackup\Queue\QueueItem; |
| 12 | use JetBackup\UserInput\UserInput; |
| 13 | use JetBackup\Web\File\FileException; |
| 14 | use JetBackup\Web\File\FileStream; |
| 15 | use SleekDB\Exceptions\InvalidArgumentException; |
| 16 | use SleekDB\Exceptions\IOException; |
| 17 | |
| 18 | class GetLog extends aAjax { |
| 19 | /** |
| 20 | * @return int |
| 21 | * @throws AjaxException |
| 22 | */ |
| 23 | private function _getQueueItemId():int { return $this->getUserInput('queue_item_id', 0, UserInput::UINT); } |
| 24 | |
| 25 | /** |
| 26 | * @return bool |
| 27 | * @throws AjaxException |
| 28 | */ |
| 29 | private function _getQueueItemContent():bool { return $this->getUserInput('content', false, UserInput::BOOL); } |
| 30 | |
| 31 | /** |
| 32 | * @return void |
| 33 | * @throws AjaxException |
| 34 | * @throws DBException |
| 35 | * @throws FileException |
| 36 | * @throws IOException |
| 37 | * @throws InvalidArgumentException |
| 38 | */ |
| 39 | public function execute(): void { |
| 40 | if (!$this->_getQueueItemId()) throw new AjaxException("No queue item ID provided"); |
| 41 | |
| 42 | $queue_item = new QueueItem($this->_getQueueItemId()); |
| 43 | if (!$queue_item->getId()) throw new AjaxException('The provided queue item id not found'); |
| 44 | |
| 45 | $logFile = $queue_item->getLogFile(); |
| 46 | if (!file_exists($logFile) || !is_readable($logFile)) throw new AjaxException("Log file not found or not readable"); |
| 47 | |
| 48 | $stream = new FileStream($logFile); |
| 49 | |
| 50 | $output = [ |
| 51 | 'path' => $logFile, |
| 52 | 'size' => Util::bytesToHumanReadable($stream->getSize()), |
| 53 | 'type' => $stream->getMimeType(), |
| 54 | ]; |
| 55 | |
| 56 | if($this->_getQueueItemContent()) $output['content'] = $stream->read(); |
| 57 | $this->setResponseData($output); |
| 58 | $stream->close(); |
| 59 | |
| 60 | } |
| 61 | |
| 62 | } |