From 4e82a958c81e6b8e2b4bbab04cd55560cc35614e Mon Sep 17 00:00:00 2001
From: Richard Harken <theharkens@charter.net>
Date: Sat, 8 Jan 2022 21:27:06 -0500
Subject: [PATCH 1/9] fixed battery reporting issues

---
 .gitignore   | 3 ++-
 livedata.php | 6 ++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/.gitignore b/.gitignore
index b0d5735..8e40c40 100644
--- a/.gitignore
+++ b/.gitignore
@@ -73,4 +73,5 @@ highcharts
 alerts.json
 checkalert.*
 settings-pb.php
-lightningdownload.php
\ No newline at end of file
+lightningdownload.php
+.DS_Store
diff --git a/livedata.php b/livedata.php
index d0861c4..d59f3a2 100644
--- a/livedata.php
+++ b/livedata.php
@@ -782,8 +782,10 @@
 	$weather['rainStartTime']	= 'All Time';
 }
 
-$weather['consoleLowBattery']	= intval($meteobridgeapi[171]); # Console battery, 0 when battery is good, 1 when battery is low
-$weather['stationLowBattery']	= intval($meteobridgeapi[172]); # Station battery, 0 when battery is good, 1 when battery is low
+//$weather['consoleLowBattery']	= intval($meteobridgeapi[171]); # Console battery, 0 when battery is good, 1 when battery is low
+$weather['consoleLowBattery']	= 0;
+//$weather['stationLowBattery']	= intval($meteobridgeapi[172]); # Station battery, 0 when battery is good, 1 when battery is low
+$weather['stationLowBattery']	= 0;
 
 #if (is_numeric($meteobridgeapi[190]){
 #	$weather['rainStartYearSec']	= $meteobridgeapi[190];

From 6a14cf525e4aa86088beb8fdb5e354aacc997b0b Mon Sep 17 00:00:00 2001
From: Richard Harken <theharkens@charter.net>
Date: Sun, 26 Nov 2023 11:03:44 -0500
Subject: [PATCH 2/9] resolved conflicts with upstream

---
 .gitignore   | 158 +++++++++++++++++++++++++--------------------------
 livedata.php |   6 +-
 2 files changed, 83 insertions(+), 81 deletions(-)

diff --git a/.gitignore b/.gitignore
index 02a1c68..ad941bd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,79 +1,79 @@
-#timelapse files
-cam.jpg
-camplus.jpg
-cam
-timelapse/weather*
-timelapse/pics/*
-timelapse/
-timelapse
-
-#Scripts
-scripts/
-scripts
-nanocharts/
-pbnotify.php
-pbnotify_test.php
-
-#Settings
-settings1.php
-
-#personal Weather Data
-mbcharts/*.csv
-mbcharts/*/*.csv
-jsondata/*.txt
-jsondata/*.json
-jsondata/*.html
-chartswudata/*
-#demodata/*
-mbridge/MBrealtimeupload.txt
-mbridge/lastupdated.php
-
-#Ignore all backup files
-*.bak
-*.orig
-*.old
-*.bak.*
-*.orig.*
-*.old.*
-**/*.bak
-**/*.orig
-**/*.old
-**/*.bak.*
-**/*.orig.*
-**/*.old.*
-
-#Ignore Log files
-*.log
-**/*.log
-
-#Ignore Mac files
-.DS_Store
-._.DS_Store
-**/.DS_Store
-**/._.DS_Store
-.DocumentRevisions-V100
-.fseventsd
-.Spotlight-V100
-.TemporaryItems
-.Trashes
-.VolumeIcon.icns
-.com.apple.timemachine.donotpresent
-.AppleDB
-.AppleDesktop
-Network Trash Folder
-Temporary Items
-.apdisk
-
-#Editors
-.vscode/
-**/_notes
-
-#Extras
-highcharts
-*test.php
-**/*test.php
-**/test-data*
-alerts.json
-checkalert.*
-settings-pb.php
-lightningdownload.php
\ No newline at end of file
+#timelapse files
+cam.jpg
+camplus.jpg
+cam
+timelapse/weather*
+timelapse/pics/*
+timelapse/
+timelapse
+
+#Scripts
+scripts/
+scripts
+nanocharts/
+pbnotify.php
+pbnotify_test.php
+
+#Settings
+settings1.php
+
+#personal Weather Data
+mbcharts/*.csv
+mbcharts/*/*.csv
+jsondata/*.txt
+jsondata/*.json
+jsondata/*.html
+chartswudata/*
+#demodata/*
+mbridge/MBrealtimeupload.txt
+mbridge/lastupdated.php
+
+#Ignore all backup files
+*.bak
+*.orig
+*.old
+*.bak.*
+*.orig.*
+*.old.*
+**/*.bak
+**/*.orig
+**/*.old
+**/*.bak.*
+**/*.orig.*
+**/*.old.*
+
+#Ignore Log files
+*.log
+**/*.log
+
+#Ignore Mac files
+.DS_Store
+._.DS_Store
+**/.DS_Store
+**/._.DS_Store
+.DocumentRevisions-V100
+.fseventsd
+.Spotlight-V100
+.TemporaryItems
+.Trashes
+.VolumeIcon.icns
+.com.apple.timemachine.donotpresent
+.AppleDB
+.AppleDesktop
+Network Trash Folder
+Temporary Items
+.apdisk
+
+#Editors
+.vscode/
+**/_notes
+
+#Extras
+highcharts
+*test.php
+**/*test.php
+**/test-data*
+alerts.json
+checkalert.*
+settings-pb.php
+lightningdownload.php
diff --git a/livedata.php b/livedata.php
index d0861c4..d59f3a2 100644
--- a/livedata.php
+++ b/livedata.php
@@ -782,8 +782,10 @@
 	$weather['rainStartTime']	= 'All Time';
 }
 
-$weather['consoleLowBattery']	= intval($meteobridgeapi[171]); # Console battery, 0 when battery is good, 1 when battery is low
-$weather['stationLowBattery']	= intval($meteobridgeapi[172]); # Station battery, 0 when battery is good, 1 when battery is low
+//$weather['consoleLowBattery']	= intval($meteobridgeapi[171]); # Console battery, 0 when battery is good, 1 when battery is low
+$weather['consoleLowBattery']	= 0;
+//$weather['stationLowBattery']	= intval($meteobridgeapi[172]); # Station battery, 0 when battery is good, 1 when battery is low
+$weather['stationLowBattery']	= 0;
 
 #if (is_numeric($meteobridgeapi[190]){
 #	$weather['rainStartYearSec']	= $meteobridgeapi[190];

From fdaef82f246007d2766535b88352e4371fac5a63 Mon Sep 17 00:00:00 2001
From: Richard Harken <theharkens@charter.net>
Date: Tue, 28 Nov 2023 09:25:57 -0500
Subject: [PATCH 3/9] Fixed earthquake data reporting

---
 eq.php                        |  20 +-
 eqlist.php                    | 369 +++++++---------------------------
 mbdbfiles/stationcron.php     |  58 +++---
 mbdbfiles/stationcroncurl.php |   6 +-
 4 files changed, 114 insertions(+), 339 deletions(-)

diff --git a/eq.php b/eq.php
index b2fdd22..936c9c6 100644
--- a/eq.php
+++ b/eq.php
@@ -5,14 +5,14 @@
 //$json_string=file_get_contents('http://earthquake-report.com/feeds/recent-eq?json');
 $json_string=file_get_contents('jsondata/eqnotification.txt');
 $parsed_json=json_decode($json_string,true);
-$magnitude1=$parsed_json{0}{'magnitude'};
-$magnitude=number_format($magnitude1,1);
-$title=$parsed_json{0}['title'];
-$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'];
+$magnitude=number_format($parsed_json["features"][0]["properties"]["mag"],1);
+$eqtitle=$parsed_json["features"][0]["properties"]["title"];
+$title=$eqtitle;
+$depth=$parsed_json["features"][0]["geometry"]["coordinates"][2];
+$utime=round($parsed_json["features"][0]["properties"]["time"] / 1000, 0, PHP_ROUND_HALF_UP);
+$time1=gmdate("Y-m-d\TH:i:s\Z", $utime);
+$lati=$parsed_json["features"][0]["geometry"]["coordinates"][1];
+$longi=$parsed_json["features"][0]["geometry"]["coordinates"][0];
 $eventime=date( $dateFormat . " " . $timeFormatShort, strtotime("$time1") );
 $shorttime=date( $timeFormatShort, strtotime("$time1") );
 ?>
@@ -32,8 +32,8 @@
 <?php //chuck
 if($eqdista <= 200){echo "<div class=tempconvertercirclered>".$eqdista ;}
 else if($eqdista <= 500){echo "<div class=tempconvertercircleorange>".$eqdista ;}
-else if($magnitude <=1000){echo "<div class=tempconvertercircleyellow>".$eqdista;}
-else if($magnitude >= 1000){echo "<div class=tempconvertercirclegreen>".$eqdista ;}
+else if($eqdista <=1000){echo "<div class=tempconvertercircleyellow>".$eqdista;}
+else if($eqdista >= 1000){echo "<div class=tempconvertercirclegreen>".$eqdista ;}
 
 
 ?></smalltempunit2></div></div>
diff --git a/eqlist.php b/eqlist.php
index 5a3f98f..48bac64 100644
--- a/eqlist.php
+++ b/eqlist.php
@@ -15,26 +15,26 @@
 
 <?php //current eqlist
 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.txt');
 $parsed_json=json_decode($json_string,true);
 $magnitude = array();
 $eqtitle = array();
 $depth = array();
