diff --git a/functions.php b/functions.php index e1f7fc4..9747ea9 100755 --- a/functions.php +++ b/functions.php @@ -113,9 +113,267 @@ function mois2 ($mois) { /* -ce-mois-ci.php +Retourne la liste des images d'un album Zenphoto +page-ce-mois-ci.php:259 */ -function displayRetina ($filename,$album) { +function imagesFromZPAlbum ($album, $connexion) { + + $table = array(); + $table['images'] = $connexion['zp_prefix'] . "images"; + $table['albums'] = $connexion['zp_prefix'] . "albums"; + + // ****** Mysqli ****** // + /* + $conn = new mysqli($connexion['host'], $connexion['user'], $connexion['password'], $connexion['db_zenphoto']); + if ($conn->connect_error) { + trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR); + exit(); + } + $conn->set_charset("utf8"); + + $excquery = "SELECT `id` FROM `" . $table['albums'] . "` WHERE `folder` = '" . $album . "'"; + + if ($result = $conn->query($excquery)) { + $result->data_seek(0); + $row = $result->fetch_row(); + $id_album = $row[0]; + $result->close(); + } + + $pictquery = "SELECT `filename`, `EXIFModel`, `EXIFDateTimeOriginal`, `EXIFExposureTime`, `EXIFFNumber`, `EXIFISOSpeedRatings`, `EXIFFocalLength`, `EXIFGPSLatitude`, `EXIFGPSLatitudeRef`, `EXIFGPSLongitude`, `EXIFGPSLongitudeRef`, `EXIFGPSAltitude`, `EXIFGPSAltitudeRef`, `desc`, `title` FROM `" . $table['images'] . "` WHERE `albumid` = ? ORDER BY `date` DESC"; + + $stmt = $conn->prepare($pictquery); + if($stmt === false) { + trigger_error('Wrong SQL: ' . $pictquery . ' Error: ' . $conn->error, E_USER_ERROR); + } + else { + $stmt->bind_param('i', $id_album); + $stmt->execute(); + $fichier = $stmt->get_result()->fetch_all(); + } + $stmt->close(); + */ + /* + Array + ( + [0] => Array + ( + [0] => 11_2018.jpg + [1] => Canon EOS-1D Mark IV + [2] => 2018:11:04 11:05:09 + [3] => 1/2000 sec + [4] => f/7,1 + [5] => 500 + [6] => 700 mm + [7] => + [8] => + [9] => + [10] => + [11] => + [12] => + [13] => + [14] => 11_2018 + ) + */ + + // ****** /Mysqli ****** // + + + // ****** PDO ****** // + + $charset = 'utf8'; + $host = $connexion['host']; + $dbname = $connexion['db_zenphoto']; + + $dsn = "mysql:host=$host;dbname=$dbname;charset=$charset"; + $options = [ + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + PDO::ATTR_EMULATE_PREPARES => false, + ]; + try { + $pdo = new PDO($dsn, $connexion['user'], $connexion['password'], $options); + } catch (\PDOException $e) { + throw new \PDOException($e->getMessage(), (int)$e->getCode()); + } + + $excquery = "SELECT `id` FROM `" . $table['albums'] . "` WHERE `folder` = '" . $album . "'"; + $stmt = $pdo->query($excquery); + while ($row = $stmt->fetch()) { + //echo $row['id'] . "\n"; + $id_album = $row['id']; + } + + $pictquery = "SELECT `filename`, `EXIFModel`, `EXIFDateTimeOriginal`, `EXIFExposureTime`, `EXIFFNumber`, `EXIFISOSpeedRatings`, `EXIFFocalLength`, `EXIFLensInfo`, `EXIFGPSLatitude`, `EXIFGPSLatitudeRef`, `EXIFGPSLongitude`, `EXIFGPSLongitudeRef`, `EXIFGPSAltitude`, `EXIFGPSAltitudeRef`, `desc`, `title` FROM `" . $table['images'] . "` WHERE `albumid` = ? ORDER BY `date` DESC"; + + $stmt = $pdo->prepare($pictquery); + $stmt->execute([$id_album]); + $fichier = $stmt->fetchAll(PDO::FETCH_ASSOC); + + /* + + Ajouter: EXIFLensInfo + + + Array + ( + [0] => Array + ( + [filename] => 11_2018.jpg + [EXIFModel] => Canon EOS-1D Mark IV + [EXIFDateTimeOriginal] => 2018:11:04 11:05:09 + [EXIFExposureTime] => 1/2000 sec + [EXIFFNumber] => f/7,1 + [EXIFISOSpeedRatings] => 500 + [EXIFFocalLength] => 700 mm + [EXIFGPSLatitude] => + [EXIFGPSLatitudeRef] => + [EXIFGPSLongitude] => + [EXIFGPSLongitudeRef] => + [EXIFGPSAltitude] => + [EXIFGPSAltitudeRef] => + [desc] => + [title] => 11_2018 + ) + */ + + //preprint($fichier); + + // ****** /PDO ****** // + + return $fichier; + } + +/* +page-ce-mois-ci.php +*/ +function displayRetina ($file,$album) { + + global $ppage; + + //preprint($file); + + /* + Array + ( + [filename] => 10_2018.jpg + [EXIFModel] => Canon EOS 5D Mark III + [EXIFDateTimeOriginal] => 2018:10:17 19:09:12 + [EXIFExposureTime] => 1/250 sec + [EXIFFNumber] => f/4 + [EXIFISOSpeedRatings] => 4000 + [EXIFFocalLength] => 500 mm + [EXIFLensInfo] => EF500mm f/4L IS USM + [EXIFGPSLatitude] => + [EXIFGPSLatitudeRef] => + [EXIFGPSLongitude] => + [EXIFGPSLongitudeRef] => + [EXIFGPSAltitude] => + [EXIFGPSAltitudeRef] => + [desc] => + [title] => 10_2018 + ) + */ + + if ($ppage == "1") { + $fullpath = "../../zenphoto/"; + } + else { + $fullpath = "../../../zenphoto/"; + } + $name = explode(".", $file['filename']); + + $thumbpath = "../zenphoto/cache/" . $album . "/"; + $a = $path . $filename; + + $file_sd = $thumbpath . $name[0] . "_200_thumb.jpg"; + $file_hd = $thumbpath . $name[0] . "_400_thumb.jpg"; + +//echo $file_sd; +//echo $file_hd; + + /* + $file_sd = $path . $file[0] . "_180_watermark.jpg"; + $file_hd = $path . $file[0] . "_360_watermark.jpg"; + */ + + $th_sd = false; + $th_hd = false; + + $thumb = array(); + + if (file_exists($file_sd)) { + $th_sd = true; + $size_sd = getimagesize($file_sd, $info); + $thumb['sd'] = array( + 'url' => "../../" . $file_sd, + 'width' => $size_sd[0], + 'height' => $size_sd[1] + ); + } + if (file_exists($file_hd)) { + $th_hd = true; + $size_hd = getimagesize($file_hd, $info); + $thumb['hd'] = array( + 'url' => "../../" . $file_hd, + 'width' => $size_hd[0], + 'height' => $size_hd[1] + ); + } + + if (($th_sd == true) && ($th_hd == true)) { + $standard = $thumb['sd']['url'] . ' 200w, ' . $thumb['hd']['url'] . ' 400w'; + } + elseif ($th_sd == true) { + $standard = $thumb['sd']['url'] . ' 200w'; + } + elseif ($th_hd == true) { + $standard = $thumb['hd']['url'] . ' 400w'; + } + + + $display = '
'; + $display .= '
'; + $display .= ''; +/* + $display .= ''; + $display .= ''; + $display .= ''; + + $display .= ''; + $display .= ''; + $display .= ''; + + $display .= ''; + + $display .= ''; +*/ + $display .= ""; + + $display .= ''; + $display .= '
'; + $display .= '
'; + $display .= ''; + $display .= ''.date_archive($file['filename']).''; + $display .= '
'; + $display .= '
' . "\r\n"; + +//echo "display: " . $display; + + return $display; + } + + +function displayRetina_bak ($filename,$album) { global $ppage; @@ -216,7 +474,6 @@ function displayRetina ($filename,$album) { return $display; } - /* *functions.php - displayRetina() displayRetina() */ diff --git a/page-ce-mois-ci.php b/page-ce-mois-ci.php index 19937ba..70669a9 100755 --- a/page-ce-mois-ci.php +++ b/page-ce-mois-ci.php @@ -11,6 +11,7 @@ $root = $_SERVER['DOCUMENT_ROOT']; define('SERVERPATH',$root.'/zenphoto'); include('../photoblog/exifer/exif.php'); +require_once($_SERVER['DOCUMENT_ROOT'].'/Connections/cnx.php'); //nb d'archive par page $nb = 12; @@ -75,49 +76,51 @@ $bg_title_img = $kk_parallax[1]; - - - + 1000) { // HD - $hd = '../../zenphoto/cache/photos-du-mois/' . substr($tableau[$i], 0, strlen($tableau[$i]) - 4) . "_FULL_watermark.jpg"; + //$hd = '../../zenphoto/cache/photos-du-mois/' . substr($tableau[$i], 0, strlen($tableau[$i]) - 4) . "_FULL_watermark.jpg"; + $hd = $file; if (file_exists($hd)) { $size_hd = getimagesize($hd, $info_hd); $imgs['img_hd'] = array( - 'url' => $hd, + 'url' => "../" . $hd, 'width' => $size_hd[0], 'height' => $size_hd[1] ); } + /* else { $imgs['img_hd'] = array( 'url' => '../' . $photo_du_mois, @@ -125,24 +128,29 @@ $bg_title_img = $kk_parallax[1]; 'height' => $size[1] ); } + */ // SD - $sd = '../../zenphoto/cache/photos-du-mois/' . substr($tableau[$i], 0, strlen($tableau[$i]) - 4) . "_800_watermark.jpg"; + + // 12_2017_800_clicclac.jpg + + $sd = '../zenphoto/cache/photos-du-mois/' . substr($filename, 0, strlen($filename) - 4) . "_800" . $watermark . ".jpg"; if (file_exists($sd)) { $size_sd = getimagesize($sd, $info_sd); $imgs['img_sd'] = array( - 'url' => $sd, + 'url' => "../" . $sd, 'width' => $size_sd[0], 'height' => $size_sd[1] ); } } + else { // SD - $sd = '../../zenphoto/cache/photos-du-mois/' . substr($tableau[$i], 0, strlen($tableau[$i]) - 4) . "_800_watermark.jpg"; + $sd = '../zenphoto/cache/photos-du-mois/' . substr($filename, 0, strlen($filename) - 4) . "_800" . $watermark . ".jpg"; if (file_exists($sd)) { $size_sd = getimagesize($sd, $info_sd); $imgs['img_sd'] = array( - 'url' => $sd, + 'url' => "../" . $sd, 'width' => $size_sd[0], 'height' => $size_sd[1] ); @@ -154,18 +162,57 @@ $bg_title_img = $kk_parallax[1]; ); } // if ($size[0] > 1000) - $title = explode('.',$title); - $title = explode('_',$title[0]); - $title = mois2($title[0]) . ' ' . $title[1]; - $imgs['img_sd']['title'] = $title; + + foreach ($images_du_mois[$i] as $key => $val) { + $imgs[$key] = $val; + } - if (isset($info["APP13"])) { - $iptc = iptcparse($info["APP13"]); + // Ajouter les tags + + // Présentation Title et Desc + +//preprint($imgs); - if (isset($iptc['2#120'][0])) $legende = $iptc['2#120'][0]; - else $legende = ""; - if (isset($iptc['2#005'][0])) $titre = $iptc['2#005'][0]; - else $titre = ""; +/* +Array +( + [img_hd] => Array + ( + [url] => ../../zenphoto/albums/photos-du-mois/11_2018.jpg + [width] => 1600 + [height] => 1067 + ) + + [img_sd] => Array + ( + [url] => ../../zenphoto/cache/photos-du-mois/11_2018_800_clicclac.jpg + [width] => 800 + [height] => 534 + ) + + [filename] => 11_2018.jpg + [EXIFModel] => Canon EOS-1D Mark IV + [EXIFDateTimeOriginal] => 2018:11:04 11:05:09 + [EXIFExposureTime] => 1/2000 sec + [EXIFFNumber] => f/7,1 + [EXIFISOSpeedRatings] => 500 + [EXIFFocalLength] => 700 mm + [EXIFLensInfo] => EF500mm f/4L IS USM +1.4x + [EXIFGPSLatitude] => + [EXIFGPSLatitudeRef] => + [EXIFGPSLongitude] => + [EXIFGPSLongitudeRef] => + [EXIFGPSAltitude] => + [EXIFGPSAltitudeRef] => + [desc] => + [title] => 11_2018 + [exif] => Le 04.11.2018 à 11:05 - 1/2000 sec à f/7,1 - 500 ISO - Focale700 mm + [exif+] => Canon EOS-1D Mark IV - EF500mm f/4L IS USM +1.4x + [gps] => +) +*/ + +/* $keyword = ""; if (isset($iptc['2#025'])) { @@ -176,23 +223,21 @@ $bg_title_img = $kk_parallax[1]; $keyword = substr($keyword, 0, -2); } - $imgs['img_sd']['legende'] = $legende; - $imgs['img_sd']['titre'] = $titre; $imgs['img_sd']['keyword'] = $keyword; } - - $exifInfo = ""; - $exif_array = read_exif_data_raw($file,'EXIF'); - $exifInfo = __('The','toppic-child') . " " .date(__("F j, Y, g:i a",'toppic-child'),strtotime($exif_array['SubIFD']['DateTimeOriginal'])).' - '; - $exifInfo .= $exif_array['SubIFD']['ExposureTime']. __(' at ','toppic-child') .$exif_array['SubIFD']['FNumber'].' - ' .$exif_array['SubIFD']['ISOSpeedRatings'].' ISO - '. __('Focal','toppic-child') .$exif_array['SubIFD']['FocalLength']; - $imgs['img_sd']['exif'] = $exifInfo; +*/ + + $exifInfo = ""; + $exifInfo = __('The','toppic-child') . " " .date(__("F j, Y, g:i a",'toppic-child'),strtotime($imgs['EXIFDateTimeOriginal'])).' - '; + $exifInfo .= $imgs['EXIFExposureTime'] . __(' at ','toppic-child') . $imgs['EXIFFNumber'] .' - ' . $imgs['EXIFISOSpeedRatings'] .' ISO - ' . __('Focal','toppic-child') .$imgs['EXIFFocalLength']; + $imgs['exif'] = $exifInfo; + $imgs['exif+'] = $imgs['EXIFModel'] . ' - ' . $imgs['EXIFLensInfo']; + $imgs['gps'] = ''; - //preprint($exif_array); break; } $i++; } - //preprint($imgs); ?> @@ -202,42 +247,28 @@ $bg_title_img = $kk_parallax[1];
- -

Titre

-

Légende

- + +

+

+ " alt="Image du mois" title="" /--> - - - - - - - - - '; - ?> - - - + $display = ''; + $display .= ""; + $display .= ''; + + echo $display; + ?>
@@ -246,84 +277,13 @@ $bg_title_img = $kk_parallax[1];

Légende

-

+

- connect_error) { - trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR); - exit(); - } - $conn->set_charset("utf8"); - - $excquery = "SELECT `id` FROM `" . $table['albums'] . "` WHERE `folder` = '" . $album . "'"; - - if ($result = $conn->query($excquery)) { - $result->data_seek(0); - $row = $result->fetch_row(); - $id_album = $row[0]; - $result->close(); - } - - $conn->close(); - - // Récupérer toutes les fichiers de l'album 'photos-du-mois' ($fichier[]) - - $conn = new mysqli($dbhost, $dbuser, $dbpassword, $zptable); - if ($conn->connect_error) { - trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR); - exit(); - } - $conn->set_charset("utf8"); - - $pictquery = "SELECT `filename` FROM `" . $table['images'] . "` WHERE `albumid` = ? ORDER BY `date` DESC"; - - $stmt = $conn->prepare($pictquery); - //echo $pictquery; - if($stmt === false) { - trigger_error('Wrong SQL: ' . $pictquery . ' Error: ' . $conn->error, E_USER_ERROR); - } - else { - $stmt->bind_param('i', $id_album); - $stmt->execute(); - $stmt->bind_result($filename); - while ($stmt->fetch()) { - $fichier[] = $filename; - $i++; - //echo $filename; - } - } - $stmt->close(); - - // -?> - ? Utilisation: cliquer sur une vignette, puis....
"; $aide .= " -sur ordinateur: naviguer avec les touches flèches droite et gauche, quitter avec ESC.
"; @@ -336,15 +296,23 @@ $aide .= " -sur tablettes et smartphones: balayer l'écran avec un