0) {
$file_id = basename($_SERVER['PHP_SELF']);
} else if (isset($_SERVER['QUERY_STRING']) && !empty(trim($_SERVER['QUERY_STRING']))) {
$file_id = basename($_SERVER['QUERY_STRING']);
}
if (FILE_CATALOG_FANCY_VIEW && $file_id) {
$file_id = explode('.', $file_id);
if (count($file_id) != 2) {
http_response_code(404);
exit();
}
$file_ext = $file_id[1];
$file_id = $file_id[0];
if (!preg_match('/^[a-zA-Z0-9_-]+$/', $file_id) || !preg_match('/^[a-zA-Z0-9]+$/', $file_ext)) {
http_response_code(404);
exit();
}
$file_path = FILE_UPLOAD_DIRECTORY . "/{$file_id}.{$file_ext}";
$meta_path = FILE_METADATA_DIRECTORY . "/{$file_id}.metadata.json";
if (!file_exists($file_path)) {
http_response_code(404);
exit();
}
if (file_exists($meta_path)) {
$file = json_decode(file_get_contents($meta_path), true);
if (isset($file['views'])) {
session_start();
$viewed_file_ids = $_SESSION['viewed_file_ids'] ?? [];
if (!in_array($file['id'], $viewed_file_ids)) {
$file['views']++;
array_push($viewed_file_ids, $file['id']);
file_put_contents($meta_path, json_encode($file, JSON_UNESCAPED_SLASHES));
}
$_SESSION['viewed_file_ids'] = $viewed_file_ids;
session_commit();
}
} else {
$file = [
'id' => $file_id,
'extension' => $file_ext,
'mime' => FILE_ACCEPTED_MIME_TYPES[$file_ext],
'size' => filesize($file_path)
];
}
$file['full_url'] = FILE_UPLOAD_DIRECTORY_PREFIX . "/{$file['id']}.{$file['extension']}";
$size = $file['size'];
$size_suffix = 'B';
$size_i = 0;
do {
$size /= 1024;
$size_suffix = match ($size_i) {
0 => 'B',
1 => 'KB',
2 => 'MB',
3 => 'GB',
default => 'TB'
};
$size_i++;
} while ($size > 1024);
$file['size_formatted'] = sprintf('%.2f%s', $size, $size_suffix);
$file['name'] = $file['original_name'] ?? sprintf('%s.%s', $file['id'], $file['extension']);
if (!isset($file['uploaded_at'])) {
$file['uploaded_at'] = filemtime($file_path);
}
if (str_starts_with($file['mime'], 'image/')) {
$file['resolution'] = trim(shell_exec('identify -format "%wx%h" ' . escapeshellarg($file_path) . '[0]'));
} else if (str_starts_with($file['mime'], 'video/')) {
$info = shell_exec('ffprobe -v error -select_streams v:0 -show_entries stream=width,height,duration -of csv=p=0 ' . escapeshellarg($file_path));
[$width, $height, $duration] = explode(',', trim($info));
$file['resolution'] = sprintf('%sx%s (%s seconds)', $width, $height, round($duration, 2));
} else if (str_starts_with($file['mime'], 'audio/')) {
$file['resolution'] = round(trim(shell_exec('ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 ' . escapeshellarg($file_path))), 2) . ' seconds';
} else if (str_starts_with($file['mime'], 'text/')) {
$file['resolution'] = trim(shell_exec('wc -l < ' . escapeshellarg($file_path))) . ' lines';
}
}
?>
= $file['name'] ?> - = INSTANCE_NAME ?>
" />
= INSTANCE_NAME ?>
= $file['size_formatted'] ?>
= $file['mime'] ?> (= $file['extension'] ?>)
= $file['resolution'] ?>
Uploaded = format_timestamp(time() - $file['uploaded_at']) ?> ago
= $file['views'] ?> views
= $file['original_name'] ?>
File = sprintf('%s.%s', $file['id'], $file['extension']) ?>
= file_get_contents(FILE_UPLOAD_DIRECTORY . "/{$file['id']}.{$file['extension']}") ?>
This file cannot be displayed.
No JavaScript Mode
What is = INSTANCE_NAME ?>?
= INSTANCE_NAME ?> is a simple, free and anonymous file sharing site.
We do not store anything other than the files you upload.
They are stored publicly until the heat death of the universe occurs or you hit the DELETE
button.
Users do not need an account to start uploading.
Click the button below and share the files with your friends today!
But, read TOS and Privacy Policy
before
interacting with the
website.