/** * @ControllerManaged */ protected function getLogFileContent() { $lines = $this->tailFile(); $wrappedLines = array(); $maxWidth = $this->configService->getDisplayWidth(); foreach ($lines as $line) { // Get rid of "Could not create directory '/var/www/.ssh'." if (preg_match("/\\.ssh'\\./", $line)) { continue; } while (strlen($line) > $maxWidth) { $wrappedLines[] = substr($line, 0, $maxWidth) . "\n"; $line = substr($line, $maxWidth); } $wrappedLines[] = $line . "\n"; } $data = ''; $linesToDisplay = array_slice($wrappedLines, 0, $this->configService->getNumberOfLinesToDisplay()); $increment = count($linesToDisplay) > 0 ? intval(200 / count($linesToDisplay)) : 0; $colorCode = 0; foreach ($linesToDisplay as $line) { $colorCodeHex = dechex($colorCode); if (strlen($colorCodeHex) == 1) { $colorCodeHex = "0" . $colorCodeHex; } $data .= "<font color=\"#{$colorCodeHex}{$colorCodeHex}{$colorCodeHex}\">" . str_replace("\n", '<br>', htmlentities($line)) . '</font>'; $colorCode += $increment; } return array('html' => $data, 'backupExecutingOrWaitingForRun' => $this->backupService->isExecutingOrWaitingForRun(), 'lastBackupHtml' => $this->renderHtml('lastbackup.inc', array('lastBackupSuccessful' => $this->backupService->isLastBackupSuccessful(), 'lastBackupTime' => $this->backupService->getLastBackupTime()))); }
private function createParameters($subTemplate) { $parameters = array('statusContainer' => $this->getStatusContainer(), 'userName' => $this->configService->getHostUserName(), 'keyUploadUrl' => $this->urlGenerator->linkToRoute('easybackup.config.uploadSshKey'), 'schedule' => $this->scheduleService, 'scheduleTime' => $this->configService->getScheduleTime(), 'isScheduled' => $this->configService->isBackupScheduled(), 'configurationUrl' => $this->urlGenerator->linkToRoute('easybackup.page.configuration'), 'backupUrl' => $this->urlGenerator->linkToRoute('easybackup.page.backup'), 'restoreUrl' => $this->urlGenerator->linkToRoute('easybackup.page.restore'), 'logfileUrl' => $this->urlGenerator->linkToRoute('easybackup.logfileview.getCompleteLogfile'), 'subTemplate' => $subTemplate, 'publicKey' => $this->configService->getPublicKey(), 'isExecuting' => $this->backupService->isExecutingOrWaitingForRun(), 'lastBackupSuccessful' => $this->backupService->isLastBackupSuccessful(), 'lastBackupTime' => $this->backupService->getLastBackupTime()); return $parameters; }