Esempio n. 1
0
 public function rsearch()
 {
     $latmsg = "";
     $longmsg = "";
     $keymsg = "";
     $radmsg = "";
     $capmsgx = "";
     $e = 0;
     $f = 0;
     if (!isset($_POST['latitude']) || empty($_POST['latitude'])) {
         $latmsg = "Please click anywhere on the map to get search coordinates.";
         $e++;
     }
     if (!isset($_POST['longitude']) || empty($_POST['longitude'])) {
         $longmsg = "Please click anywhere on the map to get search coordinates.";
         $e++;
     }
     if (!isset($_POST['keyword']) || empty($_POST['keyword'])) {
         $keymsg = "Please enter a keyword.";
         $e++;
     }
     if (!isset($_POST['radius']) || empty($_POST['radius'])) {
         $radmsg = "Please enter radius.";
         $e++;
     }
     if (!isset($_POST['recaptcha_challenge_field']) || empty($_POST['recaptcha_challenge_field']) || (!isset($_POST['recaptcha_response_field']) || empty($_POST['recaptcha_response_field']))) {
         $capmsgx = "Please enter captcha.";
         $e++;
     }
     //All input fields are NOT populated
     if ($e !== 0) {
         $ret[0]['field'] = "latmsg";
         $ret[0]['value'] = $latmsg;
         $ret[1]['field'] = "longmsg";
         $ret[1]['value'] = $longmsg;
         $ret[2]['field'] = "capmsgx";
         $ret[2]['value'] = $capmsgx;
         $ret[3]['field'] = "keymsg";
         $ret[3]['value'] = $keymsg;
         $ret[4]['field'] = "radmsg";
         $ret[4]['value'] = $radmsg;
         $ret[5]['field'] = "pres";
         $ret[5]['value'] = "";
     } else {
         $ip = $this->input->ip_address();
         $ip = (string) $ip;
         $rcf = $_POST['recaptcha_challenge_field'];
         $rrf = $_POST['recaptcha_response_field'];
         $capresp = $this->checkcaptcha($ip, $rcf, $rrf);
         //Wrong Captcha
         if (!$capresp) {
             $capmsgx = "Wrong Captcha. Please try again";
             $ret[0]['field'] = "latmsg";
             $ret[0]['value'] = $latmsg;
             $ret[1]['field'] = "longmsg";
             $ret[1]['value'] = $longmsg;
             $ret[2]['field'] = "capmsgx";
             $ret[2]['value'] = $capmsgx;
             $ret[3]['field'] = "keymsg";
             $ret[3]['value'] = $keymsg;
             $ret[4]['field'] = "radmsg";
             $ret[4]['value'] = $radmsg;
             $ret[5]['field'] = "pres";
             $ret[5]['value'] = "";
         } else {
             $lat = $_POST['latitude'];
             $long = $_POST['longitude'];
             $keyword = $_POST['keyword'];
             $radius = $_POST['radius'];
             $lat = floatval($lat);
             $long = floatval($long);
             $google_places = new joshtronic\GooglePlaces('AIzaSyAd7wY5X1Vfc2KGa2xo1gzFbHe2Qve0FA4');
             $google_places->location = array($lat, $long);
             $google_places->radius = (int) $radius;
             $google_places->types = (string) $keyword;
             $results = $google_places->radarSearch();
             $marr = array();
             $i = 0;
             //$str = "";
             $resarr = array();
             if (array_key_exists('html_attributions', $results)) {
                 $resarr['html_attributions'] = $results['html_attributions'];
             } else {
                 $resarr['html_attributions'] = "";
             }
             if (array_key_exists('next_page_token', $results)) {
                 $resarr['next_page_token'] = $results['next_page_token'];
             } else {
                 $resarr['next_page_token'] = "";
             }
             $j = 0;
             if (array_key_exists('results', $results)) {
                 if (!empty($results['results'])) {
                     foreach ($results['results'] as $value) {
                         $resarr['results'][$i]['lat'] = $value['geometry']['location']['lat'];
                         $resarr['results'][$i]['lng'] = $value['geometry']['location']['lng'];
                         if (array_key_exists('place_id', $value)) {
                             $resarr['results'][$i]['place_id'] = $value['place_id'];
                         } else {
                             $resarr['results'][$i]['place_id'] = '';
                         }
                         $i++;
                     }
                 } else {
                     $resarr['results'] = null;
                 }
             } else {
                 $resarr['results'] = null;
             }
             $str = "";
             if (!empty($resarr['results'])) {
                 $str .= "<table class=\"table table-hover\">";
                 $str .= "<thead>";
                 $str .= "<tr>";
                 $str .= "<th>Latitude</th>";
                 $str .= "<th>Longitude</th>";
                 $str .= "</tr>";
                 $str .= "</thead>";
                 $str .= "<tbody>";
                 foreach ($resarr['results'] as $value1) {
                     $marr[$j]["latitude"] = floatval($value1["lat"]);
                     $marr[$j]["longitude"] = floatval($value1["lng"]);
                     $str .= "<tr>";
                     $str .= "<td>" . $value1["lat"] . "</td>";
                     $str .= "<td>" . $value1["lng"] . "</td>";
                     $str .= "</tr>";
                     $j++;
                 }
                 $str .= "</tbody>";
                 $str .= "</table>";
             }
             $ret[0]['field'] = "latmsg";
             $ret[0]['value'] = $latmsg;
             $ret[1]['field'] = "longmsg";
             $ret[1]['value'] = $longmsg;
             $ret[2]['field'] = "capmsgx";
             $ret[2]['value'] = $capmsgx;
             $ret[3]['field'] = "keymsg";
             $ret[3]['value'] = $keymsg;
             $ret[3]['field'] = "radmsg";
             $ret[3]['value'] = $radmsg;
             $ret[5]['field'] = "pres";
             $ret[5]['value'] = $str;
             $ret[6]['field'] = "mdata";
             $ret[6]['value'] = $marr;
         }
     }
     header('Content-Type: application/x-json; charset=utf-8');
     echo json_encode($ret);
 }
