'lazanzara.greenpirates.org',
'dirfiles' => 'lazanzara',
'base_dir' => __DIR__,
'file_pattern' => '/^(\d{8})-lazanzara\.mp3$/i',
'cache_file' => __DIR__ . '/cache/valid_dates.json',
'cache_timeout' => 3600, // 1 ora
'show_download_link' => false // Mostra/nascondi link download diretto
];
/**
* Scansiona ricorsivamente le directory per trovare i file mp3
*/
function findValidDates($dir, $config) {
$validDates = [];
$fullPath = $config['base_dir'] . DIRECTORY_SEPARATOR . $dir;
if (!is_dir($fullPath)) {
return $validDates;
}
$years = scandir($fullPath);
foreach ($years as $year) {
if ($year === '.' || $year === '..' || !preg_match('/^\d{4}$/', $year)) {
continue;
}
$yearPath = $fullPath . DIRECTORY_SEPARATOR . $year;
if (!is_dir($yearPath)) {
continue;
}
$files = scandir($yearPath);
foreach ($files as $file) {
if (preg_match($config['file_pattern'], $file, $matches)) {
$validDates[] = $matches[1];
}
}
}
sort($validDates);
return $validDates;
}
/**
* Ottiene le date valide con cache
*/
function getValidDates($config) {
$useCache = false;
if (file_exists($config['cache_file'])) {
$cacheAge = time() - filemtime($config['cache_file']);
if ($cacheAge < $config['cache_timeout']) {
$useCache = true;
}
}
if ($useCache) {
return json_decode(file_get_contents($config['cache_file']), true);
} else {
$validDates = findValidDates($config['dirfiles'], $config);
$cacheDir = dirname($config['cache_file']);
if (is_dir($cacheDir) || @mkdir($cacheDir, 0755, true)) {
file_put_contents($config['cache_file'], json_encode($validDates));
}
return $validDates;
}
}
function validateDate($date) {
if (!preg_match('/^\d{8}$/', $date)) {
return false;
}
$year = substr($date, 0, 4);
$month = substr($date, 4, 2);
$day = substr($date, 6, 2);
return checkdate($month, $day, $year) ? $date : false;
}
function generateFilePath($date, $config) {
$year = substr($date, 0, 4);
return [
'local_path' => sprintf("%s/%s/%s/%s-lazanzara.mp3",
$config['base_dir'],
$config['dirfiles'],
$year,
$date
),
'url' => sprintf("https://%s/%s/%s/%s-lazanzara.mp3",
$config['urlname'],
$config['dirfiles'],
$year,
$date
),
'filename' => sprintf("%s-lazanzara.mp3", $date)
];
}
// Gestione richiesta AJAX per date valide
if (isset($_GET['action']) && $_GET['action'] === 'get_valid_dates') {
header('Content-Type: application/json');
header('Cache-Control: max-age=3600');
echo json_encode(getValidDates($config));
exit;
}
?>
Crux mea lux - LaZanzara Repository
- - - Crux mea Lux - - -
Unofficial LaZanzara Repository
0) {
$randomIndex = array_rand($validDates);
$_POST['datepicker'] = $validDates[$randomIndex];
}
}
$inputValue = '';
if (isset($_POST['datepicker']) && !empty($_POST['datepicker'])) {
$inputValue = $_POST['datepicker'];
}
?>
';
if (file_exists($paths['local_path'])) {
$year = substr($selectedDate, 0, 4);
$month = substr($selectedDate, 4, 2);
$day = substr($selectedDate, 6, 2);
$formattedDate = sprintf("%s/%s/%s", $day, $month, $year);
$fileSize = filesize($paths['local_path']);
$fileSizeMB = round($fileSize / 1024 / 1024, 1);
$validDates = getValidDates($config);
$currentIndex = array_search($selectedDate, $validDates);
$prevDate = ($currentIndex > 0) ? $validDates[$currentIndex - 1] : null;
$nextDate = ($currentIndex < count($validDates) - 1) ? $validDates[$currentIndex + 1] : null;
// MODIFICA: data grande e leggibile, MB in piccolo
if (isset($_POST['random']) && $_POST['random'] == '1') {
echo 'π² ' . htmlspecialchars($formattedDate) . ' β’ ' . $fileSizeMB . ' MB
';
} else {
echo '' . htmlspecialchars($formattedDate) . ' β’ ' . $fileSizeMB . ' MB
';
}
// Audio player custom
echo '';
echo '
';
echo '
';
echo '
';
if ($prevDate) {
echo '
';
} else {
echo '
';
}
echo '
';
echo '
';
echo '
';
if ($nextDate) {
echo '
';
} else {
echo '
';
}
echo '
'; // main-controls
echo '
';
echo '
';
echo '
';
echo '
0:00';
echo '
';
echo '
0:00';
echo '
';
echo '
';
echo '
'; // player-layout
echo '
'; // custom-audio-player
echo '';
if ($config['show_download_link']) {
echo '
Or download directly:
' .
htmlspecialchars($paths['filename']) . '
';
}
} else {
echo 'File not found for date: ' .
htmlspecialchars($selectedDate) . '
';
}
echo ' ';
} else {
echo '
Invalid date. Use format YYYYMMDD
';
}
}
$validDates = getValidDates($config);
$totalFiles = count($validDates);
if ($totalFiles > 0) {
$firstDate = $validDates[0];
$lastDate = $validDates[$totalFiles - 1];
echo '';
echo '
Archive Statistics
';
echo '
Available files: ' . $totalFiles . '
';
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) . '
';
$yearCount = [];
foreach ($validDates as $date) {
$year = substr($date, 0, 4);
if (!isset($yearCount[$year])) { $yearCount[$year] = 0; }
$yearCount[$year]++;
}
echo '
';
echo 'Files per year
';
echo '';
foreach ($yearCount as $year => $count) {
echo '- ' . $year . ': ' . $count . ' episodes
';
}
echo '
';
echo ' ';
echo '
';
}
?>
Shortcuts: β β to navigate | R for random | Space for play/pause