Created
August 13, 2017 16:46
-
-
Save Ttech/68f7b23b605283653e5a945ad57a9223 to your computer and use it in GitHub Desktop.
quickest automation page ever... and equally terrible
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 | |
@$input = $_GET['light']; | |
@$command = $_GET['command']; | |
$c = 'off'; // 1 = on, 0 = off | |
switch($command){ | |
case 'on': | |
$c = 'on'; | |
break; | |
case 'off': | |
$c = 'off'; | |
break; | |
} | |
$l = 'all'; | |
switch($input){ | |
case '1': | |
$l = "172.24.40.21"; | |
break; | |
case '2': | |
$l = "172.24.40.22"; | |
break; | |
case '3': | |
$l = "172.24.40.23"; | |
break; | |
default: | |
$l = 'all'; | |
break; | |
} | |
echo "<h3>light, command</h3>"; | |
$path = "/opt/scripts/switch.py"; | |
?> | |
<form action="<?php echo basename(__FILE__); ?>" method="get" id="main"> | |
<br/><br/> | |
Select: <select name="light"> | |
<option value="1">1</option> | |
<option value="2">2</option> | |
<option value="3">3</option> | |
<option value="4">4</option> | |
<option value="all" selected>all</option> | |
</select><br /> | |
<button type="submit" name="command" value="on">Turn On!</button><br/> | |
<button type="submit" name="command" value="off">Turn On!</button><br/> | |
</form> | |
<br/> | |
<textarea style="width:80%" align="center"> | |
<?php | |
if(isset($_GET['command'])) { | |
passthru("$path -t $l -c $c"); | |
} | |
?> | |
</textarea> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment