1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00
raspap-webgui/includes/system.php

131 lines
4.3 KiB
PHP
Raw Normal View History

2016-08-08 14:31:19 +02:00
<?php
2018-05-29 21:16:40 +02:00
2020-02-15 18:57:46 +01:00
require_once 'includes/status_messages.php';
require_once 'config.php';
2018-05-29 21:16:40 +02:00
2016-08-08 14:38:15 +02:00
/**
2018-05-29 21:16:40 +02:00
* Find the version of the Raspberry Pi
* Currently only used for the system information page but may useful elsewhere
*/
2016-08-08 14:38:15 +02:00
function RPiVersion()
{
// Lookup table from http://www.raspberrypi-spy.co.uk/2012/09/checking-your-raspberry-pi-board-version/
$revisions = array(
2016-08-08 14:38:15 +02:00
'0002' => 'Model B Revision 1.0',
'0003' => 'Model B Revision 1.0 + ECN0001',
'0004' => 'Model B Revision 2.0 (256 MB)',
'0005' => 'Model B Revision 2.0 (256 MB)',
'0006' => 'Model B Revision 2.0 (256 MB)',
'0007' => 'Model A',
'0008' => 'Model A',
'0009' => 'Model A',
'000d' => 'Model B Revision 2.0 (512 MB)',
'000e' => 'Model B Revision 2.0 (512 MB)',
'000f' => 'Model B Revision 2.0 (512 MB)',
'0010' => 'Model B+',
'0013' => 'Model B+',
'0011' => 'Compute Module',
'0012' => 'Model A+',
'a01041' => 'a01041',
'a21041' => 'a21041',
'900092' => 'PiZero 1.2',
'900093' => 'PiZero 1.3',
2017-05-19 15:44:51 +02:00
'9000c1' => 'PiZero W',
2016-08-08 14:38:15 +02:00
'a02082' => 'Pi 3 Model B',
2019-02-04 18:08:10 +01:00
'a22082' => 'Pi 3 Model B',
'a32082' => 'Pi 3 Model B',
'a52082' => 'Pi 3 Model B',
'a020d3' => 'Pi 3 Model B+',
'a220a0' => 'Compute Module 3',
'a020a0' => 'Compute Module 3',
'a02100' => 'Compute Module 3+',
2019-12-27 01:50:53 +01:00
'a03111' => 'Model 4B Revision 1.1 (1 GB)',
'b03111' => 'Model 4B Revision 1.1 (2 GB)',
'c03111' => 'Model 4B Revision 1.1 (4 GB)'
);
$cpuinfo_array = '';
exec('cat /proc/cpuinfo', $cpuinfo_array);
$rev = trim(array_pop(explode(':', array_pop(preg_grep("/^Revision/", $cpuinfo_array)))));
if (array_key_exists($rev, $revisions)) {
return $revisions[$rev];
} else {
return 'Unknown Pi';
}
2016-08-08 14:38:15 +02:00
}
2016-08-08 14:31:19 +02:00
/**
2018-05-29 21:16:40 +02:00
*
*
*/
function DisplaySystem()
{
$status = new StatusMessages();
2019-08-19 00:29:46 +02:00
if (isset($_POST['SaveLanguage'])) {
if (isset($_POST['locale'])) {
$_SESSION['locale'] = $_POST['locale'];
$status->addMessage('Language setting saved', 'success');
}
2018-05-29 21:16:40 +02:00
}
if (!RASPI_MONITOR_ENABLED) {
if (isset($_POST['SaveServerPort'])) {
if (isset($_POST['serverPort'])) {
if (strlen($_POST['serverPort']) > 4 || !is_numeric($_POST['serverPort'])) {
$status->addMessage('Invalid value for port number', 'danger');
} else {
$serverPort = escapeshellarg($_POST['serverPort']);
exec("sudo /etc/raspap/lighttpd/configport.sh $serverPort " .RASPI_LIGHTTPD_CONFIG. " ".$_SERVER['SERVER_NAME'], $return);
foreach ($return as $line) {
$status->addMessage($line, 'info');
}
}
}
}
if (isset($_POST['system_reboot'])) {
$status->addMessage("System Rebooting Now!", "warning", false);
$result = shell_exec("sudo /sbin/reboot");
}
if (isset($_POST['system_shutdown'])) {
$status->addMessage("System Shutting Down Now!", "warning", false);
$result = shell_exec("sudo /sbin/shutdown -h now");
}
}
2019-11-11 14:35:48 +01:00
if (isset($_POST['RestartLighttpd'])) {
2020-02-15 18:57:46 +01:00
$status->addMessage('Restarting lighttpd in 3 seconds...', 'info');
2019-11-11 14:35:48 +01:00
exec('sudo /etc/raspap/lighttpd/configport.sh --restart');
}
exec('cat '. RASPI_LIGHTTPD_CONFIG, $return);
$conf = ParseConfig($return);
$ServerPort = $conf['server.port'];
// define locales
$arrLocales = array(
'en_GB.UTF-8' => 'English',
'de_DE.UTF-8' => 'Deutsch',
'fr_FR.UTF-8' => 'Français',
'it_IT.UTF-8' => 'Italiano',
'pt_BR.UTF-8' => 'Português',
'sv_SE.UTF-8' => 'Svenska',
'nl_NL.UTF-8' => 'Nederlands',
'zh_CN.UTF-8' => '简体中文 (Chinese simplified)',
'id_ID.UTF-8' => 'Indonesian',
'ko_KR.UTF-8' => '한국어 (Korean)',
'ja_JP.UTF-8' => '日本語 (Japanese)',
'vi_VN.UTF-8' => 'Tiếng Việt',
'cs_CZ.UTF-8' => 'Čeština',
'ru_RU.UTF-8' => 'Русский',
'es_MX.UTF-8' => 'Español',
'fi_FI.UTF-8' => 'Finnish',
'da_DK.UTF-8' => 'Danish',
'tr_TR.UTF-8' => 'Türkçe',
'el_GR.UTF-8' => 'Ελληνικά'
);
echo renderTemplate("system", compact("arrLocales", "status", "system", "ServerPort"));
2016-08-08 14:31:19 +02:00
}