$_RESPONSE['success'] = false; $_RESPONSE['message'] = "Invalid API Key!"; } /* API CALLS MONITOR */ global $db; pg_query($db, "UPDATE users set apicalls = apicalls+1 WHERE id = " . $user['id']); if (!$error) { $m = getMapById($mapId); if (!$m) { $error = true; $_RESPONSE['success'] = false; $_RESPONSE['message'] = "Map not found!"; } } if (!$error) { if (!userHasMapAccess($user['id'], $mapId)) { $error = true; $_RESPONSE['success'] = false; $_RESPONSE['message'] = "You dont have access to the Map."; } } if (!$error) { $map['layerId'] = (int) $map['layerId']; if ($map['layerId'] != 1 && !getLayerByIdAndUserId($user['id'], $map['layerId'])) { $error = true; $_RESPONSE['success'] = false; $_RESPONSE['message'] = "Base Layer with given Id not found!"; } } if (!$error) { $map['groupId'] = (int) $map['groupId'];
function updateMap($maps_id, $users_id, $field_name, $field_value) { global $db; $maps_id = (int) $maps_id; $users_id = (int) $users_id; if ($maps_id == 0 || $users_id == 0) { return false; } if (!userHasMapAccess($users_id, $maps_id)) { return false; } $res = pg_query($db, "UPDATE maps SET status = 'true', " . $field_name . " = '" . pg_escape_string($field_value) . "' WHERE id = {$maps_id}") or die("Database Error"); if (pg_affected_rows($res) == 1) { // Do the Cache Work Here $cacheDirectory = dirname(__FILE__) . "/../cache"; if (!is_dir($cacheDirectory)) { @mkdir($cacheDirectory); } @unlink($cacheDirectory . "/" . md5($maps_id) . ".cache"); return true; } return false; }