Last active
January 30, 2016 16:19
-
-
Save tuxmartin/bd59912939111014a3df to your computer and use it in GitHub Desktop.
WakeOnLan PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
# visudo | |
www-data ALL=NOPASSWD: /usr/sbin/etherwake | |
*/ | |
$password = "test123"; | |
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"] == "X" ) exec('sudo etherwake -i br0 00:11:22:33:44:55'); | |
} 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="X" /> | |
</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