2016-08-08 12:31:19 +00:00
|
|
|
<?php
|
2018-05-29 19:16:40 +00:00
|
|
|
|
2023-03-22 19:39:00 +00:00
|
|
|
require_once 'includes/functions.php';
|
2020-02-14 02:38:46 +00:00
|
|
|
require_once 'config.php';
|
2016-08-08 12:38:15 +00:00
|
|
|
|
2016-08-08 12:31:19 +00:00
|
|
|
/**
|
2018-05-29 19:16:40 +00:00
|
|
|
*
|
|
|
|
*/
|
2023-03-22 19:39:00 +00:00
|
|
|
function DisplaySystem(&$extraFooterScripts)
|
2019-04-10 08:37:35 +00:00
|
|
|
{
|
2023-09-16 09:46:11 +00:00
|
|
|
$status = new \RaspAP\Messages\StatusMessage;
|
2019-08-18 22:29:46 +00:00
|
|
|
|
2019-04-10 08:37:35 +00:00
|
|
|
if (isset($_POST['SaveLanguage'])) {
|
2019-07-30 15:05:41 +00:00
|
|
|
if (isset($_POST['locale'])) {
|
|
|
|
$_SESSION['locale'] = $_POST['locale'];
|
|
|
|
$status->addMessage('Language setting saved', 'success');
|
2019-04-10 08:37:35 +00:00
|
|
|
}
|
2018-05-29 19:16:40 +00:00
|
|
|
}
|
|
|
|
|
2020-02-14 02:38:46 +00:00
|
|
|
if (!RASPI_MONITOR_ENABLED) {
|
2020-07-29 14:52:31 +00:00
|
|
|
if (isset($_POST['SaveServerSettings'])) {
|
2020-08-05 17:57:42 +00:00
|
|
|
$good_input = true;
|
|
|
|
// Validate server port
|
2020-02-14 02:38:46 +00:00
|
|
|
if (isset($_POST['serverPort'])) {
|
|
|
|
if (strlen($_POST['serverPort']) > 4 || !is_numeric($_POST['serverPort'])) {
|
|
|
|
$status->addMessage('Invalid value for port number', 'danger');
|
2020-08-05 17:57:42 +00:00
|
|
|
$good_input = false;
|
2020-02-14 02:38:46 +00:00
|
|
|
} else {
|
|
|
|
$serverPort = escapeshellarg($_POST['serverPort']);
|
2020-08-05 17:57:42 +00:00
|
|
|
}
|
2019-11-10 22:10:49 +00:00
|
|
|
}
|
2020-08-05 17:57:42 +00:00
|
|
|
// Validate server bind address
|
|
|
|
$serverBind = escapeshellarg('');
|
|
|
|
if ($_POST['serverBind'] && $_POST['serverBind'] !== null ) {
|
2020-07-29 14:52:31 +00:00
|
|
|
if (!filter_var($_POST['serverBind'], FILTER_VALIDATE_IP)) {
|
|
|
|
$status->addMessage('Invalid value for bind address', 'danger');
|
2020-08-05 17:57:42 +00:00
|
|
|
$good_input = false;
|
2020-07-29 14:52:31 +00:00
|
|
|
} else {
|
|
|
|
$serverBind = escapeshellarg($_POST['serverBind']);
|
|
|
|
}
|
|
|
|
}
|
2023-11-28 10:03:58 +00:00
|
|
|
// Validate log limit
|
|
|
|
if (isset($_POST['logLimit'])) {
|
|
|
|
if ( strlen($_POST['logLimit']) > 4 || !is_numeric($_POST['logLimit']) ) {
|
|
|
|
$status->addMessage('Invalid value for log size limit', 'danger');
|
|
|
|
$good_input = false;
|
|
|
|
} else {
|
|
|
|
$_SESSION['log_limit'] = intval($_POST['logLimit']);
|
|
|
|
$status->addMessage(sprintf(_('Changing log limit size to %s KB'), $_SESSION['log_limit']), 'info');
|
|
|
|
}
|
|
|
|
}
|
2020-08-05 17:57:42 +00:00
|
|
|
// Save settings
|
|
|
|
if ($good_input) {
|
|
|
|
exec("sudo /etc/raspap/lighttpd/configport.sh $serverPort $serverBind " .RASPI_LIGHTTPD_CONFIG. " ".$_SERVER['SERVER_NAME'], $return);
|
|
|
|
foreach ($return as $line) {
|
|
|
|
$status->addMessage($line, 'info');
|
|
|
|
}
|
|
|
|
}
|
2019-11-10 22:10:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-11 13:35:48 +00:00
|
|
|
if (isset($_POST['RestartLighttpd'])) {
|
2020-02-15 17:57:46 +00:00
|
|
|
$status->addMessage('Restarting lighttpd in 3 seconds...', 'info');
|
2019-11-11 13:35:48 +00:00
|
|
|
exec('sudo /etc/raspap/lighttpd/configport.sh --restart');
|
|
|
|
}
|
2019-11-10 22:10:49 +00:00
|
|
|
exec('cat '. RASPI_LIGHTTPD_CONFIG, $return);
|
|
|
|
$conf = ParseConfig($return);
|
2020-07-29 14:52:31 +00:00
|
|
|
$serverPort = $conf['server.port'];
|
2023-09-06 10:25:39 +00:00
|
|
|
if (isset($conf['server.bind'])) {
|
|
|
|
$serverBind = str_replace('"', '',$conf['server.bind']);
|
|
|
|
} else {
|
|
|
|
$serverBind = '';
|
|
|
|
}
|
2019-11-10 22:10:49 +00:00
|
|
|
|
2019-04-10 08:37:35 +00:00
|
|
|
// define locales
|
2023-03-22 19:39:00 +00:00
|
|
|
$arrLocales = getLocales();
|
2019-04-10 08:37:35 +00:00
|
|
|
|
2023-09-16 08:43:05 +00:00
|
|
|
// fetch system status variables
|
2021-08-03 14:18:36 +00:00
|
|
|
$system = new \RaspAP\System\Sysinfo;
|
2021-02-02 12:26:14 +00:00
|
|
|
|
|
|
|
$hostname = $system->hostname();
|
|
|
|
$uptime = $system->uptime();
|
|
|
|
$cores = $system->processorCount();
|
2022-06-08 17:22:52 +00:00
|
|
|
$os = $system->operatingSystem();
|
|
|
|
$kernel = $system->kernelVersion();
|
2023-06-04 15:27:54 +00:00
|
|
|
$systime = $system->systime();
|
2023-09-16 08:43:05 +00:00
|
|
|
$revision = $system->rpiRevision();
|
|
|
|
|
2021-02-02 12:26:14 +00:00
|
|
|
// mem used
|
|
|
|
$memused = $system->usedMemory();
|
|
|
|
$memused_status = "primary";
|
|
|
|
if ($memused > 90) {
|
|
|
|
$memused_status = "danger";
|
|
|
|
$memused_led = "service-status-down";
|
|
|
|
} elseif ($memused > 75) {
|
|
|
|
$memused_status = "warning";
|
|
|
|
$memused_led = "service-status-warn";
|
|
|
|
} elseif ($memused > 0) {
|
|
|
|
$memused_status = "success";
|
|
|
|
$memused_led = "service-status-up";
|
|
|
|
}
|
|
|
|
|
|
|
|
// cpu load
|
|
|
|
$cpuload = $system->systemLoadPercentage();
|
|
|
|
if ($cpuload > 90) {
|
|
|
|
$cpuload_status = "danger";
|
|
|
|
} elseif ($cpuload > 75) {
|
|
|
|
$cpuload_status = "warning";
|
|
|
|
} elseif ($cpuload >= 0) {
|
|
|
|
$cpuload_status = "success";
|
|
|
|
}
|
|
|
|
|
|
|
|
// cpu temp
|
|
|
|
$cputemp = $system->systemTemperature();
|
|
|
|
if ($cputemp > 70) {
|
|
|
|
$cputemp_status = "danger";
|
|
|
|
$cputemp_led = "service-status-down";
|
|
|
|
} elseif ($cputemp > 50) {
|
|
|
|
$cputemp_status = "warning";
|
|
|
|
$cputemp_led = "service-status-warn";
|
|
|
|
} else {
|
|
|
|
$cputemp_status = "success";
|
|
|
|
$cputemp_led = "service-status-up";
|
|
|
|
}
|
|
|
|
|
|
|
|
// hostapd status
|
|
|
|
$hostapd = $system->hostapdStatus();
|
|
|
|
if ($hostapd[0] == 1) {
|
|
|
|
$hostapd_status = "active";
|
|
|
|
$hostapd_led = "service-status-up";
|
|
|
|
} else {
|
|
|
|
$hostapd_status = "inactive";
|
|
|
|
$hostapd_led = "service-status-down";
|
|
|
|
}
|
|
|
|
|
2023-03-22 19:39:00 +00:00
|
|
|
// theme options
|
|
|
|
$themes = [
|
|
|
|
"default" => "RaspAP (default)",
|
2023-08-07 10:14:53 +00:00
|
|
|
"hackernews" => "HackerNews",
|
2023-03-22 19:39:00 +00:00
|
|
|
];
|
|
|
|
$themeFiles = [
|
|
|
|
"default" => "custom.php",
|
2023-08-07 10:14:53 +00:00
|
|
|
"hackernews" => "hackernews.css",
|
2023-03-22 19:39:00 +00:00
|
|
|
];
|
|
|
|
$selectedTheme = array_search($_COOKIE['theme'], $themeFiles);
|
|
|
|
$extraFooterScripts[] = array('src'=>'dist/huebee/huebee.pkgd.min.js', 'defer'=>false);
|
|
|
|
$extraFooterScripts[] = array('src'=>'app/js/huebee.js', 'defer'=>false);
|
2023-11-28 10:03:58 +00:00
|
|
|
$logLimit = isset($_SESSION['log_limit']) ? $_SESSION['log_limit'] : RASPI_LOG_SIZE_LIMIT;
|
2023-03-22 19:39:00 +00:00
|
|
|
|
2021-02-02 12:26:14 +00:00
|
|
|
echo renderTemplate("system", compact(
|
|
|
|
"arrLocales",
|
|
|
|
"status",
|
|
|
|
"serverPort",
|
|
|
|
"serverBind",
|
|
|
|
"hostname",
|
|
|
|
"uptime",
|
2023-06-04 15:27:54 +00:00
|
|
|
"systime",
|
2023-09-16 08:43:05 +00:00
|
|
|
"revision",
|
2021-02-02 12:26:14 +00:00
|
|
|
"cores",
|
2022-06-08 17:22:52 +00:00
|
|
|
"os",
|
|
|
|
"kernel",
|
2021-02-02 12:26:14 +00:00
|
|
|
"memused",
|
|
|
|
"memused_status",
|
|
|
|
"memused_led",
|
|
|
|
"cpuload",
|
|
|
|
"cpuload_status",
|
|
|
|
"cputemp",
|
|
|
|
"cputemp_status",
|
|
|
|
"cputemp_led",
|
|
|
|
"hostapd",
|
|
|
|
"hostapd_status",
|
2023-03-22 19:39:00 +00:00
|
|
|
"hostapd_led",
|
|
|
|
"themes",
|
2023-11-28 10:03:58 +00:00
|
|
|
"selectedTheme",
|
|
|
|
"logLimit"
|
2021-02-02 12:26:14 +00:00
|
|
|
));
|
2016-08-08 12:31:19 +00:00
|
|
|
}
|