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