Keep in mind I'm using xampp on a netbook running XP, so some scripts might need changed if you run this on a linux system.
First part is pretty simple. I ping the board once and wait 50ms. If the board does not respond, no values will be returned. This prevents the page from not loading. If it does, it gets every value from the board and breaks it up into pieces($data[0],$data[1],etc.). Each piece corresponds with a value like $data[24] is IP6 on the board. At least on my board it is. Then you can assign values to them if you don't want to see the raw value. IP6 for example has my garage door sensor on it, so I wanted to see open or closed. If not, you can just add the value that will be encoded into a readable format.
A good trick is to just encode the $data variable, then open status.php in your browser. It will give you all of the variables in order so you can pick and choose with ones you want. It's also a good way to debug the script for errors.
It's very important to just encode($status) the values you want to display and only those values. Encoding more will only result in a browser error.
--status.php--
<?php
$webcontrol = exec("ping -n 1 -w 50 192.168.1.15");
$stripped = strip_tags($webcontrol);
$explode = explode(" ", $stripped);
if ( $explode[4] == 'Packets:' ) {
$status = "null";
}
else {
$webcontrolgetall = file_get_contents('
http://admin[email protected]/getall.cgi');
$strip = strip_tags($webcontrolgetall);
$data = explode("\n", $strip);
if ( $data[24] == 1 ) {
$garage = "OPEN";
}
if ( $data[24] == 0 ) {
$garage = "CLOSED";
}
$status['garage'] = $garage;
$status['temp'] = $data[27];
}
echo json_encode($status);
?>
--status.php--