summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornokonoko <neku@pomf.se>2013-12-13 20:54:23 +0100
committernokonoko <neku@pomf.se>2013-12-13 20:54:23 +0100
commitff886b935c743be8e5e56bf953c72a0e4c15a418 (patch)
tree8579b4b46bb7fe82141211018b715b3e2c7f9f6e
parent7691fd868aba7e6e47b9e91359a661a4f0cb0e02 (diff)
ghetto fix for uploading files without extension
-rw-r--r--static/upload.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/static/upload.php b/static/upload.php
index 852c5ed..41a1ec4 100644
--- a/static/upload.php
+++ b/static/upload.php
@@ -14,7 +14,7 @@ function generate_name ($file) {
// 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?
+ // TODO: figure out a solution for .tar.gz and similar files? This has now been ghetto fixed!
$ext = pathinfo($file->name, PATHINFO_EXTENSION);
// Take the first 3 chars of the CRC32 checksum
$hashchunk = substr($file->get_crc32(), 0, 3);
@@ -27,7 +27,13 @@ function generate_name ($file) {
$newname .= chr(mt_rand(ord("a"), ord("z"))); // + random lowercase letter
$newname .= $hashchunk; // + first 3 of crc32b checksum
$newname .= chr(mt_rand(ord("a"), ord("z"))); // + random lowercase letter
- $newname .= '.' . $ext; // + '.' + extension
+ $ass = pathinfo($file->name, PATHINFO_FILENAME);
+ $pos = strpos($ass, '.');
+ if ($pos == false) {
+ // Nothing
+ }else{
+ $newname .= '.' . $ext;
+ }
} while (file_exists(POMF_FILES_ROOT . $newname)); // TODO: check the database instead?