Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Closed TopicStart new topic
> Poszukuje dobry skrypt do listingu katalogów
lear
post 25.04.2005, 11:13:34
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>&nbsp;</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
Go to the top of the page
+Quote Post
aleksander
post 25.04.2005, 11:17:05
Post #2





Grupa: Przyjaciele php.pl
Postów: 742
Pomógł: 0
Dołączył: 14.12.2003
Skąd: Gdańsk, Trójmiasto

Ostrzeżenie: (0%)
-----




proszę się zastosować inaczej zamknę
Go to the top of the page
+Quote Post
Spirit86
post 25.04.2005, 12:54:24
Post #3





Grupa: Zarejestrowani
Postów: 607
Pomógł: 23
Dołączył: 8.09.2004
Skąd: Wrocław

Ostrzeżenie: (0%)
-----


wstaw ! w odpowiednim miejscu(nie bedę tego w takiej postaci czytał) :]


--------------------
Audio: Metallica, Soil, RHCP, OffSpring, Green Day, "Retro", Gorillaz, Disturbed, Coma
DB: MySQL 4.1 | php: 4.4.3 Pomogłem Ci? Wciśnij przycisk POMÓGŁ.
Go to the top of the page
+Quote Post
aleksander
post 25.04.2005, 14:01:03
Post #4





Grupa: Przyjaciele php.pl
Postów: 742
Pomógł: 0
Dołączył: 14.12.2003
Skąd: Gdańsk, Trójmiasto

Ostrzeżenie: (0%)
-----


zamykam. Autor tematu powinien zgłosić się go któregoś z moderatorów, żeby odblokować temat. Następnie proszę o poprawienie bbcode.
Go to the top of the page
+Quote Post

Closed TopicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 27.06.2025 - 22:21