<?php
if(!defined("BASE_DIR")) exit;
if(!perm('downloads'))
{
	no_perm();
} else {
	
	if(!@file_exists(BASE_DIR . 'class/Class.Downloads.php'))
	{
		module_not_installed('Downloads');
	} else {
	
		include_once(BASE_DIR . 'admin/class/class.downloads.php');
		$downloads = new Downloads;
		
		
		
		$_REQUEST['sub'] = (isset($_REQUEST['sub']) && !empty($_REQUEST['sub'])) ? $_REQUEST['sub'] : 'overview';
		switch($_REQUEST['sub'])
		{
			case 'delrating':
				if(!perm('del_rating'))
					no_perm();
				else
					$downloads->DelRating(@$_REQUEST['id']);
			break;
			
			case 'overview':
				$downloads->ListDownloads();
			break;
			
			case 'edit':
				if(!perm('downloads_edit'))
					no_perm();
				else
					$downloads->EditDownload(@$_REQUEST['id']);
			break;
			
			case 'new':
				if(!perm('downloads_edit'))
					no_perm();
				else
					$downloads->NewDownload();
			break;
			
			case 'copy':
				if(!perm('downloads_edit'))
					no_perm();
				else
					$downloads->CopyDownload(@$_REQUEST['id']);
			break;
			
			case 'settings':
				if(!perm('links_settings'))
					no_perm();
				else
					$downloads->Settings();
			break;
			
			case 'categs':
				if(!perm('links_categs'))
					no_perm();
				else
					$downloads->LinkCategs();
			break;
			
			case 'delcateg':
				if(!perm('links_categs'))
					no_perm();
				else
					$downloads->DelCateg(@$_REQUEST['id']);
			break;
			
			case 'editcateg':
				if(!perm('links_categs'))
					no_perm();
				else
					$downloads->EditCateg(@$_REQUEST['id']);
			break;
			
			case 'filesuggest':
				$_REQUEST['noout'] =1;
				$downloads->FileSuggest($_REQUEST['q']);
			break;
			
			case 'addcateg':
				if(!perm('links_categs'))
					no_perm();
				else
					$downloads->AddCateg();
			break;
			
			case 'fileupload':
				include_once(BASE_DIR . 'admin/class/class.fileupload.php');
				$upload = new Fileupload('/uploads/downloads_files/','hidden',@$_REQUEST['divid'],0,'',1);
			break;
			
			case 'iconupload':
				include_once(BASE_DIR . 'admin/class/class.fileupload.php');
				$upload = new Fileupload('/uploads/downloads/','hidden',@$_REQUEST['divid'],@$_REQUEST['resize']);
			break;
		}
	}
}
?>