ich wollte den Downloadscript von mir erweitern und habe jetzt ein Problem. Zwar funktioniert mein Script, doch nur solange ich die Ausgabe in der downloads.php mache. Da ich mein Code an EasyHP anpassen möchte,
dachte ich mir, dass ich zur besseren Übersicht HTML und PHP trennen sollte. Also das ganze ins Template von Style einzubauen.
Mein Problem: Jetzt erkennt er nicht mehr alle Downloads (.zip/.rar) wie zuvor, sondern zeigt mir nur einen an.
Meine Codes:
Meine downloads.php
Code: Alles auswählen
<?php
define("IN_EASYHP", true);
session_start();
if ((!isset($_SESSION['captcha']) AND $_COOKIE['captcha_set'] != 'TRUE') AND ($_GET['mode'] == "new" OR $_GET['mode'] == "save_new")) {
header("Location: captcha.php?link=downloads.php");
}
include "includes/mysql.php";
include "common.php";
include "includes/website.php";
// Downloadscript
@$pfad = $_GET['pfad'];
$home = "downloads";
if (empty($pfad)) {
$dir = $home;
} else {
$dir = $pfad;
}
//readfile/readdir
$i=0;
$j=0;
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if(is_dir($dir."/".$file)) {
$blub[$j] = $file;
$j++;
} else {
// Erlaubte Dateitypen, die angezeigt werden
if (strstr($file, ".rar") || strstr($file, ".zip")) {
$bla[$i] = $file;
$i++;
}
}
}
}
closedir($handle);
}
//Download files
echo "<section id='content3'>";
echo '<div align=center>';
if ($dir != $home) {
$home ="<a href='downloads.php'>Home</a>";
$back =" <a href='javascript:history.back()'>zurück</a><br><br>";
}
@krsort($blub);
if(count($blub)>0) {
foreach ($blub as $file) {
$folder ="<a href=\"downloads.php?pfad=$dir/$file\">$file</a>";
}
}
@krsort($bla);
if(count($bla)>0) {
foreach ($bla as $file) {
$filesize = filesize ("$dir/$file");
if (strstr($file, ".zip")) {
$type = ".zip";
$bild = "styles/matze/images/download_zip.png";
}
if (strstr($file, ".rar")) {
$type = ".rar";
$bild = "styles/matze/images/download_rar.png";
}
if (empty($bild)) {
$bild = "styles/matze/images/download_file.png";
}
$suchmuster = array();
$suchmuster[1] = "/.zip/";
$suchmuster[2] = "/.rar/";
$dateiname = preg_replace($suchmuster, "", $file);
$link = "<a href=\"$dir/$file\"><img src=\"$bild\" alt=\"$file\"></a>";
}
}
echo "</div>";
echo "</section>";
$replace = array (
'page_img' => PAGE_IMG,
'info_img' => INFO_IMG,
'site_img' => SITE_IMG,
'error_img' => ERROR_IMG,
'title' => $lang['downloads'],
'content' => $lang['downloads_on'],
'filename' => $dateiname,
'filesize' => $filesize,
'size' => $lang['size_bytes'],
'link' => $link,
'folder' => $folder,
'home' => $home,
'back' => $back
);
$temp_downloads_off = make_message(ERROR_IMG, $lang['disabled'], $lang['downloads_off'], 'resume', 'index.php');
$temp_downloads = get_tpl(DOWNLOADS . 'download_body.html', DOWN_IMG, $lang['downloads'], 1);
//
// Does downloadlist is active?
//
if ($cf->down_on == '0') {
echo $temp_downloads_off;
footer(1);
}
//
// Downloadlist active
//
echo $temp_downloads;
footer(0);
?>
Code: Alles auswählen
<section id="content2">
<div>{content}</div>
{home} - {back} <br><br>
{folder} <br><br>
{filename} - {filesize}{size} - {link}<br>
</section>
Danke
Matthias