<?php
	
	if(!$dprotect) die ('Access Denied!');
        
        if(is_uploaded_file($_FILES['file']['tmp_name'])) {
            
            $ext = $core->extension($_FILES['file']['name']);
            if(($ext == 'jpg' || $ext == 'jpeg' || $ext == 'png' || $ext == 'gif') && $_FILES["file"]["size"] <= $config['maximgsize']*1024000) {
                            
                $filename = 'red_'.date("d_m_Y_H_i_s").substr(md5(time()+rand(0, 5000)), 0, 8).'.'.$ext;
                $core->convertUploadedImage($_FILES['file']);
                move_uploaded_file($_FILES['file']['tmp_name'], $config['imagedir'].'/'.$filename);
                $core->createThumbnail($config['imagedir'].'/'.$filename, $config['thumbdir'].'/'.$filename);
                $core->addImage(5, $filename);
                $array = array(
                        'filelink' => $config['url'].$config['imagedir'].'/'.$filename
                );                
            
            } else {
                
                $array = array(
                        'filelink' => $config['url'].'images/admin/imgerr.png'
                );                
                
            }
            echo stripslashes(json_encode($array));
            
        }        
	
	exit();
	
?>