当前位置: 首页>>代码示例>>PHP>>正文


PHP Generic::checkLatitude方法代码示例

本文整理汇总了PHP中Generic::checkLatitude方法的典型用法代码示例。如果您正苦于以下问题:PHP Generic::checkLatitude方法的具体用法?PHP Generic::checkLatitude怎么用?PHP Generic::checkLatitude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Generic的用法示例。


在下文中一共展示了Generic::checkLatitude方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: recommendationRestoWS

 public function recommendationRestoWS()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $lat = isset($_GET['latitude']) ? addslashes($_GET['latitude']) : "";
     if ($lat == "" or !$lat) {
         $lat = MenuRevoConstants::$latitude;
     }
     if (!Generic::checkLatitude($lat)) {
         Generic::errorMsg("Latitude must be Numeric!");
     }
     $long = isset($_GET['longitude']) ? addslashes($_GET['longitude']) : "";
     if ($long == "" or !$long) {
         $long = MenuRevoConstants::$longitude;
     }
     if (!Generic::checklongitude($long)) {
         Generic::errorMsg("Longitude must be Numeric!");
     }
     $distance = isset($_GET['distance']) ? addslashes($_GET['distance']) : 20;
     if ($distance == '') {
         $distance = 20;
     }
     $page = addslashes($_GET['page']);
     if ($page == "" || $page < 1) {
         $json['status_code'] = 0;
         $json['status_message'] = "No Page Found";
         echo json_encode($json);
         die;
     }
     $limit = addslashes($_GET['limit']);
     if ($limit == "" || $limit < 1) {
         $json['status_code'] = 0;
         $json['status_message'] = "Limit Error";
         echo json_encode($json);
         die;
     }
     $begin = ($page - 1) * $limit;
     $json = array();
     $json['status_code'] = 1;
     global $db;
     $objRecommendation = new RecommendationModel();
     $objRestaurant = new MasterRestaurantModel();
     $qdish = "SELECT recom.*, SQRT(POW(69.1 * (resto.latitude - {$lat}), 2) + POW(69.1 * ({$long} - resto.longitude) * COS(resto.latitude / 57.3), 2)) AS distance FROM {$objRecommendation->table_name} recom LEFT JOIN {$objRestaurant->table_name} resto ON  resto.id_restaurant= recom.id_restaurant AND DATE(recom.end) >= DATE(NOW()) AND DATE(recom.start)<= DATE(NOW())HAVING distance < {$distance} ORDER BY distance LIMIT {$begin},{$limit}";
     $arrRecom = $db->query($qdish, 2);
     //        if (count($arrRecom) == 0) {
     //            $json['status_code'] = 0;
     //            $json['status_message'] = "No ID Found";
     //            echo json_encode($json);
     //            die();
     //        }
     $json['results']['restaurant'] = array();
     foreach ($arrRecom as $recom) {
         $resto = Generic::getRestaurant($recom->id_restaurant);
         $resto['distance'] = $recom->distance;
         $json['results']['restaurant'][] = $resto;
     }
     echo json_encode($json);
     die;
 }
开发者ID:CapsuleCorpIndonesia,项目名称:martabak_revolution,代码行数:60,代码来源:Recommendation.php

