]>
jfr.im git - uguu.git/blob - includes/core.php
320c21c0f9eb11fe325375ddb83baeb191538a72
2 function save_file ($file, $name, $arg, $type){
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)){
13 include_once('error_meow.php');
16 exit('File type not allowed.');
19 $file_name = gen_name('random', $ext);
20 while(file_exists($path.$file_name)){
21 $file_name = gen_name('random', $ext);
24 case 'custom_original':
25 $name = stripslashes(str_replace('/', '', $name));
26 $name = strip_tags(preg_replace('/\s+/', '', $name));
27 $file_name = gen_name('custom_original', $name);
28 $ext = pathinfo($file_name, PATHINFO_EXTENSION
);
29 $ext = strtolower($ext);
30 if(in_array($ext, $block)){
32 include_once('error_meow.php');
35 exit('File type not allowed.');
38 while(file_exists($path.$file_name)){
39 $file_name = gen_name('custom_original', $name);
43 //Move the file to the above location with said filename
44 move_uploaded_file($file,$path.$file_name);
45 //Check if html or plain text should be returned
47 //Return url+filename to the user (plain text)
48 echo 'http://a.uguu.se/'.urlencode($file_name);
50 }elseif($type==='normal'){
51 //Return url+filename to the user (HTML)
52 $n=urlencode($file_name);
53 include_once('/home/neku/www/page/public/upload-done.php');
57 function gen_name($arg, $in){
58 $chars = 'abcdefghijklmnopqrstuvwxyz';
60 for ($i = 0; $i < 6; $i++
) {
61 $name .= $chars[mt_rand(0, 25)];
67 case 'custom_original':