mirror of
https://github.com/nokonoko/Uguu.git
synced 2024-01-06 13:35:15 +00:00
Update core.php
This commit is contained in:
parent
64abd972f3
commit
8c8107343a
18
core.php
18
core.php
@ -1,16 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
function save_file ($file, $name){
|
function save_file ($file, $name){
|
||||||
//Generate a random set of numbers to set in front of the filename
|
//Generate a random prefix, strip tags and remove any whitespace
|
||||||
$rand_string = crc32(microtime(true).mt_rand(1000, 9000));
|
$file_name = gen_name(strip_tags(preg_replace('/\s+/', '', $name)));
|
||||||
//Where to save
|
//Where to save
|
||||||
$path='/home/neku/www/files/';
|
$path='/home/neku/www/files/';
|
||||||
//Remove any tags
|
|
||||||
$file_data=strip_tags($file);
|
|
||||||
//Put together the random string+filename
|
|
||||||
$file_name=$rand_string.'_'.$name;
|
|
||||||
//Move the file to the above location with said filename
|
//Move the file to the above location with said filename
|
||||||
move_uploaded_file($file_data,$path.$file_name);
|
move_uploaded_file($file,$path.$file_name);
|
||||||
//Return url+filename to the user
|
//Return url+filename to the user
|
||||||
echo 'http://a.uguu.se/'.$file_name;
|
echo 'http://a.uguu.se/'.$file_name;
|
||||||
}
|
}
|
||||||
|
Function gen_name ($in){
|
||||||
|
$chars = 'abcdefghijklmnopqrstuvwxyz';
|
||||||
|
$name = '';
|
||||||
|
for ($i = 0; $i < 6; $i++) {
|
||||||
|
$name .= $chars[mt_rand(0, 25)];
|
||||||
|
}
|
||||||
|
return $name.'_'.$in;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user