Code:
<?php
//DEBUG
/*
echo "<pre>";
print_r($_GET);
echo "</pre>";
*/
if ($_GET['submit'] == "Absenden"){
//$bitmuster = hex2bin($rtmp).'0000';
$bitmuster = '00000000';
if ($_GET['relais1'] == '1') $bitmuster = substr_replace($bitmuster, '1', 0, 1);
if ($_GET['relais2'] == '1') $bitmuster = substr_replace($bitmuster, '1', 1, 1);
if ($_GET['relais3'] == '1') $bitmuster = substr_replace($bitmuster, '1', 2, 1);
if ($_GET['relais4'] == '1') $bitmuster = substr_replace($bitmuster, '1', 3, 1);
if ($_GET['relais5'] == '1') $bitmuster = substr_replace($bitmuster, '1', 4, 1);
if ($_GET['relais6'] == '1') $bitmuster = substr_replace($bitmuster, '1', 5, 1);
if ($_GET['relais7'] == '1') $bitmuster = substr_replace($bitmuster, '1', 6, 1);
if ($_GET['relais8'] == '1') $bitmuster = substr_replace($bitmuster, '1', 7, 1);
//echo $bitmuster."<br>";
//Relais setzen
exec('/opt/bin/pport -s '.$bitmuster.' 2>&1 1> /dev/null');
//Bitmuster sichern (Reboot)
$dateiname = "/opt/bin/pport-boot.sh"; // Name der Datei
// Datei öffnen,
// wenn nicht vorhanden dann wird die Datei erstellt.
$handler = fOpen($dateiname , "w");
// Dateiinhalt in die Datei schreiben
fWrite($handler , "#!/bin/sh\n/opt/bin/pport -s ".$bitmuster."\n");
chmod ($dateiname, 0755 );
fClose($handler); // Datei schließen
}
else {
$rtmp = exec('/opt/bin/pport -r', $retval);
//echo "hex: ".$rtmp."<br>";
$rtmp = hexdec($rtmp);
//echo "dec: ".$rtmp."<br>";
$rtmp = decbin($rtmp);
$bitmuster = $rtmp;
//echo "bin: ".str_pad($rtmp,8,"0",STR_PAD_LEFT)."<br>";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>WL500G IO-K8</title>
</head>
<body>
<form action="./index.php" enctype="multipart/form-data" method="get" name="relais1-8">
<table border="0" cellpadding="0" cellspacing="0" width="240">
<tr><td><h4 style="font-family:arial;font-size:12pt;">IO-8-Kanal Settings</h4></td></tr>
<tr><hr width="240"></td></tr>
<tr><td style="font-family:arial;font-size:10pt"><input type="checkbox" name="relais1" value="1" <?if (substr($bitmuster, 0, 1) == '1') echo "checked"?>> Relais 1 - Heizung (1 KW)</td></tr>
<tr><td style="font-family:arial;font-size:10pt"><input type="checkbox" name="relais2" value="1" <?if (substr($bitmuster, 1, 1) == '1') echo "checked"?>> Relais 2 - Heizung (2 KW)</td></tr>
<tr><td style="font-family:arial;font-size:10pt"><input type="checkbox" name="relais3" value="1" <?if (substr($bitmuster, 2, 1) == '1') echo "checked"?>> Relais 3 - Heizung (Gas)</td></tr>
<tr><td style="font-family:arial;font-size:10pt"><input type="checkbox" name="relais4" value="1" <?if (substr($bitmuster, 3, 1) == '1') echo "checked"?>> Relais 4 - Car-PC</td></tr
<tr><td style="font-family:arial;font-size:10pt"><input type="checkbox" name="relais5" value="1" <?if (substr($bitmuster, 4, 1) == '1') echo "checked"?>> Relais 5 - 12V Versorung</td</tr>
<tr><td style="font-family:arial;font-size:10pt"><input type="checkbox" name="relais6" value="1" <?if (substr($bitmuster, 5, 1) == '1') echo "checked"?>> Relais 6 - 12V/220V Wandler</d></tr>
<tr><td style="font-family:arial;font-size:10pt"><input type="checkbox" name="relais7" value="1" <?if (substr($bitmuster, 6, 1) == '1') echo "checked"?>> Relais 7 - Dachklima</td></tr> <tr><td style="font-family:arial;font-size:10pt"><input type="checkbox" name="relais8" value="1" <?if (substr($bitmuster, 7, 1) == '1') echo "checked"?>> Relais 8 - frei</td></tr>
<tr><td><hr width="240"></td></tr>
<tr><td style="font-family:arial;font-size:10pt"><input type="reset" value="Abbrechen"> <input type="submit" name="submit" value="Absenden"></td></tr>
<tr><td><hr width="240"></td></tr>
</table>
</form>
</body>
</html>
Bei mir soll das ganze z. B. zur "Fernsteuerung" verschiedener Geräte in