22-04-2022
This commit is contained in:
430
clean_bdd.php
430
clean_bdd.php
@@ -28,6 +28,8 @@
|
||||
|
||||
<body>
|
||||
|
||||
<h1><?php echo gettext('Clean / repare database'); ?></h1>
|
||||
|
||||
<?php
|
||||
|
||||
$base = 'db_photo.sqlite3';
|
||||
@@ -39,28 +41,8 @@ $th_h = 300;
|
||||
$img_path = "photos/img/";
|
||||
$thumb_path = "photos/thumb/";
|
||||
|
||||
//$dir = (new AdvancedFilesystemIterator('photos/img/'))->match('/heic|HEIC|jpg|jpeg|JPG|JPEG|webp|WEBP$/');
|
||||
|
||||
//echo '<h3>' . count($dir) . gettext(' images found in folder') . ' <i>photos/img/</i> ...</h3>';
|
||||
|
||||
//_pr($dir);
|
||||
|
||||
|
||||
/*
|
||||
foreach($dir as $file){
|
||||
|
||||
//$file->getFilename()
|
||||
//$file->getpathName()
|
||||
|
||||
$file = $file->getpathName();
|
||||
|
||||
$x = in_bdd($file);
|
||||
|
||||
if ($x == false) { //false
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
echo '<h2>' . gettext('Clean folder img...') . '</h2>';
|
||||
|
||||
$originals = array_map('basename', glob('photos/img/*.{jpg,jpeg,JPG,JPEG,heic,HEIC,webp,WEBP}', GLOB_BRACE));
|
||||
$thumbs = array_map('basename', glob('photos/thumb/*.{jpg,jpeg,JPG,JPEG,heic,HEIC,webp,WEBP}', GLOB_BRACE));
|
||||
@@ -68,6 +50,7 @@ $thumbs = array_map('basename', glob('photos/thumb/*.{jpg,jpeg,JPG,JPEG,heic,HEI
|
||||
$missing_thumbs = array_diff($originals, $thumbs);
|
||||
$a = count($missing_thumbs);
|
||||
echo '<h3>' . gettext('Missing thumbs: ') . $a . '</h3>';
|
||||
|
||||
if ($a > 0) {
|
||||
echo '<h4>' . gettext('Create missing thumbs...') . '</h4>';
|
||||
|
||||
@@ -79,13 +62,15 @@ if ($a > 0) {
|
||||
|
||||
}
|
||||
|
||||
$missing_originals = array_diff($thumbs, $originals);
|
||||
$b = count($missing_originals);
|
||||
|
||||
$extra_thumbs = array_diff($thumbs, $originals);
|
||||
$b = count($extra_thumbs);
|
||||
echo '<h3>' . gettext('Extra thumbs: ') . $b . '</h3>';
|
||||
//_pr($extra_thumbs);
|
||||
if ($b > 0) {
|
||||
echo '<h4>' . gettext('Delete extra thumbs...') . '</h4>';
|
||||
|
||||
foreach($missing_originals as $thumb){
|
||||
foreach($extra_thumbs as $thumb){
|
||||
$file = $thumb_path . $thumb;
|
||||
if (unlink($file)) {
|
||||
echo $thumb . gettext(' was deleted successfully!') . '<br>';
|
||||
@@ -95,10 +80,8 @@ if ($b > 0) {
|
||||
}
|
||||
}
|
||||
|
||||
_pr($missing_thumbs);
|
||||
_pr($missing_originals);
|
||||
|
||||
echo '<h3>' . gettext('Compare folder img and daatabase...') . '</h3>';
|
||||
echo '<h2>' . gettext('Compare folder img and database...') . '</h2>';
|
||||
|
||||
try {
|
||||
$conn = new PDO("sqlite:db_photo.sqlite3");
|
||||
@@ -112,7 +95,6 @@ try {
|
||||
$result = $stmt->fetchAll(PDO::FETCH_CLASS);
|
||||
$rowcount = count($result);
|
||||
|
||||
//$conn = null;
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
echo $e->getMessage();
|
||||
@@ -122,47 +104,393 @@ try {
|
||||
$bdd = array();
|
||||
|
||||
foreach($result as $file) {
|
||||
//$img = $file->filename;
|
||||
$bdd[] = $file->filename;
|
||||
}
|
||||
|
||||
|
||||
$base = array_map('basename', $bdd);
|
||||
$missing_originals = array_diff($base, $originals);
|
||||
$c = count($missing_originals);
|
||||
echo count($base) . " entries in database". "<br />";
|
||||
echo count($originals) . " files on disk" . "<br />";
|
||||
|
||||
$extra_in_bdd= array_diff($base, $originals);
|
||||
$c = count($extra_in_bdd);
|
||||
|
||||
echo '<h3>' . gettext('Extra images in database: ') . $c . '</h3>';
|
||||
|
||||
if ($c > 0) {
|
||||
echo '<h4>' . gettext('Delete extra images in database...') . '</h4>';
|
||||
|
||||
//foreach($missing_originals as $img){
|
||||
foreach($missing_originals as $key => $img){
|
||||
echo $key;
|
||||
$query2 = "DELETE FROM photos WHERE id=:id";
|
||||
|
||||
$stmt=$conn->prepare($query2);
|
||||
$stmt->bindParam(':id',$key,PDO::PARAM_INT, 5);
|
||||
|
||||
if($stmt->execute()){
|
||||
echo "Successfully deleted record ";
|
||||
} else {
|
||||
print_r($sql->errorInfo());
|
||||
foreach($extra_in_bdd as $img){
|
||||
$file = $img_path . $img;
|
||||
$query4 = "DELETE FROM photos WHERE filename=:filename";
|
||||
$stmt = $conn->prepare($query4);
|
||||
$stmt->bindParam(':filename', $file);
|
||||
$result = $stmt->execute();
|
||||
if ($result) {
|
||||
echo $img . gettext(' has been deleted from database !') . "<br />";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//_pr($bdd);
|
||||
|
||||
//_pr($base);
|
||||
$missing_in_bdd = array_diff($originals, $base);
|
||||
$d = count($missing_in_bdd);
|
||||
|
||||
_pr($missing_originals);
|
||||
echo '<h3>' . gettext('Missing images in database: ') . $d . '</h3>';
|
||||
|
||||
/*
|
||||
foreach($fileList as $filename){
|
||||
echo $filename;
|
||||
if ($d > 0) {
|
||||
echo '<h4>' . gettext('Adding missing images in database...') . '</h4>';
|
||||
|
||||
$i = 1;
|
||||
$photos = array();
|
||||
|
||||
foreach($missing_in_bdd as $img){
|
||||
$file = $img_path . $img;
|
||||
$query4 = "INSERT INTO photos WHERE filename=:filename";
|
||||
|
||||
if ($exif = @exif_read_data($file, 0, true )) {
|
||||
|
||||
$mod = isset($exif['IFD0']['Model']) ? $exif['IFD0']['Model'] : '';
|
||||
|
||||
# YYYY-MM-DD HH:MM:SS.SSS - 2019:10:01 14:03:12
|
||||
$da = isset($exif['EXIF']['DateTimeOriginal']) ? $exif['EXIF']['DateTimeOriginal'] : '';
|
||||
|
||||
if (isset($exif['EXIF']['UndefinedTag:0xA434'])) {
|
||||
$w = $exif['EXIF']['UndefinedTag:0xA434'];
|
||||
|
||||
$arr = array("100.0 mm" => "EF100mm f/2.8 Macro USM", "100.0-400.0 mm" => "EF100-400mm f/4.5-5.6L IS USM", "140.0-560.0 mm" => "EF100-400mm f/4.5-5.6L IS USM +1.4x II", "17.0-40.0 mm" => "EF17-40mm f/4L USM", "24-70mm" => "SIGMA 24-70mm F2.8 EX DG", "70.0-200.0 mm" => "EF70-200mm f/4L USM", "10.0-22.0 mm" => "EF-S10-22mm f/3.5-4.5 USM", "500.0 mm" => "Sigma 500mm f/4.5 EX HSM ", "500mm" => "Sigma 500mm f/4.5 EX HSM ");
|
||||
|
||||
if (array_key_exists($w, $arr)) $obj= $arr[$w];
|
||||
else $obj = $w;
|
||||
|
||||
} else {
|
||||
$obj = '';
|
||||
}
|
||||
*/
|
||||
//_pr($fileList);
|
||||
|
||||
if (isset($exif['EXIF']['ExposureTime'])) {
|
||||
$q = explode('/', $exif['EXIF']['ExposureTime']);
|
||||
$sp = ($q[0] > 1) ? ($q[0] / $q[1]) . "s" : $exif['EXIF']['ExposureTime'];
|
||||
} else {
|
||||
$sp = '';
|
||||
}
|
||||
|
||||
$iso = isset($exif['EXIF']['ISOSpeedRatings']) ? $exif['EXIF']['ISOSpeedRatings'] : '';
|
||||
|
||||
if (isset($exif['EXIF']['MeteringMode'])) {
|
||||
$mm = $exif['EXIF']['MeteringMode'];
|
||||
|
||||
switch ($mm) {
|
||||
case 1: $mm = gettext("Average");
|
||||
break;
|
||||
case 2: $mm = gettext("Center-weighted average"); // Moy. à pred. centrale
|
||||
break;
|
||||
case 3: $mm = gettext("Spot");
|
||||
break;
|
||||
case 4: $mm = gettext("Multi-Spot");
|
||||
break;
|
||||
case 5: $mm = gettext("Pattern"); // Mesure évaluative
|
||||
break;
|
||||
case 6: $mm = gettext("Partial"); // Mesure sélective
|
||||
break;
|
||||
default: $mm = gettext("Unknown") . ': ' . $mm;
|
||||
// Evaluative Mesure évaluative
|
||||
// Centre-weighted Average Moy. à pred. centrale
|
||||
// Partial Mesure sélective
|
||||
// Spot Spot
|
||||
|
||||
// Pattern =Mesure évaluative (30D)
|
||||
// Average Mesure évaluative
|
||||
}
|
||||
|
||||
} else {
|
||||
$mm = '';
|
||||
}
|
||||
|
||||
if (isset($exif['EXIF']['Flash'])) {
|
||||
$fla = $exif['EXIF']['Flash'];
|
||||
|
||||
switch ($fla) {
|
||||
case 0: $fla = gettext("Off");
|
||||
break;
|
||||
case 1: $fla = gettext("Auto");
|
||||
break;
|
||||
case 2: $fla = gettext("On");
|
||||
break;
|
||||
case 3: $fla = gettext("Red Eye Reduction");
|
||||
break;
|
||||
case 4: $fla = gettext("Slow Synchro");
|
||||
break;
|
||||
case 5: $fla = gettext("Auto + Red Eye Reduction");
|
||||
break;
|
||||
case 6: $fla = gettext("On + Red Eye Reduction");
|
||||
break;
|
||||
case 16: $fla = gettext("External Flash");
|
||||
break;
|
||||
default: $fla = gettext("Unknown");
|
||||
}
|
||||
|
||||
} else {
|
||||
$fla = '';
|
||||
}
|
||||
|
||||
if (isset($exif['EXIF']['FocalLength'])) {
|
||||
$k = explode('/', $exif['EXIF']['FocalLength']);
|
||||
$fl = $k[0] . " mm";
|
||||
} else {
|
||||
$fl = '';
|
||||
}
|
||||
|
||||
|
||||
if (isset($exif['EXIF']['WhiteBalance'])) {
|
||||
$wb = $exif['EXIF']['WhiteBalance'];
|
||||
|
||||
switch ($wb) {
|
||||
case 0: $wb = gettext("Auto");
|
||||
break;
|
||||
case 1: $wb = gettext("Daylight");
|
||||
break;
|
||||
case 2: $wb = gettext("Cloudy");
|
||||
break;
|
||||
case 3: $wb = gettext("Tungsten");
|
||||
break;
|
||||
case 4: $wb = gettext("Fluorescent");
|
||||
break;
|
||||
case 5: $wb = gettext("Flash");
|
||||
break;
|
||||
case 6: $wb = gettext("Custom");
|
||||
break;
|
||||
case 7: $wb = gettext("Black & White");
|
||||
break;
|
||||
case 8: $wb = gettext("Shade");
|
||||
break;
|
||||
case 9: $wb = gettext("Manual Temperature (Kelvin)");
|
||||
break;
|
||||
default: $wb = gettext("Unknown");
|
||||
}
|
||||
|
||||
} else {
|
||||
$wb = '';
|
||||
}
|
||||
|
||||
if (isset($exif['EXIF']['ExposureProgram'])) {
|
||||
$ep = $exif['EXIF']['ExposureProgram'];
|
||||
|
||||
switch ($ep) {
|
||||
case 1: $ep = gettext('Manual');
|
||||
break;
|
||||
case 2: $ep = gettext('Program');
|
||||
break;
|
||||
case 3: $ep = gettext('Aperture Priority');
|
||||
break;
|
||||
case 4: $ep = gettext('Shutter Priority');
|
||||
break;
|
||||
case 5: $ep = gettext('Program Creative');
|
||||
break;
|
||||
case 6: $ep = gettext('Program Action');
|
||||
break;
|
||||
case 7: $ep = gettext('Portrait');
|
||||
break;
|
||||
case 8: $ep = gettext('Landscape');
|
||||
break;
|
||||
default: $ep = gettext('Unknown') . ': ' . $data;
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
$ep = '';
|
||||
}
|
||||
|
||||
$wi = isset($exif['COMPUTED']['Width']) ? $exif['COMPUTED']['Width'] : '';
|
||||
$he = isset($exif['COMPUTED']['Height']) ? $exif['COMPUTED']['Height'] : '';
|
||||
$ht = isset($exif['COMPUTED']['html']) ? $exif['COMPUTED']['html'] : '';
|
||||
$ap = isset($exif['COMPUTED']['ApertureFNumber']) ? $exif['COMPUTED']['ApertureFNumber'] : '';
|
||||
|
||||
$gps = get_gps($exif);
|
||||
|
||||
$photos[$i] = array(
|
||||
'filename' => $file,
|
||||
|
||||
'date' => $da,
|
||||
'lens' => $obj,
|
||||
'speed' => $sp,
|
||||
'iso' => $iso,
|
||||
|
||||
'width' => $wi,
|
||||
'height' => $he,
|
||||
'html' => $ht,
|
||||
'aperture' => $ap,
|
||||
|
||||
'model' => $mod,
|
||||
|
||||
'lat' => $gps['latitude'],
|
||||
'long' => $gps['longitude'],
|
||||
'alt' => $gps['altitude'],
|
||||
|
||||
'metering' => $mm,
|
||||
'flash' => $fla,
|
||||
'focal' => $fl,
|
||||
'wb' => $wb,
|
||||
'program' => $ep
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
if ($iptc = @getimagesize($file, $info)) {
|
||||
//_pr($iptc);
|
||||
if (isset($info["APP13"])) {
|
||||
$mots = "";
|
||||
$iptc = iptcparse ($info["APP13"]);
|
||||
$legende = (isset($iptc["2#120"][0])) ? $iptc["2#120"][0] : '';
|
||||
$copyright = (isset($iptc["2#116"][0])) ? $iptc["2#116"][0] : '';
|
||||
$title = (isset($iptc["2#105"][0])) ? $iptc["2#105"][0] : '';
|
||||
$creator = (isset($iptc["2#080"][0])) ? $iptc["2#080"][0] : '';
|
||||
$mots_cles = (isset($iptc["2#025"])) ? $iptc["2#025"] : '';
|
||||
if (!empty($mots_cles)) {
|
||||
foreach ($mots_cles as $key => $val) {
|
||||
$mots .= $val . ",";
|
||||
}
|
||||
$mots = substr($mots, 0, -1);
|
||||
}
|
||||
|
||||
$photos[$i]['legende'] = $legende;
|
||||
$photos[$i]['copyright'] = $copyright;
|
||||
$photos[$i]['title'] = $title;
|
||||
$photos[$i]['creator'] = $creator;
|
||||
$photos[$i]['mots_cles'] = $mots;
|
||||
}
|
||||
else {
|
||||
$photos[$i]['legende'] = '';
|
||||
$photos[$i]['copyright'] = '';
|
||||
$photos[$i]['title'] = '';
|
||||
$photos[$i]['creator'] = '';
|
||||
$photos[$i]['mots_cles'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
$query5 = "SELECT MAX(id) FROM photos";
|
||||
$stmt = $conn->prepare($query5);
|
||||
$stmt->execute();
|
||||
$resultat = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$avant = $resultat['MAX(id)'];
|
||||
|
||||
$nb_avant = (isset($avant)) ? $avant : 0;
|
||||
|
||||
|
||||
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)";
|
||||
|
||||
$stmt = $conn->prepare($query2);
|
||||
$stmt->bindParam(':filename', $file);
|
||||
$stmt->bindParam(':date', $da);
|
||||
$stmt->bindParam(':lens', $obj);
|
||||
$stmt->bindParam(':speed', $sp);
|
||||
$stmt->bindParam(':iso', $iso);
|
||||
$stmt->bindParam(':width', $wi);
|
||||
$stmt->bindParam(':height', $he);
|
||||
$stmt->bindParam(':html', $ht);
|
||||
$stmt->bindParam(':aperture', $ap);
|
||||
$stmt->bindParam(':model', $mod);
|
||||
$stmt->bindParam(':lat', $gps['latitude']);
|
||||
$stmt->bindParam(':long', $gps['longitude']);
|
||||
$stmt->bindParam(':alt', $gps['altitude']);
|
||||
|
||||
$stmt->bindParam(':legende', $leg);
|
||||
$stmt->bindParam(':copyright', $cop);
|
||||
$stmt->bindParam(':title', $tit);
|
||||
$stmt->bindParam(':creator', $crea);
|
||||
$stmt->bindParam(':keywords', $mot);
|
||||
|
||||
$stmt->bindParam(':metering', $mm);
|
||||
$stmt->bindParam(':flash', $fla);
|
||||
$stmt->bindParam(':focal', $fl);
|
||||
$stmt->bindParam(':wb', $wb);
|
||||
$stmt->bindParam(':program', $ep);
|
||||
|
||||
|
||||
if (isset($photos)) {
|
||||
foreach ($photos as $item) {
|
||||
$file = $item['filename'];
|
||||
$da = $item['date'];
|
||||
$obj = $item['lens'];
|
||||
$sp = $item['speed'];
|
||||
$iso = $item['iso'];
|
||||
$wi = $item['width'];
|
||||
$he = $item['height'];
|
||||
$ht = $item['html'];
|
||||
$ap = $item['aperture'];
|
||||
$mod = $item['model'];
|
||||
$gps['latitude'] = $item['lat'];
|
||||
$gps['longitude'] = $item['long'];
|
||||
$gps['altitude'] = $item['alt'];
|
||||
|
||||
$leg = $item['legende'];
|
||||
$cop = $item['copyright'];
|
||||
$tit = $item['title'];
|
||||
$crea = $item['creator'];
|
||||
$mot = $item['mots_cles'];
|
||||
|
||||
$mm = $item['metering'];
|
||||
$fla = $item['flash'];
|
||||
$fl = $item['focal'];
|
||||
$wb = $item['wb'];
|
||||
$ep = $item['program'];
|
||||
|
||||
create_thumb($th_w, $th_h, $file);
|
||||
|
||||
$stmt->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
|
||||
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";
|
||||
|
||||
$stmt = $conn->prepare($query4);
|
||||
$stmt->bindValue(1, $nb_avant, SQLITE3_INTEGER); // (1,3...) 1=1ere valeur 3=valeur
|
||||
$stmt->execute();
|
||||
|
||||
echo '<h3>' . gettext('Reading added photos') . ':</h3>';
|
||||
echo '<div id="add_to_bdd">';
|
||||
echo '<table class="styled-table">';
|
||||
echo '<thead>';
|
||||
echo '<th>' . gettext('Thumb') . '</th><th>' . gettext('Filename') . '</th><th>' . gettext('Date') . '</th><th>' . gettext('Lens') . '</th><th>' . gettext('Speed') . '</th><th>' . gettext('Iso') . '</th><th>' . gettext('Width') . '</th><th>' . gettext('Height') . '</th><th>' . gettext('Html') . '</th>';
|
||||
echo '<th>' . gettext('Aperture') . '</th><th>' . gettext('Model') . '</th><th>' . gettext('Latitude') . '</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 '</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>' . '<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;
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
$conn = null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//echo '<h3>' . gettext('Find duplicate images in database: ') . '</h3>';
|
||||
|
||||
?>
|
||||
|
||||
<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><em><small>© 2013-<?php echo date('Y'); ?> sur-le-sentier.fr</small></em></p>
|
||||
|
||||
|
||||
145
css/sls.css
145
css/sls.css
@@ -1,6 +1,18 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Ubuntu:wght@300&display=swap');
|
||||
|
||||
h1,
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
h1 {
|
||||
font-family: sans-serif;
|
||||
font-weight: 400;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h2, h3, h4 {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
p {
|
||||
text-align: center;
|
||||
}
|
||||
@@ -9,10 +21,31 @@ a:link, a:visited {
|
||||
color: #858585;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
a:hover {
|
||||
color: #373737;
|
||||
}
|
||||
|
||||
a:active {
|
||||
color: #c91717;
|
||||
}
|
||||
|
||||
pre {
|
||||
background: #f4f4f4;
|
||||
border: 1px solid #ddd;
|
||||
border-left: 3px solid #f36d33;
|
||||
color: #666;
|
||||
page-break-inside: avoid;
|
||||
font-family: monospace;
|
||||
font-size: 15px;
|
||||
line-height: 1.6;
|
||||
margin-bottom: 1.6em;
|
||||
max-width: 100%;
|
||||
overflow: auto;
|
||||
padding: 1em 1.5em;
|
||||
display: block;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
/*
|
||||
The grid itself needs only 4 CSS declarations:
|
||||
*/
|
||||
@@ -149,10 +182,6 @@ body {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
._h1 {
|
||||
font-family: sans-serif;
|
||||
font-weight: 400;
|
||||
}
|
||||
.month {
|
||||
font-family: sans-serif;
|
||||
font-weight: 400;
|
||||
@@ -186,11 +215,24 @@ body {
|
||||
color: #ffffff;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/*
|
||||
.sort a:link, .sort a:visited, .sort a:hover {
|
||||
color: #ffffff !important;
|
||||
text-decoration: none;
|
||||
}
|
||||
*/
|
||||
table a:visited {
|
||||
color: #ffffff;
|
||||
}
|
||||
table a:link {
|
||||
color: #ffffff;
|
||||
text-decoration: none;
|
||||
}
|
||||
table a:hover {
|
||||
color: #373737;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.styled-table th, .styled-table td {
|
||||
padding: 12px 15px;
|
||||
@@ -242,20 +284,16 @@ button.myButton{
|
||||
opacity: 0.4 !important;
|
||||
*/
|
||||
}
|
||||
.myForm {
|
||||
.indexForm {
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
left: 10px;
|
||||
/*
|
||||
color: #fff;
|
||||
font: 12px "Lucida Grande", Lucida, Verdana, sans-serif;
|
||||
|
||||
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=60)";
|
||||
filter:alpha(opacity=60);
|
||||
-moz-opacity:0.6;
|
||||
opacity: 0.6;
|
||||
*/
|
||||
}
|
||||
.myForm {
|
||||
/**/
|
||||
display: inline-block;
|
||||
margin-left: 16px;
|
||||
}
|
||||
|
||||
/*
|
||||
maps2.php
|
||||
@@ -277,3 +315,76 @@ maps2.php
|
||||
text-align: center;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
view
|
||||
*/
|
||||
|
||||
select, button {
|
||||
|
||||
/* styling */
|
||||
background-color: white;
|
||||
border: thin solid PaleGoldenrod;
|
||||
border-radius: 4px;
|
||||
display: inline-block;
|
||||
font: inherit;
|
||||
font-size: smaller;
|
||||
color: darkgray;
|
||||
line-height: 1em;
|
||||
|
||||
/* reset */
|
||||
|
||||
margin: 0;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
}
|
||||
|
||||
select {
|
||||
padding: 0.25em 3.5em 0.25em 1em;
|
||||
}
|
||||
/* arrows */
|
||||
|
||||
select.classic {
|
||||
background-image:
|
||||
linear-gradient(45deg, transparent 50%, tan 50%),
|
||||
linear-gradient(135deg, tan 50%, transparent 50%),
|
||||
linear-gradient(to right, Beige, Beige);
|
||||
background-position:
|
||||
calc(100% - 20px) calc(0.5em + 2px),
|
||||
calc(100% - 15px) calc(0.5em + 2px),
|
||||
100% 0;
|
||||
|
||||
background-size:
|
||||
5px 5px,
|
||||
5px 5px,
|
||||
2.5em 2.5em;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
select.classic:focus {
|
||||
background-image:
|
||||
linear-gradient(45deg, white 50%, transparent 50%),
|
||||
linear-gradient(135deg, transparent 50%, white 50%),
|
||||
linear-gradient(to right, silver, silver);
|
||||
background-position:
|
||||
calc(100% - 15px) 0.5em,
|
||||
calc(100% - 20px) 0.5em,
|
||||
100% 0;
|
||||
background-size:
|
||||
5px 5px,
|
||||
5px 5px,
|
||||
2.5em 2.5em;
|
||||
background-repeat: no-repeat;
|
||||
border-color: darkgrey;
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
select:-moz-focusring {
|
||||
color: transparent;
|
||||
text-shadow: 0 0 0 #000;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ $("#exemple, body").vegas({
|
||||
</div>
|
||||
|
||||
|
||||
<div class="myForm">
|
||||
<div class="indexForm">
|
||||
<form name="langSelect" action="index.php" method="get" >
|
||||
<select name="lang" id="lang" class="mySelect">
|
||||
<option value="">Language</option>
|
||||
|
||||
@@ -86,16 +86,12 @@ foreach($dir as $file){
|
||||
pathName()
|
||||
*/
|
||||
$file = $file->getpathName();
|
||||
|
||||
$x = in_bdd($file);
|
||||
|
||||
if ($x == false) { //false
|
||||
|
||||
if ($exif = @exif_read_data($file, 0, true )) {
|
||||
|
||||
if (($file == 'photos/img/4_2008.jpg') || ($file == 'photos/img/10_2020.jpg')) {
|
||||
_pr($exif);
|
||||
}
|
||||
$mod = isset($exif['IFD0']['Model']) ? $exif['IFD0']['Model'] : '';
|
||||
|
||||
# YYYY-MM-DD HH:MM:SS.SSS - 2019:10:01 14:03:12
|
||||
@@ -316,10 +312,10 @@ foreach($dir as $file){
|
||||
$copyright = (isset($iptc["2#116"][0])) ? $iptc["2#116"][0] : '';
|
||||
$title = (isset($iptc["2#105"][0])) ? $iptc["2#105"][0] : '';
|
||||
$creator = (isset($iptc["2#080"][0])) ? $iptc["2#080"][0] : '';
|
||||
$mots_cles = (isset($iptc["2#025"])) ? $iptc["2#025"] : '';
|
||||
$mots_cles = (isset($iptc["2#025"])) ? $iptc["2#025"] : ''; // array
|
||||
if (!empty($mots_cles)) {
|
||||
foreach ($mots_cles as $key => $val) {
|
||||
$mots .= $val . ",";
|
||||
$mots .= strtolower($val) . ",";
|
||||
}
|
||||
$mots = substr($mots, 0, -1);
|
||||
}
|
||||
|
||||
2
maps.php
2
maps.php
@@ -35,7 +35,7 @@
|
||||
<body>
|
||||
|
||||
|
||||
<h1 class="_h1"><?php echo gettext("Maps"); ?></h1>
|
||||
<h1><?php echo gettext("Maps"); ?></h1>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
205
view_bdd.php
205
view_bdd.php
@@ -29,15 +29,18 @@
|
||||
|
||||
<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"';
|
||||
?>
|
||||
|
||||
/*
|
||||
<th>' . gettext('Date') . '</th>
|
||||
<th>' . gettext('Lens') . '</th>
|
||||
<th>' . gettext('Iso') . '</th>
|
||||
<th>' . gettext('Model') . '</th>
|
||||
<th>' . gettext('Latitude') . '</th>
|
||||
*/
|
||||
<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>
|
||||
|
||||
<?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";
|
||||
//$conn4 = new PDO('sqlite:db_photo.sqlite3');
|
||||
$query4 = "SELECT COUNT(*) AS count FROM photos " . $req;
|
||||
|
||||
$stmt = $conn4->prepare($query4);
|
||||
$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();
|
||||
|
||||
174
view_bdd_get.php
174
view_bdd_get.php
@@ -1,174 +0,0 @@
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title><?php gettext('View photos in Sqlite base'); ?></title>
|
||||
|
||||
<link rel="stylesheet" href="css/sls.css" />
|
||||
<link rel='stylesheet' href='css/lc_lightbox.min.css' />
|
||||
<link rel='stylesheet' href='css/open_close_fx.css' />
|
||||
<link rel='stylesheet' href='css/minimal.css' />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
|
||||
<?php include 'functions.php';
|
||||
session_start();
|
||||
if($_SESSION['Active'] == false){ /* Redirects user to login.php if not logged in */
|
||||
header("location:admin/login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$domain = 'sentier';
|
||||
localize($domain);
|
||||
?>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
|
||||
$base = 'db_photo.sqlite3';
|
||||
|
||||
|
||||
if (!isset($_GET['page'])) $page = 1;
|
||||
else $page = intval($_GET['page']);
|
||||
|
||||
|
||||
|
||||
$dir = (new AdvancedFilesystemIterator('photos/img/'))->match('/heic|HEIC|jpg|jpeg|JPG|JPEG|webp|WEBP$/');
|
||||
|
||||
echo '<h3>' . count($dir) . gettext(' images found in folder') . ' <i>photos/img/</i> ...</h3>';
|
||||
|
||||
$conn = new PDO("sqlite:db_photo.sqlite3");
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
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 ?";
|
||||
|
||||
//$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->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>';
|
||||
$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"';
|
||||
|
||||
/*
|
||||
<th>' . gettext('Date') . '</th>
|
||||
<th>' . gettext('Lens') . '</th>
|
||||
<th>' . gettext('Iso') . '</th>
|
||||
<th>' . gettext('Model') . '</th>
|
||||
<th>' . gettext('Latitude') . '</th>
|
||||
*/
|
||||
echo '<div id="view_bdd">';
|
||||
echo '<table class="styled-table">';
|
||||
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('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>' . 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;
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
|
||||
<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,
|
||||
});
|
||||
|
||||
});
|
||||
*/
|
||||
</script>
|
||||
|
||||
<?php
|
||||
try {
|
||||
$conn4 = new PDO('sqlite:db_photo.sqlite3');
|
||||
$query4 = "SELECT COUNT(*) AS count FROM photos";
|
||||
|
||||
$stmt = $conn4->prepare($query4);
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$numRows = $result['count'];
|
||||
|
||||
$conn4 = null;
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
// calcul du nombre de pages (arrondi a l'entier supérieur)
|
||||
$nbpages = ceil($numRows / $perpage);
|
||||
$prec = $page - 1;
|
||||
$suiv = $page + 1;
|
||||
|
||||
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").'">« '.gettext("prev").'</a> ';
|
||||
for ($i = 1; $i <= $nbpages; $i++) {
|
||||
if ($i != $page) {
|
||||
echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$i.'&column='.$column.'&order='.$sort_order.'" title="'.gettext("Page").' '.$i.'">'.$i.' </a> ';
|
||||
}
|
||||
else {
|
||||
echo "<span class='gras'>".$i."</span> ";
|
||||
}
|
||||
}
|
||||
if ($page < $nbpages) echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$suiv.'&column='.$column.'&order='.$sort_order.'" title="'.gettext("Next Page").'">'.gettext("next").' »</a> ';
|
||||
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><em><small>© 2013-<?php echo date('Y'); ?> sur-le-sentier.fr</small></em></p>
|
||||
|
||||
<script src='js/lc_lightbox.min.js' type='text/javascript'></script>
|
||||
<script src='js/alloy_finger.min.js' type='text/javascript'></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user