All pastes #916989 Raw Edit

Stuff

public text v1 · immutable
#916989 ·published 2008-02-25 01:55 UTC
rendered paste body
<?php
$dir = opendir(dirname(__FILE__));
$exclude = array(".", "..");

while ($fn = readdir($dir)) {
	if ($fn == $exclude[0] || $fn == $exclude[1]) continue;
	$array[] = $fn;
}

sort($array);

foreach ($array as $file) {
	if (is_dir($file)) {
		$dir .= '<p><a href="' . $file . '">' . $file . '</a></p>';
		$dir .= "\n";
	}
	else {
		$size = filesize($file);
		$m = 'B';
		if ($size > 1024) {
			$size = round($size/1024,2);
			$m = 'KB';
		} 
		elseif ($size > 1024*1024) {
			$size = round(($size/1024)/1024,2);
			$m = 'MB';
		}
		$arq .= '<p><a href="' . $file . '">' . $file . '</a> - ' . $size . ' ' . $m . '</p>';
		$arq .= "\n";
	}
}
echo $dir . $arq;
closedir($dir);
?>