Просмотр файла files.php

Размер файла: 1.38Kb
<?php
require('includes/header.php');
require('includes/utils.php');
require('includes/db.php');

$max_files = 2;

if(isset($_GET['from']))
   $from = $_GET['from'];
else
   $from = 0;

$to = $from + $max_files;
$login = $_GET['login'];
$n = 0;
$files = '';
$total_size = 0;
if ($handle = opendir("$login/files/"))
{
   while (false !== ($file = readdir($handle)))
   {
      if($file != '.' && $file != '..')
      {
         $filesize = filesize("$login/files/$file");
         $total_size += $filesize;
         if($n >= $from && $n < $to)
         $files .= <<<FILEDATA
<a href="$login/files/$file">$file</a> ($filesize байт)
<br/>
FILEDATA;
         $n++;
      }
   }
   closedir($handle);
}

if($n > $to )
         $files .= <<<FILEDATA
<a href="files?login=$login&amp;from=$to">Далее</a>
<br/>
FILEDATA;

$back_from = $from - $max_files;
if($from > 0)
   $files .= <<<FILEDATA
<a href="files.php?login=$login&amp;from=$back_from">Назад</a>
<br/>
FILEDATA;

   $banners = mysql_query('SELECT banner FROM users WHERE login = "' . $login . '"');
   list($banner) = mysql_fetch_array($banners);
?>
<wml>
<card id="main" title="Файлы">
<p align="center">
<?php
  if($banner == 'top')
     echo get_random_link();
?>
<?php echo $files; ?>
<?php
  if($banner == 'bottom')
     echo get_random_link();
?>
</p>
</card>
</wml>