file.php 5.8 KB
<?php
/**
 * @file	file.php
 * @category freeSN
 * @mailto	code [at] netz.coop
 * @version 0.4.200901
 * @link http://netz.coop
 * 
 *  @copyright Copyright by netz.coop e.G. 2015
 *  
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
require_once("include/config.php");
require_once("include/System/php/RequireClass.inc.php");


class FileDownload{ //extends MultimediaText

	public function fileDown(){
		$var_basedir_main = 'files/';
		$userfile = $_GET['p']['0'];
		$var_basedir = $var_basedir_main. $userfile;

		/** Array includes Content Types/Subtypes  **/
		$contenttypearray = array(
									'.avi' => 'video/x-msvideo',
									'.class'=> 'application/octet-stream',
									'.css' => 'text/css',
									'.doc' => 'application/msword',
									'.eps' => 'application/postscript',
									'.exe' => 'application/octet-stream',
									'.gif' => 'image/gif',
									'.gtar' => 'application/x-gtar',
									'.gz' => 'application/x-gzip',
									'.htm' => 'text/html',
									'.html' => 'text/html',
									'.jpe' => 'image/jpeg',
									'.jpeg' => 'image/jpeg',
									'.jpg'=> 'image/jpg',
		 							'.JPG'=> 'image/jpg',
									'.js' => 'application/x-javascript',
									'.midi' => 'audio/midi',
									'.mov' => 'video/quicktime',
									'.movie' => 'video/x-sgi-movie',
									'.mp2' => 'audio/mpeg',
									'.mp3' => 'audio/mpeg',
									'.mpe' => 'video/mpeg',
									'.mpeg' => 'video/mpeg',
									'.mpg' => 'video/mpeg',
									'.mpga' => 'audio/mpeg',
									'.ogg' => 'application/ogg',
									'.ogm' => 'application/ogm',
									'.odt' =>'application/vnd.oasis.opendocument.text',
									'.ott'=>'application/vnd.oasis.opendocument.text-template',
									'.oth'=>'application/vnd.oasis.opendocument.text-web',
									'.odm'=>'application/vnd.oasis.opendocument.text-master',
									'.odg'=>'application/vnd.oasis.opendocument.graphics',
									'.otg'=>'application/vnd.oasis.opendocument.graphics-template',
									'.odp'=>'application/vnd.oasis.opendocument.presentation',
									'.otp'=>'application/vnd.oasis.opendocument.presentation-template',
									'.ods'=>'application/vnd.oasis.opendocument.spreadsheet',
									'.ots'=>'application/vnd.oasis.opendocument.spreadsheet-template',
									'.odc'=>'application/vnd.oasis.opendocument.chart',
									'.odf'=>'application/vnd.oasis.opendocument.formula',
									'.odb'=>'application/vnd.oasis.opendocument.database',
									'.odi'=>'application/vnd.oasis.opendocument.image',
									'.oxt'=>'application/vnd.openofficeorg.extension',
									'.pbm' => 'image/x-portable-bitmap',
									'.pdf' => 'application/pdf',
									'.png' => 'image/png',
									'.pps' => 'application/mspowerpoint',
									'.ppt' => 'application/mspowerpoint',
									'.ppz' => 'application/mspowerpoint',
									'.ps' => 'application/postscript',
									'.qt' => 'video/quicktime',
									'.ra' => 'audio/x-realaudio',
									'.ram' => 'audio/x-pn-realaudio',
									'.rm' => 'audio/x-pn-realaudio',
									'.rpm' => 'audio/x-pn-realaudio-plugin',
									'.rtf' => 'text/rtf',
									'.rtx' => 'text/richtext',
									'.sgm' => 'text/sgml',
									'.sgml' => 'text/sgml',
									'.sxw'=>'application/vnd.sun.xml.writer',
									'.stw'=>'application/vnd.sun.xml.writer.template',
									'.sxc'=>'application/vnd.sun.xml.calc',
									'.stc'=>'application/vnd.sun.xml.calc.template',
									'.sxd'=>'application/vnd.sun.xml.draw',
									'.std'=>'application/vnd.sun.xml.draw.template',
									'.sxi'=>'application/vnd.sun.xml.impress',
									'.sti'=>'application/vnd.sun.xml.impress.template',
									'.sxg'=>'application/vnd.sun.xml.writer.global',
									'.sxm'=>'application/vnd.sun.xml.math',
									'.tar' => 'application/x-tar',
									'.tcl' => 'application/x-tcl',
									'.tif' => 'image/tiff',
									'.tiff' => 'image/tiff',
									'.txt' => 'text/plain',
									'.vrml' => 'model/vrml',
									'.wav' => 'audio/x-wav',
									'.wma' => 'audio/x-ms-wax',
									'.wmv' => 'video/x-ms-wvx',
									'.m3u' => 'audio/x-mpegurl',
									'.wrl' => 'model/vrml',
									'.xbm' => 'image/x-xbitmap',
									'.xlc' => 'application/vnd.ms-excel',
									'.xll' => 'application/vnd.ms-excel',
									'.xlm' => 'application/vnd.ms-exce',
									'.xls' => 'application/vnd.ms-excel',
									'.xlw' => 'application/vnd.ms-excel',
									'.xml' => 'text/xml',
									'.zip' => 'application/zip',
		);
		/** get the filename **/
		$var_posfile = strrpos($var_basedir,'/');
		$var_file   = substr($var_basedir, $var_posfile+1);
		$var_pos = strrpos($var_basedir,'.');
		$var_end   = substr($var_basedir, $var_pos);

		//		$var_contenttype = $contenttypearray[$var_end];
		$var_contenttype = FileBE::$FileTypeArray[$var_end];
		$var_type = explode('/',$var_contenttype);
		//		if($var_type['0'] != 'audio' && $var_type['0'] != 'image'){
		header("Content-Type: ". $var_contenttype);
		header("Content-Disposition: attachment; filename=\"$var_file\"");
		readfile($var_basedir);
		//		}
		//		if($var_type['0'] = 'image'){
		//			echo "<img src=$var_basedir>";
		//
		//		}


	}
}
$var_id= $_SESSION['ID'];
$filevar = new FileDownload();
$filevar->fileDown();
//echo '##################' .$_GET['p']['0'];


?>