+$utime = array();
 $time = array();
 $lati = array();
 $longi = array();
 $eventime = array();
 for ($i = 0; $i < 100; $i++) {
-	$magnitude[$i]=number_format($parsed_json{$i}{'magnitude'},1);
-	$eqtitle[$i]=$parsed_json{$i}['title'];
-	$depth[$i]=$parsed_json{$i}['depth'];
-	$time[$i]=$parsed_json{$i}['date_time'];
-	$lati[$i]=$parsed_json{$i}['latitude'];
-	$longi[$i]=$parsed_json{$i}['longitude'];
-	$eventime[$i]=date($timeFormatShort, strtotime($time[$i]) );
-	$eqdist[$i] = round(distance($lat, $lon, $lati[$i], $longi[$i])) ;
-	
+	$magnitude[$i]=number_format($parsed_json["features"][$i]["properties"]["mag"],1);
+	$eqtitle[$i]=$parsed_json["features"][$i]["properties"]["title"];
+	$depth[$i]=$parsed_json["features"][$i]["geometry"]["coordinates"][2];
+    $utime[$i]=round($parsed_json["features"][$i]["properties"]["time"] / 1000, 0, PHP_ROUND_HALF_UP);
+	$time[$i]=gmdate("Y-m-d\TH:i:s\Z", $utime[$i]);
+	$lati[$i]=$parsed_json["features"][$i]["geometry"]["coordinates"][1];
+	$longi[$i]=$parsed_json["features"][$i]["geometry"]["coordinates"][0];
+	$eventime[$i]=date($timeFormatShort, $utime[$i]);
+	$eqdist[$i] = round(distance($lat, $lon, $lati[$i], $longi[$i]));
 	
 }
 $eqalert='<svg id="i-activity" viewBox="0 0 32 32" width="52" height="52" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
@@ -120,12 +120,10 @@
   <article>  
    <div class=actualt>&nbsp;&nbsp Recent Earthquake </div>        
     <?php 
-				if($magnitude[0]>=7){echo "<div class=mag9-10>",$magnitude[0],"";}
-				else if($magnitude[0]>=5.8){echo "<div class=mag9-10>",$magnitude[0],"";}
-				else if($magnitude[0]>=5){echo "<div class=mag6-8>",$magnitude[0],"";}
+				if($magnitude[0]>=9){echo "<div class=mag9-10>",$magnitude[0],"";}
+				else if($magnitude[0]>=6){echo "<div class=mag6-8>",$magnitude[0],"";}
 				else if($magnitude[0]>=4){echo "<div class=mag4-5>",$magnitude[0],"";}
-				else if($magnitude[0]>=2){echo "<div class=mag1-3>",$magnitude[0],"";}	
-				else if($magnitude[0]<2){echo "<div class=mag1-3>N/A";}		
+				else {echo "<div class=mag1-3>",$magnitude[0],"";}	
 						
 				?>
 <div></div>
@@ -135,46 +133,18 @@
 <div class="hitempy">
 <?php
 	echo "";
