Ciao,
mi servirebbe uno script che elenchi dei file .txt e crei un link ai file di una directory che dico io.
Sapete come si può fare?
Io ne ho uno, ma elenca tutti i file della directory in cui si trova. Lo incollo, magari qualcuno può aiutarmi a fare le modifiche necessarie. (crea già i link)
[code:1:d7faa1c239]
<?php
Function fncLinkDir( $dirname )
{
/* Get rid of those stupid filenames */
/* Was I sleepy when I did this? Alrighty then. */
if ( is_file( $DOCUMENT_ROOT.$REQUEST_URI ) )
{
$REQUEST_URI = ereg_replace( $mefile = strrchr( $REQUEST_URI, "/" ), "/", $REQUEST_URI );
};
/* Open Current Working Directory for reading. */
if( !$dirid = @opendir( $dirname.$recurse ) )
{
print " &lt; - Unable to Open Directory";
return 1;
};
/* Read the contents of the directory one by one */
while ($entry = @readdir($dirid))
{
/* Begin File Exclusion;
for long lists use an array and while loop
to save you some editing time. PHP 4 races through loops.
*/
/* Do not list hidden files; begins with .
Why: Indexing . will cause infinite loop and eventually
a stack overfrow.
*/
if ( strpos( $entry, "." ) === 0 )
{
continue;
}
/* Do not list Microsoft Frontpage junk, either. */
if ( strpos( $entry, "_vti_" ) === 0 )
{
continue;
}
/* End File Exclusion */
/* Add this entry to the listing */
$dirEntries[] = $entry;
}
/* Sort listing alphabetically then reset to start */
sort( $dirEntries );
reset( $dirEntries );
/* HTML, Open an unordered list */
print "<ul>\n";
/* Walk through the current directory */
$i = 0;
while( $dirEntries[$i] )
{
/* Assign a short name */
$fileName = $dirname . "/" . $dirEntries[$i];
$fileNameShort = $dirEntries[$i];
if( is_dir( $fileName ) )
/* It is a directory structure */
{
/* HTML, Open directory list item */
print "\t<li class=\"folder\"><a href=\"$fileName\">$fileNameShort/</a>\n";
/* Recurse into subdirectory */
fncLinkDir( $fileName );
/* HTML, Close the directory list item */
print "</li>\n";
}
else
/* It is some type of file */
{
/* HTML, Create a list item entry. */
print "\t<li class=\"link\"><a href=\"$fileName\">$fileNameShort</li>\n";
}
/* Increment the index else we loop forever, doh! */
$i ++;
}
/* HTML, Close the unordered list */
print "</ul>\n";
non bisogna aggiungere la directory nel link, poichè la funzione glob, in $filename ci restituisce anche il path dalla dir corrente a quella del file interessato.........