This repository has been archived on 2020-03-25. You can view files and clone it, but cannot push or open issues or pull requests.
server-wakeonlan/index.php

69 lines
1.8 KiB
PHP

<?php
// -------------------------------------------
// Wake On LAN Webclient -- on private LAN
// copyright: Jannik Beyerstedt | https://jannikbeyerstedt.de
// license: http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 License
// -------------------------------------------
if (isset($_GET['wake'])) {
$return = shell_exec('wakeonlan '.$_GET['wake']);
}
$clients = ["nuc6i5-host"=>"b8:ae:ed:ec:18:f7",
"magrathea" =>"60:03:08:9c:25:6a"];
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WakeOnLan @ UrsaMinor.fra80</title>
<style>
body {
max-width: 500px;
margin: 0 auto;
padding: 0 5px;
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
}
small {
font-size: 0.7em;
font-weight: 500;
}
li {
margin-bottom: 1.5em;
}
a, a:visited {
color: blue;
}
.red { color: red; }
.green { color: green; }
</style>
</head>
<body>
<h1>Wake On LAN Service</h1>
<?php if (isset($return)) : ?>
<p>The command returned:</p>
<pre><?php echo $return; ?></pre>
<a href="index.php">OK</a>
<?php endif; ?>
<p>I can wake up the following clients:</p>
<ul>
<?php foreach ($clients as $name=>$mac) : ?>
<li>
<a href="?wake=<?php echo $mac ?>"><?php echo $name ?> (<?php echo $mac ?>)</a>
<?php $foo = array(); $status; exec("ping -c 1 ".$name.".fra80", $foo, $status); ?>
<?php if (!$status) : ?>
<span class="green">&#8226;</span> online
<?php else : ?>
<span class="red">&#8226;</span> offline
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</body>
</html>