Искам да попитам може ли този код да се редактира така че да показва по 20 картинки на страница и съответно да има "Напред", "Назад" и т.н.
Код:
<?php
require('page_header.php');
?>
<table cellpadding="4" cellspacing="1" border="0" width="100%">
<tr>
<th><font face="Tahoma" color=black style="font-size: 8pt">Файл</font></th>
<th><font face="Tahoma" color=black style="font-size: 8pt">Големина</font></th>
<th><font face="Tahoma" color=black style="font-size: 8pt">Дата на добавяне</font></th>
<?php
if(extension_loaded("mime_magic")) {
echo "<th>Mime type</th>\n";
}
?>
<th><font face="Tahoma" color=black style="font-size: 8pt">Изтегли</font></th>
</tr>
<?php
$path = $_CONFIG['path'];
$file_count = 0;
$dh = opendir($path);
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}
sort($files);
foreach ($files as $file) {
$full = $path.$file;
if(strlen($file)>30) {
$file = substr($file, 0, 30) . '...';
}
if($file != '.' && $file != '..' && $file != 'index.php' && $file != 'index.html' && $file != "Thumbs.db"){
$file_count++;
if($class == "row1"){
$class = "row2";
}else{
$class = "row1";
}
$extension = file_type($file);
if($extension == "bmp" || $extension == "ico"){
$thumb = $full;
}else{
$thumb = $_CONFIG['tpath'].$file;
}
?>
<tr>
<?php
switch($_CONFIG['dir_view']){
case 'thumb':
echo '<td class="'.$class.'" align="left"><a href="viewer.php?file='.$file.'"><center><img src="'.$thumb.'" width="'.$_CONFIG['thumb_w'].'" height="'.$_CONFIG['thumb_h'].'" alt="'.$file.'" /></center></a></td>';
break;
case 'links':
echo '<td class="'.$class.'" align="left"><a href="viewer.php?file='.$file.'"><b>'.$file.'</b></a></td>';
break;
default:
echo '<td class="'.$class.'" align="left"><a href="viewer.php?file='.$file.'"><center><img src="'.$thumb.'" width="'.$_CONFIG['thumb_w'].'" height="'.$_CONFIG['thumb_h'].'" alt="'.$file.'" /></center></a></td>';
}
?>
<td class="<?php echo $class; ?>" align="center"><font face="Tahoma" color=black style="font-size: 9pt"><?php echo filesize($full); ?> KB</font></td>
<td class="<?php echo $class; ?>" align="center"><font face="Tahoma" color=black style="font-size: 9pt"><?php echo date ("M d Y h:i:s A", filemtime($full)); ?></font></td>
<?php
if(extension_loaded("mime_magic")) {
echo '<td class="'.$class.'" align="left">'.mime_content_type($full).'</td>';
}
?>
<td class="<?php echo $class; ?>" align="center"><a href="download.php?download=<?php echo basename($full); ?>"><b><font face="Tahoma" style="font-size: 8pt">Download</font></b></a></td>
</tr>
<?php
}
}
?>
</table>
<?php
if($file_count<1){
echo "<br/>";
generror("Directory is empty!");
}
require('page_footer.php');
?>