2018-03-25 13:22:28 +02:00
|
|
|
<?php
|
2018-03-25 14:19:53 +02:00
|
|
|
ob_start(); // Start reading html
|
2018-04-22 19:46:59 +02:00
|
|
|
|
|
|
|
define("urlParam", "path");
|
|
|
|
|
|
|
|
// Get active path from url and prevent from seeing folders before photos/
|
|
|
|
function getActivePath()
|
2018-03-25 14:19:53 +02:00
|
|
|
{
|
2018-04-22 19:46:59 +02:00
|
|
|
$dir = $_GET[urlParam];
|
2018-04-19 08:47:19 +02:00
|
|
|
$folders = explode(DIRECTORY_SEPARATOR, $dir);
|
|
|
|
$currentPath = "";
|
|
|
|
foreach ($folders as $value) {
|
2018-04-22 19:46:59 +02:00
|
|
|
if ($value != ".." && $value != "." && $value != "") {
|
|
|
|
$currentPath .= DIRECTORY_SEPARATOR.$value;
|
2018-04-19 08:47:19 +02:00
|
|
|
}
|
2018-03-25 13:22:28 +02:00
|
|
|
}
|
2018-04-19 08:47:19 +02:00
|
|
|
return $currentPath;
|
2018-03-25 14:19:53 +02:00
|
|
|
}
|
2018-03-25 13:22:28 +02:00
|
|
|
|
2018-04-22 19:46:59 +02:00
|
|
|
// Get active folder from the active path
|
|
|
|
function GetActiveFolder($path) {
|
|
|
|
$dir = explode(DIRECTORY_SEPARATOR, $path);
|
|
|
|
return $dir[sizeof($dir) - 1]; // Last item after /
|
|
|
|
}
|
|
|
|
|
|
|
|
function isAlbumAvailable($path) {
|
|
|
|
$dir = "photos".$path;
|
|
|
|
$files = scandir($dir);
|
|
|
|
$valid = false;
|
|
|
|
foreach ($files as $key => $value) {
|
|
|
|
$path = realpath($dir.DIRECTORY_SEPARATOR.$value);
|
|
|
|
if (!is_dir($path)) {
|
|
|
|
$valid = pathinfo($path, PATHINFO_EXTENSION) == "zip";
|
|
|
|
if ($valid)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-19 08:47:19 +02:00
|
|
|
// Get all directories in the specified path
|
2018-03-25 14:19:53 +02:00
|
|
|
function getDirectories($dir)
|
|
|
|
{
|
2018-04-22 19:46:59 +02:00
|
|
|
$dir = "photos".$dir;
|
2018-03-25 14:19:53 +02:00
|
|
|
$files = scandir($dir);
|
|
|
|
$displayedItems = 0;
|
|
|
|
foreach ($files as $key => $value) {
|
|
|
|
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
|
|
|
|
if (is_dir($path) && $value != "." && $value != "..") {
|
|
|
|
$folderTitle = $value;
|
2018-04-22 19:46:59 +02:00
|
|
|
$folderLink = "?".urlParam."=".getActivePath().DIRECTORY_SEPARATOR.$value;
|
2018-03-25 14:19:53 +02:00
|
|
|
include("includes/photos/folder_template.php");
|
|
|
|
$displayedItems++;
|
2018-03-25 13:22:28 +02:00
|
|
|
}
|
|
|
|
}
|
2018-03-25 14:19:53 +02:00
|
|
|
if ($displayedItems == 0) {
|
|
|
|
$placeHolder = "Pas d'autres albums !";
|
|
|
|
include("includes/photos/place_holder.php");
|
|
|
|
}
|
|
|
|
}
|
2018-03-25 13:22:28 +02:00
|
|
|
|
2018-04-19 08:47:19 +02:00
|
|
|
// Get all photos in the specified path
|
2018-03-25 14:19:53 +02:00
|
|
|
function getPhotos($dir)
|
|
|
|
{
|
2018-04-23 09:52:46 +02:00
|
|
|
$dir = "photos_thumb".$dir;
|
2018-03-25 14:19:53 +02:00
|
|
|
$files = scandir($dir);
|
|
|
|
$displayedItems = 0;
|
|
|
|
foreach ($files as $key => $value) {
|
2018-04-22 19:46:59 +02:00
|
|
|
$path = realpath($dir.DIRECTORY_SEPARATOR.$value);
|
2018-03-25 14:19:53 +02:00
|
|
|
if (!is_dir($path)) {
|
|
|
|
$ext = pathinfo($path, PATHINFO_EXTENSION);
|
2018-04-23 12:37:45 +02:00
|
|
|
if ($ext == "jpg" || $ext == "jpeg" || $ext == "png") {
|
2018-04-22 19:46:59 +02:00
|
|
|
$imageSrc = $dir.DIRECTORY_SEPARATOR.$value;
|
|
|
|
$imageId = "photo-".$displayedItems;
|
2018-03-25 14:19:53 +02:00
|
|
|
include("includes/photos/photo_template.php");
|
|
|
|
$displayedItems++;
|
2018-03-25 13:22:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-25 14:19:53 +02:00
|
|
|
if ($displayedItems == 0) {
|
|
|
|
$placeHolder = "Pas de photos ici !";
|
|
|
|
include("includes/photos/place_holder.php");
|
|
|
|
}
|
|
|
|
}
|
2018-03-25 13:22:28 +02:00
|
|
|
|
2018-04-19 08:47:19 +02:00
|
|
|
// Creates buttons representing the actual path for easier navigation
|
2018-03-25 14:19:53 +02:00
|
|
|
function generatePath($dir)
|
|
|
|
{
|
|
|
|
$folders = explode(DIRECTORY_SEPARATOR, $dir);
|
|
|
|
$currentPath = "";
|
2018-04-19 08:47:19 +02:00
|
|
|
$pathTitle = "Menu";
|
2018-04-22 19:46:59 +02:00
|
|
|
$pathLink = "?".urlParam."=";
|
2018-04-19 08:47:19 +02:00
|
|
|
include("includes/photos/path_template.php");
|
2018-03-25 14:19:53 +02:00
|
|
|
foreach ($folders as $value) {
|
|
|
|
if ($value != "") {
|
|
|
|
$pathTitle = $value;
|
2018-04-22 19:46:59 +02:00
|
|
|
$currentPath .= DIRECTORY_SEPARATOR.$value;
|
|
|
|
$pathLink = "?".urlParam."=".$currentPath;
|
2018-03-25 14:19:53 +02:00
|
|
|
include("includes/photos/path_template.php");
|
2018-03-25 13:22:28 +02:00
|
|
|
}
|
|
|
|
}
|
2018-03-25 14:19:53 +02:00
|
|
|
}
|
|
|
|
|
2018-03-25 13:22:28 +02:00
|
|
|
?>
|
2018-04-21 15:20:18 +02:00
|
|
|
<div id="photo_overlay" style="display:none">
|
|
|
|
|
|
|
|
<img src="" id="img_big" onclick="toggleFullscreen()">
|
|
|
|
<div id="close_back" onclick="closeBig()"></div>
|
2018-04-23 12:04:40 +02:00
|
|
|
<div id="loading" onclick="closeBig()">
|
|
|
|
<i class="fas fa-spinner fa-spin"></i>
|
|
|
|
</div>
|
|
|
|
|
2018-04-21 15:20:18 +02:00
|
|
|
<div id="photo_buttons">
|
|
|
|
<i id="right" class="fas fa-arrow-right" onclick="displayNext(1)"></i>
|
|
|
|
<i id="left" class="fas fa-arrow-left" onclick="displayNext(-1)"></i>
|
|
|
|
<div id="photo_control">
|
|
|
|
<i id="close" class="fas fa-times" onclick="closeBig()"></i>
|
2018-04-22 11:37:22 +02:00
|
|
|
<a id="img_big_download" download="" href="">
|
|
|
|
<i id="download" class="fas fa-download"></i>
|
|
|
|
</a>
|
2018-04-21 15:20:18 +02:00
|
|
|
<a href="" id="img_big_link">
|
|
|
|
<i id="fullscreen" class="fas fa-expand-arrows-alt" ></i>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-03-25 13:22:28 +02:00
|
|
|
</div>
|
|
|
|
|
2018-04-23 16:18:38 +02:00
|
|
|
<h1 id="photos_title">Photos</h1>
|
2018-03-25 13:22:28 +02:00
|
|
|
<p>Cliquez sur le dossier de votre choix pour afficher les photos</p>
|
|
|
|
<ul class="photos_path">
|
2018-04-21 15:20:18 +02:00
|
|
|
<li><p>Chemin : </p></li>
|
2018-03-25 13:22:28 +02:00
|
|
|
<?php
|
2018-04-22 19:46:59 +02:00
|
|
|
generatePath(getActivePath());
|
2018-03-25 13:22:28 +02:00
|
|
|
?>
|
|
|
|
</ul>
|
|
|
|
<div class="photos_folder">
|
|
|
|
<?php
|
2018-04-22 19:46:59 +02:00
|
|
|
getDirectories(getActivePath());
|
2018-03-25 13:22:28 +02:00
|
|
|
?>
|
|
|
|
</div>
|
2018-04-22 19:46:59 +02:00
|
|
|
<?php if(isAlbumAvailable(getActivePath())): ?>
|
|
|
|
<a download="" href="photos<?php echo getActivePath().DIRECTORY_SEPARATOR.GetActiveFolder(getActivePath())?>.zip" id="download_album">
|
|
|
|
<i class="fas fa-download"></i>
|
|
|
|
<p>Télécharger l'album</p>
|
|
|
|
</a>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
2018-03-25 13:22:28 +02:00
|
|
|
<div class="photos">
|
|
|
|
<?php
|
2018-04-22 19:46:59 +02:00
|
|
|
getPhotos(getActivePath());
|
2018-03-25 13:22:28 +02:00
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
<script src="assets/scripts/photosScript.js"></script>
|
|
|
|
<?php
|
2018-03-25 14:19:53 +02:00
|
|
|
$pageContent = ob_get_clean(); // Store html content in variable
|
|
|
|
include("template.php"); // Display template with variable content
|
2018-03-25 13:22:28 +02:00
|
|
|
?>
|