2021-04-09 21:21:53 +02:00
< ? php
include ( " config.php " );
2022-05-03 00:33:31 +02:00
// 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 ;
}
2021-04-09 21:21:53 +02:00
if ( isset ( $_GET [ 'tile' ]))
{
$tile = $_GET [ 'tile' ];
}
else
{
$tile = " None " ;
}
?>
<! DOCTYPE html >
< html >
< head >
< link rel = " stylesheet " type = " text/css " href = " style.css " />
</ head >
2022-05-03 00:33:31 +02:00
< body id = " infobody " >
2021-04-09 21:21:53 +02:00
< ? php
if ( $tile == " None " )
{
echo " No tile selected " ;
}
else
{
2022-05-03 00:33:31 +02:00
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 ;
}
echo ' <! DOCTYPE svg PUBLIC " -//W3C//DTD SVG 1.1//EN " " http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd " >
< svg width = " 450 " height = " 450 " version = " 1.1 " xmlns = " http://www.w3.org/2000/svg " >
< image width = " 450 " height = " 450 " href = " https://ows.terrestris.de/osm/service?VERSION=1.3.0&SERVICE=WMS&REQUEST=GetMap&LAYERS=OSM-WMS&STYLES=&CRS=EPSG:4326&BBOX=' . (string) $lat . ',' . (string) $lon . ',' . (string)( $lat + 10) . ',' . (string)( $lon + 10) . '&WIDTH=450&HEIGHT=450&FORMAT=image/png " /> ' ;
2021-04-09 21:21:53 +02:00
// Connect to DB
$con = new mysqli ( $SQL_SERVER , $SQL_USER , $SQL_PASSWORD , $SQL_DATABASE , $SQL_PORT );
if ( $con -> connect_error )
{
quit ();
}
2022-05-03 00:33:31 +02:00
$stmt = $con -> prepare ( " SELECT secondLevel.name AS name, status.color AS color FROM secondLevel JOIN status ON secondLevel.status_id = status.id WHERE secondLevel.parent_id = (SELECT id FROM topLevel WHERE name = ?) " );
$stmt -> bind_param ( " s " , $tile );
$stmt -> execute ();
$result = $stmt -> get_result ();
$ret = $result -> fetch_all ( MYSQLI_ASSOC );
if ( $ret != False )
{
$tiles = [];
foreach ( $ret as $row )
{
$tiles [ $row [ " name " ]] = $row [ " color " ];
}
$y = 405 ;
for ( $i = $lat ; $i < $lat + 10 ; $i ++ )
{
$x = 0 ;
for ( $j = $lon ; $j < $lon + 10 ; $j ++ )
{
$name = $we . clipNumber ( $j , 3 ) . $sn . clipNumber ( $i , 2 );
2022-05-10 13:11:37 +02:00
echo '<a href="progressinfo.php?tile=' . $tile . '&minor=' . $name . '" target="progressinfo"><rect x="' . $x . '" y="' . $y . '" width="45" height="45" style="fill: ' . $tiles [ $name ] . '; opacity: 0.5;"/></a>' ;
2022-05-03 00:33:31 +02:00
$x += 45 ;
}
$y -= 45 ;
}
}
2022-05-03 12:56:28 +02:00
for ( $i = 45 ; $i < 450 ; $i += 45 )
{
echo '<line x1="' . $i . '" y1="0" x2="' . $i . '" y2="450" style="stroke:rgb(0,255,0); stroke-width:1" />' ;
echo '<line x1="0" y1="' . $i . '" x2="450" y2="' . $i . '" style="stroke:rgb(0,255,0); stroke-width:1" />' ;
}
2022-05-03 00:33:31 +02:00
echo '</svg>' ;
2021-06-03 01:26:10 +02:00
$stmt = $con -> prepare ( " SELECT status.name AS status, COUNT(*) AS sCount, status.color AS color FROM secondLevel JOIN status ON secondLevel.status_id = status.id WHERE secondLevel.parent_id = (SELECT id FROM topLevel WHERE name = ?) GROUP BY status.id ORDER BY priority " );
2021-04-09 21:21:53 +02:00
$stmt -> bind_param ( " s " , $tile );
$stmt -> execute ();
$result = $stmt -> get_result ();
$ret = $result -> fetch_all ( MYSQLI_ASSOC );
2022-05-10 13:11:37 +02:00
echo '<div id="tablecontainer"><table border="1"><tr><td>Tile Name</td><td>' . $tile . '</td></tr>' ;
2021-04-09 21:21:53 +02:00
foreach ( $ret as $row )
{
echo '<tr style="background-color: ' . $row [ " color " ] . '"><td>' . $row [ " status " ] . '</td><td>' . $row [ " sCount " ] . '</td></tr>' ;
}
2022-05-10 13:11:37 +02:00
if ( isset ( $_GET [ " minor " ]))
{
$sql = 'SELECT * FROM information_schema.tables WHERE table_name = "tile" AND table_schema = "' . $SQL_DATABASE . '"' ;
$ret = $con -> query ( $sql ) -> fetch_all ( MYSQLI_ASSOC );
if ( ! empty ( $ret ))
{
$stmt = $con -> prepare ( " SELECT status.name AS status, COUNT(*) AS sCount, status.color AS color FROM tile JOIN status ON tile.status_id = status.id WHERE tile.parent_id = (SELECT id FROM secondLevel WHERE name = ?) GROUP BY status.id ORDER BY priority " );
$stmt -> bind_param ( " s " , $_GET [ " minor " ]);
$stmt -> execute ();
$result = $stmt -> get_result ();
$ret = $result -> fetch_all ( MYSQLI_ASSOC );
echo '</table>' ;
echo '<table border="1"><tr><td>Tile Name</td><td>' . $_GET [ " minor " ] . '</td></tr>' ;
foreach ( $ret as $row )
{
echo '<tr style="background-color: ' . $row [ " color " ] . '"><td>' . $row [ " status " ] . '</td><td>' . $row [ " sCount " ] . '</td></tr>' ;
}
}
2023-01-23 12:53:49 +01:00
echo '</table>' ;
// if (isset($_POST["form"]))
// {
echo ' < form method = " post " action = " api.php " target = " _blank " >
< label > Update Area </ label >
< input type = " text " name = " auth " placeholder = " Token " />< br />
< 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 " ] . '">' . $row [ " name " ] . '</option>' ;
}
}
echo ' </ select >
< input type = " submit " value = " Update " />
</ form > ' ;
// }
2022-05-10 13:11:37 +02:00
}
2023-01-23 12:53:49 +01:00
echo '</div>' ;
2021-04-09 21:21:53 +02:00
}
?>
</ body >
</ html >