Export database in JSON

Depends of:
Write JSON file
Download a file

if (isset($_GET['export'])) {
    if (is_file('data/base.php')) {
        $export = 'data/go-export_'.date('Y-m-d_His').'.json';
        $success = writeJSON($base, $export);
        if ($success) {
            $success = downloadFile($export);
            if (!$success) {
                $msg = "Problème de téléchargement. Votre export est disponible à l'emplacement <a href='".$export."'>".$export."</a>";
            }
        } else {
            $msg = "Erreur d'écriture.";
        }
    } else {
        $msg = "Il n'y a rien à exporter."
    }
}