'.$testMatch.' is not valid.
'; echo 'Parameter geometryType is not valid (point(1),polyline(2),polygon(3))
'; die(); } $geometryType = $testMatch; $testMatch = NULL; } if (isset($_REQUEST["id"]) & $_REQUEST["id"] != "") { //validate to csv integer list $testMatch = $_REQUEST["id"]; $pattern = '/^[\d,]*$/'; if (!preg_match($pattern,$testMatch)){ //echo 'id: '.$testMatch.' is not valid.
'; echo 'Parameter id is not valid (integer or cs integer list).
'; die(); } $id = $testMatch; $testMatch = NULL; } if (isset($_REQUEST["operation"]) & $_REQUEST["operation"] != "") { //validate to csv integer list $testMatch = $_REQUEST["operation"]; if (!($testMatch == 'list' or $testMatch == 'show')){ //echo 'resource: '.$testMatch.' is not valid.
'; echo 'Parameter operation is not valid (list,show)
'; die(); } $operation = $testMatch; $testMatch = NULL; } header('Content-Type: application/json'); switch($operation) { case "list": $sql = "SELECT uuid, id, title, updated FROM json_schema WHERE public IS TRUE "; switch($geometryType) { case "false": $v = array(); $t = array(); break; default: $sql .= "AND geomtype = $1"; $v = array((integer)$geometryType); $t = array("i"); break; } break; case "show": $sql = "SELECT schema FROM json_schema WHERE id = $1 AND public IS TRUE "; $v = array($id); $t = array("i"); break; } $res = db_prep_query($sql, $v, $t); switch($operation) { case "list": $schemaArray = array(); $j = 0; while ($row = db_fetch_array($res)) { $schemaArray[$j] = array(); $schemaArray[$j]['id'] = $row['id']; $schemaArray[$j]['uuid'] = $row['uuid']; $schemaArray[$j]['updated'] = date(DATE_ATOM, $row['updated']); $schemaArray[$j]['title'] = $row['title']; $j++; } echo json_encode($schemaArray); break; case "show": $row = db_fetch_array($res); $schema = $row["schema"]; echo json_encode(json_decode($schema)); break; } ?>