Alter Version

This commit is contained in:
Walter Hupfeld
2024-02-16 15:35:01 +01:00
parent 6e85cec1da
commit 0df6729f8b
393 changed files with 173746 additions and 6 deletions

25
lib/dialog_comment.php Normal file
View File

@@ -0,0 +1,25 @@
<div id="dialog_comment" class="card" title="Kommentar">
<div class="card-header">Ihr Kommentar
<span id="close_comment" type="button" class="close right text-danger">
<i class="fa fa-window-close"></i>
</span>
</div>
<div class="card-body">
<form id="commentform" action="#" method="post" >
<fieldset style="border: none;">
<p>
<label for=comment_username"><strong>Ihr Name oder Pseudonym:</strong></label><br>
<input type="text" name="comment_username" maxlength="16" id="comment_username" placeholder="Name" class="text" required="required">
<input type="hidden" name="loc_id" id="loc_id" value="999">
</p>
<label for="description"><strong>Kommentar:</strong></label><br>
<textarea name="comment" id="comment" maxlength="1001" placeholder="Ihr Kommentar" required="required"></textarea>
<br>
<input type="submit" value ="Absenden" class="btn btn-primary" tabindex="-1">
</fieldset>
</form>
</div>
</div>

View File

@@ -0,0 +1,66 @@
<style>
#dialog_defect {
display: none;
position: absolute;
top: 30px;
left: 40px;
width: 500px;
z-index: 1200;
background-color: #efefef;
}
#description {
width: 28em;
height: 10em;
}
</style>
<div id="dialog_defect" class="card" title="Eintrag editieren">
<div class="card-header">Eintrag editieren
<span id="hint"></span>
<span id="close" type="button" class="close right text-danger">
<i class="fa fa-window-close"></i>
</span>
</div>
<div class="card-body">
<form id="editobjectform" enctype="multipart/form-data" action="#" method="post" >
<!-- Beschreibung ---------------------------------- -->
<label for="description"><strong>Beschreibung:</strong></label><br>
<textarea name="description" id="description" maxlength="1001" required="required"></textarea>
<!-- Mängelkategorie -------------------------------- -->
<?php if ($boolDefect): ?>
<p id="defect">
<label for="defect"><strong>Mängelkategorie:</strong></label>
<select name="defect">
<?php
foreach ($arrDefect as $defectKey => $defectVal) {
echo " <option value='$defectKey'>$defectVal</option>";
}
?>
</select>
</p>
<?php endif; ?>
<!-- Dateiupload ---------------------------------- -->
<?php if ($boolUpload): ?>
<label><strong>Bildupload:</strong></label>
<input type="file" id="photo" name="uploadfile" size="60" maxlength="255" />
<?php endif; ?>
<!-- Einverständnis ---------------------------------- -->
<input type="hidden" id="loc_id" name="loc_id" value="">
<input type="submit" id="submit" class="btn btn-primary" tabindex="-1">
</form>
</div> <!-- card-body -->
</div> <!-- card -->

116
lib/dialog_karte.php Normal file
View File

