Hello everyone,
I am creating an html form, where a URL is inserted and an input of type radio.
Url - site to register on the MikroTik
Radio - allow or deny this Url.
<form id="mk1" action="webProxy.php" method="post" >
Site / IP: <input type="text" name="block" />
<input type="radio" name="status" value="allow" />Liberado
<input type="radio" name="status" value="deny" checked />Bloqueado<br />
<input type="submit" value="Enviar" />
</form>
When the form is submitted it is handled by webProxy.php file, which implements the API MikroTik.
<?php
require("routeros_api.class.php");
$API = new routeros_api();
$API ->debug = false;
$url = $_POST["block"];
$acao = $_POST["status"];
if($API ->connect("192.168.88.1", "admin", "admin")){
$API ->write("/ip/proxy/access/add", false);
$API ->write("=dst-host=$url", false);
$API ->write("=action=$acao");
$READ = $API ->read(false);
$ARRAY = $API ->parse_response($READ);
$meuArray = $API ->comm("/ip/proxy/access/print");
$length = count($meuArray);
echo "<table border=2>";
echo "<tr>";
echo "<th>Site</th>";
echo "<th>Status</th>";
echo "<th>Acessos</th>";
echo "<th>Regra Ativa</th>";
echo "<th>Comentario</th>";
echo "</tr>";
for( $i = 0; $i < $length; $i++) {
$primeiro = $meuArray[$i];
echo "<tr>";
echo "<td>" . $primeiro["dst-host"] . "</td>";
echo "<td>" . $primeiro["action"] . "</td>";
echo "<td>" . $primeiro["hits"] . "</td>";
echo "<td>" . $primeiro["disabled"] . "</td>";
echo "<td>" . $primeiro["comment"] . "</td>";
echo "</tr>";
}//fim do for
$API ->disconnect();
echo "</table>";
} //fim do if
?>
webProxy.php takes the attributes that were inserted in the HTML form and add them in the proxy rules of the MikroTik. Yet it is returning an error to me:
Notice: Undefined variable: receiveddone in / var / www / html / routeros_api.class.php on line 325
Notice: Undefined variable: receiveddone in / var / www / html / routeros_api.class.php on line 325
Notice: Undefined variable: receiveddone in / var / www / html / routeros_api.class.php on line 325
What can you guys?
And while thanking everyone for their help.
= ![]()