Ejemplo n.º 1
1
 /**
  * Render a response object.
  */
 function render($output_body = true)
 {
     $this->outputHeaders();
     if ($output_body) {
         $manifest = $this->stdio->exec(array('get_manifest_of', $this->revision));
         $stanzas = IDF_Scm_Monotone_BasicIO::parse($manifest);
         $zip = new ZipStream();
         foreach ($stanzas as $stanza) {
             if ($stanza[0]['key'] != 'file') {
                 continue;
             }
             $content = $this->stdio->exec(array('get_file', $stanza[1]['hash']));
             $zip->add_file($stanza[0]['values'][0], $content);
         }
         $zip->finish();
     }
 }
Ejemplo n.º 2
0
 function __construct($plgFile, $plgName, $domain = '')
 {
     $this->status = '';
     $this->error = '';
     if (empty($plgName)) {
         $plgName = basename($plgFile, '.php');
         $plgName = ucfirst(strtr($plgName, '-_', '  '));
     }
     $this->plgName = $plgName;
     $this->slug = strtolower(strtr($plgName, ' !.,', '----'));
     $this->slug = str_replace("--", "-", $this->slug);
     if (empty($domain)) {
         $domain = $this->slug;
     }
     $this->domain = $domain;
     $this->plgDir = dirname($plgFile);
     $this->plgURL = plugin_dir_url($plgFile);
     $locale = get_locale();
     $this->locale = str_replace('-', '_', $locale);
     $this->target = $this->locale;
     if (!is_admin()) {
         return;
     }
     if (!session_id()) {
         session_start();
     }
     if (!empty($_POST['ezt-savePot']) || !empty($_POST['ezt-download'])) {
         // saving cannot be done from handleSubmits
         // because it would be too late for the headers.
         $slug = $_POST['ezt-slug'];
         if ($slug == $this->slug) {
             if (!empty($_POST['ezt-savePot'])) {
                 $target = $_POST['ezt-target'];
                 $file = "{$slug}-{$target}.zip";
                 $potArray = unserialize(gzinflate(base64_decode($_POST['potArray'])));
                 $poName = $target;
             }
             if (!empty($_POST['ezt-download'])) {
                 require_once ABSPATH . WPINC . '/pluggable.php';
                 global $current_user;
                 get_currentuserinfo();
                 $msg = array();
                 $msg['name'] = $current_user->user_firstname . " " . $current_user->user_lastname;
                 $msg['email'] = $current_user->user_email;
                 $msg['blog'] = get_bloginfo('blog');
                 $msg['url'] = get_bloginfo('url');
                 $msg['charset'] = get_bloginfo('charset');
                 $msg['locale'] = $this->locale;
                 $msg['ezt-target'] = "POT File";
                 $file = "{$slug}.zip";
                 $s = $this->getFileContents();
                 $POs = $this->getTranPOs($s);
                 $potArray = $this->mkPotStr($POs, $msg);
                 $poName = $slug;
             }
             $zip = new ZipStream($file);
             if ($this->isEmbedded && $slug != 'easy-translator' && $slug != 'easy-translator-lite') {
                 $zip->add_file("readme.txt", "Please edit the included PO files using appropriate tools such as poedit (or any text editor) and email them to the plugin author. If you are translating one of my plugins, the email address is manoj@thulasidas.com.");
             }
             foreach ($potArray as $d => $str) {
                 if (empty($d)) {
                     // skip strings with no domain -- they are WP core ones
                     continue;
                 }
                 if ($d == $slug) {
                     $filePO = "{$poName}.po";
                 } else {
                     // d should be 'easy-common'
                     $filePO = "{$poName}_{$d}.po";
                 }
                 $zip->add_file($filePO, $str);
             }
             $zip->finish();
             $this->status .= '<div class="updated">Pot file: ' . $file . ' was saved.</div> ';
             exit(0);
         }
     }
 }
Ejemplo n.º 3
0
/**
 * Outputs a file for zip download
 * @param string $zipname name of the zip file
 * @param string $file the file to zip
 */
