Halli hallo zusammen,
ich hab ein problem und zwar habe ich irgenntwo in meiner abfrage fürs formular einen fehler, der dafür sorgt, das der browser mir rein garnichts anzeigt :-/
deshalb hier mal das script in der hoffnung man kann mir sagen wo der fehler liegt, suche nun schon seit tagen
edit: die gänsefüßchen hinter checkbox grade selber entdeckt und geändert ... ändert aber nichts am ergebnis :-/
ich hab ein problem und zwar habe ich irgenntwo in meiner abfrage fürs formular einen fehler, der dafür sorgt, das der browser mir rein garnichts anzeigt :-/
deshalb hier mal das script in der hoffnung man kann mir sagen wo der fehler liegt, suche nun schon seit tagen
PHP-Code:
<?php
$debug=1;
$maxtemp=(real)85;
$mintemp=(real)-40;
$maxhum=(real)100;
$minhum=(real)0;
$maxfan=(real)100;
$minfan=(real)0;
$IP=gethostname();
$hiddenIP=$IP;
$buff="";
$alertform="";
$cel="[°C]";
$per="[%]";
$newtartempstr="";
$newtarhumstr="";
$newtarfanstr="";
if($debug===1){
ini_set('display_errors',1);
error_reporting(-1);
echo "first IP: $IP <br>";
}
function readOven($IP, $debug){
if($debug===1){
echo "readOven IP: $IP <br>";
}
$con=fsockopen($IP, 2049, $errno, $errstr);
if($con){
fputs($con, "\$01I\r");
$stream=stream_get_contents($con,131,0);
if($debug===1){echo "debug readOven: $stream <br>";}
fclose($con);
}else{
echo $errno . " ( " . $errstr . " ) ";
$stream="false";
}
return $stream;
}
function sendOven($newtemp, $newhum, $newfan, $buff, $IP, $debug){
$stream=explode(" ", $buff);
$sendstring=$newtemp . " " . $newhum . " " . $newfan . " " . $stream[8] . " " . $stream[9] . " " . $stream[10] . " " . $stream[11] . " " . $stream[14];
if ($debug===1){
echo "debug sendOven IP: $IP<br>";
echo "debug sendOven sendstring: $sendstring<br>";
echo "debug sendOven buff: $buff <br>";
for($i=0;$i<=14;$i++){
echo "debug sendOven stream[$i]: ". $stream[$i] . "<br>";
}
}
if($debug===0){
$con=fsockopen($IP, 2049, $errno, $errstr);
if($con){
fputs($con, "\$01E $sendstring\r");
fclose($con);
}else{
echo $errno . " ( " . $errstr . " ) <br>";
}
}
}
function getFormat($value, $debug){
$newform=sprintf("%1$06.f", $value);
if ($debug===1){
echo "debug newform: $newform <br> var_dump(newform): ";
var_dump($newform);
echo "<br>";
}
return $newform;
}
if($_SERVER["REQUEST_METHOD"]=="POST"){
$IP=$_POST["IP"];
$hiddenIP=$_POST["hiddenIP"];
if($IP!=$hiddenIP){
$alertform="<tr><td colspan=4 align=\"center\">If you change oven<br>please resubmit the new target Values</td></tr>";
$hiddenIP=$IP;
}
else{
$alertform="";
$newtartemp=(real)($_POST["tartemp"]);
$newtarhum=(real)($_POST["tarhum"]);
$newtarfan=(real)($_POST["tarfan"]);
if($newtartemp!=$tartemp){
if($newtartemp<$mintemp){
echo "<script type=\"text/javascript\" language=\"javascript\">
alert(\"temp to low it musst be over -40\");
</script>";
}
else if($newtartemp>$maxtemp){
echo "<script type=\"text/javascript\" language=\"javascript\">
alert(\"temp to high it musst be under 85\");
</script>";
}
else{
$newtempstr=getFormat($newtartemp, $debug);
}
}
else{
$newtartempstr=getFormat($newtartemp, $debug);
}
if($newtarhum!=$tarhum){
if($newtarhum<$minhum){
echo "<script type=\"text/javascript\" language=\"javascript\">
alert(\"humidity to low it musst be over 0\");
</script>";
}
if($newtarhum>$maxhum){
echo "<script type=\"text/javascript\" language=\"javascript\">
alert(\"humidity to high it musst be under 100\");
</script>";
}
else{
$newtarhumstr=getFormat($newtarhum, $debug);
}
}
else{
$newtarhumstr=getFormat($newtarhum, $debug);
}
if($newtarfan!=$tarfan){
if($newtarfan<$minfan){
echo "<script type=\"text/javascript\" language=\"javascript\">
alert(\"fan to low it musst be over 0\");
</script>";
}
else if($newtarfan>$maxfan){
echo "<script type=\"text/javascript\" language=\"javascript\">
alert(\"fan to high it musst be under 100\");
</script>";
}
else{
$newtarfanstr=getFormat($newtarfan, $debug);
}
}
else{
$newtarfanstr=getFormat($newtarfan, $debug);
}
if(!empty($_POST["power"])){
$buff[99]="1";
}
else{
$buff[99]="0";
}
if(!empty($_POST["humcon"){
$buff[100]="1";
}
else{
$buff[100]="0";
}
if(!empty($_POST["condprot"])){
$buff[101]="1";
}
else{
$buff[101]="0";
}
sendOven($newtartempstr, $newtarhumstr, $newtarfanstr, $buff, $IP, $debug);
}
}
$buff=readOven($IP, $debug);
$tartemp=(real)substr($buff, 0,6);
$curtemp=(real)substr($buff,7,6);
$tarhum=(real)substr($buff,14,6);
$curhum=(real)substr($buff,21,6);
$tarfan=(real)substr($buff,28,6);
$curfan=(real)substr($buff,35,6);
$power=(int)substr($buff,99,1);
$humcon=(int)substr($buff,100,1);
$condprot=(int)substr($buff,101,1);
$reload="onclick=\'document.location=\"ovenmanagementv0_1.php\"\'";
$checked='checked="checked"';
$powercheck=($power===1) ? $checked: "";
$humcheck=($humcon===1) ? $checked: "";
$condcheck=($condprot===1) ? $checked: "";
echo <<< BODY
<head>
<title>online-oven-Management</title>
</head>
<body>
<p align="center"><span style="color:#00FF00">ONLINE-OVEN-MANAMENT</span></p>
<form method="POST" action="ovenmanagementv0_1.php" align="center">
<table boarder=0 align="center">
<tr>
<td>Hostname</td>
<td colspan=3 align="center"><input name="IP" size=3 value=$IP></td>
</tr>
<tr>
<td colspan=4 align="center"><input type="hidden" name="hiddenIP" value=$IP></td>
</tr>
<tr>
<td></td>
<td></td>
<td>Target</td>
<td>Current</td>
</tr>
<tr>
<td>Temp</td>
<td>$cel</td>
<td><input name="tartemp" size=1 value=$tartemp></td>
<td>$curtemp</td>
</tr>
<tr>
<td>Humidity</td>
<td>$per</td>
<td><input name="tarhum" size=1 value=$tarhum></td>
<td>$curhum</td>
</tr>
<tr>
<td>Fan</td>
<td>$per</td>
<td><input name="tarfan" size=1 value=$tarfan></td>
<td>$curfan</td>
</tr>
<tr>
<td>Power</td>
<td><input type="checkbox" name="power" $powercheck></td>
</tr>
<tr>
<td>Humidity Control</td>
<td><input type="checkbox" name="humcon" $humcheck></td>
</tr>
<tr>
<td>Condensation Prot,</td>
<td><input type="checkbox" name="condprot" $condcheck></td>
</tr>
$alertform
</table>
</form>
</body>
BODY;
?>
Kommentar