示例2: searchDish

 public function searchDish()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $resto = "resto";
     $json = array();
     $json['status_code'] = 1;
     $search = isset($_GET['name']) ? addslashes($_GET['name']) : "";
     $lat = isset($_GET['latitude']) ? addslashes($_GET['latitude']) : "";
     if ($lat == "" or !$lat) {
         $lat = MenuRevoConstants::$latitude;
     }
     if (!Generic::checkLatitude($lat)) {
         Generic::errorMsg("Latitude must be Numeric!");
     }
     $long = isset($_GET['longitude']) ? addslashes($_GET['longitude']) : "";
     if ($long == "" or !$long) {
         $long = MenuRevoConstants::$longitude;
     }
     if (!Generic::checklongitude($long)) {
         Generic::errorMsg("Longitude must be Numeric!");
     }
     $nearby = isset($_GET['nearby']) ? addslashes($_GET['nearby']) : 20;
     if ($nearby == '1') {
         $nearby = 20;
     } else {
         $nearby = 100000;
     }
     $arrSort['distance'] = 1;
     $nearby = " HAVING distance < " . $nearby;
     $favorite = isset($_GET['fav']) ? addslashes($_GET['fav']) : "0";
     if ($favorite == '1') {
         $arrSort['fav'] = $favorite;
     }
     $houropen = isset($_GET['houropen']) ? addslashes($_GET['houropen']) : "0";
     if ($houropen == '1') {
         $whereOption = "  CONVERT_TZ(NOW(),@@session.time_zone, '+00:00') >= (CONVERT_TZ(concat(CURRENT_DATE,' ',resto.time_open),@@session.time_zone, '+00:00' )) AND CONVERT_TZ(NOW(),@@session.time_zone, '+00:00') < (CONVERT_TZ(concat(CURRENT_DATE,' ',resto.time_close),@@session.time_zone, '+00:00' ))";
     }
     $cuisine = isset($_GET['id_cuisine']) ? addslashes($_GET['id_cuisine']) : "None";
     if (Cuisine::checkCuisineID($cuisine) != 0) {
         $arrWhere['id_cuisine'] = $cuisine;
     }
     $restotype = isset($_GET['id_restotype']) ? addslashes($_GET['id_restotype']) : "None";
     if (MasterRestaurantType::isRestoTypeByIDAvailable($restotype) != 0) {
         $arrWhere['restaurant_type'] = $restotype;
     }
     $disc_mr = isset($_GET['disc_mr']) ? addslashes($_GET['disc_mr']) : "None";
     if ($disc_mr == 1) {
         $arrWhereOr['disc_mr'] = $disc_mr;
     }
     $disc_cc = isset($_GET['disc_cc']) ? addslashes($_GET['disc_cc']) : "None";
     if ($disc_cc == 1) {
         $arrWhereOr['disc_cc'] = $disc_cc;
     }
     $disc_resto = isset($_GET['disc_resto']) ? addslashes($_GET['disc_resto']) : "None";
     if ($disc_resto == 1) {
         $arrWhereOr['disc_resto'] = $disc_resto;
     }
     $where = " WHERE dish.name LIKE '%{$search}%' ";
     if ($whereOption != "") {
         $where = $where . " AND " . $whereOption;
     }
     foreach ($arrWhere as $key => $val) {
         $where = $where . " AND {$resto}" . ".{$key}= '{$val}'";
     }
     foreach ($arrWhereOr as $key => $val) {
         $where = $where . " AND {$resto}" . ".{$key} != '0'";
     }
     $sort = $nearby . " ORDER BY ";
     foreach ($arrSort as $key => $val) {
         if ($key == "distance") {
             $sort = $sort . " {$key} ASC,";
         } elseif ($key == "fav") {
             $sort = $sort . " {$resto}" . ".{$key} DESC,";
         } elseif ($key == "houropen") {
             $sort = $sort . " {$resto}" . ".{$key} ASC,";
         }
     }
     $sort = substr($sort, 0, -1);
     $page = addslashes($_GET['page']);
     if ($page == "" || $page < 1) {
         $json['status_code'] = 0;
         $json['status_message'] = "No Page Found";
         echo json_encode($json);
         die;
     }
     $limit = addslashes($_GET['limit']);
     if ($limit == "" || $limit < 1) {
         $json['status_code'] = 0;
         $json['status_message'] = "Limit Error";
         echo json_encode($json);
         die;
     }
     $begin = ($page - 1) * $limit;
     global $db;
     $objRestaurant = new MasterRestaurantModel();
     $objDish = new MasterDishModel();
     $qdish = "SELECT dish.*, resto.name as nama_restaurant, SQRT(POW(69.1 * (resto.latitude - {$lat}), 2) + POW(69.1 * ({$long} - resto.longitude) * COS(resto.latitude / 57.3), 2)) AS distance" . " FROM  {$objDish->table_name} dish LEFT JOIN {$objRestaurant->table_name} resto ON dish.id_restaurant=resto.id_restaurant " . $where . $sort . " LIMIT {$begin},{$limit}";
     //        echo $qdish. "<br>";
//.........这里部分代码省略.........
开发者ID:CapsuleCorpIndonesia,项目名称:martabak_revolution,代码行数:101,代码来源:MasterDish.php

