diff options
| author | nokonoko <neku@pomf.se> | 2013-12-13 21:49:22 +0100 |
|---|---|---|
| committer | nokonoko <neku@pomf.se> | 2013-12-13 21:49:22 +0100 |
| commit | 90e047984ab37e57ea446050a05293de3f6ea88a (patch) | |
| tree | 8d3dd5ddc7b2f805e9a155b7fde195643b20528c /static | |
| parent | ff886b935c743be8e5e56bf953c72a0e4c15a418 (diff) | |
fixed dot after extenstionless file
Diffstat (limited to 'static')
| -rw-r--r-- | static/upload.php | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/static/upload.php b/static/upload.php index 41a1ec4..824ffca 100644 --- a/static/upload.php +++ b/static/upload.php @@ -27,14 +27,17 @@ 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 + + // To add a dot or not to add a dot ghetto style $ass = pathinfo($file->name, PATHINFO_FILENAME); - $pos = strpos($ass, '.'); - if ($pos == false) { + $pos = strrpos($ass, '.'); + if ($pos === false) { // Nothing }else{ $newname .= '.' . $ext; } + } while (file_exists(POMF_FILES_ROOT . $newname)); // TODO: check the database instead? return $newname; |
