easy-osm2city-podman/managment/www/progressinfo.php
fly a87812615a Show API result directly instead of a new tab
Signed-off-by: fly <merspieler@airmail.cc>
2023-10-26 10:18:59 +00:00

93 lines
2.3 KiB
PHP

<?php
session_start();
include("config.php");
// Returns numbers in string format as needed for file names
function clipNumber($number, $length)
{
$number = abs($number) . "";
while (strlen($number) < $length)
{
$number = "0" . $number;
}
return $number;
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body id="infobody">
<?php
if (!isset($_GET['minor']))
{
echo "No tile selected";
}
else
{
$tile = $_GET['minor'];
preg_match_all('/([we])(\d{3})([sn])(\d{2})/m', $tile, $matches, PREG_SET_ORDER, 0);
$we = $matches[0][1];
$lon = (int)$matches[0][2];
$sn = $matches[0][3];
$lat = (int)$matches[0][4];
if ($we == "w")
{
$lon *= -1;
}
if ($sn == "s")
{
$lat *= -1;
}
// Connect to DB
$con = new mysqli($SQL_SERVER, $SQL_USER, $SQL_PASSWORD, $SQL_DATABASE, $SQL_PORT);
if ($con->connect_error)
{
quit();
}
echo '<div id="tablecontainer">';
$stmt = $con->prepare("SELECT status.name AS status FROM secondLevel JOIN status ON secondLevel.status_id = status.id WHERE secondLevel.name = ?");
$stmt->bind_param("s", $tile);
$stmt->execute();
$result = $stmt->get_result();
$ret = $result->fetch_all(MYSQLI_ASSOC);
$curStatus = Null;
foreach ($ret as $row)
{
$curStatus = $row["status"];
}
echo '<form method="post" action="api.php" target="api">
<label>Update Area</label> ' . $_GET['minor'] . '<br/>';
if(!isset($_SESSION["token"]))
{
echo '<input type="text" name="auth" placeholder="Token"/><br/>';
}
echo '<input type="hidden" name="action" value="set"/>
<input type="hidden" name="area" value="' . $_GET["minor"] . '"/>
<select name="status">';
$sql = "SELECT name FROM status ORDER BY priority";
$ret = $con->query($sql)->fetch_all(MYSQLI_ASSOC);
if ($ret != False)
{
foreach($ret as $row)
{
echo '<option value="' . $row["name"] . '"';
if ($row["name"] == $curStatus)
{
echo ' selected';
}
echo '>' . $row["name"] . '</option>';
}
}
echo '</select>
<input type="submit" value="Update"/>
</form>';
echo '</div>';
}
?>
<br/><br/>
<div>
<iframe id="api" name="api" style="border: 0px;" src=""/>
</div>
</body>
</html>