Gracias ya tengo el codigo listo, ademas le he añadido paginación:
Código:
<?php
$maindir = "." ;
$mydir = opendir($maindir) ;
$port= "portadas"; //carpeta donde estaran los iconos.
$arch = "index.php"; //Nombre de este archivo.
$exclude = array(".", "..", "$port") ; //Pon aqui los elementos que no quieras listar.
//establecemos condiciones de paginación.
if (!isset($pg))
$pg = ($_GET['pg']);
$cantidad = 10; //registros por pagina.
$inicial = $pg * $cantidad;
//lee las carpetas y las mete en un array.
while(false !== ($fn = readdir($mydir)))
{
if (is_dir($fn) && $fn != $exclude[0] && $fn != $exclude[1] && $fn != $exclude[2] && $fn != $exclude[3])
{
$lista[] = array (date ("d/m/y H:i:s",(filemtime($fn))),$fn);
}
}
closedir($mydir); //cerramos el directorio.
rsort($lista); //reordenamos
$total = count($lista); //contamos los elementos.
$pages = intval($total/ $cantidad); //numero de paginas a mostrar
//Mostramos las carpetas (2 tipos de presentación).
$lista = array_slice($lista,$inicial);
foreach($lista as $list)
{
if($i < $cantidad)
{//con efecto sombra
echo "<table>";
echo "<tr>";
echo "<td><br>$list[1] - $list[0]</td>";
echo "</tr>";
echo "<tr><td></td></tr>";
echo "</table>";
echo "<table border='0' cellpadding='0' bordercolor='#000000' bgcolor='#FFFFFF' style='border-collapse:collapse'>";
echo "<tr>";
echo "<td width='300' align='center' valign='middle' style='border:1px solid #000000; padding:5px'><a href='$list[1]/index0.php' target='_blank'><img src='$port/$list[1].jpg' border='0'/></a></td>";
echo "<td width='5' bgcolor='#999999' valign='top'><table width='5' height='5' border='0' cellpadding='0' cellspacing='0' ><tr><td bgcolor='#000000'><img src='images/p.gif' width='5' height='5'/></td></tr></table></td>";
echo "</tr><tr>";
echo "<td width='300' height='5' bgcolor='#999999' aling='right'><table width='100%' height='100%' cellspacing='0' cellpadding='0' border='0'><tr><td width='5' height='5' bgcolor='#000000'><img src='images/p.gif' border='0' width='5' height='5' /></td><td height='5' bgcolor='#999999' aling='right' ><img src='images/p.gif' border='0' width='100%' height='5'/></td></tr></table></td>";
echo "<td height='5' width='5' bgcolor='#999999'> <img src='images/p.gif' border='0' width='5' height='5' /></td>";
echo "</td></tr>";
echo "</table>";
//sin efecto sombra
/*echo "<table border='0' cellpadding='5' bordercolor='#000000' bgcolor='#FFFFFF'>";
echo "<tr>";
echo "<td align='left' valign='top'>";
echo "<a href='$list[1]/index0.php' target='_blank'><img src='$port/$list[1].jpg' border='0'/></a>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<table>";
echo "<td>";
echo "<tr>";
echo"<br>$list[1]";
echo "</td>";
echo "</tr>";
echo "<tr><td> </td></tr>";
echo "</table>";*/
$i++;
}
}
//Paginación
echo "<center><p>";
if ($pg <>0)
{
$url = $pg - 1;
echo "<font><a href='$arch?pg=".$url."'>« Anterior</a> </font>";
}
else
{
echo " ";
}
for ($i = 0; $i <=$pages; $i++)
{
if ($i == $pg)
{
echo "<font><b> $i </b></font>";
}
else
{
echo "<font><a href='$arch?pg=".$i."'>".$i."</a> </font>";
}
}
if ($pg < $pages)
{
$url = $pg + 1;
echo "<font><a href='$arch?pg=".$url."'>Siguiente »</a></font>";
}
else
{
echo " ";
}
echo "</p></center>";
?>
Si alguien tiene alguna propuesta de mejora que la comente please.