Also ich habe so ein Modul mal geschrieben.
Input
Code: Alles auswählen
/**
* Download aus Upload-Verzeichnis
*
* INPUT
**/
?>
<table cellspacing="0" cellpadding="0" cellpadding="4">
<tr>
<td style="font-size:11px">Upload-Zweig:</td>
<td>
<select name="CMS_VAR[0]">
<option value="0"></option>
<?php
$sql = "SELECT DISTINCT dirname from ".$cfg["tab"]["upl"];
$db->query($sql);
while ( $db->next_record() ) {
$upload_dir=substr_replace($db->f("dirname"),'',(strlen($db->f("dirname"))-1));
if ( "CMS_VALUE[0]" == $upload_dir) {
echo '<option selected="selected" value="'.$upload_dir.'">'.$db->f("dirname").'</option>';
} else {
echo '<option value="'.$upload_dir.'">'.$db->f("dirname").'</option>';
}
}
?>
</select>
</td>
</tr>
<?php
Output:
Code: Alles auswählen
<?php
//Variablen deklarieren und Werte zuweisen
$DAA_CUR_DIR = $_GET['DAA_CUR_DIR'];
$_DAA_STARTPATH_INTERNAL = $cfgClient[$client]['upl']['path'].CMS_VALUE[0];
$_DAA_STARTPATH_EXTERNAL = $cfgClient[$client]["htmlpath"]["frontend"] . $cfgClient[$client]["upload"];
if($DAA_CUR_DIR == "")
{
$_PARAM = $_DAA_STARTPATH_INTERNAL;
}
else
{
$_PARAM = $_DAA_STARTPATH_INTERNAL."/".$DAA_CUR_DIR;
}
//Klasse instanziieren
$_DAA = new daa_download($cfgClient[$client]["upload"], $cfgClient[$client]["htmlpath"]["frontend"], $_DAA_STARTPATH_INTERNAL);
if($_GET['DAA_GET_FILE'] == "")
{
$_DIR_CONTENT_ARRAYS = $_DAA->daa_get_dir_content($_PARAM);
}
else
{
$_DAA->daa_download_file($_GET['DAA_GET_FILE']);
}
$_DIR_ARRAY = $_DAA->_DAA_MULTI_ARRAY['dirs'];
$_FILE_ARRAY = $_DAA->_DAA_MULTI_ARRAY['files'];
$_HTML = $_DAA->daa_generate_download_html($_DIR_ARRAY, "yes");
$_HTML .= $_DAA->daa_generate_download_html($_FILE_ARRAY, "no");
if($_HTML == "")
$_HTML = "Das Verzeichnis ist leer.";
$_HTML = "<table width='100%'>".$_HTML;
$_HTML .= "<tr><td colspan='2'> </td></tr>";
if($_GET['DAA_CUR_DIR'] != "")
$_HTML .= "<tr><td colspan='2' align='left'><a href='javascript:history.back()'>Zurück</a></td></tr>";
$_HTML .= "</table>";
echo $_HTML;
//////////////////////////////////////////////////////////////////////////////////////////
/* Funktionen
*/
class daa_download{
var $_DAA_MULTI_ARRAY = array();
var $_DAA_HTML;
var $DAA_upl_path;
var $DAA_frontend_path;
var $_DAA_internal_path;
function daa_download($upl_path, $html_path, $internal_path)
{
$this->DAA_upl_path = $upl_path;
$this->DAA_frontend_path = $html_path;
$this->DAA_internal_path = $internal_path;
}
//Verzeichnisinhalt auslesen
function daa_get_dir_content($_DIRECTORY)
{
$_DAA_DIR_HANDLER = dir($_DIRECTORY);
$_DAA_DIR_ARRAY = array();
$_DAA_FILE_ARRAY = array();
while($_DAA_CONTENT = $_DAA_DIR_HANDLER->read())
{
if(is_dir($_DIRECTORY."/".$_DAA_CONTENT) && $_DAA_CONTENT != "." && $_DAA_CONTENT != "..")
{
array_push($_DAA_DIR_ARRAY, $_DAA_CONTENT);
}
if(is_file($_DIRECTORY."/".$_DAA_CONTENT))
{
array_push($_DAA_FILE_ARRAY, $_DAA_CONTENT);
}
}
$this->_DAA_MULTI_ARRAY['dirs'] = $_DAA_DIR_ARRAY;
$this->_DAA_MULTI_ARRAY['files'] = $_DAA_FILE_ARRAY;
return $this->_DAA_MULTI_ARRAY;
}
//HTML-Code generieren
function daa_generate_download_html($_ARRAY, $is_dir_array)
{
$this->_DAA_HTML = "";
foreach($_ARRAY as $value)
{
if($is_dir_array == "yes")
{
$this->_DAA_HTML .= "<tr>\n";
$this->_DAA_HTML .= "<td>\n";
$this->_DAA_HTML .= "<a href='".$this->DAA_frontend_path."front_content.php?idcat=".$_GET['idcat']."&DAA_CUR_DIR=".urlencode($value)."' class='visited'>".$value."</a>";
$this->_DAA_HTML .= "</td>\n";
$this->_DAA_HTML .= "<td>\n";
$this->_DAA_HTML .= "</td>\n";
$this->_DAA_HTML .= "</tr>\n";
}
else
{
$filesize = filesize($this->DAA_internal_path."/".$_GET['DAA_CUR_DIR']."/".$value);
$this->_DAA_HTML .= "<tr>\n";
$this->_DAA_HTML .= "<td align='left'>\n";
$this->_DAA_HTML .= "<a href='".$this->DAA_frontend_path."download.php?DAA_GET_FILE=".urlencode($value)."&DAA_GET_PATH=".$this->DAA_upl_path.CMS_VALUE[0]."/".$_GET['DAA_CUR_DIR']."/' class='visited'>".$value."</a>";
$this->_DAA_HTML .= "</td>\n";
$this->_DAA_HTML .= "<td align='right'>\n";
$this->_DAA_HTML .= round(($filesize / 1024), 1)." KBytes";
$this->_DAA_HTML .= "</td>\n";
$this->_DAA_HTML .= "</tr>\n";
}
}
return $this->_DAA_HTML;
}
/* Ende Funktionen
*/
}
//////////////////////////////////////////////////////////////////////////////////////////
?>
Dann brauchst du noch eine Datei namens download.php, die direkt im Ordner /cms liegen sollte:
Code: Alles auswählen
<?php
@include("../contenido/includes/config.php");
if($_GET['DAA_GET_FILE'] != "")
{
$file = $_GET['DAA_GET_FILE'];
$len = filesize($cfg['path']['frontend'] ."/".$_GET['DAA_GET_PATH'].$file);
$ext = substr($file, 0, (strlen($file)-3));
switch( $ext ){
case "pdf": $ctype="application/pdf"; break;
case "exe": $ctype="application/octet-stream"; break;
case "zip": $ctype="application/zip"; break;
case ".gz": $ctype="application/zip"; break;
case "tar": $ctype="application/zip"; break;
case "rar": $ctype="application/zip"; break;
case "zip": $ctype="application/zip"; break;
case "doc": $ctype="application/msword"; break;
case "xls": $ctype="application/vnd.ms-excel"; break;
case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpg": $ctype="image/jpg"; break;
default: $ctype="application/force-download";
}
if(strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
{
$attachment = "";
if($content_type == "")
$content_type = "application/force-download;";
}
else
{
$attachment = "attachment;";
$content_type = "application/octet-stream";
}
header("Expires: Mon, 26 Jul 2001 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Cache-control: private");
header("Content-type: ".$ctype."");
header("Content-Disposition:attachment; filename=$file");
header("Content-Transfer-Encoding: binary");
header("Expires: 0");
header("Content-Length: ".$len);
readfile($_GET['DAA_GET_PATH'].$file);
}
?>