Skip to content

Instantly share code, notes, and snippets.

@tuxmartin
Created December 27, 2017 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxmartin/11e390509e3b138d9a850c50cdebd386 to your computer and use it in GitHub Desktop.
Save tuxmartin/11e390509e3b138d9a850c50cdebd386 to your computer and use it in GitHub Desktop.
WoL php
<?php
/*
# visudo
www-data ALL=NOPASSWD: /usr/sbin/etherwake
*/
$password = "MocTajneHeslo";
if ( $_POST["computer"] ) {
if ( $_POST["password"] == $password ) {
echo "<h1>WoL to " . $_POST["computer"] . " send!</h1>";
if( $_POST["computer"] == "PC" ) exec('sudo etherwake -i br0 00:1f:d0:90:f5:00');
if( $_POST["computer"] == "Notebook Martin" ) exec('sudo etherwake -i br0 f0:de:f1:d4:7d:9e'); // enp0s25
} else {
echo "<h1>Error!</h1>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Wake On Lan</title>
<meta name="robots" content="noarchive">
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
.text {
font-size: 200%;
margin-bottom: 1em;
display: block;
}
</style>
</head>
<body>
<form action = "<?php $_PHP_SELF ?>" method="POST">
<input type="text" class="text" name="password" placeholder="Password..." size="10" />
<input type="submit" class="text" name="computer" value="PC" />
<input type="submit" class="text" name="computer" value="Notebook Martin" />
</form>
</body>
</html>
<?php
// Mobile friendly test: https://www.google.com/webmasters/tools/mobile-friendly/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment