2016-08-08 14:31:19 +02:00
|
|
|
<?php
|
2018-05-29 21:16:40 +02:00
|
|
|
|
2019-04-10 10:37:35 +02:00
|
|
|
include_once('includes/status_messages.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
|
|
|
|
2019-04-10 10:37:35 +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',
|
2017-03-08 22:24:42 +01:00
|
|
|
'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-08-12 11:22:06 +02:00
|
|
|
'c03111' => 'Model 4B v1.1'
|
2019-04-10 10:37:35 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$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
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2019-04-10 10:37:35 +02:00
|
|
|
function DisplaySystem()
|
|
|
|
{
|
|
|
|
|
|
|
|
$status = new StatusMessages();
|
|
|
|
|
|
|
|
if (isset($_POST['SaveLanguage'])) {
|
2019-07-30 17:05:41 +02:00
|
|
|
if (isset($_POST['locale'])) {
|
|
|
|
$_SESSION['locale'] = $_POST['locale'];
|
|
|
|
$status->addMessage('Language setting saved', 'success');
|
2019-04-10 10:37:35 +02:00
|
|
|
}
|
2018-05-29 21:16:40 +02:00
|
|
|
}
|
|
|
|
|
2019-04-10 10:37:35 +02:00
|
|
|
// define locales
|
|
|
|
$arrLocales = array(
|
2018-05-29 21:16:40 +02:00
|
|
|
'en_GB.UTF-8' => 'English',
|
2018-06-16 23:55:12 +02:00
|
|
|
'de_DE.UTF-8' => 'Deutsch',
|
2018-06-12 18:45:11 +02:00
|
|
|
'fr_FR.UTF-8' => 'Français',
|
|
|
|
'it_IT.UTF-8' => 'Italiano',
|
2018-05-30 00:20:08 +02:00
|
|
|
'pt_BR.UTF-8' => 'Português',
|
2018-09-12 16:43:23 +02:00
|
|
|
'sv_SE.UTF-8' => 'Svenska',
|
2018-10-17 17:51:59 +02:00
|
|
|
'nl_NL.UTF-8' => 'Nederlands',
|
2018-11-04 09:59:01 +01:00
|
|
|
'zh_CN.UTF-8' => '简体中文 (Chinese simplified)',
|
2018-11-19 17:44:44 +01:00
|
|
|
'cs_CZ.UTF-8' => 'Čeština',
|
2019-01-13 09:53:16 +01:00
|
|
|
'ru_RU.UTF-8' => 'Русский',
|
2019-03-05 00:12:01 +01:00
|
|
|
'es_MX.UTF-8' => 'Español',
|
|
|
|
'fi_FI.UTF-8' => 'Finnish',
|
2019-06-10 11:27:42 +02:00
|
|
|
'si_LK.UTF-8' => 'Sinhala',
|
|
|
|
'tr_TR.UTF-8' => 'Türkçe'
|
2019-04-10 10:37:35 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// hostname
|
|
|
|
exec("hostname -f", $hostarray);
|
|
|
|
$hostname = $hostarray[0];
|
|
|
|
|
|
|
|
// uptime
|
|
|
|
$uparray = explode(" ", exec("cat /proc/uptime"));
|
|
|
|
$seconds = round($uparray[0], 0);
|
|
|
|
$minutes = $seconds / 60;
|
|
|
|
$hours = $minutes / 60;
|
|
|
|
$days = floor($hours / 24);
|
|
|
|
$hours = floor($hours - ($days * 24));
|
|
|
|
$minutes = floor($minutes - ($days * 24 * 60) - ($hours * 60));
|
|
|
|
$uptime= '';
|
|
|
|
if ($days != 0) {
|
|
|
|
$uptime .= $days . ' day' . (($days > 1)? 's ':' ');
|
|
|
|
}
|
|
|
|
if ($hours != 0) {
|
|
|
|
$uptime .= $hours . ' hour' . (($hours > 1)? 's ':' ');
|
|
|
|
}
|
|
|
|
if ($minutes != 0) {
|
|
|
|
$uptime .= $minutes . ' minute' . (($minutes > 1)? 's ':' ');
|
|
|
|
}
|
|
|
|
|
|
|
|
// mem used
|
|
|
|
$memused_status = "primary";
|
|
|
|
exec("free -m | awk '/Mem:/ { total=$2 ; used=$3 } END { print used/total*100}'", $memarray);
|
|
|
|
$memused = floor($memarray[0]);
|
|
|
|
if ($memused > 90) {
|
|
|
|
$memused_status = "danger";
|
|
|
|
} elseif ($memused > 75) {
|
|
|
|
$memused_status = "warning";
|
|
|
|
} elseif ($memused > 0) {
|
|
|
|
$memused_status = "success";
|
|
|
|
}
|
|
|
|
|
|
|
|
// cpu load
|
|
|
|
$cores = exec("grep -c ^processor /proc/cpuinfo");
|
|
|
|
$loadavg = exec("awk '{print $1}' /proc/loadavg");
|
|
|
|
$cpuload = floor(($loadavg * 100) / $cores);
|
|
|
|
if ($cpuload > 90) {
|
|
|
|
$cpuload_status = "danger";
|
|
|
|
} elseif ($cpuload > 75) {
|
|
|
|
$cpuload_status = "warning";
|
|
|
|
} elseif ($cpuload > 0) {
|
|
|
|
$cpuload_status = "success";
|
|
|
|
}
|
2016-08-08 14:31:19 +02:00
|
|
|
|
2019-08-12 11:22:06 +02:00
|
|
|
?>
|
2016-08-08 14:38:15 +02:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-lg-12">
|
|
|
|
<div class="panel panel-primary">
|
2017-10-23 21:51:34 +02:00
|
|
|
<div class="panel-heading"><i class="fa fa-cube fa-fw"></i> <?php echo _("System"); ?></div>
|
2016-08-08 14:38:15 +02:00
|
|
|
<div class="panel-body">
|
2016-08-08 14:31:19 +02:00
|
|
|
|
2019-08-12 11:22:06 +02:00
|
|
|
<?php
|
|
|
|
if (isset($_POST['system_reboot'])) {
|
|
|
|
echo '<div class="alert alert-warning">' . _("System Rebooting Now!") . '</div>';
|
|
|
|
$result = shell_exec("sudo /sbin/reboot");
|
|
|
|
}
|
|
|
|
if (isset($_POST['system_shutdown'])) {
|
|
|
|
echo '<div class="alert alert-warning">' . _("System Shutting Down Now!") . '</div>';
|
|
|
|
$result = shell_exec("sudo /sbin/shutdown -h now");
|
|
|
|
}
|
|
|
|
?>
|
2017-10-21 14:30:15 +02:00
|
|
|
|
2018-05-29 21:16:40 +02:00
|
|
|
<p><?php $status->showMessages(); ?></p>
|
|
|
|
<form role="form" action="?page=system_info" method="POST">
|
2019-08-14 02:44:13 +02:00
|
|
|
<?php echo CSRFTokenFieldTag() ?>
|
2018-05-29 21:16:40 +02:00
|
|
|
<ul class="nav nav-tabs" role="tablist">
|
|
|
|
<li role="presentation" class="active systemtab"><a href="#system" aria-controls="system" role="tab" data-toggle="tab"><?php echo _("System"); ?></a></li>
|
|
|
|
<li role="presentation" class="languagetab"><a href="#language" aria-controls="language" role="tab" data-toggle="tab"><?php echo _("Language"); ?></a></li>
|
|
|
|
<li role="presentation" class="consoletab"><a href="#console" aria-controls="console" role="tab" data-toggle="tab"><?php echo _("Console"); ?></a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<div class="systemtabcontent tab-content">
|
|
|
|
<div role="tabpanel" class="tab-pane active" id="system">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-lg-6">
|
|
|
|
<h4><?php echo _("System Information"); ?></h4>
|
2018-08-04 01:58:34 +02:00
|
|
|
<div class="info-item"><?php echo _("Hostname"); ?></div> <?php echo htmlspecialchars($hostname, ENT_QUOTES); ?></br>
|
|
|
|
<div class="info-item"><?php echo _("Pi Revision"); ?></div> <?php echo htmlspecialchars(RPiVersion(), ENT_QUOTES); ?></br>
|
|
|
|
<div class="info-item"><?php echo _("Uptime"); ?></div> <?php echo htmlspecialchars($uptime, ENT_QUOTES); ?></br></br>
|
2018-05-29 21:16:40 +02:00
|
|
|
<div class="info-item"><?php echo _("Memory Used"); ?></div>
|
|
|
|
<div class="progress">
|
2018-08-04 01:58:34 +02:00
|
|
|
<div class="progress-bar progress-bar-<?php echo htmlspecialchars($memused_status, ENT_QUOTES); ?> progress-bar-striped active"
|
2018-05-29 21:16:40 +02:00
|
|
|
role="progressbar"
|
2018-08-04 01:58:34 +02:00
|
|
|
aria-valuenow="<?php echo htmlspecialchars($memused, ENT_QUOTES); ?>" aria-valuemin="0" aria-valuemax="100"
|
|
|
|
style="width: <?php echo htmlspecialchars($memused, ENT_QUOTES); ?>%;"><?php echo htmlspecialchars($memused, ENT_QUOTES); ?>%
|
2018-05-29 21:16:40 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="info-item"><?php echo _("CPU Load"); ?></div>
|
|
|
|
<div class="progress">
|
2018-08-04 01:58:34 +02:00
|
|
|
<div class="progress-bar progress-bar-<?php echo htmlspecialchars($cpuload_status, ENT_QUOTES); ?> progress-bar-striped active"
|
2018-05-29 21:16:40 +02:00
|
|
|
role="progressbar"
|
2018-08-04 01:58:34 +02:00
|
|
|
aria-valuenow="<?php echo htmlspecialchars($cpuload, ENT_QUOTES); ?>" aria-valuemin="0" aria-valuemax="100"
|
|
|
|
style="width: <?php echo htmlspecialchars($cpuload, ENT_QUOTES); ?>%;"><?php echo htmlspecialchars($cpuload, ENT_QUOTES); ?>%
|
2018-05-29 21:16:40 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<form action="?page=system_info" method="POST">
|
2019-08-14 02:41:20 +02:00
|
|
|
<?php echo CSRFTokenFieldTag() ?>
|
2018-05-29 21:16:40 +02:00
|
|
|
<input type="submit" class="btn btn-warning" name="system_reboot" value="<?php echo _("Reboot"); ?>" />
|
|
|
|
<input type="submit" class="btn btn-warning" name="system_shutdown" value="<?php echo _("Shutdown"); ?>" />
|
|
|
|
<input type="button" class="btn btn-outline btn-primary" value="<?php echo _("Refresh"); ?>" onclick="document.location.reload(true)" />
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div role="tabpanel" class="tab-pane" id="language">
|
|
|
|
<h4><?php echo _("Language settings") ;?></h4>
|
|
|
|
<div class="row">
|
|
|
|
<div class="form-group col-md-4">
|
|
|
|
<label for="code"><?php echo _("Select a language"); ?></label>
|
|
|
|
<?php SelectorOptions('locale', $arrLocales, $_SESSION['locale']); ?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<input type="submit" class="btn btn-outline btn-primary" name="SaveLanguage" value="<?php echo _("Save settings"); ?>" />
|
|
|
|
<input type="button" class="btn btn-outline btn-primary" value="<?php echo _("Refresh"); ?>" onclick="document.location.reload(true)" />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div role="tabpanel" class="tab-pane" id="console">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-lg-12">
|
|
|
|
<iframe src="includes/webconsole.php" class="webconsole"></iframe>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2017-10-21 14:30:15 +02:00
|
|
|
|
2019-08-07 23:16:56 +02:00
|
|
|
</div><!-- /.systemtabcontent -->
|
2017-10-21 14:30:15 +02:00
|
|
|
|
2018-05-29 21:16:40 +02:00
|
|
|
</form>
|
2019-08-09 16:21:58 +02:00
|
|
|
</div><!-- /.panel-body -->
|
2018-05-29 21:16:40 +02:00
|
|
|
<div class="panel-footer"></div>
|
2018-08-04 01:58:34 +02:00
|
|
|
</div><!-- /.panel-primary -->
|
2016-08-08 14:38:15 +02:00
|
|
|
</div><!-- /.col-lg-12 -->
|
|
|
|
</div><!-- /.row -->
|
2019-08-12 11:22:06 +02:00
|
|
|
<?php
|
2016-08-08 14:31:19 +02:00
|
|
|
}
|
2018-08-04 01:58:34 +02:00
|
|
|
|