<?php include('settings.php');?>
<?php //current eq
date_default_timezone_set($TZ);
//$json_string=file_get_contents('http://earthquake-report.com/feeds/recent-eq?json');
$json_string=file_get_contents('jsondata/eqnotification.json');
$parsed_json=json_decode($json_string,true);
$magnitude=$parsed_json{0}{'magnitude'};
$eqtitle=$parsed_json{0}['location'];
$depth=$parsed_json{0}['depth'];
$time1=$parsed_json{0}['date_time'];
$lati=$parsed_json{0}['latitude'];
$longi=$parsed_json{0}['longitude'];
$eventime=date( "d-m-Y H:i", strtotime("$time1") );
$magnitude1=$parsed_json{1}{'magnitude'};
$eqtitle1=$parsed_json{1}['location'];
$depth1=$parsed_json{1}['depth'];
$time2=$parsed_json{1}['date_time'];
$eventime1=date( "d-m-Y H:i", strtotime("$time2") );
?>
<?php                                                                       
// CALCULATE THE DISTANCE OF LATEST EARTHQUAKE //
// FROM LOCATION OF HOMEWEATHER STATION //
// Brian Underdown July 28th 2016 //
  function distance($lat, $lon, $lati, $longi) {
  $difflon = $lon - $longi;
  $dist = sin(deg2rad($lat)) * sin(deg2rad($lati)) +  cos(deg2rad($lat)) * cos(deg2rad($lati)) * cos(deg2rad($difflon));
  $dist = acos($dist);
  $dist = rad2deg($dist);
  $miles = $dist * 60 * 1.60934;
  $units="km";  
  return round ($miles,1) ; }
  $eqdist= distance($lat, $lon, $lati, $longi) ."km";
?>

<div class="updatedtime"><span>Updated</span> <?php 
 echo date('H:i:s');
?>  </div>

<br /><br />

<!-- EQ homeweather station earthquakes now with color values 27th July 2016--> 
<?php
echo " \n";
// EQ Latest earthquake 
if ($magnitude <= 0) {
    echo "<div class=\"eq03\">${magnitude}<uvi></uvi></div><div class=\"eqtext\"><i class='fa fa-map-marker1'></i>  $eqtitle <br><color>$eventime</color><br><depth>Depth:$depth km</depth><br>
	<color>$eqdist</color> from <i class='fa fa-map-marker1'></i> $stationlocation</div>";
} else if ($magnitude < 1) {
    echo "<div class=\"eq03\">${magnitude}<uvi></uvi></div><div class=\"eqtext\"><i class='fa fa-map-marker1'></i> $eqtitle <br><color>$eventime</color><br><depth>Depth:$depth km</depth><br>
	<color>$eqdist</color> from <i class='fa fa-map-marker1'></i> $stationlocation</div>";
} else if ($magnitude < 2) {
    echo "<div class=\"eq03\">${magnitude}<uvi></uvi></div><div class=\"eqtext\"><i class='fa fa-map-marker1'></i> $eqtitle <br><color>$eventime</color><br><depth>Depth:$depth km</depth><br>
	<color>$eqdist</color> from <i class='fa fa-map-marker1'></i> $stationlocation</div>";
} else if ($magnitude < 3) {
    echo "<div class=\"eq03\">${magnitude}<uvi></uvi></div><div class=\"eqtext\"><i class='fa fa-map-marker1'></i> $eqtitle <br><color>$eventime</color><br><depth>Depth:$depth km</depth><br>
	<color>$eqdist</color> from <i class='fa fa-map-marker1'></i> $stationlocation</div>";
} else if ($magnitude < 4) {
    echo "<div class=\"eq03\">${magnitude}<uvi></uvi></div><div class=\"eqtext\"><i class='fa fa-map-marker1'></i> $eqtitle <br><color>$eventime</color><br><depth>Depth:$depth km</depth><br>
	<color>$eqdist</color> from <i class='fa fa-map-marker1'></i> $stationlocation</div>";
} else if ($magnitude < 4.5) {
    echo "<div class=\"eq03\">${magnitude}<uvi></uvi></div><div class=\"eqtext\"><i class='fa fa-map-marker1'></i> $eqtitle <br><color>$eventime</color><br><depth>Depth:$depth km</depth><br>
	<color>$eqdist</color> from <i class='fa fa-map-marker1'></i> $stationlocation</div>";
}else if ($magnitude < 5) {
    echo "<div class=\"eq35\">${magnitude}<uvi></uvi></div><div class=\"eqtext\"><i class='fa fa-map-marker1'></i> $eqtitle <br><color>$eventime</color><br><depth>Depth:$depth km</depth><br>
	<color>$eqdist</color> from <i class='fa fa-map-marker1'></i> $stationlocation</div>";
} else if ($magnitude< 6) {
    echo "<div class=\"eq5\">${magnitude}<uvi></uvi></div><div class=\"eqtext\"><i class='fa fa-map-marker1'></i> $eqtitle <br><color>$eventime</color><br><depth>Depth:$depth km</depth><br>
	<color>$eqdist</color> from <i class='fa fa-map-marker1'></i> $stationlocation</div>";
} else if ($magnitude < 10) {
    echo "<div class=\"eq08\">${magnitude}<uvi></uvi></div><div class=\"eqtext\"><i class='fa fa-map-marker1'></i> $eqtitle <br><color>$eventime</color><br><depth>Depth:$depth km</depth><br>
	<color>$eqdist</color> from <i class='fa fa-map-marker1'></i> $stationlocation</div>";
} 

?> </span>

<?php echo "";
//eq2 previous earthquake
if ($magnitude1 <1){echo "<div class=\"eqcircle\">${magnitude1}<br><span>magnitude</span></div><div class=\"eqtext1\"><i class='fa fa-map-marker1'></i> $eqtitle1 <br><colortext>$eventime1</color><br>
<colordepth>Depth:$depth1 km</colordepth></div>";}
else if ($magnitude1 <4.5){echo "<div class=\"eqcircle1\">${magnitude1}<br><span>magnitude</span></div><div class=\"eqtext1\"><i class='fa fa-map-marker1'></i> $eqtitle1 <br><colortext>$eventime1</colortext><br>
<colordepth>Depth:$depth1 km</colordepth></div>";}
else if ($magnitude1 <6){echo "<div class=\"eqcircle2\">${magnitude1}<br><span>magnitude</span></div><div class=\"eqtext1\"><i class='fa fa-map-marker1'></i> $eqtitle1 <br><colortext>$eventime1</colortext><br>
<colordepth>Depth:$depth1 km</colordepth></div>";}
else if ($magnitude1 <10){echo "<div class=\"eqcircle3\">${magnitude1}<br><span>magnitude</span></div><div class=\"eqtext1\"><i class='fa fa-map-marker1'></i> $eqtitle1 <br><colortext>$eventime1</colortext><br>
<colordepth>Depth:$depth1 km</colordepth></div>";}

?>

