Update overview.php
This makes it so overview always shows the most recent detection (and not a blank div), by selecting the newest detection that also has a valid image.
This commit is contained in:
@@ -10,20 +10,19 @@ if($db == False) {
|
|||||||
|
|
||||||
if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isset($_GET['previous_detection_identifier'])) {
|
if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isset($_GET['previous_detection_identifier'])) {
|
||||||
|
|
||||||
$statement4 = $db->prepare('SELECT Com_Name, Sci_Name, Date, Time, Confidence, File_Name FROM detections ORDER BY Date DESC, Time DESC LIMIT 1');
|
$statement4 = $db->prepare('SELECT Com_Name, Sci_Name, Date, Time, Confidence, File_Name FROM detections ORDER BY Date DESC, Time DESC LIMIT 50');
|
||||||
if($statement4 == False) {
|
if($statement4 == False) {
|
||||||
echo "Database is busy";
|
echo "Database is busy";
|
||||||
header("refresh: 0;");
|
header("refresh: 0;");
|
||||||
}
|
}
|
||||||
$result4 = $statement4->execute();
|
$result4 = $statement4->execute();
|
||||||
$mostrecent = $result4->fetchArray(SQLITE3_ASSOC);
|
// hopefully one of the 5 most recent detections has an image that is valid, we'll use that one as the most recent detection until the newer ones get their images created
|
||||||
|
while($mostrecent = $result4->fetchArray(SQLITE3_ASSOC)) {
|
||||||
$comname = preg_replace('/ /', '_', $mostrecent['Com_Name']);
|
$comname = preg_replace('/ /', '_', $mostrecent['Com_Name']);
|
||||||
$sciname = preg_replace('/ /', '_', $mostrecent['Sci_Name']);
|
$sciname = preg_replace('/ /', '_', $mostrecent['Sci_Name']);
|
||||||
$comname = preg_replace('/\'/', '', $comname);
|
$comname = preg_replace('/\'/', '', $comname);
|
||||||
$filename = "/By_Date/".$mostrecent['Date']."/".$comname."/".$mostrecent['File_Name'];
|
$filename = "/By_Date/".$mostrecent['Date']."/".$comname."/".$mostrecent['File_Name'];
|
||||||
|
|
||||||
|
|
||||||
if($_GET['previous_detection_identifier'] != $filename || $_GET['previous_detection_identifier'] == "undefined") {
|
|
||||||
// check to make sure the image actually exists, sometimes it takes a minute to be created
|
// check to make sure the image actually exists, sometimes it takes a minute to be created
|
||||||
if (isset($_SERVER['HTTPS']) &&
|
if (isset($_SERVER['HTTPS']) &&
|
||||||
($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
|
($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
|
||||||
@@ -35,7 +34,9 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isse
|
|||||||
$protocol = 'http://';
|
$protocol = 'http://';
|
||||||
}
|
}
|
||||||
$headers = @get_headers($protocol.$_SERVER['HTTP_HOST'].$filename.".png");
|
$headers = @get_headers($protocol.$_SERVER['HTTP_HOST'].$filename.".png");
|
||||||
|
// we've found our valid detection! ignore everything else from the database loop
|
||||||
if(strpos($headers[0],'200')) {
|
if(strpos($headers[0],'200')) {
|
||||||
|
if($_GET['previous_detection_identifier'] == $filename) { die(); }
|
||||||
?>
|
?>
|
||||||
<style>
|
<style>
|
||||||
.fade-in {
|
.fade-in {
|
||||||
@@ -67,7 +68,7 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" && isse
|
|||||||
<video style="margin-top:10px" onplay='setLiveStreamVolume(0)' onended='setLiveStreamVolume(1)' onpause='setLiveStreamVolume(1)' controls poster="<?php echo $filename.".png";?>" preload="none" title="<?php echo $filename;?>"><source src="<?php echo $filename;?>"></video></td>
|
<video style="margin-top:10px" onplay='setLiveStreamVolume(0)' onended='setLiveStreamVolume(1)' onpause='setLiveStreamVolume(1)' controls poster="<?php echo $filename.".png";?>" preload="none" title="<?php echo $filename;?>"><source src="<?php echo $filename;?>"></video></td>
|
||||||
</form>
|
</form>
|
||||||
</tr>
|
</tr>
|
||||||
</table> <?php
|
</table> <?php break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
die();
|
die();
|
||||||
|
|||||||
Reference in New Issue
Block a user