/home/desid573/phewl.desidrivers.com.au
Edit: /home/desid573/phewl.desidrivers.com.au/11.php (3783B)
query($sql);
if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc()) {
if(doesRouteIntercept($poly, $row["lat"], $row["lng"], 250)) {
$price = $row['price'] * 1;
array_push($array, ["name"=>$row['name'], "price"=>$price, "lat"=>$row["lat"], "lng"=>$row["lng"], "brand"=>$row["brand"], "name"=>$row["name"]]);
} else {
//echo $row["name"]." not found
";
}
}
}
$test = multi_sort($array, 'price');
echo json_encode($test, true);
}
}
function multi_sort($array, $key)
{
function compare($a, $b)
{
//global $key;
return strcmp($a[$key], $b[$key]);
}
usort($array, "compare");
return $array;
}
function GetDirections($marker1, $marker2)
{
global $alt;
$url = "https://maps.googleapis.com/maps/api/directions/json?origin=".urlencode($marker1)."&destination=".urlencode($marker2)."&alternatives=".$alt."&key=AIzaSyCq_JZBDbrE5qma5SgF06M2dVAqbiZBZ-o";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);
$response_a = json_decode($response, true);
return $response;
}
function doesRouteIntercept($line, $lat, $lng, $dist) {
$decodedPoints = PolylineEncoder::decodeValue($line);
$response = \GeometryLibrary\PolyUtil::isLocationOnEdge(['lat' => $lat, 'lng' => $lng], $decodedPoints, $dist, true);
if($response) {
//error_log("found ".$lat." ".$lng);
return true; // false
}
return false;
}
//error_log(json_encode($responseArray, true));
// header("Content-type: application/json");
//echo json_encode($responseArray, true);