// Begin the zip
$zip = new ZipArchive();
if (($result = $zip->open($filepath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)) !== true)
{
// Couldn't open the zip
throw new Exception($vbphrase['dbtech_vbecommerce_invalid_temp_dir']);
}
foreach (VBECOMMERCE_FILE::$map as $filename => $shortfile)
{
// Grab the extension
$ext = strtolower(VBECOMMERCE_FILE::fetch_extension($filename));
switch ($ext)
{
case 'png':
case 'gif':
case 'jpeg':
case 'jpg':
case 'psd':
case 'ttf':
case 'zip':
case 'ogg':
$zip->addFile($filename, $addOnDir);
break;
default:
// Various replacements on the file contents go here
$zip->addFromString($addOnDir, $file);
break;
}
// Finally close the zip
$zip->close();