<?php
class Getfile extends Controller
{
	function Getfile()
	{
		parent::Controller();
	}

	function index()
	{
		redirect('');
	}
	
	function fajl(){
		//print base64_encode("downloads/hun/Hun_XP_2010.exe"),"<br>"; //ZG93bmxvYWRzL2h1bi9IdW5fWFBfMjAxMC5leGU=
		
		//print base64_encode("downloads/hun/putty.exe")."<br>";
		
		if(!$this->uri->segment(3))
		{
            redirect('');
            exit;
		}

		$file = base64_decode($this->uri->segment(3));
		//print "fajl: " . $file;
	    
	    $filename = '/home/cadline/public_html/website/public/' . $file;
	    if(file_exists($filename))
	    {
	    	header('Content-Disposition: attachment; filename="'.basename($filename).'"');
	    	header('Content-type: mime_content_type($file)');
	    	readfile($filename);
	    }
	    else
	    {
			echo 'Nincs ilyen fájl';
	    }
	}
	

	function pdf()
	{
		if(!$this->uri->segment(3))
		{
            redirect('');
            exit;
		}

		$file = base64_decode($this->uri->segment(3));
	    
	    $filename = '/home/cadline/public_html/website/public/pdf/' . $file;

		if(file_exists($filename))
	    {
            header("Pragma: public");
			header("Expires: 0");
			header("Pragma: no-cache");
			header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
			header("Content-Type: application/pdf");
			header('Content-disposition: attachment; filename=' . basename($filename));
			header("Content-Transfer-Encoding: binary");
			header('Content-Description: File Transfer');
			ob_clean();
	  		flush();
			readfile($filename);
			exit(0);
	    }
	    else
	    {
			echo 'Nincs ilyen f�jl';
	    }
	}
	
	function swf()
	{
		if(!$this->uri->segment(3))
		{
            redirect('');
            exit;
		}

		$file = base64_decode($this->uri->segment(3));

	    $filename = '/home/cadline/public_html/website/public/swf/' . $file;
	    
	    if(file_exists($filename))
	    {
			header("Pragma: public");
			header("Expires: 0");
			header("Pragma: no-cache");
			header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
			header("Content-Type: application/x-shockwave-flash");
			header('Content-disposition: attachment; filename=' . basename($filename));
			header('Content-Transfer-Encoding: binary');
			header('Content-Description: File Transfer');
			header('Content-Length: ' . filesize($filename));
			ob_clean();
	  		flush();
			readfile($filename);
			exit(0);
		}
		else
		{
			echo 'Nincs ilyen f�jl';
		}

	}
}
?>