&1", $out, $ret);
if ($ret !== 0 || !file_exists($tmp)) {
http_response_code(500);
exit('failed to create archive. please open an issue.');
}
header('Content-Type: application/x-xz');
header('Content-Disposition: attachment; filename="unimg-source.tar.xz"');
header('Content-Length: ' . filesize($tmp));
readfile($tmp);
unlink($tmp);
exit;
}
if ($action === 'raw') {
if ($real === false || !is_file($real)) {
http_response_code(404);
exit('file not found');
}
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . basename($real) . '"');
header('Content-Length: ' . filesize($real));
readfile($real);
exit;
}
function fmt_size(int $bytes): string {
if ($bytes === 0) return '0 B';
$u = ['B','KB','MB','GB','TB'];
$i = (int) floor(log($bytes, 1024));
return round($bytes / pow(1024, $i), 1) . ' ' . $u[$i];
}
function fmt_date(int $ts): string {
return date('d.m.Y', $ts);
}
function render_md(string $src): string {
$lines = explode("\n", $src);
$html = '';
$inCode = false;
$inList = false;
$inline = function(string $line) : string {
$line = preg_replace('/`([^`]+)`/', '$1', $line);
$line = preg_replace('/!\[([^\]]*)\]\(([^)]+)\)/', '', $line);
$line = preg_replace('/\[([^\]]+)\]\(([^)]+)\)/', '$1', $line);
$line = preg_replace('/\*\*(.+?)\*\*/', '$1', $line);
$line = preg_replace('/\*(.+?)\*/', '$1', $line);
return $line;
};
foreach ($lines as $line) {
if (preg_match('/^```/', $line)) {
if ($inCode) {
$html .= '';
$inCode = false;
} else {
if ($inList) { $html .= ''; $inList = false; }
$html .= '
';
$inCode = true;
}
continue;
}
if ($inCode) {
$html .= htmlspecialchars($line) . "\n";
continue;
}
$trimmed = rtrim($line);
if ($trimmed === '') {
if ($inList) { $html .= ''; $inList = false; }
$html .= "\n";
continue;
}
if (preg_match('/^---+$/', $trimmed)) {
if ($inList) { $html .= ''; $inList = false; }
$html .= '
';
continue;
}
if (preg_match('/^(#{1,6})\s+(.*)$/', $trimmed, $m)) {
if ($inList) { $html .= ''; $inList = false; }
$lvl = strlen($m[1]);
$tag = 'h' . min($lvl + 1, 6);
$html .= '<' . $tag . ' style="font-size:14px;font-weight:normal;text-transform:lowercase;margin:1.8em 0 0.6em 0;color:#fff">'
. $inline($m[2])
. '' . $tag . '>';
continue;
}
if (preg_match('/^[\-\*]\s+(.*)$/', $trimmed, $m)) {
if (!$inList) { $html .= ''; $inList = true; }
$html .= '- ' . $inline($m[1]) . '
';
continue;
}
if ($inList) { $html .= '
'; $inList = false; }
$html .= '' . $inline($trimmed) . '
';
}
if ($inCode) $html .= '';
if ($inList) $html .= '';
return $html;
}
?>
__ __ ______ _________
/ / / /___ / _/ |/ / ____/
/ / / / __ \ / // /|_/ / / __
/ /_/ / / / // // / / / /_/ /
\____/_/ /_/___/_/ /_/\____/
file not found: ' . htmlspecialchars($path) . '';
} else {
$name = basename($real);
$dir = dirname($path);
$parent = ($dir === '.' || $dir === '') ? '' : $dir;
$isMd = preg_match('/\.md$/i', $name);
$isXz = preg_match('/\.xz$/i', $name);
if ($isXz) {
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $name . '"');
header('Content-Length: ' . filesize($real));
readfile($real);
exit;
}
$parts = array_filter(explode('/', $path));
echo ''; echo '← back'; echo ' | ↓ download ' . htmlspecialchars($name) . ''; echo '
'; $content = file_get_contents($real); if ($isMd) { echo '' . htmlspecialchars($content) . '
' . fmt_size(filesize($real)) . '
'; } } else { echo ''; $target = $path === '' ? $SOURCE_DIR : $full; if (!is_dir($target)) { echo 'directory not found.
'; } else { echo 'the source directory is empty.
'; } else { echo '| name | '; echo 'size | '; echo 'modified | '; echo '||||
| 📁 .. | '; echo '— | '; echo '— | '; echo '||||
| '; echo '📁 ' . htmlspecialchars($e['name']) . '/'; echo ' | '; echo '— | '; } elseif ($isXzFile) { echo ''; echo '📄 ' . htmlspecialchars($e['name']) . ''; echo ' | '; echo '' . fmt_size($e['size']) . ' | '; } else { echo ''; echo '📄 ' . htmlspecialchars($e['name']) . ''; echo ' | '; echo '' . fmt_size($e['size']) . ' | '; } echo '' . fmt_date($e['mod']) . ' | '; echo '
'; echo $dc . ' ' . ($dc === 1 ? 'directory' : 'directories') . ', '; echo $fc . ' ' . ($fc === 1 ? 'file' : 'files'); echo '
'; } } } ?>© 2026 vextoly ยท source