function getFilePackage($fileids, $returnContent = false) { $fileids = explode(",", $fileids); include_once "createZip.inc.php"; $createZip = new createZip(); $fileCount = 0; foreach ($fileids as $fileid) { if (file_exists($this->rootPath . $fileid)) { $createZip->addFile(file_get_contents($this->rootPath . $fileid), basename($fileid)); $fileCount++; } } if ($fileCount > 0) { if ($returnContent != true) { header("Content-Type: application/zip"); header("Content-Transfer-Encoding: Binary"); #header("Content-length: ".strlen($zipped)); header("Content-disposition: attachment; filename=\"package.zip\""); echo $createZip->getZippedfile(); } else { return $createZip->getZippedfile(); } } else { $this->error('no files zipped'); } }
function getFilePackage($paths, $returnContent = false) { // paths will look like: // "/filestore~kristinaRose.jpeg,/filestore/pics~harmonyRose.jpeg" logAction('getFilePackage', $paths); $paths = explode("\\\\,", $paths); $files = array(); $fileCount = 0; include_once "inc/createZip.inc.php"; $createZip = new createZip(); foreach ($paths as $path) { $i = preg_split("/\\~/", $path); $files[] = array("path" => $i[0], "filename" => $i[1]); } foreach ($files as $file) { $filePath = $file['path'] . '/' . $file['filename']; if (file_exists($filePath)) { $createZip->addFile(file_get_contents($filePath), $file['filename']); $fileCount++; } } if ($fileCount > 0) { if ($returnContent != true) { header("Content-Type: application/zip"); header("Content-Transfer-Encoding: Binary"); header("Content-disposition: attachment; filename=\"package.zip\""); echo $createZip->getZippedfile(); } else { return $createZip->getZippedfile(); } } else { error('No files zipped.'); } }
function tfu_zip_download($files, $enable_file_download) { global $zip_folder; // The folder is used to create the temp download files! if ($enable_file_download == 'false' && !isset($_GET['fullscreen'])) { echo 'This action is not enabled!'; exit(0); } $createZip = new createZip(); $nrfiles = count($files); for ($i = 0; $i < $nrfiles; $i++) { $createZip->addFile(file_get_contents($files[$i]), my_basename($files[$i])); } $fileName = $zip_folder . '/' . $_GET['zipname']; $fd = fopen($fileName, "wb"); $out = fwrite($fd, $createZip->getZippedfile()); fclose($fd); tfu_download($fileName, $enable_file_download); @unlink($fileName); }
// Databses you wish to backup , can be many ( tables array if contains table names only those tables will be backed up ) $configBackupDB[] = array('server' => $dbhost, 'username' => $dbuser, 'password' => $dbpword, 'database' => $dbname); // Put in a email ID if you want the backup emailed $configEmail = ''; // Include backup functions file include 'includes/backup_functions.php'; $backupName = "backup-" . date('d-m-y') . '-' . date('H-i-s') . '.zip'; $createZip = new createZip(); if (isset($configBackup) && is_array($configBackup) && count($configBackup) > 0) { // Lets backup any files or folders if any foreach ($configBackup as $dir) { $basename = basename($dir); // dir basename if (is_file($dir)) { $fileContents = file_get_contents($dir); $createZip->addFile($fileContents, $basename); } else { $createZip->addDirectory($basename . "/"); $files = directoryToArray($dir, true); $files = array_reverse($files); foreach ($files as $file) { $zipPath = explode($dir, $file); $zipPath = $zipPath[1]; // skip any if required $skip = false; foreach ($configSkip as $skipObject) { if (strpos($file, $skipObject) === 0) { $skip = true; break; } }
function getFilePackage($fileids, $returnContent = false) { global $database, $fileinfo, $filepath; $fileids = preg_split("/\\,/", $fileids); include_once "inc/createZip.inc.php"; $createZip = new createZip(); $fileCount = 0; logAction('getFilePackage', $fileids); foreach ($fileids as $fileid) { if (getFileInfo($fileid)) { if (getUserAuth('download', $fileinfo['virtualpath'])) { logAction('get', $fileid); $query = "update {$GLOBALS['tablePrefix']}filesystem set downloads=downloads+1 where id={$fileid}"; $result = mysql_query($query, $database); $createZip->addFile(file_get_contents($filepath), "{$fileinfo['filename']}"); $fileCount++; } else { // denied } } else { // denied } } if ($fileCount > 0) { if ($returnContent != true) { header("Content-Type: application/zip"); header("Content-Transfer-Encoding: Binary"); #header("Content-length: ".strlen($zipped)); header("Content-disposition: attachment; filename=\"package.zip\""); echo $createZip->getZippedfile(); } else { return $createZip->getZippedfile(); } } else { error('no files zipped'); } }
$base = md5(rand(0,99999) + time()); $s = new Scaffold($table); $s->download = true; /*file_put_contents( "temp/$base/{$table['list_page']}", $s->listtable() ); file_put_contents( "temp/$base/{$table['new_page']}", $s->newrow() ); file_put_contents( "temp/$base/{$table['edit_page']}", $s->editrow() ); file_put_contents( "temp/$base/{$table['delete_page']}", $s->deleterow() ); */ $createZip = new createZip; $createZip -> addFile($s->listtable(), $table['list_page'] ); $createZip -> addFile($s->newrow(), $table['new_page'] ); $createZip -> addFile($s->editrow(), $table['edit_page'] ); $createZip -> addFile($s->deleterow(), $table['delete_page'] ); $fileName = "temp/$base.zip"; $fd = fopen ($fileName, "wb"); $out = fwrite ($fd, $createZip -> getZippedfile() ); fclose ($fd); $createZip -> forceDownload($fileName); //@unlink($fileName); } else {
$regex_to_match = count($pathspec) > 1 ? $pathspec[1] : null; /* strip off the relative-path-to-root so we're left with the full, yet relative, path. Handy when restoring data: extract zip equals (almost) done. */ $basename = $dir; if (is_file(BASE_PATH . '/' . $dir)) { if ($scantype == 'file') { $file_collection[] = array('file' => $basename); log_current_backup_state($progressfile, $file_collection); if (0) { // kick the PHP watchdog and make sure we can run for a long time at the same time: set_time_limit(0); $fileContents = file_get_contents(BASE_PATH . '/' . $dir); if (false === $createZip->addFile($fileContents, $basename)) { throw new FbX($ccms['lang']['system']['error_write'] . ": " . $fileName); } } } } else { if ($scantype != 'file') { $basename .= substr($basename, -1, 1) != '/' ? '/' : ''; $file_collection[] = array('dir' => $basename); log_current_backup_state($progressfile, $file_collection); if (0) { $createZip->addDirectory($basename); } $files = directoryToArray(BASE_PATH . '/' . $dir, $scantype == 'tree', $regex_to_match); /* * opendir+readdir deliver the file set in arbitrary order.
echo "<?php\n"; echo '$archivetime="' . $d . '";'; echo "\n?>"; ob_end_flush(); /* Zip the offline doc */ if (!is_dir('archives')) { mkdir('archives'); copy('include/index.html', 'archives/index.html'); } $zip = new createZip(); $zip->addDirectory("images/"); if ($dh = opendir('offline')) { while (($file = readdir($dh)) !== false) { if (is_file('offline/' . $file)) { $fileContents = file_get_contents('offline/' . $file); $zip->addFile($fileContents, $file); } } closedir($dh); } if ($dh = opendir('offline/images')) { while (($file = readdir($dh)) !== false) { if (is_file('offline/images/' . $file)) { $fileContents = file_get_contents('offline/images/' . $file); $zip->addFile($fileContents, 'images/' . $file); } } closedir($dh); } $fileName = 'archives/pol-docs-099-' . $d . '.zip'; $fd = fopen($fileName, "wb");
public function home() { $dim = array(900, 600); $dim = array(800, 533); $dim = array(600, 400); if (_button()) { $v = $this->__(array('start' => 0, 'folder' => '', 'width' => 0, 'height' => 0)); $images = $types = w(); $dim = array($v['width'], $v['height']); @set_time_limit(0); $original = PCK . $v['folder'] . '/'; $gallery = $original . 'gallery/'; if (!@file_exists($original)) { exit; } if (!@file_exists($gallery)) { @mkdir($gallery, 0777); @chmod($gallery, 0777); } require_once XFS . XCOR . 'upload.php'; require_once XFS . XCOR . 'zip.php'; if (!is_writable($original) || !is_writable($gallery)) { exit; } $upload = new upload(); $zip = new createZip(); $fp = @opendir(PCK . $v['folder']); while ($row = @readdir($fp)) { if (preg_match('#^(.*?)\\.(jpg|JPG)$#is', $row, $s) && @is_readable($original . $row)) { $images[] = $row; $type = preg_match('#^(\\d+)$#is', $s[1]) ? 'numeric' : 'string'; $types[$type] = true; } } @closedir($fp); if (!count($images)) { exit('No hay archivos para convertir.'); } $multisort = array(&$images, SORT_ASC); if (!isset($types['string'])) { $multisort[] = SORT_NUMERIC; } hook('array_multisort', $multisort); foreach ($images as $image) { $row = $upload->_row($gallery, $image); $xa = $upload->resize($row, $original, $gallery, $start, $dim, false, false, false, $original . $image); $start++; $zip->addFile(file_get_contents($gallery . $xa['filename']), $xa['filename']); } $zipfile = PCK . $folder . '.zip'; $fd = @fopen($zipfile, 'wb'); $out = @fwrite($fd, $zip->getZippedfile()); @fclose($fd); $zip->forceDownload($zipfile); @unlink($zipfile); exit; } $options = w(); $fp = @opendir(PCK); while ($file = @readdir($fp)) { if (substr($file, 0, 1) != '.' && is_dir(PCK . $file)) { $options[] = $file; } } @closedir($fp); foreach ($options as $row) { echo '<option value="' . $row . '">' . $row . '</option>'; } return; }
} } @closedir($fp); if (!count($images)) { exit('No hay archivos para convertir.'); } $multisort = array(&$images, SORT_ASC); if (!isset($types['string'])) { $multisort[] = SORT_NUMERIC; } hook('array_multisort', $multisort); foreach ($images as $image) { $row = $upload->_row($gallery, $image); $xa = $upload->resize($row, $original, $gallery, $start, $dim, false, false, false, $original . $image); $start++; $zip->addFile(file_get_contents($gallery . $xa['filename']), $xa['filename']); } $zipfile = PCK . $folder . '.zip'; if ($fd = @fopen($zipfile, 'wb')) { $out = @fwrite($fd, $zip->getZippedfile()); @fclose($fd); $zip->forceDownload($zipfile); @unlink($zipfile); } exit; } $options = w(); $fp = @opendir(PCK); while ($file = @readdir($fp)) { if (substr($file, 0, 1) != '.' && is_dir(PCK . $file)) { $options[] = $file;