@@ -0,0 +1,116 @@
<div id="dialog" class="card" title="Neuer Eintrag in die Karte">
<div class="card-header">Ihr Wunsch oder Anregung
<span id="hint"></span>
<span id="close" type="button" class="close right text-danger">
<i class="fa fa-window-close"></i>
</span>
</div>
<div class="card-body">
<form id="newobjectform" enctype="multipart/form-data" action="#" method="post" >
<!-- Username ---------------------------------- -->
<label for="username"><strong>Ihr Name oder Pseudonym:</strong></label>
<input type="text" name="username" maxlength="16" id="username" placeholder="Name" class="text" required="required">
<br>
<!-- Userinfo ---------------------------------- -->
<?php if ($boolUserinfo): ?>
<label><strong>Die Fragen nach Alter und Verkehrsmittel können Sie freiwillig beantworten:</strong></label>
<br>
<label for="ext_age">Ihr Alter:</label>
<select name="ext_age" id="ext_age">
<?php
foreach ($arrAge as $age) {
echo " <option value='$age'>$age</option>";
}
?>
</select>
<br>
<label for="ext_transport">Ihr hauptsächlich genutztes Verkehrsmittel:</label>
<select name="ext_transport" id="ext_transport">
<?php
foreach ($arrTransport as $transport) {
echo " <option value='$transport'>$transport</option>";
}
?>
</select>
<br>
<?php endif; ?>
<!-- Beschreibung ---------------------------------- -->
<label for="description"><strong>Beschreibung:</strong></label><br>
<textarea name="description" id="description" maxlength="1001" placeholder="Beschreiben Sie Ihren Eintrag" required="required"></textarea>
<!-- Themenfelder ---------------------------------- -->
<strong>Wählen Sie ein Themenfeld aus:</strong></br>
<div class="row">
<?php
$first=true;
foreach ($arrTopic as $keyTopic => $valTopic):
$checked = ($first) ? "checked=\"checked\"" : "";
$first=false;
?>
<div class="col-6-md col-6">
<input type="radio" id="topic<?=$keyTopic?>" name="topic" value="<?=$keyTopic?>" <?=$checked?>/>
<label for="topic<?=$keyTopic?>"><?=$valTopic?></label>
</div>
<?php endforeach; ?>
</div> <!-- row -->
<!-- Mängelkategorie -------------------------------- -->
<?php if ($boolDefect): ?>
<p>
<label for="defect"><strong>Mängelkategorie:</strong></label>
<select name="defect" id="defect">
<?php
foreach ($arrDefect as $defectKey => $defectVal) {
echo " <option value='$defectKey'>$defectVal</option>";
}
?>
</select>
</p>
<?php endif; ?>
<!-- Lokalisierung ---------------------------------- -->
<input type="hidden" id="lng" name="lng" value="0" />
<input type="hidden" id="lat" name="lat" value="0" />
<!-- Dateiupload ---------------------------------- -->
<?php if ($boolUpload): ?>
<label>Bildupload:</label>
<input type="file" id="photo" name="uploadfile" size="60" maxlength="255" />
<?php endif; ?>
<!-- Einverständnis ---------------------------------- -->
<strong>Einverständnis:</strong><br>
<label for="consent">
<input type="checkbox" id="consent" name="consent" value="1" required="required" />
Ich bin einverstanden, dass die von mir eingegebenen Daten in der
Karte veröffentlicht
<?= $boolUserinfo ? " (außer Alter und Verkehrsmittel) " : ""?>und im Rahmen der
<a href="datenschutz.php" target="_blank">Datenschutzerklärung</a>
verarbeitet werden dürfen.<br>
<?php if ($boolUpload): ?>
Wenn Sie ein <strong>Bild</strong> hochladen, achten Sie bitte auf
<strong>Urheber- und Persönlichkeitsrechte</strong>.
<?php endif; ?>
</label>
<input type="submit" id="submit" class="btn btn-primary" tabindex="-1">
</form>
</div> <!-- card-body -->
</div> <!-- card -->

119
lib/functions.php Normal file
View File

