From 82ae4c6587c81211fe384c4b8bc607026dd018a7 Mon Sep 17 00:00:00 2001 From: WubTheCaptain Date: Wed, 16 Sep 2015 00:28:14 +1000 Subject: Rework generate_name() logic Adds a new config option POMF_FILES_LENGTH. This will allow the user to adjust the length of filenames. Defaults to 6. The filename generator never used character z in new filenames. There are 27 characters in a-z, but the old code uses a magic number of 26 characters. This bug was introduced in commit 5b77a4eaab418836820b2a0bad7c88f0b88136a0. Instead of relying on magic numbers like with mt_rand(), conveniently use arrays with array_rand() instead. More characters can be added with array_merge() in future if desired. --- static/includes/settings.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'static/includes/settings.inc.php') diff --git a/static/includes/settings.inc.php b/static/includes/settings.inc.php index e909b9a..9751cff 100644 --- a/static/includes/settings.inc.php +++ b/static/includes/settings.inc.php @@ -9,8 +9,10 @@ define('POMF_DB_PASS', '***'); // Root location of files define('POMF_FILES_ROOT', '/mnt/pantsu/http/files/'); -// Maximum number of iterations while generating a new name +// Maximum number of iterations while generating a new filename define('POMF_FILES_RETRIES', 15); +// Number of random characters to use in a new filename +define('POMF_FILES_LENGTH', 6); // URL to prepend to output (include trailing slash) define('POMF_URL', 'https://i.pantsu.cat/'); -- cgit v1.2.3