]>
jfr.im git - uguu.git/blob - includes/core.php
29cfdb0c0d8566cca029cfa4fb5afe2a51b00365
2 function save_file ($file, $name, $arg){
4 $path='/home/neku/www/files/';
5 $block = array('exe', 'scr', 'rar', 'zip', 'com', 'vbs', 'bat', 'cmd', 'html', 'htm', 'msi');
6 //Generate name depending on arg
9 $ext = pathinfo($file.$name, PATHINFO_EXTENSION
);
10 $ext = strtolower($ext);
11 if(in_array($ext, $block)){
12 include_once('error_meow.php');
14 $file_name = gen_name('random', $ext);
15 while(file_exists($path.$file_name)){
16 $file_name = gen_name('random', $ext);
19 case 'custom_original':
20 $name = stripslashes(str_replace('/', '', $name));
21 $name = strip_tags(preg_replace('/\s+/', '', $name));
22 $file_name = gen_name('custom_original', $name);
23 $ext = pathinfo($file_name, PATHINFO_EXTENSION
);
24 $ext = strtolower($ext);
25 if(in_array($ext, $block)){
26 include_once('error_meow.php');
28 while(file_exists($path.$file_name)){
29 $file_name = gen_name('custom_original', $name);
33 //Move the file to the above location with said filename
34 move_uploaded_file($file,$path.$file_name);
35 //Return url+filename to the user
36 echo 'http://a.uguu.se/'.urlencode($file_name);
38 function gen_name($arg, $in){
39 $chars = 'abcdefghijklmnopqrstuvwxyz';
41 for ($i = 0; $i < 6; $i++
) {
42 $name .= $chars[mt_rand(0, 25)];
48 case 'custom_original':