This commit is contained in:
Christopher 2019-03-07 20:53:21 +01:00
parent ab7677d615
commit 80a26773c1
2 changed files with 52 additions and 0 deletions

32
index.php Normal file
View file

@ -0,0 +1,32 @@
<?php
include "mqtt.php";
$html = file_get_contents("send.html");
if($_REQUEST['text'] != "")
{
$mqtt = new phpMQTT("192.168.88.243", 1883, "dynPHPClient");
if ($mqtt->connect(true, NULL, NULL, NULL))
{
$zeilen = explode("\n", $_REQUEST['text']);
$aktuelleZeile = 1;
foreach ($zeilen as $zeile)
{
if($aktuelleZeile <= 4)
$mqtt->publish("/unhb/dfi/".$aktuelleZeile++, $zeile, 0);
}
$mqtt->close();
$html = str_replace("%%status%%", "<h2><b>Dein Text wurde erfolgreich gesendet.</b></h2>", $html);
} else {
echo "Time out!\n";
}
}else{
$html = str_replace("%%status%%", "", $html);
}
echo $html;
?>

20
send.html Normal file
View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Schreib auf das DFI</title>
</head>
<body>
<form action="index.php" method="post">
<textarea style="width: 400px; height: 65px;" name="text" cols="21" rows="4"></textarea><br>
<button type="submit" name="action" value="0">Send</button>
</form>
<br><br>
%%status%%
</body>
</html>