![]() |
![]() |
![]()
Post
#1
|
|
![]() Grupa: Zarejestrowani Postów: 11 Pomógł: 0 Dołączył: 25.04.2003 Skąd: Gdynia Ostrzeżenie: (0%) ![]() ![]() |
Witam!
Posiadam dwa skrypty do listingu katalogow i plikow. Pierwszy umozliwia listing,a takze wyswietla date modyfikacji oraz rozmiar pliku. Tutaj chcialbym zaznaczyc ze w skrypcie nalezy podac rozszerzenia plikow do filtra ktore maja byc pokazywane, natomiast chcialbym aby bylo odwrotnie - po wpisaniu rozszerzenia do filtra, plik nie bedzie wyswietlany w listingu. Drugi skrypt tez sluzy do listingu, tyle ze obsluguje podkatalogi. (np w katalogu glownym po kliknieciu na podkatalog skrypt rowniez go listuje, a nie otwiera go jak w przypadku skryptu pierwszego.) Natomiast nie wyswietla daty modyfikacji i wielkosci pliku jak w skrypcie pierwszym. I tutaj zaczyna sie najwazniejszy problem. Interesuje mnie funkcjonalnosc skryptu pierwszego (data modyfikacji i rozmiar plikow)ale chcialbym aby potrafil obslugiwac podkatalogi podobnie jak skrypt drugi.(aby skrypt listowal klikniete foldery zamiast otwierac je.) Staralem sie wszytko opisac w miare najprosty sposob, mam nadzieje ze tresc jest zrozumiala. Ponizej kody: Pierwszy skrypt: [php] <?php ############################################################################ # index.php # By: Yulianta Ramelan<y_anta@yahoo.com> # This script is used for reading current directory contents # to create filtered list of files based on it's file extension # What you have to do is: # 1. Modify $filter variable with file extension you want to filter # 2. Modify $icondir variable with the directory containing needed icons # 3. Modify $icon variable with icon representing the coresponding file # 4. Copy index.php to the directory you want to filter ############################################################################ //define filter with file extension, separate extensions with spaces $filter = 'pdf txt'; //define directory (URL) containing the corresponding icons, no trailing slash $icondir = '/icons'; //define icon representing the corresponding file, separate icons with spaces $icon = 'acrobat.gif text.gif'; ################################################## # getdirattributes ($directory) # function to get attributes of a directory # no filter applied ################################################## function getdirattributes ($directory) { global $icondir; $modified = filemtime($directory); $strdate = date("d-M-Y", $modified); $html = "<tr>\n"; if (eregi("\.\.", $directory)) { $html .= "<td><img border=\"0\" src=\"$icondir/back.gif\" alt=\"[BACK]\"></td>"; $html .= "<td><a href=\"$path".rawurlencode($directory)."\">Parent directory</a></td>"; } else { $html .= "<td><img border=\"0\" src=\"$icondir/folder.gif\" alt=\"[DIR]\"></td>"; $html .= "<td><a href=\"$path".rawurlencode($directory)."\">$directory</a></td>"; } $html .= "<td>$strdate</td><td> </td>"; $html .="</tr>\n"; return $html; } ###################################################### # getfileattributes ($filteredfile) # function to to check that the file match the filter # and get the attributes ###################################################### function getfileattributes ($file) { global $filter, $icondir, $icon; $kilobyte = 1024; $megabyte = 1024*1024; $filters = explode (" ", $filter); $icons = explode (" ", $icon); $modified = filemtime($file); $strdate = date("d-M-Y", $modified); $size = filesize($file); if ($size > $megabyte) { $size = $size/(1024*1024); $Strsize = eregi_replace("([0-9]\.[0-9])[0-9]*", "\\1MB", $size); } elseif (($size >= $kilobyte) && ($size < $megabyte)) { $size = $size/1024; $strsize = eregi_replace("([0-9]\.[0-9 |
|
|
![]() ![]() |
![]() |
Wersja Lo-Fi | Aktualny czas: 6.07.2025 - 13:02 |