Esempio n. 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
}
 public static function factory($tempfilename, $options)
 {
     if (extension_loaded('zip')) {
         return new Xerte_Zip_Native($tempfilename, $options);
     } else {
         // Use the legacy Zip thing - note it may hit memory limit(s). :-(
         $zip = new zip_file($tempfilename);
         $zip->set_options($options);
         return $zip;
     }
 }
 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;
 }
Esempio n. 4
0
/**
 * Creates a zip file of the album
 *
 * @param string $album album folder
 */
function createAlbumZip($album)
{
    global $_zp_zip_list;
    if (!checkAlbumPassword($album, $hint)) {
        pageError();
        exit;
    }
    $album = UTF8ToFilesystem($album);
    $rp = realpath(getAlbumFolder() . $album) . '/';
    $p = $album . '/';
    include_once 'archive.php';
    $dest = realpath(getAlbumFolder()) . '/' . urlencode($album) . ".zip";
    $persist = getOption('persistent_archive');
    if (!$persist || !file_exists($dest)) {
        if (file_exists($dest)) {
            unlink($dest);
        }
        $z = new zip_file($dest);
        $z->set_options(array('basedir' => $rp, 'inmemory' => 0, 'recurse' => 0, 'storepaths' => 1));
        if ($dh = opendir($rp)) {
            $_zp_zip_list[] = '*.*';
            while (($file = readdir($dh)) !== false) {
                if ($file != '.' && $file != '..') {
                    if (is_dir($rp . $file)) {
                        $base_a = explode("/", $album);
                        unset($base_a[count($base_a) - 1]);
                        $base = implode('/', $base_a);
                        zipAddSubalbum($rp, $base, $file, $z);
                    }
                }
            }
            closedir($dh);
        }
        $z->add_files($_zp_zip_list);
        $z->create_archive();
    }
    header('Content-Type: application/zip');
    header('Content-Disposition: attachment; filename="' . urlencode($album) . '.zip"');
    header("Content-Length: " . filesize($dest));
    printLargeFileContents($dest);
    if (!$persist) {
        unlink($dest);
    }
}
Esempio n. 5
0
/**
 * Creates a zip file of the album
 *
 * @param string $albumname album folder
 */
function createAlbumZip($albumname)
{
    global $_zp_zip_list, $zip_gallery;
    $zip_gallery = new Gallery();
    $album = new Album($zip_gallery, $albumname);
    if (!$album->isMyItem(LIST_RIGHTS) && !checkAlbumPassword($albumname)) {
        pageError(403, gettext("Forbidden"));
        exit;
    }
    if (!$album->exists) {
        pageError(404, gettext('Album not found'));
        exit;
    }
    $persist = $zip_gallery->getPersistentArchive();
    $dest = $album->localpath . '.zip';
    if (!$persist || !file_exists($dest)) {
        include_once 'archive.php';
        $curdir = getcwd();
        chdir($album->localpath);
        $_zp_zip_list = array();
        $z = new zip_file($dest);
        $z->set_options(array('basedir' => realpath($album->localpath . '/'), 'inmemory' => 0, 'recurse' => 0, 'storepaths' => 1));
        zipAddAlbum($album, strlen($albumname), $z);
        $z->add_files($_zp_zip_list);
        $z->create_archive();
        unset($_zp_zip_list);
        chdir($curdir);
    }
    header('Content-Type: application/zip');
    header('Content-Disposition: attachment; filename="' . pathurlencode($albumname) . '.zip"');
    header("Content-Length: " . filesize($dest));
    printLargeFileContents($dest);
    if (!$persist) {
        unlink($dest);
    }
    unset($zip_gallery);
    unset($album);
    unset($persist);
    unset($dest);
}
Esempio n. 6
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();
}
Esempio n. 7
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
        }
    }
}
    }
    echo border('sgray', 'end');
    echo '<!-- Begin Roster Footer -->';
    echo '</div>';
    echo '</body>';
    echo '</html>';
    exit;
} elseif (isset($_POST['filestoget']) && isset($_POST['ziptype'])) {
    $filesarray = explode(';', $_POST['filestoget']);
    $ziptype = $_POST['ziptype'];
    // targz  or  zip
    $errors = '';
    if ($ziptype == 'targz') {
        $downloadpackage = new gzip_file('WoWRoster_UpdatePackage_' . date('Ymd_Hi') . '.tar.gz');
    } else {
        $downloadpackage = new zip_file('WoWRoster_UpdatePackage_' . date('Ymd_Hi') . '.zip');
    }
    $downloadpackage->set_options(array('inmemory' => 1, 'recurse' => 0, 'storepaths' => 1));
    foreach ($filesarray as $file) {
        $getfile = $file;
        $pathparts_getfile = pathinfo($getfile);
        $realpath_getfile = realpath($pathparts_getfile['dirname']);
        $realpathparts_getfile = pathinfo($realpath_getfile);
        $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 {
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();
}
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;
    }
}
             $return_lnk_check = true;
         }
     } else {
         // that item hasn't been paid... display a note
         echo "<tr><td>{$value['filename']} <span class=\"album_stat\">(Id: {$value['id']})</span></td><td>{$lang_photoshop_ipn['ipn_not_paid']}</td><td></td></tr>\n\n";
         $return_lnk_check = true;
     }
 }
 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%');
