<?php

$ID = '$Id: exifupd.php 733 2007-04-27 20:59:52Z bb $';

if (!isset($_POST['lat']) || !isset($_POST['lon']) || !isset($_POST['image']))
    die('Missing parameter');

exec("sudo -u bb /home/bb/bin/gpstag '{$_POST['lat']}' '{$_POST['lon']}' '{$_SERVER['DOCUMENT_ROOT']}{$_POST['image']}'", $result, $rc);

if (sizeof($result) == 0 && $rc == 0)
    // Redirect back to the map
    header("Location: {$_SERVER['HTTP_REFERER']}");
else {
    // Display the command output
    header('Content-Type: text/plain');
    echo "Command output:\n\n" . implode("\n", $result) . "\n\nExit code: $rc\n";
}

?>