<?php
function view_image($image)
{
$info = getimagesize($image);
$types = array('Unknown', 'GIF', 'JPG', 'PNG', 'SWF', 'PSD', 'BMP',
'TIFF (Little Endian)', 'TIFF (Big Endian)', 'JPC',
'JP2', 'JPX', 'JB2', 'SWC', 'IFF-ILBM', 'WBMP', 'XBM');
?>
<p>
<strong>Width</strong>: <?= $info[0]; ?><br />
<strong>Height</strong>: <?= $info[1]; ?><br />
<strong>Type</strong>: <?= $types[$info[2]]; ?><br />
<strong>MIME type</strong>: <?= $info['mime']; ?><br />
<strong>Channels</strong>: <?= $info['channels']; /*undef for PNG*/ ?><br />
<strong>Bits/Channel</strong>: <?= $info['bits']; ?>
</p>
<p>
<img
style="border: 1px solid black;"
<?= $info[3]; ?>
src="<?=$image;?>"
alt="<?=$image?>"
/>
</p>
<?
}
function perms2str($file)
{
$st = lstat($file);
$prms = $st[2];
// Link ('l'), directory ('d'), or file ('-').
$out = ( ($prms & 020000) ? 'l'
: (($prms & 040000) ? 'd' : '-') );
for($i = 0400, $j = 04000; $i >= 04; $i /= 010, $j /= 02)
{
// Is file readable (by user ($i == 0400), group ($i == 040), all ($i == 04))?
$out .= (($prms & $i) ? 'r' : '-');
// Writeable?
$out .= (($prms & ($i / 02)) ? 'w' : '-');
if($prms & $j) // Is the file setuid, setgid or sticky?
$out .= (($j == 01000) ? 't' : 's'); // 't' is for sticky.
else // Executable?
$out .= (($prms & ($i / 04)) ? 'x' : '-');
}
return $out;
}
function size_conv($size)
{
/* Nope, no terabytes (or exa-, or petabytes) shown.
Actually, considering sourceforge's quotas, we'll never see any
gigabytes either... */
if($size >= 1073741824) return sprintf("%.1fG", $size/1073741824);
else if($size >= 1048576) return sprintf("%.1fM", $size/1048576);
else if($size >= 1024) return sprintf("%.1fk", $size/1024);
else return "$size";
}
function get_file_info($file)
{
if(file_exists($file))
{
$out .= "<td><code>" . perms2str($file) . "</code></td>\n";
$out .= "<td class=\"right\">" . size_conv(filesize($file)) . "</td>\n";
$out .= "<td>" . date("Y/m/d H:i:s", filemtime($file)) . "</td>\n";
}
return "$out";
}
function list_dir($dir)
{
$d = dir($dir);
$dirs = $files = "";
echo "<table summary=\"Listing of directory $dir\">\n";
echo '<tr style="font-weight: bold;">'.
'<td>Filename</td>'.
'<td>Permissions</td>'.
'<td>Size</td>'.
'<td>Last modified</td>'.
'</tr>';
global $username;
while($buff = $d->read())
{
// yes, a lot of code to print one little filename...
if(isset($username) ||
((strncmp($buff, '.', 1) || !strcmp($buff, '.htaccess')) && strncmp($buff, 'etc', 3)))
{
if(is_dir("$dir/$buff"))
{
$dirs .= "<tr><td>\n" .
"<a href=\"?content=sources&filename=$dir/$buff\" class=\"sourceDir\">$buff/</a>";
$dirs .= "\n</td>" . get_file_info("$dir/$buff") . "</tr>\n";
}
else
{
$files .= "<tr><td>\n";
if(preg_match("'\.php\$|\.inc\$|\.html\$|\.css\$|\.tmpl\$|\.rss\$|\.js\$|\.pl\$|^\.htaccess\$'i",
$buff) || !strstr($buff, "."))
{
$files .=
"<a href=\"?content=sources&filename=$dir/$buff\" "
. "class=\"sourceFile\">$buff</a><br />";
}
else if(getimagesize("$dir/$buff"))
$files .=
"<a href=\"?content=sources&filename=$dir/$buff\" ".
"class=\"sourceImage\">$buff</a><br />";
else if(preg_match("'\.gz$|\.tar$|\.zip$|\.bz2$|\.lha$'i", $buff))
$files .= "<a href=\"/$dir/$buff\" class=\"sourceArch\">$buff</a><br />";
else
$files .= "<a href=\"/$dir/$buff\">$buff</a><br />";
$files .= "\n</td>". get_file_info("$dir/$buff") . "</tr>\n";
}
}
}
echo "$dirs$files\n</table>";
}
if(isset($_GET["filename"]))
$filename = $_GET["filename"];
else
$filename = ".";
function path2links($p)
{
$pp = pathinfo($p);
$path = $pp["dirname"];
$file = $pp["basename"];
// Recurse if not at webroot.
if($path !== $file) path2links($path);
printf("%s<a href=\"?content=sources&filename=%s\" class=\"noul source%s\">%s</a>",
($file == ".") ? "" : "/", $p, is_dir($p) ? "Dir"
: (getimagesize($p) ? "Image"
: "File"),
($path == $file) ? "aros-stuff.tk" : $file);
}
?>
<div class="commonMain">
<?
echo '<div class="commonCaption boldlinks">';
path2links($filename);
echo '</div>';
echo '<div class="commonContent">';
if(isset($username) || (!strstr($filename, '..') && strncmp($filename, '/', 1)
&& !strstr($filename, ':') &&
!strstr($filename, 'etc/') && !strstr($filename, '/etc') && !strstr($filename, '/.')))
{
if(is_dir($filename))
list_dir($filename);
else if(file_exists($filename))
{
if(getimagesize($filename))
view_image($filename);
else
{
ini_set('highlight.keyword', '#800080');
ini_set('highlight.comment', '#00a000');
show_source($filename);
echo '<div class="right"><a href="/?content=gpl">';
echo 'Copyright © 2003, 2004 Kalle Räisanen</a></div>';
}
}
else echo "Invalid filename "$filename"!";
}
else echo "Illegal filename "$filename"!";
echo '</div>';
?>
</div>
Latest News
Latest Software
read 0.3.6
kal, 2004/04/30 07:14:24.
nroff 1.10
kal, 2004/04/22 08:29:10.
Nenscript 1.13.3
kal, 2004/04/22 08:23:53.
necho 0.2.3
kal, 2004/04/19 10:58:47.
dgrep 0.1.4
kal, 2004/04/19 10:49:42.
kal, 2004/04/30 07:14:24.
nroff 1.10
kal, 2004/04/22 08:29:10.
Nenscript 1.13.3
kal, 2004/04/22 08:23:53.
necho 0.2.3
kal, 2004/04/19 10:58:47.
dgrep 0.1.4
kal, 2004/04/19 10:49:42.
Select Theme
Links