116 lines
3.8 KiB
PHP
116 lines
3.8 KiB
PHP
<?php include('partialpage/header.php');?>
|
|
<?php include('partialpage/sidebar.php');?>
|
|
|
|
<?php if($_SERVER['REQUEST_METHOD'] == 'POST' ){
|
|
if ($_POST['reboot']){
|
|
$message = "system is rebooting, please wait...";
|
|
shell_exec('sudo /sbin/reboot');
|
|
}
|
|
if ($_POST['restore']){
|
|
$message = "---> dummy function <---";
|
|
}
|
|
if ($_POST['hostname']){
|
|
$hostname = $_POST['hostname'];
|
|
|
|
$path = "/etc/hostname";
|
|
if (file_exists($path)){
|
|
if (!is_writable($path)) {
|
|
$command = "sudo chmod 666 $path";
|
|
exec($command);
|
|
}
|
|
$fp = fopen($path, 'w');
|
|
if(!$fp){
|
|
$message = 'file is not opend';
|
|
}
|
|
fwrite($fp, $hostname . PHP_EOL);
|
|
fclose($fp);
|
|
}
|
|
shell_exec("sudo hostname $hostname");
|
|
shell_exec("sudo syseeprom -w -d$hostname");
|
|
$message = "Hostname set to " . $hostname;
|
|
}
|
|
if ($_POST['serialnumber']){
|
|
$serialnumber = $_POST['serialnumber'];
|
|
shell_exec("sudo syseeprom -w -s$serialnumber");
|
|
$message = "Serialnumber set to $serialnumber";
|
|
}
|
|
};?>
|
|
|
|
<!-- !PAGE CONTENT! -->
|
|
<div class="w3-main" style="margin-left:340px;margin-right:40px">
|
|
|
|
<!-- Header -->
|
|
<div class="w3-container" style="margin-top:80px" id="showcase">
|
|
<h1 class="w3-jumbo"><b>System</b></h1>
|
|
<br>
|
|
<div style="border:5px solid red; width:100px" class="w3-round"></div>
|
|
<br>
|
|
</div>
|
|
|
|
<?php if(isset($message)){
|
|
echo "<!-- post result messages -->";
|
|
echo "<div class='w3-container' id='resultmessage' style='margin-top:75px'>";
|
|
echo "<p>$message</p>";
|
|
echo "</div>";
|
|
};?>
|
|
|
|
<!-- change hostname -->
|
|
<div class="w3-container" id="hostname" style="margin-top:75px">
|
|
<div class="w3-col l6">
|
|
<h3>Change system hostname</h3>
|
|
<form action="system.php" method="post">
|
|
<div class="w3-section">
|
|
<label class="w3-label">Hostname</label>
|
|
<input class="w3-input w3-border" type="text" name="hostname" id="hostname" value="<?php echo shell_exec("cat /etc/hostname");?>" required>
|
|
</div>
|
|
<button type="submit" class="w3-button w3-block w3-padding-large w3-red w3-margin-bottom">Save hostname and eeprom device name</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- reboot command -->
|
|
<div class="w3-container" id="reboot" style="margin-top:75px">
|
|
<div class="w3-col l6">
|
|
<h3>Reboot the system</h3>
|
|
<form action="system.php" method="post">
|
|
<button type="submit" name="reboot" value="reboot" class="w3-button w3-block w3-padding-large w3-red w3-margin-bottom">Reboot system</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- restore command -->
|
|
<div class="w3-container" id="restore" style="margin-top:75px">
|
|
<div class="w3-col l6">
|
|
<h3>restore configs to default</h3>
|
|
<form action="system.php" method="post">
|
|
<button type="submit" name="restore" value="restore" class="w3-button w3-block w3-padding-large w3-red w3-margin-bottom">Restore configs</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
$serial = shell_exec("sudo syseeprom -s");
|
|
if (strlen($serial) == 1){
|
|
echo "<!-- change serialnumber -->";
|
|
echo "<div class='w3-container' id='serialnumber' style='margin-top:75px'>";
|
|
echo "<div class='w3-col l6'>";
|
|
echo "<h3>Set system serialnumber</h3>";
|
|
echo "<form action='system.php' method='post'>";
|
|
echo "<div class='w3-section'>";
|
|
echo "<label class='w3-label'>Serialnumber</label>";
|
|
echo "<input class='w3-input w3-border' type='text' name='serialnumber' id='serialnumber' maxlength='15' value='";
|
|
echo $serial;
|
|
echo "' required>";
|
|
echo "</div>";
|
|
echo "<button type='submit' class='w3-button w3-block w3-padding-large w3-red w3-margin-bottom'>Save serialnumber</button>";
|
|
echo "</form>";
|
|
echo "</div>";
|
|
echo "</div>";
|
|
}
|
|
?>
|
|
|
|
<!-- End page content -->
|
|
</div>
|
|
|
|
<?php include('partialpage/footer.php');?>
|