Bearsampp 2025.8.29
Loading...
Searching...
No Matches
class.tpl.app.logs.php
Go to the documentation of this file.
1<?php
2/*
3 * Copyright (c) 2021-2024 Bearsampp
4 * License: GNU General Public License version 3 or later; see LICENSE.txt
5 * Author: bear
6 * Website: https://bearsampp.com
7 * Github: https://github.com/Bearsampp
8 */
9
17{
18 // Constant for the logs menu identifier
19 const MENU = 'logs';
20
31 public static function process()
32 {
33 global $bearsamppLang;
34
35 return TplApp::getMenu($bearsamppLang->getValue(Lang::LOGS), self::MENU, get_called_class());
36 }
37
48 public static function getMenuLogs()
49 {
50 global $bearsamppRoot;
51
52 $files = array();
53
54 // Open the logs directory
55 $handle = @opendir($bearsamppRoot->getLogsPath());
56 if (!$handle) {
57 return '';
58 }
59
60 // Read log files from the directory
61 while (false !== ($file = readdir($handle))) {
62 if ($file != "." && $file != ".." && Util::endWith($file, '.log')) {
63 $files[] = $file;
64 }
65 }
66
67 // Close the directory handle
68 closedir($handle);
69 ksort($files);
70
71 // Generate menu items for each log file
72 $result = '';
73 foreach ($files as $file) {
74 $result .= TplAestan::getItemNotepad(basename($file), $bearsamppRoot->getLogsPath() . '/' . $file) . PHP_EOL;
75 }
76 return $result;
77 }
78}
$result
global $bearsamppLang
global $bearsamppRoot
const LOGS
static getItemNotepad($caption, $path)
static getMenu($caption, $menu, $class)
static endWith($string, $search)