Esempio n. 1
0
 public function show()
 {
     $offset = $this->input['offset'] ? $this->input['offset'] : 0;
     //$count = $this->input['count'] ? intval($this->input['count']) : 20;
     $count = $this->input['count'];
     $condition = $this->get_condition();
     $orderby = '  ORDER BY c.order_id DESC,c.id DESC ';
     if ($count) {
         $limit = ' LIMIT ' . $offset . ' , ' . $count;
     } else {
         $limit = '';
     }
     $ret = $this->mode->show($condition, $orderby, $limit);
     if (!empty($ret)) {
         foreach ($ret as $k => $v) {
             //传过来的是GPS坐标
             if ($this->input['jd'] || $this->input['wd']) {
                 //计算距离
                 if ($v['GPS_x'] && $v['GPS_y']) {
                     $v['distance'] = GetDistance($v['GPS_y'], $v['GPS_x'], $this->input['wd'], $this->input['jd']);
                     $v['distance_format'] = distance_change_unit($v['distance']);
                 } else {
                     $v['distance'] = '距离不详';
                 }
             }
             $this->addItem($v);
         }
     } else {
         $this->addItem(array());
     }
     $this->output();
 }
Esempio n. 2
0
 function nearby($input)
 {
     $this->db->select('id,name,avatar,sign,lat,lng,fans,cared')->where(["addrTime>" => time() - 1296000, 'id!=' => UID], NULL, FALSE)->order_by("pow(lat-{$input['lat']},2)+pow(lng-{$input['lng']},2)", 'asc')->limit($input['count'], $input['page'] * $input['count']);
     $data = $this->db->get('user')->result_array();
     $this->load->helper('distance');
     foreach ($data as $key => $value) {
         // 			$data[$key]['value']=pow($data[$key]['lat']-$input['lat'],2)+pow(($data[$key]['lng']-$input['lng'])*cos(($data[$key]['lat']+$input['lat'])/2),2);
         $data[$key]['distance'] = GetDistance($data[$key]['lat'], $data[$key]['lng'], $input['lat'], $input['lng']);
     }
     return $data;
 }
Esempio n. 3
0
 public function show()
 {
     $limit = '';
     $offset = $this->input['offset'] ? intval($this->input['offset']) : 0;
     $count = $this->input['count'] ? intval($this->input['count']) : 10;
     if ($offset || $count) {
         $limit = " limit {$offset},{$count}";
     }
     $sql = 'SELECT * FROM ' . DB_PREFIX . 'topic WHERE 1 ' . $this->get_conditions() . ' ORDER BY order_id DESC, id DESC' . $limit;
     $query = $this->db->query($sql);
     while ($row = $this->db->fetch_array($query)) {
         $row['format_create_time'] = hg_tran_time($row['create_time']);
         $row['indexpic'] = ($tmp = unserialize($row['indexpic'])) ? $tmp : array();
         $row['latest'] = ($tmp = json_decode($row['latest'], 1)) ? $tmp : array();
         $row['avatar'] = ($tmp = unserialize($row['avatar'])) ? $tmp : array();
         $row['distanc'] = GetDistance($row['lat'], $row['lon'], $this->location['lat'], $this->location['lon']);
         $this->addItem($row);
     }
     $this->output();
 }
Esempio n. 4
0
 public function detail()
 {
     $id = intval($this->input['id']);
     if (!$id) {
         $this->errorOutput(NOID);
     }
     $sql = "SELECT t1.name,t1.level,t1.address,t1.baidu_longitude,t1.baidu_latitude,t1.hospital_id,t1.telephone,t1.traffic,t2.content FROM " . DB_PREFIX . "hospital t1 \n\t\t\t\tLEFT JOIN " . DB_PREFIX . "content t2 \n\t\t\t\t\tON t1.id = t2.cid \n\t\t\t\tWHERE t1.status =1 AND t1.id = {$id}";
     $data = $this->db->query_first($sql);
     if ($data['telephone']) {
         $data['telephone'] = @unserialize($data['telephone']);
     } else {
         $data['telephone'] = array();
     }
     //ios传入gps坐标,转百度坐标
     if ($this->input['jd'] || $this->input['wd']) {
         //gps坐标转百度坐标
         $baidu_zuobiao = GpsToBaidu($this->input['jd'], $this->input['wd']);
         $this->input['baidu_longitude'] = $baidu_zuobiao['x'];
         $this->input['baidu_latitude'] = $baidu_zuobiao['y'];
     }
     if ($data['baidu_longitude'] && $data['baidu_latitude'] && $this->input['baidu_longitude'] && $this->input['baidu_latitude']) {
         //计算距离
         $data['distance'] = GetDistance($data['baidu_latitude'], $data['baidu_longitude'], $this->input['baidu_latitude'], $this->input['baidu_longitude'], 2);
         $data['distance'] .= 'KM';
     } else {
         $data['distance'] = '距离不祥';
     }
     //医院等级
     if ($data['level']) {
         $data['level'] = $this->settings['hospital_leval'][$data['level']];
     }
     //获取图片信息
     $sql = 'SELECT host,dir,filepath,filename FROM ' . DB_PREFIX . 'materials  WHERE cid = ' . $id . ' ORDER BY id DESC';
     $q = $this->db->query($sql);
     while ($row = $this->db->fetch_array($q)) {
         $data['pic_info'][] = $row;
     }
     $this->addItem($data);
     $this->output();
 }
