350 lines
11 KiB
PHP
Executable File
350 lines
11 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Template Name: Ce-mois bis
|
|
*
|
|
* @package WordPress
|
|
* @subpackage Twenty_Ten
|
|
* @since Twenty Ten 1.0
|
|
*/
|
|
|
|
|
|
get_header();
|
|
|
|
$root = $_SERVER['DOCUMENT_ROOT'];
|
|
define('SERVERPATH',$root.'/zenphoto');
|
|
include('../photoblog/exifer/exif.php');
|
|
|
|
//nb d'archive par page
|
|
$nb = 12;
|
|
global $ppage;
|
|
|
|
$url = $_SERVER[REDIRECT_URL];
|
|
$a = explode("/", $url);
|
|
$pages = end($a);
|
|
$pages = prev($a);
|
|
|
|
if ($pages != get_page_uri()) $ppage = $pages;
|
|
else $ppage = "1";
|
|
|
|
?>
|
|
|
|
<div class="content">
|
|
<div class="container">
|
|
<div class="post_content">
|
|
<?php if(have_posts()): the_post(); ?>
|
|
<article class="post_box" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
|
<h1><?php the_title(); ?></h1>
|
|
<?php the_content(); ?>
|
|
</article>
|
|
|
|
<?php
|
|
$mois = date('n');
|
|
$an = date('Y');
|
|
$image = $mois . '_' . $an . '.jpg';
|
|
$annee = $an;
|
|
|
|
// nom des fichiers: 7_2009.jpg et non pas 07_2009.jpg
|
|
|
|
for ($i = 0; $i <= 11 ; $i++) {
|
|
$a = ($mois - $i);
|
|
if ($a < 1) {
|
|
$a = (12 + $a);
|
|
$annee = $an - 1;
|
|
}
|
|
$tableau[$i] = $a . '_' . $annee . '.jpg';
|
|
}
|
|
|
|
$i = 0;
|
|
while ($i < 13) {
|
|
$file = '../zenphoto/albums/photos-du-mois/' . $tableau[$i];
|
|
//echo $file;
|
|
|
|
if (file_exists($file)) {
|
|
$photo_du_mois = $file;
|
|
$title = $tableau[$i];
|
|
|
|
$size = getimagesize($photo_du_mois, $info);
|
|
//preprint($size);
|
|
|
|
if ($size[0] > 1000) {
|
|
// HD
|
|
$hd = '../../zenphoto/cache/photos-du-mois/' . substr($tableau[$i], 0, strlen($tableau[$i]) - 4) . "_FULL_watermark.jpg";
|
|
if (file_exists($hd)) {
|
|
$size_hd = getimagesize($hd, $info_hd);
|
|
$imgs['img_hd'] = array(
|
|
'url' => $hd,
|
|
'width' => $size_hd[0],
|
|
'height' => $size_hd[1]
|
|
);
|
|
}
|
|
else {
|
|
$imgs['img_hd'] = array(
|
|
'url' => '../' . $photo_du_mois,
|
|
'width' => $size[0],
|
|
'height' => $size[1]
|
|
);
|
|
}
|
|
// SD
|
|
$sd = '../../zenphoto/cache/photos-du-mois/' . substr($tableau[$i], 0, strlen($tableau[$i]) - 4) . "_800_watermark.jpg";
|
|
if (file_exists($sd)) {
|
|
$size_sd = getimagesize($sd, $info_sd);
|
|
$imgs['img_sd'] = array(
|
|
'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";
|
|
if (file_exists($sd)) {
|
|
$size_sd = getimagesize($sd, $info_sd);
|
|
$imgs['img_sd'] = array(
|
|
'url' => $sd,
|
|
'width' => $size_sd[0],
|
|
'height' => $size_sd[1]
|
|
);
|
|
}
|
|
$imgs['img_hd'] = array(
|
|
'url' => "",
|
|
'width' => "",
|
|
'height' => ""
|
|
);
|
|
} // if ($size[0] > 1000)
|
|
|
|
$title = explode('.',$title);
|
|
$title = explode('_',$title[0]);
|
|
$title = mois2($title[0]) . ' ' . $title[1];
|
|
$imgs['img_sd']['title'] = $title;
|
|
|
|
if (isset($info["APP13"])) {
|
|
$iptc = iptcparse($info["APP13"]);
|
|
|
|
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 = "";
|
|
|
|
$keyword = "";
|
|
if (isset($iptc['2#025'])) {
|
|
foreach ($iptc['2#025'] as $key => $val) {
|
|
$keyword .= '<a href="' . $host . '/zenphoto/index.php?p=search&words=' . $val . '" title="Tag > ' . $val . '" rel="tag">' . $val . '</a>';
|
|
$keyword .= ', ';
|
|
}
|
|
$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,0);
|
|
$exifInfo = __('The','CreatorThemeRes-child') . " " .date(__("F j, Y, g:i a",'CreatorThemeRes-child'),strtotime($exif_array['SubIFD']['DateTimeOriginal'])).' - ';
|
|
$exifInfo .= $exif_array['SubIFD']['ExposureTime']. __(' at ','CreatorThemeRes-child') .$exif_array['SubIFD']['FNumber'].' - ' .$exif_array['SubIFD']['ISOSpeedRatings'].' ISO - '. __('Focal','CreatorThemeRes-child') .$exif_array['SubIFD']['FocalLength'];
|
|
$imgs['img_sd']['exif'] = $exifInfo;
|
|
|
|
|
|
break;
|
|
}
|
|
$i++;
|
|
}
|
|
//preprint($imgs);
|
|
|
|
?>
|
|
|
|
<?php if ($ppage == "1") { ?>
|
|
|
|
<div class="cadre">
|
|
|
|
<?php if (($imgs['img_sd']['titre'] != "") || ($imgs['img_sd']['legende'] != "")) { ?>
|
|
<p class="titrePhoto"><?php echo $imgs['img_sd']['titre']; ?>Titre</p>
|
|
<p class="legendePhoto"><?php echo $imgs['img_sd']['legende']; ?>Légende</p>
|
|
<?php } ?>
|
|
|
|
<!--img src="watermark2.php?src=<?php echo $photo_du_mois; ?>" alt="Image du mois" title="<?php echo $title; ?>" <?php echo $size[3]; ?> /-->
|
|
|
|
<!-- Retina -->
|
|
<?php
|
|
if (($imgs['img_sd']['url'] != "") && ($imgs['img_hd']['url'] != "")) {
|
|
$standard_source = $imgs['img_sd']['url'] . ', ' . $imgs['img_hd']['url'] . ' 2x';
|
|
//echo "1";
|
|
}
|
|
else if ($imgs['img_sd']['url'] != "") {
|
|
$standard_source = $imgs['img_sd']['url'];
|
|
//echo "2";
|
|
}
|
|
else if ($imgs['img_hd']['url'] != "") {
|
|
$standard_source = $imgs['img_hd']['url'] . ' 2x';
|
|
//echo "3";
|
|
}
|
|
//echo $standard_source;
|
|
?>
|
|
|
|
<picture data-picture data-alt="">
|
|
<!--[if IE 9]><video style="display: none;"><![endif]-->
|
|
<source class="image_standard" srcset="<?php echo $standard_source; ?>">
|
|
<!--source class="image_medium" srcset="" media="(max-width: 767px)">
|
|
<source class="image_small" srcset="" media="(max-width: 767px)"-->
|
|
<!--[if IE 9]></video><![endif]-->
|
|
<?php
|
|
echo '<img srcset="' . $imgs['img_sd']['url'] . '" alt="" width="'. $imgs['img_sd']['width'] . '" height="'. $imgs['img_sd']['height'] .'" />';
|
|
?>
|
|
</picture>
|
|
|
|
<!-- /Retina -->
|
|
|
|
</div><!-- /cadre -->
|
|
|
|
<?php if (($imgs['img_sd']['titre'] != "") || ($imgs['img_sd']['legende'] != "")) { ?>
|
|
<p class="titrePhoto"><?php echo $imgs['img_sd']['titre']; ?>Titre</p>
|
|
<p class="legendePhoto"><?php echo $imgs['img_sd']['legende']; ?>Légende</p>
|
|
<?php } ?>
|
|
|
|
<p class="exifs"><?php echo $imgs['img_sd']['exif']; ?></p>
|
|
|
|
<?php } ?>
|
|
|
|
<?php
|
|
require_once($_SERVER['DOCUMENT_ROOT'].'/Connections/cnx.php');
|
|
|
|
$album = 'photos-du-mois'; //Photos du mois
|
|
$table = array();
|
|
if ($_SERVER['HTTP_HOST'] == "macbook-pro.local") {
|
|
$table['images'] = ".images";
|
|
$table['albums'] = ".albums";
|
|
}
|
|
/*
|
|
if ($_SERVER['HTTP_HOST'] == "clicclac.info") {
|
|
$table['images'] = "zp_images";
|
|
$table['albums'] = "zp_albums";
|
|
}
|
|
*/
|
|
if ($_SERVER['HTTP_HOST'] == "clicclac.info") {
|
|
$table['images'] = "zenphoto_images";
|
|
$table['albums'] = "zenphoto_albums";
|
|
}
|
|
|
|
// Récupérer l'ID de l'album 'photos-du-mois' ($id_album)
|
|
$i = 0;
|
|
$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");
|
|
|
|
$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();
|
|
|
|
//
|
|
?>
|
|
|
|
<?php
|
|
$aide = "<span class='aide'> ? </span><b>Utilisation:</b> cliquer sur une vignette, puis....<br />";
|
|
$aide .= " <b><i>-sur ordinateur:</i></b> naviguer avec les touches flèches droite et gauche, quitter avec ESC.<br />";
|
|
$aide .= " <b><i>-sur tablettes et smartphones:</i></b> balayer l'écran avec un doigt vers la droite ou vers la gauche, ou naviguer avec les touches flèches droite et gauche. Cliquer sur la X pour quitter.";
|
|
?>
|
|
|
|
<div id="archive">
|
|
<p style="clear: both; "></p>
|
|
<h4><?php echo gettext("Archives"); ?> (<abbr title="<?php echo $aide; ?>" rel="tooltip"> ? </abbr>)</h4>
|
|
<!--h4><?php echo gettext("Archives"); ?> <span class='aide'><a href="#" title="<?php echo $aide; ?>" class="tooltip"><span title="<?php echo gettext("Help"); ?>">( ? )</span></a></span></h4-->
|
|
|
|
<?php
|
|
$debut = (($ppage - 1) * $nb) +1; // page 1: 2, page 2: 14, page 3: 26
|
|
$fin = ($debut + $nb) - 1;
|
|
|
|
for ($j=$debut; $j<=$fin; $j++) {
|
|
|
|
if ($j <= count($fichier)-1) echo displayRetina($fichier[$j],$album);
|
|
if ($j+1 <= count($fichier)-1) echo displayRetina($fichier[$j+1],$album);
|
|
if ($j+2 <= count($fichier)-1) echo displayRetina($fichier[$j+2],$album);
|
|
|
|
$j = $j + 2;
|
|
}
|
|
?>
|
|
|
|
<p style="clear: both; "></p>
|
|
|
|
|
|
<div class="blog-pagination">
|
|
|
|
<?php
|
|
/**/
|
|
// calcul du nombre de pages (arrondi a l'entier superieur)
|
|
$nbpages = ceil(count($fichier) / 12);
|
|
$prec = $ppage - 1;
|
|
$suiv = $ppage + 1;
|
|
|
|
if ($ppage >= 2) echo '<a class="prev page-numbers" href="'.$_SERVER['REQUEST_URI'].'?page='.$prec.'" title="'.gettext("Previous Page").'"> ← </a> ';
|
|
|
|
for ($i = 1; $i <= $nbpages; $i++) {
|
|
if ($i != $ppage) {
|
|
echo '<a class="page-numbers" href="'.$_SERVER['REQUEST_URI'].'?page='.$i.'" title="'.gettext("Page").' '.$i.'">'.$i.' </a> ';
|
|
}
|
|
else {
|
|
echo "<span class='current page-numbers'>".$i."</span> ";
|
|
}
|
|
}
|
|
|
|
if ($page < $nbpages) echo '<a class="next page-numbers" href="'.$_SERVER['REQUEST_URI'].'?page='.$suiv.'" title="'.gettext("Next Page").'"> → </a> ';
|
|
|
|
?>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="clear"></div>
|
|
<?php if ( comments_open() || '0' != get_comments_number() ) : ?>
|
|
<div class="home_blog_box">
|
|
|
|
</div>
|
|
<?php endif;
|
|
endif;
|
|
?>
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
get_footer( 'page' );
|
|
?>
|