Files
cdn-star/admin/power.php
T
2026-07-19 18:27:27 +08:00

93 lines
4.2 KiB
PHP

<?php
// Load the language support
require_once('config/language.php');
// Load the Pi-Star Release file
$pistarReleaseConfig = '/etc/pistar-release';
$configPistarRelease = array();
$configPistarRelease = parse_ini_file($pistarReleaseConfig, true);
// Load the Version Info
require_once('config/version.php');
// Sanity Check that this file has been opened correctly
if ($_SERVER["PHP_SELF"] == "/admin/power.php") {
// Sanity Check Passed.
header('Cache-Control: no-cache');
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" lang="en">
<head>
<meta name="robots" content="index" />
<meta name="robots" content="follow" />
<meta name="language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Author" content="Andrew Taylor (MW0MWZ)" />
<meta name="Description" content="CDN Power" />
<meta name="KeyWords" content="CDN" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="pragma" content="no-cache" />
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<meta http-equiv="Expires" content="0" />
<title>CDN - <?php echo $lang['digital_voice']." ".$lang['dashboard']." - ".$lang['power'];?></title>
<link rel="stylesheet" type="text/css" href="css/pistar-css.php" />
</head>
<body>
<div class="container">
<div class="header">
<div style="font-size: 8px; text-align: right; padding-right: 8px;">CDN:<?php echo $configPistarRelease['Pi-Star']['Version']?> / <?php echo $lang['dashboard'].": ".$version; ?></div>
<h1>CDN <?php echo $lang['digital_voice']." - ".$lang['power'];?></h1>
<p style="padding-right: 5px; text-align: right; color: #ffffff;">
<a href="/" style="color: #ffffff;"><?php echo $lang['dashboard'];?></a> |
<a href="/admin/" style="color: #ffffff;"><?php echo $lang['admin'];?></a> |
<a href="/admin/config_backup.php" style="color: #ffffff;"><?php echo $lang['backup_restore'];?></a> |
<a href="/admin/configure.php" style="color: #ffffff;"><?php echo $lang['configuration'];?></a>
</p>
</div>
<div class="contentwide">
<h2><?php echo $lang['power'];?></h2>
<?php if (!empty($_POST)) { ?>
<div class="settings-card">
<?php
if ( escapeshellcmd($_POST["action"]) == "reboot" ) {
echo '<div class="power-status">Reboot command has been sent to your Pi,
<br />please wait up to 90 secs for it to reboot.<br />
<br />You will be re-directed back to the
<br />dashboard automatically in 90 seconds.
<script language="JavaScript" type="text/javascript">
setTimeout("location.href = \'/index.php\'",90000);
</script>
</div>';
system('sudo sync && sudo sync && sudo sync && sudo mount -o remount,ro / > /dev/null &');
exec('sudo reboot > /dev/null &');
};
if ( escapeshellcmd($_POST["action"]) == "shutdown" ) {
echo '<div class="power-status">Shutdown command has been sent to your Pi,
<br /> please wait 30 secs for it to fully shutdown<br />before removing the power.</div>';
system('sudo sync && sudo sync && sudo sync && sudo mount -o remount,ro / > /dev/null &');
exec('sudo shutdown -h now > /dev/null &');
};
?>
</div>
<?php } else { ?>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post" onsubmit="return confirm('Are you sure?');">
<div class="settings-card action-tiles">
<button class="action-tile" name="action" value="reboot">
<img src="/images/reboot.png" alt="Reboot" />
<span>Reboot</span>
</button>
<button class="action-tile" name="action" value="shutdown">
<img src="/images/shutdown.png" alt="Shutdown" />
<span>Shutdown</span>
</button>
</div>
</form>
<?php } ?>
</div>
</div>
</body>
</html>
<?php
}
?>