Skip to content

Commit

Permalink
Allow non-geotagged supplimentary photos
Browse files Browse the repository at this point in the history
First photo must have a tag, others can be blank.

Fixes #160
  • Loading branch information
edent committed Jul 5, 2018
1 parent c2d1b9e commit 35db935
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
22 changes: 13 additions & 9 deletions www/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
if ($_FILES['userfile1']['tmp_name'])
{ // Has a photo been posted?
$filename = $_FILES['userfile1']['tmp_name'];
$sha1 = sha1_file ($filename); // For tweeting
$domain = $_SERVER['SERVER_NAME'];

$sha1 = sha1_file ($filename);

// For tweeting
$domain = $_SERVER['SERVER_NAME'];
$mediaURLs = array();
$mediaURLs[] = "https://{$domain}/image/{$sha1}/1024";

Expand All @@ -25,14 +26,15 @@
$error_filename = $_FILES['userfile1']['name'];
$error_message .= "<h3>{$error_filename} already exists in the database</h3>";
} else {
// Does the first file have a GPS location?
$location = get_image_location($filename);

// If there is a GPS tag on the photo
if (false != $location)
{
// Add the user to the database
$twitter = get_twitter_details();
if (null == $twitter[1]) {
if (null == $twitter[1]) {
$userID = insert_user("anon", $_SERVER['REMOTE_ADDR'], date(DateTime::ATOM));
} else {
$userID = insert_user("twitter", $twitter[0], $twitter[1]);
Expand Down Expand Up @@ -81,24 +83,26 @@

// Send the user to the bench's page
header("Location: /bench/{$benchID}/");
// Tweet the bench
// Tweet the bench
try {
tweet_bench($benchID, $mediaURLs, $inscription, $lat, $lng, "CC BY-SA 4.0");
} catch (Exception $e) {
var_export($e);
die();
}
die();
die();
} else {
$error_message .= "<h3>No location metadata found in image</h3>";
} }
$error_message .= "<h3>No location metadata found in first image</h3>";
}
}
} else if (null != $inscription) {
// If a photo hasn't been posted, recover the inscription and show an error
$error_message .= "<h3>Ooops! Looks like you didn't add a photo</h3>";
}

// Start the normal page
include("header.php");?>
include("header.php");
?>
</hgroup>
<?php
$twitter_name = get_twitter_details()[1];
Expand Down
7 changes: 4 additions & 3 deletions www/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,10 @@ function save_image($file, $media_type, $benchID, $userID) {
$filename = $file['name'];
$file = $file['tmp_name'];

if (get_image_location($file) == false) {
return "<h3>No GPS tags in: {$filename}</h3>";
}
// Not needed. This is checked in add.php
// if (get_image_location($file) == false) {
// return "<h3>No GPS tags in: {$filename}</h3>";
// }

if (duplicate_file($file)) {
return "<h3>Duplicate image: {$filename}</h3>";
Expand Down

0 comments on commit 35db935

Please sign in to comment.