Example #1
0
<?php

/*
  This file is part of the Filebin package.
  Copyright (c) 2003-2009, Stephen Olesen
  All rights reserved.
  More information is available at http://filebin.ca/
*/
require "template.inc.php";
require "filebin.inc.php";
$tag = $_GET["tag"];
$path = substr($_GET["path"], 1);
$f = new File();
$f->byTag($tag);
if ($f->isValid()) {
    $z = new ZipArchive();
    if ($z->open($f->path) === TRUE) {
        if (substr($path, -1) == '/' || $path == "") {
            for ($i = 0; $i < $z->numFiles; $i++) {
                $s = $z->statIndex($i);
                if ($path == "" || substr_compare($path, $s['name'], 0, strlen($path), true) == 0 && $path != $s['name']) {
                    $arr[] = $s['name'];
                }
            }
            asort($arr);
            foreach ($arr as $n) {
                print '<a href="http://filebin.ca/view/' . $tag . '/' . $n . '">' . $n . '</a><br />';
            }
        } else {
            if (preg_match('/\\.jpe?g/i', $path)) {
                header("Content-Type: image/jpeg");
Example #2
0
<?php

/*
  This file is part of the Filebin package.
  Copyright (c) 2003-2009, Stephen Olesen
  All rights reserved.
  More information is available at http://filebin.ca/
*/
# This does peculiar things with Zip files if On
ini_set('zlib.output_compression', 'Off');
require "filebin.inc.php";
$f = new File();
$f->byTag($_GET["tag"]);
if ($f->isValid()) {
    $etag = hash('sha1', $f->path) . '-' . filemtime($f->path);
    if (isset($_SERVER["HTTP_IF_NONE_MATCH"])) {
        if ($etag == $_SERVER["HTTP_IF_NONE_MATCH"]) {
            header("HTTP/1.0 304 Not Modified");
            exit;
        }
    }
    if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && $_SERVER["HTTP_IF_MODIFIED_SINCE"] == gmdate("D, d M Y H:i:s", filemtime($f->path)) . " GMT") {
        header("HTTP/1.0 304 Not Modified");
        exit;
    }
    if (preg_match('/\\.txt$/', $_GET["path"])) {
        header("Content-Type: text/plain");
    } else {
        if ($_GET["bin"] == "y") {
            header("Content-Type: application/octet-stream");
            header("Content-Disposition: attachment; filename=\"" . basename($_GET["path"]) . "\"");