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;
 }
 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;
 }
            // Create a unique file name
            $readme_filename = 'readme_' . time() . '.txt';
            // Create the temporary readme file
            if ($fd = @fopen($CONFIG['fullpath'] . 'edit/' . $readme_filename, 'wb')) {
                @fwrite($fd, $plaintext_message);
                @fclose($fd);
                // Add the plain text file to the file list
                $filelist[] = 'edit/' . $readme_filename;
            } else {
                // Something went wrong while creating the readme file.
                // We'll continue anyway.
            }
        }
        $favs = implode(', ', $FAVPICS);
        $result = cpg_db_query("SELECT filepath, filename 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'];
        }
    }
    $zip = new zip_file('pictures.zip');
    $options = array('basedir' => "./{$CONFIG['fullpath']}", 'inmemory' => 1, 'recurse' => 0, 'storepaths' => 0);
    $zip->set_options($options);
    $zip->add_files($filelist);
    $zip->create_archive();
    ob_end_clean();
    $zip->download_file();
    if ($CONFIG['enable_zipdownload'] == 2) {
        @unlink($CONFIG['fullpath'] . 'edit/' . $readme_filename);
    }
}
Пример #4
0
        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");
Пример #5
0
            $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 {
        echo $errors;
    }
} else {
    foreach ($files as $directory => $filedata) {
Пример #6
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;
}
Пример #7
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');
}
Пример #8
0
     }
     // 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.
     if (!$current_User->check_perm('files', 'edit_allowed', false, $selected_Filelist->get_FileRoot())) {
         // We do not have permission to edit files
         $Messages->add(T_('You have no permission to edit/modify files.'), 'error');
         $action = 'list';
         break;
     }
     $allow_locked_filetypes = $current_User->check_perm('files', 'all');
     if (!$selected_Filelist->count()) {
Пример #9
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();
}