dfi-html/index.php

32 lines
740 B
PHP

<?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;
?>