22-04-2022
This commit is contained in:
211
view_bdd.php
211
view_bdd.php
@@ -23,21 +23,24 @@
|
||||
localize($domain);
|
||||
?>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1><?php echo gettext('View database'); ?></h1>
|
||||
|
||||
<?php
|
||||
|
||||
$base = 'db_photo.sqlite3';
|
||||
$perpage = 20;
|
||||
|
||||
|
||||
if (!isset($_GET['page'])) $page = 1;
|
||||
else $page = intval($_GET['page']);
|
||||
|
||||
|
||||
//echo $req;
|
||||
|
||||
$dir = (new AdvancedFilesystemIterator('photos/img/'))->match('/heic|HEIC|jpg|jpeg|JPG|JPEG|webp|WEBP$/');
|
||||
|
||||
@@ -46,42 +49,146 @@ echo '<h3>' . count($dir) . gettext(' images found in folder') . ' <i>photos/img
|
||||
$conn = new PDO("sqlite:db_photo.sqlite3");
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
|
||||
// Construction des requêtes
|
||||
|
||||
$request = array(
|
||||
'lens' => 'SELECT DISTINCT lens FROM photos WHERE lens <> "" ORDER BY lens',
|
||||
'model' => 'SELECT DISTINCT model FROM photos WHERE model <> "" ORDER BY model',
|
||||
'iso' => 'SELECT DISTINCT iso FROM photos WHERE iso <> "" ORDER BY iso',
|
||||
'speed' => 'SELECT DISTINCT speed FROM photos WHERE speed <> "" ORDER BY speed',
|
||||
'keywords' => 'SELECT DISTINCT keywords FROM photos WHERE keywords <> ""'
|
||||
);
|
||||
|
||||
$select = array();
|
||||
$i = 0;
|
||||
foreach ($request as $key => $val){
|
||||
$query = $conn->query($val);
|
||||
$select[$i] = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
$select[$i] = array_column($select[$i],$key);
|
||||
if ($i == 4){
|
||||
$mc = array();
|
||||
foreach($select[$i] as $row){
|
||||
$x = explode(",", $row);
|
||||
foreach ($x as $y){
|
||||
if ((! str_starts_with($y, "_")) && (! str_ends_with($y, "_"))) {
|
||||
$mc [] = $y;
|
||||
}
|
||||
}
|
||||
}
|
||||
$motcles = array_unique($mc);
|
||||
usort($motcles, 'strcasecmp'); // 'strcasecmp'
|
||||
$select[$i] = $motcles;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
// Affichage des photos
|
||||
|
||||
try {
|
||||
$columns = array('date','lens','model','iso','lat');
|
||||
$column = isset($_GET['column']) && in_array($_GET['column'], $columns) ? $_GET['column'] : $columns[0];
|
||||
//$_SESSION['column'] = $column;
|
||||
$sort_order = isset($_GET['order']) && strtolower($_GET['order']) == 'desc' ? 'DESC' : 'ASC';
|
||||
//$_SESSION['sort_order'] = $sort_order;
|
||||
|
||||
$query4 = "SELECT id,filename, date, lens, speed, iso, width, height, html, aperture, model, lat, long, alt, legende, copyright, title, creator, keywords, metering, flash, focal, wb, program FROM photos ORDER BY " . $column . " " . $sort_order . " LIMIT ? OFFSET ?";
|
||||
// SELECT id,filename, date, lens, speed, iso, width, height, html, aperture, model, lat, long, alt, legende, copyright, title, creator, keywords, metering, flash, focal, wb, program
|
||||
|
||||
if (isset($_POST['lens'])) $req = "WHERE lens = '" . $_POST['lens'] . "' ";
|
||||
elseif (isset($_POST['model'])) $req = "WHERE model = '" . $_POST['model'] . "' ";
|
||||
elseif (isset($_POST['iso'])) $req = "WHERE iso = '" . $_POST['iso'] . "' ";
|
||||
elseif (isset($_POST['speed'])) $req = "WHERE speed = '" . $_POST['speed'] . "' ";
|
||||
elseif (isset($_POST['keyword'])) $req = "WHERE keywords LIKE '%" . str_replace("'","''", $_POST['keyword']) . "%' ";
|
||||
else $req = "";
|
||||
|
||||
$query = "SELECT * FROM photos " . $req . "ORDER BY " . $column . " " . $sort_order . " " . "LIMIT ? OFFSET ?";
|
||||
|
||||
echo '<pre><code>' . $query . '</code></pre>';
|
||||
|
||||
//$query4 = "SELECT id,filename, date, lens, speed, iso, width, height, html, aperture, model, lat, long, alt, legende, copyright, title, creator, keywords, metering, flash, focal, wb, program FROM photos ORDER BY date DESC LIMIT ? OFFSET ?";
|
||||
$perpage = 50;
|
||||
$offset = $perpage * ($page -1);
|
||||
|
||||
echo $query4 . "<br>";
|
||||
echo $perpage . " - " . $offset . "<br>";
|
||||
|
||||
$stmt = $conn->prepare($query4);
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->execute(array($perpage, $offset));// (1,3...) 1=1ere valeur 3=valeur
|
||||
# id 1 -> 3
|
||||
//$stmt->execute(array(1, 3)); // WHERE id >= ? AND id <= ? ORDER BY date DESC";
|
||||
$stmt->execute();
|
||||
|
||||
//$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
//_pr($result);
|
||||
//echo '<h3>' . gettext('Reading added photos') . ':</h3>';
|
||||
//$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
//$count = $rows['count(*)'];
|
||||
//echo count($result);
|
||||
//_pr($rows);
|
||||
|
||||
$up_or_down = str_replace(array('ASC','DESC'), array('up','down'), $sort_order);
|
||||
$asc_or_desc = $sort_order == 'ASC' ? 'desc' : 'asc';
|
||||
$add_class = ' class="highlight"';
|
||||
?>
|
||||
|
||||
<div class="myForm">
|
||||
<form name="keywordSelect" action="view_bdd.php" method="post" >
|
||||
<select name="keyword" id="keyword" class="classic">
|
||||
<option value=""><?php echo gettext('keywords'); ?></option>
|
||||
<?php
|
||||
for( $i = 0; $i < count($select[4]); $i++) {
|
||||
echo '<option>' . $select[4]["$i"] . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<button type="submit" class="myButton">ok</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="myForm">
|
||||
<form name="modelSelect" action="view_bdd.php" method="post" >
|
||||
<select name="model" id="model" class="classic">
|
||||
<option value=""><?php echo gettext('model'); ?></option>
|
||||
<?php
|
||||
for( $i = 0; $i < count($select[1]); $i++) {
|
||||
echo '<option>' . $select[1]["$i"] . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<button type="submit" class="myButton">ok</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="myForm">
|
||||
<form name="lensSelect" action="view_bdd.php" method="post" >
|
||||
<select name="lens" id="lens" class="classic">
|
||||
<option value=""><?php echo gettext('lens'); ?></option>
|
||||
<?php
|
||||
for( $i = 0; $i < count($select[0]); $i++) {
|
||||
echo '<option>' . $select[0]["$i"] . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<button type="submit" class="myButton">ok</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="myForm">
|
||||
<form name="isoSelect" action="view_bdd.php" method="post" >
|
||||
<select name="iso" id="iso" class="classic">
|
||||
<option value=""><?php echo gettext('iso'); ?></option>
|
||||
<?php
|
||||
for( $i = 0; $i < count($select[2]); $i++) {
|
||||
echo '<option>' . $select[2]["$i"] . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<button type="submit" class="myButton">ok</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="myForm">
|
||||
<form name="speedSelect" action="view_bdd.php" method="post" >
|
||||
<select name="speed" id="speed" class="classic">
|
||||
<option value=""><?php echo gettext('speed'); ?></option>
|
||||
<?php
|
||||
for( $i = 0; $i < count($select[3]); $i++) {
|
||||
echo '<option>' . $select[3]["$i"] . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<button type="submit" class="myButton">ok</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
/*
|
||||
<th>' . gettext('Date') . '</th>
|
||||
<th>' . gettext('Lens') . '</th>
|
||||
<th>' . gettext('Iso') . '</th>
|
||||
<th>' . gettext('Model') . '</th>
|
||||
<th>' . gettext('Latitude') . '</th>
|
||||
*/
|
||||
<?php
|
||||
echo '<div id="view_bdd">';
|
||||
echo '<table class="styled-table">';
|
||||
echo '<thead>';
|
||||
@@ -90,16 +197,19 @@ try {
|
||||
echo '<th>' . gettext('Creator') . '</th><th>' . gettext('Keywords') . '</th><th>' . gettext('Metering') . '</th><th>' . gettext('Flash') . '</th><th>' . gettext('Focal') . '</th><th>' . gettext('Wb') . '</th><th>' . gettext('Program') . '</th>';
|
||||
echo '</thead>';
|
||||
echo '<tbody>';
|
||||
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$thumbnail = host() . str_replace("photos/img", "photos/thumb", $row['filename']);
|
||||
$full = host() . $row['filename'];
|
||||
|
||||
echo '<tr><td>' . $row['id'] . '</td><td>' . '<a href="' . $full . '"><img src="'.$thumbnail.'" /></a>' . '</td><td>' . $row['filename'] . '</td><td>' . $row['date'] . '</td><td>' . $row['lens'] . '</td><td>' . $row['speed'] . '</td><td>' . $row['iso'] . '</td><td>' . $row['width'] . '</td><td>' . $row['height'] . '</td><td>' . $row['html'] . '</td><td>' . $row['aperture'] . '</td><td>' . $row['model'] . '</td><td>' . $row['lat'] . '</td><td>' . $row['long'] . '</td><td>' . $row['alt'] . '</td><td>' . $row['legende'] . '</td><td>' . $row['copyright'] . '</td><td>' . $row['title'] . '</td><td>' . $row['creator'] . '</td><td>' . $row['keywords'] . '</td><td>' . $row['metering'] . '</td><td>' . $row['flash'] . '</td><td>' . $row['focal'] . '</td><td>' . $row['wb'] . '</td><td>' . $row['program'] . '</td></tr>';
|
||||
}
|
||||
|
||||
echo '</tbody></table>';
|
||||
echo '</div>';
|
||||
|
||||
$conn = null;
|
||||
//$stmt = $conn->reset();
|
||||
//$conn = null;
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
echo $e->getMessage();
|
||||
@@ -107,37 +217,54 @@ try {
|
||||
?>
|
||||
|
||||
<script type='text/javascript'>
|
||||
/*
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var $obj = lc_lightbox('#view_bdd a', {
|
||||
open_close_time : 200,
|
||||
ol_time_diff : 100,
|
||||
wrap_class : 'lcl_zoomin_oc',
|
||||
skin : 'minimal',
|
||||
txt_hidden : true,
|
||||
fullscreen : false,
|
||||
fs_img_behavior : 'smart',
|
||||
browser_fs_mode : true,
|
||||
rclick_prevent : true,
|
||||
});
|
||||
|
||||
var $obj = lc_lightbox('td a', {
|
||||
img_zoom : true,
|
||||
open_close_time : 200, // durée de l'animation pour l'ouverture et la fermeture de la lightbox
|
||||
ol_time_diff : 100, // animation de superposition avance (à l'ouverture) et retard (à la fermeture) à la fenêtre
|
||||
fading_time : 50, // durée de l'animation de fondu des éléments
|
||||
slideshow_time : 4000, // durée de l'intervalle du diaporama
|
||||
animation_time : 100,
|
||||
counter : false, // s'il faut afficher le compteur d'éléments
|
||||
progressbar : false, // s'il faut afficher une barre de progression lors de l'exécution du diaporama
|
||||
max_width : '95%', // largeur maximale de la lightbox
|
||||
max_height : '95%', // hauteur maximale de la lightbox
|
||||
wrap_class : 'lcl_fade_oc', // Classes personnalisées ajoutées au wrapper: effet à l'ouverture de la lb (lcl_fade_oc | lcl_zoomin_oc | lcl_rtl_oc)
|
||||
skin : 'minimal', // minimal | light | dark
|
||||
data_position : 'over', // Spécifie où les données des éléments seront affichées. Les modes disponibles sont :over, under|rside|lside
|
||||
cmd_position : 'inner', // Déclare où les commandes doivent être affichées : inner|outer
|
||||
nav_btn_pos : 'normal', // Régle les flèches et la position de lecture/pause. Options disponibles: normal|middle
|
||||
shox_title : true, // s'il faut afficher les titres
|
||||
show_descr : false, // s'il faut afficher les descriptions
|
||||
show_author : true, // s'il faut afficher les auteurs
|
||||
thumbs_nav : false, // permet la navigation par vignettes (nécessite des éléments affiche ou images)
|
||||
fullscreen : true, // Autoriser ou non le mode plein écran
|
||||
fs_img_behavior : 'smart', //Comportement de l'image en plein écran : fit|fill|smart
|
||||
fs_only : 500, // s'il faut utiliser uniquement l'ouverture de la lightbox en mode plein écran (utile pour les appareils mobiles) : false | (integer)
|
||||
browser_fs_mode : true, // utiliser ou non le mode plein écran du navigateur
|
||||
txt_toggle_cmd : true, // s'il faut afficher le bouton de basculement du texte de l'élément
|
||||
download : true, // whether to show element's file download button
|
||||
touchswipe : true, // permet les interactions tactiles (nécessite AlloyFinger)
|
||||
rclick_prevent : true, // s'il faut éviter le clic droit sur les éléments de la lightbox
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
try {
|
||||
$conn4 = new PDO('sqlite:db_photo.sqlite3');
|
||||
$query4 = "SELECT COUNT(*) AS count FROM photos";
|
||||
|
||||
$stmt = $conn4->prepare($query4);
|
||||
//$conn4 = new PDO('sqlite:db_photo.sqlite3');
|
||||
$query4 = "SELECT COUNT(*) AS count FROM photos " . $req;
|
||||
|
||||
$stmt = $conn->prepare($query4);
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$numRows = $result['count'];
|
||||
|
||||
$conn4 = null;
|
||||
$conn = null;
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
echo $e->getMessage();
|
||||
|
||||
Reference in New Issue
Block a user