Flex
(aka Felix Jacobi)
Jop, hier ist es...
directorylist.class.php ist von Dennis Wronka und findet man hier => SourceForge
Diese exzessiven Kommentare sind nur, weil sich jemand anders das Script auch noch anschauen und benutzen wollte, der weder PHP noch deutsch wirklich kann
PHP:
<?php
/*
by Felix Jacobi
© April, 2007 */
## Config Constants [Start]
define('STAT_FILE', './statistics.dat');
define('TRAFFIC_FILE', './traffic.dat');
define('LOAD_DIRECTORY', './vids/');
define('MAX_TRAFFIC', 500000); # In MegaBytes
define('HTML_HEADER', './html/header.tpl');
define('HTML_FOOTER', './html/footer.tpl');
define('HTML_BODY', './html/body.tpl');
## Config Constants [End]
## Require and instance DirectoryListing Class [Start]
require_once('./directorylist.class.php');
$dirlist = new directorylist(LOAD_DIRECTORY);
## Require and instance DirectoryListing Class [End]
## Read LOAD_DIRECTORY and STAT_FILE [Start]
$total = $dirlist->readdir(STAT_FILE);
$config = $total['config'];
$files = $total['files'];
unset($total);
## Read LOAD_DIRECTORY and STAT_FILE [End]
## Check for Download [Start]
if(isset($_GET['action']) && $_GET['action'] == 'load' && isset($_GET['file']) && file_exists(LOAD_DIRECTORY . $_GET['file'])) {
$dirlist->writetraffic(filesize(LOAD_DIRECTORY . $_GET['file']), TRAFFIC_FILE);
header('Content-Type: application/octetstream', true);
header('Content-Disposition: attachment; filename="'.LOAD_DIRECTORY . $_GET['file'].'"');
readfile(LOAD_DIRECTORY . $_GET['file']);
exit;
}
## Check for Download [End]
## Include Header [Start]
include(HTML_HEADER);
## Include Header [End]
## Generate Body [Start]
foreach($files as $value) {
if(isset($config[$value])) {
$tempsize = explode('.', filesize(LOAD_DIRECTORY . $value) / 1024 / 1024);
$filesize = $tempsize[0]." MB";
$file = file_get_contents(HTML_BODY);
$content = str_replace('{NAME}', $config[$value]['filename'], $file);
$content = str_replace('{SIZE}', $filesize, $content);
$content = str_replace('{DATE}', date('j-m-y', $config[$value]['date']), $content);
$content = str_replace('{LINK}', '<a href="./index.php?action=load&file='.$config[$value]['filename'].'">Click</a>', $content);
echo $content;
}
}
## Generate Body [End]
## Include Footer [Start]
$footer = file_get_contents(HTML_FOOTER);
$filesize = explode(".", file_get_contents(TRAFFIC_FILE) / 1024 / 1024);
echo str_replace("{TOTAL_TRAFFIC}", $filesize[0]." MB", $footer);
## Include Footer [End]
?>
directorylist.class.php ist von Dennis Wronka und findet man hier => SourceForge
Diese exzessiven Kommentare sind nur, weil sich jemand anders das Script auch noch anschauen und benutzen wollte, der weder PHP noch deutsch wirklich kann