diff --git a/webinterface/config.php b/webinterface/config.php index 5c0f78f..8be049f 100644 --- a/webinterface/config.php +++ b/webinterface/config.php @@ -1,14 +1,34 @@ diff --git a/webinterface/index.php b/webinterface/index.php index 40c6c87..7647c2a 100644 --- a/webinterface/index.php +++ b/webinterface/index.php @@ -1,7 +1,21 @@ = 8) { $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) or die("Could not create socket\n"); @@ -41,6 +59,9 @@ Delay: "; echo "60 "; echo "

"; +/* + * table containing all configured sockets + */ $index=0; echo "\n"; foreach($config as $current) { - $ig = $current[0]; - $is = $current[1]; - $id = $current[2]; + if ($current != "") { + $ig = $current[0]; + $is = $current[1]; + $id = $current[2]; - $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"); + if ($index%2 == 0) echo "\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"; + $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"; + } echo "\n"; + socket_close($socket); + } + else { + echo "\n"; + } if ($index%2 == 1) echo "\n"; $index++; - socket_close($socket); } echo "
\n"; echo "
"; echo ""; echo "
\n"; echo "
"; ?>