Location: PHPKode > projects > Netautor Professional > netautor/napro4/wrapper/media.php
<?php
/* +----------------------------------------------------------------------+
   | Netautor Professional Application Server                             |
   +----------------------------------------------------------------------+
   | Copyright (C) 1998-2005 digiconcept GmbH. <www.digiconcept.net>      |
   +----------------------------------------------------------------------+
   | This file is subject to license, that is bundled with this package   |
   | in the file LICENSE.TXT, and is available at through the             |
   | world-wide-web at http://www.netautor.com/license/                   |
   |                                                                      |
   | If you did not receive a copy of the license and are unable to       |
   | obtain it through the world-wide-web, please send a note to          |
   | hide@address.com so we can mail you a copy.                      |
   +----------------------------------------------------------------------+
   | Authors: Stefan Rottensteiner <hide@address.com>    |
   |          Marek  Kadziela      <hide@address.com>	      |
   |          Gregor Wollner                                              |
   |          Christian Unger                                             |
   |          Helli  Kleinhans  									      |
   +----------------------------------------------------------------------+*/

/**
 * Netautor MediaWrapper
 * @version $Revision: 1.21 $
 * @author	Helmut Kleinhans
 * @author	Stefan Rottensteiner
*/

	error_reporting(0);
	@ob_end_clean();

	if(strpos($filename,'='))
	{
		//	---	read configuration 4 pool
		require_once('../../config/pool.conf');

		if(empty($pool))
		{
			@Header('Content-Type: text/plain');
			die('Error: No MultiMedia-Pool definition detected!');
		}

		list( $name, $path ) = explode('=',$filename,2);
//		$name=substr($filename,0,strpos($filename,'='));
//		$path=substr($filename,strpos($filename,'=')+1);

		if(!isset($pool[$name]) || empty($pool[$name]))
		{
			@Header('Content-Type: text/plain');
			die("Error: Pool '".$name."' not defined in pool.conf!");
		}
		$filename=$pool[$name].$path;
	}

	if(!is_file($filename))
	{
		@Header('Content-Type: text/plain');
		die('Error: File not found');
	}

	/* Check 4 bad file extensions. Immediat silent exit if file seems to not be a standard file to download */
	$fileextension	= trim(strtolower(substr($filename,1+(strrpos($filename,'.')))));
	$exclude		= array(	'php'	=>true,'php3'	=>true,'php4'	=>true,'phtml'	=>true,
								'conf'	=>true,'cfg'	=>true,'ini'	=>true,'init'	=>true,
								'bat'	=>true,'exe'	=>true,'sh'		=>true,'dll'	=>true,
								'asp'	=>true,'dat'	=>true,'fnc'	=>true,'inc'	=>true,
								'conf'	=>true,'c'		=>true,'d'		=>true);
	if (empty($fileextension) || isset($exclude[$fileextension]) || !strrpos($filename,'.')) 
	{
		@Header('Content-Type: text/plain');
		die('Error: File disallowed');
	}

	require_once('../include/functions/filetype.fnc');
	$info=array();
	ext2mime($filename,$info);

	if(!strpos($info['mimetype'],'/'))
	{
		@Header('Content-Type: text/plain');
		die('Error: Unknown filetype!');
	}
	else
	{
		$mimetype = $info['mimetype'];
	}

	if ( !empty($url) && !empty($_SERVER['HTTP_REFERER']))
	{
		require_once('../include/functions/web.fnc');
		require_once('../include/functions/string.fnc');

		$url_dummy			= explode('&',$url);
		$url_dummy_count 	= count($url_dummy);
		for($i=0;$i<$url_dummy_count;$i++)
		{
				$dummy2[$i]=chopright('=',$url_dummy[$i]).'='.urlencode(chopleft('=',$url_dummy[$i]));
		}
		$url			= implode('&',$dummy2);
		$Proxy			= '';
		$run_script 	= 'HTTP://'.$GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST'].chopright('wrapper/media.php',$_SERVER['PHP_SELF']).'appl/na_professional/parse.php?'.$url;

		$Connection 	= new URL($run_script,$Proxy,true);
		if ($Connection->connect())
		{
			// Quelle auslesen und den Text ausgeben
			$ForeignContent	= $Connection->readContent();
			$Connection->disconnect();
			if ($ForeignContent)
			{
				unset($ForeignContent);
			}
			unset($Connection);
		}
	}

	$filesize 		= filesize($filename);

	if ( !empty($rn) )
	{
		$user_agent = strtolower ($_SERVER['HTTP_USER_AGENT']);
		$isIE		= ( strpos($user_agent, 'msie') !== false && strpos($user_agent, 'windows') !== false );
		$isIE6		= ( strpos($user_agent, 'msie 6') !== false);
		$isIE5		= ( strpos($user_agent, 'msie 5') !== false);
		$isNetscape = ( strpos($user_agent, 'netscape') !== false); 

		//  A so-called HOT-FIX for the broken IE 5 and the very old Netscape
		if ( $isIE5 || $isNetscape )
		{
			Header('Pragma: cache');
			Header('Cache-Control: store');

			Header('Content-Type: application/octet-stream');
			Header('Content-Disposition: filename="'.basename($rn).'"; size="'.$filesize.'"');
		}
		else
		{

			Header('Pragma: public');
			Header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 

			Header('Content-Type: '.$mimetype);
			Header('Content-Disposition: attachment; filename="'.basename($rn).'"; size="'.$filesize.'"');
		}

	}
	else
	{
		Header( 'Content-Type: '.$mimetype);
		Header( 'Content-Disposition: inline; filename="'.basename($filename).'"; size="'.$filesize.'"');
	}

	Header('Expires: 0');
	Header('Content-Length: '.$filesize);
	readfile($filename);
	die();
?>
Return current item: Netautor Professional