<?php
	
	if(!$dprotect) die ('Access Denied!');
	
        if(is_uploaded_file($_FILES['file']['tmp_name'])) {
            
            if($_FILES["file"]["size"] <= $config['maxfilesize']*1024000) {
            
                $ext = $core->extension($_FILES['file']['name']);
                $filename = 'red_'.date("d_m_Y_H_i_s").substr(md5(time()+rand(0, 5000)), 0, 8).'.'.$ext;					
                move_uploaded_file($_FILES['file']['tmp_name'], $config['filedir'].'/'.$filename);
                $core->addFile(5, $filename, $filename);
                $array = array(
                        'filelink' => $config['url'].$config['filedir'].'/'.$filename,
                        'filename' => $filename
                );
                
            } else {
                
                $array = array(
                        'filelink' => $config['url'].'images/admin/fileerr.png',
                        'filename' => 'Error. The file is to large.'
                );
                
            }            
            echo stripslashes(json_encode($array));
            
        }
        
	exit();	
	
?>