forked from SimonezYT/fantacalcio-4h
Add initial implementation of Fantacalcio application
This commit is contained in:
Executable
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
require 'conversioni.php';
|
||||
|
||||
if (!isset($_GET['type'])) {
|
||||
die('Tipo di esportazione non specificato.');
|
||||
}
|
||||
|
||||
$type = $_GET['type'];
|
||||
$sourceFile = '';
|
||||
$outputFilename = '';
|
||||
$exportFunction = '';
|
||||
|
||||
if ($type === 'giocatori') {
|
||||
$sourceFile = 'giocatori.json';
|
||||
$outputFilename = 'giocatori.csv';
|
||||
$exportFunction = 'esportaGiocatori';
|
||||
} elseif ($type === 'voti') {
|
||||
$sourceFile = 'voti.json';
|
||||
$outputFilename = 'voti.csv';
|
||||
$exportFunction = 'esportaVoti';
|
||||
} else {
|
||||
die('Tipo di esportazione non valido.');
|
||||
}
|
||||
|
||||
if (!file_exists($sourceFile)) {
|
||||
die("File di origine non trovato: $sourceFile");
|
||||
}
|
||||
|
||||
$jsonContent = file_get_contents($sourceFile);
|
||||
$csvContent = $exportFunction($jsonContent);
|
||||
|
||||
header('Content-Type: text/csv; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename="' . $outputFilename . '"');
|
||||
|
||||
// Pulisce il buffer di output prima di inviare il file
|
||||
ob_end_clean();
|
||||
|
||||
echo $csvContent;
|
||||
exit;
|
||||
Reference in New Issue
Block a user