Online Zip Archiver
A script that generates an archive online, so that it puts the contents of a site, or a part, can help to make a backup or to create an archive for users.
If the site is under a CMS, this does not save the database, which can also be exported with a tool like PHPMyAdmin. In fact, by combining a backup of the database and an archive of all the files, you make a backup of the entire site.
The script is obviously protected by a password.
It requires PHP 5 and the zip module. You can verify the presence of available modules on the server with this command:
<?php foreach(get_loaded_extensions() as $ext) print $ext."<br>"; ?>
To generate the archive from a list of files, the following script is implemented:
define('ABSPATH', $_SERVER['DOCUMENT_ROOT']); $zip = new ZipArchive; if($zip->open($target, ZipArchive::CREATE) === true) {
foreach($ziplist as $file)
{
$path = ABSPATH.$file; $zip->addFile($path, $file); } } $zip->close();
The following variables are passed to the script:
- $ziplist which is the file list. The files have a path relative to the root of the site.
- We build the absolute path by concatenating ABSPATH and the relative path.
- This is assigned to the $path variable, while the relative path is provided as second argument to the addFile method.
- The variable $target is the name with an absolute path of the archive to be created.
Selecting files to archive is achieved from within a form, whose code is in the zip.php file.
Download the archive
- The archive is integrated with the Bioloide interface.
License GPL 3.0.