HEX
Server: Apache
System: Linux www3.pit.tblive.com 5.14.0-687.38.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Aug 12 17:19:12 EDT 2026 x86_64
User: awaldron (1020)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/home/awaldron/public_html/archive/ressyn/include/functions/f_geo.php
<?php

function yahoo_geocoding($zip,$city=0,$state=0,$street=0) {
	//if (!empty($zip))    $qstr = '&zip='.str_replace(" ","+",$zip);
	//if (!empty($city))   $qstr .= '&city='.str_replace(" ","+",$city);
	//if (!empty($state))  $qstr .= '&state='.str_replace(" ","+",$state);
	//if (!empty($street)) $qstr .= '&street='.str_replace(" ","+",$city);
	//
	//if (!empty($qstr)) {
	//	$appid = 'pUeOtzTV34GbDDUjJGHAAI_lJu2MQ5FpR5av1BubByy9UKdsBeFuzSMSePyTFw--';
	//	$url = 'http://local.yahooapis.com/MapsService/V1/geocode?appid='.$appid.$qstr;
	//
	//	// GRAB SEARCH RESULTS
	//	$ch = curl_init();
	//	curl_setopt($ch, CURLOPT_URL, $url );
	//	curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
	//	$data = curl_exec($ch);
	//	curl_close($ch);
	//
	//	$poslatstart  = strpos($data,"<Latitude>") + 10;
	//	$poslatlength = strpos($data,"</Latitude>") - $poslatstart;
	//	$poslongstart  = strpos($data,"<Longitude>") + 11;
	//	$poslonglength = strpos($data,"</Longitude>") - $poslongstart;
	//	
	//	$coordinates[lat] = substr($data,$poslatstart,$poslatlength);
	//	$coordinates[lon] = substr($data,$poslongstart,$poslonglength);
	//
	//	return $coordinates;
	//} else {
		$coordinates[lat] = 0;
		$coordinates[lon] = 0;
		return FALSE;
	//}
}

// Returns a list of zip codes within a given distance of a specified zip code
// Will have to modify this to only work for Lats & Longs, taking out zips.
// Returns an IN() clause for SQL
function zip_radius($zip,$rad) {
	$sql = "SELECT latitude, longitude FROM lu_zips WHERE zip=".ziptoint($zip);
	$result = mysql_query($sql);
	$home = mysql_fetch_array($result);
	$range = get_range($home["latitude"],$home["longitude"],$rad);
	
	$sql = "SELECT zip, latitude, longitude FROM lu_zips WHERE latitude >= ".$range["latmin"]." AND latitude <= ".$range["latmax"]." AND longitude >= ".$range["lonmin"]." AND longitude <= ".$range["lonmax"]." ORDER BY zip ASC";
	$result = mysql_query($sql);

	$in = ""; $ctr = 0;
	for ($i=0; $i < mysql_num_rows($result); $i++) {
		$dest = mysql_fetch_array($result);	
		//echo "<P>".$dest["zip_code"]." = ".get_distance($home["zip_lat"],$home["zip_lon"],$dest["zip_lat"],$dest["zip_lon"])." miles\n";
		if (get_distance($home["latitude"],$home["longitude"],$dest["latitude"],$dest["longitude"]) <= $rad) {
			if ($ctr != 0) $in .= ", ";
			$in .= "'".zipout($dest["zip"])."'";
			$ctr++;
		}
	}
	
	return $in;
}

function get_range($lat,$lon,$rad) {
	// Latitude and Longitude are in Degrees
	// Radius is in miles
	
	$len = $rad / (((cos($lat * pi() / 180) * 6076 ) / 5280 ) * 60);
	$range["latmax"] = round(($lat+$len),5);
	$range["latmin"] = round(($lat-$len),5);
	$range["lonmax"] = round(($lon+$len),5);
	$range["lonmin"] = round(($lon-$len),5);
	
	return $range;
}

function get_distance($lat1,$lon1,$lat2,$lon2) {
	// Latitude and Longitude are in Degrees	
	$x = (sin(get_radian($lat1)) * sin(get_radian($lat2)) + cos(get_radian($lat1)) * cos(get_radian($lat2)) * cos(abs((get_radian($lon2))-(get_radian($lon1)))));
	$x = atan((sqrt(1-pow($x,2)))/$x);
	return round(((1.852*60*(($x/pi())*180))/1.609344),1);
}

function get_radian($deg) {
	return round(($deg*pi()/180),7);
}

?>