diff --git a/zanzara.php b/zanzara.php index 875ea4e..22377fa 100644 --- a/zanzara.php +++ b/zanzara.php @@ -12,26 +12,18 @@ $config = [ /** * Scansiona ricorsivamente le directory per trovare i file mp3 - * - * @param string $dir Directory da scansionare - * @param array $config Configurazione - * @return array Array di date valide (formato YYYYMMDD) */ function findValidDates($dir, $config) { $validDates = []; - - // Costruisci il percorso completo $fullPath = $config['base_dir'] . DIRECTORY_SEPARATOR . $dir; if (!is_dir($fullPath)) { return $validDates; } - // Scansiona tutte le sottodirectory (anni) $years = scandir($fullPath); foreach ($years as $year) { - // Salta . e .. e verifica che sia una directory anno valida if ($year === '.' || $year === '..' || !preg_match('/^\d{4}$/', $year)) { continue; } @@ -42,18 +34,15 @@ function findValidDates($dir, $config) { continue; } - // Scansiona i file nella directory dell'anno $files = scandir($yearPath); foreach ($files as $file) { - // Verifica se il file corrisponde al pattern if (preg_match($config['file_pattern'], $file, $matches)) { $validDates[] = $matches[1]; } } } - // Ordina le date in ordine cronologico sort($validDates); return $validDates; @@ -63,7 +52,6 @@ function findValidDates($dir, $config) { * Ottiene le date valide con cache */ function getValidDates($config) { - // Verifica se usare la cache $useCache = false; if (file_exists($config['cache_file'])) { $cacheAge = time() - filemtime($config['cache_file']); @@ -73,13 +61,10 @@ function getValidDates($config) { } if ($useCache) { - // Usa i dati dalla cache return json_decode(file_get_contents($config['cache_file']), true); } else { - // Scansiona le directory $validDates = findValidDates($config['dirfiles'], $config); - // Salva nella cache (se la directory cache esiste) $cacheDir = dirname($config['cache_file']); if (is_dir($cacheDir) || @mkdir($cacheDir, 0755, true)) { file_put_contents($config['cache_file'], json_encode($validDates)); @@ -89,9 +74,7 @@ function getValidDates($config) { } } -// Funzione per validare e formattare la data function validateDate($date) { - // Verifica se la data è nel formato YYYYMMDD if (!preg_match('/^\d{8}$/', $date)) { return false; } @@ -100,11 +83,9 @@ function validateDate($date) { $month = substr($date, 4, 2); $day = substr($date, 6, 2); - // Verifica se è una data valida return checkdate($month, $day, $year) ? $date : false; } -// Funzione per generare il percorso del file function generateFilePath($date, $config) { $year = substr($date, 0, 4); @@ -168,14 +149,12 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { min-height: 100vh; display: flex; flex-direction: column; - /* Disabilita selezione testo per sicurezza aggiuntiva */ -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } - /* Permetti selezione solo negli input */ input[type="text"] { -webkit-user-select: text; -moz-user-select: text; @@ -256,6 +235,7 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { transform: scale(1.05); } + /* MODIFICA: font più grande e data in evidenza */ .episode-info { background-color: #e8f4f8; color: #2c5282; @@ -270,10 +250,9 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { min-width: 400px; margin-left: auto; margin-right: auto; + font-size: 1.4rem; } - - input[type="text"] { border: 1px solid #ccc; border-radius: 4px; @@ -297,7 +276,6 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { margin-top: 40px; } - /* Stili specifici dell'applicazione */ .container { width: 100%; max-width: 800px; @@ -354,14 +332,12 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { margin-top: 20px; } - /* PLAYER AUDIO CUSTOM SEMPLICE */ - - /* Nascondi il player nativo */ + /* PLAYER AUDIO CUSTOM */ + audio { display: none; } - /* Container del player custom */ .custom-audio-player { background-color: #f8f9fa; border: 1px solid #dee2e6; @@ -373,7 +349,6 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { box-shadow: 0 2px 4px rgba(0,0,0,0.1); } - /* Layout principale centrato */ .player-layout { display: flex; flex-direction: column; @@ -381,14 +356,12 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { gap: 20px; } - /* Controlli principali con navigazione */ .main-controls { display: flex; align-items: center; gap: 15px; } - /* Pulsanti di navigazione */ .nav-btn { width: 50px; height: 50px; @@ -420,7 +393,14 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { pointer-events: none; } - /* Pulsante Play/Pause */ + .seek-btn { + background-color: #4169E1; + } + + .seek-btn:hover:not(:disabled) { + background-color: #1E90FF; + } + .play-pause-btn { width: 70px; height: 70px; @@ -451,7 +431,6 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { pointer-events: none; } - /* Container per barra del progresso e tempi */ .progress-container { width: 100%; display: flex; @@ -459,7 +438,6 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { gap: 10px; } - /* Container dei tempi con data */ .time-info { display: flex; justify-content: space-between; @@ -467,7 +445,6 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { width: 100%; } - /* Display del tempo */ .time-display { font-size: 18px; font-weight: 600; @@ -475,19 +452,15 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { font-variant-numeric: tabular-nums; } - /* Barra del progresso più alta */ .progress-bar { width: 100%; - height: 40px; /* Altezza totale con padding */ + height: 40px; cursor: pointer; position: relative; overflow: visible; - /* Padding per area cliccabile più grande */ padding: 10px 0; - /* Rimuovo il background dal contenitore principale */ } - /* Sfondo grigio della barra */ .progress-bar::before { content: ''; position: absolute; @@ -514,12 +487,11 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { width: 0%; transition: background-color 0.3s ease; position: absolute; - top: 10px; /* Allineato perfettamente con ::before */ + top: 10px; left: 0; pointer-events: none; } - /* Indicatore sulla barra più grande */ .progress-fill::after { content: ''; position: absolute; @@ -536,29 +508,11 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { pointer-events: none; } - /* Stato durante il dragging */ .dragging .progress-fill::after { transform: translateY(-50%) scale(1.3); box-shadow: 0 4px 10px rgba(0,0,0,0.4); } - /* Container dei tempi */ - .time-info { - display: flex; - justify-content: space-between; - align-items: center; - width: 100%; - } - - /* Display del tempo */ - .time-display { - font-size: 18px; - font-weight: 600; - color: #333; - font-variant-numeric: tabular-nums; - } - - /* Pulsante Share inline */ .share-btn-inline { background-color: #6c757d; color: white; @@ -587,7 +541,6 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { fill: currentColor; } - /* Messaggio di conferma */ .share-success { position: fixed; top: 50%; @@ -608,12 +561,10 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { opacity: 0.9; } - /* Stato buffering */ .buffering .play-pause-btn { animation: pulse 1.5s ease-in-out infinite; } - /* Icone play/pause */ .play-icon { display: block; } @@ -630,9 +581,6 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { display: block; } - - - /* Stili per il calendario */ .ui-datepicker td.available a { background-color: #90EE90 !important; color: #000 !important; @@ -643,7 +591,6 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { color: #999 !important; } - /* Stili per le statistiche */ .stats { margin-top: 40px; padding: 20px; @@ -689,7 +636,6 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { color: #666; } - /* Tooltip per scorciatoie */ .shortcuts-info { position: fixed; bottom: 20px; @@ -732,11 +678,9 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { flex-direction: column; gap: 10px; align-items: stretch; - min-width: auto; /* Rimuovo min-width su mobile */ + min-width: auto; } - - .form-group button { width: 100%; padding: 12px; @@ -756,12 +700,10 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { order: 2; } - - .episode-info { padding: 10px 15px; - font-size: 14px; - min-width: auto; /* Rimuovo min-width su mobile */ + font-size: 1.2rem; + min-width: auto; } .share-btn-inline { @@ -786,7 +728,6 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { line-height: 22px; } - /* Player custom su mobile */ .custom-audio-player { padding: 20px; margin: 15px 0; @@ -867,7 +808,6 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { } } - /* Media query per schermi molto piccoli */ @media (max-width: 380px) { h1 { font-size: 1.3rem; @@ -922,18 +862,15 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') {
0) { @@ -942,7 +879,6 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { } } - // Determina il valore da mostrare nell'input $inputValue = ''; if (isset($_POST['datepicker']) && !empty($_POST['datepicker'])) { $inputValue = $_POST['datepicker']; @@ -973,7 +909,6 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { '; if (file_exists($paths['local_path'])) { - // File trovato $year = substr($selectedDate, 0, 4); $month = substr($selectedDate, 4, 2); $day = substr($selectedDate, 6, 2); $formattedDate = sprintf("%s/%s/%s", $day, $month, $year); - // Ottieni dimensione file $fileSize = filesize($paths['local_path']); $fileSizeMB = round($fileSize / 1024 / 1024, 1); - // Trova puntata precedente e successiva $validDates = getValidDates($config); $currentIndex = array_search($selectedDate, $validDates); $prevDate = ($currentIndex > 0) ? $validDates[$currentIndex - 1] : null; $nextDate = ($currentIndex < count($validDates) - 1) ? $validDates[$currentIndex + 1] : null; - // Mostra se è una puntata random + // MODIFICA: data grande e leggibile, MB in piccolo if (isset($_POST['random']) && $_POST['random'] == '1') { - echo '

🎲 Random episode • ' . htmlspecialchars($formattedDate) . ' • ' . $fileSizeMB . ' MB

'; + echo '

🎲 ' . htmlspecialchars($formattedDate) . ' • ' . $fileSizeMB . ' MB

'; } else { - echo '

Selected episode • ' . htmlspecialchars($formattedDate) . ' • ' . $fileSizeMB . ' MB

'; + echo '

' . htmlspecialchars($formattedDate) . ' • ' . $fileSizeMB . ' MB

'; } // Audio player custom @@ -1011,14 +943,11 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { echo ''; - - // Layout principale + echo '
'; - - // Controlli principali con navigazione + echo '
'; - - // Pulsante precedente + if ($prevDate) { echo ''; } - - // Pulsante Play/Pause + + echo ''; + echo ''; - - // Pulsante successivo + + echo ''; + if ($nextDate) { echo ''; } - - echo '
'; // Chiude main-controls - - // Container progresso + + echo '
'; // main-controls + echo '
'; echo '
@@ -1075,11 +1015,10 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { echo '0:00'; echo '
'; echo '
'; - - echo ''; // Chiude player-layout - echo ''; // Chiude custom-audio-player - // JavaScript per il player + echo ''; // player-layout + echo ''; // custom-audio-player + echo ''; - // Mostra link download solo se configurato if ($config['show_download_link']) { echo '

Or download directly: @@ -1369,7 +1282,6 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') {

'; } } else { - // File non trovato echo '

File not found for date: ' . htmlspecialchars($selectedDate) . '

'; } @@ -1382,7 +1294,6 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { } } - // Mostra statistiche $validDates = getValidDates($config); $totalFiles = count($validDates); if ($totalFiles > 0) { @@ -1395,13 +1306,10 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') { echo '

First episode: ' . substr($firstDate, 6, 2) . '/' . substr($firstDate, 4, 2) . '/' . substr($firstDate, 0, 4) . '

'; echo '

Last episode: ' . substr($lastDate, 6, 2) . '/' . substr($lastDate, 4, 2) . '/' . substr($lastDate, 0, 4) . '

'; - // Conta file per anno $yearCount = []; foreach ($validDates as $date) { $year = substr($date, 0, 4); - if (!isset($yearCount[$year])) { - $yearCount[$year] = 0; - } + if (!isset($yearCount[$year])) { $yearCount[$year] = 0; } $yearCount[$year]++; } @@ -1419,7 +1327,6 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') {
-
Shortcuts: ← → to navigate | R for random | Space for play/pause
@@ -1429,46 +1336,40 @@ if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') {