예제 #1
0
function findDistance($data)
{
    $timeArr = array();
    $totalDistance = 0;
    $data1 = explode("#", $data);
    for ($j1 = 0; $j1 < count($data1); $j1++) {
        $data2 = explode("\$", $data1[$j1]);
        if (count($data2) > 1) {
            $data3 = explode(",", $data2[1]);
            $vehi = $data3[0];
            $geodate = date("d-m-Y h:i A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
            $geoTime = date("H:i:s A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
            $pos1 = convertLat(calLat($data3[7]));
            $pos2 = convertLong(calLong($data3[8]));
            if ($pos1 > 0 && $pos2 > 0) {
                if (!in_array($geoTime, $timeArr)) {
                    if ($j1 == 0) {
                        $pits1 = $pos1;
                        $pits2 = $pos2;
                    } else {
                        $pits3 = $pos1;
                        $pits4 = $pos2;
                        $dist = getDistance($pits1, $pits2, $pits3, $pits4);
                        $totalDistance += $dist;
                        $pits1 = $pits3;
                        $pits2 = $pits4;
                    }
                }
            }
        }
        array_push($timeArr, $geoTime);
    }
    return round($totalDistance);
}
function getResult(&$rs, $x, $y, $km, $p, $id, $pageShow, $myKey, $lng = 'lng', $lat = 'lat')
{
    $km = $km * 1000;
    $data = array('data' => $rs, 'total_count' => 0, 'total_page' => 0);
    // 算出实际距离
    if ($data['data']) {
        $sortdistance = array();
        foreach ($data['data'] as $key => $val) {
            $distance = getDistance($x, $y, $val[$lng], $val[$lat]);
            if ($val[$myKey] != $id && $distance <= $km) {
                $data['data'][$key]['distance'] = $distance;
                $sortdistance[$key] = $distance;
                // 排序列
            } else {
                unset($data['data'][$key]);
            }
        }
        if ($sortdistance) {
            // 距离排序
            array_multisort($sortdistance, SORT_ASC, $data['data']);
            $data['total_count'] = count($data['data']);
            $data['total_page'] = ceil($data['total_count'] / $pageShow);
            if ($p > $data['total_page']) {
                $p = $data['total_page'];
            }
            $data['data'] = array_slice($data['data'], ($p - 1) * $pageShow, $pageShow);
        }
    }
    return $data;
}
예제 #3
0
 protected function validateAddresses($origin, $destination)
 {
     $errorOrigin = '';
     $errorDestination = '';
     $distance = '';
     if (empty($origin)) {
         $errorOrigin = $this->errorMsg;
     }
     if (empty($destination)) {
         $errorDestination = $this->errorMsg;
     }
     if (!empty($origin) && !empty($destination)) {
         $arrayGoogleMapAPIResponse = getDistance($origin, $destination);
         if ($arrayGoogleMapAPIResponse['geocoded_waypoints'][0]['geocoder_status'] != 'OK') {
             $errorOrigin = $this->errorAddressMsg;
         }
         if ($arrayGoogleMapAPIResponse['geocoded_waypoints'][1]['geocoder_status'] != 'OK') {
             $errorDestination = $this->errorAddressMsg;
         }
         if (empty($errorOrigin) && empty($errorDestination) && $arrayGoogleMapAPIResponse['status'] != 'OK') {
             $errorDestination = $this->errorRouteMsg;
         }
     }
     if ($errorOrigin == '' && $errorDestination == '') {
         $distance = $arrayGoogleMapAPIResponse['routes'][0]['legs'][0]['distance']['value'];
     }
     $arrayErrorAddresses = [$errorOrigin, $errorDestination, $distance];
     return $arrayErrorAddresses;
 }
예제 #4
0
function matchTrip($tripId)
{
    if (!isLoggedIn()) {
        $response = array("status" => 1, "error" => "Invalid session");
        echo json_encode($response);
        return;
    }
    include "config.php";
    $myTripQuery = "SELECT * FROM " . $db_mysql_table_name . " WHERE id='" . $tripId . "'";
    $tripQuerySuccess = mysqli_query($link, $myTripQuery);
    if ($tripQuerySuccess) {
        if (mysqli_num_rows($tripQuerySuccess) == 1) {
            $matchTrip = mysqli_fetch_assoc($tripQuerySuccess);
        } else {
            $response = array("status" => 1, "error" => "Duplicate id in DB ");
            echo json_encode($response);
        }
    } else {
        $response = array("status" => 1, "error" => "Unable to run query in DB");
        echo json_encode($response);
    }
    $query = "SELECT * FROM " . $db_mysql_table_name . " WHERE state=0" . " AND id!='" . $tripId . "'" . " AND date='" . getTripDate($matchTrip) . "'";
    // Ensures rides are on the same day.
    $success = mysqli_query($link, $query);
    $rows = array();
    if ($success) {
        while ($row = mysqli_fetch_assoc($success)) {
            if (timeCoincides($row, $matchTrip)) {
                // Ensures that they start at around the same time.
                if (getDistance(getDestAddr($row), getDestAddr($matchTrip)) <= 3000) {
                    if (getDistance(getSourceAddr($row), getSourceAddr($matchTrip)) <= 3000) {
                        $rows[] = $row;
                    }
                }
            }
        }
        $response = array("status" => 0, "data" => $rows);
        $response = json_encode($response);
        foreach ($rows as $match) {
            send_email(getUserId($match), $response);
        }
        if (!empty($playerlist)) {
            // Do not send email if no match found
            send_email(getMailId(), $response);
        } else {
            // Send email of no match if needed.
        }
        echo json_encode($response);
    } else {
        $response = array("status" => 1, "error" => "Unable to run query in DB");
        echo json_encode($response);
    }
}
예제 #5
0
function kmsPerDay($path)
{
    $timeArr = array();
    $cnt = 1;
    $totalDistance = 0;
    $file1 = @fopen($path, "r");
    if ($file1) {
        $i = 0;
        while (!feof($file1)) {
            $data = fgets($file1);
            //$i++;
        }
        $data = getSortedData($data);
        $data1 = explode("#", $data);
        for ($j1 = 0; $j1 < count($data1); $j1++) {
            $data2 = explode("\$", $data1[$j1]);
            if (count($data2) > 1) {
                $data3 = explode(",", $data2[1]);
                $vehi = $data3[0];
                $geodate = date("d-m-Y h:i A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                $geoTime = date("H:i:s A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                $pos1 = convertLat(calLat($data3[7]));
                $pos2 = convertLong(calLong($data3[8]));
                if ($pos1 > 0 && $pos2 > 0) {
                    if (!in_array($geoTime, $timeArr)) {
                        if ($j1 == 0) {
                            $pits1 = $pos1;
                            $pits2 = $pos2;
                        } else {
                            $pits3 = $pos1;
                            $pits4 = $pos2;
                            $dist = getDistance($pits1, $pits2, $pits3, $pits4);
                            $totalDistance += $dist;
                            $pits1 = $pits3;
                            $pits2 = $pits4;
                        }
                    }
                }
            }
            array_push($timeArr, $geoTime);
        }
        //echo $data3[11];
        $res = simpleGeocode($pos1, $pos2);
        //print_r($res);
        $res = str_replace('"', "", $res);
        //echo $res."<br>";
        //echo round($totalDistance,2);
        $finalData = round($totalDistance) . "#" . $geodate . "#" . $res;
        fclose($file1);
        return $finalData;
    }
}
예제 #6
0
 public function lists()
 {
     $must = array();
     $this->check_param($must);
     $this->check_sign();
     extract($this->params);
     do {
         if (!isset($page_size)) {
             $page_size = 10;
         }
         //设置默认的 city_id 为 1
         if (!isset($city_id)) {
             $city_id = 1;
         }
         $this->Table_model->init(T_DISTRICT);
         $where_map = array('city' => $city_id);
         //是否只返回已经开发的商圈
         if (isset($is_developed)) {
             $where_map['is_developed'] = $is_developed;
         }
         $limit_arr = array($page_size, $this->page_now);
         $order_map = array('is_developed' => 'desc');
         $res = $this->Table_model->records($where_map, array(), $limit_arr, $order_map);
         if ($res['err_num'] == 0) {
             $results =& $res['results'];
             $results['pager'] = paging($results['records_num'], $this->page_now, $page_size);
             foreach ($results['records'] as &$value) {
                 $value['photo'] = json_decode($value['photo']);
                 //@todo 因为城市暂时只有一个北京,先临时处理下
                 $value['city_name'] = "北京";
                 //如果传参数 longtitude , 和 latitude ,则多返回一个 用户距 商圈距离字段
                 if (isset($Latitude) && isset($Longitude)) {
                     if (!$Latitude) {
                         $value['distance'] = "无法获取您的位置信息";
                     }
                     if (!$Longitude) {
                         $value['distance'] = "无法获取您的位置信息";
                     } else {
                         $value['distance'] = getDistance($value['Latitude'], $value['Longitude'], $Latitude, $Longitude);
                     }
                 } else {
                     $value['distance'] = "无法获取您的位置信息";
                 }
             }
             unset($results['records_num']);
             $this->op($res);
         } else {
             $this->st(array(), "获取商圈列表失败!", API_UNKNOW_ERR);
         }
     } while (0);
     $this->op();
 }
예제 #7
0
function bestServer($location, $server)
{
    foreach ($server as $k => $s) {
        foreach ($location as $i => $loc) {
            $sum = $sum + getDistance($loc['latitutde'], $loc['longitude'], $s['latitude'], $s['longitude']);
            if ($sum <= $min || !$min) {
                $min = $sum;
                $id = $s['id'];
            }
        }
    }
    return $id;
}
예제 #8
0
function getStations($lat, $lng, $rad)
{
    global $db;
    $ret = array();
    $q = mysqli_query($db, "SELECT * FROM `it_stations`");
    while (($station = mysqli_fetch_assoc($q)) != null) {
        $station["distance"] = ceil(getDistance((double) $station["lat"], (double) $station["lng"], (double) $lat, (double) $lng) * 1000);
        if ($station["distance"] < $rad * 1000) {
            $station["prices"] = getPrices($station["id"]);
            $ret[] = $station;
        }
    }
    return $ret;
}
예제 #9
0
function getDistance($evalCallback, $from, $previousDistance = 0, $previousLocations = [])
{
    global $routes;
    $previousLocations[] = $from;
    $distances = [];
    foreach ($routes[$from] as $to => $length) {
        if (\in_array($to, $previousLocations)) {
            continue;
        }
        // Here (at least on shortest path) we could stop if previous + length > previous-best
        $distances[$to] = \getDistance($evalCallback, $to, $previousDistance + $length, $previousLocations);
    }
    return empty($distances) ? $previousDistance : \call_user_func($evalCallback, $distances);
}
예제 #10
0
 public function testUserLocation()
 {
     $this->load->model('Venue_model');
     $this->load->model('User_model');
     $this->load->helper("location");
     $me = $this->User_model->load(1);
     $me = $me[0];
     $peppers = $this->Venue_model->load(1);
     $peppers = $peppers[0];
     $capital = $this->Venue_model->load(7);
     $capital = $capital[0];
     $distanceToPeps = getDistance($me->lastLocationLat, $me->lastLocationLong, $peppers->latitude, $peppers->longitude);
     $distanceToCap = getDistance($me->lastLocationLat, $me->lastLocationLong, $capital->latitude, $capital->longitude);
     //echo "To Peps: " . $distanceToPeps . ", To Capital: " . $distanceToCap;
     self::printJson($capital);
 }
 public function showdetail()
 {
     global $G, $lang;
     $tid = intval($_GET['tid']);
     $task = $this->t('task')->where(array('tid' => $tid))->selectOne();
     if ($task) {
         $task['pic'] = image($task['pic']);
         $task['distance'] = getDistance($this->longitude, $this->latitude, $task['longitude'], $task['latitude']);
         if ($_GET['datatype'] == 'json') {
             $task['content'] = stripHtml($task['content']);
             $this->showAppData($task);
         } else {
             include template('task_detail', 'app');
         }
     }
 }
예제 #12
0
function liveKmsPerDay($lData, $sTime1, $eTime1)
{
    $timeArr = array();
    //$ptArr = array();
    $cnt = 0;
    $totalDistance = 0;
    $data1 = explode("#", $lData);
    for ($j1 = 0; $j1 < count($data1); $j1++) {
        $data2 = explode("@", $data1[$j1]);
        if (count($data2) > 1) {
            $data3 = explode(",", $data2[1]);
            $geodate = $data3[8];
            $geoTime = $data3[9];
            $curTime = explode(":", $data3[9]);
            $curTime = $curTime[0] * 60 + $curTime[1];
            //echo "<br>";
            if ($curTime >= $sTime1 && $curTime <= $eTime1) {
                $pos1 = calLat($data3[2]);
                $pos2 = calLong($data3[1]);
                if ($pos1 > 0 && $pos2 > 0) {
                    if (!in_array($geoTime, $timeArr)) {
                        if ($cnt == 0) {
                            $pits1 = $pos1;
                            $pits2 = $pos2;
                        } else {
                            $pits3 = $pos1;
                            $pits4 = $pos2;
                            //echo $sTime1." >= ".$curTime." <= ".$eTime1." ".$totalDistance."<br>";
                            $dist = getDistance($pits1, $pits2, $pits3, $pits4);
                            $totalDistance += $dist;
                            $pits1 = $pits3;
                            $pits2 = $pits4;
                        }
                    }
                }
                $cnt++;
            }
        }
        array_push($timeArr, $geoTime);
    }
    //$res=simpleGeocode($pos1,$pos2);
    //$res=str_replace('"',"",$res);
    $finalData = round($totalDistance);
    return $finalData;
}
 /**
  * 显示商品详细信息
  */
 public function showdetail()
 {
     global $G, $lang;
     $id = intval($_GET['id']);
     $this->t('goods')->where(array('id' => $id))->update('viewnum=viewnum+1');
     $goods = $this->t('goods')->where(array('id' => $id))->selectOne();
     $goods['dateline'] = @date('Y-m-d H:i', $goods['dateline']);
     $goods['modified'] = @date('Y-m-d H:i', $goods['modified']);
     $goods['pic'] = image($goods['pic']);
     $goods['distance'] = getDistance($this->longitude, $this->latitude, $goods['longitude'], $goods['latitude']);
     if ($_GET['datatype'] == 'json') {
         $this->showAppData($goods);
     } else {
         $json = json_encode($goods);
         $description = $this->t('goods_description')->where(array('goods_id' => $id))->selectOne();
         $shop = $this->t('shop')->where(array('shopid' => $goods['shopid']))->selectOne();
         $shop['pic'] = image($shop['pic']);
         include template('goods_detail', 'app');
     }
 }
function getSaving($source, $destination)
{
    $data = getDistance($source, $destination);
    $fare = calculateFare($data["distance"]);
    $duration = minToHours(calculateDuration($data["distance"]));
    $start_date = "06/03/2015";
    $end_date = "09/03/2015";
    $geoCordinates = get_lat_long($destination);
    $hotelPrice = getStayzillahotel($geoCordinates[0], $geoCordinates[1], $start_date, $end_date);
    $Price = $hotelPrice->hotels[0]->rawPrice;
    $stayzillaSource = $hotelPrice->hotels[0]->address;
    $data_User = array("distance" => $data["distance"], "duration" => $duration, "cabFare" => $fare);
    $stayzillaData = getDistance($stayzillaSource, $destination);
    $stayZillaDistance = number_format((double) $hotelPrice->hotels[0]->distanceFromLatLong / 1000, 2, '.', '');
    $stayzillafare = calculateFare($stayZillaDistance);
    $stayzillaDuration = minToHours(calculateDuration($stayZillaDistance));
    $data_stayzilla = array("distance" => $stayZillaDistance . " km", "duration" => $stayzillaDuration, "cabFare" => $stayzillafare, "hotelFare" => $Price, "hotelData" => $hotelPrice->hotels[0]);
    $responceData = array();
    $responceData["user"] = $data_User;
    $responceData["stayzilla"] = $data_stayzilla;
    return json_encode($responceData);
}
예제 #15
0
파일: hotels.php 프로젝트: class142/proj
function addTableData()
{
    $abfrage = "SELECT * FROM Hotel";
    $ergebnis = mysql_query($abfrage);
    if (mysql_num_rows($ergebnis) == 0) {
        echo "keine Daten vorhanden";
    }
    while ($row = mysql_fetch_row($ergebnis)) {
        //Land besorgen
        $ab = "SELECT * FROM Countries WHERE iso2='" . $row[6] . "'";
        $land = mysql_fetch_object(mysql_query($ab));
        //Zimmerbuchungen besorgen
        $ab1 = "SELECT * FROM Zimmerbuchung WHERE hotelid='" . $row[0] . "' AND von<'" . date("Y-m-d H:i:s") . "' AND bis>'" . date("Y-m-d H:i:s") . "'";
        $zimmer = mysql_num_rows(mysql_query($ab1));
        $zimmer = !$zimmer ? "0" : $zimmer;
        $hotelname = getHotelNameByID($row[0]);
        //Tabellenzeile einfügen
        echo "<tr>";
        echo '<td><div class="box">
		<p class"hover">' . $row[0] . '</p>
		<div class="mask"><img class="minipic" src="../images/hotels/' . getHotelBild($hotelname) . '" width="250" height="270" border="0" alt=' . $hotelname . '></div>
		</td>';
        // echo "<td>" . $row[0] . "</td>";
        echo '<td class="name">' . $row[1] . '<input type="button" class="showZimmer" value="Zimmer" onclick=\'window.location.href = "#' . $row[0] . '"\'/></td>';
        echo "<td style='width:125px;'><p hidden>" . $row[2] . "</p>" . addSterne($row[2]) . "</td>";
        echo '<td><span class="pie">' . $zimmer . '/' . $row[3] . '</span><br>' . $zimmer . '/' . $row[3] . '</td>';
        echo "<td>" . $row[4] . "<br>" . $row[5] . "<br>" . $land->country . "<img src='../images/flags/" . strtolower($row[6]) . ".png'></td>";
        $flughafen = getDistance($row[4] . " " . $row[5], "airport " . $row[8]);
        echo "<td>" . getOrtAndFlag($row[8]) . "<br>" . $flughafen . " km</td>";
        echo "<td><a href='" . $row[7] . "'>Link</a></td>";
        echo "<td><a href='../phpdata/hotelAendern.php?";
        echo addEditList($row[0], "Hotel");
        echo "#openModal'><img src='../images/edit.png'  class='bin'></td>";
        echo "<td><a href='../phpdata/hotelLoeschen.php?id=" . $row[0] . "'><img src='../images/loeschen.png'  class='bin'></td>";
        echo "</tr>";
    }
}
예제 #16
0
        $activities = pdo_fetchall("select * from " . tablename('weilive_activity') . " where start_time < " . time() . " and end_time > " . time() . " and flag = 0 and isopen = 1 and weid = " . $weid);
        $total = pdo_fetchcolumn('SELECT COUNT(id) FROM ' . tablename('weilive_stores') . " WHERE weid = :weid AND status<>0 AND checked=1 {$condition_store} ", array(':weid' => $weid));
    }
} else {
    $styles = 2;
    if (empty($_GPC['lng'])) {
        $gps = false;
    } else {
        $gps = true;
        $lng = $_GPC['lng'];
        $lat = $_GPC['lat'];
        $stores = pdo_fetchall("SELECT * FROM " . tablename('weilive_stores') . " WHERE weid = :weid AND status<>0 AND checked=1 {$condition_store} {$order_condition} LIMIT " . ($pindex - 1) * $psize . ',' . $psize, array(':weid' => $weid));
        $distance = empty($setting) ? 5 : $setting['distance'];
        $total1 = 0;
        foreach ($stores as $key => $s) {
            $stores[$key]['dis'] = getDistance($lng, $lat, $s['lng'], $s['lat']);
            if ($stores[$key]['dis'] > $distance) {
                $total1++;
                unset($stores[$key]);
            }
        }
        if (!empty($stores)) {
            foreach ($stores as $key => $row) {
                $level[$key] = $row['level'];
                $dis[$key] = $row['dis'];
            }
            array_multisort($dis, SORT_ASC, $level, SORT_DESC, $stores);
        }
        $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('weilive_stores') . " WHERE weid = :weid AND status<>0 AND checked=1 {$condition_store} ", array(':weid' => $weid));
        $total = $total - $total1;
        $activities = pdo_fetchall("select * from " . tablename('weilive_activity') . " where start_time < " . time() . " and end_time > " . time() . " and flag = 0 and isopen = 1 and weid = " . $weid);
예제 #17
0
 public function searchArea()
 {
     $resto_cuisine = '';
     $rating = '';
     $minimum = '';
     $pay_by = '';
     $minus_has_delivery_rates = 0;
     $cuisine_list = Yii::app()->functions->Cuisine(true);
     $country_list = Yii::app()->functions->CountryList();
     $this->data['s'] = isset($this->data['s']) ? $this->data['s'] : "";
     $search_str = explode(",", $this->data['s']);
     if (is_array($search_str) && count($search_str) >= 2) {
         $city = isset($search_str[1]) ? trim($search_str[1]) : '';
         $state = isset($search_str[2]) ? trim($search_str[2]) : '';
     } else {
         $city = trim($this->data['s']);
         $state = trim($this->data['s']);
     }
     $from_address = $this->data['s'];
     if (empty($from_address)) {
         $from_address = isset($this->data['st']) ? $this->data['st'] : '';
         if (!empty($this->data['st'])) {
             $_SESSION['kr_search_address'] = $this->data['st'];
         }
     }
     if ($res = Yii::app()->functions->searchByArea($city, $state)) {
         if (is_array($res) && count($res) >= 1) {
             $total = Yii::app()->functions->search_result_total;
             $feed_datas['sEcho'] = $this->data['sEcho'];
             $feed_datas['iTotalRecords'] = $total;
             $feed_datas['iTotalDisplayRecords'] = $total;
             /*dump($feed_datas);
               die();*/
             foreach ($res as $val) {
                 $merchant_address = $val['street'] . " " . $val['city'] . " " . $val['post_code'];
                 $miles = 0;
                 $kms = 0;
                 $ft = false;
                 $new_distance_raw = 0;
                 if ($distance = getDistance($from_address, $merchant_address, $val['country_code'], false)) {
                     $miles = $distance->rows[0]->elements[0]->distance->text;
                     //dump($miles);
                     if (preg_match("/ft/i", $miles)) {
                         $ft = true;
                         $miles_raw = $miles;
                         $new_distance_raw = str_replace("ft", '', $miles);
                         $new_distance_raw = ft2kms(trim($new_distance_raw));
                     } else {
                         $miles_raw = str_replace(array(" ", "mi"), "", $miles);
                         $kms = miles2kms(unPrettyPrice($miles_raw));
                         $new_distance_raw = $kms;
                         $kms = standardPrettyFormat($kms);
                     }
                 }
                 /*get merchant distance */
                 $mt_delivery_miles = Yii::app()->functions->getOption("merchant_delivery_miles", $val['merchant_id']);
                 $merchant_distance_type = Yii::app()->functions->getOption("merchant_distance_type", $val['merchant_id']);
                 /*dump($mt_delivery_miles);
                 		dump($miles_raw);*/
                 $resto_cuisine = '';
                 $cuisine = !empty($val['cuisine']) ? (array) json_decode($val['cuisine']) : false;
                 if ($cuisine != false) {
                     foreach ($cuisine as $valc) {
                         if (array_key_exists($valc, (array) $cuisine_list)) {
                             $resto_cuisine .= $cuisine_list[$valc] . ", ";
                         }
                     }
                     $resto_cuisine = !empty($resto_cuisine) ? substr($resto_cuisine, 0, -2) : '';
                 }
                 $resto_info = "<h5><a href=\"" . baseUrl() . "/store/menu/merchant/" . $val['restaurant_slug'] . "\">" . $val['restaurant_name'] . "</a></h5>";
                 //$resto_cuisine="<span class=\"cuisine-list\">".$resto_cuisine."</span>";
                 $resto_cuisine = wordwrap($resto_cuisine, 50, "<br />\n");
                 $resto_info .= "<p class=\"uk-text-muted\">" . $val['street'] . " " . $val['city'] . " " . $val['post_code'] . "</p>";
                 if (array_key_exists($val['country_code'], (array) $country_list)) {
                     $resto_info .= "<p class=\"uk-text-bold\">" . $country_list[$val['country_code']] . "</p>";
                 }
                 $resto_info .= "<p class=\"uk-text-bold\">" . Yii::t('default', "Cuisine") . " - " . $resto_cuisine . "</p>";
                 $delivery_est = Yii::app()->functions->getOption("merchant_delivery_estimation", $val['merchant_id']);
                 $distancesya = $miles_raw;
                 $unit_distance = $merchant_distance_type;
                 if (!empty($from_address)) {
                     if ($ft == TRUE) {
                         $resto_info .= "<p><span class=\"uk-text-bold\">" . Yii::t("default", "Distance") . ": </span> {$miles_raw} </p>";
                         if ($merchant_distance_type == "km") {
                             $distance_type = Yii::t("default", "km");
                         } else {
                             $distance_type = Yii::t("default", "miles");
                         }
                     } else {
                         if ($merchant_distance_type == "km") {
                             $distance_type = Yii::t("default", "km");
                             $resto_info .= "<p><span class=\"uk-text-bold\">" . Yii::t("default", "Distance") . ": </span> {$kms} " . Yii::t("default", "km") . "</p>";
                             $distancesya = $kms;
                         } else {
                             $resto_info .= "<p><span class=\"uk-text-bold\">" . Yii::t("default", "Distance") . ": </span> {$miles_raw} " . Yii::t("default", "miles") . "</p>";
                             $distance_type = Yii::t("default", "miles");
                         }
                     }
                 }
                 $resto_info .= "<p><span class=\"uk-text-bold\">" . Yii::t("default", "Delivery Est") . ": </span> " . $delivery_est . "</p>";
                 if (is_numeric($mt_delivery_miles)) {
                     $resto_info .= "<p><span class=\"uk-text-bold\">" . Yii::t("default", "Delivery Distance") . ": </span> " . $mt_delivery_miles . " " . $distance_type . "</p>";
                 }
                 $shipping_enabled = Yii::app()->functions->getOption("shipping_enabled", $val['merchant_id']);
                 //delivery rates table
                 $delivery_fee = $val['delivery_charges'];
                 if ($shipping_enabled == 2) {
                     $FunctionsK = new FunctionsK();
                     //$distancesya=round($distancesya);
                     //dump($distancesya);
                     $delivery_fee = $FunctionsK->getDeliveryChargesByDistance($val['merchant_id'], $distancesya, $unit_distance, $delivery_fee);
                     if ($delivery_fee >= 0.01) {
                         if (isset($_GET['filter_promo'])) {
                             if (preg_match("/free-delivery/i", $_GET['filter_promo'])) {
                                 $minus_has_delivery_rates++;
                                 continue;
                             }
                         }
                     }
                 }
                 if (is_numeric($delivery_fee) && $delivery_fee >= 1) {
                     $resto_info .= "<p><span class=\"uk-text-bold\">" . Yii::t("default", "Delivery Fee") . ":</span> " . displayPrice(getCurrencyCode(), prettyFormat($delivery_fee)) . "</p>";
                 } else {
                     $resto_info .= "<p><span class=\"uk-text-bold\">" . Yii::t("default", "Delivery Fee") . ":</span> " . "<span class=\"uk-text-success\">" . Yii::t("default", "Free Delivery") . "</span>" . "</p>";
                 }
                 $image = '';
                 $merchant_photo = Yii::app()->functions->getOption("merchant_photo", $val['merchant_id']);
                 if (!empty($merchant_photo)) {
                     $image .= "<a href=\"" . baseUrl() . "/store/menu/merchant/" . $val['restaurant_slug'] . "\">";
                     $image .= "<img class=\"uk-thumbnail uk-thumbnail-mini\" src=\"" . baseUrl() . "/upload/" . $merchant_photo . "\" alt=\"\" title=\"\">";
                     $image .= "</a>";
                 }
                 if (empty($image)) {
                     $image .= "<a href=\"" . baseUrl() . "/store/menu/merchant/" . $val['restaurant_slug'] . "\">";
                     $image .= "<img class=\"uk-thumbnail uk-thumbnail-mini\" src=\"" . baseUrl() . "/assets/images/thumbnail-medium.png\" alt=\"\" title=\"\">";
                     $image .= "</a>";
                 }
                 $ratings = Yii::app()->functions->getRatings($val['merchant_id']);
                 $rating_meanings = '';
                 if ($ratings['ratings'] >= 1) {
                     $rating_meaning = Yii::app()->functions->getRatingsMeaning($ratings['ratings']);
                     $rating_meanings = ucwords($rating_meaning['meaning']);
                 }
                 $rating = "<div class=\"rate-wrap\">\r\n\t    \t\t\t\t<h6 class=\"rounded2\" data-uk-tooltip=\"{pos:'bottom-left'}\" title=\"{$rating_meanings}\" >" . number_format($ratings['ratings'], 1) . "</h6>\r\n\t    \t\t\t\t<span>" . $ratings['votes'] . " " . Yii::t("default", "Votes") . "</span>\r\n\t    \t\t\t\t</div>";
                 $stores_open_day = Yii::app()->functions->getOption("stores_open_day", $val['merchant_id']);
                 $stores_open_starts = Yii::app()->functions->getOption("stores_open_starts", $val['merchant_id']);
                 $stores_open_ends = Yii::app()->functions->getOption("stores_open_ends", $val['merchant_id']);
                 $stores_open_custom_text = Yii::app()->functions->getOption("stores_open_custom_text", $val['merchant_id']);
                 $stores_open_day = !empty($stores_open_day) ? (array) json_decode($stores_open_day) : false;
                 $stores_open_starts = !empty($stores_open_starts) ? (array) json_decode($stores_open_starts) : false;
                 $stores_open_ends = !empty($stores_open_ends) ? (array) json_decode($stores_open_ends) : false;
                 $stores_open_custom_text = !empty($stores_open_custom_text) ? (array) json_decode($stores_open_custom_text) : false;
                 $tip = '';
                 $open_starts = '';
                 $open_ends = '';
                 $open_text = '';
                 $tip .= "<ul class=\"hr_op rounded2\"><i class=\"fa fa-caret-up\"></i>";
                 if (is_array($stores_open_day) && count($stores_open_day) >= 1) {
                     foreach ($stores_open_day as $val_open) {
                         if (array_key_exists($val_open, (array) $stores_open_starts)) {
                             $open_starts = timeFormat($stores_open_starts[$val_open], true);
                         }
                         if (array_key_exists($val_open, (array) $stores_open_ends)) {
                             $open_ends = timeFormat($stores_open_ends[$val_open], true);
                         }
                         if (array_key_exists($val_open, (array) $stores_open_custom_text)) {
                             $open_text = $stores_open_custom_text[$val_open];
                         }
                         $tip .= '<li><span>' . ucwords(Yii::t("default", $val_open)) . '</span><value>' . $open_starts . " - " . $open_ends . "&nbsp;&nbsp;&nbsp;" . ucfirst($open_text) . '</value></li>';
                         $open_starts = '';
                         $open_ends = '';
                         $open_text = '';
                     }
                 } else {
                     $tip .= '<li>' . Yii::t("default", "Not available.") . '</li>';
                 }
                 $tip .= "<div class=\"clear\"></div>";
                 $tip .= "</ul>";
                 $tips = "<a class=\"opening-hours-wrap\" href=\"javascript:;\">" . Yii::t("default", "Hours of Operation") . "{$tip}</a>";
                 $resto_info .= $tips;
                 $resto_info .= "<div class=\"spacer\"></div>";
                 $resto_info .= "<div>\r\n\t\t\t\t\t\t<a class=\"uk-button uk-button-success uk-width-1-2\" href=\"" . baseUrl() . "/store/menu/merchant/" . $val['restaurant_slug'] . "\">";
                 $resto_info .= Yii::t("default", "Order Now");
                 $resto_info .= "</a></div>";
                 $resto_info .= "<div class=\"spacer\"></div>";
                 $table_book = Yii::app()->functions->getOption("merchant_table_booking", $val['merchant_id']);
                 if ($table_book == "") {
                     $resto_info .= "<div>\r\n\t\t\t\t\t\t<a class=\"uk-button uk-button-success uk-width-1-2\" href=\"" . baseUrl() . "/store/menu/merchant/" . $val['restaurant_slug'] . "/?tab=booking" . "\">";
                     $resto_info .= Yii::t("default", "Book a Table");
                     $resto_info .= "</a></div>";
                 }
                 $is_sponsored = '';
                 if ($val['is_sponsored'] == 2) {
                     $is_sponsored = "<br/><div class=\"uk-badge uk-badge-warning\">" . Yii::t("default", "sponsored") . "</div>";
                 }
                 $is_merchant_open = Yii::app()->functions->isMerchantOpen($val['merchant_id']);
                 $merchant_preorder = Yii::app()->functions->getOption("merchant_preorder", $val['merchant_id']);
                 $now = date('Y-m-d');
                 $is_holiday = false;
                 if ($m_holiday = Yii::app()->functions->getMerchantHoliday($val['merchant_id'])) {
                     if (in_array($now, (array) $m_holiday)) {
                         $is_merchant_open = false;
                     }
                 }
                 $tag_open = '';
                 if ($is_merchant_open == TRUE) {
                     $tag_open = '<div class="uk-badge uk-badge-success">' . t("Open") . '</div>';
                 } else {
                     if ($merchant_preorder) {
                         $tag_open = '<div class="uk-badge uk-badge-warning">' . t("Pre-Order") . '</div>';
                     } else {
                         $tag_open = '<div class="uk-badge uk-badge-danger">' . t("Closed") . '</div>';
                     }
                 }
                 $is_sponsored .= $tag_open;
                 $offers = Widgets::offers($val['merchant_id'], 2);
                 $is_sponsored .= $offers;
                 $merchant_latitude = Yii::app()->functions->getOption("merchant_latitude", $val['merchant_id']);
                 $merchant_longtitude = Yii::app()->functions->getOption("merchant_longtitude", $val['merchant_id']);
                 $merchant_latitude = !empty($merchant_latitude) ? $merchant_latitude : '0';
                 $merchant_longtitude = !empty($merchant_longtitude) ? $merchant_longtitude : '0';
                 $feed_data[] = array($image, $resto_info, $rating, !empty($val['minimum_order']) ? displayPrice(getCurrencyCode(), prettyFormat($val['minimum_order'])) . "<br/>" . $is_sponsored : "{$is_sponsored}", $miles_raw, $merchant_latitude, $merchant_longtitude, addslashes($val['restaurant_name']), $merchant_address, $val['restaurant_slug'], $image, $new_distance_raw);
             }
             $this->data['sort_filter'] = isset($this->data['sort_filter']) ? $this->data['sort_filter'] : '';
             //dump($feed_data);
             if ($this->data['sort_filter'] == "distance") {
                 Yii::app()->functions->arraySortByColumn($feed_data, 11);
                 $feed_datas['aaData'] = $feed_data;
             } else {
                 /** sort by distance */
                 if (Yii::app()->functions->getOptionAdmin('search_result_bydistance') == 2) {
                     Yii::app()->functions->arraySortByColumn($feed_data, 11);
                     $feed_datas['aaData'] = $feed_data;
                 } else {
                     $feed_datas['aaData'] = $feed_data;
                 }
             }
             //dump("minus_has_delivery_rates->".$minus_has_delivery_rates);
             if ($minus_has_delivery_rates >= 1) {
                 $feed_datas['iTotalRecords'] = $feed_datas['iTotalRecords'] - $minus_has_delivery_rates;
                 $feed_datas['iTotalDisplayRecords'] = $feed_datas['iTotalDisplayRecords'] - $minus_has_delivery_rates;
                 if ($feed_datas['iTotalRecords'] <= 0) {
                     $this->otableNodata();
                 }
             }
             $this->otableOutput($feed_datas);
         }
     }
     $this->otableNodata();
 }
예제 #18
0
function storeData($data, $km, $devName, $sTime2, $eTime2)
{
    //echo $data;
    $data1 = explode("#", $data);
    $latnlong_values = "";
    //$xml = '<gps geoData="'.$latnlong_values.'" geoPointName="'.$point_names.'">';
    $km = explode("#", $km);
    $totKm += $km[0];
    $totPath .= $km[1];
    //print_r($km);
    //exit;
    $xml = '<gps>';
    $timeArr = array();
    $totalDistance = 0;
    $ct = 0;
    $j1 = 0;
    while ($j1 < count($data1)) {
        $data2 = explode("@", $data1[$j1]);
        if (count($data2) > 1) {
            $data3 = explode(",", $data2[1]);
            //print_r($data3);
            $date = $data3[8] / 1000;
            $date = $data3[8] . " " . $data3[9];
            $geodate = $data3[8] . " " . $data3[9];
            $geoTime = $data3[9];
            $pos1 = calLat($data3[2]);
            $pos2 = calLong($data3[1]);
            if ($pos1 > 0 && $pos2 > 0) {
                if (!in_array($geoTime, $timeArr)) {
                    if ($j1 == 0) {
                        $pits1 = $pos1;
                        $pits2 = $pos2;
                    } else {
                        $pits3 = $pos1;
                        $pits4 = $pos2;
                        $dist = getDistance($pits1, $pits2, $pits3, $pits4);
                        $totalDistance += $dist;
                        $pits1 = $pits3;
                        $pits2 = $pits4;
                    }
                    $mph = $data3[3];
                    $direction = $data3[4];
                    $altitute = $data3[5];
                    $deviceIMEI = $data3[0];
                    $sessionID = $_GET["sessionID"];
                    $accuracy = $data3[6];
                    $extraInfo = $data3[6];
                    $fule_param = $data3[7];
                    $d = preg_split("/[\\s,]+/", $fule_param);
                    foreach ($d as $e) {
                        if (substr($e, 0, 3) == '[9=') {
                            $fuel = str_replace(array('[9=', ']'), '', $e);
                        }
                        if (substr($e, 0, 3) == '[1=') {
                            $engine = str_replace(array('[1=', ']'), '', $e);
                            if ($engine == '1') {
                                $engine_st = 'On';
                            } else {
                                $engine_st = 'Off';
                            }
                        }
                    }
                    $xml .= '<locations latitude="' . $pos1 . '" longitude="' . $pos2 . '" speed="' . $mph . '" direction="' . $direction . '" altitute="' . $altitute . '" curTime = "' . $curTime . '" distance="' . round($totalDistance) . '" gpsTime="' . date("h:i A", strtotime($geoTime)) . '" geodate="' . $geodate . '" deviceIMEI="' . $deviceIMEI . '" deviceName="' . $devName . '" sessionID="' . $sessionID . '"  extraInfo="' . $extraInfo . '"  route="' . $rtName . '"  other="' . $data3[7] . '"/>';
                }
            }
        }
        array_push($timeArr, $geoTime);
        if ($j1 > 0) {
            $dif = count($data1) - $j1;
            if ($dif > 10) {
                $j1 = $j1 + 10;
            } else {
                $j1 = $j1 + 1;
            }
            //echo $dif." ".$j1." ".count($data1)."<br>";
        } else {
            $j1 = $j1 + 1;
            //echo $dif." ".$j1." ".count($data1)."<br>";
        }
    }
    $xml .= '<OtherData totPt="' . $totPath . '" geoData="" geoPointName="" totalDist="' . $totKm . '" />';
    $xml .= '</gps>';
    header('Content-Type: text/xml');
    echo $xml;
}
 /**
  * 用户需求详情 type=1 未报价 type=2已报价
  */
 public function get_member_demand()
 {
     //跨域解决方法: 指定域名
     header('Access-Control-Allow-Origin:http://www.caryu.net');
     header('Access-Control-Allow-Credentials:true');
     $mer_session_id = $_POST['mer_session_id'];
     $merchant_id = $this->session_handle->getsession_userid($mer_session_id);
     $id = (int) $_POST['id'];
     $bidd = M('MerchantBidding')->where(array('demand_id' => $id, 'merchant_id' => $merchant_id))->find();
     if ($bidd) {
         $type = 2;
     } else {
         $type = 1;
     }
     if (empty($id)) {
         $this->jsonUtils->echo_json_msg(4, '车主需求ID为空...');
         exit;
     }
     $arr = $this->dao->query("select a.id,a.status as demand_status ,from_unixtime(a.reach_time,'%Y-%m-%d %H:%i') as reach_time ,a.description,a.pics,a.member_id,a.longitude,a.latitude,a.cart_data,b.nick_name,b.header,a.publish,a.expire_time from " . C('DB_PREFIX') . "member_demand as a left join " . C('DB_PREFIX') . "member as b on a.member_id = b.id   where a.id={$id}");
     if ($arr) {
         $arr[0]['header'] = imgUrl($arr[0]['header']);
         $cart = json_decode($arr[0]['cart_data'], true);
         $arr[0]['cart_model'] = $cart['cart_model'];
         $model = new Model();
         $merchant = M('Merchant');
         $mer_arr = $merchant->field("longitude,latitude")->where("id={$merchant_id}")->select();
         $longitude = $arr[0]['longitude'];
         // 用户发布需求的经纬度
         $latitude = $arr[0]['latitude'];
         $demand_id = $arr[0]['id'];
         // 计算商家店铺和用户需求距离
         $arr[0]['distance'] = getDistance($latitude, $longitude, $mer_arr[0]['latitude'], $mer_arr[0]['longitude']);
         $is_expire = time() - $arr[0]['expire_time'] > 0 ? '1' : '0';
         if ($is_expire) {
             if ($arr[0]['demand_status'] == 0) {
                 $arr[0]['demand_status'] = '3';
                 //过期
             }
         }
         // 服务项目信息
         if ($arr[0]['publish'] == 0) {
             $category = "category";
         } elseif ($arr[0]['publish'] == 1) {
             $category = "car_maintain_category";
         } else {
             $this->jsonUtils->echo_json_msg(4, '订单有误');
             exit;
         }
         //
         $s_arr = $model->query("select b.name,b.id from " . C('DB_PREFIX') . "member_demand_subitems as a left join " . C('DB_PREFIX') . "{$category} as b on a.category_id=b.id  where a.demand_id={$demand_id} ");
         $perlist = array();
         if ($s_arr) {
             if ($type == 1) {
                 // 未报价
                 $arr[0]['merchant_remark'] = '';
             } elseif ($type == 2) {
                 // 已报价 bidding
                 $merchant_remark = M('MerchantBiddingRemark')->where(array('demand_id' => $id, 'merchant_id' => $merchant_id))->getField('remark');
                 $arr[0]['merchant_remark'] = !empty($merchant_remark) ? $merchant_remark : '';
                 $map['demand_id'] = $id;
                 $map['merchant_id'] = $merchant_id;
                 $alert_price = M('MerchantBidding')->where($map)->field('id as bidding_id,price,sub_id as cat_id,out_time as time')->select();
                 foreach ($alert_price as $tem) {
                     $price[$tem['cat_id']] = $tem;
                 }
             } else {
                 $this->jsonUtils->echo_json_msg(4, '参数不全.');
                 exit;
             }
             // 区分是报价为0 还是未报价,-1标识未报价
             foreach ($s_arr as $key => $row) {
                 $perlist[$key]['category_id'] = $row['id'];
                 $perlist[$key]['server_name'] = $row['name'];
                 $perlist[$key]['is_server'] = 1;
                 $perlist[$key]['price'] = !isset($price[$row['id']]['price']) ? '-1' : $price[$row['id']]['price'];
                 $perlist[$key]['bidding_id'] = !isset($price[$row['id']]['bidding_id']) ? '-1' : $price[$row['id']]['bidding_id'];
                 $perlist[$key]['time'] = !isset($price[$row['id']]['time']) ? '-1' : $price[$row['id']]['time'];
             }
         }
         $arr[0]['list'] = $perlist;
         if ($arr[0]['pics']) {
             $json_obj = json_decode($arr[0]['pics'], true);
             $arr[0]['pics'] = imgUrl($json_obj);
         } else {
             $arr[0]['pics'] = '';
         }
         $arr[0]['cart_model'] == null ? '' : $arr[0]['cart_model'];
         $this->jsonUtils->echo_json_data(0, 'ok', $arr[0]);
         exit;
     } else {
         $this->jsonUtils->echo_json_msg(1, '没有该用户需求...');
         exit;
     }
 }
예제 #20
0
 public function act_findPosition()
 {
     $now_position = isset($_POST['now_position']) ? $_POST['now_position'] : "";
     $where = " where pName='{$now_position}'";
     $now_position_info = whShelfModel::selectPosition($where);
     if (!$now_position_info || empty($now_position_info)) {
         self::$errCode = "003";
         self::$errMsg = "系统中不存在[{$now_position}]仓位信息";
         return false;
     }
     $where = " where is_enable=0 and type=1 and id!={$now_position_info[0]['id']}";
     $picking_position_list = whShelfModel::selectPosition($where);
     //未用仓位
     $where = " where is_enable=0 and type=2 and id!={$now_position_info[0]['id']}";
     $nopicking_position_list = whShelfModel::selectPosition($where);
     //未用备货位
     $picking_arr = array();
     $picking_pname_arr = array();
     $show_picking_arr = array();
     $nopicking_arr = array();
     $nopicking_pname_arr = array();
     $show_nopicking_arr = array();
     if ($now_position_info[0]['type'] == 1) {
         $show_picking_arr[] = array('id' => $now_position_info[0]['id'], 'pName' => $now_position_info[0]['pName']);
     } else {
         if ($now_position_info[0]['type'] == 2) {
             $show_nopicking_arr[] = array('id' => $now_position_info[0]['id'], 'pName' => $now_position_info[0]['pName']);
         }
     }
     if ($picking_position_list) {
         foreach ($picking_position_list as $picking_position) {
             $distance = getDistance($now_position_info[0]['x_alixs'], $now_position_info[0]['y_alixs'], $now_position_info[0]['floor'], $picking_position['x_alixs'], $picking_position['y_alixs'], $picking_position['floor']);
             $picking_arr[$picking_position['id']] = $distance;
             $picking_pname_arr[$picking_position['id']] = $picking_position['pName'];
         }
         asort($picking_arr);
         $i = 0;
         foreach ($picking_arr as $p_key => $picking_info) {
             if ($i >= 3) {
                 break;
             }
             $show_picking_arr[] = array('id' => $p_key, 'pName' => $picking_pname_arr[$p_key]);
             $i++;
         }
     }
     if ($nopicking_position_list) {
         foreach ($nopicking_position_list as $nopicking_position) {
             $distance = getDistance($now_position_info[0]['x_alixs'], $now_position_info[0]['y_alixs'], $now_position_info[0]['floor'], $nopicking_position['x_alixs'], $nopicking_position['y_alixs'], $nopicking_position['floor']);
             $nopicking_arr[$nopicking_position['id']] = $distance;
             $nopicking_pname_arr[$nopicking_position['id']] = $nopicking_position['pName'];
         }
         asort($nopicking_arr);
         $j = 0;
         foreach ($nopicking_arr as $p_key => $nopicking_info) {
             if ($j >= 3) {
                 break;
             }
             $show_nopicking_arr[] = array('id' => $p_key, 'pName' => $nopicking_pname_arr[$p_key]);
             $j++;
         }
     }
     $res['show_picking'] = $show_picking_arr;
     $res['show_nopicking'] = $show_nopicking_arr;
     self::$errMsg = "请选择上架位置";
     return $res;
 }
function kmsPerDay($path)
{
    $timeArr = array();
    $cnt = 1;
    $totalDistance = 0;
    $file1 = @fopen($path, "r");
    if ($file1) {
        $i = 0;
        while (!feof($file1)) {
            $data = fgets($file1);
            //$i++;
        }
        $data = getSortedData($data);
        $data1 = explode("#", $data);
        for ($j1 = 0; $j1 < count($data1); $j1++) {
            $data2 = explode("\$", $data1[$j1]);
            if (count($data2) > 1) {
                $data3 = explode(",", $data2[1]);
                $vehi = $data3[0];
                $geodate = date("d-m-Y h:i A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                $geoTime = date("H:i:s A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                $pos1 = convertLat(calLat($data3[7]));
                $pos2 = convertLong(calLong($data3[8]));
                if ($pos1 > 0 && $pos2 > 0) {
                    if (!in_array($geoTime, $timeArr)) {
                        if ($j1 == 0) {
                            $pits1 = $pos1;
                            $pits2 = $pos2;
                        } else {
                            $pits3 = $pos1;
                            $pits4 = $pos2;
                            $dist = getDistance($pits1, $pits2, $pits3, $pits4);
                            $totalDistance += $dist;
                            $pits1 = $pits3;
                            $pits2 = $pits4;
                        }
                        $mph = $data3[9];
                        $direction = $data3[10];
                        $distance = '';
                        $date = $date;
                        $locationMethod = '327681';
                        //echo getDateFromJavaDate($date);
                        $phoneNumber = $data3[0];
                        $sessionID = $_GET["sessionID"];
                        $accuracy = 11;
                        $locationIsValid = yes;
                        $extraInfo = $data3[11];
                        $xml .= '<locations latitude="' . $pos1 . '" longitude="' . $pos2 . '" speed="' . $mph . '" direction="' . $direction . '" distance="' . round($totalDistance, 2) . '" locationMethod="327681" gpsTime="' . $geodate . '" phoneNumber="' . $phoneNumber . '" sessionID="' . $sessionID . '" accuracy="11" isLocationValid="yes" extraInfo="' . $extraInfo . '" />';
                    }
                }
            }
            array_push($timeArr, $geoTime);
        }
        //echo $data3[11];
        //$res=simpleGeocode($pos1,$pos2);
        //print_r($res);
        //$res=str_replace(",","-",$res[0]);
        //echo $res."<br>";
        //echo round($totalDistance,2);
        $finalData = round($totalDistance) . "#" . $geodate . "#" . $res;
        fclose($file1);
        return $finalData;
    }
}
예제 #22
0
파일: app.php 프로젝트: Rockroc/PHP
if (!empty($_GET['type'])) {
    $url .= "&type={$_GET['type']}";
}
$context = stream_context_create($opts);
$html = file_get_contents($url, false, $context);
//echo json_encode($html);die();
$arr = json_decode($html, true);
$far = array();
foreach ($arr['dealers'] as $key => $value) {
    $url = "http://api.map.baidu.com/geocoder/v2/?address={$value['address']}&output=json&ak=YIjdDENupKI3zHmuTioRP3t6";
    $address = file_get_contents($url);
    $addressArr = json_decode($address, true);
    if ($addressArr['status'] == 0) {
        $lng = $addressArr['result']['location']['lng'];
        $lat = $addressArr['result']['location']['lat'];
        $distance = getDistance($addressLng, $addressLat, $lng, $lat);
        $far[$key] = $distance;
        $arr['dealers'][$key]['distance'] = meter_calculate($distance);
        $arr['dealers'][$key]['lng'] = $lng;
        $arr['dealers'][$key]['lat'] = $lat;
        //手机号码处理
        $phone = trim($arr['dealers'][$key]['contacts'][0]['phone_number'], '?');
        $phoneArr = explode('  ', $phone);
        $phoneHtml = "";
        foreach ($phoneArr as $val) {
            $phoneHtml .= "<a href='tel:{$val}'>{$val}</a>&nbsp;&nbsp;";
        }
        $arr['dealers'][$key]['phone'] = $phoneHtml;
    } else {
        unset($arr['dealers'][$key]);
    }
function storeData1($data)
{
    //echo $data;
    $data1 = explode("#", $data);
    $latnlong_values = "";
    if ($_GET[sessionID] != '') {
        $getDriver = "SELECT di_id,di_driverId,di_license,di_firstName,di_lastName,di_phone1,di_profile_image from driver_info,gps_task_info, vehicle_info  WHERE gti_clientId=" . $_GET[sessionID] . " AND di_id=gti_driver_id AND  '" . $_GET[date_offline] . "' BETWEEN DATE_FORMAT( gti_start_date, '%Y-%m-%d' ) AND DATE_FORMAT( gti_end_date, '%Y-%m-%d' ) AND vi_reg_no = '" . $_GET[phoneNumber] . "' LIMIT 0 , 30";
        $resDriver = mysql_query($getDriver);
        $fetchDriver = @mysql_fetch_assoc($resDriver);
        $qr = "SELECT * FROM gps_geopoints_info WHERE gpi_clientID=" . $_SESSION["clientID"];
        $rs_geofence_details = mysql_query($qr);
        if (@mysql_num_rows($rs_geofence_details) == 0) {
            $latnlong_values = "";
        } else {
            $latnlong_values = "";
            $ct = 0;
            while ($fetch_geofence_details = @mysql_fetch_assoc($rs_geofence_details)) {
                //print_r($fetch_geofence_details);
                if ($ct == 0) {
                    $latnlong_values = $fetch_geofence_details[gpi_miles] . "," . $fetch_geofence_details[gpi_latVal] . "," . $fetch_geofence_details[gpi_longVal] . "@";
                    $ct++;
                } else {
                    $latnlong_values .= $fetch_geofence_details[gpi_miles] . "," . $fetch_geofence_details[gpi_latVal] . "," . $fetch_geofence_details[gpi_longVal] . "@";
                    $ct++;
                }
                if ($ct != @mysql_num_rows($rs_geofence_details)) {
                    $point_names .= $fetch_geofence_details[gpi_stopName] . ",";
                } else {
                    $point_names .= $fetch_geofence_details[gpi_stopName];
                }
            }
            //echo $latnlong_values;
        }
    } else {
        $client_array = array();
        $res_clients = SuperAdminSF::getClients();
        while ($clientIds = mysql_fetch_assoc($res_clients)) {
            array_push($client_array, $clientIds);
        }
        for ($cl = 0; $cl < count($client_array); $cl++) {
            $fetchDriver = getDriverDetails($client_array[$cl][clin_id], $_GET[date_offline], $_GET[phoneNumber]);
        }
    }
    $xml = '<gps geoData="' . $latnlong_values . '" geoPointName="' . $point_names . '">';
    $timeArr = array();
    $totalDistance = 0;
    if ($_GET[from_hrs] != '' && ($fm = $_GET[from_mins] != '' && ($th = $_GET[to_hrs] != '' && ($tm = $_GET[to_mins] != '')))) {
        for ($j1 = 0; $j1 < count($data1); $j1++) {
            $data2 = explode("\$", $data1[$j1]);
            if (count($data2) > 1) {
                $data3 = explode(",", $data2[1]);
                if (date("d-m-Y", strtotime($_GET[date_offline])) == date("d-m-Y", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]))) {
                    $fh = $_GET[from_hrs];
                    $fm = $_GET[from_mins];
                    $fs = '00';
                    $th = $_GET[to_hrs];
                    $tm = $_GET[to_mins];
                    $ts = '00';
                    $h = date("H", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                    $m = date("i", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                    $s = date("s", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                    if ($fh == $th && $fh == $h) {
                        if ($m >= $fm && $m < $tm) {
                            $show = 1;
                        } else {
                            $show = 0;
                        }
                    } else {
                        if ($h >= $fh && $h <= $th) {
                            if ($h < $th) {
                                if ($m >= $fm || $m < $tm) {
                                    $show = 1;
                                } else {
                                    $show = 0;
                                }
                            } else {
                                if ($h == $th) {
                                    if ($m >= $fm && $m < $tm) {
                                        $show = 1;
                                    } else {
                                        $show = 0;
                                    }
                                }
                            }
                        } else {
                            $show = 0;
                        }
                    }
                    if ($show == 1) {
                        $vehi = $data3[0];
                        $geodate = date("d-m-Y h:i A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                        $geoTime = date("h:i:s A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                        $pos1 = convertLat(calLat($data3[7]));
                        $pos2 = convertLong(calLong($data3[8]));
                        if ($pos1 > 0 && $pos2 > 0) {
                            if (!in_array($geoTime, $timeArr)) {
                                //echo $sPt=$pos1."#".$pos2;
                                if ($cnt == 1) {
                                    $pits1 = $pos1;
                                    $pits2 = $pos2;
                                } else {
                                    $pits3 = $pos1;
                                    $pits4 = $pos2;
                                    $dist = getDistance($pits1, $pits2, $pits3, $pits4);
                                    $totalDistance += $dist;
                                    $pits1 = $pits3;
                                    $pits2 = $pits4;
                                }
                                $mph = $data3[9];
                                $direction = $data3[10];
                                $distance = '';
                                $date = $date;
                                $locationMethod = '327681';
                                //echo getDateFromJavaDate($date);
                                $phoneNumber = $data3[0];
                                $sessionID = $_GET["sessionID"];
                                $accuracy = 11;
                                $locationIsValid = yes;
                                $extraInfo = $data3[11];
                                $xml .= '<locations latitude="' . $pos1 . '" longitude="' . $pos2 . '" speed="' . $mph . '" direction="' . $direction . '" distance="' . round($totalDistance, 2) . '" locationMethod="327681" gpsTime="' . $geodate . '" phoneNumber="' . $phoneNumber . '" sessionID="' . $sessionID . '" accuracy="11" isLocationValid="yes" extraInfo="' . $extraInfo . '"  route="' . $rtName . '"/>';
                            }
                        }
                    }
                    array_push($timeArr, $geoTime);
                }
            }
        }
    } else {
        for ($j1 = 0; $j1 < count($data1); $j1++) {
            $data2 = explode("\$", $data1[$j1]);
            if (count($data2) > 1) {
                $data3 = explode(",", $data2[1]);
                $vehi = $data3[0];
                $geodate = date("d-m-Y h:i A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                $geoTime = date("H:i:s A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                $pos1 = convertLat(calLat($data3[7]));
                $pos2 = convertLong(calLong($data3[8]));
                if ($pos1 > 0 && $pos2 > 0) {
                    if (!in_array($geoTime, $timeArr)) {
                        if ($j1 == 0) {
                            $pits1 = $pos1;
                            $pits2 = $pos2;
                        } else {
                            $pits3 = $pos1;
                            $pits4 = $pos2;
                            $dist = getDistance($pits1, $pits2, $pits3, $pits4);
                            $totalDistance += $dist;
                            $pits1 = $pits3;
                            $pits2 = $pits4;
                        }
                        $mph = $data3[9];
                        $direction = $data3[10];
                        $distance = '';
                        $date = $date;
                        $locationMethod = '327681';
                        //echo getDateFromJavaDate($date);
                        $phoneNumber = $data3[0];
                        $sessionID = $_GET["sessionID"];
                        $accuracy = 11;
                        $locationIsValid = yes;
                        $extraInfo = $data3[11];
                        $xml .= '<locations latitude="' . $pos1 . '" longitude="' . $pos2 . '" speed="' . $mph . '" direction="' . $direction . '" distance="' . round($totalDistance, 2) . '" locationMethod="327681" gpsTime="' . $geodate . '" phoneNumber="' . $phoneNumber . '" sessionID="' . $sessionID . '" accuracy="11" isLocationValid="yes" extraInfo="' . $extraInfo . '"  route="' . $rtName . '"/>';
                    }
                }
            }
            array_push($timeArr, $geoTime);
        }
    }
    //echo $totalDistance;
    $xml .= '</gps>';
    header('Content-Type: text/xml');
    echo $xml;
}
예제 #24
0
<?php

// date_default_timezone_set('PRC'); //默认时区
// echo "今天:",date("Y-m-d",time()),"<br>";
// echo "昨天:",date("Y-m-d",strtotime("-2 day")), "<br>";
// echo "明天:",date("Y-m-d",strtotime("+1 day")), "<br>";
// echo "一周后:",date("Y-m-d",strtotime("+1 week")), "<br>";
// echo "一周零两天四小时两秒后:",date("Y-m-d G:H:s",strtotime("+1 week 2 days 4 hours 2 seconds")), "<br>";
// echo "下个星期四:",date("Y-m-d",strtotime("next Thursday")), "<br>";
// echo "上个周一:".date("Y-m-d",strtotime("last Monday"))."<br>";
// echo "一个月前:".date("Y-m-d",strtotime("last month"))."<br>";
// echo "一个月后:".date("Y-m-d",strtotime("+1 month"))."<br>";
// echo "十年后:".date("Y-m-d",strtotime("+10 year"))."<br>";
include "helper.php";
//function getDistance($lat1, $lng1, $lat2, $lng2)
//     function getDistance($lat1, $lng1, $lat2, $lng2, $len_type = 1, $decimal = 2)
//118.814771#31.988162  120.738459#31.321361
echo getDistance(31.988162, 118.814771, 31.321361, 120.738459);
//echo getDistance(30, 50, 50, 100, $len_type = 2, $decimal = 2);
예제 #25
0
function PrintKMLFolder($path1, $vehiName, $resellID)
{
    //echo $path;
    $timeArr = array();
    $cnt = 1;
    $totalDistance = 0;
    $file1 = @fopen($path1, "r");
    if ($file1) {
        //echo $path1;
        while (!feof($file1)) {
            $data = @fgets($file1);
        }
        $data = getSortedData($data);
        $data1 = explode("#", $data);
        //print_r($data1);
        for ($j1 = 0; $j1 < count($data1); $j1++) {
            $data2 = explode("@", $data1[$j1]);
            if (count($data2) > 1) {
                $data3 = explode(",", $data2[1]);
                $vehi = $data3[0];
                $geodate = $data3[8];
                $geoTime = date("h:i A", strtotime($data3[9]));
                $pos1 = calLat($data3[2]);
                $pos2 = calLong($data3[1]);
                $mph = $data3[3];
                if ($pos1 > 0 && $pos2 > 0) {
                    if (!in_array($geoTime, $timeArr)) {
                        if ($j1 == 0) {
                            $pits1 = $pos1;
                            $pits2 = $pos2;
                        } else {
                            $pits3 = $pos1;
                            $pits4 = $pos2;
                            $dist = getDistance($pits1, $pits2, $pits3, $pits4);
                            $totalDistance += $dist;
                            $pits1 = $pits3;
                            $pits2 = $pits4;
                        }
                    }
                }
            }
            array_push($timeArr, $geoTime);
        }
        $locat = simpleGeocode($pits1, $pits2);
        $locat = str_replace('"', "", $locat);
        //$finalData = round($totalDistance).",".$locat.",".$data3[3].",".$geodate.",".$geoTime;
        @fclose($file1);
        print "Dear Client! " . $vehiName . " is located at " . $locat . " on " . $geodate . ", Sd = " . $mph . " k/h TD = " . round($totalDistance) . " km - VTS Alert.";
        $from = "";
        $to = $_GET[from];
        //sendLocation($from,$to,$msg,$resellID);
        //sendGatewaySMS($from,$to,$msg,$smsUri,$smsUname,$smsPwd,$smsSender);
        //return $finalData;
    } else {
        //return false;
        print_r("Dear Client! " . $vehiName . " is not avilable today - VTS Alert.");
        $from = "";
        $to = $_GET[from];
        //sendLocation($from,$to,$msg,$resellID);
        //sendGatewaySMS($from,$to,$msg,$smsUri,$smsUname,$smsPwd,$smsSender);
    }
}
예제 #26
0
파일: purchase.php 프로젝트: evilgeny/bob
 foreach ($fields as $k) {
     $data[$k] = $obj[$k];
 }
 if ($obj['date_entered']) {
     $data['bdate'] = date('Y-m-d', strtotime($obj['date_entered']));
     $tmp = mysql_fetch_assoc(query("select date_format(date_buy,'%H') as bhour, date_format(date_buy,'%i') as bminute from panelie_user_check where user_id=" . $obj['user_id'] . ' and check_number=' . intval($obj['check_id']) . " and date_format(date_buy,'%Y-%m-%d')='" . $data['bdate'] . "'"));
     if ($tmp && ($tmp['bhour'] != 0 || $tmp['bminute'] != 0)) {
         $data['bhour'] = $tmp['bhour'];
         $data['bminute'] = $tmp['bminute'];
     }
 }
 $data['first_date'] = getFirstDate($obj['user_id']);
 $data = array_merge($data, getShop($obj['user_id'], $obj['shop_id']));
 $data = array_merge($data, getUnit($obj['unit_id']));
 $data = array_merge($data, getCity($obj['city_id']));
 $data = array_merge($data, getDistance($obj['user_id'], $obj['shop_id']));
 $data = array_merge($data, getBarcode($obj['barcode_value']));
 if (!$data['product_name']) {
     $data['product_name'] = $obj['corrected_name'];
     if (!$data['product_name']) {
         unset($data['product_name']);
     }
 }
 $data = array_merge($data, calcWeight($data));
 $data = array_merge($data, getRange($obj['date_entered']));
 $data = array_merge($data, getNoPurchases($obj['date_entered']));
 $data = array_merge($data, getFamilyDetails($obj['user_id']));
 $data['discount'] = countDiscount($obj['price'], $obj['discount']);
 if ($obj['id']) {
     $data['purchase_id'] = $obj['id'];
 }
예제 #27
0
파일: getLists.php 프로젝트: class142/proj
function getNearestAirport($ort, $land)
{
    $ort = ucfirst($ort);
    $ab = "SELECT * FROM Flughafen WHERE INSTR(ort, '{$ort}') > 0";
    $res = mysql_query($ab);
    if (mysql_num_rows($res) != 0) {
        $flughafen = array();
        $strecke = array();
        $count = 0;
        while ($airport = mysql_fetch_object($res)) {
            $strecke[$count] = getDistance($ort, "airport " . $airport->id);
            $flughafen[$count] = $airport->ort;
            // echo $strecke[$count]."-->".$flughafen[$count];
            $count++;
        }
        $min = getNearest($strecke);
        return array(getFlughafenIDByOrt($flughafen[$min]), $strecke[getNearest($strecke)]);
    }
    $ab = "SELECT * From Flughafen WHERE land_id='{$land}'";
    $res = mysql_query($ab);
    $flughafen = array();
    $strecke = array();
    $count = 0;
    while ($airport = mysql_fetch_object($res)) {
        $strecke[$count] = getDistance($ort, $airport->id);
        $flughafen[$count] = $airport->ort;
        $count++;
    }
    $min = getNearest($strecke);
    return array(getFlughafenIDByOrt($flughafen[$min]), $strecke[getNearest($strecke)]);
}
예제 #28
0
function trouverPartenaire($player, $soloPlayers)
{
    //$first =  array_shift($soloPlayers);
    $procheP = $soloPlayers[0];
    $distanceMin = getDistance($player['address'], $procheP['address']);
    foreach ($soloPlayers as $p) {
        $tmp = getDistance($player['address'], $p['address']);
        if ($tmp < $distanceMin) {
            $procheP = $p;
            $distanceMin = $tmp;
        }
    }
    return [$player, $procheP];
}
예제 #29
0
        } else {
            $tuijian = pdo_fetchcolumn("SELECT count(*)  FROM " . $tablename . " WHERE  weid='{$weid}' AND nickname!='' AND isshow='{$isshow}'  AND yingcang='1' AND gender='2' AND tuijian='2' ");
            if ($tuijian < $tuijiannum) {
                $list1 = pdo_fetchall("SELECT * FROM " . $tablename . " WHERE  weid='{$weid}' AND nickname!='' AND isshow='{$isshow}'  AND yingcang='1' AND gender='2' AND tuijian='2' ORDER BY love DESC,time DESC");
                $NUM = $tuijiannum - $tuijian;
                $list2 = pdo_fetchall("SELECT * FROM " . $tablename . " WHERE  weid='{$weid}' AND nickname!='' AND isshow='{$isshow}'  AND yingcang='1' AND gender='2' AND tuijian='1' ORDER BY RAND()  LIMIT " . $NUM . "");
                $list = array_merge_recursive($list1, $list2);
            } else {
                $list = pdo_fetchall("SELECT * FROM " . $tablename . " WHERE  weid='{$weid}' AND nickname!='' AND isshow='{$isshow}'  AND yingcang='1' AND gender='2' AND tuijian='2' ORDER BY love DESC,time DESC LIMIT 0," . $tuijiannum);
            }
        }
        if (!empty($list) && is_array($list)) {
            foreach ($list as $row) {
                if (!empty($row['lat']) && !empty($row['lng'])) {
                    if (!empty($res['lat']) && !empty($res['lng'])) {
                        $juli[$row['id']] = "相距: " . getDistance($res['lat'], $res['lng'], $row['lat'], $row['lng']) . "km";
                    } else {
                        $juli[$row['id']] = "";
                    }
                } else {
                    $juli[$row['id']] = "";
                }
            }
        }
    }
} else {
    $url = empty($settings['url']) ? 'http://baidu.com' : $settings['url'];
    header("location:{$url}");
    exit;
}
if ($cfg['telephoneconfirm'] == '1') {
예제 #30
0
<?php

$config->styles->add($config->urls->templates . 'css/leaflet.css');
$config->scripts->add($config->urls->templates . 'js/leaflet-src.js');
$latitude = str_replace(',', '.', $page->latitude);
$longitude = str_replace(',', '.', $page->longitude);
$nearnodes = umkreissuche("node", $page->latitude, $page->longitude, 5);
$marker = '';
foreach ($nearnodes as $node) {
    $marker .= "L.circle([" . str_replace(',', '.', $node->latitude) . "," . str_replace(',', '.', $node->longitude) . "], 10,{\n                color:'blue',\n                fillColor:" . ($page->online == 1 ? "'green'" : "'red'") . "\n              }).addTo(map)\n                .bindPopup('<a href=\"" . $node->httpUrl . "\">{$node->subtitle}</a><br>" . getDistance($node->dist) . " entfernt');";
}
$script = "<script>\n            var map = L.map('map').setView([{$latitude}, {$longitude}], 16);\n\n            L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {\n              maxZoom: 19,\n              attribution: '&copy; <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>'\n            }).addTo(map);\n\n            L.circle([{$latitude}, {$longitude}], 10, {\n              color:" . ($page->online == 1 ? "'green'" : "'red'") . ",\n              fillColor: " . ($page->online == 1 ? "'green'" : "'red'") . "\n            }).addTo(map);\n\n            {$marker}\n\n            map.invalidateSize();\n          </script>";
$page->losttime = time_elapsed_string($page->getUnformatted('lastseen'));
$content = renderPage();