@@ -0,0 +1,119 @@
<?php
/** *****************************
* Ideenmelder
* Autor: Walter Hupfeld, Hamm
* E-Mail: info@hupfeld-software.de
* Version: 1.0
* Datum: 18.05.2021
******************************** */
function generate_tooltip_description($row) {
global $boolRating;
global $boolComment;
global $boolUpload;
global $boolDefect;
global $uploaddir;
global $arrTopic;
global $arrDefect;
global $db;
$description = $row['description'];
$numUps = $row['thumb_ups'];
$numDowns = $row['thumb_downs'];
$id = $row['id'];
$topic = $row['topic'];
$numDatum= strtotime($row['created_at']);
$datum= date("d.m.Y",$numDatum);
$strDescription = "<strong>Anmerkung zu ".$arrTopic[$topic]."</strong><br>";
if ($boolUpload && isset($row['filename'])) {
$strDescription .= "<a href=\'images/".$row['filename']."\' data-lightbox=\'radweg".$id."\'>";
$strDescription .= "<img src=\'images/".$row['filename']."\' style=\'width:200px;\' /></a><br>";
}
$strDescription .= nl2br2($description);
$strDescription .= "<br> - ".$row['username']." (".$datum.")";
if ($boolDefect) {
if ($row['defect']>0) {
$strDescription .= "<br><em>" . $arrDefect[$row['defect']] ."</em>";
}
}
if ($boolRating) {
$strDescription .=" <hr><div style=\'text-align:center\'>";
$strDescription .= "<a href=\'#\' onclick=\'thumb_up_down(".$id.",".$numUps.",up)\'>";
$strDescription .= "<i class=\'text-muted fa fa-thumbs-up\'></i></a> ";
$strDescription .= "&nbsp;<span class=\'text-muted\' id=\'ups_".$id."\'>".$numUps."</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$strDescription .= "<a href=\'#\' onclick=\'thumb_up_down(".$id.",".$numDowns.",down)\'>";
$strDescription .= "<i class=\'text-muted fa fa-thumbs-down\'></i></a>";
$strDescription .= "&nbsp;<span class=\'text-muted\' id=\'downs_".$id."\'>".$numDowns."</span></div>";
}
if ($boolComment) {
$strDescription .= "<hr><div style=\'text-align:center\'>";
$strDescription .= "<a href=\'#\' onclick=\'open_comment(".$id.")\'>Kommentar hinzufügen</a>";
$strDescription .= "</div>";
$strSQL = "SELECT username,comment,created_at FROM comment WHERE loc_id=".$id;
$result = $db->query($strSQL);
while ($comment = $result->fetchArray()) {
$strDescription .= "<div class=\'comment\'>";
$strDescription .= "<em>".$comment['username']." schrieb am ";
$numDatum = strtotime($comment['created_at']);
$strDatum = date("d.m.Y",$numDatum);
$strDescription .= $strDatum."</em><br>";
$strDescription .= nl2br2($comment['comment']);
$strDescription .= "</div>";
}
}
return $strDescription;
}
/**
* reads gps location form picture data
*/
function read_gps_location($file){
if (is_file($file)) {
$info = exif_read_data($file);
if (isset($info['GPSLatitude']) && isset($info['GPSLongitude']) &&
isset($info['GPSLatitudeRef']) && isset($info['GPSLongitudeRef']) &&
in_array($info['GPSLatitudeRef'], array('E','W','N','S')) && in_array($info['GPSLongitudeRef'], array('E','W','N','S'))) {
$GPSLatitudeRef = strtolower(trim($info['GPSLatitudeRef']));
$GPSLongitudeRef = strtolower(trim($info['GPSLongitudeRef']));
$lat_degrees_a = explode('/',$info['GPSLatitude'][0]);
$lat_minutes_a = explode('/',$info['GPSLatitude'][1]);
$lat_seconds_a = explode('/',$info['GPSLatitude'][2]);
$lng_degrees_a = explode('/',$info['GPSLongitude'][0]);
$lng_minutes_a = explode('/',$info['GPSLongitude'][1]);
$lng_seconds_a = explode('/',$info['GPSLongitude'][2]);
$lat_degrees = $lat_degrees_a[0] / $lat_degrees_a[1];
$lat_minutes = $lat_minutes_a[0] / $lat_minutes_a[1];
$lat_seconds = $lat_seconds_a[0] / $lat_seconds_a[1];
$lng_degrees = $lng_degrees_a[0] / $lng_degrees_a[1];
$lng_minutes = $lng_minutes_a[0] / $lng_minutes_a[1];
$lng_seconds = $lng_seconds_a[0] / $lng_seconds_a[1];
$lat = (float) $lat_degrees+((($lat_minutes*60)+($lat_seconds))/3600);
$lng = (float) $lng_degrees+((($lng_minutes*60)+($lng_seconds))/3600);
//If the latitude is South, make it negative.
//If the longitude is west, make it negative
$GPSLatitudeRef == 's' ? $lat *= -1 : '';
$GPSLongitudeRef == 'w' ? $lng *= -1 : '';
return array(
'lat' => $lat,
'lng' => $lng
);
}
}
return false;
}
function nl2br2($string) {
$string = str_replace(array("\r\n", "\r", "\n"), "<br />", $string);
return $string;
}

