|
8 | 8 | * License: GNU/GPLv2
|
9 | 9 | * @see LICENSE.txt
|
10 | 10 | *
|
11 |
| - * This file: The logs page (last modified: 2023.12.13). |
| 11 | + * This file: The logs page (last modified: 2025.04.24). |
12 | 12 | */
|
13 | 13 |
|
14 | 14 | namespace phpMussel\FrontEnd;
|
|
26 | 26 | /** Initialise array for fetching logs data. */
|
27 | 27 | $FE['LogFiles'] = ['Files' => $this->logsRecursiveList(), 'Out' => ''];
|
28 | 28 |
|
| 29 | +/** Download a log file. */ |
| 30 | +if ( |
| 31 | + isset($this->QueryVariables['text-mode'], $this->QueryVariables['logfile']) && |
| 32 | + $this->QueryVariables['text-mode'] === 'download' && |
| 33 | + isset($FE['LogFiles']['Files'][$this->QueryVariables['logfile']]) |
| 34 | +) { |
| 35 | + header('Content-Type: application/octet-stream'); |
| 36 | + header('Content-Transfer-Encoding: Binary'); |
| 37 | + header('Content-disposition: attachment; filename="' . basename($this->QueryVariables['logfile']) . '"'); |
| 38 | + echo $this->Loader->readFile($this->Vault . $this->QueryVariables['logfile']); |
| 39 | + return; |
| 40 | +} |
| 41 | + |
29 | 42 | /** Text mode switch link base. */
|
30 | 43 | $FE['TextModeSwitchLink'] = '';
|
31 | 44 |
|
|
83 | 96 | $this->formatter($FE['logfileData']);
|
84 | 97 | }
|
85 | 98 |
|
86 |
| -/** Process logs list. */ |
| 99 | +$DownloadLabel = $this->Loader->L10N->getString('field.Download'); |
| 100 | + |
| 101 | +/** Generate a list of the logs. */ |
87 | 102 | foreach ($FE['LogFiles']['Files'] as $Filename => $Filesize) {
|
88 | 103 | $FE['LogFiles']['Out'] .= sprintf(
|
89 |
| - ' <a href="?phpmussel-page=logs&logfile=%1$s&text-mode=%3$s">%1$s</a> – %2$s<br />', |
| 104 | + ' <a href="?phpmussel-page=logs&logfile=%1$s&text-mode=%3$s">%1$s</a> – %2$s <a title="%4$s" href="?phpmussel-page=logs&logfile=%1$s&text-mode=download"><span class="navicon download"></span></a><br />', |
90 | 105 | $Filename ?? '',
|
91 | 106 | $Filesize ?? '',
|
92 |
| - $FE['TextModeLinks'] ?? '' |
| 107 | + $FE['TextModeLinks'] ?? '', |
| 108 | + $DownloadLabel |
93 | 109 | ) . "\n";
|
94 | 110 | }
|
| 111 | +unset($Filesize, $Filename, $DownloadLabel); |
95 | 112 |
|
96 | 113 | /** Calculate page load time (useful for debugging). */
|
97 | 114 | $FE['ProcessTime'] = microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'];
|
|
0 commit comments