[ 'page_title' => 'Διαχείριση Themes - Hockey CMS', 'header_title' => '🎨 Διαχείριση Εμφάνισης (Themes)', 'upload_title' => 'Μεταφόρτωση Νέου Theme (.zip)', 'choose_zip' => 'Επιλέξτε αρχείο Zip Θέματος', 'btn_upload' => 'Ανέβασμα & Εγκατάσταση', 'list_title' => 'Εγκατεστημένα Themes', 'th_name' => 'Όνομα Φακέλου Theme', 'th_status' => 'Κατάσταση', 'th_action' => 'Ενέργεια', 'badge_active' => 'Ενεργό', 'badge_inactive' => 'Ανενεργό', 'btn_activate' => 'Ενεργοποίηση', 'btn_delete' => 'Διαγραφή', 'in_use' => 'Σε χρήση', 'msg_upload_ok' => 'Το θέμα ανέβηκε και αποσυμπιέστηκε επιτυχώς!', 'msg_err_read' => 'Αποτυχία: Δεν ήταν δυνατή η ανάγνωση του αρχείου ZIP.', 'msg_err_ext' => 'Επιτρέπονται μόνο αρχεία .zip', 'msg_err_upload' => 'Σφάλμα κατά το ανέβασμα του αρχείου.', 'msg_act_ok' => 'Το ενεργό θέμα άλλαξε επιτυχώς!', 'msg_err_del_def' => 'Δεν μπορείτε να διαγράψετε το προεπιλεγμένο θέμα (default).', 'msg_err_del_act' => 'Δεν μπορείτε να διαγράψετε το θέμα που είναι αυτή τη στιγμή ενεργό. Ενεργοποιήστε πρώτα ένα άλλο.', 'msg_del_ok' => 'Το θέμα διαγράφηκε επιτυχώς!', 'msg_err_perms' => 'Σφάλμα κατά τη διαγραφή. Ελέγξτε τα δικαιώματα (permissions).' ], 'en' => [ 'page_title' => 'Theme Management - Hockey CMS', 'header_title' => '🎨 Appearance Management (Themes)', 'upload_title' => 'Upload New Theme (.zip)', 'choose_zip' => 'Select Theme Zip File', 'btn_upload' => 'Upload & Install', 'list_title' => 'Installed Themes', 'th_name' => 'Theme Folder Name', 'th_status' => 'Status', 'th_action' => 'Action', 'badge_active' => 'Active', 'badge_inactive' => 'Inactive', 'btn_activate' => 'Activate', 'btn_delete' => 'Delete', 'in_use' => 'In Use', 'msg_upload_ok' => 'Theme uploaded and extracted successfully!', 'msg_err_read' => 'Failure: Could not read ZIP file.', 'msg_err_ext' => 'Only .zip files are allowed.', 'msg_err_upload' => 'Error uploading file.', 'msg_act_ok' => 'Active theme changed successfully!', 'msg_err_del_def' => 'You cannot delete the default theme.', 'msg_err_del_act' => 'You cannot delete the currently active theme. Activate another one first.', 'msg_del_ok' => 'Theme deleted successfully!', 'msg_err_perms' => 'Error deleting files. Check permissions.' ] ]; $t = $translations[$current_lang]; header('Content-Type: text/html; charset=utf-8'); $message = '';$themes_dir = __DIR__ . '/../themes/'; function deleteDirectory($dir) { if (!file_exists($dir)) { return true; } if (!is_dir($dir)) { return unlink($dir); } foreach (scandir($dir) as$item) { if ($item == '.' or$item == '..') { continue; } if (!deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) { return false; } } return rmdir($dir); } try { $pdo->exec("CREATE TABLE IF NOT EXISTS settings (`key` VARCHAR(50) PRIMARY KEY, `value` TEXT NOT NULL)"); } catch (Exception $e) {} $stmt =$pdo->prepare("SELECT value FROM settings WHERE `key` = 'active_theme'"); $stmt->execute(); $active_theme =$stmt->fetchColumn(); if (!$active_theme) {$active_theme = 'default'; } if ($_SERVER['REQUEST_METHOD'] === 'POST' and isset($_FILES['theme_zip'])) { if ($_FILES['theme_zip']['error'] == 0) { $file_name =$_FILES['theme_zip']['name']; $file_tmp =$_FILES['theme_zip']['tmp_name']; $ext = strtolower(pathinfo($file_name, PATHINFO_EXTENSION)); if ($ext === 'zip') {$zip = new ZipArchive; if ($zip->open($file_tmp) === TRUE) {$theme_name = pathinfo($file_name, PATHINFO_FILENAME);$target_path = $themes_dir .$theme_name; if (!is_dir($target_path)) { mkdir($target_path, 0755, true); } $zip->extractTo($target_path); $zip->close();$message = "
{$t['msg_upload_ok']}
"; } else { $message = "
{$t['msg_err_read']}
"; } } else { $message = "
{$t['msg_err_ext']}
"; } } else { $message = "
{$t['msg_err_upload']}
"; } } if (isset($_GET['activate'])) { $new_theme = basename($_GET['activate']); if (is_dir($themes_dir .$new_theme)) { $stmt =$pdo->prepare("REPLACE INTO settings (`key`, `value`) VALUES ('active_theme', ?)"); $stmt->execute([$new_theme]); $active_theme =$new_theme; $message = "
{$t['msg_act_ok']}
"; } } if (isset($_GET['delete'])) { $theme_to_delete = basename($_GET['delete']); if ($theme_to_delete === 'default') {$message = "
{$t['msg_err_del_def']}
"; } elseif ($theme_to_delete === $active_theme) {$message = "
{$t['msg_err_del_act']}
"; } else { $delete_path = $themes_dir .$theme_to_delete; if (is_dir($delete_path)) { if (deleteDirectory($delete_path)) {$message = "
{$t['msg_del_ok']}
"; } else { $message = "
{$t['msg_err_perms']}
"; } } } } $available_themes = []; if (is_dir($themes_dir)) { $scan = scandir($themes_dir); foreach ($scan as$folder) { if ($folder !== '.' and$folder !== '..' and is_dir($themes_dir .$folder)) { $available_themes[] =$folder; } } } ?> <?php echo $t['page_title']; ?>