Esempio n. 2
0
 public function index()
 {
     $data = array();
     $data['main_content'] = "testa";
     $data['title'] = "Purnima Progressive - Test";
     $data['keywords'] = "Purnima Progressive, software demo, solution demo, product demo, showcase, demonstration, sign in, login, signin, landing";
     $data['description'] = "Purnima Progressive services and solutions demo. User Landing Page.";
     $data['canonical'] = 'test/index';
     $this->load->model('menumodel');
     $active = '';
     $data['menustr'] = $this->menumodel->menuf($active);
     $google_places = new joshtronic\GooglePlaces('AIzaSyAd7wY5X1Vfc2KGa2xo1gzFbHe2Qve0FA4');
     $google_places->location = array(-33.8682, 151.194586);
     $google_places->radius = 800;
     $google_places->types = 'restaurant';
     $results = $google_places->radarSearch();
     $rem = $results;
     $resarr = array();
     $resarr['html_attributions'] = $results['html_attributions'];
     if (array_key_exists('next_page_token', $results)) {
         $resarr['next_page_token'] = $results['next_page_token'];
     } else {
         $resarr['next_page_token'] = "";
     }
     $i = 0;
     foreach ($results['results'] as $value) {
         $resarr['results'][$i]['lat'] = $value['geometry']['location']['lat'];
         $resarr['results'][$i]['lng'] = $value['geometry']['location']['lng'];
         if (array_key_exists('icon', $value)) {
             $resarr['results'][$i]['icon'] = $value['icon'];
         } else {
             $resarr['results'][$i]['icon'] = '';
         }
         if (array_key_exists('id', $value)) {
             $resarr['results'][$i]['id'] = $value['id'];
         } else {
             $resarr['results'][$i]['id'] = '';
         }
         if (array_key_exists('name', $value)) {
             $resarr['results'][$i]['name'] = $value['name'];
         } else {
             $resarr['results'][$i]['name'] = '';
         }
         if (array_key_exists('place_id', $value)) {
             $resarr['results'][$i]['place_id'] = $value['place_id'];
         } else {
             $resarr['results'][$i]['place_id'] = '';
         }
         if (array_key_exists('rating', $value)) {
             $resarr['results'][$i]['rating'] = $value['rating'];
         } else {
             $resarr['results'][$i]['rating'] = '';
         }
         if (array_key_exists('reference', $value)) {
             $resarr['results'][$i]['reference'] = $value['reference'];
         } else {
             $resarr['results'][$i]['reference'] = '';
         }
         if (array_key_exists('scope', $value)) {
             $resarr['results'][$i]['scope'] = $value['scope'];
         } else {
             $resarr['results'][$i]['scope'] = '';
         }
         if (array_key_exists('types', $value)) {
             $resarr['results'][$i]['types'] = $value['types'];
         } else {
             $resarr['results'][$i]['types'] = '';
         }
         if (array_key_exists('vicinity', $value)) {
             $resarr['results'][$i]['vicinity'] = $value['vicinity'];
         } else {
             $resarr['results'][$i]['vicinity'] = '';
         }
         if (array_key_exists('photos', $value)) {
             $resarr['results'][$i]['photos'] = $value['photos'];
         } else {
             $resarr['results'][$i]['photos'] = '';
         }
         $i++;
     }
     //$data['results'] = $resarr;
     $data['results'] = $rem;
     $this->load->view('template', $data);
 }