Esempio n. 1
0
            }
            $upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ";
            $lower = "abcdefghijklmnopqrstuvwxyzæøå";
            $XPath_query = '/locations/location[translate(' . $URL_key . ',"' . $upper . '","' . $lower . '") ' . $URL_comp . ' "' . $URL_value . '"]';
        }
    }
}
//Creo un nuovo documento DOM
$DOM_doc = DOMDocument::load($filePath);
$XPath_doc = new DOMXPath($DOM_doc);
//Salvo il risultato della query xpath
$locationList = $XPath_doc->query($XPath_query);
$locationsEl = $DOM_doc->documentElement;
//Trovo e salvo i Metadati
$metadata = $locationsEl->getElementsByTagName("metadata")->item(0);
$DOM_doc->removeChild($locationsEl);
//Creo una locations vuota
$emptyLocations = $DOM_doc->createElement("locations", "");
$DOM_doc->appendChild($emptyLocations);
$newLocations = $DOM_doc->getElementsByTagName("locations")->item(0);
//Aggiungo i metadati
$newLocations->appendChild($metadata);
//Aggiungo tutte le location del risultato
foreach ($locationList as $location) {
    $newLocations->appendChild($location);
}
//Salvo il documento XML
$body = $DOM_doc->saveXML($DOM_doc);
//Mando la risposta
sendHTTPResult($headers, $body);
Esempio n. 2
0
            //Controllo se l'orario ricercato  contenuto in uno dei set di orari
            $ore1 = explode("-", $setorari[$a]);
            // Divido la stringa con il set di orari per ottenere un array con l'orario di apertura in 0 e l'orario di chiusura in 1
            $ap2 = $ore1[0];
            //orario di apertura
            $ch2 = $ore1[1];
            //orario di chiusura
            if ($ch2 < $ap2) {
                if ($ap1 < $ap2 and $ch1 < $ap2 and ($ap1 > $ch2 and $ch1 > $ch2)) {
                    sendHTTPResult("Content-type: text/plain", "Chiuso");
                    return FALSE;
                } else {
                    sendHTTPResult("Content-type: text/plain", "Aperto");
                    return TRUE;
                    // Se l'orario è contenuto ridò true e esco dal for
                    break;
                }
            } else {
                if ($ap1 < $ap2 and $ch1 < $ap2 or $ap1 > $ch2 and $ch1 > $ch2) {
                    sendHTTPResult("Content-type: text/plain", "Chiuso");
                    return FALSE;
                } else {
                    sendHTTPResult("Content-type: text/plain", "Aperto");
                    return TRUE;
                    // Se l'orario è contenuto ridò true e esco dal for
                    break;
                }
            }
        }
    }
}
Esempio n. 3
0
$lat1 = $_GET["lat1"];
$long1 = $_GET["long1"];
$lat2 = $_GET["lat2"];
$long2 = $_GET["long2"];
$lat1 = trim($lat1);
$lat2 = trim($lat2);
$long1 = trim($long1);
$long2 = trim($long2);
//Gestione degli errori
if (!$lat1 or !$lat2 or !$long1 or !$long2) {
    sendHTTPError($Errore[406], 'Uno o piu parametri assenti');
}
if (is_numeric($lat1) == FALSE or is_numeric($lat2) == FALSE or is_numeric($long1) == FALSE or is_numeric($long2) == FALSE) {
    sendHTTPError($Errore[406], 'Uno o piu parametri non sono numeri');
}
//Verifico che lat e long siano rispettino gli standard reali
if (90 >= $lat1 and $lat1 >= -90 and 90 >= $lat2 and $lat2 >= -90 and 180 >= $long1 and $long1 >= -180 and 180 >= $long2 and $long2 >= -180) {
    //Calcolo la distanza
    $diff_long = $long1 - $long2;
    $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($diff_long));
    $dist = acos($dist);
    $dist = rad2deg($dist);
    $miles = $dist * 60 * 1.1515;
    $distanzainkm = $miles * 1.609344;
    $distanzainm = $distanzainkm * 1000;
    //Mando il risultato
    sendHTTPResult("Content-type: text/plain", $distanzainm);
    //echo $distanzainm;
} else {
    sendHTTPError($Errore[406], 'Valori al di fuori del range massimo (-90/90 per lat e -180/180 per long)');
}
Esempio n. 4
0
require_once '../funzioni.php';
require_once '../conversioni/CONVERSIONI_NEW.php';
//Prendo i valori dall'url
$strinput = strtolower($_GET['s']);
$strinput = trim($strinput);
$idagg = strtolower($_GET['aggr_id']);
$idagg = trim($idagg);
//Leggo l'accept header del narratore
$arrayHead = apache_request_headers();
$accept = $arrayHead["Accept"];
//Gestione degli errori
if (!$idagg or !$strinput) {
    sendHTTPError($Errore[406], 'Parametro/i assente/i');
}
//Richiamo la funzione per ricercare l'url dell'aggregatore
$urlaggr = get_aggr_url($idagg);
//Se non esiste rispondo con un errore
if ($urlaggr == NULL) {
    sendHTTPError($Errore[404], 'Aggregatore non trovato');
}
//Custom: se nel narratore viene effettuata una ricerca vuota, restituisco tutto il database
if ($strinput == '*') {
    $url = $urlaggr;
    $xml_result = curl_request($url, $accept);
    sendHTTPResult("Content-type: " . $accept . "; charset=utf-8", $xml_result);
} else {
    $url = $urlaggr . "/name/contains/" . $strinput;
    $xml_result = curl_request($url, $accept);
    //Mando il risultato
    sendHTTPResult("Content-type: " . $accept . "; charset=utf-8", $xml_result);
}