public function loadHomeFav()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $page = addslashes($_GET['page']);
     if ($page == "" || $page < 1) {
         Generic::errorMsg("No Page Found");
     }
     $limit = addslashes($_GET['limit']);
     if ($limit == "" || $limit < 1) {
         Generic::errorMsg("Limit Error");
     }
     $currentLat = isset($_GET['latitude']) ? addslashes($_GET['latitude']) : "";
     if (!$currentLat) {
         Generic::errorMsg("No Lat");
     }
     $currentLong = isset($_GET['longitude']) ? addslashes($_GET['longitude']) : "";
     if (!$currentLong) {
         Generic::errorMsg("No Long");
     }
     $begin = ($page - 1) * $limit;
     $json = array();
     $sem = array();
     global $db;
     $objRestaurant = new MasterRestaurantModel();
     $exp = explode(",", str_replace(" ", "", $objRestaurant->crud_webservice_allowed));
     $arrPicsToAddPhotoUrl = $objRestaurant->crud_add_photourl;
     $arr = $objRestaurant->getOrderBy("fav DESC  LIMIT {$begin},{$limit}", "*");
     $q = "SELECT *, SQRT(POW(69.1 * (latitude - {$currentLat}), 2) + POW(69.1 * ({$currentLong} - longitude) * COS(latitude / 57.3), 2)) AS distance FROM {$objRestaurant->table_name} HAVING distance < 1000000 ORDER by fav DESC, DISTANCE ASC  LIMIT {$begin},{$limit}";
     $arr = $db->query($q, 2);
     $json["results"]['restaurant'] = array();
     foreach ($arr as $o) {
         foreach ($exp as $attr) {
             if (in_array($attr, $arrPicsToAddPhotoUrl)) {
                 $sem[$attr] = Generic::insertImageUrl($o->{$attr});
             } elseif ($attr == "time_open" || $attr == "time_close") {
                 $sem[$attr] = date('H:i', strtotime(stripslashes($o->{$attr})));
             } else {
                 $sem[$attr] = stripslashes($o->{$attr});
             }
             $sem['disc_mr'] = MasterOrder::getDiscountMR($o->id_restaurant);
         }
         $sem["distance"] = sqrt(pow(69.09999999999999 * ($o->latitude - $currentLat), 2) + pow(69.09999999999999 * ($currentLong - $o->longitude) * cos($o->latitude / 57.3), 2));
         $json["results"]['restaurant'][] = $sem;
     }
     echo json_encode($json);
     die;
 }