diff --git a/utils/features.php b/utils/features.php deleted file mode 100644 index 1880ef1..0000000 --- a/utils/features.php +++ /dev/null @@ -1,30 +0,0 @@ - "success", - "data" => $data - ]; -} -function res_err(string|null $message = null) :object { - return (object) [ - "type" => "error", - "message" => $message - ]; -} \ No newline at end of file diff --git a/utils/url_handler.php b/utils/url_handler.php index 45662f3..410078a 100644 --- a/utils/url_handler.php +++ b/utils/url_handler.php @@ -1,13 +1,8 @@ get_body_text()); - } public function get_html_file(string $file_path): string { if (!file_exists($file_path)) { @@ -48,7 +40,6 @@ class TurtleURLObject { return file_get_contents($file_path); } } - public function send_text(string $text) :void { header('Content-Type: text/plain'); echo $text; @@ -95,20 +86,6 @@ class TurtleURLObject { return true; } - public function send_download_file(string $path) :bool { - if (!file_exists($path)) return false; - header('Content-Description: File Transfer'); - header('Content-Type: application/octet-stream'); - header('Content-Disposition: attachment; filename="'.basename($path).'"'); - header('Expires: 0'); - header('Cache-Control: must-revalidate'); - header('Pragma: public'); - header('Content-Length: ' . filesize($path)); - - readfile($path); - return true; - } - public function is_image_request() :bool { foreach ($this->method_type as $type) { if (!str_starts_with($type, "image/")) return false; @@ -164,4 +141,16 @@ function _parseUrlMark($urlParts) :object { } } return $res; +} +function isFileExtImage(string $fileExt) :bool { + switch ($fileExt) { + case 'png': + case 'jpg': + case 'jpeg': + case 'ico': + case 'gif': + return true; + default: + return false; + } } \ No newline at end of file