MINI MINI MANI MO

Path : /home/lhcar/www/mobile/_config/_class/
File Upload :
Current File : /home/lhcar/www/mobile/_config/_class/fileFun.class.php

<?php

class fileFun {
	var $path;

	function fileFun($path) {
		$this->path = $_SERVER['DOCUMENT_ROOT'].'/'.$path.'/';
	}

	//´Ù¿î·Îµå ¸Þ¼Òµå * $fileÀº ¹Ýµå½Ã ¹è¿­À̾î¾ß ÇÑ´Ù
	function download($fileList) {
		if(!is_array($fileList))$this->alert('µ¥ÀÌÅÍ´Â ¹Ýµå½Ã ¹è¿­ÇüÅÂÀ̾î¾ß ÇÕ´Ï´Ù');
		
		$getfile = $this->path.$fileList['file'];
		if(!file_exists($getfile))$this->alert('ÆÄÀÏÀÌ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù');
		else if(!is_readable($getfile))$this->alert('ÆÄÀÏÀÇ Àбâ±ÇÇÑÀÌ ¾ø½À´Ï´Ù');
		else { 
			$file_size = filesize($getfile);
			$fp = fopen($getfile,"r");
			$contents = fread($fp,$file_size);
			fclose($fp);
		
			$filename = str_replace(";", "%3B",$this->basename_fix($fileList['name']));
			$mtime = time();
			
			header('Last-Modified: '.date('r', $mtime));
			header("Content-Type: application/octet-stream\r\n");
			header("Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n");
			header("Content-Length: ".$file_size."\r\n");
			header("Content-Transfer-Encoding: binary\r\n");
			echo $contents;
		}
	}	

	function alert($msg="",$url="") {
		if(!$msg)$msg = 'À߸øµÈ Á¢±ÙÀÔ´Ï´Ù';
		
		echo "<script>";
		echo "alert('".$msg."');";
		if($url)echo "location.replace('".$url."');";
		else echo "history.go(-1);";
		echo "</script>";
	return exit;
	}

	function basename_fix($filename) {
		return preg_replace('/^.+[\\\\\\/]/', '', $filename);
	}
}
?>

OHA YOOOO