getUserInput('queue_item_id', 0, UserInput::UINT); } /** * @return bool * @throws AjaxException */ private function _getQueueItemContent():bool { return $this->getUserInput('content', false, UserInput::BOOL); } /** * @return void * @throws AjaxException * @throws DBException * @throws FileException * @throws IOException * @throws InvalidArgumentException */ public function execute(): void { if (!$this->_getQueueItemId()) throw new AjaxException("No queue item ID provided"); $queue_item = new QueueItem($this->_getQueueItemId()); if (!$queue_item->getId()) throw new AjaxException('The provided queue item id not found'); $logFile = $queue_item->getLogFile(); if (!file_exists($logFile) || !is_readable($logFile)) throw new AjaxException("Log file not found or not readable"); $stream = new FileStream($logFile); $output = [ 'path' => $logFile, 'size' => Util::bytesToHumanReadable($stream->getSize()), 'type' => $stream->getMimeType(), ]; if($this->_getQueueItemContent()) $output['content'] = $stream->read(); $this->setResponseData($output); $stream->close(); } }