$ss) $ret= true; $sr= date_sunrise(time(), SUNFUNCS_RET_TIMESTAMP, $lat, $long, $zenith); if (time() < $sr) $ret= true; $error= null; if ($values['To']>50) $error= "To too high"; if ($values['To']>$values['Tomax']) $error= "To > Tomax"; if ($values['To']<$values['Tomin']) $error= "To < Tomin";; if ($values['RP']>1200) $error= "Rp too high"; if ($values['RP']<800) $error= "Rp too low"; if ($values['RHo']>105) $error= "RHo too high"; if (!$error == null) { $txtfile= fopen("/var/www/addicted/fileadmin/webcam/kochelsee/wetter/test.txt", "a"); fwrite($txtfile, date("m.d.y H:i:s")." No valid wx data.\n $error"); fclose($txtfile); exit; } $dbhost = 'localhost'; $dbuser = 'addictedmysql'; $dppass = 'WAvQ4hpAS5m73vQ6'; $conn = mysql_connect($dbhost, $dbuser,$dppass) or die ('Error connecting to mysql'); $dbname = 'addicted'; mysql_select_db($dbname); $time=time(); if (($values["WSmin"]*0.539956803>12 or $values["WSmax"]*0.539956803>18) and $ret==false){ exec("touch $windfile"); } $values[DIR0]=$values[DIR0]+112; if ($values[DIR0]>360)$values[DIR0]=$values[DIR0]-360; mysql_query("INSERT INTO tx_webcam_wetter(pid,tstamp,crdate,cruser_id,tempin,tempout,dp,rhi,rho,ws,wc,r1h,r24h,rtot,rp,dir0,minws,maxws,forecast) VALUES ('172','$time','$time','2','$values[Ti]','$values[To]','$values[DP]','$values[RHi]','$values[RHo]','$values[WS]','$values[WC]','$values[R1h]','$values[R24h]','$values[Rtot]','$values[RP]','$values[DIR0]','$values[WSmin]','$values[WSmax]','$values[Forecast]')"); mysql_close($conn); $richtung=$values[DIR0]; if (($richtung < 22.5) or($richtung >= 337.5)) $w_text = "N"; if (($richtung < 67.5) and($richtung >= 22.5)) $w_text = "NO"; if (($richtung < 125.5) and($richtung >= 67.5)) $w_text = "O"; if (($richtung < 157.5) and($richtung >= 125.5)) $w_text = "SO"; if (($richtung < 202.5) and($richtung >= 157.5)) $w_text = "S"; if (($richtung < 247.5) and($richtung >= 202.5)) $w_text = "SW"; if (($richtung < 292.5) and($richtung >= 247.5)) $w_text = "W"; if (($richtung < 337.5) and($richtung >= 292.5)) $w_text = "NW"; $txtfile= fopen("/var/www/addicted/fileadmin/webcam/kochelsee/wetter/cam.txt", "w"); $tempFile=fopen($wetterPath."temp.txt", "w"); $windMessungFile=fopen($wetterPath."wind.txt", "w"); if ($txtfile) { $txt= ""; fwrite($tempFile,$values["To"]); fwrite($windMessungFile,round($values["WSmin"]*0.539956803,2)."-".round($values["WSmax"]*0.539956803,2)); fclose($tempFile); fclose($windMessungFile); //$rp = substr($values["RP"],0,-4); fwrite($txtfile,"Wind:".round($values["WSmin"]*0.539956803,2)."kts Böe:".round($values["WSmax"]*0.539956803,2)."kts ".$values["To"]."°"); fclose($txtfile); } $txtfile= fopen("/var/www/addicted/fileadmin/webcam/kochelsee/wetter/test.txt", "a"); fwrite($txtfile, date("d.m.y H:i:s")." OK!.\n"); fclose($txtfile); exec("ssh kochel minmax2300 wmax"); exec("ssh kochel minmax2300 wmin"); ?>