From f1c8246ab7720da28b744fdefa9f063885990c8e Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sat, 8 Apr 2023 13:28:25 +0700 Subject: [PATCH] Attachment system bugfix (#141) --- ajax.php | 6 +----- library/attach_mod/includes/functions_attach.php | 8 +++++--- library/attach_mod/posting_attachments.php | 2 +- viewtopic.php | 5 +++-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ajax.php b/ajax.php index 5e4a9da5..2ad4fb2a 100644 --- a/ajax.php +++ b/ajax.php @@ -29,12 +29,8 @@ switch ($ajax->action) case 'view_torrent': case 'mod_action': case 'change_tor_status': - case 'gen_passkey': - require(ATTACH_DIR . 'attachment_mod.php'); - require(INC_DIR . 'functions_torrent.php'); - break; - case 'change_torrent': + case 'gen_passkey': require(ATTACH_DIR . 'attachment_mod.php'); require(INC_DIR . 'functions_torrent.php'); break; diff --git a/library/attach_mod/includes/functions_attach.php b/library/attach_mod/includes/functions_attach.php index cab4f37c..497ffd54 100644 --- a/library/attach_mod/includes/functions_attach.php +++ b/library/attach_mod/includes/functions_attach.php @@ -547,9 +547,11 @@ function get_var($var_name, $default, $multibyte = false) } else { - list($key_type, $type) = each($default); - $type = gettype($type); - $key_type = gettype($key_type); + foreach ($default as $key_type => $type) + { + $key_type = gettype($key_type); + $type = gettype($type); + } } if (is_array($var)) diff --git a/library/attach_mod/posting_attachments.php b/library/attach_mod/posting_attachments.php index 368706b3..f9461874 100644 --- a/library/attach_mod/posting_attachments.php +++ b/library/attach_mod/posting_attachments.php @@ -975,7 +975,7 @@ class attach_parent $this->attach_filename = preg_replace('#([\xC2\xC3])([\x80-\xBF])#', 'chr(ord(\'$1\')<<6&0xC0|ord(\'$2\')&0x3F)', $this->attach_filename); $this->attach_filename = rawurlencode($this->attach_filename); $this->attach_filename = preg_replace("/(%[0-9A-F]{1,2})/i", '', $this->attach_filename); - $this->attach_filename = trim($this->attach_filename); + $this->attach_filename = trim($this->attach_filename . time()); } $this->attach_filename = str_replace(array('&','&',' '), '_', $this->attach_filename); $this->attach_filename = str_replace('php', '_php_', $this->attach_filename); diff --git a/viewtopic.php b/viewtopic.php index 124df448..38b9c039 100644 --- a/viewtopic.php +++ b/viewtopic.php @@ -121,6 +121,7 @@ if (!$t_data = DB()->fetch_row($sql)) $forum_topic_data =& $t_data; $topic_id = $t_data['topic_id']; $forum_id = $t_data['forum_id']; +$topic_attachment = isset($t_data['topic_attachment']) ? (int)$t_data['topic_attachment'] : null; if($t_data['allow_porno_topic'] && bf($userdata['user_opt'], 'user_opt', 'user_porn_forums')) bb_die($lang['ERROR_PORNO_FORUM']); @@ -131,7 +132,7 @@ if ($userdata['session_admin'] && !empty($_REQUEST['mod'])) $datastore->enqueue(array('viewtopic_forum_select')); } } -if ($t_data['topic_attachment']) +if ($topic_attachment) { $datastore->enqueue(array( 'attach_extensions', @@ -606,7 +607,7 @@ $template->assign_vars(array( )); require(INC_DIR .'torrent_show_dl_list.php'); -if ($t_data['topic_attachment']) +if ($topic_attachment) { require(ATTACH_DIR .'attachment_mod.php'); init_display_post_attachments($t_data['topic_attachment']);