diff --git a/daemon.h b/daemon.h index 1540cc0..e1cf936 100644 --- a/daemon.h +++ b/daemon.h @@ -2,7 +2,7 @@ char nGroup[6]; int nSwitchNumber; int nAction; int nPlugs; -int PORT = 12345; +int PORT = 11337; void error(const char *msg); int getAddr(const char* nGroup, int nSwitchNumber); diff --git a/webinterface/config.php b/webinterface/config.php new file mode 100644 index 0000000..5c0f78f --- /dev/null +++ b/webinterface/config.php @@ -0,0 +1,14 @@ + diff --git a/webinterface/index.php b/webinterface/index.php index c664fd4..e41981c 100644 --- a/webinterface/index.php +++ b/webinterface/index.php @@ -1,13 +1,12 @@ "; -foreach($groups as $ig) { - for ($is=1; $is<=5; $is++) { - $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) or die("Could not create socket\n"); - socket_bind($socket, $source) or die("Could not bind to socket\n"); - socket_connect($socket, $target, $port) or die("Could not connect to socket\n"); +echo "\n"; +foreach($config as $current) { + $ig = $current[0]; + $is = $current[1]; + $id = $current[2]; - $output = $ig."0".$is."2"; - socket_write($socket, $output, strlen ($output)) or die("Could not write output\n"); - $state = socket_read($socket, 2048); - if ($state == 0) { - $color=" BGCOLOR=\"#C00000\""; - $action = 1; - $done="switch on"; - } - if ($state == 1) { - $color=" BGCOLOR=\"#00C000\""; - $action = 0; - $done="switch off"; - } - if (($ig == $nGroup) && ($is == $nSwitch)) { - if ($state == 1) { - $done="switched on"; - $color=" BGCOLOR=\"#00FF00\""; - } - else if ($state == 0) { - $done="switched off"; - $color=" BGCOLOR=\"#FF0000\""; - } - } - echo ""; - // socket_close($socket); - if ($index%2 == 1) { - echo ""; - } - $index++; - socket_close($socket); + $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) or die("Could not create socket\n"); + socket_bind($socket, $source) or die("Could not bind to socket\n"); + socket_connect($socket, $target, $port) or die("Could not connect to socket\n"); + + $output = $ig.$is."2"; + socket_write($socket, $output, strlen ($output)) or die("Could not write output\n"); + $state = socket_read($socket, 2048); + if ($state == 0) { + $color=" BGCOLOR=\"#C00000\""; + $ia = 1; + $direction="on"; + } + if ($state == 1) { + $color=" BGCOLOR=\"#00C000\""; + $ia = 0; + $direction="off"; } + if ($index%2 == 0) echo "\n"; + echo "\n"; + if ($index%2 == 1) echo "\n"; + $index++; + socket_close($socket); } echo "
"; - echo "
"; - echo ""; - echo "

".$names[$index]."


"; - echo $ig.":".$is."
"; - echo $done; - echo "
"; - echo "
"; - echo "
\n"; + echo ""; + echo "
"; + echo ""; + echo "

".$id."


"; + echo $ig.":".$is."
"; + echo "switch ".$direction; + echo "
"; + echo "
\n"; + echo "
"; ?> diff --git a/webinterface/style.css b/webinterface/style.css index 893b598..b22b841 100644 --- a/webinterface/style.css +++ b/webinterface/style.css @@ -4,29 +4,10 @@ body { font-size: 26px; } -h1 { -} - -h2 { -} - h3 { font-size: 30px; } -p { -} - -div { - width: 495px; - padding: 10px; -} - -div.changelog { - color: #ffffff; - background-color: #14171b; -} - table { vertical-align: middle; text-align: center; @@ -58,39 +39,19 @@ a:hover { color: #298aad; text-decoration: none; } -a:active { - color: #ffffff; i +a.on:hover { + color: #00ff00; text-decoration: none; } - -span { - color: #ffffff; -} - - -.ics { - color: #298aad; -} - -ul { - list-style-type: circle; - color: #298aad; +a.off:hover { + color: #ff0000; + text-decoration: none; } - -li { - color: #ffffff; +a:active { + color: #ffffff; i + text-decoration: none; } -/* Display */ -.hidden { display: none; } -.visible { display: block; } - -/* Visibility */ -/* -.hidden { visibility: hidden; } -.visible { visibility: visible; } -*/ - /* Android HDPI */ @media only screen and (-webkit-device-pixel-ratio:1.5) { }