function putZip($zipname, $file)
{
    //we are dealing with file system items, convert the names
    $fileFS = internalToFilesystem($file);
    if (class_exists('ZipArchive')) {
        $zipfileFS = tempnam('', 'zip');
        $zip = new ZipArchive();
        $zip->open($zipfileFS, ZipArchive::CREATE);
        $zip->addFile($fileFS, basename($fileFS));
        $zip->close();
        ob_get_clean();
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: private", false);
        header("Content-Type: application/zip");
        header("Content-Disposition: attachment; filename=" . basename($zipname) . ";");
        header("Content-Transfer-Encoding: binary");
        header("Content-Length: " . filesize($zipfileFS));
        readfile($zipfileFS);
        // remove zip file from temp path
        unlink($zipfileFS);
    } else {
        include_once SERVERPATH . '/' . ZENFOLDER . '/lib-zipStream.php';
        $zip = new ZipStream(internalToFilesystem($zipname));
        $zip->add_file_from_path(basename($fileFS), $fileFS);
        $zip->finish();
    }
}
Ejemplo n.º 4
0
 /**
  *Export an entire collection as a zip file filled with METS xml 
  *files for each item.
  *
  *@param int $collectionID The ID of the omeka collection to export
  *@return void
  */
 public function exportCollectionZip($collectionID)
 {
     include_once dirname(dirname(__FILE__)) . '/libraries/zipstream-php-0.2.2/zipstream.php';
     $collection = get_record_by_id("collection", $collectionID);
     $items = get_records('Item', array('collection' => $collectionID), 999);
     error_reporting(0);
     $zip = new ZipStream('Collection_' . $collection->id . '.zip');
     foreach ($items as $item) {
         ob_start();
         $this->_generateMETS($item->id, false);
         $zip->add_file("Item_" . $item->id . ".mets.xml", ob_get_clean());
     }
     $zip->finish();
 }
Ejemplo n.º 5
0
 public static function apiDownload(Request $r)
 {
     self::authenticateRequest($r);
     self::validateStats($r);
     // Get our runs
     $relevant_columns = array("run_id", "guid", "language", "status", "verdict", "runtime", "penalty", "memory", "score", "contest_score", "time", "submit_delay", "Users.username", "Problems.alias");
     try {
         $runs = RunsDAO::search(new Runs(array("contest_id" => $r["contest"]->getContestId())), "time", "DESC", $relevant_columns);
     } catch (Exception $e) {
         // Operation failed in the data layer
         throw new InvalidDatabaseOperationException($e);
     }
     $zip = new ZipStream($r["contest_alias"] . '.zip');
     // Add runs to zip
     $table = "guid,user,problem,verdict,points\n";
     foreach ($runs as $run) {
         $zip->add_file_from_path("runs/" . $run->getGuid(), RunController::getSubmissionPath($run));
         $columns[0] = 'username';
         $columns[1] = 'alias';
         $usernameProblemData = $run->asFilteredArray($columns);
         $table .= $run->getGuid() . "," . $usernameProblemData['username'] . "," . $usernameProblemData['alias'] . "," . $run->getVerdict() . "," . $run->getContestScore();
         $table .= "\n";
     }
     $zip->add_file("summary.csv", $table);
     // Add problem cases to zip
     $contest_problems = ContestProblemsDAO::GetRelevantProblems($r["contest"]->getContestId());
     foreach ($contest_problems as $problem) {
         $zip->add_file_from_path($problem->getAlias() . "_cases.zip", PROBLEMS_PATH . "/" . $problem->getAlias() . "/cases.zip");
     }
     // Return zip
     $zip->finish();
     die;
 }
Ejemplo n.º 6
0
 /**
  * Creates a zip file of the album
  *
  * @param string $albumname album folder
  * @param bool fromcache if true, images will be the "sized" image in the cache file
  */
 static function create($albumname, $fromcache)
 {
     global $_zp_zip_list, $_zp_gallery, $defaultSize;
     $album = newAlbum($albumname);
     if (!$album->isMyItem(LIST_RIGHTS) && !checkAlbumPassword($albumname)) {
         self::pageError(403, gettext("Forbidden"));
     }
     if (!$album->exists) {
         self::pageError(404, gettext('Album not found'));
     }
     $_zp_zip_list = array();
     if ($fromcache) {
         $opt = array('large_file_size' => 5 * 1024 * 1024, 'comment' => sprintf(gettext('Created from cached images of %1$s on %2$s.'), $album->name, zpFormattedDate(DATE_FORMAT, time())));
         loadLocalOptions(false, $_zp_gallery->getCurrentTheme());
         $defaultSize = getOption('image_size');
         self::AddAlbumCache($album, strlen($albumname), SERVERPATH . '/' . CACHEFOLDER . '/' . $albumname);
     } else {
         $opt = array('large_file_size' => 5 * 1024 * 1024, 'comment' => sprintf(gettext('Created from images in %1$s on %2$s.'), $album->name, zpFormattedDate(DATE_FORMAT, time())));
         self::AddAlbum($album, strlen($albumname), SERVERPATH . '/' . ALBUMFOLDER . '/' . $albumname);
     }
     $zip = new ZipStream($albumname . '.zip', $opt);
     foreach ($_zp_zip_list as $path => $file) {
         @set_time_limit(6000);
         $zip->add_file_from_path(internalToFilesystem($file), internalToFilesystem($path));
     }
     $zip->finish();
 }
