41 lines
1.2 KiB
PHP
Executable File
41 lines
1.2 KiB
PHP
Executable File
<?php
|
|
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
|
|
require "$root/database/credentials.php";
|
|
|
|
// Connect the database
|
|
try {
|
|
$db = new PDO("mysql:host=$host;dbname=$database;charset=utf8",
|
|
$user,
|
|
$password,
|
|
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
|
));
|
|
} catch (Exception $e) {
|
|
die("Error : ".$e->getMessage());
|
|
}
|
|
|
|
$req = $db->prepare('SELECT id, recordist_name, file_name, license, species, sound_type, date, time FROM `records` ORDER BY `entry_timestamp` DESC LIMIT 1');
|
|
$req->execute();
|
|
if ($data = $req->fetch())
|
|
{
|
|
?>
|
|
<div class="sound">
|
|
<h3><?=$data['file_name']?></h3>
|
|
<h4><em><?=$data['species']?></em></h4>
|
|
<p>Recorded on <?=$data['date']?> at <?=$data['time']?></p>
|
|
<?php
|
|
if (file_exists($root."/storage/spectrograms/".$data['file_name'].'.png'))
|
|
{
|
|
?>
|
|
<img id="spectrogram" src="<?="/storage/spectrograms/".$data['file_name'].'.png'?>" alt="bat sound spectrogram">
|
|
<?php
|
|
}
|
|
?>
|
|
<br>
|
|
<audio src="<?="../storage/records/".$data['file_name']?>" controls></audio>
|
|
<p><?=$data['license']?> <?=$data['recordist_name']?></p>
|
|
</div>
|
|
<?php
|
|
} else {
|
|
echo "Error fetch.";
|
|
}
|
|
?>
|