From ebda5ef7cb6f2793bcca8c861f40364639ed43a1 Mon Sep 17 00:00:00 2001 From: max/sooulix Date: Tue, 11 Feb 2025 10:15:43 +0100 Subject: [PATCH] error codes sur page read --- src/common.php | 8 +++++++- src/read.php | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/common.php b/src/common.php index 0bf8a7a..ac9ea9f 100644 --- a/src/common.php +++ b/src/common.php @@ -84,7 +84,6 @@ function share_list($dir) { $tsv = tsv_path($child); - var_dump(is_file($tsv)); if (is_file($tsv)) { return array_merge($carry, read_tsv($child, $tsv)); @@ -206,9 +205,16 @@ function find_share($dir, $creation) return NULL; } +function error_code($int) +{ + header("Location: /", TRUE, $int); + exit(); +} + function _($var) { print($var); } + ?> diff --git a/src/read.php b/src/read.php index b7ea4c3..030f548 100644 --- a/src/read.php +++ b/src/read.php @@ -9,8 +9,17 @@ if (isset($_GET['id'])) { if (gen_identifier($share) == $_GET['id']) { + $expires_date = DateTime::createFromFormat( + DateTimeInterface::ISO8601, + $share['expires'] + ); + if ($expires_date < (new DateTime())) + { + error_code(410); + } zip_response($share['dir']); } } } +error_code(403); ?>