n@650: 0; $abs=preg_replace($re, '/', $abs, -1, $n)) {} n@650: n@650: /* absolute URL is ready! */ n@650: return $scheme.'://'.$abs; n@650: } n@650: n@650: /* n@650: This looks for files that pass the filtering response n@650: The filtering system uses key-value pairs n@650: The key is double encoded using a '-'. The first part is the ID of the item to filter, n@650: the second is the method: n@650: min - Minimum Inclusive n@650: max - Maximum Inclusive n@650: exclude-# - exclude, followed by a number to uniquely add, (will create a triple [], ignore the third as random) n@650: */ n@650: $keys = []; n@650: $waet_url = null; n@650: foreach ($_GET as $key => $value) { n@650: $key = explode("-",$key); n@650: if ($key[0] == "url") { n@650: $waet_url = $value; n@650: } else { n@650: $v_pair = [$key[1],$value]; n@650: if(array_key_exists($key[0],$keys)) { n@650: // We have some data n@650: array_push($keys[$key[0]],$v_pair); n@650: } else { n@650: // Create new key data n@650: $keys[$key[0]] = [$v_pair]; n@650: } n@650: } n@650: } n@650: n@650: $files = []; n@650: $saves = glob("../saves/*.xml"); n@650: if (is_array($saves)) n@650: { n@650: foreach($saves as $filename) { n@650: $xml_string = file_get_contents($filename, FILE_TEXT); n@650: $xml_object = simplexml_load_string($xml_string); n@650: if ($xml_object) { n@650: // First we must check the URLs match n@650: $waet = $xml_object->waet[0]; n@650: if (urldecode($waet["url"])==$waet_url) { n@650: // It is part of the dataset, so now perform checks n@650: $continue = true; n@650: foreach($keys as $keyId => $keyArr) { n@650: $elem = $xml_object->xpath("//*[@ref='".$keyId."']"); n@650: $elem = $elem[0]; // Can only be one. n@650: switch ($elem["type"]) { n@650: case "number": n@650: // Number, we must check for min/max n@650: $value = (real)$elem->response; n@650: foreach ($keyArr as $keyCheck) { n@650: if ($keyCheck[0] == 'min' && $value < $keyCheck[1]) { n@650: $continue = false; n@650: break; n@650: } else if ($keyCheck[0] == 'max' && $value > $keyCheck[1]) { n@650: $continue = false; n@650: break; n@650: } n@650: } n@650: break; n@650: case "checkbox": n@650: // Will have an array of n@650: foreach ($elem->response as $response) { n@650: foreach ($keyArr as $keyCheck) { n@650: if ($response["name"] == $keyCheck[1]) { n@650: if($response["checked"] == "true" && $keyCheck[0] == "exclude") { n@650: $continue = false; n@650: break; n@650: } n@650: } n@650: } n@650: if($continue == false) { n@650: break; n@650: } n@650: } n@650: break; n@650: case "radio": n@650: foreach ($keyArr as $keyCheck) { n@650: if ($keyCheck[0] == "exclude" && $elem->response["name"] == $keyCheck[1]) { n@650: n@650: $continue = false; n@650: break; n@650: } n@650: } n@650: break; n@650: default: n@650: break; n@650: } n@650: if ($continue == false) { n@650: break; n@650: } n@650: } n@650: if ($continue) { n@650: array_push($files,rel2abs($filename,"http://".$_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'])); n@650: } n@650: } n@650: } n@650: } n@650: } n@650: if (count($files) == 0) { n@650: echo '{"urls": []}'; n@650: } else { n@650: echo '{"urls": ["'.implode('","',$files).'"]}'; n@650: } n@650: n@650: ?>