\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); } } #print_r($output); #exit; # 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); #searching for rooms/fs20 $rooms=array(); $fs20devs=array(); $fhtdevs=array(); if ($showroombuttons==1) for($i=0; $i < count($stack[0][children]); $i++) { if ((substr($stack[0][children][$i][name],0,5)=='FS20_') || (substr($stack[0][children][$i][name],0,4)=='X10_')) { 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 (substr($stack[0][children][$i][name],0,4)=='FHT_') { 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 (substr($stack[0][children][$i][name],0,4)=='HMS_') { 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 (substr($stack[0][children][$i][name],0,6)=='SCIVT_') { 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); } } } } # SCIVT elseif (substr($stack[0][children][$i][name],0,6)=='KS300_') { 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 in the array from fhem # user defined rooms? if ($UserDefs==1) { for($i=0; $i < count($userdef); $i++) { $room=$userdef[$i]['room']; if (! in_array($room,$rooms)) array_push($rooms,$room); } } array_push($rooms,'ALL'); sort($rooms); #print_r($rooms); echo "Count: $countrooms"; exit; #print_r($fs20devs); exit; #echo count($stack[0][children]);exit; # Print Array on Screen $now=date($timeformat); # only RSS-Feeds?? if (isset($showrss)) { include "include/rssfeeds.php"; exit; } ###### write the header on screen echo " $titel"; include ("include/style.css"); echo " "; echo" $errormessage
"; ###################### Webcam if ($showwebcam==1) { echo " "; }; ############################ FHZ if ($show_fs20pulldown==1 or $show_general==1 or $show_fhtpulldown==1) { echo ""; } if ($showmenu=='1') { if ($show_general=='1') {echo " "; }; if ($show_fs20pulldown=='1') include 'include/fs20pulldown.php'; if ($show_fhtpulldown=='1') include 'include/fhtpulldown.php'; }; ############################ ROOMS if (($showroombuttons==1) and (count($rooms)>1)) { echo ""; echo ""; } ##################################################################################################################### ##### Check Version of FHEM if (! ($stack[0][children][0][name]=='_internal__LIST')) ##older FHZ100 have no Internal_LIST {echo "Error!! There is no FHEM. You need at least FHEM-4.0 to run this pgm3!!";} ##### Let's go.... :-))))) for($i=0; $i < count($stack[0][children]); $i++) { ############################ if ((substr($stack[0][children][$i][name],0,5)=='FS20_') || (substr( $stack[0][children][$i][name],0,4)=='X10_')) { $type=$stack[0][children][$i][name]; echo ""; $counter=0; echo ""; if (isset($showfs20) and $showgnuplot == 1) { drawgnuplot($showfs20,"FS20",$gnuplot,$pictype,$logpath, $FHTyrange,$FHTy2range); $FS20dev1=$showfs20.'1'; echo ""; } } ############################ elseif (substr($stack[0][children][$i][name],0,4)=='FHT_') { $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 ""; } else {echo ""; }; echo ""; echo ""; if ($showfht==$FHTdev and $showgnuplot == 1) { drawgnuplot($FHTdev,"FHT",$gnuplot,$pictype,$logpath, $FHTyrange,$FHTy2range); $FHTdev1=$FHTdev.'1'; echo ""; } if ( $showfht==$FHTdev) { echo ""; } } } } ############################ elseif (substr($stack[0][children][$i][name],0,4)=='HMS_') { $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][key]=="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,0,0); $HMSdev1=$HMSdev.'1'; echo ""; } } } } ############################ elseif (substr($stack[0][children][$i][name],0,6)=='KS300_' or substr($stack[0][children][$i][name],0,6)=='WS300_') { $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][key]; $check2=$stack[0][children][$i][children][$j][children][$k][attrs][name]; if ($check=='room') $room=$stack[0][children][$i][children][$j][children][$k][attrs][value]; elseif ($check=='willi') $willi=1; elseif ($check=='avg_day') $KSavgday=$stack[0][children][$i][children][$j][children][$k][attrs][value]; elseif ($check=='temperature') $KSmeasured=$stack[0][children][$i][children][$j][children][$k][attrs][measured]; elseif ($check=='avg_month') $KSavgmonth=$stack[0][children][$i][children][$j][children][$k][attrs][value]; # for older versions... if ($check2=='avg_month') $KSavgmonth=$stack[0][children][$i][children][$j][children][$k][attrs][value]; elseif ($check2=='avg_day') $KSavgday=$stack[0][children][$i][children][$j][children][$k][attrs][value]; elseif ($check2=='temperature') $KSmeasured=$stack[0][children][$i][children][$j][children][$k][attrs][measured]; elseif ($check2=='willi') $willi=1; } if (($room != 'hidden') and ($showroom=='ALL' or $showroom==$room)) { $Xks=$imgmaxxks; $Yks=$imgmaxyks*4; ##gnuplot if ($showks == $KSdev) {echo "";} else {echo ""; }; echo ""; if (! isset ($willi)) $drawtype="KS300"; else $drawtype="WS300"; if (($showks == $KSdev) and $showgnuplot=='1') { if ($kstyp=="1") { drawgnuplot($KSdev,$drawtype."_t1",$gnuplot,$pictype,$logpath,0,0); } else { drawgnuplot($KSdev,$drawtype."_t2",$gnuplot,$pictype,$logpath,0,0); } $KSdev1=$KSdev.'1'; echo ""; } } } } ############################ elseif ($stack[0][children][$i][name]=='LOGS'or $stack[0][children][$i][name]=='FileLog_LIST') { echo ""; if (isset ($showlogs)) 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][key]; if ($check=='DEF') { $value=$stack[0][children][$i][children][$j][children][$k][attrs][value]; } } $name=$stack[0][children][$i][children][$j][attrs][name]; echo ""; } } ############################ elseif ($stack[0][children][$i][name]=='NOTIFICATIONS' or $stack[0][children][$i][name]=='notify_LIST') { echo ""; if (isset ($shownoti)) 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][key]; if ($check=='DEF') { $value=$stack[0][children][$i][children][$j][children][$k][attrs][value]; } } $name=$stack[0][children][$i][children][$j][attrs][name]; echo ""; } } ############################ elseif ($stack[0][children][$i][name]=='AT_JOBS' or $stack[0][children][$i][name]=='at_LIST') { echo ""; if (isset ($showat)) for($j=0; $j < count($stack[0][children][$i][children]); $j++) { $command=$stack[0][children][$i][children][$j][attrs][name]; $next=$stack[0][children][$i][children][$j][attrs][state]; $order=$command; 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=='DEF') { $value=$stack[0][children][$i][children][$j][children][$k][attrs][value]; } } $order='delete '.$order; echo ""; } } }; ## that is all of fhem ##################### User defined graphics?? if ($UserDefs==1) { echo ""; $type='userdef'; for($i=0; $i < count($userdef); $i++) { $room=$userdef[$i]['room']; $UserDef=$userdef[$i]['name']; $imgmaxxuserdef=$userdef[$i]['imagemax']; $imgmaxyuserdef=$userdef[$i]['imagemay']; if (($room != 'hidden') and ($showroom=='ALL' or $showroom==$room)) { if ($showuserdefgnu== $UserDef) {$formvalue="hide";$gnuvalue="";} else {$formvalue="show";$gnuvalue=$UserDef;}; echo ""; if ($showuserdefgnu == $UserDef and $showgnuplot == 1) { drawgnuplot($UserDef,$type,$gnuplot,$pictype,$logpath,$userdef[$i],$i); $UserDef1=$UserDef.'1'; echo ""; } }# /not room hidden } } #/userdefs ##################### taillog if ($taillog==1) { echo ""; if (isset ($showhist)) {foreach($tailoutput as $data) echo "";}; }; echo "