Esempio n. 5
0
            $lobbyplayers = $lobby->lobbyData();
            $count = countPlayers($lid);
            updateLobbyReady($lid);
            if ($lobby->status == "ready") {
                removeOfflinePlayers(checkOfflinePlayers($lid));
            }
            $array = array('id' => $uid, 'ready' => readystatus($id, true), 'inlobby' => isPlayerInLobby($uid), 'info' => $lobbyinfo, 'count' => $count, 'players' => $lobbyplayers);
            echo json_encode($array);
            break;
        case "lobbyplayers":
            echo json_encode($lobby->lobbyData());
            break;
        case "distance":
            if ($lat && $lon) {
                $server = new Server($lobby->lobbyserver($lid));
                echo GetDistance($lat, $lon, $server->latitude, $server->longitude);
            }
            break;
        case "balanceTeams":
            $players = getPlayersSkill($lid);
            balanceTeams($lid, $players);
            break;
    }
} elseif ($uid) {
    switch ($request) {
        case "addFriend":
            if ($fid) {
                addFriend($uid, $fid);
            }
            break;
        case "newLobby":
Esempio n. 6
0
 public function show()
 {
     //ios传入gps坐标,转百度坐标
     if ($this->input['jd'] || $this->input['wd']) {
         //gps坐标转百度坐标
         $baidu_zuobiao = GpsToBaidu($this->input['jd'], $this->input['wd']);
         $this->input['baidu_longitude'] = $baidu_zuobiao['x'];
         $this->input['baidu_latitude'] = $baidu_zuobiao['y'];
     }
     $cond = $this->get_condition();
     $offset = $this->input['offset'] ? intval($this->input['offset']) : 0;
     $count = $this->input['count'] ? intval($this->input['count']) : 20;
     $limit = ' LIMIT ' . $offset . ',' . $count;
     $sql = "SELECT t1.id,t1.name,t1.company_id,t1.currentnum,t1.totalnum,t1.station_id,t1.address,t1.stationx, t1.stationy, t1.baidu_latitude, t1.baidu_longitude, t3.station_icon FROM " . DB_PREFIX . "station t1 \n\t\t\t\tLEFT JOIN " . DB_PREFIX . "company t3 \n\t\t\t\t\tON t1.company_id = t3.id \n\t\t\t\tWHERE 1 " . $cond;
     $q = $this->db->query($sql);
     while ($row = $this->db->fetch_array($q)) {
         if ($row['baidu_longitude'] && $row['baidu_latitude']) {
             if ($this->input['baidu_longitude'] || $this->input['baidu_latitude']) {
                 //计算距离
                 $row['distance'] = GetDistance($row['baidu_latitude'], $row['baidu_longitude'], $this->input['baidu_latitude'], $this->input['baidu_longitude'], 1);
             }
         }
         $row['station_icon'] = unserialize($row['station_icon']);
         if (!$row['station_icon']['filename']) {
             $row['station_icon'] = array();
         }
         if ($row['totalnum'] && $row['totalnum'] >= $row['currentnum']) {
             $row['park_num'] = $row['totalnum'] - $row['currentnum'];
         } else {
             $row['park_num'] = 0;
         }
         $row['currentnum'] = intval($row['currentnum']);
         unset($row['totalnum']);
         $info[] = $row;
     }
     if ($info) {
         //按距离由近到远排序
         $len = count($info);
         for ($i = 1; $i < $len; $i++) {
             for ($j = $len - 1; $j >= $i; $j--) {
                 if ($info[$j]['distance'] < $info[$j - 1]['distance']) {
                     $x = $info[$j - 1];
                     $info[$j - 1] = $info[$j];
                     $info[$j] = $x;
                 }
             }
         }
         //根据偏移量返回结果
         if ($offset) {
             $station_num = 0;
             foreach ($info as $k => $v) {
                 if ($station_num == $count) {
                     break;
                 }
                 if ($k >= $offset) {
                     $station_num = $station_num + 1;
                     $info_limit[] = $v;
                 }
             }
         } else {
             foreach ($info as $k => $v) {
                 if ($station_num == $count) {
                     break;
                 }
                 $station_num = $station_num + 1;
                 $info_limit[] = $v;
             }
         }
         $info = array();
         $info = $info_limit;
         //单位换算
         foreach ($info as $k => $row) {
             if ($row['distance']) {
                 if ($row['distance'] > 1000) {
                     $row['distance'] /= 1000;
                     $row['distance'] .= 'km';
                 } else {
                     $row['distance'] .= 'm';
                 }
             } else {
                 $row['distance'] .= '距离不详';
             }
             $this->addItem($row);
         }
     }
     $this->output();
 }
Esempio n. 7
0
 public function get_subway_sites($condition, $limit, $info = array())
 {
     $sql = "SELECT DISTINCT a.*\r\n\t\t\t\tFROM  " . DB_PREFIX . "subway_site a\r\n\t\t\t\tLEFT JOIN " . DB_PREFIX . "subway_relation b on a.id = b.site_id\r\n\t\t\t\tLEFT JOIN " . DB_PREFIX . "subway c on c.id = b.sub_id\r\n\t\t\t\tWHERE 1" . $condition . ' AND c.state=1 ORDER BY id DESC ' . $limit;
     $q = $this->db->query($sql);
     $site_color = $ret = $retu = $distance = array();
     $site_color = $this->get_site_color(1);
     if ($info['latitude'] && $info['longitude']) {
         while ($row = $this->db->fetch_array($q)) {
             $suname = $color = array();
             $suname = $site_color[$row['id']]['subname'];
             $color = $site_color[$row['id']]['color'];
             $row['subway'] = $suname;
             $row['sub_color'] = $color;
             if ($row['latitude'] && $row['longitude']) {
                 $row['distance'] = GetDistance($info['latitude'], $info['longitude'], $row['latitude'], $row['longitude']);
                 if ($row['distance']) {
                     $retu[$row['distance']] = $row;
                     $distance[] = $row['distance'];
                 } else {
                     $retu[0] = $row;
                     $distance[] = 0;
                 }
             }
         }
         asort($distance, SORT_NUMERIC);
         $key = array_shift($distance);
         //$retu[$key]['distance']	= $this->get_distance($retu[$key]['distance']);
         $ret[] = $retu[$key];
     } else {
         while ($row = $this->db->fetch_array($q)) {
             $suname = $color = array();
             $suname = $site_color[$row['id']]['subname'];
             $color = $site_color[$row['id']]['color'];
             $row['subway'] = $suname;
             $row['sub_color'] = $color;
             $ret[] = $row;
         }
     }
     foreach ($ret as $k => $v) {
         $v['distance'] = intval($v['distance']);
         if ($v['distance'] >= 1000) {
             $v['distance'] = $v['distance'] / 1000;
             $ret[$k]['distance'] = sprintf("%.2f", $v['distance']) . ' km';
         } else {
             $ret[$k]['distance'] .= ' m';
         }
     }
     return $ret;
 }
Esempio n. 8
0
if (isset($_GET['id'])) {
    echo '
			<div class="rightbox rbox2">				
				';
    while ($row = mysqli_fetch_array($result)) {
        $date2 = $row['end'];
        $myend = strtotime($date2);
        if ($myend > strtotime(date("Y-m-d")) || $myend == strtotime(date("Y-m-d"))) {
            $e1 = $row['lat'];
            $n1 = $row['lon'];
            /*$e2 = $_SESSION['val']['lat'];
            		$n2 = $_SESSION['val']['lng'];*/
            $distance = 0;
            $id = $row['ID'];
            $_SESSION['ref'] = $id;
            $distance = GetDistance($e1, $_SESSION['e2'], $n1, $_SESSION['n2']);
            $distance = round($distance * 1000 * 100 / 1609, 0);
            $_SESSION['dis'] = $distance;
            if ($distance <= $_SESSION['mydis']) {
                echo '
										<div class="resultbox">
										<small style="float:right;">Job Ref: ' . $id . '</small>
										<font class="headA">' . ucwords($row['title']) . '</font><br>
										<small>' . $distance . ' Miles away (' . substr($row['postcode'], 0, -3) . ')</small><br><br>
										<font class="headB">Job Type: </font>&nbsp;' . ucwords($row['type']) . '<br>
										<p><font class="headB">Description: </font>&nbsp;' . $row['jobinfo'] . '</p><br>
										<font class="headB">End Date: </font>&nbsp;' . date("d/m/Y", strtotime($row['end'])) . '<br>
										<div class="clear"></div><!--clear floats-->
										</div>
										
										';
Esempio n. 9
0
 public function get_carpark_by_district($city_name, $wd = '', $jd = '', $type_id = '')
 {
     //查询出城市id
     $sql = "SELECT * FROM " . DB_PREFIX . "carpark_district WHERE name = '" . $city_name . "'";
     $city_arr = $this->db->query_first($sql);
     if (!$city_arr) {
         return false;
     }
     //查询出该城市里面的区域
     $sql = "SELECT * FROM " . DB_PREFIX . "carpark_district WHERE fid = '" . $city_arr['id'] . "'";
     $q = $this->db->query($sql);
     $district = array();
     $district_ids = array();
     while ($r = $this->db->fetch_array($q)) {
         $district[$r['id']] = $r;
         $district_ids[] = $r['id'];
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "carpark WHERE status=2 AND district_id IN (" . implode(',', $district_ids) . ")";
     //如果类型id存在,连上类型id
     if ($type_id) {
         $sql .= " AND type_id = " . $type_id;
     }
     $q = $this->db->query($sql);
     $carpark = array();
     while ($r = $this->db->fetch_array($q)) {
         $r['district_name'] = $district[$r['district_id']]['name'];
         $r['carpark_num'] = $district[$r['district_id']]['carpark_num'];
         if ($wd && $jd) {
             $r['distance'] = GetDistance($r['GPS_y'], $r['GPS_x'], $wd, $jd);
         }
         $carpark[$r['district_id']][$r['id']] = $r;
     }
     //如果存在当前的经纬度(GPS),算出某个区域内最近的停车场
     $carpark_nearest = array();
     if ($wd && $jd) {
         foreach ($carpark as $k => $v) {
             $_k = 0;
             //记录最近的停车场id
             $flag = 1;
             $_distance_tmp = 0;
             foreach ($v as $kk => $vv) {
                 if (intval($vv['distance']) < $_distance_tmp || $flag) {
                     $_distance_tmp = intval($vv['distance']);
                     $_k = $vv['id'];
                 }
                 $flag = 0;
             }
             $v[$_k]['distance_format'] = distance_change_unit($v[$_k]['distance']);
             $carpark_nearest[] = $v[$_k];
         }
     }
     //如果存在返回给个区域最近的停车场,不存在就返回所有区里面所有的停车场
     if ($carpark_nearest) {
         return $carpark_nearest;
     } else {
         return $carpark;
     }
 }
Esempio n. 10
0
 public function show()
 {
     $id = intval($this->input['station_id']);
     if (!$id) {
         $this->errorOutput('NOID');
     }
     $cond = " AND t1.id = " . $id;
     $sql = "SELECT t1.id, t1.name, t1.company_id, t1.station_id, t1.totalnum, t1.currentnum, t1.address, t1.brief, t1.dateline, t1.baidu_latitude, t1.baidu_longitude, t2.host, t2.dir, t2.filepath, t2.filename, t3.name company_name, t3.customer_hotline, t3.api_url, t3.brief as company_brief, t3.station_icon, t4.name as region_name FROM " . DB_PREFIX . "station t1 \n\t\t\tLEFT JOIN " . DB_PREFIX . "material t2 \n\t\t\t\tON t1.material_id=t2.id \n\t\t\tLEFT JOIN " . DB_PREFIX . "company t3 \n\t\t\t\tON t1.company_id=t3.id \n\t\t\tLEFT JOIN " . DB_PREFIX . "region t4\n\t\t\t\tON t1.region_id = t4.id\n\t\t\tWHERE 1 " . $cond;
     $ret = $this->db->query_first($sql);
     //hg_pre($ret,0);
     if (!$ret) {
         $this->errorOutput('NOCONTENT');
     }
     //查询站点下的实景照片数目
     $sql = "SELECT count(*) as total FROM " . DB_PREFIX . "material WHERE cid = " . $id;
     $pho_total = $this->db->query_first($sql);
     //实景照片数目
     $ret['img_num'] = $pho_total['total'];
     //如果运营单位有更新数据接口,请求接口替换总数,可借自行车数量
     if ($ret['api_url']) {
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $ret['api_url']);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         $response = curl_exec($ch);
         if ($response) {
             $response = json_decode($response, 1);
             $info = $response['date'];
         }
         curl_close($ch);
         //关闭
         if ($info) {
             foreach ($info as $k => $v) {
                 if ($ret['station_id'] == ltrim($v['stationid'], '0')) {
                     $ret['dateline'] = $v['dateline'];
                     $ret['totalnum'] = $v['totalnum'];
                     $ret['currentnum'] = $v['currentnum'];
                     break;
                 }
             }
         }
     }
     unset($ret['api_url']);
     //可停车位
     if ($ret['totalnum'] && $ret['totalnum'] >= $ret['currentnum']) {
         $ret['park_num'] = $ret['totalnum'] - $ret['currentnum'];
         unset($ret['totalnum']);
     } else {
         $ret['park_num'] = 0;
     }
     if ($ret['host'] && $ret['dir'] && $ret['filepath'] && $ret['filename']) {
         //索引图
         $ret['indexpic'] = array('host' => $ret['host'], 'dir' => $ret['dir'], 'filepath' => $ret['filepath'], 'filename' => $ret['filename']);
     } else {
         if ($ret['station_icon']) {
             $icon = '';
             $icon = unserialize($ret['station_icon']);
             if (is_array($icon) && !empty($icon)) {
                 $ret['indexpic'] = array('host' => $icon['host'], 'dir' => $icon['dir'], 'filepath' => $icon['filepath'], 'filename' => $icon['filename']);
             } else {
                 $ret['indexpic'] = array();
             }
         } else {
             $ret['indexpic'] = array();
         }
     }
     unset($ret['host'], $ret['dir'], $ret['filepath'], $ret['filename'], $ret['station_icon']);
     //数据更新时间
     if ($ret['dateline']) {
         $ret['dateline'] = date('m-d H:i', $ret['dateline']);
     } else {
         $ret['dateline'] = date('m-d H:i', TIMENOW);
     }
     if ($ret['baidu_longitude'] && $ret['baidu_latitude']) {
         //ios传入gps坐标,转百度坐标
         if ($this->input['jd'] && $this->input['wd']) {
             //gps坐标转百度坐标
             $baidu_zuobiao = GpsToBaidu($this->input['jd'], $this->input['wd']);
             $this->input['baidu_longitude'] = $baidu_zuobiao['x'];
             $this->input['baidu_latitude'] = $baidu_zuobiao['y'];
         }
         if ($this->input['baidu_longitude'] || $this->input['baidu_latitude']) {
             //计算距离
             $ret['distance'] = GetDistance($ret['baidu_latitude'], $ret['baidu_longitude'], $this->input['baidu_latitude'], $this->input['baidu_longitude'], 1);
             if ($ret['distance']) {
                 if ($ret['distance'] > 1000) {
                     $ret['distance'] /= 1000;
                     $ret['distance'] .= 'km';
                 } else {
                     $ret['distance'] .= 'm';
                 }
             } else {
                 $ret['distance'] = '距离不详';
             }
         }
     }
     if ($ret['baidu_latitude'] != '0.00000000000000') {
         $ret['latitude'] = $ret['baidu_latitude'];
     }
     if ($ret['baidu_longitude'] != '0.00000000000000') {
         $ret['longitude'] = $ret['baidu_longitude'];
     }
     unset($ret['baidu_longitude'], $ret['baidu_latitude']);
     $this->addItem($ret);
     $this->output();
 }
Esempio n. 11
0
 public function show()
 {
     //判断有没有登陆
     if (!$this->user['user_id']) {
         $this->errorOutput(NO_LOGIN);
     }
     //判断到没到签到时间
     if (TIMENOW < strtotime(SIGN_STIME)) {
         $this->errorOutput(SIGN_NOT_START);
     }
     //判断是否过了签到时间
     if (TIMENOW > strtotime(SIGN_ETIME)) {
         $this->errorOutput(SIGN_HAVE_OVER);
     }
     //判断用户在不在会场附近
     if (defined('IS_VERIFY_GPS') && IS_VERIFY_GPS) {
         if (!$this->input['long_x'] || !$this->input['lat_y']) {
             $this->errorOutput(NO_X_Y);
         } else {
             $long_x = $this->input['long_x'];
             //经度
             $lat_y = $this->input['lat_y'];
             //纬度
             //如果是安卓设备传过来的话,传过来的是百度坐标,需要转换成GPS坐标
             if (defined('ISANDROID') && ISANDROID || $this->input['is_android']) {
                 $_GPS = FromBaiduToGpsXY($long_x, $lat_y);
                 if ($_GPS) {
                     $long_x = $_GPS['GPS_x'];
                     $lat_y = $_GPS['GPS_y'];
                 }
             }
             $_distance = GetDistance($lat_y, $long_x, $this->settings['meeting_pos']['y'], $this->settings['meeting_pos']['x']);
             if ($_distance > MEETING_DISTANCE) {
                 $this->errorOutput(YOU_NOT_NEARBY_MEETING);
             }
         }
     }
     //判断当前用户有没有激活
     $_memberInfo = $this->member_mode->detail('', " AND member_id = '" . $this->user['user_id'] . "' ");
     if (!$_memberInfo) {
         $this->errorOutput(YOU_HAVE_NOT_ACTIVATED);
     }
     $ret = array();
     //根据激活码id取出激活码类型
     $code = $this->activate->detail($_memberInfo['activate_code_id']);
     if ($code) {
         $ret['guest_type'] = $code['guest_type'];
     } else {
         $ret['guest_type'] = '1';
         //默认场外嘉宾
     }
     //判断当前用户是否已经签过到
     if ($_memberInfo['is_sign']) {
         //已经签到的场外嘉宾提示
         if ($ret['guest_type'] == '1') {
             $this->errorOutput(NOT_KNOW_IDENTY);
         } else {
             $this->errorOutput(YOU_HAVE_SIGNED);
         }
     }
     $this->addItem($ret);
     $this->output();
 }
Esempio n. 12
0
function CheckLocations($Locations, $StoreID, $Lat, $Lng)
{
    foreach ($Locations as $Location) {
        if ($Location[1] == -1) {
            return SetToWeb($StoreID, 'web data');
        }
    }
    if ($Lat != -1) {
        //Look for locations
        list($QR, $RS, $T) = QuerySet("SELECT SL.LocationID, L.LocationLatitude AS Lat, L.LocationLongitude AS Lng\n                                        FROM 2200_Store_Locations SL\n                                       INNER JOIN 3000_Locations L ON SL.LocationID = L.LocationID\n                                       WHERE SL.StoreID = " . $StoreID . ";");
        if ($QR < 0) {
            return SysLogIt('Error searching for store locations.', StatusError, ActionSelect);
        }
        if ($QR > 0) {
            while ($DR = mysql_fetch_array($RS)) {
                $Dist = GetDistance($DR['Lat'], $DR['Lng'], $Lat, $Lng);
                if ($Dist > 1000) {
                    return SetToWeb($StoreID, 'distance of current division (distance of ' . $Dist . ')');
                }
            }
        }
    }
    return AddLocationsTo($Locations, $StoreID, $Lat, $Lng);
}
Esempio n. 13
0
function GetSpeed($track, $dstPts)
{
    $speed = array_fill(0, $dstPts, 0);
    for ($i = 0, $idx = 0, $step = ($track['nbPt'] - 1) / ($dstPts - 1); $i < $dstPts; $i++, $idx += $step) {
        $dist = $count = $time = 0;
        $avgidx = $idx;
        while (--$avgidx >= 0 && $count < 65) {
            $deltaT = $track['timeSec'][$idx] - $track['timeSec'][$avgidx];
            if ($count > 0 && $deltaT > 60) {
                break;
            }
            $dist += GetDistance($track['lat'][$avgidx], $track['lon'][$avgidx], $track['lat'][$avgidx + 1], $track['lon'][$avgidx + 1]);
            $time = $deltaT;
            $count++;
        }
        $speed[$i] = $time > 0 ? floor(3600 * $dist / $time) : 0;
    }
    return $speed;
}
Esempio n. 14
0
 public function detail()
 {
     //echo generateExchangeCode();exit();
     $user_id = intval($this->user['user_id']);
     //$user_id = 496;
     if (!$user_id) {
         $this->errorOutput('登录才能参加抽奖哦!');
     }
     $id = intval($this->input['id']);
     $sort_id = intval($this->input['sort_id']);
     if ($this->input['shenwen']) {
         if (!$this->curl) {
             return array();
         }
         if ($_FILES) {
             $file = $_FILES;
         }
         $this->curl->setSubmitType('post');
         $this->curl->setReturnFormat('json');
         $this->curl->initPostData();
         $this->curl->addFile($file);
         $this->curl->addRequestData('shenwen', $this->input['shenwen']);
         $this->curl->addRequestData('a', 'show');
         $ret = $this->curl->request('shenwen.php');
         if ($ret['channel_name']) {
             $sql = "SELECT id FROM " . DB_PREFIX . "sort WHERE name LIME '" . $ret['channel_name'] . "%'";
             $res = $this->db->query_first($sql);
             if ($res['id']) {
                 $sort_id = $res['id'];
             }
         }
     }
     $data = array();
     if ($this->settings['lottery_filter']) {
         $sql = "SELECT * FROM " . DB_PREFIX . "lottery_filter WHERE 1 ";
         if ($sort_id) {
             $sql .= "AND sort_id = " . $sort_id . " ORDER BY order_id DESC LIMIT 0,1";
         } else {
             if ($id) {
                 $sql .= "AND id = " . $id;
             } else {
                 $sql .= "ORDER BY order_id DESC LIMIT 0,1";
             }
         }
         $res = $this->db->query_first($sql);
         if ($res['content']) {
             $data = unserialize($res['content']);
             $data['end_hours'] = $data['end_hour'];
             $data['start_hours'] = $data['start_hour'];
             $id = $data['id'];
             if ($res['win_info']) {
                 $data['win_info'] = unserialize($res['win_info']);
             }
         }
     }
     //hg_pre($data,0);
     if (empty($data)) {
         if ($sort_id) {
             $sql = "SELECT id FROM " . DB_PREFIX . "lottery WHERE status = 1 AND sort_id = " . $sort_id . " \n\t\t\t\t\t\tORDER BY order_id DESC LIMIT 0,1";
             $res = $this->db->query_first($sql);
             $id = $res['id'] ? $res['id'] : 0;
         }
     }
     $id = $id ? $id : intval($this->input['id']);
     if (!$id) {
         $this->errorOutput('不存在此活动');
     }
     if (empty($data)) {
         include_once CUR_CONF_PATH . 'lib/lottery_mode.php';
         $obj = new lottery_mode();
         $data = $obj->detail($id);
     }
     if (!$data['id'] || $data['status'] != 1) {
         $this->errorOutput('不存在此活动');
     }
     //hg_pre($data,0);
     //时间和周期判断
     if ($data['time_limit']) {
         $week_now = date('w', TIMENOW);
         $hour_now = date('His', TIMENOW);
         $day_now = date('d', TIMENOW);
         $notstartdesc = $data['notstartdesc'];
         if (!$notstartdesc) {
             $notstartdesc = $this->settings['notstartdesc'] ? $this->settings['notstartdesc'] : '活动尚未开始, 敬请期待';
         }
         if ($data['start_times'] > TIMENOW || $data['start_hours'] > $hour_now) {
             $this->errorOutput($notstartdesc);
         }
         if ($data['end_times'] < TIMENOW || $hour_now > $data['end_hours']) {
             $message = $data['finish_desc'];
             if (!$message) {
                 $message = $this->settings['finish_desc'] ? $this->settings['finish_desc'] : '活动已结束, 敬请期待下次活动1.';
             }
             $this->errorOutput($message);
         }
         if ($data['cycle_type'] && $data['cycle_value']) {
             $data['cycle_value'] = explode(',', $data['cycle_value']);
             if ($week_now == 0) {
                 $week_now = 1;
             }
             if ($data['cycle_type'] == 1 && !in_array($week_now, $data['cycle_value'])) {
                 $this->errorOutput($notstartdesc);
             } else {
                 if ($data['cycle_type'] == 2 && !in_array($day_now, $data['cycle_value'])) {
                     $this->errorOutput($notstartdesc);
                 }
             }
         }
     }
     //中奖限制
     if ($data['lottery_limit']) {
         $sql = "SELECT count(*) as total FROM " . DB_PREFIX . "win_info WHERE prize_id != 0 AND confirm = 1 AND member_id = " . $user_id . " AND lottery_id = " . $data['id'];
         $res = $this->db->query_first($sql);
         if ($res['total']) {
             $message = $this->settings['lottery_limit_tip'] ? $this->settings['lottery_limit_tip'] : '您已中奖,谢谢参与!';
             $this->errorOutput($message);
         }
     }
     //积分限制
     if ($data['score_limit'] && $data['need_score'] > 0) {
         include_once ROOT_PATH . 'lib/class/members.class.php';
         $mem_obj = new members();
         $credit = $mem_obj->get_member_credits($user_id);
         if ($credit[$user_id]['credits'] < $data['need_score']) {
             $this->errorOutput('对不起,您的积分不够了!');
         }
     }
     //限制ip
     if ($data['ip_limit']) {
         $ip_limit_hour = $data['ip_limit_time'] ? $data['ip_limit_time'] : 1;
         $ip_limit_num = $data['ip_limit_num'] ? $data['ip_limit_num'] : 1;
         $ip_limit_time = TIMENOW - $ip_limit_hour * 3600;
         $ip = hg_getip();
         //查询用户参加此活动次数
         $sql = "SELECT count(*) as total FROM " . DB_PREFIX . "win_info WHERE confirm = 1 AND ip = '" . $ip . "' AND lottery_id = " . $data['id'] . " AND create_time > " . $ip_limit_time;
         $res = $this->db->query_first($sql);
         //达到ip限制次数
         if ($res['total'] >= $data['ip_limit_num']) {
             $this->errorOutput('您已参加活动,下一时段活动再来吧!');
         }
     }
     //限制设备标识
     $device_token = $this->input['device_token'];
     if ($data['device_limit'] && $device_token) {
         $device_limit_hour = $data['device_limit_time'] ? $data['device_limit_time'] : 1;
         $device_num_limit = $data['device_num_limit'] ? $data['device_num_limit'] : 1;
         $device_limit_time = TIMENOW - $device_limit_hour * 3600;
         //查询用户参加此活动次数
         $sql = "SELECT count(*) as total FROM " . DB_PREFIX . "win_info WHERE confirm = 1 AND device_token = '" . $device_token . "' AND lottery_id = " . $data['id'] . " AND create_time > " . $device_limit_time;
         $res = $this->db->query_first($sql);
         //达到ip限制次数
         if ($res['total'] >= $data['device_num_limit']) {
             $this->errorOutput('您已参加活动,下一时段活动再来吧!');
         }
     }
     //限制用户参加活动次数
     if ($data['num_limit'] && $data['account_limit']) {
         //查询用户参加此活动次数
         $sql = "SELECT count(*) as total FROM " . DB_PREFIX . "win_info WHERE confirm = 1 AND member_id = " . $user_id . " AND lottery_id = " . $data['id'];
         $res = $this->db->query_first($sql);
         //查询额外奖励抽奖次数
         $sql = "SELECT reward_num FROM " . DB_PREFIX . "reward WHERE member_id = {$user_id} AND lottery_id = {$id}";
         $reward = $this->db->query_first($sql);
         $reward_num = $reward['reward_num'];
         if ($reward_num) {
             $data['account_limit'] += $reward_num;
         }
         //达到活动限制次数
         if ($res['total'] >= $data['account_limit']) {
             $this->errorOutput('您已参加活动,下一时段活动再来吧!');
         }
     }
     //区域限制
     if ($data['area_limit']) {
         $distance = '';
         if ($this->input['GPS_longitude'] || $this->input['GPS_latitude']) {
             //计算距离
             if ($data['GPS_latitude'] && $data['GPS_longitude']) {
                 $distance = GetDistance($data['GPS_latitude'], $data['GPS_longitude'], $this->input['GPS_latitude'], $this->input['GPS_longitude']);
             }
         } elseif ($this->input['baidu_longitude'] || $this->input['baidu_latitude']) {
             if ($data['baidu_latitude'] && $data['baidu_longitude']) {
                 $distance = GetDistance($data['baidu_latitude'], $data['baidu_longitude'], $this->input['baidu_latitude'], $this->input['baidu_longitude']);
             }
         }
         if ($distance > $data['distance']) {
             $this->errorOutput('您不在抽奖范围内,请到' . $data['address'] . '附近。');
         }
     }
     //版本限制
     if ($data['version_limit'] && $data['version_limit'] > $this->input['version']) {
         $this->errorOutput('您的应用版本过低,升级后再来吧!');
     }
     //未中奖反馈
     $feedback = $data['feedback'];
     $arr = $prize = $award = array();
     //查询活动奖品
     $prize_arr = array();
     $prize_arr = $data['prize'];
     //中奖次数限制
     $win_limit_flag = false;
     if ($data['win_limit']) {
         if (!$data['win_num_limit']) {
             $win_limit_flag = true;
         } else {
             $today_start = strtotime(date('Y-m-d', TIMENOW));
             $today_end = $today_start + 86400;
             $sql = "SELECT count(*) as total FROM " . DB_PREFIX . "win_info WHERE confirm = 1 AND prize_id != '' AND create_time >= '" . $today_start . "' AND create_time < '" . $today_end . "' AND lottery_id = " . $data['id'];
             $res = $this->db->query_first($sql);
             if ($res['total'] >= $data['win_num_limit']) {
                 $win_limit_flag = true;
             }
         }
     }
     if (empty($prize_arr) && !$win_limit_flag) {
         //查询奖项
         $sql = 'SELECT p.*,m.host,m.dir,m.filepath,m.filename FROM ' . DB_PREFIX . "prize p  \n\t\t\t\t\tLEFT JOIN " . DB_PREFIX . "materials m \n\t\t\t\t\t\tON p.indexpic_id = m.id \n\t\t\t\t\tWHERE p.lottery_id = {$data['id']} ORDER BY id ASC";
         $q = $this->db->query($sql);
         while ($row = $this->db->fetch_array($q)) {
             $prize_arr[$row['id']] = $row;
         }
     }
     $sum = array();
     $arr = array();
     if (is_array($prize_arr) && count($prize_arr) && !$win_limit_flag) {
         foreach ($prize_arr as $key => $val) {
             if ($val['prize_win'] >= $val['prize_num']) {
                 continue;
             }
             $chance = array();
             $chance = explode('/', $val['chance']);
             if (!$chance[1]) {
                 continue;
             }
             $arr[$val['id']] = $chance[0];
             $sum[$val['id']] = $chance[1];
         }
     }
     $prize_id = '';
     if ($sum && $arr) {
         $prize_id = get_rand($arr, $sum);
         //根据概率获取奖项id
     }
     $prize_id = $prize_id ? $prize_id : 0;
     $award['lottery_id'] = $data['id'];
     //抽奖活动id
     $award['score_limit'] = $data['score_limit'];
     //积分限制
     $award['need_score'] = $data['need_score'];
     //需要积分
     $award['id'] = $prize_id;
     //奖品id
     $award['win_info'] = $data['win_info'] ? $data['win_info'] : array();
     $award['indexpic'] = $data['indexpic'] ? $data['indexpic'] : array();
     if ($prize_id) {
         $prize = $prize_arr[$prize_id];
         $prize_indexpic = array('host' => $prize['host'], 'dir' => $prize['dir'], 'filepath' => $prize['filepath'], 'filename' => $prize['filename']);
         $award['prize'] = $prize['prize'];
         //奖品名称
         $award['name'] = $prize['name'];
         //奖项名称
         $award['tip'] = $prize['tip'];
         //奖品名称
         $award['prize_indexpic'] = $prize_indexpic;
         //奖品索引图
     } else {
         $feedback_count = count($feedback);
         $rand_num = mt_rand(0, $feedback_count - 1);
         $award['tip'] = $feedback[$rand_num];
         //奖品名称
         $award['name'] = '谢谢参与';
         //奖项名称
     }
     //记录获奖记录
     $lottery_data = array('lottery_id' => $data['id'], 'prize_id' => $prize_id, 'create_time' => TIMENOW);
     $send_no = md5(uniqid(rand(), true));
     $lottery_data['sendno'] = $award['sendno'] = $send_no;
     //中奖随机串
     if ($data['score_limit'] && $data['need_score'] != 0) {
         $award['scores'] = $data['need_score'] < 0 ? abs($data['need_score']) : '-' . $data['need_score'];
     }
     $sql = " INSERT INTO " . DB_PREFIX . "win_info SET ";
     foreach ($lottery_data as $k => $v) {
         $sql .= " {$k} = '{$v}',";
     }
     $sql = trim($sql, ',');
     $this->db->query($sql);
     $wininfo_id = $this->db->insert_id();
     //中奖信息记录成功
     if ($wininfo_id && $this->settings['lock_stock']) {
         //更新库存
         $sql = "UPDATE " . DB_PREFIX . "prize SET prize_win = prize_win + 1 WHERE id = " . $prize_id;
         $this->db->query($sql);
         //记录锁止库存表
         $lock_data = array('send_no' => $send_no, 'prize_id' => $prize_id, 'member_id' => $user_id, 'lottery_id' => $data['id'], 'create_time' => TIMENOW);
         $sql = " INSERT INTO " . DB_PREFIX . "stock_lock SET ";
         foreach ($lock_data as $k => $v) {
             $sql .= " {$k} = '{$v}',";
         }
         $sql = trim($sql, ',');
         $this->db->query($sql);
     }
     if ($this->input['tv_interact']) {
         $this->input['sendno'] = $lottery_data['sendno'];
         $this->update_win_info();
     }
     $this->addItem($award);
     $this->output();
 }
Esempio n. 15
0
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE. 
*/
require_once 'yahoo/yahoo_geo_coding.inc';
require_once 'geo_math.inc';
$Y = new YahooGeoCoding();
$r = $Y->Request(array('zip' => '111033', 'state' => 'Russia'));
$Yandex = array($r['ResultSet']['Result']['Latitude'], $r['ResultSet']['Result']['Longitude']);
$r = $Y->Request(array('zip' => '10011', 'state' => 'NY'));
$Google = array($r['ResultSet']['Result']['Latitude'], $r['ResultSet']['Result']['Longitude']);
$Distance = GetDistance($Google, $Yandex);
echo "<p>The distance between Yandex Office in Moscow and Google office in NY is <b>{$Distance} kilometers</b></p>";
<html style="height:100%">
<head>
</head>
<title>Beta :: Results</title>

<body><br>results:<br><br>';
while ($row = mysqli_fetch_array($result)) {
    $date2 = $row['end'];
    $myend = strtotime($date2);
    if ($myend > strtotime(date("Y-m-d")) || $myend == strtotime(date("Y-m-d"))) {
        $e1 = $row['lat'];
        $n1 = $row['lon'];
        $e2 = 52.6278291;
        $n2 = -2.061504;
        $distance = 0;
        $distance = GetDistance($e1, $e2, $n1, $n2);
        $distance = round($distance * 1000 * 100 / 1609, 0);
        if ($distance <= $mydis) {
            echo '
			' . $row['title'] . ' <br>
			' . $row['jobinfo'] . ' <br>
			' . $row['end'] . ' <br>
			' . $row['postcode'] . ' <br><br><br><br>
			';
        }
    }
}
echo '
</body>
</html>
';
Esempio n. 17
0
        break;
    case '1':
        $orderStr = 'total DESC';
        break;
    case '2':
        $orderStr = 'sendprice ASC';
        break;
    case '3':
        $orderStr = 'enabled DESC';
        break;
}
if (!empty($typeid)) {
    $typeidStr = " AND typeid = '{$typeid}'";
} else {
    $typeidStr = '';
}
$shop = pdo_fetchall("SELECT * FROM " . tablename('jufeng_wcy_category') . " WHERE weid = '{$_W['uniacid']}' AND parentid = '0'" . $typeidStr . " ORDER BY " . $orderStr . " LIMIT " . ($pindex - 1) * $psize . ',' . $psize);
foreach ($shop as &$row) {
    $dist = GetDistance($fansloc["loc_x"], $fansloc["loc_y"], $row['loc_x'], $row['loc_y']);
    if ($dist >= 10) {
        $dist = round($dist / 10, 1);
        $dist .= "千米";
    } else {
        $dist = round($dist * 100, -1);
        $dist .= "米";
    }
    $row['dist'] = $dist;
}
$total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('jufeng_wcy_category') . " WHERE weid = '{$_W['uniacid']}' AND parentid = '0'" . $typeidStr . " ORDER BY displayorder DESC");
$pager = pagination($total, $pindex, $psize, $url = '', $context = array('before' => 0, 'after' => 0, 'ajaxcallback' => ''));
include $this->template('dianjia');
Esempio n. 18
0
 public function show()
 {
     $line_no = $this->input['routeid'];
     $line_direct = $this->input['stationseq'] == 2 ? 2 : 1;
     $station_no = $this->input['segmentid'];
     if (!$line_no || !$station_no) {
         $return = array('message' => '信息不全', 'result' => '');
         echo json_encode($return);
         exit;
     }
     //$line_no = str_pad($line_no,4,'0',STR_PAD_LEFT);
     $sql = "SELECT * FROM  " . DB_PREFIX . "line_station t1\n\t\t\t\t\tLEFT JOIN " . DB_PREFIX . "station t2\n\t\t\t\t\t\tON t2.station_id=t1.station_id\n\t\t\t\t\tWHERE t1.line_no='{$line_no}' AND t1.line_direct={$line_direct} AND t1.station_no = {$station_no}";
     //echo $sql;
     $r = $this->db->query_first($sql);
     ############站点名称处理############
     $r['station_name'] = str_replace('-1', '', $r['station_name']);
     $r['station_name'] = str_replace('-2', '', $r['station_name']);
     #################################
     //hg_pre($r,0);
     $curlocation = array($r['location_x'], $r['location_y'], $r['station_name']);
     $station_id = '';
     $station_id = $r['station_id'];
     if (!$station_id) {
         $return = array('message' => '站点已经不存在', 'result' => '');
         echo json_encode($return);
         exit;
     }
     $buses = array();
     $line_bus_tab = $this->settings['bus_tab'];
     if ($line_bus_tab) {
         $sql = "SELECT t1.*, t2.station_no, t3.station_name,t3.location_x st_location_x, t3.location_y st_location_y, runtime FROM " . DB_PREFIX . "bus t1 \n\t\t\t\t\tLEFT JOIN " . DB_PREFIX . "line_station t2\n\t\t\t\t\t\tON t2.station_id=t1.station_id\n\t\t\t\t\tLEFT JOIN " . DB_PREFIX . "station t3\n\t\t\t\t\t\tON t3.station_id=t1.station_id\n\t\t\t\t\tWHERE t1.line_no='{$line_no}' AND t1.line_direct={$line_direct} AND t2.station_no < {$station_no} ORDER BY t2.station_no DESC";
         //echo $sql;
         $query = $this->db->query($sql);
         $delay_time = intval($this->settings['delay_time']);
         //单位秒
         //$delay_time = 0;
         while ($r = $this->db->fetch_array($query)) {
             ############站点名称处理############
             $r['station_name'] = str_replace('-1', '', $r['station_name']);
             $r['station_name'] = str_replace('-2', '', $r['station_name']);
             #################################
             if ($r['runtime']) {
                 $r['runtime'] = date('H:i:s', strtotime($r['runtime']));
             }
             if ($curlocation[0]) {
                 $r['distance'] = GetDistance($r['location_x'], $r['location_y'], $curlocation[0], $curlocation[1]);
             } else {
                 $r['distance'] = 'unknown';
             }
             $num = $station_no - $r['station_no'];
             if ($num == 0) {
                 $r['distance'] = '-' . $r['distance'];
             }
             $near_des = '最近一班车距离本站' . $num . '站';
             if ($r['distance'] != 'unknown') {
                 if ($delay_time && $r['bus_v']) {
                     if (strpos($r['distance'], '公里')) {
                         $r['distance'] = floatval($r['distance']);
                         $r['distance'] -= $r['bus_v'] * $delay_time / 3600;
                         $r['distance'] = round($r['distance'], 2) . '公里';
                     } else {
                         if (strpos($r['distance'], '米')) {
                             $r['distance'] = floatval($r['distance']);
                             $r['distance'] -= $r['bus_v'] * $delay_time / 3600 * 1000;
                             $r['distance'] = round($r['distance']) . '米';
                         }
                     }
                 }
                 $near_des .= ' ' . $r['distance'];
             }
             $t = array('stationname' => $r['station_name'], 'actdatetime' => $r['runtime'], 'stationnum' => $num, 'busselfid' => $r['bus_no'], 'productid' => $r['bus_id'], 'lastBus' => 0, 'distance' => $r['distance'], 'curstation' => $curlocation[2], 'near_des' => $near_des);
             $buses[] = $t;
         }
     } else {
         require_once CUR_CONF_PATH . 'data/bus.php';
         $ret = array();
         //echo $line_no . '---' . $station_id . '----' . $line_direct;
         $ret = line_bus($line_no, $station_id, $line_direct);
         //hg_pre($ret,0);
         if (!empty($ret)) {
             if ($ret['leave_time']) {
                 $leave_time = $ret['leave_time'];
             } else {
                 foreach ($ret as $val) {
                     $stop = '';
                     $stop = $val['stop'] == 'no' ? '驶离' : '到达';
                     $runtime = '';
                     $runtime = $val['runtime'] ? '于' . $val['runtime'] : '';
                     $val['descr'] = '车辆' . $val['bus_no'] . '已' . $runtime . $stop . $val['station'] . ',距离本站还有' . $val['station_no'] . '站';
                     $val['brief'] = '车辆已' . $stop . '本站';
                     $t = array('stationname' => $val['station'], 'actdatetime' => $val['runtime'] ? $val['runtime'] : '', 'stationnum' => $val['station_no'], 'busselfid' => $val['bus_no'], 'productid' => $val['bus_id'], 'lastBus' => 0, 'curstation' => $curlocation[2], 'stop' => $val['stop'] == 'no' ? 1 : 0, 'brief' => $val['brief'], 'descr' => $val['descr'], 'near_des' => '最近一班车距离本站还有' . $val['station_no'] . '站');
                     $buses[] = $t;
                 }
             }
         }
     }
     if ($buses) {
         $return = array('message' => "", 'result' => $buses);
     } else {
         $sql = "SELECT start_time,stop_time,sub_start_time,sub_stop_time FROM " . DB_PREFIX . "line WHERE line_no = '{$line_no}'";
         $r = $this->db->query_first($sql);
         if ($line_direct == 1) {
             $start_time = strtotime(date('H:i', $r['start_time']));
             $end_time = strtotime(date('H:i', $r['stop_time']));
         } else {
             if ($line_direct == 2) {
                 $start_time = strtotime(date('H:i', $r['sub_start_time']));
                 $end_time = strtotime(date('H:i', $r['sub_stop_time']));
             }
         }
         $time = TIMENOW;
         if ($leave_time) {
             $message = '最近一班将于' . $leave_time . '从首站发出';
         } elseif ($time >= $start_time && $time <= $end_time) {
             $message = '无发车信息';
         } else {
             $message = '还未运行';
         }
         $return = array('message' => $message, 'result' => '');
         //print_r($return);
     }
     echo json_encode($return);
     exit;
 }