12-08-2022

This commit is contained in:
2022-08-12 06:56:30 +02:00
parent e73a0c3a4b
commit f7c5cf7d47
7 changed files with 249 additions and 65 deletions

View File

@@ -1,3 +1,4 @@
<!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>

View File

@@ -278,12 +278,17 @@ select.mySelect option{
opacity: 0.7 !important; opacity: 0.7 !important;
} }
button.myButton{ button.myButton{
background-color: Beige;
/* /*
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.6); box-shadow: 0 3px 6px rgba(0, 0, 0, 0.6);
background-color: transparent; background-color: transparent;
opacity: 0.4 !important; opacity: 0.4 !important;
*/ */
} }
.all{
font-weight: 800;
margin-left: 2em;
}
.indexForm { .indexForm {
position: absolute; position: absolute;
bottom: 0px; bottom: 0px;
@@ -294,7 +299,23 @@ button.myButton{
display: inline-block; display: inline-block;
margin-left: 16px; margin-left: 16px;
} }
.bordure {
border: 1px solid #dad59c;
border-radius: 5px;
padding: 15px;
margin: 8px;
}
fieldset {
border: 1px solid #dad59c;
border-radius: 5px;
padding: 15px;
margin: 8px;
}
legend {
font-size: 14px;
color: #b1ac72;
}
/* /*
maps2.php maps2.php
*/ */
@@ -318,9 +339,11 @@ maps2.php
/* /*
view view
input[type="radio"]
*/ */
select, button { select, button, label, .operateur {
/* styling */ /* styling */
background-color: white; background-color: white;
@@ -345,6 +368,10 @@ view
select { select {
padding: 0.25em 3.5em 0.25em 1em; padding: 0.25em 3.5em 0.25em 1em;
} }
.operateur {
padding: 0.25em 1em 0.25em 1em;
}
/* arrows */ /* arrows */
select.classic { select.classic {
@@ -387,4 +414,7 @@ select:-moz-focusring {
text-shadow: 0 0 0 #000; text-shadow: 0 0 0 #000;
} }
.noimg {
text-align: center;
}

View File

@@ -1,5 +1,13 @@
<?php <?php
function preprint($s, $return=false) {
$x = "<pre>";
$x .= print_r($s, 1);
$x .= "</pre>";
if ($return) return $x;
else print $x;
}
/* Fonction month(): convertit le mois (nb) en mois (texte) francais /* Fonction month(): convertit le mois (nb) en mois (texte) francais
photo-du-mois.php photo-du-mois.php
@@ -77,22 +85,62 @@ function get_gps($exif) {
$GPSLongitude = isset($exif['GPS']['GPSLongitude']) ? $exif['GPS']['GPSLongitude'] : ''; $GPSLongitude = isset($exif['GPS']['GPSLongitude']) ? $exif['GPS']['GPSLongitude'] : '';
$GPSAltitude = isset($exif['GPS']['GPSAltitude']) ? $exif['GPS']['GPSAltitude'] : ''; $GPSAltitude = isset($exif['GPS']['GPSAltitude']) ? $exif['GPS']['GPSAltitude'] : '';
preprint($GPSLatitude);
preprint($GPSLongitude);
preprint($GPSAltitude);
$lat_degrees = count($GPSLatitude) > 0 ? gps2Num($GPSLatitude[0]) : 0; $lat_degrees = count($GPSLatitude) > 0 ? gps2Num($GPSLatitude[0]) : 0;
$lat_minutes = count($GPSLatitude) > 1 ? gps2Num($GPSLatitude[1]) : 0; $lat_minutes = count($GPSLatitude) > 1 ? gps2Num($GPSLatitude[1]) : 0;
$lat_seconds = count($GPSLatitude) > 2 ? gps2Num($GPSLatitude[2]) : 0; $lat_seconds = count($GPSLatitude) > 2 ? gps2Num($GPSLatitude[2]) : 0;
/*
echo "latitude <br />";
echo $lat_degrees . "<br />";
echo $lat_minutes . "<br />";
echo $lat_seconds . "<br />";
*/
$lon_degrees = count($GPSLongitude) > 0 ? gps2Num($GPSLongitude[0]) : 0; $lon_degrees = count($GPSLongitude) > 0 ? gps2Num($GPSLongitude[0]) : 0;
$lon_minutes = count($GPSLongitude) > 1 ? gps2Num($GPSLongitude[1]) : 0; $lon_minutes = count($GPSLongitude) > 1 ? gps2Num($GPSLongitude[1]) : 0;
$lon_seconds = count($GPSLongitude) > 2 ? gps2Num($GPSLongitude[2]) : 0; $lon_seconds = count($GPSLongitude) > 2 ? gps2Num($GPSLongitude[2]) : 0;
/*
echo "longitude <br />";
echo $lon_degrees . "<br />";
echo $lon_minutes . "<br />";
echo $lon_seconds . "<br />";
*/
$lat_direction = ($GPSLatitudeRef == 'W' or $GPSLatitudeRef == 'S') ? -1 : 1; $lat_direction = ($GPSLatitudeRef == 'W' or $GPSLatitudeRef == 'S') ? -1 : 1;
$lon_direction = ($GPSLongitudeRef == 'W' or $GPSLongitudeRef == 'S') ? -1 : 1; $lon_direction = ($GPSLongitudeRef == 'W' or $GPSLongitudeRef == 'S') ? -1 : 1;
/*
echo $lat_direction . "<br />";
echo $lon_direction . "<br />";
*/
$latitude = $lat_direction * ($lat_degrees + ($lat_minutes / 60) + ($lat_seconds / (60*60))); $latitude = $lat_direction * ($lat_degrees + ($lat_minutes / 60) + ($lat_seconds / (60*60)));
$longitude = $lon_direction * ($lon_degrees + ($lon_minutes / 60) + ($lon_seconds / (60*60))); $longitude = $lon_direction * ($lon_degrees + ($lon_minutes / 60) + ($lon_seconds / (60*60)));
#echo "lat type: " . gettype($latitude);
$latitude = number_format($latitude, 10, '.', '');
#echo "long type: " . gettype($longitude);
$longitude = number_format($longitude, 10, '.', '');
#echo "latitude: " . $latitude . "<br />";
#echo "longitude: " . $longitude . "<br />";
if($GPSAltitude != ""){
$alt = explode('/', $GPSAltitude); $alt = explode('/', $GPSAltitude);
$altitude = (isset($alt[1])) ? ($alt[0] / $alt[1]) : $alt[0]; $altitude = (isset($alt[1])) ? ($alt[0] / $alt[1]) : $alt[0];
}
else $altitude = 0;
#echo "alt type: " . gettype($altitude);
$altitude = number_format($altitude, 2, '.', '');
#echo "altitude: " . $altitude . "<br />";
} }
else { else {
$latitude = ''; $latitude = '';

View File

@@ -37,7 +37,7 @@ $base = 'db_photo.sqlite3';
$th_w = 300; $th_w = 300;
$th_h = 300; $th_h = 300;
$dir = (new AdvancedFilesystemIterator('photos/img/'))->match('/heic|HEIC|jpg|jpeg|JPG|JPEG|webp|WEBP$/'); $dir = (new AdvancedFilesystemIterator('photos/img/'))->match('/heic|HEIC|jpg|jpeg|JPG|JPEG|webp|WEBP|avif|AVIF$/');
echo '<h3>' . count($dir) . gettext(' images found in folder') . ' <i>photos/img/</i> ...</h3>'; echo '<h3>' . count($dir) . gettext(' images found in folder') . ' <i>photos/img/</i> ...</h3>';
@@ -49,7 +49,7 @@ $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = "CREATE TABLE IF NOT EXISTS photos ( $query = "CREATE TABLE IF NOT EXISTS photos (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
filename TEXT NOT NULL, filename TEXT NOT NULL,
date TEXT, dateoriginal TEXT,
lens TEXT, lens TEXT,
speed TEXT, speed TEXT,
iso INTEGER, iso INTEGER,
@@ -96,6 +96,12 @@ foreach($dir as $file){
# YYYY-MM-DD HH:MM:SS.SSS - 2019:10:01 14:03:12 # YYYY-MM-DD HH:MM:SS.SSS - 2019:10:01 14:03:12
$da = isset($exif['EXIF']['DateTimeOriginal']) ? $exif['EXIF']['DateTimeOriginal'] : ''; $da = isset($exif['EXIF']['DateTimeOriginal']) ? $exif['EXIF']['DateTimeOriginal'] : '';
if (isset($exif['EXIF']['DateTimeOriginal'])) {
$d = explode(' ', $exif['EXIF']['DateTimeOriginal']);
$da = str_replace(':', '-', $d[0]) . " " . $d[1] . ".000";
} else {
$d = '';
}
if (isset($exif['EXIF']['UndefinedTag:0xA434'])) { if (isset($exif['EXIF']['UndefinedTag:0xA434'])) {
$w = $exif['EXIF']['UndefinedTag:0xA434']; $w = $exif['EXIF']['UndefinedTag:0xA434'];
@@ -274,11 +280,15 @@ foreach($dir as $file){
$ap = isset($exif['COMPUTED']['ApertureFNumber']) ? $exif['COMPUTED']['ApertureFNumber'] : ''; $ap = isset($exif['COMPUTED']['ApertureFNumber']) ? $exif['COMPUTED']['ApertureFNumber'] : '';
$gps = get_gps($exif); $gps = get_gps($exif);
if ($gps['latitude'] != "") {
echo "lat: " . $gps['latitude'] . "<br>";
echo "long: " . $gps['longitude'] . "<br>";
echo "alt: " . $gps['altitude'] . "<br>";
}
$photos[$i] = array( $photos[$i] = array(
'filename' => $file, 'filename' => $file,
'date' => $da, 'dateoriginal' => $da,
'lens' => $obj, 'lens' => $obj,
'speed' => $sp, 'speed' => $sp,
'iso' => $iso, 'iso' => $iso,
@@ -364,11 +374,11 @@ echo '<h3>' . gettext('Insertion of ') . $z . ' ' . $b . gettext(' in database')
// Insertion des photos dans la base // Insertion des photos dans la base
// Création des vignettes // Création des vignettes
try { try {
$query2 = "INSERT OR IGNORE INTO photos (filename, date, lens, speed, iso, width, height, html, aperture, model, lat, long, alt, legende, copyright, title, creator, keywords, metering, flash, focal, wb, program) VALUES (:filename, :date, :lens, :speed, :iso, :width, :height, :html, :aperture, :model, :lat, :long, :alt, :legende, :copyright, :title, :creator, :keywords, :metering, :flash, :focal, :wb, :program)"; $query2 = "INSERT OR IGNORE INTO photos (filename, dateoriginal, lens, speed, iso, width, height, html, aperture, model, lat, long, alt, legende, copyright, title, creator, keywords, metering, flash, focal, wb, program) VALUES (:filename, :dateoriginal, :lens, :speed, :iso, :width, :height, :html, :aperture, :model, :lat, :long, :alt, :legende, :copyright, :title, :creator, :keywords, :metering, :flash, :focal, :wb, :program)";
$stmt = $conn->prepare($query2); $stmt = $conn->prepare($query2);
$stmt->bindParam(':filename', $file); $stmt->bindParam(':filename', $file);
$stmt->bindParam(':date', $da); $stmt->bindParam(':dateoriginal', $da);
$stmt->bindParam(':lens', $obj); $stmt->bindParam(':lens', $obj);
$stmt->bindParam(':speed', $sp); $stmt->bindParam(':speed', $sp);
$stmt->bindParam(':iso', $iso); $stmt->bindParam(':iso', $iso);
@@ -397,7 +407,7 @@ try {
if (isset($photos)) { if (isset($photos)) {
foreach ($photos as $item) { foreach ($photos as $item) {
$file = $item['filename']; $file = $item['filename'];
$da = $item['date']; $da = $item['dateoriginal'];
$obj = $item['lens']; $obj = $item['lens'];
$sp = $item['speed']; $sp = $item['speed'];
$iso = $item['iso']; $iso = $item['iso'];
@@ -434,9 +444,9 @@ try {
/* Affichage depuis la bdd des dernières images ajoutées */ /* Affichage depuis la bdd des dernières images ajoutées */
/*
try { try {
$query4 = "SELECT 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 WHERE id > ? ORDER BY date DESC"; $query4 = "SELECT filename, dateoriginal, lens, speed, iso, width, height, html, aperture, model, lat, long, alt, legende, copyright, title, creator, keywords, metering, flash, focal, wb, program FROM photos WHERE id > ? ORDER BY dateoriginal DESC";
//$query4 = "SELECT filename, date, lens, speed, iso, width, height, html, aperture, model, lat, long, alt, legende, copyright, title, creator, keywords FROM photos WHERE lat != '' OR long != '' ORDER BY date DESC"; //$query4 = "SELECT filename, date, lens, speed, iso, width, height, html, aperture, model, lat, long, alt, legende, copyright, title, creator, keywords FROM photos WHERE lat != '' OR long != '' ORDER BY date DESC";
$stmt = $conn->prepare($query4); $stmt = $conn->prepare($query4);
@@ -461,7 +471,7 @@ try {
$thumbnail = host() . str_replace("photos/img", "photos/thumb", $row['filename']); $thumbnail = host() . str_replace("photos/img", "photos/thumb", $row['filename']);
$full = host() . $row['filename']; $full = host() . $row['filename'];
echo '<tr><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 '<tr><td>' . '<a href="' . $full . '"><img src="'.$thumbnail.'" /></a>' . '</td><td>' . $row['filename'] . '</td><td>' . $row['dateoriginal'] . '</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 '</tbody></table>';
echo '</div>'; echo '</div>';
@@ -471,6 +481,7 @@ try {
catch(PDOException $e) { catch(PDOException $e) {
echo $e->getMessage(); echo $e->getMessage();
} }
*/
?> ?>
<script type='text/javascript'> <script type='text/javascript'>

View File

@@ -41,7 +41,7 @@
try { try {
$conn4 = new PDO('sqlite:db_photo.sqlite3'); $conn4 = new PDO('sqlite:db_photo.sqlite3');
$query4 = "SELECT 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 WHERE lat != '' ORDER BY date DESC"; $query4 = "SELECT filename, dateoriginal, lens, speed, iso, width, height, html, aperture, model, lat, long, alt, legende, copyright, title, creator, keywords, metering, flash, focal, wb, program FROM photos WHERE lat != '' ORDER BY dateoriginal DESC";
$stmt = $conn4->prepare($query4); $stmt = $conn4->prepare($query4);
$stmt->execute(); $stmt->execute();

View File

@@ -35,7 +35,7 @@ else $page = intval($_GET['page']);
try { try {
$conn4 = new PDO('sqlite:db_photo.sqlite3'); $conn4 = new PDO('sqlite:db_photo.sqlite3');
// WHERE id='26' // WHERE id='26'
$query4 = "SELECT 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 ?"; $query4 = "SELECT filename, dateoriginal, 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 dateoriginal DESC LIMIT ? OFFSET ?";
//nb d'archive par page //nb d'archive par page
$limit = 13; $limit = 13;
$offset = $limit * ($page -1); $offset = $limit * ($page -1);
@@ -53,7 +53,7 @@ try {
} }
?> ?>
<p class="month"><?php echo month($result[0]['date']); ?></p> <p class="month"><?php echo month($result[0]['dateoriginal']); ?></p>
<?php <?php
$lb = data_for_lightbox($result[0]); $lb = data_for_lightbox($result[0]);
@@ -115,7 +115,7 @@ try {
<?php <?php
for ($i = 1; $i <= ($rowcount -1); $i++) { for ($i = 1; $i <= ($rowcount -1); $i++) {
$date = $result[$i]['date']; $date = $result[$i]['dateoriginal'];
$lb = data_for_lightbox($result[$i]); $lb = data_for_lightbox($result[$i]);

View File

@@ -1,3 +1,4 @@
<!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
@@ -18,6 +19,9 @@
header("location:admin/login.php"); header("location:admin/login.php");
exit; exit;
} }
echo "_SESSION<br>";
_pr($_SESSION);
//echo $_SESSION['query'];
$domain = 'sentier'; $domain = 'sentier';
localize($domain); localize($domain);
@@ -36,11 +40,24 @@
$base = 'db_photo.sqlite3'; $base = 'db_photo.sqlite3';
$perpage = 20; $perpage = 20;
echo "<a href='close.php'> close session </a>";
if (!isset($_GET['page'])) $page = 1; if (!isset($_GET['page'])) $page = 1;
else $page = intval($_GET['page']); else $page = intval($_GET['page']);
//echo $req; echo "_POST<br>";
_pr($_POST);
if (!empty($_POST)) {
$_SESSION['query'] = $_POST;
echo "post query non vide";
echo gettype($_POST);
echo gettype($_SESSION['query']);
}
echo "_SESSION['query']<br>";
_pr($_SESSION['query']);
$gps = (isset($_SESSION['query']['gps'])) ? $_SESSION['query']['gps'] : "off";
echo $gps;
// form option <selected>
$dir = (new AdvancedFilesystemIterator('photos/img/'))->match('/heic|HEIC|jpg|jpeg|JPG|JPEG|webp|WEBP$/'); $dir = (new AdvancedFilesystemIterator('photos/img/'))->match('/heic|HEIC|jpg|jpeg|JPG|JPEG|webp|WEBP$/');
@@ -51,15 +68,30 @@ $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Construction des requêtes // Construction des requêtes
# SELECT * FROM photos WHERE dateoriginal LIKe '2021%'
# SELECT * FROM photos WHERE strftime('%Y', dateoriginal) = '2021' ORDER BY dateoriginal
# SELECT * FROM photos WHERE strftime('%Y', dateoriginal) = '2015' ORDER BY dateoriginal
# SELECT DISTINCT strftime('%Y', dateoriginal) FROM photos WHERE dateoriginal <> "" ORDER BY dateoriginal
$request = array( $request = array(
'lens' => 'SELECT DISTINCT lens FROM photos WHERE lens <> "" ORDER BY lens', 'lens' => 'SELECT DISTINCT lens FROM photos WHERE lens <> "" ORDER BY lens',
'model' => 'SELECT DISTINCT model FROM photos WHERE model <> "" ORDER BY model', 'model' => 'SELECT DISTINCT model FROM photos WHERE model <> "" ORDER BY model',
'iso' => 'SELECT DISTINCT iso FROM photos WHERE iso <> "" ORDER BY iso', 'iso' => 'SELECT DISTINCT iso FROM photos WHERE iso <> "" ORDER BY iso',
'speed' => 'SELECT DISTINCT speed FROM photos WHERE speed <> "" ORDER BY speed', 'speed' => 'SELECT DISTINCT speed FROM photos WHERE speed <> "" ORDER BY speed',
'keywords' => 'SELECT DISTINCT keywords FROM photos WHERE keywords <> ""' 'keywords' => 'SELECT DISTINCT keywords FROM photos WHERE keywords <> ""',
'strftime("%Y", dateoriginal)' => 'SELECT DISTINCT strftime("%Y", dateoriginal) FROM photos WHERE dateoriginal <> "" ORDER BY dateoriginal DESC'
); );
/*
$req = 'SELECT DISTINCT strftime("%Y", dateoriginal) FROM photos WHERE dateoriginal <> "" ORDER BY dateoriginal';
$query = $conn->query($req);
$res = $query->fetchAll(PDO::FETCH_ASSOC);
preprint($res);
$res = array_column($res,'strftime("%Y", dateoriginal)');
preprint($res);
*/
$select = array(); $select = array();
$i = 0; $i = 0;
foreach ($request as $key => $val){ foreach ($request as $key => $val){
@@ -83,22 +115,59 @@ foreach ($request as $key => $val){
$i++; $i++;
} }
//preprint($select);
// Affichage des photos // Affichage des photos
try { try {
$columns = array('date','lens','model','iso','lat'); $columns = array('dateoriginal','lens','model','iso','lat');
$column = isset($_GET['column']) && in_array($_GET['column'], $columns) ? $_GET['column'] : $columns[0]; $column = isset($_GET['column']) && in_array($_GET['column'], $columns) ? $_GET['column'] : $columns[0];
$sort_order = isset($_GET['order']) && strtolower($_GET['order']) == 'desc' ? 'DESC' : 'ASC'; $sort_order = isset($_GET['order']) && strtolower($_GET['order']) == 'desc' ? 'DESC' : 'ASC';
// 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 // 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'] . "' "; if (isset($_POST['lens'])) $req = "WHERE lens = '" . $_POST['lens'] . "' ";
elseif (isset($_POST['model'])) $req = "WHERE model = '" . $_POST['model'] . "' "; elseif (isset($_POST['model'])) $req = "WHERE model = '" . $_POST['model'] . "' ";
elseif (isset($_POST['iso'])) $req = "WHERE iso = '" . $_POST['iso'] . "' "; elseif (isset($_POST['iso'])) $req = "WHERE iso = '" . $_POST['iso'] . "' ";
elseif (isset($_POST['speed'])) $req = "WHERE speed = '" . $_POST['speed'] . "' "; elseif (isset($_POST['speed'])) $req = "WHERE speed = '" . $_POST['speed'] . "' ";
elseif (isset($_POST['keyword'])) $req = "WHERE keywords LIKE '%" . str_replace("'","''", $_POST['keyword']) . "%' "; elseif (isset($_POST['keyword'])) $req = "WHERE keywords LIKE '%" . str_replace("'","''", $_POST['keyword']) . "%' ";
else $req = ""; else $req = "";
*/
$req1 = "";
$req2 = "";
$req3 = "";
$req4 = "";
$req5 = "";
$req6 = "";
$req7 = "";
if (!empty($_SESSION['query']['lens'])) $req1 = "lens = '" . $_SESSION['query']['lens'] . "'";
if (!empty($_SESSION['query']['model'])) $req2 = "model = '" . $_SESSION['query']['model'] . "'";
if (!empty($_SESSION['query']['iso'])) $req3 = "iso = '" . $_SESSION['query']['iso'] . "'";
if (!empty($_SESSION['query']['speed'])) $req4 = "speed = '" . $_SESSION['query']['speed'] . "'";
if (!empty($_SESSION['query']['keyword'])) $req5 = "keywords LIKE '%" . str_replace("'","''", $_SESSION['query']['keyword']) . "%'";
if (!empty($_SESSION['query']['all']) && ($_SESSION['query']['all'] == "all")) $req = "";
if (isset($_SESSION['query']['operator'])) $operator = " " . $_SESSION['query']['operator'] . " ";
if (!empty($_SESSION['query']['gps'])) $req6 = "lat != '' AND long != ''";
if (!empty($_SESSION['query']['date'])) $req7 = "strftime('%Y', dateoriginal) = '" . $_SESSION['query']['date'] . "'";
if (($req1 != "") || ($req2 != "") || ($req3 != "") || ($req4 != "") || ($req5 != "")) {
$req = "WHERE " . ($req1 != "" ? $req1 . $operator : "") . ($req2 != "" ? $req2 . $operator : "") . ($req3 != "" ? $req3 . $operator : "") . ($req4 != "" ? $req4 . $operator : "") . ($req5 != "" ? $req5 . $operator : "");
$req = substr_replace($req, " ", (strlen($req) - strlen($operator)), strlen($operator));
}
// add
elseif ($req6 != "") {
$req = "WHERE " . $req6 . " ";
}
elseif ($req7 != "") {
$req = "WHERE " . $req7 . " ";
}
//
else $req = "";
//echo '<pre><code>' . $req . '</code></pre>';
$query = "SELECT * FROM photos " . $req . "ORDER BY " . $column . " " . $sort_order . " " . "LIMIT ? OFFSET ?"; $query = "SELECT * FROM photos " . $req . "ORDER BY " . $column . " " . $sort_order . " " . "LIMIT ? OFFSET ?";
@@ -108,7 +177,7 @@ try {
$stmt = $conn->prepare($query); $stmt = $conn->prepare($query);
$stmt->execute(array($perpage, $offset)); // (1,3...) 1=1ere valeur 3=valeur $stmt->execute(array($perpage, $offset)); // (1,3...) 1=1ere valeur 3=valeur
# id 1 -> 3 // id 1 -> 3
//$stmt->execute(array(1, 3)); // WHERE id >= ? AND id <= ? ORDER BY date DESC"; //$stmt->execute(array(1, 3)); // WHERE id >= ? AND id <= ? ORDER BY date DESC";
//$result = $stmt->fetchAll(PDO::FETCH_ASSOC); //$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -121,8 +190,11 @@ try {
$add_class = ' class="highlight"'; $add_class = ' class="highlight"';
?> ?>
<div class="myForm"> <form id="keywordSelect" name="keywordSelect" action="view_bdd.php" method="post" class="myForm" >
<form name="keywordSelect" action="view_bdd.php" method="post" > <fieldset>
<legend>APN</legend>
<select name="keyword" id="keyword" class="classic"> <select name="keyword" id="keyword" class="classic">
<option value=""><?php echo gettext('keywords'); ?></option> <option value=""><?php echo gettext('keywords'); ?></option>
<?php <?php
@@ -131,12 +203,6 @@ try {
} }
?> ?>
</select> </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"> <select name="model" id="model" class="classic">
<option value=""><?php echo gettext('model'); ?></option> <option value=""><?php echo gettext('model'); ?></option>
<?php <?php
@@ -145,11 +211,6 @@ try {
} }
?> ?>
</select> </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"> <select name="lens" id="lens" class="classic">
<option value=""><?php echo gettext('lens'); ?></option> <option value=""><?php echo gettext('lens'); ?></option>
<?php <?php
@@ -158,11 +219,6 @@ try {
} }
?> ?>
</select> </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"> <select name="iso" id="iso" class="classic">
<option value=""><?php echo gettext('iso'); ?></option> <option value=""><?php echo gettext('iso'); ?></option>
<?php <?php
@@ -171,11 +227,6 @@ try {
} }
?> ?>
</select> </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"> <select name="speed" id="speed" class="classic">
<option value=""><?php echo gettext('speed'); ?></option> <option value=""><?php echo gettext('speed'); ?></option>
<?php <?php
@@ -184,27 +235,67 @@ try {
} }
?> ?>
</select> </select>
<button type="submit" class="myButton">ok</button> <span class="operateur"><?php echo gettext('Operator:'); ?></span>
<input type="radio" id="operator1" name="operator" value="AND" checked>
<label for="ope1"><?php echo gettext('AND'); ?></label>
<input type="radio" id="operator2" name="operator" value="OR">
<label for="ope1"><?php echo gettext('OR'); ?></label>
<button type="submit" class="myButton">OK</button>
</fieldset>
</form>
<form id="allSelect" name="allSelect" action="view_bdd.php" method="post" class="myForm" >
<fieldset>
<legend>All</legend>
<button type="submit" name = "all" value="all" class="myButton all"> <?php echo gettext('All photos'); ?> </button>
</fieldset>
</form>
<form id="dateSelect" name="dateSelect" action="view_bdd.php" method="post" class="myForm" >
<fieldset>
<legend>Divers</legend>
<select name="date" id="date" class="classic">
<option value=""><?php echo gettext('year'); ?></option>
<?php
for( $i = 0; $i < count($select[5]); $i++) {
echo '<option>' . $select[5]["$i"] . '</option>';
}
?>
</select>
<input type="checkbox" id="gps" name="gps">
<label for="gps">gps</label>
<button type="submit" name = "all" value="all" class="myButton all"> <?php echo gettext('OK'); ?> </button>
</fieldset>
</form> </form>
</div>
<?php <?php
echo '<div id="view_bdd">'; echo '<div id="view_bdd">';
echo '<table class="styled-table">'; echo '<table class="styled-table">';
echo '<thead>'; echo '<thead>';
echo '<th>' . gettext('Id') . '</th><th>' . gettext('Thumb') . '</th><th>' . gettext('Filename') . '</th><th><a class="sort" href="view_bdd.php?column=date&order=' . $asc_or_desc . '">' . gettext('Date') . ' <i class="fas fa-sort' . ($column == 'date' ? '-' . $up_or_down : '') . '"></i></a></th><th><a href="view_bdd.php?column=lens&order=' . $asc_or_desc . '">' . gettext('Lens') . ' <i class="fas fa-sort' . ($column == 'lens' ? '-' . $up_or_down : '') . '"></i></a></th><th>' . gettext('Speed') . '</th><th><a href="view_bdd.php?column=iso&order=' . $asc_or_desc . '">' . gettext('Iso') . ' <i class="fas fa-sort' . ($column == 'iso' ? '-' . $up_or_down : '') . '"></i></a></th><th>' . gettext('Width') . '</th><th>' . gettext('Height') . '</th><th>' . gettext('Html') . '</th>'; echo '<th>' . gettext('Id') . '</th><th>' . gettext('Thumb') . '</th><th>' . gettext('Filename') . '</th><th><a class="sort" href="view_bdd.php?column=date&order=' . $asc_or_desc . '">' . gettext('Date') . ' <i class="fas fa-sort' . ($column == 'date' ? '-' . $up_or_down : '') . '"></i></a></th><th><a href="view_bdd.php?column=lens&order=' . $asc_or_desc . '">' . gettext('Lens') . ' <i class="fas fa-sort' . ($column == 'lens' ? '-' . $up_or_down : '') . '"></i></a></th><th>' . gettext('Speed') . '</th><th>' . gettext('Aperture') . '</th><th><a href="view_bdd.php?column=iso&order=' . $asc_or_desc . '">' . gettext('Iso') . ' <i class="fas fa-sort' . ($column == 'iso' ? '-' . $up_or_down : '') . '"></i></a></th><th>' . gettext('Width') . '</th><th>' . gettext('Height') . '</th>';
echo '<th>' . gettext('Aperture') . '</th><th><a href="view_bdd.php?column=model&order=' . $asc_or_desc . '">' . gettext('Model') . ' <i class="fas fa-sort' . ($column == 'Model' ? '-' . $up_or_down : '') . '"></i></a></th><th><a href="view_bdd.php?column=lat&order=' . $asc_or_desc . '">' . gettext('Latitude') . ' <i class="fas fa-sort' . ($column == 'lat' ? '-' . $up_or_down : '') . '"></i></a></th><th>' . gettext('Longitude') . '</th><th>' . gettext('Alttitude') . '</th><th>' . gettext('Legende') . '</th><th>' . gettext('Copyright') . '</th><th>' . gettext('Title') . '</th>'; echo '<th><a href="view_bdd.php?column=model&order=' . $asc_or_desc . '">' . gettext('Model') . ' <i class="fas fa-sort' . ($column == 'Model' ? '-' . $up_or_down : '') . '"></i></a></th><th><a href="view_bdd.php?column=lat&order=' . $asc_or_desc . '">' . gettext('Latitude') . ' <i class="fas fa-sort' . ($column == 'lat' ? '-' . $up_or_down : '') . '"></i></a></th><th>' . gettext('Longitude') . '</th><th>' . gettext('Alttitude') . '</th><th>' . gettext('Legende') . '</th><th>' . gettext('Copyright') . '</th><th>' . gettext('Title') . '</th>';
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 '<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><th>' . gettext('Html') . '</th>';
echo '</thead>'; echo '</thead>';
echo '<tbody>'; echo '<tbody>';
$nRows = 0;
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$thumbnail = host() . str_replace("photos/img", "photos/thumb", $row['filename']); $thumbnail = host() . str_replace("photos/img", "photos/thumb", $row['filename']);
$full = host() . $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 '<tr><td>' . $row['id'] . '</td><td>' . '<a href="' . $full . '"><img src="'.$thumbnail.'" /></a>' . '</td><td>' . $row['filename'] . '</td><td>' . $row['dateoriginal'] . '</td><td>' . $row['lens'] . '</td><td>' . $row['speed'] . '</td><td>' . $row['aperture'] . '</td><td>' . $row['iso'] . '</td><td>' . $row['width'] . '</td><td>' . $row['height'] . '</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><td>' . $row['html'] . '</td></tr>';
$nRows++;
} }
if ($nRows == 0) echo '<tr><td colspan="25" class="noimg">' . gettext("No image found !") .'</td></tr>';
echo '</tbody></table>'; echo '</tbody></table>';
echo '</div>'; echo '</div>';
@@ -254,6 +345,7 @@ try {
</script> </script>
<?php <?php
try { try {
//$conn4 = new PDO('sqlite:db_photo.sqlite3'); //$conn4 = new PDO('sqlite:db_photo.sqlite3');
$query4 = "SELECT COUNT(*) AS count FROM photos " . $req; $query4 = "SELECT COUNT(*) AS count FROM photos " . $req;
@@ -275,6 +367,7 @@ try {
$prec = $page - 1; $prec = $page - 1;
$suiv = $page + 1; $suiv = $page + 1;
if ($numRows > 0) {
echo '<div class="navPage">' . gettext("Page") . ': '; echo '<div class="navPage">' . gettext("Page") . ': ';
if ($page >= 2) echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$prec.'&column='.$column.'&order='.$sort_order.'" title="'.gettext("Previous Page").'">&laquo; '.gettext("prev").'</a>&nbsp;'; if ($page >= 2) echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$prec.'&column='.$column.'&order='.$sort_order.'" title="'.gettext("Previous Page").'">&laquo; '.gettext("prev").'</a>&nbsp;';
for ($i = 1; $i <= $nbpages; $i++) { for ($i = 1; $i <= $nbpages; $i++) {
@@ -287,6 +380,7 @@ try {
} }
if ($page < $nbpages) echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$suiv.'&column='.$column.'&order='.$sort_order.'" title="'.gettext("Next Page").'">'.gettext("next").' &raquo;</a>&nbsp;'; if ($page < $nbpages) echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$suiv.'&column='.$column.'&order='.$sort_order.'" title="'.gettext("Next Page").'">'.gettext("next").' &raquo;</a>&nbsp;';
echo '</div>'; echo '</div>';
}
?> ?>
<p class="navPage"><a href="index.php" title="<?php echo gettext("Home"); ?>"><?php echo gettext("Home"); ?></a> | <a href="maps.php" title="<?php echo gettext("Maps"); ?>"><?php echo gettext("Maps"); ?></a> | <a href="photo-du-mois.php" title="<?php echo gettext("Picture of the month"); ?>"><?php echo gettext("Picture of the month"); ?></a> | <a href="admin/index.php" title="<?php echo gettext("Admin"); ?>"><?php echo gettext("Admin"); ?></a></p> <p class="navPage"><a href="index.php" title="<?php echo gettext("Home"); ?>"><?php echo gettext("Home"); ?></a> | <a href="maps.php" title="<?php echo gettext("Maps"); ?>"><?php echo gettext("Maps"); ?></a> | <a href="photo-du-mois.php" title="<?php echo gettext("Picture of the month"); ?>"><?php echo gettext("Picture of the month"); ?></a> | <a href="admin/index.php" title="<?php echo gettext("Admin"); ?>"><?php echo gettext("Admin"); ?></a></p>