From d388fc2c0ccef306b97715453e60fa5a3dbaa2c0 Mon Sep 17 00:00:00 2001
From: xkonni
Date: Sun, 25 Nov 2012 02:19:05 +0100
Subject: [PATCH] webinterface: add comments, update layout
* added a lot of comments to increase readability
* updated layout, it is now possible to create empty boxes
---
webinterface/config.php | 28 ++++++++++++---
webinterface/index.php | 76 ++++++++++++++++++++++++++++-------------
2 files changed, 77 insertions(+), 27 deletions(-)
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";
echo "\n";
echo " | \n";
+ socket_close($socket);
+ }
+ else {
+ echo " | \n";
+ }
if ($index%2 == 1) echo "
\n";
$index++;
- socket_close($socket);
}
echo "
";
?>