示例3: searchResto

 public function searchResto()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $json = array();
     $json['status_code'] = 1;
     $search = isset($_GET['name']) ? addslashes($_GET['name']) : "";
     $lat = isset($_GET['latitude']) ? addslashes($_GET['latitude']) : "";
     if ($lat != "") {
         if (!Generic::checkLatitude($lat)) {
             Generic::errorMsg("Latitude must be Numeric!");
         }
     } else {
         Generic::errorMsg("Latitude is empty");
     }
     $long = isset($_GET['longitude']) ? addslashes($_GET['longitude']) : "";
     if ($long != "") {
         if (!Generic::checklongitude($long)) {
             Generic::errorMsg("Longitude must be Numeric!");
         }
     } else {
         Generic::errorMsg("Longitude is empty");
     }
     //
     $nearby = isset($_GET['nearby']) ? addslashes($_GET['nearby']) : 20;
     if ($nearby == '1') {
         $nearby = 20;
     } else {
         $nearby = 100000;
     }
     //        echo "near: " . $nearby;
     $arrSort['distance'] = 1;
     $nearby = " HAVING distance < " . $nearby;
     $favorite = isset($_GET['fav']) ? addslashes($_GET['fav']) : "0";
     if ($favorite == '1') {
         $arrSort['fav'] = $favorite;
     }
     $houropen = isset($_GET['houropen']) ? addslashes($_GET['houropen']) : "0";
     if ($houropen == '1') {
         $whereOption = " AND CONVERT_TZ(NOW(),@@session.time_zone, '+00:00') >= (CONVERT_TZ(concat(CURRENT_DATE,' ',time_open),@@session.time_zone, '+00:00' )) AND CONVERT_TZ(NOW(),@@session.time_zone, '+00:00') < (CONVERT_TZ(concat(CURRENT_DATE,' ',time_close),@@session.time_zone, '+00:00' ))";
         //            CONVERT_TZ(NOW(),@@session.time_zone, '+00:00') >= (CONVERT_TZ(concat(CURRENT_DATE,' ',time_open),@@session.time_zone, '+00:00' )) AND CONVERT_TZ(NOW(),@@session.time_zone, '+00:00') < (CONVERT_TZ(concat(CURRENT_DATE,' ',time_close),@@session.time_zone, '+00:00' ))
         //            $whereOption = " AND (CURTIME() BETWEEN time_open AND time_close) ";
     }
     $cuisine = isset($_GET['id_cuisine']) ? addslashes($_GET['id_cuisine']) : "None";
     if (Cuisine::checkCuisineID($cuisine) != 0) {
         $arrWhere['id_cuisine'] = $cuisine;
     }
     $restotype = isset($_GET['id_restotype']) ? addslashes($_GET['id_restotype']) : "None";
     if (MasterRestaurantType::isRestoTypeByIDAvailable($restotype) != 0) {
         $arrWhere['restaurant_type'] = $restotype;
     }
     $disc_mr = isset($_GET['disc_mr']) ? addslashes($_GET['disc_mr']) : "None";
     if ($disc_mr == 1) {
         $arrWhereOr['disc_mr'] = $disc_mr;
     }
     $disc_cc = isset($_GET['disc_cc']) ? addslashes($_GET['disc_cc']) : "None";
     if ($disc_cc == 1) {
         $arrWhereOr['disc_cc'] = $disc_cc;
     }
     $disc_resto = isset($_GET['disc_resto']) ? addslashes($_GET['disc_resto']) : "None";
     if ($disc_resto == 1) {
         $arrWhereOr['disc_resto'] = $disc_resto;
     }
     $where = " WHERE name LIKE '%{$search}%' AND aktiv='1' AND show_in_apps='1'";
     if ($whereOption != "") {
         $where = $where . $whereOption;
     }
     foreach ($arrWhere as $key => $val) {
         $where = $where . " AND {$key}= '{$val}'";
     }
     foreach ($arrWhereOr as $key => $val) {
         $where = $where . " AND {$key} != '0'";
     }
     //        pr($where);
     //        die();
     $sort = " ORDER BY ";
     foreach ($arrSort as $key => $val) {
         if ($key == "distance") {
             $sort = $sort . " {$key} ASC,";
         } elseif ($key == "fav") {
             $sort = $sort . " {$key} DESC,";
         } elseif ($key == "houropen") {
             $sort = $sort . " {$key} ASC,";
         }
     }
     $sort = substr($sort, 0, -1);
     $page = addslashes($_GET['page']);
     if ($page == "" || $page < 1) {
         $json['status_code'] = 0;
         $json['status_message'] = "No Page Found";
         echo json_encode($json);
         die;
     }
     $limit = addslashes($_GET['limit']);
     if ($limit == "" || $limit < 1) {
         $json['status_code'] = 0;
         $json['status_message'] = "Limit Error";
         echo json_encode($json);
         die;
//.........这里部分代码省略.........
开发者ID:CapsuleCorpIndonesia,项目名称:martabak_revolution,代码行数:101,代码来源:MasterRestaurant.php


注:本文中的Generic::checkLatitude方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。