Files
camera-gallery/src/includes/admin_actions.php
2025-10-21 17:53:37 +01:00

50 lines
1.4 KiB
PHP

<?php
// includes/admin_actions.php
require_once __DIR__ . '/config.php';
session_start();
if (empty($_SESSION['is_admin'])) {
http_response_code(403);
exit('Access denied');
}
$action = $_GET['action'] ?? '';
switch ($action) {
case 'rebuild_gallery':
require_once __DIR__ . '/api.php';
echo "✅ Gallery cache rebuilt successfully.";
break;
case 'rebuild_exif':
require_once __DIR__ . '/exif_helper.php';
$dir = $CONFIG['gallery_dir'];
$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir));
$count = 0;
foreach ($rii as $file) {
if ($file->isFile() && preg_match('/\.jpe?g$/i', $file->getFilename())) {
get_exif_cached($file->getPathname(), $CONFIG['exif_dir'], 0);
$count++;
}
}
echo "✅ Rebuilt EXIF cache for {$count} images.";
break;
case 'clean_thumbs':
$thumb_dir = $CONFIG['thumb_dir'];
$removed = 0;
foreach (glob($thumb_dir . '/*.jpg') as $t) {
unlink($t);
$removed++;
}
echo "🧹 Removed {$removed} thumbnails.";
break;
case 'restart_php':
shell_exec('pgrep php-fpm | xargs kill -USR2 2>/dev/null');
echo "🔄 PHP-FPM reload signal sent.";
break;
default:
echo "Unknown action.";
}