diff options
Diffstat (limited to 'static')
| -rw-r--r-- | static/includes/settings.inc.php | 11 | ||||
| -rw-r--r-- | static/upload.php | 11 |
2 files changed, 21 insertions, 1 deletions
diff --git a/static/includes/settings.inc.php b/static/includes/settings.inc.php index 41f7679..3155a60 100644 --- a/static/includes/settings.inc.php +++ b/static/includes/settings.inc.php @@ -17,4 +17,15 @@ define('POMF_DB_PASS', '***'); define('POMF_FILES_ROOT', '/mnt/disk1/pomf/files/'); // How many times to retry when exists() before giving up define('POMF_FILES_RETRIES', 30); + +/** + * Double-dot extensions + */ +$doubledots = array_map('strrev', array( + 'tar.gz', + 'tar.bz', + 'tar.bz2', + 'tar.xz' +)); + ?> diff --git a/static/upload.php b/static/upload.php index 3da7174..5fd553e 100644 --- a/static/upload.php +++ b/static/upload.php @@ -10,11 +10,20 @@ include_once 'includes/database.inc.php'; * @return string */ function generate_name ($file) { + global $doubledots; // We start at N retries, and --N until we give up $tries = POMF_FILES_RETRIES; // We rip out the extension using pathinfo - // TODO: figure out a solution for .tar.gz and similar files? This has now been ghetto fixed, read below! $ext = pathinfo($file->name, PATHINFO_EXTENSION); + + // And if we realize it's actually a doubledot + // we just override $ext + $revname = strrev($file->name); + foreach ($doubledots as $ddot) { + if (stripos($revname, $ddot) === 0) { + $ext = strrev($ddot); + } + } do { // If we run out of tries, throw an exception. Should be caught and JSONified. if ($tries-- == 0) throw new Exception('Gave up trying to find an unused name'); |
