Example #1
0
function user_get_location($plz, $city, $country)
{
    global $apx, $db, $set;
    //PLZ und Land bekannt
    if ($plz && in_array($country, array('DE', 'AT', 'CH'))) {
        $plzstamp = sprintf('%05d', intval($plz));
        $stamp = $country . '-' . $plzstamp;
        $data = $db->fetch("\n\t\t\tSELECT l.id,l.name\n\t\t\tFROM " . PRE . "_user_locations_plz AS p\n\t\t\tLEFT JOIN " . PRE . "_user_locations AS l ON p.locid=l.id\n\t\t\tWHERE p.stamp='" . addslashes($stamp) . "'\n\t\t");
    } elseif ($plz) {
        $plzstamp = sprintf('%05d', intval($plz));
        $data = $db->fetch("\n\t\t\tSELECT l.id,l.name\n\t\t\tFROM " . PRE . "_user_locations_plz AS p\n\t\t\tLEFT JOIN " . PRE . "_user_locations AS l ON p.locid=l.id\n\t\t\tWHERE p.plz='" . addslashes($plzstamp) . "'\n\t\t");
    } elseif ($city) {
        $name = user_city_mysql_match($city);
        $data = $db->fetch("\n\t\t\tSELECT id,name\n\t\t\tFROM " . PRE . "_user_locations\n\t\t\tWHERE name LIKE '" . addslashes($name) . "'\n\t\t");
        $citysearch = true;
    }
    //Passenden Ort suchen
    if (count($data) == 1) {
        foreach ($data as $res) {
            return $res['id'];
        }
    } elseif (count($data) > 1 && !isset($citysearch) && $city) {
        foreach ($data as $res) {
            if (user_city_match($res['name'], $city)) {
                return $res['id'];
            }
        }
    }
    return 0;
}
Example #2
0
     list($l, $b) = $db->first("SELECT l,b FROM " . PRE . "_user_locations WHERE id='" . $_POST['locid'] . "' LIMIT 1");
     $distance = (int) $_POST['distance'];
     $data = $db->fetch("\n\t\t\tSELECT id\n\t\t\tFROM `" . PRE . "_user_locations`\n\t\t\tWHERE (sqrt((l-" . $l . ")*70*(l-" . $l . ")*70+(b-" . $b . ")*111*(b-" . $b . ")*111))<=" . $distance . "\n\t\t");
     $neighbours = get_ids($data, 'id');
     //Auf Locids eingrenzen
     $where .= " AND locid IN (" . implode(',', $neighbours) . ") ";
 } elseif ($_POST['city'] || $_POST['plz']) {
     //PLZ bekannt
     if ($_POST['plz']) {
         $plzstamp = sprintf('%05d', intval($_POST['plz']));
         $data = $db->fetch("\n\t\t\t\tSELECT l.id,l.name,p.stamp\n\t\t\t\tFROM " . PRE . "_user_locations_plz AS p\n\t\t\t\tLEFT JOIN " . PRE . "_user_locations AS l ON p.locid=l.id\n\t\t\t\tWHERE p.plz='" . addslashes($plzstamp) . "'\n\t\t\t\tGROUP BY p.stamp,l.name\n\t\t\t\tORDER BY p.stamp ASC\n\t\t\t");
         $locids = get_ids($data, 'id');
         //City-Match bei mehreren Treffern
         if (count($data) > 1 && $_POST['city']) {
             foreach ($data as $key => $res) {
                 if (!user_city_match($res['name'], $_POST['city'])) {
                     unset($data[$key]);
                 }
             }
             $locids = get_ids($data, 'id');
         }
     } elseif ($_POST['city']) {
         $name = user_city_mysql_match($_POST['city']);
         $data = $db->fetch("\n\t\t\t\tSELECT l.id,l.name,p.stamp\n\t\t\t\tFROM " . PRE . "_user_locations_plz AS p\n\t\t\t\tLEFT JOIN " . PRE . "_user_locations AS l ON p.locid=l.id\n\t\t\t\tWHERE l.name LIKE '" . addslashes($name) . "'\n\t\t\t\tGROUP BY p.stamp,l.name\n\t\t\t\tORDER BY p.stamp ASC\n\t\t\t");
         $locids = get_ids($data, 'id');
     }
     //Keine passende Stadt gefunden
     if (!count($locids)) {
         message($apx->lang->get('MSG_NOCITY'), 'back');
         require 'lib/_end.php';
     } elseif (count($locids) > 1) {