$titel
$now
v$pgm3version
WEBCAM "; if (! isset($showpics)) { echo "show pics";} else { echo "hide pics";} echo" "; if (isset($showpics)) { for($i=0; $i < count($webcam); $i++) { $webcam1=$webcam[$i]; $pos = strpos($webcam1,'://'); # e.g. http://.. if ($pos === false) # picture instead of an URL { $webcamname=$webcam[$i]; } else { $webcamname=str_replace("/","",$webcam1); $webcamname=str_replace(":","",$webcamname); # $order="$wgetpath -O tmp/$webcamname $webcam1; /usr/bin/touch tmp/$webcamname"; $order="$wgetpath -O tmp/$webcamname $webcam1"; exec($order,$res); $errormessage = $res[0]; echo $errormessage; } echo""; } } echo"
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
adjust
adjust


"; for($k=0; $k < count($stack[0][children][$i][children][$j][children]); $k++) { $name=$stack[0][children][$i][children][$j][children][$k][attrs][key]; $value=$stack[0][children][$i][children][$j][children][$k][attrs][value]; $measured=$stack[0][children][$i][children][$j][children][$k][attrs][measured]; echo ""; } echo "
$FHTdev (FHT): $name$value $measured
"; echo "$type
"; } else {echo "
";} echo "

"; echo "$type
"; echo "
Temp./Hum.


"; if (! isset ($willi)) echo "Wind/Rain
"; else echo "Air Pressure/ Willi
"; echo "

"; echo "
"; echo ""; echo "

LOGS"; if (! isset ($showlogs)) { echo "show";} else { echo "hide";} echo "
Log: $value / $name
NOTIFICATIONS"; if (! isset ($shownoti)) { echo "show";} else { echo "hide";} echo "
Notification:$value / $name
AT_JOBS"; if (! isset ($showat)) { echo "show";} else { echo "hide";} echo "
AT-Job: del$value / $next / $command
USER DEFINED
"; echo "

$taillogorder"; if (! isset ($showhist)) { echo "show";} else { echo "hide";} echo "
History$data
"; ?>