rewritten php and some python for SQLITE
This commit is contained in:
+42
-9
@@ -4,6 +4,31 @@ ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
header("refresh: 30;");
|
||||
|
||||
$db = new SQLite3('/home/pi/BirdNET-Pi/scripts/birds.db', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
|
||||
|
||||
$statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\') ORDER BY Time DESC');
|
||||
$result0 = $statement0->execute();
|
||||
|
||||
$statement1 = $db->prepare('SELECT COUNT(*) FROM detections');
|
||||
$result1 = $statement1->execute();
|
||||
$totalcount = $result1->fetchArray(SQLITE3_ASSOC);
|
||||
|
||||
$statement2 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Date == DATE(\'now\')');
|
||||
$result2 = $statement2->execute();
|
||||
$todaycount = $result2->fetchArray(SQLITE3_ASSOC);
|
||||
|
||||
$statement3 = $db->prepare('SELECT COUNT(*) FROM detections WHERE TIME >= TIME(\'now\', \'localtime\', \'-1 hour\')');
|
||||
$result3 = $statement3->execute();
|
||||
$hourcount = $result3->fetchArray(SQLITE3_ASSOC);
|
||||
|
||||
$statement4 = $db->prepare('SELECT Com_Name, Sci_Name, Time, Confidence FROM detections LIMIT 1');
|
||||
$result4 = $statement4->execute();
|
||||
$mostrecent = $result4->fetchArray(SQLITE3_ASSOC);
|
||||
|
||||
$statement5 = $db->prepare('SELECT COUNT(DISTINCT(Com_Name)) FROM detections');
|
||||
$result5 = $statement5->execute();
|
||||
$speciestally = $result5->fetchArray(SQLITE3_ASSOC);
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
@@ -36,10 +61,10 @@ a {
|
||||
<th>Number of Unique Species</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td><?php echo $totalcount['COUNT(*)'];?></td>
|
||||
<td><a href="/By_Date/<?php echo date('Y-m-d');?>"/><?php echo $todaycount['COUNT(*)'];?></a></td>
|
||||
<td><?php echo $hourcount['COUNT(*)'];?></td>
|
||||
<td><a href="/stats.php"/><?php echo $speciestally['COUNT(DISTINCT(Com_Name))'];?></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -53,11 +78,19 @@ a {
|
||||
<th>Confidence</th>
|
||||
<th>Links</th>
|
||||
</tr>
|
||||
<?php
|
||||
while($todaytable=$result0->fetchArray(SQLITE3_ASSOC))
|
||||
{
|
||||
$comname = preg_replace('/ /', '_', $todaytable['Com_Name']);
|
||||
$comlink = "/By_Date/".date('Y-m-d')."/".$comname."/".$todaytable['File_Name'];
|
||||
$sciname = preg_replace('/ /', '_', $todaytable['Sci_Name']);
|
||||
?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><a href="/By_Scientific_Name/"/></a></td>
|
||||
<td><a href="/By_Common_Name/"/></a></td>
|
||||
<td></td>
|
||||
<td><a class="a2" href="https://allaboutbirds.org/guide/" target="top">All About Birds</a>, <a class="a2" href="https://wikipedia.org/wiki/" target="top">Wikipedia</a></td>
|
||||
<td><a href="<?php echo $comlink;?>" target="footer"/><?php echo $todaytable['Time'];?></a></td>
|
||||
<td><?php echo $todaytable['Sci_Name'];?></td>
|
||||
<td><?php echo $todaytable['Com_Name'];?></td>
|
||||
<td><?php echo $todaytable['Confidence'];?></td>
|
||||
<td><a class="a2" href="https://allaboutbirds.org/guide/<?php echo $comname;?>" target="top">All About Birds</a>, <a class="a2" href="https://wikipedia.org/wiki/<?php echo $sciname;?>" target="top">Wikipedia</a></td>
|
||||
<?php }?>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user