Request: Save backup_albums.php output to file on drive

samkuhn2

Joined: 2004-04-13
Posts: 60
Posted: Tue, 2004-04-13 18:42

Would anyone with mild PHP skills be willing to modify the backup_albums.php file (found in /gallery/setup) to allow a user to save the output to a file on the drive rather than forcing the user to attempt to download it? I know that the script currently generates (at least when making a zip file) a copy of the file in the gallery temp dir, but it has a random name, making it difficult to say, write an automated backup script, or provide a static link for later download, etc.

In summary, I was hoping some would:
1) Modify script to allow the user to save the archive to disk locally
2) Allow the user to choose the name and location of the saved file

This seems to be the critical portion of code for the zip file.


        else if  (!strcmp($backup_method, "zip") &&
                !strcmp($target_files, "dat")) {
                $zipfile=tempnam($gallery->app->tmpDir, "dump").".zip";
                $cmd=fs_import_filename($zip_path).
                        " -r $zipfile ".  $gallery->app->albumDir .
                        ' -i "*.dat"';
                exec_wrapper($cmd);
                // echo ("$cmd<p>");
                $cmd=fs_import_filename($zip_path).
                        " -r $zipfile ".  $gallery->app->userDir;
                exec_wrapper($cmd);
                // echo ("$cmd<p>");
                header( "Content-type: application/zip" );
                header( "Content-Disposition: attachment; filename=gallery_dump.zip" );
                header( "Content-Description: PHP Generated Data" );
                readfile($zipfile);
                fs_unlink($zipfile);
        }
        else if  (!strcmp($backup_method, "zip") &&
                !strcmp($target_files, "all")) {
                $zipfile=tempnam($gallery->app->tmpDir, "dump").".zip";
                $cmd=fs_import_filename($zip_path).
                        " -r $zipfile ".  $gallery->app->userDir . " " .
                        $gallery->app->albumDir;
                exec_wrapper($cmd);
                // echo ("$cmd<p>");
                header( "Content-type: application/zip" );
                header( "Content-Disposition: attachment; filename=gallery_dump.zip" );
                header( "Content-Description: PHP Generated Data" );
                readfile($zipfile);
                fs_unlink($zipfile);
        }
}