$lang["error"],"text" => $lang['resourcenotfound']); include "../include/footer.php"; exit(); } // Check if the user is allowed to edit this resource. if (!get_edit_access($ref, $resource['archive'], $resource)) { exit($lang['error-permissiondenied']); } // Update database with geolocation. $valid_coords = true; if (isset($_POST['submit']) && enforcePostRequest(false)) { $s = explode(",", getval('geo-loc', '')); $lat = isset($s[0]) ? $s[0] : ""; $lng = isset($s[1]) ? $s[1] : ""; if (!is_numeric($lat) || $lat < -90 || $lat > 90) { $valid_coords = false; } if (!is_numeric($lng) || $lng < -180 || $lng > 180) { $valid_coords = false; } if (count($s) == 2 && $valid_coords) { $mapzoom = getval('map-zoom', ''); if ($mapzoom >= 2 && $mapzoom <= 21) { ps_query("update resource set geo_lat= ?,geo_long= ?,mapzoom= ? where ref= ?", ['d', $s[0], 'd', $s[1], 'i', $mapzoom, 'i', $ref]); } else { ps_query("update resource set geo_lat= ?,geo_long= ?,mapzoom=null where ref=?", ['d', $s[0], 'd', $s[1],'i', $ref]); } if ($resource["geo_lat"] != "" && $resource["geo_long"] != "") { $old_location = $resource["geo_lat"] . ", " . $resource["geo_long"]; } resource_log( $ref, LOG_CODE_EDITED_RESOURCE, null, "Edited Location", $old_location ?? "", $lat . ", " . $lng ); } elseif (getval('geo-loc', '') == '') { # Blank geo-location ps_query("update resource set geo_lat=null,geo_long=null,mapzoom=null where ref= ?", ['i', $ref]); resource_log( $ref, LOG_CODE_EDITED_RESOURCE, null, "Removed Location", $resource["geo_lat"] . ", " . $resource["geo_long"], "" ); } # Reload resource data $resource = get_resource_data($ref, false); } $zoom = getval('new_zoom', $resource["mapzoom"]); if (!$valid_coords && getval('geo-loc', '') != '') { echo "
" . escape($lang['location-validation-error']) . "
"; } ?>