Ejemplo n.º 7
0
 public static function apiDownload(Request $r)
 {
     self::authenticateRequest($r);
     self::validateStats($r);
     // Get our runs
     $relevant_columns = array('run_id', 'guid', 'language', 'status', 'verdict', 'runtime', 'penalty', 'memory', 'score', 'contest_score', 'time', 'submit_delay', 'Users.username', 'Problems.alias');
     try {
         $runs = RunsDAO::search(new Runs(array('contest_id' => $r['contest']->getContestId())), 'time', 'DESC', $relevant_columns);
     } catch (Exception $e) {
         // Operation failed in the data layer
         throw new InvalidDatabaseOperationException($e);
     }
     $zip = new ZipStream($r['contest_alias'] . '.zip');
     // Add runs to zip
     $table = "guid,user,problem,verdict,points\n";
     foreach ($runs as $run) {
         $zip->add_file_from_path('runs/' . $run->getGuid(), RunController::getSubmissionPath($run));
         $columns[0] = 'username';
         $columns[1] = 'alias';
         $usernameProblemData = $run->asFilteredArray($columns);
         $table .= $run->getGuid() . ',' . $usernameProblemData['username'] . ',' . $usernameProblemData['alias'] . ',' . $run->getVerdict() . ',' . $run->getContestScore();
         $table .= "\n";
     }
     $zip->add_file('summary.csv', $table);
     // Add problem cases to zip
     $contest_problems = ContestProblemsDAO::GetRelevantProblems($r['contest']->getContestId());
     foreach ($contest_problems as $problem) {
         $zip->add_file_from_path($problem->getAlias() . '_cases.zip', PROBLEMS_PATH . '/' . $problem->getAlias() . '/cases.zip');
     }
     // Return zip
     $zip->finish();
     die;
 }
 static function downloadToZip($data)
 {
     // set cookie
     setcookie('fileLoading', true, time() + 10, '/');
     //Create ZipArchive using Stream
     $zipStream = new ZipStream('exams.zip');
     foreach ($data as $item) {
         //Add files
         $filesInDirectory = $item["value"];
         foreach ($filesInDirectory as $file) {
             //Download file
             $downloaded_file = file_get_contents($file);
             //Add to zip
             $zipStream->add_file($item["key"] . "/" . basename($file), $downloaded_file);
         }
     }
     $zipStream->finish();
     //Clean up
     ob_clean();
     flush();
 }
Ejemplo n.º 9
0
                        header("Expires: 0");
                        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                        header("Cache-Control: private", false);
                        header("Content-Type: application/zip");
                        header("Content-Disposition: attachment; filename=" . basename($zipname) . ";");
                        header("Content-Transfer-Encoding: binary");
                        header("Content-Length: " . filesize($zipname));
                        readfile($zipname);
                        // remove zip file from temp path
                        unlink($zipname);
                        exit;
                    } else {
                        include_once SERVERPATH . '/' . ZENFOLDER . '/lib-zipStream.php';
                        $zip = new ZipStream($zipname);
                        $zip->add_file_from_path(internalToFilesystem(basename($file)), internalToFilesystem($file));
                        $zip->finish();
                    }
                }
                break;
        }
    }
}
list($subtabs, $default) = getLogTabs();
$zenphoto_tabs['logs'] = array('text' => gettext("logs"), 'link' => WEBPATH . "/" . ZENFOLDER . '/admin-logs.php?page=logs', 'subtabs' => $subtabs, 'default' => $default);
printAdminHeader('logs', $default);
echo "\n</head>";
?>

<body>

	<?php 
