\n"; } else { fwrite($fp, "$order\n;quit\n"); $errormessage= fgets($fp, 1024); fclose($fp); } } return $errormessage; } ###### make an array from the xmllist unset($output); $stack = array(); $output=array(); $version = explode('.', phpversion()); if ( $version[0] == 4 ) { $xmllist="$fhz1000_pl $fhz1000port xmllist"; exec($xmllist,$output); } else { $fp = stream_socket_client("tcp://$fhz1000:$fhz1000port", $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)
\n"; } else { fwrite($fp, "xmllist\r\n;quit\r\n"); while (!feof($fp)) { $outputvar = fgets($fp, 1024); array_push($output,$outputvar); } fclose($fp); } } # start_element_handler ( resource parser, string name, array attribs ) function startElement($parser, $name, $attribs) { global $stack; $tag=array("name"=>$name,"attrs"=>$attribs); array_push($stack,$tag); } # end_element_handler ( resource parser, string name ) function endElement($parser, $name) { global $stack; $stack[count($stack)-2]['children'][] = $stack[count($stack)-1]; array_pop($stack); } function new_xml_parser($live) { global $parser_live; $xml_parser = xml_parser_create(); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0); xml_set_element_handler($xml_parser, "startElement", "endElement"); if (!is_array($parser_live)) { settype($parser_live, "array"); } $parser_live[$xml_parser] = $live; return array($xml_parser, $live); } # go parsing if (!(list($xml_parser, $live) = new_xml_parser($live))) { die("could not parse XML input"); } foreach($output as $data) { if (!xml_parse($xml_parser, $data)) { die(sprintf("XML error: %s at line %d\n", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } } xml_parser_free($xml_parser); #for testing #print_r($stack);exit; #searching for rooms/fs20 $rooms=array(); $fs20devs=array(); $fhtdevs=array(); if ($showroombuttons==1) for($i=0; $i < count($stack[0][children]); $i++) { if ($stack[0][children][$i][name]=='FS20_DEVICES') { for($j=0; $j < count($stack[0][children][$i][children]); $j++) { $fs20devxml=$stack[0][children][$i][children][$j][attrs][name]; for($k=0; $k < count($stack[0][children][$i][children][$j][children]); $k++) { $check=$stack[0][children][$i][children][$j][children][$k][attrs][name]; if ($check='ATTR') { if (($stack[0][children][$i][children][$j][children][$k][attrs][key])=='room') { $room=$stack[0][children][$i][children][$j][children][$k][attrs][value]; if (! in_array($room,$rooms)) array_push($rooms,$room); } } } if ((! in_array($fs20devxml,$fs20devs)) AND ( $room != 'hidden')) array_push($fs20devs,$fs20devxml); } }#FS20 elseif ($stack[0][children][$i][name]=='FHT_DEVICES') { for($j=0; $j < count($stack[0][children][$i][children]); $j++) { $fhtdevxml=$stack[0][children][$i][children][$j][attrs][name]; for($k=0; $k < count($stack[0][children][$i][children][$j][children]); $k++) { $check=$stack[0][children][$i][children][$j][children][$k][attrs][key]; if ( $check=="room") {$room=$stack[0][children][$i][children][$j][children][$k][attrs][value]; if (! in_array($room,$rooms)) array_push($rooms,$room); } } if ((! in_array($fhtdevxml,$fhtdevs)) AND ( $room != 'hidden')) array_push($fhtdevs,$fhtdevxml); } } #FHT elseif ($stack[0][children][$i][name]=='HMS_DEVICES') { for($j=0; $j < count($stack[0][children][$i][children]); $j++) { for($k=0; $k < count($stack[0][children][$i][children][$j][children]); $k++) { if ( $stack[0][children][$i][children][$j][children][$k][attrs][key]=="room") {$room=$stack[0][children][$i][children][$j][children][$k][attrs][value]; if (! in_array($room,$rooms)) array_push($rooms,$room); } } } } # HMS elseif ($stack[0][children][$i][name]=='KS300_DEVICES') { for($j=0; $j < count($stack[0][children][$i][children]); $j++) { for($k=0; $k < count($stack[0][children][$i][children][$j][children]); $k++) { $check=$stack[0][children][$i][children][$j][children][$k][attrs][name]; if ($check='ATTR') { if (($stack[0][children][$i][children][$j][children][$k][attrs][key])=='room') { $room=$stack[0][children][$i][children][$j][children][$k][attrs][value]; if (! in_array($room,$rooms)) array_push($rooms,$room); } } } } } } # end searching rooms array_push($rooms,'ALL'); sort($rooms); #print_r($rooms); echo "Count: $countrooms"; exit; #print_r($fs20devs); exit; # Print Array on Screen $now=date($timeformat); echo " $titel"; include ("include/style.css"); echo " "; echo" $errormessage
"; ############################ FHZ echo ""; if (($show_general=='1') AND ($showmenu=='1')) {echo " "; }; if (($show_fs20pulldown=='1') AND ($showmenu=='1')) include 'include/fs20pulldown.php'; if (($show_fhtpulldown=='1') AND ($showmenu=='1')) include 'include/fhtpulldown.php'; ############################ ROOMS if (($showroombuttons==1) and (count($rooms)>1)) { echo ""; echo ""; } ##################################################################################################################### ##### Let's go.... :-))))) for($i=0; $i < count($stack[0][children]); $i++) { ############################ if ($stack[0][children][$i][name]=='FS20_DEVICES') { $type=$stack[0][children][$i][name]; echo ""; $counter=0; echo ""; } ############################ elseif ($stack[0][children][$i][name]=='FHT_DEVICES') { $type=$stack[0][children][$i][name]; echo ""; for($j=0; $j < count($stack[0][children][$i][children]); $j++) { $room=""; for($k=0; $k < count($stack[0][children][$i][children][$j][children]); $k++) { $check=$stack[0][children][$i][children][$j][children][$k][attrs][key]; if ( $check=="room") {$room=$stack[0][children][$i][children][$j][children][$k][attrs][value]; } } if (($room != 'hidden') and ($showroom=='ALL' or $showroom==$room)) { $FHTdev=$stack[0][children][$i][children][$j][attrs][name]; if ($showfht == $FHTdev) {echo ""; }; echo " "; echo ""; echo ""; if ($showfht==$FHTdev and $showgnuplot == 1) { drawgnuplot($FHTdev,"FHT",$gnuplot,$pictype,$logpath); $FHTdev1=$FHTdev.'1'; echo ""; } for($k=0; $k < count($stack[0][children][$i][children][$j][children]); $k++) { if ( $showfht==$FHTdev) { $name=$stack[0][children][$i][children][$j][children][$k][attrs][name]; $value=$stack[0][children][$i][children][$j][children][$k][attrs][value]; $measured=$stack[0][children][$i][children][$j][children][$k][attrs][measured]; echo ""; } } } } } ############################ elseif ($stack[0][children][$i][name]=='HMS_DEVICES') { $type=$stack[0][children][$i][name]; echo ""; for($j=0; $j < count($stack[0][children][$i][children]); $j++) { $room=""; for($k=0; $k < count($stack[0][children][$i][children][$j][children]); $k++) { if ( $stack[0][children][$i][children][$j][children][$k][attrs][key]=="room") {$room=$stack[0][children][$i][children][$j][children][$k][attrs][value]; } if ( $stack[0][children][$i][children][$j][children][$k][attrs][name]=="type") {$type=$stack[0][children][$i][children][$j][children][$k][attrs][value];}; } if (($room != 'hidden') and ($showroom=='ALL' or $showroom==$room)) { $HMSdev=$stack[0][children][$i][children][$j][attrs][name]; if ($type=="HMS100T" or $type=="HMS100TF") { if ($showhmsgnu== $HMSdev) {$formvalue="hide";$gnuvalue="";} else {$formvalue="show";$gnuvalue=$HMSdev;}; echo ""; if ($showhmsgnu == $HMSdev and $showgnuplot == 1) { drawgnuplot($HMSdev,$type,$gnuplot,$pictype,$logpath); $HMSdev1=$HMSdev.'1'; echo ""; } } } } ############################ elseif ($stack[0][children][$i][name]=='KS300_DEVICES') { $type=$stack[0][children][$i][name]; echo ""; for($j=0; $j < count($stack[0][children][$i][children]); $j++) { $KSdev=$stack[0][children][$i][children][$j][attrs][name]; $room=''; for($k=0; $k < count($stack[0][children][$i][children][$j][children]); $k++) { $check=$stack[0][children][$i][children][$j][children][$k][attrs][name]; if ($check='STATE') { $name=$stack[0][children][$i][children][$j][children][$k][attrs][name]; $value=$stack[0][children][$i][children][$j][children][$k][attrs][value]; $measured=$stack[0][children][$i][children][$j][children][$k][attrs][measured]; if ($name=='temperature') {$KSmeasured=$measured;} elseif ($name=='avg_month') {$KSavgmonth=$value;} elseif ($name=='avg_day') {$KSavgday=$value;}; } if ($check='ATTR') { if (($stack[0][children][$i][children][$j][children][$k][attrs][key])=='room') { $room=$stack[0][children][$i][children][$j][children][$k][attrs][value]; } } } if (($room != 'hidden') and ($showroom=='ALL' or $showroom==$room)) { $Xks=$imgmaxxks; $Yks=$imgmaxyks*4; ##gnuplot if ($showks == $KSdev) {echo "";} else {echo ""; }; echo ""; if (($showks == $KSdev) and $showgnuplot=='1') { if ($kstyp=="1")drawgnuplot($KSdev,"KS300_t1",$gnuplot,$pictype,$logpath); else drawgnuplot($KSdev,"KS300_t2",$gnuplot,$pictype,$logpath); $KSdev1=$KSdev.'1'; echo ""; } } } } ############################ elseif ($stack[0][children][$i][name]=='LOGS') { echo ""; if (isset ($showlogs)) for($j=0; $j < count($stack[0][children][$i][children]); $j++) { $name=$stack[0][children][$i][children][$j][attrs][name]; $definition=$stack[0][children][$i][children][$j][attrs][definition]; if ($definition != "") {echo ""; } } } ############################ elseif ($stack[0][children][$i][name]=='NOTIFICATIONS') { echo ""; if (isset ($shownoti)) for($j=0; $j < count($stack[0][children][$i][children]); $j++) { $event=$stack[0][children][$i][children][$j][attrs][event]; $command=$stack[0][children][$i][children][$j][attrs][command]; $measured=$stack[0][children][$i][children][$j][children][0][attrs][measured]; echo ""; } } ############################ elseif ($stack[0][children][$i][name]=='AT_JOBS') { echo ""; if (isset ($showat)) for($j=0; $j < count($stack[0][children][$i][children]); $j++) { $command=$stack[0][children][$i][children][$j][attrs][command]; $next=$stack[0][children][$i][children][$j][attrs][next]; $order=$command; $order=str_replace("+","@",$order); $order='del at '.$order; if ($next != '') {$nexttxt='('.$next .')';} else {$nexttxt='';}; echo ""; } } }; if ($taillog==1) { echo ""; if (isset ($showhist)) {foreach($tailoutput as $data) echo "";}; }; echo "

