From eb1225a6b6d5bc9a03ee7774d197eff4558a671f Mon Sep 17 00:00:00 2001 From: RealAngeleno Date: Mon, 10 Jul 2023 02:46:28 -0700 Subject: [PATCH] prohibit original filename from showing up in api when disabled Makes it so that if $config['show_filename'] = false, it will show $apiPost['tim'] as the filename instead. --- inc/api.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/inc/api.php b/inc/api.php index 43464887..d6f3f740 100644 --- a/inc/api.php +++ b/inc/api.php @@ -92,7 +92,6 @@ class Api { global $config; $this->translateFields($this->fileFields, $file, $apiPost); - $apiPost['filename'] = @substr($file->name, 0, strrpos($file->name, '.')); $dotPos = strrpos($file->file, '.'); $apiPost['ext'] = substr($file->file, $dotPos); $apiPost['tim'] = substr($file->file, 0, $dotPos); @@ -102,6 +101,12 @@ class Api { if(isset($file->thumb) && $file->thumb == 'spoiler') $apiPost['spoiler'] = 1; + if (isset($this->config['show_filename']) && $this->config['show_filename']) { + $apiPost['filename'] = @substr($file->name, 0, strrpos($file->name, '.')); + } + else { + $apiPost['filename'] = substr($file->file, 0, $dotPos); + } if (isset ($file->hash) && $file->hash) { $apiPost['md5'] = base64_encode(hex2bin($file->hash)); }