Sindbad~EG File Manager

Current Path : /usr/home/beeson/public_html/michaelbeeson_old/photos/Africa2023/
Upload File :
Current File : /usr/home/beeson/public_html/michaelbeeson_old/photos/Africa2023/index.php

<?php
// Directory containing your images and videos
$directory = './';

// Get all files in the directory
$files = scandir($directory);

// Filter out files with specific extensions
$allowedExtensions = ['jpg', 'jpeg', 'png', 'gif', 'mov'];
$mediaFiles = [];
foreach ($files as $file) {
    $ext = pathinfo($file, PATHINFO_EXTENSION);
    if (in_array($ext, $allowedExtensions)) {
        $mediaFiles[] = $file;
    }
}

// Get the current image index from the query parameter
$currentImageIndex = isset($_GET['image']) ? intval($_GET['image']) : 0;

// Ensure the index is within bounds
if ($currentImageIndex < 0) {
    $currentImageIndex = 0;
} elseif ($currentImageIndex >= count($mediaFiles)) {
    $currentImageIndex = count($mediaFiles) - 1;
}

// Get the current media file
$currentMediaFile = $mediaFiles[$currentImageIndex];

// Calculate the previous and next indexes
$prevImageIndex = ($currentImageIndex > 0) ? $currentImageIndex - 1 : count($mediaFiles) - 1;
$nextImageIndex = ($currentImageIndex < count($mediaFiles) - 1) ? $currentImageIndex + 1 : 0;

?>

<!DOCTYPE html>
<html>
<head>
    <title>Image Viewer</title>
</head>
<body>
    <h1>Pictures from Africa</h1>
    <div>
        <a href="?image=<?= $prevImageIndex ?>">&lt; Previous</a>
        <img src="<?= $currentMediaFile ?>" alt="<?= $currentMediaFile ?>" style="max-width: 80%;">
        <a href="?image=<?= $nextImageIndex ?>">Next &gt;</a>
    </div>
</body>
</html>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists