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
function get_places($lat, $long, $radius, $types, $res_temp_1)
{
    $google_places = new joshtronic\GooglePlaces('AIzaSyARM9C4EtyNYH0mSk-iyUtAoEnj_8Yrixs');
    $google_places->location = array($lat, $long);
    $google_places->radius = $radius;
    $google_places->output = 'json';
    $google_places->keyword = $types;
    $results = $google_places->nearbySearch();
    $r = $results['results'];
    #var_dump($r);
    #$res_final = explode(' ' ,$res_final);
    #var_dump($res_temp_1);
    foreach ($r as $x) {
        $x = $x['types'];
        foreach ($x as $y) {
            if ($topics[$y] != '') {
                $topics[$y] = $topics[$y] + 1;
            } else {
                $topics[$y] = 1;
            }
        }
        foreach ($res_temp_1 as $a => $b) {
            #echo $a;
            if ($topics[$a] != '') {
                $topics[$a] = $topics[$a] + 1;
            } else {
                $topics[$a] = 1;
            }
        }
        #var_dump($x['types']);
    }
    #echo "something";
    arsort($topics);
    #array_push($temp, "tourist destinations", "budget travel", "adventure","leisure","trekking","sightseeing");
    #shuffle($topics);
    #
    #$temp = $topics;
    foreach ($topics as $x => $y) {
        $temp[] = $x;
    }
    $topics = $temp;
    #$topics = array_slice($temp, 0, 7);
    $pre = str_replace("%20", "&", $_GET["pre"]);
    $pre = str_replace(" ", "&", $_GET["pre"]);
    $pre_a = explode('&', $pre);
    $pre_arr = array();
    for ($i = 0; $i < count($pre_a); $i++) {
        $pre_arr[$pre_a[$i]] = True;
    }
    #var_dump($pre_arr);
    for ($i = 0; $i < count($topics); $i++) {
        #echo $topics[$i];
        if ($topics[$i] != null && !isset($pre_arr[$topics[$i]])) {
            $final_answer['categories'][] = $topics[$i];
        }
        #echo '<form action="'.$PHP_SELF.'" method = "GET"><input type="hidden" name="types" value="'.$key.'"><button type="submit">'.$key.' </button></form>';
    }
    #var_dump($final_answer);
    $i = 0;
    foreach ($r as $x) {
        #var_dump($x);
        $final_answer['title'][$i]['name'] = $x['name'];
        $final_answer['title'][$i]['icon'] = $x['icon'];
        $final_answer['title'][$i]['lat'] = $x['geometry']['location']['lat'];
        $final_answer['title'][$i]['lng'] = $x['geometry']['location']['lng'];
        $final_answer['title'][$i]['vicinity'] = $x['vicinity'];
        $i = $i + 1;
        #echo '<tr><td>'.$x['name'].'</td></tr>';
    }
    $answer = json_encode($final_answer);
    header('Content-Type: application/json');
    echo $answer;
    #var_dump( $answer);
}
Esempio n. 3
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);
 }
Esempio n. 4
0
if (array_key_exists('zip', $arguments) && (!array_key_exists('latitude', $arguments) || !array_key_exists('longitude', $arguments))) {
    $queryzipcoordinate = <<<SQL
SELECT `latitude`, `longitude` FROM `zipcoordinates`
WHERE `zip` = ?
SQL;
    $stmt = $db->prepare($queryzipcoordinate);
    $stmt->bind_param('i', $arguments['zip']);
    $stmt->execute();
    $stmt->bind_result($latitude, $longitude);
    $stmt->fetch();
    $arguments['latitude'] = $latitude;
    $arguments['longitude'] = $longitude;
    $stmt->free_result();
}
// Places Search API object
$places = new joshtronic\GooglePlaces(GOOGLE_SERVER_KEY);
$places->location = array($arguments['latitude'], $arguments['longitude']);
$places->radius = $arguments['maxdistance'];
$places->types = array('restaurant', 'food');
$places->keyword = 'food';
$places->opennow = true;
$places->minprice = $arguments['minprice'];
$places->maxprice = $arguments['maxprice'];
if (array_key_exists('pagetoken', $arguments)) {
    // Retrieves next page of results
    $places->pagetoken = $arguments['pagetoken'];
}
$search = $places->nearbySearch();
$search['browserapikey'] = GOOGLE_BROWSER_KEY;
// Return all rows in addlocations
// Could have database calculate distance and return within bounds, not enough rows yet to justify duplicate code