Esempio n. 1
0
 public function execute()
 {
     $geo_model = new geo();
     $geo = $geo_model->getGeoList();
     require 'Views/Geo_View.php';
     /*
             try{
                 $id_geo = $this->getGeoId();
                 $params = array("geo" => $id_geo);
                 
                 $geo_model = new Geo();
                 
                 if(
                     filter_has_var(INPUT_GET, "name")    )
                 
             } catch (Exception $ex) {
     
             }
     */
 }
if (!empty($_POST)) {
    $accountId = isset($_POST['accountId']) ? $_POST['accountId'] : 0;
    $accessToken = isset($_POST['accessToken']) ? $_POST['accessToken'] : '';
    $lat = isset($_POST['lat']) ? $_POST['lat'] : '';
    $lng = isset($_POST['lng']) ? $_POST['lng'] : '';
    $lat = helper::clearText($lat);
    $lat = helper::escapeText($lat);
    $lng = helper::clearText($lng);
    $lng = helper::escapeText($lng);
    $result = array("error" => true, "error_code" => ERROR_UNKNOWN);
    $auth = new auth($dbo);
    if (!$auth->authorize($accountId, $accessToken)) {
        api::printError(ERROR_ACCESS_TOKEN, "Error authorization.");
    }
    $result = array("error" => false, "error_code" => ERROR_SUCCESS);
    $geo = new geo($dbo);
    $info = $geo->info(helper::ip_addr());
    $account = new account($dbo, $accountId);
    if (strlen($lat) > 0 && strlen($lng) > 0) {
        $result = $account->setGeoLocation($lat, $lng);
    } else {
        if ($info['geoplugin_status'] == 206) {
            $result = $account->setGeoLocation($info['geoplugin_latitude'], $info['geoplugin_longitude']);
        } else {
            // 37.421011, -122.084968 | Mountain View, CA 94043, USA   ;)
            $result = $account->setGeoLocation("37.421011", "-122.084968");
        }
    }
    echo json_encode($result);
    exit;
}
Esempio n. 3
0
 function draw_line($line, &$params)
 {
     $ret = "";
     $a = explode("(", $line, 2);
     while (count($a) < 2) {
         $a[] = "";
     }
     $command = trim(strtolower(array_shift($a)));
     $values = trim(str_replace(")", "", array_shift($a)));
     if ($command == "addregs" || $command == "include") {
         $values = explode(",", $values);
         $params->expand_ids($values, $this->id);
         foreach ($values as $v) {
             $v = $this->fullid($v);
             $ng = new geo();
             $ng->set_from_id($v, $params);
             $ret .= $ng->draw($params);
         }
     } elseif ($command == "polygon" || $command == "polyline") {
         if (!$this->draw_this($params)) {
             return $ret;
         }
         $data = array();
         $values = explode(",", $values);
         $params->expand_ids($values, $this->id);
         foreach ($values as $v) {
             $v = $this->fullid($v);
             $ng = new geo();
             $ng->set_from_id($v, $params);
             $b = $ng->get_data($params);
             $this->add_reordered_data($data, $b);
         }
         $style = $this->get_current_style($params);
         if ($command == "polygon") {
             $ret .= "<polygon {$style} points=\"";
         }
         if ($command == "polyline") {
             $ret .= "<polyline {$style} points=\"";
         }
         foreach ($data as $a) {
             $x = $a[0];
             $y = $a[1];
             $this->xsum += $x;
             $this->ysum += $y;
             $this->count++;
             $ret .= "{$x},{$y} ";
         }
         $ret = trim($ret) . "\"/>\n";
     }
     return $ret;
 }
Esempio n. 4
0
 public function _rd2wgs($x, $y)
 {
     return parent::rd2wgs($x, $y);
 }
/*!
 * ifsoft.co.uk engine v1.0
 *
 * http://ifsoft.com.ua, http://ifsoft.co.uk
 * qascript@ifsoft.co.uk
 *
 * Copyright 2012-2016 Demyanchuk Dmitry (https://vk.com/dmitry.demyanchuk)
 */
include_once $_SERVER['DOCUMENT_ROOT'] . "/core/init.inc.php";
include_once $_SERVER['DOCUMENT_ROOT'] . "/config/api.inc.php";
if (!empty($_POST)) {
    $accountId = isset($_POST['accountId']) ? $_POST['accountId'] : 0;
    $accessToken = isset($_POST['accessToken']) ? $_POST['accessToken'] : '';
    $distance = isset($_POST['distance']) ? $_POST['distance'] : 30;
    $itemId = isset($_POST['itemId']) ? $_POST['itemId'] : 0;
    $distance = helper::clearInt($distance);
    $itemId = helper::clearInt($itemId);
    $result = array("error" => true, "error_code" => ERROR_UNKNOWN);
    $auth = new auth($dbo);
    if (!$auth->authorize($accountId, $accessToken)) {
        api::printError(ERROR_ACCESS_TOKEN, "Error authorization.");
    }
    $account = new account($dbo, $accountId);
    $account_info = $account->get();
    $geo = new geo($dbo);
    $geo->setRequestFrom($accountId);
    $result = $geo->getPeopleNearby($itemId, $account_info['lat'], $account_info['lng'], $distance);
    echo json_encode($result);
    exit;
}