]> git.mxchange.org Git - friendica.git/blob - src/Module/Admin/Logs/View.php
Remove join profile table
[friendica.git] / src / Module / Admin / Logs / View.php
1 <?php
2
3 namespace Friendica\Module\Admin\Logs;
4
5 use Friendica\Core\Renderer;
6 use Friendica\DI;
7 use Friendica\Module\BaseAdmin;
8 use Friendica\Util\Strings;
9
10 class View extends BaseAdmin
11 {
12         public static function content(array $parameters = [])
13         {
14                 parent::content($parameters);
15
16                 $t = Renderer::getMarkupTemplate('admin/logs/view.tpl');
17                 $f = DI::config()->get('system', 'logfile');
18                 $data = '';
19
20                 if (!file_exists($f)) {
21                         $data = DI::l10n()->t('Error trying to open <strong>%1$s</strong> log file.\r\n<br/>Check to see if file %1$s exist and is readable.', $f);
22                 } else {
23                         $fp = fopen($f, 'r');
24                         if (!$fp) {
25                                 $data = DI::l10n()->t('Couldn\'t open <strong>%1$s</strong> log file.\r\n<br/>Check to see if file %1$s is readable.', $f);
26                         } else {
27                                 $fstat = fstat($fp);
28                                 $size = $fstat['size'];
29                                 if ($size != 0) {
30                                         if ($size > 5000000 || $size < 0) {
31                                                 $size = 5000000;
32                                         }
33                                         $seek = fseek($fp, 0 - $size, SEEK_END);
34                                         if ($seek === 0) {
35                                                 $data = Strings::escapeHtml(fread($fp, $size));
36                                                 while (!feof($fp)) {
37                                                         $data .= Strings::escapeHtml(fread($fp, 4096));
38                                                 }
39                                         }
40                                 }
41                                 fclose($fp);
42                         }
43                 }
44                 return Renderer::replaceMacros($t, [
45                         '$title' => DI::l10n()->t('Administration'),
46                         '$page' => DI::l10n()->t('View Logs'),
47                         '$data' => $data,
48                         '$logname' => DI::config()->get('system', 'logfile')
49                 ]);
50         }
51 }