";
}
}
// BEGIN GEO IP FUNCTIONS
/* file_get_contents do the "GET" */
// file from freegeoip.com
$theUserIpAddress = $_SERVER['REMOTE_ADDR'];
// testing :::::::::::::
// $theUserIpAddress = '173.245.64.80'; // san jose ip address for testing
// $jsonReceived = @file_get_contents('http://freegeoip.net/json/'.$theUserIpAddress);
// check to see if the files exists from the server ::::::::::::
if($jsonReceived) {
//
// and if result if it doesnt exist in the db
// detected loction img icon in popup
// maybe add logic to display if user location matches state page selected
// diff icon for your location and icon for area
/* Array from json */
$results = json_decode_nice($jsonReceived);
$thePartsArray = array($results);
// define the variables and names to defined varname for usage
foreach($thePartsArray[0] as $key=>$value) { $$key = $value; }
$userState = $region_code;
$userCity = $city;
// $city = 'test';
// print_r($thePartsArray);
} else {
// hide map if file not there
$displayMap = 'NO';
}
/* function to decode json with whitespaces or not used for map json above */
function json_decode_nice($json, $assoc = FALSE){
$json = @str_replace(array("\n","\r"),"",$json);
$json = @preg_replace('/([{,])(\s*)([^"]+?)\s*:/','$1"$3":',$json);
return @json_decode($json,$assoc);
}
// END GEO IP FUNCTIONS
function displayLatLongListings22() {
Global $table, $state, $city, $bizName, $myLongitude, $myLatitude, $bizID, $bizCity2, $bizAddr, $locationsMapsPageName, $userState, $userCity, $bizPhone;
if($userState == 'CA') {
$query = "SELECT * FROM $table where bizState LIKE '%$userState%' AND bizCity LIKE '%$userCity%' ORDER BY myLatitude ASC ";
} else {
$query = "SELECT * FROM $table where bizState LIKE '%$userState%' ORDER BY myLatitude ASC ";
}
// $query = "SELECT * FROM $table where bizState LIKE '%$userState%' ORDER BY myLatitude ASC ";
// echo $query;
$result = @mysql_query($query);
while ($row = @mysql_fetch_array($result, MYSQL_ASSOC)) {
$bizPhone = $row['bizPhone'];
// $bizState = $row['bizState'];
$bizCity2 = ucwords(strtolower($row['bizCity']));
$bizAddr = ucwords(strtolower($row['bizAddr']));
$bizName = $row['bizName'];
$bizName = str_replace("'", "", $row['bizName']);
$myLongitude = $row['myLongitude'];
$myLatitude = $row['myLatitude'];
$bizID = $row['bizID'];
echo "L.marker([";
echo $myLongitude;
echo ",";
echo $myLatitude;
echo "], {icon: foodMarker})";
echo ".addTo(map).bindPopup('";
echo $bizName . " located at: " . $bizAddr ." ". $bizCity2 . " " . $bizPhone;
echo " Get Directions '); ";
}
// echo "the city is " . $city;
}
function turnOnorOffMap() {
Global $table, $state, $city, $bizName, $myLongitude, $myLatitude, $bizID, $bizAddr, $bizCity, $locationsMapsPageName, $userState, $userCity, $displayMap, $con;
// $query = "SELECT bizID FROM $table where bizState LIKE '%$userState%' ORDER BY myLatitude ASC ";
$query = "SELECT bizID FROM $table where bizState LIKE '%$userState%' ORDER BY myLatitude ASC ";
// echo $query;
$result = @mysqli_query($con, $query);
while ($row = @mysqli_fetch_array($result, MYSQL_ASSOC)) {
$bizID = $row['bizID'];
}
if(!$bizID) { $displayMap = 'NO'; }
}
?>
';
// enter div style elements
// echo '
';
/* echo "
$adName Get $$dealAmount
$adDescription
";
*/
// echo "
";
}
// select query to display end
// start: function to write the view count to the db
@$sqlViewCount = 'SELECT viewCount FROM ' . $databaseNiche2 . ' WHERE autoID = ' . $theID . ' ';
@$sqlViewCountresult = mysqli_query($con2, $sqlViewCount);
if (@$ViewCountRow = mysqli_fetch_array($sqlViewCountresult)) {
$viewCount = $ViewCountRow['viewCount'];
$updatedViewCount = $viewCount + 1;
}
$sqlViewCountUpdate = 'UPDATE ' . $databaseNiche2 . ' SET viewCount = ' . $updatedViewCount .' WHERE autoID = ' . $theID . ' ';
// echo " the sql query is " . $sqlViewCountUpdate . " !!";
@$sqlViewCountUpdateresult = mysqli_query($con2, $sqlViewCountUpdate);
// echo "the view count update result is " . $sqlViewCountUpdateresult;
// if ($ViewCountUpdateRow = mysqli_fetch_array($sqlViewCountUpdateresult)) {
// echo " if view count call";
// }
// end: function to write the view count to the db
} // end displayAd function
?>
// mysql_free_result($connectdb);
mysqli_close($con2);
?>