function makeZip($dirName, $path, $year, $month) { global $done, $Message; if (isset($month) || isset($year)) { if (isset($month)) { $zipfile = new zip_file($path = $path . "/" . $year . "_" . $month . ".zip"); } elseif (isset($year)) { $zipfile = new zip_file($path = $path . "/" . $year . ".zip"); } } else { $zipfile = new zip_file($path = $path . "/chat_ip_logs_" . date('ymd') . ".zip"); } $zipfile->set_options(array('level' => 3, 'overwrite' => 1, 'method' => 1, 'inmemory' => 0, 'recurse' => isset($month) ? 0 : 1, 'storepaths' => isset($month) || isset($year) ? 1 : 0, 'comment' => "Archive Class © 2005 - Devin Doucette (class programmer).\nModule © 2008" . (date('Y') > "2008" ? "-" . date('Y') : "") . " - " . PLUS_DEVELOPER . " (phpMyChat-Plus developer).\n\nFile built on " . date('jS \\of F Y, H:i:s') . ".\nDownloaded from [" . C_CHAT_NAME . "]\nat " . C_CHAT_URL . ".\nContent © " . date('Y') . " - " . C_ADMIN_NAME . " (chat site owner).")); $zipfile->add_files(array($dirName, $dirName . "/*.htm", $dirName . "/*.php", $dirName . "/*.txt")); $zipfile->create_archive(); $path = "<span class=\"error\">" . str_replace("./", "", $path) . "</span>"; if (count($zipfile->errors) > 0) { $Message = sprintf(A_CHAT_LOGS_40, A_CHAT_LOGS_32, $path); $done = 0; } else { $Message = sprintf(A_CHAT_LOGS_35, A_CHAT_LOGS_32, $path); $done = 1; } // successful saving }
function perform() { $this->_templateId = $this->_request->getValue("templateId"); $ts = new TemplateSetStorage(); $blogId = $this->_blogInfo->getId(); $baseTemplateFolder = $ts->getBaseTemplateFolder(); $templateArchive = new zip_file($this->_templateId . ".zip"); $templateArchive->set_options(array('basedir' => $baseTemplateFolder, 'overwrite' => 1, 'inmemory' => 1)); $templateArchive->add_files($this->_templateId); $templateArchive->create_archive(); $templateArchive->download_file(); return true; }
@unlink($sitemap_xml_file); $fp = fopen($cache_data_file, 'w'); @fwrite($fp, $xml_content); @fclose($fp); @chmod($cache_data_file, 0666); @copy($cache_data_file, $sitemap_xml_file); @chmod($sitemap_xml_file, 0666); if (ZIP_SITEMAP) { @chmod($sitemap_zip_file, 0777); @unlink($sitemap_zip_file); $archive = new zip_file($sitemap_zip_file); $archive->set_options(array('overwrite' => 1, 'storepaths' => 0, 'comment' => 'Sitemap of ' . strip_tags($config['sitename']))); $archive->add_files($cache_data_file); $archive->create_archive(); @chmod($sitemap_zip_file, 0666); } //Compresss the sitemap with gzip //this isn't as pretty as the code in page_header.php, but it's simple & it works :) if(function_exists(ob_gzhandler) && ($config['gzip_compress'] == 1)) { //ob_start(ob_gzhandler); } $MyETag = '"Sitemap' . gmdate('YmdHis', $cache_file_time) . $verinfo . '"'; $MyGMTtime = gmdate('D, d M Y H:i:s', $cache_file_time) . ' GMT'; if(!empty($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache/2')) { header ('Cache-Control: no-cache, pre-check=0, post-check=0, max-age=0'); }
function download($album) { mp3act_connect(); $query = "SELECT mp3act_songs.filename,\n\tmp3act_artists.artist_name,\n\tmp3act_albums.album_name \n\tFROM mp3act_songs,mp3act_artists,mp3act_albums \n\tWHERE mp3act_songs.album_id={$album} \n\tAND mp3act_songs.album_id=mp3act_albums.album_id \n\tAND mp3act_songs.artist_id=mp3act_artists.artist_id LIMIT 1"; $result = mysql_query($query); $row = mysql_fetch_array($result); $dir = dirname($row['filename']); $test = new zip_file("/tmp/album_{$album}.zip"); $test->set_options(array('inmemory' => 0, 'storepaths' => 0, 'level' => 0, 'method' => 0, 'prepend' => "{$row['artist_name']} - {$row['album_name']}")); $test->add_files($dir); $test->store_files($dir); $test->create_archive(); header("Content-type:application/zip"); $header = "Content-disposition: attachment; filename=\""; $header .= "album_{$album}.zip"; $header .= "\""; header($header); header("Content-length: " . filesize("/tmp/album_{$album}.zip")); header("Content-transfer-encoding: binary"); header("Pragma: no-cache"); header("Expires: 0"); $chunksize = 1 * (1024 * 1024); // how many bytes per chunk $buffer = ''; $handle = fopen("/tmp/album_{$album}.zip", 'rb'); if ($handle === false) { return false; } while (!feof($handle)) { $buffer = fread($handle, $chunksize); print $buffer; } fclose($handle); //readfile("/tmp/album_$album.zip"); unlink("/tmp/album_{$album}.zip"); //$test->download_file(); }
echo '<p>Deleting old zip files...</p>'; $dir = $CONFIG['fullpath'] . 'edit/'; if ($handle = opendir($dir)) { while (false !== ($entry = readdir($handle))) { if (preg_match('/^pictures-[0-9a-f]+.zip$/', $entry) && filemtime($dir . $entry) < time() - 2 * CPG_DAY) { unlink($dir . $entry); } } closedir($handle); } echo '<p>Creating file list...</p>'; $filelist = array(); $aid = $superCage->get->getInt('aid'); get_meta_album_set(0); $query = "SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} AS pictures , (SELECT keyword FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '" . $aid . "' ) AS keyword, {$CONFIG['TABLE_ALBUMS']} AS r {$RESTRICTEDWHERE} AND r.aid = pictures.aid AND (pictures.aid = '" . $aid . "' OR ( keyword.keyword <> '' AND CONCAT(';', keywords, ';') LIKE CONCAT('%;', keyword.keyword, ';%')))"; $result = cpg_db_query($query); $rowset = cpg_db_fetch_rowset($result); foreach ($rowset as $row) { $fileentry = $row['filepath'] . $row['filename']; $filelist[] = $fileentry; } echo '<p>Creating zip file...</p>'; $filename = 'edit/pictures-' . uniqid(null) . '.zip'; $zip = new zip_file($filename); $options = array('basedir' => "./{$CONFIG['fullpath']}", 'recurse' => 0, 'storepaths' => 0); $zip->set_options($options); $zip->add_files($filelist); $zip->create_archive(); echo '<p>Downloading...</p>'; ob_end_clean(); header('Location: ' . $CONFIG['site_url'] . $CONFIG['fullpath'] . $filename);
function auto_update_showpage() { global $db, $main_smarty, $the_template, $template_dir; include_once 'config.php'; include_once mnminclude . 'html1.php'; include_once mnminclude . 'link.php'; include_once mnminclude . 'tags.php'; include_once mnminclude . 'smartyvariables.php'; include_once "archive.php"; // Create mysql backup if ($_GET['download'] == 'mysql') { set_time_limit(0); require "auto_update_backup.php"; $b = new MysqlBackup($_GET['type'] == 'zip' ? '' : $_GET['type']); $tmpfname = $b->backup(); header('Content-Description: File Transfer'); header('Pragma: no-cache'); header('Content-Type: application/force-download'); header('Cache-Control: no-cache, must-revalidate'); header("Content-Disposition: attachment; filename=pligg_db_backup_" . date("Y_m_d") . ".sql" . ($_GET['type'] == 'gzip' ? '.gz' : ($_GET['type'] == 'zip' ? '.zip' : ''))); if ($_GET['type'] == 'zip') { $test = new zip_file(tempnam('/tmp', '')); $test->set_options(array('inmemory' => 1, 'storepaths' => 0)); $test->add_files(array($tmpfname)); $test->create_archive(); print $test->archive; } else { readfile($tmpfname); unlink($tmpfname); } exit; } elseif ($_GET['download'] == 'files') { set_time_limit(0); $tmpfname = tempnam('/tmp', ''); if ($_GET['type'] == 'gzip') { $test = new gzip_file($tmpfname); $test->set_options(array('inmemory' => 1, 'basedir' => "./", 'overwrite' => 1, 'level' => 1)); } else { $test = new zip_file($tmpfname); $test->set_options(array('inmemory' => 1, 'recurse' => 1, 'storepaths' => 1)); } $test->add_files("*"); $test->exclude_files("./cache/*"); $test->create_archive(); // Check for errors (you can check for errors at any point) if (count($test->errors) > 0) { print "Errors occurred."; } // Process errors here header('Content-Description: File Transfer'); header('Pragma: no-cache'); header('Content-Type: application/force-download'); header('Cache-Control: no-cache, must-revalidate'); header("Content-Disposition: attachment; filename=pligg_backup_" . date("Y_m_d") . ($_GET['type'] == 'gzip' ? '.tar.gz' : '.zip')); // Send archive to user for download print $test->archive; exit; } $main_smarty = do_sidebar($main_smarty); force_authentication(); $canIhaveAccess = 0; $canIhaveAccess = $canIhaveAccess + checklevel('god'); if ($canIhaveAccess == 1) { // breadcrumbs $main_smarty->assign('navbar_where', $navwhere); $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel')); // breadcrumbs define('modulename', 'status'); $main_smarty->assign('modulename', modulename); define('pagename', 'admin_modifystatus'); $main_smarty->assign('pagename', pagename); if ($_GET['step'] == 2) { $main_smarty->assign('gzip', function_exists('gzopen')); $main_smarty->assign('zip', class_exists('ZipArchive', FALSE)); $main_smarty->assign('tpl_center', auto_update_tpl_path . 'auto_update_step2'); } elseif ($_GET['step'] == 3) { $_SESSION['upload_files'] = array(); $main_smarty->assign('exists', !file_exists(mnmpath . "latest.zip") ? 'disabled' : ''); $main_smarty->assign('tpl_center', auto_update_tpl_path . 'auto_update_step3'); } elseif ($_GET['step'] == 4) { $main_smarty->assign('tpl_center', auto_update_tpl_path . 'auto_update_step4'); } elseif ($_GET['step'] == 5) { $main_smarty->assign('upgrade_exists', file_exists('install/upgrade.php')); $main_smarty->assign('tpl_center', auto_update_tpl_path . 'auto_update_step5'); } elseif ($_GET['step'] == 6) { $main_smarty->assign('tpl_center', auto_update_tpl_path . 'auto_update_step6'); } else { $main_smarty->assign('tpl_center', auto_update_tpl_path . 'auto_update_main'); } list($yourversion, $latestversion) = auto_update_detect_version(); $main_smarty->assign('yourversion', $yourversion); $main_smarty->assign('latestversion', $latestversion); $main_smarty->display($template_dir . '/admin/admin.tpl'); } else { header("Location: " . getmyurl('login', $_SERVER['REQUEST_URI'])); die; } }
$data = implode("\n", $data_array); $pdf->setXY($xpos, $ypos); $pdf->MultiCell($label_width, $line_height, $data); $xpos += $label_width; $qty = $elements_qty[$e['elements_id']]; $data_array = array(); $data_array[] = ': ' . $e['item_number']; $data_array[] = ': ' . $qty . ' piece(s)'; $data_array[] = ': ' . displayCurrency($e['price_currency'], $e['elements_price']) . " / " . $e['price_quantity_type']; $data_array[] = ': ' . $e['elements_id']; //.' / '.$e['elements_code']; $data = implode("\n", $data_array); $pdf->setXY($xpos, $ypos); $pdf->MultiCell($value_width, $line_height, $data); $ypos += $img_size - $text_middling; $counter++; } $supsname = str_replace(' ', '', strtolower($suppliers[$sup_id])); $filename = $pdf_temp_path . 'JnG-SPL-' . $supsname . '-' . date('Ymd-Hi') . '.pdf'; $pdf->Output($filename, 'F'); $zipper->add_files($filename); $pdf_files[] = $filename; } $zipper->create_archive(); foreach ($pdf_files as $pf) { if (file_exists($pf)) { unlink($pf); } } header("Location: {$zip_file}"); exit;
if (!file_exists($dest_dir . "download.zip")) { //zip file doesn't exist... create it // Create new zip file in the directory below the current one $test = new zip_file($dest_dir . "download.zip"); // Do not recurse through subdirectories // Do not store file paths in archive // Overwrite existing files // Do not create in mem but on hd $test->set_options(array('overwrite' => 1, 'inmemory' => 0, 'recurse' => 0, 'storepaths' => 0)); // Add all jpegs and gifs in the images directory to archive $test->add_files(array("{$dest_dir}/*.*")); $test->exclude_files("{$dest_dir}/*.html"); $test->exclude_files("{$dest_dir}/*.htaccess"); $test->exclude_files("{$dest_dir}/*.htpasswd"); // Create archive in path $test->create_archive(); } //display zipo download button msg_box($lang_photoshop_ipn['ipn_download_zip'], '', $lang_photoshop_ipn['ipn_download_zip'], $dest_dir . "download.zip", '100%'); } } //display continue button if ($display_continue_button || $return_lnk != '') { if ($return_lnk == 'index' && $display_continue_button) { // we're coming here from the admin, but we need to continue further from the creation to the download... carry the admin with msg_box($lang_photoshop_ipn['ipn_image_create_finished'], '', $lang_photoshop_ipn['ipn_continue'], str_replace('&', '&', "index.php?file=photo_shop/photo_shop_download_order&order={$order}&return_lnk=index"), '100%'); } elseif ($return_lnk == 'index' && !$display_continue_button) { //we came from the admin and now we're on the download page, display continue back to admin msg_box($lang_photoshop_ipn['ipn_image_create_finished'], '', $lang_photoshop_ipn['ipn_continue'], str_replace('&', '&', "index.php?file=photo_shop/photo_shop_admin"), '100%'); } elseif ($display_continue_button) { //we're user and get displayed a continue button to the download
function eshop_multi_download($email, $code, $update = true) { //multiple files - need to be zipped. include_once "archive-class.php"; global $wpdb, $eshopoptions; $table = $wpdb->prefix . "eshop_downloads"; $ordertable = $wpdb->prefix . "eshop_download_orders"; $dir_upload = eshop_download_directory(); $date = date("Y-m-d"); $backupfilename = get_bloginfo('name') . '-' . $date . '.zip'; $test = new zip_file($backupfilename); // Create archive in memory // Do not recurse through subdirectories // Do not store file paths in archive // Add lib/archive.php to archive //$test->add_files("src/archive.php"); // Add all jpegs and gifs in the images directory to archive $addfiles = array(); $test->set_options(array('inmemory' => 1, 'recurse' => 1, 'storepaths' => 0, 'prepend' => 'downloads')); $chkcount = $wpdb->get_var("SELECT COUNT(id) FROM {$ordertable} where email='{$email}' && code='{$code}' && downloads!='0'"); $chkresult = $wpdb->get_results("Select * from {$ordertable} where email='{$email}' && code='{$code}' && downloads!='0'"); if ($chkcount > 0) { foreach ($chkresult as $drow) { $item = $drow->files; $dload = $dir_upload . $drow->files; list($title, $ext) = explode('.', $drow->files); if (is_dir($dir_upload . $title)) { $addfiles[] = $dir_upload . $title; } else { $addfiles[] = $dload; } if ($update === true) { $wpdb->query("UPDATE {$ordertable} SET downloads=downloads-1 where email='{$email}' && code='{$code}' && id='{$drow->id}'"); //update product with number of downloads made $wpdb->query("UPDATE {$table} SET downloads=downloads+1 where title='{$drow->title}' && files='{$item}' limit 1"); } } } $test->add_files($addfiles); // make sure output buffering is disabled ob_start(); ob_end_clean(); // Create archive in memory $test->create_archive(); // Send archive to user for download $test->download_file(); exit; }
scorm_html5_page_create($row['template_framework'], $lo_name, $xml->getLanguage()); } } else { if ($scorm == "2004") { $useflash = $export_flash && !$export_html5; lmsmanifest_2004_create($row['zipname'], $useflash, $lo_name); if ($export_flash && !$export_html5) { scorm2004_html_page_create($row['template_name'], $row['template_framework'], $rlo_file, $lo_name, $xml->getLanguage()); } else { scorm2004_html5_page_create($row['template_framework'], $lo_name, $xml->getLanguage()); } } else { if ($export_flash) { basic_html_page_create($row['template_name'], $row['template_framework'], $rlo_file, $lo_name); } if ($export_html5) { basic_html5_page_create($row['template_framework'], $lo_name); } } } /* * Add the files to the zip file, create the archive, then send it to the user */ xerte_zip_files($fullArchive, $dir_path); $zipfile->create_archive(); $zipfile->download_file($row['zipname']); /* * remove the files */ clean_up_files(); unlink($dir_path . "template.xml");
function zipnload(array $d) { global $config; if ($config["zipnload"] != 1) { echo json_encode(array("status" => "ERROR", "message" => "No permission to download directories")); } else { chDirIfNecessary($d['dir']); if (!file_exists($d['filename'])) { echo json_encode(array("status" => "ERROR", "message" => "Directory not found")); } else { unset($zip); $dfile = uniqid("epfm") . ".zip"; // temporary filename $zip = new zip_file($dfile); $zip->add_files($d['filename']); $zip->create_archive(); header("Content-Disposition: attachment; filename=\"" . $d['filename'] . ".zip\""); echo file_get_contents($dfile); unlink($dfile); // delete temporary file } } }
//echo $file . ', ' . $thisfile . ', ' . $realpath_thisfile . ', ' . $realpathparts_getfile['dirname'] . ', ' . $realpathparts_thisfile . '<br />'; if (substr($getfile, 0, 1) == '.') { $subpath_getfile = substr($pathparts_getfile['dirname'], 2); } else { $subpath_getfile = $pathparts_getfile['dirname']; } if (!checkfile($pathparts_getfile, $realpath_getfile, $realpathparts_thisfile['dirname'] . '/' . $subpath_getfile)) { $errors .= '[ERROR] INVALID FILE: ' . $getfile . ', Operation NOT Allowed!!!<br />'; } else { // Add file to Archive // echo $getfile . '<br />'; $downloadpackage->add_files($getfile); } } if ($errors == '') { $downloadpackage->create_archive(); // Send archive to user for download // if (count($downloadpackage->error) == 0) { $downloadpackage->download_file(); } else { foreach ($downloadpackage->error as $error) { echo $error . '<br />'; } } /*foreach( $filesarray as $file ) { echo $file . '<br />'; } echo 'DOWNLOAD STARTING of the following files';*/ } else {
function backup_imgdb($backup = 1, $err_show = 1) { require "zip.class.php"; // Get the zipfile class if ($backup == 1) { $files_to_zip = array(CFDATAPATH . 'imgdb.db'); $savt_as = CFBACKUPPATH . 'imgdb_backup_' . date("Y") . '-' . date("m") . '-' . date("d") . '_' . date("H.i.s") . '.zip'; } else { $files_to_zip = array(CFBANDWIDTHPATH . "*.db"); $savt_as = CFBACKUPPATH . 'bandwidth_backup_' . date("Y") . '-' . date("m") . '-' . date("d") . '_' . date("H.i.s") . '.zip'; } $test = new zip_file($savt_as); $test->set_options(array('overwrite' => 1, 'inmemory' => 0, 'recurse' => 0, 'storepaths' => 0)); // Add lib/archive.php to archive $test->add_files($files_to_zip); // Create file $test->create_archive(); $test->download_file(); // Check for errors (you can check for errors at any point) if (!$test->errors) { if ($err_show) { user_feedback('success', 'Backup done!', 'backup_imgdb'); } return true; // Process errors here } if ($err_show) { user_feedback('error', 'Can\'t made backup zip file!', 'backup_imgdb'); } return false; }
unset($_GET['tab']); // it is gone, after all if (basename($file) == 'security_log.txt') { zp_apply_filter('admin_log_actions', true, $file, $action); // have to record the fact } break; case 'download_log': include_once SERVERPATH . '/' . ZENFOLDER . '/archive.php'; $subtab = sanitize($_GET['tab'], 3); $dest = SERVERPATH . '/' . DATA_FOLDER . '/' . $subtab . ".zip"; $rp = dirname($file); $z = new zip_file($dest); $z->set_options(array('basedir' => $rp, 'inmemory' => 0, 'recurse' => 0, 'storepaths' => 1)); $z->add_files(array(basename($file))); $z->create_archive(); header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="' . $subtab . '.zip"'); header("Content-Length: " . filesize($dest)); printLargeFileContents($dest); unlink($dest); break; } } } // Print our header $filelist = safe_glob(SERVERPATH . "/" . DATA_FOLDER . '/*.txt'); if (count($filelist) > 0) { $subtabs = array(); if (isset($_GET['tab'])) { $default = sanitize($_GET['tab'], 3);
/** * send_zip * * takes array of full paths to songs * zips them and sends them * * @param string $name name of the zip file to be created * @param array $song_files array of full paths to songs to zip create w/ call to get_song_files */ function send_zip($name, $song_files) { // Check if they want to save it to a file, if so then make sure they've // got a defined path as well and that it's writable. $basedir = ''; if (AmpConfig::get('file_zip_download') && AmpConfig::get('tmp_dir_path')) { // Check writeable if (!is_writable(AmpConfig::get('tmp_dir_path'))) { $in_memory = '1'; debug_event('Error', 'File Zip Path:' . AmpConfig::get('tmp_dir_path') . ' is not writable', '1'); } else { $in_memory = '0'; $basedir = AmpConfig::get('tmp_dir_path'); } } else { $in_memory = '1'; } // if file downloads /* Require needed library */ require_once AmpConfig::get('prefix') . '/modules/archive/archive.lib.php'; $arc = new zip_file($name . ".zip"); $options = array('inmemory' => $in_memory, 'basedir' => $basedir, 'storepaths' => 0, 'level' => 0, 'comment' => AmpConfig::get('file_zip_comment'), 'type' => "zip"); $arc->set_options($options); foreach ($song_files as $dir => $files) { $arc->add_files($files, $dir); } if (count($arc->error)) { debug_event('archive', "Error: unable to add songs", '3'); return false; } // if failed to add songs if (!$arc->create_archive()) { debug_event('archive', "Error: unable to create archive", '3'); return false; } // if failed to create archive $arc->download_file(); }