generic start

This commit is contained in:
Walter Hupfeld
2021-10-27 15:01:27 +02:00
parent 4c54b396ac
commit e958343004
12 changed files with 86 additions and 17 deletions
+7
View File
@@ -3,3 +3,10 @@
RedirectMatch 404 /\.git
RedirectMatch 404 /db
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ index.php?d=$1 [QSA]
+5 -8
View File
@@ -8,20 +8,17 @@ date_default_timezone_set('UTC');
$db_server = "mariadb";
$db_user = "unfallstatistik";
$db_passwd = "BCJloVozJbdDHQTS";
$db_server = "localhost";
$db_user = "root";
$db_passwd = "g0r@w@";
$db = "unfallstatistik";
try {
$db = new PDO('mysql:host='.$db_server.';dbname='.$db.';charset=utf8mb4', $db_user, $db_passwd);
} catch (PDOException $e) {echo "Fehler: ".$e->getMessage(); die();}
$strTitle = "Unfallkarte Soest ";
$strIntroText = "Unfallkarte für die Stadt Soest basierend auf den Daten des Statistischen Bundesamtes.";
$numInfoLat =51.5718;
$numInfoLng =8.10716;
$numZoom=12;
$fileGeojson ="geojson/soest.geojson";
$strLocation = " AND ULAND=5 AND UREGBEZ=9 AND UKREIS=74 AND UGEMEINDE=40 ";
$arrVehicles = array (
1 => "Fahrrad",
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+66 -9
View File
@@ -3,12 +3,60 @@
require("config.php");
require_once("lib/functions.php");
$strIntro ="<h4>".$strTitle."</h4>";
$strIntro .= nl2br2($strIntroText);
$numYear=2020;
$numYear="2020";
$strDistrict = (isset($_GET['d'])) ? $_GET['d'] : "Hamm";
$numVehicle = (isset($_GET['v'])) ? (int) $_GET['v'] : 1;
$numYear = (isset($_GET['year'])) ? (int) $_GET['year'] : $numYear;
$result= $db->prepare("SELECT count(*) FROM district WHERE district=:district");
$result->bindParam(":district",$strDistrict);
$result->execute();
if ($row=$result->fetch(PDO::FETCH_NUM)) {
if ($row[0]==0) $strDistrict="hamm";
}
//$result = $db->query($strSQL);
$result= $db->prepare("SELECT * FROM district WHERE district=:district");
$result->bindParam(":district",$strDistrict);
$result->execute();
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$strDistrict = $row['district'];
$strTitle = $row['title'];
$strGeojson = $row['geojson'];
$numULAND=$row['ULAND'];
$numUREGBEZ=$row['UREGBEZ'];
$numUKREIS=$row['UKREIS'];
$numUGEMEINDE=$row['UGEMEINDE'];
$numInfoLat=$row['lat'];
$numInfoLng=$row['lng'];
$numZoom=$row['zoom'];
$strTitle = "Unfallkarte $strTitle ";
$strIntroText = "Unfallkarte für die Stadt $strTitle basierend auf den Daten des Statistischen Bundesamtes.";
$fileGeojson ="geojson/$strGeojson";
$strLocation = " AND ULAND=$numULAND AND UREGBEZ=$numUREGBEZ AND UKREIS=$numUKREIS ";
if ($numUGEMEINDE>0) {
$strLocation .= "AND UGEMEINDE=$numUGEMEINDE";
}
}
$arrDisctrict = array ();
$strSQL = "SELECT district,title FROM district ORDER BY title ASC";
$result=$db->query($strSQL);
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$arrDistrict[$row['district']]=$row['title'];
}
$strIntro ="<h4>".$strTitle."</h4>";
$strIntro .= nl2br2($strIntroText);
switch ($numVehicle) {
case 1:
@@ -43,7 +91,6 @@
$strYear = " AND UJAHR='".$numYear."' ";
$strSQL="SELECT * FROM data WHERE ".$strWhere.$strYear.$strLocation;
echo $strSQL;
$result = $db->query($strSQL);
@@ -101,8 +148,8 @@
<!-- Navbar -->
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#"><?= $strTitle ?></a>
<a class="navbar-brand" href="index.php?year=2019&v=<?=$numVehicle?>">2019</a>
<a class="navbar-brand" href="index.php?year=2020&v=<?=$numVehicle?>">2020</a>
<a class="navbar-brand" href="index.php?year=2019&v=<?=$numVehicle?>&d=<?=$strDistrict?>">2019</a>
<a class="navbar-brand" href="index.php?year=2020&v=<?=$numVehicle?>&d=<?=$strDistrict?>">2020</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbars" aria-controls="navbars" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
@@ -115,13 +162,21 @@
?>
<li class="nav-item <?=$strActive?>">
<a class="nav-link" href="index.php?v=<?=$key?>&year=<?=$numYear?>"><?=$strVehicle?>
<a class="nav-link" href="index.php?v=<?=$key?>&year=<?=$numYear?>&d=<?=$strDistrict?>"><?=$strVehicle?>
<span class="sr-only">(current)</span> </a>
<?php endforeach; ?>
</ul>
<div>
<form method="GET" action="index.php">
<select name="d" style="float:left;margin-top:0.5em;margin-right:0.5em;" onchange="this.form.submit()">
<?php foreach ($arrDistrict as $key => $strTitle):
$strActive = ($strDistrict==$key) ? "selected=\"selected\"" : ""; ?>
<option value="<?=$key?>" <?=$strActive?>><?=$strTitle?></option>
<?php endforeach; ?>
</select>
</from>
<ul class="navbar-nav mr-auto right">
<li class="nav-item">
<a class="nav-link" href="impressum.php">Impressum</a>
@@ -263,7 +318,9 @@
})
function myFunction(chosen) {
console.log(chosen);
}
</script>