<?php if (!isset($_POST['lat']) || !isset($_POST['lon']) || !isset($_POST['image'])) die('Missing parameter'); unset $result; exec("sudo -u bb /home/bb/bin/gpstag " . escapeshellarg($_POST['lat']) . " " . escapeshellarg($_POST['lon']) . " " . escapeshellarg($_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"; } ?>