Esempio n. 12
0
    starttable('-2', $lang_error);
    print <<<EOT
<tr>
        <td align="center" class="tableb">
      {$lang_errors['perm_denied']}
      </td>
</tr>
EOT;
    endtable();
    pagefooter();
    ob_end_flush();
} else {
    // zipdownload allowed, go ahead...
    $filelist = array();
    if (count($FAVPICS) > 0) {
        $favs = implode(",", $FAVPICS);
        $select_columns = 'filepath,filename';
        $result = cpg_db_query("SELECT {$select_columns} FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES'AND pid IN ({$favs})");
        $rowset = cpg_db_fetch_rowset($result);
        foreach ($rowset as $key => $row) {
            $filelist[] = $rowset[$key]['filepath'] . $rowset[$key]['filename'];
        }
    }
    $cwd = "./{$CONFIG['fullpath']}";
    $zip = new zip_file('pictures.zip');
    $zip->set_options(array('basedir' => $cwd, 'inmemory' => 1, 'recurse' => 0, 'storepaths' => 0));
    $zip->add_files($filelist);
    $zip->create_archive();
    ob_end_clean();
    $zip->download_file();
}
Esempio n. 13
0
             // Action was invoked, add "hint"
             param_error('zipname', T_('Please provide the name of the archive.'));
         }
         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!
