";
$x .= print_r($s, 1);
$x .= "";
if ($return) return $x;
else print $x;
}
function displayRetina ($filename,$album) {
// 6_2012.jpg
// 4_2014_180_thumb.jpg 4_2014_360_thumb.jpg
$path = "../../../../zenphoto/cache/" . $album . "/";
$file = explode(".", $filename);
//$a = $path . $filename;
//echo $a. " ";
$file_sd = $path . $file[0] . "_180_thumb.jpg";
$file_hd = $path . $file[0] . "_360_thumb.jpg";
/*
$file_sd = $path . $file[0] . "_180_watermark.jpg";
$file_hd = $path . $file[0] . "_360_watermark.jpg";
*/
//
$th_sd = false;
$th_hd = false;
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]
);
}
//preprint($thumb);
if (($th_sd == true) && ($th_hd == true)) {
$standard = $thumb['sd']['url'] . ', ' . $thumb['hd']['url'] . ' 2x';
}
elseif ($th_sd == true) {
$standard = $thumb['sd']['url'];
}
elseif ($th_hd == true) {
$standard = $thumb['hd']['url'] . ' 2x';
}
/*
$display = '
';
$display .= '
';
$display .= '
';
$display .= '
';
$display .= '';
$display .= '';
$display .= '';
$display .= ' ';
$display .= ' ';
$display .= '';
$display .= '
';
$display .= '
';
$display .= '
';
$display .= '
'.date_archive($filename).' ';
$display .= '
';
$display .= '
';
*/
$display = '';
$display .= '
';
$display .= '
';
$display .= '';
$display .= ' ';
$display .= ' ';
$display .= '
';
$display .= '
';
$display .= '
';
$display .= ' '.date_archive($filename).'';
$display .= ' ';
$display .= '
';
return $display;
}
function date_archive ($chaine) {
$pieces = explode(".", $chaine);
$b = explode("_", $pieces[0]);
$mois = $b[0];
$an = $b[1];
$chaine = mois2($mois) . ' '. $an;
return $chaine;
}
function mois2 ($mois) {
switch ($mois)
{
case 00:
$mois = "00";
break;
case 1:
$mois = gettext('January');
break;
case 2:
$mois = gettext('February');
break;
case 3:
$mois = gettext('March');
break;
case 4:
$mois = gettext('April');
break;
case 5:
$mois = gettext('May');
break;
case 6:
$mois = gettext('June');
break;
case 7:
$mois = gettext('July');
break;
case 8:
$mois = gettext('August');
break;
case 9:
$mois = gettext('September');
break;
case 10:
$mois = gettext('October');
break;
case 11:
$mois = gettext('November');
break;
case 12:
$mois = gettext('December');
break;
}
return $mois;
}
//continue only if $_POST is set and it is a Ajax request
if(isset($_POST) && isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
//include("config.inc.php"); //include config file
//require_once($_SERVER['DOCUMENT_ROOT'].'/Connections/cnx.php');
$db_host = 'localhost';
$db_username = 'root';
$db_password = 'sncfp1p2';
$db_name = 'zenphoto';
$zptable = 'zenphoto';
$album = 'photos-du-mois'; //Photos du mois
$item_per_page = 12; //item to display per page
$table = array();
if ($_SERVER['HTTP_HOST'] == "macbook-pro.local") {
$table['images'] = ".images";
$table['albums'] = ".albums";
}
if ($_SERVER['HTTP_HOST'] == "clicclac.info") {
$table['images'] = "zenphoto_images";
$table['albums'] = "zenphoto_albums";
}
$mysqli = new mysqli($db_host, $db_username, $db_password, $db_name);
//Output any connection error
if ($mysqli->connect_error) {
die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}
// Récupérer l'ID de l'album 'photos-du-mois' ($id_album)
$i = 0;
$conn = new mysqli($db_host, $db_username, $db_password, $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();
//Get page number from Ajax POST
if(isset($_POST["page"])){
$page_number = filter_var($_POST["page"], FILTER_SANITIZE_NUMBER_INT, FILTER_FLAG_STRIP_HIGH); //filter number
if(!is_numeric($page_number)){die('Invalid page number!');} //incase of invalid page number
}else{
$page_number = 1; //if there's no page number, set it to 1
}
//get total number of records from database for pagination
//$results = $mysqli->query("SELECT COUNT(*) FROM paginate");
$results = $mysqli->query("SELECT COUNT(*) FROM `" . $table['images'] . "` WHERE `albumid` = $id_album ");
$get_total_rows = $results->fetch_row(); //hold total records in variable
//break records into pages
$total_pages = ceil($get_total_rows[0]/$item_per_page);
//get starting position to fetch the records
$page_position = (($page_number-1) * $item_per_page);
//Limit our results within a specified range.
$results = $mysqli->prepare("SELECT `filename` FROM `" . $table['images'] . "` WHERE `albumid` = ? ORDER BY `date` DESC LIMIT $page_position, $item_per_page");
$results->bind_param('i', $id_album);
$results->execute(); //Execute prepared Query
$results->bind_result($filename); //bind variables to prepared statement
//Display records fetched from database.
//echo '';
while($results->fetch()){ //fetch values
/*
echo '';
echo $filename;
echo ' ';
*/
echo displayRetina($filename,$album);
/*
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);
//echo $fichier[$j];
$j = $j + 2;
*/
}
//echo ' ';
echo '';
/* We call the pagination function here to generate Pagination link for us.
As you can see I have passed several parameters to the function. */
echo paginate_function($item_per_page, $page_number, $get_total_rows[0], $total_pages);
echo '
';
echo '
';
exit;
}
################ pagination function #########################################
function paginate_function($item_per_page, $current_page, $total_records, $total_pages)
{
$pagination = '';
if($total_pages > 0 && $total_pages != 1 && $current_page <= $total_pages){ //verify total pages and current page number
$pagination .= '';
}
return $pagination; //return pagination links
}
?>