2 //Loading configuration file
3 require_once "config.php";
5 //Saving the file on the server
6 function save_file ($file, $name, $arg, $type){
7 //Generate name depending on arg
10 $ext = pathinfo($file.$name, PATHINFO_EXTENSION
);
11 $ext = strtolower($ext);
12 if(in_array($ext, unserialize(CONFIG_BLOCKED_EXTENSIONS
))){
14 include_once(CONFIG_ROOT_PATH
.'error_meow.php');
17 exit('File type not allowed.');
20 $file_name = gen_name('random', $ext);
21 while(file_exists(CONFIG_FILES_PATH
.$file_name)){
22 $file_name = gen_name('random', $ext);
25 case 'custom_original':
26 $name = stripslashes(str_replace('/', '', $name));
27 $name = strip_tags(preg_replace('/\s+/', '', $name));
28 $file_name = gen_name('custom_original', $name);
29 $ext = pathinfo($file_name, PATHINFO_EXTENSION
);
30 $ext = strtolower($ext);
31 if(in_array($ext, unserialize(CONFIG_BLOCKED_EXTENSIONS
))){
33 include_once(CONFIG_ROOT_PATH
.'error_meow.php');
36 exit('File type not allowed.');
39 while(file_exists(CONFIG_FILES_PATH
.$file_name)){
40 $file_name = gen_name('custom_original', $name);
44 //Move the file to the above location with said filename
45 move_uploaded_file($file,CONFIG_FILES_PATH
.$file_name);
46 //Check if html or plain text should be returned
48 //Return url+filename to the user (plain text)
49 echo CONFIG_ROOT_URL
.'/files/'.urlencode($file_name);
51 }elseif($type==='normal'){
52 //Return url+filename to the user (HTML)
53 $n=urlencode($file_name);
54 include_once(CONFIG_ROOT_PATH
.'upload-done.php');
59 #Generate a random name for the uploaded file
60 function gen_name($arg, $in){
61 $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
63 for ($i = 0; $i < CONFIG_RANDOM_LENGTH
; $i++
) {
64 $name .= $chars[mt_rand(0, 60)];
70 case 'custom_original':