//ViewPeople.php
<?php
$getP = new user();
$recPPL = $getP->getRecommendationsPpl($_SESSION['id']);
foreach($recPPL as $peopleD){
$peopleid = $peopleD['u_id'];
$user = new user();
$getuserInfo = $user->getUserInfo($peopleid);
// userClasses.php
public function getRecommendationsPpl($userID){
$conn = new db();
$conn = $conn->dataConn();
$people = array();
$getCurrUserGeo = "SELECT * from user_geo WHERE u_id = $userID";
$checkFetch = $conn->query($getCurrUserGeo);
$fatch = $checkFetch->fetch();
$currUlong = $fatch['u_long'];
$currUlati = $fatch['u_lati'];
$getOtherUserGeo = "SELECT * from user_geo WHERE not u_id = $userID ORDER BY u_time DESC";
$checkFetch = $conn->query($getOtherUserGeo);
while ($row = $checkFetch->fetch()){
if($this->CalDistance($currUlati, $currUlong, $row['u_lati'], $row['u_long'], "K") < 1)
{
array_push($people, $row);
}
}
return $people;
}
public function CalDistance($lat1, $lon1, $lat2, $lon2, $unit)
{
if (($lat1 == $lat2) && ($lon1 == $lon2)) {
return 0;
}
else {
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$unit = strtoupper($unit);
if ($unit == "K") {
return ($miles * 1.609344);
} else if ($unit == "N") {
return ($miles * 0.8684);
} else {
return $miles;
}
}
}
