Ho un problema con questo script che mi elenca le immagini contenute in una cartella
Ho cercato di fare in modo che riporti solo i file di immagine...
...invece mi riporta tutto il contenuto della cartella.
Codice PHP:
<?php
function image_list ()
{
// Get a list of images in the image folder. Return HTML.
//
if (!file_exists(IMAGES_DIR))
{
$oldumask = umask(0);
$ok = mkdir(IMAGES_DIR, 0777 );
umask($oldumask);
}
// Changed this to only display Image files. This function
// is used in comment.php if the blog owner has img tag
// enabled for comments.
$dir = IMAGES_DIR;
$contents = sb_folder_listing( $dir, array( '.jpg', '.jpeg', '.gif', '.png' ) );
// $contents = sb_folder_listing( $dir, array() );
$str = NULL;
if ($contents)
{
for ( $i = 0; $i < count( $contents ); $i++ )
{
if ($contents[$i] != '.htaccess' && $contents[$i] != 'Thumbs.db')
{
$str .= '<img src=scripts/sb_thumb.php?dir=../' . $dir . '&file=' . $contents[$i] . '>
';
$str .= '[url='.$dir.$contents[$i].']'.$contents[$i].'[/url]
';
}
}
}
return ( $str );
}
?>