summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeku <neku@pomf.se>2013-12-15 00:12:44 +0100
committerNeku <neku@pomf.se>2013-12-15 00:12:44 +0100
commit6b6f5916b55aec25314a1eef1b1b0c50ca8965b5 (patch)
tree315cba9dfde30c3d980c41dec943cd73ba3679e5
parent67715182996c76f8379746d7c6ebcc42b10c76d7 (diff)
other name generate algo
-rw-r--r--static/upload.php10
1 files changed, 5 insertions, 5 deletions
diff --git a/static/upload.php b/static/upload.php
index 730e612..65fde41 100644
--- a/static/upload.php
+++ b/static/upload.php
@@ -16,17 +16,17 @@ function generate_name ($file) {
// 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);
- // Take the first 3 chars of the CRC32 checksum
- $hashchunk = substr($file->get_crc32(), 0, 3);
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');
// TODO: come up with a better name generating algorithm
$newname = ''; // Filename Generator:
- $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 .= chr(mt_rand(ord("z"), ord("a"))); // + random lowercase letter
+ $newname .= chr(mt_rand(ord("a"), ord("z"))); // + random lowercase letter
+ $newname .= chr(mt_rand(ord("z"), ord("a"))); // + random lowercase letter
+ $newname .= chr(mt_rand(ord("a"), ord("z"))); // + random lowercase letter
+ $newname .= chr(mt_rand(ord("z"), ord("a"))); // + random lowercase letter
// To add a dot or not after a file which has no extension
if ($ext != '') $newname .= '.' . $ext;