Пример #1
0
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;
 }
        $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;
 }
 endtable();
 if (!$display_continue_button) {
     //no
     if ($CONFIG['photo_shop_download_zip'] == '1') {
         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('&amp;', '&', "index.php?file=photo_shop/photo_shop_download_order&amp;order={$order}&amp;return_lnk=index"), '100%');
 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;
 }
     foreach ($temp_images as $ti) {
         $zip_filesize += intval(filesize($ti));
         if ($zip_filesize >= $zip_filesize_limit) {
             $zipper->create_archive();
             $zip_filenames[] = $zip_filename;
             $zip_filesize = 0;
             $zip_filecounter++;
             $zip_filename = $prefix_date . '-LazadaProductImages-' . $zip_filecounter . '.zip';
             $zip_file = SP_LAZADAID_TEMP_IMAGE_DIR . $zip_filename;
             if (file_exists($zip_file)) {
                 unlink($zip_file);
             }
             $zipper = new zip_file($zip_file);
             $zipper->set_options(array('storepaths' => 0));
         }
         $zipper->add_files($ti);
     }
     $zipper->create_archive();
     $zip_filenames[] = $zip_filename;
 }
 $total_zipfiles = count($zip_filenames);
 if (isset($temp_images)) {
     foreach ($temp_images as $ti) {
         if (file_exists($ti)) {
             unlink($ti);
         }
     }
 }
 $result .= '<table border="0" cellpadding="0" cellspacing="0">';
 if (is_file($csv_bulk_item_location)) {
     $filesize = filesize($csv_bulk_item_location);
Пример #7
0
<?php

include "archive.php";
$today = date("m.j.y-gi");
$test = new zip_file("./data/backups/" . $today . ".zip");
$test->set_options(array('inmemory' => 0, 'recurse' => 1, 'storepaths' => 1));
$test->add_files("./data/blocks/*.*");
$test->add_files("./data/blog/*.*");
$test->add_files("./data/img/*.*");
$test->create_archive();
print "<p class=\"complete\"><b>{$lang_backup_complete}</b></p>";
?>

<?php 
$_SESSION["backups"] = $backups;
Пример #8
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();
}
Пример #9
0
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;
}
Пример #10
0
// ------------------------------------
// Build archive
// ------------------------------------
if ($total_pics > 0) {
    if (isset($_GET['download_all_pics'])) {
        $limit_sql = ' ';
    } else {
        $limit_sql = $start == 0 ? ' LIMIT ' . $pics_per_page : ' LIMIT ' . $start . ',' . $pics_per_page;
    }
    $sql = "SELECT pic_filename\n\t\t\tFROM " . ALBUM_TABLE . "\n\t\t\tWHERE pic_cat_id = {$cat_id}\n\t\t\tORDER BY {$sort_method} {$sort_order}\n\t\t\t{$limit_sql}";
    $result = $db->sql_query($sql);
    // ------------------------------------
    // If you wish to use a format other than zip uncomment the necessary line, "archive" can also be renamed
    // ------------------------------------
    $archive = new zip_file('archive.zip');
    // save as zip
    // $archive = new tar_file('archive.tar'); // save as tar
    // $archive = new gzip_file('archive.tgz'); // save as gzip
    $archive->set_options(array('inmemory' => 1, 'storepaths' => 0, 'comment' => 'Archived photos from ' . $config['sitename']));
    $DLpics = array();
    while ($row = $db->sql_fetchrow($result)) {
        $DLpics[] = $row;
    }
    for ($num = 0; $num < sizeof($DLpics); $num++) {
        $archive->add_files(ALBUM_UPLOAD_PATH . $DLpics[$num]['pic_filename']);
    }
    $archive->create_archive();
    $archive->download_file();
} else {
    message_die(GENERAL_ERROR, 'There are no pictures to download');
}
     $xml_content .= writeXMLline('FileName', $new_filename, 4);
     $xml_content .= writeXMLclose($img_tag, 3);
     $image_for_items[] = $new_filename;
     //Check if image is already uploaded (or need reupload)
     if ($p['image_uploaded'] != '1') {
         //UPLOAD IMAGE WITH CATALOG FILE
         $img_location = DIR_WS_IMAGES . $pi;
         if (!in_array($p['jng_sp_catalog_id'], $upload_image_log)) {
             $upload_image_log[] = $p['jng_sp_catalog_id'];
         }
         if ($create_image_zip) {
             //CREATE IMAGE ARCHIVE FOR UPLOAD
             $new_location = SP_OTTODE_TEMP_IMAGE_DIR . $new_filename;
             copy($img_location, $new_location);
             $temp_images[] = $new_location;
             $zipper->add_files($new_location);
         } else {
             $new_location = SP_OTTODE_UPLOAD_PATH . $new_filename;
             copy($img_location, $new_location);
             $temp_images[] = $new_location;
         }
     }
 }
 $xml_content .= writeXMLclose('Images', 2);
 //Our XML settings for OTTO:
 //1 Product = 1 Style = 1 Item = X SKUS
 $xml_content .= writeXMLopen('Item', 2);
 $xml_content .= writeXMLline('ItemDesc', $p['name'], 3);
 $xml_content .= writeXMLline('OrderQuantityDefault', 1, 3);
 $xml_content .= writeXMLline('OrderQuantityMin', 1, 3);
 $xml_content .= writeXMLline('OrderQuantityMax', 9, 3);
