Commit 74aefb00 authored by raphael's avatar raphael
Browse files

site pictures upload fixed and delete feature

parent 04bb13df
<h3>The website</h3>
<p>PgEarth is a worldwide collaboratice free-flight sites database.</p>
<p>What you shall find on the website :
<ul>
<li>free flight sites : text info, orientations, pictures, maps, etc</li>
<li>free flight clubs and professionalw</li>
<li>no adds, nor any gafam intrusive 'like' buttons</li>
</ul>
</p>
<p>The database beeing collaborative and open, users are more than welcome to add/edit information for any items to keep it as up to date as possible.</p>
<p>You can browse it:
<ul>
<li>here: http://paraglidinearth.com for the current stable version (as of october 2017, in read-only flavor...)</li>
<li>or here: http://paragliding.earth for the beta/testing/dev version which code is shared on this gitlab</li>
</ul>
</p>
<h3>The framagit project</h3>
<p>The website is beeing rebuilt from scratch to be mobile-friendly, responsive, 2.0, bootstraped, googlemaps and fb buttons free, with yet such an amazing user experience, in order to make the world a better place by extensive use of fancy jquery and ajax requests.</p>
<p>If you want to help building this piece of of the web, please join the team !</p>
......@@ -37,9 +37,10 @@ $pic = mysqli_fetch_array($r);
<?php
} else {
/*** if not a member or not the pic author, offer to login or report picture ***/ ?>
<p>As you are not the author of this picture, you can report it to moderators.</p>
<p>As you are not the author of this picture, you can report it to moderators.<br />
To do so, open the "About" menu link and use the form in "contact" tab.</p>
<?php if($userId == -1) { ?>
<p>If this your picture, you might want to login to the site.</p>
<p>If this your picture, you might want to <a href="#" modalToOpen="loginModal" class="openAnotherModal">login to the site</a>.</p>
<?php }
}
?>
......@@ -49,13 +50,11 @@ $pic = mysqli_fetch_array($r);
</div>
<script>
$("#deletePicBtn").click( function() {
$("#deletePicBtn").on ('click', function() {
$.post("assets/ajax/updateItem/deletePictureSave.php", { picture: "<?php echo $picName; ?>"}, function(){
$("#pictureDeleteText").html('Picture is deleted');
/* $("#siteDetailsModal").modal('hide');
$("#siteDetailsModal").on('hidden.bs.modal', function (e) {
siteModal(<?php echo $pic['site']?>);
$("#siteDetailsModal").modal('toggle');
alert('Picture is deleted');
siteModal(<?php echo $pic['site']?>);
});
*/ });
});
</script>
<?php
session_start();
include '../../connexion.php';
require '_checkLoggedIn.php';
include '../../../connexion.php';
$picName = $_POST['picture'];
/****** get picture details (author, site) */
......@@ -9,11 +10,21 @@ $q = "select * from picture where name LIKE '".$picName."'";
$r = mysqli_query($bdd, $q);
$pic = mysqli_fetch_array($r);
/****** delete DB entry **********/
if (file_exists('../../img/sites-pictures/'.$picName) and $pic['id'] > 0 ){
/****** delete file *******/
if (unlink('../../img/sites-pictures/'.$picName)) echo 'file deleted - ';
else echo "file not deleted";
/****** delete file *******/
/****** delete DB entry **********/
$qDelete = "DELETE FROM picture WHERE name LIKE '".$picName."'";
if ($rDelete = mysqli_query($bdd, $qDelete)) echo 'db entry deleted';
else echo "db entry not deleted : ".$qDelete;
?>
So you want this pic <?php echo $picName;?> to be deleted ?
} else {
if (file_exists('../../img/sites-pictures/'.$picName)) echo "pbm db entry...";
else echo "pbme with file '../../img/sites-pictures/".$picName."' ";
}
?>
......@@ -131,7 +131,7 @@ $(my_form_id).on( "submit", function(event) {
{
$("#siteDetailsModal").modal('toggle');
alert(data);
console.log(data); // show response from the php script.
// console.log(data); // show response from the php script.
siteModal( $("#siteIdFormField").val() );
$("#imageUploadResults").toggle(600);
......
......@@ -65,9 +65,9 @@ try{
$strImagesOutput .= ' <img src="'.$config["upload_url"].$response["name"].'" width="100px" title="'.$response["name"].'" /> ';
$strImagesOutput .= ' <input type="text" name="'.$response["name"].'"></input> <br/>';
$qImg = "INSERT INTO `picture`
(`id`, `name`, `site`, `pro`, `number`, `country`, `date`, `author`, `comment`)
VALUES (NULL, '".$response["name"]."', '".$response["site"]."', '0', '".$response["index"]."', '', CURRENT_DATE(), '".$_SESSION["userId"]."', '');";
if ( ! $rImg = mysqli_query($bdd, $qImg)) echo " debug : Problem saving img in db !";
(`id`, `name`, `site`, `pro`, `number`, `date`, `author`, `comment`)
VALUES (NULL, '".$response["name"]."', '".$response["site"]."', '0', '".$response["index"]."', CURRENT_DATE(), '".$_SESSION["userId"]."', '');";
if ( ! $rImg = mysqli_query($bdd, $qImg)) echo " debug : Problem saving img in db !<br />".$qImg;
$changed = 'picture';
$id = $response["site"];
......
......@@ -254,8 +254,9 @@ function siteModal(id){ // we define the modal content with an ajax call
if ( json.body["landing_lat"] != 0 && json.body["landing_lng"] != 0 ) {
siteMapDirection = '<a target="_blank" href="http://www.openstreetmap.org/directions?engine=graphhopper_car&route='+json.body["landing_lat"]+'%2C'+json.body["landing_lng"]+'%3B'+json.body["lat"]+'%2C'+json.body["lng"]+'&layers=CG">';
siteMapDirection += '<i class="fa fa-car"></i> LZ to TO driving direction</a><br />';
siteMapDirection += '<a target="_blank" href="http://www.openstreetmap.org/directions?engine=graphhopper_foot&route='+json.body["landing_lat"]+'%2C'+json.body["landing_lng"]+'%3B'+json.body["lat"]+'%2C'+json.body["lng"]+'&layers=CG">';
siteMapDirection += '<a target="_blank" href="https://graphhopper.com/maps/?point='+json.body["landing_lat"]+'%2C'+json.body["landing_lng"]+'&point='+json.body["lat"]+'%2C'+json.body["lng"]+'&locale=en&vehicle=foot&weighting=fastest&elevation=true&use_miles=false&layer=TF Cycle">';
siteMapDirection += '<i class="fa fa-male"></i> LZ to TO walking direction</a>';
siteMapDirection += ' ( <a target="_blank" href="http://www.openstreetmap.org/directions?engine=graphhopper_foot&route='+json.body["landing_lat"]+'%2C'+json.body["landing_lng"]+'%3B'+json.body["lat"]+'%2C'+json.body["lng"]+'&layers=CG">osm</a> )';
$("#siteMapDirection").html( siteMapDirection );
}
......
......@@ -194,7 +194,12 @@ if (! app('login')->isLoggedIn()) {
// console.log(item.name);
// if item is new, put it on map center
if (item.lat == 0 && item.lng==0 ) var centerLatLng = siteMap.getCenter();
if (item.lat == 0 && item.lng==0 ) {
var centerLatLng = siteMap.getCenter();
item.lat = centerLatLng.lat;
item.lng = centerLatLng.lng;
}
else centerLatLng = [item.lat, item.lng];
// wheter or not base items are present and we must show/hide new items creation links
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment