#1 13. Oktober 2007 Hallo! Ich wollte mal fragen, wie es möglich ist, das bei diesem DIRECTORY LISTING spezielle Dateien/Ordner ausgeblendet werden. Hat jemand eine Ahnung, und kann zusätzliche Zeilen hinzufügen, das man mehrere Dateien / Ordner nicht anzeigen lassen kann? Danke im Voraus! Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> ven000m dir list</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="functions.js"></script> </head> <body> <div id="header"><i>ven000m</i>.browser</div> <div id="previewbox" style="display: none; padding: 3px;"></div> <?php #assign vars if(isset($_GET['fol']) && strlen($_GET['fol']) > 0) { #security fix if($_GET['fol']{0} == "/" || substr($_GET['fol'], 0, 3) == "../") { $thisfolder = "./"; } else { $thisfolder = $_GET['fol']."/"; } $thisfolder = str_replace("../", "", $thisfolder); } else { $thisfolder = "./"; } $hide = array( 'functions.js', 'index.php', '.dlf', 'images', '.di', '.browser', '._thumbs', 'style.css', '.htaccess', '.htpasswd' ); #Change this to the main directory name $mainname = "Home"; $thisfilename = substr(strrchr($_SERVER['SCRIPT_NAME'], "/"), 1); $typetext = "<b><u>Type:</u></b>"; $nametext = "<b><u>Name:</u></b>"; $fsizetext = "<b><u>FileSize:</u></b>"; $lmodtext = "<b><u>Last Modified:</u></b>"; # get arrays into vars $files = _foldersort($thisfolder, "files"); $folders = _foldersort($thisfolder, "folders"); # count all files and folders $totalfilecount = count($files)-1; $totalfoldercount = count($folders)-1; ?> <div id="main_wrap"> <div id="main_inner"> <?php # Show path of current folder echo "<span class=\"cpath\">Current Path : "; if($thisfolder == "./") { echo '<a href="'.$thisfilename.'">'.$mainname."</a>"; } else { $thefolders = explode("/", $thisfolder); $thisf = "./"; for($cf = 0; $cf < count($thefolders); $cf++) { if($thefolders[$cf] == ".") { echo '<a href="'.$thisfilename.'">'.$mainname."</a> "; } elseif ($thefolders[$cf] == "") { continue; } else { $thisf = $thisf.$thefolders[$cf]."/"; echo '/ <a href="'.$thisfilename.'?fol='.$thisf.'">'.$thefolders[$cf]."</a> "; } } } echo "</span>\n<br />\n\n"; #### Display information... #asc/decs text $typead = " (<a href=\"{$thisfilename}?sort=type&ad=asc\">a</a>/<a href=\"{$thisfilename}?sort=type&ad=dsc\">d</a>)"; $namead = " (<a href=\"{$thisfilename}?sort=name&ad=asc\">a</a>/<a href=\"{$thisfilename}?sort=name&ad=dsc\">d</a>)"; $fsizead = " (<a href=\"{$thisfilename}?sort=filesize&ad=asc\">a</a>/<a href=\"{$thisfilename}?sort=filesize&ad=dsc\">d</a>)"; $lmodad = " (<a href=\"{$thisfilename}?sort=lastmod&ad=asc\">a</a>/<a href=\"{$thisfilename}?sort=lastmod&ad=dsc\">d</a>)"; #sort into certain category if(isset($_GET['sort'])) { if(isset($_GET['ad'])) { switch($_GET['sort']) { case "name": if($_GET['ad'] == "asc") { sort($files); sort($folders); $namead = " (<a href=\"{$thisfilename}?sort=name&ad=dsc\">d</a>)"; } elseif($_GET['ad'] == "dsc") { rsort($files); rsort($folders); $namead = " (<a href=\"{$thisfilename}?sort=name&ad=asc\">a</a>)"; } break; case "type": $files = _foldersort($thisfolder, "files", $i1="type", $i2="name"); $folders = _foldersort($thisfolder, "folders", $i1="type", $i2="name"); if($_GET['ad'] == "asc") { sort($files); sort($folders); $typead = " (<a href=\"{$thisfilename}?sort=type&ad=dsc\">d</a>)"; } elseif($_GET['ad'] == "dsc") { rsort($files); rsort($folders); $typead = " (<a href=\"{$thisfilename}?sort=type&ad=asc\">a</a>)"; } break; case "filesize": $files = _foldersort($thisfolder, "files", $i1="filesize", $i2="type", $i3="name"); $folders = _foldersort($thisfolder, "folders", $i1="filesize", $i3="name"); if($_GET['ad'] == "asc") { sort($files); sort($folders); $fsizead = " (<a href=\"{$thisfilename}?sort=filesize&ad=dsc\">d</a>)"; } elseif($_GET['ad'] == "dsc") { rsort($files); rsort($folders); $fsizead = " (<a href=\"{$thisfilename}?sort=filesize&ad=asc\">a</a>)"; } break; case "lastmod": $files = _foldersort($thisfolder, "files", $i1="lastmod", $i2="type", $i3="filesize", $i4="name"); $folders = _foldersort($thisfolder, "folders", $i1="lastmod", $i4="name"); if($_GET['ad'] == "asc") { sort($files); sort($folders); $lmodad = " (<a href=\"{$thisfilename}?sort=lastmod&ad=dsc\">d</a>)"; } elseif($_GET['ad'] == "dsc") { rsort($files); rsort($folders); $lmodad = " (<a href=\"{$thisfilename}?sort=lastmod&ad=asc\">a</a>)"; } break; } } } else { sort($files); sort($folders); $namead = " (<a href=\"{$thisfilename}?sort=name&ad=dsc\">d</a>)"; } #ascending / descending info if(isset($_GET['fol']) && strlen($_GET['fol']) > 0) { $typead = str_replace("'{$thisfilename}?sort=", "'{$thisfilename}?fol=".$_GET['fol']."&sort=", $typead); $namead = str_replace("'{$thisfilename}?sort=", "'{$thisfilename}?fol=".$_GET['fol']."&sort=", $namead); $fsizead = str_replace("'{$thisfilename}?sort=", "'{$thisfilename}?fol=".$_GET['fol']."&sort=", $fsizead); $lmodad = str_replace("'{$thisfilename}?sort=", "'{$thisfilename}?fol=".$_GET['fol']."&sort=", $lmodad); } echo '<span class="icon">'." </span>\n"; echo '<span class="name">'.$nametext.$namead."</span>\n"; echo '<span class="size">'.$fsizetext.$fsizead."</span>\n"; echo '<span class="type">'.$typetext.$typead."</span>\n"; echo '<span class="mod">'.$lmodtext.$lmodad."</span><br />\n"; echo '<div id="minibox">'; $filterfolders = array("mstuff"); # show folders for ($i = 0; $i <= $totalfoldercount; $i++) { #icon echo '<span class="icon">'."<img src=\"images/foldericon.gif\" alt=\"foldericon\" /></span>\n"; #name and link to folder echo '<span class="name"><a href="'.$thisfilename.$folders[$i]['link'].'" title="'.$folders[$i]['name'].'">'.format_name($folders[$i]['name'])."</a></span>\n"; #foldersize echo '<span class="size">'.format_filesize($folders[$i]['filesize'])."</span>\n"; #type echo '<span class="type">'." </span>\n"; #lastmod echo '<span class="mod">'.format_datetime($folders[$i]['lastmod'])."</span><br />\n\n"; } #show files for ($i = 0; $i <= $totalfilecount;$i++) { #icon echo '<span class="icon">'.format_filetype($files[$i]['type'])."</span>\n"; #name and link to file echo '<span class="name">'.format_a_name($files[$i]['name'], $files[$i]['link'], $files[$i]['type']).format_name($files[$i]['name'])."</a></span>\n"; #filesize echo '<span class="size">'.format_filesize($files[$i]['filesize'])."</span>\n"; #type echo '<span class="type">'.$files[$i]['type']."</span>\n"; #lastmod echo '<span class="mod">'.format_datetime($files[$i]['lastmod'])."</span><br />\n\n"; } ?> </div> </div> </div> <?php ############################### ##### ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ;) ##### ############################### ## format functions function format_name($name) { if(strlen($name) > 48) { $name = substr($name, 0, 45)."..."; } return $name; } function format_filetype($type) { # icons $allimagetypes = array("jpg", "png", "gif", "ico", "jpeg", "bmp"); $allcompresstypes = array("zip", "rar"); $csstypes = array("css"); $htmltypes = array("html", "htm", "stm"); $phptypes = array("php"); $txttypes = array("txt", "js", "pl"); if(in_array($type, $allimagetypes)) { $ficon = "<img src=\"images/imageicon.png\" alt=\"imageicon\" />"; } elseif(in_array($type, $allcompresstypes)) { $ficon = "<img src=\"images/compressicon.png\" alt=\"compressicon\" />"; } elseif(in_array($type, $csstypes)) { $ficon = "<img src=\"images/cssicon.png\" alt=\"cssicon\" />"; } elseif(in_array($type, $htmltypes)) { $ficon = "<img src=\"images/htmlicon.png\" alt=\"htmlicon\" />"; } elseif(in_array($type, $phptypes)) { $ficon = "<img src=\"images/phpicon.gif\" alt=\"phpicon\" />"; } elseif(in_array($type, $txttypes)) { $ficon = "<img src=\"images/fileicon.png\" alt=\"fileicon\" />"; } else { $ficon = "<img src=\"images/othericon.png\" alt=\"othericon\" />"; ; } return $ficon; } function format_a_name($name, $link, $type) { $allimagetypes = array("jpg", "png", "gif", "ico", "jpeg", "bmp"); if(in_array($type, $allimagetypes)) { $gis = getimagesize($link); $onclick = ' onclick="window.open(this.href, null, \'height='.$gis[1].',width='.$gis[0].'\'); return false;" onmouseover="preview(this, \''.$link.'\', '.$gis[0].', '.$gis[1].');" onmouseout="hideprev();"'; } else { $onclick = ' onclick="window.open(this.href); return false;"'; } $link = str_replace(" ", "%10", $link); return '<a href="'.$link.'"'.$onclick.' title="'.$name.'">'; } function format_filesize($filesize) { if(strlen($filesize) <= 3) { $filesize = $filesize." b"; } elseif(strlen($filesize) < 7) { $filesize = ($filesize/1024); $fsplit = substr(strstr($filesize, "."), 0, 4); $fstart = explode(".", $filesize); $fstart = $fstart[0]; $filesize = $fstart.$fsplit." kb"; } else { $filesize = ($filesize/1024/1024); $fsplit = substr(strstr($filesize, "."), 0, 4); $fstart = explode(".", $filesize); $fstart = $fstart[0]; $filesize = $fstart.$fsplit." mb"; } return $filesize; } function format_datetime($datetime) { if(is_numeric($datetime) && strlen($datetime) == 12) { $Y = substr($datetime, 0, 4); $m = substr($datetime, 4, 2); $d = substr($datetime, 6, 2); $H = substr($datetime, 8, 2); $i = substr($datetime, 10, 2); return $d."/".$m."/".$Y." ".$H.":".$i; } else { return false; } } #foldersize functions function getfoldersize($folder) { if(isset($_GET['fol']) && strlen($_GET['fol']) > 0) { $folder = $_GET['fol']."/".$folder."/"; } else { $folder = $folder."/"; } #open dir $dir = opendir($folder); $foldersize = 0; #get contents of dir while (false !== ($contents = readdir($dir))) { if($contents == "." || $contents == "..") { continue; } if(!is_dir($folder.$contents)) { $foldersize = $foldersize + ((int)filesize($folder.$contents)); } } return $foldersize; } function getfolderlastmod($folder) { if(isset($_GET['fol']) && strlen($_GET['fol']) > 0) { $folder = $_GET['fol']."/".$folder."/"; } else { $folder = $folder."/"; } #open dir $dir = opendir($folder); $folderlastmod = array(); #get contents of dir while (false !== ($contents = readdir($dir))) { if($contents == "." || $contents == "..") { continue; } if(!is_dir($folder.$contents)) { $folderlastmod[] = date("YmdHi", filemtime($folder.$contents)); } } rsort($folderlastmod); if($folderlastmod) { return $folderlastmod[0]; } else { return 0; } } # main function sorts all files in arrays function _foldersort($thisfolder, $rt, &$i1="name", &$i2="type", &$i3="filesize", &$i4="lastmod"){ # vars ; $files = array(); $folders = array(); $filecount = 0; $foldercount = 0; #open dir $dir = opendir($thisfolder); #get contents of dir while (false !== ($contents = readdir($dir))) { if($contents == "." || $contents == "..") { continue; } if(is_dir($thisfolder.$contents)) { #putintoarray $folders[$foldercount] = array(); switch($i1) { case "name": $folders[$foldercount][$i1] = $contents; break; case "type"; $folders[$foldercount][$i1] = " "; break; case "filesize": $folders[$foldercount][$i1] = getfoldersize($contents); break; case "lastmod": $folders[$foldercount][$i1] = getfolderlastmod($contents); break; } switch($i2) { case "name": $folders[$foldercount][$i2] = $contents; break; case "type"; $folders[$foldercount][$i2] = " "; break; case "filesize": $folders[$foldercount][$i2] = getfoldersize($contents); break; case "lastmod": $folders[$foldercount][$i2] = getfolderlastmod($contents); break; } switch($i3) { case "name": $folders[$foldercount][$i3] = $contents; break; case "type"; $folders[$foldercount][$i3] = " "; break; case "filesize": $folders[$foldercount][$i3] = getfoldersize($contents); break; case "lastmod": $folders[$foldercount][$i3] = getfolderlastmod($contents); break; } switch($i4) { case "name": $folders[$foldercount][$i4] = $contents; break; case "type"; $folders[$foldercount][$i4] = " "; break; case "filesize": $folders[$foldercount][$i4] = getfoldersize($contents); break; case "lastmod": $folders[$foldercount][$i4] = getfolderlastmod($contents); break; } $folders[$foldercount]['link'] = "?fol=".$thisfolder.$contents; #foldercount $foldercount++; } else { #filetype $ft = substr(strtolower(strrchr($contents, ".")), 1); #filesize $fsize = ((int)filesize($thisfolder.$contents)); #filelastmod $lastmod = date ("YmdHi", filemtime($thisfolder.$contents)); #putintoarray $files[$filecount] = array(); switch($i1) { case "name": $files[$filecount][$i1] = $contents; break; case "type"; $files[$filecount][$i1] = $ft; break; case "filesize": $files[$filecount][$i1] = $fsize; break; case "lastmod": $files[$filecount][$i1] = $lastmod; break; } switch($i2) { case "name": $files[$filecount][$i2] = $contents; break; case "type"; $files[$filecount][$i2] = $ft; break; case "filesize": $files[$filecount][$i2] = $fsize; break; case "lastmod": $files[$filecount][$i2] = $lastmod; break; } switch($i3) { case "name": $files[$filecount][$i3] = $contents; break; case "type"; $files[$filecount][$i3] = $ft; break; case "filesize": $files[$filecount][$i3] = $fsize; break; case "lastmod": $files[$filecount][$i3] = $lastmod; break; } switch($i4) { case "name": $files[$filecount][$i4] = $contents; break; case "type"; $files[$filecount][$i4] = $ft; break; case "filesize": $files[$filecount][$i4] = $fsize; break; case "lastmod": $files[$filecount][$i4] = $lastmod; break; } $files[$filecount]['link'] = $thisfolder.$contents; #filecount $filecount++; } } #return either files or folder array switch($rt){ case "files": return $files; break; case "folders"; return $folders; break; } } ?> <div id="footer"> <!-- Please leave the text below even if its hidden in the source =) --> </div> </body> </html> + Multi-Zitat Zitieren
#2 13. Oktober 2007 AW: [PHP Script] Dateien/Ordner nicht anzeigen Weitere Ordner bzw. Dateien angeben kannste folgendermassen: Code: $hide = array( 'functions.js', 'index.php', '.dlf', 'images', '.di', '.browser', '._thumbs', 'style.css', '.htaccess', '.htpasswd' Diese Funktion in dem Script ist dazu gedacht das bestimmte Sachen ausgeblendet werden. Fuehre diese Liste einfach weiter: Z.B. Code: $hide = array( 'functions.js', 'index.php', '.dlf', 'images', '.di', '.browser', '._thumbs', 'style.css', '.htaccess', '.htpasswd' [COLOR="Red"]'meinbild.jpg'[/COLOR] [COLOR="Red"]'mein Ordner'[/COLOR] Hoffe das ich dir damit ein bischen weiterhelfen konnte. + Multi-Zitat Zitieren
#3 14. Oktober 2007 AW: [PHP Script] Dateien/Ordner nicht anzeigen Den Abschnitt hab ich nur zum testen reingemacht, wo jedoch nicht funktioniert. + Multi-Zitat Zitieren
#4 14. Oktober 2007 AW: [PHP Script] Dateien/Ordner nicht anzeigen such: $thisfilename = substr(strrchr($_SERVER['SCRIPT_NAME'], "/"), 1); schreib drunter: PHP: if( in_array ( $thisfolder , $hide ) || in_array ( $thisfilename , $hide )) exit( header ( 'location: index.php' )); + Multi-Zitat Zitieren
#5 14. Oktober 2007 AW: [PHP Script] Dateien/Ordner nicht anzeigen Hi, danke schonmal für deine Hilfe! habs jetz so: Code: $thisfilename = substr(strrchr($_SERVER['SCRIPT_NAME'], "/"), 1); if(in_array($thisfolder, $hide) || in_array($thisfilename, $hide)) exit(header('location: index.php, functions.js, style.css, images')); $typetext = "<b><u>Type:</u></b>"; jedoch erscheint nun ein Error! was mach ich falsch? + Multi-Zitat Zitieren
#6 14. Oktober 2007 AW: [PHP Script] Dateien/Ordner nicht anzeigen Murdoc-4D hat ja auch nicht gesagt, dass du PHP: if( in_array ( $thisfolder , $hide ) || in_array ( $thisfilename , $hide )) exit( header ( 'location: index.php, functions.js, style.css, images' )); benutzen sollst, sondern PHP: if( in_array ( $thisfolder , $hide ) || in_array ( $thisfilename , $hide )) exit( header ( 'location: index.php' )); und dann bei PHP: $hide = array( 'bild.jpg' , '.....' , ); einfach deine Ordner/Dateien reinschreiben sollst, die man nicht anschauen darf. + Multi-Zitat Zitieren
#7 14. Oktober 2007 AW: [PHP Script] Dateien/Ordner nicht anzeigen PHP: if( in_array ( $thisfolder , $hide ) || in_array ( $thisfilename , $hide )) exit( header ( 'location: index.php, functions.js, style.css, images' )) ; änder das mal in PHP: if( in_array ( $thisfolder , $hide ) || in_array ( $thisfilename , $hide )) exit( header ( 'location: index.php' )) ; edit: da war jemand schneller + Multi-Zitat Zitieren
#8 14. Oktober 2007 AW: [PHP Script] Dateien/Ordner nicht anzeigen Habs jetzt so gemacht wie ihrs beschrieben habt, jedoch erscheint nun bei dem einen webspace: Code: The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete. * This problem can sometimes be caused by disabling or refusing to accept cookies. und bei dem anderen Code: Warning: Cannot modify header information - headers already sent by (output started at /xxx/raibadatschi/index.php:11) in /xxx/raibadatschi/index.php on line 53 + Multi-Zitat Zitieren
#9 14. Oktober 2007 AW: [PHP Script] Dateien/Ordner nicht anzeigen suche: if(in_array($thisfolder, $hide) || in_array($thisfilename, $hide)) exit(header('location: index.php')); ersetze mit: PHP: if( in_array ( $thisfolder , $hide ) || in_array ( $thisfilename , $hide )) { ob_clean (); exit( ' <html> <head> <meta http-equiv="refresh" content="2, http://domain.tld" /> </head> <body> <p align="center"> <strong>fehler, dieser file/ordner darf nicht geöffnet werden!</strong><br /> </p> </body> </html> ' );} suche: <!DOCTYPE [...] schreib drüber: <?php ob_start(); > suche: </html> schreib drunter: <?php ob_end_flush(); ?> + Multi-Zitat Zitieren
#10 14. Oktober 2007 AW: [PHP Script] Dateien/Ordner nicht anzeigen Parse error: syntax error, unexpected '>' in /xxx/index.php on line 1 :/ + Multi-Zitat Zitieren
#11 14. Oktober 2007 AW: [PHP Script] Dateien/Ordner nicht anzeigen Ach komm, bitte nicht blind kopieren. Da oben hat Murdoc auf die schnelle wohl das"?" vergessen, also: PHP: <? php ob_start (); ?> lg Sn0wm4n + Multi-Zitat Zitieren
#12 14. Oktober 2007 AW: [PHP Script] Dateien/Ordner nicht anzeigen Vielen Dank für die Bemühungen von allen hier! (Bewertung is raus!) Aber schaut mal: http://esl-bugs.extra.hu/hi/index.php Die Dateien können immer noch eingesehen werden ^^ + Multi-Zitat Zitieren
#13 14. Oktober 2007 AW: [PHP Script] Dateien/Ordner nicht anzeigen der link hätt scho viel früher fallen müssen.... meld dich ma bei coco, der hat ein angepastes dirlisting script von mir, da kannste dich als admin einloggen, datein aussperren, löschen, ordner freigeben zum upload für user und gäste usw... + Multi-Zitat Zitieren