$titel
$now
v$pgm3version
FHZ_DEVICE"; if ($showmenu != '1') { echo "show menu";} else { echo "hide menu";} echo "
"; echo "
General:
"; echo "ROOMS "; echo "
"; $counter=0; for($i=0; $i < count($rooms); $i++) { $room=$rooms[$i]; if ($room != 'hidden') { echo""; $counter++; if (fmod($counter,$roommaxiconperline)== 0.0) echo "
"; } else $counter--; } echo "
"; echo "$type
"; for($j=0; $j < count($stack[0][children][$i][children]); $j++) { $fs20=$stack[0][children][$i][children][$j][attrs][name]; $state=$stack[0][children][$i][children][$j][attrs][state]; $room=''; for($k=0; $k < count($stack[0][children][$i][children][$j][children]); $k++) { $check=$stack[0][children][$i][children][$j][children][$k][attrs][name]; if ($check='STATE') { $measured=$stack[0][children][$i][children][$j][children][$k][attrs][measured]; } if ($check='ATTR') { if (($stack[0][children][$i][children][$j][children][$k][attrs][key])=='room') { $room=$stack[0][children][$i][children][$j][children][$k][attrs][value]; } } } if (($state=='on') or ($state=='dimup')) {$order="set $fs20 off";} else {$order="set $fs20 on";}; if (($room != 'hidden') and ($showroom=='ALL' or $showroom==$room)) { $counter++; echo""; if (fmod($counter,$fs20maxiconperline)== 0.0) echo "
"; }; } echo "
"; echo "$type
";} else {echo "
$FHTdev
desired-temp "; echo "


$FHTdev (FHT): $name$value $measured
"; echo "$type
"; } else echo "
"; echo " $HMSdev

"; echo "$type

Temp./Hum.


Wind/Rain


$KSdev "; echo ""; echo "

LOGS"; if (! isset ($showlogs)) { echo "show";} else { echo "hide";} echo "
Log: $definition
NOTIFICATIONS"; if (! isset ($shownoti)) { echo "show";} else { echo "hide";} echo "
Notification:$event $command
AT_JOBS"; if (! isset ($showat)) { echo "show";} else { echo "hide";} echo "
AT-Job: del$command $nexttxt
$taillogorder"; if (! isset ($showhist)) { echo "show";} else { echo "hide";} echo "
History$data
"; ?>