'Numele fisierului', 'date' => 'Data', 'size' => 'Marime'];
foreach ($columns as $name => $title)
{
$arrow_class = '';
$order = 'asc';
if ($name == $column_sort)
{
if ($column_order == 'asc')
{
$arrow_class = 'arrow-up';
$order = 'desc';
}
else
{
$arrow_class = 'arrow-down';
}
}
echo " | $title | \n";
}
?>
No files to show\n";
}
else
{
usort($files_to_show, function($a, $b)
{
global $dir;
global $column_sort;
global $column_order;
if ($column_order == 'desc')
{
$temp = $a;
$a = $b;
$b = $temp;
}
if ($column_sort == 'size')
{
if (filesize($dir.$a) == filesize($dir.$b))
return 0;
return filesize($dir.$a) > filesize($dir.$b);
}
else
if ($column_sort == 'date')
{
if (filemtime($dir.$a) == filemtime($dir.$b))
return 0;
return filemtime($dir.$a) > filemtime($dir.$b);
}
return strcmp($a, $b);
});
$downloads = array();
if ($show_count)
{
$fp = fopen($db, 'r');
while (!feof($fp))
{
$data[] = rtrim(fgets($fp, 4096));
}
fclose($fp);
foreach ($data as $row)
{
list($filename, $count) = explode('|', $row);
$downloads[md5($filename)] = $count;
}
}
foreach ($files_to_show as $file)
{
$file_date = date('F d Y, H:i:s', filemtime($dir.$file));
$bytes = filesize($dir.$file);
$size = array('B', 'kB', 'MB', 'GB', 'TB');
$factor = floor((strlen($bytes) - 1) / 3);
$file_size = sprintf("%.2f", $bytes / pow(1024, $factor)) . @$size[$factor];
$table_row = " | $file";
if ($show_count)
{
$table_row .= " ";
$table_row .= (int)$downloads[md5($file)];
$table_row .= "";
}
$table_row .= " | $file_date | $file_size |
\n";
echo $table_row;
}
}
?>