PHP_SMART_HOME_V3/app/views/Log.php

62 lines
1.3 KiB
PHP
Raw Normal View History

2019-09-01 13:55:33 +00:00
<?php
class Log extends Template
{
2020-04-28 13:17:14 +00:00
//TODO: to server manager
function getSystemMemInfo()
{
$data = explode("\n", file_get_contents("/proc/meminfo"));
$meminfo = array();
foreach ($data as $line) {
$data = explode(":", $line);
if (count($data)!=2) continue;
$meminfo[$data[0]] = trim($data[1]);
}
return $meminfo;
}
2019-09-01 13:55:33 +00:00
function __construct()
{
global $userManager;
2019-10-11 12:12:05 +00:00
global $langMng;
2019-09-01 13:55:33 +00:00
if (!$userManager->isLogin()){
2020-04-28 09:52:14 +00:00
header('Location: ' . BASEURL . 'login');
2019-09-01 13:55:33 +00:00
}
$template = new Template('log');
$template->prepare('title', 'Log');
$result = array();
2020-04-28 09:52:14 +00:00
$cdir = scandir('../logs/');
2019-09-01 13:55:33 +00:00
foreach ($cdir as $key => $value)
{
if (!in_array($value,array(".","..", ".gitkeep")))
2019-09-01 13:55:33 +00:00
{
$result[$value] = $value;
}
}
2019-10-11 14:38:20 +00:00
$template->prepare('baseDir', BASEDIR);
2020-02-18 20:30:44 +00:00
$template->prepare('debugMod', DEBUGMOD);
$template->prepare('logToLiveTime', LOGTIMOUT);
2019-10-11 14:38:20 +00:00
$template->prepare('title', 'Logy');
2019-09-01 13:55:33 +00:00
$template->prepare('logsFiles', $result);
2019-10-11 12:12:05 +00:00
$template->prepare('langMng', $langMng);
2020-04-28 13:17:14 +00:00
$template->prepare('CPU', sys_getloadavg()[0]);
$template->prepare('UPTIME', shell_exec('uptime -p'));
$template->prepare('ramFree', $this->getSystemMemInfo()["MemFree"]);
$template->prepare('ramTotal', $this->getSystemMemInfo()["MemTotal"]);
$template->prepare('diskTotal', disk_total_space("/"));
2019-09-01 13:55:33 +00:00
$template->render();
}
}