Ejemplo n.º 10
0
@(require_once "zipstream.php");
/**
 * generate the metadata conf
 */
function getMetadataContent($conf)
{
    return "[Desktop Entry]\n" . "Name=" . $conf->title . "\n" . "Comment=" . $conf->title . "\n" . "Type=Service\n" . "X-KDE-ServiceTypes=Plasma/Comic\n" . "Icon=favicon.png\n" . "\n" . "X-KDE-Library=plasma_comic_krossprovider\n" . "X-KDE-PluginInfo-Author=Frederic Forjan\n" . "X-KDE-PluginInfo-Email=fforjab@free.fr\n" . "X-KDE-PluginInfo-Name=" . $conf->title . "\n" . "X-KDE-PluginInfo-Version=0.2\n" . "X-KDE-PluginInfo-Website=http://stripit.sf.net\n" . "X-KDE-PluginInfo-License=GPLv2\n" . "X-KDE-PluginInfo-EnabledByDefault=true\n" . "X-KDE-PlasmaComicProvider-SuffixType=Number";
}
/**
 * return the favicon content
 */
function getFaviconContent()
{
    return implode("", file("../favicon.png"));
}
/**
 * generate the main.es file
 */
function getMainEsContent($conf)
{
    return "//auto-generated URL\nvar URL =  \"" . $conf->url . "/\"\n" . implode("", file("main.es.template"));
}
# create a new stream object
$conf = new configuration();
$zipfile = new ZipStream($conf->title . ".comic", array('content_type' => 'application/octet-stream'));
$conf = new configuration();
$zipfile->add_file("favicon.png", getFaviconContent());
$zipfile->add_file("metadata.desktop", getMetadataContent($conf));
$zipfile->add_file("contents/code/main.es", getMainEsContent($conf));
$zipfile->finish();
Ejemplo n.º 11
0
 /**
  * Creates a zip file of the album
  *
  * @param object $album album folder
  * @param string $zipname name of zip file
  * @param bool fromcache if true, images will be the "sized" image in the cache file
  */
 static function create($album, $zipname, $fromcache)
 {
     global $_zp_zip_list, $_zp_albums_visited_albumMenu, $_zp_gallery, $defaultSize;
     if (!$album->exists) {
         self::pageError(404, gettext('Album not found'));
     }
     if (!$album->checkAccess()) {
         self::pageError(403, gettext("Forbidden"));
     }
     $_zp_albums_visited_albumMenu = $_zp_zip_list = array();
     if ($fromcache) {
         $opt = array('large_file_size' => 5 * 1024 * 1024, 'comment' => sprintf(gettext('Created from cached images of %1$s on %2$s.'), $album->name, zpFormattedDate(DATE_FORMAT, time())));
         $defaultSize = getThemeOption('image_size', NULL, $_zp_gallery->getCurrentTheme());
     } else {
         $defaultSize = NULL;
         $opt = array('large_file_size' => 5 * 1024 * 1024, 'comment' => sprintf(gettext('Created from images in %1$s on %2$s.'), $album->name, zpFormattedDate(DATE_FORMAT, time())));
     }
     self::AddAlbum($album, $fromcache);
     if (class_exists('ZipArchive')) {
         $zipfileFS = tempnam('', 'zip');
         $zip = new ZipArchive();
         $zip->open($zipfileFS, ZipArchive::CREATE);
         foreach ($_zp_zip_list as $path => $file) {
             @set_time_limit(6000);
             $zip->addFile($path, internalToFilesystem(trim($file, '/')));
         }
         $zip->close();
         ob_get_clean();
         header("Pragma: public");
         header("Expires: 0");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Cache-Control: private", false);
         header("Content-Type: application/zip");
         header("Content-Disposition: attachment; filename=" . basename($zipname . '.zip') . ";");
         header("Content-Transfer-Encoding: binary");
         header("Content-Length: " . filesize($zipfileFS));
         readfile($zipfileFS);
         // remove zip file from temp path
         unlink($zipfileFS);
     } else {
         require_once SERVERPATH . '/' . ZENFOLDER . '/lib-zipStream.php';
         $zip = new ZipStream(internalToFilesystem($zipname) . '.zip', $opt);
         foreach ($_zp_zip_list as $path => $file) {
             @set_time_limit(6000);
             $zip->add_file_from_path(internalToFilesystem($file), $path);
         }
         $zip->finish();
     }
 }