chiro-canto/public/explore/list/index.php

89 lines
3.7 KiB
PHP
Executable File

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
require("$root/lang/gettext.php");
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 * FROM records ORDER BY date');
$req->execute();
$result = $req->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?=_('Explore')?> | Chiro - Canto</title>
<link rel="stylesheet" type="text/css" href="/styles/style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<?php
include("$root/analytics/matomo.php");
include("$root/analytics/owa.php");
?>
<body>
<?php include("$root/menu.php");?>
<?php include("$root/header.php");?>
<section>
<h2><?=_('Explore')?></h2>
<h3><?=_('Recording List')?></h3>
<table id="list">
<thead>
<tr>
<th><?=_('Datetime')?></th>
<th><?=_('Species')?></th>
<th><?=_('File Name')?></th>
<th><?=_('Author')?></th>
<th><?=_('License')?></th>
<th><?=_('Audio')?></th>
</tr>
</thead>
<tbody>
<?php
foreach($result as $row) {
$author_id = $row['author_id'];
$req = $db->prepare('SELECT * FROM authors WHERE id=:id');
$req->execute(array(
"id"=>$author_id
));
if ($data = $req->fetch()) {
$username = $data['username'];
}
?>
<tr>
<td><?=$row['date']?> <?=$row['time']?></td>
<td><em><?=$row['species']?></em></td>
<td>
<a href="/explore/spectrograms/?record=<?=$row['id']?>"><?=$row['file_name']?></a>
<a href="/storage/records/<?=$row['file_name']?>" title="Download file"><i class="fa fa-download" aria-hidden="true"></i></a>
<a href="/larynx/?record=<?=$row['id']?>" title="<?=_('Open with Larynx')?>"><img src="/media/icons/wave.svg" alt="spectro analysis"></a>
<a href="/explore/guano?record=<?=$row['id']?>" title="<?=_('See GUANO metadata')?>"><img src="/media/icons/data.png" alt="database search"></a>
<a href="/explore/record/edit/?id=<?=$row['id']?>" title="<?=_('Edit record metadata')?>"><i class="fa fa-edit " ></i></a>
</td>
<td><?=$username?></td>
<td><?=$row['license']?></td>
<td><audio src="/storage/records/<?=$row['file_name']?>" controls></audio></td>
</tr>
<?php
}
?>
</tbody>
</table>
</section>
<?php include("$root/footer.php");?>
</body>
<script src="/scripts/script.js"></script>
</html>