From 68109155b35e20251457031be7603ae94f9386d8 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 23 Apr 2015 05:06:34 +0200 Subject: [PATCH] append a random number, if a file already exists on a board --- post.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/post.php b/post.php index 5a583b88..d2f86d11 100644 --- a/post.php +++ b/post.php @@ -549,6 +549,12 @@ elseif (isset($_POST['post'])) { $file['file_id'] .= "-$i"; $file['file'] = $config['dir']['img_root'] . $board['dir'] . $config['dir']['img'] . $file['file_id'] . '.' . $file['extension']; + + while (file_exists ($file['file'])) { + $file['file_id'] .= rand(0,9); + $file['file'] = $config['dir']['img_root'] . $board['dir'] . $config['dir']['img'] . $file['file_id'] . '.' . $file['extension']; + } + $file['thumb'] = $config['dir']['img_root'] . $board['dir'] . $config['dir']['thumb'] . $file['file_id'] . '.' . ($config['thumb_ext'] ? $config['thumb_ext'] : $file['extension']); $post['files'][] = $file; $i++;