Пример #12
0
         }
         if ($selected_Filelist->count() == 1) {
             $only_File = $selected_Filelist->get_array();
             $only_File = $only_File[0];
             // TODO: once we support additional formats, use the default extension here:
             $zipname = $only_File->get_name() . '.zip';
         }
         break;
     }
     // Downloading
     load_class('_ext/_zip_archives.php', 'zip_file');
     $arraylist = $selected_Filelist->get_array('get_name');
     $options = array('basedir' => $fm_Filelist->get_ads_list_path(), 'inmemory' => 1, 'recurse' => 1 - $exclude_sd);
     $zipfile = new zip_file($zipname);
     $zipfile->set_options($options);
     $zipfile->add_files($arraylist, array('_evocache'));
     $zipfile->create_archive();
     if ($zipfile->error) {
         foreach ($zipfile->error as $v) {
             $Messages->add($v, 'error');
         }
         break;
     }
     $zipfile->download_file();
     exit(0);
     /* EXITED! */
 /* EXITED! */
 case 'rename':
     // TODO: We don't need the Filelist, move UP!
     // Rename a file:
     // This will not allow to overwrite existing files, the same way Windows and MacOS do not allow it. Adding an option will only clutter the interface and satisfy geeks only.
Пример #13
0
                clearstatcache();
                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'])) {
Пример #14
0
/**
 * 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();
}
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;
    }
}
Пример #16
0
     $thisfile = $_SERVER['SCRIPT_FILENAME'];
     $realpath_thisfile = realpath($thisfile);
     $pathparts_thisfile = pathinfo($thisfile);
     $realpathparts_thisfile = pathinfo($realpath_thisfile);
     //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 )
     		{
Пример #17
0
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);
Пример #18
0
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
        }
    }
}
Пример #19
0
	@unlink($cache_data_file);
	@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');
Пример #20
0
<?php

//压缩操作类测试
//by indraw
//2004/11/4
require 'FileZip.class.php';
//---------------------------------------------------------
$test = new zip_file("test.zip");
$test->set_options(array('basedir' => "./", 'overwrite' => 1, 'level' => 1, 'type' => zip));
$test->add_files("FileCsv.class.php");
//要压缩的文件目录
//$test->exclude_files("d/*.swf");			//跳过的文件
//$test->store_files("d/*.txt");				//只保存,不压缩
$test->create_archive();
echo "成功压缩:test.zip";
//---------------------------------------------------------
/*
$test = new gzip_file("test.gzip");
$test->set_options(array('overwrite'=>1));
$test->extract_files();
echo "成功展开:test.gzip";
*/
//---------------------------------------------------------