Exemplo n.º 1
0
    $pat = $preta[1];
}
$pretaa = explode(" en ", $pat);
if ($pretaa[1] != '') {
    $sol = $pretaa[0];
    $pat = $pretaa[1];
}
//Busca si la cadena a buscar es una localidad o provincia
$ver_loc = mysql_query("SELECT * FROM localidades WHERE localidad = '{$pat}' OR provincia = '{$pat}'");
$num_loc = mysql_num_rows($ver_loc);
//
//Si es mayor que 0, quiere decir que si es una localidad.
if ($num_loc > 0) {
    //Convertir cadena de busqueda a coordenadas
    $GoogleMapsApiKey = 'ABQIAAAAsfZ3WhPrjeePQbQ_0RWTRBTIu1KiFe28F4Nw1cnpSoAJjSwXMBR-1y-kGIMTRpZ6_A71qPiaPPz16g';
    $ga = new googleRequest(' ', $pat, ' ', ' ');
    //$ga->country="ES";
    $ga->setGoogleKey($GoogleMapsApiKey);
    $ga->GetRequest();
    $pre_lat = $_GET['la'];
    $pre_lon = $_GET['lo'];
    $pre_city = $_GET['city'];
    $new_lat = $ga->getVar('latitude');
    $new_long = $ga->getVar('longitude');
    if ($pre_lon) {
        $new_lat = $pre_lat;
    }
    if ($pre_lat) {
        $new_long = $pre_lon;
    }
    //Recorta las Coordenadas a 40.0 para poder compararlas con la bbdd
Exemplo n.º 2
0
$haycookie = $_COOKIE["quecomes"];
if (isset($haycookie) && !$_SESSION['username']) {
    $userc = mysql_query("SELECT * FROM `usuarios` WHERE `unique` = '{$haycookie}' LIMIT 1");
    $muserc = mysql_fetch_array($userc);
    $username = $muserc['username'];
    $_SESSION['username'] = $username;
}
$username = $_SESSION['username'];
if ($username) {
    $verdirecc = mysql_query("SELECT * FROM `usuarios` WHERE username = '******' LIMIT 1");
    $mira = mysql_fetch_array($verdirecc);
    $sitio = $mira['direccion'];
    if ($sitio) {
        include "getcoord.php";
        $GoogleMapsApiKey = 'ABQIAAAAsfZ3WhPrjeePQbQ_0RWTRBTIu1KiFe28F4Nw1cnpSoAJjSwXMBR-1y-kGIMTRpZ6_A71qPiaPPz16g';
        $ga = new googleRequest(' ', $sitio, ' ', ' ');
        //$ga->country="ES";
        $ga->setGoogleKey($GoogleMapsApiKey);
        $ga->GetRequest();
        $new_lat = $ga->getVar('latitude');
        $new_long = $ga->getVar('longitude');
        $location['City'] = $ga->getVar('city');
        $location["CountryCode"] = "ES";
        $location["Longitude"] = $new_long;
        $location["Latitude"] = $new_lat;
        if ($new_lat == '') {
            include "logerror.php";
        } else {
            $haydirec = true;
        }
    }