<?php
///////////////////////////////////////////////////////////////////////////////////////
// PHPizabi 0.848b C1 [ALICIA]                               http://www.phpizabi.net //
///////////////////////////////////////////////////////////////////////////////////////
// Please read the license.txt file before using / modifying this software           //
// Original author:         Claude Desjardins, R - feedback@realitymedias.com        //
// Last modification date:  August 13th 2006                                         //
// Version:                 PHPizabi 0.848b C1                                       //
//                                                                                   //
// (C) 2005, 2006 Real!ty Medias / PHPizabi - All rights reserved                    //
///////////////////////////////////////////////////////////////////////////////////////

	/* Check Structure Availability */
	if (!defined("CORE_STRAP")) die("Out of structure call");
	
	function distance ($user1, $user2) {
		global $CONF;
		
		/*
			Find out the distance in miles
		*/
		$distanceValue = rad2deg(acos(sin(deg2rad(_fnc("user", $user1,"latitude")))*sin(deg2rad(_fnc("user", $user2, "latitude")))+cos(deg2rad(_fnc("user", $user1,"latitude")))*cos(deg2rad(_fnc("user", $user2,"latitude")))*cos(deg2rad(_fnc("user", $user1,"longitude")-_fnc("user", $user2,"longitude")))))*69.09;		
		/*
			Distance value evaluated in miles
		*/
		if ($CONF["DISTANCE_VALUES_UNIT:MILES"]) $distanceRenderValue = $distanceValue;
		
		/*
			Distance value evaluated in kilometers
		*/
		else $distanceRenderValue = $distanceValue * 1.609344;

		/*
			Return data
		*/
		if ($distanceRenderValue >= 6319) return false;
		else return number_format($distanceRenderValue, 2, ".", ",");
    }

?>