126
lib/geocoding.php Normal file
View File

@@ -0,0 +1,126 @@
<?php
/** -----------------------------------------------------
* function getAdress($lat,$lng)
* Reverse geocoding of address by using locationiq.com
* Input: lat and lng of location
* Returns: data-array
* ----------------------------------------------------- */
//$dbFilename = "../db/locations.db";
//$db = new SQLite3($dbFilename);
function getAddress($lat,$lng) {
$key="your-key-here";
$url="https://us1.locationiq.com/v1/reverse.php?key=".$key."&lat=".$lat."&lon=".$lng."&format=json";
$curl = curl_init($url);
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
$arrData = array();
if ($err) {
return false; //"cURL Error #:" . $err;
} else {
$data = json_decode($response);
foreach ($data as $key=>$value) {
if ($key=="address") {
foreach ($value as $k=>$v) {
//echo $k." ".$v."<br>";
$arrData[$k]=$v;
}
}
};
return $arrData;
}
}
/** ----------------------------------------------
* function writeAddress
* Write data to database
* $db - database handel
* $id - id of location
* $data - address data of location
* location - address schould be an 1:1-relation
* ----------------------------------------------- */
function writeAddress($db,$id,$data) {
$arrKeys = array ('parking','road','house_number','industrial','neighbourhood','hamlet','suburb','postcode','city','county','country');
$strSQL="insert into address (loc_id,parking,road,house_number,industrial,";
$strSQL.="neighbourhood,hamlet,suburb,postcode,city,county,country) values ($id";
foreach ($arrKeys as $key) {
$strSQL .= (isset($data[$key])) ? ",'".$data[$key]."'" : ",''";
}
$strSQL.=")";
$db->exec($strSQL);
}
/**
* function fillAddressTable($db,$limit)
* $db - database handel
* $limit - only look for these count of entries because of api restriction
*/
function fillAddressTable($db,$limit=20) {
$arrIds = array();
// Get all ids from address table and write to array
$strSQL="select loc_id from address";
$result=$db->query($strSQL);
while ($row=$result->fetchArray()) {
$arrIds[]=$row['loc_id'];
}
$counter=0;
$strSQL="SELECT id,lat,lng FROM location";
$arrKeys = array ('parking','road','house_number','industrial','neighbourhood','hamlet','suburb','postcode','city','county','country');
$result=$db->query($strSQL);
$strTable = "<table class='table table-bordered table-striped'>";
$strTable .= "<tr><th>id</th><th>lat</th><th>lng</th>";
foreach ($arrKeys as $key) {
$strTable .= "<th>".$key."</th>";
}
$strTable .= "</tr>";
while ($row=$result->fetchArray()) {
$id=$row['id'];
if (!in_array($id,$arrIds) && $counter<$limit) {
$counter++;
$lat=$row['lat'];
$lng=$row['lng'];
$data=getAddress($lat,$lng);
$strTable .= "<tr><td>$id</td><td>$lat</td><td>$lng</td>";
foreach ($arrKeys as $key) {
$strTable .= (isset($data[$key])) ? "<td>".$data[$key]."</td>" : "<td></td>";
}
$strTable .= "</tr>";
sleep(0.5); //api restriction
writeAddress($db,$id,$data);
}
}
$strTable .= "<table>";
return ($counter>0) ? $strTable : "Keine neuen Adressdaten.";
}
function cleanAddresses($db){
$strSQL="DELETE FROM address WHERE parking='' and road='' and house_number=''
and industrial='' and neighbourhood='' and hamlet=''
and suburb='' and postcode='' and city='' and county=''";
$db->query($strSQL);
}
// echo fillAddressTable($db,10);