forked from rebillar/site-accueil-insa
Improved photo navigation security
This commit is contained in:
parent
0455d642ab
commit
12e172c0c3
1 changed files with 17 additions and 4 deletions
21
photos.php
21
photos.php
|
@ -1,16 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
ob_start(); // Start reading html
|
ob_start(); // Start reading html
|
||||||
|
// Get active folder from url and prevent from seeing folders before photos/
|
||||||
function getActiveFolder()
|
function getActiveFolder()
|
||||||
{
|
{
|
||||||
if ($_GET['folder'] != "") {
|
$dir = $_GET['folder'];
|
||||||
return $_GET['folder'];
|
$folders = explode(DIRECTORY_SEPARATOR, $dir);
|
||||||
} else {
|
$currentPath = "";
|
||||||
return "photos/";
|
foreach ($folders as $value) {
|
||||||
|
if ($value != "..") {
|
||||||
|
$currentPath .= $value . DIRECTORY_SEPARATOR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return $currentPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get all directories in the specified path
|
||||||
function getDirectories($dir)
|
function getDirectories($dir)
|
||||||
{
|
{
|
||||||
|
$dir = "photos/".$dir;
|
||||||
$files = scandir($dir);
|
$files = scandir($dir);
|
||||||
$displayedItems = 0;
|
$displayedItems = 0;
|
||||||
foreach ($files as $key => $value) {
|
foreach ($files as $key => $value) {
|
||||||
|
@ -29,8 +36,10 @@ function getDirectories($dir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get all photos in the specified path
|
||||||
function getPhotos($dir)
|
function getPhotos($dir)
|
||||||
{
|
{
|
||||||
|
$dir = "photos/".$dir;
|
||||||
$files = scandir($dir);
|
$files = scandir($dir);
|
||||||
$displayedItems = 0;
|
$displayedItems = 0;
|
||||||
foreach ($files as $key => $value) {
|
foreach ($files as $key => $value) {
|
||||||
|
@ -51,10 +60,14 @@ function getPhotos($dir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Creates buttons representing the actual path for easier navigation
|
||||||
function generatePath($dir)
|
function generatePath($dir)
|
||||||
{
|
{
|
||||||
$folders = explode(DIRECTORY_SEPARATOR, $dir);
|
$folders = explode(DIRECTORY_SEPARATOR, $dir);
|
||||||
$currentPath = "";
|
$currentPath = "";
|
||||||
|
$pathTitle = "Menu";
|
||||||
|
$pathLink = "?folder=";
|
||||||
|
include("includes/photos/path_template.php");
|
||||||
foreach ($folders as $value) {
|
foreach ($folders as $value) {
|
||||||
if ($value != "") {
|
if ($value != "") {
|
||||||
$pathTitle = $value;
|
$pathTitle = $value;
|
||||||
|
|
Loading…
Reference in a new issue