Files
sls/photo-du-mois.php
Bruno21 b35196fdb8 Version 1.0
-déplacement des fichiers d’admin dans un dossier admin
-corrections dans la fonction data_for_lightbox($data). Celle-ci est maintenant toujours utilisé pour l’affichage des vignettes et des images dans la lightbox
-les chemins sont nettoyés avec 2 variables: $chemin pour les images, $base pour la base Sqlite
-corrections diverses
2025-02-13 10:07:21 +01:00

357 lines
12 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
session_start();
include 'i18n_setup.php';
/*include 'localize.php';
$domain = 'sentier';
localize($domain);
*/
include 'functions.php';
/*
_pr($_REQUEST); //
_pr($_SESSION); // [language] => de_DE
_pr($_POST); //
_pr($_GET); //
_pr($_COOKIE);
$locale = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']); // fr_FR
echo $locale;
*/
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Sur le sentier: la photos du mois">
<title><?php echo gettext("Picture of the month"); ?></title>
<meta name="msapplication-TileColor" content="#2b5797">
<meta name="msapplication-config" content="/icons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
<link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/icons/favicon-16x16.png">
<link rel="manifest" href="/icons/site.webmanifest">
<link rel="shortcut icon" href="/icons/favicon.ico">
<link rel="stylesheet" href="css/sls.css">
<link rel="stylesheet" href="lc-lightbox/css/lc_lightbox.min.css">
<link rel="stylesheet" href="lc-lightbox/css/open_close_fx.css">
<link rel="stylesheet" href="lc-lightbox/skins/minimal.css">
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
</head>
<body>
<h1 class="_h1"> <?php echo gettext("Picture of the month"); ?></h1>
<?php
if (!isset($_GET['page'])) $page = 1;
else $page = intval($_GET['page']);
?>
<?php
$chemin = 'photos/img/';
$base = 'db_photo.sqlite3';
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/" . $base)) {
try {
$conn4 = new PDO("sqlite:$base");
// WHERE id='26'
$query4 = "SELECT filename, filesize, dateoriginal, lens, speed, correctexpo, iso, usercomment, comment, model, metering, flash, focal, program, wb, mode, width, height, html, aperture, software, lat, long, alt, keywords, title, creator, city, department, code, country, copyright, legende FROM photos ORDER BY dateoriginal DESC LIMIT ? OFFSET ?";
//nb d'archive par page
$limit = 13;
$offset = $limit * ($page -1);
$stmt = $conn4->prepare($query4);
$stmt->execute(array($limit, $offset));
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$rowcount = count($result);
$conn4 = null;
}
catch(PDOException $e) {
echo $e->getMessage();
}
}
else exit("Database " . $base . " does not exist !");
//_pr($result);
?>
<p class="month"><?php echo month($result[0]['dateoriginal']); ?></p>
<?php
//_pr($result[0]);
//$thumbnail = host() . str_replace("img", "thumb", $chemin) . $result[0]['filename'];
//$full = host() . $chemin . $result[0]['filename'];
$lb = data_for_lightbox($result[0]);
//_pr($lb);
/*
$lightbox['title_thumb'] = $title_thumb;
$lightbox['exif'] = $exif;
$lightbox['title'] = $x;
$lightbox['legende'] = $y;
$lightbox['thumb'] = $thumb;
$lightbox['big'] = $big;
$lightbox['keywords'] = $keywords;
$lightbox['creator'] = $creator;
$lightbox['gps'] = $gps;
$lightbox['description'] = $description;
*/
echo '<div class="cadre" id="lcl_month">';
//echo '<a href ="' . $full . '" title="' . htmlspecialchars($lb['title']) . '" data-lcl-txt="' . htmlspecialchars($lb['description']) .'" data-lcl-author="' . htmlspecialchars($lb['creator']) . '">';
//echo '<img src="' . $full . '" alt="' . htmlspecialchars($lb['title']) . '" class="trois">';
echo '<a href ="' . $lb['big'] . '" title="' . htmlspecialchars($lb['title']) . '" data-lcl-txt="' . htmlspecialchars($lb['description']) .'" data-lcl-author="' . htmlspecialchars($lb['creator']) . '">';
echo '<img src="' . $lb['big'] . '" alt="' . htmlspecialchars($lb['title']) . '" class="trois">';
echo "</a>";
echo '</div>';
if (!empty($lb['title']) || !empty($lb['legende'])) {
?>
<p class="titrePhoto"><?php echo $lb['title']; ?></p>
<p class="legendePhoto"><?php echo $lb['legende']; ?></p>
<?php if (!empty($lb['gps']) && false) { ?>
<p class="titrePhoto">
<a href = "https://maps.google.com/maps?q=<?php echo $lb['gps']; ?>&t=&z=9&ie=UTF8&iwloc=&output=embed" title="Google Maps Iframe" data-lcl-txt="LC Lightbox can handle any iframe:&lt;br/&gt; for example you can also display websites and Google Documents &lt;em&gt;(then Word docs, PDFs, etc)&lt;/em&gt;" data-lcl-author="@sur-le-sentier.fr"><?php echo "\u{2693} "; ?></a>
</p>
<?php } ?>
<?php
/*
🌍
globe centré sur lEurope et lAfrique
Unicode: U+1F30D, UTF-8: F0 9F 8C 8D
⚓︎
ANCHOR
Unicode: U+2693 U+FE0E, UTF-8: E2 9A 93 EF B8 8E
*/
//echo "\u{1F30D} ";
/*
<!--
# Feature-Policy
<IfModule mod_headers.c>
Header set Feature-Policy "geolocation 'self'; vibrate 'none'"
</IfModule>
-->
*/
?>
<?php
}
if (!empty($lb['gps'])) {
$map = '<a href = "https://maps.google.com/maps?q=' . $lb['gps'] . '&t=&z=9&ie=UTF8&iwloc=&output=embed" title="' . $lb['title'] . '" data-lcl-txt="' . $lb['legende'] . '">' . " \u{30FB} \u{2693} " . '</a>';
}
else {
$map = '';
}
echo '<div class="exif" id="lcl_gm">';
echo $lb['exif'] . $map;
echo '</div>';
?>
<div class="myGallery" id="lcl_gallery">
<?php
for ($i = 1; $i <= ($rowcount -1); $i++) {
$date = $result[$i]['dateoriginal'];
//_pr($result[$i]);
//debug_to_console($result[$i]);
//$thumbnail = host() . str_replace("img", "thumb", $chemin) . $result[$i]['filename'];
//$full = host() . $chemin . $result[$i]['filename'];
$lb = data_for_lightbox($result[$i]);
//_pr($lb);
if (!empty($lb['gps'])) {
$map = '<a href = "https://maps.google.com/maps?q=' . $lb['gps'] . '&t=&z=9&ie=UTF8&iwloc=&output=embed" title="' . $lb['title'] . '" data-lcl-txt="' . $lb['legende'] . '">' . " \u{30FB} \u{2693} " . '</a>';
$meta = $lb['exif'] . $map;
} else {
$meta = '';
}
echo '<div class="item">';
echo '<a href ="' . $lb['big'] . '" title="' . htmlspecialchars($lb['title']) . '" data-lcl-txt="' . htmlspecialchars($lb['description']) . '" data-lcl-author="' . htmlspecialchars($lb['creator']) . '">';
echo '<img src="' . $lb['thumb'] . '" alt="' . htmlspecialchars($lb['title']) . '">';
echo "</a>";
echo '<span class="caption">' . month($date) . '</span>';
echo '</div>';
}
/*
$rowcount = 5 - 10 - 15 => add 0
$rowcount = 4 - 9 - 14 => add 1
$rowcount = 3 - 8 - 13 => add 2
$rowcount = 2 - 7 - 12 => add 3
$rowcount = 1 - 6 - 11 => add 4
*/
if ($rowcount % 4 == 0) $blank = 1;
elseif ($rowcount % 3 == 0) $blank = 2;
elseif ($rowcount % 2 == 0) $blank = 3;
elseif ($rowcount % 1 == 0) $blank = 4;
for ($i = 1; $i <= $blank; $i++) {
echo '<div class="item">';
echo '</div>';
}
?>
</div>
<script>
$(document).ready(function() {
var $obj = lc_lightbox('#lcl_gallery a', {
img_zoom : true, // whether to enable zooming system
author_by_txt : '<?php echo gettext("by"); ?>', // which text is used before the author name, by default is "by"
slideshow : true, // whether to enable slideshow
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
animation_time : 100,
slideshow_time : 4000, // durée de l'intervalle du diaporama
autoplay : false, // autoplay slideshow - bool
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
ol_opacity : 0.7, // overlay opacity / value between 0 and 1
ol_color : '#111', // background color of the overlay
ol_pattern : false, // overlay patterns - insert the pattern name or false
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
ins_close_pos : 'normal', // set closing button position for inner commands - normal/corner
nav_btn_pos : 'normal', // Régle les flèches et la position de lecture/pause. Options disponibles: normal|middle
txt_hidden : true, // whether to hide texts on lightbox opening - bool or int (related to browser's smaller side)
shox_title : true, // s'il faut afficher les titres
show_descr : true, // 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
autoplay_videos : false, // bool / whether to autoplay videos (NB: modern browsers ignore this for deeplinked elements. Not applied if video has poster)
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
});
var $obj = lc_lightbox('#lcl_month a', {
img_zoom : true,
deeplink : true,
open_close_time : 200,
ol_time_diff : 100,
wrap_class : 'lcl_zoomin_oc',
skin : 'minimal',
txt_hidden : true,
fullscreen : true,
fs_img_behavior : 'smart',
browser_fs_mode : true,
rclick_prevent : true,
});
var $obj3 = lc_lightbox('#lcl_gm a', {
img_zoom : true,
open_close_time : 100,
ol_time_diff : 100,
max_width : '65%',
max_height : '65%',
wrap_class : 'lcl_zoomin_oc',
skin : 'minimal',
data_position : 'rside',
cmd_position : 'inner',
show_title : true,
show_descr : true,
show_author : true,
fullscreen : true,
fs_img_behavior : 'smart',
browser_fs_mode : false,
touchswipe : 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 / 13);
$prec = $page - 1;
$suiv = $page + 1;
echo '<div class="navPage">' . gettext("Page") . ': ';
if ($page >= 2) echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$prec.'" title="'.gettext("Previous Page").'">&laquo; '.gettext("prev").'</a>&nbsp;';
for ($i = 1; $i <= $nbpages; $i++) {
if ($i != $page) {
echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$i.'" title="'.gettext("Page").' '.$i.'">'.$i.' </a>&nbsp;';
}
else {
echo "<span class='gras'>".$i."</span>&nbsp;&nbsp;";
}
}
if ($page < $nbpages) echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$suiv.'" title="'.gettext("Next Page").'">'.gettext("next").' &raquo;</a>&nbsp;';
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></p>
<p><em><small>&copy; 2013-<?php echo date('Y'); ?> sur-le-sentier.fr</small></em></p>
<script src='lc-lightbox/js/lc_lightbox.min.js'></script>
<script src='lc-lightbox/lib/AlloyFinger/alloy_finger.min.js'></script>
</body>
</html>