-for ($i = 0; $i < 1; $i++) {
+//for ($i = 0; $i < 1; $i++) {
 	// EQ Latest earthquake 
 	
 	if ($eqdist[0]<1300)  {
 	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[0]."</div></span>";
 	echo $eqtitle[0];
 	} 
-	else if ($magnitude[0]>7)  {
-	echo "<div class='time'><span>",$eventime[0] ,"</div></span>";
-	echo $eqtitle[0] ;
-	} 
-	
-	
-	else if ($magnitude[0]>5.7)  {
-	echo "<div class='time'><span>",$eventime[0] ,"</div></span>";
-	echo $eqtitle[0] ;
-	} 
-	
-	
-	else if ($magnitude[0]>5.2)  {
-	echo "<div class='time'><span>",$eventime[0] ,"</div></span>";
-	echo $eqtitle[0] ;
-	} 
-	
-	else if ($magnitude[0]>4)  {
-	echo "<div class='time'><span>",$eventime[0] ,"</div></span>";
-	echo $eqtitle[0] ;
-	} 
-	
-	
-	else if ($magnitude[0]>3)  {
+	else {
 	echo "<div class='time'><span>",$eventime[0] ,"</div></span>";
 	echo $eqtitle[0] ;
 	} 
-	
-	else if ($magnitude[0]>2)  {
-	echo "<div class='time'><span>",$eventime[0] ,"</div></span>";
-	echo $eqtitle[0] ;
-	} 
-}
+//}
 
 ?><br>
 <?php
@@ -202,12 +172,11 @@
  <article>  
    <div class=actualt>&nbsp;&nbsp Recent Earthquake </div>        
     <?php  //1
-				if($magnitude[1]>=7){echo "<div class=mag9-10>",$magnitude[1],"";}
-				else if($magnitude[1]>=5.8){echo "<div class=mag9-10>",$magnitude[1],"";}
-				else if($magnitude[1]>=5){echo "<div class=mag6-8>",$magnitude[1],"";}
+
+				if($magnitude[1]>=9){echo "<div class=mag9-10>",$magnitude[1],"";}
+				else if($magnitude[1]>=6){echo "<div class=mag6-8>",$magnitude[1],"";}
 				else if($magnitude[1]>=4){echo "<div class=mag4-5>",$magnitude[1],"";}
-				else if($magnitude[1]>=2){echo "<div class=mag1-3>",$magnitude[1],"";}	
-				else if($magnitude[1]<2){echo "<div class=mag1-3>N/A";}		
+				else {echo "<div class=mag1-3>",$magnitude[1],"";}	
 						
 				?>
 <div></div>
@@ -217,46 +186,18 @@
 <div class="hitempy">
 <?php
 	echo "";
-for ($i = 0; $i < 1; $i++) {
-	// EQ Latest earthquake 
+//for ($i = 1; $i < 2; $i++) {
+	// Temp fix
 	
 	if ($eqdist[1]<1300)  {
 	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[1]."</div></span>";
 	echo $eqtitle[1];
 	} 
-	else if ($magnitude[1]>7)  {
-	echo "<div class='time'><span>",$eventime[1] ,"</div></span>";
-	echo $eqtitle[1] ;
-	} 
-	
-	
-	else if ($magnitude[1]>5.7)  {
-	echo "<div class='time'><span>",$eventime[1] ,"</div></span>";
-	echo $eqtitle[1] ;
-	} 
-	
-	
-	else if ($magnitude[1]>5.2)  {
-	echo "<div class='time'><span>",$eventime[1] ,"</div></span>";
-	echo $eqtitle[1] ;
-	} 
-	
-	else if ($magnitude[1]>4)  {
+	else {
 	echo "<div class='time'><span>",$eventime[1] ,"</div></span>";
 	echo $eqtitle[1] ;
 	} 
-	
-	
-	else if ($magnitude[1]>3)  {
-	echo "<div class='time'><span>",$eventime[1] ,"</div></span>";
-	echo $eqtitle[0] ;
-	} 
-	
-	else if ($magnitude[1]>2)  {
-	echo "<div class='time'><span>",$eventime[1] ,"</div></span>";
-	echo $eqtitle[1] ;
-	} 
-}
+//}
 
 ?><br>
 <?php
@@ -284,12 +225,12 @@
    <article>  
    <div class=actualt>&nbsp;&nbsp Recent Earthquake </div>        
     <?php //2
-				if($magnitude[2]>=7){echo "<div class=mag9-10>",$magnitude[2],"";}
-				else if($magnitude[2]>=5.8){echo "<div class=mag9-10>",$magnitude[2],"";}
-				else if($magnitude[2]>=5){echo "<div class=mag6-8>",$magnitude[2],"";}
+
+				if($magnitude[2]>=9){echo "<div class=mag9-10>",$magnitude[2],"";}
+				else if($magnitude[2]>=6){echo "<div class=mag6-8>",$magnitude[2],"";}
 				else if($magnitude[2]>=4){echo "<div class=mag4-5>",$magnitude[2],"";}
-				else if($magnitude[2]>=2){echo "<div class=mag1-3>",$magnitude[2],"";}	
-				else if($magnitude[2]<2){echo "<div class=mag1-3>N/A";}		
+				else {echo "<div class=mag1-3>",$magnitude[2],"";}	
+
 						
 				?>
 <div></div>
@@ -299,46 +240,18 @@
 <div class="hitempy">
 <?php
 	echo "";
-for ($i = 0; $i < 1; $i++) {
+//for ($i = 2; $i < 3; $i++) {
 	// EQ Latest earthquake 
 	
 	if ($eqdist[2]<1300)  {
 	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[2]."</div></span>";
 	echo $eqtitle[2];
 	} 
-	else if ($magnitude[2]>7)  {
-	echo "<div class='time'><span>",$eventime[2] ,"</div></span>";
-	echo $eqtitle[2] ;
-	} 
-	
-	
-	else if ($magnitude[2]>5.7)  {
-	echo "<div class='time'><span>",$eventime[2] ,"</div></span>";
-	echo $eqtitle[2] ;
-	} 
-	
-	
-	else if ($magnitude[2]>5.2)  {
-	echo "<div class='time'><span>",$eventime[2] ,"</div></span>";
-	echo $eqtitle[2] ;
-	} 
-	
-	else if ($magnitude[2]>4)  {
+	else {
 	echo "<div class='time'><span>",$eventime[2] ,"</div></span>";
 	echo $eqtitle[2] ;
 	} 
-	
-	
-	else if ($magnitude[2]>3)  {
-	echo "<div class='time'><span>",$eventime[2] ,"</div></span>";
-	echo $eqtitle[0] ;
-	} 
-	
-	else if ($magnitude[2]>2)  {
-	echo "<div class='time'><span>",$eventime[2] ,"</div></span>";
-	echo $eqtitle[2] ;
-	} 
-}
+//}
 
 ?><br>
 <?php
@@ -366,12 +279,12 @@
    <article>  
    <div class=actualt>&nbsp;&nbsp Recent Earthquake </div>        
     <?php //3
-				if($magnitude[3]>=7){echo "<div class=mag9-10>",$magnitude[3],"";}
-				else if($magnitude[3]>=5.8){echo "<div class=mag9-10>",$magnitude[3],"";}
-				else if($magnitude[3]>=5){echo "<div class=mag6-8>",$magnitude[3],"";}
+
+				if($magnitude[3]>=9){echo "<div class=mag9-10>",$magnitude[3],"";}
+				else if($magnitude[3]>=6){echo "<div class=mag6-8>",$magnitude[3],"";}
 				else if($magnitude[3]>=4){echo "<div class=mag4-5>",$magnitude[3],"";}
-				else if($magnitude[3]>=2){echo "<div class=mag1-3>",$magnitude[3],"";}	
-				else if($magnitude[3]<2){echo "<div class=mag1-3>N/A";}		
+				else {echo "<div class=mag1-3>",$magnitude[3],"";}	
+
 						
 				?>
 <div></div>
@@ -381,46 +294,18 @@
 <div class="hitempy">
 <?php
 	echo "";
-for ($i = 0; $i < 1; $i++) {
+//for ($i = 3; $i < 4; $i++) {
 	// EQ Latest earthquake 
 	
 	if ($eqdist[3]<1300)  {
 	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[3]."</div></span>";
 	echo $eqtitle[3];
 	} 
-	else if ($magnitude[3]>7)  {
+	else {
 	echo "<div class='time'><span>",$eventime[3] ,"</div></span>";
 	echo $eqtitle[3] ;
 	} 
-	
-	
-	else if ($magnitude[3]>5.7)  {
-	echo "<div class='time'><span>",$eventime[3] ,"</div></span>";
-	echo $eqtitle[3] ;
-	} 
-	
-	
-	else if ($magnitude[3]>5.2)  {
-	echo "<div class='time'><span>",$eventime[3] ,"</div></span>";
-	echo $eqtitle[3] ;
-	} 
-	
-	else if ($magnitude[3]>4)  {
-	echo "<div class='time'><span>",$eventime[3] ,"</div></span>";
-	echo $eqtitle[3] ;
-	} 
-	
-	
-	else if ($magnitude[3]>3)  {
-	echo "<div class='time'><span>",$eventime[3] ,"</div></span>";
-	echo $eqtitle[3] ;
-	} 
-	
-	else if ($magnitude[3]>2)  {
-	echo "<div class='time'><span>",$eventime[3] ,"</div></span>";
-	echo $eqtitle[3] ;
-	} 
-}
+//}
 
 ?><br>
 <?php
@@ -448,12 +333,12 @@
  <article>  
    <div class=actualt>&nbsp;&nbsp Recent Earthquake </div>        
     <?php //4
-				if($magnitude[4]>=7){echo "<div class=mag9-10>",$magnitude[4],"";}
-				else if($magnitude[4]>=5.8){echo "<div class=mag9-10>",$magnitude[4],"";}
-				else if($magnitude[4]>=5){echo "<div class=mag6-8>",$magnitude[4],"";}
+
+				if($magnitude[4]>=9){echo "<div class=mag9-10>",$magnitude[4],"";}
+				else if($magnitude[4]>=6){echo "<div class=mag6-8>",$magnitude[4],"";}
 				else if($magnitude[4]>=4){echo "<div class=mag4-5>",$magnitude[4],"";}
-				else if($magnitude[4]>=2){echo "<div class=mag1-3>",$magnitude[4],"";}	
-				else if($magnitude[4]<2){echo "<div class=mag1-3>N/A";}		
+				else {echo "<div class=mag1-3>",$magnitude[4],"";}	
+
 						
 				?>
 <div></div>
@@ -463,46 +348,18 @@
 <div class="hitempy">
 <?php
 	echo "";
-for ($i = 0; $i < 1; $i++) {
+//for ($i = 4; $i < 5; $i++) {
 	// EQ Latest earthquake 
 	
 	if ($eqdist[4]<1300)  {
 	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[4]."</div></span>";
 	echo $eqtitle[4];
 	} 
-	else if ($magnitude[4]>7)  {
-	echo "<div class='time'><span>",$eventime[4] ,"</div></span>";
-	echo $eqtitle[4] ;
-	} 
-	
-	
-	else if ($magnitude[4]>5.7)  {
-	echo "<div class='time'><span>",$eventime[4] ,"</div></span>";
-	echo $eqtitle[4] ;
-	} 
-	
-	
-	else if ($magnitude[4]>5.2)  {
-	echo "<div class='time'><span>",$eventime[4] ,"</div></span>";
-	echo $eqtitle[4] ;
-	} 
-	
-	else if ($magnitude[4]>4)  {
+	else {
 	echo "<div class='time'><span>",$eventime[4] ,"</div></span>";
 	echo $eqtitle[4] ;
 	} 
-	
-	
-	else if ($magnitude[4]>3)  {
-	echo "<div class='time'><span>",$eventime[4] ,"</div></span>";
-	echo $eqtitle[4] ;
-	} 
-	
-	else if ($magnitude[4]>2)  {
-	echo "<div class='time'><span>",$eventime[4] ,"</div></span>";
-	echo $eqtitle[4] ;
-	} 
-}
+//}
 
 ?><br>
 <?php
@@ -530,12 +387,12 @@
  <article>  
    <div class=actualt>&nbsp;&nbsp Recent Earthquake </div>        
     <?php //5
-				if($magnitude[5]>=7){echo "<div class=mag9-10>",$magnitude[5],"";}
-				else if($magnitude[5]>=5.8){echo "<div class=mag9-10>",$magnitude[5],"";}
-				else if($magnitude[5]>=5){echo "<div class=mag6-8>",$magnitude[5],"";}
+
+				if($magnitude[5]>=9){echo "<div class=mag9-10>",$magnitude[5],"";}
+				else if($magnitude[5]>=6){echo "<div class=mag6-8>",$magnitude[5],"";}
 				else if($magnitude[5]>=4){echo "<div class=mag4-5>",$magnitude[5],"";}
-				else if($magnitude[5]>=2){echo "<div class=mag1-3>",$magnitude[5],"";}	
-				else if($magnitude[5]<2){echo "<div class=mag1-3>N/A";}		
+				else {echo "<div class=mag1-3>",$magnitude[5],"";}	
+
 						
 				?>
 <div></div>
@@ -545,46 +402,18 @@
 <div class="hitempy">
 <?php
 	echo "";
-for ($i = 0; $i < 1; $i++) {
+//for ($i = 5; $i < 6; $i++) {
 	// EQ Latest earthquake 
 	
 	if ($eqdist[5]<1300)  {
 	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[5]."</div></span>";
 	echo $eqtitle[5];
 	} 
-	else if ($magnitude[5]>7)  {
-	echo "<div class='time'><span>",$eventime[5] ,"</div></span>";
-	echo $eqtitle[0] ;
-	} 
-	
-	
-	else if ($magnitude[5]>5.7)  {
-	echo "<div class='time'><span>",$eventime[5] ,"</div></span>";
-	echo $eqtitle[5] ;
-	} 
-	
-	
-	else if ($magnitude[5]>5.2)  {
-	echo "<div class='time'><span>",$eventime[5] ,"</div></span>";
-	echo $eqtitle[5] ;
-	} 
-	
-	else if ($magnitude[5]>4)  {
-	echo "<div class='time'><span>",$eventime[5] ,"</div></span>";
-	echo $eqtitle[5] ;
-	} 
-	
-	
-	else if ($magnitude[5]>3)  {
-	echo "<div class='time'><span>",$eventime[5] ,"</div></span>";
-	echo $eqtitle[5] ;
-	} 
-	
-	else if ($magnitude[5]>2)  {
+	else {
 	echo "<div class='time'><span>",$eventime[5] ,"</div></span>";
 	echo $eqtitle[5] ;
 	} 
-}
+//}
 
 ?><br>
 <?php
@@ -613,12 +442,11 @@
 <article>  
    <div class=actualt>&nbsp;&nbsp Recent Earthquake </div>        
     <?php //6
-				if($magnitude[6]>=7){echo "<div class=mag9-10>",$magnitude[6],"";}
-				else if($magnitude[6]>=5.8){echo "<div class=mag9-10>",$magnitude[6],"";}
-				else if($magnitude[6]>=5){echo "<div class=mag6-8>",$magnitude[6],"";}
+
+				if($magnitude[6]>=9){echo "<div class=mag9-10>",$magnitude[6],"";}
+				else if($magnitude[6]>=6){echo "<div class=mag6-8>",$magnitude[6],"";}
 				else if($magnitude[6]>=4){echo "<div class=mag4-5>",$magnitude[6],"";}
-				else if($magnitude[6]>=2){echo "<div class=mag1-3>",$magnitude[6],"";}	
-				else if($magnitude[6]<2){echo "<div class=mag1-3>N/A";}		
+				else {echo "<div class=mag1-3>",$magnitude[6],"";}	
 						
 				?>
 <div></div>
@@ -628,46 +456,18 @@
 <div class="hitempy">
 <?php
 	echo "";
-for ($i = 0; $i < 1; $i++) {
+//for ($i = 6; $i < 7; $i++) {
 	// EQ Latest earthquake 
 	
 	if ($eqdist[6]<1300)  {
 	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[6]."</div></span>";
 	echo $eqtitle[6];
 	} 
-	else if ($magnitude[6]>7)  {
-	echo "<div class='time'><span>",$eventime[6] ,"</div></span>";
-	echo $eqtitle[6] ;
-	} 
-	
-	
-	else if ($magnitude[6]>5.7)  {
-	echo "<div class='time'><span>",$eventime[6] ,"</div></span>";
-	echo $eqtitle[6] ;
-	} 
-	
-	
-	else if ($magnitude[6]>5.2)  {
-	echo "<div class='time'><span>",$eventime[6] ,"</div></span>";
-	echo $eqtitle[6] ;
-	} 
-	
-	else if ($magnitude[6]>4)  {
+	else {
 	echo "<div class='time'><span>",$eventime[6] ,"</div></span>";
 	echo $eqtitle[6] ;
 	} 
-	
-	
-	else if ($magnitude[6]>3)  {
-	echo "<div class='time'><span>",$eventime[6] ,"</div></span>";
-	echo $eqtitle[6] ;
-	} 
-	
-	else if ($magnitude[6]>2)  {
-	echo "<div class='time'><span>",$eventime[6] ,"</div></span>";
-	echo $eqtitle[6] ;
-	} 
-}
+//}
 
 ?><br>
 <?php
@@ -695,12 +495,11 @@
 <article>  
    <div class=actualt>&nbsp;&nbsp Recent Earthquake </div>        
     <?php //7
-				if($magnitude[7]>=7){echo "<div class=mag9-10>",$magnitude[7],"";}
-				else if($magnitude[7]>=5.8){echo "<div class=mag9-10>",$magnitude[7],"";}
-				else if($magnitude[7]>=5){echo "<div class=mag6-8>",$magnitude[7],"";}
+
+				if($magnitude[7]>=9){echo "<div class=mag9-10>",$magnitude[7],"";}
+				else if($magnitude[7]>=6){echo "<div class=mag6-8>",$magnitude[7],"";}
 				else if($magnitude[7]>=4){echo "<div class=mag4-5>",$magnitude[7],"";}
-				else if($magnitude[7]>=2){echo "<div class=mag1-3>",$magnitude[7],"";}	
-				else if($magnitude[7]<2){echo "<div class=mag1-3>N/A";}		
+				else {echo "<div class=mag1-3>",$magnitude[7],"";}	
 						
 				?>
 <div></div>
@@ -710,46 +509,18 @@
 <div class="hitempy">
 <?php
 	echo "";
-for ($i = 0; $i < 1; $i++) {
+//for ($i = 7; $i < 8; $i++) {
 	// EQ Latest earthquake 
 	
 	if ($eqdist[7]<1300)  {
 	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[7]."</div></span>";
 	echo $eqtitle[7];
 	} 
-	else if ($magnitude[7]>7)  {
+	else {
 	echo "<div class='time'><span>",$eventime[7] ,"</div></span>";
 	echo $eqtitle[7] ;
 	} 
-	
-	
-	else if ($magnitude[7]>5.7)  {
-	echo "<div class='time'><span>",$eventime[7] ,"</div></span>";
-	echo $eqtitle[7] ;
-	} 
-	
-	
-	else if ($magnitude[7]>5.2)  {
-	echo "<div class='time'><span>",$eventime[7] ,"</div></span>";
-	echo $eqtitle[7] ;
-	} 
-	
-	else if ($magnitude[7]>4)  {
-	echo "<div class='time'><span>",$eventime[7] ,"</div></span>";
-	echo $eqtitle[7] ;
-	} 
-	
-	
-	else if ($magnitude[7]>3)  {
-	echo "<div class='time'><span>",$eventime[7] ,"</div></span>";
-	echo $eqtitle[7] ;
-	} 
-	
-	else if ($magnitude[7]>2)  {
-	echo "<div class='time'><span>",$eventime[7] ,"</div></span>";
-	echo $eqtitle[7] ;
-	} 
-}
+//}
 
 ?><br>
 <?php
diff --git a/mbdbfiles/stationcron.php b/mbdbfiles/stationcron.php
index faf0419..db2a97d 100644
--- a/mbdbfiles/stationcron.php
+++ b/mbdbfiles/stationcron.php
@@ -57,32 +57,32 @@
     echo ($_SERVER['HTTP_USER_AGENT']=='meteobridge'?'Please set your Metar API Key in EasyWeatherSetup.php<br>':"<span style='color:red;font-weight:bold'><pre>Please set your Metar API Key in EasyWeatherSetup.php</pre></span>");
 }
 
-#Update DarkSky
-if ($position6=="forecast3ds.php" || $position6=='forecast3wu.php' || $position6=='forecast3wularge.php' || $position4 == "advisory.php"){
-    if ($apikey != "11111111111111") {
-        // weather34 darksky  curl based
-        $url4a = 'https://api.forecast.io/forecast/'.$apikey.'/'.$lat.','.$lon.'?lang='.$language.'&units='.$darkskyunit ;
-        $ch4a = curl_init($url4a);
-        $filename4a = '../jsondata/darksky.txt';
-        $complete_save_loc4a = $filename4a;
-        $fp4a = fopen($complete_save_loc4a, 'wb');
-        curl_setopt($ch4a, CURLOPT_FILE, $fp4a);
-        curl_setopt($ch4a, CURLOPT_HEADER, 0);
-        $result = curl_exec($ch4a);
-        if ($result) {
-            echo ($_SERVER['HTTP_USER_AGENT']=='meteobridge'?'DarkSky updated<br>':"<pre>DarkSky updated</pre>");
-        } else {
-            echo ($_SERVER['HTTP_USER_AGENT']=='meteobridge'?'Problem updating DarkSky<br>':"<span style='color:red;font-weight:bold'><pre>Problem updating DarkSky</pre></span>");
-        }
-        curl_close($ch4a);
-        fclose($fp4a);
-        unset($result);
-    } else {
-        echo ($_SERVER['HTTP_USER_AGENT']=='meteobridge'?'Please set your DarkSky API Key in EasyWeatherSetup.php<br>':"<span style='color:red;font-weight:bold'><pre>Please set your DarkSky API Key in EasyWeatherSetup.php</pre></span>");
-    }
-} else {
-    echo ($_SERVER['HTTP_USER_AGENT']=='meteobridge'?'Not set to use DarkSky<br>':"<pre>Not set to use DarkSky</pre>");
-}
+#Update DarkSky ***** DarkSky is no longer Operational *****
+//if ($position6=="forecast3ds.php" || $position6=='forecast3wu.php' || $position6=='forecast3wularge.php' || $position4 == "advisory.php"){
+//    if ($apikey != "11111111111111") {
+//        // weather34 darksky  curl based
+//        $url4a = 'https://api.forecast.io/forecast/'.$apikey.'/'.$lat.','.$lon.'?lang='.$language.'&units='.$darkskyunit ;
+//        $ch4a = curl_init($url4a);
+//        $filename4a = '../jsondata/darksky.txt';
+//        $complete_save_loc4a = $filename4a;
+//        $fp4a = fopen($complete_save_loc4a, 'wb');
+//        curl_setopt($ch4a, CURLOPT_FILE, $fp4a);
+//        curl_setopt($ch4a, CURLOPT_HEADER, 0);
+//        $result = curl_exec($ch4a);
+//        if ($result) {
+//            echo ($_SERVER['HTTP_USER_AGENT']=='meteobridge'?'DarkSky updated<br>':"<pre>DarkSky updated</pre>");
+//        } else {
+//            echo ($_SERVER['HTTP_USER_AGENT']=='meteobridge'?'Problem updating DarkSky<br>':"<span style='color:red;font-weight:bold'><pre>Problem updating DarkSky</pre></span>");
+//        }
+//        curl_close($ch4a);
+//        fclose($fp4a);
+//        unset($result);
+//    } else {
+//        echo ($_SERVER['HTTP_USER_AGENT']=='meteobridge'?'Please set your DarkSky API Key in EasyWeatherSetup.php<br>':"<span style='color:red;font-weight:bold'><pre>Please set your DarkSky API Key in EasyWeatherSetup.php</pre></span>");
+//    }
+//} else {
+//    echo ($_SERVER['HTTP_USER_AGENT']=='meteobridge'?'Not set to use DarkSky<br>':"<pre>Not set to use DarkSky</pre>");
+//}
 
 #Update WU
 if ($position6=="forecast3wu.php" || $position6=="forecast3wularge.php"){
@@ -112,7 +112,8 @@
 }
 
 // weather34 earthquakes curl based
-$url1 = 'https://earthquake-report.com/feeds/recent-eq?json';
+//$url1 = 'https://earthquake-report.com/feeds/recent-eq?json';
+$url1 = 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.geojson';
 $ch1 = curl_init($url1);
 $filename1 = '../jsondata/eqnotification.txt';
 $complete_save_loc1 = $filename1;
@@ -130,7 +131,8 @@
 unset($result);
 
 //k-index curl based
-$url2a = 'https://services.swpc.noaa.gov/products/geospace/planetary-k-index-dst.json';
+//$url2a = 'https://services.swpc.noaa.gov/products/geospace/planetary-k-index-dst.json';
+$url2a = 'https://services.swpc.noaa.gov/products/noaa-planetary-k-index.json';
 $ch2a = curl_init($url2a);
 $filename2a = '../jsondata/kindex.txt';
 $complete_save_loc2a = $filename2a;
diff --git a/mbdbfiles/stationcroncurl.php b/mbdbfiles/stationcroncurl.php
index 3791ba0..31a2d33 100644
--- a/mbdbfiles/stationcroncurl.php
+++ b/mbdbfiles/stationcroncurl.php
@@ -59,7 +59,8 @@
 fclose($fp);
 ?>
 <?php // weather34 earthquakes curl based
-$url1 = 'https://earthquake-report.com/feeds/recent-eq?json'; 
+//$url1 = 'https://earthquake-report.com/feeds/recent-eq?json'; 
+$url1 = 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.geojson';
 $ch1 = curl_init($url1);
 $filename1 = '../jsondata/eqnotification.txt';
 $complete_save_loc1 = $filename1; 
@@ -71,7 +72,8 @@
 fclose($fp1);
 ?>
 <?php //k-index curl based
-$url2 = 'https://services.swpc.noaa.gov/products/geospace/planetary-k-index-dst.json'; 
+//$url2 = 'https://services.swpc.noaa.gov/products/geospace/planetary-k-index-dst.json'; 
+$url2 = 'https://services.swpc.noaa.gov/products/noaa-planetary-k-index.json';
 $ch2 = curl_init($url2);
 $filename2 = '../jsondata/kindex.txt';
 $complete_save_loc2 = $filename2; 

From d0d61abf96ecbfd5ce5afae162712b7d3321dcab Mon Sep 17 00:00:00 2001
From: Richard Harken <theharkens@charter.net>
Date: Tue, 28 Nov 2023 13:46:17 -0500
Subject: [PATCH 4/9] optimized earthquake display

---
 eqlist.php | 502 +++++++----------------------------------------------
 1 file changed, 65 insertions(+), 437 deletions(-)

diff --git a/eqlist.php b/eqlist.php
index 48bac64..72f1158 100644
--- a/eqlist.php
+++ b/eqlist.php
@@ -25,7 +25,9 @@
 $lati = array();
 $longi = array();
 $eventime = array();
-for ($i = 0; $i < 100; $i++) {
+$eqdist = array();
+$eqcount = 8;
+for ($i = 0; $i < $eqcount; $i++) {
 	$magnitude[$i]=number_format($parsed_json["features"][$i]["properties"]["mag"],1);
 	$eqtitle[$i]=$parsed_json["features"][$i]["properties"]["title"];
 	$depth[$i]=$parsed_json["features"][$i]["geometry"]["coordinates"][2];
@@ -37,14 +39,63 @@
 	$eqdist[$i] = round(distance($lat, $lon, $lati[$i], $longi[$i]));
 	
 }
-$eqalert='<svg id="i-activity" viewBox="0 0 32 32" width="52" height="52" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
-    <path d="M4 16 L11 16 14 29 18 3 21 16 28 16" />
-</svg>';
-$eqalert6='<svg id="i-activity" viewBox="0 0 32 32" width="28" height="28" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
-    <path d="M4 16 L11 16 14 29 18 3 21 16 28 16" />
-</svg>';
+
+//$eqalert='<svg id="i-activity" viewBox="0 0 32 32" width="52" height="52" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
+//    <path d="M4 16 L11 16 14 29 18 3 21 16 28 16" />
+//</svg>';
+//$eqalert6='<svg id="i-activity" viewBox="0 0 32 32" width="28" height="28" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
+//    <path d="M4 16 L11 16 14 29 18 3 21 16 28 16" />
+//</svg>';
 ?>
 
+<?php
+function formatArticle($item) {
+	global $magnitude, $eqdist, $eqtitle, $stationlocation, $windunit;
+    echo ("<article>\n");  
+
+    echo ("<div class=actualt>&nbsp;&nbsp Recent Earthquake </div>\n");      
+	//Magnitude
+    if ($magnitude[$item]>=11){echo "<div class=mag11>",$magnitude[$item],"";}
+	else if($magnitude[$item]>=9){echo "<div class=mag9-10>",$magnitude[$item],"";}
+	else if($magnitude[$item]>=6){echo "<div class=mag6-8>",$magnitude[$item],"";}
+	else if($magnitude[$item]>=4){echo "<div class=mag4-5>",$magnitude[$item],"";}
+	else {echo "<div class=mag1-3>",$magnitude[$item],"";}
+
+	echo ("<div></div>\n");
+
+    echo ("<div class=\"hitempy\">\n");
+	echo ("");
+
+	//Title
+	if ($eqdist[$item]<1300)  {
+	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[$item]."</span></div>";
+	echo $eqtitle[$item];
+	} 
+	else {
+	echo "<div class='time'><span>",$eventime[$item] ,"</span></div>";
+	echo $eqtitle[$item] ;
+	} 
+
+	echo ("<br>");
+    if ($windunit == 'mph' && $eqdist[$item]<200) {
+		 echo round($eqdist[$item]  * 0.621371) ." Miles from<br> $stationlocation";
+	}
+	
+    else if ($windunit == 'km/h' && $eqdist[$item]<700) {
+		 echo "<orange>",round($eqdist[$item]) ." </orange>Km from<br> $stationlocation";
+	}			
+
+    else if ($windunit == 'mph') {
+		 echo round($eqdist[$item]  * 0.621371) ." Miles from<br> $stationlocation";
+	} else {
+		 echo $eqdist[$item] ." Km from<br> $stationlocation" ;
+	}
+	echo "";
+
+	echo ("</div>\n");
+    echo ("</article>\n");
+}
+?>
 
 <!DOCTYPE html>
 <html lang="en">
@@ -76,11 +127,11 @@
 }
 
   
- .weather34chart-btn.close:after,.weather34chart-btn.close:before{color:#ccc;position:absolute;font-size:14px;font-family:Arial,Helvetica,sans-serif;font-weight:600}.weather34browser-header{flex-basis:auto;height:35px;background:#ebebeb;background:0;border-bottom:0;display:flex;margin-top:-20px;width:100%;-webkit-border-top-left-radius:5px;-webkit-border-top-right-radius:5px;-moz-border-radius-topleft:5px;-moz-border-radius-topright:5px;border-top-left-radius:5px;border-top-right-radius:5px}.weather34browser-footer{flex-basis:auto;height:35px;background:#ebebeb;background:rgba(56,56,60,1);border-bottom:0;display:flex;bottom:-20px;width:97.4%;-webkit-border-bottom-right-radius:5px;-webkit-border-bottom-left-radius:5px;-moz-border-radius-bottomright:5px;-moz-border-radius-bottomleft:5px;border-bottom-right-radius:5px;border-bottom-left-radius:5px}.weather34chart-btns{position:absolute;height:35px;display:inline-block;padding:0 10px;line-height:38px;width:55px;flex-basis:auto;top:5px}.weather34chart-btn{width:14px;height:14px;border:1px solid rgba(0,0,0,.15);border-radius:6px;display:inline-block;margin:1px}.weather34chart-btn.close{background-color: rgba(255, 124, 57, 1.000)}.weather34chart-btn.close:before{content:"x";margin-top:-14px;margin-left:2px}.weather34chart-btn.close:after{content:"close window";margin-top:-13px;margin-left:15px;width:300px}a{color:#aaa;text-decoration:none}
+.weather34chart-btn.close:after,.weather34chart-btn.close:before{color:#ccc;position:absolute;font-size:14px;font-family:Arial,Helvetica,sans-serif;font-weight:600}.weather34browser-header{flex-basis:auto;height:35px;background:#ebebeb;background:0;border-bottom:0;display:flex;margin-top:-20px;width:100%;-webkit-border-top-left-radius:5px;-webkit-border-top-right-radius:5px;-moz-border-radius-topleft:5px;-moz-border-radius-topright:5px;border-top-left-radius:5px;border-top-right-radius:5px}.weather34browser-footer{flex-basis:auto;height:35px;background:#ebebeb;background:rgba(56,56,60,1);border-bottom:0;display:flex;bottom:-20px;width:97.4%;-webkit-border-bottom-right-radius:5px;-webkit-border-bottom-left-radius:5px;-moz-border-radius-bottomright:5px;-moz-border-radius-bottomleft:5px;border-bottom-right-radius:5px;border-bottom-left-radius:5px}.weather34chart-btns{position:absolute;height:35px;display:inline-block;padding:0 10px;line-height:38px;width:55px;flex-basis:auto;top:5px}.weather34chart-btn{width:14px;height:14px;border:1px solid rgba(0,0,0,.15);border-radius:6px;display:inline-block;margin:1px}.weather34chart-btn.close{background-color: rgba(255, 124, 57, 1.000)}.weather34chart-btn.close:before{content:"x";margin-top:-14px;margin-left:2px}.weather34chart-btn.close:after{content:"close window";margin-top:-13px;margin-left:15px;width:300px}a{color:#aaa;text-decoration:none}
 .weather34darkbrowser{position:relative;background:0;width:100%;max-height:30px;margin:auto;margin-top:-15px;margin-left:0px;border-top-left-radius:5px;border-top-right-radius:5px;padding-top:45px;background-image:radial-gradient(circle,#EB7061 6px,transparent 8px),radial-gradient(circle,#F5D160 6px,transparent 8px),radial-gradient(circle,#81D982 6px,transparent 8px),radial-gradient(circle,rgba(97,106,114,1) 2px,transparent 2px),radial-gradient(circle,rgba(97,106,114,1) 2px,transparent 2px),radial-gradient(circle,rgba(97,106,114,1) 2px,transparent 2px),linear-gradient(to bottom,rgba(59,60,63,0.4) 40px,transparent 0);background-position:left top,left top,left top,right top,right top,right top,0 0;background-size:50px 45px,90px 45px,130px 45px,50px 30px,50px 45px,50px 60px,100%;background-repeat:no-repeat,no-repeat}.weather34darkbrowser[url]:after{content:attr(url);color:#aaa;font-size:10px;position:absolute;left:0;right:0;top:0;padding:4px 15px;margin:11px 50px 0 90px;border-radius:3px;background:rgba(97, 106, 114, 0.3);height:20px;box-sizing:border-box}
  blue{color:#01a4b4}orange{color:#009bb4}green{color:#aaa}red{color:#f37867}red6{color:#d65b4a}value{color:#fff}yellow{color:#CC0}purple{color:#916392}
 
-smalluvunit{font-size:.6rem;font-family:Arial,Helvetica,system;}
+//smalluvunit{font-size:.6rem;font-family:Arial,Helvetica,system;}
 smallmagunit{font-size:.55rem;font-family:Arial,Helvetica,system;font-weight:500}
 .magcontainer1{left:70px;top:0}
 .mag1,.mag1-3,.mag11,.mag4-5,.mag6-8,.mag9-10{
@@ -103,7 +154,7 @@
 metricsblue{color:#44a6b5;font-family:"weathertext2",Helvetica, Arial, sans-serif;background:rgba(86, 95, 103, 0.5);-webkit-border-radius:2px;border-radius:2px;align-items:center;justify-content:center;font-size:.9em;left:10px;padding:0 3px 0 3px;}
 .w34convertrain{position:relative;font-size:.5em;top:9px;color:#c0c0c0;margin-left:5px}
 .hitempy{position:relative;background:rgba(61, 64, 66, 0.5);color:#fff;font-size:12px;width:110px;padding:1px;-webit-border-radius:2px;border-radius:2px;
-margin-top:-48px;margin-left:72px;padding:5px;line-height:10px;font-size:9px}
+margin-top:-40px;margin-left:72px;padding:5px;line-height:10px;font-size:9px}
 
 .actualt{position:relative;left:5px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;border-radius:3px;background:rgba(74, 99, 111, 0.1);
 padding:5px;font-family:Arial, Helvetica, sans-serif;width:100px;height:0.8em;font-size:0.8rem;padding-top:2px;color:#aaa;
@@ -117,435 +168,12 @@
 <div class="weather34darkbrowser" url="Recent Earthquakes"></div>
   
 <main class="grid">
-  <article>  
-   <div class=actualt>&nbsp;&nbsp Recent Earthquake </div>        
-    <?php 
-				if($magnitude[0]>=9){echo "<div class=mag9-10>",$magnitude[0],"";}
-				else if($magnitude[0]>=6){echo "<div class=mag6-8>",$magnitude[0],"";}
-				else if($magnitude[0]>=4){echo "<div class=mag4-5>",$magnitude[0],"";}
-				else {echo "<div class=mag1-3>",$magnitude[0],"";}	
-						
-				?>
-<div></div>
-
-
-
-<div class="hitempy">
-<?php
-	echo "";
-//for ($i = 0; $i < 1; $i++) {
-	// EQ Latest earthquake 
-	
-	if ($eqdist[0]<1300)  {
-	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[0]."</div></span>";
-	echo $eqtitle[0];
-	} 
-	else {
-	echo "<div class='time'><span>",$eventime[0] ,"</div></span>";
-	echo $eqtitle[0] ;
-	} 
-//}
-
-?><br>
-<?php
-			
-if ($windunit == 'mph' && $eqdist[0]<200) {
-		 echo round($eqdist[0]  * 0.621371) ." Miles from<br> $stationlocation";
-	}
-	
-else if ($windunit == 'km/h' && $eqdist[0]<700) {
-		 echo "<orange>",round($eqdist[0]) ." </orange>Km from<br> $stationlocation";
-	}			
-
-else if ($windunit == 'mph') {
-		 echo round($eqdist[0]  * 0.621371) ." Miles from<br> $stationlocation";
-	} else {
-		 echo $eqdist[0] ." Km from<br> $stationlocation" ;
-	}
-	echo "";
-	?>
-
-</div>
-</smalluvunit>
-</article>  
-  
- <article>  
-   <div class=actualt>&nbsp;&nbsp Recent Earthquake </div>        
-    <?php  //1
-
-				if($magnitude[1]>=9){echo "<div class=mag9-10>",$magnitude[1],"";}
-				else if($magnitude[1]>=6){echo "<div class=mag6-8>",$magnitude[1],"";}
-				else if($magnitude[1]>=4){echo "<div class=mag4-5>",$magnitude[1],"";}
-				else {echo "<div class=mag1-3>",$magnitude[1],"";}	
-						
-				?>
-<div></div>
-
-
-
-<div class="hitempy">
-<?php
-	echo "";
-//for ($i = 1; $i < 2; $i++) {
-	// Temp fix
-	
-	if ($eqdist[1]<1300)  {
-	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[1]."</div></span>";
-	echo $eqtitle[1];
-	} 
-	else {
-	echo "<div class='time'><span>",$eventime[1] ,"</div></span>";
-	echo $eqtitle[1] ;
-	} 
-//}
-
-?><br>
-<?php
-			
-if ($windunit == 'mph' && $eqdist[1]<200) {
-		 echo round($eqdist[1]  * 0.621371) ." Miles from<br> $stationlocation";
-	}
-	
-else if ($windunit == 'km/h' && $eqdist[1]<700) {
-		 echo "<orange>",round($eqdist[1]) ." </orange>Km from<br> $stationlocation";
-	}			
-
-else if ($windunit == 'mph') {
-		 echo round($eqdist[1]  * 0.621371) ." Miles from<br> $stationlocation";
-	} else {
-		 echo $eqdist[1] ." Km from<br> $stationlocation" ;
-	}
-	echo "";
-	?>
-
-</div>
-</smalluvunit>
-</article>  
-  
-   <article>  
-   <div class=actualt>&nbsp;&nbsp Recent Earthquake </div>        
-    <?php //2
-
-				if($magnitude[2]>=9){echo "<div class=mag9-10>",$magnitude[2],"";}
-				else if($magnitude[2]>=6){echo "<div class=mag6-8>",$magnitude[2],"";}
-				else if($magnitude[2]>=4){echo "<div class=mag4-5>",$magnitude[2],"";}
-				else {echo "<div class=mag1-3>",$magnitude[2],"";}	
-
-						
-				?>
-<div></div>
-
-
-
-<div class="hitempy">
-<?php
-	echo "";
-//for ($i = 2; $i < 3; $i++) {
-	// EQ Latest earthquake 
-	
-	if ($eqdist[2]<1300)  {
-	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[2]."</div></span>";
-	echo $eqtitle[2];
-	} 
-	else {
-	echo "<div class='time'><span>",$eventime[2] ,"</div></span>";
-	echo $eqtitle[2] ;
-	} 
-//}
-
-?><br>
-<?php
-			
-if ($windunit == 'mph' && $eqdist[2]<200) {
-		 echo round($eqdist[2]  * 0.621371) ." Miles from<br> $stationlocation";
-	}
-	
-else if ($windunit == 'km/h' && $eqdist[2]<700) {
-		 echo "<orange>",round($eqdist[2]) ." </orange>Km from<br> $stationlocation";
-	}			
-
-else if ($windunit == 'mph') {
-		 echo round($eqdist[2]  * 0.621371) ." Miles from<br> $stationlocation";
-	} else {
-		 echo $eqdist[2] ." Km from<br> $stationlocation" ;
-	}
-	echo "";
+	<?php
+        for ($i = 0; $i < $eqcount; $i++) {
+	        formatArticle($i);
+		}   
 	?>
 
-</div>
-</smalluvunit>
-</article>  
-  
-   <article>  
-   <div class=actualt>&nbsp;&nbsp Recent Earthquake </div>        
-    <?php //3
-
-				if($magnitude[3]>=9){echo "<div class=mag9-10>",$magnitude[3],"";}
-				else if($magnitude[3]>=6){echo "<div class=mag6-8>",$magnitude[3],"";}
-				else if($magnitude[3]>=4){echo "<div class=mag4-5>",$magnitude[3],"";}
-				else {echo "<div class=mag1-3>",$magnitude[3],"";}	
-
-						
-				?>
-<div></div>
-
-
-
-<div class="hitempy">
-<?php
-	echo "";
-//for ($i = 3; $i < 4; $i++) {
-	// EQ Latest earthquake 
-	
-	if ($eqdist[3]<1300)  {
-	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[3]."</div></span>";
-	echo $eqtitle[3];
-	} 
-	else {
-	echo "<div class='time'><span>",$eventime[3] ,"</div></span>";
-	echo $eqtitle[3] ;
-	} 
-//}
-
-?><br>
-<?php
-			
-if ($windunit == 'mph' && $eqdist[0]<200) {
-		 echo round($eqdist[3]  * 0.621371) ." Miles from<br> $stationlocation";
-	}
-	
-else if ($windunit == 'km/h' && $eqdist[0]<700) {
-		 echo "<orange>",round($eqdist[3]) ." </orange>Km from<br> $stationlocation";
-	}			
-
-else if ($windunit == 'mph') {
-		 echo round($eqdist[3]  * 0.621371) ." Miles from<br> $stationlocation";
-	} else {
-		 echo $eqdist[3] ." Km from<br> $stationlocation" ;
-	}
-	echo "";
-	?>
-
-</div>
-</smalluvunit>
-</article>  
-
- <article>  
-   <div class=actualt>&nbsp;&nbsp Recent Earthquake </div>        
-    <?php //4
-
-				if($magnitude[4]>=9){echo "<div class=mag9-10>",$magnitude[4],"";}
-				else if($magnitude[4]>=6){echo "<div class=mag6-8>",$magnitude[4],"";}
-				else if($magnitude[4]>=4){echo "<div class=mag4-5>",$magnitude[4],"";}
-				else {echo "<div class=mag1-3>",$magnitude[4],"";}	
-
-						
-				?>
-<div></div>
-
-
-
-<div class="hitempy">
-<?php
-	echo "";
-//for ($i = 4; $i < 5; $i++) {
-	// EQ Latest earthquake 
-	
-	if ($eqdist[4]<1300)  {
-	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[4]."</div></span>";
-	echo $eqtitle[4];
-	} 
-	else {
-	echo "<div class='time'><span>",$eventime[4] ,"</div></span>";
-	echo $eqtitle[4] ;
-	} 
-//}
-
-?><br>
-<?php
-			
-if ($windunit == 'mph' && $eqdist[4]<200) {
-		 echo round($eqdist[4]  * 0.621371) ." Miles from<br> $stationlocation";
-	}
-	
-else if ($windunit == 'km/h' && $eqdist[4]<700) {
-		 echo "<orange>",round($eqdist[4]) ." </orange>Km from<br> $stationlocation";
-	}			
-
-else if ($windunit == 'mph') {
-		 echo round($eqdist[4]  * 0.621371) ." Miles from<br> $stationlocation";
-	} else {
-		 echo $eqdist[4] ." Km from<br> $stationlocation" ;
-	}
-	echo "";
-	?>
-
-</div>
-</smalluvunit>
-</article>  
-  
- <article>  
-   <div class=actualt>&nbsp;&nbsp Recent Earthquake </div>        
-    <?php //5
-
-				if($magnitude[5]>=9){echo "<div class=mag9-10>",$magnitude[5],"";}
-				else if($magnitude[5]>=6){echo "<div class=mag6-8>",$magnitude[5],"";}
-				else if($magnitude[5]>=4){echo "<div class=mag4-5>",$magnitude[5],"";}
-				else {echo "<div class=mag1-3>",$magnitude[5],"";}	
-
-						
-				?>
-<div></div>
-
-
-
-<div class="hitempy">
-<?php
-	echo "";
-//for ($i = 5; $i < 6; $i++) {
-	// EQ Latest earthquake 
-	
-	if ($eqdist[5]<1300)  {
-	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[5]."</div></span>";
-	echo $eqtitle[5];
-	} 
-	else {
-	echo "<div class='time'><span>",$eventime[5] ,"</div></span>";
-	echo $eqtitle[5] ;
-	} 
-//}
-
-?><br>
-<?php
-			
-if ($windunit == 'mph' && $eqdist[5]<200) {
-		 echo round($eqdist[5]  * 0.621371) ." Miles from<br> $stationlocation";
-	}
-	
-else if ($windunit == 'km/h' && $eqdist[5]<700) {
-		 echo "<orange>",round($eqdist[5]) ." </orange>Km from<br> $stationlocation";
-	}			
-
-else if ($windunit == 'mph') {
-		 echo round($eqdist[5]  * 0.621371) ." Miles from<br> $stationlocation";
-	} else {
-		 echo $eqdist[5] ." Km from<br> $stationlocation" ;
-	}
-	echo "";
-	?>
-
-</div>
-</smalluvunit>
-</article>  
-
-
-<article>  
-   <div class=actualt>&nbsp;&nbsp Recent Earthquake </div>        
-    <?php //6
-
-				if($magnitude[6]>=9){echo "<div class=mag9-10>",$magnitude[6],"";}
-				else if($magnitude[6]>=6){echo "<div class=mag6-8>",$magnitude[6],"";}
-				else if($magnitude[6]>=4){echo "<div class=mag4-5>",$magnitude[6],"";}
-				else {echo "<div class=mag1-3>",$magnitude[6],"";}	
-						
-				?>
-<div></div>
-
-
-
-<div class="hitempy">
-<?php
-	echo "";
-//for ($i = 6; $i < 7; $i++) {
-	// EQ Latest earthquake 
-	
-	if ($eqdist[6]<1300)  {
-	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[6]."</div></span>";
-	echo $eqtitle[6];
-	} 
-	else {
-	echo "<div class='time'><span>",$eventime[6] ,"</div></span>";
-	echo $eqtitle[6] ;
-	} 
-//}
-
-?><br>
-<?php
-			
-if ($windunit == 'mph' && $eqdist[6]<200) {
-		 echo round($eqdist[6]  * 0.621371) ." Miles from<br> $stationlocation";
-	}
-	
-else if ($windunit == 'km/h' && $eqdist[6]<700) {
-		 echo "<orange>",round($eqdist[6]) ." </orange>Km from<br> $stationlocation";
-	}			
-
-else if ($windunit == 'mph') {
-		 echo round($eqdist[6]  * 0.621371) ." Miles from<br> $stationlocation";
-	} else {
-		 echo $eqdist[6] ." Km from<br> $stationlocation" ;
-	}
-	echo "";
-	?>
-
-</div>
-</smalluvunit>
-</article>  
-
-<article>  
-   <div class=actualt>&nbsp;&nbsp Recent Earthquake </div>        
-    <?php //7
-
-				if($magnitude[7]>=9){echo "<div class=mag9-10>",$magnitude[7],"";}
-				else if($magnitude[7]>=6){echo "<div class=mag6-8>",$magnitude[7],"";}
-				else if($magnitude[7]>=4){echo "<div class=mag4-5>",$magnitude[7],"";}
-				else {echo "<div class=mag1-3>",$magnitude[7],"";}	
-						
-				?>
-<div></div>
-
-
-
-<div class="hitempy">
-<?php
-	echo "";
-//for ($i = 7; $i < 8; $i++) {
-	// EQ Latest earthquake 
-	
-	if ($eqdist[7]<1300)  {
-	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[7]."</div></span>";
-	echo $eqtitle[7];
-	} 
-	else {
-	echo "<div class='time'><span>",$eventime[7] ,"</div></span>";
-	echo $eqtitle[7] ;
-	} 
-//}
-
-?><br>
-<?php
-			
-if ($windunit == 'mph' && $eqdist[7]<200) {
-		 echo round($eqdist[7]  * 0.621371) ." Miles from<br> $stationlocation";
-	}
-	
-else if ($windunit == 'km/h' && $eqdist[7]<700) {
-		 echo "<orange>",round($eqdist[7]) ." </orange>Km from<br> $stationlocation";
-	}			
-
-else if ($windunit == 'mph') {
-		 echo round($eqdist[7]  * 0.621371) ." Miles from<br> $stationlocation";
-	} else {
-		 echo $eqdist[7] ." Km from<br> $stationlocation" ;
-	}
-	echo "";
-	?>
-
-</div>
-</smalluvunit>
-</article>  
-  
-  
   <article>
    <div class=actualt>&nbsp;&nbsp &copy; Information</div>
    <span style="font-size:8px;">  

From b35920393da95f5a768c3ec3900983ecbde5402b Mon Sep 17 00:00:00 2001
From: Richard Harken <theharkens@charter.net>
Date: Tue, 28 Nov 2023 14:42:07 -0500
Subject: [PATCH 5/9] Fixed time issue

---
 eqlist.php | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/eqlist.php b/eqlist.php
index 72f1158..ee8901e 100644
--- a/eqlist.php
+++ b/eqlist.php
@@ -50,7 +50,7 @@
 
 <?php
 function formatArticle($item) {
-	global $magnitude, $eqdist, $eqtitle, $stationlocation, $windunit;
+	global $magnitude, $eqdist, $eqtitle, $stationlocation, $windunit, $time;
     echo ("<article>\n");  
 
     echo ("<div class=actualt>&nbsp;&nbsp Recent Earthquake </div>\n");      
@@ -68,12 +68,12 @@ function formatArticle($item) {
 
 	//Title
 	if ($eqdist[$item]<1300)  {
-	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$eventime[$item]."</span></div>";
+	echo "<div class='time'><orange1>*Regional</orange1> <span> ".$time[$item]."</span></div>";
 	echo $eqtitle[$item];
 	} 
 	else {
-	echo "<div class='time'><span>",$eventime[$item] ,"</span></div>";
-	echo $eqtitle[$item] ;
+	echo "<div class='time'><span>",$time[$item] ,"</span></div>";
+	echo $eqtitle[$item];
 	} 
 
 	echo ("<br>");

From bb40f8ca378f9de27e86f48532d8c11079574225 Mon Sep 17 00:00:00 2001
From: Richard Harken <theharkens@charter.net>
Date: Tue, 28 Nov 2023 16:58:22 -0500
Subject: [PATCH 6/9] correct attribution

---
 eqlist.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eqlist.php b/eqlist.php
index ee8901e..9802a63 100644
--- a/eqlist.php
+++ b/eqlist.php
@@ -182,7 +182,7 @@ function formatArticle($item) {
   <br>
   <br>
   <?php echo $info?>  
-<a href="http://earthquake-report.com" title="Earthquake-Report.com" target="_blank">Data © <?php echo date('Y');?> Earthquake-Report.com</a></span>
+<a href="https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php" title="USGS Earthquake GeoJSON Summary Feed" target="_blank">Data © <?php echo date('Y');?> USGS Earthquake GeoJSON Summary Feed</a></span>
 
   
   </article> 

From 5a7e765fea3e316e8fa4526f18217a7bf08010fa Mon Sep 17 00:00:00 2001
From: Richard Harken <theharkens@charter.net>
Date: Wed, 29 Nov 2023 14:55:19 -0500
Subject: [PATCH 7/9] Additional functionality to eq reporting

---
 eqlist.php | 64 ++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 40 insertions(+), 24 deletions(-)

diff --git a/eqlist.php b/eqlist.php
index 9802a63..e52626d 100644
--- a/eqlist.php
+++ b/eqlist.php
@@ -26,19 +26,26 @@
 $longi = array();
 $eventime = array();
 $eqdist = array();
+$file_elements = count($parsed_json["features"]); //For safety checks
+// Set minimum size of earthquakes to report - set to 0.0 for all
+$min_eq = 3.5; // Based on research - 3.5 is the minimum that can be felt
+// Set max number of earthquakes to report
 $eqcount = 8;
-for ($i = 0; $i < $eqcount; $i++) {
-	$magnitude[$i]=number_format($parsed_json["features"][$i]["properties"]["mag"],1);
-	$eqtitle[$i]=$parsed_json["features"][$i]["properties"]["title"];
-	$depth[$i]=$parsed_json["features"][$i]["geometry"]["coordinates"][2];
-    $utime[$i]=round($parsed_json["features"][$i]["properties"]["time"] / 1000, 0, PHP_ROUND_HALF_UP);
-	$time[$i]=gmdate("Y-m-d\TH:i:s\Z", $utime[$i]);
-	$lati[$i]=$parsed_json["features"][$i]["geometry"]["coordinates"][1];
-	$longi[$i]=$parsed_json["features"][$i]["geometry"]["coordinates"][0];
-	$eventime[$i]=date($timeFormatShort, $utime[$i]);
-	$eqdist[$i] = round(distance($lat, $lon, $lati[$i], $longi[$i]));
-	
+for ($i = 0, $a = 0; $i < $file_elements && $a < $eqcount; $i++) {
+	if (number_format($parsed_json["features"][$i]["properties"]["mag"],1) >= $min_eq) {
+	    $magnitude[$a]=number_format($parsed_json["features"][$i]["properties"]["mag"],1);
+	    $eqtitle[$a]=$parsed_json["features"][$i]["properties"]["title"];
+	    $depth[$a]=$parsed_json["features"][$i]["geometry"]["coordinates"][2];
+        $utime[$a]=round($parsed_json["features"][$i]["properties"]["time"] / 1000, 0, PHP_ROUND_HALF_UP);
+	    $time[$a]=gmdate("Y-m-d\TH:i:s\Z", $utime[$a]);
+	    $lati[$a]=$parsed_json["features"][$i]["geometry"]["coordinates"][1];
+	    $longi[$a]=$parsed_json["features"][$i]["geometry"]["coordinates"][0];
+	    $eventime[$a]=date($timeFormatShort, $utime[$a]);
+	    $eqdist[$a] = round(distance($lat, $lon, $lati[$i], $longi[$i]));
+		$a+=1;
+	}
 }
+$eqcount = $a; // In case we don't get enough eq meeting the min magnitude
 
 //$eqalert='<svg id="i-activity" viewBox="0 0 32 32" width="52" height="52" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
 //    <path d="M4 16 L11 16 14 29 18 3 21 16 28 16" />
@@ -77,18 +84,20 @@ function formatArticle($item) {
 	} 
 
 	echo ("<br>");
-    if ($windunit == 'mph' && $eqdist[$item]<200) {
-		 echo round($eqdist[$item]  * 0.621371) ." Miles from<br> $stationlocation";
+	$eqclose=200; //This is km
+    if ($windunit == 'mph') {
+		if ($eqdist[$item]<$eqclose) {
+		    echo "<orange>",round($eqdist[$item] * 0.621371) ." </orange>Miles from<br> $stationlocation";
+		} else {
+		    echo round($eqdist[$item]  * 0.621371) ." Miles from<br> $stationlocation";
+		}
 	}
-	
-    else if ($windunit == 'km/h' && $eqdist[$item]<700) {
-		 echo "<orange>",round($eqdist[$item]) ." </orange>Km from<br> $stationlocation";
-	}			
-
-    else if ($windunit == 'mph') {
-		 echo round($eqdist[$item]  * 0.621371) ." Miles from<br> $stationlocation";
-	} else {
-		 echo $eqdist[$item] ." Km from<br> $stationlocation" ;
+    else { //if ($windunit == 'km/h') { -- No reason to check this
+		if ($eqdist[$item]<$eqclose) {
+		    echo "<orange>",round($eqdist[$item]) ." </orange>Km from<br> $stationlocation";
+		} else {
+		    echo round($eqdist[$item]) ." Km from<br> $stationlocation" ;
+		}
 	}
 	echo "";
 
@@ -165,8 +174,15 @@ function formatArticle($item) {
 .svgimage{background:rgba(0, 155, 171, 1.000);-webit-border-radius:2px;border-radius:2px;}
 orange1{color:rgba(255, 131, 47, 1.000);}
 </style>
-<div class="weather34darkbrowser" url="Recent Earthquakes"></div>
-  
+<?php
+    global $min_eq;
+    if ($min_eq) {
+		echo ("<div class=\"weather34darkbrowser\" url=\"Recent Earthquakes Magnitude $min_eq or Greater\"></div>");
+	} else {
+		echo ("<div class=\"weather34darkbrowser\" url=\"Recent Earthquakes\"></div>");
+	}
+?>
+
 <main class="grid">
 	<?php
         for ($i = 0; $i < $eqcount; $i++) {

From 315642649d6a346ac58af617f9e7315895758299 Mon Sep 17 00:00:00 2001
From: Richard Harken <theharkens@charter.net>
Date: Fri, 15 Dec 2023 23:38:11 -0500
Subject: [PATCH 8/9] Typo in distance calculation

---
 eqlist.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eqlist.php b/eqlist.php
index e52626d..bc8d606 100644
--- a/eqlist.php
+++ b/eqlist.php
@@ -41,7 +41,7 @@
 	    $lati[$a]=$parsed_json["features"][$i]["geometry"]["coordinates"][1];
 	    $longi[$a]=$parsed_json["features"][$i]["geometry"]["coordinates"][0];
 	    $eventime[$a]=date($timeFormatShort, $utime[$a]);
-	    $eqdist[$a] = round(distance($lat, $lon, $lati[$i], $longi[$i]));
+	    $eqdist[$a] = round(distance($lat, $lon, $lati[$a], $longi[$a]));
 		$a+=1;
 	}
 }

From cbb568b43fdf9feec715f80a7a483c5693490847 Mon Sep 17 00:00:00 2001
From: Richard Harken <theharkens@charter.net>
Date: Sat, 6 Jan 2024 23:23:10 -0500
Subject: [PATCH 9/9] Fixed purple air sensor data and display

---
 easyweathersetup.php          | 12 +++++++++++-
 mbdbfiles/stationcron.php     |  6 ++++--
 mbdbfiles/stationcroncurl.php | 23 +++++++++++++----------
 purpleair.php                 | 12 ++++++------
 settings1.default.php         |  1 +
 5 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/easyweathersetup.php b/easyweathersetup.php
index 56cd8a5..84e9503 100644
--- a/easyweathersetup.php
+++ b/easyweathersetup.php
@@ -2212,13 +2212,23 @@ function showForm($error="LOGIN"){
     <input name="purpleair" type="text" id="purpleair" value="<?php echo $purpleairID ;?>" class="choose">
 
 
+    <br/> <svg id="i-info" viewBox="0 0 32 32" width="12" height="12" fill="none" stroke="#777" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
+    <path d="M16 14 L16 23 M16 8 L16 10" />
+    <circle cx="16" cy="16" r="14" />
+</svg> <span style="color:#777;">enter your <strong>PurpleAir </strong> station id example <strong><span style="color:rgba(86, 95, 103, 1.000);"> 1200</strong></span></span>
 
+    <br/>
+    <div class="stationvalue"> Purple Air API Key</div>
+    <svg id="i-chevron-right" viewBox="0 0 32 32" width="14" height="14" fill="none" stroke="rgba(86, 95, 103, 1.000)" stroke-linecap="round" stroke-linejoin="round" stroke-width="6.25%">
+    <path d="M12 30 L24 16 12 2" />
+</svg>
 
+    <input name="purpleair" type="text" id="purpleair" value="<?php echo $purpleairapikey ;?>" class="chooseapi">
 
     <br/> <svg id="i-info" viewBox="0 0 32 32" width="12" height="12" fill="none" stroke="#777" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
     <path d="M16 14 L16 23 M16 8 L16 10" />
     <circle cx="16" cy="16" r="14" />
-</svg> <span style="color:#777;">enter your <strong>PurpleAir </strong> station id example <strong><span style="color:rgba(86, 95, 103, 1.000);"> 1200</strong></span></span>
+</svg> <span style="color:#777;">enter your <strong>PurpleAir </strong> API Key example <strong><span style="color:rgba(86, 95, 103, 1.000);"> XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX</strong></span></span>
 
     </div>
     <br/>
diff --git a/mbdbfiles/stationcron.php b/mbdbfiles/stationcron.php
index db2a97d..af6b333 100644
--- a/mbdbfiles/stationcron.php
+++ b/mbdbfiles/stationcron.php
@@ -152,13 +152,15 @@
 // weather34 purple air quality  curl based
 if($purpleairhardware=='yes'){
     if ($purpleairID != "11111") {
-        $url4 = 'https://www.purpleair.com/json?show='.$purpleairID;
+        $url4 = 'https://api.purpleair.com/v1/sensors/'.$purpleairID;
         $ch4 = curl_init($url4);
         $filename4 = '../jsondata/purpleair.txt';
         $complete_save_loc4 = $filename4;
         $fp4 = fopen($complete_save_loc4, 'wb');
         curl_setopt($ch4, CURLOPT_FILE, $fp4);
-        curl_setopt($ch4, CURLOPT_HEADER, 0);
+        $pahdr = [ "X-API-Key: ".$purpleairapikey ];
+        curl_setopt($ch4, CURLOPT_HTTPHEADER, $pahdr);
+
         $result = curl_exec($ch4);
         if ($result) {
             echo ($_SERVER['HTTP_USER_AGENT']=='meteobridge'?'PurpleAir updated<br>':"<pre>PurpleAir updated</pre>");
diff --git a/mbdbfiles/stationcroncurl.php b/mbdbfiles/stationcroncurl.php
index 31a2d33..5732bbc 100644
--- a/mbdbfiles/stationcroncurl.php
+++ b/mbdbfiles/stationcroncurl.php
@@ -99,14 +99,17 @@
 ?>
 <?php // weather34 purple air quality  curl based
 if($purpleairhardware=='yes'){
-$url4 = 'https://www.purpleair.com/json?show='.$purpleairID.''; 
-$ch4 = curl_init($url4);
-$filename4 = '../jsondata/purpleair.txt';
-$complete_save_loc4 = $filename4; 
-$fp4 = fopen($complete_save_loc4, 'wb'); 
-curl_setopt($ch4, CURLOPT_FILE, $fp4);
-curl_setopt($ch4, CURLOPT_HEADER, 0);
-curl_exec($ch4);
-curl_close($ch4);
-fclose($fp4);}
+   $url4 = 'https://api.purpleair.com/v1/sensors/'.$purpleairID;
+   $ch4 = curl_init($url4);
+   $filename4 = '../jsondata/purpleair.txt';
+   $complete_save_loc4 = $filename4;
+   $fp4 = fopen($complete_save_loc4, 'wb');
+   curl_setopt($ch4, CURLOPT_FILE, $fp4);
+   $pahdr = [ "X-API-Key: ".$purpleairapikey ];
+   curl_setopt($ch4, CURLOPT_HTTPHEADER, $pahdr);
+
+   curl_exec($ch4);
+   curl_close($ch4);
+   fclose($fp4);
+}
 ?>
\ No newline at end of file
diff --git a/purpleair.php b/purpleair.php
index 3afb717..8410215 100644
--- a/purpleair.php
+++ b/purpleair.php
@@ -42,14 +42,14 @@ function map($value, $fromLow, $fromHigh, $toLow, $toHigh){
     return $tmpValue + $toLow;
 }
 $json_string             = file_get_contents("jsondata/purpleair.txt");
-$parsed_json             = json_decode($json_string);
+$parsed_json             = json_decode($json_string, true);
 //$aqiweather["aqi"]       = $parsed_json->{'results'}[1]->{'PM2_5Value'};
-$aqiweather["aqi"]       = number_format(pm25_to_aqi(($parsed_json->{'results'}[0]->{'PM2_5Value'} + $parsed_json->{'results'}[1]->{'PM2_5Value'}) / 2),1);
+$aqiweather["aqi"]       = number_format(pm25_to_aqi($parsed_json['sensor']['stats']['pm2.5_10minute']),1);
 $aqiweather["aqiozone"]  = 'N/A';
-$aqiweather["time2"]     = $parsed_json->{'results'}[0]->{'LastSeen'};
-$aqiweather["time"]      = date("H:i",$aqiweather["time2"]);
-$aqiweather["city"]      = $parsed_json->{'results'}[0]->{'ID'};
-$aqiweather["label"]     = $parsed_json->{'results'}[0]->{'Label'};
+$aqiweather["time2"]     = $parsed_json['sensor']['last_seen'];
+$aqiweather["time"]      = date($timeFormat,$aqiweather["time2"]);
+$aqiweather["city"]      = $parsed_json['sensor']['name'];
+$aqiweather["label"]     = $parsed_json['sensor']['name'];
 $a="";if($aqiweather["aqi"]==$a){$aqiweather["aqi"] = "0" ;}
 
 
diff --git a/settings1.default.php b/settings1.default.php
index 301c1e9..6a0db4a 100644
--- a/settings1.default.php
+++ b/settings1.default.php
@@ -8,6 +8,7 @@
 $id = "ISTANBUL161";
 $purpleairID = "11111";
 $purpleairhardware   = "yes";
+$purpleairapikey = "XXXXX-XXXX-XXXX-XXXX-XXXXXXXX";
 $metarapikey ="11111111111111";
 $TZ = "Europe/London";
 $UTC = "1";