Skip to content

Commit

Permalink
Merge pull request #8 from devzero84/master
Browse files Browse the repository at this point in the history
looks good, merged.
  • Loading branch information
konni committed Jul 16, 2015
2 parents 68be96c + aef4541 commit 366127c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
1 change: 0 additions & 1 deletion webinterface/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
/*
* define ip address and port here
*/
$source = $_SERVER['SERVER_ADDR'];
$target = '192.168.11.124';
$port = 11337;

Expand Down
32 changes: 19 additions & 13 deletions webinterface/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,26 @@
*
*/


function daemon_send($target, $port, $output)
{
$fp = fsockopen($target, $port, $errno, $errstr, 30) or die("$errstr ($errno)\n");
fwrite($fp, $output);
$state = "";
while(!feof($fp))
{
$state .= fgets($fp, 2);
}
fclose($fp);
return $state;
}


/*
* get configuration
* don't forget to edit config.php
*/
include("config.php");
require 'config.php';

/*
* get parameters
Expand All @@ -33,12 +48,9 @@
*/
$output = $nGroup.$nSwitch.$nAction.$nDelay;
if (strlen($output) >= 8) {
$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");
socket_write($socket, $output, strlen ($output)) or die("Could not write output\n");
socket_close($socket);
daemon_send($target, $port, $output);
header("Location: index.php?delay=$nDelay");
exit();
}
?>
<html>
Expand Down Expand Up @@ -93,13 +105,8 @@

if ($index%2 == 0) echo "<TR>\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);
$state = daemon_send($target, $port, $output);
if ($state == 0) {
$color=" BGCOLOR=\"#C00000\"";
$ia = 1;
Expand All @@ -123,7 +130,6 @@
echo "</TD>";
echo "</TR></TABLE>\n";
echo "</TD>\n";
socket_close($socket);
}
else {
echo "<TD></TD>\n";
Expand Down

0 comments on commit 366127c

Please sign in to comment.