diff --git a/classes/Endpoint.php b/classes/Endpoint.php index aa2cff11d32b20cd0c778694cd79118df3bb0f65..16a7fbe2b99b4ae281b90088bb2aa568ff5547f3 100644 --- a/classes/Endpoint.php +++ b/classes/Endpoint.php @@ -45,6 +45,10 @@ class Endpoint{ if(preg_match("/construct/i", $q)){ return $aux; } + if(preg_match("/ask/i", $q)){ + $r = json_decode($aux, true); + return $r; + } } public function queryPost($q){ diff --git a/classes/Queries.php b/classes/Queries.php index 3e2451ef27cd2afbd6355fd179ccf254ebbd007e..9e650c72b22a54feb3f82fe0c4360a460ae14e51 100644 --- a/classes/Queries.php +++ b/classes/Queries.php @@ -2,16 +2,25 @@ class Queries{ public static function uriExist($uri, $e){ - $q = "SELECT * WHERE{ - {<$uri> ?p1 ?o1} - UNION - {?s1 <$uri> ?o2} - UNION - {?s2 ?p2 <$uri>} - }LIMIT 1"; - - $r = $e->query($q); - if(sizeof($r['results']['bindings'])>0){ + $q = "ASK WHERE{ + { + GRAPH ?g{ + {<$uri> ?p1 []} + UNION + {[] <$uri> []} + UNION + {[] ?p2 <$uri>} + } + }UNION{ + {<$uri> ?p1 []} + UNION + {[] <$uri> []} + UNION + {[] ?p2 <$uri>} + } + }"; + $r = $e->query($q); + if($r['boolean'] && strtolower($r['boolean']) !== false){ return true; } return false; diff --git a/classes/Utils.php b/classes/Utils.php index 8175d512178944b244c7ee558e927506e9dbf20b..871998d86ee6204795ef1cf0c2c28304d33485ec 100644 --- a/classes/Utils.php +++ b/classes/Utils.php @@ -12,7 +12,7 @@ class Utils{ public static function send404($uri){ header("HTTP/1.0 404 Not Found"); - echo "LODSPeaKr could not find ".$uri." or information about it.\n\n"; + echo "LODSPeaKr could not find ".$uri." or information about it.\nNo URIs in the triple store, or services configured with that URI\n"; exit(0); }