Esempio n. 14
0
            case 'delete_log':
                @unlink($file);
                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) {
Esempio n. 15
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;
Esempio n. 16
0
$scorm2004_path = $xerte_toolkits_site->basic_template_path . $row['template_framework'] . "/scorm2004.3rd/";
$scorm2004_language_relpath = $xerte_toolkits_site->module_path . $row['template_framework'] . "/scorm2004.3rd/";
$js_path = $xerte_toolkits_site->basic_template_path . $row['template_framework'] . "/js/";
if (isset($_REQUEST['html5'])) {
    $export_html5 = $_REQUEST['html5'] == 'true' ? true : false;
}
if (isset($_REQUEST['flash'])) {
    $export_flash = $_REQUEST['flash'] == 'true' ? true : false;
}
if (!$export_html5 && !$export_flash) {
    $export_html5 = true;
}
/*
 * Make the zip
 */
$zipfile = new zip_file("example_zipper_new" . time() . ".zip");
$zipfile->set_options(array('basedir' => $dir_path, 'prepand' => "", 'inmemory' => 1, 'recurse' => 1, 'storepaths' => 1));
/*
 * Copy the core files over from the parent folder
 */
copy($dir_path . "data.xml", $dir_path . "template.xml");
$xml = new XerteXMLInspector();
$xml->loadTemplateXML($dir_path . 'template.xml');
if ($fullArchive) {
    _debug("Full archive");
    export_folder_loop($parent_template_path);
} else {
    _debug("Deployment archive");
    if ($export_flash) {
        _debug("  use flash");
        $models = $xml->getUsedModels();
Esempio n. 17
0
function pm_export_messages($messages_array, $options_array = array())
{
    if (!is_array($messages_array)) {
        return false;
    }
    $messages_array = array_filter($messages_array, 'is_numeric');
    if (sizeof($messages_array) < 1) {
        return false;
    }
    if (!is_array($options_array)) {
        $options_array = array();
    }
    $logon = mb_strtolower(session::get_value('LOGON'));
    if (!isset($options_array['PM_EXPORT_TYPE'])) {
        $options_array['PM_EXPORT_TYPE'] = session::get_value('PM_EXPORT_TYPE');
    }
    if (!isset($options_array['PM_EXPORT_STYLE'])) {
        $options_array['PM_EXPORT_STYLE'] = session::get_value('PM_EXPORT_STYLE');
    }
    $zip_file = new zip_file();
    if ($options_array['PM_EXPORT_STYLE'] == "Y" && @file_exists("styles/style.css")) {
        $zip_file->add_file(file_get_contents("styles/style.css"), "styles/style.css");
    }
    switch ($options_array['PM_EXPORT_TYPE']) {
        case PM_EXPORT_HTML:
            if (!pm_export_html($messages_array, $zip_file, $options_array)) {
                return false;
            }
            break;
        case PM_EXPORT_XML:
            if (!pm_export_xml($messages_array, $zip_file, $options_array)) {
                return false;
            }
            break;
        case PM_EXPORT_CSV:
            if (!pm_export_csv($messages_array, $zip_file, $options_array)) {
                return false;
            }
            break;
    }
    header("Content-Type: application/zip");
    header("Expires: " . gmdate('D, d M Y H:i:s') . " GMT");
    header("Content-Disposition: attachment; filename=\"pm_backup_{$logon}.zip\"");
    header("Pragma: no-cache");
    echo $zip_file->output_zip();
    exit;
}
 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;
 }
Esempio n. 19
0
$total_pics = $row['count'];
// ------------------------------------
// 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');
    //Page footer
    function Footer()
    {
    }
}
$zip_temp_path = '../temp/zips/';
$zip_filename = 'elements-picking-list-' . date('Ymd-Hi') . '.zip';
$zip_file = $zip_temp_path . $zip_filename;
if (file_exists($zip_file)) {
    $prev_deleted = unlink($zip_file);
    if (!$prev_deleted) {
        echo '<h3>Can not delete last generated file</h3>';
        echo '<div>Please try again later, or contact administrator if you keep getting this message.</div>';
    }
}
$zipper = new zip_file($zip_file);
$zipper->set_options(array('storepaths' => 0));
$pdf_temp_path = '../temp/pdfs/';
$pdf_files = array();
$margin_top = 40;
$margin_left = 10;
$spacing = 10;
$img_size = 18;
$line_height = 5;
$label_width = 20;
$value_width = 80;
$product_per_col = 8;
$product_per_page = $product_per_col * 2;
foreach ($supplier_list as $sup_id => $sl) {
    $pdf = new PDF('P', 'mm', 'A4');
    $pdf->setTitle('J&G Elements Picking List');
 $deleted_eans_reported = retrieveOTDEremovedEANList();
 $create_image_zip = false;
 $trigger_jms_manually = false;
 $deleted_eans = array();
 $temp_images = array();
 if ($create_image_zip) {
     $zip_filename = $sp_detail['jng_id'] . 'media-' . date('YmdHis') . '.zip';
     $zip_file = SP_OTTODE_TEMP_FOLDER . $zip_filename;
     $zip_final = SP_OTTODE_UPLOAD_PATH . $zip_filename;
     if (file_exists($zip_file)) {
         unlink($zip_file);
     }
     if (file_exists($zip_final)) {
         unlink($zip_final);
     }
     $zipper = new zip_file($zip_file);
     $zipper->set_options(array('storepaths' => 0));
 }
 //SPLIT FOR EACH XML MAX 5MB
 $otto_xml_limit = 5240000;
 //PREPARE XML FILE HANDLER
 $xml_files = array();
 $xml_filename_template = $sp_detail['jng_id'] . 'AE-' . date('YmdHis');
 $new_xml = createNewXML($xml_filename_template, $sp_detail, $xml_files);
 $xml_filename = $new_xml['filename'];
 $xml_content = $new_xml['content'];
 $xml_files[] = $xml_filename;
 $xml_content .= writeXMLopen('Styles', 0);
 $file = createNewXMLOnServer($xml_filename, $xml_content);
 //CLEAR
 $xml_content = '';
Esempio n. 22
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);
Esempio n. 23
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;
}
Esempio n. 24
0
	@chmod($cache_data_file, 0777);
	@chmod($sitemap_xml_file, 0777);
	@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'))
Esempio n. 25
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";
*/
//---------------------------------------------------------